VirtualBox

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


Ignore:
Timestamp:
Sep 10, 2010 2:40:01 PM (14 years ago)
Author:
vboxsync
Message:

Runtime/r3/coredumper: addressed some todos in r65763.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/solaris/coredumper-solaris.cpp

    r32406 r32411  
    6161*   Globals                                                                    *
    6262*******************************************************************************/
    63 static RTNATIVETHREAD volatile  g_CoreDumpThread = NIL_RTNATIVETHREAD;
     63static RTNATIVETHREAD volatile  g_CoreDumpThread             = NIL_RTNATIVETHREAD;
    6464static bool volatile            g_fCoreDumpSignalSetup       = false;
    6565static bool volatile            g_fCoreDumpDeliberate        = false;
     
    541541                /* Terminate list of vectors */
    542542                pVBoxProc->cAuxVecs = cbAuxFile / sizeof(auxv_t);
    543                 CORELOG((CORELOG_NAME "ProcReadAuxVecs: cbAuxFile=%u auxv_t size %d cAuxVecs=%u\n", cbAuxFile, sizeof(auxv_t), pVBoxProc->cAuxVecs));
     543                CORELOG((CORELOG_NAME "ProcReadAuxVecs: cbAuxFile=%u auxv_t size %d cAuxVecs=%u\n", cbAuxFile, sizeof(auxv_t),
     544                         pVBoxProc->cAuxVecs));
    544545                if (pVBoxProc->cAuxVecs > 0)
    545546                {
     
    666667                                    if (RT_FAILURE(rc2))
    667668                                    {
    668                                         CORELOGRELSYS((CORELOG_NAME "ProcReadMappings: skipping mapping. vaddr=%#x rc=%Rrc\n", pCur->pMap.pr_vaddr, rc2));
     669                                        CORELOGRELSYS((CORELOG_NAME "ProcReadMappings: skipping mapping. vaddr=%#x rc=%Rrc\n",
     670                                                       pCur->pMap.pr_vaddr, rc2));
    669671
    670672                                        /*
     
    695697                        else
    696698                        {
    697                             CORELOGRELSYS((CORELOG_NAME "ProcReadMappings: GetMemoryChunk failed %u\n", pVBoxProc->cMappings * sizeof(VBOXSOLMAPINFO)));
     699                            CORELOGRELSYS((CORELOG_NAME "ProcReadMappings: GetMemoryChunk failed %u\n",
     700                                           pVBoxProc->cMappings * sizeof(VBOXSOLMAPINFO)));
    698701                            rc = VERR_NO_MEMORY;
    699702                        }
     
    873876                CORELOGRELSYS((CORELOG_NAME "ProcReadThreads: huh!? cbStatusHdrAndData=%u prheader_t=%u entsize=%u\n", cbStatusHdrAndData,
    874877                            sizeof(prheader_t), pStatusHdr->pr_entsize));
    875                 CORELOGRELSYS((CORELOG_NAME "ProcReadThreads: huh!? cbInfoHdrAndData=%u entsize=%u\n", cbInfoHdrAndData, pStatusHdr->pr_entsize));
     878                CORELOGRELSYS((CORELOG_NAME "ProcReadThreads: huh!? cbInfoHdrAndData=%u entsize=%u\n", cbInfoHdrAndData,
     879                               pStatusHdr->pr_entsize));
    876880                rc = VERR_INVALID_STATE;
    877881            }
     
    922926    if (rc < 0)
    923927    {
    924         CORELOGRELSYS((CORELOG_NAME "ProcReadMiscInfo: getzonenamebyid failed. rc=%d errno=%d zoneid=%d\n", rc, errno, pVBoxProc->ProcInfo.pr_zoneid));
     928        CORELOGRELSYS((CORELOG_NAME "ProcReadMiscInfo: getzonenamebyid failed. rc=%d errno=%d zoneid=%d\n", rc, errno,
     929                       pVBoxProc->ProcInfo.pr_zoneid));
    925930        return VERR_GENERAL_FAILURE;
    926931    }
     
    17781783     * Create the core file.
    17791784     */
    1780     rc = RTFileOpen(&pVBoxCore->hCoreFile, pVBoxCore->szCorePath, RTFILE_O_OPEN_CREATE | RTFILE_O_TRUNCATE | RTFILE_O_READWRITE | RTFILE_O_DENY_ALL);
     1785    rc = RTFileOpen(&pVBoxCore->hCoreFile, pVBoxCore->szCorePath,
     1786                    RTFILE_O_OPEN_CREATE | RTFILE_O_TRUNCATE | RTFILE_O_READWRITE | RTFILE_O_DENY_ALL);
    17811787    if (RT_FAILURE(rc))
    17821788    {
     
    21352141            CORELOGRELSYS((CORELOG_NAME "TakeDump failed! rc=%Rrc\n", rc));
    21362142    }
    2137     else if (Sig == SIGSEGV || Sig == SIGBUS)
     2143    else if (Sig == SIGSEGV || Sig == SIGBUS || Sig == SIGTRAP)
    21382144    {
    21392145        /*
     
    21812187    }
    21822188
    2183     if (Sig == SIGSEGV || Sig == SIGBUS)
     2189    if (Sig == SIGSEGV || Sig == SIGBUS || Sig == SIGTRAP)
    21842190    {
    21852191        /*
     
    21892195        signal(SIGSEGV, SIG_DFL);
    21902196        signal(SIGBUS, SIG_DFL);
     2197        signal(SIGTRAP, SIG_DFL);
    21912198
    21922199        /*
     
    22552262     * Validate flags.
    22562263     */
    2257     AssertReturn(fFlags, VERR_INVALID_PARAMETER); /** @todo r=bird: Update the function docs to reflect this.  It currently reads
    2258                                                    * as if RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP was standard behavior.
    2259                                                    * The SIGUSR2/RTCOREDUMPER_FLAGS_LIVE_CORE behavior isn't mentioned at all. */
     2264    AssertReturn(fFlags, VERR_INVALID_PARAMETER);
    22602265    AssertReturn(!(fFlags & ~(  RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP
    22612266                              | RTCOREDUMPER_FLAGS_LIVE_CORE)),
     
    22752280 *        Adding the conditional registration via the two flags complicates
    22762281 *        the implementation of this use case. */
     2282
    22772283    /*
    22782284     * Install core dump signal handler.
    22792285     */
    2280     struct sigaction sigAct;
    2281     RT_ZERO(sigAct);
    2282     sigAct.sa_sigaction = &rtCoreDumperSignalHandler;
    2283     sigemptyset(&sigAct.sa_mask); /** @todo r=bird: We're probably better off blocking all signals here. */
    2284     sigAct.sa_flags = SA_RESTART | SA_SIGINFO | SA_NODEFER; /** @todo r=bird: SA_NODEFER doesn't make sense for SIGUSR2. For the hardware triggered ones, I don't think you can efficiently mask them, but it doesn't hurt playing safe ofc. */
    2285 
    2286     if (fFlags & RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP)
    2287     {
    2288         sigaction(SIGSEGV, &sigAct, NULL);
    2289         sigaction(SIGBUS, &sigAct, NULL);
    2290 /** @todo Add SIGTRAP or release+fatal assertions. */
    2291     }
    2292 
    2293     if (fFlags & RTCOREDUMPER_FLAGS_LIVE_CORE)
    2294         sigaction(SIGUSR2, &sigAct, NULL);
    2295 
    2296     ASMAtomicWriteBool(&g_fCoreDumpSignalSetup, true);
     2286    if (   ASMAtomicReadBool(&g_fCoreDumpSignalSetup) == false
     2287        || ASMAtomicReadU32(&g_fCoreDumpFlags) != fFlags)
     2288    {
     2289        struct sigaction sigAct;
     2290        RT_ZERO(sigAct);
     2291        sigAct.sa_sigaction = &rtCoreDumperSignalHandler;
     2292        sigfillset(&sigAct.sa_mask);                        /* Block all signals while in the signal handler */
     2293        sigAct.sa_flags = SA_RESTART | SA_SIGINFO;
     2294
     2295        if (   (fFlags & RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP)
     2296            && !(g_fCoreDumpFlags & RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP))
     2297        {
     2298            sigAct.sa_flags |= SA_NODEFER;                  /* Don't block the below signal while in it's signal handler. */
     2299            sigaction(SIGSEGV, &sigAct, NULL);
     2300            sigaction(SIGBUS, &sigAct, NULL);
     2301            sigaction(SIGTRAP, &sigAct, NULL);
     2302        }
     2303
     2304        if (   fFlags & RTCOREDUMPER_FLAGS_LIVE_CORE
     2305            && !(g_fCoreDumpFlags & RTCOREDUMPER_FLAGS_LIVE_CORE))
     2306        {
     2307            sigAct.sa_flags = SA_RESTART | SA_SIGINFO;
     2308            sigaction(SIGUSR2, &sigAct, NULL);
     2309        }
     2310
     2311        ASMAtomicWriteU32(&g_fCoreDumpFlags, fFlags);
     2312        ASMAtomicWriteBool(&g_fCoreDumpSignalSetup, true);
     2313    }
    22972314
    22982315    RT_ZERO(g_szCoreDumpDir);
     
    23002317        RTStrCopy(g_szCoreDumpDir, sizeof(g_szCoreDumpDir), pszOutputDir);
    23012318
    2302     ASMAtomicWriteU32(&g_fCoreDumpFlags, fFlags);
    2303 
    23042319    return VINF_SUCCESS;
    23052320}
     
    23152330        signal(SIGSEGV, SIG_DFL);
    23162331        signal(SIGBUS, SIG_DFL);
     2332        signal(SIGTRAP, SIG_DFL);
    23172333        signal(SIGUSR2, SIG_DFL);
    23182334        ASMAtomicWriteBool(&g_fCoreDumpSignalSetup, false);
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