gdb 7.6 can take tens of seconds to resolve symbols in C++

Bug #1178539 reported by Constantine Sapuntzakis
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
gdb
Unknown
Unknown
gdb (Ubuntu)
Fix Released
High
Unassigned

Bug Description

See http://sourceware.org/bugzilla/show_bug.cgi?id=15454
filed by me.

Reverting 677b1bf from the gdb git repository fixes the problem.

In this revision, gdb started searching the base classes for the symbol too. The algorithm seems to require optimization.

Meanwhile, the problem can be worked with a one-line diff that reverts the behavior to the pre-677b1bf. Attaching the patch

lsb_release -rd
Description: Ubuntu 13.04
Release: 13.04

gdb:
  Installed: 7.6~20130417-0ubuntu1
  Candidate: 7.6~20130417-0ubuntu1
  Version table:
 *** 7.6~20130417-0ubuntu1 0
        500 http://us.archive.ubuntu.com/ubuntu/ raring/main amd64 Packages
        100 /var/lib/dpkg/status

Tags: patch raring
Revision history for this message
In , Constantine Sapuntzakis (csapuntz) wrote :

Created attachment 7020
breakpoint trace

It takes minutes for GDB to find a symbol (vol::content_lh_key in this case) defined in a global namespace unless I prefix the symbol with ::

It seems to search for vol in the namespaces of all classes that the current class inherits from. This is ok, but it seems to repeat the search on the same symbol many times over.

I ran gdb against gdb and capture a bunch of stack traces during the symbol lookup. The file is attached.

break cp_lookup_symbol_in_namespace
silent
bt 4
print "\n\n"
cont
end

Revision history for this message
Constantine Sapuntzakis (csapuntz) wrote :
Revision history for this message
In , Constantine Sapuntzakis (csapuntz) wrote :

The following diff works around the problem for me by disabling lookup in base classes:

--- gdb-7.6~20130417/gdb/cp-namespace.c 2013-03-18 02:20:02.000000000 -0700
+++ gdb-7.6-mine/gdb/cp-namespace.c 2013-05-09 22:32:17.907659782 -0700
@@ -808,9 +808,7 @@
        if (sym != NULL)
          return sym;

- /* If no matching symbols were found, try searching any
- base classes. */
- return find_symbol_in_baseclass (parent_type, nested_name, block);
+ return NULL;
       }

     case TYPE_CODE_FUNC:

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Disable base class search" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
tags: added: raring
Changed in gdb:
importance: Unknown → Critical
status: Unknown → Confirmed
Revision history for this message
Brian Murray (brian-murray) wrote :

doko - could you take a look at this?

Changed in gdb (Ubuntu):
assignee: nobody → Matthias Klose (doko)
assignee: Matthias Klose (doko) → nobody
importance: Undecided → High
status: New → Triaged
Revision history for this message
In , Keiths-x (keiths-x) wrote :
Revision history for this message
Brian Murray (brian-murray) wrote :

The changes referenced in the following bug probably fixed this issue:

https://sourceware.org/bugzilla/show_bug.cgi?id=15519

Changed in gdb:
importance: Critical → Unknown
status: Confirmed → Unknown
Changed in gdb (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.