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

#Copyright (c) 1992-2000 Microsoft Corporation
#
#Module Name:
#
# pooltags.pl
#
#Abstract:
#
# WinDbg Extension Api
#
#Environment:
#
# User Mode.
#
#Revision History:
#
# Kshitix K. Sharma (kksharma)
#
#
# Parse pooltags.txt file to generate C-relevant info for pool tags
#
# Expected format of a pooltag description line in pooltags.txt
#
# PPPP - <One line description string>
#
# PPPP is a 4 character max pooltag
#
# Any line which doesn't fit this format is ignored
#
sub EmitFileHeader;
sub NextLine;
sub IsPoolTagDescription;
#####################################################################################
#
# main
#
# Usage pooltags [-o <outfile>] [-i] <infile>
#
#####################################################################################
$g_NumLine = 0;
$PoolTagDesc = {
TAG => 0,
DESCRIPTION => "",
};
while ($arg = shift) {
if ($arg eq "-o") {
$OutFileName = shift;
} elsif ($arg eq "-i") {
$PoolTagTxtFile = shift;
} else {
$PoolTagTxtFile = $arg;
}
}
die "Cannot open file $PoolTagTxtFile\n" if !open(POOLT_FILE, $PoolTagTxtFile);
die "Cannot open file $OutFileName\n" if !open(OUT_FILE, ">" . $OutFileName);
EmitFileHeader();
print OUT_FILE "POOLTAG_DESCRIPTION g_PoolTagDescriptions[] = {\n";
while (IsPoolTagDescription() || NextLine ) {
if (($PoolTag,$Description) = $g_line =~ /^ ?(....) +-\s*(.*)$/) {
($T1,$T2,$T3,$T4) = $PoolTag =~ /^(.)(.)(.)(.)$/;
$Description =~ s/([\\"])/\\$1/g ;
printf OUT_FILE (" { '%s', '%s', '%s', '%s', \"%s\"},\n", $T1, $T2, $T3, $T4, $Description);
}
} continue {
close POOLT_FILE if eof;
}
print OUT_FILE "};\n";
print OUT_FILE "ULONG g_NumPoolTagDescriptions = sizeof(g_PoolTagDescriptions) / sizeof(POOLTAG_DESCRIPTION);\n";
close OUT_FILE;
#####################################################################################
#
# Subroutines
#
#####################################################################################
sub NextLine {
$g_line = <POOLT_FILE>;
$g_NumLine++;
while ($g_line =~ /\s*\%.*$/) {
# Skip commented lines - ones which beging with %
$g_line = <POOLT_FILE>;
$g_NumLine++;
}
return $g_line;
}
sub IsPoolTagDescription {
# Match PPPP - <Description>
if ($g_line =~ /^ ?.... +- .*$/) {
NextLine;
}
if ($g_line =~ /^([A-Z][A-Z_0-9]+)\s*\((.*)\)$/) {
return 1;
}
return 0;
}
sub EmitFileHeader {
print OUT_FILE "//-------------------------------------".
"--------------------------------------\n";
print OUT_FILE "//\n";
print OUT_FILE "// IMPORTANT: This file is automatically generated.\n";
print OUT_FILE "// Do not edit by hand.\n";
print OUT_FILE "//\n";
print OUT_FILE "// Generated from $PoolTagTxtFile on " . localtime() . "\n";
print OUT_FILE "//\n";
print OUT_FILE "//-------------------------------------".
"--------------------------------------\n\n";
print OUT_FILE "#include \"precomp.h\"\n";
print OUT_FILE "\n\n";
}
#################################################33
#$PoolTagList = {};
#$NumTags = 0;
# $PoolTagDescription = {
# TAG => $PoolTag;
# DESCRIPTION => $Description;
# };
# push ($PoolTagList, $PoolTagDescription);
# $NumPoolTags++;
#