From 741f5e3c63f81da03e3c73b09c0205c3bcac0658 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sun, 9 Oct 2011 18:37:27 +0000 Subject: [PATCH] gdb/ Fix initial language detection with -readnow. * dwarf2read.c (dw2_find_symbol_file): Handle OBJF_READNOW case. * symfile.h (struct quick_symbol_functions): State find_symbol_file searches only for global symbols. gdb/testsuite/ Fix initial language detection with -readnow. * gdb.cp/readnow-language.cc: New file. * gdb.cp/readnow-language.exp: New file. --- gdb/ChangeLog | 7 ++++++ gdb/dwarf2read.c | 16 ++++++++++++- gdb/symfile.h | 2 +- gdb/testsuite/ChangeLog | 6 +++++ gdb/testsuite/gdb.cp/readnow-language.cc | 21 +++++++++++++++++ gdb/testsuite/gdb.cp/readnow-language.exp | 28 +++++++++++++++++++++++ 6 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 gdb/testsuite/gdb.cp/readnow-language.cc create mode 100644 gdb/testsuite/gdb.cp/readnow-language.exp diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b366c65f1f..9333ab15b0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2011-10-09 Jan Kratochvil + + Fix initial language detection with -readnow. + * dwarf2read.c (dw2_find_symbol_file): Handle OBJF_READNOW case. + * symfile.h (struct quick_symbol_functions): State find_symbol_file + searches only for global symbols. + 2011-10-09 Jan Kratochvil Fix printed anonymous struct name. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 55abb93b96..be7a7ef0c1 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -2650,7 +2650,21 @@ dw2_find_symbol_file (struct objfile *objfile, const char *name) /* index_table is NULL if OBJF_READNOW. */ if (!dwarf2_per_objfile->index_table) - return NULL; + { + struct symtab *s; + + ALL_OBJFILE_SYMTABS (objfile, s) + if (s->primary) + { + struct blockvector *bv = BLOCKVECTOR (s); + const struct block *block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); + struct symbol *sym = lookup_block_symbol (block, name, VAR_DOMAIN); + + if (sym) + return sym->symtab->filename; + } + return NULL; + } if (!find_slot_in_mapped_hash (dwarf2_per_objfile->index_table, name, &vec)) diff --git a/gdb/symfile.h b/gdb/symfile.h index 0e648d0979..624df76823 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -222,7 +222,7 @@ struct quick_symbol_functions void (*expand_symtabs_with_filename) (struct objfile *objfile, const char *filename); - /* Return the file name of the file holding the symbol in OBJFILE + /* Return the file name of the file holding the global symbol in OBJFILE named NAME. If no such symbol exists in OBJFILE, return NULL. */ const char *(*find_symbol_file) (struct objfile *objfile, const char *name); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 0ec3cf95cc..8c9a719577 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-10-09 Jan Kratochvil + + Fix initial language detection with -readnow. + * gdb.cp/readnow-language.cc: New file. + * gdb.cp/readnow-language.exp: New file. + 2011-10-09 Jan Kratochvil Fix printed anonymous struct name. diff --git a/gdb/testsuite/gdb.cp/readnow-language.cc b/gdb/testsuite/gdb.cp/readnow-language.cc new file mode 100644 index 0000000000..32c4fbdbdc --- /dev/null +++ b/gdb/testsuite/gdb.cp/readnow-language.cc @@ -0,0 +1,21 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +int +main () +{ +} diff --git a/gdb/testsuite/gdb.cp/readnow-language.exp b/gdb/testsuite/gdb.cp/readnow-language.exp new file mode 100644 index 0000000000..d6d3646fc7 --- /dev/null +++ b/gdb/testsuite/gdb.cp/readnow-language.exp @@ -0,0 +1,28 @@ +# Copyright 2011 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set testfile readnow-language +set srcfile ${testfile}.cc +set executable ${testfile} +if {[build_executable ${testfile}.exp $executable ${testfile}.cc {c++ debug}] == -1} { + return -1 +} + +set old_gdbflags $GDBFLAGS +set GDBFLAGS "$GDBFLAGS -readnow" +clean_restart $executable +set GDBFLAGS $old_gdbflags + +gdb_test "show language" {The current source language is "auto; currently c\+\+"\.}