GitXplorerGitXplorer
N

strace-little-book

public
255 stars
16 forks
0 issues

Commits

List of commits on branch master.
Verified
cb832782a3c9b475529a76843cbd9a755aa7ec9c

Create FUNDING.yml

NNanXiao committed 6 years ago
Unverified
8fdceda4b4d000058685b63646d3c7fd8e5d870e

Update publish_gitbook.sh

NNanXiao committed 6 years ago
Unverified
232a70ea76d7fe128de667e15fe238d75022a38f

Revert publish_gitbook.sh

NNanXiao committed 6 years ago
Unverified
31e7585321b4109b928db4037b9c012854bdd1ab

Update publish_gitbook.sh

NNanXiao committed 6 years ago
Unverified
605e11f1711dd562c492e526198e817ca56a4d22

Update publish_gitbook.sh

NNanXiao committed 6 years ago
Unverified
453667dfac727ce502d9d7dd41d8690a2f592571

Add .travis.yml

NNanXiao committed 6 years ago

README

The README file for this repository.

Strace little book

I like researching debugging techniques, so I decide to write this booklet to introduce strace. The following is the official definition of strace:

strace is a diagnostic, debugging and instructional userspace utility for Linux. It is used to monitor and tamper with interactions between processes and the Linux kernel, which include system calls, signal deliveries, and changes of process state.

System administrators, diagnosticians and trouble-shooters will find it invaluable for solving problems with programs for which the source is not readily available since they do not need to be recompiled in order to trace them.

The operation of strace is made possible by the kernel feature known as ptrace.

In one word, strace helps you know a process's activities between user-space and kernel-space. Let's check a simple example to get first impression of strace:

# strace ls
execve("/usr/bin/ls", ["ls"], 0x7ffe7727eec0 /* 20 vars */) = 0
brk(NULL)                               = 0x560a32cda000
arch_prctl(0x3001 /* ARCH_??? */, 0x7fff167898f0) = -1 EINVAL (Invalid argument)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=98317, ...}) = 0
mmap(NULL, 98317, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7face703c000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libcap.so.2", O_RDONLY|O_CLOEXEC) = 3
......

strace outputs all the syscalls' names, arguments, and return values. Very cool, isn't it? OK, let's begin our journey now.