From: Djordje Todorovic <djordje.todorovic@rt-rk.com>
To: "Maciej W. Rozycki" <macro@mips.com>, Pedro Alves <palves@redhat.com>
Cc: binutils@sourceware.org, gdb-patches@sourceware.org,
"nemanja.popov@rt-rk.com" <nemanja.popov@rt-rk.com>,
petar.jovanovic@rt-rk.com,
"Ananthakrishna Sowda (asowda)" <asowda@cisco.com>,
Nikola Prica <nikola.prica@rt-rk.com>
Subject: Re: [PATCH 0/3] Fix issues with writing Linux core PRSTATUS note on MIPS o32, n32 and n64 into core file
Date: Thu, 26 Oct 2017 11:22:00 -0000 [thread overview]
Message-ID: <64ad38a4-b8ae-912e-45d6-7048135ada2e@rt-rk.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1710252126220.3886@tp.orcam.me.uk>
Hi Maciej,
> Thank you. There's still a small nit remaining WRT 1/3, but as I have
> noted in a separate reply I'll handle it myself when committing.
Thanks a lot! I really appreciate it!
>> Regarding patch 3/3, as Pedro said, currently “thread” function has a
>> piece of code that is never going to be executed since core file is
>> going to be generated as soon as the first thread reaches the thread
>> function. So, since we are testing fetching value of TLS variable from
>> core file, creating just a one thread in test case would be enough and
>> regarding that, I have cut unnecessary code from the function.
>
> Hmm, to understand how exactly the bug triggers (as you may recall long
> ago I observed GDB prefers LWPID over PID if available) I ran your test
> case with the code changes removed and the test has still passed across
> the three ABIs. So it does not actually cover the case concerned here.
> I still would like to keep it to verify the consistency between core files
> written and read (following the various issues discovered in the course of
> this review, including the n32 BFD fix I have cc-ed you on lately),
> however that brings the question again about how you originally observed
> the problem you've addressed. Is there another test scenario that can be
> created?
Thanks a lot, I saw that n32 BFD fix, and it is great!
Actually, I have faced it when I tried to read value of TLS variable on MIPS platforms (native). I agree with you that GDB prefers LWPID over PID if available, but with no PID from core file GDB, at least on my boards, can not read value of TLS variable. I have tried to do some observation on x86_64 native platform and commented piece of code for fetching PID from core file like this:
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 6a5159d..9ee9231 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -415,8 +415,8 @@ elf_x86_64_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
break;
case 136: /* sizeof(struct elf_prpsinfo) on Linux/x86_64 */
- elf_tdata (abfd)->core->pid
- = bfd_get_32 (abfd, note->descdata + 24);
+ //elf_tdata (abfd)->core->pid
+ // = bfd_get_32 (abfd, note->descdata + 24);
elf_tdata (abfd)->core->program
= _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
elf_tdata (abfd)->core->command
and rebuilt GDB (with "make clean" and "make"), the test case was FAIL:
(gdb) file /home/rtrk/gdb/build_native/gdb/testsuite/outputs/gdb.threads/tls-core/tls-core
Reading symbols from /home/rtrk/gdb/build_native/gdb/testsuite/outputs/gdb.threads/tls-core/tls-core...done.
(gdb) core /home/rtrk/gdb/build_native/gdb/testsuite/outputs/gdb.threads/tls-core/gcore.test
[New LWP 12556]
[New LWP 12552]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/home/rtrk/gdb/build_native/gdb/testsuite/outputs/gdb.threads/tls-core/tls-core'.
Program terminated with signal SIGTRAP, Trace/breakpoint trap.
#0 thread_proc (arg=0x0) at /home/rtrk/gdb/build_native/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.threads/tls-core.c:25
25 return arg;
[Current thread is 1 (LWP 12556)]
(gdb) PASS: gdb.threads/tls-core.exp: load generated corefile
p/x foo
Cannot find user-level thread for LWP 12556: generic error
When I reverted this observation changes and rebuilt it again, GDB was able to read value of TLS variable:
(gdb) file /home/rtrk/gdb/build_native/gdb/testsuite/outputs/gdb.threads/tls-core/tls-core
Reading symbols from /home/rtrk/gdb/build_native/gdb/testsuite/outputs/gdb.threads/tls-core/tls-core...done.
(gdb) core /home/rtrk/gdb/build_native/gdb/testsuite/outputs/gdb.threads/tls-core/gcore.test
[New LWP 11099]
[New LWP 11095]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/home/rtrk/gdb/build_native/gdb/testsuite/outputs/gdb.threads/tls-core/tls-core'.
Program terminated with signal SIGTRAP, Trace/breakpoint trap.
#0 thread_proc (arg=0x0) at /home/rtrk/gdb/build_native/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.threads/tls-core.c:25
25 return arg;
[Current thread is 1 (Thread 0x7ffff77ef700 (LWP 11099))]
(gdb) PASS: gdb.threads/tls-core.exp: load generated corefile
p/x foo
$1 = 0xdeadbeef
Exactly the same situation I have reproduced on MIPS platforms. Have I missed something?
Regarding fetching value of TLS variable with cross or Multiarch GDB, we actually had proposal for resolving that issue in GDB, where we proposed that GDB can have its own "libthread_db" functions for getting TLS in case of cross debugging, where it is going to "simulate" "target" architecture, but that code would be hard to maintain, because every changes in "libthread_db" functions regarding particular architecture in GLIBC would take also changes in GDB, so it was not accepted by community, reasonably (please briefly see that thread: http://sourceware-org.1504.n7.nabble.com/PATCH-TLS-access-support-in-cross-Linux-GDB-td452155.html). But yes, I also think in those cases, test should be marked as known failure.
Thanks,
Djordje
next prev parent reply other threads:[~2017-10-26 11:22 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-17 13:47 Djordje Todorovic
2017-10-17 13:55 ` Maciej W. Rozycki
2017-10-17 13:57 ` Djordje Todorovic
2017-10-25 14:15 ` Djordje Todorovic
2017-10-25 22:40 ` Maciej W. Rozycki
2017-10-26 11:22 ` Djordje Todorovic [this message]
2017-10-30 13:44 ` Maciej W. Rozycki
2017-10-30 14:12 ` Maciej W. Rozycki
2017-11-03 13:05 ` Djordje Todorovic
2017-11-07 21:59 ` Maciej W. Rozycki
2017-11-08 10:10 ` Pedro Alves
2017-11-08 21:23 ` Maciej W. Rozycki
2017-11-08 21:24 ` [committed v7 1/3] BFD: Write Linux core PRSTATUS note into MIPS " Maciej W. Rozycki
2017-11-08 21:24 ` [committed v7 2/3] BFD: Extract PID from MIPS core dump file Maciej W. Rozycki
2017-11-08 21:26 ` [committed v7 3/3] Add test for fetching TLS from core file Maciej W. Rozycki
2017-11-09 10:32 ` [PATCH 0/3] Fix issues with writing Linux core PRSTATUS note on MIPS o32, n32 and n64 into " Djordje Todorovic
2017-11-09 22:41 ` Maciej W. Rozycki
2017-11-07 21:31 ` Maciej W. Rozycki
2017-11-08 9:56 ` Pedro Alves
2017-11-08 18:41 ` Maciej W. Rozycki
2017-10-27 15:00 ` Pedro Alves
2017-10-30 13:38 ` Maciej W. Rozycki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=64ad38a4-b8ae-912e-45d6-7048135ada2e@rt-rk.com \
--to=djordje.todorovic@rt-rk.com \
--cc=asowda@cisco.com \
--cc=binutils@sourceware.org \
--cc=gdb-patches@sourceware.org \
--cc=macro@mips.com \
--cc=nemanja.popov@rt-rk.com \
--cc=nikola.prica@rt-rk.com \
--cc=palves@redhat.com \
--cc=petar.jovanovic@rt-rk.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox