[padb] r348 committed - Add new as-yet unused asyncronous gdb attaching code. Gdb can take a...
padb at googlecode.com
padb at googlecode.com
Mon Dec 7 12:30:55 GMT 2009
Revision: 348
Author: apittman
Date: Mon Dec 7 04:30:03 2009
Log: Add new as-yet unused asyncronous gdb attaching code. Gdb can take a
while to attach to a process, expecially if it's got lots of shared
librarys which need to be loaded off a shared filesystems, this change
adds the option to asyncronously attach meaning that padb can launch
a instance of gdb for every target process on a node, tell them all to
attach and allow them to procede in parallel. This should help the
performance a lot, particuarly on nodes with lots of cores.
http://code.google.com/p/padb/source/detail?r=348
Modified:
/trunk/src/padb
=======================================
--- /trunk/src/padb Mon Dec 7 04:22:42 2009
+++ /trunk/src/padb Mon Dec 7 04:30:03 2009
@@ -5473,6 +5473,14 @@
}
return;
}
+
+ gdb_attach_post( $gdb, $pid );
+
+ return $pid;
+}
+
+sub gdb_attach_post {
+ my ( $gdb, $pid ) = @_;
$gdb->{attached} = 1;
$gdb->{tracepid} = $pid;
@@ -5493,6 +5501,52 @@
gdb_n_send( $gdb, '-gdb-set print address off' );
+}
+
+sub gdb_attach_async_start {
+ my ( $gdb, $pid ) = @_;
+
+ if ($running_on_solaris) {
+ my $exe = readlink("/proc/$pid/path/a.out");
+ my %cs = gdb_n_send( $gdb, "file $exe" );
+ if ( $cs{status} ne 'done' ) {
+ croak("Gdb command file $exe failed");
+ return;
+ }
+ }
+
+ send_cont_signal($pid);
+
+ _gdb_send_real_async_start( $gdb, "attach $pid" );
+
+ return;
+}
+
+sub gdb_attach_async_end {
+ my ( $gdb, $pid ) = @_;
+
+ my %p = _gdb_send_real_async_wait( $gdb, "attach $pid" );
+
+ if ( not defined $p{status} ) {
+ $gdb->{error} = 'Failed to attach to process';
+ if ( not find_exe('gdb') ) {
+ $gdb->{error} = 'Failed to attach to process (gdb not
installed?)';
+ }
+ return;
+ }
+
+ if ( $p{status} eq 'error' ) {
+ my $r = gdb_parse_reason( $p{reason} );
+ if ( defined $r->{msg} ) {
+ $gdb->{error} = "Failed to attach to process: $r->{msg}";
+ } else {
+ $gdb->{error} = 'Failed to attach to process';
+ }
+ return;
+ }
+
+ gdb_attach_post( $gdb, $pid );
+
return $pid;
}
@@ -5543,6 +5597,34 @@
}
return %r;
}
+
+sub _gdb_send_real_async_start {
+ my ( $gdb, $cmd ) = @_;
+ gdb_wait_for_prompt($gdb);
+ my $handle = $gdb->{wtr};
+ my $seq = $gdb->{seq}++;
+ print {$handle} "$seq$cmd\n";
+ if ( defined $gdb->{debugfd} ) {
+ print { $gdb->{debugfd} } "$seq$cmd\n";
+ }
+ return;
+}
+
+sub _gdb_send_real_async_wait {
+ my ( $gdb, $cmd ) = @_;
+ my $seq = $gdb->{seq};
+ my %r = gdb_n_next_result( $gdb, $seq );
+ if ( $gdb->{attached} and $r{seq} ne $seq ) {
+ croak(
+"Invalid sequence number from gdb, expecting $seq got $r{seq} cmd=\"$cmd\""
+ );
+ }
+ $r{cmd} = $cmd;
+ if ( $gdb->{debugfd} and defined $r{status} and $r{status} ne 'done' )
{
+ print Dumper \%r;
+ }
+ return %r;
+}
sub _gdb_set_print_address {
my ( $gdb, $flag ) = @_;
More information about the padb-devel
mailing list