[PATCH] Enable dumping running process stack.

From: Leon Ma
Date: Mon Aug 19 2013 - 21:48:04 EST


From: Leon Ma <xindong.ma@xxxxxxxxx>
Date: Fri, 16 Aug 2013 13:11:15 +0800
Subject: [PATCH] Enable dumping running process stack.

Currently, if the process is running, we can not dump the stack via
/proc/<pid>/stack, because in __save_stack_address() it will return
immediately if the address is not reliable.
Sometimes one process would run into dead loop in kernel, it will
facilitate debugging to have it's stack retrieved via procfs.

Signed-off-by: Leon Ma <xindong.ma@xxxxxxxxx>
---
arch/x86/kernel/dumpstack.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 1b81839..c892ceb 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -103,7 +103,10 @@ print_context_stack(struct thread_info *tinfo,
frame = frame->next_frame;
bp = (unsigned long) frame;
} else {
- ops->address(data, addr, 0);
+ if (tinfo->task->state == TASK_RUNNING)
+ ops->address(data, addr, 1);
+ else
+ ops->address(data, addr, 0);
}
print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
}
--
1.7.4.1



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/