6

I compile the c++ project, which is not too large, about 6M binary. When I debug it and want to print some variable, I type the first two characters and press the Tab to complete. Then the gdb read symbols forever freezing. How can I solve this problem. thank you!

JunWangCas
  • 89
  • 1
  • 7

2 Answers2

3

I type the first two characters and press the Tab to complete. Then the gdb read symbols forever freezing. How can I solve this problem

Doctor, it hurts when I do that.

Well, don't do that.

Seriously, if you have a very large binary (it's unclear whether your 6MB is the size with debug info or without), and lots of variables, then GDB will necessarily have to spend some time searching for variables matching your two initial characters.

That said,

  • we routinely debug binaries that are 2GB in size or larger, and
  • have spent quite a lot of effort improving GDB experience with such binaries

So perhaps your first step should be to take the latest release of GDB, and see if the problem has already been solved for you.

Update:

My binary is 6MB with debug info

That's not large at all. Certainly it should not cause more than a few seconds delay to list all variables in such a binary.

My GDB version is "GNU gdb (GDB) 7.6.2"

That's the latest release.

It's probably safe to conclude that there is a bug in GDB.

If you can construct a minimal test case that shows the problem, then your best bet is to report it as a bug in http://sourceware.org/bugzilla.

If you can't, you'll have to debug GDB yourself. A reasonable place to start is running strace -p <pid-of-hung-gdb> and gdb -p <pid-of-hung-gdb>; (gdb) where to find out exactly where GDB is getting stuck.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • My binary is 6MB with debug info and I also think this is not a big project. The problem occur again, even without press Tab key, I just type "print some variable". and the terminal says:" Reading in symbols for sdk/segment/cpcidskapmodel.cpp...done.", freezing.(I set verbose on before). I cannot understand what the sdk/segment/cpcidskapmodel.cpp is, which is not my project files. My GDB version is "GNU gdb (GDB) 7.6.2"; – JunWangCas Jan 06 '14 at 02:52
  • More seriously, I cannot interrupt it and have to kill the gdb process. – JunWangCas Jan 06 '14 at 03:10
1

If you can update to GDB 7.10, your tab-completion freeze-ups should disappear.

GDB 7.10 (as of August 2015) contains a feature to address this problem.

set max-completions

Set the maximum number of candidates to be considered during completion. The default value is 200. This limit allows GDB to avoid generating large completion lists, the computation of which can cause the debugger to become temporarily unresponsive.

[The above quote is taken from the patch shown on the gitweb site for gdb]

The GDB news release lists the feature as: "The number of candidates to be considered during completion can now be limited."

Updating to GDB 7.10 solved the problem for me. The default value of 200 for max-completions was sufficient. I did not customize it.

pestophagous
  • 4,069
  • 3
  • 33
  • 42