1

I want to debug an application in Linux. The application is created in C++. The GUI is created using QT. The GUI is linked with a static library that can be treated as the back end of the application.

I want to debug the static library but am not sure how to do that.

I tried using gdb

gdb GUI

But how can I attach the library?

Has anyone had experience in debugging libraries in linux?

5 Answers 5

7

gdb will automatically debug functions in the library when they are called. just call it like

gdb ./foo
run

:) . Be sure you build foo with debugging flags (-g3 will enable all debugging stuffs for gcc :). You should not optimize when debugging (pass at most -O1 to gcc, do not optimize further). It can confuse the debugger.

Sign up to request clarification or add additional context in comments.

Comments

5

If you want to debug the library code itself, you'll need to build the library with the -g compiler flag (as well as building the executable with -g as litb pointed out). Otherwise gdb will step through your code fine but will throw up its hands each time you make a library call.

Comments

2

You can Try KDbg, DDD - Data Display Debugger, Code::Blocks

Ulike DDD, others are IDE with debugger integrated but core debugger [gdb] remains same in those IDE. only thing is that you will get oragnized view of debugger view in GUI.

Also try Eclipse+CDT pluggin. it's also good.

Comments

1

A little-known alternative is gdbtui which uses a curses based interface.

Comments

0

You can also use Kdbg or ddd

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.