-
Notifications
You must be signed in to change notification settings - Fork 495
chore(build, crashtracker): build w/ debug symbols #14286
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
Merged
Merged
Changes from all commits
Commits
Show all changes
104 commits
Select commit
Hold shift + click to select a range
70b1a33
build with debug symbol by default
taegyunkim bd0b38a
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim d01f289
strip debug symbols
taegyunkim a2ebbe9
strip symbols when not debug
taegyunkim 48d7d41
use -g
taegyunkim 9353a9e
ignore .debug files
taegyunkim 00ace36
ignore *.debug files
taegyunkim ddcaefb
strip debug symbols to .debug for libdd_wrapper
taegyunkim aa38f9d
update
taegyunkim 48c49bd
use hash
taegyunkim 46ce257
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim 2fc6965
--archs
taegyunkim f366bb5
Revert "update"
taegyunkim b5abe41
Revert "--archs"
taegyunkim c64d46f
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim 530091f
handle this later
taegyunkim edeb6ed
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim f4f199f
include debug symbols to be installed/packaged
taegyunkim d291bbd
extract debug symbols into separate zip files
taegyunkim 58da60c
set --output-dir
taegyunkim 18a7573
set versions for packages used
taegyunkim f3ef896
this is redundant
taegyunkim b95b0b5
compile C extensions and Cython extensions with debug symbols when Re…
taegyunkim 19e9cfa
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim d39714a
remove newline
taegyunkim 77ce358
specify audithweel versions
taegyunkim 81ef283
update
taegyunkim 0489f5b
extract debug symbols before auditwheel
taegyunkim e937f93
revert
taegyunkim 1ce1254
use auditwheel command
taegyunkim 8e6800d
dont generate debug file here
taegyunkim 093cc10
generate debug files before auditwheel and delocate-wheel to make sur…
taegyunkim ca9dee1
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim ffec034
fix docs build
taegyunkim 7bb1874
Merge branch 'taegyunkim/prof-12156-with-debug' of github.com:DataDog…
taegyunkim c4a068a
fix script for older python versions
taegyunkim a304967
keep the same directory structure
taegyunkim 43baefc
make sure to not strip these symbols
taegyunkim 0b66d1c
format
taegyunkim 8dbb8fa
copy over debugwheelhouse
taegyunkim 39665b3
Format code
taegyunkim 5cf1291
remove newlines
taegyunkim 0ed4e99
no need to include these, as theyre generated while auditing and delo…
taegyunkim 637524f
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim ba11f4f
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim 2690477
update dirs
taegyunkim db44478
create directory under {dest_dir}
taegyunkim 99641b2
fix for mac
taegyunkim c18f125
linux: put to /output container output dir, mac: dont move it to dest…
taegyunkim e10abf0
add comments
taegyunkim 5b2ee80
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim bf6f03c
only download wheels and source-dist
taegyunkim e6c6ac0
enable memalloc assertions only on Debug compile mode
taegyunkim 9bff627
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim e9c35d0
verify step
taegyunkim 543284e
fix lto options for appleclang
taegyunkim 8da48c9
fix lto
taegyunkim bd9a3e7
recursive copy for mac
taegyunkim 823b3fb
use in instead of startswith
taegyunkim 0bae713
format
taegyunkim 9c0bcff
use taegyunkim/dd-compile-release for serverless benchmarks
taegyunkim 70ca0fc
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim 357ad7e
strip debug symbol when release
taegyunkim 8f0d7b9
add debug print for compile mode
taegyunkim d7eaa71
fix typo
taegyunkim 5bb7ab4
update comment
taegyunkim e9d7fc2
Revive try_strip_symbols for minsizerel
taegyunkim 32ada00
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim 33495a0
Merge branch 'taegyunkim/prof-12156-with-debug' of github.com:DataDog…
taegyunkim ae5d0fc
remove debug print
taegyunkim e2d4f3c
update comments
taegyunkim 3c22db9
supply ignore pattern having libddwaf* by default
taegyunkim 3356d8d
macOS: error when no debug symbols
taegyunkim 3de37a2
Fail if no debug symbols
taegyunkim 20d7a62
Revert to use head DataDog/serverless-tools
taegyunkim 58cb4bf
fix typo
taegyunkim b74d4c2
update comments and dont strip rust binary from here
taegyunkim fe34d65
no need to set -g in linker options
taegyunkim e5dc580
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim f10708e
minimize diff
taegyunkim 4b8a645
minimize diff
taegyunkim 91321e5
update comment
taegyunkim 3dddf37
remove unnecessary changes
taegyunkim 2c79734
minimize diff and add comment
taegyunkim d1a2865
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim c1949ff
format
taegyunkim 81c4a02
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim 919326b
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim 8fbb5a5
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim 20bc06d
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim 6c9535e
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim d8f6e51
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim 8d651c7
update docs on how to set substitute-path
taegyunkim 8337a61
update with expected output
taegyunkim 27d04b4
proper code formatting
taegyunkim 377b630
code formatting
taegyunkim 8166378
inline formats
taegyunkim d0c5007
more inline
taegyunkim 0f51076
few more edits to docs
taegyunkim 238a525
lldb instructions
taegyunkim 0921930
this is still relevant to strip debug symbols from release build mode…
taegyunkim 4ae93b0
Merge branch 'main' into taegyunkim/prof-12156-with-debug
taegyunkim dccf04e
update comment
taegyunkim 76ca29c
Merge branch 'taegyunkim/prof-12156-with-debug' of github.com:DataDog…
taegyunkim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -195,3 +195,6 @@ tests/appsec/iast/fixtures/taint_sinks/not_exists.txt | |
| # .env file | ||
| .env | ||
| .envrc | ||
|
|
||
| *.debug | ||
| *.dSYM/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| Debugging Native Extensions with Debug Symbols | ||
| ============================================== | ||
|
|
||
| dd-trace-py is built with debug symbols by default, and packaged separately from the main wheel files to reduce the size of the primary distribution packages. | ||
|
|
||
| Debug Symbol Files | ||
| ------------------ | ||
|
|
||
| The project generates debug symbols during the build process: | ||
|
|
||
| - **Linux**: ``.debug`` files (using ``objcopy --only-keep-debug``) | ||
| - **macOS**: ``.dSYM`` bundles (using ``dsymutil``) | ||
|
|
||
| These debug symbols are extracted from the main wheels and packaged into separate `.zip` files with the naming convention: | ||
|
|
||
| :: | ||
|
|
||
| {original-wheel-name}-debug-symbols.zip | ||
|
|
||
| For example: | ||
|
|
||
| - ``ddtrace-1.20.0-cp39-cp39-linux_x86_64.whl`` → ``ddtrace-1.20.0-cp39-cp39-linux_x86_64-debug-symbols.zip`` | ||
| - ``ddtrace-1.20.0-cp39-cp39-macosx_10_9_x86_64.whl`` → ``ddtrace-1.20.0-cp39-cp39-macosx_10_9_x86_64-debug-symbols.zip`` | ||
|
|
||
| Build Process | ||
| ------------- | ||
|
|
||
| The debug symbols are handled automatically during the CI build process: | ||
|
|
||
| 1. Wheels are built with debug symbols included | ||
| 2. Debug symbols are extracted using the ``scripts/extract_debug_symbols.py`` script | ||
| 3. Debug symbols are removed from the main wheel to reduce size | ||
| 4. Separate debug symbol packages are created and uploaded as artifacts | ||
|
|
||
| Usage | ||
| ----- | ||
|
|
||
| To use debug symbols for debugging or crash analysis: | ||
|
|
||
| 1. Download the appropriate debug symbol package for your platform and Python version | ||
| 2. Extract the debug symbol files to the same directory as the corresponding `.so` files. | ||
| Typically, the site-packages directory where ddtrace is installed. | ||
| 3. Your debugger or crash analysis tool should automatically find the debug symbols | ||
taegyunkim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 4. To view assembly with code side by side, you also need the source code, and | ||
| set substitute paths in your debugger to the source code directory. For example, | ||
| for ``_stack_v2.cpython-313-x86_64-linux-gnu.so`` is compiled from | ||
| echion as specified in ``ddtrace/internal/datadog/profiling/stack_v2/CMakeLists.txt``. | ||
| So you first need to check out the echion repository and checkout the commit hash. | ||
| Then, set substitute paths in gdb to the echion source code directory. | ||
| Typically, if you run ``dias /m <symbol>`` in gdb, it will tell you the full | ||
| file path of the source code as the following: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| (gdb) disas /m Frame::read | ||
| Dump of assembler code for function _ZN5Frame4readEP19_PyInterpreterFramePS1_: | ||
| 269 /project/build/cmake.linux-x86_64-cpython-313/ddtrace.internal.datadog.profiling.stack_v2._stack_v2/_deps/echion-src/echion/frame.cc: No such file or directory. | ||
| 0x000000000000ece4 <+0>: push %r12 | ||
| 0x000000000000ece6 <+2>: mov %rdi,%r8 | ||
| 0x000000000000ece9 <+5>: push %rbp | ||
| 0x000000000000ecea <+6>: mov %rsi,%rbp | ||
| 0x000000000000eced <+9>: push %rbx | ||
| 0x000000000000ecee <+10>: sub $0x60,%rsp | ||
|
|
||
| 270 in /project/build/cmake.linux-x86_64-cpython-313/ddtrace.internal.datadog.profiling.stack_v2._stack_v2/_deps/echion-src/echion/frame.cc | ||
| 271 in /project/build/cmake.linux-x86_64-cpython-313/ddtrace.internal.datadog.profiling.stack_v2._stack_v2/_deps/echion-src/echion/frame.cc | ||
|
|
||
| Then you can set substitute paths in gdb to the echion source code directory | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| (gdb) set substitute-path /project/build/cmake.linux-x86_64-cpython-313/ddtrace.internal.datadog.profiling.stack_v2._stack_v2/_deps/echion-src/echion /path/to/echion/source/code | ||
|
|
||
| Run ``dias /m Frame::read`` again to see the assembly with code side by side. | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| (gdb) disas /m Frame::read | ||
| Dump of assembler code for function _ZN5Frame4readEP19_PyInterpreterFramePS1_: | ||
| warning: Source file is more recent than executable. | ||
| 269 { | ||
| 0x000000000000ece4 <+0>: push %r12 | ||
| 0x000000000000ece6 <+2>: mov %rdi,%r8 | ||
| 0x000000000000ece9 <+5>: push %rbp | ||
| 0x000000000000ecea <+6>: mov %rsi,%rbp | ||
| 0x000000000000eced <+9>: push %rbx | ||
| 0x000000000000ecee <+10>: sub $0x60,%rsp | ||
|
|
||
| 270 #if PY_VERSION_HEX >= 0x030b0000 | ||
| 271 _PyInterpreterFrame iframe; | ||
|
|
||
| 272 #if PY_VERSION_HEX >= 0x030d0000 | ||
| 273 // From Python versions 3.13, f_executable can have objects other than | ||
| 274 // code objects for an internal frame. We need to skip some frames if | ||
| 275 // its f_executable is not code as suggested here: | ||
| 276 // https://github.com/python/cpython/issues/100987#issuecomment-1485556487 | ||
| 277 PyObject f_executable; | ||
|
|
||
| 278 | ||
| 279 for (; frame_addr; frame_addr = frame_addr->previous) | ||
| 0x000000000000ecf7 <+19>: test %r8,%r8 | ||
| 0x000000000000ecfa <+22>: je 0xed91 <_ZN5Frame4readEP19_PyInterpreterFramePS1_+173> | ||
| 0x000000000000ed88 <+164>: mov 0x8(%rbx),%r8 | ||
| 0x000000000000ed8c <+168>: jmp 0xecf7 <_ZN5Frame4readEP19_PyInterpreterFramePS1_+19> | ||
|
|
||
| On lldb, you can find the source code full path by running ``image lookup -n Frame::read --verbose``, | ||
| and set the source code path using ``settings set target.source-map <expected-path> <actual-path>``. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.