[padb] r419 committed - Switch gdb into 'c' mode for expressions which are known to require...

padb at googlecode.com padb at googlecode.com
Thu Nov 25 18:34:43 GMT 2010


Revision: 419
Author: apittman at gmail.com
Date: Thu Nov 25 10:33:54 2010
Log: Switch gdb into 'c' mode for expressions which are known to require
this.  Without this patch then attempting to read the MPI message
queues from fortran programs will fail due to padb being unable
to correctly calculate the offset of members within structs.

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

Modified:
  /trunk/src/padb

=======================================
--- /trunk/src/padb	Tue Nov  9 08:09:47 2010
+++ /trunk/src/padb	Thu Nov 25 10:33:54 2010
@@ -6052,6 +6052,7 @@
          tracepid => -1,
          attached => 0,
          pa       => 0,
+        lang     => 'auto',
          debug    => 0,
          seq      => 1,
      };
@@ -6163,6 +6164,7 @@
      }

      gdb_n_send( $gdb, '-gdb-set print address off' );
+    gdb_n_send( $gdb, '-gdb-set language auto' );

      return;
  }
@@ -6314,17 +6316,41 @@
      }
      return;
  }
+
+sub _gdb_set_lang {
+    my ( $gdb, $lang ) = @_;
+
+    if ( $lang eq $gdb->{lang} ) {
+        return;
+    }
+
+    $gdb->{lang} = $lang;
+
+    _gdb_send_real( $gdb, "-gdb-set language $lang" );
+
+    return;
+}

  sub gdb_n_send {
      my ( $gdb, $cmd ) = @_;
      _gdb_set_print_address( $gdb, 0 );
+    _gdb_set_lang( $gdb, 'auto' );
      return _gdb_send_real( $gdb, $cmd );
  }
+
+# Send a command in the c language
+sub gdb_send_c {
+    my ( $gdb, $cmd ) = @_;
+    _gdb_set_print_address( $gdb, 1 );
+    _gdb_set_lang( $gdb, 'c' );
+    return _gdb_send_real( $gdb, $cmd );
+}

  # Send a command with print address enabled.
  sub gdb_send_addr {
      my ( $gdb, $cmd ) = @_;
      _gdb_set_print_address( $gdb, 1 );
+    _gdb_set_lang( $gdb, 'auto' );
      return _gdb_send_real( $gdb, $cmd );
  }

@@ -6662,7 +6688,7 @@
  # adding extra text after the value which is causing hex to throw warnings.
  sub gdb_type_offset {
      my ( $gdb, $type, $field ) = @_;
-    my %p = gdb_send_addr( $gdb,
+    my %p = gdb_send_c( $gdb,
          "-data-evaluate-expression \"(void *)&(($type *)0)->$field\"" );
      return unless ( $p{status} eq 'done' );
      return hex gdb_strip_value( $p{reason} );




More information about the padb-devel mailing list