#include "source.h"
#include "filenames.h" /* for FILENAME_CMP */
#include "objc-lang.h"
+#include "d-lang.h"
#include "ada-lang.h"
#include "p-lang.h"
#include "addrmap.h"
if (full_path != NULL)
{
const char *fp = symtab_to_fullname (s);
+
if (fp != NULL && FILENAME_CMP (full_path, fp) == 0)
{
return s;
if (real_path != NULL)
{
char *fullname = symtab_to_fullname (s);
+
if (fullname != NULL)
{
char *rp = gdb_realpath (fullname);
+
make_cleanup (xfree, rp);
if (FILENAME_CMP (real_path, rp) == 0)
{
mangled_name_len = ((is_constructor ? 0 : strlen (field_name))
+ strlen (buf) + len + strlen (physname) + 1);
- {
- mangled_name = (char *) xmalloc (mangled_name_len);
- if (is_constructor)
- mangled_name[0] = '\0';
- else
- strcpy (mangled_name, field_name);
- }
+ mangled_name = (char *) xmalloc (mangled_name_len);
+ if (is_constructor)
+ mangled_name[0] = '\0';
+ else
+ strcpy (mangled_name, field_name);
+
strcat (mangled_name, buf);
/* If the class doesn't have a name, i.e. newname NULL, then we just
mangle it using 0 for the length of the class. Thus it gets mangled
{
gsymbol->language = language;
if (gsymbol->language == language_cplus
+ || gsymbol->language == language_d
|| gsymbol->language == language_java
|| gsymbol->language == language_objc)
{
hash_demangled_name_entry (const void *data)
{
const struct demangled_name_entry *e = data;
+
return htab_hash_string (e->mangled);
}
{
const struct demangled_name_entry *da = a;
const struct demangled_name_entry *db = b;
+
return strcmp (da->mangled, db->mangled) == 0;
}
return demangled;
}
}
+ if (gsymbol->language == language_d
+ || gsymbol->language == language_auto)
+ {
+ demangled = d_demangle(mangled, 0);
+ if (demangled != NULL)
+ {
+ gsymbol->language = language_d;
+ return demangled;
+ }
+ }
return NULL;
}
if (gsymbol->language == language_java)
{
char *alloc_name;
- lookup_len = len + JAVA_PREFIX_LEN;
+ lookup_len = len + JAVA_PREFIX_LEN;
alloc_name = alloca (lookup_len + 1);
memcpy (alloc_name, JAVA_PREFIX, JAVA_PREFIX_LEN);
memcpy (alloc_name + JAVA_PREFIX_LEN, linkage_name, len);
else if (linkage_name[len] != '\0')
{
char *alloc_name;
- lookup_len = len;
+ lookup_len = len;
alloc_name = alloca (lookup_len + 1);
memcpy (alloc_name, linkage_name, len);
alloc_name[lookup_len] = '\0';
It turns out that it is actually important to still save such
an entry in the hash table, because storing this name gives
- us better backache hit rates for partial symbols. */
+ us better bcache hit rates for partial symbols. */
if (!copy_name && lookup_name == linkage_name)
{
*slot = obstack_alloc (&objfile->objfile_obstack,
switch (gsymbol->language)
{
case language_cplus:
+ case language_d:
case language_java:
case language_objc:
if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
switch (gsymbol->language)
{
case language_cplus:
+ case language_d:
case language_java:
case language_objc:
if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
ALL_OBJFILES (objfile)
{
struct symtab *result = NULL;
+
if (objfile->sf)
result = objfile->sf->qf->find_pc_sect_symtab (objfile, msymbol,
pc, section, 0);
a search of the section table. */
struct obj_section *s;
+
ALL_OBJFILE_OSECTIONS (objfile, s)
{
int idx = s->the_bfd_section->index;
modified_name = name;
- /* If we are using C++ or Java, demangle the name before doing a lookup, so
- we can always binary search. */
+ /* If we are using C++, D, or Java, demangle the name before doing a
+ lookup, so we can always binary search. */
if (lang == language_cplus)
{
demangled_name = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
make_cleanup (xfree, demangled_name);
}
}
+ else if (lang == language_d)
+ {
+ demangled_name = d_demangle (name, 0);
+ if (demangled_name)
+ {
+ modified_name = demangled_name;
+ make_cleanup (xfree, demangled_name);
+ }
+ }
if (case_sensitivity == case_sensitive_off)
{
{
struct symbol *sym = NULL;
const struct block *function_block = block;
+
/* 'this' is only defined in the function's block, so find the
enclosing function block. */
for (; function_block && !BLOCK_FUNCTION (function_block);
/* Look up OBJFILE to BLOCK. */
-static struct objfile *
+struct objfile *
lookup_objfile_from_block (const struct block *block)
{
struct objfile *obj;
struct symtab *symtab;
struct blockvector *bv;
const struct block *block;
- struct partial_symtab *ps;
struct symbol *sym;
if (!objfile->sf)
A Java class declaration also defines a typedef for the class.
Similarly, any Ada type declaration implicitly defines a typedef. */
if (symbol_language == language_cplus
+ || symbol_language == language_d
|| symbol_language == language_java
|| symbol_language == language_ada)
{
struct blockvector *bv;
struct symtab *s = NULL;
struct symtab *best_s = NULL;
- struct partial_symtab *ps;
struct objfile *objfile;
struct program_space *pspace;
CORE_ADDR distance = 0;
if ((objfile->flags & OBJF_REORDERED) && objfile->sf)
{
struct symtab *result;
+
result
= objfile->sf->qf->find_pc_sect_symtab (objfile,
msymbol,
ALL_OBJFILES (objfile)
{
struct symtab *result;
+
if (!objfile->sf)
continue;
result = objfile->sf->qf->find_pc_sect_symtab (objfile,
If not found, return NULL. */
struct symtab *
-find_line_symtab (struct symtab *symtab, int line, int *index, int *exact_match)
+find_line_symtab (struct symtab *symtab, int line,
+ int *index, int *exact_match)
{
int exact = 0; /* Initialized here to avoid a compiler warning. */
find_pc_line_pc_range (CORE_ADDR pc, CORE_ADDR *startptr, CORE_ADDR *endptr)
{
struct symtab_and_line sal;
+
sal = find_pc_line (pc, 0);
*startptr = sal.pc;
*endptr = sal.end;
return sal.symtab != 0;
}
-/* Given a function start address PC and SECTION, find the first
- address after the function prologue. */
-CORE_ADDR
-find_function_start_pc (struct gdbarch *gdbarch,
- CORE_ADDR pc, struct obj_section *section)
-{
- /* If the function is in an unmapped overlay, use its unmapped LMA address,
- so that gdbarch_skip_prologue has something unique to work on. */
- if (section_is_overlay (section) && !section_is_mapped (section))
- pc = overlay_unmapped_address (pc, section);
-
- pc += gdbarch_deprecated_function_start_offset (gdbarch);
- pc = gdbarch_skip_prologue (gdbarch, pc);
-
- /* For overlays, map pc back into its mapped VMA range. */
- pc = overlay_mapped_address (pc, section);
-
- return pc;
-}
-
/* Given a function start address FUNC_ADDR and SYMTAB, find the first
address for that function that has an entry in SYMTAB's line info
table. If such an entry cannot be found, return FUNC_ADDR
{
CORE_ADDR func_start, func_end;
struct linetable *l;
- int ind, i, len;
- int best_lineno = 0;
- CORE_ADDR best_pc = func_addr;
+ int i;
/* Give up if this symbol has no lineinfo table. */
l = LINETABLE (symtab);
struct symtab_and_line
find_function_start_sal (struct symbol *sym, int funfirstline)
{
- struct block *block = SYMBOL_BLOCK_VALUE (sym);
- struct objfile *objfile = lookup_objfile_from_block (block);
- struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ struct symtab_and_line sal;
+ fixup_symbol_section (sym, NULL);
+ sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)),
+ SYMBOL_OBJ_SECTION (sym), 0);
+
+ /* We always should have a line for the function start address.
+ If we don't, something is odd. Create a plain SAL refering
+ just the PC and hope that skip_prologue_sal (if requested)
+ can find a line number for after the prologue. */
+ if (sal.pc < BLOCK_START (SYMBOL_BLOCK_VALUE (sym)))
+ {
+ init_sal (&sal);
+ sal.pspace = current_program_space;
+ sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
+ sal.section = SYMBOL_OBJ_SECTION (sym);
+ }
+
+ if (funfirstline)
+ skip_prologue_sal (&sal);
+
+ return sal;
+}
+
+/* Adjust SAL to the first instruction past the function prologue.
+ If the PC was explicitly specified, the SAL is not changed.
+ If the line number was explicitly specified, at most the SAL's PC
+ is updated. If SAL is already past the prologue, then do nothing. */
+void
+skip_prologue_sal (struct symtab_and_line *sal)
+{
+ struct symbol *sym;
+ struct symtab_and_line start_sal;
+ struct cleanup *old_chain;
CORE_ADDR pc;
- struct symtab_and_line sal;
+ struct obj_section *section;
+ const char *name;
+ struct objfile *objfile;
+ struct gdbarch *gdbarch;
struct block *b, *function_block;
- struct cleanup *old_chain;
+ /* Do not change the SAL is PC was specified explicitly. */
+ if (sal->explicit_pc)
+ return;
old_chain = save_current_space_and_thread ();
- switch_to_program_space_and_thread (objfile->pspace);
+ switch_to_program_space_and_thread (sal->pspace);
- pc = BLOCK_START (block);
- fixup_symbol_section (sym, objfile);
- if (funfirstline)
+ sym = find_pc_sect_function (sal->pc, sal->section);
+ if (sym != NULL)
{
- /* Skip "first line" of function (which is actually its prologue). */
- pc = find_function_start_pc (gdbarch, pc, SYMBOL_OBJ_SECTION (sym));
+ fixup_symbol_section (sym, NULL);
+
+ pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
+ section = SYMBOL_OBJ_SECTION (sym);
+ name = SYMBOL_LINKAGE_NAME (sym);
+ objfile = SYMBOL_SYMTAB (sym)->objfile;
}
- sal = find_pc_sect_line (pc, SYMBOL_OBJ_SECTION (sym), 0);
+ else
+ {
+ struct minimal_symbol *msymbol
+ = lookup_minimal_symbol_by_pc_section (sal->pc, sal->section);
+
+ if (msymbol == NULL)
+ {
+ do_cleanups (old_chain);
+ return;
+ }
+
+ pc = SYMBOL_VALUE_ADDRESS (msymbol);
+ section = SYMBOL_OBJ_SECTION (msymbol);
+ name = SYMBOL_LINKAGE_NAME (msymbol);
+ objfile = msymbol_objfile (msymbol);
+ }
+
+ gdbarch = get_objfile_arch (objfile);
+
+ /* If the function is in an unmapped overlay, use its unmapped LMA address,
+ so that gdbarch_skip_prologue has something unique to work on. */
+ if (section_is_overlay (section) && !section_is_mapped (section))
+ pc = overlay_unmapped_address (pc, section);
+
+ /* Skip "first line" of function (which is actually its prologue). */
+ pc += gdbarch_deprecated_function_start_offset (gdbarch);
+ pc = gdbarch_skip_prologue (gdbarch, pc);
+
+ /* For overlays, map pc back into its mapped VMA range. */
+ pc = overlay_mapped_address (pc, section);
+
+ /* Calculate line number. */
+ start_sal = find_pc_sect_line (pc, section, 0);
/* Check if gdbarch_skip_prologue left us in mid-line, and the next
line is still part of the same function. */
- if (sal.pc != pc
- && BLOCK_START (block) <= sal.end
- && sal.end < BLOCK_END (block))
+ if (start_sal.pc != pc
+ && (sym? (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) <= start_sal.end
+ && start_sal.end < BLOCK_END (SYMBOL_BLOCK_VALUE (sym)))
+ : (lookup_minimal_symbol_by_pc_section (start_sal.end, section)
+ == lookup_minimal_symbol_by_pc_section (pc, section))))
{
/* First pc of next line */
- pc = sal.end;
+ pc = start_sal.end;
/* Recalculate the line number (might not be N+1). */
- sal = find_pc_sect_line (pc, SYMBOL_OBJ_SECTION (sym), 0);
+ start_sal = find_pc_sect_line (pc, section, 0);
}
/* On targets with executable formats that don't have a concept of
constructors (ELF with .init has, PE doesn't), gcc emits a call
to `__main' in `main' between the prologue and before user
code. */
- if (funfirstline
- && gdbarch_skip_main_prologue_p (gdbarch)
- && SYMBOL_LINKAGE_NAME (sym)
- && strcmp (SYMBOL_LINKAGE_NAME (sym), "main") == 0)
+ if (gdbarch_skip_main_prologue_p (gdbarch)
+ && name && strcmp (name, "main") == 0)
{
pc = gdbarch_skip_main_prologue (gdbarch, pc);
/* Recalculate the line number (might not be N+1). */
- sal = find_pc_sect_line (pc, SYMBOL_OBJ_SECTION (sym), 0);
+ start_sal = find_pc_sect_line (pc, section, 0);
}
/* If we still don't have a valid source line, try to find the first
the case with the DJGPP target using "gcc -gcoff" when the
compiler inserted code after the prologue to make sure the stack
is aligned. */
- if (funfirstline && sal.symtab == NULL)
+ if (sym && start_sal.symtab == NULL)
{
pc = skip_prologue_using_lineinfo (pc, SYMBOL_SYMTAB (sym));
/* Recalculate the line number. */
- sal = find_pc_sect_line (pc, SYMBOL_OBJ_SECTION (sym), 0);
+ start_sal = find_pc_sect_line (pc, section, 0);
}
- sal.pc = pc;
- sal.pspace = objfile->pspace;
+ do_cleanups (old_chain);
+
+ /* If we're already past the prologue, leave SAL unchanged. Otherwise
+ forward SAL to the end of the prologue. */
+ if (sal->pc >= pc)
+ return;
+
+ sal->pc = pc;
+ sal->section = section;
+
+ /* Unless the explicit_line flag was set, update the SAL line
+ and symtab to correspond to the modified PC location. */
+ if (sal->explicit_line)
+ return;
+
+ sal->symtab = start_sal.symtab;
+ sal->line = start_sal.line;
+ sal->end = start_sal.end;
/* Check if we are now inside an inlined function. If we can,
use the call site of the function instead. */
- b = block_for_pc_sect (sal.pc, SYMBOL_OBJ_SECTION (sym));
+ b = block_for_pc_sect (sal->pc, sal->section);
function_block = NULL;
while (b != NULL)
{
if (function_block != NULL
&& SYMBOL_LINE (BLOCK_FUNCTION (function_block)) != 0)
{
- sal.line = SYMBOL_LINE (BLOCK_FUNCTION (function_block));
- sal.symtab = SYMBOL_SYMTAB (BLOCK_FUNCTION (function_block));
+ sal->line = SYMBOL_LINE (BLOCK_FUNCTION (function_block));
+ sal->symtab = SYMBOL_SYMTAB (BLOCK_FUNCTION (function_block));
}
-
- do_cleanups (old_chain);
- return sal;
}
/* If P is of the form "operator[ \t]+..." where `...' is
if (isalpha (*p) || *p == '_' || *p == '$')
{
char *q = p + 1;
+
while (isalnum (*q) || *q == '_' || *q == '$')
q++;
*end = q;
sources_info (char *ignore, int from_tty)
{
struct symtab *s;
- struct partial_symtab *ps;
struct objfile *objfile;
int first;
ALL_SYMTABS (objfile, s)
{
const char *fullname = symtab_to_fullname (s);
+
output_source_filename (fullname ? fullname : s->filename, &first);
}
printf_filtered ("\n\n");
search_symbols_file_matches (const char *filename, void *user_data)
{
struct search_symbols_data *data = user_data;
+
return file_matches (filename, data->files, data->nfiles);
}
search_symbols_name_matches (const char *symname, void *user_data)
{
struct search_symbols_data *data = user_data;
+
return data->regexp == NULL || re_exec (symname);
}
char *val;
int found_misc = 0;
static enum minimal_symbol_type types[]
- =
- {mst_data, mst_text, mst_abs, mst_unknown};
+ = {mst_data, mst_text, mst_abs, mst_unknown};
static enum minimal_symbol_type types2[]
- =
- {mst_bss, mst_file_text, mst_abs, mst_unknown};
+ = {mst_bss, mst_file_text, mst_abs, mst_unknown};
static enum minimal_symbol_type types3[]
- =
- {mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown};
+ = {mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown};
static enum minimal_symbol_type types4[]
- =
- {mst_file_bss, mst_text, mst_abs, mst_unknown};
+ = {mst_file_bss, mst_text, mst_abs, mst_unknown};
enum minimal_symbol_type ourtype;
enum minimal_symbol_type ourtype2;
enum minimal_symbol_type ourtype3;
and <TYPENAME> or <OPERATOR>. */
char *opend;
char *opname = operator_chars (regexp, &opend);
+
if (*opname)
{
int fix = -1; /* -1 means ok; otherwise number of spaces needed. */
+
if (isalpha (*opname) || *opname == '_' || *opname == '$')
{
/* There should 1 space between 'operator' and 'TYPENAME'. */
if (fix >= 0)
{
char *tmp = (char *) alloca (8 + fix + strlen (opname) + 1);
+
sprintf (tmp, "operator%.*s%s", fix, " ", opname);
regexp = tmp;
}
{
struct symbol_search *prevtail = tail;
int nfound = 0;
+
b = BLOCKVECTOR_BLOCK (bv, i);
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
struct symtab *real_symtab = SYMBOL_SYMTAB (sym);
+
QUIT;
if (file_matches (real_symtab->filename, files, nfiles)
static void
symtab_symbol_info (char *regexp, domain_enum kind, int from_tty)
{
- static char *classnames[]
- =
- {"variable", "function", "type", "method"};
+ static char *classnames[] = {"variable", "function", "type", "method"};
struct symbol_search *symbols;
struct symbol_search *p;
struct cleanup *old_chain;
rbreak_command (regexp, from_tty);
}
+/* A cleanup function that calls end_rbreak_breakpoints. */
+
+static void
+do_end_rbreak_breakpoints (void *ignore)
+{
+ end_rbreak_breakpoints ();
+}
+
static void
rbreak_command (char *regexp, int from_tty)
{
struct symbol_search *ss;
struct symbol_search *p;
struct cleanup *old_chain;
+ char *string = NULL;
+ int len = 0;
+ char **files = NULL;
+ int nfiles = 0;
+
+ if (regexp)
+ {
+ char *colon = strchr (regexp, ':');
+
+ if (colon && *(colon + 1) != ':')
+ {
+ int colon_index;
+ char * file_name;
+
+ colon_index = colon - regexp;
+ file_name = alloca (colon_index + 1);
+ memcpy (file_name, regexp, colon_index);
+ file_name[colon_index--] = 0;
+ while (isspace (file_name[colon_index]))
+ file_name[colon_index--] = 0;
+ files = &file_name;
+ nfiles = 1;
+ regexp = colon + 1;
+ while (isspace (*regexp)) regexp++;
+ }
+ }
- search_symbols (regexp, FUNCTIONS_DOMAIN, 0, (char **) NULL, &ss);
+ search_symbols (regexp, FUNCTIONS_DOMAIN, nfiles, files, &ss);
old_chain = make_cleanup_free_search_symbols (ss);
+ make_cleanup (free_current_contents, &string);
+ start_rbreak_breakpoints ();
+ make_cleanup (do_end_rbreak_breakpoints, NULL);
for (p = ss; p != NULL; p = p->next)
{
if (p->msymbol == NULL)
{
- char *string = alloca (strlen (p->symtab->filename)
- + strlen (SYMBOL_LINKAGE_NAME (p->symbol))
- + 4);
+ int newlen = (strlen (p->symtab->filename)
+ + strlen (SYMBOL_LINKAGE_NAME (p->symbol))
+ + 4);
+
+ if (newlen > len)
+ {
+ string = xrealloc (string, newlen);
+ len = newlen;
+ }
strcpy (string, p->symtab->filename);
strcat (string, ":'");
strcat (string, SYMBOL_LINKAGE_NAME (p->symbol));
}
else
{
- char *string = alloca (strlen (SYMBOL_LINKAGE_NAME (p->msymbol))
- + 3);
+ int newlen = (strlen (SYMBOL_LINKAGE_NAME (p->msymbol)) + 3);
+
+ if (newlen > len)
+ {
+ string = xrealloc (string, newlen);
+ len = newlen;
+ }
strcpy (string, "'");
strcat (string, SYMBOL_LINKAGE_NAME (p->msymbol));
strcat (string, "'");
char *text, char *word)
{
int newsize;
- int i;
/* clip symbols that cannot match */
{
char *new;
+
if (word == sym_text)
{
new = xmalloc (strlen (symname) + 5);
void *user_data)
{
struct add_name_data *datum = (struct add_name_data *) user_data;
+
completion_list_add_name ((char *) name,
datum->sym_text, datum->sym_text_len,
datum->text, datum->word);
add_partial_symbol_name (const char *name, void *user_data)
{
struct add_name_data *datum = (struct add_name_data *) user_data;
+
completion_list_add_name ((char *) name,
datum->sym_text, datum->sym_text_len,
datum->text, datum->word);
else
{
const char *base_name = lbasename (filename);
+
if (base_name != filename
&& !filename_seen (base_name, 1, data->first)
#if HAVE_DOS_BASED_FILE_SYSTEM
if (prologue_sal.symtab->language != language_asm)
{
struct linetable *linetable = LINETABLE (prologue_sal.symtab);
- int exact;
int idx = 0;
/* Skip any earlier lines, and any end-of-sequence marker
{
struct linetable *l;
int len;
+
if (fullname != NULL
&& symtab_to_fullname (symtab) != NULL
&& FILENAME_CMP (fullname, symtab->fullname) != 0)
struct symtabs_and_lines
expand_line_sal (struct symtab_and_line sal)
{
- struct symtabs_and_lines ret, this_line;
+ struct symtabs_and_lines ret;
int i, j;
struct objfile *objfile;
- struct partial_symtab *psymtab;
- struct symtab *symtab;
int lineno;
int deleted = 0;
struct block **blocks = NULL;
blocks = alloca (ret.nelts * sizeof (struct block *));
for (i = 0; i < ret.nelts; ++i)
{
- struct blockvector *bl;
- struct block *b;
-
set_current_program_space (ret.sals[i].pspace);
filter[i] = 1;