aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog21
-rw-r--r--gdb/ada-lang.c1740
-rw-r--r--gdb/ada-lang.h4
-rw-r--r--gdb/defs.h1
-rw-r--r--gdb/gdbtypes.h11
-rw-r--r--gdb/symfile.c4
6 files changed, 40 insertions, 1741 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 95b5c60..62819e7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,24 @@
+2004-10-01 Paul N. Hilfinger <Hilfinger@gnat.com>
+
+ * symfile.c (init_filename_language_table): Add extensions for
+ Ada.
+ * defs.h (enum language): Add language_ada.
+ * gdbtypes.h (TYPE_FLAG_FIXED_INSTANCE): Define.
+ * ada-lang.c: Strip code that is conditionalized out by GNAT_GDB.
+ (add_symbols_from_enclosing_procs): Make a no-op for now.
+ (ada_unqualified_name,add_angle_brackets,function_name_from_pc)
+ (extended_canonical_line_spec, find_sal_from_funcs_and_line)
+ (find_line_in_linetable, find_next_line_in_linetable)
+ (read_all_symtabs, is_plausible_func_for_line)
+ (adjust_pc_past_prologue, error_breakpoint_runtime_sym_not_found)
+ (is_runtime_sym_defined, check_size): Remove declaration.
+ (function_name_from_pc, ada_translate_error_message)
+ (ada_lookup_minimal_symbol): Remove definition.
+ (ada_add_block_symbols): Remove useless label.
+ * ada-lang.h (ada_maybe_exception_partial_symbol): Remove
+ useless declaration.
+ (ada_is_exception_sym): Likewise.
+
2004-09-30 Kei Sakamoto <sakamoto.kei@renesas.com>
Add m32r-linux support.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 0babcca..c4e04b7 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -19,18 +19,6 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* Sections of code marked
-
- #ifdef GNAT_GDB
- ...
- #endif
-
- indicate sections that are used in sources distributed by
- ACT, Inc., but not yet integrated into the public tree (where
- GNAT_GDB is not defined). They are retained here nevertheless
- to minimize the problems of maintaining different versions
- of the source and to make the full source available. */
-
#include "defs.h"
#include <stdio.h>
#include "gdb_string.h"
@@ -75,27 +63,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2)
#endif
-#ifdef GNAT_GDB
-/* A structure that contains a vector of strings.
- The main purpose of this type is to group the vector and its
- associated parameters in one structure. This makes it easier
- to handle and pass around. */
-
-struct string_vector
-{
- char **array; /* The vector itself. */
- int index; /* Index of the next available element in the array. */
- size_t size; /* The number of entries allocated in the array. */
-};
-static struct string_vector xnew_string_vector (int initial_size);
-static void string_vector_append (struct string_vector *sv, char *str);
-#endif /* GNAT_GDB */
-
-static const char *ada_unqualified_name (const char *decoded_name);
-static char *add_angle_brackets (const char *str);
static void extract_string (CORE_ADDR addr, char *buf);
-static char *function_name_from_pc (CORE_ADDR pc);
static struct type *ada_create_fundamental_type (struct objfile *, int);
@@ -184,9 +153,6 @@ static int discrete_type_p (struct type *);
static struct type *ada_lookup_struct_elt_type (struct type *, char *,
int, int, int *);
-static char *extended_canonical_line_spec (struct symtab_and_line,
- const char *);
-
static struct value *evaluate_subexp (struct type *, struct expression *,
int *, enum noside);
@@ -228,19 +194,6 @@ static int is_name_suffix (const char *);
static int wild_match (const char *, int, const char *);
-static struct symtabs_and_lines
-find_sal_from_funcs_and_line (const char *, int,
- struct ada_symbol_info *, int);
-
-static int find_line_in_linetable (struct linetable *, int,
- struct ada_symbol_info *, int, int *);
-
-static int find_next_line_in_linetable (struct linetable *, int, int, int);
-
-static void read_all_symtabs (const char *);
-
-static int is_plausible_func_for_line (struct symbol *, int);
-
static struct value *ada_coerce_ref (struct value *);
static LONGEST pos_atr (struct value *);
@@ -266,8 +219,6 @@ static struct value *ada_to_fixed_value_create (struct type *, CORE_ADDR,
static struct value *ada_to_fixed_value (struct value *);
-static void adjust_pc_past_prologue (CORE_ADDR *);
-
static int ada_resolve_function (struct ada_symbol_info *, int,
struct value **, int, const char *,
struct type *);
@@ -276,14 +227,8 @@ static struct value *ada_coerce_to_simple_array (struct value *);
static int ada_is_direct_array_type (struct type *);
-static void error_breakpoint_runtime_sym_not_found (const char *err_desc);
-
-static int is_runtime_sym_defined (const char *name, int allow_tramp);
-
static void ada_language_arch_info (struct gdbarch *,
struct language_arch_info *);
-
-static void check_size (const struct type *);
@@ -346,69 +291,6 @@ static struct obstack symbol_list_obstack;
/* Utilities */
-#ifdef GNAT_GDB
-
-/* Create a new empty string_vector struct with an initial size of
- INITIAL_SIZE. */
-
-static struct string_vector
-xnew_string_vector (int initial_size)
-{
- struct string_vector result;
-
- result.array = (char **) xmalloc ((initial_size + 1) * sizeof (char *));
- result.index = 0;
- result.size = initial_size;
-
- return result;
-}
-
-/* Add STR at the end of the given string vector SV. If SV is already
- full, its size is automatically increased (doubled). */
-
-static void
-string_vector_append (struct string_vector *sv, char *str)
-{
- if (sv->index >= sv->size)
- GROW_VECT (sv->array, sv->size, sv->size * 2);
-
- sv->array[sv->index] = str;
- sv->index++;
-}
-
-/* Given DECODED_NAME a string holding a symbol name in its
- decoded form (ie using the Ada dotted notation), returns
- its unqualified name. */
-
-static const char *
-ada_unqualified_name (const char *decoded_name)
-{
- const char *result = strrchr (decoded_name, '.');
-
- if (result != NULL)
- result++; /* Skip the dot... */
- else
- result = decoded_name;
-
- return result;
-}
-
-/* Return a string starting with '<', followed by STR, and '>'.
- The result is good until the next call. */
-
-static char *
-add_angle_brackets (const char *str)
-{
- static char *result = NULL;
-
- xfree (result);
- result = (char *) xmalloc ((strlen (str) + 3) * sizeof (char));
-
- sprintf (result, "<%s>", str);
- return result;
-}
-
-#endif /* GNAT_GDB */
static char *
ada_get_gdb_completer_word_break_characters (void)
@@ -435,20 +317,6 @@ extract_string (CORE_ADDR addr, char *buf)
while (buf[char_index - 1] != '\000');
}
-/* Return the name of the function owning the instruction located at PC.
- Return NULL if no such function could be found. */
-
-static char *
-function_name_from_pc (CORE_ADDR pc)
-{
- char *func_name;
-
- if (!find_pc_partial_function (pc, &func_name, NULL, NULL))
- return NULL;
-
- return func_name;
-}
-
/* Assuming *OLD_VECT points to an array of *SIZE objects of size
ELEMENT_SIZE, grow it to contain at least MIN_SIZE objects,
updating *OLD_VECT and *SIZE as necessary. */
@@ -617,15 +485,6 @@ lim_warning (const char *format, long arg)
warning (format, arg);
}
-static const char *
-ada_translate_error_message (const char *string)
-{
- if (strcmp (string, "Invalid cast.") == 0)
- return "Invalid type conversion.";
- else
- return string;
-}
-
/* Note: would have used MAX_OF_TYPE and MIN_OF_TYPE macros from
gdbtypes.h, but some of the necessary definitions in that file
seem to have gone missing. */
@@ -3713,112 +3572,14 @@ ada_convert_actuals (struct value *func, int nargs, struct value *args[],
convert_actual (args[i], TYPE_FIELD_TYPE (VALUE_TYPE (func), i), sp);
}
- /* Experimental Symbol Cache Module */
-
-/* This module may well have been OBE, due to improvements in the
- symbol-table module. So until proven otherwise, it is disabled in
- the submitted public code, and may be removed from all sources
- in the future. */
-
-#ifdef GNAT_GDB
-
-/* This section implements a simple, fixed-sized hash table for those
- Ada-mode symbols that get looked up in the course of executing the user's
- commands. The size is fixed on the grounds that there are not
- likely to be all that many symbols looked up during any given
- session, regardless of the size of the symbol table. If we decide
- to go to a resizable table, let's just use the stuff from libiberty
- instead. */
-
-#define HASH_SIZE 1009
-
-struct cache_entry
-{
- const char *name;
- domain_enum namespace;
- struct symbol *sym;
- struct symtab *symtab;
- struct block *block;
- struct cache_entry *next;
-};
-
-static struct obstack cache_space;
-
-static struct cache_entry *cache[HASH_SIZE];
-
-/* Clear all entries from the symbol cache. */
-
-void
-clear_ada_sym_cache (void)
-{
- obstack_free (&cache_space, NULL);
- obstack_init (&cache_space);
- memset (cache, '\000', sizeof (cache));
-}
-
-static struct cache_entry **
-find_entry (const char *name, domain_enum namespace)
-{
- int h = msymbol_hash (name) % HASH_SIZE;
- struct cache_entry **e;
- for (e = &cache[h]; *e != NULL; e = &(*e)->next)
- {
- if (namespace == (*e)->namespace && strcmp (name, (*e)->name) == 0)
- return e;
- }
- return NULL;
-}
-
-/* Return (in SYM) the last cached definition for global or static symbol NAME
- in namespace DOMAIN. Returns 1 if entry found, 0 otherwise.
- If SYMTAB is non-NULL, store the symbol
- table in which the symbol was found there, or NULL if not found.
- *BLOCK is set to the block in which NAME is found. */
+/* Dummy definitions for an experimental caching module that is not
+ * used in the public sources. */
static int
lookup_cached_symbol (const char *name, domain_enum namespace,
struct symbol **sym, struct block **block,
struct symtab **symtab)
{
- struct cache_entry **e = find_entry (name, namespace);
- if (e == NULL)
- return 0;
- if (sym != NULL)
- *sym = (*e)->sym;
- if (block != NULL)
- *block = (*e)->block;
- if (symtab != NULL)
- *symtab = (*e)->symtab;
- return 1;
-}
-
-/* Set the cached definition of NAME in DOMAIN to SYM in block
- BLOCK and symbol table SYMTAB. */
-
-static void
-cache_symbol (const char *name, domain_enum namespace, struct symbol *sym,
- struct block *block, struct symtab *symtab)
-{
- int h = msymbol_hash (name) % HASH_SIZE;
- char *copy;
- struct cache_entry *e =
- (struct cache_entry *) obstack_alloc (&cache_space, sizeof (*e));
- e->next = cache[h];
- cache[h] = e;
- e->name = copy = obstack_alloc (&cache_space, strlen (name) + 1);
- strcpy (copy, name);
- e->sym = sym;
- e->namespace = namespace;
- e->symtab = symtab;
- e->block = block;
-}
-
-#else
-static int
-lookup_cached_symbol (const char *name, domain_enum namespace,
- struct symbol **sym, struct block **block,
- struct symtab **symtab)
-{
return 0;
}
@@ -3827,7 +3588,6 @@ cache_symbol (const char *name, domain_enum namespace, struct symbol *sym,
struct block *block, struct symtab *symtab)
{
}
-#endif /* GNAT_GDB */
/* Symbol Lookup */
@@ -4209,16 +3969,6 @@ ada_lookup_simple_minsym (const char *name)
return NULL;
}
-/* Return up minimal symbol for NAME, folded and encoded according to
- Ada conventions, or NULL if none. The last two arguments are ignored. */
-
-static struct minimal_symbol *
-ada_lookup_minimal_symbol (const char *name, const char *sfile,
- struct objfile *objf)
-{
- return ada_lookup_simple_minsym (ada_encode (name));
-}
-
/* For all subprograms that statically enclose the subprogram of the
selected frame, add symbols matching identifier NAME in DOMAIN
and their blocks to the list of data in OBSTACKP, as for
@@ -4230,72 +3980,6 @@ add_symbols_from_enclosing_procs (struct obstack *obstackp,
const char *name, domain_enum namespace,
int wild_match)
{
-#ifdef HAVE_ADD_SYMBOLS_FROM_ENCLOSING_PROCS
- /* Use a heuristic to find the frames of enclosing subprograms: treat the
- pointer-sized value at location 0 from the local-variable base of a
- frame as a static link, and then search up the call stack for a
- frame with that same local-variable base. */
- static struct symbol static_link_sym;
- static struct symbol *static_link;
- struct value *target_link_val;
-
- struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
- struct frame_info *frame;
-
- if (!target_has_stack)
- return;
-
- if (static_link == NULL)
- {
- /* Initialize the local variable symbol that stands for the
- static link (when there is one). */
- static_link = &static_link_sym;
- SYMBOL_LINKAGE_NAME (static_link) = "";
- SYMBOL_LANGUAGE (static_link) = language_unknown;
- SYMBOL_CLASS (static_link) = LOC_LOCAL;
- SYMBOL_DOMAIN (static_link) = VAR_DOMAIN;
- SYMBOL_TYPE (static_link) = lookup_pointer_type (builtin_type_void);
- SYMBOL_VALUE (static_link) =
- -(long) TYPE_LENGTH (SYMBOL_TYPE (static_link));
- }
-
- frame = get_selected_frame ();
- if (frame == NULL || inside_main_func (get_frame_address_in_block (frame)))
- return;
-
- target_link_val = read_var_value (static_link, frame);
- while (target_link_val != NULL
- && num_defns_collected (obstackp) == 0
- && frame_relative_level (frame) <= MAX_ENCLOSING_FRAME_LEVELS)
- {
- CORE_ADDR target_link = value_as_address (target_link_val);
-
- frame = get_prev_frame (frame);
- if (frame == NULL)
- break;
-
- if (get_frame_locals_address (frame) == target_link)
- {
- struct block *block;
-
- QUIT;
-
- block = get_frame_block (frame, 0);
- while (block != NULL && block_function (block) != NULL
- && num_defns_collected (obstackp) == 0)
- {
- QUIT;
-
- ada_add_block_symbols (obstackp, block, name, namespace,
- NULL, NULL, wild_match);
-
- block = BLOCK_SUPERBLOCK (block);
- }
- }
- }
-
- do_cleanups (old_chain);
-#endif
}
/* FIXME: The next two routines belong in symtab.c */
@@ -4758,8 +4442,6 @@ done:
set to 0 and *SYMTAB is set to the symbol table in which the symbol
was found (in both cases, these assignments occur only if the
pointers are non-null). */
-
-
struct symbol *
ada_lookup_symbol (const char *name, const struct block *block0,
domain_enum namespace, int *is_a_field_of_this,
@@ -5178,7 +4860,6 @@ ada_add_block_symbols (struct obstack *obstackp,
}
}
}
- end_loop2:;
}
/* NOTE: This really shouldn't be needed for _ada_ symbols.
@@ -5192,1388 +4873,6 @@ ada_add_block_symbols (struct obstack *obstackp,
}
}
-#ifdef GNAT_GDB
-
- /* Symbol Completion */
-
-/* If SYM_NAME is a completion candidate for TEXT, return this symbol
- name in a form that's appropriate for the completion. The result
- does not need to be deallocated, but is only good until the next call.
-
- TEXT_LEN is equal to the length of TEXT.
- Perform a wild match if WILD_MATCH is set.
- ENCODED should be set if TEXT represents the start of a symbol name
- in its encoded form. */
-
-static const char *
-symbol_completion_match (const char *sym_name,
- const char *text, int text_len,
- int wild_match, int encoded)
-{
- char *result;
- const int verbatim_match = (text[0] == '<');
- int match = 0;
-
- if (verbatim_match)
- {
- /* Strip the leading angle bracket. */
- text = text + 1;
- text_len--;
- }
-
- /* First, test against the fully qualified name of the symbol. */
-
- if (strncmp (sym_name, text, text_len) == 0)
- match = 1;
-
- if (match && !encoded)
- {
- /* One needed check before declaring a positive match is to verify
- that iff we are doing a verbatim match, the decoded version
- of the symbol name starts with '<'. Otherwise, this symbol name
- is not a suitable completion. */
- const char *sym_name_copy = sym_name;
- int has_angle_bracket;
-
- sym_name = ada_decode (sym_name);
- has_angle_bracket = (sym_name[0] == '<');
- match = (has_angle_bracket == verbatim_match);
- sym_name = sym_name_copy;
- }
-
- if (match && !verbatim_match)
- {
- /* When doing non-verbatim match, another check that needs to
- be done is to verify that the potentially matching symbol name
- does not include capital letters, because the ada-mode would
- not be able to understand these symbol names without the
- angle bracket notation. */
- const char *tmp;
-
- for (tmp = sym_name; *tmp != '\0' && !isupper (*tmp); tmp++);
- if (*tmp != '\0')
- match = 0;
- }
-
- /* Second: Try wild matching... */
-
- if (!match && wild_match)
- {
- /* Since we are doing wild matching, this means that TEXT
- may represent an unqualified symbol name. We therefore must
- also compare TEXT against the unqualified name of the symbol. */
- sym_name = ada_unqualified_name (ada_decode (sym_name));
-
- if (strncmp (sym_name, text, text_len) == 0)
- match = 1;
- }
-
- /* Finally: If we found a mach, prepare the result to return. */
-
- if (!match)
- return NULL;
-
- if (verbatim_match)
- sym_name = add_angle_brackets (sym_name);
-
- if (!encoded)
- sym_name = ada_decode (sym_name);
-
- return sym_name;
-}
-
-/* A companion function to ada_make_symbol_completion_list().
- 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.
-
- ORIG_TEXT is the string original string from the user command
- that needs to be completed. WORD is the entire command on which
- completion should be performed. These two parameters are used to
- determine which part of the symbol name should be added to the
- completion vector.
- if WILD_MATCH is set, then wild matching is performed.
- ENCODED should be set if TEXT represents a symbol name in its
- encoded formed (in which case the completion should also be
- encoded). */
-
-static void
-symbol_completion_add (struct string_vector *sv,
- const char *sym_name,
- const char *text, int text_len,
- const char *orig_text, const char *word,
- int wild_match, int encoded)
-{
- const char *match = symbol_completion_match (sym_name, text, text_len,
- wild_match, encoded);
- char *completion;
-
- if (match == NULL)
- return;
-
- /* We found a match, so add the appropriate completion to the given
- string vector. */
-
- if (word == orig_text)
- {
- completion = xmalloc (strlen (match) + 5);
- strcpy (completion, match);
- }
- else if (word > orig_text)
- {
- /* Return some portion of sym_name. */
- completion = xmalloc (strlen (match) + 5);
- strcpy (completion, match + (word - orig_text));
- }
- else
- {
- /* Return some of ORIG_TEXT plus sym_name. */
- completion = xmalloc (strlen (match) + (orig_text - word) + 5);
- strncpy (completion, word, orig_text - word);
- completion[orig_text - word] = '\0';
- strcat (completion, match);
- }
-
- string_vector_append (sv, completion);
-}
-
-/* Return a list of possible symbol names completing TEXT0. The list
- is NULL terminated. WORD is the entire command on which completion
- is made. */
-
-char **
-ada_make_symbol_completion_list (const char *text0, const char *word)
-{
- /* Note: This function is almost a copy of make_symbol_completion_list(),
- except it has been adapted for Ada. It is somewhat of a shame to
- duplicate so much code, but we don't really have the infrastructure
- yet to develop a language-aware version of he symbol completer... */
- char *text;
- int text_len;
- int wild_match;
- int encoded;
- struct string_vector result = xnew_string_vector (128);
- struct symbol *sym;
- struct symtab *s;
- struct partial_symtab *ps;
- struct minimal_symbol *msymbol;
- struct objfile *objfile;
- struct block *b, *surrounding_static_block = 0;
- int i;
- struct dict_iterator iter;
-
- if (text0[0] == '<')
- {
- text = xstrdup (text0);
- make_cleanup (xfree, text);
- text_len = strlen (text);
- wild_match = 0;
- encoded = 1;
- }
- else
- {
- text = xstrdup (ada_encode (text0));
- make_cleanup (xfree, text);
- text_len = strlen (text);
- for (i = 0; i < text_len; i++)
- text[i] = tolower (text[i]);
-
- /* FIXME: brobecker/2003-09-17: When we get rid of ADA_RETAIN_DOTS,
- we can restrict the wild_match check to searching "__" only. */
- wild_match = (strstr (text0, "__") == NULL
- && strchr (text0, '.') == NULL);
- encoded = (strstr (text0, "__") != NULL);
- }
-
- /* First, look at the partial symtab symbols. */
- ALL_PSYMTABS (objfile, ps)
- {
- struct partial_symbol **psym;
-
- /* If the psymtab's been read in we'll get it when we search
- through the blockvector. */
- if (ps->readin)
- continue;
-
- for (psym = objfile->global_psymbols.list + ps->globals_offset;
- psym < (objfile->global_psymbols.list + ps->globals_offset
- + ps->n_global_syms); psym++)
- {
- QUIT;
- symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (*psym),
- text, text_len, text0, word,
- wild_match, encoded);
- }
-
- for (psym = objfile->static_psymbols.list + ps->statics_offset;
- psym < (objfile->static_psymbols.list + ps->statics_offset
- + ps->n_static_syms); psym++)
- {
- QUIT;
- symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (*psym),
- text, text_len, text0, word,
- wild_match, encoded);
- }
- }
-
- /* At this point scan through the misc symbol vectors and add each
- symbol you find to the list. Eventually we want to ignore
- anything that isn't a text symbol (everything else will be
- handled by the psymtab code above). */
-
- ALL_MSYMBOLS (objfile, msymbol)
- {
- QUIT;
- symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (msymbol),
- text, text_len, text0, word, wild_match, encoded);
- }
-
- /* Search upwards from currently selected frame (so that we can
- complete on local vars. */
-
- for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
- {
- if (!BLOCK_SUPERBLOCK (b))
- surrounding_static_block = b; /* For elmin of dups */
-
- ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym),
- text, text_len, text0, word,
- wild_match, encoded);
- }
- }
-
- /* Go through the symtabs and check the externs and statics for
- symbols which match. */
-
- ALL_SYMTABS (objfile, s)
- {
- QUIT;
- b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
- ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym),
- text, text_len, text0, word,
- wild_match, encoded);
- }
- }
-
- ALL_SYMTABS (objfile, s)
- {
- QUIT;
- b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
- /* Don't do this block twice. */
- if (b == surrounding_static_block)
- continue;
- ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym),
- text, text_len, text0, word,
- wild_match, encoded);
- }
- }
-
- /* Append the closing NULL entry. */
- string_vector_append (&result, NULL);
-
- return (result.array);
-}
-
-#endif /* GNAT_GDB */
-
-#ifdef GNAT_GDB
- /* Breakpoint-related */
-
-/* Assuming that LINE is pointing at the beginning of an argument to
- 'break', return a pointer to the delimiter for the initial segment
- of that name. This is the first ':', ' ', or end of LINE. */
-
-char *
-ada_start_decode_line_1 (char *line)
-{
- /* NOTE: strpbrk would be more elegant, but I am reluctant to be
- the first to use such a library function in GDB code. */
- char *p;
- for (p = line; *p != '\000' && *p != ' ' && *p != ':'; p += 1)
- ;
- return p;
-}
-
-/* *SPEC points to a function and line number spec (as in a break
- command), following any initial file name specification.
-
- Return all symbol table/line specfications (sals) consistent with the
- information in *SPEC and FILE_TABLE in the following sense:
- + FILE_TABLE is null, or the sal refers to a line in the file
- named by FILE_TABLE.
- + If *SPEC points to an argument with a trailing ':LINENUM',
- then the sal refers to that line (or one following it as closely as
- possible).
- + If *SPEC does not start with '*', the sal is in a function with
- that name.
-
- Returns with 0 elements if no matching non-minimal symbols found.
-
- If *SPEC begins with a function name of the form <NAME>, then NAME
- is taken as a literal name; otherwise the function name is subject
- to the usual encoding.
-
- *SPEC is updated to point after the function/line number specification.
-
- FUNFIRSTLINE is non-zero if we desire the first line of real code
- in each function.
-
- If CANONICAL is non-NULL, and if any of the sals require a
- 'canonical line spec', then *CANONICAL is set to point to an array
- of strings, corresponding to and equal in length to the returned
- list of sals, such that (*CANONICAL)[i] is non-null and contains a
- canonical line spec for the ith returned sal, if needed. If no
- canonical line specs are required and CANONICAL is non-null,
- *CANONICAL is set to NULL.
-
- A 'canonical line spec' is simply a name (in the format of the
- breakpoint command) that uniquely identifies a breakpoint position,
- with no further contextual information or user selection. It is
- needed whenever the file name, function name, and line number
- information supplied is insufficient for this unique
- identification. Currently overloaded functions, the name '*',
- or static functions without a filename yield a canonical line spec.
- The array and the line spec strings are allocated on the heap; it
- is the caller's responsibility to free them. */
-
-struct symtabs_and_lines
-ada_finish_decode_line_1 (char **spec, struct symtab *file_table,
- int funfirstline, char ***canonical)
-{
- struct ada_symbol_info *symbols;
- const struct block *block;
- int n_matches, i, line_num;
- struct symtabs_and_lines selected;
- struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
- char *name;
- int is_quoted;
-
- int len;
- char *lower_name;
- char *unquoted_name;
-
- if (file_table == NULL)
- block = block_static_block (get_selected_block (0));
- else
- block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (file_table), STATIC_BLOCK);
-
- if (canonical != NULL)
- *canonical = (char **) NULL;
-
- is_quoted = (**spec && strchr (get_gdb_completer_quote_characters (),
- **spec) != NULL);
-
- name = *spec;
- if (**spec == '*')
- *spec += 1;
- else
- {
- if (is_quoted)
- *spec = skip_quoted (*spec);
- while (**spec != '\000'
- && !strchr (ada_completer_word_break_characters, **spec))
- *spec += 1;
- }
- len = *spec - name;
-
- line_num = -1;
- if (file_table != NULL && (*spec)[0] == ':' && isdigit ((*spec)[1]))
- {
- line_num = strtol (*spec + 1, spec, 10);
- while (**spec == ' ' || **spec == '\t')
- *spec += 1;
- }
-
- if (name[0] == '*')
- {
- if (line_num == -1)
- error ("Wild-card function with no line number or file name.");
-
- return ada_sals_for_line (file_table->filename, line_num,
- funfirstline, canonical, 0);
- }
-
- if (name[0] == '\'')
- {
- name += 1;
- len -= 2;
- }
-
- if (name[0] == '<')
- {
- unquoted_name = (char *) alloca (len - 1);
- memcpy (unquoted_name, name + 1, len - 2);
- unquoted_name[len - 2] = '\000';
- lower_name = NULL;
- }
- else
- {
- unquoted_name = (char *) alloca (len + 1);
- memcpy (unquoted_name, name, len);
- unquoted_name[len] = '\000';
- lower_name = (char *) alloca (len + 1);
- for (i = 0; i < len; i += 1)
- lower_name[i] = tolower (name[i]);
- lower_name[len] = '\000';
- }
-
- n_matches = 0;
- if (lower_name != NULL)
- n_matches = ada_lookup_symbol_list (ada_encode (lower_name), block,
- VAR_DOMAIN, &symbols);
- if (n_matches == 0)
- n_matches = ada_lookup_symbol_list (unquoted_name, block,
- VAR_DOMAIN, &symbols);
- if (n_matches == 0 && line_num >= 0)
- error ("No line number information found for %s.", unquoted_name);
- else if (n_matches == 0)
- {
-#ifdef HPPA_COMPILER_BUG
- /* FIXME: See comment in symtab.c::decode_line_1 */
-#undef volatile
- volatile struct symtab_and_line val;
-#define volatile /*nothing */
-#else
- struct symtab_and_line val;
-#endif
- struct minimal_symbol *msymbol;
-
- init_sal (&val);
-
- msymbol = NULL;
- if (lower_name != NULL)
- msymbol = ada_lookup_simple_minsym (ada_encode (lower_name));
- if (msymbol == NULL)
- msymbol = ada_lookup_simple_minsym (unquoted_name);
- if (msymbol != NULL)
- {
- val.pc = SYMBOL_VALUE_ADDRESS (msymbol);
- val.section = SYMBOL_BFD_SECTION (msymbol);
- if (funfirstline)
- {
- val.pc = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
- val.pc,
- &current_target);
- SKIP_PROLOGUE (val.pc);
- }
- selected.sals = (struct symtab_and_line *)
- xmalloc (sizeof (struct symtab_and_line));
- selected.sals[0] = val;
- selected.nelts = 1;
- return selected;
- }
-
- if (!have_full_symbols ()
- && !have_partial_symbols () && !have_minimal_symbols ())
- error ("No symbol table is loaded. Use the \"file\" command.");
-
- error ("Function \"%s\" not defined.", unquoted_name);
- return selected; /* for lint */
- }
-
- if (line_num >= 0)
- {
- struct symtabs_and_lines best_sal =
- find_sal_from_funcs_and_line (file_table->filename, line_num,
- symbols, n_matches);
- if (funfirstline)
- adjust_pc_past_prologue (&best_sal.sals[0].pc);
- return best_sal;
- }
- else
- {
- selected.nelts = user_select_syms (symbols, n_matches, n_matches);
- }
-
- selected.sals = (struct symtab_and_line *)
- xmalloc (sizeof (struct symtab_and_line) * selected.nelts);
- memset (selected.sals, 0, selected.nelts * sizeof (selected.sals[i]));
- make_cleanup (xfree, selected.sals);
-
- i = 0;
- while (i < selected.nelts)
- {
- if (SYMBOL_CLASS (symbols[i].sym) == LOC_BLOCK)
- selected.sals[i]
- = find_function_start_sal (symbols[i].sym, funfirstline);
- else if (SYMBOL_LINE (symbols[i].sym) != 0)
- {
- selected.sals[i].symtab =
- symbols[i].symtab
- ? symbols[i].symtab : symtab_for_sym (symbols[i].sym);
- selected.sals[i].line = SYMBOL_LINE (symbols[i].sym);
- }
- else if (line_num >= 0)
- {
- /* Ignore this choice */
- symbols[i] = symbols[selected.nelts - 1];
- selected.nelts -= 1;
- continue;
- }
- else
- error ("Line number not known for symbol \"%s\"", unquoted_name);
- i += 1;
- }
-
- if (canonical != NULL && (line_num >= 0 || n_matches > 1))
- {
- *canonical = (char **) xmalloc (sizeof (char *) * selected.nelts);
- for (i = 0; i < selected.nelts; i += 1)
- (*canonical)[i] =
- extended_canonical_line_spec (selected.sals[i],
- SYMBOL_PRINT_NAME (symbols[i].sym));
- }
-
- discard_cleanups (old_chain);
- return selected;
-}
-
-/* The (single) sal corresponding to line LINE_NUM in a symbol table
- with file name FILENAME that occurs in one of the functions listed
- in the symbol fields of SYMBOLS[0 .. NSYMS-1]. */
-
-static struct symtabs_and_lines
-find_sal_from_funcs_and_line (const char *filename, int line_num,
- struct ada_symbol_info *symbols, int nsyms)
-{
- struct symtabs_and_lines sals;
- int best_index, best;
- struct linetable *best_linetable;
- struct objfile *objfile;
- struct symtab *s;
- struct symtab *best_symtab;
-
- read_all_symtabs (filename);
-
- best_index = 0;
- best_linetable = NULL;
- best_symtab = NULL;
- best = 0;
- ALL_SYMTABS (objfile, s)
- {
- struct linetable *l;
- int ind, exact;
-
- QUIT;
-
- if (strcmp (filename, s->filename) != 0)
- continue;
- l = LINETABLE (s);
- ind = find_line_in_linetable (l, line_num, symbols, nsyms, &exact);
- if (ind >= 0)
- {
- if (exact)
- {
- best_index = ind;
- best_linetable = l;
- best_symtab = s;
- goto done;
- }
- if (best == 0 || l->item[ind].line < best)
- {
- best = l->item[ind].line;
- best_index = ind;
- best_linetable = l;
- best_symtab = s;
- }
- }
- }
-
- if (best == 0)
- error ("Line number not found in designated function.");
-
-done:
-
- sals.nelts = 1;
- sals.sals = (struct symtab_and_line *) xmalloc (sizeof (sals.sals[0]));
-
- init_sal (&sals.sals[0]);
-
- sals.sals[0].line = best_linetable->item[best_index].line;
- sals.sals[0].pc = best_linetable->item[best_index].pc;
- sals.sals[0].symtab = best_symtab;
-
- return sals;
-}
-
-/* Return the index in LINETABLE of the best match for LINE_NUM whose
- pc falls within one of the functions denoted by the symbol fields
- of SYMBOLS[0..NSYMS-1]. Set *EXACTP to 1 if the match is exact,
- and 0 otherwise. */
-
-static int
-find_line_in_linetable (struct linetable *linetable, int line_num,
- struct ada_symbol_info *symbols, int nsyms,
- int *exactp)
-{
- int i, len, best_index, best;
-
- if (line_num <= 0 || linetable == NULL)
- return -1;
-
- len = linetable->nitems;
- for (i = 0, best_index = -1, best = 0; i < len; i += 1)
- {
- int k;
- struct linetable_entry *item = &(linetable->item[i]);
-
- for (k = 0; k < nsyms; k += 1)
- {
- if (symbols[k].sym != NULL
- && SYMBOL_CLASS (symbols[k].sym) == LOC_BLOCK
- && item->pc >= BLOCK_START (SYMBOL_BLOCK_VALUE (symbols[k].sym))
- && item->pc < BLOCK_END (SYMBOL_BLOCK_VALUE (symbols[k].sym)))
- goto candidate;
- }
- continue;
-
- candidate:
-
- if (item->line == line_num)
- {
- *exactp = 1;
- return i;
- }
-
- if (item->line > line_num && (best == 0 || item->line < best))
- {
- best = item->line;
- best_index = i;
- }
- }
-
- *exactp = 0;
- return best_index;
-}
-
-/* Find the smallest k >= LINE_NUM such that k is a line number in
- LINETABLE, and k falls strictly within a named function that begins at
- or before LINE_NUM. Return -1 if there is no such k. */
-
-static int
-nearest_line_number_in_linetable (struct linetable *linetable, int line_num)
-{
- int i, len, best;
-
- if (line_num <= 0 || linetable == NULL || linetable->nitems == 0)
- return -1;
- len = linetable->nitems;
-
- i = 0;
- best = INT_MAX;
- while (i < len)
- {
- struct linetable_entry *item = &(linetable->item[i]);
-
- if (item->line >= line_num && item->line < best)
- {
- char *func_name;
- CORE_ADDR start, end;
-
- func_name = NULL;
- find_pc_partial_function (item->pc, &func_name, &start, &end);
-
- if (func_name != NULL && item->pc < end)
- {
- if (item->line == line_num)
- return line_num;
- else
- {
- struct symbol *sym =
- standard_lookup (func_name, NULL, VAR_DOMAIN);
- if (is_plausible_func_for_line (sym, line_num))
- best = item->line;
- else
- {
- do
- i += 1;
- while (i < len && linetable->item[i].pc < end);
- continue;
- }
- }
- }
- }
-
- i += 1;
- }
-
- return (best == INT_MAX) ? -1 : best;
-}
-
-
-/* Return the next higher index, k, into LINETABLE such that k > IND,
- entry k in LINETABLE has a line number equal to LINE_NUM, k
- corresponds to a PC that is in a function different from that
- corresponding to IND, and falls strictly within a named function
- that begins at a line at or preceding STARTING_LINE.
- Return -1 if there is no such k.
- IND == -1 corresponds to no function. */
-
-static int
-find_next_line_in_linetable (struct linetable *linetable, int line_num,
- int starting_line, int ind)
-{
- int i, len;
-
- if (line_num <= 0 || linetable == NULL || ind >= linetable->nitems)
- return -1;
- len = linetable->nitems;
-
- if (ind >= 0)
- {
- CORE_ADDR start, end;
-
- if (find_pc_partial_function (linetable->item[ind].pc,
- (char **) NULL, &start, &end))
- {
- while (ind < len && linetable->item[ind].pc < end)
- ind += 1;
- }
- else
- ind += 1;
- }
- else
- ind = 0;
-
- i = ind;
- while (i < len)
- {
- struct linetable_entry *item = &(linetable->item[i]);
-
- if (item->line >= line_num)
- {
- char *func_name;
- CORE_ADDR start, end;
-
- func_name = NULL;
- find_pc_partial_function (item->pc, &func_name, &start, &end);
-
- if (func_name != NULL && item->pc < end)
- {
- if (item->line == line_num)
- {
- struct symbol *sym =
- standard_lookup (func_name, NULL, VAR_DOMAIN);
- if (is_plausible_func_for_line (sym, starting_line))
- return i;
- else
- {
- while ((i + 1) < len && linetable->item[i + 1].pc < end)
- i += 1;
- }
- }
- }
- }
- i += 1;
- }
-
- return -1;
-}
-
-/* True iff function symbol SYM starts somewhere at or before line #
- LINE_NUM. */
-
-static int
-is_plausible_func_for_line (struct symbol *sym, int line_num)
-{
- struct symtab_and_line start_sal;
-
- if (sym == NULL)
- return 0;
-
- start_sal = find_function_start_sal (sym, 0);
-
- return (start_sal.line != 0 && line_num >= start_sal.line);
-}
-
-/* Read in all symbol tables corresponding to partial symbol tables
- with file name FILENAME. */
-
-static void
-read_all_symtabs (const char *filename)
-{
- struct partial_symtab *ps;
- struct objfile *objfile;
-
- ALL_PSYMTABS (objfile, ps)
- {
- QUIT;
-
- if (strcmp (filename, ps->filename) == 0)
- PSYMTAB_TO_SYMTAB (ps);
- }
-}
-
-/* All sals corresponding to line LINE_NUM in a symbol table from file
- FILENAME, as filtered by the user. Filter out any lines that
- reside in functions with "suppressed" names (not corresponding to
- explicit Ada functions), if there is at least one in a function
- with a non-suppressed name. If CANONICAL is not null, set
- it to a corresponding array of canonical line specs.
- If ONE_LOCATION_ONLY is set and several matches are found for
- the given location, then automatically select the first match found
- instead of asking the user which instance should be returned. */
-
-struct symtabs_and_lines
-ada_sals_for_line (const char *filename, int line_num,
- int funfirstline, char ***canonical, int one_location_only)
-{
- struct symtabs_and_lines result;
- struct objfile *objfile;
- struct symtab *s;
- struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
- size_t len;
-
- read_all_symtabs (filename);
-
- result.sals =
- (struct symtab_and_line *) xmalloc (4 * sizeof (result.sals[0]));
- result.nelts = 0;
- len = 4;
- make_cleanup (free_current_contents, &result.sals);
-
- ALL_SYMTABS (objfile, s)
- {
- int ind, target_line_num;
-
- QUIT;
-
- if (strcmp (s->filename, filename) != 0)
- continue;
-
- target_line_num =
- nearest_line_number_in_linetable (LINETABLE (s), line_num);
- if (target_line_num == -1)
- continue;
-
- ind = -1;
- while (1)
- {
- ind =
- find_next_line_in_linetable (LINETABLE (s),
- target_line_num, line_num, ind);
-
- if (ind < 0)
- break;
-
- GROW_VECT (result.sals, len, result.nelts + 1);
- init_sal (&result.sals[result.nelts]);
- result.sals[result.nelts].line = line_num;
- result.sals[result.nelts].pc = LINETABLE (s)->item[ind].pc;
- result.sals[result.nelts].symtab = s;
-
- if (funfirstline)
- adjust_pc_past_prologue (&result.sals[result.nelts].pc);
-
- result.nelts += 1;
- }
- }
-
- if (canonical != NULL || result.nelts > 1)
- {
- int k, j, n;
- char **func_names = (char **) alloca (result.nelts * sizeof (char *));
- int first_choice = (result.nelts > 1) ? 2 : 1;
- int *choices = (int *) alloca (result.nelts * sizeof (int));
-
- for (k = 0; k < result.nelts; k += 1)
- {
- find_pc_partial_function (result.sals[k].pc, &func_names[k],
- (CORE_ADDR *) NULL, (CORE_ADDR *) NULL);
- if (func_names[k] == NULL)
- error ("Could not find function for one or more breakpoints.");
- }
-
- /* Remove suppressed names, unless all are suppressed. */
- for (j = 0; j < result.nelts; j += 1)
- if (!is_suppressed_name (func_names[j]))
- {
- /* At least one name is unsuppressed, so remove all
- suppressed names. */
- for (k = n = 0; k < result.nelts; k += 1)
- if (!is_suppressed_name (func_names[k]))
- {
- func_names[n] = func_names[k];
- result.sals[n] = result.sals[k];
- n += 1;
- }
- result.nelts = n;
- break;
- }
-
- if (result.nelts > 1)
- {
- if (one_location_only)
- {
- /* Automatically select the first of all possible choices. */
- n = 1;
- choices[0] = 0;
- }
- else
- {
- printf_unfiltered ("[0] cancel\n");
- if (result.nelts > 1)
- printf_unfiltered ("[1] all\n");
- for (k = 0; k < result.nelts; k += 1)
- printf_unfiltered ("[%d] %s\n", k + first_choice,
- ada_decode (func_names[k]));
-
- n = get_selections (choices, result.nelts, result.nelts,
- result.nelts > 1, "instance-choice");
- }
-
- for (k = 0; k < n; k += 1)
- {
- result.sals[k] = result.sals[choices[k]];
- func_names[k] = func_names[choices[k]];
- }
- result.nelts = n;
- }
-
- if (canonical != NULL && result.nelts == 0)
- *canonical = NULL;
- else if (canonical != NULL)
- {
- *canonical = (char **) xmalloc (result.nelts * sizeof (char **));
- make_cleanup (xfree, *canonical);
- for (k = 0; k < result.nelts; k += 1)
- {
- (*canonical)[k] =
- extended_canonical_line_spec (result.sals[k], func_names[k]);
- if ((*canonical)[k] == NULL)
- error ("Could not locate one or more breakpoints.");
- make_cleanup (xfree, (*canonical)[k]);
- }
- }
- }
-
- if (result.nelts == 0)
- {
- do_cleanups (old_chain);
- result.sals = NULL;
- }
- else
- discard_cleanups (old_chain);
- return result;
-}
-
-
-/* A canonical line specification of the form FILE:NAME:LINENUM for
- symbol table and line data SAL. NULL if insufficient
- information. The caller is responsible for releasing any space
- allocated. */
-
-static char *
-extended_canonical_line_spec (struct symtab_and_line sal, const char *name)
-{
- char *r;
-
- if (sal.symtab == NULL || sal.symtab->filename == NULL || sal.line <= 0)
- return NULL;
-
- r = (char *) xmalloc (strlen (name) + strlen (sal.symtab->filename)
- + sizeof (sal.line) * 3 + 3);
- sprintf (r, "%s:'%s':%d", sal.symtab->filename, name, sal.line);
- return r;
-}
-
-
- /* Exception-related */
-
-int
-ada_is_exception_sym (struct symbol *sym)
-{
- char *type_name = type_name_no_tag (SYMBOL_TYPE (sym));
-
- return (SYMBOL_CLASS (sym) != LOC_TYPEDEF
- && SYMBOL_CLASS (sym) != LOC_BLOCK
- && SYMBOL_CLASS (sym) != LOC_CONST
- && type_name != NULL && strcmp (type_name, "exception") == 0);
-}
-
-/* Return type of Ada breakpoint associated with bp_stat:
- 0 if not an Ada-specific breakpoint, 1 for break on specific exception,
- 2 for break on unhandled exception, 3 for assert. */
-
-static int
-ada_exception_breakpoint_type (bpstat bs)
-{
- return ((!bs || !bs->breakpoint_at) ? 0
- : bs->breakpoint_at->break_on_exception);
-}
-
-/* True iff FRAME is very likely to be that of a function that is
- part of the runtime system. This is all very heuristic, but is
- intended to be used as advice as to what frames are uninteresting
- to most users. */
-
-static int
-is_known_support_routine (struct frame_info *frame)
-{
- struct frame_info *next_frame = get_next_frame (frame);
- /* If frame is not innermost, that normally means that frame->pc
- points to *after* the call instruction, and we want to get the line
- containing the call, never the next line. But if the next frame is
- a signal_handler_caller or a dummy frame, then the next frame was
- not entered as the result of a call, and we want to get the line
- containing frame->pc. */
- const int pc_is_after_call =
- next_frame != NULL
- && get_frame_type (next_frame) != SIGTRAMP_FRAME
- && get_frame_type (next_frame) != DUMMY_FRAME;
- struct symtab_and_line sal
- = find_pc_line (get_frame_pc (frame), pc_is_after_call);
- char *func_name;
- int i;
- struct stat st;
-
- /* The heuristic:
- 1. The symtab is null (indicating no debugging symbols)
- 2. The symtab's filename does not exist.
- 3. The object file's name is one of the standard libraries.
- 4. The symtab's file name has the form of an Ada library source file.
- 5. The function at frame's PC has a GNAT-compiler-generated name. */
-
- if (sal.symtab == NULL)
- return 1;
-
- /* On some systems (e.g. VxWorks), the kernel contains debugging
- symbols; in this case, the filename referenced by these symbols
- does not exists. */
-
- if (stat (sal.symtab->filename, &st))
- return 1;
-
- for (i = 0; known_runtime_file_name_patterns[i] != NULL; i += 1)
- {
- re_comp (known_runtime_file_name_patterns[i]);
- if (re_exec (sal.symtab->filename))
- return 1;
- }
- if (sal.symtab->objfile != NULL)
- {
- for (i = 0; known_runtime_file_name_patterns[i] != NULL; i += 1)
- {
- re_comp (known_runtime_file_name_patterns[i]);
- if (re_exec (sal.symtab->objfile->name))
- return 1;
- }
- }
-
- /* If the frame PC points after the call instruction, then we need to
- decrement it in order to search for the function associated to this
- PC. Otherwise, if the associated call was the last instruction of
- the function, we might either find the wrong function or even fail
- during the function name lookup. */
- if (pc_is_after_call)
- func_name = function_name_from_pc (get_frame_pc (frame) - 1);
- else
- func_name = function_name_from_pc (get_frame_pc (frame));
-
- if (func_name == NULL)
- return 1;
-
- for (i = 0; known_auxiliary_function_name_patterns[i] != NULL; i += 1)
- {
- re_comp (known_auxiliary_function_name_patterns[i]);
- if (re_exec (func_name))
- return 1;
- }
-
- return 0;
-}
-
-/* Find the first frame that contains debugging information and that is not
- part of the Ada run-time, starting from FI and moving upward. */
-
-void
-ada_find_printable_frame (struct frame_info *fi)
-{
- for (; fi != NULL; fi = get_prev_frame (fi))
- {
- if (!is_known_support_routine (fi))
- {
- select_frame (fi);
- break;
- }
- }
-
-}
-
-/* Name found for exception associated with last bpstat sent to
- ada_adjust_exception_stop. Set to the null string if that bpstat
- did not correspond to an Ada exception or no name could be found. */
-
-static char last_exception_name[256];
-
-/* If BS indicates a stop in an Ada exception, try to go up to a frame
- that will be meaningful to the user, and save the name of the last
- exception (truncated, if necessary) in last_exception_name. */
-
-void
-ada_adjust_exception_stop (bpstat bs)
-{
- CORE_ADDR addr;
- struct frame_info *fi;
- int frame_level;
- char *selected_frame_func;
-
- addr = 0;
- last_exception_name[0] = '\0';
- fi = get_selected_frame ();
- selected_frame_func = function_name_from_pc (get_frame_pc (fi));
-
- switch (ada_exception_breakpoint_type (bs))
- {
- default:
- return;
- case 1:
- break;
- case 2:
- /* Unhandled exceptions. Select the frame corresponding to
- ada.exceptions.process_raise_exception. This frame is at
- least 2 levels up, so we simply skip the first 2 frames
- without checking the name of their associated function. */
- for (frame_level = 0; frame_level < 2; frame_level += 1)
- if (fi != NULL)
- fi = get_prev_frame (fi);
- while (fi != NULL)
- {
- const char *func_name = function_name_from_pc (get_frame_pc (fi));
- if (func_name != NULL
- && strcmp (func_name, process_raise_exception_name) == 0)
- break; /* We found the frame we were looking for... */
- fi = get_prev_frame (fi);
- }
- if (fi == NULL)
- break;
- select_frame (fi);
- break;
- }
-
- addr = parse_and_eval_address ("e.full_name");
-
- if (addr != 0)
- read_memory (addr, last_exception_name, sizeof (last_exception_name) - 1);
- last_exception_name[sizeof (last_exception_name) - 1] = '\0';
- ada_find_printable_frame (get_selected_frame ());
-}
-
-/* Output Ada exception name (if any) associated with last call to
- ada_adjust_exception_stop. */
-
-void
-ada_print_exception_stop (bpstat bs)
-{
- if (last_exception_name[0] != '\000')
- {
- ui_out_text (uiout, last_exception_name);
- ui_out_text (uiout, " at ");
- }
-}
-
-/* Parses the CONDITION string associated with a breakpoint exception
- to get the name of the exception on which the breakpoint has been
- set. The returned string needs to be deallocated after use. */
-
-static char *
-exception_name_from_cond (const char *condition)
-{
- char *start, *end, *exception_name;
- int exception_name_len;
-
- start = strrchr (condition, '&') + 1;
- end = strchr (start, ')') - 1;
- exception_name_len = end - start + 1;
-
- exception_name =
- (char *) xmalloc ((exception_name_len + 1) * sizeof (char));
- sprintf (exception_name, "%.*s", exception_name_len, start);
-
- return exception_name;
-}
-
-/* Print Ada-specific exception information about B, other than task
- clause. Return non-zero iff B was an Ada exception breakpoint. */
-
-int
-ada_print_exception_breakpoint_nontask (struct breakpoint *b)
-{
- if (b->break_on_exception == 1)
- {
- if (b->cond_string) /* the breakpoint is on a specific exception. */
- {
- char *exception_name = exception_name_from_cond (b->cond_string);
-
- make_cleanup (xfree, exception_name);
-
- ui_out_text (uiout, "on ");
- if (ui_out_is_mi_like_p (uiout))
- ui_out_field_string (uiout, "exception", exception_name);
- else
- {
- ui_out_text (uiout, "exception ");
- ui_out_text (uiout, exception_name);
- ui_out_text (uiout, " ");
- }
- }
- else
- ui_out_text (uiout, "on all exceptions");
- }
- else if (b->break_on_exception == 2)
- ui_out_text (uiout, "on unhandled exception");
- else if (b->break_on_exception == 3)
- ui_out_text (uiout, "on assert failure");
- else
- return 0;
- return 1;
-}
-
-/* Print task identifier for breakpoint B, if it is an Ada-specific
- breakpoint with non-zero tasking information. */
-
-void
-ada_print_exception_breakpoint_task (struct breakpoint *b)
-{
- if (b->task != 0)
- {
- ui_out_text (uiout, " task ");
- ui_out_field_int (uiout, "task", b->task);
- }
-}
-
-/* Cause the appropriate error if no appropriate runtime symbol is
- found to set a breakpoint, using ERR_DESC to describe the
- breakpoint. */
-
-static void
-error_breakpoint_runtime_sym_not_found (const char *err_desc)
-{
- /* If we are not debugging an Ada program, we can not put exception
- breakpoints! */
-
- if (ada_update_initial_language (language_unknown, NULL) != language_ada)
- error ("Unable to break on %s. Is this an Ada main program?", err_desc);
-
- /* If the symbol does not exist, then check that the program is
- already started, to make sure that shared libraries have been
- loaded. If it is not started, this may mean that the symbol is
- in a shared library. */
-
- if (ptid_get_pid (inferior_ptid) == 0)
- error ("Unable to break on %s. Try to start the program first.",
- err_desc);
-
- /* At this point, we know that we are debugging an Ada program and
- that the inferior has been started, but we still are not able to
- find the run-time symbols. That can mean that we are in
- configurable run time mode, or that a-except as been optimized
- out by the linker... In any case, at this point it is not worth
- supporting this feature. */
-
- error ("Cannot break on %s in this configuration.", err_desc);
-}
-
-/* Test if NAME is currently defined, and that either ALLOW_TRAMP or
- the symbol is not a shared-library trampoline. Return the result of
- the test. */
-
-static int
-is_runtime_sym_defined (const char *name, int allow_tramp)
-{
- struct minimal_symbol *msym;
-
- msym = lookup_minimal_symbol (name, NULL, NULL);
- return (msym != NULL && msym->type != mst_unknown
- && (allow_tramp || msym->type != mst_solib_trampoline));
-}
-
-/* If ARG points to an Ada exception or assert breakpoint, rewrite
- into equivalent form. Return resulting argument string. Set
- *BREAK_ON_EXCEPTIONP to 1 for ordinary break on exception, 2 for
- break on unhandled, 3 for assert, 0 otherwise. */
-
-char *
-ada_breakpoint_rewrite (char *arg, int *break_on_exceptionp)
-{
- if (arg == NULL)
- return arg;
- *break_on_exceptionp = 0;
- if (current_language->la_language == language_ada
- && strncmp (arg, "exception", 9) == 0
- && (arg[9] == ' ' || arg[9] == '\t' || arg[9] == '\0'))
- {
- char *tok, *end_tok;
- int toklen;
- int has_exception_propagation =
- is_runtime_sym_defined (raise_sym_name, 1);
-
- *break_on_exceptionp = 1;
-
- tok = arg + 9;
- while (*tok == ' ' || *tok == '\t')
- tok += 1;
-
- end_tok = tok;
-
- while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
- end_tok += 1;
-
- toklen = end_tok - tok;
-
- arg = (char *) xmalloc (sizeof (longest_exception_template) + toklen);
- make_cleanup (xfree, arg);
- if (toklen == 0)
- {
- if (has_exception_propagation)
- sprintf (arg, "'%s'", raise_sym_name);
- else
- error_breakpoint_runtime_sym_not_found ("exception");
- }
- else if (strncmp (tok, "unhandled", toklen) == 0)
- {
- if (is_runtime_sym_defined (raise_unhandled_sym_name, 1))
- sprintf (arg, "'%s'", raise_unhandled_sym_name);
- else
- error_breakpoint_runtime_sym_not_found ("exception");
-
- *break_on_exceptionp = 2;
- }
- else
- {
- if (is_runtime_sym_defined (raise_sym_name, 0))
- sprintf (arg, "'%s' if long_integer(e) = long_integer(&%.*s)",
- raise_sym_name, toklen, tok);
- else
- error_breakpoint_runtime_sym_not_found ("specific exception");
- }
- }
- else if (current_language->la_language == language_ada
- && strncmp (arg, "assert", 6) == 0
- && (arg[6] == ' ' || arg[6] == '\t' || arg[6] == '\0'))
- {
- char *tok = arg + 6;
-
- if (!is_runtime_sym_defined (raise_assert_sym_name, 1))
- error_breakpoint_runtime_sym_not_found ("failed assertion");
-
- *break_on_exceptionp = 3;
-
- arg =
- (char *) xmalloc (sizeof (raise_assert_sym_name) + strlen (tok) + 2);
- make_cleanup (xfree, arg);
- sprintf (arg, "'%s'%s", raise_assert_sym_name, tok);
- }
- return arg;
-}
-#endif /* GNAT_GDB */
-
/* Field Access */
/* True if field number FIELD_NUM in struct or union type TYPE is supposed
@@ -8251,24 +6550,6 @@ ada_to_fixed_value (struct value *val)
val);
}
-/* If the PC is pointing inside a function prologue, then re-adjust it
- past this prologue. */
-
-static void
-adjust_pc_past_prologue (CORE_ADDR *pc)
-{
- struct symbol *func_sym = find_pc_function (*pc);
-
- if (func_sym)
- {
- const struct symtab_and_line sal =
- find_function_start_sal (func_sym, 1);
-
- if (*pc <= sal.pc)
- *pc = sal.pc;
- }
-}
-
/* A value representing VAL, but with a standard (static-sized) type
chosen to approximate the real type of VAL as well as possible, but
without consulting any runtime values. For Ada dynamic-sized
@@ -9043,6 +7324,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
LONGEST low_bound = pos_atr (low_bound_val);
LONGEST high_bound
= pos_atr (evaluate_subexp (NULL_TYPE, exp, pos, noside));
+
if (noside == EVAL_SKIP)
goto nosideret;
@@ -10325,10 +8607,6 @@ const struct language_defn ada_language_defn = {
type_check_off,
case_sensitive_on, /* Yes, Ada is case-insensitive, but
that's not quite what this means. */
-#ifdef GNAT_GDB
- ada_lookup_symbol,
- ada_lookup_minimal_symbol,
-#endif /* GNAT_GDB */
array_row_major,
&ada_exp_descriptor,
parse,
@@ -10353,10 +8631,6 @@ const struct language_defn ada_language_defn = {
NULL,
ada_get_gdb_completer_word_break_characters,
ada_language_arch_info,
-#ifdef GNAT_GDB
- ada_translate_error_message, /* Substitute Ada-specific terminology
- in errors and warnings. */
-#endif /* GNAT_GDB */
LANG_MAGIC
};
@@ -10366,14 +8640,6 @@ _initialize_ada_language (void)
add_language (&ada_language_defn);
varsize_limit = 65536;
-#ifdef GNAT_GDB
- add_setshow_uinteger_cmd ("varsize-limit", class_support,
- &varsize_limit, "\
-Set the maximum number of bytes allowed in a dynamic-sized object.", "\
-Show the maximum number of bytes allowed in a dynamic-sized object.",
- NULL, NULL, &setlist, &showlist);
- obstack_init (&cache_space);
-#endif /* GNAT_GDB */
obstack_init (&symbol_list_obstack);
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 931fd8e..a2f929a 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -413,10 +413,6 @@ extern int ada_print_exception_breakpoint_nontask (struct breakpoint *);
extern void ada_print_exception_breakpoint_task (struct breakpoint *);
-extern int ada_maybe_exception_partial_symbol (struct partial_symbol *sym);
-
-extern int ada_is_exception_sym (struct symbol *sym);
-
extern void ada_find_printable_frame (struct frame_info *fi);
extern void ada_reset_thread_registers (void);
diff --git a/gdb/defs.h b/gdb/defs.h
index 24b7c9a..d994d3d 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -197,6 +197,7 @@ enum language
language_asm, /* Assembly language */
language_scm, /* Scheme / Guile */
language_pascal, /* Pascal */
+ language_ada, /* Ada */
language_minimal, /* All other languages, minimal support only */
nr_languages
};
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 4f95e13..eb28de2 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -293,6 +293,17 @@ enum type_code
#define TYPE_ADDRESS_CLASS_ALL(t) (TYPE_INSTANCE_FLAGS(t) \
& TYPE_FLAG_ADDRESS_CLASS_ALL)
+/* The debugging formats (especially STABS) do not contain enough information
+ to represent all Ada types---especially those whose size depends on
+ dynamic quantities. Therefore, the GNAT Ada compiler includes
+ extra information in the form of additional type definitions
+ connected by naming conventions. This flag indicates that the
+ type is an ordinary (unencoded) GDB type that has been created from
+ the necessary run-time information, and does not need further
+ interpretation. Optionally marks ordinary, fixed-size GDB type. */
+
+#define TYPE_FLAG_FIXED_INSTANCE (1 << 15)
+
/* Array bound type. */
enum array_bound_type
{
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 14e8ccd..ee9336d 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2185,6 +2185,10 @@ init_filename_language_table (void)
add_filename_language (".pas", language_pascal);
add_filename_language (".p", language_pascal);
add_filename_language (".pp", language_pascal);
+ add_filename_language (".adb", language_ada);
+ add_filename_language (".ads", language_ada);
+ add_filename_language (".a", language_ada);
+ add_filename_language (".ada", language_ada);
}
}