Changeset 40504 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Mar 16, 2012 4:38:06 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 76890
- 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 247 247 struct stat st; 248 248 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 } 250 255 251 256 CORELOGRELSYS((CORELOG_NAME "GetFileSizeByFd: fstat failed rc=%Rrc\n", RTErrConvertFromErrno(errno))); … … 1806 1811 } 1807 1812 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 */ 1817 static int rtCoreDumperWriteCoreDoIt(PRTSOLCORE pSolCore, PFNRTCOREWRITER pfnWriter, 1818 PRTSOLCOREPROCESS pSolProc) 1819 { 1861 1820 pSolCore->offWrite = 0; 1862 uint32_t cProgHdrs 1821 uint32_t cProgHdrs = pSolProc->cMappings + 2; /* two PT_NOTE program headers (old, new style) */ 1863 1822 1864 1823 /* … … 1889 1848 ElfHdr.e_phentsize = sizeof(Elf_Phdr); 1890 1849 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)); 1892 1851 if (RT_FAILURE(rc)) 1893 1852 { 1894 1853 CORELOGRELSYS((CORELOG_NAME "WriteCore: pfnWriter failed writing ELF header. rc=%Rrc\n", rc)); 1895 goto WriteCoreDone;1854 return rc; 1896 1855 } 1897 1856 … … 1914 1873 { 1915 1874 CORELOGRELSYS((CORELOG_NAME "WriteCore: pfnWriter failed writing old-style ELF program Header. rc=%Rrc\n", rc)); 1916 goto WriteCoreDone;1875 return rc; 1917 1876 } 1918 1877 … … 1927 1886 { 1928 1887 CORELOGRELSYS((CORELOG_NAME "WriteCore: pfnWriter failed writing new-style ELF program header. rc=%Rrc\n", rc)); 1929 goto WriteCoreDone;1888 return rc; 1930 1889 } 1931 1890 … … 1938 1897 { 1939 1898 CORELOGRELSYS((CORELOG_NAME "Write: ElfWriteMappings failed. rc=%Rrc\n", rc)); 1940 goto WriteCoreDone;1899 return rc; 1941 1900 } 1942 1901 … … 1948 1907 { 1949 1908 CORELOGRELSYS((CORELOG_NAME "WriteCore: ElfWriteNoteSection old-style failed. rc=%Rrc\n", rc)); 1950 goto WriteCoreDone;1909 return rc; 1951 1910 } 1952 1911 … … 1958 1917 { 1959 1918 CORELOGRELSYS((CORELOG_NAME "WriteCore: ElfWriteNoteSection new-style failed. rc=%Rrc\n", rc)); 1960 goto WriteCoreDone;1919 return rc; 1961 1920 } 1962 1921 … … 1968 1927 { 1969 1928 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 */ 1947 static 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 } 1983 1991 close(pSolProc->fdAs); 1984 1992 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)); 1985 1998 } 1986 1999 -
trunk/src/VBox/Runtime/r3/solaris/fileaio-solaris.cpp
r30238 r40504 167 167 168 168 pReqInt->AioCB.aio_lio_opcode = uTransferDirection; 169 pReqInt->AioCB.aio_fildes = (int)hFile;169 pReqInt->AioCB.aio_fildes = RTFileToNative(hFile); 170 170 pReqInt->AioCB.aio_offset = off; 171 171 pReqInt->AioCB.aio_nbytes = cbTransfer; … … 202 202 203 203 pReqInt->fFlush = true; 204 pReqInt->AioCB.aio_fildes = (int)hFile;204 pReqInt->AioCB.aio_fildes = RTFileToNative(hFile); 205 205 pReqInt->AioCB.aio_offset = 0; 206 206 pReqInt->AioCB.aio_nbytes = 0;
Note:
See TracChangeset
for help on using the changeset viewer.