aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2014-04-16 14:20:19 -0700
committerKeith Seitz <keiths@redhat.com>2014-04-16 14:20:19 -0700
commitc4f87ca6dbe041e2a331e5054a76c9134f29d545 (patch)
tree40f41bd7fc91b39debea57804458d7d7b1e41696 /gdb
parentfe28be73c7c22cc6eb1c3573f1be65c75e37d9b7 (diff)
downloadgdb-c4f87ca6dbe041e2a331e5054a76c9134f29d545.zip
gdb-c4f87ca6dbe041e2a331e5054a76c9134f29d545.tar.gz
gdb-c4f87ca6dbe041e2a331e5054a76c9134f29d545.tar.bz2
PR c++/16597
[forgot to commit/push these with previous push] If lookup_symbol_file tries to locate a member variable with NULL name: /* A simple lookup failed. Check if the symbol was defined in a base class. */ cleanup = make_cleanup (null_cleanup, NULL); /* Find the name of the class and the name of the method, variable, etc. */ prefix_len = cp_entire_prefix_len (name); /* If no prefix was found, search "this". */ if (prefix_len == 0) { struct type *type; struct symbol *this; this = lookup_language_this (language_def (language_cplus), block); if (this == NULL) { do_cleanups (cleanup); return NULL; } type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this))); klass = xstrdup (TYPE_NAME (type)); nested = xstrdup (name); } TYPE_NAME (type) is NULL, so xstrdup (NULL) and boom! This can happen, e.g., with clang++. See testsuite/gdb.cp/namelessclass.exp or the bugzilla report. This patch simply adds a fencepost against this case, allowing the caller of lookup_symbol_file to search other blocks for the right symbol.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/cp-namespace.c5
-rw-r--r--gdb/testsuite/ChangeLog7
3 files changed, 18 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cbd3a77..cd35011 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2014-04-16 Keith Seitz <keiths@redhat.com>
+
+ PR c++/16597
+ * cp-namespace.c (lookup_symbol_file): If the type name of
+ `this' is NULL, return immediately.
+
2014-04-14 Keith Seitz <keiths@redhat.com>
PR c++/16253
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 1085556..ae7c852 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -694,6 +694,11 @@ lookup_symbol_file (const char *name,
}
type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
+ /* If TYPE_NAME is NULL, abandon trying to find this symbol.
+ This can happen for lambda functions compiled with clang++,
+ which outputs no name for the container class. */
+ if (TYPE_NAME (type) == NULL)
+ return NULL;
klass = xstrdup (TYPE_NAME (type));
nested = xstrdup (name);
}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 7c7bd34..a7e7dcb 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2014-04-16 Keith Seitz <keiths@redhat.com>
+
+ PR c++/16597
+ * gdb.cp/namelessclass.cc: New file.
+ * gdb.cp/namelessclass.exp: New file.
+ * gdb.cp/namelessclass.S: New file.
+
2014-04-16 Doug Evans <dje@google.com>
* lib/gdbserver-support.exp (gdbserver_default_get_remote_address):