Changeset 41130 in vbox
- Timestamp:
- May 3, 2012 11:35:25 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxTpG.h
r41117 r41130 43 43 uint32_t idProbe; 44 44 uint32_t pszFunction; 45 uint32_t p bProbe;45 uint32_t pProbe; 46 46 } VTGPROBELOC32; 47 47 AssertCompileSize(VTGPROBELOC32, 16); … … 60 60 uint32_t idProbe; 61 61 uint64_t pszFunction; 62 uint64_t p bProbe;62 uint64_t pProbe; 63 63 uint64_t uAlignment; 64 64 } VTGPROBELOC64; … … 75 75 typedef struct VTGPROBELOC 76 76 { 77 uint32_t uLine : 31;78 uint32_t fEnabled : 1;79 uint32_t idProbe;80 const char *pszFunction;81 uint8_t *pbProbe;77 uint32_t uLine : 31; 78 uint32_t fEnabled : 1; 79 uint32_t idProbe; 80 const char *pszFunction; 81 struct VTGDESCPROBE *pProbe; 82 82 #if ARCH_BITS == 64 83 uintptr_t uAlignment;83 uintptr_t uAlignment; 84 84 #endif 85 85 } VTGPROBELOC; -
trunk/include/VBox/sup.h
r41117 r41130 1559 1559 * @param pSession The user session. 1560 1560 * @param pCtx The usermode context info. 1561 * @param pVtgHdr The VTG header (read-only). 1562 * @param pProbeLocRO The read-only probe location record . 1561 1563 */ 1562 DECLR0CALLBACKMEMBER(void, pfnProbeFireUser, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, PCSUPDRVTRACERUSRCTX pCtx)); 1564 DECLR0CALLBACKMEMBER(void, pfnProbeFireUser, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, PCSUPDRVTRACERUSRCTX pCtx, 1565 struct VTGOBJHDR const *pVtgHdr, struct VTGPROBELOC const *pProbeLocRO)); 1563 1566 1564 1567 /** -
trunk/src/VBox/HostDrivers/Support/SUPDrv-dtrace.cpp
r40975 r41130 66 66 #endif 67 67 68 /** Caller indicator. */ 69 typedef enum VBOXDTCALLER 70 { 71 kVBoxDtCaller_Invalid = 0, 72 kVBoxDtCaller_Generic, 73 kVBoxDtCaller_ProbeFireUser, 74 kVBoxDtCaller_ProbeFireKernel 75 } VBOXDTCALLER; 76 68 77 69 78 /** … … 71 80 * stack argument later. 72 81 */ 73 typedef struct SUPDRVDTSTACKDATA82 typedef struct VBDTSTACKDATA 74 83 { 75 84 /** Eyecatcher no. 1 (SUPDRVDT_STACK_DATA_MAGIC2). */ … … 77 86 /** Eyecatcher no. 2 (SUPDRVDT_STACK_DATA_MAGIC2). */ 78 87 uint32_t u32Magic2; 79 /** Pointer to the stack arguments of a probe function call. */ 80 uintptr_t *pauStackArgs; 88 /** The format of the caller specific data. */ 89 VBOXDTCALLER enmCaller; 90 /** Caller specific data. */ 91 union 92 { 93 /** kVBoxDtCaller_ProbeFireKernel. */ 94 struct 95 { 96 /** Pointer to the stack arguments of a probe function call. */ 97 uintptr_t *pauStackArgs; 98 } ProbeFireKernel; 99 /** kVBoxDtCaller_ProbeFireUser. */ 100 struct 101 { 102 /** The user context. */ 103 PCSUPDRVTRACERUSRCTX pCtx; 104 /** The argument displacement caused by 64-bit arguments passed directly to 105 * dtrace_probe. */ 106 int offArg; 107 } ProbeFireUser; 108 } u; 81 109 /** Pointer to this structure. 82 110 * This is the final bit of integrity checking. */ 83 struct SUPDRVDTSTACKDATA*pSelf;84 } SUPDRVDTSTACKDATA;111 struct VBDTSTACKDATA *pSelf; 112 } VBDTSTACKDATA; 85 113 /** Pointer to the on-stack thread specific data. */ 86 typedef SUPDRVDTSTACKDATA *PSUPDRVDTSTACKDATA;114 typedef VBDTSTACKDATA *PVBDTSTACKDATA; 87 115 88 116 … … 101 129 102 130 /** Plants the stack data. */ 103 #define SUPDRVDT_SETUP_STACK_DATA() \104 uint8_t abBlob[sizeof( SUPDRVDTSTACKDATA) + SUPDRVDT_STACK_DATA_ALIGN - 1]; \105 P SUPDRVDTSTACKDATA pStackData = (PSUPDRVDTSTACKDATA)( (uintptr_t)&abBlob[SUPDRVDT_STACK_DATA_ALIGN - 1] \106 131 #define VBDT_SETUP_STACK_DATA(a_enmCaller) \ 132 uint8_t abBlob[sizeof(VBDTSTACKDATA) + SUPDRVDT_STACK_DATA_ALIGN - 1]; \ 133 PVBDTSTACKDATA pStackData = (PVBDTSTACKDATA)( (uintptr_t)&abBlob[SUPDRVDT_STACK_DATA_ALIGN - 1] \ 134 & ~(uintptr_t)(SUPDRVDT_STACK_DATA_ALIGN - 1)); \ 107 135 pStackData->u32Magic1 = SUPDRVDT_STACK_DATA_MAGIC1; \ 108 136 pStackData->u32Magic2 = SUPDRVDT_STACK_DATA_MAGIC2; \ 137 pStackData->enmCaller = a_enmCaller; \ 109 138 pStackData->pSelf = pStackData 110 139 111 140 /** Passifies the stack data and frees up resource held within it. */ 112 #define SUPDRVDT_CLEAR_STACK_DATA() \141 #define VBDT_CLEAR_STACK_DATA() \ 113 142 do \ 114 143 { \ … … 151 180 152 181 182 /** 183 * Gets the stack data. 184 * 185 * @returns Pointer to the stack data. Never NULL. 186 */ 187 static PVBDTSTACKDATA vboxDtGetStackData(void) 188 { 189 /* 190 * Locate the caller of probe_dtrace. 191 */ 192 int volatile iDummy = 1; /* use this to get the stack address. */ 193 PVBDTSTACKDATA pData = (PVBDTSTACKDATA)( ((uintptr_t)&iDummy + SUPDRVDT_STACK_DATA_ALIGN - 1) 194 & ~(uintptr_t)(SUPDRVDT_STACK_DATA_ALIGN - 1)); 195 for (;;) 196 { 197 if ( pData->u32Magic1 == SUPDRVDT_STACK_DATA_MAGIC1 198 && pData->u32Magic2 == SUPDRVDT_STACK_DATA_MAGIC2 199 && pData->pSelf == pData) 200 return pData; 201 pData = (PVBDTSTACKDATA)((uintptr_t)pData + SUPDRVDT_STACK_DATA_ALIGN); 202 } 203 } 204 205 153 206 /* 154 207 * … … 181 234 * @param offStrTab The string table offset. 182 235 */ 183 static const char *vboxDtVtgGetString(PVTGOBJHDR pVtgHdr, 236 static const char *vboxDtVtgGetString(PVTGOBJHDR pVtgHdr, uint32_t offStrTab) 184 237 { 185 238 Assert(offStrTab < pVtgHdr->cbStrTab); 186 return &pVtgHdr->pachStrTab[offStrTab];239 return (const char *)pVtgHdr + pVtgHdr->offStrTab + offStrTab; 187 240 } 188 241 … … 201 254 * @callback_method_impl{dtrace_pops_t,dtps_provide} 202 255 */ 203 static void supdrvDtPOps_Provide(void *pvProv, const dtrace_probedesc_t *pDtProbeDesc)204 { 205 PSUPDRVVDTPROVIDERCORE pProv 256 static void vboxDtPOps_Provide(void *pvProv, const dtrace_probedesc_t *pDtProbeDesc) 257 { 258 PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv; 206 259 AssertPtrReturnVoid(pProv); 207 LOG_DTRACE(("supdrvDtPOps_Provide: %p / %p pDtProbeDesc=%p\n", pProv, pProv->TracerData.DTrace.idProvider, pDtProbeDesc)); 208 size_t const cbFnNmBuf = _4K + _1K; 209 char *pszFnNmBuf; 210 uint16_t idxProv; 260 LOG_DTRACE(("%s: %p / %p pDtProbeDesc=%p\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, pDtProbeDesc)); 211 261 212 262 if (pDtProbeDesc) … … 216 266 return; 217 267 218 dtrace_provider_id_t idProvider= pProv->TracerData.DTrace.idProvider;268 dtrace_provider_id_t const idProvider = pProv->TracerData.DTrace.idProvider; 219 269 AssertPtrReturnVoid(idProvider); 220 270 221 271 AssertPtrReturnVoid(pProv->pHdr); 222 PVTGPROBELOC pProbeLoc = pProv->pHdr->paProbLocs; 223 AssertPtrReturnVoid(pProbeLoc); 224 PVTGPROBELOC pProbeLocEnd = pProv->pHdr->paProbLocsEnd; 225 AssertPtrReturnVoid(pProbeLocEnd); 226 if (pProv->TracerData.DTrace.cProvidedProbes >= (uintptr_t)(pProbeLocEnd - pProbeLoc)) 227 return; 228 229 /* Need a buffer for extracting the function names and mangling them in 230 case of collision. */ 231 pszFnNmBuf = (char *)RTMemAlloc(cbFnNmBuf); 232 if (!pszFnNmBuf) 272 AssertReturnVoid(pProv->pHdr->offProbeLocs != 0); 273 uint32_t const cProbeLocs = pProv->pHdr->cbProbeLocs / sizeof(VTGPROBELOC); 274 275 /* Need a buffer for extracting the function names and mangling them in 276 case of collision. */ 277 size_t const cbFnNmBuf = _4K + _1K; 278 char *pszFnNmBuf = (char *)RTMemAlloc(cbFnNmBuf); 279 if (!pszFnNmBuf) 233 280 return; 234 281 235 /* 236 * Itereate the probe location list and register all probes related to 237 * this provider. 238 */ 239 idxProv = (uint16_t)(&pProv->pHdr->paProviders[0] - pProv->pDesc); 240 while ((uintptr_t)pProbeLoc < (uintptr_t)pProbeLocEnd) 241 { 242 PVTGDESCPROBE pProbeDesc = (PVTGDESCPROBE)pProbeLoc->pbProbe; 243 if ( pProbeDesc->idxProvider == idxProv 244 && pProbeLoc->idProbe == UINT32_MAX) 282 /* 283 * Itereate the probe location list and register all probes related to 284 * this provider. 285 */ 286 uint16_t const idxProv = (uint16_t)((PVTGDESCPROVIDER)((uintptr_t)pProv->pHdr + pProv->pHdr->offProviders) - pProv->pDesc); 287 for (uint32_t idxProbeLoc = 0; idxProbeLoc < cProbeLocs; idxProbeLoc++) 288 { 289 /* Skip probe location belonging to other providers or once that 290 we've already reported. */ 291 PCVTGPROBELOC pProbeLocRO = &pProv->paProbeLocsRO[idxProbeLoc]; 292 PVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe; 293 if (pProbeDesc->idxProvider != idxProv) 294 continue; 295 296 uint32_t *pidProbe; 297 if (!pProv->fUmod) 298 pidProbe = (uint32_t *)&pProbeLocRO->idProbe; 299 else 300 pidProbe = &pProv->paR0ProbeLocs[idxProbeLoc].idProbe; 301 if (*pidProbe != 0) 302 continue; 303 304 /* The function name may need to be stripped since we're using C++ 305 compilers for most of the code. ASSUMES nobody are brave/stupid 306 enough to use function pointer returns without typedef'ing 307 properly them (e.g. signal). */ 308 const char *pszPrbName = vboxDtVtgGetString(pProv->pHdr, pProbeDesc->offName); 309 const char *pszFunc = pProbeLocRO->pszFunction; 310 const char *psz = strchr(pProbeLocRO->pszFunction, '('); 311 size_t cch; 312 if (psz) 245 313 { 246 /* The function name normally needs to be stripped since we're 247 using C++ compilers for most of the code. ASSUMES nobody are 248 brave/stupid enough to use function pointer returns without 249 typedef'ing properly them. */ 250 const char *pszPrbName = vboxDtVtgGetString(pProv->pHdr, pProbeDesc->offName); 251 const char *pszFunc = pProbeLoc->pszFunction; 252 const char *psz = strchr(pProbeLoc->pszFunction, '('); 253 size_t cch; 254 if (psz) 314 /* skip blanks preceeding the parameter parenthesis. */ 315 while ( (uintptr_t)psz > (uintptr_t)pProbeLocRO->pszFunction 316 && RT_C_IS_BLANK(psz[-1])) 317 psz--; 318 319 /* Find the start of the function name. */ 320 pszFunc = psz - 1; 321 while ((uintptr_t)pszFunc > (uintptr_t)pProbeLocRO->pszFunction) 255 322 { 256 /* skip blanks preceeding the parameter parenthesis. */ 257 while ( (uintptr_t)psz > (uintptr_t)pProbeLoc->pszFunction 258 && RT_C_IS_BLANK(psz[-1])) 259 psz--; 260 261 /* Find the start of the function name. */ 262 pszFunc = psz - 1; 263 while ((uintptr_t)pszFunc > (uintptr_t)pProbeLoc->pszFunction) 264 { 265 char ch = pszFunc[-1]; 266 if (!RT_C_IS_ALNUM(ch) && ch != '_' && ch != ':') 267 break; 268 pszFunc--; 269 } 270 cch = psz - pszFunc; 323 char ch = pszFunc[-1]; 324 if (!RT_C_IS_ALNUM(ch) && ch != '_' && ch != ':') 325 break; 326 pszFunc--; 271 327 } 272 else 273 cch = strlen(pszFunc); 274 RTStrCopyEx(pszFnNmBuf, cbFnNmBuf, pszFunc, cch); 275 276 /* Look up the probe, if we have one in the same function, mangle 277 the function name a little to avoid having to deal with having 278 multiple location entries with the same probe ID. (lazy bird) */ 279 Assert(pProbeLoc->idProbe == UINT32_MAX); 328 cch = psz - pszFunc; 329 } 330 else 331 cch = strlen(pszFunc); 332 RTStrCopyEx(pszFnNmBuf, cbFnNmBuf, pszFunc, cch); 333 334 /* Look up the probe, if we have one in the same function, mangle 335 the function name a little to avoid having to deal with having 336 multiple location entries with the same probe ID. (lazy bird) */ 337 Assert(!*pidProbe); 338 if (dtrace_probe_lookup(idProvider, pProv->pszModName, pszFnNmBuf, pszPrbName) != DTRACE_IDNONE) 339 { 340 RTStrPrintf(pszFnNmBuf+cch, cbFnNmBuf - cch, "-%u", pProbeLocRO->uLine); 280 341 if (dtrace_probe_lookup(idProvider, pProv->pszModName, pszFnNmBuf, pszPrbName) != DTRACE_IDNONE) 281 342 { 282 RTStrPrintf(pszFnNmBuf+cch, cbFnNmBuf - cch, "-%u", pProbeLoc->uLine);283 if (dtrace_probe_lookup(idProvider, pProv->pszModName, pszFnNmBuf, pszPrbName) != DTRACE_IDNONE)343 unsigned iOrd = 2; 344 while (iOrd < 128) 284 345 { 285 unsigned iOrd = 2; 286 while (iOrd < 128) 287 { 288 RTStrPrintf(pszFnNmBuf+cch, cbFnNmBuf - cch, "-%u-%u", pProbeLoc->uLine, iOrd); 289 if (dtrace_probe_lookup(idProvider, pProv->pszModName, pszFnNmBuf, pszPrbName) == DTRACE_IDNONE) 290 break; 291 iOrd++; 292 } 293 if (iOrd >= 128) 294 { 295 LogRel(("VBoxDrv: More than 128 duplicate probe location instances %s at line %u in function %s [%s], probe %s\n", 296 pProbeLoc->uLine, pProbeLoc->pszFunction, pszFnNmBuf, pszPrbName)); 297 continue; 298 } 346 RTStrPrintf(pszFnNmBuf+cch, cbFnNmBuf - cch, "-%u-%u", pProbeLocRO->uLine, iOrd); 347 if (dtrace_probe_lookup(idProvider, pProv->pszModName, pszFnNmBuf, pszPrbName) == DTRACE_IDNONE) 348 break; 349 iOrd++; 350 } 351 if (iOrd >= 128) 352 { 353 LogRel(("VBoxDrv: More than 128 duplicate probe location instances %s at line %u in function %s [%s], probe %s\n", 354 pProbeLocRO->uLine, pProbeLocRO->pszFunction, pszFnNmBuf, pszPrbName)); 355 continue; 299 356 } 300 357 } 301 302 /* Create the probe. */303 AssertCompile(sizeof(pProbeLoc->idProbe) == sizeof(dtrace_id_t));304 pProbeLoc->idProbe = dtrace_probe_create(idProvider, pProv->pszModName, pszFnNmBuf, pszPrbName,305 1 /*aframes*/, pProbeLoc);306 pProv->TracerData.DTrace.cProvidedProbes++;307 358 } 308 359 309 pProbeLoc++; 360 /* Create the probe. */ 361 AssertCompile(sizeof(*pidProbe) == sizeof(dtrace_id_t)); 362 *pidProbe = dtrace_probe_create(idProvider, pProv->pszModName, pszFnNmBuf, pszPrbName, 363 1 /*aframes*/, (void *)(uintptr_t)idxProbeLoc); 364 pProv->TracerData.DTrace.cProvidedProbes++; 310 365 } 311 366 312 367 RTMemFree(pszFnNmBuf); 313 LOG_DTRACE((" supdrvDtPOps_Provide: returns\n"));368 LOG_DTRACE(("%s: returns\n", __FUNCTION__)); 314 369 } 315 370 … … 318 373 * @callback_method_impl{dtrace_pops_t,dtps_enable} 319 374 */ 320 static int supdrvDtPOps_Enable(void *pvProv, dtrace_id_t idProbe, void *pvProbe) 321 { 322 PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv; 323 AssertPtrReturn(pProv, EINVAL); 324 LOG_DTRACE(("supdrvDtPOps_Enable: %p / %p - %#x / %p\n", pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe)); 325 AssertPtrReturn(pvProbe, EINVAL); 375 static int vboxDtPOps_Enable(void *pvProv, dtrace_id_t idProbe, void *pvProbe) 376 { 377 PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv; 378 LOG_DTRACE(("%s: %p / %p - %#x / %p\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe)); 326 379 AssertPtrReturn(pProv->TracerData.DTrace.idProvider, EINVAL); 327 380 328 381 if (!pProv->TracerData.DTrace.fZombie) 329 382 { 330 PVTGPROBELOC pProbeLoc = (PVTGPROBELOC)pvProbe; 331 PVTGDESCPROBE pProbeDesc = (PVTGDESCPROBE)pProbeLoc->pbProbe; 332 333 if (!pProbeLoc->fEnabled) 334 { 335 pProbeLoc->fEnabled = 1; 336 if (ASMAtomicIncU32(&pProbeDesc->u32User) == 1) 337 pProv->pHdr->pafProbeEnabled[pProbeDesc->idxEnabled] = 1; 383 uint32_t idxProbeLoc = (uint32_t)(uintptr_t)pvProbe; 384 PVTGPROBELOC32 pProbeLocEn = (PVTGPROBELOC32)( (uintptr_t)pProv->pvProbeLocsEn + idxProbeLoc * pProv->cbProbeLocsEn); 385 PCVTGPROBELOC pProbeLocRO = (PVTGPROBELOC)&pProv->paProbeLocsRO[idxProbeLoc]; 386 PCVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe; 387 uint32_t const idxProbe = pProbeDesc->idxEnabled; 388 389 if (!pProv->fUmod) 390 { 391 if (!pProbeLocEn->fEnabled) 392 { 393 pProbeLocEn->fEnabled = 1; 394 ASMAtomicIncU32(&pProv->pacProbeEnabled[idxProbe]); 395 } 396 } 397 else 398 { 399 /* Update kernel mode structure */ 400 if (!pProv->paR0ProbeLocs[idxProbeLoc].fEnabled) 401 { 402 pProv->paR0ProbeLocs[idxProbeLoc].fEnabled = 1; 403 ASMAtomicIncU32(&pProv->paR0Probes[idxProbe].cEnabled); 404 } 405 406 /* Update user mode structure. */ 407 pProbeLocEn->fEnabled = 1; 408 pProv->pacProbeEnabled[idxProbe] = pProv->paR0Probes[idxProbe].cEnabled; 338 409 } 339 410 } … … 346 417 * @callback_method_impl{dtrace_pops_t,dtps_disable} 347 418 */ 348 static void supdrvDtPOps_Disable(void *pvProv, dtrace_id_t idProbe, void *pvProbe)419 static void vboxDtPOps_Disable(void *pvProv, dtrace_id_t idProbe, void *pvProbe) 349 420 { 350 421 PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv; 351 422 AssertPtrReturnVoid(pProv); 352 LOG_DTRACE((" supdrvDtPOps_Disable: %p / %p - %#x / %p\n", pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe));423 LOG_DTRACE(("%s: %p / %p - %#x / %p\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe)); 353 424 AssertPtrReturnVoid(pvProbe); 354 425 AssertPtrReturnVoid(pProv->TracerData.DTrace.idProvider); … … 356 427 if (!pProv->TracerData.DTrace.fZombie) 357 428 { 358 PVTGPROBELOC pProbeLoc = (PVTGPROBELOC)pvProbe; 359 PVTGDESCPROBE pProbeDesc = (PVTGDESCPROBE)pProbeLoc->pbProbe; 360 AssertPtrReturnVoid(pProbeDesc); 361 362 if (pProbeLoc->fEnabled) 363 { 364 pProbeLoc->fEnabled = 0; 365 if (ASMAtomicDecU32(&pProbeDesc->u32User) == 0) 366 pProv->pHdr->pafProbeEnabled[pProbeDesc->idxEnabled] = 0; 429 uint32_t idxProbeLoc = (uint32_t)(uintptr_t)pvProbe; 430 PVTGPROBELOC32 pProbeLocEn = (PVTGPROBELOC32)( (uintptr_t)pProv->pvProbeLocsEn + idxProbeLoc * pProv->cbProbeLocsEn); 431 PCVTGPROBELOC pProbeLocRO = (PVTGPROBELOC)&pProv->paProbeLocsRO[idxProbeLoc]; 432 PCVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe; 433 uint32_t const idxProbe = pProbeDesc->idxEnabled; 434 435 if (!pProv->fUmod) 436 { 437 if (pProbeLocEn->fEnabled) 438 { 439 pProbeLocEn->fEnabled = 0; 440 ASMAtomicDecU32(&pProv->pacProbeEnabled[idxProbe]); 441 } 442 } 443 else 444 { 445 /* Update kernel mode structure */ 446 if (pProv->paR0ProbeLocs[idxProbeLoc].fEnabled) 447 { 448 pProv->paR0ProbeLocs[idxProbeLoc].fEnabled = 0; 449 ASMAtomicDecU32(&pProv->paR0Probes[idxProbe].cEnabled); 450 } 451 452 /* Update user mode structure. */ 453 pProbeLocEn->fEnabled = 0; 454 pProv->pacProbeEnabled[idxProbe] = pProv->paR0Probes[idxProbe].cEnabled; 367 455 } 368 456 } … … 373 461 * @callback_method_impl{dtrace_pops_t,dtps_getargdesc} 374 462 */ 375 static void supdrvDtPOps_GetArgDesc(void *pvProv, dtrace_id_t idProbe, void *pvProbe,376 463 static void vboxDtPOps_GetArgDesc(void *pvProv, dtrace_id_t idProbe, void *pvProbe, 464 dtrace_argdesc_t *pArgDesc) 377 465 { 378 466 PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv; … … 381 469 pArgDesc->dtargd_ndx = DTRACE_ARGNONE; 382 470 AssertPtrReturnVoid(pProv); 383 LOG_DTRACE((" supdrvDtPOps_GetArgDesc: %p / %p - %#x / %p uArg=%d\n", pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe, uArg));471 LOG_DTRACE(("%s: %p / %p - %#x / %p uArg=%d\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe, uArg)); 384 472 AssertPtrReturnVoid(pvProbe); 385 473 AssertPtrReturnVoid(pProv->TracerData.DTrace.idProvider); … … 387 475 if (!pProv->TracerData.DTrace.fZombie) 388 476 { 389 PVTGPROBELOC pProbeLoc = (PVTGPROBELOC)pvProbe; 390 PVTGDESCPROBE pProbeDesc = (PVTGDESCPROBE)pProbeLoc->pbProbe; 391 AssertPtrReturnVoid(pProbeDesc); 392 AssertPtrReturnVoid(pProv->pHdr); 393 PVTGDESCARGLIST pArgList = (PVTGDESCARGLIST)((uintptr_t)pProv->pHdr->paArgLists + pProbeDesc->offArgList); 394 AssertPtrReturnVoid(pArgList); 395 477 uint32_t idxProbeLoc = (uint32_t)(uintptr_t)pvProbe; 478 PCVTGPROBELOC pProbeLocRO = (PVTGPROBELOC)&pProv->paProbeLocsRO[idxProbeLoc]; 479 PCVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe; 480 PCVTGDESCARGLIST pArgList = (PCVTGDESCARGLIST)( (uintptr_t)pProv->pHdr 481 + pProv->pHdr->offArgLists 482 + pProbeDesc->offArgList); 396 483 AssertReturnVoid(pProbeDesc->offArgList < pProv->pHdr->cbArgLists); 484 397 485 if (uArg < pArgList->cArgs) 398 486 { … … 404 492 /** @todo mapping? */ 405 493 pArgDesc->dtargd_ndx = uArg; 406 SUPR0Printf("supdrvDtPOps_GetArgVal: returns dtargd_native = %s for #%u\n", pArgDesc->dtargd_native, uArg); 407 LOG_DTRACE(("supdrvDtPOps_GetArgVal: returns dtargd_native = %s\n", pArgDesc->dtargd_native)); 494 LOG_DTRACE(("%s: returns dtargd_native = %s\n", __FUNCTION__, pArgDesc->dtargd_native)); 408 495 return; 409 496 } 410 497 } 411 498 } 412 SUPR0Printf("supdrvDtPOps_GetArgVal: returns faiure for #%u\n", uArg);413 499 } 414 500 … … 446 532 * 447 533 */ 448 static uint64_t supdrvDtPOps_GetArgVal(void *pvProv, dtrace_id_t idProbe, void *pvProbe,449 450 { 451 PSUPDRVVDTPROVIDERCORE pProv 534 static uint64_t vboxDtPOps_GetArgVal(void *pvProv, dtrace_id_t idProbe, void *pvProbe, 535 int iArg, int cFrames) 536 { 537 PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv; 452 538 AssertPtrReturn(pProv, UINT64_MAX); 453 LOG_DTRACE((" supdrvDtPOps_GetArgVal: %p / %p - %#x / %p iArg=%d cFrames=%u\n", pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe, iArg, cFrames));539 LOG_DTRACE(("%s: %p / %p - %#x / %p iArg=%d cFrames=%u\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe, iArg, cFrames)); 454 540 AssertReturn(iArg >= 5, UINT64_MAX); 455 AssertPtrReturn(pvProbe, UINT64_MAX); 456 AssertReturn(!pProv->TracerData.DTrace.fZombie, UINT64_MAX); 457 AssertPtrReturn(pProv->TracerData.DTrace.idProvider, UINT64_MAX); 458 PVTGPROBELOC pProbeLoc = (PVTGPROBELOC)pvProbe; 459 AssertPtrReturn(pProbeLoc, UINT64_MAX); 460 PVTGDESCPROBE pProbe = (PVTGDESCPROBE)pProbeLoc->pbProbe; 461 AssertPtrReturn(pProbe, UINT64_MAX); 462 PVTGDESCARGLIST pArgList = (PVTGDESCARGLIST)((uintptr_t)pProv->pHdr->paArgLists + pProbe->offArgList); 463 AssertPtrReturn(pArgList, UINT64_MAX); 464 465 /* Locate the caller of probe_dtrace, . */ 466 int volatile iDummy = 1; /* use this to get the stack address. */ 467 PSUPDRVDTSTACKDATA pData = (PSUPDRVDTSTACKDATA)( ((uintptr_t)&iDummy + SUPDRVDT_STACK_DATA_ALIGN - 1) 468 & ~(uintptr_t)(SUPDRVDT_STACK_DATA_ALIGN - 1)); 469 for (;;) 470 { 471 if ( pData->u32Magic1 == SUPDRVDT_STACK_DATA_MAGIC1 472 && pData->u32Magic2 == SUPDRVDT_STACK_DATA_MAGIC2 473 && pData->pSelf == pData) 474 break; 475 pData = (PSUPDRVDTSTACKDATA)((uintptr_t)pData + SUPDRVDT_STACK_DATA_ALIGN); 476 } 541 if (pProv->TracerData.DTrace.fZombie) 542 return UINT64_MAX; 543 544 uint32_t idxProbeLoc = (uint32_t)(uintptr_t)pvProbe; 545 PCVTGPROBELOC pProbeLocRO = (PVTGPROBELOC)&pProv->paProbeLocsRO[idxProbeLoc]; 546 PCVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe; 547 PCVTGDESCARGLIST pArgList = (PCVTGDESCARGLIST)( (uintptr_t)pProv->pHdr 548 + pProv->pHdr->offArgLists 549 + pProbeDesc->offArgList); 550 AssertReturn(pProbeDesc->offArgList < pProv->pHdr->cbArgLists, UINT64_MAX); 551 552 PVBDTSTACKDATA pData = vboxDtGetStackData(); 477 553 478 554 /* … … 480 556 * since we want to support 64-bit integer arguments. 481 557 */ 558 uint64_t u64Ret; 559 if (iArg >= 20) 560 u64Ret = UINT64_MAX; 561 else if (pData->enmCaller == kVBoxDtCaller_ProbeFireKernel) 562 { 482 563 #if ARCH_BITS == 64 483 uint64_t u64Ret = pData->pauStackArgs[iArg - 5];564 u64Ret = pData->u.ProbeFireKernel.pauStackArgs[iArg - 5]; 484 565 #else 485 uint64_t u64Ret; 486 if ( !pArgList->fHaveLargeArgs 487 || pArgList->cArgs <= iArg) 488 u64Ret = pData->pauStackArgs[iArg - 5]; 566 if ( !pArgList->fHaveLargeArgs 567 || iArg >= pArgList->cArgs) 568 u64Ret = pData->u.ProbeFireKernel.pauStackArgs[iArg - 5]; 569 else 570 { 571 /* Similar to what we did for mac in when calling dtrace_probe(). */ 572 uint32_t offArg = 0; 573 for (int i = 5; i < iArg; i++) 574 if (VTG_TYPE_IS_LARGE(pArgList->aArgs[iArg].fType)) 575 offArg++; 576 u64Ret = pData->u.ProbeFireKernel.pauStackArgs[iArg - 5 + offArg]; 577 if (VTG_TYPE_IS_LARGE(pArgList->aArgs[iArg].fType)) 578 u64Ret |= (uint64_t)pData->u.ProbeFireKernel.pauStackArgs[iArg - 5 + offArg + 1] << 32; 579 } 580 #endif 581 } 582 else if (pData->enmCaller == kVBoxDtCaller_ProbeFireUser) 583 { 584 int offArg = pData->u.ProbeFireUser.offArg; 585 PCSUPDRVTRACERUSRCTX pCtx = pData->u.ProbeFireUser.pCtx; 586 AssertPtrReturn(pCtx, UINT64_MAX); 587 588 if (pCtx->cBits == 32) 589 { 590 if ( !pArgList->fHaveLargeArgs 591 || iArg >= pArgList->cArgs) 592 { 593 if (iArg + offArg < (int)RT_ELEMENTS(pCtx->u.X86.aArgs)) 594 u64Ret = pCtx->u.Amd64.aArgs[iArg + offArg]; 595 else 596 u64Ret = UINT64_MAX; 597 } 598 else 599 { 600 for (int i = 5; i < iArg; i++) 601 if (VTG_TYPE_IS_LARGE(pArgList->aArgs[iArg].fType)) 602 offArg++; 603 if (offArg + iArg < (int)RT_ELEMENTS(pCtx->u.X86.aArgs)) 604 { 605 u64Ret = pCtx->u.X86.aArgs[iArg + offArg]; 606 if ( VTG_TYPE_IS_LARGE(pArgList->aArgs[iArg].fType) 607 && offArg + iArg + 1 < (int)RT_ELEMENTS(pCtx->u.X86.aArgs)) 608 u64Ret |= (uint64_t)pCtx->u.X86.aArgs[iArg + offArg + 1] << 32; 609 } 610 else 611 u64Ret = UINT64_MAX; 612 } 613 } 614 else 615 { 616 if (iArg + offArg < (int)RT_ELEMENTS(pCtx->u.Amd64.aArgs)) 617 u64Ret = pCtx->u.Amd64.aArgs[iArg + offArg]; 618 else 619 u64Ret = UINT64_MAX; 620 } 621 } 489 622 else 490 { 491 /* Similar to what we did for mac in when calling dtrace_probe(). */ 492 uint32_t off = 0; 493 for (int i = 5; i < iArg; i++) 494 if (VTG_TYPE_IS_LARGE(pArgList->aArgs[iArg].fType)) 495 off++; 496 u64Ret = pData->pauStackArgs[iArg - 5 + off]; 497 if ( (pArgList->aArgs[iArg].fType & VTG_TYPE_FIXED_SIZED) 498 && (pArgList->aArgs[iArg].fType & VTG_TYPE_SIZE_MASK) == 8 ) 499 u64Ret |= (uint64_t)pData->pauStackArgs[iArg - 5 + off + 1] << 32; 500 } 501 #endif 502 503 LOG_DTRACE(("supdrvDtPOps_GetArgVal: returns %#llx\n", u64Ret)); 623 AssertFailedReturn(UINT64_MAX); 624 625 LOG_DTRACE(("%s: returns %#llx\n", __FUNCTION__, u64Ret)); 504 626 return u64Ret; 505 627 } … … 509 631 * @callback_method_impl{dtrace_pops_t,dtps_destroy} 510 632 */ 511 static void supdrvDtPOps_Destroy(void *pvProv, dtrace_id_t idProbe, void *pvProbe)633 static void vboxDtPOps_Destroy(void *pvProv, dtrace_id_t idProbe, void *pvProbe) 512 634 { 513 635 PSUPDRVVDTPROVIDERCORE pProv = (PSUPDRVVDTPROVIDERCORE)pvProv; 514 636 AssertPtrReturnVoid(pProv); 515 LOG_DTRACE((" supdrvDtPOps_Destroy: %p / %p - %#x / %p\n", pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe));637 LOG_DTRACE(("%s: %p / %p - %#x / %p\n", __FUNCTION__, pProv, pProv->TracerData.DTrace.idProvider, idProbe, pvProbe)); 516 638 AssertReturnVoid(pProv->TracerData.DTrace.cProvidedProbes > 0); 517 639 AssertPtrReturnVoid(pProv->TracerData.DTrace.idProvider); … … 519 641 if (!pProv->TracerData.DTrace.fZombie) 520 642 { 521 PVTGPROBELOC pProbeLoc = (PVTGPROBELOC)pvProbe; 522 AssertPtrReturnVoid(pProbeLoc); 523 AssertPtrReturnVoid(pProbeLoc->pszFunction); 524 Assert(!pProbeLoc->fEnabled); 525 AssertReturnVoid(pProbeLoc->idProbe == idProbe); 526 527 pProbeLoc->idProbe = UINT32_MAX; 643 uint32_t idxProbeLoc = (uint32_t)(uintptr_t)pvProbe; 644 PCVTGPROBELOC pProbeLocRO = (PVTGPROBELOC)&pProv->paProbeLocsRO[idxProbeLoc]; 645 uint32_t *pidProbe; 646 if (!pProv->fUmod) 647 { 648 pidProbe = (uint32_t *)&pProbeLocRO->idProbe; 649 Assert(!pProbeLocRO->fEnabled); 650 Assert(*pidProbe == idProbe); 651 } 652 else 653 { 654 pidProbe = &pProv->paR0ProbeLocs[idxProbeLoc].idProbe; 655 Assert(!pProv->paR0ProbeLocs[idxProbeLoc].fEnabled); 656 Assert(*pidProbe == idProbe); NOREF(idProbe); 657 } 658 *pidProbe = 0; 528 659 } 529 660 pProv->TracerData.DTrace.cProvidedProbes--; … … 537 668 static const dtrace_pops_t g_vboxDtVtgProvOps = 538 669 { 539 /* .dtps_provide = */ supdrvDtPOps_Provide,670 /* .dtps_provide = */ vboxDtPOps_Provide, 540 671 /* .dtps_provide_module = */ NULL, 541 /* .dtps_enable = */ (FNPOPS_ENABLE *) supdrvDtPOps_Enable,542 /* .dtps_disable = */ supdrvDtPOps_Disable,672 /* .dtps_enable = */ (FNPOPS_ENABLE *)vboxDtPOps_Enable, 673 /* .dtps_disable = */ vboxDtPOps_Disable, 543 674 /* .dtps_suspend = */ NULL, 544 675 /* .dtps_resume = */ NULL, 545 /* .dtps_getargdesc = */ supdrvDtPOps_GetArgDesc,546 /* .dtps_getargval = */ supdrvDtPOps_GetArgVal,676 /* .dtps_getargdesc = */ vboxDtPOps_GetArgDesc, 677 /* .dtps_getargval = */ vboxDtPOps_GetArgVal, 547 678 /* .dtps_usermode = */ NULL, 548 /* .dtps_destroy = */ supdrvDtPOps_Destroy679 /* .dtps_destroy = */ vboxDtPOps_Destroy 549 680 }; 550 681 … … 563 694 564 695 /** 565 * interface_method_impl{SUPDRVTRACERREG,pfnProbeFire User}566 */ 567 static DECLCALLBACK(void) supdrvDtTOps_ProbeFireKernel(struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,568 696 * interface_method_impl{SUPDRVTRACERREG,pfnProbeFireKernel} 697 */ 698 static DECLCALLBACK(void) vboxDtTOps_ProbeFireKernel(struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2, 699 uintptr_t uArg3, uintptr_t uArg4) 569 700 { 570 701 AssertPtrReturnVoid(pVtgProbeLoc); 571 LOG_DTRACE((" supdrvDtTOps_ProbeFireKernel: %p / %p\n", pVtgProbeLoc, pVtgProbeLoc->idProbe));572 AssertPtrReturnVoid(pVtgProbeLoc->p bProbe);702 LOG_DTRACE(("%s: %p / %p\n", __FUNCTION__, pVtgProbeLoc, pVtgProbeLoc->idProbe)); 703 AssertPtrReturnVoid(pVtgProbeLoc->pProbe); 573 704 AssertPtrReturnVoid(pVtgProbeLoc->pszFunction); 574 705 575 SUPDRVDT_SETUP_STACK_DATA();576 577 pStackData-> pauStackArgs = &uArg4 + 1;706 VBDT_SETUP_STACK_DATA(kVBoxDtCaller_ProbeFireKernel); 707 708 pStackData->u.ProbeFireKernel.pauStackArgs = &uArg4 + 1; 578 709 579 710 #if defined(RT_OS_DARWIN) && ARCH_BITS == 32 … … 585 716 PVTGOBJHDR pVtgHdr = (PVTGOBJHDR)((uintptr_t)pProbe + pProbe->offObjHdr); 586 717 AssertPtrReturnVoid(pVtgHdr); 587 PVTGDESCARGLIST pArgList = (PVTGDESCARGLIST)((uintptr_t)pVtgHdr ->paArgLists + pProbe->offArgList);718 PVTGDESCARGLIST pArgList = (PVTGDESCARGLIST)((uintptr_t)pVtgHdr + pVtgHdr->offArgLists + pProbe->offArgList); 588 719 AssertPtrReturnVoid(pArgList); 589 720 if (!pArgList->fHaveLargeArgs) … … 608 739 au64DstArgs[iDstArg++] = auSrcArgs[iSrcArg++]; 609 740 610 pStackData-> pauStackArgs= &auSrcArgs[iSrcArg];741 pStackData->u.ProbeFireK.pauStackArgs = &auSrcArgs[iSrcArg]; 611 742 dtrace_probe(pVtgProbeLoc->idProbe, au64DstArgs[0], au64DstArgs[1], au64DstArgs[2], au64DstArgs[3], au64DstArgs[4]); 612 743 } … … 615 746 #endif 616 747 617 SUPDRVDT_CLEAR_STACK_DATA();618 LOG_DTRACE((" supdrvDtTOps_ProbeFireKernel: returns\n"));748 VBDT_CLEAR_STACK_DATA(); 749 LOG_DTRACE(("%s: returns\n", __FUNCTION__)); 619 750 } 620 751 … … 623 754 * interface_method_impl{SUPDRVTRACERREG,pfnProbeFireUser} 624 755 */ 625 static DECLCALLBACK(void) supdrvDtTOps_ProbeFireUser(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, PCSUPDRVTRACERUSRCTX pCtx) 626 { 627 NOREF(pThis); NOREF(pSession); NOREF(pCtx); 628 return; 756 static DECLCALLBACK(void) vboxDtTOps_ProbeFireUser(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, PCSUPDRVTRACERUSRCTX pCtx, 757 PCVTGOBJHDR pVtgHdr, PCVTGPROBELOC pProbeLocRO) 758 { 759 LOG_DTRACE(("%s: %p / %p\n", __FUNCTION__, pCtx, pCtx->idProbe)); 760 AssertPtrReturnVoid(pProbeLocRO); 761 AssertPtrReturnVoid(pVtgHdr); 762 763 VBDT_SETUP_STACK_DATA(kVBoxDtCaller_ProbeFireUser); 764 765 if (pCtx->cBits == 32) 766 { 767 pStackData->u.ProbeFireUser.pCtx = pCtx; 768 pStackData->u.ProbeFireUser.offArg = 0; 769 770 #if ARCH_BITS == 64 || defined(RT_OS_DARWIN) 771 /* 772 * Combine two 32-bit arguments into one 64-bit argument where needed. 773 */ 774 PVTGDESCPROBE pProbeDesc = pProbeLocRO->pProbe; 775 AssertPtrReturnVoid(pProbeDesc); 776 PVTGDESCARGLIST pArgList = (PVTGDESCARGLIST)((uintptr_t)pVtgHdr + pVtgHdr->offArgLists + pProbeDesc->offArgList); 777 AssertPtrReturnVoid(pArgList); 778 779 if (!pArgList->fHaveLargeArgs) 780 dtrace_probe(pCtx->idProbe, 781 pCtx->u.X86.aArgs[0], 782 pCtx->u.X86.aArgs[1], 783 pCtx->u.X86.aArgs[2], 784 pCtx->u.X86.aArgs[3], 785 pCtx->u.X86.aArgs[4]); 786 else 787 { 788 uint32_t const *auSrcArgs = &pCtx->u.X86.aArgs[0]; 789 uint32_t iSrcArg = 0; 790 uint32_t iDstArg = 0; 791 uint64_t au64DstArgs[5]; 792 793 while ( iDstArg < RT_ELEMENTS(au64DstArgs) 794 && iSrcArg < pArgList->cArgs) 795 { 796 au64DstArgs[iDstArg] = auSrcArgs[iSrcArg]; 797 if (VTG_TYPE_IS_LARGE(pArgList->aArgs[iDstArg].fType)) 798 au64DstArgs[iDstArg] |= (uint64_t)auSrcArgs[++iSrcArg] << 32; 799 iSrcArg++; 800 iDstArg++; 801 } 802 while (iDstArg < RT_ELEMENTS(au64DstArgs)) 803 au64DstArgs[iDstArg++] = auSrcArgs[iSrcArg++]; 804 805 pStackData->u.ProbeFireUser.offArg = iSrcArg - RT_ELEMENTS(au64DstArgs); 806 dtrace_probe(pCtx->idProbe, au64DstArgs[0], au64DstArgs[1], au64DstArgs[2], au64DstArgs[3], au64DstArgs[4]); 807 } 808 #else 809 dtrace_probe(pCtx->idProbe, 810 pCtx->u.X86.aArgs[0], 811 pCtx->u.X86.aArgs[1], 812 pCtx->u.X86.aArgs[2], 813 pCtx->u.X86.aArgs[3], 814 pCtx->u.X86.aArgs[4]); 815 #endif 816 } 817 else if (pCtx->cBits == 64) 818 { 819 pStackData->u.ProbeFireUser.pCtx = pCtx; 820 pStackData->u.ProbeFireUser.offArg = 0; 821 dtrace_probe(pCtx->idProbe, 822 pCtx->u.Amd64.aArgs[0], 823 pCtx->u.Amd64.aArgs[1], 824 pCtx->u.Amd64.aArgs[2], 825 pCtx->u.Amd64.aArgs[3], 826 pCtx->u.Amd64.aArgs[4]); 827 } 828 else 829 AssertFailed(); 830 831 VBDT_CLEAR_STACK_DATA(); 832 LOG_DTRACE(("%s: returns\n", __FUNCTION__)); 629 833 } 630 834 … … 633 837 * interface_method_impl{SUPDRVTRACERREG,pfnTracerOpen} 634 838 */ 635 static DECLCALLBACK(int) supdrvDtTOps_TracerOpen(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uint32_t uCookie,636 839 static DECLCALLBACK(int) vboxDtTOps_TracerOpen(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uint32_t uCookie, 840 uintptr_t uArg, uintptr_t *puSessionData) 637 841 { 638 842 NOREF(pThis); NOREF(pSession); NOREF(uCookie); NOREF(uArg); … … 645 849 * interface_method_impl{SUPDRVTRACERREG,pfnTracerClose} 646 850 */ 647 static DECLCALLBACK(int) supdrvDtTOps_TracerIoCtl(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData,648 851 static DECLCALLBACK(int) vboxDtTOps_TracerIoCtl(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData, 852 uintptr_t uCmd, uintptr_t uArg, int32_t *piRetVal) 649 853 { 650 854 NOREF(pThis); NOREF(pSession); NOREF(uSessionData); … … 657 861 * interface_method_impl{SUPDRVTRACERREG,pfnTracerClose} 658 862 */ 659 static DECLCALLBACK(void) supdrvDtTOps_TracerClose(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData)863 static DECLCALLBACK(void) vboxDtTOps_TracerClose(PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData) 660 864 { 661 865 NOREF(pThis); NOREF(pSession); NOREF(uSessionData); … … 667 871 * interface_method_impl{SUPDRVTRACERREG,pfnProviderRegister} 668 872 */ 669 static DECLCALLBACK(int) supdrvDtTOps_ProviderRegister(PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore) 670 { 671 LOG_DTRACE(("supdrvDtTOps_ProviderRegister: %p %s/%s\n", pThis, pCore->pszModName, pCore->pszName)); 672 AssertReturn(pCore->TracerData.DTrace.idProvider == UINT32_MAX || pCore->TracerData.DTrace.idProvider == 0, 673 VERR_INTERNAL_ERROR_3); 873 static DECLCALLBACK(int) vboxDtTOps_ProviderRegister(PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore) 874 { 875 LOG_DTRACE(("%s: %p %s/%s\n", __FUNCTION__, pThis, pCore->pszModName, pCore->pszName)); 876 AssertReturn(pCore->TracerData.DTrace.idProvider == 0, VERR_INTERNAL_ERROR_3); 674 877 675 878 PVTGDESCPROVIDER pDesc = pCore->pDesc; … … 683 886 /* Note! DTrace may call us back before dtrace_register returns, so we 684 887 have to point it to pCore->TracerData.DTrace.idProvider. */ 888 AssertCompile(sizeof(dtrace_provider_id_t) == sizeof(pCore->TracerData.DTrace.idProvider)); 685 889 int rc = dtrace_register(pCore->pszName, 686 890 &DtAttrs, … … 690 894 pCore, 691 895 &pCore->TracerData.DTrace.idProvider); 692 LOG_DTRACE(("supdrvDtTOps_ProviderRegister: idProvider=%p\n", pCore->TracerData.DTrace.idProvider));693 896 if (!rc) 694 897 { 695 Assert(pCore->TracerData.DTrace.idProvider != UINT32_MAX && pCore->TracerData.DTrace.idProvider != 0);898 LOG_DTRACE(("%s: idProvider=%p\n", __FUNCTION__, pCore->TracerData.DTrace.idProvider)); 696 899 AssertPtr(pCore->TracerData.DTrace.idProvider); 697 900 rc = VINF_SUCCESS; … … 699 902 else 700 903 { 701 pCore->TracerData.DTrace.idProvider = UINT32_MAX;904 pCore->TracerData.DTrace.idProvider = 0; 702 905 rc = RTErrConvertFromErrno(rc); 703 906 } 704 907 705 LOG_DTRACE((" supdrvDtTOps_ProviderRegister: returns %Rrc\n", rc));908 LOG_DTRACE(("%s: returns %Rrc\n", __FUNCTION__, rc)); 706 909 return rc; 707 910 } … … 711 914 * interface_method_impl{SUPDRVTRACERREG,pfnProviderDeregister} 712 915 */ 713 static DECLCALLBACK(int) supdrvDtTOps_ProviderDeregister(PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore)916 static DECLCALLBACK(int) vboxDtTOps_ProviderDeregister(PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore) 714 917 { 715 918 uintptr_t idProvider = pCore->TracerData.DTrace.idProvider; 716 LOG_DTRACE((" supdrvDtTOps_ProviderDeregister: %p / %p\n", pThis, idProvider));919 LOG_DTRACE(("%s: %p / %p\n", __FUNCTION__, pThis, idProvider)); 717 920 AssertPtrReturn(idProvider, VERR_INTERNAL_ERROR_3); 718 AssertReturn(idProvider != UINT32_MAX && idProvider != 0, VERR_INTERNAL_ERROR_4);719 921 720 922 dtrace_invalidate(idProvider); … … 722 924 if (!rc) 723 925 { 724 pCore->TracerData.DTrace.idProvider = UINT32_MAX;926 pCore->TracerData.DTrace.idProvider = 0; 725 927 rc = VINF_SUCCESS; 726 928 } … … 732 934 } 733 935 734 LOG_DTRACE((" supdrvDtTOps_ProviderDeregister: returns %Rrc\n", rc));936 LOG_DTRACE(("%s: returns %Rrc\n", __FUNCTION__, rc)); 735 937 return rc; 736 938 } … … 740 942 * interface_method_impl{SUPDRVTRACERREG,pfnProviderDeregisterZombie} 741 943 */ 742 static DECLCALLBACK(int) supdrvDtTOps_ProviderDeregisterZombie(PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore)944 static DECLCALLBACK(int) vboxDtTOps_ProviderDeregisterZombie(PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore) 743 945 { 744 946 uintptr_t idProvider = pCore->TracerData.DTrace.idProvider; 745 LOG_DTRACE((" supdrvDtTOps_ProviderDeregisterZombie: %p / %p\n", pThis, idProvider));947 LOG_DTRACE(("%s: %p / %p\n", __FUNCTION__, pThis, idProvider)); 746 948 AssertPtrReturn(idProvider, VERR_INTERNAL_ERROR_3); 747 AssertReturn(idProvider != UINT32_MAX && idProvider != 0, VERR_INTERNAL_ERROR_4);748 949 Assert(pCore->TracerData.DTrace.fZombie); 749 950 … … 751 952 if (!rc) 752 953 { 753 pCore->TracerData.DTrace.idProvider = UINT32_MAX;954 pCore->TracerData.DTrace.idProvider = 0; 754 955 rc = VINF_SUCCESS; 755 956 } … … 760 961 } 761 962 762 LOG_DTRACE((" supdrvDtTOps_ProviderDeregisterZombie: returns %Rrc\n", rc));963 LOG_DTRACE(("%s: returns %Rrc\n", __FUNCTION__, rc)); 763 964 return rc; 764 965 } … … 769 970 * The tracer registration record of the VBox DTrace implementation 770 971 */ 771 static SUPDRVTRACERREG g_ supdrvDTraceReg =972 static SUPDRVTRACERREG g_VBoxDTraceReg = 772 973 { 773 974 SUPDRVTRACERREG_MAGIC, 774 975 SUPDRVTRACERREG_VERSION, 775 supdrvDtTOps_ProbeFireKernel,776 supdrvDtTOps_ProbeFireUser,777 supdrvDtTOps_TracerOpen,778 supdrvDtTOps_TracerIoCtl,779 supdrvDtTOps_TracerClose,780 supdrvDtTOps_ProviderRegister,781 supdrvDtTOps_ProviderDeregister,782 supdrvDtTOps_ProviderDeregisterZombie,976 vboxDtTOps_ProbeFireKernel, 977 vboxDtTOps_ProbeFireUser, 978 vboxDtTOps_TracerOpen, 979 vboxDtTOps_TracerIoCtl, 980 vboxDtTOps_TracerClose, 981 vboxDtTOps_ProviderRegister, 982 vboxDtTOps_ProviderDeregister, 983 vboxDtTOps_ProviderDeregisterZombie, 783 984 SUPDRVTRACERREG_MAGIC 784 985 }; … … 834 1035 #endif 835 1036 836 return &g_ supdrvDTraceReg;1037 return &g_VBoxDTraceReg; 837 1038 } 838 1039 -
trunk/src/VBox/HostDrivers/Support/SUPDrvTracer.cpp
r41117 r41130 617 617 MY_CHECK_RET(paProbeLocs[i].idProbe == 0, VERR_SUPDRV_VTG_BAD_PROBE_LOC); 618 618 MY_WITHIN_IMAGE(paProbeLocs[i].pszFunction, VERR_SUPDRV_VTG_BAD_PROBE_LOC); 619 offTmp = (uintptr_t)paProbeLocs[i].p bProbe - (uintptr_t)pVtgHdr->offProbes - (uintptr_t)pVtgHdr;619 offTmp = (uintptr_t)paProbeLocs[i].pProbe - (uintptr_t)pVtgHdr->offProbes - (uintptr_t)pVtgHdr; 620 620 MY_CHECK_RET(offTmp < pVtgHdr->cbProbes, VERR_SUPDRV_VTG_BAD_PROBE_LOC); 621 621 MY_CHECK_RET(offTmp / sizeof(VTGDESCPROBE) * sizeof(VTGDESCPROBE) == offTmp, VERR_SUPDRV_VTG_BAD_PROBE_LOC); … … 1738 1738 } 1739 1739 paDst[i].pszFunction = pchStrTab + paSrc[i].pszFunction; 1740 paDst[i].p bProbe = (uint8_t *)(paSrc[i].pbProbe + offDelta);1740 paDst[i].pProbe = (PVTGDESCPROBE)(uintptr_t)(paSrc[i].pProbe + offDelta); 1741 1741 } 1742 1742 } … … 1757 1757 } 1758 1758 paDst[i].pszFunction = pchStrTab + (uintptr_t)paSrc[i].pszFunction; 1759 paDst[i].p bProbe = (uint8_t *)(uintptr_t)(paSrc[i].pbProbe + offDelta);1759 paDst[i].pProbe = (PVTGDESCPROBE)(uintptr_t)(paSrc[i].pProbe + offDelta); 1760 1760 } 1761 1761 } … … 2149 2149 if (RT_LIKELY(pUmod->aProbeLocs[iProbeLoc].fEnabled)) 2150 2150 { 2151 PSUPDRVVTGCOPY pVtgCopy; 2151 2152 ASMAtomicIncU32(&pDevExt->cTracerCallers); 2153 pVtgCopy = pUmod->pVtgCopy; 2152 2154 if (RT_LIKELY( pDevExt->pTracerOps 2153 && !pDevExt->fTracerUnloading)) 2155 && !pDevExt->fTracerUnloading 2156 && pVtgCopy)) 2154 2157 { 2158 PCVTGPROBELOC pProbeLocRO; 2159 pProbeLocRO = (PCVTGPROBELOC)((uintptr_t)&pVtgCopy->Hdr + pVtgCopy->Hdr.offProbeLocs) + iProbeLoc; 2160 2155 2161 pCtx->idProbe = pUmod->aProbeLocs[iProbeLoc].idProbe; 2156 pDevExt->pTracerOps->pfnProbeFireUser(pDevExt->pTracerOps, pSession, pCtx );2162 pDevExt->pTracerOps->pfnProbeFireUser(pDevExt->pTracerOps, pSession, pCtx, &pVtgCopy->Hdr, pProbeLocRO); 2157 2163 } 2158 2164 ASMAtomicDecU32(&pDevExt->cTracerCallers); -
trunk/src/bldprogs/VBoxTpG.cpp
r41117 r41130 969 969 { 970 970 ScmStreamPrintf(pStrm, 971 "extern uint32_t g_cVTGProbeEnabled_%s_%s;\n"972 "extern uint8_tg_VTGProbeData_%s_%s;\n"973 "DECLASM(void) VTGProbeStub_%s_%s(PVTGPROBELOC",971 "extern uint32_t g_cVTGProbeEnabled_%s_%s;\n" 972 "extern VTGDESCPROBE g_VTGProbeData_%s_%s;\n" 973 "DECLASM(void) VTGProbeStub_%s_%s(PVTGPROBELOC", 974 974 pProv->pszName, pProbe->pszMangledName, 975 975 pProv->pszName, pProbe->pszMangledName,
Note:
See TracChangeset
for help on using the changeset viewer.