This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gdb / thread_db / multiple ABI question


On Mon, 2017-07-10 at 19:21 +0100, Pedro Alves wrote:
> On 07/10/2017 07:02 PM, Steve Ellcey wrote:
> > 
> > No, without thread_db I get this:
> > 
> > (gdb) file m32
> > Reading symbols from m32...done.
> > (gdb) core c_32
> > [New LWP 79425]
> > [New LWP 79425]
> > [New LWP 79425]
> This means that GDB/bfd thinks that there are 3 threads
> in the core, but they all have the same TID, which is of course
> bogus.  So this still looks to me like something is wrong on
> the bfd side.  Try "objdump -h c_32".  You should see
> one ".reg/NNN" section per thread, like e.g.:


FYI: I think I found the cause of this problem.  In bfd/elfxx-
aarch64.c:_bfd_aarch64_elf_grok_prstatus there is code to
differentiate LP64 and ILP32 based on the different sizes of
elf_prstatus (note->descsz).  But after that differentiation I was
using 12 as the offset of pr_cursig in elf_prstatus and 32 for the
offset of pr_reg in both the ILP32 and LP64 cases.  I think the offset
of 12 for pr_cursig is OK because there are 3 int fields in front of
it and those are 4 bytes in both modes.  But the offset of pr_reg
should be 32 for LP64 and 24 for ILP32 because there are two long
variables between pr_cursig and pr_pid so the offset to pr_pid will
differ based on the ABI.  After this change:

(gdb) file m32
Reading symbols from m32...done.
(gdb) core c_32
[New LWP 15129]
[New LWP 15130]
[New LWP 15128]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/home/sellcey/gdb-ilp32/install/lib64/libthread_db.so.1".
Core was generated by `./m32'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00400680 in doSomeThing ()
[Current thread is 1 (Thread 0xf725f490 (LWP 15129))]
(gdb) info threads
  Id   Target Id         Frame 
* 1    Thread 0xf725f490 (LWP 15129) 0x00400680 in doSomeThing ()
  2    Thread 0xf6a5f490 (LWP 15130) 0xf72fa2d0 in __GI___nanosleep (
    requested_time=requested_time@entry=0xf6a5eeb8, 
    remaining=remaining@entry=0xf6a5eeb8)
    at ../sysdeps/unix/sysv/linux/nanosleep.c:27
  3    Thread 0xf743ef70 (LWP 15128) 0xf72fa2d0 in __GI___nanosleep (
    requested_time=requested_time@entry=0xffa1b1c8, 
    remaining=remaining@entry=0xffa1b1c8)
    at ../sysdeps/unix/sysv/linux/nanosleep.c:27


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]