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
Dan Miller
November 13, 2014
Programming
3
630
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
270
HHVM at Etsy
jazzdan
22
6.8k
"API First" Development
jazzdan
7
1k
Other Decks in Programming
See All in Programming
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
440
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
520
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
230
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
300
Effective Signals in Angular 19+: Rules and Helpers
manfredsteyer
PRO
0
120
return文におけるstd::moveについて
onihusube
1
1.2k
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
810
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
950
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
260
Online-Dokumentation, die hilft: Strukturen, Prozesse, Tools
ahus1
0
100
命名をリントする
chiroruxx
1
450
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
243
12k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
A Philosophy of Restraint
colly
203
16k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
How to train your dragon (web standard)
notwaldorf
88
5.7k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
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?