Changeset 40594 in vbox
- Timestamp:
- Mar 23, 2012 2:53:06 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 edited
-
include/VBox/VBoxTpG.h (added)
-
src/bldprogs/VBoxTpG.cpp (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/VBoxTpG.cpp
r40589 r40594 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT Testcase / Tool - VBox Tracepoint Compiler.3 * VBox Build Tool - VBox Tracepoint Generator. 4 4 */ 5 5 … … 20 20 * Header Files * 21 21 *******************************************************************************/ 22 #include <VBox/VBoxTpG.h> 23 22 24 #include <iprt/alloca.h> 23 25 #include <iprt/assert.h> … … 465 467 ";\n" 466 468 "%%ifdef ASM_FORMAT_OMF\n" 469 " %%macro VTG_GLOBAL 2\n" 470 " global NAME(%%1)\n" 471 " NAME(%%1):\n" 472 " %%endmacro\n" 467 473 " segment VTG.Obj public CLASS=DATA align=4096 use32\n" 474 "\n" 468 475 "%%elifdef ASM_FORMAT_MACHO\n" 476 " %%macro VTG_GLOBAL 2\n" 477 " global NAME(%%1)\n" 478 " NAME(%%1):\n" 479 " %%endmacro\n" 469 480 " ;[section VTG Obj align=4096]\n" 470 481 " [section .data]\n" 482 "\n" 471 483 "%%elifdef ASM_FORMAT_PE\n" 484 " %%macro VTG_GLOBAL 2\n" 485 " global NAME(%%1)\n" 486 " NAME(%%1):\n" 487 " %%endmacro\n" 472 488 " [section VTGObj align=4096]\n" 473 489 "\n" 474 490 "%%elifdef ASM_FORMAT_ELF\n" 491 " %%macro VTG_GLOBAL 2\n" 492 " global NAME(%%1):%%2 hidden\n" 493 " NAME(%%1):\n" 494 " %%endmacro\n" 475 495 " [section .VTGPrLc.Start progbits alloc noexec write align=1]\n" 476 " dd 42\n" 477 " dd 42\n" 478 " RTCCPTR_DEF 42\n" 479 " RTCCPTR_DEF 42\n" 480 " RTCCPTR_DEF 42\n" 481 "GLOBALNAME g_aVTGPrLc\n" 496 "VTG_GLOBAL g_aVTGPrLc, data\n" 482 497 " [section .VTGPrLc progbits alloc noexec write align=1]\n" 483 498 " [section .VTGPrLc.End progbits alloc noexec write align=1]\n" 484 "GLOBALNAME g_aVTGPrLc_End\n" 485 " dd 0xdeadbeef\n" 486 " dd 0xdeadbeef\n" 487 " RTCCPTR_DEF 0xdeadbeef\n" 488 " RTCCPTR_DEF 0xdeadbeef\n" 489 " RTCCPTR_DEF 0xdeadbeef\n" 490 " [section .VTGObj progbits alloc noexec write align=4096]\n" 499 "VTG_GLOBAL g_aVTGPrLc_End, data\n" 500 " [section .VTGData progbits alloc noexec write align=4096]\n" 501 "\n" 491 502 "%%else\n" 492 503 " %%error \"ASM_FORMAT_XXX is not defined\"\n" 493 504 "%%endif\n" 494 505 "\n" 495 "GLOBALNAME g_VTGObjStart\n" 496 " db 'VBoxTpG Obj v1', 0, 0\n" 497 " RTCCPTR_DEF g_aVTGProviders\n" 498 " RTCCPTR_DEF g_aVTGProviders_End - g_aVTGProviders\n" 499 " RTCCPTR_DEF g_aVTGProbes\n" 500 " RTCCPTR_DEF g_aVTGProbes_End - g_aVTGProbes\n" 501 " RTCCPTR_DEF g_afVTGProbeEnabled\n" 502 " RTCCPTR_DEF g_afVTGProbeEnabled_End - g_afVTGProbeEnabled\n" 503 " RTCCPTR_DEF g_achVTGStringTable\n" 504 " RTCCPTR_DEF g_achVTGStringTable_End - g_achVTGStringTable\n" 505 " RTCCPTR_DEF g_aVTGArgLists\n" 506 " RTCCPTR_DEF g_aVTGArgLists_End - g_aVTGArgLists\n" 507 " RTCCPTR_DEF g_aVTGPrLc\n" 508 " RTCCPTR_DEF g_aVTGPrLc_End ; cross section/segment size not possible\n" 506 "\n" 507 "VTG_GLOBAL g_VTGObjHeader, data\n" 508 " ;0 1 2 3\n" 509 " ;012345678901234567890123456789012\n" 510 " db 'VTG Object Header v1.0', 0, 0\n" 511 " dd %u\n" 512 " dd 0\n" 513 " RTCCPTR_DEF NAME(g_aVTGProviders)\n" 514 " RTCCPTR_DEF NAME(g_aVTGProviders_End) - NAME(g_aVTGProviders)\n" 515 " RTCCPTR_DEF NAME(g_aVTGProbes)\n" 516 " RTCCPTR_DEF NAME(g_aVTGProbes_End) - NAME(g_aVTGProbes)\n" 517 " RTCCPTR_DEF NAME(g_afVTGProbeEnabled)\n" 518 " RTCCPTR_DEF NAME(g_afVTGProbeEnabled_End) - NAME(g_afVTGProbeEnabled)\n" 519 " RTCCPTR_DEF NAME(g_achVTGStringTable)\n" 520 " RTCCPTR_DEF NAME(g_achVTGStringTable_End) - NAME(g_achVTGStringTable)\n" 521 " RTCCPTR_DEF NAME(g_aVTGArgLists)\n" 522 " RTCCPTR_DEF NAME(g_aVTGArgLists_End) - NAME(g_aVTGArgLists)\n" 523 " RTCCPTR_DEF NAME(g_aVTGPrLc)\n" 524 " RTCCPTR_DEF NAME(g_aVTGPrLc_End) ; cross section/segment size not possible\n" 509 525 " RTCCPTR_DEF 0\n" 510 526 " RTCCPTR_DEF 0\n" … … 512 528 " RTCCPTR_DEF 0\n" 513 529 , 514 g_pszScript );530 g_pszScript, g_cBits); 515 531 516 532 /* … … 523 539 "; cache and TLB hits when the probes are disabled.\n" 524 540 ";\n" 525 " GLOBALNAME g_afVTGProbeEnabled\n"541 "VTG_GLOBAL g_afVTGProbeEnabled, data\n" 526 542 ); 527 543 uint32_t cProbes = 0; … … 531 547 { 532 548 ScmStreamPrintf(pStrm, 533 " GLOBALNAME g_fVTGProbeEnabled_%s_%s\n"549 "VTG_GLOBAL g_fVTGProbeEnabled_%s_%s, data\n" 534 550 " db 0\n", 535 551 pProvider->pszName, pProbe->pszName); … … 537 553 } 538 554 } 539 ScmStreamPrintf(pStrm, " GLOBALNAME g_afVTGProbeEnabled_End\n");555 ScmStreamPrintf(pStrm, "VTG_GLOBAL g_afVTGProbeEnabled_End, data\n"); 540 556 if (cProbes >= _32K) 541 557 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Too many probes: %u (max %u)", cProbes, _32K - 1); … … 549 565 "; The string table.\n" 550 566 ";\n" 551 " GLOBALNAME g_achVTGStringTable\n");567 "VTG_GLOBAL g_achVTGStringTable, data\n"); 552 568 g_offStrTab = 0; 553 569 RTStrSpaceEnumerate(&g_StrSpace, generateAssemblyStrTabCallback, pStrm); 554 570 ScmStreamPrintf(pStrm, 555 " GLOBALNAME g_achVTGStringTable_End\n");571 "VTG_GLOBAL g_achVTGStringTable_End, data\n"); 556 572 557 573 /* … … 563 579 "; The argument lists.\n" 564 580 ";\n" 565 " GLOBALNAME g_aVTGArgLists\n");581 "VTG_GLOBAL g_aVTGArgLists, data\n"); 566 582 uint32_t off = 0; 567 583 RTListForEach(&g_ProviderHead, pProvider, VTGPROVIDER, ListEntry) … … 621 637 } 622 638 ScmStreamPrintf(pStrm, 623 " GLOBALNAME g_aVTGArgLists_End\n");639 "VTG_GLOBAL g_aVTGArgLists_End, data\n"); 624 640 625 641 … … 632 648 "; Prob definitions.\n" 633 649 ";\n" 634 " GLOBALNAME g_aVTGProbes\n"650 "VTG_GLOBAL g_aVTGProbes, data\n" 635 651 "\n"); 636 652 uint32_t iProvider = 0; … … 642 658 { 643 659 ScmStreamPrintf(pStrm, 644 " GLOBALNAME g_VTGProbeData_%s_%s; idx=#%4u\n"660 "VTG_GLOBAL g_VTGProbeData_%s_%s, data ; idx=#%4u\n" 645 661 " dd %6u ; name\n" 646 662 " dd %6u ; Argument list offset\n" 647 663 " dw g_fVTGProbeEnabled_%s_%s - g_afVTGProbeEnabled\n" 648 664 " dw %6u ; provider index\n" 665 " dd 0 ; for the application\n" 649 666 , 650 667 pProvider->pszName, pProbe->pszName, iProbe, … … 659 676 iProvider++; 660 677 } 661 ScmStreamPrintf(pStrm, " GLOBALNAME g_aVTGProbes_End\n");678 ScmStreamPrintf(pStrm, "VTG_GLOBAL g_aVTGProbes_End, data\n"); 662 679 663 680 /* … … 669 686 "; Provider data.\n" 670 687 ";\n" 671 " GLOBALNAME g_aVTGProviders\n");688 "VTG_GLOBAL g_aVTGProviders, data\n"); 672 689 iProvider = 0; 673 690 RTListForEach(&g_ProviderHead, pProvider, VTGPROVIDER, ListEntry) … … 696 713 iProvider++; 697 714 } 698 ScmStreamPrintf(pStrm, " GLOBALNAME g_aVTGProviders_End\n");715 ScmStreamPrintf(pStrm, "VTG_GLOBAL g_aVTGProviders_End, data\n"); 699 716 700 717 /* … … 715 732 ScmStreamPrintf(pStrm, 716 733 "\n" 717 " GLOBALNAME VTGProbeStub_%s_%s; (VBOXTPGPROBELOC pVTGProbeLoc",734 "VTG_GLOBAL VTGProbeStub_%s_%s, function; (VBOXTPGPROBELOC pVTGProbeLoc", 718 735 pProvider->pszName, pProbe->pszName); 719 736 RTListForEach(&pProbe->ArgHead, pArg, VTGARG, ListEntry) … … 862 879 "#define %s\n" 863 880 "\n" 864 "#include <iprt/types.h>\n" 865 "\n" 866 "#ifdef _MSC_VER\n" 867 "# define DECL_DATA_SECT(scope, type, name, sect) __declspec(allocate(#sect)) scope type name\n" 868 "#elif defined(__GNUC__)\n" 869 "# ifdef RT_OS_DARWIN\n" 870 "# define DECL_DATA_SECT(scope, type, name, sect) scope type __attribute__((section(#sect \",\" #sect))) name\n" 871 "# else\n" 872 "# define DECL_DATA_SECT(scope, type, name, sect) scope type __attribute__((section(\".\" #sect))) name\n" 873 "# endif\n" 874 "#else\n" 875 "# error portme\n" 876 "#endif\n" 877 "\n" 878 "typedef struct VBOXTPGPROBELOC\n" 879 "{\n" 880 " uint32_t uLine : 31;\n" 881 " uint32_t fEnabled : 1;\n" 882 " uint32_t idProbe;\n" 883 " const char *pszFunction;\n" 884 " const char *pszFile;\n" 885 " uint8_t *pbProbe;\n" 886 "} VBOXTPGPROBELOC;\n" 881 "#include <VBox/VBoxTpG.h>\n" 887 882 "\n" 888 883 "RT_C_DECLS_BEGIN\n" 884 "\n" 885 "#ifdef VBOX_WITH_DTRACE\n" 886 "\n" 889 887 , 890 888 g_pszScript, … … 896 894 */ 897 895 PVTGPROVIDER pProv; 896 PVTGPROBE pProbe; 897 PVTGARG pArg; 898 898 RTListForEach(&g_ProviderHead, pProv, VTGPROVIDER, ListEntry) 899 899 { 900 PVTGPROBE pProbe;901 900 RTListForEach(&pProv->ProbeHead, pProbe, VTGPROBE, ListEntry) 902 901 { 903 PVTGARG pArg;904 902 ScmStreamPrintf(pStrm, 905 903 "extern bool g_fVTGProbeEnabled_%s_%s;\n" 906 904 "extern uint8_t g_VTGProbeData_%s_%s;\n" 907 "DECLASM(void) VTGProbeStub_%s_%s( VBOXTPGPROBELOC *",905 "DECLASM(void) VTGProbeStub_%s_%s(PVTGPROBELOC", 908 906 pProv->pszName, pProbe->pszName, 909 907 pProv->pszName, pProbe->pszName, … … 916 914 ScmStreamPrintf(pStrm, 917 915 ");\n" 918 "# define %s_ENABLED() \\\n"916 "# define %s_ENABLED() \\\n" 919 917 " (RT_UNLIKELY(g_fVTGProbeEnabled_%s_%s)) \n" 920 "# define %s("918 "# define %s(" 921 919 , szTmp, 922 920 pProv->pszName, pProbe->pszName, … … 932 930 ") \\\n" 933 931 " do { \\\n" 934 " if (RT_UNLIKELY( /*g_fVTGProbeEnabled_%s_%s*/ true)) \\\n"932 " if (RT_UNLIKELY(g_fVTGProbeEnabled_%s_%s)) \\\n" 935 933 " { \\\n" 936 " DECL_DATA_SECT(static, VBOXTPGPROBELOC, s_VTGProbeLoc, VTGPrLc) = \\\n"934 " VTG_DECL_VTGPROBELOC(s_VTGProbeLoc) = \\\n" 937 935 " { __LINE__, 0, UINT32_MAX, __PRETTY_FUNCTION__, __FILE__, &g_VTGProbeData_%s_%s }; \\\n" 938 936 " VTGProbeStub_%s_%s(&s_VTGProbeLoc", … … 961 959 } 962 960 961 ScmStreamPrintf(pStrm, 962 "\n" 963 "#else\n" 964 "\n"); 965 RTListForEach(&g_ProviderHead, pProv, VTGPROVIDER, ListEntry) 966 { 967 RTListForEach(&pProv->ProbeHead, pProbe, VTGPROBE, ListEntry) 968 { 969 generateProbeDefineName(szTmp, sizeof(szTmp), pProv->pszName, pProbe->pszName); 970 ScmStreamPrintf(pStrm, 971 "# define %s_ENABLED() (false)\n" 972 "# define %s(" 973 , szTmp, szTmp); 974 RTListForEach(&pProbe->ArgHead, pArg, VTGARG, ListEntry) 975 { 976 if (RTListNodeIsFirst(&pProbe->ArgHead, &pArg->ListEntry)) 977 ScmStreamPrintf(pStrm, "%s", pArg->pszName); 978 else 979 ScmStreamPrintf(pStrm, ", %s", pArg->pszName); 980 } 981 ScmStreamPrintf(pStrm, 982 ") do { } while (0)\n"); 983 } 984 } 985 963 986 ScmStreamWrite(pStrm, RT_STR_TUPLE("\n" 987 "#endif\n" 988 "\n" 964 989 "RT_C_DECLS_END\n" 965 990 "#endif\n")); … … 1441 1466 break; 1442 1467 } 1443 if ( !pProv)1468 if (RTListNodeIsDummy(&g_ProviderHead, pProv, VTGPROVIDER, ListEntry)) 1444 1469 return parseError(pStrm, cchName, "Provider not found"); 1445 1470
Note:
See TracChangeset
for help on using the changeset viewer.

