Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Debugging tutorial #632

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Install Crystal and get it running.
Introductory courses for beginners and advanced learners.

* [Basics](tutorials/basics/README.md)
* [Debugging](tutorials/debugging/README.md)

</div>
<div class="card" markdown="1">
Expand Down
3 changes: 3 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,6 @@
* [Strings](tutorials/basics/40_strings.md)
* [Control Flow](tutorials/basics/50_control_flow.md)
* [Methods](tutorials/basics/60_methods.md)
* [Debugging](tutorials/debugging/README.md)
* [Debuggers](tutorials/debugging/10_debuggers.md)
* [Caveats](tutorials/debugging/20_caveats.md)
6 changes: 6 additions & 0 deletions docs/tutorials/debugging/10_debuggers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Debuggers

## Tools

* [GDB](https://www.sourceware.org/gdb/)
* [LLDB](https://lldb.llvm.org/)
19 changes: 19 additions & 0 deletions docs/tutorials/debugging/20_caveats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Caveats

## Segmentation Fault During GC Initialization

It is generally safe to ignore `SIGSEGV` during startup of a Crystal program. This is intended behavior; see the [Debugging](https://hboehm.info/gc/debugging.html) documentation of Crystal's [GC library](https://hboehm.info/gc/).

### Mitigation

Automatically ignore this segmentation fault with breakpoints:

<!-- TODO: GDB mitigation instructions -->

#### LLDB


```
breakpoint set -n main -G true -o true -C 'process handle -s false -n false SIGSEGV SIGBUS'
breakpoint set -n __crystal_main -G true -o true -C 'process handle -s true -n true SIGSEGV SIGBUS'
```
8 changes: 8 additions & 0 deletions docs/tutorials/debugging/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Debugging

This course targets experienced Crystal programmers and discusses common tools and methods to debug your Crystal code.

Contents:

* [Debuggers](10_debuggers.md) – Introduction to common debugging tools compatible with Crystal
* [Caveats](20_caveats.md) – Gotchas and limitations when debugging Crystal code