Bug 971849 - Add $_signo convenience variable
Add $_signo convenience variable
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gdb (Show other bugs)
6.5
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Sergio Durigan Junior
qe-baseos-tools
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-07 08:14 EDT by Denys Vlasenko
Modified: 2014-10-14 03:27 EDT (History)
5 users (show)

See Also:
Fixed In Version: gdb-7.2-66.el6
Doc Type: Enhancement
Doc Text:
Cause: GDB did not had a proper way of representing the signal that caused the program being debugged to exit. Consequence: There was no way to retrieve this information when using a corefile for debugging. Fix: GDB now correctly exports the signal that caused the program being debugged to exit. Result: The user can now obtain this information when using a corefile for debugging.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-10-14 03:27:57 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Proposed patch (untested) (2.12 KB, patch)
2013-06-07 09:23 EDT, Denys Vlasenko
no flags Details | Diff
Updated patch. (1.76 KB, patch)
2013-06-11 11:59 EDT, Denys Vlasenko
no flags Details | Diff

  None (edit)
Description Denys Vlasenko 2013-06-07 08:14:44 EDT
Abrt project wants to perform vulnerability analysis on saved coredumps.
It is planned to be implemented as a python gdb module.
A part of analysis requires knowing the signal which killed the task.

This works on a live process:

sig = gdb.parse_and_eval("$_siginfo.si_signo")

but not on the coredump:

(gdb) core ./coredump
[New LWP 2703]
Core was generated by `/usr/bin/gnote <<skip>>'.
Program terminated with signal 11, Segmentation fault.
#0  0x09fa5348 in ?? ()
(gdb) print $_siginfo.si_signo
Unable to read siginfo

But obviously, gdb does know the signal number - it even said so a few lines above.

Please add a convenience variable for it. Say, call it $_signo.
Comment 1 Jan Kratochvil 2013-06-07 08:23:20 EDT
GDB can decode full $_siginfo from NT_SIGINFO; I did not test it but assuming RHEL-6 kernel still did not produce NT_SIGINFO.

As it is just a backward compatibility issue isn't it enough to use:
eu-readelf -n ~/t/sleep.core | grep info.si_
    info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
Comment 2 Denys Vlasenko 2013-06-07 09:23:07 EDT
Created attachment 758156 [details]
Proposed patch (untested)
Comment 3 Denys Vlasenko 2013-06-07 09:31:53 EDT
(In reply to Jan Kratochvil from comment #1)
> GDB can decode full $_siginfo from NT_SIGINFO; I did not test it but
> assuming RHEL-6 kernel still did not produce NT_SIGINFO.

Yes, I want to get at signo even on older kernels.

> As it is just a backward compatibility issue isn't it enough to use:
> eu-readelf -n ~/t/sleep.core | grep info.si_
>     info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11

Python gdb plugin wouldn't know whether it is being run on a coredump or a live process which has crashed just now.
How do you imagine to implement this in a not-horrifyingly hackish way?
I really don't want to do something like:

    try:
        sig = gdb.parse_and_eval("$_siginfo.si_signo")
    except gdb.error:
        # Hmm, we are probably working on coredump....
        # ... lets see whether we are running from the abrt and it provided us with signal number...
        try:
            sig = int(os.environ["ABRT_SIGNO_OF_THE_COREDUMP")
        except:
             ...

with corresponding code elsewhere which sets $ABRT_SIGNO_OF_THE_COREDUMP.
Comment 4 Denys Vlasenko 2013-06-11 11:59:10 EDT
Created attachment 759707 [details]
Updated patch.

I built modified gdb-7.5.1-39.fc18 with this patch, it works for me.
Comment 5 Sergio Durigan Junior 2013-06-14 14:00:35 EDT
Proposed upstream patch: http://sourceware.org/ml/gdb-patches/2013-06/msg00321.html
Comment 7 Sergio Durigan Junior 2013-10-13 20:07:16 EDT
Oh, just in case it wasn't clear: the name of the convenience variable accepted upstream has been changed from $_signo (as proposed in this bug report) to $_exitsignal.
Comment 13 errata-xmlrpc 2014-10-14 03:27:57 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1534.html

Note You need to log in before you can comment on or make changes to this bug.