A small tool that shows the stacktrace of a running task.
pstkdrv, pstack, and libelf are driver, process, and library, respectively. Thus, you can compile them in driver/, bappl/, and lib/, respectively.
As pstack depends on libelf header files and library, you need to make && make install before compiling pstack application.
% lodspg pstkdrv
. % ref tsk
command to get the task ID of the target task whose stacktrace you want to view. % pstack 123
% pstack 123:/path/to/mapfile.map
% pstack 123:/path/to/exefile.out
[/SYS]% pstack 47:/SYS/USR/webkit.out
*** TID = 47:
EIP = 8000c51e : _end+2116597870
<-- 80015544 : _end+2116634772
<-- 80060038 : _end+2116940680
<-- 800134ca : _end+2116626458
<-- 8001555d : _end+2116634797
<-- 0000003b : _usemt_+58
<-- c062b418 : _end+3196757864
<-- c061d884 : _end+3196701652
<-- c061f3e2 : _end+3196708658
<-- c060c2e6 : _end+3196630582
<-- 800134ca : _end+2116626458
<-- 8001555d : _end+2116634797
<-- 00979073 : b_cact_par+11
<-- 0010709a : TShellWebKitPanel::onWorkAreaMouseDown()+122
<-- 004ca049 : TShellWindow::onMouseDown()+129
<-- 004c952a : TShellApp::dispatch()+142
<-- 004c9781 : TShellApp::cycle()+49
<-- 001036d7 : TShellWebKitApp::cycle()+15
<-- 004c979e : TShellApp::run()+18
<-- 0010346f : MAIN_sub(message*)+91
<-- 0010352f : MAIN+27
<-- 001002ad : _C_startup+105
Of course, you can embed libpstk.c, pstack.h, and demangle.cc into your own applications to do print_stacktrace(...);
for debugging purpose. However, if you do not need symbol resolution, it is easier to put tm_command("btr");
.
Backtraces in kernel mode frames are sometimes incorrect. In the example above, address 0x0006003b is apparently wrong.
As the stacktraces in user mode are considered correct, you should (1) only target at tasks that belongs to a process, and (2) trust only stacktraces before syscalls. (In the above example, below "b_cact_par" can be trusted.)
Here's the reasons of the problems described previously. If you have any good ideas that helps to solve them, please tell me.
[ Back ]
Yashiro Takeshi <yashiromann@gmail.com>