* 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:
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;
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;
}
# 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;
$switchInstr = 0;
$headerPrinted = 0;
$dumpHint = "";
+
$verbose = 0;
%spids = ();
elsif ($arg =~ /^--version$/) {
printVersion;
}
+ elsif ($arg =~ /^--vgdb-prefix=.*$/) {
+ # handled during the initial parsing.
+ next;
+ }
elsif ($arg =~ /^-v$/) {
$verbose++;
next;
} else {
print "\n";
}
- open RESULT, "vgdb --pid=$pid $vgdbCommand|";
+ open RESULT, "vgdb $vgdbPrefixOption --pid=$pid $vgdbCommand|";
@tids = ();
$ctid = 0;
</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>
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) : ""));
}
}
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;
"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
"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");
}
-/* 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)
}
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)) {}
#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;
#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
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);
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. */