Codebase list abi-dumper / 41bd68f
Import Upstream version 0.99.7 Mathieu Malaterre 3 years ago
2 changed file(s) with 141 addition(s) and 88 deletion(s). Raw diff Collapse all Expand all
55 RELEASE INFORMATION
66
77 Project: ABI Dumper
8 Version: 0.99.6
9 Date: 2013-09-16
8 Version: 0.99.7
9 Date: 2013-10-25
1010
1111
1212 This file explains how to install and setup environment
00 #!/usr/bin/perl
11 ###########################################################################
2 # ABI Dumper 0.99.6
2 # ABI Dumper 0.99.7
33 # Dump ABI of an ELF object containing DWARF debug info
44 #
55 # Copyright (C) 2013 ROSA Laboratory
4242 use Storable qw(dclone);
4343 use Data::Dumper;
4444
45 my $TOOL_VERSION = "0.99.6";
45 my $TOOL_VERSION = "0.99.7";
4646 my $ABI_DUMP_VERSION = "3.2";
4747 my $ORIG_DIR = cwd();
4848 my $TMP_DIR = tempdir(CLEANUP=>1);
243243
244244 my $STDCXX_TARGET = 0;
245245 my $GLOBAL_ID = 0;
246 my %ANON_TYPE = ();
246247
247248 my %Mangled_ID;
248249 my %Checked_Spec;
270271 "Const"=>"const"
271272 );
272273
273 my $HEADER_EXT = "h|hh|hp|hxx|hpp|h\\+\\+";
274 my $HEADER_EXT = "h|hh|hp|hxx|hpp|h\\+\\+|tcc";
274275 my $SRC_EXT = "c|cpp|cxx|c\\+\\+";
275276
276277 # Other
892893 if(defined $DWARF_Info{$ID}{"decl_file"})
893894 {
894895 my $File = $DWARF_Info{$ID}{"decl_file"};
895 my $Unit = $DWARF_Info{$ID}{"CompUnit"};
896 my $Unit = $DWARF_Info{$ID}{"Unit"};
896897
897898 my $Name = undef;
898899
966967 "encoding" => 1
967968 );
968969
970 my %MarkByUnit = (
971 "member" => 1,
972 "subprogram" => 1,
973 "variable" => 1
974 );
975
969976 my %Excess_IDs;
970 my %Delete_IDs;
971977 my %Delete_Src;
972978
973979 my $Lexical_Block = undef;
980 my $Inlined_Block = undef;
974981 my $Subprogram_Block = undef;
982 my $Skip_Block = undef;
975983
976984 while(($Import and $Line = $ImportedUnit{$Import}{$Import_Num}) or $Line = <$FH>)
977985 {
987995 }
988996 if($ID and $Line=~/\A\s*(\w+)\s*(.+?)\s*\Z/)
989997 {
998
999 if(defined $Skip_Block) {
1000 next;
1001 }
1002
9901003 my ($Attr, $Val) = ($1, $2);
9911004
9921005 if($Kind eq "member"
10101023 $UsedUnit{$Import} = 1;
10111024 }
10121025 }
1026 }
1027 }
1028
1029 if($Kind eq "member")
1030 {
1031 if($Attr eq "data_member_location")
1032 {
1033 delete($DWARF_Info{$ID}{"Unit"});
10131034 }
10141035 }
10151036
11731194 $NS = length($2);
11741195 $Kind = $3;
11751196
1197 $Skip_Block = undef;
1198
1199 if(defined $SkipNode{$Kind})
1200 {
1201 $Skip_Block = 1;
1202 next;
1203 }
1204
1205 if($Kind eq "lexical_block")
1206 {
1207 $Lexical_Block = $NS;
1208 $Skip_Block = 1;
1209 next;
1210 }
1211 else
1212 {
1213 if(defined $Lexical_Block)
1214 {
1215 if($NS>$Lexical_Block)
1216 {
1217 $Skip_Block = 1;
1218 next;
1219 }
1220 else
1221 { # end of lexical block
1222 $Lexical_Block = undef;
1223 }
1224 }
1225 }
1226
1227 if($Kind eq "inlined_subroutine")
1228 {
1229 $Inlined_Block = $NS;
1230 $Skip_Block = 1;
1231 next;
1232 }
1233 else
1234 {
1235 if(defined $Inlined_Block)
1236 {
1237 if($NS>$Inlined_Block)
1238 {
1239 $Skip_Block = 1;
1240 next;
1241 }
1242 else
1243 { # end of inlined subroutine
1244 $Inlined_Block = undef;
1245 }
1246 }
1247 }
1248
1249 if($Kind eq "subprogram")
1250 {
1251 $Subprogram_Block = $NS;
1252 }
1253 else
1254 {
1255 if(defined $Subprogram_Block)
1256 {
1257 if($NS>$Subprogram_Block)
1258 {
1259 if($Kind eq "variable")
1260 { # temp variables
1261 $Skip_Block = 1;
1262 next;
1263 }
1264 }
1265 else
1266 { # end of subprogram block
1267 $Subprogram_Block = undef;
1268 }
1269 }
1270 }
1271
11761272 if($Import or not $Primary)
11771273 {
11781274 $ID = -$ID;
12111307 }
12121308 }
12131309
1214 if($Kind eq "lexical_block")
1215 {
1216 $Lexical_Block = $NS;
1217 $Delete_IDs{$ID} = 1;
1218 }
1219 else
1220 {
1221 if(defined $Lexical_Block)
1222 {
1223 if($NS>$Lexical_Block)
1224 {
1225 $Delete_IDs{$ID} = 1;
1226 }
1227 else
1228 { # end of lexical block
1229 $Lexical_Block = undef;
1230 }
1231 }
1232 }
1233
1234 if($Kind eq "subprogram")
1235 {
1236 $Subprogram_Block = $NS;
1237 }
1238 else
1239 {
1240 if(defined $Subprogram_Block)
1241 {
1242 if($NS>$Subprogram_Block)
1243 {
1244 if($Kind eq "variable")
1245 { # temp variables
1246 $Delete_IDs{$ID} = 1;
1247 }
1248 }
1249 else
1250 { # end of subprogram block
1251 $Subprogram_Block = undef;
1252 }
1253 }
1254 }
1255
12561310 if(defined $ID_Pre)
12571311 {
12581312 my $Kind_Pre = $DWARF_Info{$ID_Pre}{"Kind"};
1259
1260 if(defined $SkipNode{$Kind_Pre}) {
1261 $Delete_IDs{$ID_Pre} = 1;
1262 }
12631313
12641314 if(my $Sp = $DWARF_Info{$ID_Pre}{"specification"})
12651315 {
13021352 {
13031353 delete($Excess_IDs{$Orig});
13041354 }
1305
13061355 }
13071356 }
13081357 elsif($NS==4)
13451394
13461395 $ID_Pre = $ID;
13471396
1348 if(defined $CUnit) {
1349 $DWARF_Info{$ID}{"CompUnit"} = $CUnit;
1397 if(defined $CUnit)
1398 {
1399 if(defined $MarkByUnit{$Kind}
1400 or defined $TypeType{$Kind}) {
1401 $DWARF_Info{$ID}{"Unit"} = $CUnit;
1402 }
13501403 }
13511404
13521405 if(not defined $ID_Shift) {
14581511 %ImportedDecl = ();
14591512 %UsedUnit = ();
14601513 %UsedDecl = ();
1461
1462 foreach my $ID (keys(%Delete_IDs))
1463 {
1464 delete($DWARF_Info{$ID});
1465 }
1466
1467 %Delete_IDs = ();
14681514
14691515 foreach my $ID (keys(%Delete_Src))
14701516 {
16531699 sub read_ABI()
16541700 {
16551701 printMsg("INFO", "Extracting ABI information");
1656
1702
16571703 my %CurID = ();
16581704
16591705 my @IDs = sort {int($a) <=> int($b)} keys(%DWARF_Info);
16791725 }
16801726 }
16811727
1728 if($Kind ne "subprogram") {
1729 delete($DWARF_Info{$ID}{"NS"});
1730 }
1731
16821732 my $IsType = ($Kind=~/(struct|structure|class|union|enumeration|subroutine|array)_type/);
16831733
16841734 if($IsType
16851735 or $Kind eq "typedef"
16861736 or $Kind eq "subprogram"
1687 or $Kind eq "inlined_subroutine"
1688 or $Kind eq "lexical_block"
16891737 or $Kind eq "variable"
16901738 or $Kind eq "namespace")
16911739 {
19692017 }
19702018
19712019 # free memory
2020 # delete types info
19722021 %Delete = ();
19732022 foreach (keys(%DWARF_Info))
19742023 {
21142163
21152164 delete($SymbolInfo{$ID}{"External"});
21162165 }
2117
2118 #use Devel::Size qw(size total_size);
2119 #print keys(%DWARF_Info)." ".(total_size(\%DWARF_Info)/(1024*1024))." Mb ".localtime(time)."\n";
2120 #print keys(%TypeInfo)." ".(total_size(\%TypeInfo)/(1024*1024))." Mb ".localtime(time)."\n";
2121 #print keys(%SymbolInfo)." ".(total_size(\%SymbolInfo)/(1024*1024))." Mb ".localtime(time)."\n";
2122
2123 #writeFile("out.txt", Dumper(\%DWARF_Info));
21242166 }
21252167
21262168 sub cloneSymbol($$)
28092851 elsif($TInfo{"Source"}) {
28102852 $TInfo{"Name"} = "anon-".lc($TInfo{"Type"})."-".$TInfo{"Source"}."-".$TInfo{"SourceLine"};
28112853 }
2854 else
2855 {
2856 if(not defined $TypeMember{$ID})
2857 {
2858 if(not defined $ANON_TYPE{$TInfo{"Type"}})
2859 {
2860 printMsg("WARNING", "a \"".$TInfo{"Type"}."\" type with no attributes detected in the DWARF dump ($ID)");
2861 $ANON_TYPE{$TInfo{"Type"}} = 1;
2862 }
2863 $TInfo{"Name"} = "anon-".lc($TInfo{"Type"});
2864 }
2865 }
28122866
28132867 if($TInfo{"Name"} and $TInfo{"NameSpace"}) {
28142868 $TInfo{"Name"} = $TInfo{"NameSpace"}."::".$TInfo{"Name"};
28642918 my $File = $DWARF_Info{$ID}{"decl_file"};
28652919 my $Line = $DWARF_Info{$ID}{"decl_line"};
28662920
2867 my $Unit = $DWARF_Info{$ID}{"CompUnit"};
2921 my $Unit = $DWARF_Info{$ID}{"Unit"};
28682922
28692923 if(defined $File)
28702924 {
28792933 }
28802934
28812935 if($Name=~/\.($HEADER_EXT)\Z/)
2882 {
2936 { # header
28832937 $R->{"Header"} = $Name;
28842938 if(defined $Line) {
28852939 $R->{"Line"} = $Line;
28862940 }
28872941 }
28882942 elsif($Name ne "<built-in>")
2889 {
2943 { # source
28902944 $R->{"Source"} = $Name;
28912945 if(defined $Line) {
28922946 $R->{"SourceLine"} = $Line;
31183172 {
31193173 if(my $OLD_ID = $Mangled_ID{$MnglName})
31203174 { # duplicates
3121 #print Dumper($DWARF_Info{$ID})." $OLD_ID $ID\n" if($MnglName eq "_ZSt22__uninitialized_move_aIPSsS0_SaISsEET0_T_S3_S2_RT1_");
3175 if(not defined $SymbolInfo{$OLD_ID}{"Header"}
3176 or not defined $SymbolInfo{$OLD_ID}{"Source"})
3177 {
3178 setSource($SymbolInfo{$OLD_ID}, $ID);
3179 }
3180
31223181 if(defined $Checked_Spec{$MnglName}
31233182 or not $DWARF_Info{$ID}{"specification"})
3124 { # add spec info
3125 if(not defined $SymbolInfo{$OLD_ID}{"Header"}
3126 or not defined $SymbolInfo{$OLD_ID}{"Source"})
3127 {
3128 if($DWARF_Info{$ID}{"decl_file"} ne $DWARF_Info{$OLD_ID}{"decl_file"})
3129 {
3130 setSource($SymbolInfo{$OLD_ID}, $ID);
3131 }
3132 }
3133
3183 {
31343184 if(not defined $SpecElem{$ID}
31353185 and not defined $OrigElem{$ID}) {
31363186 delete($DWARF_Info{$ID});
31373187 }
3138
31393188 return;
31403189 }
31413190 }
36963745 delete($TypeInfo{$Tid});
36973746 }
36983747 }
3748
3749 # clean memory
3750 %MergedTypes = ();
3751 %LocalType = ();
36993752
37003753 # completeness
37013754 foreach my $Tid (keys(%TypeInfo)) {