summaryrefslogtreecommitdiff
path: root/src/kern/linux/events.cc
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2016-06-20 14:39:49 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2016-06-20 14:39:49 +0100
commit37bb0d0fb30a3548173253b0f19861a7ee4f8fce (patch)
treeee2e89b4a804e4bcaca76c0f38a359c1f5bab3c0 /src/kern/linux/events.cc
parent60fb5e79f358b7d0784e4cfae4df9ec196e47f19 (diff)
downloadgem5-37bb0d0fb30a3548173253b0f19861a7ee4f8fce.tar.xz
kern, arm: Dump dmesg on kernel panic/oops
Add helper functions to dump the guest kernel's dmesg buffer to a text file in m5out. This functionality is split into two parts. First, a dmesg dump function that can be used in other places: void Linux::dumpDmesg(ThreadContext *, std::ostream &) This function is used to implement two PCEvents: DmesgDumpEvent and KernelPanic event. The only difference between the two is that the latter produces a gem5 panic instead of a warning in addition to dumping the kernel log. Change-Id: I6d2af1d666ace57124089648ea906f6c787ac63c Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Gabor Dozsa <gabor.dozsa@arm.com>
Diffstat (limited to 'src/kern/linux/events.cc')
-rw-r--r--src/kern/linux/events.cc33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/kern/linux/events.cc b/src/kern/linux/events.cc
index 42f058a72..f4e694436 100644
--- a/src/kern/linux/events.cc
+++ b/src/kern/linux/events.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 ARM Limited
+ * Copyright (c) 2011, 2016 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -41,13 +41,17 @@
* Ali Saidi
*/
+#include "kern/linux/events.hh"
+
#include <sstream>
#include "arch/utility.hh"
+#include "base/output.hh"
#include "base/trace.hh"
+#include "cpu/base.hh"
#include "cpu/thread_context.hh"
#include "debug/DebugPrintf.hh"
-#include "kern/linux/events.hh"
+#include "kern/linux/helpers.hh"
#include "kern/linux/printk.hh"
#include "kern/system_events.hh"
#include "sim/arguments.hh"
@@ -94,5 +98,30 @@ UDelayEvent::process(ThreadContext *tc)
}
}
+void
+DmesgDumpEvent::process(ThreadContext *tc)
+{
+ StringWrap name(tc->getCpuPtr()->name() + ".dmesg_dump_event");
+
+ inform("Dumping kernel dmesg buffer to %s...\n", fname);
+ OutputStream *os = simout.create(fname);
+ dumpDmesg(tc, *os->stream());
+ simout.close(os);
+
+ warn(descr());
+}
+
+void
+KernelPanicEvent::process(ThreadContext *tc)
+{
+ StringWrap name(tc->getCpuPtr()->name() + ".dmesg_dump_event");
+
+ inform("Dumping kernel dmesg buffer to %s...\n", fname);
+ OutputStream *os = simout.create(fname);
+ dumpDmesg(tc, *os->stream());
+ simout.close(os);
+
+ panic(descr());
+}
} // namespace linux