开发者

Is it possible to accelerate debugging with GDB?

开发者 https://www.devze.com 2022-12-24 17:37 出处:网络
I am debugging with GDB a crunching number C++ program. I开发者_如何学编程t takes 10 minutes till I reach the interesting function to be debugged. Then I inspect variables, understand parts of the pro

I am debugging with GDB a crunching number C++ program. I开发者_如何学编程t takes 10 minutes till I reach the interesting function to be debugged. Then I inspect variables, understand parts of the program and recompile again, and run again GDB till I reach the point again.

This procedure is sometimes a bit time consuming. I wonder if somehow can be accelerated. Any ideas?

Thanks


You definitely can't have your compiler optimize the code to make it run faster before running GDB. Have you written good unit tests? Having a decent test suite might save you considerable time and prevent you from spending undue amount in the debugger.


there are gdb canned instruction(a sort of minilanguage where you automate the debugging process). and there are also python bindings that can help you automate gdb. debugging should be last resort, you should write tests instead or think more about what you write, this would speed up the deubgging process considerably(as you would probably not need to debug anymore, or very seldom).


Write tests which run the interesting function with various inputs. Then you can debug the function without having to worry about the rest of the code.


Have you tried UndoDB: http://undo-software.com/

It allows you to step back and forth - reversible debugging. While gdb has it's own reversible debugging these days, running in that mode has massive slowdown -- 20,000x or worse. UndoDB will run with about 1.7x slow-down, so you can quickly get to the interesting part, and then step back and forth to home in on your bug.

(Disclosure: I work for Undo Software)


Under GNU/Linux, you can also try:

checkpoint
...
restore n

if your program is not multithreaded (checkpoint uses internally fork(), so the same limitations apply).

It should same you the 10min you need to reach the beginning of your debugging!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号