[padb-devel] [padb commit] r112 - Collect together all the code which sends SIGCONT to a process
codesite-noreply at google.com
codesite-noreply at google.com
Fri Jul 17 18:10:42 BST 2009
Author: apittman
Date: Fri Jul 17 10:09:46 2009
New Revision: 112
Modified:
branches/full-duplex/src/padb
Log:
Collect together all the code which sends SIGCONT to a process
before attaching into a send_cont_signal() function. Call this
function inside gdb_attach and gdb_detach to ensure it always gets
called. We should probably read the process state and check if it's
T or not and warn the user if it is rather than just silently fixing
things up.
Modified: branches/full-duplex/src/padb
==============================================================================
--- branches/full-duplex/src/padb (original)
+++ branches/full-duplex/src/padb Fri Jul 17 10:09:46 2009
@@ -4196,6 +4196,7 @@
sub gdb_attach {
my ( $gdb, $pid ) = @_;
+ send_cont_signal($pid);
my $result = gdb_send( $gdb, "attach $pid" );
return unless defined $result;
@@ -4215,7 +4216,7 @@
$gdb->{attached} = 0;
- return $gdb->{tracepid};
+ send_cont_signal( $gdb->{tracepid} );
}
sub gdb_wait_for_prompt {
@@ -4671,10 +4672,19 @@
return @mq;
}
+# Send a CONT signal to a pid, there have been problems where a program
+# is in "T" state which causes the attach to hang forever. Send the
+# process a signal before attaching to wake it up in case this is the case.
+# gdb crashing (yes it does happen) is a common case for processes to be
+# stopped so always deliver this signal before and after attaching.
+sub send_cont_signal {
+ my $pid = shift;
+ kill( "CONT", $pid );
+}
+
sub fetch_mpi_queue {
my ( $carg, $vp, $pid ) = @_;
my $g = gdb_start();
- kill( "CONT", $pid );
my $p = gdb_attach( $g, $pid );
if ( !$p ) {
debug( $vp, "Failed to attach to process\n" );
@@ -4735,7 +4745,6 @@
debug $vp, "Attaching to $pid";
my $gdb = gdb_start();
- kill( "CONT", $pid );
if ( gdb_attach( $gdb, $pid ) ) {
$proc->{gdb} = $gdb;
push( @all, $proc );
@@ -4778,7 +4787,6 @@
debug $vp, "Attaching to $pid";
my $gdb = gdb_start();
- kill( "CONT", $pid );
if ( gdb_attach( $gdb, $pid ) ) {
$proc->{gdb} = $gdb;
push( @all, $proc );
@@ -5001,6 +5009,7 @@
sub gdb_read_value {
my ( $gdb, $name ) = @_;
+
# Quote the request in case it contains spaces.
my %t = gdb_n_send( $gdb, "-data-evaluate-expression \"$name\"" );
if ( $t{status} eq "done" ) {
@@ -5237,7 +5246,7 @@
debug $vp, "running (p) $cmd";
my $lines = 0;
- kill( "CONT", $pid );
+ send_cont_signal($pid);
open( CMD, "$cmd 2>/dev/null|" )
|| p_die( $vp, "cant start command $cmd" );
while (<CMD>) {
@@ -5245,7 +5254,7 @@
output $vp, $_;
$lines++;
}
- kill( "CONT", $pid );
+ send_cont_signal($pid);
close CMD;
return $lines;
}
@@ -5776,7 +5785,6 @@
debug $vp, "Attaching to $pid";
my $gdb = gdb_start();
- kill( "CONT", $pid );
if ( gdb_attach( $gdb, $pid ) ) {
$proc->{gdb} = $gdb;
push( @all, $proc );
@@ -5801,7 +5809,7 @@
if ($tries) {
debug $vp, "Re-attaching to $pid, $tries";
- kill( "CONT", $pid );
+ send_cont_signal($pid);
sleep(1);
my $g = gdb_start();
if ( gdb_attach( $g, $pid ) ) {
@@ -5824,7 +5832,6 @@
}
gdb_detach($gdb);
gdb_quit($gdb);
- kill( "CONT", $pid );
if ( defined $threads[0]->{frames} ) {
my @frames = @{ $threads[0]->{frames} };
@@ -5914,12 +5921,11 @@
my ( $vp, $pid ) = @_;
my $gdb = gdb_start();
- kill( "CONT", $pid );
+
if ( gdb_attach( $gdb, $pid ) ) {
my @threads = gdb_dump_frames_per_thread( $gdb, 1 );
gdb_detach($gdb);
gdb_quit($gdb);
- kill( "CONT", $pid );
foreach my $thread ( sort { $a->{id} <=> $b->{id} } @threads ) {
my @frames = @{ $thread->{frames} };
@@ -6061,7 +6067,6 @@
my $vp = $proc->{vp};
my $pid = $proc->{pid};
my $gdb = gdb_start();
- kill( "CONT", $pid );
if ( gdb_attach( $gdb, $pid ) ) {
$proc->{gdb} = $gdb;
} else {
More information about the padb-devel
mailing list