How to debug the C++ code of sherpa-onnx? #1260
Replies: 7 comments 5 replies
-
Please build a debug version of sherpa-onnx. You can pass
to cmake. By the way, there is nothing special with sherpa-onnx. Everything is open-sourced. It is just plain C++. |
Beta Was this translation helpful? Give feedback.
-
Could you show the build logs? Just want to check you are indeed using a debug build. |
Beta Was this translation helpful? Give feedback.
-
Also, please show the file size of the binary you are debugging. |
Beta Was this translation helpful? Give feedback.
-
wow new baby |
Beta Was this translation helpful? Give feedback.
-
Sure, the binary I'm debugging is "sherpa-onnx/c-api-examples/decode-file-c-api". Its 24KB, but it's just a test program, and it calls for other shared libraries. |
Beta Was this translation helpful? Give feedback.
-
Did you guys had a different experience with debugging the code and printing the unique pointers? Did you use GDB or any other debugger? |
Beta Was this translation helpful? Give feedback.
-
Could you try It should work now.
|
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
I'm trying to debug the C++ sherpa-onnx code, and have difficulties printing the content of all "unique_ptr" objects, and there are plenty of them in the code (virtually every "important" object is referenced via a unique_ptr).
For example, I'm debugging the sherpa-onnx/c-api-examples/decode-file-c-api executable, and specifically focus on the function SherpaOnnxIsOnlineStreamReady.
When I step into it (after some additional step-in operations), I get to the code located here: sherpa-onnx/sherpa-onnx/csrc/online-recognizer.cc:219
bool OnlineRecognizer::IsReady(OnlineStream *s) const {
return impl_->IsReady(s);
}
However, when I try to print the content of s or impl_ via gdb (or lldb, it doesn't matter), I get the following:
219 return impl_->IsReady(s);
(gdb) print s
$3 = (struct OnlineStream *) 0x555555ddaa70
(gdb) print *s
$4 = {impl_ = {M_t = {M_t = {< No data fields >}}}}
(gdb) print impl
No symbol "impl" in current context.
I compiled the package as follows:
git clone https://github.com/k2-fsa/sherpa-onnx
cd sherpa-onnx
mkdir build
cd build
cmake
-DCMAKE_BUILD_TYPE=Debug
-DSHERPA_ONNX_ENABLE_PYTHON=ON
-DBUILD_SHARED_LIBS=ON
-DSHERPA_ONNX_ENABLE_CHECK=OFF
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF
-DSHERPA_ONNX_ENABLE_C_API=ON
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF
-DSHERPA_ONNX_ENABLE_GPU=ON
..
make -j
Does anyone have an idea, how can i print in gdb the content of objects referenced via unique_ptr? I tried looking over the internet, but didn't find a solution.
Maybe there is a better debugger that can do better?
Thanks!
Omar.
Beta Was this translation helpful? Give feedback.
All reactions