From 0742270560b516a11e0b1a42c4f2ac865f390be8 Mon Sep 17 00:00:00 2001 From: Peter Schauer Date: Sat, 22 Mar 1997 10:50:18 +0000 Subject: [PATCH] * c-exp.y (yylex): Handle nested template parameter lists. * symtab.c (decode_line_2): Fix test for valid choice number. --- gdb/ChangeLog | 5 +++++ gdb/c-exp.y | 35 +++++++++++++++++++++++++---------- gdb/symtab.c | 29 ++++++++++++++++------------- 3 files changed, 46 insertions(+), 23 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bc85bfaf0a..7e750c02c8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +Sat Mar 22 02:48:11 1997 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * c-exp.y (yylex): Handle nested template parameter lists. + * symtab.c (decode_line_2): Fix test for valid choice number. + Fri Mar 21 19:10:05 1997 Mark Alexander * mips-tdep.c (mips_push_arguments): On non-EABI architectures, diff --git a/gdb/c-exp.y b/gdb/c-exp.y index d7d4235dee..a70691fce9 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1,5 +1,5 @@ /* YACC parser for C expressions, for GDB. - Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994, 1996 + Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994, 1996, 1997 Free Software Foundation, Inc. This file is part of GDB. @@ -1409,15 +1409,30 @@ yylex () (c == '_' || c == '$' || (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');) { - if (c == '<') - { - int i = namelen; - while (tokstart[++i] && tokstart[i] != '>'); - if (tokstart[i] == '>') - namelen = i; - } - c = tokstart[++namelen]; - } + /* Template parameter lists are part of the name. + FIXME: This mishandles `print $a<4&&$a>3'. */ + + if (c == '<') + { + int i = namelen; + int nesting_level = 1; + while (tokstart[++i]) + { + if (tokstart[i] == '<') + nesting_level++; + else if (tokstart[i] == '>') + { + if (--nesting_level == 0) + break; + } + } + if (tokstart[i] == '>') + namelen = i; + else + break; + } + c = tokstart[++namelen]; + } /* The token "if" terminates the expression and is NOT removed from the input stream. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index bc20016a8f..654098e652 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1,5 +1,5 @@ /* Symbol table lookup for the GNU debugger, GDB. - Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 + Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. This file is part of GDB. @@ -472,6 +472,9 @@ fixup_symbol_section (sym, objfile) { struct minimal_symbol *msym; + if (!sym) + return NULL; + if (SYMBOL_BFD_SECTION (sym)) return sym; @@ -1196,15 +1199,15 @@ find_pc_line (pc, notcurrent) But what we want is the statement containing the instruction. Fudge the pc to make sure we get that. */ - if (notcurrent) pc -= 1; + INIT_SAL (&val); /* initialize to zeroes */ + + if (notcurrent) + pc -= 1; s = find_pc_symtab (pc); if (!s) { - val.symtab = 0; - val.line = 0; val.pc = pc; - val.end = 0; return val; } @@ -1274,11 +1277,8 @@ find_pc_line (pc, notcurrent) { if (!alt_symtab) { /* If we didn't find any line # info, just - return zeros. */ - val.symtab = 0; - val.line = 0; + return zeros. */ val.pc = pc; - val.end = 0; } else { @@ -1921,6 +1921,8 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical) char *saved_arg = *argptr; extern char *gdb_completer_quote_characters; + INIT_SAL (&val); /* initialize to zeroes */ + /* Defaults have defaults. */ if (default_symtab == 0) @@ -2340,15 +2342,14 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical) msymbol = lookup_minimal_symbol (copy, NULL, NULL); if (msymbol != NULL) { - val.symtab = 0; - val.line = 0; val.pc = SYMBOL_VALUE_ADDRESS (msymbol); if (funfirstline) { val.pc += FUNCTION_START_OFFSET; SKIP_PROLOGUE (val.pc); } - values.sals = (struct symtab_and_line *)xmalloc (sizeof (struct symtab_and_line)); + values.sals = (struct symtab_and_line *) + xmalloc (sizeof (struct symtab_and_line)); values.sals[0] = val; values.nelts = 1; return values; @@ -2414,6 +2415,8 @@ decode_line_2 (sym_arr, nelts, funfirstline, canonical) printf_unfiltered("[0] cancel\n[1] all\n"); while (i < nelts) { + INIT_SAL (&return_values.sals[i]); /* initialize to zeroes */ + INIT_SAL (&values.sals[i]); if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK) { values.sals[i] = find_function_start_sal (sym_arr[i], funfirstline); @@ -2474,7 +2477,7 @@ decode_line_2 (sym_arr, nelts, funfirstline, canonical) return return_values; } - if (num > nelts + 2) + if (num >= nelts + 2) { printf_unfiltered ("No choice number %d.\n", num); }