[PATCH 19/19] x86/dumpstack: print any pt_regs found on the stack

From: Josh Poimboeuf
Date: Thu Jul 21 2016 - 17:22:45 EST


Now that we can find pt_regs registers in the middle of the stack due to
an interrupt or exception, we can print them. Here's what it looks
like:

...
[<ffffffff8106f7dc>] do_async_page_fault+0x2c/0xa0
[<ffffffff8189f558>] async_page_fault+0x28/0x30
RIP: 0010:[<ffffffff814529e2>] [<ffffffff814529e2>] __clear_user+0x42/0x70
RSP: 0018:ffff88007876fd38 EFLAGS: 00010202
RAX: 0000000000000000 RBX: 0000000000000138 RCX: 0000000000000138
RDX: 0000000000000000 RSI: 0000000000000008 RDI: 000000000061b640
RBP: ffff88007876fd48 R08: 0000000dc2ced0d0 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: 000000000061b640
R13: 0000000000000000 R14: ffff880078770000 R15: ffff880079947200
[<ffffffff814529e2>] ? __clear_user+0x42/0x70
[<ffffffff814529c3>] ? __clear_user+0x23/0x70
[<ffffffff81452a7b>] clear_user+0x2b/0x40
...

Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
arch/x86/kernel/dumpstack.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 0eedb01..4509866 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -173,6 +173,14 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
* printed as unreliable.
*/
unwind_next_frame(&state);
+
+ /*
+ * If the previous frame had pt_regs associated with it
+ * due to an interrupt or exception, print them.
+ */
+ regs = unwind_get_entry_regs(&state);
+ if (regs)
+ __show_regs(regs, 0);
}

if (str_end)
--
2.7.4