From 6f451e5ec454cf6611b99df727ba77bf8bc71da7 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 17 Feb 2010 22:25:05 +0000 Subject: [PATCH] gdb * objfiles.c (gdb_bfd_ref): Handle abfd==NULL. gdb/testsuite * gdb.java/jprint.java (jprint.props): New field. * gdb.java/jprint.exp (set_lang_java): Add regression test. --- gdb/ChangeLog | 4 ++++ gdb/objfiles.c | 7 ++++++- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.java/jprint.exp | 3 +++ gdb/testsuite/gdb.java/jprint.java | 6 +++++- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 70d1c205c9d..425e8c8a8ce 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2010-02-17 Tom Tromey + + * objfiles.c (gdb_bfd_ref): Handle abfd==NULL. + 2010-02-17 Jan Kratochvil * symfile.c (build_section_addr_info_from_objfile): Include sections diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 489b81289f0..c2763c22401 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -1504,7 +1504,12 @@ objfiles_changed (void) struct bfd * gdb_bfd_ref (struct bfd *abfd) { - int *p_refcount = bfd_usrdata (abfd); + int *p_refcount; + + if (abfd == NULL) + return NULL; + + p_refcount = bfd_usrdata (abfd); if (p_refcount != NULL) { diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 9497fd52f6d..c2827eff800 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-02-17 Tom Tromey + + * gdb.java/jprint.java (jprint.props): New field. + * gdb.java/jprint.exp (set_lang_java): Add regression test. + 2010-02-17 Pedro Alves * gdb.base/charset.exp: Don't assume new `regsub' syntax diff --git a/gdb/testsuite/gdb.java/jprint.exp b/gdb/testsuite/gdb.java/jprint.exp index bb929aaa2c4..29dbf4badee 100644 --- a/gdb/testsuite/gdb.java/jprint.exp +++ b/gdb/testsuite/gdb.java/jprint.exp @@ -84,4 +84,7 @@ if ![set_lang_java] then { gdb_test "call x.dothat(55)" "new value is 58\r\n.*= 62.*" "virtual fn call" gdb_test "p x.addprint(1,2,3)" "sum is 6\r\n.*" "inherited static call" gdb_test "call x.addk(44)" "adding k gives 121\r\n.*= 121.*" "inherited virtual fn call" + + # Regression test for a crasher. + gdb_test "print *jprint.props" " = .*" "print a java.util.Properties" } diff --git a/gdb/testsuite/gdb.java/jprint.java b/gdb/testsuite/gdb.java/jprint.java index bd4fa96be87..01ebdbc1140 100644 --- a/gdb/testsuite/gdb.java/jprint.java +++ b/gdb/testsuite/gdb.java/jprint.java @@ -1,6 +1,6 @@ // jprint.java test program. // -// Copyright 2004 +// Copyright 2004, 2010 // Free Software Foundation, Inc. // // Written by Jeff Johnston @@ -21,6 +21,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +import java.util.Properties; + class jvclass { public static int k; static { @@ -39,6 +41,8 @@ class jvclass { } public class jprint extends jvclass { + public static Properties props = new Properties (); + public int dothat (int x) { int y = x + 3; System.out.println ("new value is " + y); -- 2.30.2