Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: stand-alone binary to dump a running process' stacktrace #130

Open
matklad opened this issue Nov 16, 2020 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@matklad
Copy link

matklad commented Nov 16, 2020

Sort version of an ask:

$ cargo-install print-stacktrace
   Installing ...
$ print-stacktrace rust-analyzer
thread #10, name = 'rust-analyzer'
    frame #0: 0x00007f7133cd7bb9 libc.so.6`sysmalloc(nb=336, av=0x00007f7108000020) at malloc.c:2739
    frame #1: 0x00007f7133cd8ff0 libc.so.6`_int_malloc(av=0x00007f7108000020, bytes=321) at malloc.c:4125
    frame #2: 0x00007f7133cd98f5 libc.so.6`_int_realloc(av=0x00007f7108000020, oldp=0x00007f70afffff30, oldsize=176, nb=336) at malloc.c:4570
    frame #3: 0x00007f7133cdcf9b libc.so.6`__GI___libc_realloc(oldmem=&0x7f70afffff40, bytes=320) at malloc.c:3230
    frame #4: 0x00005571f6b8846b rust_analyzer`_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..SpecExtend$LT$T$C$I$GT$$GT$::from_iter::hdc9ae08fd4d2dcd5 [inlined] alloc::alloc::realloc::h7df9eca016b70494 at alloc.rs:128
    ...

Long version:

For my personal use, I reach for debuggers mostly to get stactraces on deadlocks/livelocks. Every time I need to google how to gdb and recollect that bt thread all incantation. Moreover, when I debug a hang on someone-else's computer, I need to teach them how to work with gdb. My life would be much easier if I can ask them to just cargo install print-stacktrace .

This utility should dump a stack of a running process using either process name (default) or PID (with -p argument). Defaulting to name makes sense, as figuring out a PID is often a stumbling block. If there's more than one process with a matching name, I think the tool should print:

Found 2 processes with a name `foo`:
  Pid:    Process:
  1234    '/usr/bin/foo --eggs'
  9292    '/home/alice/bin/foo --spam'

Use the following command to disambiguate:

  print-stacktrace -p Pid

It seems like implementing this should be possible in the early stages of headcrab (I've said it already, and I say it again: what a delightful name!), and it'll put some part of the infra into production usage.

@matklad matklad changed the title Feature request: stand-alone library to dump a running process' stacktrace Feature request: stand-alone binary to dump a running process' stacktrace Nov 16, 2020
@bjorn3
Copy link
Contributor

bjorn3 commented Nov 16, 2020

Headcrab doesn't have support for DWARF unwinding yet (#60). It shouldn't be too implement this tool for the existing frame pointer unwinder though. I don't think I will be able to implement this myself very soon unfortunately.

@bjorn3 bjorn3 added the enhancement New feature or request label Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants