]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix 393023 - callgrind_control risks using the wrong vgdb
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 15 Apr 2018 10:41:48 +0000 (12:41 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 15 Apr 2018 10:41:48 +0000 (12:41 +0200)
Search for a vgdb executable in the same dir as callgrind_control perl file.
If not found, search for a vgdb executable in a sibling coregrind dir
   (covers the case of :   perl  callgrind/callgrind_control)
Otherwise, just hope we find a vgdb executable in PATH

NEWS
callgrind/callgrind_control.in

diff --git a/NEWS b/NEWS
index dae825b820a0446ca8dd7758b94c1d70bffab41f..ce01442d4730ae1da07875cc36e4317361edca4b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -103,6 +103,7 @@ where XXXXXX is the bug number as listed below.
 391861  Massif Assertion 'n_ips >= 1 && n_ips <= VG_(clo_backtrace_size)'
 393017  Add missing support for xsmaxcdp instruction, bug fixes for xsmincdp,
         lxssp, stxssp and stxvl instructions.
+393023  callgrind_control risks using the wrong vgdb
 393099  posix_memalign() invalid write if alignment == 0
 
 n-i-bz  Fix missing workq_ops operations (macOS)
index 4c57ccff52212071fccce0b9711e08b259608aca..4660f526cd1f58f587a75a853f051097b483c542 100644 (file)
 #  along with this program; if not, write to the Free Software
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 #  02111-1307, USA.
+use File::Basename;
+
+# vgdb_exe will be set to a vgdb found 'near' the callgrind_control file
+my $vgdb_exe = "";
 
 sub getCallgrindPids {
 
   @pids = ();
-  open LIST, "vgdb $vgdbPrefixOption -l|";
+  open LIST, $vgdb_exe . " $vgdbPrefixOption -l|";
   while(<LIST>) {
       if (/^use --pid=(\d+) for \S*?valgrind\s+(.*?)\s*$/) {
          $pid = $1;
@@ -187,6 +191,20 @@ sub print_events ($)
 # Main
 #
 
+# Search the appropriate vgdb executable
+my $controldir = dirname(__FILE__);
+if (-x $controldir . "/vgdb") {
+    # classical case: callgrind_control and vgdb from the install bin dir
+    $vgdb_exe = $controldir . "/vgdb";
+} elsif (-x $controldir . "/../coregrind/vgdb") {
+    # callgrind_control called from the callgrind tool source/build dir
+    $vgdb_exe = $controldir . "/../coregrind/vgdb";
+} else {
+    # no idea. Use whatever vgdb found in PATH
+    $vgdb_exe = "vgdb"
+}
+# print "will use vgdb at [" . $vgdb_exe . "]\n";
+
 # To find the list of active pids, we need to have
 # the --vgdb-prefix option if given.
 $vgdbPrefixOption = "";
@@ -363,7 +381,7 @@ foreach $pid (@pids) {
   } else {
       print "\n";
   }
-  open RESULT, "vgdb $vgdbPrefixOption --pid=$pid $vgdbCommand|";
+  open RESULT, $vgdb_exe . " $vgdbPrefixOption --pid=$pid $vgdbCommand|";
 
   @tids = ();
   $ctid = 0;