Bug 971849

Summary: Add $_signo convenience variable
Product: Red Hat Enterprise Linux 6 Reporter: Denys Vlasenko <dvlasenk>
Component: gdbAssignee: Sergio Durigan Junior <sergiodj>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.5CC: dvlasenk, jan.kratochvil, mcermak, mfranc, mmilata
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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 07:27:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Proposed patch (untested)
none
Updated patch. none

Description Denys Vlasenko 2013-06-07 12:14:44 UTC
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 12:23:20 UTC
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 13:23:07 UTC
Created attachment 758156 [details]
Proposed patch (untested)

Comment 3 Denys Vlasenko 2013-06-07 13:31:53 UTC
(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 15:59:10 UTC
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 18:00:35 UTC
Proposed upstream patch: http://sourceware.org/ml/gdb-patches/2013-06/msg00321.html

Comment 7 Sergio Durigan Junior 2013-10-14 00:07:16 UTC
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 07:27:57 UTC
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