diff options
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 84 |
1 files changed, 33 insertions, 51 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 7c60624..9dd3b31 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -194,8 +194,6 @@ static void move_bits (gdb_byte *, int, const gdb_byte *, int, int, int); static struct value *coerce_unspec_val_to_type (struct value *, struct type *); -static struct value *get_var_value (char *, char *); - static int lesseq_defined_than (struct symbol *, struct symbol *); static int equiv_types (struct type *, struct type *); @@ -6440,10 +6438,10 @@ symbol_completion_match (const char *sym_name, return sym_name; } -/* A companion function to ada_make_symbol_completion_list(). +/* A companion function to ada_collect_symbol_completion_matches(). Check if SYM_NAME represents a symbol which name would be suitable - to complete TEXT (TEXT_LEN is the length of TEXT), in which case - it is appended at the end of the given string vector SV. + to complete TEXT (TEXT_LEN is the length of TEXT), in which case it + is added as a completion match to TRACKER. ORIG_TEXT is the string original string from the user command that needs to be completed. WORD is the entire command on which @@ -6456,8 +6454,8 @@ symbol_completion_match (const char *sym_name, encoded). */ static void -symbol_completion_add (VEC(char_ptr) **sv, - const char *sym_name, +symbol_completion_add (completion_tracker &tracker, + const char *sym_name, const char *text, int text_len, const char *orig_text, const char *word, int wild_match_p, int encoded_p) @@ -6492,21 +6490,22 @@ symbol_completion_add (VEC(char_ptr) **sv, strcat (completion, match); } - VEC_safe_push (char_ptr, *sv, completion); + tracker.add_completion (gdb::unique_xmalloc_ptr<char> (completion)); } -/* Return a list of possible symbol names completing TEXT0. WORD is - the entire command on which completion is made. */ +/* Add the list of possible symbol names completing TEXT0 to TRACKER. + WORD is the entire command on which completion is made. */ -static VEC (char_ptr) * -ada_make_symbol_completion_list (const char *text0, const char *word, - enum type_code code) +static void +ada_collect_symbol_completion_matches (completion_tracker &tracker, + complete_symbol_mode mode, + const char *text0, const char *word, + enum type_code code) { char *text; int text_len; int wild_match_p; int encoded_p; - VEC(char_ptr) *completions = VEC_alloc (char_ptr, 128); struct symbol *sym; struct compunit_symtab *s; struct minimal_symbol *msymbol; @@ -6562,7 +6561,7 @@ ada_make_symbol_completion_list (const char *text0, const char *word, ALL_MSYMBOLS (objfile, msymbol) { QUIT; - symbol_completion_add (&completions, MSYMBOL_LINKAGE_NAME (msymbol), + symbol_completion_add (tracker, MSYMBOL_LINKAGE_NAME (msymbol), text, text_len, text0, word, wild_match_p, encoded_p); } @@ -6577,7 +6576,7 @@ ada_make_symbol_completion_list (const char *text0, const char *word, ALL_BLOCK_SYMBOLS (b, iter, sym) { - symbol_completion_add (&completions, SYMBOL_LINKAGE_NAME (sym), + symbol_completion_add (tracker, SYMBOL_LINKAGE_NAME (sym), text, text_len, text0, word, wild_match_p, encoded_p); } @@ -6592,7 +6591,7 @@ ada_make_symbol_completion_list (const char *text0, const char *word, b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK); ALL_BLOCK_SYMBOLS (b, iter, sym) { - symbol_completion_add (&completions, SYMBOL_LINKAGE_NAME (sym), + symbol_completion_add (tracker, SYMBOL_LINKAGE_NAME (sym), text, text_len, text0, word, wild_match_p, encoded_p); } @@ -6607,14 +6606,13 @@ ada_make_symbol_completion_list (const char *text0, const char *word, continue; ALL_BLOCK_SYMBOLS (b, iter, sym) { - symbol_completion_add (&completions, SYMBOL_LINKAGE_NAME (sym), + symbol_completion_add (tracker, SYMBOL_LINKAGE_NAME (sym), text, text_len, text0, word, wild_match_p, encoded_p); } } do_cleanups (old_chain); - return completions; } /* Field Access */ @@ -8989,12 +8987,11 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr, const char *name = ada_type_name (fixed_record_type); char *xvz_name = (char *) alloca (strlen (name) + 7 /* "___XVZ\0" */); - int xvz_found = 0; LONGEST size; xsnprintf (xvz_name, strlen (name) + 7, "%s___XVZ", name); - size = get_int_var_value (xvz_name, &xvz_found); - if (xvz_found && TYPE_LENGTH (fixed_record_type) != size) + if (get_int_var_value (xvz_name, size) + && TYPE_LENGTH (fixed_record_type) != size) { fixed_record_type = copy_type (fixed_record_type); TYPE_LENGTH (fixed_record_type) = size; @@ -11614,7 +11611,7 @@ scan_discrim_bound (const char *str, int k, struct value *dval, LONGEST * px, otherwise causes an error with message ERR_MSG. */ static struct value * -get_var_value (char *name, char *err_msg) +get_var_value (const char *name, const char *err_msg) { struct block_symbol *syms; int nsyms; @@ -11633,27 +11630,20 @@ get_var_value (char *name, char *err_msg) return value_of_variable (syms[0].symbol, syms[0].block); } -/* Value of integer variable named NAME in the current environment. If - no such variable found, returns 0, and sets *FLAG to 0. If - successful, sets *FLAG to 1. */ +/* Value of integer variable named NAME in the current environment. + If no such variable is found, returns false. Otherwise, sets VALUE + to the variable's value and returns true. */ -LONGEST -get_int_var_value (char *name, int *flag) +bool +get_int_var_value (const char *name, LONGEST &value) { struct value *var_val = get_var_value (name, 0); if (var_val == 0) - { - if (flag != NULL) - *flag = 0; - return 0; - } - else - { - if (flag != NULL) - *flag = 1; - return value_as_long (var_val); - } + return false; + + value = value_as_long (var_val); + return true; } @@ -11725,11 +11715,8 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) } else { - int ok; - strcpy (name_buf + prefix_len, "___L"); - L = get_int_var_value (name_buf, &ok); - if (!ok) + if (!get_int_var_value (name_buf, L)) { lim_warning (_("Unknown lower bound, using 1.")); L = 1; @@ -11744,11 +11731,8 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) } else { - int ok; - strcpy (name_buf + prefix_len, "___U"); - U = get_int_var_value (name_buf, &ok); - if (!ok) + if (!get_int_var_value (name_buf, U)) { lim_warning (_("Unknown upper bound, using %ld."), (long) L); U = L; @@ -13976,7 +13960,7 @@ static const char *ada_extensions[] = ".adb", ".ads", ".a", ".ada", ".dg", NULL }; -const struct language_defn ada_language_defn = { +extern const struct language_defn ada_language_defn = { "ada", /* Language name */ "Ada", language_ada, @@ -14010,7 +13994,7 @@ const struct language_defn ada_language_defn = { 0, /* c-style arrays */ 1, /* String lower bound */ ada_get_gdb_completer_word_break_characters, - ada_make_symbol_completion_list, + ada_collect_symbol_completion_matches, ada_language_arch_info, ada_print_array_index, default_pass_by_reference, @@ -14107,8 +14091,6 @@ ada_free_objfile_observer (struct objfile *objfile) void _initialize_ada_language (void) { - add_language (&ada_language_defn); - initialize_ada_catchpoint_ops (); add_prefix_cmd ("ada", no_class, set_ada_command, |