From 41ffe1ecdd4befd33c80d6fedc8e1a701958dcfe Mon Sep 17 00:00:00 2001 From: konstin Date: Mon, 4 Mar 2019 23:17:48 +0100 Subject: [PATCH] Add notes about the c api and stacktraces to the guide --- guide/src/SUMMARY.md | 1 + guide/src/advanced.md | 7 +++++++ guide/src/debugging.md | 9 +++++++++ 3 files changed, 17 insertions(+) create mode 100644 guide/src/advanced.md diff --git a/guide/src/SUMMARY.md b/guide/src/SUMMARY.md index 24bc9689..64515c6e 100644 --- a/guide/src/SUMMARY.md +++ b/guide/src/SUMMARY.md @@ -8,5 +8,6 @@ - [Python Class](class.md) - [Parallelism](parallelism.md) - [Debugging](debugging.md) +- [Advanced Topics](advanced.md) - [Building and Distribution](building-and-distribution.md) - [Appendix: Pyo3 and rust-cpython](rust-cpython.md) diff --git a/guide/src/advanced.md b/guide/src/advanced.md new file mode 100644 index 00000000..7c47505a --- /dev/null +++ b/guide/src/advanced.md @@ -0,0 +1,7 @@ +# Advanced topics + +## ffi + +pyo3 exposes much of python's c api through the `ffi`. + +The c api is naturually unsafe and requires you to manage reference counts, errors and specific invariants yourself. Please refer to the [C API Reference Manual](https://docs.python.org/3/c-api/) and [The Rustonomicon](https://doc.rust-lang.org/nightly/nomicon/ffi.html) before using any function from that api. \ No newline at end of file diff --git a/guide/src/debugging.md b/guide/src/debugging.md index b268a155..c1699922 100644 --- a/guide/src/debugging.md +++ b/guide/src/debugging.md @@ -29,3 +29,12 @@ Activate an environment with the debug interpreter and recompile. If you're on l [Download the suppressions file for cpython](https://raw.githubusercontent.com/python/cpython/master/Misc/valgrind-python.supp). Run valgrind with `valgrind --suppressions=valgrind-python.supp ./my-command --with-options` + +## Getting a stacktrace + +The best start to investigate a crash such as an segmentation fault is a backtrace. + + * Link against a debug build of python as described in the previous chapter + * Run `gdb ` + * Enter `r` to run + * After the crash occured, enter `bt` or `bt full` to print the stacktrace \ No newline at end of file