Code cleanup.
	* breakpoint.c (print_breakpoint_location): Replace bp_location field
	source_file references by symtab field references.  Remove variables
	sal and fullname.
	(momentary_breakpoint_from_master, add_location_to_breakpoint):
	(clear_command, say_where): Replace bp_location field source_file
	references by symtab field references.
	(bp_location_dtor): Remove the source_file reference.
	(update_static_tracepoint): Replace bp_location field source_file
	references by symtab field references.
	(breakpoint_free_objfile): New function.
	* breakpoint.h (struct bp_location): Extend the comment for line_number.
	Replace the field source_file by field symtab, extend its comment.
	(breakpoint_free_objfile): New declaration.
	* objfiles.c (free_objfile): Call breakpoint_free_objfile.
	* tui/tui-winsource.c (tui_update_breakpoint_info): Replace bp_location
	field source_file references by symtab field references.
This commit is contained in:
Jan Kratochvil 2013-02-03 15:57:07 +00:00
parent f5b95b5073
commit 2f202fde0a
5 changed files with 58 additions and 33 deletions

View File

@ -1,3 +1,23 @@
2013-02-03 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup.
* breakpoint.c (print_breakpoint_location): Replace bp_location field
source_file references by symtab field references. Remove variables
sal and fullname.
(momentary_breakpoint_from_master, add_location_to_breakpoint):
(clear_command, say_where): Replace bp_location field source_file
references by symtab field references.
(bp_location_dtor): Remove the source_file reference.
(update_static_tracepoint): Replace bp_location field source_file
references by symtab field references.
(breakpoint_free_objfile): New function.
* breakpoint.h (struct bp_location): Extend the comment for line_number.
Replace the field source_file by field symtab, extend its comment.
(breakpoint_free_objfile): New declaration.
* objfiles.c (free_objfile): Call breakpoint_free_objfile.
* tui/tui-winsource.c (tui_update_breakpoint_info): Replace bp_location
field source_file references by symtab field references.
2013-02-03 Jan Kratochvil <jan.kratochvil@redhat.com>
Replace xfullpath calls by gdb_realpath calls.

View File

@ -5694,7 +5694,7 @@ print_breakpoint_location (struct breakpoint *b,
if (b->display_canonical)
ui_out_field_string (uiout, "what", b->addr_string);
else if (loc && loc->source_file)
else if (loc && loc->symtab)
{
struct symbol *sym
= find_pc_sect_function (loc->address, loc->section);
@ -5707,16 +5707,12 @@ print_breakpoint_location (struct breakpoint *b,
ui_out_wrap_hint (uiout, wrap_indent_at_field (uiout, "what"));
ui_out_text (uiout, "at ");
}
ui_out_field_string (uiout, "file", loc->source_file);
ui_out_field_string (uiout, "file", loc->symtab->filename);
ui_out_text (uiout, ":");
if (ui_out_is_mi_like_p (uiout))
{
struct symtab_and_line sal = find_pc_line (loc->address, 0);
const char *fullname = symtab_to_fullname (sal.symtab);
ui_out_field_string (uiout, "fullname", fullname);
}
ui_out_field_string (uiout, "fullname",
symtab_to_fullname (loc->symtab));
ui_out_field_int (uiout, "line", loc->line_number);
}
@ -8756,11 +8752,8 @@ momentary_breakpoint_from_master (struct breakpoint *orig,
copy->loc->section = orig->loc->section;
copy->loc->pspace = orig->loc->pspace;
copy->loc->probe = orig->loc->probe;
if (orig->loc->source_file != NULL)
copy->loc->source_file = xstrdup (orig->loc->source_file);
copy->loc->line_number = orig->loc->line_number;
copy->loc->symtab = orig->loc->symtab;
copy->frame_id = orig->frame_id;
copy->thread = orig->thread;
copy->pspace = orig->pspace;
@ -8845,10 +8838,8 @@ add_location_to_breakpoint (struct breakpoint *b,
gdb_assert (loc->pspace != NULL);
loc->section = sal->section;
loc->gdbarch = loc_gdbarch;
if (sal->symtab != NULL)
loc->source_file = xstrdup (sal->symtab->filename);
loc->line_number = sal->line;
loc->symtab = sal->symtab;
set_breakpoint_location_function (loc,
sal->explicit_pc || sal->explicit_line);
@ -11988,16 +11979,16 @@ clear_command (char *arg, int from_tty)
int line_match = 0;
if ((default_match || sal.explicit_line)
&& loc->source_file != NULL
&& loc->symtab != NULL
&& sal.symtab != NULL
&& sal.pspace == loc->pspace
&& loc->line_number == sal.line)
{
if (filename_cmp (loc->source_file,
if (filename_cmp (loc->symtab->filename,
sal.symtab->filename) == 0)
line_match = 1;
else if (!IS_ABSOLUTE_PATH (sal.symtab->filename)
&& compare_filenames_for_search (loc->source_file,
&& compare_filenames_for_search (loc->symtab->filename,
sal.symtab->filename))
line_match = 1;
}
@ -12730,19 +12721,19 @@ say_where (struct breakpoint *b)
}
else
{
if (opts.addressprint || b->loc->source_file == NULL)
if (opts.addressprint || b->loc->symtab == NULL)
{
printf_filtered (" at ");
fputs_filtered (paddress (b->loc->gdbarch, b->loc->address),
gdb_stdout);
}
if (b->loc->source_file)
if (b->loc->symtab != NULL)
{
/* If there is a single location, we can print the location
more nicely. */
if (b->loc->next == NULL)
printf_filtered (": file %s, line %d.",
b->loc->source_file, b->loc->line_number);
b->loc->symtab->filename, b->loc->line_number);
else
/* This is not ideal, but each location may have a
different file name, and this at least reflects the
@ -12770,7 +12761,6 @@ bp_location_dtor (struct bp_location *self)
if (self->cond_bytecode)
free_agent_expr (self->cond_bytecode);
xfree (self->function_name);
xfree (self->source_file);
}
static const struct bp_location_ops bp_location_ops =
@ -13956,12 +13946,7 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
ui_out_text (uiout, "\n");
b->loc->line_number = sal2.line;
xfree (b->loc->source_file);
if (sym)
b->loc->source_file = xstrdup (sal2.symtab->filename);
else
b->loc->source_file = NULL;
b->loc->symtab = sym != NULL ? sal2.symtab : NULL;
xfree (b->addr_string);
b->addr_string = xstrprintf ("%s:%d",
@ -15798,6 +15783,18 @@ pc_at_non_inline_function (struct address_space *aspace, CORE_ADDR pc,
return 0;
}
/* Remove any references to OBJFILE which is going to be freed. */
void
breakpoint_free_objfile (struct objfile *objfile)
{
struct bp_location **locp, *loc;
ALL_BP_LOCATIONS (loc, locp)
if (loc->symtab != NULL && loc->symtab->objfile == objfile)
loc->symtab = NULL;
}
void
initialize_breakpoint_ops (void)
{

View File

@ -465,13 +465,17 @@ struct bp_location
it becomes 0 this location is retired. */
int events_till_retirement;
/* Line number of this address. */
/* Line number which was used to place this location.
Breakpoint placed into a comment keeps it's user specified line number
despite ADDRESS resolves into a different line number. */
int line_number;
/* Source file name of this address. */
/* Symtab which was used to place this location. This is used
to find the corresponding source file name. */
char *source_file;
struct symtab *symtab;
};
/* Return values for bpstat_explains_signal. Note that the order of
@ -1550,4 +1554,6 @@ extern struct gdbarch *get_sal_arch (struct symtab_and_line sal);
extern void handle_solib_event (void);
extern void breakpoint_free_objfile (struct objfile *objfile);
#endif /* !defined (BREAKPOINT_H) */

View File

@ -566,6 +566,8 @@ free_objfile (struct objfile *objfile)
the symbol file data. */
forget_cached_source_info_for_objfile (objfile);
breakpoint_free_objfile (objfile);
/* First do any symbol file specific actions required when we are
finished with a particular symbol file. Note that if the objfile
is using reusable symbol information (via mmalloc) then each of

View File

@ -462,8 +462,8 @@ tui_update_breakpoint_info (struct tui_win_info *win,
for (loc = bp->loc; loc != NULL; loc = loc->next)
{
if ((win == TUI_SRC_WIN
&& loc->source_file
&& (filename_cmp (src->filename, loc->source_file) == 0)
&& loc->symtab != NULL
&& (filename_cmp (src->filename, loc->symtab->filename) == 0)
&& line->line_or_addr.loa == LOA_LINE
&& loc->line_number == line->line_or_addr.u.line_no)
|| (win == TUI_DISASM_WIN