Leaked source code of windows server 2003
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.

244 lines
6.1 KiB

  1. @rem = '-*- Mode: Perl -*-
  2. @goto endofperl
  3. ';
  4. require "..\\perl\\lib\\getopts.pl" ;
  5. %modules = () ;
  6. %objs = () ;
  7. %pagesizes = () ;
  8. $line = 0 ;
  9. $H = "[0-9A-Fa-f]";
  10. do Getopts ('smor') ;
  11. die "Invalid arguments\n\nUsage: mapsum [-s] [-m] [-o] [-r] <file list>"
  12. if ($#ARGV == -1) ;
  13. die "Need to specify -m (modules), -s (summary), -o (objects), -r (raw)\n\nUsage: mapsum [-s] [-m] [-o] [-r]<file list>"
  14. if (!($opt_s || $opt_o || $opt_m || $opt_r)) ;
  15. print "Processing summary info..." ;
  16. while (<ARGV>) {
  17. chop;
  18. $line++ ;
  19. last if (/publics\s+by\s+value/i) ;
  20. if (/preferred\s+load\s+address\s+is\s+($H+)/i) {
  21. $loadaddr = hex($1) ;
  22. }
  23. if (/[^:]:$H+\s+($H+)H\s+\S+\s+(\S+)/) {
  24. $size = hex($1) ;
  25. $page = $2 ;
  26. if (/rsrc/) {
  27. $rsrcsize += $size ;
  28. } else {
  29. $pagesizes{$page} += $size ;
  30. }
  31. }
  32. }
  33. print "(complete)\n" ;
  34. print "Processing modules..." ;
  35. $lastaddr = "" ;
  36. $lastobj = "" ;
  37. $lastmod = "" ;
  38. $neednewline = 1 ;
  39. while (<ARGV>) {
  40. chop ;
  41. $line++ ;
  42. if (($line % 800) == 0) {
  43. print "." ;
  44. $neednewline = 1 ;
  45. }
  46. last if (/static symbols/i) ;
  47. if (/($H+) ([ f]) ([^: ]+:)?(\S+)$/)
  48. {
  49. # Get the address
  50. $addr = hex($1) ;
  51. # print "1: $1 - 2: $2 - 3: $3 - 4: $4 \n";
  52. $fun = ($2 eq "f") ;
  53. # Get the module - remove extra : - it may be null
  54. $mod = $3 ;
  55. chop $mod ;
  56. $mod = "(unassigned)" if (!$mod) ;
  57. # Get the object file
  58. $obj = $4 ;
  59. $obj = "(unassigned)" if (!$obj) ;
  60. if ($lastaddr) {
  61. $size = $addr - $lastaddr ;
  62. # print "$line:$lastaddr - $addr - $lastmod - $lastobj - $size\n" ;
  63. if ($size >= 0) {
  64. ($f,$d) = split(",",$modules{$lastmod}) ;
  65. if ($fun) {
  66. $f += $size ;
  67. } else {
  68. $d += $size ;
  69. }
  70. $modules{$lastmod} = join (",",$f,$d) ;
  71. $objkey = join(",",$lastmod,$lastobj) ;
  72. ($f,$d) = split(",",$objs{$objkey}) ;
  73. if ($fun) {
  74. $f += $size ;
  75. } else {
  76. $d += $size ;
  77. }
  78. $objs{$objkey} = join (",",$f,$d) ;
  79. } else {
  80. if ($neednewline) {
  81. print "\n" ;
  82. $neednewline = 0 ;
  83. }
  84. print "$line:Negative size - ignoring.\n" ;
  85. print "$line:$lastaddr - $addr - $lastmod - $lastobj - $size\n" ;
  86. }
  87. }
  88. $lastaddr = $addr ;
  89. $lastmod = $mod ;
  90. $lastobj = $obj ;
  91. }
  92. }
  93. print "(complete)\n" ;
  94. # --------------------------------
  95. # Summary
  96. # --------------------------------
  97. if ($opt_s) {
  98. print "\n\n" ;
  99. print "Summary Info\n" ;
  100. print "============\n" ;
  101. $total = 0 ;
  102. for (sort (keys %pagesizes)) {
  103. $size = $pagesizes{$_} ;
  104. $total += $size ;
  105. $f = "$_:" ;
  106. printf ("%-20s%9d\n",$f,$size) ;
  107. }
  108. printf ("%-20s%9d\n","Resources",$rsrcsize) ;
  109. $total += $rsrcsize ;
  110. printf ("%-20s=========\n","") ;
  111. printf ("%-20s%9d\n","Total:",$total) ;
  112. }
  113. # --------------------------------
  114. # Modules
  115. # --------------------------------
  116. if ($opt_m) {
  117. print "\n\n" ;
  118. print "Module Info\n" ;
  119. print "============\n" ;
  120. printf ("%-20s%-9s %-9s %-9s\n","Module"," Code "," Data "," Total ") ;
  121. print "================== ========= ========= =========\n" ;
  122. $ftotal = 0 ;
  123. $dtotal = 0 ;
  124. for (sort (keys %modules)) {
  125. ($fsize,$dsize) = split(",",$modules{$_}) ;
  126. $ftotal += $fsize ;
  127. $dtotal += $dsize ;
  128. $f = "$_:" ;
  129. printf ("%-20s%9d %9d %9d\n",$f,$fsize,$dsize,$fsize+$dsize) ;
  130. }
  131. printf ("%-20s========= ========= =========\n","") ;
  132. printf ("%-20s%9d %9d %9d\n","Total:",$ftotal,$dtotal,$ftotal+$dtotal) ;
  133. }
  134. # --------------------------------
  135. # Object files
  136. # --------------------------------
  137. if ($opt_o) {
  138. print "\n\n" ;
  139. print "Object File Info\n" ;
  140. print "============\n" ;
  141. $ftotal = 0 ;
  142. $dtotal = 0 ;
  143. $lastmodname = "" ;
  144. if ($opt_r) {
  145. printf (" %-30s\t%9s\t%9s\t%9s\n","Object File"," Code"," Data"," Total");
  146. printf (" %-30s\t%9s\t%9s\t%9s\n","==========="," ===="," ===="," =====");
  147. }
  148. for (sort (keys %objs)) {
  149. ($mod,$obj) = split(",",$_) ;
  150. ($fsize,$dsize) = split(",",$objs{$_}) ;
  151. if ($lastmodname ne $mod) {
  152. if (!($opt_r)) {
  153. if ($lastmodname ne "") {
  154. printf (" %-20s========= ========= =========\n","") ;
  155. printf (" %-20s%9d %9d %9d\n","Total:",$ftotal,$dtotal,$ftotal+$dtotal) ;
  156. }
  157. print "\n" ;
  158. print "$mod:\n" ;
  159. print "==========\n" ;
  160. printf (" %-30s%-9s %-9s %-9s\n","Object File"," Code "," Data "," Total ") ;
  161. print " ================== ========= ========= =========\n" ;
  162. }
  163. $lastmodname = $mod ;
  164. $ftotal = 0 ;
  165. $dtotal = 0 ;
  166. }
  167. $ftotal += $fsize ;
  168. $dtotal += $dsize ;
  169. $f = "$obj:" ;
  170. $fname = $f ;
  171. if ($opt_r) {
  172. $fname = "$mod/$f" ;
  173. }
  174. printf (" %-30s\t%9d\t%9d\t%9d\n",$fname,$fsize,$dsize,$fsize+$dsize) ;
  175. }
  176. if ($lastmodname ne "") {
  177. printf (" %-20s========= ========= =========\n","") ;
  178. printf (" %-20s%9d %9d %9d\n","Total:",$ftotal,$dtotal,$ftotal+$dtotal) ;
  179. }
  180. }
  181. __END__
  182. :endofperl
  183. @..\perl\bin\perl %0 %1 %2 %3 %4 %5 %6 %7 %8 %9