Bug 24283 - $_siginfo decoding missing _sigsys structure
Summary: $_siginfo decoding missing _sigsys structure
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: unknown
: P2 enhancement
Target Milestone: 12.1
Assignee: Not yet assigned to anyone
URL: https://git.kernel.org/pub/scm/linux/...
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-28 21:08 UTC by Mike Frysinger
Modified: 2022-01-08 13:18 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Frysinger 2019-02-28 21:08:20 UTC
newer kernels have a _sigsys structure:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/siginfo.h?h=v4.20#n103
	/* SIGSYS */
	struct {
		void __user *_call_addr; /* calling user insn */
		int _syscall;	/* triggering system call number */
		unsigned int _arch;	/* AUDIT_ARCH_* of syscall */
	} _sigsys;

this helps a lot when debugging seccomp failures.

i guess gdb/linux-tdep.c:linux_get_siginfo_type_with_fields needs updating.  i've never played with this section of code before, so throwing up a feature bug so it doesn't get lost.
Comment 1 Hannes Domani 2020-04-07 18:56:04 UTC
I think it should be as simple as that:

--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -350,6 +350,13 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
   append_composite_type_field (type, "si_fd", int_type);
   append_composite_type_field (sifields_type, "_sigpoll", type);

+  /* _sigsys */
+  type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+  append_composite_type_field (type, "_call_addr", void_ptr_type);
+  append_composite_type_field (type, "_syscall", int_type);
+  append_composite_type_field (type, "_arch", uint_type);
+  append_composite_type_field (sifields_type, "_sigsys", type);
+
   /* struct siginfo */
   siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
   TYPE_NAME (siginfo_type) = xstrdup ("siginfo");

But I don't have Linux, so I can't test it.
Comment 2 Mike Frysinger 2021-03-09 23:43:26 UTC
looks like we've had someone test it on our side: https://crrev.com/c/2745853

can you send your patch to the mailing list since you're the author ?
Comment 3 Sourceware Commits 2022-01-08 13:16:37 UTC
The master branch has been updated by Hannes Domani <ssbssa@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24fe764c8a14bd519826e7e9af01edff59ab6be3

commit 24fe764c8a14bd519826e7e9af01edff59ab6be3
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Tue Apr 7 20:57:07 2020 +0200

    Add _sigsys info to siginfo struct
    
    This patch adds information about _sigsys structure from newer
    kernels, so that $_siginfo decoding can show information about
    _sigsys, making it easier for developers to debug seccomp failures.
    Requested in PR gdb/24283.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24283
Comment 4 Hannes Domani 2022-01-08 13:18:01 UTC
Fixed.