试图理解 strace 输出
我正在尝试了解 strace。
所以我认为一个非常实用的方法是执行以下操作:
strace ``echo "1"'' > echo1.txt
strace ``echo "2"'' > echo2.txt
然后:
diff echo1.txt echo2.txt
然后从那里开始。这个想法是,如果我能看到输出的差异,我就可以推断出 strace 告诉我的大量内容。
不幸的是,echo1.txt 和 echo2.txt 仅包含 echo 的输出,而不包含 strace 的输出。我可以手动复制/粘贴输出,然后运行差异,但现在我只是好奇我做错了什么。
有人可以帮忙吗?
I'm trying to get an understanding of strace.
So I figured a very hands on way would be to do the following:
strace ``echo "1"'' > echo1.txt
strace ``echo "2"'' > echo2.txt
Then:
diff echo1.txt echo2.txt
And go from there. The idea being, that if I can see the difference in the output, I can deduce a great deal of what strace is telling me.
Unfortunately, the echo1.txt and echo2.txt only contained the output from the echo, not the strace. I can just copy/paste the output manually, then run a diff, but now I'm simply curious about what I did wrong.
Can someone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
strace
打印到 stderr,而不是 stdout。您需要使用2> 进行重定向echo1.txt
以便将 stderr 重定向到文件,或者仅使用strace -o echo1.txt
将 strace 输出显式写入该文件。strace
prints to stderr, not stdout. You need should redirect with2> echo1.txt
in order to redirect stderr to a file, or just usestrace -o echo1.txt
to explicitly write the strace output into that file.