task/thread id from core file - Linux

This is a discussion on task/thread id from core file - Linux ; Hi all, I have a large application that occasionally crashes and produces a core file. Sometimes the backtraces provides very little information. Since the app has many running pthreads, I wonder if it's somehow possible to know WHICH thread (task ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: task/thread id from core file

  1. task/thread id from core file

    Hi all,

    I have a large application that occasionally crashes and produces a
    core file. Sometimes the backtraces provides very little information.
    Since the app has many running pthreads, I wonder if it's somehow
    possible to know WHICH thread (task id) crashed?

    Thanks,
    --Robbert


  2. Re: task/thread id from core file

    > I have a large application that occasionally crashes and produces a
    > core file. Sometimes the backtraces provides very little information.
    > Since the app has many running pthreads, I wonder if it's somehow
    > possible to know WHICH thread (task id) crashed?


    The safest way is to establish a handler for each signal,
    and have the handler save information before killing the process.
    Any process with "many" threads should be doing this already,
    because threads need all the debugging help they can get.

    A 'core' file is an ELF file; see /usr/include/elf.h.

    "readelf --all core" from a testcase shows:
    -----
    Notes at offset 0x00000254 with length 0x000001d8:
    Owner Data size Description
    CORE 0x00000090 NT_PRSTATUS (prstatus structure)
    CORE 0x0000007c NT_PRPSINFO (prpsinfo structure)
    CORE 0x00000090 NT_AUXV (auxiliary vector)
    -----

    "grep -sr NT_PRSTATUS" on a 2.6.15 kernel source tree leads to
    -----
    struct elf_prstatus
    {
    struct elf_siginfo pr_info; /* Info associated with signal */
    short pr_cursig; /* Current signal */
    unsigned int pr_sigpend; /* Set of pending signals */
    unsigned int pr_sighold; /* Set of held signals */
    pid_t pr_pid;
    pid_t pr_ppid;
    pid_t pr_pgrp;
    pid_t pr_sid;
    -----
    and pr_pid might be what you seek. If it isn't the thread id,
    then it will be the process id, and you might find the thread id
    somewhere else.

    --

+ Reply to Thread