VirtualBox

Changeset 83660 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Apr 9, 2020 6:06:53 PM (5 years ago)
Author:
vboxsync
Message:

IPRT/log-vbox.cpp: Use timestamped log files in GAs too, not just VBox.log. Unlike on the host, the files are prefixed 'VBoxGAs-' so they are easier to find and delete. Not printing any header as I'm unsure about the amount of stack space we can use when called, playing it safe for now. Also reduced the stack space used on the host side by combining the executable path buffer with szBuf. bugref:9670

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/VBox/log-vbox.cpp

    r82968 r83660  
    497497     */
    498498#ifdef IN_RING3
    499 # ifndef IN_GUEST
    500     char szExecName[RTPATH_MAX];
    501     if (!RTProcGetExecutablePath(szExecName, sizeof(szExecName)))
    502         strcpy(szExecName, "VBox");
     499    const char *pszExeName = RTProcShortName();
     500    if (!pszExeName)
     501        pszExeName = "VBox";
    503502    RTTIMESPEC TimeSpec;
    504503    RTTIME Time;
    505504    RTTimeExplode(&Time, RTTimeNow(&TimeSpec));
    506     rc = RTLogCreate(&pLogger, 0, NULL, "VBOX_LOG", RT_ELEMENTS(g_apszGroups), &g_apszGroups[0], RTLOGDEST_FILE,
     505    rc = RTLogCreate(&pLogger, 0, NULL, "VBOX_LOG", RT_ELEMENTS(g_apszGroups), &g_apszGroups[0],
     506# ifdef IN_GUEST
     507                     RTLOGDEST_USER /* backdoor */,
     508                     "./VBoxGAs-%04d-%02d-%02d-%02d-%02d-%02d.%03d-%s-%d.log",
     509# else
     510                     RTLOGDEST_FILE,
    507511                     "./%04d-%02d-%02d-%02d-%02d-%02d.%03d-%s-%d.log",
    508                      Time.i32Year, Time.u8Month, Time.u8MonthDay, Time.u8Hour, Time.u8Minute, Time.u8Second, Time.u32Nanosecond / 10000000,
    509                      RTPathFilename(szExecName), RTProcSelf());
     512# endif
     513                     Time.i32Year, Time.u8Month, Time.u8MonthDay, Time.u8Hour, Time.u8Minute, Time.u8Second,
     514                     Time.u32Nanosecond / 10000000, pszExeName, RTProcSelf());
    510515    if (RT_SUCCESS(rc))
    511516    {
     517# ifndef IN_GUEST
    512518        /*
    513519         * Write a log header.
     
    516522        RTTimeSpecToString(&TimeSpec, szBuf, sizeof(szBuf));
    517523        RTLogLoggerEx(pLogger, 0, ~0U, "Log created: %s\n", szBuf);
    518         RTLogLoggerEx(pLogger, 0, ~0U, "Executable: %s\n", szExecName);
     524        RTLogLoggerEx(pLogger, 0, ~0U, "Executable: %s\n", RTProcGetExecutablePath(szBuf, sizeof(szBuf)));
    519525
    520526        /* executable and arguments - tricky and all platform specific. */
     
    526532        char szArgFileBuf[80];
    527533        RTStrPrintf(szArgFileBuf, sizeof(szArgFileBuf), "/proc/%ld/psinfo", (long)getpid());
    528         FILE* pFile = fopen(szArgFileBuf, "rb");
     534        FILE *pFile = fopen(szArgFileBuf, "rb");
    529535        if (pFile)
    530536        {
     
    582588        /* Retrieve the required length first */
    583589        int aiName[4];
    584 if defined(RT_OS_FREEBSD)
     590 if defined(RT_OS_FREEBSD)
    585591        aiName[0] = CTL_KERN;
    586592        aiName[1] = KERN_PROC;
    587593        aiName[2] = KERN_PROC_ARGS;     /* Introduced in FreeBSD 4.0 */
    588594        aiName[3] = getpid();
    589 elif defined(RT_OS_NETBSD)
     595 elif defined(RT_OS_NETBSD)
    590596        aiName[0] = CTL_KERN;
    591597        aiName[1] = KERN_PROC_ARGS;
    592598        aiName[2] = getpid();
    593599        aiName[3] = KERN_PROC_ARGV;
    594 endif
     600 endif
    595601        size_t cchArgs = 0;
    596602        int rcBSD = sysctl(aiName, RT_ELEMENTS(aiName), NULL, &cchArgs, NULL, 0);
     
    625631#   error needs porting.
    626632#  endif
     633# endif /* IN_GUEST */
    627634    }
    628 
    629 # else  /* IN_GUEST */
    630     /* The user destination is backdoor logging. */
    631     rc = RTLogCreate(&pLogger, 0, NULL, "VBOX_LOG", RT_ELEMENTS(g_apszGroups), &g_apszGroups[0], RTLOGDEST_USER, "VBox.log");
    632 # endif /* IN_GUEST */
    633635
    634636#else /* IN_RING0 */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette