VirtualBox

Changeset 40504 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Mar 16, 2012 4:38:06 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
76890
Message:

Solaris 11 build fixes.

Location:
trunk/src/VBox/Runtime/r3/solaris
Files:
2 edited

Legend:

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

    r37631 r40504  
    247247    struct stat st;
    248248    if (fstat(fd, &st) == 0)
    249         return st.st_size < ~(size_t)0 ? (size_t)st.st_size : ~(size_t)0;
     249    {
     250        if (st.st_size <= 0)
     251            return 0;
     252        size_t cbFile = (size_t)st.st_size;
     253        return (off_t)cbFile == st.st_size ? cbFile : ~(size_t)0;
     254    }
    250255
    251256    CORELOGRELSYS((CORELOG_NAME "GetFileSizeByFd: fstat failed rc=%Rrc\n", RTErrConvertFromErrno(errno)));
     
    18061811}
    18071812
    1808 
    1809 /**
    1810  * Write a prepared core file using a user-passed in writer function, requires all threads
    1811  * to be in suspended state (i.e. called after CreateCore).
    1812  *
    1813  * @param pSolCore          Pointer to the core object.
    1814  * @param pfnWriter         Pointer to the writer function to override default writer (NULL uses default).
    1815  *
    1816  * @remarks Resumes all suspended threads, unless it's an invalid core. This
    1817  *          function must be called only -after- rtCoreDumperCreateCore().
    1818  * @return IPRT status.
    1819  */
    1820 static int rtCoreDumperWriteCore(PRTSOLCORE pSolCore, PFNRTCOREWRITER pfnWriter)
    1821 {
    1822     AssertReturn(pSolCore, VERR_INVALID_POINTER);
    1823 
    1824     if (!pSolCore->fIsValid)
    1825         return VERR_INVALID_STATE;
    1826 
    1827     if (pfnWriter)
    1828         pSolCore->pfnWriter = pfnWriter;
    1829 
    1830     PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
    1831     char szPath[PATH_MAX];
    1832     int rc = VINF_SUCCESS;
    1833 
    1834     /*
    1835      * Open the process address space file.
    1836      */
    1837     RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/as", (int)pSolProc->Process);
    1838     int fd = open(szPath, O_RDONLY);
    1839     if (fd < 0)
    1840     {
    1841         rc = RTErrConvertFromErrno(fd);
    1842         CORELOGRELSYS((CORELOG_NAME "WriteCore: Failed to open address space, %s. rc=%Rrc\n", szPath, rc));
    1843         goto WriteCoreDone;
    1844     }
    1845 
    1846     pSolProc->fdAs = fd;
    1847 
    1848     /*
    1849      * Create the core file.
    1850      */
    1851     fd = open(pSolCore->szCorePath, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR);
    1852     if (fd < 0)
    1853     {
    1854         rc = RTErrConvertFromErrno(fd);
    1855         CORELOGRELSYS((CORELOG_NAME "WriteCore: failed to open %s. rc=%Rrc\n", pSolCore->szCorePath, rc));
    1856         goto WriteCoreDone;
    1857     }
    1858 
    1859     pSolCore->fdCoreFile = fd;
    1860 
     1813/**
     1814 * Inner worker for rtCoreDumperWriteCore, which purpose is to
     1815 * squash cleanup gotos.
     1816 */
     1817static int rtCoreDumperWriteCoreDoIt(PRTSOLCORE pSolCore, PFNRTCOREWRITER pfnWriter,
     1818                                     PRTSOLCOREPROCESS pSolProc)
     1819{
    18611820    pSolCore->offWrite = 0;
    1862     uint32_t cProgHdrs  = pSolProc->cMappings + 2; /* two PT_NOTE program headers (old, new style) */
     1821    uint32_t cProgHdrs = pSolProc->cMappings + 2; /* two PT_NOTE program headers (old, new style) */
    18631822
    18641823    /*
     
    18891848    ElfHdr.e_phentsize       = sizeof(Elf_Phdr);
    18901849    ElfHdr.e_shentsize       = sizeof(Elf_Shdr);
    1891     rc = pSolCore->pfnWriter(pSolCore->fdCoreFile, &ElfHdr, sizeof(ElfHdr));
     1850    int rc = pSolCore->pfnWriter(pSolCore->fdCoreFile, &ElfHdr, sizeof(ElfHdr));
    18921851    if (RT_FAILURE(rc))
    18931852    {
    18941853        CORELOGRELSYS((CORELOG_NAME "WriteCore: pfnWriter failed writing ELF header. rc=%Rrc\n", rc));
    1895         goto WriteCoreDone;
     1854        return rc;
    18961855    }
    18971856
     
    19141873    {
    19151874        CORELOGRELSYS((CORELOG_NAME "WriteCore: pfnWriter failed writing old-style ELF program Header. rc=%Rrc\n", rc));
    1916         goto WriteCoreDone;
     1875        return rc;
    19171876    }
    19181877
     
    19271886    {
    19281887        CORELOGRELSYS((CORELOG_NAME "WriteCore: pfnWriter failed writing new-style ELF program header. rc=%Rrc\n", rc));
    1929         goto WriteCoreDone;
     1888        return rc;
    19301889    }
    19311890
     
    19381897    {
    19391898        CORELOGRELSYS((CORELOG_NAME "Write: ElfWriteMappings failed. rc=%Rrc\n", rc));
    1940         goto WriteCoreDone;
     1899        return rc;
    19411900    }
    19421901
     
    19481907    {
    19491908        CORELOGRELSYS((CORELOG_NAME "WriteCore: ElfWriteNoteSection old-style failed. rc=%Rrc\n", rc));
    1950         goto WriteCoreDone;
     1909        return rc;
    19511910    }
    19521911
     
    19581917    {
    19591918        CORELOGRELSYS((CORELOG_NAME "WriteCore: ElfWriteNoteSection new-style failed. rc=%Rrc\n", rc));
    1960         goto WriteCoreDone;
     1919        return rc;
    19611920    }
    19621921
     
    19681927    {
    19691928        CORELOGRELSYS((CORELOG_NAME "WriteCore: ElfWriteMappings failed. rc=%Rrc\n", rc));
    1970         goto WriteCoreDone;
    1971     }
    1972 
    1973 
    1974 WriteCoreDone:
    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     {
     1929        return rc;
     1930    }
     1931
     1932    return rc;
     1933}
     1934
     1935
     1936/**
     1937 * Write a prepared core file using a user-passed in writer function, requires all threads
     1938 * to be in suspended state (i.e. called after CreateCore).
     1939 *
     1940 * @param pSolCore          Pointer to the core object.
     1941 * @param pfnWriter         Pointer to the writer function to override default writer (NULL uses default).
     1942 *
     1943 * @remarks Resumes all suspended threads, unless it's an invalid core. This
     1944 *          function must be called only -after- rtCoreDumperCreateCore().
     1945 * @return IPRT status.
     1946 */
     1947static int rtCoreDumperWriteCore(PRTSOLCORE pSolCore, PFNRTCOREWRITER pfnWriter)
     1948{
     1949    AssertReturn(pSolCore, VERR_INVALID_POINTER);
     1950
     1951    if (!pSolCore->fIsValid)
     1952        return VERR_INVALID_STATE;
     1953
     1954    if (pfnWriter)
     1955        pSolCore->pfnWriter = pfnWriter;
     1956
     1957    PRTSOLCOREPROCESS pSolProc = &pSolCore->SolProc;
     1958    char szPath[PATH_MAX];
     1959    int  rc;
     1960
     1961    /*
     1962     * Open the process address space file.
     1963     */
     1964    RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/as", (int)pSolProc->Process);
     1965    int fd = open(szPath, O_RDONLY);
     1966    if (fd >= 0)
     1967    {
     1968        pSolProc->fdAs = fd;
     1969
     1970        /*
     1971         * Create the core file.
     1972         */
     1973        fd = open(pSolCore->szCorePath, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR);
     1974        if (fd >= 0)
     1975        {
     1976            pSolCore->fdCoreFile = fd;
     1977
     1978            /*
     1979             * Do the actual writing.
     1980             */
     1981            rc = rtCoreDumperWriteCoreDoIt(pSolCore, pfnWriter, pSolProc);
     1982
     1983            close(pSolCore->fdCoreFile);
     1984            pSolCore->fdCoreFile = -1;
     1985        }
     1986        else
     1987        {
     1988            rc = RTErrConvertFromErrno(fd);
     1989            CORELOGRELSYS((CORELOG_NAME "WriteCore: failed to open %s. rc=%Rrc\n", pSolCore->szCorePath, rc));
     1990        }
    19831991        close(pSolProc->fdAs);
    19841992        pSolProc->fdAs = -1;
     1993    }
     1994    else
     1995    {
     1996        rc = RTErrConvertFromErrno(fd);
     1997        CORELOGRELSYS((CORELOG_NAME "WriteCore: Failed to open address space, %s. rc=%Rrc\n", szPath, rc));
    19851998    }
    19861999
  • trunk/src/VBox/Runtime/r3/solaris/fileaio-solaris.cpp

    r30238 r40504  
    167167
    168168    pReqInt->AioCB.aio_lio_opcode = uTransferDirection;
    169     pReqInt->AioCB.aio_fildes     = (int)hFile;
     169    pReqInt->AioCB.aio_fildes     = RTFileToNative(hFile);
    170170    pReqInt->AioCB.aio_offset     = off;
    171171    pReqInt->AioCB.aio_nbytes     = cbTransfer;
     
    202202
    203203    pReqInt->fFlush           = true;
    204     pReqInt->AioCB.aio_fildes = (int)hFile;
     204    pReqInt->AioCB.aio_fildes = RTFileToNative(hFile);
    205205    pReqInt->AioCB.aio_offset = 0;
    206206    pReqInt->AioCB.aio_nbytes = 0;
Note: See TracChangeset for help on using the changeset viewer.

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