* [PATCH v2 3/5] use language of the main symbol
2013-08-07 19:45 [PATCH v2 0/5] fix some "dwz -m" regressions Tom Tromey
@ 2013-08-07 19:45 ` Tom Tromey
2013-08-08 15:22 ` Regression for gdb.objc/basicclass.exp [Re: [PATCH v2 3/5] use language of the main symbol] Jan Kratochvil
2013-08-07 19:45 ` [PATCH v2 5/5] fix PR symtab/15028 Tom Tromey
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Tom Tromey @ 2013-08-07 19:45 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
With "dwz -m", "main" appears in both the PU and the importing CU when
running anon-struct.exp. However, the PU does not have a file name.
So, find_main_filename returns the empty string, making
deduce_language_from_filename return language_unknown.
This patch fixes this problem by changing gdb to use the ordinary
symbol-lookup functions to find "main"'s symbol. Then, it examines the
symbol's language.
I think this is cleaner than the current approach. For one thing it
avoids trying to guess the language based on the source file name,
instead deferring to the presumably more reliable debuginfo.
Another possible fix would have been to change how the file name is
found via the "qf" methods. However, I think the approach given is
preferable for the reason outlined above.
This required a minor test suite change, as now a symtab is expanded
during the search for "main".
Built and regtested (both ways) on x86-64 Fedora 18.
* symfile.c (set_initial_language): Look up "main" symbol
and use its language.
* symtab.c (find_main_filename): Remove.
* symtab.h (find_main_filename): Remove.
* gdb.base/maint.exp: Allow zero symtabs to be expanded.
---
gdb/symfile.c | 8 ++++----
gdb/symtab.c | 23 -----------------------
gdb/symtab.h | 2 --
gdb/testsuite/gdb.base/maint.exp | 7 ++++---
4 files changed, 8 insertions(+), 32 deletions(-)
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 3328648..3dd5509 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1612,11 +1612,11 @@ set_initial_language (void)
lang = language_of_main;
else
{
- const char *filename;
+ char *name = main_name ();
+ struct symbol *sym = lookup_symbol (name, NULL, VAR_DOMAIN, NULL);
- filename = find_main_filename ();
- if (filename != NULL)
- lang = deduce_language_from_filename (filename);
+ if (sym != NULL)
+ lang = SYMBOL_LANGUAGE (sym);
}
if (lang == language_unknown)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 8076fe5..3bcec23 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1949,29 +1949,6 @@ basic_lookup_transparent_type (const char *name)
return (struct type *) 0;
}
-/* Find the name of the file containing main(). */
-/* FIXME: What about languages without main() or specially linked
- executables that have no main() ? */
-
-const char *
-find_main_filename (void)
-{
- struct objfile *objfile;
- char *name = main_name ();
-
- ALL_OBJFILES (objfile)
- {
- const char *result;
-
- if (!objfile->sf)
- continue;
- result = objfile->sf->qf->find_symbol_file (objfile, name);
- if (result)
- return result;
- }
- return (NULL);
-}
-
/* Search BLOCK for symbol NAME in DOMAIN.
Note that if NAME is the demangled form of a C++ symbol, we will fail
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 6d81507..ccf4a4f 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1252,8 +1252,6 @@ extern VEC (char_ptr) *make_source_files_completion_list (const char *,
int matching_obj_sections (struct obj_section *, struct obj_section *);
-extern const char *find_main_filename (void);
-
extern struct symtab *find_line_symtab (struct symtab *, int, int *, int *);
extern struct symtab_and_line find_function_start_sal (struct symbol *sym,
diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 7057ac7..3093aae 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -72,9 +72,10 @@ gdb_test "maint print registers" "Name.*Nr.*Rel.*Offset.*Size.*Type.*"
gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
"mt expand-symtabs" {
- -re "#primary symtabs: (1|2) \\(\[+\](1|2)\\),.*$gdb_prompt $" {
- # This should expand one or at most two primary symtabs.
- # "Normally" it will expand just the one for break.c, but if the
+ -re "#primary symtabs: (1|2) \\(\[+\](0|1|2)\\),.*$gdb_prompt $" {
+ # This should expand at most two primary symtabs.
+ # "Normally" it will not expand any, because the symtab
+ # holding "main" will already have been expanded, but if the
# file is compiled with -fdebug-types-section then a second primary
# symtab for break.c will be created for any types.
pass "mt expand-symtabs"
--
1.8.1.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* Regression for gdb.objc/basicclass.exp [Re: [PATCH v2 3/5] use language of the main symbol]
2013-08-07 19:45 ` [PATCH v2 3/5] use language of the main symbol Tom Tromey
@ 2013-08-08 15:22 ` Jan Kratochvil
0 siblings, 0 replies; 9+ messages in thread
From: Jan Kratochvil @ 2013-08-08 15:22 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
Hi Tom,
I am aware GDB does not support ObjC too much AFAIK.
Another issues is that on any recent OS the ObjC testcases are being skipped
due to GCC warnings (going to post some patch for it).
This regression happens on CentOS-5:
Running gdb/testsuite/gdb.objc/basicclass.exp ...
PASS: gdb.objc/basicclass.exp: successfully compiled objc with posix threads test case
-PASS: gdb.objc/basicclass.exp: deduced language is Objective-C, before full symbols
-PASS: gdb.objc/basicclass.exp: deduced language is Objective-C, after full symbols
+FAIL: gdb.objc/basicclass.exp: source language not correct for Objective-C (psymtabs only)
PASS: gdb.objc/basicclass.exp: set breakpoint pending
PASS: gdb.objc/basicclass.exp: breakpoint method
PASS: gdb.objc/basicclass.exp: breakpoint method with colon
PASS: gdb.objc/basicclass.exp: breakpoint class method with colon
-PASS: gdb.objc/basicclass.exp: continue until method breakpoint
-PASS: gdb.objc/basicclass.exp: resetting breakpoints when rerunning
-PASS: gdb.objc/basicclass.exp: continue until method breakpoint
-PASS: gdb.objc/basicclass.exp: print an ivar of self
-PASS: gdb.objc/basicclass.exp: print self
-PASS: gdb.objc/basicclass.exp: print contents of self
+FAIL: gdb.objc/basicclass.exp: continue until method breakpoint (the program is no longer running)
+FAIL: gdb.objc/basicclass.exp: resetting breakpoints when rerunning
+FAIL: gdb.objc/basicclass.exp: continue until method breakpoint (the program exited)
+FAIL: gdb.objc/basicclass.exp: print an ivar of self
+FAIL: gdb.objc/basicclass.exp: print self
+FAIL: gdb.objc/basicclass.exp: print contents of self
PASS: gdb.objc/basicclass.exp: breakpoint in category method
-PASS: gdb.objc/basicclass.exp: continue until category method
-PASS: gdb.objc/basicclass.exp: Call an Objective-C method with no arguments
-PASS: gdb.objc/basicclass.exp: Call an Objective-C method with one argument
-PASS: gdb.objc/basicclass.exp: Use of the print-object command
-PASS: gdb.objc/basicclass.exp: Use of the po (print-object) command
+FAIL: gdb.objc/basicclass.exp: continue until category method (the program is no longer running)
+FAIL: gdb.objc/basicclass.exp: Call an Objective-C method with no arguments
+FAIL: gdb.objc/basicclass.exp: Call an Objective-C method with one argument
+FAIL: gdb.objc/basicclass.exp: Use of the print-object command
+FAIL: gdb.objc/basicclass.exp: Use of the po (print-object) command
2851c5f32ef2fafa14f453c605d9d7d1b1b0ebc6 is the first bad commit
commit 2851c5f32ef2fafa14f453c605d9d7d1b1b0ebc6
Author: Tom Tromey <tromey@redhat.com>
Date: Wed Aug 7 20:03:51 2013 +0000
use language of the main symbol
[...]
Built and regtested (both ways) on x86-64 Fedora 18.
* symfile.c (set_initial_language): Look up "main" symbol
and use its language.
* symtab.c (find_main_filename): Remove.
* symtab.h (find_main_filename): Remove.
* gdb.base/maint.exp: Allow zero symtabs to be expanded.
I have not checked more why it fails.
Jan
On Wed, 07 Aug 2013 21:44:53 +0200, Tom Tromey wrote:
> With "dwz -m", "main" appears in both the PU and the importing CU when
> running anon-struct.exp. However, the PU does not have a file name.
> So, find_main_filename returns the empty string, making
> deduce_language_from_filename return language_unknown.
>
> This patch fixes this problem by changing gdb to use the ordinary
> symbol-lookup functions to find "main"'s symbol. Then, it examines the
> symbol's language.
>
> I think this is cleaner than the current approach. For one thing it
> avoids trying to guess the language based on the source file name,
> instead deferring to the presumably more reliable debuginfo.
>
> Another possible fix would have been to change how the file name is
> found via the "qf" methods. However, I think the approach given is
> preferable for the reason outlined above.
>
> This required a minor test suite change, as now a symtab is expanded
> during the search for "main".
>
> Built and regtested (both ways) on x86-64 Fedora 18.
>
> * symfile.c (set_initial_language): Look up "main" symbol
> and use its language.
> * symtab.c (find_main_filename): Remove.
> * symtab.h (find_main_filename): Remove.
>
> * gdb.base/maint.exp: Allow zero symtabs to be expanded.
> ---
> gdb/symfile.c | 8 ++++----
> gdb/symtab.c | 23 -----------------------
> gdb/symtab.h | 2 --
> gdb/testsuite/gdb.base/maint.exp | 7 ++++---
> 4 files changed, 8 insertions(+), 32 deletions(-)
>
> diff --git a/gdb/symfile.c b/gdb/symfile.c
> index 3328648..3dd5509 100644
> --- a/gdb/symfile.c
> +++ b/gdb/symfile.c
> @@ -1612,11 +1612,11 @@ set_initial_language (void)
> lang = language_of_main;
> else
> {
> - const char *filename;
> + char *name = main_name ();
> + struct symbol *sym = lookup_symbol (name, NULL, VAR_DOMAIN, NULL);
>
> - filename = find_main_filename ();
> - if (filename != NULL)
> - lang = deduce_language_from_filename (filename);
> + if (sym != NULL)
> + lang = SYMBOL_LANGUAGE (sym);
> }
>
> if (lang == language_unknown)
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index 8076fe5..3bcec23 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -1949,29 +1949,6 @@ basic_lookup_transparent_type (const char *name)
> return (struct type *) 0;
> }
>
> -/* Find the name of the file containing main(). */
> -/* FIXME: What about languages without main() or specially linked
> - executables that have no main() ? */
> -
> -const char *
> -find_main_filename (void)
> -{
> - struct objfile *objfile;
> - char *name = main_name ();
> -
> - ALL_OBJFILES (objfile)
> - {
> - const char *result;
> -
> - if (!objfile->sf)
> - continue;
> - result = objfile->sf->qf->find_symbol_file (objfile, name);
> - if (result)
> - return result;
> - }
> - return (NULL);
> -}
> -
> /* Search BLOCK for symbol NAME in DOMAIN.
>
> Note that if NAME is the demangled form of a C++ symbol, we will fail
> diff --git a/gdb/symtab.h b/gdb/symtab.h
> index 6d81507..ccf4a4f 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -1252,8 +1252,6 @@ extern VEC (char_ptr) *make_source_files_completion_list (const char *,
>
> int matching_obj_sections (struct obj_section *, struct obj_section *);
>
> -extern const char *find_main_filename (void);
> -
> extern struct symtab *find_line_symtab (struct symtab *, int, int *, int *);
>
> extern struct symtab_and_line find_function_start_sal (struct symbol *sym,
> diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
> index 7057ac7..3093aae 100644
> --- a/gdb/testsuite/gdb.base/maint.exp
> +++ b/gdb/testsuite/gdb.base/maint.exp
> @@ -72,9 +72,10 @@ gdb_test "maint print registers" "Name.*Nr.*Rel.*Offset.*Size.*Type.*"
> gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
> gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
> "mt expand-symtabs" {
> - -re "#primary symtabs: (1|2) \\(\[+\](1|2)\\),.*$gdb_prompt $" {
> - # This should expand one or at most two primary symtabs.
> - # "Normally" it will expand just the one for break.c, but if the
> + -re "#primary symtabs: (1|2) \\(\[+\](0|1|2)\\),.*$gdb_prompt $" {
> + # This should expand at most two primary symtabs.
> + # "Normally" it will not expand any, because the symtab
> + # holding "main" will already have been expanded, but if the
> # file is compiled with -fdebug-types-section then a second primary
> # symtab for break.c will be created for any types.
> pass "mt expand-symtabs"
> --
> 1.8.1.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 5/5] fix PR symtab/15028
2013-08-07 19:45 [PATCH v2 0/5] fix some "dwz -m" regressions Tom Tromey
2013-08-07 19:45 ` [PATCH v2 3/5] use language of the main symbol Tom Tromey
@ 2013-08-07 19:45 ` Tom Tromey
2013-08-07 19:45 ` [PATCH v2 1/5] also filter label symbols Tom Tromey
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2013-08-07 19:45 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This fixes some derivation.exp regressions with "dwz -m".
The bug here is that the imported PU is given language_minimal.
However, it ought to be C++.
The "pretend language" machinery exists to solve this problem, but it
wasn't handled in process_psymtab_comp_unit. So, this patch adds it
there.
Built and regtested, both normally and using "dwz -m", on x86-64
Fedora 18.
PR symtab/15028:
* dwarf2read.c (struct process_psymtab_comp_unit_data): New.
(process_psymtab_comp_unit_reader): Use it.
(process_psymtab_comp_unit): Update. Add "pretend_language"
argument.
(dwarf2_build_psymtabs_hard): Update.
(scan_partial_symbols): Pass CU's language to
process_psymtab_comp_unit.
---
gdb/dwarf2read.c | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 13cd12f..9e19e78 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -5623,6 +5623,21 @@ create_partial_symtab (struct dwarf2_per_cu_data *per_cu, const char *name)
return pst;
}
+/* The DATA object passed to process_psymtab_comp_unit_reader has this
+ type. */
+
+struct process_psymtab_comp_unit_data
+{
+ /* True if we are reading a DW_TAG_partial_unit. */
+
+ int want_partial_unit;
+
+ /* The "pretend" language that is used if the CU doesn't declare a
+ language. */
+
+ enum language pretend_language;
+};
+
/* die_reader_func for process_psymtab_comp_unit. */
static void
@@ -5641,16 +5656,14 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
struct partial_symtab *pst;
int has_pc_info;
const char *filename;
- int *want_partial_unit_ptr = data;
+ struct process_psymtab_comp_unit_data *info = data;
- if (comp_unit_die->tag == DW_TAG_partial_unit
- && (want_partial_unit_ptr == NULL
- || !*want_partial_unit_ptr))
+ if (comp_unit_die->tag == DW_TAG_partial_unit && !info->want_partial_unit)
return;
gdb_assert (! per_cu->is_debug_types);
- prepare_one_comp_unit (cu, comp_unit_die, language_minimal);
+ prepare_one_comp_unit (cu, comp_unit_die, info->pretend_language);
cu->list_in_scope = &file_symbols;
@@ -5765,8 +5778,11 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
static void
process_psymtab_comp_unit (struct dwarf2_per_cu_data *this_cu,
- int want_partial_unit)
+ int want_partial_unit,
+ enum language pretend_language)
{
+ struct process_psymtab_comp_unit_data info;
+
/* If this compilation unit was already read in, free the
cached copy in order to read it in again. This is
necessary because we skipped some symbols when we first
@@ -5776,9 +5792,11 @@ process_psymtab_comp_unit (struct dwarf2_per_cu_data *this_cu,
free_one_cached_comp_unit (this_cu);
gdb_assert (! this_cu->is_debug_types);
+ info.want_partial_unit = want_partial_unit;
+ info.pretend_language = pretend_language;
init_cutu_and_read_dies (this_cu, NULL, 0, 0,
process_psymtab_comp_unit_reader,
- &want_partial_unit);
+ &info);
/* Age out any secondary CUs. */
age_cached_comp_units ();
@@ -5956,7 +5974,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile)
{
struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
- process_psymtab_comp_unit (per_cu, 0);
+ process_psymtab_comp_unit (per_cu, 0, language_minimal);
}
set_partial_user (objfile);
@@ -6178,7 +6196,7 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc,
/* Go read the partial unit, if needed. */
if (per_cu->v.psymtab == NULL)
- process_psymtab_comp_unit (per_cu, 1);
+ process_psymtab_comp_unit (per_cu, 1, cu->language);
VEC_safe_push (dwarf2_per_cu_ptr,
cu->per_cu->imported_symtabs, per_cu);
--
1.8.1.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/5] also filter label symbols
2013-08-07 19:45 [PATCH v2 0/5] fix some "dwz -m" regressions Tom Tromey
2013-08-07 19:45 ` [PATCH v2 3/5] use language of the main symbol Tom Tromey
2013-08-07 19:45 ` [PATCH v2 5/5] fix PR symtab/15028 Tom Tromey
@ 2013-08-07 19:45 ` Tom Tromey
2013-08-07 19:45 ` [PATCH v2 4/5] remove unused qf method Tom Tromey
2013-08-07 19:45 ` [PATCH v2 2/5] fix recursively_compute_inclusions and add dwz test case Tom Tromey
4 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2013-08-07 19:45 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
The bug here is that, with dwz -m, a function (and a label) appear in
both a PU and a CU when running cplabel.exp. So, a breakpoint gets
two locations:
(gdb) break foo::bar:to_the_top
Breakpoint 2 at 0x400503: foo::bar:to_the_top. (2 locations)
What is especially wacky is that both locations are at the same place:
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x000000000040051c foo::bar:get_out_of_here
1.2 y 0x000000000040051c foo::bar:get_out_of_here
This happens due to the weird way we run "dwz -m".
It's unclear to me that this would ever happen for real code.
While I think this borders on "diminishing returns" territory, the fix
is pretty straightforward: use the existing address-filtering function
in linespec to also filter when looking at labels.
Built and regtested (both ways) on x86-64 Fedora 18.
* linespec.c (convert_linespec_to_sals): Use maybe_add_address
when adding label symbols.
---
gdb/ChangeLog | 5 +++++
gdb/linespec.c | 5 ++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 975d2c5..3e50dff 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2013-02-04 Tom Tromey <tromey@redhat.com>
+
+ * linespec.c (convert_linespec_to_sals): Use maybe_add_address
+ when adding label symbols.
+
2013-08-05 Tom Tromey <tromey@redhat.com>
* aix-thread.c (_initialize_aix_thread): Use
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 2f2a1a3..019a9f8 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1996,7 +1996,10 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls)
for (i = 0; VEC_iterate (symbolp, ls->labels.label_symbols, i, sym); ++i)
{
- if (symbol_to_sal (&sal, state->funfirstline, sym))
+ struct program_space *pspace = SYMTAB_PSPACE (SYMBOL_SYMTAB (sym));
+
+ if (symbol_to_sal (&sal, state->funfirstline, sym)
+ && maybe_add_address (state->addr_set, pspace, sal.pc))
add_sal_to_sals (state, &sals, &sal,
SYMBOL_NATURAL_NAME (sym), 0);
}
--
1.8.1.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 4/5] remove unused qf method
2013-08-07 19:45 [PATCH v2 0/5] fix some "dwz -m" regressions Tom Tromey
` (2 preceding siblings ...)
2013-08-07 19:45 ` [PATCH v2 1/5] also filter label symbols Tom Tromey
@ 2013-08-07 19:45 ` Tom Tromey
2013-08-07 19:45 ` [PATCH v2 2/5] fix recursively_compute_inclusions and add dwz test case Tom Tromey
4 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2013-08-07 19:45 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
After the previous patch in the series, nothing uses the "quick"
method find_symbol_file.
This patch removes it.
Tested by rebuilding.
* dwarf2read.c (dw2_get_primary_filename_reader): Remove.
(dwarf2_gdb_index_functions): Update.
* psymtab.c (find_symbol_file_from_partial): Remove.
(psym_functions): Update.
* symfile.h (struct quick_symbol_functions) <find_symbol_file>:
Remove.
---
gdb/dwarf2read.c | 78 --------------------------------------------------------
gdb/psymtab.c | 14 ----------
gdb/symfile.h | 5 ----
3 files changed, 97 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index ff901e9..13cd12f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3445,83 +3445,6 @@ dw2_expand_symtabs_with_fullname (struct objfile *objfile,
}
}
-/* A helper function for dw2_find_symbol_file that finds the primary
- file name for a given CU. This is a die_reader_func. */
-
-static void
-dw2_get_primary_filename_reader (const struct die_reader_specs *reader,
- const gdb_byte *info_ptr,
- struct die_info *comp_unit_die,
- int has_children,
- void *data)
-{
- const char **result_ptr = data;
- struct dwarf2_cu *cu = reader->cu;
- struct attribute *attr;
-
- attr = dwarf2_attr (comp_unit_die, DW_AT_name, cu);
- if (attr == NULL)
- *result_ptr = NULL;
- else
- *result_ptr = DW_STRING (attr);
-}
-
-static const char *
-dw2_find_symbol_file (struct objfile *objfile, const char *name)
-{
- struct dwarf2_per_cu_data *per_cu;
- offset_type *vec;
- const char *filename;
-
- dw2_setup (objfile);
-
- /* index_table is NULL if OBJF_READNOW. */
- if (!dwarf2_per_objfile->index_table)
- {
- struct symtab *s;
-
- ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
- {
- 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)
- {
- /* Only file extension of returned filename is recognized. */
- return SYMBOL_SYMTAB (sym)->filename;
- }
- }
- return NULL;
- }
-
- if (!find_slot_in_mapped_hash (dwarf2_per_objfile->index_table,
- name, &vec))
- return NULL;
-
- /* Note that this just looks at the very first one named NAME -- but
- actually we are looking for a function. find_main_filename
- should be rewritten so that it doesn't require a custom hook. It
- could just use the ordinary symbol tables. */
- /* vec[0] is the length, which must always be >0. */
- per_cu = dw2_get_cu (GDB_INDEX_CU_VALUE (MAYBE_SWAP (vec[1])));
-
- if (per_cu->v.quick->symtab != NULL)
- {
- /* Only file extension of returned filename is recognized. */
- return per_cu->v.quick->symtab->filename;
- }
-
- /* Initialize filename in case there's a problem reading the DWARF,
- dw2_get_primary_filename_reader may not get called. */
- filename = NULL;
- init_cutu_and_read_dies (per_cu, NULL, 0, 0,
- dw2_get_primary_filename_reader, &filename);
-
- /* Only file extension of returned filename is recognized. */
- return filename;
-}
-
static void
dw2_map_matching_symbols (const char * name, domain_enum namespace,
struct objfile *objfile, int global,
@@ -3845,7 +3768,6 @@ const struct quick_symbol_functions dwarf2_gdb_index_functions =
dw2_expand_symtabs_for_function,
dw2_expand_all_symtabs,
dw2_expand_symtabs_with_fullname,
- dw2_find_symbol_file,
dw2_map_matching_symbols,
dw2_expand_symtabs_matching,
dw2_find_pc_sect_symtab,
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 10bd844..3bab747 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1206,19 +1206,6 @@ psymtab_to_fullname (struct partial_symtab *ps)
return ps->fullname;
}
-static const char *
-find_symbol_file_from_partial (struct objfile *objfile, const char *name)
-{
- struct partial_symtab *pst;
-
- ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
- {
- if (lookup_partial_symbol (objfile, pst, name, 1, VAR_DOMAIN))
- return pst->filename;
- }
- return NULL;
-}
-
/* For all symbols, s, in BLOCK that are in NAMESPACE and match NAME
according to the function MATCH, call CALLBACK(BLOCK, s, DATA).
BLOCK is assumed to come from OBJFILE. Returns 1 iff CALLBACK
@@ -1442,7 +1429,6 @@ const struct quick_symbol_functions psym_functions =
read_symtabs_for_function,
expand_partial_symbol_tables,
read_psymtabs_with_fullname,
- find_symbol_file_from_partial,
map_matching_symbols_psymtab,
expand_symtabs_matching_via_partial,
find_pc_sect_symtab_from_partial,
diff --git a/gdb/symfile.h b/gdb/symfile.h
index c36e6b3..4371cf4 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -220,11 +220,6 @@ struct quick_symbol_functions
void (*expand_symtabs_with_fullname) (struct objfile *objfile,
const char *fullname);
- /* Return the file name of the file holding the global symbol in OBJFILE
- named NAME. If no such symbol exists in OBJFILE, return NULL.
- Only file extension of returned filename is recognized. */
- const char *(*find_symbol_file) (struct objfile *objfile, const char *name);
-
/* Find global or static symbols in all tables that are in NAMESPACE
and for which MATCH (symbol name, NAME) == 0, passing each to
CALLBACK, reading in partial symbol tables as needed. Look
--
1.8.1.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/5] fix recursively_compute_inclusions and add dwz test case
2013-08-07 19:45 [PATCH v2 0/5] fix some "dwz -m" regressions Tom Tromey
` (3 preceding siblings ...)
2013-08-07 19:45 ` [PATCH v2 4/5] remove unused qf method Tom Tromey
@ 2013-08-07 19:45 ` Tom Tromey
2013-08-08 14:40 ` dwz.exp testsuite error on 32-bit targets [Re: [PATCH v2 2/5] fix recursively_compute_inclusions and add dwz test case] Jan Kratochvil
4 siblings, 1 reply; 9+ messages in thread
From: Tom Tromey @ 2013-08-07 19:45 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
Doug pointed out a while ago that in the final dwz -m patch, nothing
ever set symtab::user.
This patch fixes this oversight and adds a test case showing why it is
important.
Built and regtested (both ways) on x86-64 Fedora 18.
The new test unconditionally tests the partial unit machinery, which I
think is an added plus.
* dwarf2read.c (recursively_compute_inclusions): Add
"immediate_parent" argument. Set symtab's "user" field
if not set.
(compute_symtab_includes): Update.
* gdb.dwarf2/dwz.exp: New file.
---
gdb/dwarf2read.c | 16 ++++--
gdb/testsuite/gdb.dwarf2/dwz.exp | 106 +++++++++++++++++++++++++++++++++++++++
2 files changed, 118 insertions(+), 4 deletions(-)
create mode 100644 gdb/testsuite/gdb.dwarf2/dwz.exp
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index cb77386..ff901e9 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7374,7 +7374,8 @@ get_symtab (struct dwarf2_per_cu_data *per_cu)
static void
recursively_compute_inclusions (VEC (symtab_ptr) **result,
htab_t all_children, htab_t all_type_symtabs,
- struct dwarf2_per_cu_data *per_cu)
+ struct dwarf2_per_cu_data *per_cu,
+ struct symtab *immediate_parent)
{
void **slot;
int ix;
@@ -7402,10 +7403,16 @@ recursively_compute_inclusions (VEC (symtab_ptr) **result,
{
*slot = symtab;
VEC_safe_push (symtab_ptr, *result, symtab);
+ if (symtab->user == NULL)
+ symtab->user = immediate_parent;
}
}
else
- VEC_safe_push (symtab_ptr, *result, symtab);
+ {
+ VEC_safe_push (symtab_ptr, *result, symtab);
+ if (symtab->user == NULL)
+ symtab->user = immediate_parent;
+ }
}
for (ix = 0;
@@ -7413,7 +7420,7 @@ recursively_compute_inclusions (VEC (symtab_ptr) **result,
++ix)
{
recursively_compute_inclusions (result, all_children,
- all_type_symtabs, iter);
+ all_type_symtabs, iter, symtab);
}
}
@@ -7449,7 +7456,8 @@ compute_symtab_includes (struct dwarf2_per_cu_data *per_cu)
++ix)
{
recursively_compute_inclusions (&result_symtabs, all_children,
- all_type_symtabs, per_cu_iter);
+ all_type_symtabs, per_cu_iter,
+ symtab);
}
/* Now we have a transitive closure of all the included symtabs. */
diff --git a/gdb/testsuite/gdb.dwarf2/dwz.exp b/gdb/testsuite/gdb.dwarf2/dwz.exp
new file mode 100644
index 0000000..895444b
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dwz.exp
@@ -0,0 +1,106 @@
+# Copyright 2013 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/>.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if {![dwarf2_support]} {
+ return 0
+}
+
+standard_testfile main.c dwz.S
+
+# Create the DWARF.
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+ declare_labels partial_label double_label int_label int_label2
+
+ extern main
+
+ cu {} {
+ partial_label: partial_unit {} {
+ subprogram {
+ {name main}
+ {low_pc main addr}
+ {high_pc "main + 10" addr}
+ }
+ }
+ }
+
+ cu {} {
+ compile_unit {{language @DW_LANG_C}} {
+ int_label2: base_type {
+ {name int}
+ {byte_size 4 sdata}
+ {encoding @DW_ATE_signed}
+ }
+
+ constant {
+ {name the_int}
+ {type :$int_label2}
+ {const_value 99 data1}
+ }
+
+ constant {
+ {name other_int}
+ {type :$int_label2}
+ {const_value 99 data1}
+ }
+ }
+ }
+
+ cu {} {
+ compile_unit {{language @DW_LANG_C}} {
+ imported_unit {
+ {import $partial_label ref_addr}
+ }
+
+ int_label: base_type {
+ {name int}
+ {byte_size 4 sdata}
+ {encoding @DW_ATE_signed}
+ }
+
+ constant {
+ {name the_int}
+ {type :$int_label}
+ {const_value 23 data1}
+ }
+ }
+ }
+}
+
+if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
+ object {nodebug}] != "" } {
+ return -1
+}
+
+if { [gdb_compile $asm_file ${binfile}2.o object {nodebug}] != "" } {
+ return -1
+}
+
+if { [gdb_compile [list ${binfile}1.o ${binfile}2.o] \
+ "${binfile}" executable {}] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+if ![runto_main] {
+ return -1
+}
+
+gdb_test "p other_int" " = 99"
+gdb_test "p the_int" " = 23"
--
1.8.1.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* dwz.exp testsuite error on 32-bit targets [Re: [PATCH v2 2/5] fix recursively_compute_inclusions and add dwz test case]
2013-08-07 19:45 ` [PATCH v2 2/5] fix recursively_compute_inclusions and add dwz test case Tom Tromey
@ 2013-08-08 14:40 ` Jan Kratochvil
2013-08-21 15:34 ` Tom Tromey
0 siblings, 1 reply; 9+ messages in thread
From: Jan Kratochvil @ 2013-08-08 14:40 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Wed, 07 Aug 2013 21:44:52 +0200, Tom Tromey wrote:
> * gdb.dwarf2/dwz.exp: New file.
With 32-bit targets
+Running gdb/testsuite/gdb.dwarf2/dwz.exp ...
+gdb compile failed, /gdb/testsuite.unix.-m32/gdb.dwarf2/dwz.S: Assembler messages:
+/gdb/testsuite.unix.-m32/gdb.dwarf2/dwz.S:13: Error: cannot represent relocation type BFD_RELOC_64
+/gdb/testsuite.unix.-m32/gdb.dwarf2/dwz.S:14: Error: cannot represent relocation type BFD_RELOC_64
on lines:
.8byte main
.8byte main + 10
so either testcase should be skipped on 32-bit targets or rather I guess it
needs a fix in Dwarf::assemble.
Jan
^ permalink raw reply [flat|nested] 9+ messages in thread