|
From: <sv...@va...> - 2014-01-11 13:57:03
|
Author: philippe
Date: Sat Jan 11 13:56:48 2014
New Revision: 13769
Log:
add --vgdb-prefix arg to callgrind_control
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.
Modified:
trunk/NEWS
trunk/callgrind/callgrind_control.in
trunk/callgrind/docs/cl-manual.xml
trunk/callgrind/main.c
trunk/coregrind/m_gdbserver/remote-utils.c
trunk/coregrind/m_main.c
trunk/coregrind/m_options.c
trunk/coregrind/pub_core_gdbserver.h
trunk/coregrind/pub_core_options.h
trunk/include/pub_tool_options.h
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sat Jan 11 13:56:48 2014
@@ -9,6 +9,10 @@
* 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:
Modified: trunk/callgrind/callgrind_control.in
==============================================================================
--- trunk/callgrind/callgrind_control.in (original)
+++ trunk/callgrind/callgrind_control.in Sat Jan 11 13:56:48 2014
@@ -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 @@
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 @@
# 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 @@
$switchInstr = 0;
$headerPrinted = 0;
$dumpHint = "";
+
$verbose = 0;
%spids = ();
@@ -206,6 +219,10 @@
elsif ($arg =~ /^--version$/) {
printVersion;
}
+ elsif ($arg =~ /^--vgdb-prefix=.*$/) {
+ # handled during the initial parsing.
+ next;
+ }
elsif ($arg =~ /^-v$/) {
$verbose++;
next;
@@ -346,7 +363,7 @@
} else {
print "\n";
}
- open RESULT, "vgdb --pid=$pid $vgdbCommand|";
+ open RESULT, "vgdb $vgdbPrefixOption --pid=$pid $vgdbCommand|";
@tids = ();
$ctid = 0;
Modified: trunk/callgrind/docs/cl-manual.xml
==============================================================================
--- trunk/callgrind/docs/cl-manual.xml (original)
+++ trunk/callgrind/docs/cl-manual.xml Sat Jan 11 13:56:48 2014
@@ -1400,12 +1400,13 @@
</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>
Modified: trunk/callgrind/main.c
==============================================================================
--- trunk/callgrind/main.c (original)
+++ trunk/callgrind/main.c Sat Jan 11 13:56:48 2014
@@ -2024,7 +2024,9 @@
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) : ""));
}
}
Modified: trunk/coregrind/m_gdbserver/remote-utils.c
==============================================================================
--- trunk/coregrind/m_gdbserver/remote-utils.c (original)
+++ trunk/coregrind/m_gdbserver/remote-utils.c Sat Jan 11 13:56:48 2014
@@ -234,7 +234,6 @@
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 @@
"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 @@
"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 @@
}
-/* 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)
Modified: trunk/coregrind/m_main.c
==============================================================================
--- trunk/coregrind/m_main.c (original)
+++ trunk/coregrind/m_main.c Sat Jan 11 13:56:48 2014
@@ -562,7 +562,9 @@
}
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)) {}
Modified: trunk/coregrind/m_options.c
==============================================================================
--- trunk/coregrind/m_options.c (original)
+++ trunk/coregrind/m_options.c Sat Jan 11 13:56:48 2014
@@ -55,7 +55,8 @@
#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;
Modified: trunk/coregrind/pub_core_gdbserver.h
==============================================================================
--- trunk/coregrind/pub_core_gdbserver.h (original)
+++ trunk/coregrind/pub_core_gdbserver.h Sat Jan 11 13:56:48 2014
@@ -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
Modified: trunk/coregrind/pub_core_options.h
==============================================================================
--- trunk/coregrind/pub_core_options.h (original)
+++ trunk/coregrind/pub_core_options.h Sat Jan 11 13:56:48 2014
@@ -68,8 +68,10 @@
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);
Modified: trunk/include/pub_tool_options.h
==============================================================================
--- trunk/include/pub_tool_options.h (original)
+++ trunk/include/pub_tool_options.h Sat Jan 11 13:56:48 2014
@@ -155,6 +155,14 @@
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. */
|