This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] Add panic tapset
- From: "Bryn M. Reeves" <bmr at redhat dot com>
- To: Systemtap List <systemtap at sourceware dot org>
- Date: Mon, 18 Jun 2012 18:56:16 +0100
- Subject: [PATCH] Add panic tapset
Hi Folks,
This patch adds a tapset with a single function to call the native
panic() routine. This is useful in order to trigger a core dump to
collect post-mortem debugging data when some condition occurs.
I've used this sort of trick several times (e.g. the PanicOnOom war
story in the systemtap wiki) and find it a very handy tool.
E.g.:
stap -g -e 'probe end { panic("whoops!") }'
Regards,
Bryn.
>From 16f8bd43fddeec7bec370562b68d3baac256282c Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Mon, 18 Jun 2012 18:09:47 +0100
Subject: [PATCH] Add panic tapset
Add a tapset to expose the kernel's panic() routine.
---
tapset/panic.stp | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
create mode 100644 tapset/panic.stp
diff --git a/tapset/panic.stp b/tapset/panic.stp
new file mode 100644
index 0000000..48ea2c9
--- /dev/null
+++ b/tapset/panic.stp
@@ -0,0 +1,32 @@
+// Copyright (C) 2012 Red Hat Inc., Bryn M. Reeves <bmr@redhat.com>
+//
+// This file is part of systemtap, and is free software. You can
+// redistribute it and/or modify it under the terms of the GNU General
+// Public License (GPL); either version 2, or (at your option) any
+// later version.
+//
+
+// <tapsetdescription>
+// Functions in the panic tapset allow a probe handler to invoke
+// the system panic routine with a user-specified message.
+//
+// This may be used with a crash dump collection facility such as
+// kexec/kdump in order to capture data for post-mortem debugging.
+//
+// Due to the fact that this will bring the system to an immediate
+// halt the functions in this tapset require guru mode.
+// </tapsetdescription>
+
+/**
+ * sfunction panic - trigger a panic
+ * @msg: message to pass to kernel's panic() function
+ *
+ * Description: this function triggers an immediate panic of the running
+ * kernel with a user-specified panic message.
+ * It requires guru mode.
+ */
+function panic(msg:string) %{
+ /* guru */
+ panic("%s", THIS->msg);
+%}
+
--
1.7.6.5