[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210223143426.2412737-5-elver@google.com>
Date: Tue, 23 Feb 2021 15:34:26 +0100
From: Marco Elver <elver@...gle.com>
To: elver@...gle.com, peterz@...radead.org,
alexander.shishkin@...ux.intel.com, acme@...nel.org,
mingo@...hat.com, jolsa@...hat.com, mark.rutland@....com,
namhyung@...nel.org, tglx@...utronix.de
Cc: glider@...gle.com, viro@...iv.linux.org.uk, arnd@...db.de,
christian@...uner.io, dvyukov@...gle.com, jannh@...gle.com,
axboe@...nel.dk, mascasa@...gle.com, pcc@...gle.com,
irogers@...gle.com, kasan-dev@...glegroups.com,
linux-arch@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
x86@...nel.org
Subject: [PATCH RFC 4/4] perf/core: Add breakpoint information to siginfo on SIGTRAP
Encode information from breakpoint attributes into siginfo_t, which
helps disambiguate which breakpoint fired.
Note, providing the event fd may be unreliable, since the event may have
been modified (via PERF_EVENT_IOC_MODIFY_ATTRIBUTES) between the event
triggering and the signal being delivered to user space.
Signed-off-by: Marco Elver <elver@...gle.com>
---
kernel/events/core.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 8718763045fd..d7908322d796 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6296,6 +6296,17 @@ static void perf_sigtrap(struct perf_event *event)
info.si_signo = SIGTRAP;
info.si_code = TRAP_PERF;
info.si_errno = event->attr.type;
+
+ switch (event->attr.type) {
+ case PERF_TYPE_BREAKPOINT:
+ info.si_addr = (void *)(unsigned long)event->attr.bp_addr;
+ info.si_perf = (event->attr.bp_len << 16) | (u64)event->attr.bp_type;
+ break;
+ default:
+ /* No additional info set. */
+ break;
+ }
+
force_sig_info(&info);
}
--
2.30.0.617.g56c4b15f3c-goog
Powered by blists - more mailing lists