Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
strace(1) all the things!
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Dan Miller
November 13, 2014
Programming
3
650
strace(1) all the things!
Presented at the Marist College Computer Society meeting, 11/12/14
Dan Miller
November 13, 2014
Tweet
Share
More Decks by Dan Miller
See All by Dan Miller
Oh Snap!
jazzdan
0
290
HHVM at Etsy
jazzdan
22
6.9k
"API First" Development
jazzdan
7
1.1k
Other Decks in Programming
See All in Programming
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
16
3.3k
Claude Code Skill入門
mayahoney
0
410
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
1
150
CSC307 Lecture 14
javiergs
PRO
0
480
AI駆動開発の本音 〜Claude Code並列開発で見えたエンジニアの新しい役割〜
hisuzuya
4
520
米国のサイバーセキュリティタイムラインと見る Goの暗号パッケージの進化
tomtwinkle
2
620
どんと来い、データベース信頼性エンジニアリング / Introduction to DBRE
nnaka2992
1
310
Java 21/25 Virtual Threads 소개
debop
0
130
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2k
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
9
2.9k
Everything Claude Code OSS詳細 — 5層構造の中身と導入方法
targe
0
140
Goの型安全性で実現する複数プロダクトの権限管理
ishikawa_pro
2
490
Featured
See All Featured
Chasing Engaging Ingredients in Design
codingconduct
0
150
How to Talk to Developers About Accessibility
jct
2
160
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
100
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
150
From π to Pie charts
rasagy
0
150
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
220
Designing for Timeless Needs
cassininazir
0
170
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Why Our Code Smells
bkeepers
PRO
340
58k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
Unsuck your backbone
ammeep
672
58k
Transcript
strace(1) all the things Dan Miller Software Engineer Etsy
etsy.com/careers
@jazzdan strace(1) all the things What is strace(1)? How to
see what a program does without the source A quick aside about man(1) pages How does ls(1) work?
What is strace?
@jazzdan strace(1) is a unix utility for observing system calls
How do we see what a program does without reading
the source?
@jazzdan $ls
@jazzdan $strace ls
None
@jazzdan strace ls • execve(2) • open(2) • close(2) •
getdents(2) • write(2)
A quick aside on Unix man pages
@jazzdan $man man
None
None
None
How does ls work?
execve("/bin/ls", ["ls"], [/* 23 vars */]) = 0
None
execve() executes the program pointed to by filename. filename must
be either a binary executable, or a script starting with a line of the form: ! #! interpreter [optional-arg]
int execve(const char *filename, char *const argv[], char *const envp[]);
open( “/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC ) = 3
None
Given a pathname for a file, open() returns a file
descriptor, a small, nonnegative integer for use in subsequent system calls (read(2), write(2), lseek(2), fcntl(2), etc.).
int open(const char *pathname, int flags)
open( “/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC ) = 3
@jazzdan Wait… what is libc?
@jazzdan $man libc
None
open( “.", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC ) = 3
getdents( 3, /* 4 entries */, 32768 ) = 712
None
int getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int count);
getdents( 3, /* 23 entries */, 32768 )= 712
open( “.", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC ) = 3
close(3)
None
int close(int fd);
close(3)
write( 1, “hello_world\n", hello_world ) = 23
None
exit_group(0) = ?
None
This system call is equivalent to exit(2) except that it
terminates not only the calling thread, but all threads in the calling process's thread group.
void exit_group(int status);
@jazzdan When is strace(1) useful? • Anything involving files or
sockets • Path issues • See what is being sent over a network interface
@jazzdan When is strace(1) not useful? • In production (performance
is terrible) • When no syscalls are being executed
One Cool Trick for Performance Analysis (perf folks hate ‘em)
@jazzdan $strace -c ls
None
Questions?