]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
add --vgdb-prefix arg to callgrind_control
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 11 Jan 2014 13:56:48 +0000 (13:56 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 11 Jan 2014 13:56:48 +0000 (13:56 +0000)
If valgrind is started with --vgdb-prefix arg, then callgrind_control
cannot find and control this valgrind.
So, add an (optional) argument to callgrind_control,
and have callgrind tool report the needed vgdb prefix argument
if the user supplied this arg.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13769

NEWS
callgrind/callgrind_control.in
callgrind/docs/cl-manual.xml
callgrind/main.c
coregrind/m_gdbserver/remote-utils.c
coregrind/m_main.c
coregrind/m_options.c
coregrind/pub_core_gdbserver.h
coregrind/pub_core_options.h
include/pub_tool_options.h

diff --git a/NEWS b/NEWS
index be7ceb7f42f32004a75e0ccb36869ad809412020..9441c0a3d2700deeb8d54373954b77c1ea69dd4e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,10 @@ Release 3.10.0 (?? ?????? 201?)
 
 * Helgrind:
 
+* Callgrind:
+  - callgrind_control now supports the --vgdb-prefix argument,
+    which is needed if valgrind was started with this same argument.
+
 * ==================== OTHER CHANGES ====================
 
 * New and modified GDB server monitor features:
index 4a526d97ef2da5191d73788d31b4adb792ccc97e..1dd8cce6864a126a439ad186eac673f61aa7366a 100644 (file)
@@ -27,7 +27,7 @@
 sub getCallgrindPids {
 
   @pids = ();
-  open LIST, "vgdb -l|";
+  open LIST, "vgdb $vgdbPrefixOption -l|";
   while(<LIST>) {
       if (/^use --pid=(\d+) for \S*?valgrind\s+(.*?)\s*$/) {
          $pid = $1;
@@ -78,6 +78,8 @@ sub printHelp {
   print "  -z --zero         Zero all event counters\n";
   print "  -k --kill         Kill\n";
   print "  -i --instr=on|off Switch instrumentation state on/off\n";
+  print "Uncommon options:\n";
+  print "  --vgdb-prefix=<prefix> Only provide this if the same was given to Valgrind\n";
   print "\n";
   exit;
 }
@@ -185,6 +187,16 @@ sub print_events ($)
 # Main
 #
 
+# To find the list of active pids, we need to have
+# the --vgdb-prefix option if given.
+$vgdbPrefixOption = "";
+foreach $arg (@ARGV) {
+    if ($arg =~ /^--vgdb-prefix=.*$/) {
+        $vgdbPrefixOption=$arg;
+    }
+    next;
+}
+
 getCallgrindPids;
 
 $requestEvents = 0;
@@ -192,6 +204,7 @@ $requestDump = 0;
 $switchInstr = 0;
 $headerPrinted = 0;
 $dumpHint = "";
+
 $verbose = 0;
 
 %spids = ();
@@ -206,6 +219,10 @@ foreach $arg (@ARGV) {
     elsif ($arg =~ /^--version$/) {
        printVersion;
     }
+    elsif ($arg =~ /^--vgdb-prefix=.*$/) {
+        # handled during the initial parsing.
+        next;
+    }
     elsif ($arg =~ /^-v$/) {
        $verbose++;
        next;
@@ -346,7 +363,7 @@ foreach $pid (@pids) {
   } else {
       print "\n";
   }
-  open RESULT, "vgdb --pid=$pid $vgdbCommand|";
+  open RESULT, "vgdb $vgdbPrefixOption --pid=$pid $vgdbCommand|";
 
   @tids = ();
   $ctid = 0;
index 2f08ac865ef9e3b1a77faee0745eff071297136f..369180ca57b1b8f6d43ef8b279ef2c05afc5c76b 100644 (file)
@@ -1400,12 +1400,13 @@ their arguments.</para>
   </varlistentry>
 
   <varlistentry>
-    <term><option><![CDATA[-w=<dir>]]></option></term>
+    <term><option><![CDATA[--vgdb-prefix=<prefix>]]></option></term>
     <listitem>
-      <para>Specify the startup directory of an active Callgrind run. On some
-      systems, active Callgrind runs can not be detected. To be able to
-      control these, the failed auto-detection can be worked around by
-      specifying the directory where a Callgrind run was started.</para>
+      <para>Specify the vgdb prefix to use by callgrind_control.
+      callgrind_control internally uses vgdb to find and control the active
+      Callgrind runs. If the <option>--vgdb-prefix</option> option was used
+      for launching valgrind, then the same option must be given to
+      callgrind_control.</para>
     </listitem>
   </varlistentry>
 </variablelist>
index a58bc00a0b68378a5d826840e2527e75af643c36..fcd78a1efa7f51502c7be91a53f4d114693f1a90 100644 (file)
@@ -2024,7 +2024,9 @@ void CLG_(post_clo_init)(void)
 
    if (VG_(clo_verbosity > 0)) {
       VG_(message)(Vg_UserMsg,
-                   "For interactive control, run 'callgrind_control -h'.\n");
+                   "For interactive control, run 'callgrind_control%s%s -h'.\n",
+                   (VG_(arg_vgdb_prefix) ? " " : ""),
+                   (VG_(arg_vgdb_prefix) ? VG_(arg_vgdb_prefix) : ""));
    }
 }
 
index 25e8f46a2068b97c4ecc6ceadb806d354f42b783..6916fc0cb666ae7ed05a94a44cca918f1b09af52 100644 (file)
@@ -234,7 +234,6 @@ void remote_open (const HChar *name)
        offsetof(ThreadState, os_state) + offsetof(ThreadOSstate, lwpid),
        0};
    const int pid = VG_(getpid)();
-   const int name_default = strcmp(name, VG_(vgdb_prefix_default)()) == 0;
    Addr addr_shared;
    SysRes o;
    int shared_mem_fd = INVALID_DESCRIPTOR;
@@ -274,8 +273,9 @@ void remote_open (const HChar *name)
                 "don't want to do, unless you know exactly what you're doing,\n"
                 "or are doing some strange experiment):\n"
                 "  %s/../../bin/vgdb%s%s --pid=%d ...command...\n",
-                VG_(libdir), (name_default ? "" : " --vgdb-prefix="),
-                (name_default ? "" : name),
+                VG_(libdir),
+                (VG_(arg_vgdb_prefix) ? " " : ""),
+                (VG_(arg_vgdb_prefix) ? VG_(arg_vgdb_prefix) : ""),
                 pid);
    }
    if (VG_(clo_verbosity) > 1 
@@ -287,8 +287,9 @@ void remote_open (const HChar *name)
          "and then give GDB the following command\n"
          "  target remote | %s/../../bin/vgdb%s%s --pid=%d\n",
          VG_(args_the_exename),
-         VG_(libdir), (name_default ? "" : " --vgdb-prefix="), 
-         (name_default ? "" : name),
+         VG_(libdir),
+         (VG_(arg_vgdb_prefix) ? " " : ""),
+         (VG_(arg_vgdb_prefix) ? VG_(arg_vgdb_prefix) : ""),
          pid
       );
       VG_(umsg)("--pid is optional if only one valgrind process is running\n");
@@ -1119,7 +1120,7 @@ int decode_X_packet (char *from, int packet_len, CORE_ADDR *mem_addr_ptr,
 }
 
 
-/* Return the path prefix for the named pipes (FIFOs) used by vgdb/gdb
+/* Return the default path prefix for the named pipes (FIFOs) used by vgdb/gdb
    to communicate with valgrind */
 HChar *
 VG_(vgdb_prefix_default)(void)
index 35c11e1fb304cbf08733dbdb00d70dce10c9d6ea..41934f1430581b771e3b6beff1024cd1a003e8ab 100644 (file)
@@ -562,7 +562,9 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
       }
       else if VG_INT_CLO (arg, "--vgdb-poll",      VG_(clo_vgdb_poll)) {}
       else if VG_INT_CLO (arg, "--vgdb-error",     VG_(clo_vgdb_error)) {}
-      else if VG_STR_CLO (arg, "--vgdb-prefix",    VG_(clo_vgdb_prefix)) {}
+      else if VG_STR_CLO (arg, "--vgdb-prefix",    VG_(clo_vgdb_prefix)) {
+         VG_(arg_vgdb_prefix) = arg;
+      }
       else if VG_BOOL_CLO(arg, "--vgdb-shadow-registers",
                             VG_(clo_vgdb_shadow_registers)) {}
       else if VG_BOOL_CLO(arg, "--db-attach",      VG_(clo_db_attach)) {}
index 2163ebe310a63328e6c71ea72635d80d003cd322..fcc8e219bb166c3cb339516910a0a4d396f94f83 100644 (file)
@@ -55,7 +55,8 @@ VgVgdb VG_(clo_vgdb)           = Vg_VgdbYes;
 #endif
 Int    VG_(clo_vgdb_poll)      = 5000; 
 Int    VG_(clo_vgdb_error)     = 999999999;
-const HChar* VG_(clo_vgdb_prefix)    = NULL;
+const HChar *VG_(clo_vgdb_prefix)    = NULL;
+const HChar *VG_(arg_vgdb_prefix)    = NULL;
 Bool   VG_(clo_vgdb_shadow_registers) = False;
 
 Bool   VG_(clo_db_attach)      = False;
index b10adbb8de0aad8f0811bc4b9810911ab2ce48cd..8059420ee2f38d3f733fa41663317df4a144702c 100644 (file)
@@ -33,9 +33,9 @@
 #include "pub_tool_gdbserver.h"
 #include "pub_core_threadstate.h"   // VgSchedReturnCode
 
-/* Return the path prefix for the named pipes (FIFOs) used by vgdb/gdb
+/* Return the default path prefix for the named pipes (FIFOs) used by vgdb/gdb
    to communicate with valgrind */
-HChar*  VG_(vgdb_prefix_default)(void);
+HChar* VG_(vgdb_prefix_default)(void);
 
 // After a fork or after an exec, call the below to (possibly) terminate
 // the previous gdbserver and then activate a new gdbserver
index c2363efaadef7619c2096f46ca9a7a411fc0bc3a..fb178fc19acd6304fbd1610e51e9e9fb761eafc0 100644 (file)
@@ -68,8 +68,10 @@ typedef
 extern VgVgdb VG_(clo_vgdb);
 /* if > 0, checks every VG_(clo_vgdb_poll) BBS if vgdb wants to be served. */
 extern Int VG_(clo_vgdb_poll);
+
 /* prefix for the named pipes (FIFOs) used by vgdb/gdb to communicate with valgrind */
-extern const HChar* VG_(clo_vgdb_prefix);
+extern const HChar *VG_(clo_vgdb_prefix);
+
 /* if True, gdbserver in valgrind will expose a target description containing
    shadow registers */
 extern Bool  VG_(clo_vgdb_shadow_registers);
index 7b80d3dc4ef7ff141e2e0139dd02dbbd150276f3..2ad1da8f0ddcd36a989ded2c65a3af72775725e7 100644 (file)
@@ -155,6 +155,14 @@ extern Bool VG_(clo_stats);
    can be changed dynamically.*/
 extern Int VG_(clo_vgdb_error);
 
+/* If user has provided the --vgdb-prefix command line option,
+   VG_(arg_vgdb_prefix) points at the provided argument (including the
+   '--vgdb-prefix=' string).
+   Otherwise, it is NULL.
+   Typically, this is used by tools to produce user message with the
+   expected vgdb prefix argument, if the user has changed the default. */
+extern const HChar *VG_(arg_vgdb_prefix);
+
 /* Emit all messages as XML? default: NO */
 /* If clo_xml is set, various other options are set in a non-default
    way.  See vg_main.c and mc_main.c. */