[padb-devel] [padb] r159 committed - In mpi-watch mode sample process status before attempting to attach wi...

codesite-noreply at google.com codesite-noreply at google.com
Wed Aug 26 09:44:49 BST 2009


Revision: 159
Author: apittman
Date: Wed Aug 26 01:43:48 2009
Log: In mpi-watch mode sample process status before attempting to attach  
with gdb,
otherwise the process state is always T which is treated as an error.  Also
handle the case where gdb isn't installed, previously an error was given
and the program hung, now it just doesn't report stack data.

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

Modified:
  /trunk/src/padb

=======================================
--- /trunk/src/padb	Tue Aug 25 10:45:00 2009
+++ /trunk/src/padb	Wed Aug 26 01:43:48 2009
@@ -3808,7 +3808,8 @@
              }
              return;
          } elsif ( $value >= $part->{l} and $value <= $part->{u} ) {
-            confess("Failed to add value to range (Value already in  
range)");
+            carp("Failed to add value to range (Value already in range)");
+            return;
          }
          $idx++;
      }
@@ -6415,17 +6416,40 @@
      foreach my $proc ( @{$list} ) {
          my $vp  = $proc->{vp};
          my $pid = $proc->{pid};
+
+        # Load the status now before we attach with GDB,
+        # otherwise we'll just see it as "T" (Stopped).
+        my $m = find_from_status( $pid, "State" );
+        if ( $m eq "R" ) {
+            $m = ",";
+        } elsif ( $m eq "S" ) {
+            $m = "-";
+        } else {
+            $m = "*";
+        }
+        $proc->{state} = $m;
+
          my $gdb = gdb_start();
          if ( gdb_attach( $gdb, $pid ) ) {
              $proc->{gdb} = $gdb;
          } else {
-            output $vp, "Failed to attach to to process";
+            if ( defined $gdb->{error} ) {
+                target_error( $vp, $gdb->{error} );
+            } else {
+                target_error( $vp, "Failed to attach to process" );
+            }
          }
      }

      foreach my $proc ( @{$list} ) {
          my $vp  = $proc->{vp};
          my $pid = $proc->{pid};
+
+        if ( not defined $proc->{gdb} ) {
+            $res{$vp}{state} = $proc->{state};
+            next;
+        }
+
          my $gdb = $proc->{gdb};

          my @mq;
@@ -6488,22 +6512,15 @@

          }

-        my $m = find_from_status( $pid, "State" );
-        if ( $m eq "R" ) {
-            $m = $good;
-        } elsif ( $m eq "S" ) {
-            $m = "-";
-        } else {
-            $m = "*";
-        }
-
-        $res{$vp}{state} = $m;
+        # Fall through case.
+        $res{$vp}{state} = $proc->{state};
      }

      foreach my $proc ( @{$list} ) {
-        my $gdb = $proc->{gdb};
-        gdb_detach($gdb);
-        gdb_quit($gdb);
+        if ( $proc->{gdb} ) {
+            gdb_detach( $proc->{gdb} );
+            gdb_quit( $proc->{gdb} );
+        }
      }

      return \%res;




More information about the padb-devel mailing list