VirtualBox

Changeset 58598 in vbox for trunk/src/VBox/Runtime/r0drv


Ignore:
Timestamp:
Nov 6, 2015 11:24:38 AM (9 years ago)
Author:
vboxsync
Message:

dbgkernel-info-r0drv-darwin.cpp: Look for development and debug kernels too. Try the next alternative when the kernel file doesn't match, not just when it doesn't exist. This should fix issues for people with /mach_kernel on 10.11 and for those using alternative kernels provided in the Kernel Debug Kit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/darwin/dbgkrnlinfo-r0drv-darwin.cpp

    r57358 r58598  
    4545# include <vfs/vfs_support.h>
    4646/*# include <miscfs/specfs/specdev.h>*/
     47#else
     48# include <stdio.h> /* for printf */
    4749#endif
    4850
     
    10321034
    10331035
    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 
     1036static int rtR0DbgKrnlDarwinOpen(PRTDBGKRNLINFO phKrnlInfo, const char *pszKernelFile)
     1037{
    10401038    RTDBGKRNLINFOINT *pThis = (RTDBGKRNLINFOINT *)RTMemAllocZ(sizeof(*pThis));
    10411039    if (!pThis)
     
    10431041    pThis->hFile = NIL_RTFILE;
    10441042
    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);
    10481044    if (RT_SUCCESS(rc))
    10491045        rc = rtR0DbgKrnlDarwinLoadFileHeaders(pThis);
     
    10781074
    10791075
     1076RTR0DECL(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
    10801136RTR0DECL(uint32_t) RTR0DbgKrnlInfoRetain(RTDBGKRNLINFO hKrnlInfo)
    10811137{
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