I want to know who called *sys_reboot* when the phone(android) reboot unexpectly.
Is there a way to dump the call stack in syscall(android kernel)?
I want to know who called *sys_reboot* when the phone(android) reboot unexpectly.
Is there a way to dump the call stack in syscall(android kernel)?
If all you want it a kernel call trace, you can get that via dump_stack()
. panic()
calls that, amongst other things. The BUG()
/ BUG_ON()
wrappers give it a more descriptive message and an optional conditional test.
A userland stacktrace, particularly a symbolic one, though, cannot reliably be obtained from within the kernel directly. It's possible to copy the stack memory into kernel space and log the contents, or even heuristically walk SP
/FP
linkage if framepointers aren't optimized out, but to resolve symbols, it'd need to access and parse ELF information. I'm unsure anyone has done that as pure kernel-side implementation; an easier solution there would be to stop the program from your syscall hook, spawn a userspace debugger attaching to it, extracting a stacktrace, continuing the program when done.
See this SO posting, call_usermodehelper / call_usermodehelperpipe usage for how to do this.
See also this SO posting: How to print the userspace stack trace in linux kernelspace for another reference to the same question.