News for hackers. Stuff that matters.
Re:Some ways to get better at debugging by benreesman on Wednesday August 31, 2022 @06:27PM (#32669156)
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!!!!!!!

Re:Some ways to get better at debugging by mnutt on Wednesday August 31, 2022 @07:11PM (#32669539)
It'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.

Re:Some ways to get better at debugging by omginternets on Wednesday August 31, 2022 @06:33PM (#32669210)
>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?

Re:Some ways to get better at debugging by benreesman on Wednesday August 31, 2022 @06:43PM (#32669293)
`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...

Re:Some ways to get better at debugging by mbwgh on Thursday September 01, 2022 @07:06AM (#32674711)
If 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.
Re:Some ways to get better at debugging by omginternets on Thursday September 01, 2022 @12:09PM (#32678517)
That's super cool. Thanks for the tip!
Re:Some ways to get better at debugging by omginternets on Wednesday August 31, 2022 @07:15PM (#32669574)
Nice. I definitely need to use this more. Thanks :)
Re:Some ways to get better at debugging by FullyFunctional on Thursday September 01, 2022 @01:22PM (#32679770)
Having 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.
Re:Some ways to get better at debugging by themichaellai on Wednesday August 31, 2022 @08:51PM (#32670378)
Does 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.