Skip to content
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

Development/debugging advice? Struggling to use gdb to debug clboss #206

Open
sj-fisher opened this issue May 22, 2024 · 4 comments
Open

Comments

@sj-fisher
Copy link

sj-fisher commented May 22, 2024

Is there any documentation on this which I've missed?

I am trying to use gdb to debug clboss but I'm getting tied up in knots. I'm probably doing something really stupid, but I can't get it to work.

I see there is a --debugger command line option to clboss. The only way I can find to persuade c-lightning to start the clboss plugin with this option is to use a wrapper script:

#!/bin/bash
cd $HOME/src/clboss
./clboss --debugger $*

and then tell lightning-cli to start that wrapper:

$ lightning-cli plugin start `pwd`/debug-wrap.sh

This fires up a terminal with gdb attached to clboss, but (even though as far as I can tell the paths are correct) it doesn't seem to be able to find the source, e.g.

(gdb) list Boss/Mod/OnchainFundsIgnorer.cpp:30
No source file named Boss/Mod/OnchainFundsIgnorer.cpp.
(gdb) shell
$ ls -l Boss/Mod/OnchainFundsIgnorer.cpp
-rw-rw-r-- 1 steve steve 6353 May 20 17:57 Boss/Mod/OnchainFundsIgnorer.cpp

I also seem to be struggling to step through the code because the event framework is constantly receiving SIGSTOP signals, but this may be normal or may be a side effect of these other problems.

As far as I can tell my clboss executable does have debug symbols - "objdump --syms clboss | c++filt" shows lots of clboss symbols. Do I need to pass some special arguments to the configure script to get proper symbols?

If there's any interest, I'm happy to write up a starter "how to work with clboss for developers" document once I know how to do it myself.

Any advice would be appreciated, thanks!

(For what it's worth, one of my local code changes is making clboss crash on startup and I'm trying to debug that. But I have temporarily reverted back to the upstream clboss code while I figure out how to use the debugger with clboss, so unless I made a mistake that shouldn't be the problem here.)

It feels a bit like I'm abusing the issues section by asking this question here, if there's somewhere else to ask this kind of thing please let me know.

@sj-fisher
Copy link
Author

I've had some luck with the debugging symbols by running configure like this:

CPPFLAGS=-g LDFLAGS=-g ./configure --enable-debug

I don't know if some of that is unnecessary, but it does seem to be working. I am currently fighting with the "can't debug properly for all the SIGSTOP signals" problem, so I haven't got that much further and it may be the debug symbols are still wrong/incomplete somehow.

@sj-fisher
Copy link
Author

The magic gdb incantation for the SIGSTOP problems appears to be:

handle SIGSTOP nostop

I now have a backtrace on a SEGV. It's an incomprehensible C++ backtrace, but it's progress. :-)

@ksedgwic
Copy link
Collaborator

Check out c++filt for demangling the symbols

@sj-fisher
Copy link
Author

Thanks! I think gdb is doing that automatically - they were just incomprehensible because of all the templates, not because they were mangled. :-) But I am slowly getting to grips with things and making what feels like progress on my prototype for #202.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants