3 # infos = [file, ref, level, type of declaration, parent (if level>1), name, type (base type or ref dwarf), global, size, address]
4 # type of declaration : base_type, pointer_type, const_type, structure_type, member, enumeration_type, enumerator
11 my ($argument) = @ARGV;
13 my $executable = $argument;
14 open (FILE, $executable) or die "E/S : $!\n";
23 my $ref=0; my $parent_ref=0;
24 my $type_decl="undef";
32 while ($ligne=<FILE>) {
34 @champs = split /\s+/, $ligne;
38 if ($champs[0] eq "<") { # new declaration
40 # save last information in infos
42 my @entry = ($file, $ref, $level, $type_decl, $parent_ref, $name, $type, $global, $size, $address);
47 my @lr = split /></, $champs[1];
49 if($lr[0] > 0){ # level = 0, information about source file
59 $level = $lr[0]; # level
60 $ref = substr($lr[1], 0, length($lr[1]) -1 ); # dwarf ref
61 $type_decl = $champs[2];
63 }else{ # create new hashtable
73 case "DW_AT_name" { $name = substr($champs[2], 1, length($champs[2]) - 2); }
74 case "DW_AT_type" { $type = substr($champs[2], 1, length($champs[2]) - 2); }
75 case "DW_AT_byte_size" { $size = hex($champs[2]); }
76 case "DW_AT_external" { $global = 1; }
77 case "DW_AT_location" {
79 $address = $champs[3];
86 #print $champs[1]." ".$champs[2]."\n";
91 # save last information in infos
92 my @entry = ($file, $ref, $level, $type_decl, $parent_ref, $name, $type, $global, $size, $address);
97 printf "%5s %12s %6s %30s %11s %60s %15s %9s %5s %10s\n", "file", "ref", "level", "type of declaration", "parent", "name", "type", "isGlobal", "size", "address";
98 for($i = 0; $i < @infos; $i++){
99 printf "%5s %12s %6s %30s %11s %60s %15s %9s %5s %10s\n", $infos[$i]->[0], $infos[$i]->[1], $infos[$i]->[2], $infos[$i]->[3], $infos[$i]->[4], $infos[$i]->[5], $infos[$i]->[6], $infos[$i]->[7], $infos[$i]->[8], $infos[$i]->[9];