Re: gdb / thread_db / multiple ABI question

Steve Ellcey
2017-07-10T21:22:18Z

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