looking for gdb's help

classic Classic list List threaded Threaded
4 messages Options
XXX
Reply | Threaded
Open this post in threaded view
|

looking for gdb's help

XXX
hello!

i have a question about gdb debugging. while a signal cause a core dump, how can i get which thread cause the signal. the _siginfo only records the pid, not thread id. while debugging the core file, the current thread is not the thread which cause the core signal.


i am looking for your reply, thank you!
Reply | Threaded
Open this post in threaded view
|

Re: looking for gdb's help

Simon Marchi-4
On 2019-05-14 3:26 a.m., XXX wrote:
> hello!
>
> i have a question about gdb debugging. while a signal cause a core dump, how can i get which thread cause the signal. the _siginfo only records the pid, not thread id. while debugging the core file, the current thread is not the thread which cause the core signal.
>
>
> i am looking for your reply, thank you!
>

Is this core dump created by the Linux kernel?  IIRC, the Linux kernel typically
places the signalled thread first in the list of of threads, such that when I
open a core dump in GDB, thread 1 is usually the one that caused the problem.

Simon
Reply | Threaded
Open this post in threaded view
|

Re: looking for gdb's help

Jan Kratochvil-2
In reply to this post by XXX
On Tue, 14 May 2019 09:26:56 +0200, XXX wrote:
> i have a question about gdb debugging. while a signal cause a core dump, how
> can i get which thread cause the signal.

$ eu-readelf corefile # eu-readelf is from elfutils package
  Owner          Data size  Type
  CORE                 336  PRSTATUS
    info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
    sigpend: <>
    sighold: <>
    pid: 2700200, ppid: 2700198, pgrp: 2700198, sid: 2652754
         ^^^^^^^ = crashed thread TID
...
  CORE                 136  PRPSINFO
    state: 2, sname: D, zomb: 0, nice: 0, flag: 0x0000000040404404
    uid: 1001, gid: 1001, pid: 2700199, ppid: 2700198, pgrp: 2700198
                               ^^^^^^^ = crashed process PID


Jan
XXX
Reply | Threaded
Open this post in threaded view
|

Re: looking for gdb's help

XXX
Normally, your description is right and i think the "thread 1" while using gdb is from these information. But in some case this thread ID is the "main thread", not the real point.




------------------ Original ------------------
From: "Jan Kratochvil"<[hidden email]>;
Date: Wed, May 15, 2019 10:28 PM
To: "XXX"<[hidden email]>;
Cc: "gdb"<[hidden email]>;
Subject: Re: looking for gdb's help



On Tue, 14 May 2019 09:26:56 +0200, XXX wrote:
> i have a question about gdb debugging. while a signal cause a core dump, how
> can i get which thread cause the signal.

$ eu-readelf corefile # eu-readelf is from elfutils package
  Owner          Data size  Type
  CORE                 336  PRSTATUS
    info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
    sigpend: <>
    sighold: <>
    pid: 2700200, ppid: 2700198, pgrp: 2700198, sid: 2652754
         ^^^^^^^ = crashed thread TID
...
  CORE                 136  PRPSINFO
    state: 2, sname: D, zomb: 0, nice: 0, flag: 0x0000000040404404
    uid: 1001, gid: 1001, pid: 2700199, ppid: 2700198, pgrp: 2700198
                               ^^^^^^^ = crashed process PID


Jan