4 ms·
I’d like to signal boost strace. It is a lifesaver. In some ways it’s more important than your compiler: it’s how you know what wrong-ass directory your compile
by benreesman 4y ago
I’d like to signal boost strace. It is a lifesaver. In some ways it’s more important than your compiler: it’s how you know what wrong-ass directory your compiler is pulling the broken config from.
I only know like 10% of the tool and it’s just indispensable. Use strace!!!!!!!
- omginternets 4y ago>it’s how you know what wrong-ass directory your compiler is pulling the broken config from Mind=blown. Of course! I've been neglecting this thing for so many years! Question: any recommended reading for using strace effectively?
- benreesman 4y ago`strace` has a bunch of features that I'd like to learn thoroughly someday, but I get weekly if not daily value from a few basic invocations: `run_my_build.whatever` -> hangs, damn. `strace run_my_build.whatever` -> awesome i can see all the system calls so i know what `.so`s it's pulling in, and what config files it's trying to read, and if it's hanging on a network socket or whatever. This is usually where `strace` just immediately solves my problem. If you've got like a background daemon that's misbehaving you can do `strace -p <PID>` and it will attach and start printing out the syscalls, this can also be really useful. `strace` (on all my systems at least) logs to `STDERR` by default, so sometimes you want some combination of like `2>/tmp/log.strace.blah` or to interleave the `STDOOUT` of the process so it's just the usual shell stuff `strace whatever 2>&1 | rg -C ...`. My use of the tool is very basic, but that's part of what makes it such a great tool, a few simple invocations will just save your bacon. This is especially true on a new team/company or whatever where you run the thing from the Wiki and it doesn't build or start or...
- omginternets 4y agoNice. I definitely need to use this more. Thanks :)
- mbwgh 4y agoIf you use `htop`, you can press `s` while hovering over the process. In addition to providing the `strace -p` functionality, you also get some rudimentary helper functionality like searching, filtering, or manually scrolling vs. tailing the output.
- omginternets 4y agoThat's super cool. Thanks for the tip!
- mnutt 4y agoIt's especially great in how easy it is to just immediately drop in and get some useful feedback. Except not on MacOS. Lots of tracing is denied by System Integrity Protection; you can use Instruments.app [0] but it doesn't lend itself as well to quick exploration in my experience. [0] - something like: `xctrace record --template 'System Trace' --launch -- /bin/ls`, then open the trace with Instruments.app.
- themichaellai 4y agoDoes anyone have alternatives that work well on Mac? Right now, I keep a virtual machine so that I can use strace (among other reasons), which is workable but tough to use quickly.
- FullyFunctional 4y agoHaving strace and gdb working always is a major reason why I prefer to develop on Linux. I don't typically use much of the feature set, but I almost always have to reach for '-s' as the default string length of 32 is much too tiny.