aboutsummaryrefslogtreecommitdiff
path: root/gdb/cp-namespace.c
diff options
context:
space:
mode:
authorDon Breazeal <donb@codesourcery.com>2016-03-15 15:18:28 -0700
committerDon Breazeal <donb@codesourcery.com>2016-03-15 15:25:15 -0700
commit1cafadb4e4eb329dea01355c6632b3077113d80c (patch)
tree2aa982ab01ff1f0649de210f67bdada496a42e0a /gdb/cp-namespace.c
parent79427bd2f8edb59110f16a9c1652e3d6e41e08e7 (diff)
downloadgdb-1cafadb4e4eb329dea01355c6632b3077113d80c.zip
gdb-1cafadb4e4eb329dea01355c6632b3077113d80c.tar.gz
gdb-1cafadb4e4eb329dea01355c6632b3077113d80c.tar.bz2
PR 18303, Tolerate malformed input for lookup_symbol-called functions
lookup_symbol is often called with user input. Consequently, any function called from lookup_symbol{,_in_language} should attempt to deal with malformed input gracefully. After all, malformed user input is not a programming/API error. This patch does not attempt to find/correct all instances of this. It only fixes locations in the code that trigger test suite failures. This patch fixes PR breakpoints/18303, "Assertion: -breakpoint-insert with windows paths of file in non-current directory". The patch includes three new tests related to this. One is just gdb.linespec/ls-errs.exp copied and converted to use C++ instead of C, and to add a case using a file name containing a Windows-style logical drive specifier. The others include an MI test to provide a regression test for the specific case reported in PR 18303, and a C++ test for proper error handling of access to a program variable when using a file scope specifier that refers to a non-existent file. Tested on x86_64 native Linux. gdb/ChangeLog 2016-01-28 Keith Seitz <keiths@redhat.com> PR breakpoints/18303 * cp-namespace.c (cp_lookup_bare_symbol): Change assertion to look for "::" instead of simply ":". (cp_search_static_and_baseclasses): Return null_block_symbol for malformed input. Remove assertions. * cp-support.c (cp_find_first_component_aux): Do not return a prefix length for ':' unless the next character is also ':'. gdb/testsuite/ChangeLog 2016-01-28 Don Breazeal <donb@codesourcery.com> * gdb.cp/scope-err.cc: New test program. * gdb.cp/scope-err.exp: New test script. * gdb.linespec/ls-errs.c (myfunction): Expanded to have multiple lines and "set breakpoint here" comment. * gdb.linespec/ls-errs.exp: Added C++ testing and new test case. Fixed some whitespace and format issues. * gdb.mi/mi-linespec-err-cp.cc: New test program. * gdb.mi/mi-linespec-err-cp.exp: New test script.
Diffstat (limited to 'gdb/cp-namespace.c')
-rw-r--r--gdb/cp-namespace.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 72002d6..016a42f 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -170,7 +170,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
':' may be in the args of a template spec. This isn't intended to be
a complete test, just cheap and documentary. */
if (strchr (name, '<') == NULL && strchr (name, '(') == NULL)
- gdb_assert (strchr (name, ':') == NULL);
+ gdb_assert (strstr (name, "::") == NULL);
sym = lookup_symbol_in_static_block (name, block, domain);
if (sym.symbol != NULL)
@@ -246,10 +246,9 @@ cp_search_static_and_baseclasses (const char *name,
struct block_symbol klass_sym;
struct type *klass_type;
- /* The test here uses <= instead of < because Fortran also uses this,
- and the module.exp testcase will pass "modmany::" for NAME here. */
- gdb_assert (prefix_len + 2 <= strlen (name));
- gdb_assert (name[prefix_len + 1] == ':');
+ /* Check for malformed input. */
+ if (prefix_len + 2 > strlen (name) || name[prefix_len + 1] != ':')
+ return null_block_symbol;
/* Find the name of the class and the name of the method, variable, etc. */