diff --git a/docs/platforms/rust/common/source-context/index.mdx b/docs/platforms/rust/common/source-context/index.mdx new file mode 100644 index 00000000000000..6e7a174975e099 --- /dev/null +++ b/docs/platforms/rust/common/source-context/index.mdx @@ -0,0 +1,33 @@ +--- +title: Source Context +sidebar_order: 2400 +description: "Learn about showing your source code as part of stack traces." +--- + +## Prerequisites + +[Install](/cli/installation/) and [Configure](/cli/configuration/) Sentry CLI by providing an auth token, org and project. + +Then, enable full debug information for your release build: +```toml {filename:Cargo.toml} +[profiles.release] +debug = true +``` + +## Upload debug information files and source code + +Build the release binary, extract debug information and strip it from the binary: +```bash +cargo build --release +objcopy --only-keep-debug target/release/app{,.d} +objcopy --strip-debug --strip-unneeded target/release/app +objcopy --add-gnu-debuglink target/release/app{.d,} +``` + +If you don't want to strip the binary, you should disable the `debug-images` integration of the SDK, as otherwise you will run into the issue documented [here](https://github.com/getsentry/sentry-rust/issues/470#issuecomment-1472136215) which could cause duplicated frames to appear in your Sentry issues. + +Use Sentry CLI to upload debug information and source files: + +```bash +sentry-cli debug-files upload --include-sources . +```