* [Bug exp/30911] [gdb/exp] Cannot call ifunc strstr with debuginfo installed
2023-09-28 10:48 [Bug exp/30911] New: [gdb/exp] Cannot call ifunc strstr with debuginfo installed vries at gcc dot gnu.org
@ 2023-09-28 10:49 ` vries at gcc dot gnu.org
2023-09-28 10:50 ` sam at gentoo dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-28 10:49 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30911
--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Tentative fix: swap the order here:
...
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 0f9ad34bbb4..20d0f9acca5 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -316,17 +316,20 @@ find_function_addr (struct value *function,
FUNCTION_TYPE have been asked for. */
if (retval_type != NULL || function_type != NULL)
{
- type *target_ftype = find_function_type (funaddr);
- /* If we don't have debug info for the target function,
- see if we can instead extract the target function's
- type from the type that the resolver returns. */
- if (target_ftype == NULL)
- target_ftype = find_gnu_ifunc_target_type (resolver_addr);
+ /* Try to get the target function's type from the type that
+ the resolver returns. We do this first to work around
+ PR gas/29517. */
+ type *target_ftype = find_gnu_ifunc_target_type (resolver_addr);
if (target_ftype != NULL)
{
value_type = check_typedef (target_ftype)->target_type ();
ftype = target_ftype;
}
+
+ /* Try to get the target function's type from the target
+ function. */
+ if (target_ftype == NULL)
+ target_ftype = find_function_type (funaddr);
}
}
else
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug exp/30911] [gdb/exp] Cannot call ifunc strstr with debuginfo installed
2023-09-28 10:48 [Bug exp/30911] New: [gdb/exp] Cannot call ifunc strstr with debuginfo installed vries at gcc dot gnu.org
2023-09-28 10:49 ` [Bug exp/30911] " vries at gcc dot gnu.org
@ 2023-09-28 10:50 ` sam at gentoo dot org
2023-09-28 11:24 ` vries at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sam at gentoo dot org @ 2023-09-28 10:50 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30911
Sam James <sam at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sam at gentoo dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug exp/30911] [gdb/exp] Cannot call ifunc strstr with debuginfo installed
2023-09-28 10:48 [Bug exp/30911] New: [gdb/exp] Cannot call ifunc strstr with debuginfo installed vries at gcc dot gnu.org
2023-09-28 10:49 ` [Bug exp/30911] " vries at gcc dot gnu.org
2023-09-28 10:50 ` sam at gentoo dot org
@ 2023-09-28 11:24 ` vries at gcc dot gnu.org
2023-09-28 11:54 ` vries at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-28 11:24 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30911
--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #1)
> Tentative fix: swap the order here:
And we get:
...
FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=0: final_debug=1:
p gnu_ifunc (3)
FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=0: final_debug=1:
p gnu_ifunc()
FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=1:
p gnu_ifunc (3)
FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=1:
p gnu_ifunc()
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug exp/30911] [gdb/exp] Cannot call ifunc strstr with debuginfo installed
2023-09-28 10:48 [Bug exp/30911] New: [gdb/exp] Cannot call ifunc strstr with debuginfo installed vries at gcc dot gnu.org
` (2 preceding siblings ...)
2023-09-28 11:24 ` vries at gcc dot gnu.org
@ 2023-09-28 11:54 ` vries at gcc dot gnu.org
2023-09-28 13:09 ` [Bug symtab/30911] " vries at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-28 11:54 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30911
--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Alternatively, we detect the problem while reading the debug info and fix it:
...
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 5bbc8e24cf9..e547653d7fe 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -10161,7 +10161,20 @@ read_func_scope (struct die_info *die, struct
dwarf2_cu *cu)
gdb_assert (cu->get_builder () != nullptr);
newobj = cu->get_builder ()->push_context (0, lowpc);
- newobj->name = new_symbol (die, read_type_die (die, cu), cu, templ_func);
+ struct type *type = read_type_die (die, cu);
+ if (type->code () == TYPE_CODE_FUNC
+ && type->num_fields () == 0
+ && type->target_type ()->code () == TYPE_CODE_VOID
+ && !type->target_type ()->is_stub ()
+ && strcmp (cu->producer, "GNU AS 2.39.0") == 0)
+ {
+ /* Work around PR gas/29517. */
+ type = (type_allocator (cu->per_objfile->objfile, cu->lang ())
+ .new_type (TYPE_CODE_VOID, 0, nullptr));
+ type->set_is_stub (true);
+ set_die_type (die, type, cu);
+ }
+ newobj->name = new_symbol (die, type, cu, templ_func);
if (dwarf2_func_is_main_p (die, cu))
set_objfile_main_name (objfile, newobj->name->linkage_name (),
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/30911] [gdb/exp] Cannot call ifunc strstr with debuginfo installed
2023-09-28 10:48 [Bug exp/30911] New: [gdb/exp] Cannot call ifunc strstr with debuginfo installed vries at gcc dot gnu.org
` (3 preceding siblings ...)
2023-09-28 11:54 ` vries at gcc dot gnu.org
@ 2023-09-28 13:09 ` vries at gcc dot gnu.org
2023-09-28 16:08 ` vries at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-28 13:09 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30911
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|exp |symtab
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/30911] [gdb/exp] Cannot call ifunc strstr with debuginfo installed
2023-09-28 10:48 [Bug exp/30911] New: [gdb/exp] Cannot call ifunc strstr with debuginfo installed vries at gcc dot gnu.org
` (4 preceding siblings ...)
2023-09-28 13:09 ` [Bug symtab/30911] " vries at gcc dot gnu.org
@ 2023-09-28 16:08 ` vries at gcc dot gnu.org
2023-09-30 8:37 ` [Bug symtab/30911] [gdb/symtab] " vries at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-28 16:08 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30911
--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2023-September/202828.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/30911] [gdb/symtab] Cannot call ifunc strstr with debuginfo installed
2023-09-28 10:48 [Bug exp/30911] New: [gdb/exp] Cannot call ifunc strstr with debuginfo installed vries at gcc dot gnu.org
` (5 preceding siblings ...)
2023-09-28 16:08 ` vries at gcc dot gnu.org
@ 2023-09-30 8:37 ` vries at gcc dot gnu.org
2023-10-16 14:32 ` cvs-commit at gcc dot gnu.org
2023-10-16 14:33 ` vries at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-30 8:37 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30911
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[gdb/exp] Cannot call ifunc |[gdb/symtab] Cannot call
|strstr with debuginfo |ifunc strstr with debuginfo
|installed |installed
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/30911] [gdb/symtab] Cannot call ifunc strstr with debuginfo installed
2023-09-28 10:48 [Bug exp/30911] New: [gdb/exp] Cannot call ifunc strstr with debuginfo installed vries at gcc dot gnu.org
` (6 preceding siblings ...)
2023-09-30 8:37 ` [Bug symtab/30911] [gdb/symtab] " vries at gcc dot gnu.org
@ 2023-10-16 14:32 ` cvs-commit at gcc dot gnu.org
2023-10-16 14:33 ` vries at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-16 14:32 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30911
--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1d45d90934b10862c00a22bcf4075815a785001b
commit 1d45d90934b10862c00a22bcf4075815a785001b
Author: Tom de Vries <tdevries@suse.de>
Date: Mon Oct 16 16:32:28 2023 +0200
[gdb/symtab] Work around PR gas/29517
When using glibc debuginfo generated with gas 2.39, we run into PR
gas/29517:
...
$ gdb -q -batch a.out -ex start -ex "p (char *)strstr (\"haha\", \"ah\")"
Temporary breakpoint 1 at 0x40051b: file hello.c, line 6.
Temporary breakpoint 1, main () at hello.c:6
6 printf ("hello\n");
Invalid cast.
...
while without glibc debuginfo installed we get the expected result:
...
$n = 0x7ffff7daa1b1 "aha"
...
and likewise with glibc debuginfo generated with gas 2.40.
The strstr ifunc resolves to __strstr_sse2_unaligned. The problem is that
gas
generates dwarf that states that the return type is void:
...
<1><3e1e58>: Abbrev Number: 2 (DW_TAG_subprogram)
<3e1e59> DW_AT_name : __strstr_sse2_unaligned
<3e1e5d> DW_AT_external : 1
<3e1e5e> DW_AT_low_pc : 0xbbd2e
<3e1e66> DW_AT_high_pc : 0xbc1c3
...
while the return type should be a DW_TAG_unspecified_type, as is the case
with gas 2.40.
We can still use the workaround of casting to another function type for
both
__strstr_sse2_unaligned:
...
(gdb) p ((char * (*) (const char *, const char *))__strstr_sse2_unaligned)
\
("haha", "ah")
$n = 0x7ffff7daa211 "aha"
...
and strstr (which requires using *strstr to dereference the ifunc before we
cast):
...
gdb) p ((char * (*) (const char *, const char *))*strstr) ("haha", "ah")
$n = 0x7ffff7daa251 "aha"
...
but that's a bit cumbersome to use.
Work around this in the dwarf reader, such that we have instead:
...
(gdb) p (char *)strstr ("haha", "ah")
$n = 0x7ffff7daa1b1 "aha"
...
This also requires fixing producer_is_gcc to stop returning true for
producer "GNU AS 2.39.0".
Tested on x86_64-linux.
Approved-By: Andrew Burgess <aburgess@redhat.com>
PR symtab/30911
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30911
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/30911] [gdb/symtab] Cannot call ifunc strstr with debuginfo installed
2023-09-28 10:48 [Bug exp/30911] New: [gdb/exp] Cannot call ifunc strstr with debuginfo installed vries at gcc dot gnu.org
` (7 preceding siblings ...)
2023-10-16 14:32 ` cvs-commit at gcc dot gnu.org
@ 2023-10-16 14:33 ` vries at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-10-16 14:33 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30911
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |15.1
--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread