From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org, Simon Marchi <simon.marchi@polymtl.ca>
Subject: Re: [PATCH][gdb/symtab] Handle .gdb_index in ada language mode
Date: Wed, 20 May 2020 11:40:21 +0200 [thread overview]
Message-ID: <89719b8a-9252-7af5-3ad8-1bcd1ebbc80c@suse.de> (raw)
In-Reply-To: <87tv0b64yd.fsf@tromey.com>
[-- Attachment #1: Type: text/plain, Size: 1532 bytes --]
On 19-05-2020 22:32, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> Fix the inconsistency by completing implementation of
> Tom> dw2_map_matching_symbols.
>
> Thanks for doing this.
>
> Tom> Tested on x86_64-linux, both with native and target board
> Tom> cc-with-debug-index.
>
> Tom> Any comments?
>
> This may be the only barrier to supporting Ada in .gdb_index.
> So, it seems like the Ada check in dwarf2/index-write.c should probably
> be removed as well...?
>
> I'm not 100% sure whether it will work or not.
Using this patch, I managed to get it working.
The patch does the following:
- enable ada .gdb_index by removing the ada check in write_psymbols
- copy some ada-specific code from debug_names::insert to
write_psymbols
- disable a workaround for gold/15646 in dw2_expand_marked_cus
As for the disabled workaround, I ran into trouble in
gdb.ada/access_tagged_param.exp, where setting a breakpoint on foo failed.
The index shows that there are two entries for foo, one variable, one
function:
...
[3733] foo:
3 [global, variable]
5 [global, function]
...
The workaround skips the function, so disabling the workaround allows
the test to pass (my guess atm is that the workaround is not precise
enough).
FWIW, if I use .debug_names instead, I see the same pattern:
...
[445] #0b887389 foo:
<6> DW_TAG_subprogram DW_IDX_compile_unit=5 DW_IDX_GNU_external=1
<2> DW_TAG_variable DW_IDX_compile_unit=3 DW_IDX_GNU_external=1
...
Thanks,
- Tom
[-- Attachment #2: 0002-try.patch --]
[-- Type: text/x-patch, Size: 3472 bytes --]
try
---
gdb/dwarf2/index-write.c | 34 ++++++++++++++++++++++++++++++----
gdb/dwarf2/read.c | 12 ------------
2 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index eabfe5d682..3e83e3ae2c 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -543,18 +543,44 @@ write_psymbols (struct mapped_symtab *symtab,
for (; count-- > 0; ++psymp)
{
struct partial_symbol *psym = *psymp;
+ const char *name = psym->ginfo.search_name ();
if (psym->ginfo.language () == language_ada)
- error (_("Ada is not currently supported by the index; "
- "use the DWARF 5 index instead"));
+ {
+ /* We want to ensure that the Ada main function's name appears
+ verbatim in the index. However, this name will be of the
+ form "_ada_mumble", and will be rewritten by ada_decode.
+ So, recognize it specially here and add it to the index by
+ hand. */
+ if (strcmp (main_name (), name) == 0)
+ {
+ gdb_index_symbol_kind kind = symbol_kind (psym);
+
+ add_index_entry (symtab, name, is_static, kind, cu_index);
+ }
+
+ /* In order for the index to work when read back into gdb, it
+ has to supply a funny form of the name: it should be the
+ encoded name, with any suffixes stripped. Using the
+ ordinary encoded name will not work properly with the
+ searching logic in find_name_components_bounds; nor will
+ using the decoded name. Furthermore, an Ada "verbatim"
+ name (of the form "<MumBle>") must be entered without the
+ angle brackets. Note that the current index is unusual,
+ see PR symtab/24820 for details. */
+ std::string decoded = ada_decode (name);
+ if (decoded[0] == '<')
+ name = (char *) strndup (decoded.c_str () + 1, decoded.length () - 2);
+ else
+ name = strdup (ada_encode (decoded.c_str ()));
+ }
/* Only add a given psymbol once. */
if (psyms_seen.insert (psym).second)
{
gdb_index_symbol_kind kind = symbol_kind (psym);
- add_index_entry (symtab, psym->ginfo.search_name (),
- is_static, kind, cu_index);
+ add_index_entry (symtab, name, is_static, kind, cu_index);
}
}
}
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index ded71f53b5..d25e8ecb8c 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -4514,7 +4514,6 @@ dw2_expand_marked_cus
search_domain kind)
{
offset_type *vec, vec_len, vec_idx;
- bool global_seen = false;
mapped_index &index = *dwarf2_per_objfile->index_table;
vec = (offset_type *) (index.constant_pool
@@ -4523,8 +4522,6 @@ dw2_expand_marked_cus
for (vec_idx = 0; vec_idx < vec_len; ++vec_idx)
{
offset_type cu_index_and_attrs = MAYBE_SWAP (vec[vec_idx + 1]);
- /* This value is only valid for index versions >= 7. */
- int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
gdb_index_symbol_kind symbol_kind =
GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs);
int cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs);
@@ -4536,15 +4533,6 @@ dw2_expand_marked_cus
(index.version >= 7
&& symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
- /* Work around gold/15646. */
- if (attrs_valid)
- {
- if (!is_static && global_seen)
- continue;
- if (!is_static)
- global_seen = true;
- }
-
/* Only check the symbol's kind if it has one. */
if (attrs_valid)
{
next prev parent reply other threads:[~2020-05-20 9:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-13 9:41 Tom de Vries
2020-05-19 20:32 ` Tom Tromey
2020-05-20 9:40 ` Tom de Vries [this message]
2020-05-22 20:31 ` Tom Tromey
2020-05-26 13:01 ` [PATCH][gdb/symtab] Make gold index workaround more precise Tom de Vries
2020-05-26 14:03 ` Tom de Vries
2020-05-27 15:22 ` Tom Tromey
2020-05-28 13:02 ` Tom de Vries
2020-05-27 15:21 ` Tom Tromey
2020-06-02 10:47 ` [PATCH][gdb/symtab] Handle .gdb_index in ada language mode Tom de Vries
2020-06-10 12:49 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=89719b8a-9252-7af5-3ad8-1bcd1ebbc80c@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox