Skip to content

Commit 8d76ceb

Browse files
committed
[gdb/symtab] Remove superfluous handling of Ada main in write_cooked_index
I filed PR29179 about the following FAIL in test-case gdb.ada/O2_float_param.exp with target board cc-with-gdb-index: ... (gdb) break increment^M Function "increment" not defined.^M Make breakpoint pending on future shared library load? (y or [n]) n^M (gdb) FAIL: gdb.ada/O2_float_param.exp: scenario=all: gdb_breakpoint: \ set breakpoint at increment ... The FAIL was a regression since commit 2cf349b ("Do not put linkage names into .gdb_index"). Before that commit we had: ... $ readelf -w foo > READELF $ grep callee.*increment READELF [1568] callee__increment: 5 [global, function] [3115] callee.increment: 5 [global, function] ... but after only: ... $ grep callee.*increment READELF [3115] callee.increment: 5 [global, function] ... The regression was fixed by commit 67e83a0 ("Fix regression in c-linkage-name.exp with gdb index"), which got us again: ... $ grep callee.*increment READELF [1568] callee__increment: 5 [global, function] [3115] callee.increment: 5 [global, function] ... The commit however did not claim that particular PR. A subsequent commit, commit 5fea979 ("Improve Ada support in .gdb_index") did claim to fix it, together with commit dd05fc7 ("Change .gdb_index de-duplication implementation"). The commit 5fea979 contained the following addition in write_cooked_index: ... + if (entry->per_cu->lang () == language_ada) + { + /* 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 (entry->tag == DW_TAG_subprogram + && strcmp (main_for_ada, name) == 0) + { + /* Leave it alone. */ + } + else + { + /* In order for the index to work when read back into + gdb, it has to use the encoded name, with any + suffixes stripped. */ + std::string encoded = ada_encode (name, false); + name = obstack_strdup (&symtab->m_string_obstack, + encoded.c_str ()); + } + } ... The code contains some special handling related to the Ada main function, so let's look at that one: foo. Before commit 67e83a0 we have: ... $ grep foo.*function READELF [3733] foo: 7 [global, function] ... and after: ... $ grep foo.*function READELF [2738] _ada_foo: 7 [global, function] [3733] foo: 7 [global, function] ... so that looks identical to the callee.increment case. At commit 5fea979, we have slightly different index numbers: ... $ grep foo.*function READELF [1658] foo: 7 [global, function] [2738] _ada_foo: 7 [global, function] ... but otherwise the same result. If we disable the special handling of the Ada main function like so: ... - if (entry->tag == DW_TAG_subprogram + if (false && entry->tag == DW_TAG_subprogram ... we still have the exact same result because: ... (gdb) p main_for_ada $1 = 0x352e6a0 "_ada_foo" ... and ada_encode ("_ada_foo", false) == "_ada_foo". The comment seems to be copied from debug_names::insert, which does indeed use ada_decode, while the code in write_cooked_index uses ada_encode instead. Remove the superfluous special handling of Ada main in write_cooked_index. Tested on x86_64-linux, with target boards unix and cc-with-gdb-index. Approved-By: Tom Tromey <tom@tromey.com>
1 parent 5c9adb8 commit 8d76ceb

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

gdb/dwarf2/index-write.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,8 +1128,6 @@ write_cooked_index (cooked_index *table,
11281128
const cu_index_map &cu_index_htab,
11291129
struct mapped_symtab *symtab)
11301130
{
1131-
const char *main_for_ada = main_name ();
1132-
11331131
for (const cooked_index_entry *entry : table->all_entries ())
11341132
{
11351133
const auto it = cu_index_htab.find (entry->per_cu);
@@ -1139,25 +1137,12 @@ write_cooked_index (cooked_index *table,
11391137

11401138
if (entry->per_cu->lang () == language_ada)
11411139
{
1142-
/* We want to ensure that the Ada main function's name
1143-
appears verbatim in the index. However, this name will
1144-
be of the form "_ada_mumble", and will be rewritten by
1145-
ada_decode. So, recognize it specially here and add it
1146-
to the index by hand. */
1147-
if (entry->tag == DW_TAG_subprogram
1148-
&& strcmp (main_for_ada, name) == 0)
1149-
{
1150-
/* Leave it alone. */
1151-
}
1152-
else
1153-
{
1154-
/* In order for the index to work when read back into
1155-
gdb, it has to use the encoded name, with any
1156-
suffixes stripped. */
1157-
std::string encoded = ada_encode (name, false);
1158-
name = obstack_strdup (&symtab->m_string_obstack,
1159-
encoded.c_str ());
1160-
}
1140+
/* In order for the index to work when read back into
1141+
gdb, it has to use the encoded name, with any
1142+
suffixes stripped. */
1143+
std::string encoded = ada_encode (name, false);
1144+
name = obstack_strdup (&symtab->m_string_obstack,
1145+
encoded.c_str ());
11611146
}
11621147
else if (entry->per_cu->lang () == language_cplus
11631148
&& (entry->flags & IS_LINKAGE) != 0)

0 commit comments

Comments
 (0)