diff options
-rw-r--r-- | gdb/ChangeLog | 17 | ||||
-rw-r--r-- | gdb/breakpoint.c | 20 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.c | 8 | ||||
-rw-r--r-- | gdb/linespec.c | 49 | ||||
-rw-r--r-- | gdb/linespec.h | 2 | ||||
-rw-r--r-- | gdb/tracepoint.c | 4 |
6 files changed, 73 insertions, 27 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fe96d8f..4878139 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,20 @@ +2003-12-17 Jeff Johnston <jjohnstn@redhat.com> + + * linespec.h (decode_line_1): Add new not_found_ptr parameter. + * linespec.c (decode_line_1): Add new parameter. Pass on + new parameter to decode_variable and symtab_from_filename + functions. + (decode_variable): Add new not_found_ptr parameter. Throw exception + rather than failing if the not_found_ptr is non-null and the + function is not found. + (symtab_from_filename): Add new not_found_ptr parametr. Throw + exception rather than failing if the not_found_ptr is non-null and + the source file is not found. + * breakpoint.c: Change all callers of decode_line_1 to add default + extra parameter for decode_line_1 calls. + * tracepoint.c: Ditto. + * cli/cli-cmds.c: Ditto. + 2003-12-16 J. Brobecker <brobecker@gnat.com> * irix5-nat.c: Include mips-tdep.h. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ddf51b7..c535add 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4328,7 +4328,7 @@ solib_load_unload_1 (char *hookname, int tempflag, char *dll_pathname, int thread = -1; /* All threads. */ /* Set a breakpoint on the specified hook. */ - sals = decode_line_1 (&hookname, 1, (struct symtab *) NULL, 0, &canonical); + sals = decode_line_1 (&hookname, 1, (struct symtab *) NULL, 0, &canonical, NULL); addr_end = hookname; if (sals.nelts == 0) @@ -4845,9 +4845,9 @@ parse_breakpoint_sals (char **address, || ((strchr ("+-", (*address)[0]) != NULL) && ((*address)[1] != '[')))) *sals = decode_line_1 (address, 1, default_breakpoint_symtab, - default_breakpoint_line, addr_string); + default_breakpoint_line, addr_string, NULL); else - *sals = decode_line_1 (address, 1, (struct symtab *) NULL, 0, addr_string); + *sals = decode_line_1 (address, 1, (struct symtab *) NULL, 0, addr_string, NULL); } /* For any SAL that didn't have a canonical string, fill one in. */ if (sals->nelts > 0 && *addr_string == NULL) @@ -5293,7 +5293,7 @@ break_at_finish_command_1 (char *arg, int flag, int from_tty) beg_addr_string = addr_string; sals = decode_line_1 (&addr_string, 1, (struct symtab *) NULL, 0, - (char ***) NULL); + (char ***) NULL, NULL); xfree (beg_addr_string); old_chain = make_cleanup (xfree, sals.sals); @@ -5810,10 +5810,10 @@ until_break_command (char *arg, int from_tty, int anywhere) if (default_breakpoint_valid) sals = decode_line_1 (&arg, 1, default_breakpoint_symtab, - default_breakpoint_line, (char ***) NULL); + default_breakpoint_line, (char ***) NULL, NULL); else sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, - 0, (char ***) NULL); + 0, (char ***) NULL, NULL); if (sals.nelts != 1) error ("Couldn't get information on specified line."); @@ -6273,7 +6273,7 @@ handle_gnu_v3_exceptions (int tempflag, char *cond_string, trigger_func_name = xstrdup ("__cxa_throw"); nameptr = trigger_func_name; - sals = decode_line_1 (&nameptr, 1, NULL, 0, NULL); + sals = decode_line_1 (&nameptr, 1, NULL, 0, NULL, NULL); if (sals.nelts == 0) { xfree (trigger_func_name); @@ -6980,7 +6980,7 @@ breakpoint_re_set_one (void *bint) set_language (b->language); input_radix = b->input_radix; s = b->addr_string; - sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, (char ***) NULL); + sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, (char ***) NULL, NULL); for (i = 0; i < sals.nelts; i++) { resolve_sal_pc (&sals.sals[i]); @@ -7516,10 +7516,10 @@ decode_line_spec_1 (char *string, int funfirstline) sals = decode_line_1 (&string, funfirstline, default_breakpoint_symtab, default_breakpoint_line, - (char ***) NULL); + (char ***) NULL, NULL); else sals = decode_line_1 (&string, funfirstline, - (struct symtab *) NULL, 0, (char ***) NULL); + (struct symtab *) NULL, 0, (char ***) NULL, NULL); if (*string) error ("Junk at end of line specification: %s", string); return sals; diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 6f9fe90..dcfd74f 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -557,7 +557,7 @@ edit_command (char *arg, int from_tty) /* Now should only be one argument -- decode it in SAL */ arg1 = arg; - sals = decode_line_1 (&arg1, 0, 0, 0, 0); + sals = decode_line_1 (&arg1, 0, 0, 0, 0, 0); if (! sals.nelts) return; /* C++ */ if (sals.nelts > 1) { @@ -681,7 +681,7 @@ list_command (char *arg, int from_tty) dummy_beg = 1; else { - sals = decode_line_1 (&arg1, 0, 0, 0, 0); + sals = decode_line_1 (&arg1, 0, 0, 0, 0, 0); if (!sals.nelts) return; /* C++ */ @@ -714,9 +714,9 @@ list_command (char *arg, int from_tty) else { if (dummy_beg) - sals_end = decode_line_1 (&arg1, 0, 0, 0, 0); + sals_end = decode_line_1 (&arg1, 0, 0, 0, 0, 0); else - sals_end = decode_line_1 (&arg1, 0, sal.symtab, sal.line, 0); + sals_end = decode_line_1 (&arg1, 0, sal.symtab, sal.line, 0, 0); if (sals_end.nelts == 0) return; if (sals_end.nelts > 1) diff --git a/gdb/linespec.c b/gdb/linespec.c index b3eb05f..741ac88 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -100,7 +100,8 @@ static struct symtabs_and_lines decode_line_2 (struct symbol *[], int, int, char ***); static struct symtab *symtab_from_filename (char **argptr, - char *p, int is_quote_enclosed); + char *p, int is_quote_enclosed, + int *not_found_ptr); static struct symtabs_and_lines decode_all_digits (char **argptr, @@ -119,7 +120,8 @@ static struct symtabs_and_lines decode_dollar (char *copy, static struct symtabs_and_lines decode_variable (char *copy, int funfirstline, char ***canonical, - struct symtab *file_symtab); + struct symtab *file_symtab, + int *not_found_ptr); static struct symtabs_and_lines symbol_found (int funfirstline, @@ -637,7 +639,12 @@ decode_line_2 (struct symbol *sym_arr[], int nelts, int funfirstline, Note that it is possible to return zero for the symtab if no file is validly specified. Callers must check that. - Also, the line number returned may be invalid. */ + Also, the line number returned may be invalid. + + If NOT_FOUND_PTR is not null, store a boolean true/false value at the location, based + on whether or not failure occurs due to an unknown function or file. In the case + where failure does occur due to an unknown function or file, do not issue an error + message. */ /* We allow single quotes in various places. This is a hideous kludge, which exists because the completer can't yet deal with the @@ -646,7 +653,7 @@ decode_line_2 (struct symbol *sym_arr[], int nelts, int funfirstline, struct symtabs_and_lines decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, - int default_line, char ***canonical) + int default_line, char ***canonical, int *not_found_ptr) { char *p; char *q; @@ -665,6 +672,9 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, int is_objc_method = 0; char *saved_arg = *argptr; + if (not_found_ptr) + *not_found_ptr = 0; + /* Defaults have defaults. */ initialize_defaults (&default_symtab, &default_line); @@ -722,7 +732,8 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, /* No, the first part is a filename; set s to be that file's symtab. Also, move argptr past the filename. */ - file_symtab = symtab_from_filename (argptr, p, is_quote_enclosed); + file_symtab = symtab_from_filename (argptr, p, is_quote_enclosed, + not_found_ptr); } #if 0 /* No one really seems to know why this was added. It certainly @@ -827,7 +838,8 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, /* Look up that token as a variable. If file specified, use that file's per-file block to start with. */ - return decode_variable (copy, funfirstline, canonical, file_symtab); + return decode_variable (copy, funfirstline, canonical, + file_symtab, not_found_ptr); } @@ -1422,10 +1434,14 @@ collect_methods (char *copy, struct type *t, /* Return the symtab associated to the filename given by the substring - of *ARGPTR ending at P, and advance ARGPTR past that filename. */ + of *ARGPTR ending at P, and advance ARGPTR past that filename. If + NOT_FOUND_PTR is not null and the source file is not found, store + boolean true at the location pointed to and do not issue an + error message. */ static struct symtab * -symtab_from_filename (char **argptr, char *p, int is_quote_enclosed) +symtab_from_filename (char **argptr, char *p, int is_quote_enclosed, + int *not_found_ptr) { char *p1; char *copy; @@ -1450,6 +1466,11 @@ symtab_from_filename (char **argptr, char *p, int is_quote_enclosed) { if (!have_full_symbols () && !have_partial_symbols ()) error ("No symbol table is loaded. Use the \"file\" command."); + if (not_found_ptr) + { + *not_found_ptr = 1; + throw_exception (RETURN_ERROR); + } error ("No source file named %s.", copy); } @@ -1626,11 +1647,13 @@ decode_dollar (char *copy, int funfirstline, struct symtab *default_symtab, /* Decode a linespec that's a variable. If FILE_SYMTAB is non-NULL, - look in that symtab's static variables first. */ + look in that symtab's static variables first. If NOT_FOUND_PTR is not NULL and + the function cannot be found, store boolean true in the location pointed to + and do not issue an error message. */ static struct symtabs_and_lines decode_variable (char *copy, int funfirstline, char ***canonical, - struct symtab *file_symtab) + struct symtab *file_symtab, int *not_found_ptr) { struct symbol *sym; /* The symtab that SYM was found in. */ @@ -1658,6 +1681,12 @@ decode_variable (char *copy, int funfirstline, char ***canonical, !have_partial_symbols () && !have_minimal_symbols ()) error ("No symbol table is loaded. Use the \"file\" command."); + if (not_found_ptr) + { + *not_found_ptr = 1; + throw_exception (RETURN_ERROR); + } + error ("Function \"%s\" not defined.", copy); } diff --git a/gdb/linespec.h b/gdb/linespec.h index 3ede4bd..38b0941 100644 --- a/gdb/linespec.h +++ b/gdb/linespec.h @@ -24,6 +24,6 @@ struct symtab; extern struct symtabs_and_lines decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, int default_line, - char ***canonical); + char ***canonical, int *not_found_ptr); #endif /* defined (LINESPEC_H) */ diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 5c85db4..6e33841 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -392,7 +392,7 @@ trace_command (char *arg, int from_tty) printf_filtered ("TRACE %s\n", arg); addr_start = arg; - sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, &canonical); + sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, &canonical, NULL); addr_end = arg; if (!sals.nelts) return; /* ??? Presumably decode_line_1 has already warned? */ @@ -2341,7 +2341,7 @@ scope_info (char *args, int from_tty) if (args == 0 || *args == 0) error ("requires an argument (function, line or *addr) to define a scope"); - sals = decode_line_1 (&args, 1, NULL, 0, &canonical); + sals = decode_line_1 (&args, 1, NULL, 0, &canonical, NULL); if (sals.nelts == 0) return; /* presumably decode_line_1 has already warned */ |