gdb/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Sun, 9 Oct 2011 18:37:27 +0000 (18:37 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Sun, 9 Oct 2011 18:37:27 +0000 (18:37 +0000)
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
gdb/dwarf2read.c
gdb/symfile.h
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/readnow-language.cc [new file with mode: 0644]
gdb/testsuite/gdb.cp/readnow-language.exp [new file with mode: 0644]

index b366c65f1f007330a4561eb8a66c288f31d24b57..9333ab15b0b02ddc281cdc35c83117718726a154 100644 (file)
@@ -1,3 +1,10 @@
+2011-10-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       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  <jan.kratochvil@redhat.com>
 
        Fix printed anonymous struct name.
index 55abb93b9634da0aea9b606b214b689381c62527..be7a7ef0c16d01dd4c12a54a40c2a0309e05c721 100644 (file)
@@ -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))
index 0e648d097955ba73bd0e0f4d14cbee86bf01b59e..624df7682324f0adac2546a955f7cbba379f000a 100644 (file)
@@ -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);
 
index 0ec3cf95cc7891e4ebc5096e41c4acd9f8f3f616..8c9a719577563c12fc2e68b7f98706cefb96368b 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       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  <jan.kratochvil@redhat.com>
 
        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 (file)
index 0000000..32c4fbd
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.  */
+
+int
+main ()
+{
+}
diff --git a/gdb/testsuite/gdb.cp/readnow-language.exp b/gdb/testsuite/gdb.cp/readnow-language.exp
new file mode 100644 (file)
index 0000000..d6d3646
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+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\+\+"\.}