Debugging framework for C API functions

What is the recommended framework to debug XGboost’s C API functions?

For context, I’m trying to include custom node-splitting logic, but first I need to trace through the logic of XGBoosterUpdateOneIter defined in [src/c_api.cc]. To do so, I created a dummy.cc file that calls the function appropriately (following https://xgboost.readthedocs.io/en/stable/tutorials/c_api_tutorial.html) with the correct CMake debugging symbols.

From here, my first approach was to step in with lldb (I’m using M1 mac) but this outputs assembly code since XGBoosterUpdateOneIter is type XGB_DLL.

My second approach was to instead cast as follows in dummy.cc

auto* bst = static_cast<xgboost::Learner*>(booster);
auto *dtr = static_cast<std::shared_ptr<xgboost::DMatrix> *>(dmatrix);
bst -> UpdateOneIter(i, *dtr);

and just step into UpdateOneIter defined in [src/learner.cc]. Unfortunately, this also outputs assembly code:
frame #0: 0x000000010066386c libxgboost.dylib`xgboost::LearnerImpl::UpdateOneIter(int,
std::__1::shared_ptr<xgboost::DMatrix>)

Is there any method to trace line-by-line through XGBoost’s C API? I’m assuming that there must be a developer setup that allows this but I’m having trouble finding anything of the sort as of now.

I don’t know why you see assembly code though. I use gdb all the time.

I have a m1 so I’m using lldb. Since the c_api functions are DLL functions, it seems like the debugger is reading the binary files directly instead of the source code. Are you able to see the source code for UpdateOneIter in the learner.cc with gdb? If so, can you share your settings?

Yes, I use GDB to dubug both c++ tests and Python programs, the latter calls XGB functions through the use of C API. One thing you may look into is whether XGBoost is compiled with CXX symbol hidden. There’s an option in the CMake file under the repository root. I haven’t run into issue with debugger before (I used lldb before), I don’t know what to share. On Linux with GCC, one can also compile the code with an additional cxx flag -rdynamic to have additional rt info,.

I’ve checked the options in CMakeLists.txt and that doesn’t seem to be the issue… Sorry if this is repetitive but I just wanted to clarify, when you say “the latter calls XGB functions through the use of C API,” were you able to step through these specific C API functions?

I’m asking because I’m able to step through c++ tests and python programs, i just can’t access line-by-line the C API functions. Thanks for the help!