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.

Why use strace in 2023? [video]

143 pointsby r4umover 1 year ago

13 comments

mlyleover 1 year ago
strace is basically my first go-to when a command immediately fails with an obscure message.<p>strace, skim the last 4-5 pages of trace output before the error message is emitted, looking in particular for error return values (it&#x27;s often not <i>right</i> before the error because the program has started to clean up). Figures out the problem 80% of the time within a couple of minutes.
评论 #38909837 未加载
评论 #38909934 未加载
评论 #38913456 未加载
评论 #38909217 未加载
评论 #38909781 未加载
zbentleyover 1 year ago
The widespread switch to epoll(7)-based I&#x2F;O systems has taken a big bite out of strace&#x27;s usefulness for me.<p>Back when most programs did most of their I&#x2F;O synchronously or with select(2)&#x2F;poll(2), it was really easy to use strace to track down slow network services. If you wanted to figure out why a process was taking too long, you could strace it, grab the file descriptor numbers that it was spending a long time reading&#x2F;writing&#x2F;selecting&#x2F;polling, feed those into lsof and turn them into network addresses&#x2F;ports, then shell into those remote hosts and see what it was doing with the slow client&#x27;s connection (e.g. if the remote host was a MySQL database you could check what queries were running on its connection&#x2F;session; if it was a RabbitMQ you could see what queues its connection was operating on).<p>Don&#x27;t get me wrong: strace is still an incredibly useful tool every Linux developer, no matter where they are in the stack, should know (Julia Evans made that case better than I could[1]). I also understand why I&#x2F;O systems switched to more &quot;file descriptor opaque&quot; tools like epoll&#x2F;kqueue&#x2F;io_uring, which makes sense and brings a lot of benefits. I just miss the transparency of the old APIs a little bit, you know?<p>1: <a href="https:&#x2F;&#x2F;jvns.ca&#x2F;blog&#x2F;2014&#x2F;04&#x2F;20&#x2F;debug-your-programs-like-theyre-closed-source&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jvns.ca&#x2F;blog&#x2F;2014&#x2F;04&#x2F;20&#x2F;debug-your-programs-like-the...</a>
methouover 1 year ago
I hated macOS for gating &#x2F; crippling dtruss with SIP every time I need to find out what’s wrong with a random cmd.<p>Is there any alternatives on Mac?
评论 #38909962 未加载
评论 #38910104 未加载
评论 #38911094 未加载
评论 #38909715 未加载
评论 #38909987 未加载
ur-whaleover 1 year ago
Oh boy, strace is soooo useful, and not just for coding or sysadmin.<p>As a <i>user</i>, when e.g. my browser does funky stuff like freezing for no reason, my knee-jerk reflex is always strace.<p>I was initially a little put down by the russian style moody intro (the longish &quot;why would you use such an antiquated thing as strace in 2023&quot; which made me think he was going to tear down strace), but stick with the video past it, it is actually an ode to strace and it&#x27;s well worth it.<p>Personnaly, I never realized strace had this many features.
评论 #38911864 未加载
lelandbateyover 1 year ago
Talking about strace per the title without watching; wow is strace ever helpful!<p>You can build an ordered tree of all the programs launched by a program, recursively, using strace. You can do the same for observing files opened. It&#x27;s an amazing tool when you need to observe some software from the outside; in many ways it&#x27;ll give you much better understanding of a program than even reading it&#x27;s source code.
评论 #38909513 未加载
评论 #38909376 未加载
vcdimensionover 1 year ago
In emacs you can use syslog-mode for analyzing strace output: <a href="https:&#x2F;&#x2F;github.com&#x2F;vapniks&#x2F;syslog-mode">https:&#x2F;&#x2F;github.com&#x2F;vapniks&#x2F;syslog-mode</a> It allows you to easily navigate, filter, highlight lines, and lookup documentation.
tanelpoderover 1 year ago
The safer&#x2F;non-slowing down alternative for tracing syscalls would be &quot;perf trace&quot; (and eBPF scripts), but I&#x27;ve found in past that perf trace didn&#x27;t decode enough syscall arguments (and just listed pointers to structs, where strace showed the info inside these structs). But I just ran a few simple &quot;perf trace&quot; commands on RHEL 9, looks like it has caught up somewhat.
INTPenisover 1 year ago
He mentions all these other ways of doing tracing and I assume he means eBPF, but I&#x27;ve yet to see anything useful I can run from the CLI to use that.<p>So what is there out there? Because I&#x27;m a veteran Linux&#x2F;Unix sysadmin for 25 years now and I love strace when I&#x27;m in a bind.<p>So what should I look at now based on eBPF instead?
评论 #38913126 未加载
评论 #38913370 未加载
ExoticPearTreeover 1 year ago
another useful tool is sysdig with its curses gui csysdig which summarizes operations, you can filter on them etc.
评论 #38910790 未加载
评论 #38926661 未加载
alecstover 1 year ago
What are some options on MacOs? Hard to do much with SIP enabled. Ran into the issue a few days ago and still no solution.
评论 #38911121 未加载
arminiusreturnsover 1 year ago
Just be aware that in prod strace can have real impacts and run-away side-effects please!
评论 #38918411 未加载
dwatttttover 1 year ago
For those curious about the Windows equivalent, procmon is a system-wide strace tool; filtering mandatory.
eisvogelover 1 year ago
Why use C in 2024?
评论 #38909470 未加载
评论 #38909707 未加载
评论 #38910780 未加载
评论 #38912184 未加载