This is an automated email from the ASF dual-hosted git repository.

changchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new a0378b759f [CH][Doc] Add Gluten CH Debug docs. (#7846)
a0378b759f is described below

commit a0378b759f86176c7bd2b3c9a68ed7daf9c148e3
Author: Wenzheng Liu <[email protected]>
AuthorDate: Fri Nov 8 15:32:45 2024 +0800

    [CH][Doc] Add Gluten CH Debug docs. (#7846)
---
 docs/developers/clickhouse-backend-debug.md        |  98 +++++++++++++++++++++
 docs/image/ClickHouse/gluten-debug-build-libch.png | Bin 0 -> 224526 bytes
 docs/image/ClickHouse/gluten-debug-clion-debug.png | Bin 0 -> 290162 bytes
 .../ClickHouse/gluten-debug-clion-toolchains.png   | Bin 0 -> 164977 bytes
 docs/image/ClickHouse/gluten-debug-cmake-debug.png | Bin 0 -> 254090 bytes
 .../image/ClickHouse/gluten-debug-cmake-reload.png | Bin 0 -> 412031 bytes
 docs/image/ClickHouse/gluten-debug-idea-config.png | Bin 0 -> 226892 bytes
 .../ClickHouse/gluten-debug-profile-settings.png   | Bin 0 -> 28429 bytes
 .../image/ClickHouse/gluten-debug-program-args.png | Bin 0 -> 175558 bytes
 9 files changed, 98 insertions(+)

diff --git a/docs/developers/clickhouse-backend-debug.md 
b/docs/developers/clickhouse-backend-debug.md
new file mode 100644
index 0000000000..13799ac2cb
--- /dev/null
+++ b/docs/developers/clickhouse-backend-debug.md
@@ -0,0 +1,98 @@
+---
+layout: page
+title: Debug CH Backend
+nav_order: 13
+has_children: true
+parent: /developer-overview/
+---
+
+# Debug CH Backend
+
+## Debug Java/Scala Code with IntelliJ IDEA
+
+1. Build Gluten ClickHouse Native Lib.
+   ```
+   export CMAKE_BUILD_TYPE=Release && bash 
ep/build-clickhouse/src/build_clickhouse.sh
+   ```
+   libch.so will be generated in 
`cpp-ch/build/utils/extern-local-engine/libch.so`.
+
+2. Maven Build Gluten ClickHouse with Profile
+   ```
+   mvn clean install -DskipTests -Pbackends-clickhouse -Pspark-3.3 -Pspark-ut
+   ```
+   
+3. Set Maven Profiles in IntelliJ IDEA
+
+   
![gluten-debug-profile-settings.png](../image/ClickHouse/gluten-debug-profile-settings.png)
+
+4. Set Debug Configuration in IntelliJ IDEA
+
+   For example, debug GlutenMathExpressionsSuite.
+   
![gluten-debug-idea-config.png](../image/ClickHouse/gluten-debug-idea-config.png)
+
+   VM Options: 
+   `-Dtpcds.data.path=/data/tpcds-data-sf1 
-Dclickhouse.lib.path=/path/to/gluten/cpp-ch/build/utils/extern-local-engine/libch.so
 -Dspark.test.home=/path/to/spark33`
+   > Download tpcds-data in https://gluten-nginx.kyligence.com/dataset/
+   > Download spark33 using `git clone --depth 1 --branch v3.3.1 
https://github.com/apache/spark.git /tmp/spark33`
+   
+   Environment Variables: 
+   
`LD_PRELOAD=/path/to/gluten/cpp-ch/build/utils/extern-local-engine/libch.so:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/amd64/libjsig.so`
+
+## Debug Native Code with CLion
+
+1. Toolchains Settings
+
+   
![gluten-debug-clion-toolchains](../image/ClickHouse/gluten-debug-clion-toolchains.png)
+   > Some Clion versions have not supported lldb-18, you can manually set 
refer to [CLion Custom 
LLDB](https://youtrack.jetbrains.com/issue/CPP-3589/Support-using-custom-LLDB). 
Or you can use gdb as default.
+
+2. CMake Debug Configuration
+
+   
![gluten-debug-clion-debug](../image/ClickHouse/gluten-debug-clion-debug.png)
+
+   CMake Options: 
+   `-DENABLE_PROTOBUF=ON -DENABLE_TESTS=OFF -DENABLE_BENCHMARKS=ON 
-DENABLE_JEMALLOC=ON -DENABLE_MULTITARGET_CODE=ON 
-DENABLE_EXTERN_LOCAL_ENGINE=ON -DENABLE_ODBC=OFF -DENABLE_CAPNP=OFF 
-DENABLE_ROCKSDB=OFF -DENABLE_GRPC=OFF -DENABLE_RUST=OFF -DENABLE_H3=OFF 
-DENABLE_AMQPCPP=OFF -DENABLE_CASSANDRA=OFF -DENABLE_KAFKA=OFF 
-DENABLE_NATS=OFF -DENABLE_LIBPQXX=OFF -DENABLE_NURAFT=OFF 
-DENABLE_DATASKETCHES=OFF -DENABLE_SQLITE=OFF -DENABLE_S2_GEOMETRY=OFF 
-DENABLE_ANNOY=OFF -DENABLE_ULID=OFF -DE [...]
+
+3. Reload CMake Project
+
+   
![gluten-debug-cmake-reload](../image/ClickHouse/gluten-debug-cmake-reload.png)
+
+   After reload cmake projects, you can find target `libch` in run 
configurations.
+
+4. Build `libchd.so` with Debug Mode
+
+   
![gluten-debug-build-libch](../image/ClickHouse/gluten-debug-build-libch.png)
+
+   `libchd.so` will be generated in 
`cmake-build-debug/utils/extern-local-engine/libchd.so`.
+
+5. Create File `.gdbinit` and `.lldbinit` to Avoid Unused Signal
+
+   vi ~/.gdbinit
+   ```
+   handle SIGSEGV nostop noprint
+
+   set print pretty on
+   set print object on
+   python
+   import sys
+   sys.path.insert(0, '/path/to/libcxx-pretty-printers/src')
+   from libcxx.v1.printers import register_libcxx_printers
+   register_libcxx_printers(None)
+   end
+   ```
+   > Download libcxx-pretty-printers in 
https://github.com/koutheir/libcxx-pretty-printers
+   
+   vi ~/.lldbinit
+   ```
+   process handle -n true -p true -s false SIGBUS SIGSEGV
+   ```
+   
+6. Debug Application
+
+   
![gluten-debug-cmake-debug.png](../image/ClickHouse/gluten-debug-cmake-debug.png)
+
+   Executable: `/path/to/java`
+
+   Program Arguments: Copy from IntelliJ IDEA debug command line and remove 
`-javaagent`
+   
![gluten-debug-program-args.png](../image/ClickHouse/gluten-debug-program-args.png)
+
+
diff --git a/docs/image/ClickHouse/gluten-debug-build-libch.png 
b/docs/image/ClickHouse/gluten-debug-build-libch.png
new file mode 100644
index 0000000000..4cf914dc8b
Binary files /dev/null and b/docs/image/ClickHouse/gluten-debug-build-libch.png 
differ
diff --git a/docs/image/ClickHouse/gluten-debug-clion-debug.png 
b/docs/image/ClickHouse/gluten-debug-clion-debug.png
new file mode 100644
index 0000000000..e217eff097
Binary files /dev/null and b/docs/image/ClickHouse/gluten-debug-clion-debug.png 
differ
diff --git a/docs/image/ClickHouse/gluten-debug-clion-toolchains.png 
b/docs/image/ClickHouse/gluten-debug-clion-toolchains.png
new file mode 100644
index 0000000000..a90e474463
Binary files /dev/null and 
b/docs/image/ClickHouse/gluten-debug-clion-toolchains.png differ
diff --git a/docs/image/ClickHouse/gluten-debug-cmake-debug.png 
b/docs/image/ClickHouse/gluten-debug-cmake-debug.png
new file mode 100644
index 0000000000..3c050328c4
Binary files /dev/null and b/docs/image/ClickHouse/gluten-debug-cmake-debug.png 
differ
diff --git a/docs/image/ClickHouse/gluten-debug-cmake-reload.png 
b/docs/image/ClickHouse/gluten-debug-cmake-reload.png
new file mode 100644
index 0000000000..40d2c77758
Binary files /dev/null and 
b/docs/image/ClickHouse/gluten-debug-cmake-reload.png differ
diff --git a/docs/image/ClickHouse/gluten-debug-idea-config.png 
b/docs/image/ClickHouse/gluten-debug-idea-config.png
new file mode 100644
index 0000000000..112b0d3fbd
Binary files /dev/null and b/docs/image/ClickHouse/gluten-debug-idea-config.png 
differ
diff --git a/docs/image/ClickHouse/gluten-debug-profile-settings.png 
b/docs/image/ClickHouse/gluten-debug-profile-settings.png
new file mode 100644
index 0000000000..b2b7a8451d
Binary files /dev/null and 
b/docs/image/ClickHouse/gluten-debug-profile-settings.png differ
diff --git a/docs/image/ClickHouse/gluten-debug-program-args.png 
b/docs/image/ClickHouse/gluten-debug-program-args.png
new file mode 100644
index 0000000000..bc6475511f
Binary files /dev/null and 
b/docs/image/ClickHouse/gluten-debug-program-args.png differ


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to