]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make some vgdb interface to callgrind_control internal
authorJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Tue, 6 Sep 2011 19:08:35 +0000 (19:08 +0000)
committerJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Tue, 6 Sep 2011 19:08:35 +0000 (19:08 +0000)
The vgdb "status" monitor command is still available, but
used for pretty printing of status information now (acutally,
just some place holder for real information up to now: just
number of running threads). The internal interface used by
callgrind_control to provide stack traces and event counts
is using "status internal", and is not documented, as the
format is not for human consumption.

This also adds some documentation.

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

callgrind/callgrind_control.in
callgrind/docs/cl-manual.xml
callgrind/main.c

index 6492d7b139acc95eac87294d4413e37a1cd72d0a..4a526d97ef2da5191d73788d31b4adb792ccc97e 100644 (file)
@@ -192,6 +192,7 @@ $requestDump = 0;
 $switchInstr = 0;
 $headerPrinted = 0;
 $dumpHint = "";
+$verbose = 0;
 
 %spids = ();
 foreach $arg (@ARGV) {
@@ -205,6 +206,10 @@ foreach $arg (@ARGV) {
     elsif ($arg =~ /^--version$/) {
        printVersion;
     }
+    elsif ($arg =~ /^-v$/) {
+       $verbose++;
+       next;
+    }
     elsif ($arg =~ /^(-s|--stat)$/) {
        $printStatus = 1;
        next;
@@ -324,7 +329,7 @@ if ($requestZero) { $vgdbCommand = "zero"; }
 if ($requestKill) { $vgdbCommand = "v.kill"; }
 if ($switchInstr) { $vgdbCommand = "instrumentation ".$switchInstrMode; }
 if ($printStatus || $printBacktrace || $requestEvents) {
-  $vgdbCommand = "status";
+  $vgdbCommand = "status internal";
   $waitForAnswer = 1;
 }
 
@@ -336,7 +341,11 @@ foreach $pid (@pids) {
       print "\n";
       next;
   }
-  print " [requesting '$vgdbCommand']\n";
+  if ($verbose>0) {
+      print " [requesting '$vgdbCommand']\n";
+  } else {
+      print "\n";
+  }
   open RESULT, "vgdb --pid=$pid $vgdbCommand|";
 
   @tids = ();
index 0da3589ec30f45cee336327d54b7dd71cee0d282..994ddcbacb8de3eb4920324b0cb131b9926c6e88 100644 (file)
@@ -1093,11 +1093,16 @@ gdbserver (see <xref linkend="manual-core-adv.gdbserver-commandhandling"/>).
   </listitem>
 
   <listitem>
-    <para>It would be nice to have some more callgrind monitor
-    commands such as e.g. toggle collect and start instrumentation.
+    <para><varname>instrumentation [on|off]</varname> requests to set 
+    (if parameter on/off is given) or get the current instrumentation state.
     </para>
   </listitem>
 
+  <listitem>
+    <para><varname>status</varname> requests to print out some status
+    information.</para>
+  </listitem>
+
 </itemizedlist>
 </sect1>
 
index 00c076b7abe216bf8c00f02d5413b23b9f158aad..6f8e07de51d80e04c50a30d9814b092daa985a4e 100644 (file)
@@ -1450,7 +1450,7 @@ static void print_monitor_help ( void )
    VG_(gdb_printf) ("  zero\n");
    VG_(gdb_printf) ("        zero counters\n");
    VG_(gdb_printf) ("  status\n");
-   VG_(gdb_printf) ("        print status (statistics and shadow stacks)\n");
+   VG_(gdb_printf) ("        print status\n");
    VG_(gdb_printf) ("  instrumentation [on|off]\n");
    VG_(gdb_printf) ("        get/set (if on/off given) instrumentation state\n");
    VG_(gdb_printf) ("\n");
@@ -1483,10 +1483,28 @@ static Bool handle_gdb_monitor_command (ThreadId tid, Char *req)
       CLG_(zero_all_cost)(False);
       return True;
    }
+
    case 3: { /* status */
-     dump_state_togdb();
+     Char* arg = VG_(strtok_r) (0, " ", &ssaveptr);
+     if (arg && (VG_(strcmp)(arg, "internal") == 0)) {
+       /* internal interface to callgrind_control */
+       dump_state_togdb();
+       return True;
+     }
+
+     if (!CLG_(instrument_state)) {
+       VG_(gdb_printf)("No status available as instrumentation is switched off\n");
+     } else {
+       // Status information to be improved ...
+       thread_info** th = CLG_(get_threads)();
+       Int t, tcount = 0;
+       for(t=1;t<VG_N_THREADS;t++)
+        if (th[t]) tcount++;
+       VG_(gdb_printf)("%d thread(s) running.\n", tcount);
+     }
      return True;
    }
+
    case 4: { /* instrumentation */
      Char* arg = VG_(strtok_r) (0, " ", &ssaveptr);
      if (!arg) {