This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 2/3] Linespec rewrite: Cleanups
- From: Keith Seitz <keiths at redhat dot com>
- To: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Mon, 19 Mar 2012 14:21:43 -0700
- Subject: [RFA 2/3] Linespec rewrite: Cleanups
Hi,
This second patch deals with cleanups in the codebase and test suite:
removing unused functions, updating test suite error messages, and the like.
Keith
ChangeLog
2012-03-19 Keith Seitz <keiths@redhat.com>
* cp-support.c (SKIP_SPACE): Remove.
(cp_validate_operator): Remove.
* cp-support.h (cp_validate_operator): Remove declaration.
testsuite/ChangeLog
2012-03-19 Keith Seitz <keiths@redhat.com>
* gdb.base/advance.exp: Update error message for
"advance malformed" test.
* gdb.base/break.exp: Likewise for "breakpoint with
trailing garbage" test.
* gdb.base/hbreak2.exp: Likewise for "hardware breakpoint
with trailing garbage" test.
* gdb.base/sepdebug.exp: Likewise for "breakpoint with
trailng garbage" test.
* gdb.base/until.exp: Likewise for "malformed until" test.
* gdb.base/list.exp: Update "list 'list0.c:main'", which contains
invalid quoting.
* gdb.cp/overload.exp: Fix invalidly quoted linespec.
* gdb.cp/ovldbreak.exp: Create the breakpoint table
for "breakpoint info (after setting on all)".
* gdb.cp/static-method.exp: Remove redundant (and invalid
linespec) test "list '$srcfile:$test'".
* gdb.cp/userdef.exp: Remove quoting for "break A2::operator+"
tests.
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index a41bcec..e73715b 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1459,110 +1459,6 @@ first_component_command (char *arg, int from_tty)
extern initialize_file_ftype _initialize_cp_support; /* -Wmissing-prototypes */
-#define SKIP_SPACE(P) \
- do \
- { \
- while (*(P) == ' ' || *(P) == '\t') \
- ++(P); \
- } \
- while (0)
-
-/* Returns the length of the operator name or 0 if INPUT does not
- point to a valid C++ operator. INPUT should start with
- "operator". */
-int
-cp_validate_operator (const char *input)
-{
- int i;
- char *copy;
- const char *p;
- struct expression *expr;
- struct value *val;
- volatile struct gdb_exception except;
-
- p = input;
-
- if (strncmp (p, "operator", 8) == 0)
- {
- int valid = 0;
-
- p += 8;
- SKIP_SPACE (p);
- for (i = 0;
- i < sizeof (operator_tokens) / sizeof (operator_tokens[0]);
- ++i)
- {
- int length = strlen (operator_tokens[i]);
-
- /* By using strncmp here, we MUST have operator_tokens
- ordered! See additional notes where operator_tokens is
- defined above. */
- if (strncmp (p, operator_tokens[i], length) == 0)
- {
- const char *op = p;
-
- valid = 1;
- p += length;
-
- if (strncmp (op, "new", 3) == 0
- || strncmp (op, "delete", 6) == 0)
- {
-
- /* Special case: new[] and delete[]. We must be
- careful to swallow whitespace before/in "[]". */
- SKIP_SPACE (p);
-
- if (*p == '[')
- {
- ++p;
- SKIP_SPACE (p);
- if (*p == ']')
- ++p;
- else
- valid = 0;
- }
- }
-
- if (valid)
- return (p - input);
- }
- }
-
- /* Check input for a conversion operator. */
-
- /* Skip past base typename. */
- while (*p != '*' && *p != '&' && *p != 0 && *p != ' ')
- ++p;
- SKIP_SPACE (p);
-
- /* Add modifiers '*' / '&'. */
- while (*p == '*' || *p == '&')
- {
- ++p;
- SKIP_SPACE (p);
- }
-
- /* Check for valid type. [Remember: input starts with
- "operator".] */
- copy = savestring (input + 8, p - input - 8);
- expr = NULL;
- val = NULL;
- TRY_CATCH (except, RETURN_MASK_ALL)
- {
- expr = parse_expression (copy);
- val = evaluate_type (expr);
- }
-
- xfree (copy);
- if (expr)
- xfree (expr);
-
- if (val != NULL && value_type (val) != NULL)
- return (p - input);
- }
-
- return 0;
-}
/* Implement "info vtbl". */
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 8898807..5988418 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -170,8 +170,6 @@ extern struct symbol **make_symbol_overload_list_adl (struct type **arg_types,
extern struct type *cp_lookup_rtti_type (const char *name,
struct block *block);
-extern int cp_validate_operator (const char *input);
-
/* Functions/variables from cp-namespace.c. */
extern int cp_is_anonymous (const char *namespace);
diff --git a/gdb/testsuite/gdb.base/advance.exp b/gdb/testsuite/gdb.base/advance.exp
index 456268d..617a7fb 100644
--- a/gdb/testsuite/gdb.base/advance.exp
+++ b/gdb/testsuite/gdb.base/advance.exp
@@ -45,7 +45,8 @@ gdb_test "advance [gdb_get_line_number "advance this location"]" \
# Verify that a malformed "advance" is gracefully caught.
#
gdb_test "advance [gdb_get_line_number "advance malformed"] then stop" \
- "Junk at end of arguments." "malformed advance"
+ "malformed linespec error: unexpected string, \"then stop\"" \
+ "malformed advance"
# Verify that "advance <funcname>" works.
#
diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index 71eb3a6..a203364 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -600,7 +600,7 @@ gdb_test "break $bp_location12 thread foo" \
# trailing garbage.
#
gdb_test "break $bp_location12 foo" \
- "Junk at end of arguments.*" \
+ "malformed linespec error: unexpected string, \"foo\".*" \
"breakpoint with trailing garbage disallowed"
# Verify that GDB responds gracefully to a "clear" command that has
diff --git a/gdb/testsuite/gdb.base/hbreak2.exp b/gdb/testsuite/gdb.base/hbreak2.exp
index 7f52cd3..a11d8b6 100644
--- a/gdb/testsuite/gdb.base/hbreak2.exp
+++ b/gdb/testsuite/gdb.base/hbreak2.exp
@@ -356,7 +356,7 @@ gdb_test "hbreak $bp_location12 thread foo" \
# trailing garbage.
#
gdb_test "hbreak $bp_location12 foo" \
- "Junk at end of arguments.*" \
+ "malformed linespec error: unexpected string, \"foo\".*" \
"hardware breakpoint with trailing garbage disallowed"
# Verify that GDB responds gracefully to a "clear" command that has
diff --git a/gdb/testsuite/gdb.base/jump.exp b/gdb/testsuite/gdb.base/jump.exp
index a5577e2..a7b2177 100644
--- a/gdb/testsuite/gdb.base/jump.exp
+++ b/gdb/testsuite/gdb.base/jump.exp
@@ -92,7 +92,7 @@ gdb_test "jump" "Argument required .starting address.*" \
# trailing junk.
#
gdb_test "jump 21 100" \
- "Junk at end of line specification: 100.*" \
+ "malformed linespec error: unexpected number, \"100\"" \
"jump with trailing argument junk"
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index d1358c3..d00159d 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -468,7 +468,7 @@ proc test_list_filename_and_function {} {
pass "list filename:function ($testcnt tests)"
# Test with quoting.
- gdb_test "list 'list0.c:main'" "int main.*"
+ gdb_test "list 'list0.c':'main'" "int main.*"
# Test some invalid specs
# The following test takes the FIXME result on most systems using
diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp
index bd60c70..e6973fb 100644
--- a/gdb/testsuite/gdb.base/sepdebug.exp
+++ b/gdb/testsuite/gdb.base/sepdebug.exp
@@ -408,7 +408,7 @@ gdb_test "break $bp_location12 thread foo" \
#
gdb_test "break $bp_location12 foo" \
- "Junk at end of arguments.*" \
+ "malformed linespec error: unexpected string, \"foo\".*" \
"breakpoint with trailing garbage disallowed"
# Verify that GDB responds gracefully to a "clear" command that has
diff --git a/gdb/testsuite/gdb.base/until.exp b/gdb/testsuite/gdb.base/until.exp
index 6b647cd..bdee21d 100644
--- a/gdb/testsuite/gdb.base/until.exp
+++ b/gdb/testsuite/gdb.base/until.exp
@@ -40,7 +40,8 @@ gdb_test "until $bp_location1" \
# Verify that a malformed "advance" is gracefully caught.
#
gdb_test "until 80 then stop" \
- "Junk at end of arguments." "malformed until"
+ "malformed linespec error: unexpected string, \"then stop\"." \
+ "malformed until"
# Rerun up to factorial, outer invocation
if { ![runto factorial] } then { gdb_suppress_tests; }
diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp
index 5116e5f..f3e56c7 100644
--- a/gdb/testsuite/gdb.cp/overload.exp
+++ b/gdb/testsuite/gdb.cp/overload.exp
@@ -306,7 +306,6 @@ gdb_test "list \"foo::overloadfnarg(int, int (*)(int))\"" \
gdb_test "list ${srcfile}:intToChar" "int intToChar.*"
gdb_test "list ${srcfile}:intToChar(char)" "int intToChar.*"
gdb_test "list ${srcfile}:'intToChar(char)'" "int intToChar.*"
-gdb_test "list '${srcfile}:intToChar(char)'" "int intToChar.*"
gdb_test "list '${srcfile}':intToChar(char)" "int intToChar.*"
gdb_test "list '${srcfile}':'intToChar(char)'" "int intToChar.*"
diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp
index 3e35b79..2c27f2d 100644
--- a/gdb/testsuite/gdb.cp/ovldbreak.exp
+++ b/gdb/testsuite/gdb.cp/ovldbreak.exp
@@ -320,23 +320,17 @@ gdb_expect {
}
}
-gdb_test "info break" \
- "Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+<MULTIPLE>\[\t \]*\r
-\[0-9\]+.1\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:140\r
-\[0-9\]+.2\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:137\r
-\[0-9\]+.3\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:134\r
-\[0-9\]+.4\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:131\r
-\[0-9\]+.5\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:128\r
-\[0-9\]+.6\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:125\r
-\[0-9\]+.7\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:122\r
-\[0-9\]+.8\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:119\r
-\[0-9\]+.9\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:116\r
-\[0-9\]+.10\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:113\r
-\[0-9\]+.11\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:110\r
-\[0-9\]+.12\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:107" \
- "breakpoint info (after setting on all)"
+# Create the breakpoint table for "info breakpoint".
+set bptable "Num Type\[\t \]+Disp Enb Address\[\t \]+What.*\[\r\n]+"
+append bptable "\[0-9\]+\[\t \]+breakpoint\[\t \]+keep\[\t \]y\[\t \]+<MULTIPLE>.*\[\r\n\]+"
+foreach ovld {void char signed_char unsigned_char short_int \
+ unsigned_short_int int unsigned_int long_int \
+ unsigned_long_int float double} {
+ append bptable [format "\[0-9\]+.\[0-9\]+\[\t \]+y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(%s\\) at.*$srcfile:%d\[\r\n\]+" \
+ $types($ovld) $line($ovld)]
+}
+gdb_test "info break" $bptable "breakpoint info (after setting on all)"
# Run through each breakpoint.
proc continue_to_bp_overloaded {bpnumber might_fail line argtype argument} {
diff --git a/gdb/testsuite/gdb.cp/static-method.exp b/gdb/testsuite/gdb.cp/static-method.exp
index 6e086f3..576666c 100644
--- a/gdb/testsuite/gdb.cp/static-method.exp
+++ b/gdb/testsuite/gdb.cp/static-method.exp
@@ -95,11 +95,6 @@ foreach test $methods {
&& !$have_gcc_45682_fixed} {
setup_xfail gcc/45682 "*-*-*"
}
- gdb_test "list '${srcfile}:$test'" $result
- if {[string compare $test "xxx::${ans}::A::func"] == 0
- && !$have_gcc_45682_fixed} {
- setup_xfail gcc/45682 "*-*-*"
- }
gdb_test "list '${srcfile}':'$test'" $result
if {[string compare $test "xxx::${ans}::A::func"] == 0
&& !$have_gcc_45682_fixed} {
diff --git a/gdb/testsuite/gdb.cp/userdef.exp b/gdb/testsuite/gdb.cp/userdef.exp
index 9c7cb57..90eb99d 100644
--- a/gdb/testsuite/gdb.cp/userdef.exp
+++ b/gdb/testsuite/gdb.cp/userdef.exp
@@ -136,8 +136,8 @@ gdb_test "print one += 7" "\\\$\[0-9\]* = {x = 9, y = 10}"
gdb_test "print two = one" "\\\$\[0-9\]* = {x = 9, y = 10}"
# Check that GDB tolerates whitespace in operator names.
-gdb_test "break A2::'operator+'" ".*Breakpoint $decimal at.*"
-gdb_test "break A2::'operator +'" ".*Breakpoint $decimal at.*"
+gdb_test "break A2::operator+" ".*Breakpoint $decimal at.*"
+gdb_test "break A2::operator +" ".*Breakpoint $decimal at.*"
# Check that GDB handles operator* correctly.
gdb_test "print c" "\\\$\[0-9\]* = {m = {z = .*}}"