Changeset 72309 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- May 24, 2018 7:23:34 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/log/tracelogwriter.cpp
r71502 r72309 67 67 /** Number of non static raw binary items in the descriptor. */ 68 68 uint32_t cRawDataNonStatic; 69 /** Pointer to the scratch event data buffer when adding events. */ 70 uint8_t *pbEvt; 69 71 /** Embedded event descriptor. */ 70 72 RTTRACELOGEVTDESC EvtDesc; … … 354 356 355 357 pEvtDescInt->cbEvtData = cbEvtData; 358 if (cbEvtData) 359 { 360 pEvtDescInt->pbEvt = (uint8_t *)RTMemAllocZ(cbEvtData); 361 if (!pEvtDescInt->pbEvt) 362 { 363 RTMemFree(pEvtDescInt); 364 pEvtDescInt = NULL; 365 } 366 } 356 367 } 357 368 … … 514 525 static DECLCALLBACK(int) rtTraceLogWrEvtDescsDestroy(PAVLPVNODECORE pCore, void *pvParam) 515 526 { 527 PRTTRACELOGWREVTDESC pEvtDesc = (PRTTRACELOGWREVTDESC)pCore; 516 528 RT_NOREF(pvParam); 517 529 518 RTMemFree(pCore); 530 RTMemFree(pEvtDesc->pbEvt); 531 RTMemFree(pEvtDesc); 519 532 return VINF_SUCCESS; 520 533 } … … 609 622 610 623 /** 624 * Fills a given buffer with the given event data as described in the given descriptor. 625 * 626 * @returns IPRT status code. 627 * @param pThis The trace log writer instance. 628 * @param pEvtDescInt Pointer to the internal event descriptor. 629 * @param pb The byte buffer to fill. 630 * @param va The event data. 631 */ 632 static int rtTraceLogWrEvtFill(PRTTRACELOGWRINT pThis, PRTTRACELOGWREVTDESC pEvtDescInt, uint8_t *pb, va_list va) 633 { 634 int rc = VINF_SUCCESS; 635 uint8_t *pbCur = pb; 636 637 RT_NOREF(pThis); 638 639 for (unsigned i = 0; i < pEvtDescInt->EvtDesc.cEvtItems; i++) 640 { 641 PCRTTRACELOGEVTITEMDESC pEvtItemDesc = &pEvtDescInt->EvtDesc.paEvtItemDesc[i]; 642 643 size_t cbItem = rtTraceLogWrGetEvtItemDataSz(pEvtItemDesc); 644 switch (cbItem) 645 { 646 case sizeof(uint8_t): 647 *pbCur++ = va_arg(va, /*uint8_t*/ unsigned); 648 break; 649 case sizeof(uint16_t): 650 *(uint16_t *)pbCur = va_arg(va, /*uint16_t*/ unsigned); 651 pbCur += sizeof(uint16_t); 652 break; 653 case sizeof(uint32_t): 654 *(uint32_t *)pbCur = va_arg(va, uint32_t); 655 pbCur += sizeof(uint32_t); 656 break; 657 case sizeof(uint64_t): 658 *(uint64_t *)pbCur = va_arg(va, uint64_t); 659 pbCur += sizeof(uint64_t); 660 break; 661 default: 662 /* Some raw data item. */ 663 Assert(pEvtItemDesc->enmType == RTTRACELOGTYPE_RAWDATA); 664 if (cbItem != 0) 665 { 666 /* Static raw data. */ 667 void *pvSrc = va_arg(va, void *); 668 memcpy(pbCur, pvSrc, cbItem); 669 pbCur += cbItem; 670 } 671 else 672 { 673 AssertMsgFailed(("Not implemented!\n")); 674 rc = VERR_NOT_IMPLEMENTED; 675 } 676 } 677 } 678 679 return rc; 680 } 681 682 683 /** 611 684 * @copydoc FNRTTRACELOGWRSTREAM 612 685 */ … … 843 916 } 844 917 918 919 RTDECL(int) RTTraceLogWrEvtAddLV(RTTRACELOGWR hTraceLogWr, PCRTTRACELOGEVTDESC pEvtDesc, uint32_t fFlags, 920 RTTRACELOGEVTGRPID uGrpId, RTTRACELOGEVTGRPID uParentGrpId, va_list va) 921 { 922 PRTTRACELOGWRINT pThis = hTraceLogWr; 923 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 924 925 int rc = VINF_SUCCESS; 926 PRTTRACELOGWREVTDESC pEvtDescInt = rtTraceLogWrEvtDescGetInternal(pThis, pEvtDesc); 927 if (RT_UNLIKELY(!pEvtDescInt)) 928 rc = rtTraceLogWrEvtDescAdd(pThis, pEvtDesc, &pEvtDescInt); 929 930 if ( RT_SUCCESS(rc) 931 && VALID_PTR(pEvtDescInt)) 932 { 933 TRACELOGEVT Evt; 934 size_t cbEvtData = rtTraceLogWrEvtInit(&Evt, pEvtDescInt, fFlags, uGrpId, uParentGrpId, NULL); 935 936 if (cbEvtData) 937 rc = rtTraceLogWrEvtFill(pThis, pEvtDescInt, pEvtDescInt->pbEvt, va); 938 if (RT_SUCCESS(rc)) 939 rc = rtTraceLogWrEvtStream(pThis, &Evt, pEvtDescInt->pbEvt, cbEvtData, NULL); 940 } 941 942 return rc; 943 } 944 945 946 RTDECL(int) RTTraceLogWrEvtAddL(RTTRACELOGWR hTraceLogWr, PCRTTRACELOGEVTDESC pEvtDesc, uint32_t fFlags, 947 RTTRACELOGEVTGRPID uGrpId, RTTRACELOGEVTGRPID uParentGrpId, ...) 948 { 949 va_list va; 950 va_start(va, uParentGrpId); 951 int rc = RTTraceLogWrEvtAddLV(hTraceLogWr, pEvtDesc, fFlags, uGrpId, uParentGrpId, va); 952 va_end(va); 953 return rc; 954 } 955
Note:
See TracChangeset
for help on using the changeset viewer.