VirtualBox

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


Ignore:
Timestamp:
Jun 24, 2011 1:25:07 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72480
Message:

coredumper-solaris.*,tstRTCoreDump: Don't use RTFile*; rewrote testcase to use RTTest and not crash.

Location:
trunk/src/VBox/Runtime
Files:
3 edited

Legend:

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

    r37609 r37631  
    11/* $Id$ */
    22/** @file
    3  * IPRT Testcase - Core Dumper.
     3 * IPRT - Custom Core Dumper, Solaris.
    44 */
    55
    66/*
    7  * Copyright (C) 2010 Oracle Corporation
     7 * Copyright (C) 2010-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2525 */
    2626
     27
    2728/*******************************************************************************
    2829*   Header Files                                                               *
    2930*******************************************************************************/
    30 #define LOG_GROUP LOG_GROUP_CORE_DUMPER
    31 #include <VBox/log.h>
     31#define LOG_GROUP RTLOGGROUP_DEFAULT
    3232#include <iprt/coredumper.h>
    33 #include <iprt/types.h>
    34 #include <iprt/file.h>
     33
     34#include <iprt/asm.h>
     35#include <iprt/dir.h>
    3536#include <iprt/err.h>
    36 #include <iprt/dir.h>
     37#include <iprt/log.h>
     38#include <iprt/param.h>
    3739#include <iprt/path.h>
     40#include <iprt/process.h>
    3841#include <iprt/string.h>
    3942#include <iprt/thread.h>
    40 #include <iprt/param.h>
    41 #include <iprt/asm.h>
    4243#include "coredumper-solaris.h"
    4344
     
    6263#include "internal/ldrELF64.h"
    6364
     65
    6466/*******************************************************************************
    6567*   Globals                                                                    *
     
    127129 * Reads from a file making sure an interruption doesn't cause a failure.
    128130 *
    129  * @param hFile             Handle to the file to read.
     131 * @param fd                Handle to the file to read.
    130132 * @param pv                Where to store the read data.
    131133 * @param cbToRead          Size of data to read.
     
    133135 * @return IPRT status code.
    134136 */
    135 static int ReadFileNoIntr(RTFILE hFile, void *pv, size_t cbToRead)
    136 {
    137     int rc = VERR_READ_ERROR;
    138     while (1)
    139     {
    140         rc = RTFileRead(hFile, pv, cbToRead, NULL /* Read all */);
    141         if (rc == VERR_INTERRUPTED)
    142             continue;
    143         break;
    144     }
    145     return rc;
     137static int ReadFileNoIntr(int fd, void *pv, size_t cbToRead)
     138{
     139    for (;;)
     140    {
     141        ssize_t cbRead = read(fd, pv, cbToRead);
     142        if (cbRead < 0)
     143        {
     144            if (errno == EINTR)
     145                continue;
     146            return RTErrConvertFromErrno(errno);
     147        }
     148        if ((size_t)cbRead == cbToRead)
     149            return VINF_SUCCESS;
     150        if ((size_t)cbRead > cbToRead)
     151            return VERR_INTERNAL_ERROR_3;
     152        if (cbRead == 0)
     153            return VERR_EOF;
     154        pv = (uint8_t *)pv + cbRead;
     155        cbToRead -= cbRead;
     156    }
    146157}
    147158
     
    150161 * Writes to a file making sure an interruption doesn't cause a failure.
    151162 *
    152  * @param hFile             Handle to the file to write.
     163 * @param fd                Handle to the file to write to.
    153164 * @param pv                Pointer to what to write.
    154  * @param cbToRead          Size of data to write.
     165 * @param cbToWrite          Size of data to write.
    155166 *
    156167 * @return IPRT status code.
    157168 */
    158 static int WriteFileNoIntr(RTFILE hFile, const void *pcv, size_t cbToRead)
    159 {
    160     int rc = VERR_READ_ERROR;
    161     while (1)
    162     {
    163         rc = RTFileWrite(hFile, pcv, cbToRead, NULL /* Write all */);
    164         if (rc == VERR_INTERRUPTED)
    165             continue;
    166         break;
    167     }
    168     return rc;
     169static int WriteFileNoIntr(int fd, const void *pv, size_t cbToWrite)
     170{
     171    for (;;)
     172    {
     173        ssize_t cbWritten = write(fd, pv, cbToWrite);
     174        if (cbWritten < 0)
     175        {
     176            if (errno == EINTR)
     177                continue;
     178            return RTErrConvertFromErrno(errno);
     179        }
     180        if ((size_t)cbWritten == cbToWrite)
     181            return VINF_SUCCESS;
     182        if ((size_t)cbWritten > cbToWrite)
     183            return VERR_INTERNAL_ERROR_2;
     184        pv = (uint8_t const *)pv + cbWritten;
     185        cbToWrite -= cbWritten;
     186    }
    169187}
    170188
     
    173191 * Read from a given offset in the process' address space.
    174192 *
    175  * @param pVBoxProc         Pointer to the VBox process.
     193 * @param pSolProc         Pointer to the solaris process.
    176194 * @param pv                Where to read the data into.
    177195 * @param cb                Size of the read buffer.
     
    180198 * @return VINF_SUCCESS, if all the given bytes was read in, otherwise VERR_READ_ERROR.
    181199 */
    182 static ssize_t ProcReadAddrSpace(PVBOXPROCESS pVBoxProc, RTFOFF off, void *pvBuf, size_t cbToRead)
    183 {
    184     while (1)
    185     {
    186         int rc = RTFileReadAt(pVBoxProc->hAs, off, pvBuf, cbToRead, NULL);
    187         if (rc == VERR_INTERRUPTED)
    188             continue;
    189         return rc;
     200static ssize_t ProcReadAddrSpace(PRTSOLCOREPROCESS pSolProc, RTFOFF off, void *pvBuf, size_t cbToRead)
     201{
     202    for (;;)
     203    {
     204        ssize_t cbRead = pread(pSolProc->fdAs, pvBuf, cbToRead, off);
     205        if (cbRead < 0)
     206        {
     207            if (errno == EINTR)
     208                continue;
     209            return RTErrConvertFromErrno(errno);
     210        }
     211        if ((size_t)cbRead == cbToRead)
     212            return VINF_SUCCESS;
     213        if ((size_t)cbRead > cbToRead)
     214            return VERR_INTERNAL_ERROR_4;
     215        if (cbRead == 0)
     216            return VERR_EOF;
     217
     218        pvBuf     = (uint8_t *)pvBuf + cbRead;
     219        cbToRead -= cbRead;
     220        off      += cbRead;
    190221    }
    191222}
     
    195226 * Determines if the current process' architecture is suitable for dumping core.
    196227 *
    197  * @param pVBoxProc         Pointer to the VBox process.
     228 * @param pSolProc         Pointer to the solaris process.
    198229 *
    199230 * @return true if the architecture matches the current one.
    200231 */
    201 static inline bool IsProcessArchNative(PVBOXPROCESS pVBoxProc)
    202 {
    203     return pVBoxProc->ProcInfo.pr_dmodel == PR_MODEL_NATIVE;
    204 }
    205 
    206 
    207 /**
    208  * Helper function to get the size of a file given it's path.
    209  *
    210  * @param pszPath           Pointer to the full path of the file.
    211  *
    212  * @return The size of the file in bytes.
    213  */
    214 static size_t GetFileSize(const char *pszPath)
    215 {
    216     uint64_t cb = 0;
     232static inline bool IsProcessArchNative(PRTSOLCOREPROCESS pSolProc)
     233{
     234    return pSolProc->ProcInfo.pr_dmodel == PR_MODEL_NATIVE;
     235}
     236
     237
     238/**
     239 * Helper function to get the size_t compatible file size from a file
     240 * descriptor.
     241 *
     242 * @return  The file size (in bytes).
     243 * @param   fd              The file descriptor.
     244 */
     245static size_t GetFileSizeByFd(int fd)
     246{
     247    struct stat st;
     248    if (fstat(fd, &st) == 0)
     249        return st.st_size < ~(size_t)0 ? (size_t)st.st_size : ~(size_t)0;
     250
     251    CORELOGRELSYS((CORELOG_NAME "GetFileSizeByFd: fstat failed rc=%Rrc\n", RTErrConvertFromErrno(errno)));
     252    return 0;
     253}
     254
     255
     256/**
     257 * Helper function to get the size_t compatible size of a file given its path.
     258 *
     259 * @return  The file size (in bytes).
     260 * @param   pszPath         Pointer to the full path of the file.
     261 */
     262static size_t GetFileSizeByName(const char *pszPath)
     263{
    217264    int fd = open(pszPath, O_RDONLY);
    218     if (fd >= 0)
    219     {
    220         RTFILE hFile = (RTFILE)(uintptr_t)fd;
    221         RTFileGetSize(hFile, &cb);
    222         RTFileClose(hFile);
    223     }
    224     else
    225         CORELOGRELSYS((CORELOG_NAME "GetFileSize: failed to open %s rc=%Rrc\n", pszPath, RTErrConvertFromErrno(fd)));
    226     return cb < ~(size_t)0 ? (size_t)cb : ~(size_t)0;
     265    if (fd < 0)
     266    {
     267        CORELOGRELSYS((CORELOG_NAME "GetFileSizeByName: failed to open %s rc=%Rrc\n", pszPath, RTErrConvertFromErrno(errno)));
     268        return 0;
     269    }
     270
     271    size_t cb = GetFileSizeByFd(fd);
     272    close(fd);
     273    return cb;
    227274}
    228275
     
    233280 * mapped memory area which will be used during the core dumping routines.
    234281 *
    235  * @param pVBoxCore         Pointer to the core object.
     282 * @param pSolCore          Pointer to the core object.
    236283 *
    237284 * @return IPRT status code.
    238285 */
    239 static int AllocMemoryArea(PVBOXCORE pVBoxCore)
    240 {
    241     AssertReturn(pVBoxCore->pvCore == NULL, VERR_ALREADY_EXISTS);
    242 
    243     struct VBOXSOLPREALLOCTABLE
     286static int AllocMemoryArea(PRTSOLCORE pSolCore)
     287{
     288    AssertReturn(pSolCore->pvCore == NULL, VERR_ALREADY_EXISTS);
     289
     290    static struct
    244291    {
    245292        const char *pszFilePath;        /* Proc based path */
     
    247294        size_t      cbEntry;            /* Size of each entry in file */
    248295        size_t      cbAccounting;       /* Size of each accounting entry per entry */
    249     } aPreAllocTable[] = {
    250         { "/proc/%d/map",        0,                  sizeof(prmap_t),       sizeof(VBOXSOLMAPINFO) },
     296    } const s_aPreAllocTable[] =
     297    {
     298        { "/proc/%d/map",        0,                  sizeof(prmap_t),       sizeof(RTSOLCOREMAPINFO) },
    251299        { "/proc/%d/auxv",       0,                  0,                     0 },
    252         { "/proc/%d/lpsinfo",    sizeof(prheader_t), sizeof(lwpsinfo_t),    sizeof(VBOXSOLTHREADINFO) },
     300        { "/proc/%d/lpsinfo",    sizeof(prheader_t), sizeof(lwpsinfo_t),    sizeof(RTSOLCORETHREADINFO) },
    253301        { "/proc/%d/lstatus",    0,                  0,                     0 },
    254302        { "/proc/%d/ldt",        0,                  0,                     0 },
     
    258306
    259307    size_t cb = 0;
    260     for (int i = 0; i < (int)RT_ELEMENTS(aPreAllocTable); i++)
     308    for (unsigned i = 0; i < RT_ELEMENTS(s_aPreAllocTable); i++)
    261309    {
    262310        char szPath[PATH_MAX];
    263         RTStrPrintf(szPath, sizeof(szPath), aPreAllocTable[i].pszFilePath, (int)pVBoxCore->VBoxProc.Process);
    264         size_t cbFile = GetFileSize(szPath);
     311        RTStrPrintf(szPath, sizeof(szPath), s_aPreAllocTable[i].pszFilePath, (int)pSolCore->SolProc.Process);
     312        size_t cbFile = GetFileSizeByName(szPath);
    265313        cb += cbFile;
    266314        if (   cbFile > 0
    267             && aPreAllocTable[i].cbEntry > 0)
    268         {
    269             cb += ((cbFile - aPreAllocTable[i].cbHeader) / aPreAllocTable[i].cbEntry) * (aPreAllocTable[i].cbAccounting > 0 ?
    270                                                                                          aPreAllocTable[i].cbAccounting : 1);
    271             cb += aPreAllocTable[i].cbHeader;
     315            && s_aPreAllocTable[i].cbEntry > 0)
     316        {
     317            cb += ((cbFile - s_aPreAllocTable[i].cbHeader) / s_aPreAllocTable[i].cbEntry)
     318                * (s_aPreAllocTable[i].cbAccounting > 0 ? s_aPreAllocTable[i].cbAccounting : 1);
     319            cb += s_aPreAllocTable[i].cbHeader;
    272320        }
    273321    }
     
    276324     * Make room for our own mapping accountant entry which will also be included in the core.
    277325     */
    278     cb += sizeof(VBOXSOLMAPINFO);
     326    cb += sizeof(RTSOLCOREMAPINFO);
    279327
    280328    /*
     
    286334    {
    287335        CORELOG((CORELOG_NAME "AllocMemoryArea: memory area of %u bytes allocated.\n", cb));
    288         pVBoxCore->pvCore = pv;
    289         pVBoxCore->pvFree = pv;
    290         pVBoxCore->cbCore = cb;
     336        pSolCore->pvCore = pv;
     337        pSolCore->pvFree = pv;
     338        pSolCore->cbCore = cb;
    291339        return VINF_SUCCESS;
    292340    }
    293     else
    294     {
    295         CORELOGRELSYS((CORELOG_NAME "AllocMemoryArea: failed cb=%u\n", cb));
    296         return VERR_NO_MEMORY;
    297     }
     341    CORELOGRELSYS((CORELOG_NAME "AllocMemoryArea: failed cb=%u\n", cb));
     342    return VERR_NO_MEMORY;
    298343}
    299344
     
    302347 * Free memory area used by the core object.
    303348 *
    304  * @param pVBoxCore         Pointer to the core object.
    305  */
    306 static void FreeMemoryArea(PVBOXCORE pVBoxCore)
    307 {
    308     AssertReturnVoid(pVBoxCore);
    309     AssertReturnVoid(pVBoxCore->pvCore);
    310     AssertReturnVoid(pVBoxCore->cbCore > 0);
    311 
    312     munmap(pVBoxCore->pvCore, pVBoxCore->cbCore);
    313     CORELOG((CORELOG_NAME "FreeMemoryArea: memory area of %u bytes freed.\n", pVBoxCore->cbCore));
    314 
    315     pVBoxCore->pvCore = NULL;
    316     pVBoxCore->pvFree= NULL;
    317     pVBoxCore->cbCore = 0;
     349 * @param pSolCore          Pointer to the core object.
     350 */
     351static void FreeMemoryArea(PRTSOLCORE pSolCore)
     352{
     353    AssertReturnVoid(pSolCore);
     354    AssertReturnVoid(pSolCore->pvCore);
     355    AssertReturnVoid(pSolCore->cbCore > 0);
     356
     357    munmap(pSolCore->pvCore, pSolCore->cbCore);
     358    CORELOG((CORELOG_NAME "FreeMemoryArea: memory area of %u bytes freed.\n", pSolCore->cbCore));
     359
     360    pSolCore->pvCore = NULL;
     361    pSolCore->pvFree= NULL;
     362    pSolCore->cbCore = 0;
    318363}
    319364
     
    322367 * Get a chunk from the area of allocated memory.
    323368 *
    324  * @param pVBoxCore         Pointer to the core object.
     369 * @param pSolCore          Pointer to the core object.
    325370 * @param cb                Size of requested chunk.
    326371 *
    327372 * @return Pointer to allocated memory, or NULL on failure.
    328373 */
    329 static void *GetMemoryChunk(PVBOXCORE pVBoxCore, size_t cb)
    330 {
    331     AssertReturn(pVBoxCore, NULL);
    332     AssertReturn(pVBoxCore->pvCore, NULL);
    333     AssertReturn(pVBoxCore->pvFree, NULL);
    334 
    335     size_t cbAllocated = (char *)pVBoxCore->pvFree - (char *)pVBoxCore->pvCore;
    336     if (cbAllocated < pVBoxCore->cbCore)
    337     {
    338         char *pb = (char *)pVBoxCore->pvFree;
    339         pVBoxCore->pvFree = pb + cb;
     374static void *GetMemoryChunk(PRTSOLCORE pSolCore, size_t cb)
     375{
     376    AssertReturn(pSolCore, NULL);
     377    AssertReturn(pSolCore->pvCore, NULL);
     378    AssertReturn(pSolCore->pvFree, NULL);
     379
     380    size_t cbAllocated = (char *)pSolCore->pvFree - (char *)pSolCore->pvCore;
     381    if (cbAllocated < pSolCore->cbCore)
     382    {
     383        char *pb = (char *)pSolCore->pvFree;
     384        pSolCore->pvFree = pb + cb;
    340385        return pb;
    341386    }
     
    348393 * Reads the proc file's content into a newly allocated buffer.
    349394 *
    350  * @param pVBoxCore         Pointer to the core object.
     395 * @param pSolCore          Pointer to the core object.
    351396 * @param pszFileFmt        Only the name of the file to read from (/proc/<pid> will be prepended)
    352397 * @param ppv               Where to store the allocated buffer.
     
    357402 *          respectively.
    358403 */
    359 static int ProcReadFileInto(PVBOXCORE pVBoxCore, const char *pszProcFileName, void **ppv, size_t *pcb)
    360 {
    361     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
     404static int ProcReadFileInto(PRTSOLCORE pSolCore, const char *pszProcFileName, void **ppv, size_t *pcb)
     405{
     406    AssertReturn(pSolCore, VERR_INVALID_POINTER);
    362407
    363408    char szPath[PATH_MAX];
    364     RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/%s", (int)pVBoxCore->VBoxProc.Process, pszProcFileName);
     409    RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/%s", (int)pSolCore->SolProc.Process, pszProcFileName);
    365410    int rc = VINF_SUCCESS;
    366411    int fd = open(szPath, O_RDONLY);
    367412    if (fd >= 0)
    368413    {
    369         RTFILE hFile = (RTFILE)(uintptr_t)fd;
    370         uint64_t u64Size;
    371         RTFileGetSize(hFile, &u64Size);
    372         *pcb = u64Size < ~(size_t)0 ? u64Size : ~(size_t)0;
     414        *pcb = GetFileSizeByFd(fd);
    373415        if (*pcb > 0)
    374416        {
    375             *ppv = GetMemoryChunk(pVBoxCore, *pcb);
     417            *ppv = GetMemoryChunk(pSolCore, *pcb);
    376418            if (*ppv)
    377                 rc = ReadFileNoIntr(hFile, *ppv, *pcb);
     419                rc = ReadFileNoIntr(fd, *ppv, *pcb);
    378420            else
    379421                rc = VERR_NO_MEMORY;
     
    385427            rc = VINF_SUCCESS;
    386428        }
    387         RTFileClose(hFile);
     429        close(fd);
    388430    }
    389431    else
     
    399441 * Read process information (format psinfo_t) from /proc.
    400442 *
    401  * @param pVBoxCore         Pointer to the core object.
     443 * @param pSolCore          Pointer to the core object.
    402444 *
    403445 * @return IPRT status code.
    404446 */
    405 static int ProcReadInfo(PVBOXCORE pVBoxCore)
    406 {
    407     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    408 
    409     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     447static int ProcReadInfo(PRTSOLCORE pSolCore)
     448{
     449    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     450
     451    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    410452    char szPath[PATH_MAX];
    411453    int rc = VINF_SUCCESS;
    412454
    413     RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/psinfo", (int)pVBoxProc->Process);
     455    RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/psinfo", (int)pSolProc->Process);
    414456    int fd = open(szPath, O_RDONLY);
    415457    if (fd >= 0)
    416458    {
    417         RTFILE hFile = (RTFILE)(uintptr_t)fd;
    418459        size_t cbProcInfo = sizeof(psinfo_t);
    419         rc = ReadFileNoIntr(hFile, &pVBoxProc->ProcInfo, cbProcInfo);
    420         RTFileClose(hFile);
     460        rc = ReadFileNoIntr(fd, &pSolProc->ProcInfo, cbProcInfo);
     461        close(fd);
    421462    }
    422463    else
     
    433474 * Read process status (format pstatus_t) from /proc.
    434475 *
    435  * @param pVBoxCore         Pointer to the core object.
     476 * @param pSolCore          Pointer to the core object.
    436477 *
    437478 * @return IPRT status code.
    438479 */
    439 static int ProcReadStatus(PVBOXCORE pVBoxCore)
    440 {
    441     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    442 
    443     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     480static int ProcReadStatus(PRTSOLCORE pSolCore)
     481{
     482    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     483
     484    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    444485
    445486    char szPath[PATH_MAX];
    446487    int rc = VINF_SUCCESS;
    447488
    448     RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/status", (int)pVBoxProc->Process);
     489    RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/status", (int)pSolProc->Process);
    449490    int fd = open(szPath, O_RDONLY);
    450491    if (fd >= 0)
    451492    {
    452         RTFILE hFile = (RTFILE)(uintptr_t)fd;
    453         size_t cbRead;
    454493        size_t cbProcStatus = sizeof(pstatus_t);
    455         AssertCompile(sizeof(pstatus_t) == sizeof(pVBoxProc->ProcStatus));
    456         rc = ReadFileNoIntr(hFile, &pVBoxProc->ProcStatus, cbProcStatus);
    457         RTFileClose(hFile);
     494        AssertCompile(sizeof(pstatus_t) == sizeof(pSolProc->ProcStatus));
     495        rc = ReadFileNoIntr(fd, &pSolProc->ProcStatus, cbProcStatus);
     496        close(fd);
    458497    }
    459498    else
     
    469508 * Read process credential information (format prcred_t + array of guid_t)
    470509 *
    471  * @param pVBoxCore         Pointer to the core object.
     510 * @param pSolCore          Pointer to the core object.
    472511 *
    473512 * @remarks Should not be called before successful call to @see AllocMemoryArea()
    474513 * @return IPRT status code.
    475514 */
    476 static int ProcReadCred(PVBOXCORE pVBoxCore)
    477 {
    478     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    479 
    480     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
    481     return ProcReadFileInto(pVBoxCore, "cred", &pVBoxProc->pvCred, &pVBoxProc->cbCred);
     515static int ProcReadCred(PRTSOLCORE pSolCore)
     516{
     517    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     518
     519    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
     520    return ProcReadFileInto(pSolCore, "cred", &pSolProc->pvCred, &pSolProc->cbCred);
    482521}
    483522
     
    486525 * Read process privilege information (format prpriv_t + array of priv_chunk_t)
    487526 *
    488  * @param pVBoxCore         Pointer to the core object.
     527 * @param pSolCore          Pointer to the core object.
    489528 *
    490529 * @remarks Should not be called before successful call to @see AllocMemoryArea()
    491530 * @return IPRT status code.
    492531 */
    493 static int ProcReadPriv(PVBOXCORE pVBoxCore)
    494 {
    495     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    496 
    497     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
    498     int rc = ProcReadFileInto(pVBoxCore, "priv", (void **)&pVBoxProc->pPriv, &pVBoxProc->cbPriv);
     532static int ProcReadPriv(PRTSOLCORE pSolCore)
     533{
     534    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     535
     536    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
     537    int rc = ProcReadFileInto(pSolCore, "priv", (void **)&pSolProc->pPriv, &pSolProc->cbPriv);
    499538    if (RT_FAILURE(rc))
    500539        return rc;
    501     pVBoxProc->pcPrivImpl = getprivimplinfo();
    502     if (!pVBoxProc->pcPrivImpl)
     540    pSolProc->pcPrivImpl = getprivimplinfo();
     541    if (!pSolProc->pcPrivImpl)
    503542    {
    504543        CORELOGRELSYS((CORELOG_NAME "ProcReadPriv: getprivimplinfo returned NULL.\n"));
     
    512551 * Read process LDT information (format array of struct ssd) from /proc.
    513552 *
    514  * @param pVBoxProc         Pointer to the core object.
     553 * @param pSolProc         Pointer to the core object.
    515554 *
    516555 * @remarks Should not be called before successful call to @see AllocMemoryArea()
    517556 * @return IPRT status code.
    518557 */
    519 static int ProcReadLdt(PVBOXCORE pVBoxCore)
    520 {
    521     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    522 
    523     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
    524     return ProcReadFileInto(pVBoxCore, "ldt", &pVBoxProc->pvLdt, &pVBoxProc->cbLdt);
     558static int ProcReadLdt(PRTSOLCORE pSolCore)
     559{
     560    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     561
     562    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
     563    return ProcReadFileInto(pSolCore, "ldt", &pSolProc->pvLdt, &pSolProc->cbLdt);
    525564}
    526565
     
    529568 * Read process auxiliary vectors (format auxv_t) for the process.
    530569 *
    531  * @param pVBoxCore         Pointer to the core object.
     570 * @param pSolCore          Pointer to the core object.
    532571 *
    533572 * @remarks Should not be called before successful call to @see AllocMemoryArea()
    534573 * @return IPRT status code.
    535574 */
    536 static int ProcReadAuxVecs(PVBOXCORE pVBoxCore)
    537 {
    538     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    539 
    540     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     575static int ProcReadAuxVecs(PRTSOLCORE pSolCore)
     576{
     577    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     578
     579    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    541580    char szPath[PATH_MAX];
    542581    int rc = VINF_SUCCESS;
    543     RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/auxv", (int)pVBoxProc->Process);
     582    RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/auxv", (int)pSolProc->Process);
    544583    int fd = open(szPath, O_RDONLY);
    545584    if (fd < 0)
     
    550589    }
    551590
    552     RTFILE hFile = (RTFILE)(uintptr_t)fd;
    553     uint64_t u64Size;
    554     RTFileGetSize(hFile, &u64Size);
    555     size_t cbAuxFile = u64Size < ~(size_t)0 ? u64Size : ~(size_t)0;
     591    size_t cbAuxFile = GetFileSizeByFd(fd);
    556592    if (cbAuxFile >= sizeof(auxv_t))
    557593    {
    558         pVBoxProc->pAuxVecs = (auxv_t*)GetMemoryChunk(pVBoxCore, cbAuxFile + sizeof(auxv_t));
    559         if (pVBoxProc->pAuxVecs)
    560         {
    561             rc = ReadFileNoIntr(hFile, pVBoxProc->pAuxVecs, cbAuxFile);
     594        pSolProc->pAuxVecs = (auxv_t*)GetMemoryChunk(pSolCore, cbAuxFile + sizeof(auxv_t));
     595        if (pSolProc->pAuxVecs)
     596        {
     597            rc = ReadFileNoIntr(fd, pSolProc->pAuxVecs, cbAuxFile);
    562598            if (RT_SUCCESS(rc))
    563599            {
    564600                /* Terminate list of vectors */
    565                 pVBoxProc->cAuxVecs = cbAuxFile / sizeof(auxv_t);
     601                pSolProc->cAuxVecs = cbAuxFile / sizeof(auxv_t);
    566602                CORELOG((CORELOG_NAME "ProcReadAuxVecs: cbAuxFile=%u auxv_t size %d cAuxVecs=%u\n", cbAuxFile, sizeof(auxv_t),
    567                          pVBoxProc->cAuxVecs));
    568                 if (pVBoxProc->cAuxVecs > 0)
     603                         pSolProc->cAuxVecs));
     604                if (pSolProc->cAuxVecs > 0)
    569605                {
    570                     pVBoxProc->pAuxVecs[pVBoxProc->cAuxVecs].a_type = AT_NULL;
    571                     pVBoxProc->pAuxVecs[pVBoxProc->cAuxVecs].a_un.a_val = 0L;
    572                     RTFileClose(hFile);
     606                    pSolProc->pAuxVecs[pSolProc->cAuxVecs].a_type = AT_NULL;
     607                    pSolProc->pAuxVecs[pSolProc->cAuxVecs].a_un.a_val = 0L;
     608                    close(fd);
    573609                    return VINF_SUCCESS;
    574610                }
    575                 else
    576                 {
    577                     CORELOGRELSYS((CORELOG_NAME "ProcReadAuxVecs: Invalid vector count %u\n", pVBoxProc->cAuxVecs));
    578                     rc = VERR_READ_ERROR;
    579                 }
     611
     612                CORELOGRELSYS((CORELOG_NAME "ProcReadAuxVecs: Invalid vector count %u\n", pSolProc->cAuxVecs));
     613                rc = VERR_READ_ERROR;
    580614            }
    581615            else
    582616                CORELOGRELSYS((CORELOG_NAME "ProcReadAuxVecs: ReadFileNoIntr failed. rc=%Rrc cbAuxFile=%u\n", rc, cbAuxFile));
    583617
    584             pVBoxProc->pAuxVecs = NULL;
    585             pVBoxProc->cAuxVecs = 0;
     618            pSolProc->pAuxVecs = NULL;
     619            pSolProc->cAuxVecs = 0;
    586620        }
    587621        else
     
    597631    }
    598632
    599     RTFileClose(hFile);
     633    close(fd);
    600634    return rc;
    601635}
     
    605639 * Find an element in the process' auxiliary vector.
    606640 */
    607 static long GetAuxVal(PVBOXPROCESS pVBoxProc, int Type)
    608 {
    609     AssertReturn(pVBoxProc, -1);
    610     if (pVBoxProc->pAuxVecs)
    611     {
    612         auxv_t *pAuxVec = pVBoxProc->pAuxVecs;
     641static long GetAuxVal(PRTSOLCOREPROCESS pSolProc, int Type)
     642{
     643    AssertReturn(pSolProc, -1);
     644    if (pSolProc->pAuxVecs)
     645    {
     646        auxv_t *pAuxVec = pSolProc->pAuxVecs;
    613647        for (; pAuxVec->a_type != AT_NULL; pAuxVec++)
    614648        {
     
    624658 * Read the process mappings (format prmap_t array).
    625659 *
    626  * @param   pVBoxCore           Pointer to the core object.
     660 * @param   pSolCore            Pointer to the core object.
    627661 *
    628662 * @remarks Should not be called before successful call to @see AllocMemoryArea()
    629663 * @return IPRT status code.
    630664 */
    631 static int ProcReadMappings(PVBOXCORE pVBoxCore)
    632 {
    633     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    634 
    635     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     665static int ProcReadMappings(PRTSOLCORE pSolCore)
     666{
     667    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     668
     669    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    636670    char szPath[PATH_MAX];
    637671    int rc = VINF_SUCCESS;
    638     RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/map", (int)pVBoxProc->Process);
    639     int fd = open(szPath, O_RDONLY);
    640     if (fd < 0)
    641     {
    642         rc = RTErrConvertFromErrno(fd);
     672    RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/map", (int)pSolProc->Process);
     673    int fdMap = open(szPath, O_RDONLY);
     674    if (fdMap < 0)
     675    {
     676        rc = RTErrConvertFromErrno(errno);
    643677        CORELOGRELSYS((CORELOG_NAME "ProcReadMappings: failed to open %s. rc=%Rrc\n", szPath, rc));
    644678        return rc;
    645679    }
    646680
    647     RTFILE hFile = (RTFILE)(uintptr_t)fd;
    648     RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/as", (int)pVBoxProc->Process);
    649     fd = open(szPath, O_RDONLY);
    650     if (fd >= 0)
    651     {
    652         pVBoxProc->hAs = (RTFILE)(uintptr_t)fd;
    653 
     681    RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/as", (int)pSolProc->Process);
     682    pSolProc->fdAs = open(szPath, O_RDONLY);
     683    if (pSolProc->fdAs >= 0)
     684    {
    654685        /*
    655686         * Allocate and read all the prmap_t objects from proc.
    656687         */
    657         uint64_t u64Size;
    658         RTFileGetSize(hFile, &u64Size);
    659         size_t cbMapFile = u64Size < ~(size_t)0 ? u64Size : ~(size_t)0;
     688        size_t cbMapFile = GetFileSizeByFd(fdMap);
    660689        if (cbMapFile >= sizeof(prmap_t))
    661690        {
    662             prmap_t *pMap = (prmap_t*)GetMemoryChunk(pVBoxCore, cbMapFile);
     691            prmap_t *pMap = (prmap_t*)GetMemoryChunk(pSolCore, cbMapFile);
    663692            if (pMap)
    664693            {
    665                 rc = ReadFileNoIntr(hFile, pMap, cbMapFile);
     694                rc = ReadFileNoIntr(fdMap, pMap, cbMapFile);
    666695                if (RT_SUCCESS(rc))
    667696                {
    668                     pVBoxProc->cMappings = cbMapFile / sizeof(prmap_t);
    669                     if (pVBoxProc->cMappings > 0)
     697                    pSolProc->cMappings = cbMapFile / sizeof(prmap_t);
     698                    if (pSolProc->cMappings > 0)
    670699                    {
    671700                        /*
    672                          * Allocate for each prmap_t object, a corresponding VBOXSOLMAPINFO object.
     701                         * Allocate for each prmap_t object, a corresponding RTSOLCOREMAPINFO object.
    673702                         */
    674                         pVBoxProc->pMapInfoHead = (PVBOXSOLMAPINFO)GetMemoryChunk(pVBoxCore, pVBoxProc->cMappings * sizeof(VBOXSOLMAPINFO));
    675                         if (pVBoxProc->pMapInfoHead)
     703                        pSolProc->pMapInfoHead = (PRTSOLCOREMAPINFO)GetMemoryChunk(pSolCore, pSolProc->cMappings * sizeof(RTSOLCOREMAPINFO));
     704                        if (pSolProc->pMapInfoHead)
    676705                        {
    677706                            /*
    678707                             * Associate the prmap_t with the mapping info object.
    679708                             */
    680                             Assert(pVBoxProc->pMapInfoHead == NULL);
    681                             PVBOXSOLMAPINFO pCur = pVBoxProc->pMapInfoHead;
    682                             PVBOXSOLMAPINFO pPrev = NULL;
    683                             for (uint64_t i = 0; i < pVBoxProc->cMappings; i++, pMap++, pCur++)
     709                            /*Assert(pSolProc->pMapInfoHead == NULL); - does not make sense */
     710                            PRTSOLCOREMAPINFO pCur = pSolProc->pMapInfoHead;
     711                            PRTSOLCOREMAPINFO pPrev = NULL;
     712                            for (uint64_t i = 0; i < pSolProc->cMappings; i++, pMap++, pCur++)
    684713                            {
    685714                                memcpy(&pCur->pMap, pMap, sizeof(pCur->pMap));
     
    697726                                {
    698727                                    size_t cb = RT_MIN(sizeof(achBuf), pCur->pMap.pr_size - k);
    699                                     int rc2 = ProcReadAddrSpace(pVBoxProc, pCur->pMap.pr_vaddr + k, &achBuf, cb);
     728                                    int rc2 = ProcReadAddrSpace(pSolProc, pCur->pMap.pr_vaddr + k, &achBuf, cb);
    700729                                    if (RT_FAILURE(rc2))
    701730                                    {
     
    722751                                pPrev->pNext = NULL;
    723752
    724                             RTFileClose(hFile);
    725                             RTFileClose(pVBoxProc->hAs);
    726                             pVBoxProc->hAs = NIL_RTFILE;
    727                             CORELOG((CORELOG_NAME "ProcReadMappings: successfully read in %u mappings\n", pVBoxProc->cMappings));
     753                            close(fdMap);
     754                            close(pSolProc->fdAs);
     755                            pSolProc->fdAs = -1;
     756                            CORELOG((CORELOG_NAME "ProcReadMappings: successfully read in %u mappings\n", pSolProc->cMappings));
    728757                            return VINF_SUCCESS;
    729758                        }
    730                         else
    731                         {
    732                             CORELOGRELSYS((CORELOG_NAME "ProcReadMappings: GetMemoryChunk failed %u\n",
    733                                            pVBoxProc->cMappings * sizeof(VBOXSOLMAPINFO)));
    734                             rc = VERR_NO_MEMORY;
    735                         }
     759
     760                        CORELOGRELSYS((CORELOG_NAME "ProcReadMappings: GetMemoryChunk failed %u\n",
     761                                       pSolProc->cMappings * sizeof(RTSOLCOREMAPINFO)));
     762                        rc = VERR_NO_MEMORY;
    736763                    }
    737764                    else
    738765                    {
    739                         CORELOGRELSYS((CORELOG_NAME "ProcReadMappings: Invalid mapping count %u\n", pVBoxProc->cMappings));
     766                        CORELOGRELSYS((CORELOG_NAME "ProcReadMappings: Invalid mapping count %u\n", pSolProc->cMappings));
    740767                        rc = VERR_READ_ERROR;
    741768                    }
     
    751778        }
    752779
    753         RTFileClose(pVBoxProc->hAs);
    754         pVBoxProc->hAs = NIL_RTFILE;
     780        close(pSolProc->fdAs);
     781        pSolProc->fdAs = -1;
    755782    }
    756783    else
    757784        CORELOGRELSYS((CORELOG_NAME "ProcReadMappings: failed to open %s. rc=%Rrc\n", szPath, rc));
    758785
    759     RTFileClose(hFile);
     786    close(fdMap);
    760787    return rc;
    761788}
     
    765792 * Reads the thread information for all threads in the process.
    766793 *
    767  * @param pVBoxCore         Pointer to the core object.
     794 * @param pSolCore          Pointer to the core object.
    768795 *
    769796 * @remarks Should not be called before successful call to @see AllocMemoryArea()
    770797 * @return IPRT status code.
    771798 */
    772 static int ProcReadThreads(PVBOXCORE pVBoxCore)
    773 {
    774     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    775 
    776     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
    777     AssertReturn(pVBoxProc->pCurThreadCtx, VERR_NO_DATA);
     799static int ProcReadThreads(PRTSOLCORE pSolCore)
     800{
     801    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     802
     803    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
     804    AssertReturn(pSolProc->pCurThreadCtx, VERR_NO_DATA);
    778805
    779806    /*
     
    783810    size_t cbInfoHdrAndData;
    784811    void *pvInfoHdr = NULL;
    785     int rc = ProcReadFileInto(pVBoxCore, "lpsinfo", &pvInfoHdr, &cbInfoHdrAndData);
     812    int rc = ProcReadFileInto(pSolCore, "lpsinfo", &pvInfoHdr, &cbInfoHdrAndData);
    786813    if (RT_SUCCESS(rc))
    787814    {
     
    792819        void *pvStatusHdr = NULL;
    793820        size_t cbStatusHdrAndData;
    794         rc = ProcReadFileInto(pVBoxCore, "lstatus", &pvStatusHdr, &cbStatusHdrAndData);
     821        rc = ProcReadFileInto(pSolCore, "lstatus", &pvStatusHdr, &cbStatusHdrAndData);
    795822        if (RT_SUCCESS(rc))
    796823        {
     
    844871                    cStatus = pInfoHdr->pr_nent;
    845872
    846                     size_t cbThreadInfo = RT_MAX(cStatus, cInfo) * sizeof(VBOXSOLTHREADINFO);
    847                     pVBoxProc->pThreadInfoHead = (PVBOXSOLTHREADINFO)GetMemoryChunk(pVBoxCore, cbThreadInfo);
    848                     if (pVBoxProc->pThreadInfoHead)
     873                    size_t cbThreadInfo = RT_MAX(cStatus, cInfo) * sizeof(RTSOLCORETHREADINFO);
     874                    pSolProc->pThreadInfoHead = (PRTSOLCORETHREADINFO)GetMemoryChunk(pSolCore, cbThreadInfo);
     875                    if (pSolProc->pThreadInfoHead)
    849876                    {
    850                         PVBOXSOLTHREADINFO pCur = pVBoxProc->pThreadInfoHead;
    851                         PVBOXSOLTHREADINFO pPrev = NULL;
     877                        PRTSOLCORETHREADINFO pCur = pSolProc->pThreadInfoHead;
     878                        PRTSOLCORETHREADINFO pPrev = NULL;
    852879                        for (uint64_t i = 0; i < cInfo; i++, pCur++)
    853880                        {
     
    861888                                 */
    862889                                if (   pStatus          /* noid droid */
    863                                     && pStatus->pr_lwpid == (id_t)pVBoxProc->hCurThread)
     890                                    && pStatus->pr_lwpid == (id_t)pSolProc->hCurThread)
    864891                                {
    865                                     AssertCompile(sizeof(pStatus->pr_reg) == sizeof(pVBoxProc->pCurThreadCtx->uc_mcontext.gregs));
    866                                     AssertCompile(sizeof(pStatus->pr_fpreg) == sizeof(pVBoxProc->pCurThreadCtx->uc_mcontext.fpregs));
    867                                     memcpy(&pStatus->pr_reg, &pVBoxProc->pCurThreadCtx->uc_mcontext.gregs, sizeof(pStatus->pr_reg));
    868                                     memcpy(&pStatus->pr_fpreg, &pVBoxProc->pCurThreadCtx->uc_mcontext.fpregs, sizeof(pStatus->pr_fpreg));
    869 
    870                                     AssertCompile(sizeof(pStatus->pr_lwphold) == sizeof(pVBoxProc->pCurThreadCtx->uc_sigmask));
    871                                     memcpy(&pStatus->pr_lwphold, &pVBoxProc->pCurThreadCtx->uc_sigmask, sizeof(pStatus->pr_lwphold));
    872                                     pStatus->pr_ustack = (uintptr_t)&pVBoxProc->pCurThreadCtx->uc_stack;
     892                                    AssertCompile(sizeof(pStatus->pr_reg) == sizeof(pSolProc->pCurThreadCtx->uc_mcontext.gregs));
     893                                    AssertCompile(sizeof(pStatus->pr_fpreg) == sizeof(pSolProc->pCurThreadCtx->uc_mcontext.fpregs));
     894                                    memcpy(&pStatus->pr_reg, &pSolProc->pCurThreadCtx->uc_mcontext.gregs, sizeof(pStatus->pr_reg));
     895                                    memcpy(&pStatus->pr_fpreg, &pSolProc->pCurThreadCtx->uc_mcontext.fpregs, sizeof(pStatus->pr_fpreg));
     896
     897                                    AssertCompile(sizeof(pStatus->pr_lwphold) == sizeof(pSolProc->pCurThreadCtx->uc_sigmask));
     898                                    memcpy(&pStatus->pr_lwphold, &pSolProc->pCurThreadCtx->uc_sigmask, sizeof(pStatus->pr_lwphold));
     899                                    pStatus->pr_ustack = (uintptr_t)&pSolProc->pCurThreadCtx->uc_stack;
    873900
    874901                                    CORELOG((CORELOG_NAME "ProcReadThreads: patched dumper thread context with pre-dump time context.\n"));
     
    893920
    894921                        CORELOG((CORELOG_NAME "ProcReadThreads: successfully read %u threads.\n", cInfo));
    895                         pVBoxProc->cThreads = cInfo;
     922                        pSolProc->cThreads = cInfo;
    896923                        return VINF_SUCCESS;
    897924                    }
     
    927954 * This may include platform name, zone name and other OS-specific information.
    928955 *
    929  * @param pVBoxCore         Pointer to the core object.
     956 * @param pSolCore          Pointer to the core object.
    930957 *
    931958 * @return IPRT status code.
    932959 */
    933 static int ProcReadMiscInfo(PVBOXCORE pVBoxCore)
    934 {
    935     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    936 
    937     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     960static int ProcReadMiscInfo(PRTSOLCORE pSolCore)
     961{
     962    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     963
     964    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    938965
    939966#ifdef RT_OS_SOLARIS
     
    941968     * Read the platform name, uname string and zone name.
    942969     */
    943     int rc = sysinfo(SI_PLATFORM, pVBoxProc->szPlatform, sizeof(pVBoxProc->szPlatform));
     970    int rc = sysinfo(SI_PLATFORM, pSolProc->szPlatform, sizeof(pSolProc->szPlatform));
    944971    if (rc == -1)
    945972    {
     
    947974        return VERR_GENERAL_FAILURE;
    948975    }
    949     pVBoxProc->szPlatform[sizeof(pVBoxProc->szPlatform) - 1] = '\0';
    950 
    951     rc = uname(&pVBoxProc->UtsName);
     976    pSolProc->szPlatform[sizeof(pSolProc->szPlatform) - 1] = '\0';
     977
     978    rc = uname(&pSolProc->UtsName);
    952979    if (rc == -1)
    953980    {
     
    956983    }
    957984
    958     rc = getzonenamebyid(pVBoxProc->ProcInfo.pr_zoneid, pVBoxProc->szZoneName, sizeof(pVBoxProc->szZoneName));
     985    rc = getzonenamebyid(pSolProc->ProcInfo.pr_zoneid, pSolProc->szZoneName, sizeof(pSolProc->szZoneName));
    959986    if (rc < 0)
    960987    {
    961988        CORELOGRELSYS((CORELOG_NAME "ProcReadMiscInfo: getzonenamebyid failed. rc=%d errno=%d zoneid=%d\n", rc, errno,
    962                        pVBoxProc->ProcInfo.pr_zoneid));
     989                       pSolProc->ProcInfo.pr_zoneid));
    963990        return VERR_GENERAL_FAILURE;
    964991    }
    965     pVBoxProc->szZoneName[sizeof(pVBoxProc->szZoneName) - 1] = '\0';
     992    pSolProc->szZoneName[sizeof(pSolProc->szZoneName) - 1] = '\0';
    966993    rc = VINF_SUCCESS;
    967994
     
    9771004 * info. for backward and GDB compatibility, hence the need for this ugly function.
    9781005 *
    979  * @param pVBoxCore         Pointer to the core object.
     1006 * @param pSolCore          Pointer to the core object.
    9801007 * @param pInfo             Pointer to the old prpsinfo_t structure to update.
    9811008 */
    982 static void GetOldProcessInfo(PVBOXCORE pVBoxCore, prpsinfo_t *pInfo)
    983 {
    984     AssertReturnVoid(pVBoxCore);
     1009static void GetOldProcessInfo(PRTSOLCORE pSolCore, prpsinfo_t *pInfo)
     1010{
     1011    AssertReturnVoid(pSolCore);
    9851012    AssertReturnVoid(pInfo);
    9861013
    987     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
    988     psinfo_t *pSrc = &pVBoxProc->ProcInfo;
     1014    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
     1015    psinfo_t *pSrc = &pSolProc->ProcInfo;
    9891016    memset(pInfo, 0, sizeof(prpsinfo_t));
    9901017    pInfo->pr_state    = pSrc->pr_lwp.pr_state;
     
    10331060 * info. for backward and GDB compatibility, hence the need for this ugly function.
    10341061 *
    1035  * @param pVBoxCore         Pointer to the core object.
     1062 * @param pSolCore          Pointer to the core object.
    10361063 * @param pInfo             Pointer to the thread info.
    10371064 * @param pStatus           Pointer to the thread status.
     
    10391066 *
    10401067 */
    1041 static void GetOldProcessStatus(PVBOXCORE pVBoxCore, lwpsinfo_t *pInfo, lwpstatus_t *pStatus, prstatus_t *pDst)
    1042 {
    1043     AssertReturnVoid(pVBoxCore);
     1068static void GetOldProcessStatus(PRTSOLCORE pSolCore, lwpsinfo_t *pInfo, lwpstatus_t *pStatus, prstatus_t *pDst)
     1069{
     1070    AssertReturnVoid(pSolCore);
    10441071    AssertReturnVoid(pInfo);
    10451072    AssertReturnVoid(pStatus);
    10461073    AssertReturnVoid(pDst);
    10471074
    1048     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     1075    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    10491076    memset(pDst, 0, sizeof(prstatus_t));
    10501077    if (pStatus->pr_flags & PR_STOPPED)
     
    10961123    RTStrCopy(pDst->pr_clname, sizeof(pDst->pr_clname), pStatus->pr_clname);
    10971124
    1098     pDst->pr_nlwp       = pVBoxProc->ProcStatus.pr_nlwp;
    1099     pDst->pr_sigpend    = pVBoxProc->ProcStatus.pr_sigpend;
    1100     pDst->pr_pid        = pVBoxProc->ProcStatus.pr_pid;
    1101     pDst->pr_ppid       = pVBoxProc->ProcStatus.pr_ppid;
    1102     pDst->pr_pgrp       = pVBoxProc->ProcStatus.pr_pgid;
    1103     pDst->pr_sid        = pVBoxProc->ProcStatus.pr_sid;
    1104     pDst->pr_utime      = pVBoxProc->ProcStatus.pr_utime;
    1105     pDst->pr_stime      = pVBoxProc->ProcStatus.pr_stime;
    1106     pDst->pr_cutime     = pVBoxProc->ProcStatus.pr_cutime;
    1107     pDst->pr_cstime     = pVBoxProc->ProcStatus.pr_cstime;
    1108     pDst->pr_brkbase    = (caddr_t)pVBoxProc->ProcStatus.pr_brkbase;
    1109     pDst->pr_brksize    = pVBoxProc->ProcStatus.pr_brksize;
    1110     pDst->pr_stkbase    = (caddr_t)pVBoxProc->ProcStatus.pr_stkbase;
    1111     pDst->pr_stksize    = pVBoxProc->ProcStatus.pr_stksize;
     1125    pDst->pr_nlwp       = pSolProc->ProcStatus.pr_nlwp;
     1126    pDst->pr_sigpend    = pSolProc->ProcStatus.pr_sigpend;
     1127    pDst->pr_pid        = pSolProc->ProcStatus.pr_pid;
     1128    pDst->pr_ppid       = pSolProc->ProcStatus.pr_ppid;
     1129    pDst->pr_pgrp       = pSolProc->ProcStatus.pr_pgid;
     1130    pDst->pr_sid        = pSolProc->ProcStatus.pr_sid;
     1131    pDst->pr_utime      = pSolProc->ProcStatus.pr_utime;
     1132    pDst->pr_stime      = pSolProc->ProcStatus.pr_stime;
     1133    pDst->pr_cutime     = pSolProc->ProcStatus.pr_cutime;
     1134    pDst->pr_cstime     = pSolProc->ProcStatus.pr_cstime;
     1135    pDst->pr_brkbase    = (caddr_t)pSolProc->ProcStatus.pr_brkbase;
     1136    pDst->pr_brksize    = pSolProc->ProcStatus.pr_brksize;
     1137    pDst->pr_stkbase    = (caddr_t)pSolProc->ProcStatus.pr_stkbase;
     1138    pDst->pr_stksize    = pSolProc->ProcStatus.pr_stksize;
    11121139
    11131140    pDst->pr_processor  = (short)pInfo->pr_onpro;
     
    11201147 * Callback for rtCoreDumperForEachThread to suspend a thread.
    11211148 *
    1122  * @param pVBoxCore             Pointer to the core object.
     1149 * @param pSolCore              Pointer to the core object.
    11231150 * @param pvThreadInfo          Opaque pointer to thread information.
    11241151 *
    11251152 * @return IPRT status code.
    11261153 */
    1127 static int suspendThread(PVBOXCORE pVBoxCore, void *pvThreadInfo)
     1154static int suspendThread(PRTSOLCORE pSolCore, void *pvThreadInfo)
    11281155{
    11291156    AssertPtrReturn(pvThreadInfo, VERR_INVALID_POINTER);
    1130     NOREF(pVBoxCore);
     1157    NOREF(pSolCore);
    11311158
    11321159    lwpsinfo_t *pThreadInfo = (lwpsinfo_t *)pvThreadInfo;
    11331160    CORELOG((CORELOG_NAME ":suspendThread %d\n", (lwpid_t)pThreadInfo->pr_lwpid));
    1134     if ((lwpid_t)pThreadInfo->pr_lwpid != pVBoxCore->VBoxProc.hCurThread)
     1161    if ((lwpid_t)pThreadInfo->pr_lwpid != pSolCore->SolProc.hCurThread)
    11351162        _lwp_suspend(pThreadInfo->pr_lwpid);
    11361163    return VINF_SUCCESS;
     
    11411168 * Callback for rtCoreDumperForEachThread to resume a thread.
    11421169 *
    1143  * @param pVBoxCore             Pointer to the core object.
     1170 * @param pSolCore              Pointer to the core object.
    11441171 * @param pvThreadInfo          Opaque pointer to thread information.
    11451172 *
    11461173 * @return IPRT status code.
    11471174 */
    1148 static int resumeThread(PVBOXCORE pVBoxCore, void *pvThreadInfo)
     1175static int resumeThread(PRTSOLCORE pSolCore, void *pvThreadInfo)
    11491176{
    11501177    AssertPtrReturn(pvThreadInfo, VERR_INVALID_POINTER);
    1151     NOREF(pVBoxCore);
     1178    NOREF(pSolCore);
    11521179
    11531180    lwpsinfo_t *pThreadInfo = (lwpsinfo_t *)pvThreadInfo;
    11541181    CORELOG((CORELOG_NAME ":resumeThread %d\n", (lwpid_t)pThreadInfo->pr_lwpid));
    1155     if ((lwpid_t)pThreadInfo->pr_lwpid != (lwpid_t)pVBoxCore->VBoxProc.hCurThread)
     1182    if ((lwpid_t)pThreadInfo->pr_lwpid != (lwpid_t)pSolCore->SolProc.hCurThread)
    11561183        _lwp_continue(pThreadInfo->pr_lwpid);
    11571184    return VINF_SUCCESS;
     
    11621189 * Calls a thread worker function for all threads in the process as described by /proc
    11631190 *
    1164  * @param pVBoxCore             Pointer to the core object.
     1191 * @param pSolCore              Pointer to the core object.
    11651192 * @param pcThreads             Number of threads read.
    11661193 * @param pfnWorker             Callback function for each thread.
     
    11681195 * @return IPRT status code.
    11691196 */
    1170 static int rtCoreDumperForEachThread(PVBOXCORE pVBoxCore,  uint64_t *pcThreads, PFNCORETHREADWORKER pfnWorker)
    1171 {
    1172     AssertPtrReturn(pVBoxCore, VERR_INVALID_POINTER);
    1173 
    1174     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     1197static int rtCoreDumperForEachThread(PRTSOLCORE pSolCore,  uint64_t *pcThreads, PFNRTSOLCORETHREADWORKER pfnWorker)
     1198{
     1199    AssertPtrReturn(pSolCore, VERR_INVALID_POINTER);
     1200
     1201    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    11751202
    11761203    /*
     
    11791206     */
    11801207    char szLpsInfoPath[PATH_MAX];
    1181     RTStrPrintf(szLpsInfoPath, sizeof(szLpsInfoPath), "/proc/%d/lpsinfo", (int)pVBoxProc->Process);
     1208    RTStrPrintf(szLpsInfoPath, sizeof(szLpsInfoPath), "/proc/%d/lpsinfo", (int)pSolProc->Process);
    11821209
    11831210    int rc = VINF_SUCCESS;
     
    11851212    if (fd >= 0)
    11861213    {
    1187         RTFILE hFile = (RTFILE)(uintptr_t)fd;
    1188         uint64_t u64Size;
    1189         RTFileGetSize(hFile, &u64Size);
    1190         size_t cbInfoHdrAndData = u64Size < ~(size_t)0 ? u64Size : ~(size_t)0;
    1191         void *pvInfoHdr = mmap(NULL, cbInfoHdrAndData, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1 /* fd */, 0 /* offset */);
     1214        size_t cbInfoHdrAndData = GetFileSizeByFd(fd);
     1215        void *pvInfoHdr = mmap(NULL, cbInfoHdrAndData, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON,
     1216                               -1 /* fd */, 0 /* offset */);
    11921217        if (pvInfoHdr != MAP_FAILED)
    11931218        {
    1194             rc = RTFileRead(hFile, pvInfoHdr, cbInfoHdrAndData, NULL);
     1219            rc = ReadFileNoIntr(fd, pvInfoHdr, cbInfoHdrAndData);
    11951220            if (RT_SUCCESS(rc))
    11961221            {
     
    11991224                for (long i = 0; i < pHeader->pr_nent; i++)
    12001225                {
    1201                     pfnWorker(pVBoxCore, pThreadInfo);
     1226                    pfnWorker(pSolCore, pThreadInfo);
    12021227                    pThreadInfo = (lwpsinfo_t *)((uintptr_t)pThreadInfo + pHeader->pr_entsize);
    12031228                }
     
    12101235        else
    12111236            rc = VERR_NO_MEMORY;
    1212         RTFileClose(hFile);
     1237        close(fd);
    12131238    }
    12141239    else
     
    12221247 * Resume all threads of this process.
    12231248 *
    1224  * @param pVBoxCore             Pointer to the core object.
     1249 * @param pSolCore              Pointer to the core object.
    12251250 *
    12261251 * @return IPRT status code..
    12271252 */
    1228 static int rtCoreDumperResumeThreads(PVBOXCORE pVBoxCore)
    1229 {
    1230     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
     1253static int rtCoreDumperResumeThreads(PRTSOLCORE pSolCore)
     1254{
     1255    AssertReturn(pSolCore, VERR_INVALID_POINTER);
    12311256
    12321257#if 1
    12331258    uint64_t cThreads;
    1234     return rtCoreDumperForEachThread(pVBoxCore, &cThreads, resumeThread);
     1259    return rtCoreDumperForEachThread(pSolCore, &cThreads, resumeThread);
    12351260#else
    1236     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     1261    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    12371262
    12381263    char szCurThread[128];
     
    12401265    PRTDIR pDir = NULL;
    12411266
    1242     RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/lwp", (int)pVBoxProc->Process);
    1243     RTStrPrintf(szCurThread, sizeof(szCurThread), "%d", (int)pVBoxProc->hCurThread);
     1267    RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/lwp", (int)pSolProc->Process);
     1268    RTStrPrintf(szCurThread, sizeof(szCurThread), "%d", (int)pSolProc->hCurThread);
    12441269
    12451270    int32_t cRunningThreads = 0;
     
    12811306 * Stop all running threads of this process except the current one.
    12821307 *
    1283  * @param pVBoxCore         Pointer to the core object.
     1308 * @param pSolCore          Pointer to the core object.
    12841309 *
    12851310 * @return IPRT status code.
    12861311 */
    1287 static int rtCoreDumperSuspendThreads(PVBOXCORE pVBoxCore)
    1288 {
    1289     AssertPtrReturn(pVBoxCore, VERR_INVALID_POINTER);
     1312static int rtCoreDumperSuspendThreads(PRTSOLCORE pSolCore)
     1313{
     1314    AssertPtrReturn(pSolCore, VERR_INVALID_POINTER);
    12901315
    12911316    /*
     
    13031328    for (cTries = 0; cTries < RT_ELEMENTS(aThreads); cTries++)
    13041329    {
    1305         rc = rtCoreDumperForEachThread(pVBoxCore, &aThreads[cTries], suspendThread);
     1330        rc = rtCoreDumperForEachThread(pSolCore, &aThreads[cTries], suspendThread);
    13061331        if (RT_FAILURE(rc))
    13071332            break;
     
    13151340    return rc;
    13161341#else
    1317     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     1342    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    13181343
    13191344    char szCurThread[128];
     
    13211346    PRTDIR pDir = NULL;
    13221347
    1323     RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/lwp", (int)pVBoxProc->Process);
    1324     RTStrPrintf(szCurThread, sizeof(szCurThread), "%d", (int)pVBoxProc->hCurThread);
     1348    RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/lwp", (int)pSolProc->Process);
     1349    RTStrPrintf(szCurThread, sizeof(szCurThread), "%d", (int)pSolProc->hCurThread);
    13251350
    13261351    int rc = -1;
     
    13911416 * Write an ELF NOTE header into the core file.
    13921417 *
    1393  * @param pVBoxCore         Pointer to the core object.
     1418 * @param pSolCore          Pointer to the core object.
    13941419 * @param Type              Type of this NOTE section.
    13951420 * @param pcv               Opaque pointer to the data, if NULL only computes size.
     
    13981423 * @return IPRT status code.
    13991424 */
    1400 static int ElfWriteNoteHeader(PVBOXCORE pVBoxCore, uint_t Type, const void *pcv, size_t cb)
    1401 {
    1402     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
     1425static int ElfWriteNoteHeader(PRTSOLCORE pSolCore, uint_t Type, const void *pcv, size_t cb)
     1426{
     1427    AssertReturn(pSolCore, VERR_INVALID_POINTER);
    14031428    AssertReturn(pcv, VERR_INVALID_POINTER);
    14041429    AssertReturn(cb > 0, VERR_NO_DATA);
    1405     AssertReturn(pVBoxCore->pfnWriter, VERR_WRITE_ERROR);
    1406     AssertReturn(pVBoxCore->hCoreFile, VERR_INVALID_HANDLE);
     1430    AssertReturn(pSolCore->pfnWriter, VERR_WRITE_ERROR);
     1431    AssertReturn(pSolCore->fdCoreFile >= 0, VERR_INVALID_HANDLE);
    14071432
    14081433    int rc = VERR_GENERAL_FAILURE;
     
    14281453     * Write note header and description.
    14291454     */
    1430     rc = pVBoxCore->pfnWriter(pVBoxCore->hCoreFile, &ElfNoteHdr, sizeof(ElfNoteHdr));
     1455    rc = pSolCore->pfnWriter(pSolCore->fdCoreFile, &ElfNoteHdr, sizeof(ElfNoteHdr));
    14311456    if (RT_SUCCESS(rc))
    14321457    {
    1433        rc = pVBoxCore->pfnWriter(pVBoxCore->hCoreFile, pcv, cb);
     1458       rc = pSolCore->pfnWriter(pSolCore->fdCoreFile, pcv, cb);
    14341459       if (RT_SUCCESS(rc))
    14351460       {
    14361461           if (cbAlign > cb)
    1437                rc = pVBoxCore->pfnWriter(pVBoxCore->hCoreFile, s_achPad, cbAlign - cb);
     1462               rc = pSolCore->pfnWriter(pSolCore->fdCoreFile, s_achPad, cbAlign - cb);
    14381463       }
    14391464    }
     
    14521477 * Solaris has two types of program header information (new and old).
    14531478 *
    1454  * @param pVBoxCore         Pointer to the core object.
     1479 * @param pSolCore          Pointer to the core object.
    14551480 * @param enmType           Type of core file information required.
    14561481 *
    14571482 * @return Size of NOTE section.
    14581483 */
    1459 static size_t ElfNoteSectionSize(PVBOXCORE pVBoxCore, VBOXSOLCORETYPE enmType)
    1460 {
    1461     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     1484static size_t ElfNoteSectionSize(PRTSOLCORE pSolCore, RTSOLCORETYPE enmType)
     1485{
     1486    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    14621487    size_t cb = 0;
    14631488    switch (enmType)
     
    14661491        {
    14671492            cb += ElfNoteHeaderSize(sizeof(prpsinfo_t));
    1468             cb += ElfNoteHeaderSize(pVBoxProc->cAuxVecs * sizeof(auxv_t));
    1469             cb += ElfNoteHeaderSize(strlen(pVBoxProc->szPlatform));
    1470 
    1471             PVBOXSOLTHREADINFO pThreadInfo = pVBoxProc->pThreadInfoHead;
     1493            cb += ElfNoteHeaderSize(pSolProc->cAuxVecs * sizeof(auxv_t));
     1494            cb += ElfNoteHeaderSize(strlen(pSolProc->szPlatform));
     1495
     1496            PRTSOLCORETHREADINFO pThreadInfo = pSolProc->pThreadInfoHead;
    14721497            while (pThreadInfo)
    14731498            {
     
    14871512            cb += ElfNoteHeaderSize(sizeof(psinfo_t));
    14881513            cb += ElfNoteHeaderSize(sizeof(pstatus_t));
    1489             cb += ElfNoteHeaderSize(pVBoxProc->cAuxVecs * sizeof(auxv_t));
    1490             cb += ElfNoteHeaderSize(strlen(pVBoxProc->szPlatform) + 1);
     1514            cb += ElfNoteHeaderSize(pSolProc->cAuxVecs * sizeof(auxv_t));
     1515            cb += ElfNoteHeaderSize(strlen(pSolProc->szPlatform) + 1);
    14911516            cb += ElfNoteHeaderSize(sizeof(struct utsname));
    14921517            cb += ElfNoteHeaderSize(sizeof(core_content_t));
    1493             cb += ElfNoteHeaderSize(pVBoxProc->cbCred);
    1494 
    1495             if (pVBoxProc->pPriv)
    1496                 cb += ElfNoteHeaderSize(PRIV_PRPRIV_SIZE(pVBoxProc->pPriv));   /* Ought to be same as cbPriv!? */
    1497 
    1498             if (pVBoxProc->pcPrivImpl)
    1499                 cb += ElfNoteHeaderSize(PRIV_IMPL_INFO_SIZE(pVBoxProc->pcPrivImpl));
    1500 
    1501             cb += ElfNoteHeaderSize(strlen(pVBoxProc->szZoneName) + 1);
    1502             if (pVBoxProc->cbLdt > 0)
    1503                 cb += ElfNoteHeaderSize(pVBoxProc->cbLdt);
    1504 
    1505             PVBOXSOLTHREADINFO pThreadInfo = pVBoxProc->pThreadInfoHead;
     1518            cb += ElfNoteHeaderSize(pSolProc->cbCred);
     1519
     1520            if (pSolProc->pPriv)
     1521                cb += ElfNoteHeaderSize(PRIV_PRPRIV_SIZE(pSolProc->pPriv));   /* Ought to be same as cbPriv!? */
     1522
     1523            if (pSolProc->pcPrivImpl)
     1524                cb += ElfNoteHeaderSize(PRIV_IMPL_INFO_SIZE(pSolProc->pcPrivImpl));
     1525
     1526            cb += ElfNoteHeaderSize(strlen(pSolProc->szZoneName) + 1);
     1527            if (pSolProc->cbLdt > 0)
     1528                cb += ElfNoteHeaderSize(pSolProc->cbLdt);
     1529
     1530            PRTSOLCORETHREADINFO pThreadInfo = pSolProc->pThreadInfoHead;
    15061531            while (pThreadInfo)
    15071532            {
     
    15311556 * Solaris has two types of program  header information (new and old).
    15321557 *
    1533  * @param pVBoxCore         Pointer to the core object.
     1558 * @param pSolCore          Pointer to the core object.
    15341559 * @param enmType           Type of core file information required.
    15351560 *
    15361561 * @return IPRT status code.
    15371562 */
    1538 static int ElfWriteNoteSection(PVBOXCORE pVBoxCore, VBOXSOLCORETYPE enmType)
    1539 {
    1540     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    1541 
    1542     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     1563static int ElfWriteNoteSection(PRTSOLCORE pSolCore, RTSOLCORETYPE enmType)
     1564{
     1565    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     1566
     1567    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    15431568    int rc = VERR_GENERAL_FAILURE;
    15441569
    15451570#ifdef RT_OS_SOLARIS
    1546     typedef int (*PFNELFWRITENOTEHDR)(PVBOXCORE pVBoxCore, uint_t, const void *pcv, size_t cb);
     1571    typedef int (*PFNELFWRITENOTEHDR)(PRTSOLCORE pSolCore, uint_t, const void *pcv, size_t cb);
    15471572    typedef struct ELFWRITENOTE
    15481573    {
     
    15591584            ELFWRITENOTE aElfNotes[] =
    15601585            {
    1561                 { "NT_PRPSINFO", NT_PRPSINFO, &pVBoxProc->ProcInfoOld,  sizeof(prpsinfo_t) },
    1562                 { "NT_AUXV",     NT_AUXV,      pVBoxProc->pAuxVecs,      pVBoxProc->cAuxVecs * sizeof(auxv_t) },
    1563                 { "NT_PLATFORM", NT_PLATFORM,  pVBoxProc->szPlatform,    strlen(pVBoxProc->szPlatform) + 1 }
     1586                { "NT_PRPSINFO", NT_PRPSINFO, &pSolProc->ProcInfoOld,  sizeof(prpsinfo_t) },
     1587                { "NT_AUXV",     NT_AUXV,      pSolProc->pAuxVecs,      pSolProc->cAuxVecs * sizeof(auxv_t) },
     1588                { "NT_PLATFORM", NT_PLATFORM,  pSolProc->szPlatform,    strlen(pSolProc->szPlatform) + 1 }
    15641589            };
    15651590
    15661591            for (unsigned i = 0; i < RT_ELEMENTS(aElfNotes); i++)
    15671592            {
    1568                 rc = ElfWriteNoteHeader(pVBoxCore, aElfNotes[i].Type, aElfNotes[i].pcv, aElfNotes[i].cb);
     1593                rc = ElfWriteNoteHeader(pSolCore, aElfNotes[i].Type, aElfNotes[i].pcv, aElfNotes[i].cb);
    15691594                if (RT_FAILURE(rc))
    15701595                {
     
    15781603             * so we just skip if there is no status information for them.
    15791604             */
    1580             PVBOXSOLTHREADINFO pThreadInfo = pVBoxProc->pThreadInfoHead;
     1605            PRTSOLCORETHREADINFO pThreadInfo = pSolProc->pThreadInfoHead;
    15811606            for (; pThreadInfo; pThreadInfo = pThreadInfo->pNext)
    15821607            {
     
    15851610
    15861611                prstatus_t OldProcessStatus;
    1587                 GetOldProcessStatus(pVBoxCore, &pThreadInfo->Info, pThreadInfo->pStatus, &OldProcessStatus);
    1588                 rc = ElfWriteNoteHeader(pVBoxCore, NT_PRSTATUS, &OldProcessStatus, sizeof(prstatus_t));
     1612                GetOldProcessStatus(pSolCore, &pThreadInfo->Info, pThreadInfo->pStatus, &OldProcessStatus);
     1613                rc = ElfWriteNoteHeader(pSolCore, NT_PRSTATUS, &OldProcessStatus, sizeof(prstatus_t));
    15891614                if (RT_SUCCESS(rc))
    15901615                {
    1591                     rc = ElfWriteNoteHeader(pVBoxCore, NT_PRFPREG, &pThreadInfo->pStatus->pr_fpreg, sizeof(prfpregset_t));
     1616                    rc = ElfWriteNoteHeader(pSolCore, NT_PRFPREG, &pThreadInfo->pStatus->pr_fpreg, sizeof(prfpregset_t));
    15921617                    if (RT_FAILURE(rc))
    15931618                    {
     
    16091634            ELFWRITENOTE aElfNotes[] =
    16101635            {
    1611                 { "NT_PSINFO",     NT_PSINFO,     &pVBoxProc->ProcInfo,     sizeof(psinfo_t) },
    1612                 { "NT_PSTATUS",    NT_PSTATUS,    &pVBoxProc->ProcStatus,   sizeof(pstatus_t) },
    1613                 { "NT_AUXV",       NT_AUXV,        pVBoxProc->pAuxVecs,     pVBoxProc->cAuxVecs * sizeof(auxv_t) },
    1614                 { "NT_PLATFORM",   NT_PLATFORM,    pVBoxProc->szPlatform,   strlen(pVBoxProc->szPlatform) + 1 },
    1615                 { "NT_UTSNAME",    NT_UTSNAME,    &pVBoxProc->UtsName,      sizeof(struct utsname) },
    1616                 { "NT_CONTENT",    NT_CONTENT,    &pVBoxProc->CoreContent,  sizeof(core_content_t) },
    1617                 { "NT_PRCRED",     NT_PRCRED,      pVBoxProc->pvCred,       pVBoxProc->cbCred },
    1618                 { "NT_PRPRIV",     NT_PRPRIV,      pVBoxProc->pPriv,        PRIV_PRPRIV_SIZE(pVBoxProc->pPriv) },
    1619                 { "NT_PRPRIVINFO", NT_PRPRIVINFO,  pVBoxProc->pcPrivImpl,   PRIV_IMPL_INFO_SIZE(pVBoxProc->pcPrivImpl) },
    1620                 { "NT_ZONENAME",   NT_ZONENAME,    pVBoxProc->szZoneName,   strlen(pVBoxProc->szZoneName) + 1 }
     1636                { "NT_PSINFO",     NT_PSINFO,     &pSolProc->ProcInfo,     sizeof(psinfo_t) },
     1637                { "NT_PSTATUS",    NT_PSTATUS,    &pSolProc->ProcStatus,   sizeof(pstatus_t) },
     1638                { "NT_AUXV",       NT_AUXV,        pSolProc->pAuxVecs,     pSolProc->cAuxVecs * sizeof(auxv_t) },
     1639                { "NT_PLATFORM",   NT_PLATFORM,    pSolProc->szPlatform,   strlen(pSolProc->szPlatform) + 1 },
     1640                { "NT_UTSNAME",    NT_UTSNAME,    &pSolProc->UtsName,      sizeof(struct utsname) },
     1641                { "NT_CONTENT",    NT_CONTENT,    &pSolProc->CoreContent,  sizeof(core_content_t) },
     1642                { "NT_PRCRED",     NT_PRCRED,      pSolProc->pvCred,       pSolProc->cbCred },
     1643                { "NT_PRPRIV",     NT_PRPRIV,      pSolProc->pPriv,        PRIV_PRPRIV_SIZE(pSolProc->pPriv) },
     1644                { "NT_PRPRIVINFO", NT_PRPRIVINFO,  pSolProc->pcPrivImpl,   PRIV_IMPL_INFO_SIZE(pSolProc->pcPrivImpl) },
     1645                { "NT_ZONENAME",   NT_ZONENAME,    pSolProc->szZoneName,   strlen(pSolProc->szZoneName) + 1 }
    16211646            };
    16221647
    16231648            for (unsigned i = 0; i < RT_ELEMENTS(aElfNotes); i++)
    16241649            {
    1625                 rc = ElfWriteNoteHeader(pVBoxCore, aElfNotes[i].Type, aElfNotes[i].pcv, aElfNotes[i].cb);
     1650                rc = ElfWriteNoteHeader(pSolCore, aElfNotes[i].Type, aElfNotes[i].pcv, aElfNotes[i].cb);
    16261651                if (RT_FAILURE(rc))
    16271652                {
     
    16351660             * we only dump the lwpsinfo_t in that case.
    16361661             */
    1637             PVBOXSOLTHREADINFO pThreadInfo = pVBoxProc->pThreadInfoHead;
     1662            PRTSOLCORETHREADINFO pThreadInfo = pSolProc->pThreadInfoHead;
    16381663            for (; pThreadInfo; pThreadInfo = pThreadInfo->pNext)
    16391664            {
    1640                 rc = ElfWriteNoteHeader(pVBoxCore, NT_LWPSINFO, &pThreadInfo->Info, sizeof(lwpsinfo_t));
     1665                rc = ElfWriteNoteHeader(pSolCore, NT_LWPSINFO, &pThreadInfo->Info, sizeof(lwpsinfo_t));
    16411666                if (RT_FAILURE(rc))
    16421667                {
     
    16471672                if (pThreadInfo->pStatus)
    16481673                {
    1649                     rc = ElfWriteNoteHeader(pVBoxCore, NT_LWPSTATUS, pThreadInfo->pStatus, sizeof(lwpstatus_t));
     1674                    rc = ElfWriteNoteHeader(pSolCore, NT_LWPSTATUS, pThreadInfo->pStatus, sizeof(lwpstatus_t));
    16501675                    if (RT_FAILURE(rc))
    16511676                    {
     
    16751700 * Write mappings into the core file.
    16761701 *
    1677  * @param pVBoxCore         Pointer to the core object.
     1702 * @param pSolCore          Pointer to the core object.
    16781703 *
    16791704 * @return IPRT status code.
    16801705 */
    1681 static int ElfWriteMappings(PVBOXCORE pVBoxCore)
    1682 {
    1683     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     1706static int ElfWriteMappings(PRTSOLCORE pSolCore)
     1707{
     1708    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    16841709
    16851710    int rc = VERR_GENERAL_FAILURE;
    1686     PVBOXSOLMAPINFO pMapInfo = pVBoxProc->pMapInfoHead;
     1711    PRTSOLCOREMAPINFO pMapInfo = pSolProc->pMapInfoHead;
    16871712    while (pMapInfo)
    16881713    {
     
    16941719            {
    16951720                size_t cb = RT_MIN(sizeof(achBuf), pMapInfo->pMap.pr_size - k);
    1696                 int rc2 = ProcReadAddrSpace(pVBoxProc, pMapInfo->pMap.pr_vaddr + k, &achBuf, cb);
     1721                int rc2 = ProcReadAddrSpace(pSolProc, pMapInfo->pMap.pr_vaddr + k, &achBuf, cb);
    16971722                if (RT_FAILURE(rc2))
    16981723                {
     
    17011726                }
    17021727
    1703                 rc = pVBoxCore->pfnWriter(pVBoxCore->hCoreFile, achBuf, sizeof(achBuf));
     1728                rc = pSolCore->pfnWriter(pSolCore->fdCoreFile, achBuf, sizeof(achBuf));
    17041729                if (RT_FAILURE(rc))
    17051730                {
     
    17171742            if (sizeof(achBuf) != pMapInfo->pMap.pr_size)
    17181743                CORELOGRELSYS((CORELOG_NAME "ElfWriteMappings: Huh!? something is wrong!\n"));
    1719             rc = pVBoxCore->pfnWriter(pVBoxCore->hCoreFile, &achBuf, sizeof(achBuf));
     1744            rc = pSolCore->pfnWriter(pSolCore->fdCoreFile, &achBuf, sizeof(achBuf));
    17201745            if (RT_FAILURE(rc))
    17211746            {
     
    17351760 * Write program headers for all mappings into the core file.
    17361761 *
    1737  * @param pVBoxCore         Pointer to the core object.
     1762 * @param pSolCore          Pointer to the core object.
    17381763 *
    17391764 * @return IPRT status code.
    17401765 */
    1741 static int ElfWriteMappingHeaders(PVBOXCORE pVBoxCore)
    1742 {
    1743     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    1744 
    1745     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     1766static int ElfWriteMappingHeaders(PRTSOLCORE pSolCore)
     1767{
     1768    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     1769
     1770    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    17461771    Elf_Phdr ProgHdr;
    17471772    RT_ZERO(ProgHdr);
     
    17491774
    17501775    int rc = VERR_GENERAL_FAILURE;
    1751     PVBOXSOLMAPINFO pMapInfo = pVBoxProc->pMapInfoHead;
     1776    PRTSOLCOREMAPINFO pMapInfo = pSolProc->pMapInfoHead;
    17521777    while (pMapInfo)
    17531778    {
    17541779        ProgHdr.p_vaddr  = pMapInfo->pMap.pr_vaddr;     /* Virtual address of this mapping in the process address space */
    1755         ProgHdr.p_offset = pVBoxCore->offWrite;         /* Where this mapping is located in the core file */
     1780        ProgHdr.p_offset = pSolCore->offWrite;         /* Where this mapping is located in the core file */
    17561781        ProgHdr.p_memsz  = pMapInfo->pMap.pr_size;      /* Size of the memory image of the mapping */
    17571782        ProgHdr.p_filesz = pMapInfo->pMap.pr_size;      /* Size of the file image of the mapping */
     
    17681793            ProgHdr.p_flags |= PF_SUNW_FAILURE;
    17691794
    1770         rc = pVBoxCore->pfnWriter(pVBoxCore->hCoreFile, &ProgHdr, sizeof(ProgHdr));
     1795        rc = pSolCore->pfnWriter(pSolCore->fdCoreFile, &ProgHdr, sizeof(ProgHdr));
    17711796        if (RT_FAILURE(rc))
    17721797        {
     
    17751800        }
    17761801
    1777         pVBoxCore->offWrite += ProgHdr.p_filesz;
     1802        pSolCore->offWrite += ProgHdr.p_filesz;
    17781803        pMapInfo = pMapInfo->pNext;
    17791804    }
     
    17861811 * to be in suspended state (i.e. called after CreateCore).
    17871812 *
    1788  * @param pVBoxCore         Pointer to the core object.
     1813 * @param pSolCore          Pointer to the core object.
    17891814 * @param pfnWriter         Pointer to the writer function to override default writer (NULL uses default).
    17901815 *
    17911816 * @remarks Resumes all suspended threads, unless it's an invalid core. This
    17921817 *          function must be called only -after- rtCoreDumperCreateCore().
    1793  * @return VBox status.
    1794  */
    1795 static int rtCoreDumperWriteCore(PVBOXCORE pVBoxCore, PFNCOREWRITER pfnWriter)
    1796 {
    1797     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    1798 
    1799     if (!pVBoxCore->fIsValid)
     1818 * @return IPRT status.
     1819 */
     1820static int rtCoreDumperWriteCore(PRTSOLCORE pSolCore, PFNRTCOREWRITER pfnWriter)
     1821{
     1822    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     1823
     1824    if (!pSolCore->fIsValid)
    18001825        return VERR_INVALID_STATE;
    18011826
    18021827    if (pfnWriter)
    1803         pVBoxCore->pfnWriter = pfnWriter;
    1804 
    1805     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
     1828        pSolCore->pfnWriter = pfnWriter;
     1829
     1830    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    18061831    char szPath[PATH_MAX];
    18071832    int rc = VINF_SUCCESS;
     
    18101835     * Open the process address space file.
    18111836     */
    1812     RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/as", (int)pVBoxProc->Process);
     1837    RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/as", (int)pSolProc->Process);
    18131838    int fd = open(szPath, O_RDONLY);
    18141839    if (fd < 0)
     
    18191844    }
    18201845
    1821     pVBoxProc->hAs = (RTFILE)(uintptr_t)fd;
     1846    pSolProc->fdAs = fd;
    18221847
    18231848    /*
    18241849     * Create the core file.
    18251850     */
    1826     fd = open(pVBoxCore->szCorePath, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR);
     1851    fd = open(pSolCore->szCorePath, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR);
    18271852    if (fd < 0)
    18281853    {
    18291854        rc = RTErrConvertFromErrno(fd);
    1830         CORELOGRELSYS((CORELOG_NAME "WriteCore: failed to open %s. rc=%Rrc\n", pVBoxCore->szCorePath, rc));
     1855        CORELOGRELSYS((CORELOG_NAME "WriteCore: failed to open %s. rc=%Rrc\n", pSolCore->szCorePath, rc));
    18311856        goto WriteCoreDone;
    18321857    }
    18331858
    1834     pVBoxCore->hCoreFile = (RTFILE)(uintptr_t)fd;
    1835 
    1836     pVBoxCore->offWrite = 0;
    1837     uint32_t cProgHdrs  = pVBoxProc->cMappings + 2; /* two PT_NOTE program headers (old, new style) */
     1859    pSolCore->fdCoreFile = fd;
     1860
     1861    pSolCore->offWrite = 0;
     1862    uint32_t cProgHdrs  = pSolProc->cMappings + 2; /* two PT_NOTE program headers (old, new style) */
    18381863
    18391864    /*
     
    18641889    ElfHdr.e_phentsize       = sizeof(Elf_Phdr);
    18651890    ElfHdr.e_shentsize       = sizeof(Elf_Shdr);
    1866     rc = pVBoxCore->pfnWriter(pVBoxCore->hCoreFile, &ElfHdr, sizeof(ElfHdr));
     1891    rc = pSolCore->pfnWriter(pSolCore->fdCoreFile, &ElfHdr, sizeof(ElfHdr));
    18671892    if (RT_FAILURE(rc))
    18681893    {
     
    18821907     * Write old-style NOTE program header.
    18831908     */
    1884     pVBoxCore->offWrite += sizeof(ElfHdr) + cProgHdrs * sizeof(ProgHdr);
    1885     ProgHdr.p_offset = pVBoxCore->offWrite;
    1886     ProgHdr.p_filesz = ElfNoteSectionSize(pVBoxCore, enmOldEra);
    1887     rc = pVBoxCore->pfnWriter(pVBoxCore->hCoreFile, &ProgHdr, sizeof(ProgHdr));
     1909    pSolCore->offWrite += sizeof(ElfHdr) + cProgHdrs * sizeof(ProgHdr);
     1910    ProgHdr.p_offset = pSolCore->offWrite;
     1911    ProgHdr.p_filesz = ElfNoteSectionSize(pSolCore, enmOldEra);
     1912    rc = pSolCore->pfnWriter(pSolCore->fdCoreFile, &ProgHdr, sizeof(ProgHdr));
    18881913    if (RT_FAILURE(rc))
    18891914    {
     
    18951920     * Write new-style NOTE program header.
    18961921     */
    1897     pVBoxCore->offWrite += ProgHdr.p_filesz;
    1898     ProgHdr.p_offset = pVBoxCore->offWrite;
    1899     ProgHdr.p_filesz = ElfNoteSectionSize(pVBoxCore, enmNewEra);
    1900     rc = pVBoxCore->pfnWriter(pVBoxCore->hCoreFile, &ProgHdr, sizeof(ProgHdr));
     1922    pSolCore->offWrite += ProgHdr.p_filesz;
     1923    ProgHdr.p_offset = pSolCore->offWrite;
     1924    ProgHdr.p_filesz = ElfNoteSectionSize(pSolCore, enmNewEra);
     1925    rc = pSolCore->pfnWriter(pSolCore->fdCoreFile, &ProgHdr, sizeof(ProgHdr));
    19011926    if (RT_FAILURE(rc))
    19021927    {
     
    19081933     * Write program headers per mapping.
    19091934     */
    1910     pVBoxCore->offWrite += ProgHdr.p_filesz;
    1911     rc = ElfWriteMappingHeaders(pVBoxCore);
     1935    pSolCore->offWrite += ProgHdr.p_filesz;
     1936    rc = ElfWriteMappingHeaders(pSolCore);
    19121937    if (RT_FAILURE(rc))
    19131938    {
     
    19191944     * Write old-style note section.
    19201945     */
    1921     rc = ElfWriteNoteSection(pVBoxCore, enmOldEra);
     1946    rc = ElfWriteNoteSection(pSolCore, enmOldEra);
    19221947    if (RT_FAILURE(rc))
    19231948    {
     
    19291954     * Write new-style section.
    19301955     */
    1931     rc = ElfWriteNoteSection(pVBoxCore, enmNewEra);
     1956    rc = ElfWriteNoteSection(pSolCore, enmNewEra);
    19321957    if (RT_FAILURE(rc))
    19331958    {
     
    19391964     * Write all mappings.
    19401965     */
    1941     rc = ElfWriteMappings(pVBoxCore);
     1966    rc = ElfWriteMappings(pSolCore);
    19421967    if (RT_FAILURE(rc))
    19431968    {
     
    19481973
    19491974WriteCoreDone:
    1950     if (pVBoxCore->hCoreFile != NIL_RTFILE)     /* Initialized in rtCoreDumperCreateCore() */
    1951     {
    1952         RTFileClose(pVBoxCore->hCoreFile);
    1953         pVBoxCore->hCoreFile = NIL_RTFILE;
    1954     }
    1955 
    1956     if (pVBoxProc->hAs != NIL_RTFILE)           /* Initialized in rtCoreDumperCreateCore() */
    1957     {
    1958         RTFileClose(pVBoxProc->hAs);
    1959         pVBoxProc->hAs = NIL_RTFILE;
    1960     }
    1961 
    1962     rtCoreDumperResumeThreads(pVBoxCore);
     1975    if (pSolCore->fdCoreFile != -1)     /* Initialized in rtCoreDumperCreateCore() */
     1976    {
     1977        close(pSolCore->fdCoreFile);
     1978        pSolCore->fdCoreFile = -1;
     1979    }
     1980
     1981    if (pSolProc->fdAs != -1)           /* Initialized in rtCoreDumperCreateCore() */
     1982    {
     1983        close(pSolProc->fdAs);
     1984        pSolProc->fdAs = -1;
     1985    }
     1986
     1987    rtCoreDumperResumeThreads(pSolCore);
    19631988    return rc;
    19641989}
     
    19701995 * are ultimately resumed en-masse) already suspended while calling this function.
    19711996 *
    1972  * @param pVBoxCore         Pointer to a core object.
     1997 * @param pSolCore          Pointer to a core object.
    19731998 * @param pContext          Pointer to the caller context thread.
    19741999 * @param pszCoreFilePath   Path to the core file. If NULL is passed, the global
     
    19782003 * @return IPRT status code.
    19792004 */
    1980 static int rtCoreDumperCreateCore(PVBOXCORE pVBoxCore, ucontext_t *pContext, const char *pszCoreFilePath)
    1981 {
    1982     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
     2005static int rtCoreDumperCreateCore(PRTSOLCORE pSolCore, ucontext_t *pContext, const char *pszCoreFilePath)
     2006{
     2007    AssertReturn(pSolCore, VERR_INVALID_POINTER);
    19832008    AssertReturn(pContext, VERR_INVALID_POINTER);
    19842009
     
    19862011     * Initialize core structures.
    19872012     */
    1988     memset(pVBoxCore, 0, sizeof(VBOXCORE));
    1989     pVBoxCore->pfnReader = &ReadFileNoIntr;
    1990     pVBoxCore->pfnWriter = &WriteFileNoIntr;
    1991     pVBoxCore->fIsValid  = false;
    1992     pVBoxCore->hCoreFile = NIL_RTFILE;
    1993 
    1994     PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc;
    1995     pVBoxProc->Process        = RTProcSelf();
    1996     pVBoxProc->hCurThread     = _lwp_self(); /* thr_self() */
    1997     pVBoxProc->hAs            = NIL_RTFILE;
    1998     pVBoxProc->pCurThreadCtx  = pContext;
    1999     pVBoxProc->CoreContent    = CC_CONTENT_DEFAULT;
    2000 
    2001     RTProcGetExecutablePath(pVBoxProc->szExecPath, sizeof(pVBoxProc->szExecPath));  /* this gets full path not just name */
    2002     pVBoxProc->pszExecName = RTPathFilename(pVBoxProc->szExecPath);
     2013    memset(pSolCore, 0, sizeof(RTSOLCORE));
     2014    pSolCore->pfnReader = &ReadFileNoIntr;
     2015    pSolCore->pfnWriter = &WriteFileNoIntr;
     2016    pSolCore->fIsValid  = false;
     2017    pSolCore->fdCoreFile = -1;
     2018
     2019    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
     2020    pSolProc->Process        = RTProcSelf();
     2021    pSolProc->hCurThread     = _lwp_self(); /* thr_self() */
     2022    pSolProc->fdAs           = -1;
     2023    pSolProc->pCurThreadCtx  = pContext;
     2024    pSolProc->CoreContent    = CC_CONTENT_DEFAULT;
     2025
     2026    RTProcGetExecutablePath(pSolProc->szExecPath, sizeof(pSolProc->szExecPath));  /* this gets full path not just name */
     2027    pSolProc->pszExecName = RTPathFilename(pSolProc->szExecPath);
    20032028
    20042029    /*
     
    20162041        {
    20172042            /* We cannot call RTPathAbs*() as they call getcwd() which calls malloc. */
    2018             RTStrPrintf(pVBoxCore->szCorePath, sizeof(pVBoxCore->szCorePath), "%s/core.vb.%s.%d",
    2019                         g_szCoreDumpDir, pVBoxProc->pszExecName, (int)pVBoxProc->Process);
     2043            RTStrPrintf(pSolCore->szCorePath, sizeof(pSolCore->szCorePath), "%s/core.vb.%s.%d",
     2044                        g_szCoreDumpDir, pSolProc->pszExecName, (int)pSolProc->Process);
    20202045        }
    20212046        else
    2022             RTStrPrintf(pVBoxCore->szCorePath, sizeof(pVBoxCore->szCorePath), "%s/core.vb.%s", g_szCoreDumpDir, g_szCoreDumpFile);
     2047            RTStrPrintf(pSolCore->szCorePath, sizeof(pSolCore->szCorePath), "%s/core.vb.%s", g_szCoreDumpDir, g_szCoreDumpFile);
    20232048    }
    20242049    else
    2025         RTStrCopy(pVBoxCore->szCorePath, sizeof(pVBoxCore->szCorePath), pszCoreFilePath);
    2026 
    2027     CORELOG((CORELOG_NAME  "CreateCore: Taking Core %s from Thread %d\n", pVBoxCore->szCorePath, (int)pVBoxProc->hCurThread));
     2050        RTStrCopy(pSolCore->szCorePath, sizeof(pSolCore->szCorePath), pszCoreFilePath);
     2051
     2052    CORELOG((CORELOG_NAME  "CreateCore: Taking Core %s from Thread %d\n", pSolCore->szCorePath, (int)pSolProc->hCurThread));
    20282053
    20292054    /*
    20302055     * Quiesce the process.
    20312056     */
    2032     int rc = rtCoreDumperSuspendThreads(pVBoxCore);
     2057    int rc = rtCoreDumperSuspendThreads(pSolCore);
    20332058    if (RT_SUCCESS(rc))
    20342059    {
    2035         rc = ProcReadInfo(pVBoxCore);
     2060        rc = ProcReadInfo(pSolCore);
    20362061        if (RT_SUCCESS(rc))
    20372062        {
    2038             GetOldProcessInfo(pVBoxCore, &pVBoxProc->ProcInfoOld);
    2039             if (IsProcessArchNative(pVBoxProc))
     2063            GetOldProcessInfo(pSolCore, &pSolProc->ProcInfoOld);
     2064            if (IsProcessArchNative(pSolProc))
    20402065            {
    20412066                /*
    20422067                 * Read process status, information such as number of active LWPs will be invalid since we just quiesced the process.
    20432068                 */
    2044                 rc = ProcReadStatus(pVBoxCore);
     2069                rc = ProcReadStatus(pSolCore);
    20452070                if (RT_SUCCESS(rc))
    20462071                {
    2047                     rc = AllocMemoryArea(pVBoxCore);
     2072                    rc = AllocMemoryArea(pSolCore);
    20482073                    if (RT_SUCCESS(rc))
    20492074                    {
     
    20512076                        {
    20522077                            const char        *pszName;
    2053                             PFNCOREACCUMULATOR pfnAcc;
     2078                            PFNRTSOLCOREACCUMULATOR pfnAcc;
    20542079                            bool               fOptional;
    20552080                        } aAccumulators[] =
     
    20662091                        for (unsigned i = 0; i < RT_ELEMENTS(aAccumulators); i++)
    20672092                        {
    2068                             rc = aAccumulators[i].pfnAcc(pVBoxCore);
     2093                            rc = aAccumulators[i].pfnAcc(pSolCore);
    20692094                            if (RT_FAILURE(rc))
    20702095                            {
     
    20772102                        if (RT_SUCCESS(rc))
    20782103                        {
    2079                             pVBoxCore->fIsValid = true;
     2104                            pSolCore->fIsValid = true;
    20802105                            return VINF_SUCCESS;
    20812106                        }
    20822107
    2083                         FreeMemoryArea(pVBoxCore);
     2108                        FreeMemoryArea(pSolCore);
    20842109                    }
    20852110                    else
     
    21012126         * Resume threads on failure.
    21022127         */
    2103         rtCoreDumperResumeThreads(pVBoxCore);
     2128        rtCoreDumperResumeThreads(pSolCore);
    21042129    }
    21052130    else
     
    21132138 * Destroy an existing core object.
    21142139 *
    2115  * @param pVBoxCore         Pointer to the core object.
     2140 * @param pSolCore          Pointer to the core object.
    21162141 *
    21172142 * @return IPRT status code.
    21182143 */
    2119 static int rtCoreDumperDestroyCore(PVBOXCORE pVBoxCore)
    2120 {
    2121     AssertReturn(pVBoxCore, VERR_INVALID_POINTER);
    2122     if (!pVBoxCore->fIsValid)
     2144static int rtCoreDumperDestroyCore(PRTSOLCORE pSolCore)
     2145{
     2146    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     2147    if (!pSolCore->fIsValid)
    21232148        return VERR_INVALID_STATE;
    21242149
    2125     FreeMemoryArea(pVBoxCore);
    2126     pVBoxCore->fIsValid = false;
     2150    FreeMemoryArea(pSolCore);
     2151    pSolCore->fIsValid = false;
    21272152    return VINF_SUCCESS;
    21282153}
     
    21522177     * Any errors would resume all threads if they were halted.
    21532178     */
    2154     VBOXCORE VBoxCore;
    2155     RT_ZERO(VBoxCore);
    2156     int rc = rtCoreDumperCreateCore(&VBoxCore, pContext, pszOutputFile);
     2179    RTSOLCORE SolCore;
     2180    RT_ZERO(SolCore);
     2181    int rc = rtCoreDumperCreateCore(&SolCore, pContext, pszOutputFile);
    21572182    if (RT_SUCCESS(rc))
    21582183    {
    2159         rc = rtCoreDumperWriteCore(&VBoxCore, &WriteFileNoIntr);
     2184        rc = rtCoreDumperWriteCore(&SolCore, &WriteFileNoIntr);
    21602185        if (RT_SUCCESS(rc))
    2161             CORELOGRELSYS((CORELOG_NAME "Core dumped in %s\n", VBoxCore.szCorePath));
     2186            CORELOGRELSYS((CORELOG_NAME "Core dumped in %s\n", SolCore.szCorePath));
    21622187        else
    2163             CORELOGRELSYS((CORELOG_NAME "TakeDump: WriteCore failed. szCorePath=%s rc=%Rrc\n", VBoxCore.szCorePath, rc));
    2164 
    2165         rtCoreDumperDestroyCore(&VBoxCore);
     2188            CORELOGRELSYS((CORELOG_NAME "TakeDump: WriteCore failed. szCorePath=%s rc=%Rrc\n", SolCore.szCorePath, rc));
     2189
     2190        rtCoreDumperDestroyCore(&SolCore);
    21662191    }
    21672192    else
  • trunk/src/VBox/Runtime/r3/solaris/coredumper-solaris.h

    r31980 r37631  
    11/* $Id$ */
    22/** @file
    3  * IPRT Testcase - Core dump, header.
     3 * IPRT - Custom Core Dumper, Solaris.
    44 */
    55
    66/*
    7  * Copyright (C) 2010 Oracle Corporation
     7 * Copyright (C) 2010-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2525 */
    2626
    27 #include <iprt/process.h>
    28 #include <iprt/file.h>
     27#include <iprt/types.h>
    2928
    3029#ifdef RT_OS_SOLARIS
     
    6261#ifdef RT_OS_SOLARIS
    6362/**
    64  * VBOXSOLMAPINFO: Memory mapping description.
     63 * Memory mapping descriptor employed by the solaris core dumper.
    6564 */
    66 typedef struct VBOXSOLMAPINFO
     65typedef struct RTSOLCOREMAPINFO
    6766{
    68     prmap_t                         pMap;                       /* Proc description of this mapping */
    69     int                             fError;                     /* Any error reading this mapping (errno) */
    70     struct VBOXSOLMAPINFO          *pNext;                      /* Pointer to the next mapping */
    71 } VBOXSOLMAPINFO;
    72 typedef VBOXSOLMAPINFO *PVBOXSOLMAPINFO;
     67    prmap_t                         pMap;                       /**< Proc description of this mapping */
     68    int                             fError;                     /**< Any error reading this mapping (errno) */
     69    struct RTSOLCOREMAPINFO            *pNext;                      /**< Pointer to the next mapping */
     70} RTSOLCOREMAPINFO;
     71/** Pointer to a solaris memory mapping descriptor. */
     72typedef RTSOLCOREMAPINFO *PRTSOLCOREMAPINFO;
    7373
    7474/**
    75  * VBOXSOLCORETYPE: Whether this is an old or new style core.
     75 * Whether this is an old or new style solaris core.
    7676 */
    77 typedef enum VBOXSOLCORETYPE
     77typedef enum RTSOLCORETYPE
    7878{
    79     enmOldEra       = 0x01d,        /* old */
    80     enmNewEra       = 0x5c1f1       /* sci-fi */
    81 } VBOXSOLCORETYPE;
     79    enmOldEra = 0x01d,   /**< old */
     80    enmNewEra = 0x5c1f1  /**< sci-fi */
     81} RTSOLCORETYPE;
    8282
    8383/**
    84  * VBOXSOLTHREADINFO: Per-Thread information.
     84 * Per-Thread information employed by the solaris core dumper.
    8585 */
    86 typedef struct VBOXSOLTHREADINFO
     86typedef struct RTSOLCORETHREADINFO
    8787{
    88     lwpsinfo_t                      Info;                       /* Proc description of this thread */
    89     lwpstatus_t                    *pStatus;                    /* Proc description of this thread's status (can be NULL, zombie lwp) */
    90     struct VBOXSOLTHREADINFO       *pNext;                      /* Pointer to the next thread */
    91 } VBOXSOLTHREADINFO;
    92 typedef VBOXSOLTHREADINFO *PVBOXSOLTHREADINFO;
     88    lwpsinfo_t                      Info;                       /**< Proc description of this thread */
     89    lwpstatus_t                    *pStatus;                    /**< Proc description of this thread's status (can be NULL, zombie lwp) */
     90    struct RTSOLCORETHREADINFO     *pNext;                      /**< Pointer to the next thread */
     91} RTSOLCORETHREADINFO;
     92typedef RTSOLCORETHREADINFO *PRTSOLCORETHREADINFO;
    9393#endif
    9494
    9595
    9696/**
    97  * VBOXPROCESS: Current (also the core target) process information.
     97 * Current (also the core target) process information.
    9898 */
    99 typedef struct VBOXPROCESS
     99typedef struct RTSOLCOREPROCESS
    100100{
    101     RTPROCESS                       Process;                    /* The pid of the process */
    102     char                            szExecPath[PATH_MAX];       /* Path of the executable */
    103     char                           *pszExecName;                /* Name of the executable file */
     101    RTPROCESS                       Process;                    /**< The pid of the process */
     102    char                            szExecPath[PATH_MAX];       /**< Path of the executable */
     103    char                           *pszExecName;                /**< Name of the executable file */
    104104#ifdef RT_OS_SOLARIS
    105     psinfo_t                        ProcInfo;                   /* Process info. */
    106     prpsinfo_t                      ProcInfoOld;                /* Process info. Older version (for GDB compat.) */
    107     pstatus_t                       ProcStatus;                 /* Process status info. */
    108     thread_t                        hCurThread;                 /* The current thread */
    109     ucontext_t                     *pCurThreadCtx;              /* Context info. of current thread before starting to dump */
    110     RTFILE                          hAs;                        /* proc/<pid/as file handle */
    111     auxv_t                         *pAuxVecs;                   /* Aux vector of process */
    112     int                             cAuxVecs;                   /* Number of aux vector entries */
    113     PVBOXSOLMAPINFO                 pMapInfoHead;               /* Pointer to the head of list of mappings */
    114     uint32_t                        cMappings;                  /* Number of mappings (count of pMapInfoHead list) */
    115     PVBOXSOLTHREADINFO              pThreadInfoHead;            /* Pointer to the head of list of threads */
    116     uint64_t                        cThreads;                   /* Number of threads (count of pThreadInfoHead list) */
    117     char                            szPlatform[SYS_NMLN];       /* Platform name  */
    118     char                            szZoneName[ZONENAME_MAX];   /* Zone name */
    119     struct utsname                  UtsName;                    /* UTS name */
    120     void                           *pvCred;                     /* Process credential info. */
    121     size_t                          cbCred;                     /* Size of process credential info. */
    122     void                           *pvLdt;                      /* Process LDT info. */
    123     size_t                          cbLdt;                      /* Size of the LDT info. */
    124     prpriv_t                       *pPriv;                      /* Process privilege info. */
    125     size_t                          cbPriv;                     /* Size of process privilege info. */
    126     const priv_impl_info_t         *pcPrivImpl;                 /* Process privilege implementation info. (opaque handle) */
    127     core_content_t                  CoreContent;                /* What information goes in the core */
     105    psinfo_t                        ProcInfo;                   /**< Process info. */
     106    prpsinfo_t                      ProcInfoOld;                /**< Process info. Older version (for GDB compat.) */
     107    pstatus_t                       ProcStatus;                 /**< Process status info. */
     108    thread_t                        hCurThread;                 /**< The current thread */
     109    ucontext_t                     *pCurThreadCtx;              /**< Context info. of current thread before starting to dump */
     110    int                             fdAs;                       /**< proc/pid/as file handle */
     111    auxv_t                         *pAuxVecs;                   /**< Aux vector of process */
     112    int                             cAuxVecs;                   /**< Number of aux vector entries */
     113    PRTSOLCOREMAPINFO               pMapInfoHead;               /**< Pointer to the head of list of mappings */
     114    uint32_t                        cMappings;                  /**< Number of mappings (count of pMapInfoHead list) */
     115    PRTSOLCORETHREADINFO            pThreadInfoHead;            /**< Pointer to the head of list of threads */
     116    uint64_t                        cThreads;                   /**< Number of threads (count of pThreadInfoHead list) */
     117    char                            szPlatform[SYS_NMLN];       /**< Platform name  */
     118    char                            szZoneName[ZONENAME_MAX];   /**< Zone name */
     119    struct utsname                  UtsName;                    /**< UTS name */
     120    void                           *pvCred;                     /**< Process credential info. */
     121    size_t                          cbCred;                     /**< Size of process credential info. */
     122    void                           *pvLdt;                      /**< Process LDT info. */
     123    size_t                          cbLdt;                      /**< Size of the LDT info. */
     124    prpriv_t                       *pPriv;                      /**< Process privilege info. */
     125    size_t                          cbPriv;                     /**< Size of process privilege info. */
     126    const priv_impl_info_t         *pcPrivImpl;                 /**< Process privilege implementation info. (opaque handle) */
     127    core_content_t                  CoreContent;                /**< What information goes in the core */
    128128#else
    129129# error Port Me!
    130130#endif
    131131
    132 } VBOXPROCESS;
    133 typedef VBOXPROCESS *PVBOXPROCESS;
     132} RTSOLCOREPROCESS;
     133typedef RTSOLCOREPROCESS *PRTSOLCOREPROCESS;
    134134
    135 typedef int (*PFNCOREREADER)(RTFILE hFile, void *pv, size_t cb);
    136 typedef int (*PFNCOREWRITER)(RTFILE hFile, const void *pcv, size_t cb);
     135typedef int (*PFNRTCOREREADER)(int fdFile, void *pv, size_t cb);
     136typedef int (*PFNRTCOREWRITER)(int fdhFile, const void *pcv, size_t cb);
    137137
    138138/**
    139  * VBOXCORE: Core file object.
     139 * The solaris core file object.
    140140 */
    141 typedef struct VBOXCORE
     141typedef struct RTSOLCORE
    142142{
    143     char                            szCorePath[PATH_MAX];       /* Path of the core file */
    144     VBOXPROCESS                     VBoxProc;                   /* Current process information */
    145     void                           *pvCore;                     /* Pointer to memory area during dumping */
    146     size_t                          cbCore;                     /* Size of memory area during dumping */
    147     void                           *pvFree;                     /* Pointer to base of free range in preallocated memory area */
    148     bool                            fIsValid;                   /* Whether core information has been fully collected */
    149     PFNCOREREADER                   pfnReader;                  /* Reader function */
    150     PFNCOREWRITER                   pfnWriter;                  /* Writer function */
    151     RTFILE                          hCoreFile;                  /* Core file (used only while writing the core) */
    152     RTFOFF                          offWrite;                   /* Segment/section offset (used only while writing the core) */
    153 } VBOXCORE;
    154 typedef VBOXCORE *PVBOXCORE;
     143    char                            szCorePath[PATH_MAX];       /**< Path of the core file */
     144    RTSOLCOREPROCESS                SolProc;                    /**< Current process information */
     145    void                           *pvCore;                     /**< Pointer to memory area during dumping */
     146    size_t                          cbCore;                     /**< Size of memory area during dumping */
     147    void                           *pvFree;                     /**< Pointer to base of free range in preallocated memory area */
     148    bool                            fIsValid;                   /**< Whether core information has been fully collected */
     149    PFNRTCOREREADER                 pfnReader;                  /**< Reader function */
     150    PFNRTCOREWRITER                 pfnWriter;                  /**< Writer function */
     151    int                             fdCoreFile;                 /**< Core file (used only while writing the core) */
     152    RTFOFF                          offWrite;                   /**< Segment/section offset (used only while writing the core) */
     153} RTSOLCORE;
     154typedef RTSOLCORE *PRTSOLCORE;
    155155
    156 typedef int (*PFNCOREACCUMULATOR)(PVBOXCORE pVBoxCore);
    157 typedef int (*PFNCORETHREADWORKER)(PVBOXCORE pVBoxCore, void *pvThreadInfo);
     156typedef int (*PFNRTSOLCOREACCUMULATOR)(PRTSOLCORE pSolCore);
     157typedef int (*PFNRTSOLCORETHREADWORKER)(PRTSOLCORE pSolCore, void *pvThreadInfo);
    158158
  • trunk/src/VBox/Runtime/testcase/tstRTCoreDump.cpp

    r32350 r37631  
    55
    66/*
    7  * Copyright (C) 2010 Oracle Corporation
     7 * Copyright (C) 2010-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828*   Header Files                                                               *
    2929*******************************************************************************/
    30 #include <iprt/types.h>
     30#include <iprt/coredumper.h>
     31
     32#include <iprt/test.h>
    3133#include <iprt/err.h>
    3234#include <iprt/initterm.h>
    3335#include <iprt/thread.h>
    34 #include <iprt/stream.h>
    35 #include <iprt/coredumper.h>
    3636
    3737
     
    3939*   Globals                                                                    *
    4040*******************************************************************************/
    41 static unsigned volatile g_cErrors = 0;
    42 
    43 static DECLCALLBACK(int) SleepyThread(RTTHREAD Thread, void *pvUser)
     41static DECLCALLBACK(int) SleepyThread(RTTHREAD hThread, void *pvUser)
    4442{
    4543    NOREF(pvUser);
    46     RTThreadSleep(90000000);
     44    RTThreadUserWait(hThread, 90000000);
    4745    return VINF_SUCCESS;
    4846}
     
    5048int main()
    5149{
    52     RTR3Init();
    53     RTPrintf("tstRTCoreDump: TESTING...\n");
     50    RTTEST     hTest;
     51    RTEXITCODE rcExit = RTTestInitAndCreate("tstRTCoreDump", &hTest);
     52    if (rcExit != RTEXITCODE_SUCCESS)
     53        return rcExit;
     54    RTTestBanner(hTest);
    5455
    5556    /*
    5657     * Setup core dumping.
    5758     */
    58     int rc = RTCoreDumperSetup(NULL, RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP | RTCOREDUMPER_FLAGS_LIVE_CORE);
     59    int rc;
     60    RTTESTI_CHECK_RC(rc = RTCoreDumperSetup(NULL, RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP | RTCOREDUMPER_FLAGS_LIVE_CORE),
     61                     VINF_SUCCESS);
    5962    if (RT_SUCCESS(rc))
    6063    {
     
    6366         */
    6467        RTTHREAD ahThreads[5];
    65         unsigned i = 0;
    66         for (; i < RT_ELEMENTS(ahThreads); i++)
     68        unsigned i;
     69        for (i = 0; i < RT_ELEMENTS(ahThreads); i++)
    6770        {
    68             rc = RTThreadCreate(&ahThreads[i], SleepyThread, &ahThreads[i], 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "TEST1");
    69             if (RT_FAILURE(rc))
    70             {
    71                 RTPrintf("tstRTCoreDump: FAILURE(%d) - %d RTThreadCreate failed, rc=%Rrc\n", __LINE__, i, rc);
    72                 g_cErrors++;
    73                 ahThreads[i] = NIL_RTTHREAD;
    74                 break;
    75             }
     71            RTTESTI_CHECK_RC_BREAK(RTThreadCreate(&ahThreads[i], SleepyThread, &ahThreads[i], 0, RTTHREADTYPE_DEFAULT,
     72                                                  RTTHREADFLAGS_WAITABLE, "TEST1"),
     73                                   VINF_SUCCESS);
    7674        }
    77         RTPrintf("Spawned %d threads.\n", i);
     75        RTTestIPrintf(RTTESTLVL_ALWAYS, "Spawned %d threads.\n", i);
    7876
    7977        /*
    8078         * Write the core to disk.
    8179         */
    82         rc = RTCoreDumperTakeDump(NULL, false /* fLiveCore*/);
    83         if (RT_FAILURE(rc))
     80        RTTESTI_CHECK_RC(RTCoreDumperTakeDump(NULL, true /* fLiveCore*/), VINF_SUCCESS);
     81
     82        /*
     83         * Clean up.
     84         */
     85        RTTESTI_CHECK_RC(RTCoreDumperDisable(), VINF_SUCCESS);
     86        while (i-- > 0)
    8487        {
    85             g_cErrors++;
    86             RTPrintf("RTCoreDumperTakeDump failed. rc=%Rrc\n", rc);
     88            RTTESTI_CHECK_RC(RTThreadUserSignal(ahThreads[i]), VINF_SUCCESS);
     89            RTTESTI_CHECK_RC(RTThreadWait(ahThreads[i], 60*1000, NULL), VINF_SUCCESS);
    8790        }
    88         RTCoreDumperDisable();
    89     }
    90     else
    91     {
    92         g_cErrors++;
    93         RTPrintf("RTCoreDumperSetup failed. rc=%Rrc\n", rc);
    9491    }
    9592
     
    9794     * Summary.
    9895     */
    99     if (!g_cErrors)
    100         RTPrintf("tstRTCoreDump: SUCCESS\n");
    101     else
    102         RTPrintf("tstRTCoreDump: FAILURE - %d errors\n", g_cErrors);
    103 
    104     return !!g_cErrors;
     96    return RTTestSummaryAndDestroy(hTest);
    10597}
    10698
Note: See TracChangeset for help on using the changeset viewer.

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