From: Philippe Waroquiers Date: Sun, 15 Apr 2018 10:41:48 +0000 (+0200) Subject: Fix 393023 - callgrind_control risks using the wrong vgdb X-Git-Tag: VALGRIND_3_14_0~123 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=532ed8a48b72231f424dd0b421cceb91d601389a;p=thirdparty%2Fvalgrind.git Fix 393023 - callgrind_control risks using the wrong vgdb 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 --- diff --git a/NEWS b/NEWS index dae825b820..ce01442d47 100644 --- 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) diff --git a/callgrind/callgrind_control.in b/callgrind/callgrind_control.in index 4c57ccff52..4660f526cd 100644 --- a/callgrind/callgrind_control.in +++ b/callgrind/callgrind_control.in @@ -23,11 +23,15 @@ # 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() { 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;