VirtualBox

Changeset 40857 in vbox


Ignore:
Timestamp:
Apr 10, 2012 6:52:33 PM (12 years ago)
Author:
vboxsync
Message:

Make VBoxTpG work on 64-bit darwin. (Still need to check 32-bit.)

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxTpG.h

    r40851 r40857  
    7272# ifdef __GNUC__
    7373#  define VTG_DECL_VTGPROBELOC(a_VarName) \
    74     static VTGPROBELOC __attribute__((section(VTG_LOC_SECT))) a_VarName
     74    static VTGPROBELOC __attribute__((section(VTG_LOC_SEG "," VTG_LOC_SECT ",regular")/*, aligned(16)*/)) a_VarName
    7575# else
    7676#  error "Unsupported Darwin compiler!"
  • trunk/src/VBox/HostDrivers/Support/Makefile.kmk

    r40851 r40857  
    303303 VBoxDrv_SOURCES.darwin   = darwin/SUPDrv-darwin.cpp
    304304 VBoxDrv_SOURCES.solaris  = \
    305         solaris/SUPDrv-solaris.c 
     305        solaris/SUPDrv-solaris.c
    306306 VBoxDrv_SOURCES.win      = \
    307307        win/SUPDrv-win.cpp \
     
    316316  VBoxDrv_SOURCES        += \
    317317        SUPDrv-dtrace.cpp
     318  VBoxDrv_DTRACE_OBJ_FLAGS = -v -v -v
     319  SUPDrv-dtrace.cpp_DEFS.darwin += VBOX_PATH_MACOSX_DTRACE_H=\"$(VBOX_PATH_MACOSX_SDK)/usr/include/sys/dtrace.h\"
    318320 endif
    319321 ifn1of ($(KBUILD_TARGET), linux freebsd)
  • trunk/src/VBox/HostDrivers/Support/SUPDrv-dtrace.cpp

    r40851 r40857  
    3939#include <iprt/ctype.h>
    4040#include <iprt/mem.h>
    41 
    42 #ifdef RT_OS_DARWIN /** @todo figure this! */
    43 # include "/Developer/SDKs/MacOSX10.6.sdk/usr/include/sys/dtrace.h"
     41#include <iprt/errno.h>
     42#ifdef RT_OS_DARWIN
     43# include <iprt/dbg.h>
     44#endif
     45
     46#ifdef RT_OS_DARWIN
     47# include VBOX_PATH_MACOSX_DTRACE_H
    4448#else
    4549# include <sys/dtrace.h>
     
    112116#ifdef RT_OS_DARWIN
    113117/** @name DTrace kernel interface used on Darwin
    114  * @{ */
    115 static void        (* dtrace_probe)(dtrace_id_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t);
    116 static dtrace_id_t (* dtrace_probe_create)(dtrace_provider_id_t, const char *, const char *, const char *, int, void *);
    117 static dtrace_id_t (* dtrace_probe_lookup)(dtrace_provider_id_t, const char *, const char *, const char *);
    118 static int         (* dtrace_register)(const char *, const dtrace_pattr_t *, uint32_t, /*cred_t*/ void *,
    119                                        const dtrace_pops_t *, void *, dtrace_provider_id_t *);
    120 static void        (* dtrace_invalidate)(dtrace_provider_id_t);
    121 static int         (* dtrace_unregister)(dtrace_provider_id_t);
     118 * @{ */
     119static void        (* g_pfnDTraceProbeFire)(dtrace_id_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t);
     120static dtrace_id_t (* g_pfnDTraceProbeCreate)(dtrace_provider_id_t, const char *, const char *, const char *, int, void *);
     121static dtrace_id_t (* g_pfnDTraceProbeLookup)(dtrace_provider_id_t, const char *, const char *, const char *);
     122static int         (* g_pfnDTraceProviderRegister)(const char *, const dtrace_pattr_t *, uint32_t, /*cred_t*/ void *,
     123                                                   const dtrace_pops_t *, void *, dtrace_provider_id_t *);
     124static void        (* g_pfnDTraceProviderInvalidate)(dtrace_provider_id_t);
     125static int         (* g_pfnDTraceProviderUnregister)(dtrace_provider_id_t);
     126
     127#define dtrace_probe            g_pfnDTraceProbeFire
     128#define dtrace_probe_create     g_pfnDTraceProbeCreate
     129#define dtrace_probe_lookup     g_pfnDTraceProbeLookup
     130#define dtrace_register         g_pfnDTraceProviderRegister
     131#define dtrace_invalidate       g_pfnDTraceProviderInvalidate
     132#define dtrace_unregister       g_pfnDTraceProviderUnregister
     133
    122134/** @} */
    123135#endif
     
    358370
    359371/**
    360  * @callback_method_impl{dtrace_pops_t,dtps_getargval} 
    361  * 
    362  * 
    363  * We just cook our own stuff here, using a stack marker for finding the 
    364  * required information.  That's more reliable than subjecting oneself to the 
    365  * solaris bugs and 32-bit apple peculiarities. 
    366  * 
    367  * 
     372 * @callback_method_impl{dtrace_pops_t,dtps_getargval}
     373 *
     374 *
     375 * We just cook our own stuff here, using a stack marker for finding the
     376 * required information.  That's more reliable than subjecting oneself to the
     377 * solaris bugs and 32-bit apple peculiarities.
     378 *
     379 *
    368380 * @remarks Solaris Bug
    369  * 
    370  * dtrace_getarg on AMD64 has a different opinion about how to use the cFrames 
    371  * argument than dtrace_caller() and/or dtrace_getpcstack(), at least when the 
    372  * probe is fired by dtrace_probe() the way we do. 
    373  * 
     381 *
     382 * dtrace_getarg on AMD64 has a different opinion about how to use the cFrames
     383 * argument than dtrace_caller() and/or dtrace_getpcstack(), at least when the
     384 * probe is fired by dtrace_probe() the way we do.
     385 *
    374386 * Setting aframes to 1 when calling dtrace_probe_create gives me the right
    375387 * arguments, but the wrong 'caller'.  Since I cannot do anything about
    376388 * 'caller', the only solution is this hack.
    377  * 
     389 *
    378390 * Not sure why the  Solaris guys hasn't seen this issue before, but maybe there
    379  * isn't anyone using the default argument getter path for ring-0 dtrace_probe() 
    380  * calls, SDT surely isn't. 
    381  * 
     391 * isn't anyone using the default argument getter path for ring-0 dtrace_probe()
     392 * calls, SDT surely isn't.
     393 *
    382394 * @todo File a solaris bug on dtrace_probe() + dtrace_getarg().
    383  * 
    384  * 
    385  * @remarks 32-bit XNU (Apple) 
    386  * 
    387  * The dtrace_probe arguments are 64-bit unsigned integers instead of uintptr_t, 
    388  * so we need to make an extra call. 
    389  * 
     395 *
     396 *
     397 * @remarks 32-bit XNU (Apple)
     398 *
     399 * The dtrace_probe arguments are 64-bit unsigned integers instead of uintptr_t,
     400 * so we need to make an extra call.
     401 *
    390402 */
    391403static uint64_t supdrvDtPOps_GetArgVal(void *pvProv, dtrace_id_t idProbe, void *pvProbe,
     
    488500 * interface_method_impl{SUPDRVTRACERREG,pfnTracerOpen}
    489501 */
    490 static DECLCALLBACK(int) supdrvDtTOps_TracerOpen(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uint32_t uCookie, 
     502static DECLCALLBACK(int) supdrvDtTOps_TracerOpen(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uint32_t uCookie,
    491503                                                 uintptr_t uArg, uintptr_t *puSessionData)
    492504{
     
    653665        PFNRT      *ppfn;
    654666    } s_aDTraceFunctions[] =
    655     {   
     667    {
    656668        { "dtrace_probe",        (PFNRT*)&dtrace_probe        },
    657669        { "dtrace_probe_create", (PFNRT*)&dtrace_probe_create },
     
    663675    for (unsigned i = 0; i < RT_ELEMENTS(s_aDTraceFunctions); i++)
    664676    {
    665         rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, s_aDTraceFunctions[i].pszName, 
     677        rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, s_aDTraceFunctions[i].pszName,
    666678                                        (void **)s_aDTraceFunctions[i].ppfn);
    667679        if (RT_FAILURE(rc))
  • trunk/src/bldprogs/VBoxTpG.cpp

    r40851 r40857  
    136136static const char           g_szAssemblerFmtVal32[]     = "macho32";
    137137static const char           g_szAssemblerFmtVal64[]     = "macho64";
     138static const char           g_szAssemblerOsDef[]        = "RT_OS_DARWIN";
    138139#elif defined(RT_OS_OS2)
    139140static const char          *pszAssembler                = "nasm.exe";
     
    141142static const char           g_szAssemblerFmtVal32[]     = "obj";
    142143static const char           g_szAssemblerFmtVal64[]     = "elf64";
     144static const char           g_szAssemblerOsDef[]        = "RT_OS_OS2";
    143145#elif defined(RT_OS_WINDOWS)
    144146static const char          *g_pszAssembler              = "yasm.exe";
     
    146148static const char           g_szAssemblerFmtVal32[]     = "win32";
    147149static const char           g_szAssemblerFmtVal64[]     = "win64";
     150static const char           g_szAssemblerOsDef[]        = "RT_OS_WINDOWS";
    148151#else
    149152static const char          *g_pszAssembler              = "yasm";
     
    151154static const char           g_szAssemblerFmtVal32[]     = "elf32";
    152155static const char           g_szAssemblerFmtVal64[]     = "elf64";
     156# ifdef RT_OS_FREEBSD
     157static const char           g_szAssemblerOsDef[]        = "RT_OS_FREEBSD";
     158# elif  defined(RT_OS_NETBSD)
     159static const char           g_szAssemblerOsDef[]        = "RT_OS_NETBSD";
     160# elif  defined(RT_OS_OPENBSD)
     161static const char           g_szAssemblerOsDef[]        = "RT_OS_OPENBSD";
     162# elif  defined(RT_OS_LINUX)
     163static const char           g_szAssemblerOsDef[]        = "RT_OS_LINUX";
     164# elif  defined(RT_OS_SOLARIS)
     165static const char           g_szAssemblerOsDef[]        = "RT_OS_SOLARIS";
     166# else
     167#  error "Port me!"
     168# endif
    153169#endif
    154170static const char          *g_pszAssemblerFmtVal        = RT_CONCAT(g_szAssemblerFmtVal, ARCH_BITS);
     
    253269    else
    254270        apszArgs[iArg++] = "RT_ARCH_AMD64";
     271    if (g_szAssemblerOsDef[0])
     272    {
     273        apszArgs[iArg++] = g_pszAssemblerDefOpt;
     274        apszArgs[iArg++] = g_szAssemblerOsDef;
     275    }
    255276    apszArgs[iArg++] = g_pszAssemblerIncOpt;
    256277    apszArgs[iArg++] = g_pszAssemblerIncVal;
     
    452473                    "  NAME(%%1):\n"
    453474                    " %%endmacro\n"
    454                     " ;[section VTG Obj align=4096]\n"
    455                     " [section .data]\n"
     475                    " [section __VTG __VTGObj        align=64]\n"
    456476                    "\n"
    457477                    "%%elifdef ASM_FORMAT_PE\n"
     
    502522                    "    RTCCPTR_DEF NAME(g_aVTGArgLists)\n"
    503523                    "    RTCCPTR_DEF NAME(g_aVTGArgLists_End)      - NAME(g_aVTGArgLists)\n"
     524                    "%%ifdef ASM_FORMAT_MACHO ; Apple has a real decent linker!\n"
     525                    "extern section$start$__VTG$__VTGPrLc\n"
     526                    "    RTCCPTR_DEF section$start$__VTG$__VTGPrLc\n"
     527                    "extern section$end$__VTG$__VTGPrLc\n"
     528                    "    RTCCPTR_DEF section$end$__VTG$__VTGPrLc\n"
     529                    "%%else\n"
    504530                    "    RTCCPTR_DEF NAME(g_aVTGPrLc)\n"
    505531                    "    RTCCPTR_DEF NAME(g_aVTGPrLc_End) ; cross section/segment size not possible\n"
     532                    "%%endif\n"
    506533                    "    RTCCPTR_DEF 0\n"
    507534                    "    RTCCPTR_DEF 0\n"
     
    642669                            "    dd %6u  ; name\n"
    643670                            "    dd %6u  ; Argument list offset\n"
    644                             "    dw g_fVTGProbeEnabled_%s_%s - g_afVTGProbeEnabled\n"
     671                            "    dw NAME(g_fVTGProbeEnabled_%s_%s) - NAME(g_afVTGProbeEnabled)\n"
    645672                            "    dw %6u  ; provider index\n"
    646673                            "    dd 0       ; for the application\n"
     
    19031930        { "--probe-fn-name",                    kVBoxTpGOpt_ProbeFnName,                RTGETOPT_REQ_STRING  },
    19041931        { "--probe-fn-imported",                kVBoxTpGOpt_ProbeFnImported,            RTGETOPT_REQ_BOOL    },
     1932        /** @todo We're missing a bunch of assembler options! */
    19051933    };
    19061934
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