[padb-devel] [padb] r303 committed - Add an option to save a trace of the communication with minfo to a fil...

padb at googlecode.com padb at googlecode.com
Tue Oct 27 21:33:31 GMT 2009


Revision: 303
Author: apittman
Date: Tue Oct 27 14:33:16 2009
Log: Add an option to save a trace of the communication with minfo to a file
in /tmp.  Useful for debugging problems with padb itself.

http://code.google.com/p/padb/source/detail?r=303

Modified:
  /trunk/src/padb

=======================================
--- /trunk/src/padb	Tue Oct 27 13:59:52 2009
+++ /trunk/src/padb	Tue Oct 27 14:33:16 2009
@@ -5724,12 +5724,18 @@
          hpid     => -1,
          tracepid => -1,
          attached => 0,
+        debug    => 0,
      };

      my $cmd = $inner_conf{minfo};
      $h->{hpid} = open3( $h->{fd}{wtr}, $h->{fd}{rdr}, $h->{fd}{err}, $cmd )
        or confess "Unable to popen() h: $!\n";

+    if ( $h->{debug} ) {
+        my ( $fh, $file ) =  
tempfile("/tmp/padb-minfo-debug-log-$vp-XXXXXX");
+        $h->{debugfd} = $fh;
+    }
+
      my $handle = $h->{fd}{rdr};

      my $out = $h->{fd}{wtr};
@@ -5751,6 +5757,10 @@
      while (<$handle>) {
          my $r = $_;

+        if ( defined $h->{debugfd} ) {
+            print { $h->{debugfd} } $r;
+        }
+
          if ( defined $bytes_to_read ) {
              $str_value .= $r;
              if ( length $str_value eq $bytes_to_read + 1 ) {
@@ -5790,6 +5800,11 @@
              # and we don't need to report it.

              print {$out} "$res\n";
+
+            if ( defined $h->{debugfd} ) {
+                print { $h->{debugfd} } "$res\n";
+            }
+
          } elsif ( $cmd eq 'out:' ) {
              if (
                  $r =~ m{\A
@@ -6581,6 +6596,7 @@
          push @th, \%t;
          return @th;
      }
+
      # Solaris has a extra "LWP" thread for every process which gdb reports
      # as being a duplicate of the main thread for a process.  Skip loading
      # this thread as it doesn't add anything to the output rather muddies




More information about the padb-devel mailing list