[Lsb-messages] /var/www/bzr/lsb/devel/componenttodb r46: Upload RawVtable data

Denis Silakov denis.silakov at rosalab.ru
Thu Jul 10 07:26:56 UTC 2014


------------------------------------------------------------
revno: 46
committer: Denis Silakov <denis.silakov at rosalab.ru>
branch nick: componenttodb
timestamp: Thu 2014-07-10 11:26:56 +0400
message:
  Upload RawVtable data
modified:
  Upload.pm
  componenttodb.pl
  upload_distr_data.pl
-------------- next part --------------
=== modified file 'Upload.pm'
--- a/Upload.pm	2012-03-15 06:47:08 +0000
+++ b/Upload.pm	2014-07-10 07:26:56 +0000
@@ -9,7 +9,7 @@
     $quiet $DBmode $sqlFileHandle
     $LibId $AppId $DistrId $ComponentId $ClassId $ArchId $LibraryName
     %processed_classes %processed_sonames
-    $distro_Q $component_Q $rawlib_Q $rawclass_Q $rawint_Q $rawcmd_Q $rawint_all_libs_Q $rawint_lsb_lib_Q $raw_ilmodule_Q
+    $distro_Q $component_Q $rawlib_Q $rawclass_Q $rawint_Q $rawcmd_Q $rawint_all_libs_Q $rawint_lsb_lib_Q $raw_ilmodule_Q $rawint_wo_vers_Q
     $arch_Q $app_Q $app_lib_Q
     $distro_I $component_I $rawlib_I $rawclass_I $rawint_I $rawcmd_I $raw_ilmodule_I
     $rawscript_I $last_insert_id_Q
@@ -46,7 +46,7 @@
 
 our $last_insert_id_Q;
 
-our ($distro_Q, $component_Q, $rawlib_Q, $library_Q, $rawclass_Q, $rawint_Q, $raw_ilmodule_Q, $rawcmd_Q);
+our ($distro_Q, $component_Q, $rawlib_Q, $library_Q, $rawclass_Q, $rawint_Q, $raw_ilmodule_Q, $rawcmd_Q, $rawint_wo_vers_Q);
 our ($rawint_all_libs_Q, $rawint_lsb_lib_Q);
 our ($app_Q, $app_lib_Q, $app_info_Q);
 our $arch_Q;
@@ -112,12 +112,16 @@
 
     $rawint_Q = $dbh->prepare(
     'select RIid from RawInterface where RIname = ? and RIlibrary = ? and RIversion = ?')
-        or prep_die('rawint'); # args: raw interface name, library, version and class.
+        or prep_die('rawint'); # args: raw interface name, library, version.
 
     $last_insert_id_Q = $dbh->prepare(
     'select last_insert_id()')
         or prep_die('last_insert_id');
 
+    $rawint_wo_vers_Q = $dbh->prepare(
+    'select RIid from RawInterface join RawLibrary on RLname=RIlibrary where RIname = ? and RIlibrary = ? LIMIT 1')
+        or prep_die('rawint'); # args: raw interface name, library.
+
     $rawint_all_libs_Q = $dbh->prepare(
     'select distinct RIlibrary,RLrunname,RLsoname from RawInterface join RawLibrary on RLname=RIlibrary where RIname = ? and RIlibrary > "" and RIversion = ? and RIrcid = ?')
         or prep_die('rawint'); # args: raw interface name, version, class.

=== modified file 'componenttodb.pl'
--- a/componenttodb.pl	2014-07-02 11:04:51 +0000
+++ b/componenttodb.pl	2014-07-10 07:26:56 +0000
@@ -496,11 +496,11 @@
             # We'll ty to invoke 32bit vtable-dumpe for 32bit libs and 64bit dumper for 64bit libs
             # assuming that we are running inside 64bit system and have a separate vtable-dumper32 executable
 	    if( $elf_class eq "ELF32" and does_shell_know("vtable-dumper32") ) {
-        	$cmd = "vtable-dumper32 $filename >> $tmpFile | grep -v 'Failed to open'";
+        	$cmd = "vtable-dumper32 -mangled $filename >> $tmpFile | grep -v 'Failed to open'";
         	system( $cmd );
     	    }
     	    else {
-        	$cmd = "vtable-dumper $filename >> $tmpFile | grep -v 'Failed to open'";
+        	$cmd = "vtable-dumper -mangled $filename >> $tmpFile | grep -v 'Failed to open'";
         	# Do not die on failure
         	system( $cmd );
     	    }

=== modified file 'upload_distr_data.pl'
--- a/upload_distr_data.pl	2012-05-31 12:30:52 +0000
+++ b/upload_distr_data.pl	2014-07-10 07:26:56 +0000
@@ -56,6 +56,10 @@
 my @comp_files;
 my @comp_requires;
 
+my $vtable_class;
+my $vtable_vtpos;
+my $vtable_pos;
+
 sub HELP_MESSAGE();
 sub add_distr_ilmodule($$ );
 sub add_comp_ldpath($ );
@@ -72,6 +76,7 @@
 sub process_collected_files();
 sub process_collected_deps();
 sub detect_biarch_components();
+sub process_vtable_dumper_line($ );
 
 # 'report' option is not supported yet
 GetOptions("help|h!" => \$opt_help,
@@ -184,6 +189,7 @@
 my $java_class_name = "";
 my $inside_java_class = 0;
 my ($java_access, $java_final, $java_static, $java_synchronized); # particular access flags
+my $inside_vtable = 0;
 
 my ($lib_arch, $lib_arch_id)=(0,0); # real library architecture
 
@@ -227,6 +233,18 @@
             $inside_java_class = 0;
         }
     }
+    elsif( $inside_vtable  ) {
+        if( !/^\!/ ) {
+            # It can happen that we are inside a private shared object which is not uploaded to the database
+            if( $LibId ) {
+                process_vtable_dumper_line($_);
+            }
+            next;
+        }
+        else {
+            $inside_vtable = 0;
+        }
+    }
     elsif( /^ELF Header/ ) {
         $elfheader=1;
         next;
@@ -463,6 +481,10 @@
         }
         next;
     }
+    elsif( /^\!Vtables/ ) {
+        $inside_vtable = 1;
+        next;
+    }
     elsif( /^\!JavaClassFile/ ) {
         $access_flags = "";
         $entity_name = "";
@@ -965,6 +987,104 @@
 # Routines
 ##############################################################################
 
+# Process line of the data file that is present inside 'Vtable' section
+# (output of 'vtable-dumper' tool)
+sub process_vtable_dumper_line($ )
+{
+    my $line = $_[0];
+    chomp($line);
+
+    my ($RIlibrary) = $dbh->selectrow_array("SELECT RLname FROM RawLibrary WHERE RLid=$LibId");
+
+    if( /^\d+\s+\(int \(\*\)\(\.\.\.\)\) (.+)/ ) {
+        my $vtentry = $1;
+        if( $vtentry =~ /\& _ZTI/ ) {
+            # Number of vtable (initially set to '-1')
+            $vtable_vtpos++;
+            # Number of entry inside vtable
+            $vtable_pos = 0;
+            return;
+        }
+
+        if( $vtentry =~ /^0/ or $vtentry =~ /^-0/ ) {
+            return;
+        }
+
+        my $VTviid = 0;
+
+        if( $vtentry =~ /^_Z/ or $vtentry =~ /^__cx/ ) {
+            # Mangled name is used
+            my $vtunmangled = `c++filt $vtentry`;
+            chomp($vtunmangled);
+
+            if( $DBmode eq "patch" ) {
+                print $sqlFileHandle "INSERT IGNORE INTO RawInterface VALUES(0,'$vtentry','$vtunmangled','','$RIlibrary',0);\n";
+                print $sqlFileHandle "SET \@VTviid=(SELECT RIid FROM RawInterface WHERE RIname='$vtentry' AND RIlibrary='$RIlibrary' LIMIT 1);\n";
+                print $sqlFileHandle "INSERT IGNORE INTO RLibRInt VALUES(\@L,\@VTviid);\n";
+            }
+            else {
+                $rawint_wo_vers_Q->execute($vtentry, $RIlibrary) or exec_die("rawint_wo_vers");
+                my @row = $rawint_wo_vers_Q->fetchrow_array();
+                if (@row) {
+                    $VTviid = $row[0];
+                }
+                else {
+                    print "RawInterface record for '$vtentry' ($RIlibrary) was not found, inserting ...\n" if(not $quiet);
+                    $rawint_I->execute($vtentry, $vtunmangled, '', $RIlibrary, 0) or exec_die("rawint_I");
+                    $VTviid = $dbh->{'mysql_insertid'};
+                    $dbh->do("INSERT IGNORE INTO RLibRInt VALUES($LibId,$VTviid)");
+                }
+
+                $dbh->do("INSERT IGNORE INTO RawVtable VALUES()");
+            }
+        }
+        else {
+            # Return to be safe, unrecognized records may come from vtable-dumper
+            return;
+        }
+
+        if( $DBmode eq "patch" ) {
+            print $sqlFileHandle "INSERT IGNORE INTO RawVtable VALUES(\@VC,\@L,$vtable_vtpos,$vtable_pos,\@VTviid,$ArchId);\n";
+        }
+        else {
+            if( not $VTviid or $VTviid == 0 ) {
+                warn "Failed to detect VTviid for $line ($vtentry) ($RIlibrary)";
+                if( not $VTviid ) {
+                    $VTviid = 0;
+                }
+            }
+            $dbh->do("INSERT IGNORE INTO RawVtable VALUES($vtable_class,$LibId,$vtable_vtpos,$vtable_pos,$VTviid,$ArchId)");
+        }
+
+        $vtable_pos++;
+    }
+    elsif( $line =~ /^Failed to dlopen/ ) {
+        return;
+    }
+    elsif( $line =~ /^Vtable for (.+)/ ) {
+        my $classname = $1;
+        if( $DBmode eq "patch" ) {
+            print $sqlFileHandle "INSERT IGNORE INTO RawClass VALUES(0,'$classname');\n";
+            print $sqlFileHandle "SET \@VC=(SELECT RCid FROM RawClass WHERE RCname='$classname');\n";
+        }
+        else {
+            $rawclass_Q->execute($classname);
+            my @row = $rawclass_Q->fetchrow_array();
+            if (@row) {
+                $vtable_class = $row[0];
+            }
+            else {
+                $rawclass_I->execute($classname);
+                $vtable_class = $dbh->{'mysql_insertid'};
+            }
+        }
+
+        # Number of vtable
+        # Set to '-1' so the first "++" will set it to zero
+        $vtable_vtpos = -1;
+    }
+}
+
 # Process line of the data file that is present inside 'JavaClass' section
 sub process_java_class_line($ )
 {
@@ -1102,7 +1222,6 @@
     $raw_ilmodule_I->execute($modname, $LangId) or exec_die("rilm");
     print "ILModule $modname has been successfully added to the database\n" if(not $quiet);
 
-    #~ (my $RILMid) = $dbh->selectrow_array('select last_insert_id()');
     my $RILMid = $dbh->{'mysql_insertid'};
     push( @comp_rilms, "($ComponentId,$RILMid)" );
     print "Module has been assigned to the component\n" if(not $quiet);



More information about the lsb-messages mailing list