From: Philippe Waroquiers Date: Sat, 11 Jan 2014 13:56:48 +0000 (+0000) Subject: add --vgdb-prefix arg to callgrind_control X-Git-Tag: svn/VALGRIND_3_10_0~667 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=231d67347fd92ecf61363a6a583b0d7f50f2d257;p=thirdparty%2Fvalgrind.git 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. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13769 --- diff --git a/NEWS b/NEWS index be7ceb7f42..9441c0a3d2 100644 --- 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: diff --git a/callgrind/callgrind_control.in b/callgrind/callgrind_control.in index 4a526d97ef..1dd8cce686 100644 --- a/callgrind/callgrind_control.in +++ b/callgrind/callgrind_control.in @@ -27,7 +27,7 @@ sub getCallgrindPids { @pids = (); - open LIST, "vgdb -l|"; + open LIST, "vgdb $vgdbPrefixOption -l|"; while() { 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= 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; diff --git a/callgrind/docs/cl-manual.xml b/callgrind/docs/cl-manual.xml index 2f08ac865e..369180ca57 100644 --- a/callgrind/docs/cl-manual.xml +++ b/callgrind/docs/cl-manual.xml @@ -1400,12 +1400,13 @@ their arguments. - + - 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. + 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 was used + for launching valgrind, then the same option must be given to + callgrind_control. diff --git a/callgrind/main.c b/callgrind/main.c index a58bc00a0b..fcd78a1efa 100644 --- a/callgrind/main.c +++ b/callgrind/main.c @@ -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) : "")); } } diff --git a/coregrind/m_gdbserver/remote-utils.c b/coregrind/m_gdbserver/remote-utils.c index 25e8f46a20..6916fc0cb6 100644 --- a/coregrind/m_gdbserver/remote-utils.c +++ b/coregrind/m_gdbserver/remote-utils.c @@ -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) diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 35c11e1fb3..41934f1430 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -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)) {} diff --git a/coregrind/m_options.c b/coregrind/m_options.c index 2163ebe310..fcc8e219bb 100644 --- a/coregrind/m_options.c +++ b/coregrind/m_options.c @@ -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; diff --git a/coregrind/pub_core_gdbserver.h b/coregrind/pub_core_gdbserver.h index b10adbb8de..8059420ee2 100644 --- a/coregrind/pub_core_gdbserver.h +++ b/coregrind/pub_core_gdbserver.h @@ -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 diff --git a/coregrind/pub_core_options.h b/coregrind/pub_core_options.h index c2363efaad..fb178fc19a 100644 --- a/coregrind/pub_core_options.h +++ b/coregrind/pub_core_options.h @@ -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); diff --git a/include/pub_tool_options.h b/include/pub_tool_options.h index 7b80d3dc4e..2ad1da8f0d 100644 --- a/include/pub_tool_options.h +++ b/include/pub_tool_options.h @@ -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. */