Skip to content

Instantly share code, notes, and snippets.

@ossareh
Created May 12, 2012 20:56
Show Gist options
  • Save ossareh/2668983 to your computer and use it in GitHub Desktop.
Save ossareh/2668983 to your computer and use it in GitHub Desktop.
Humbling
$ cat echo.c
#include <stdio.h>
int main() {
int c;
while ((c = getchar()) != EOF) {
putchar(c);
}
}
$ sudo dtruss ./a.out
a
a
SYSCALL(args) = return
open(".\0", 0x0, 0x1) = 3 0
fstat64(0x3, 0x7FFF622FE5B0, 0x0) = 0 0
fcntl(0x3, 0x32, 0x7FFF622FE830) = 0 0
close(0x3) = 0 0
stat64("/Users/ossareh/dev/personal/practice/ansi_c/ch1/s5\0", 0x7FFF622FE520, 0x0) = 0 0
issetugid(0x7FFF6233A530, 0x7FFF622FED68, 0x7FFF6233A530) = 0 0
csops(0x0, 0x0, 0x7FFF622FE80C) = 0 0
shared_region_check_np(0x7FFF622FC758, 0x2, 0x55) = 0 0
stat64("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x7FFF622FD920, 0x7FFF622FE810) = 0 0
open("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x0, 0x0) = 3 0
pread(0x3, "\312\376\272\276\0", 0x1000, 0x0) = 4096 0
pread(0x3, "\317\372\355\376\a\0", 0x1000, 0x1000) = 4096 0
mmap(0x102703000, 0x2000, 0x5, 0x12, 0x3, 0x100001F) = 0x2703000 0
mmap(0x102705000, 0x1000, 0x3, 0x12, 0x3, 0x100001F) = 0x2705000 0
mmap(0x102706000, 0x1F10, 0x1, 0x12, 0x3, 0x100001F) = 0x2706000 0
close(0x3) = 0 0
stat64("/usr/lib/libSystem.B.dylib\0", 0x7FFF622FD760, 0x7FFF622FE5E0) = 0 0
stat64("/usr/lib/system/libcache.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libcommonCrypto.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libcompiler_rt.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libcopyfile.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libdispatch.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libdnsinfo.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libdyld.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libkeymgr.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/liblaunch.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libmacho.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libmathCommon.A.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libquarantine.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libremovefile.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libsystem_blocks.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libsystem_c.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libsystem_dnssd.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libsystem_info.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libsystem_kernel.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libsystem_network.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libsystem_notify.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libsystem_sandbox.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libunc.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libunwind.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
stat64("/usr/lib/system/libxpc.dylib\0", 0x7FFF622FD460, 0x7FFF622FE2E0) = 0 0
getpid(0x7FFF622FE628, 0x102702004, 0xEA60) = 12890 0
getrlimit(0x1008, 0x7FFF622FEB70, 0xFFFFFFFF) = 0 0
fstat64(0x0, 0x7FFF622FEAD8, 0x7FFF622FEB9C) = 0 0
ioctl(0x0, 0x4004667A, 0x7FFF622FEB74) = 0 0
mmap(0x7FD4E1400000, 0x1000000, 0x3, 0x1002, 0x2000000, 0x6) = 0xE1500000 0
munmap(0x7FD4E1500000, 0x300000) = 0 0
munmap(0x7FD4E2000000, 0x500000) = 0 0
open("/dev/dtracehelper\0", 0x2, 0xFFFFFFFFFFFFFFE8) = 3 0
ioctl(0x3, 0x80086804, 0x7FFF622FE6A8) = 0 0
close(0x3) = 0 0
stat64("/usr/lib/libstdc++.6.dylib\0", 0x7FFF622FD750, 0x7FFF622FE5D0) = 0 0
stat64("/usr/lib/libc++abi.dylib\0", 0x7FFF622FD660, 0x7FFF622FE4E0) = 0 0
__sysctl(0x7FFF622FE21C, 0x2, 0x7FFF622FE208) = 0 0
bsdthread_register(0x7FFF8A8A5B68, 0x7FFF8A8A5B78, 0x2000) = 0 0
thread_selfid(0x7FFF8A8A5B68, 0x7FFF8A8A5B78, 0x0) = 385348 0
mmap(0x0, 0x2000, 0x3, 0x1002, 0x1000000, 0x4) = 0x2708000 0
mprotect(0x102708000, 0x88, 0x1) = 0 0
mmap(0x0, 0x17000, 0x3, 0x1002, 0x1000000, 0x6) = 0x270A000 0
mprotect(0x10270A000, 0x1000, 0x0) = 0 0
mprotect(0x102720000, 0x1000, 0x0) = 0 0
mmap(0x0, 0x17000, 0x3, 0x1002, 0x1000000, 0x6) = 0x2721000 0
mprotect(0x102721000, 0x1000, 0x0) = 0 0
mprotect(0x102737000, 0x1000, 0x0) = 0 0
mmap(0x0, 0x1000, 0x3, 0x1002, 0x1000000, 0x6) = 0x2738000 0
mprotect(0x102738000, 0x1000, 0x1) = 0 0
mprotect(0x102708000, 0x88, 0x3) = 0 0
mmap(0x7FD4F1400000, 0x200000, 0x3, 0x1002, 0x7000000, 0x6) = 0x2739000 0
munmap(0x102739000, 0xC7000) = 0 0
munmap(0x102900000, 0x39000) = 0 0
mprotect(0x102708000, 0x88, 0x1) = 0 0
getpid(0x7FFF622FE054, 0x3, 0x1) = 12890 0
__mac_syscall(0x7FFF86AC47FE, 0x2, 0x7FFF622FE0A0) = 0 0
stat64("/AppleInternal\0", 0x7FFF622FE108, 0x0) = -1 Err#2
audit_session_self(0x7FFF622FDE58, 0xFFFFFFFFFFFFFFFC, 0x4) = 5379 0
geteuid(0x7FFF622FDE58, 0xFFFFFFFFFFFFFFFC, 0x0) = 0 0
getegid(0x7FFF622FDE58, 0xFFFFFFFFFFFFFFFC, 0x0) = 0 0
getaudit_addr(0x7FFF622FE0A0, 0x30, 0x0) = 0 0
csops(0x325A, 0x7, 0x7FFF622FDCD0) = 0 0
mmap(0x0, 0x2000, 0x3, 0x1002, 0x1000000, 0x14) = 0x2739000 0
mprotect(0x102739000, 0x88, 0x1) = 0 0
mmap(0x0, 0x17000, 0x3, 0x1002, 0x1000000, 0x6) = 0x273B000 0
mprotect(0x10273B000, 0x1000, 0x0) = 0 0
mprotect(0x102751000, 0x1000, 0x0) = 0 0
mmap(0x0, 0x17000, 0x3, 0x1002, 0x1000000, 0x6) = 0x2752000 0
mprotect(0x102752000, 0x1000, 0x0) = 0 0
mprotect(0x102768000, 0x1000, 0x0) = 0 0
mprotect(0x102738000, 0x1000, 0x3) = 0 0
mprotect(0x102738000, 0x1000, 0x1) = 0 0
mprotect(0x102739000, 0x88, 0x3) = 0 0
mmap(0x7FD4E1400000, 0x200000, 0x3, 0x1002, 0x7000000, 0x7) = 0xE1400000 0
munmap(0x7FD4E1500000, 0x100000) = 0 0
mprotect(0x102739000, 0x88, 0x1) = 0 0
read_nocancel(0x0, "a\n\0", 0x1000) = 2 0
fstat64(0x1, 0x7FFF622FEAE8, 0x7FFF622FEBAC) = 0 0
ioctl(0x1, 0x4004667A, 0x7FFF622FEB84) = 0 0
write_nocancel(0x1, "a\n\0", 0x2) = 2 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment