Changeset 58598 in vbox for trunk/src/VBox/Runtime/r0drv
- Timestamp:
- Nov 6, 2015 11:24:38 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/darwin/dbgkrnlinfo-r0drv-darwin.cpp
r57358 r58598 45 45 # include <vfs/vfs_support.h> 46 46 /*# include <miscfs/specfs/specdev.h>*/ 47 #else 48 # include <stdio.h> /* for printf */ 47 49 #endif 48 50 … … 1032 1034 1033 1035 1034 RTR0DECL(int) RTR0DbgKrnlInfoOpen(PRTDBGKRNLINFO phKrnlInfo, uint32_t fFlags) 1035 { 1036 AssertPtrReturn(phKrnlInfo, VERR_INVALID_POINTER); 1037 *phKrnlInfo = NIL_RTDBGKRNLINFO; 1038 AssertReturn(!fFlags, VERR_INVALID_PARAMETER); 1039 1036 static int rtR0DbgKrnlDarwinOpen(PRTDBGKRNLINFO phKrnlInfo, const char *pszKernelFile) 1037 { 1040 1038 RTDBGKRNLINFOINT *pThis = (RTDBGKRNLINFOINT *)RTMemAllocZ(sizeof(*pThis)); 1041 1039 if (!pThis) … … 1043 1041 pThis->hFile = NIL_RTFILE; 1044 1042 1045 int rc = RTFileOpen(&pThis->hFile, "/mach_kernel", RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 1046 if (rc == VERR_FILE_NOT_FOUND) 1047 rc = RTFileOpen(&pThis->hFile, "/System/Library/Kernels/kernel", RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 1043 int rc = RTFileOpen(&pThis->hFile, pszKernelFile, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 1048 1044 if (RT_SUCCESS(rc)) 1049 1045 rc = rtR0DbgKrnlDarwinLoadFileHeaders(pThis); … … 1078 1074 1079 1075 1076 RTR0DECL(int) RTR0DbgKrnlInfoOpen(PRTDBGKRNLINFO phKrnlInfo, uint32_t fFlags) 1077 { 1078 AssertPtrReturn(phKrnlInfo, VERR_INVALID_POINTER); 1079 *phKrnlInfo = NIL_RTDBGKRNLINFO; 1080 AssertReturn(!fFlags, VERR_INVALID_PARAMETER); 1081 1082 /* 1083 * Go thru likely kernel locations 1084 * 1085 * Note! Check the OS X version and reorder the list? 1086 * Note! We should try fish kcsuffix out of bootargs or somewhere one day. 1087 */ 1088 static bool s_fFirstCall = true; 1089 struct 1090 { 1091 const char *pszLocation; 1092 int rc; 1093 } aKernels[] = 1094 { 1095 { "/System/Library/Kernels/kernel", VERR_WRONG_ORDER }, 1096 { "/System/Library/Kernels/kernel.development", VERR_WRONG_ORDER }, 1097 { "/System/Library/Kernels/kernel.debug", VERR_WRONG_ORDER }, 1098 { "/mach_kernel", VERR_WRONG_ORDER }, 1099 }; 1100 int rc; 1101 for (uint32_t i = 0; i < RT_ELEMENTS(aKernels); i++) 1102 { 1103 aKernels[i].rc = rc = rtR0DbgKrnlDarwinOpen(phKrnlInfo, aKernels[i].pszLocation); 1104 if (RT_SUCCESS(rc)) 1105 { 1106 if (s_fFirstCall) 1107 { 1108 printf("RTR0DbgKrnlInfoOpen: Using kernel file '%s'\n", aKernels[i].pszLocation); 1109 s_fFirstCall = false; 1110 } 1111 return rc; 1112 } 1113 } 1114 1115 /* 1116 * Failed. 1117 */ 1118 /* Pick the best error code. */ 1119 for (uint32_t i = 0; rc == VERR_FILE_NOT_FOUND && i < RT_ELEMENTS(aKernels); i++) 1120 if (aKernels[i].rc != VERR_FILE_NOT_FOUND) 1121 rc = aKernels[i].rc; 1122 1123 /* Bitch about it. */ 1124 printf("RTR0DbgKrnlInfoOpen: failed to find matching kernel file! rc=%d\n", rc); 1125 if (s_fFirstCall) 1126 { 1127 for (uint32_t i = 0; i < RT_ELEMENTS(aKernels); i++) 1128 printf("RTR0DbgKrnlInfoOpen: '%s' -> %d\n", aKernels[i].pszLocation, aKernels[i].rc); 1129 s_fFirstCall = false; 1130 } 1131 1132 return rc; 1133 } 1134 1135 1080 1136 RTR0DECL(uint32_t) RTR0DbgKrnlInfoRetain(RTDBGKRNLINFO hKrnlInfo) 1081 1137 {
Note:
See TracChangeset
for help on using the changeset viewer.