Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
3.3 KiB

  1. #Copyright (c) 1992-2000 Microsoft Corporation
  2. #
  3. #Module Name:
  4. #
  5. # pooltags.pl
  6. #
  7. #Abstract:
  8. #
  9. # WinDbg Extension Api
  10. #
  11. #Environment:
  12. #
  13. # User Mode.
  14. #
  15. #Revision History:
  16. #
  17. # Kshitix K. Sharma (kksharma)
  18. #
  19. #
  20. # Parse pooltags.txt file to generate C-relevant info for pool tags
  21. #
  22. # Expected format of a pooltag description line in pooltags.txt
  23. #
  24. # PPPP - <One line description string>
  25. #
  26. # PPPP is a 4 character max pooltag
  27. #
  28. # Any line which doesn't fit this format is ignored
  29. #
  30. sub EmitFileHeader;
  31. sub NextLine;
  32. sub IsPoolTagDescription;
  33. #####################################################################################
  34. #
  35. # main
  36. #
  37. # Usage pooltags [-o <outfile>] [-i] <infile>
  38. #
  39. #####################################################################################
  40. $g_NumLine = 0;
  41. $PoolTagDesc = {
  42. TAG => 0,
  43. DESCRIPTION => "",
  44. };
  45. while ($arg = shift) {
  46. if ($arg eq "-o") {
  47. $OutFileName = shift;
  48. } elsif ($arg eq "-i") {
  49. $PoolTagTxtFile = shift;
  50. } else {
  51. $PoolTagTxtFile = $arg;
  52. }
  53. }
  54. die "Cannot open file $PoolTagTxtFile\n" if !open(POOLT_FILE, $PoolTagTxtFile);
  55. die "Cannot open file $OutFileName\n" if !open(OUT_FILE, ">" . $OutFileName);
  56. EmitFileHeader();
  57. print OUT_FILE "POOLTAG_DESCRIPTION g_PoolTagDescriptions[] = {\n";
  58. while (IsPoolTagDescription() || NextLine ) {
  59. if (($PoolTag,$Description) = $g_line =~ /^ ?(....) +-\s*(.*)$/) {
  60. ($T1,$T2,$T3,$T4) = $PoolTag =~ /^(.)(.)(.)(.)$/;
  61. $Description =~ s/([\\"])/\\$1/g ;
  62. printf OUT_FILE (" { '%s', '%s', '%s', '%s', \"%s\"},\n", $T1, $T2, $T3, $T4, $Description);
  63. }
  64. } continue {
  65. close POOLT_FILE if eof;
  66. }
  67. print OUT_FILE "};\n";
  68. print OUT_FILE "ULONG g_NumPoolTagDescriptions = sizeof(g_PoolTagDescriptions) / sizeof(POOLTAG_DESCRIPTION);\n";
  69. close OUT_FILE;
  70. #####################################################################################
  71. #
  72. # Subroutines
  73. #
  74. #####################################################################################
  75. sub NextLine {
  76. $g_line = <POOLT_FILE>;
  77. $g_NumLine++;
  78. while ($g_line =~ /\s*\%.*$/) {
  79. # Skip commented lines - ones which beging with %
  80. $g_line = <POOLT_FILE>;
  81. $g_NumLine++;
  82. }
  83. return $g_line;
  84. }
  85. sub IsPoolTagDescription {
  86. # Match PPPP - <Description>
  87. if ($g_line =~ /^ ?.... +- .*$/) {
  88. NextLine;
  89. }
  90. if ($g_line =~ /^([A-Z][A-Z_0-9]+)\s*\((.*)\)$/) {
  91. return 1;
  92. }
  93. return 0;
  94. }
  95. sub EmitFileHeader {
  96. print OUT_FILE "//-------------------------------------".
  97. "--------------------------------------\n";
  98. print OUT_FILE "//\n";
  99. print OUT_FILE "// IMPORTANT: This file is automatically generated.\n";
  100. print OUT_FILE "// Do not edit by hand.\n";
  101. print OUT_FILE "//\n";
  102. print OUT_FILE "// Generated from $PoolTagTxtFile on " . localtime() . "\n";
  103. print OUT_FILE "//\n";
  104. print OUT_FILE "//-------------------------------------".
  105. "--------------------------------------\n\n";
  106. print OUT_FILE "#include \"precomp.h\"\n";
  107. print OUT_FILE "\n\n";
  108. }
  109. #################################################33
  110. #$PoolTagList = {};
  111. #$NumTags = 0;
  112. # $PoolTagDescription = {
  113. # TAG => $PoolTag;
  114. # DESCRIPTION => $Description;
  115. # };
  116. # push ($PoolTagList, $PoolTagDescription);
  117. # $NumPoolTags++;
  118. #