Bug #96272 Incomplete type in gdb when linking with lld --gdb-index
Submitted: 22 Jul 2019 14:29 Modified: 25 Jul 2019 13:42
Reporter: Knut Anders Hatlen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.18 OS:Any
Assigned to: CPU Architecture:Any

[22 Jul 2019 14:29] Knut Anders Hatlen
Description:
The ADD_GDB_INDEX option that was added in bug#95857 seems to cause problems when debugging in gdb. gdb sometimes reports "incomplete type" when printing expressions. Other times it can report "no member" when accessing members of a class. It can be worked around by manually opening the file that contains the definition of the type, but that is inconvenient.

It seems to work fine for gold --gdb-index, and also when adding the index manually with the gdb-add-index script that comes with gdb, but not when using lld --gdb-index. LLD is the only linker for which the cmake scripts add the --gdb-index argument by default.

How to repeat:
Build with debug enabled on a system where the LLD linker is used. Start mysqld in gdb and observe:

(gdb) b JOIN::optimize
Breakpoint 1 at 0x4ba4ca3: file /code/mysql/trunk/sql/sql_optimizer.cc, line 201.
(gdb) c
Continuing.
[Switching to Thread 0x7fffe46c4700 (LWP 10872)]

Thread 44 "mysqld" hit Breakpoint 1, JOIN::optimize (this=0x7fff3400b230) at /code/mysql/trunk/sql/sql_optimizer.cc:201
201	  DBUG_TRACE;
(gdb) p thd
$1 = (THD * const) 0x7fff34000f50
(gdb) p thd->lex
There is no member named lex.
(gdb) l sql_class.cc:1,1
1	/*
(gdb) p thd->lex
warning: RTTI symbol not found for class 'THD'
warning: RTTI symbol not found for class 'THD'
warning: RTTI symbol not found for class 'THD'
$2 = (LEX *) 0x7fff34003ee0

Suggested fix:
Make ADD_GDB_INDEX default to OFF, also when using LLD.
[25 Jul 2019 13:42] Paul DuBois
Posted by developer:
 
Fixed in 8.0.18.

Bug affects no released version. No changelog entry required.