* [commit] Fix crash of gdb save-index on a STABS file
@ 2011-04-09 15:23 Jan Kratochvil
2011-04-14 20:44 ` Tom Tromey
0 siblings, 1 reply; 11+ messages in thread
From: Jan Kratochvil @ 2011-04-09 15:23 UTC (permalink / raw)
To: gdb-patches
Hi,
checked in, index saving functions crashed on NULL psymtabs_addrmap.
Running gdb/testsuite/gdb.stabs/gdb11479.exp ...
-gdb compile failed, gdb/cc-with-index.sh: line 107: 3487 Segmentation fault (core dumped) $GDB --batch-silent -nx -ex "file $output_file" -ex "save gdb-index $output_dir"
-UNTESTED: gdb.stabs/gdb11479.exp: gdb11479.exp
-gdb compile failed, cc-with-index.sh: Index file gdb/testsuite.unix.-m32/gdb.stabs/gdb11479.gdb-index exists, won't clobber.
-UNTESTED: gdb.stabs/gdb11479.exp: gdb11479.exp
+PASS: gdb.stabs/gdb11479.exp: Set breakpoints forced_stabs
[...]
+PASS: gdb.stabs/gdb11479.exp: sizeof (e) in test natural_debug_format
No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu.
There are some concerns what is a file uses both DWARF and STABS, it may
possibly currently have a regression with .gdb_index. But that is unrelated
to this patch.
Thanks,
Jan
http://sourceware.org/ml/gdb-cvs/2011-04/msg00061.html
--- src/gdb/ChangeLog 2011/04/09 11:15:28 1.12915
+++ src/gdb/ChangeLog 2011/04/09 15:20:37 1.12916
@@ -1,5 +1,11 @@
2011-04-09 Jan Kratochvil <jan.kratochvil@redhat.com>
+ Fix crash of gdb save-index on a STABS file.
+ * dwarf2read.c (write_psymtabs_to_index): Return also on no
+ PSYMTABS_ADDRMAP.
+
+2011-04-09 Jan Kratochvil <jan.kratochvil@redhat.com>
+
Fix DW_AT_accessibility compatibility with gcc-4.6+.
* dwarf2read.c: Include ctype.h.
(producer_is_gxx_lt_4_6, dwarf2_default_access_attribute): New
--- src/gdb/dwarf2read.c 2011/04/09 11:15:29 1.522
+++ src/gdb/dwarf2read.c 2011/04/09 15:20:38 1.523
@@ -15843,8 +15843,9 @@
htab_t cu_index_htab;
struct psymtab_cu_index_map *psymtab_cu_index_map;
- if (!objfile->psymtabs)
+ if (!objfile->psymtabs || !objfile->psymtabs_addrmap)
return;
+
if (dwarf2_per_objfile->using_index)
error (_("Cannot use an index to create the index"));
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [commit] Fix crash of gdb save-index on a STABS file
2011-04-09 15:23 [commit] Fix crash of gdb save-index on a STABS file Jan Kratochvil
@ 2011-04-14 20:44 ` Tom Tromey
2011-04-17 16:32 ` [patch+7.3] gdbindex regression: stabs forgotten [Fix crash of gdb save-index on a STABS file] Jan Kratochvil
0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2011-04-14 20:44 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> There are some concerns what is a file uses both DWARF and STABS,
Jan> it may possibly currently have a regression with .gdb_index. But
Jan> that is unrelated to this patch.
I think it should all work. At least, I designed it to.
The index itself is written by looking at the CUs in the objfile's
dwarf2_per_objfile. So, I think the index should not reference any
psymtabs coming from STABS.
On the reader side, the code in elfread.c is written to read STABS
first -- and skip using the index if any are found. This handles the
problem that an objfile can only have one set of quick functions.
This is expensive, but people mixing in this way deserve it ;-)
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch+7.3] gdbindex regression: stabs forgotten [Fix crash of gdb save-index on a STABS file]
2011-04-14 20:44 ` Tom Tromey
@ 2011-04-17 16:32 ` Jan Kratochvil
2011-04-18 17:31 ` Tom Tromey
0 siblings, 1 reply; 11+ messages in thread
From: Jan Kratochvil @ 2011-04-17 16:32 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Thu, 14 Apr 2011 22:44:28 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>
> Jan> There are some concerns what is a file uses both DWARF and STABS,
> Jan> it may possibly currently have a regression with .gdb_index. But
> Jan> that is unrelated to this patch.
>
> I think it should all work. At least, I designed it to.
[...]
> On the reader side, the code in elfread.c is written to read STABS
> first -- and skip using the index if any are found. This handles the
> problem that an objfile can only have one set of quick functions.
I do not see it implemented. This is a regression.
No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu and with
cc-with-index.sh (where it turns FAIL->PASS).
Thanks,
Jan
gdb/
2011-04-17 Jan Kratochvil <jan.kratochvil@redhat.com>
* elfread.c (elf_symfile_read): Protect dwarf2_initialize_objfile by
!objfile_has_partial_symbols. New comment.
* objfiles.c (objfile_has_partial_symbols): Call HAS_SYMBOLS if
SYM_READ_PSYMBOLS is not present.
gdb/testsuite/
2011-04-17 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/gdbindex-stabs-dwarf.c: New file.
* gdb.base/gdbindex-stabs.c: New file.
* gdb.base/gdbindex-stabs.exp: New file.
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1375,7 +1375,12 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
if (dwarf2_has_info (objfile))
{
- if (dwarf2_initialize_objfile (objfile))
+ /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF debug
+ information present in OBJFILE. If there is such debug info present
+ never use .gdb_index. */
+
+ if (!objfile_has_partial_symbols (objfile)
+ && dwarf2_initialize_objfile (objfile))
objfile->sf = &elf_sym_fns_gdb_index;
else
{
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -909,8 +909,9 @@ objfile_has_partial_symbols (struct objfile *objfile)
/* If we have not read psymbols, but we have a function capable of
reading them, then that is an indication that they are in fact
available. */
- if ((objfile->flags & OBJF_PSYMTABS_READ) == 0)
- return objfile->sf->sym_read_psymbols != NULL;
+ if ((objfile->flags & OBJF_PSYMTABS_READ) == 0
+ && objfile->sf->sym_read_psymbols != NULL)
+ return 1;
return objfile->sf->qf->has_symbols (objfile);
}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gdbindex-stabs-dwarf.c
@@ -0,0 +1,25 @@
+/* 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/>. */
+
+extern void stabs_function (void);
+
+int
+main (void)
+{
+ stabs_function ();
+ return 0;
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gdbindex-stabs.c
@@ -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/>. */
+
+void
+stabs_function (void) /* marker-here */
+{
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gdbindex-stabs.exp
@@ -0,0 +1,36 @@
+# Copyright (C) 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/>.
+
+# This problem is reproducible only when using `gdb/cc-with-index.sh'.
+
+set testfile gdbindex-stabs
+set executable ${testfile}
+set binfile ${objdir}/${subdir}/${executable}
+set srcfile_stabs ${testfile}.c
+set srcfile_dwarf ${testfile}-dwarf.c
+set objfile_stabs ${testfile}.o
+set objfile_dwarf ${testfile}-dwarf.o
+
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile_stabs}" ${objfile_stabs} object {additional_flags=-gstabs}] != ""
+ || [gdb_compile "${srcdir}/${subdir}/${srcfile_dwarf}" ${objfile_dwarf} object {additional_flags=-gdwarf-2}] != ""
+ || [gdb_compile "${objfile_stabs} ${objfile_dwarf}" ${binfile} executable {nodebug}] != ""} {
+ untested ${testfile}.exp
+ return -1
+}
+
+clean_restart ${executable}
+
+# FAIL was: No line number known for stabs_function.
+gdb_test "list stabs_function" " marker-here .*"
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch+7.3] gdbindex regression: stabs forgotten [Fix crash of gdb save-index on a STABS file]
2011-04-17 16:32 ` [patch+7.3] gdbindex regression: stabs forgotten [Fix crash of gdb save-index on a STABS file] Jan Kratochvil
@ 2011-04-18 17:31 ` Tom Tromey
2011-04-23 4:53 ` [wrong patch] Re: [patch+7.3] gdbindex regression: stabs forgotten Jan Kratochvil
2011-04-23 5:15 ` Jan Kratochvil
0 siblings, 2 replies; 11+ messages in thread
From: Tom Tromey @ 2011-04-18 17:31 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Tom> On the reader side, the code in elfread.c is written to read STABS
Tom> first -- and skip using the index if any are found. This handles the
Tom> problem that an objfile can only have one set of quick functions.
Jan> I do not see it implemented. This is a regression.
I must have dropped something somewhere along the line, oops.
Or maybe I just botched the logic when I added lazy psymtabs.
Jan> if (dwarf2_has_info (objfile))
Jan> {
Jan> - if (dwarf2_initialize_objfile (objfile))
Jan> + /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF debug
Jan> + information present in OBJFILE. If there is such debug info present
Jan> + never use .gdb_index. */
Jan> +
Jan> + if (!objfile_has_partial_symbols (objfile)
Jan> + && dwarf2_initialize_objfile (objfile))
This makes the case of "stabs, plus gnu index, plus -readnow" a little
worse.
It is hard to imagine anybody caring about this kind of thing though.
I just thought it was funny.
Jan> /* If we have not read psymbols, but we have a function capable of
Jan> reading them, then that is an indication that they are in fact
Jan> available. */
Jan> - if ((objfile->flags & OBJF_PSYMTABS_READ) == 0)
Jan> - return objfile->sf->sym_read_psymbols != NULL;
Jan> + if ((objfile->flags & OBJF_PSYMTABS_READ) == 0
Jan> + && objfile->sf->sym_read_psymbols != NULL)
Jan> + return 1;
I think this change requires an update to the comment and also maybe to
the corresponding comment in symfile.h.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* [wrong patch] Re: [patch+7.3] gdbindex regression: stabs forgotten
2011-04-18 17:31 ` Tom Tromey
@ 2011-04-23 4:53 ` Jan Kratochvil
2011-04-25 16:02 ` Tom Tromey
2011-04-23 5:15 ` Jan Kratochvil
1 sibling, 1 reply; 11+ messages in thread
From: Jan Kratochvil @ 2011-04-23 4:53 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Mon, 18 Apr 2011 19:31:21 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> Jan> if (dwarf2_has_info (objfile))
> Jan> {
> Jan> - if (dwarf2_initialize_objfile (objfile))
> Jan> + /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF debug
> Jan> + information present in OBJFILE. If there is such debug info present
> Jan> + never use .gdb_index. */
> Jan> +
> Jan> + if (!objfile_has_partial_symbols (objfile)
> Jan> + && dwarf2_initialize_objfile (objfile))
>
> This makes the case of "stabs, plus gnu index, plus -readnow" a little
> worse.
I tried to use elf_sym_fns_gdb_index even for STABS+DWARF files but that does
not work:
$ ../gdb -readnow -nx gdb.base/gdbindex-stabs -ex 'list stabs_function' -ex q
No line number known for stabs_function.
It seems even understandable for me. dwarf2_gdb_index_functions would need to
fallback to psym_functions IMO, if you meant that. I am not going to
implement that part, therefore just FYI.
> It is hard to imagine anybody caring about this kind of thing though.
> I just thought it was funny.
While it will probably never happen in Fedora still STABS is in use at least
for Firefox upstream and static libraries are also in use outside of Fedora so
I can imagine it may happen. Still -readnow needs no optimizations, I agree.
Thanks,
Jan
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2044,10 +2044,11 @@ find_slot_in_mapped_hash (struct mapped_index *index, const char *name,
}
/* Read the index file. If everything went ok, initialize the "quick"
- elements of all the CUs and return 1. Otherwise, return 0. */
+ elements of all the CUs and return 1 to use the GNU index. Otherwise,
+ return 0 so this file will use psymtabs. */
-static int
-dwarf2_read_index (struct objfile *objfile)
+int
+dwarf2_initialize_objfile (struct objfile *objfile)
{
char *addr;
struct mapped_index *map;
@@ -2727,49 +2728,31 @@ const struct quick_symbol_functions dwarf2_gdb_index_functions =
dw2_map_symbol_filenames
};
-/* Initialize for reading DWARF for this objfile. Return 0 if this
- file will use psymtabs, or 1 if using the GNU index. */
+/* If we're about to read full symbols, don't bother with the indices. In this
+ case we also don't care if some other debug format is making psymtabs,
+ because they are all about to be expanded anyway. */
-int
-dwarf2_initialize_objfile (struct objfile *objfile)
+void
+dwarf2_initialize_objfile_readnow (struct objfile *objfile)
{
- /* If we're about to read full symbols, don't bother with the
- indices. In this case we also don't care if some other debug
- format is making psymtabs, because they are all about to be
- expanded anyway. */
- if ((objfile->flags & OBJF_READNOW))
- {
- int i;
-
- dwarf2_per_objfile->using_index = 1;
- create_all_comp_units (objfile);
- create_debug_types_hash_table (objfile);
- dwarf2_per_objfile->quick_file_names_table =
- create_quick_file_names_table (dwarf2_per_objfile->n_comp_units);
+ int i;
- for (i = 0; i < (dwarf2_per_objfile->n_comp_units
- + dwarf2_per_objfile->n_type_comp_units); ++i)
- {
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ dwarf2_per_objfile->using_index = 1;
+ create_all_comp_units (objfile);
+ create_debug_types_hash_table (objfile);
+ dwarf2_per_objfile->quick_file_names_table =
+ create_quick_file_names_table (dwarf2_per_objfile->n_comp_units);
- per_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
- struct dwarf2_per_cu_quick_data);
- }
+ for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+ + dwarf2_per_objfile->n_type_comp_units); ++i)
+ {
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
- /* Return 1 so that gdb sees the "quick" functions. However,
- these functions will be no-ops because we will have expanded
- all symtabs. */
- return 1;
+ per_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+ struct dwarf2_per_cu_quick_data);
}
-
- if (dwarf2_read_index (objfile))
- return 1;
-
- return 0;
}
-\f
-
/* Build a partial symbol table. */
void
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1396,7 +1396,19 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
if (dwarf2_has_info (objfile))
{
- if (dwarf2_initialize_objfile (objfile))
+ if (objfile->flags & OBJF_READNOW)
+ {
+ dwarf2_initialize_objfile_readnow (objfile);
+
+ /* GDB will use the "quick" functions. However, these functions will
+ be no-ops because we will have expanded all symtabs. */
+ objfile->sf = &elf_sym_fns_gdb_index;
+ }
+ /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF debug
+ information present in OBJFILE. If there is such debug info present
+ never use .gdb_index. */
+ else if (!objfile_has_partial_symbols (objfile)
+ && dwarf2_initialize_objfile (objfile))
objfile->sf = &elf_sym_fns_gdb_index;
else
{
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -909,8 +909,9 @@ objfile_has_partial_symbols (struct objfile *objfile)
/* If we have not read psymbols, but we have a function capable of
reading them, then that is an indication that they are in fact
available. */
- if ((objfile->flags & OBJF_PSYMTABS_READ) == 0)
- return objfile->sf->sym_read_psymbols != NULL;
+ if ((objfile->flags & OBJF_PSYMTABS_READ) == 0
+ && objfile->sf->sym_read_psymbols != NULL)
+ return 1;
return objfile->sf->qf->has_symbols (objfile);
}
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -556,6 +556,7 @@ extern struct cleanup *increment_reading_symtab (void);
extern int dwarf2_has_info (struct objfile *);
extern int dwarf2_initialize_objfile (struct objfile *);
+extern void dwarf2_initialize_objfile_readnow (struct objfile *);
extern void dwarf2_build_psymtabs (struct objfile *);
extern void dwarf2_build_frame_info (struct objfile *);
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gdbindex-stabs-dwarf.c
@@ -0,0 +1,25 @@
+/* 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/>. */
+
+extern void stabs_function (void);
+
+int
+main (void)
+{
+ stabs_function ();
+ return 0;
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gdbindex-stabs.c
@@ -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/>. */
+
+void
+stabs_function (void) /* marker-here */
+{
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gdbindex-stabs.exp
@@ -0,0 +1,36 @@
+# Copyright (C) 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/>.
+
+# This problem is reproducible only when using `gdb/cc-with-index.sh'.
+
+set testfile gdbindex-stabs
+set executable ${testfile}
+set binfile ${objdir}/${subdir}/${executable}
+set srcfile_stabs ${testfile}.c
+set srcfile_dwarf ${testfile}-dwarf.c
+set objfile_stabs ${testfile}.o
+set objfile_dwarf ${testfile}-dwarf.o
+
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile_stabs}" ${objfile_stabs} object {additional_flags=-gstabs}] != ""
+ || [gdb_compile "${srcdir}/${subdir}/${srcfile_dwarf}" ${objfile_dwarf} object {additional_flags=-gdwarf-2}] != ""
+ || [gdb_compile "${objfile_stabs} ${objfile_dwarf}" ${binfile} executable {nodebug}] != ""} {
+ untested ${testfile}.exp
+ return -1
+}
+
+clean_restart ${executable}
+
+# FAIL was: No line number known for stabs_function.
+gdb_test "list stabs_function" " marker-here .*"
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch+7.3] gdbindex regression: stabs forgotten
2011-04-18 17:31 ` Tom Tromey
2011-04-23 4:53 ` [wrong patch] Re: [patch+7.3] gdbindex regression: stabs forgotten Jan Kratochvil
@ 2011-04-23 5:15 ` Jan Kratochvil
2011-04-25 16:03 ` Tom Tromey
1 sibling, 1 reply; 11+ messages in thread
From: Jan Kratochvil @ 2011-04-23 5:15 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Mon, 18 Apr 2011 19:31:21 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> Jan> /* If we have not read psymbols, but we have a function capable of
> Jan> reading them, then that is an indication that they are in fact
> Jan> available. */
> Jan> - if ((objfile->flags & OBJF_PSYMTABS_READ) == 0)
> Jan> - return objfile->sf->sym_read_psymbols != NULL;
> Jan> + if ((objfile->flags & OBJF_PSYMTABS_READ) == 0
> Jan> + && objfile->sf->sym_read_psymbols != NULL)
> Jan> + return 1;
>
> I think this change requires an update to the comment and also maybe to
> the corresponding comment in symfile.h.
ISTM the current code matches the comment better. Updated incl. symfile.h.
Thanks,
Jan
gdb/
2011-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
* elfread.c (elf_symfile_read): Protect dwarf2_initialize_objfile by
!objfile_has_partial_symbols. New comment.
* objfiles.c (objfile_has_partial_symbols): Call HAS_SYMBOLS if
SYM_READ_PSYMBOLS is not present. Extend the comment.
* symfile.h (struct sym_fns): Extend the sym_read_psymbols comment.
gdb/testsuite/
2011-04-17 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/gdbindex-stabs-dwarf.c: New file.
* gdb.base/gdbindex-stabs.c: New file.
* gdb.base/gdbindex-stabs.exp: New file.
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1396,7 +1396,12 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
if (dwarf2_has_info (objfile))
{
- if (dwarf2_initialize_objfile (objfile))
+ /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF debug
+ information present in OBJFILE. If there is such debug info present
+ never use .gdb_index. */
+
+ if (!objfile_has_partial_symbols (objfile)
+ && dwarf2_initialize_objfile (objfile))
objfile->sf = &elf_sym_fns_gdb_index;
else
{
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -906,11 +906,15 @@ objfile_has_partial_symbols (struct objfile *objfile)
{
if (!objfile->sf)
return 0;
- /* If we have not read psymbols, but we have a function capable of
- reading them, then that is an indication that they are in fact
- available. */
- if ((objfile->flags & OBJF_PSYMTABS_READ) == 0)
- return objfile->sf->sym_read_psymbols != NULL;
+
+ /* If we have not read psymbols, but we have a function capable of reading
+ them, then that is an indication that they are in fact available. Without
+ this function the symbols may have been already read in but they also may
+ not be present in this objfile. */
+ if ((objfile->flags & OBJF_PSYMTABS_READ) == 0
+ && objfile->sf->sym_read_psymbols != NULL)
+ return 1;
+
return objfile->sf->qf->has_symbols (objfile);
}
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -321,10 +321,10 @@ struct sym_fns
void (*sym_read) (struct objfile *, int);
- /* Read the partial symbols for an objfile. This may be NULL, in
- which case gdb assumes that sym_read already read the partial
- symbols. This may only be non-NULL if the objfile actually does
- have debuginfo available. */
+ /* Read the partial symbols for an objfile. This may be NULL, in which case
+ gdb has to check other ways if this objfile has any symbols. This may
+ only be non-NULL if the objfile actually does have debuginfo available.
+ */
void (*sym_read_psymbols) (struct objfile *);
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gdbindex-stabs-dwarf.c
@@ -0,0 +1,25 @@
+/* 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/>. */
+
+extern void stabs_function (void);
+
+int
+main (void)
+{
+ stabs_function ();
+ return 0;
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gdbindex-stabs.c
@@ -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/>. */
+
+void
+stabs_function (void) /* marker-here */
+{
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gdbindex-stabs.exp
@@ -0,0 +1,36 @@
+# Copyright (C) 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/>.
+
+# This problem is reproducible only when using `gdb/cc-with-index.sh'.
+
+set testfile gdbindex-stabs
+set executable ${testfile}
+set binfile ${objdir}/${subdir}/${executable}
+set srcfile_stabs ${testfile}.c
+set srcfile_dwarf ${testfile}-dwarf.c
+set objfile_stabs ${testfile}.o
+set objfile_dwarf ${testfile}-dwarf.o
+
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile_stabs}" ${objfile_stabs} object {additional_flags=-gstabs}] != ""
+ || [gdb_compile "${srcdir}/${subdir}/${srcfile_dwarf}" ${objfile_dwarf} object {additional_flags=-gdwarf-2}] != ""
+ || [gdb_compile "${objfile_stabs} ${objfile_dwarf}" ${binfile} executable {nodebug}] != ""} {
+ untested ${testfile}.exp
+ return -1
+}
+
+clean_restart ${executable}
+
+# FAIL was: No line number known for stabs_function.
+gdb_test "list stabs_function" " marker-here .*"
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [wrong patch] Re: [patch+7.3] gdbindex regression: stabs forgotten
2011-04-23 4:53 ` [wrong patch] Re: [patch+7.3] gdbindex regression: stabs forgotten Jan Kratochvil
@ 2011-04-25 16:02 ` Tom Tromey
0 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2011-04-25 16:02 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> It seems even understandable for me. dwarf2_gdb_index_functions
Jan> would need to fallback to psym_functions IMO, if you meant that. I
Jan> am not going to implement that part, therefore just FYI.
Yeah, I wouldn't bother.
This patch looks good to me.
Tom> It is hard to imagine anybody caring about this kind of thing though.
Tom> I just thought it was funny.
Jan> While it will probably never happen in Fedora still STABS is in use
Jan> at least for Firefox upstream and static libraries are also in use
Jan> outside of Fedora so I can imagine it may happen.
Gross.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch+7.3] gdbindex regression: stabs forgotten
2011-04-23 5:15 ` Jan Kratochvil
@ 2011-04-25 16:03 ` Tom Tromey
2011-04-25 19:41 ` Jan Kratochvil
0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2011-04-25 16:03 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> gdb/
Jan> 2011-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
Jan> * elfread.c (elf_symfile_read): Protect dwarf2_initialize_objfile by
Jan> !objfile_has_partial_symbols. New comment.
Jan> * objfiles.c (objfile_has_partial_symbols): Call HAS_SYMBOLS if
Jan> SYM_READ_PSYMBOLS is not present. Extend the comment.
Jan> * symfile.h (struct sym_fns): Extend the sym_read_psymbols comment.
Looks good.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch+7.3] gdbindex regression: stabs forgotten
2011-04-25 16:03 ` Tom Tromey
@ 2011-04-25 19:41 ` Jan Kratochvil
2011-04-25 20:49 ` Joel Brobecker
0 siblings, 1 reply; 11+ messages in thread
From: Jan Kratochvil @ 2011-04-25 19:41 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, Tom Tromey
On Mon, 25 Apr 2011 18:03:14 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>
> Jan> gdb/
> Jan> 2011-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Jan> * elfread.c (elf_symfile_read): Protect dwarf2_initialize_objfile by
> Jan> !objfile_has_partial_symbols. New comment.
> Jan> * objfiles.c (objfile_has_partial_symbols): Call HAS_SYMBOLS if
> Jan> SYM_READ_PSYMBOLS is not present. Extend the comment.
> Jan> * symfile.h (struct sym_fns): Extend the sym_read_psymbols comment.
>
> Looks good.
Checked in:
http://sourceware.org/ml/gdb-cvs/2011-04/msg00154.html
Joel, do you have anything against 7.3 check-in of this regression-fixing patch?
http://sourceware.org/ml/gdb-patches/2011-04/msg00421.html
But it affects only a special case...
Thanks,
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch+7.3] gdbindex regression: stabs forgotten
2011-04-25 19:41 ` Jan Kratochvil
@ 2011-04-25 20:49 ` Joel Brobecker
2011-04-25 21:28 ` Jan Kratochvil
0 siblings, 1 reply; 11+ messages in thread
From: Joel Brobecker @ 2011-04-25 20:49 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, Tom Tromey
> Checked in:
> http://sourceware.org/ml/gdb-cvs/2011-04/msg00154.html
>
> Joel, do you have anything against 7.3 check-in of this regression-fixing patch?
> http://sourceware.org/ml/gdb-patches/2011-04/msg00421.html
No problem on my side, please go ahead.
--
Joel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch+7.3] gdbindex regression: stabs forgotten
2011-04-25 20:49 ` Joel Brobecker
@ 2011-04-25 21:28 ` Jan Kratochvil
0 siblings, 0 replies; 11+ messages in thread
From: Jan Kratochvil @ 2011-04-25 21:28 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, Tom Tromey
On Mon, 25 Apr 2011 22:48:46 +0200, Joel Brobecker wrote:
> > Joel, do you have anything against 7.3 check-in of this regression-fixing patch?
> > http://sourceware.org/ml/gdb-patches/2011-04/msg00421.html
>
> No problem on my side, please go ahead.
Checked in:
Branch: gdb_7_3-branch
http://sourceware.org/ml/gdb-cvs/2011-04/msg00155.html
http://sourceware.org/ml/gdb-cvs/2011-04/msg00156.html
(in two commits due to my mistake)
Thanks,
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-04-25 21:28 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-09 15:23 [commit] Fix crash of gdb save-index on a STABS file Jan Kratochvil
2011-04-14 20:44 ` Tom Tromey
2011-04-17 16:32 ` [patch+7.3] gdbindex regression: stabs forgotten [Fix crash of gdb save-index on a STABS file] Jan Kratochvil
2011-04-18 17:31 ` Tom Tromey
2011-04-23 4:53 ` [wrong patch] Re: [patch+7.3] gdbindex regression: stabs forgotten Jan Kratochvil
2011-04-25 16:02 ` Tom Tromey
2011-04-23 5:15 ` Jan Kratochvil
2011-04-25 16:03 ` Tom Tromey
2011-04-25 19:41 ` Jan Kratochvil
2011-04-25 20:49 ` Joel Brobecker
2011-04-25 21:28 ` Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox