X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Flinespec.c;h=ccedec8841a02f0b569cec398515b4907cc042ae;hb=ad43e107eb233dcef8e76da6328aa4e4d74afd84;hp=84e518fc719802bb24a73f060349ee2462fe863a;hpb=00e52e5376c7ec604a739e6242e6be36221162d7;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/linespec.c b/gdb/linespec.c index 84e518fc71..ccedec8841 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1,6 +1,6 @@ /* Parser for linespec for the GNU debugger, GDB. - Copyright (C) 1986-2015 Free Software Foundation, Inc. + Copyright (C) 1986-2016 Free Software Foundation, Inc. This file is part of GDB. @@ -72,7 +72,7 @@ DEF_VEC_O (bound_minimal_symbol_d); struct linespec { /* An explicit location describing the SaLs. */ - struct explicit_location explicit; + struct explicit_location explicit_loc; /* The list of symtabs to search to which to limit the search. May not be NULL. If explicit.SOURCE_FILENAME is NULL (no user-specified @@ -123,6 +123,10 @@ struct linespec_state /* The program space as seen when the module was entered. */ struct program_space *program_space; + /* If not NULL, the search is restricted to just this program + space. */ + struct program_space *search_pspace; + /* The default symtab to use, if no other symtab is specified. */ struct symtab *default_symtab; @@ -256,7 +260,7 @@ typedef struct ls_parser linespec_parser; /* A convenience macro for accessing the explicit location result of the parser. */ -#define PARSER_EXPLICIT(PPTR) (&PARSER_RESULT ((PPTR))->explicit) +#define PARSER_EXPLICIT(PPTR) (&PARSER_RESULT ((PPTR))->explicit_loc) /* Prototypes for local functions. */ @@ -274,7 +278,8 @@ static struct symtabs_and_lines decode_objc (struct linespec_state *self, linespec_p ls, const char *arg); -static VEC (symtab_ptr) *symtabs_from_filename (const char *); +static VEC (symtab_ptr) *symtabs_from_filename (const char *, + struct program_space *pspace); static VEC (symbolp) *find_label_symbols (struct linespec_state *self, VEC (symbolp) *function_symbols, @@ -302,7 +307,9 @@ static void add_all_symbol_names_from_pspace (struct collect_info *info, struct program_space *pspace, VEC (const_char_ptr) *names); -static VEC (symtab_ptr) *collect_symtabs_from_filename (const char *file); +static VEC (symtab_ptr) * + collect_symtabs_from_filename (const char *file, + struct program_space *pspace); static void decode_digits_ordinary (struct linespec_state *self, linespec_p ls, @@ -323,8 +330,6 @@ static int compare_symbols (const void *a, const void *b); static int compare_msymbols (const void *a, const void *b); -static const char *find_toplevel_char (const char *s, char c); - /* Permitted quote characters for the parser. This is different from the completer's quote characters to allow backward compatibility with the previous parser. */ @@ -419,10 +424,9 @@ linespec_lexer_lex_keyword (const char *p) return NULL; } -/* Does STRING represent an Ada operator? If so, return the length - of the decoded operator name. If not, return 0. */ +/* See description in linespec.h. */ -static int +int is_ada_operator (const char *string) { const struct ada_opname_map *mapping; @@ -672,7 +676,7 @@ linespec_lexer_lex_string (linespec_parser *parser) && (PARSER_STREAM (parser) - start) > 8 /* strlen ("operator") */) { - char *p = strstr (start, "operator"); + const char *p = strstr (start, "operator"); if (p != NULL && is_operator_name (p)) { @@ -813,7 +817,7 @@ add_sal_to_sals_basic (struct symtabs_and_lines *sals, struct symtab_and_line *sal) { ++sals->nelts; - sals->sals = xrealloc (sals->sals, sals->nelts * sizeof (sals->sals[0])); + sals->sals = XRESIZEVEC (struct symtab_and_line, sals->sals, sals->nelts); sals->sals[sals->nelts - 1] = *sal; } @@ -836,13 +840,12 @@ add_sal_to_sals (struct linespec_state *self, { struct linespec_canonical_name *canonical; - self->canonical_names = xrealloc (self->canonical_names, - (sals->nelts - * sizeof (*self->canonical_names))); + self->canonical_names = XRESIZEVEC (struct linespec_canonical_name, + self->canonical_names, sals->nelts); canonical = &self->canonical_names[sals->nelts - 1]; if (!literal_canonical && sal->symtab) { - const char *fullname = symtab_to_fullname (sal->symtab); + symtab_to_fullname (sal->symtab); /* Note that the filter doesn't have to be a valid linespec input. We only apply the ":LINE" treatment to Ada for @@ -872,7 +875,7 @@ add_sal_to_sals (struct linespec_state *self, static hashval_t hash_address_entry (const void *p) { - const struct address_entry *aep = p; + const struct address_entry *aep = (const struct address_entry *) p; hashval_t hash; hash = iterative_hash_object (aep->pspace, 0); @@ -884,8 +887,8 @@ hash_address_entry (const void *p) static int eq_address_entry (const void *a, const void *b) { - const struct address_entry *aea = a; - const struct address_entry *aeb = b; + const struct address_entry *aea = (const struct address_entry *) a; + const struct address_entry *aeb = (const struct address_entry *) b; return aea->pspace == aeb->pspace && aea->addr == aeb->addr; } @@ -933,7 +936,8 @@ iterate_inline_only (struct symbol *sym, void *d) { if (SYMBOL_INLINED (sym)) { - struct symbol_and_data_callback *cad = d; + struct symbol_and_data_callback *cad + = (struct symbol_and_data_callback *) d; return cad->callback (sym, cad->data); } @@ -957,7 +961,8 @@ struct symbol_matcher_data static int iterate_name_matcher (const char *name, void *d) { - const struct symbol_matcher_data *data = d; + const struct symbol_matcher_data *data + = (const struct symbol_matcher_data *) d; if (data->symbol_name_cmp (name, data->lookup_name) == 0) return 1; /* Expand this symbol's symbol table. */ @@ -1140,7 +1145,7 @@ find_methods (struct type *t, const char *name, strings. Also, ignore the char within a template name, like a ',' within foo. */ -static const char * +const char * find_toplevel_char (const char *s, char c) { int quoted = 0; /* zero if we're not in quotes; @@ -1298,8 +1303,8 @@ struct decode_line_2_item static int decode_line_2_compare_items (const void *ap, const void *bp) { - const struct decode_line_2_item *a = ap; - const struct decode_line_2_item *b = bp; + const struct decode_line_2_item *a = (const struct decode_line_2_item *) ap; + const struct decode_line_2_item *b = (const struct decode_line_2_item *) bp; int retval; retval = strcmp (a->displayform, b->displayform); @@ -1335,7 +1340,7 @@ decode_line_2 (struct linespec_state *self, /* Prepare ITEMS array. */ items_count = result->nelts; - items = xmalloc (sizeof (*items) * items_count); + items = XNEWVEC (struct decode_line_2_item, items_count); make_cleanup (xfree, items); for (i = 0; i < items_count; ++i) { @@ -1514,10 +1519,9 @@ unexpected_linespec_error (linespec_parser *parser) || token.type == LSTOKEN_KEYWORD) { char *string; - struct cleanup *cleanup; string = copy_token_string (token); - cleanup = make_cleanup (xfree, string); + make_cleanup (xfree, string); throw_error (GENERIC_ERROR, _("malformed linespec error: unexpected %s, \"%s\""), token_type_strings[token.type], string); @@ -1551,11 +1555,12 @@ source_file_not_found_error (const char *name) throw_error (NOT_FOUND_ERROR, _("No source file named %s."), name); } -/* Parse and return a line offset in STRING. */ +/* See description in linespec.h. */ -static struct line_offset +struct line_offset linespec_parse_line_offset (const char *string) { + const char *start = string; struct line_offset line_offset = {0, LINE_OFFSET_NONE}; if (*string == '+') @@ -1569,6 +1574,9 @@ linespec_parse_line_offset (const char *string) ++string; } + if (*string != '\0' && !isdigit (*string)) + error (_("malformed line offset: \"%s\""), start); + /* Right now, we only allow base 10 for offsets. */ line_offset.offset = atoi (string); return line_offset; @@ -1768,21 +1776,22 @@ static void canonicalize_linespec (struct linespec_state *state, const linespec_p ls) { struct event_location *canon; - struct explicit_location *explicit; + struct explicit_location *explicit_loc; /* If canonicalization was not requested, no need to do anything. */ if (!state->canonical) return; /* Save everything as an explicit location. */ - canon = state->canonical->location = new_explicit_location (&ls->explicit); - explicit = get_explicit_location (canon); + canon = state->canonical->location + = new_explicit_location (&ls->explicit_loc); + explicit_loc = get_explicit_location (canon); - if (explicit->label_name != NULL) + if (explicit_loc->label_name != NULL) { state->canonical->special_display = 1; - if (explicit->function_name == NULL) + if (explicit_loc->function_name == NULL) { struct symbol *s; @@ -1791,7 +1800,7 @@ canonicalize_linespec (struct linespec_state *state, const linespec_p ls) && (VEC_length (symbolp, ls->labels.function_symbols) == 1)); s = VEC_index (symbolp, ls->labels.function_symbols, 0); - explicit->function_name = xstrdup (SYMBOL_NATURAL_NAME (s)); + explicit_loc->function_name = xstrdup (SYMBOL_NATURAL_NAME (s)); } } @@ -1799,7 +1808,7 @@ canonicalize_linespec (struct linespec_state *state, const linespec_p ls) representation of it for display and saving to file. */ if (state->is_linespec) { - char *linespec = explicit_location_to_linespec (explicit); + char *linespec = explicit_location_to_linespec (explicit_loc); set_event_location_string (canon, linespec); xfree (linespec); @@ -1839,22 +1848,23 @@ create_sals_line_offset (struct linespec_state *self, fullname = symtab_to_fullname (self->default_symtab); VEC_pop (symtab_ptr, ls->file_symtabs); VEC_free (symtab_ptr, ls->file_symtabs); - ls->file_symtabs = collect_symtabs_from_filename (fullname); + ls->file_symtabs = collect_symtabs_from_filename (fullname, + self->search_pspace); use_default = 1; } - val.line = ls->explicit.line_offset.offset; - switch (ls->explicit.line_offset.sign) + val.line = ls->explicit_loc.line_offset.offset; + switch (ls->explicit_loc.line_offset.sign) { case LINE_OFFSET_PLUS: - if (ls->explicit.line_offset.offset == 0) + if (ls->explicit_loc.line_offset.offset == 0) val.line = 5; if (use_default) val.line = self->default_line + val.line; break; case LINE_OFFSET_MINUS: - if (ls->explicit.line_offset.offset == 0) + if (ls->explicit_loc.line_offset.offset == 0) val.line = 15; if (use_default) val.line = self->default_line - val.line; @@ -1946,9 +1956,9 @@ create_sals_line_offset (struct linespec_state *self, if (values.nelts == 0) { - if (ls->explicit.source_filename) + if (ls->explicit_loc.source_filename) throw_error (NOT_FOUND_ERROR, _("No line %d in file \"%s\"."), - val.line, ls->explicit.source_filename); + val.line, ls->explicit_loc.source_filename); else throw_error (NOT_FOUND_ERROR, _("No line %d in the current file."), val.line); @@ -2045,13 +2055,13 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls) } } } - else if (ls->explicit.line_offset.sign != LINE_OFFSET_UNKNOWN) + else if (ls->explicit_loc.line_offset.sign != LINE_OFFSET_UNKNOWN) { /* Only an offset was specified. */ sals = create_sals_line_offset (state, ls); /* Make sure we have a filename for canonicalization. */ - if (ls->explicit.source_filename == NULL) + if (ls->explicit_loc.source_filename == NULL) { const char *fullname = symtab_to_fullname (state->default_symtab); @@ -2059,7 +2069,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls) form so that displaying SOURCE_FILENAME can follow the current FILENAME_DISPLAY_STRING setting. But as it is used only rarely it has been kept for code simplicity only in absolute form. */ - ls->explicit.source_filename = xstrdup (fullname); + ls->explicit_loc.source_filename = xstrdup (fullname); } } else @@ -2076,29 +2086,31 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls) return sals; } -/* Convert the explicit location EXPLICIT into SaLs. */ +/* Convert the explicit location EXPLICIT_LOC into SaLs. */ static struct symtabs_and_lines convert_explicit_location_to_sals (struct linespec_state *self, linespec_p result, - const struct explicit_location *explicit) + const struct explicit_location *explicit_loc) { VEC (symbolp) *symbols, *labels; VEC (bound_minimal_symbol_d) *minimal_symbols; - if (explicit->source_filename != NULL) + if (explicit_loc->source_filename != NULL) { TRY { result->file_symtabs - = symtabs_from_filename (explicit->source_filename); + = symtabs_from_filename (explicit_loc->source_filename, + self->search_pspace); } CATCH (except, RETURN_MASK_ERROR) { - source_file_not_found_error (explicit->source_filename); + source_file_not_found_error (explicit_loc->source_filename); } END_CATCH - result->explicit.source_filename = xstrdup (explicit->source_filename); + result->explicit_loc.source_filename + = xstrdup (explicit_loc->source_filename); } else { @@ -2106,38 +2118,39 @@ convert_explicit_location_to_sals (struct linespec_state *self, VEC_safe_push (symtab_ptr, result->file_symtabs, NULL); } - if (explicit->function_name != NULL) + if (explicit_loc->function_name != NULL) { find_linespec_symbols (self, result->file_symtabs, - explicit->function_name, &symbols, + explicit_loc->function_name, &symbols, &minimal_symbols); if (symbols == NULL && minimal_symbols == NULL) - symbol_not_found_error (explicit->function_name, - result->explicit.source_filename); + symbol_not_found_error (explicit_loc->function_name, + result->explicit_loc.source_filename); - result->explicit.function_name = xstrdup (explicit->function_name); + result->explicit_loc.function_name + = xstrdup (explicit_loc->function_name); result->function_symbols = symbols; result->minimal_symbols = minimal_symbols; } - if (explicit->label_name != NULL) + if (explicit_loc->label_name != NULL) { symbols = NULL; labels = find_label_symbols (self, result->function_symbols, - &symbols, explicit->label_name); + &symbols, explicit_loc->label_name); if (labels == NULL) - undefined_label_error (result->explicit.function_name, - explicit->label_name); + undefined_label_error (result->explicit_loc.function_name, + explicit_loc->label_name); - result->explicit.label_name = xstrdup (explicit->label_name); + result->explicit_loc.label_name = xstrdup (explicit_loc->label_name); result->labels.label_symbols = labels; result->labels.function_symbols = symbols; } - if (explicit->line_offset.sign != LINE_OFFSET_UNKNOWN) - result->explicit.line_offset = explicit->line_offset; + if (explicit_loc->line_offset.sign != LINE_OFFSET_UNKNOWN) + result->explicit_loc.line_offset = explicit_loc->line_offset; return convert_linespec_to_sals (self, result); } @@ -2280,7 +2293,8 @@ parse_linespec (linespec_parser *parser, const char *arg) TRY { PARSER_RESULT (parser)->file_symtabs - = symtabs_from_filename (user_filename); + = symtabs_from_filename (user_filename, + PARSER_STATE (parser)->search_pspace); } CATCH (ex, RETURN_MASK_ERROR) { @@ -2362,6 +2376,7 @@ parse_linespec (linespec_parser *parser, const char *arg) static void linespec_state_constructor (struct linespec_state *self, int flags, const struct language_defn *language, + struct program_space *search_pspace, struct symtab *default_symtab, int default_line, struct linespec_result *canonical) @@ -2370,6 +2385,7 @@ linespec_state_constructor (struct linespec_state *self, self->language = language; self->funfirstline = (flags & DECODE_LINE_FUNFIRSTLINE) ? 1 : 0; self->list_mode = (flags & DECODE_LINE_LIST_MODE) ? 1 : 0; + self->search_pspace = search_pspace; self->default_symtab = default_symtab; self->default_line = default_line; self->canonical = canonical; @@ -2384,6 +2400,7 @@ linespec_state_constructor (struct linespec_state *self, static void linespec_parser_new (linespec_parser *parser, int flags, const struct language_defn *language, + struct program_space *search_pspace, struct symtab *default_symtab, int default_line, struct linespec_result *canonical) @@ -2393,6 +2410,7 @@ linespec_parser_new (linespec_parser *parser, memset (PARSER_RESULT (parser), 0, sizeof (struct linespec)); PARSER_EXPLICIT (parser)->line_offset.sign = LINE_OFFSET_UNKNOWN; linespec_state_constructor (PARSER_STATE (parser), flags, language, + search_pspace, default_symtab, default_line, canonical); } @@ -2446,7 +2464,7 @@ linespec_lex_to_end (char **stringp) if (stringp == NULL || *stringp == NULL) return; - linespec_parser_new (&parser, 0, current_language, NULL, 0, NULL); + linespec_parser_new (&parser, 0, current_language, NULL, NULL, 0, NULL); cleanup = make_cleanup (linespec_parser_delete, &parser); parser.lexer.saved_arg = *stringp; PARSER_STREAM (&parser) = orig = *stringp; @@ -2493,19 +2511,37 @@ event_location_to_sals (linespec_parser *parser, break; case ADDRESS_LOCATION: - result - = convert_address_location_to_sals (PARSER_STATE (parser), - get_address_location (location)); + { + const char *addr_string = get_address_string_location (location); + CORE_ADDR addr = get_address_location (location); + + if (addr_string != NULL) + { + char *expr = xstrdup (addr_string); + const char *const_expr = expr; + struct cleanup *cleanup = make_cleanup (xfree, expr); + + addr = linespec_expression_to_pc (&const_expr); + if (PARSER_STATE (parser)->canonical != NULL) + PARSER_STATE (parser)->canonical->location + = copy_event_location (location); + + do_cleanups (cleanup); + } + + result = convert_address_location_to_sals (PARSER_STATE (parser), + addr); + } break; case EXPLICIT_LOCATION: { - const struct explicit_location *explicit; + const struct explicit_location *explicit_loc; - explicit = get_explicit_location_const (location); + explicit_loc = get_explicit_location_const (location); result = convert_explicit_location_to_sals (PARSER_STATE (parser), PARSER_RESULT (parser), - explicit); + explicit_loc); } break; @@ -2525,6 +2561,7 @@ event_location_to_sals (linespec_parser *parser, void decode_line_full (const struct event_location *location, int flags, + struct program_space *search_pspace, struct symtab *default_symtab, int default_line, struct linespec_result *canonical, const char *select_mode, @@ -2545,7 +2582,8 @@ decode_line_full (const struct event_location *location, int flags, || select_mode == multiple_symbols_cancel); gdb_assert ((flags & DECODE_LINE_LIST_MODE) == 0); - linespec_parser_new (&parser, flags, current_language, default_symtab, + linespec_parser_new (&parser, flags, current_language, + search_pspace, default_symtab, default_line, canonical); cleanups = make_cleanup (linespec_parser_delete, &parser); save_current_program_space (); @@ -2598,6 +2636,7 @@ decode_line_full (const struct event_location *location, int flags, struct symtabs_and_lines decode_line_1 (const struct event_location *location, int flags, + struct program_space *search_pspace, struct symtab *default_symtab, int default_line) { @@ -2605,7 +2644,8 @@ decode_line_1 (const struct event_location *location, int flags, linespec_parser parser; struct cleanup *cleanups; - linespec_parser_new (&parser, flags, current_language, default_symtab, + linespec_parser_new (&parser, flags, current_language, + search_pspace, default_symtab, default_line, NULL); cleanups = make_cleanup (linespec_parser_delete, &parser); save_current_program_space (); @@ -2635,7 +2675,7 @@ decode_line_with_current_source (char *string, int flags) location = string_to_event_location (&string, current_language); cleanup = make_cleanup_delete_event_location (location); - sals = decode_line_1 (location, flags, + sals = decode_line_1 (location, flags, NULL, cursal.symtab, cursal.line); if (*string) @@ -2660,11 +2700,11 @@ decode_line_with_last_displayed (char *string, int flags) location = string_to_event_location (&string, current_language); cleanup = make_cleanup_delete_event_location (location); if (last_displayed_sal_is_valid ()) - sals = decode_line_1 (location, flags, + sals = decode_line_1 (location, flags, NULL, get_last_displayed_symtab (), get_last_displayed_line ()); else - sals = decode_line_1 (location, flags, (struct symtab *) NULL, 0); + sals = decode_line_1 (location, flags, NULL, (struct symtab *) NULL, 0); if (*string) error (_("Junk at end of line specification: %s"), string); @@ -2754,11 +2794,11 @@ decode_objc (struct linespec_state *self, linespec_p ls, const char *arg) { char *saved_arg; - saved_arg = alloca (new_argptr - arg + 1); + saved_arg = (char *) alloca (new_argptr - arg + 1); memcpy (saved_arg, arg, new_argptr - arg); saved_arg[new_argptr - arg] = '\0'; - ls->explicit.function_name = xstrdup (saved_arg); + ls->explicit_loc.function_name = xstrdup (saved_arg); ls->function_symbols = info.result.symbols; ls->minimal_symbols = info.result.minimal_symbols; values = convert_linespec_to_sals (self, ls); @@ -2769,10 +2809,10 @@ decode_objc (struct linespec_state *self, linespec_p ls, const char *arg) self->canonical->pre_expanded = 1; - if (ls->explicit.source_filename) + if (ls->explicit_loc.source_filename) { str = xstrprintf ("%s:%s", - ls->explicit.source_filename, saved_arg); + ls->explicit_loc.source_filename, saved_arg); } else str = xstrdup (saved_arg); @@ -2806,7 +2846,8 @@ struct decode_compound_collector static int collect_one_symbol (struct symbol *sym, void *d) { - struct decode_compound_collector *collector = d; + struct decode_compound_collector *collector + = (struct decode_compound_collector *) d; void **slot; struct type *t; @@ -2886,8 +2927,8 @@ lookup_prefix_sym (struct linespec_state *state, VEC (symtab_ptr) *file_symtabs, static int compare_symbols (const void *a, const void *b) { - struct symbol * const *sa = a; - struct symbol * const *sb = b; + struct symbol * const *sa = (struct symbol * const*) a; + struct symbol * const *sb = (struct symbol * const*) b; uintptr_t uia, uib; uia = (uintptr_t) SYMTAB_PSPACE (symbol_symtab (*sa)); @@ -2914,8 +2955,10 @@ compare_symbols (const void *a, const void *b) static int compare_msymbols (const void *a, const void *b) { - const struct bound_minimal_symbol *sa = a; - const struct bound_minimal_symbol *sb = b; + const struct bound_minimal_symbol *sa + = (const struct bound_minimal_symbol *) a; + const struct bound_minimal_symbol *sb + = (const struct bound_minimal_symbol *) b; uintptr_t uia, uib; uia = (uintptr_t) sa->objfile->pspace; @@ -3096,7 +3139,7 @@ struct symtab_collector static int add_symtabs_to_list (struct symtab *symtab, void *d) { - struct symtab_collector *data = d; + struct symtab_collector *data = (struct symtab_collector *) d; void **slot; slot = htab_find_slot (data->symtab_table, symtab, INSERT); @@ -3109,10 +3152,13 @@ add_symtabs_to_list (struct symtab *symtab, void *d) return 0; } -/* Given a file name, return a VEC of all matching symtabs. */ +/* Given a file name, return a VEC of all matching symtabs. If + SEARCH_PSPACE is not NULL, the search is restricted to just that + program space. */ static VEC (symtab_ptr) * -collect_symtabs_from_filename (const char *file) +collect_symtabs_from_filename (const char *file, + struct program_space *search_pspace) { struct symtab_collector collector; struct cleanup *cleanups; @@ -3124,27 +3170,37 @@ collect_symtabs_from_filename (const char *file) cleanups = make_cleanup_htab_delete (collector.symtab_table); /* Find that file's data. */ - ALL_PSPACES (pspace) - { - if (pspace->executing_startup) - continue; + if (search_pspace == NULL) + { + ALL_PSPACES (pspace) + { + if (pspace->executing_startup) + continue; - set_current_program_space (pspace); - iterate_over_symtabs (file, add_symtabs_to_list, &collector); - } + set_current_program_space (pspace); + iterate_over_symtabs (file, add_symtabs_to_list, &collector); + } + } + else + { + set_current_program_space (search_pspace); + iterate_over_symtabs (file, add_symtabs_to_list, &collector); + } do_cleanups (cleanups); return collector.symtabs; } -/* Return all the symtabs associated to the FILENAME. */ +/* Return all the symtabs associated to the FILENAME. If SEARCH_PSPACE is + not NULL, the search is restricted to just that program space. */ static VEC (symtab_ptr) * -symtabs_from_filename (const char *filename) +symtabs_from_filename (const char *filename, + struct program_space *search_pspace) { VEC (symtab_ptr) *result; - result = collect_symtabs_from_filename (filename); + result = collect_symtabs_from_filename (filename, search_pspace); if (VEC_empty (symtab_ptr, result)) { @@ -3181,9 +3237,10 @@ find_function_symbols (struct linespec_state *state, /* Try NAME as an Objective-C selector. */ find_imps (name, &symbol_names); if (!VEC_empty (const_char_ptr, symbol_names)) - add_all_symbol_names_from_pspace (&info, NULL, symbol_names); + add_all_symbol_names_from_pspace (&info, state->search_pspace, + symbol_names); else - add_matching_symbols_to_info (name, &info, NULL); + add_matching_symbols_to_info (name, &info, state->search_pspace); do_cleanups (cleanup); @@ -3286,14 +3343,14 @@ find_linespec_symbols (struct linespec_state *state, /* LOOKUP_NAME points to the class name. LAST points to the method name. */ - klass = xmalloc ((last - lookup_name + 1) * sizeof (char)); + klass = XNEWVEC (char, last - lookup_name + 1); make_cleanup (xfree, klass); strncpy (klass, lookup_name, last - lookup_name); klass[last - lookup_name] = '\0'; /* Skip past the scope operator. */ last += strlen (scope_op); - method = xmalloc ((strlen (last) + 1) * sizeof (char)); + method = XNEWVEC (char, strlen (last) + 1); make_cleanup (xfree, method); strcpy (method, last); @@ -3519,7 +3576,7 @@ linespec_parse_variable (struct linespec_state *self, const char *variable) static int collect_symbols (struct symbol *sym, void *data) { - struct collect_info *info = data; + struct collect_info *info = (struct collect_info *) data; /* In list mode, add all matching symbols, regardless of class. This allows the user to type "list a_global_variable". */ @@ -3566,6 +3623,8 @@ minsym_found (struct linespec_state *self, struct objfile *objfile, sal.pc = MSYMBOL_VALUE_ADDRESS (objfile, msymbol); sal.pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc, ¤t_target); + if (gdbarch_skip_entrypoint_p (gdbarch)) + sal.pc = gdbarch_skip_entrypoint (gdbarch, sal.pc); } else skip_prologue_sal (&sal); @@ -3625,8 +3684,8 @@ classify_mtype (enum minimal_symbol_type t) static int compare_msyms (const void *a, const void *b) { - const bound_minimal_symbol_d *moa = a; - const bound_minimal_symbol_d *mob = b; + const bound_minimal_symbol_d *moa = (const bound_minimal_symbol_d *) a; + const bound_minimal_symbol_d *mob = (const bound_minimal_symbol_d *) b; enum minimal_symbol_type ta = MSYMBOL_TYPE (moa->minsym); enum minimal_symbol_type tb = MSYMBOL_TYPE (mob->minsym); @@ -3639,7 +3698,7 @@ compare_msyms (const void *a, const void *b) static void add_minsym (struct minimal_symbol *minsym, void *d) { - struct collect_minsyms *info = d; + struct collect_minsyms *info = (struct collect_minsyms *) d; bound_minimal_symbol_d mo; mo.minsym = minsym; @@ -3893,7 +3952,7 @@ destroy_linespec_result (struct linespec_result *ls) static void cleanup_linespec_result (void *a) { - destroy_linespec_result (a); + destroy_linespec_result ((struct linespec_result *) a); } /* See the comment in linespec.h. */ @@ -3903,3 +3962,11 @@ make_cleanup_destroy_linespec_result (struct linespec_result *ls) { return make_cleanup (cleanup_linespec_result, ls); } + +/* Return the quote characters permitted by the linespec parser. */ + +const char * +get_gdb_linespec_parser_quote_characters (void) +{ + return linespec_quote_characters; +}