Discussion:
[Bug gdb/23283] New: Inconsistent multi-versioning behaviour
mwelinder at gmail dot com
2018-06-13 15:47:13 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23283

Bug ID: 23283
Summary: Inconsistent multi-versioning behaviour
Product: gdb
Version: 8.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: mwelinder at gmail dot com
Target Milestone: ---

The support for multiversioning is weak and can cause misleading
output, missed breakpoints, etc.

Compile the following with g++ 8.1:

// ttt.C:
__attribute__((target("default"))) inline int foo() { return 0; }
__attribute__((target("sse2"))) inline int foo() { return 1; }
__attribute__((target("avx"))) inline int foo() { return 2; }
__attribute__((target("avx2"))) inline int foo() { return 3; }
__attribute__((target("avx512f"))) inline int foo() { return 4; }

int
main ()
{
return foo ();
}


gdb [...]/ttt
GNU gdb (GDB) 8.1
[...]
(gdb) disass 'foo() [TAB]
foo() foo() [clone .avx] foo() [clone .resolver]

### NOTE: shows default, avx, and resolver versions. No sign of sse2, avx2,
### avx512f versions.

(gdb) info functions
All defined functions:
[...]
File [...]/ttt.C:
int _Z3foov.avx2(void);
int _Z3foov.avx512f(void);
int _Z3foov.sse2(void);
int foo();
int foo() [clone .avx];
int main();
[...]

### NOTE: The functions are there, but gdb fails to see them as clones

(gdb) disass foo
Dump of assembler code for function foo() [clone .avx]:
0x08048b00 <+0>: mov $0x2,%eax
0x08048b05 <+5>: ret
End of assembler dump.

### NOTE: That is not the function that is actually in use. It should
either refuse the command or disassemble the right version.

(gdb) b foo
Breakpoint 1 at 0x400af0: foo. (3 locations)

### NOTE: 3 locations -- it missed sse2/avx2/avx512f
--
You are receiving this mail because:
You are on the CC list for the bug.
mwelinder at gmail dot com
2018-06-13 18:27:22 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23283

--- Comment #1 from M Welinder <mwelinder at gmail dot com> ---
This may be a demangler problem. It is unhappy with any clone whose
suffix has digits:

***@dicentra:~> echo _Z3foov.avx2 | c++filt
_Z3foov.avx2
***@dicentra:~> echo _Z3foov.avx | c++filt
foo() [clone .avx]
***@dicentra:~> echo _Z3foov.mooooo | c++filt
foo() [clone .mooooo]
***@dicentra:~> echo _Z3foov.mooooo2 | c++filt
_Z3foov.mooooo2
--
You are receiving this mail because:
You are on the CC list for the bug.
mwelinder at gmail dot com
2018-06-13 18:59:30 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23283

--- Comment #2 from M Welinder <mwelinder at gmail dot com> ---
This fixes the issue for me, but...

1. libiberty is imported. gdb's copy probably isn't the right one to patch.
2. Think about upper case letters.



--- /usr/local/src/gdb/gdb-8.1/libiberty/cp-demangle.c 2018-01-30
21:58:50.000000000 -0500
+++ /usr/local/src/gdb/gdb-8.1a/libiberty/cp-demangle.c 2018-06-13
14:39:31.285829000 -0400
@@ -3752,7 +3752,7 @@
if (*pend == '.' && (IS_LOWER (pend[1]) || pend[1] == '_'))
{
pend += 2;
- while (IS_LOWER (*pend) || *pend == '_')
+ while (IS_LOWER (*pend) || IS_DIGIT(*pend) || *pend == '_')
++pend;
}
while (*pend == '.' && IS_DIGIT (pend[1]))
--
You are receiving this mail because:
You are on the CC list for the bug.
palves at redhat dot com
2018-06-14 08:33:31 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23283

Pedro Alves <palves at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |palves at redhat dot com

--- Comment #3 from Pedro Alves <palves at redhat dot com> ---
(In reply to M Welinder from comment #2)
Post by mwelinder at gmail dot com
1. libiberty is imported. gdb's copy probably isn't the right one to patch.
Right, the master copy is in gcc. Can you report this there please?

Note that ideally, a patch will add a test to
libiberty/testsuite/demangle-expected too.
--
You are receiving this mail because:
You are on the CC list for the bug.
mwelinder at gmail dot com
2018-06-14 14:27:38 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23283

--- Comment #4 from M Welinder <mwelinder at gmail dot com> ---
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86152
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...