From ae68c6b548c59438f447a282b8477a019f8783ee Mon Sep 17 00:00:00 2001 From: Navin Kumar <97137715+NVnavkumar@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:22:55 -0800 Subject: [PATCH] Add docs for how to add debug symbols [skip ci] (#1575) * Add documentation on how to add debug symbols and debug spark-rapids-jni C++ code. Signed-off-by: Navin Kumar * Address feedback Signed-off-by: Navin Kumar --------- Signed-off-by: Navin Kumar --- CONTRIBUTING.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c230cf1c69..628fa410eb5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -259,6 +259,39 @@ class NormalCaseTest { } ``` +### Debugging +You can add debug symbols selectively to C++ files in spark-rapids-jni by modifying the appropriate +`CMakeLists.txt` files. You will need to add a specific flag depending on what kind of code you are +debugging. For CUDA code, you need to add the `-G` flag to add device debug symbols: + +```cmake +set_source_files_properties(src/row_conversion.cu PROPERTIES COMPILE_OPTIONS "-G") +``` + +For C++ code, you will need to add the `-g` flag to add host debug symbols. + +```cmake +set_source_files_properties(row_conversion.cpp PROPERTIES COMPILE_OPTIONS "-G") +``` + +For debugging C++ tests, you need to add both device debug symbols to the CUDA kernel files involved +in testing (in `src/main/cpp/CMakeLists.txt`) **and** host debug symbols to the CPP files used for +testing (in `src/main/cpp/tests/CMakeLists.txt`). + +You can then use `cuda-gdb` to debug the gtest (NOTE: For Docker, run an interactive shell first and +then run `cuda-gdb`. You do not necessarily need to run `cuda-gdb` in Docker): + +```bash +./build/run-in-docker +bash-4.2$ cuda-gdb target/cmake-build/gtests/ROW_CONVERSION +``` + +You can also use the [NVIDIA Nsight VSCode Code Integration](https://docs.nvidia.com/nsight-visual-studio-code-edition/cuda-debugger/index.html) +as well to debug within Visual Studio Code. + +To debug libcudf code, please see [Debugging cuDF](thirdparty/cudf/CONTRIBUTING.md#debugging-cudf) +in the cuDF [CONTRIBUTING](thirdparty/cudf/CONTRIBUTING.md) guide. + ### Benchmarks Benchmarks exist for c++ benchmarks using NVBench and are in the `src/main/cpp/benchmarks` directory. To build these benchmarks requires the `-DBUILD_BENCHMARKS` build option. Once built, the benchmarks