TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Using /proc to get a process' current stack trace

190 pointsby cirowrcover 6 years ago

8 comments

drewg123over 6 years ago
FWIW, the equivalent in FreeBSD is &#x27;procstat -kk $PID&#x27; Eg:<p><pre><code> % procstat -kk 5592 PID TID COMM TDNAME KSTACK 5592 103222 less - </code></pre> mi_switch+0xe1 sleepq_catch_signals+0x405 sleepq_wait_sig+0xf _cv_wait_sig+0x154 tty_wait+0x1c ttydisc_read+0x1f2 ttydev_read+0x64 devfs_read_f+0xdc dofileread+0x95 sys_read+0xc3 amd64_syscall+0x369 fast_syscall_common+0x101<p>procstat can also do interesting things, like show current rusage state:<p><pre><code> % procstat -r 5592 PID COMM RESOURCE VALUE 5592 less user time 00:00:00.010805 5592 less system time 00:00:00.002444 5592 less maximum RSS 3172 KB 5592 less integral shared memory 192 KB 5592 less integral unshared data 80 KB 5592 less integral unshared stack 256 KB 5592 less page reclaims 199 5592 less page faults 0 5592 less swaps 0 5592 less block reads 4 5592 less block writes 0 5592 less messages sent 0 5592 less messages received 0 5592 less signals received 0 5592 less voluntary context switches 59 5592 less involuntary context switches 0</code></pre>
评论 #18223227 未加载
评论 #18220319 未加载
lixtraover 6 years ago
If you are running java instead of a c program the proc stacktrace shows you just the virtual machine state. You can still get a stacktrace of your java threads[1].<p>How about other languages? Python, ruby?<p>[1] <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;4876274&#x2F;kill-3-to-get-java-thread-dump" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;4876274&#x2F;kill-3-to-get-ja...</a>
评论 #18224467 未加载
评论 #18220975 未加载
评论 #18220338 未加载
评论 #18222284 未加载
indigodaddyover 6 years ago
Nicely formatted site. Anyone know if&#x2F;what static site generator&#x2F;theme is being used? Couldn&#x27;t find anything on the footer, site tags, or his GitHub that would reveal that...
评论 #18245428 未加载
ktpsnsover 6 years ago
Note, the GNU debugger (gdb) can attach to running processes. This should give you a stack trace with readable addresses, cf. <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;2308653&#x2F;can-i-use-gdb-to-debug-a-running-process" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;2308653&#x2F;can-i-use-gdb-to...</a>
评论 #18223753 未加载
_pmf_over 6 years ago
My favorite proc hack: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17061499" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17061499</a>
评论 #18222985 未加载
jhallenworldover 6 years ago
I want this capability for embedded ARM systems. I should be able to call a function to have the current stack trace printed:<p><a href="https:&#x2F;&#x2F;communities.mentor.com&#x2F;thread&#x2F;16468" rel="nofollow">https:&#x2F;&#x2F;communities.mentor.com&#x2F;thread&#x2F;16468</a>
评论 #18220781 未加载
评论 #18220415 未加载
AlphaWeaverover 6 years ago
This is a very well written and formatted article... I found it easy to read!
Annatarover 6 years ago
Instead of teaching people how to do this portably across all UNIX-like systems, by sending SIGABRT to the process, the article is steeping them in GNU&#x2F;Linux only way of doing things. This feels exactly like the &#x27;90&#x27;s of the past century, where a lot of people with computer-related careers had no idea that there were other operating systems and other ways of doing things (better): an intel-based PC tin bucket with Windows was the one and only truth for them. Now it&#x27;s exactly the same except Windows has been replaced with GNU&#x2F;Linux. 28 years later and the only advancement some people have made is running the proverbial sed &#x27;s&#x2F;Windows&#x2F;Linux&#x2F;g&#x27;.
评论 #18220241 未加载
评论 #18221138 未加载
评论 #18220200 未加载
评论 #18220637 未加载
评论 #18220176 未加载
评论 #18219937 未加载
评论 #18222129 未加载
评论 #18220195 未加载
评论 #18220466 未加载
评论 #18220058 未加载