Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ process to generate a core file, and then use GDB to inspect it afterwards.
# Enable core dumps.
ulimit -c unlimited

# Ensure core dumps are written to a file.
# e.g. this is sometimes needed in Ubuntu to override the default behavior of
# piping the core file to the system crash handler.
echo core | sudo tee /proc/sys/kernel/core_pattern

# Run the simulation in which a process is crashing.
shadow shadow.yaml

Expand Down Expand Up @@ -79,10 +84,25 @@ $ gdb --pid=1234

### Debugging with GDB

In managed processes, Shadow uses `SIGSYS` and `SIGSEGV` to intercept system
calls and some CPU instructions. By default, GDB stops every time these signals
are raised. In most cases you'll want to override this behavior to silently
continue executing instead:

```
(gdb) handle SIGSYS noprint
(gdb) handle SIGSEGV noprint
```

Once you have reached a point of interest, it's often useful to look at the
backtrace for the current stack:

```
# It's often useful to look at the stack backtrace:
> bt
(gdb) bt
```

In multi-threaded applications, you can get a backtrace for all stacks:

# Or for a multi-threaded process, to look at all of the threads' backtraces:
> thread apply all bt
```
(gdb) thread apply all bt
```