* breakpoint.h (struct breakpoint): New member GDBARCH.

* breakpoint.c: Include "arch-utils.h".
	(set_raw_breakpoint_without_location): Add GDBARCH parameter.
	Use it to set breakpoint architecture.
	(set_raw_breakpoint): Add GDBARCH parameter.
	(create_internal_breakpoint): Likewise.
	(create_catchpoint): Likewise.
	(create_fork_vfork_event_catchpoint): Likewise.
	(create_breakpoint): Likewise.
	(create_breakpoints): Likewise.
	(break_command_really): Likewise.
	(create_ada_exception_breakpoint): Likewise.
	Update local callers to pass architecture:
	(create_internal_breakpoint): Update.
	(create_overlay_event_breakpoint): Update.
	(create_longjmp_master_breakpoint): Update.
	(create_thread_event_breakpoint): Update.
	(create_solib_event_breakpoint): Update.
	(create_catchpoint): Update.
	(create_fork_vfork_event_catchpoint): Update.
	(set_momentary_breakpoint): Update.
	(clone_momentary_breakpoint): Update.
	(create_breakpoint): Update.
	(create_breakpoints): Update.
	(break_command_really): Update.
	(break_command_1): Update.
	(set_breakpoint): Update.
	(watch_command_1): Update.
	(catch_fork_command_1): Update.
	(catch_exec_commnd_1): Update.
	(handle_gnu_v3_exceptions): Update.
	(create_ada_exception_breakpoint): Update.
	(catch_ada_exception_command): Update.
	(catch_assert_command): Update.
	(trace_command): Update.

	* breakpoint.h (struct bp_location): New member GDBARCH.
	* breakpoint.c (get_sal_arch): New function.
	(set_raw_breakpoint): Set location architecture.
	(add_location_to_breakpoint): Likewise.
	(clone_momentary_breakpoint): Likewise.
	(watch_command_1): Likewise.
	(update_watchpoint): Likewise.
	(bp_loc_is_permanent): Use location architecture instead of
	current_gdbarch.
	(adjust_breakpoint_address): Add GDBARCH parameter; use it
	instead of current_gdbarch.
	Update callers of adjust_breakpoint_address to pass
	breakpoint location architecture:
	(set_raw_breakpoint): Update.
	(watch_command_1): Update.

        * tracepoint.c: (collect_symbol): Add GDBARCH parameter, use instead
	of current_gdbarch.
	(add_local_symbols): Add GDBARCH parameter.  Pass to collect_symbol.
	(encode_actions): Pass tracepoint architecture to add_local_symbols
	(encode_actions): Use tracepoint architecture instead of
	current_gdbarch.  Pass it to add_local_symbols and collect_symbol.

	* breakpoint.h (struct breakpoint_ops): Replace last_addr parameter
	of print_one callback with last_loc.
	* breakpoint.c (print_one_breakpoint_location): Replace last_addr
	parameter with last_loc.
	(print_one_breakpoint): Likewise.
	(do_captured_breakpoint_query): Update call.
	(breakpoint_1): Pass last_loc instead of last_addr to
	print_one_breakpoint.  Pass last location architecture instead of
	current_gdbarch to set_next_address.
	Update all implementations of the print_one callback:
	* breakpoint.c (print_one_catch_fork): Update.
	(print_one_catch_vfork): Update.
	(print_one_catch_exec): Update.
	(print_one_exception_catchpoint): Update.
	* ada-lang.c (print_one_exception): Update.
	(print_one_catch_exception): Update.
	(print_one_catch_exception_unhandled): Update.
	(print_one_catch_assert): Update.

	* breakpoint.c (print_one_breakpoint_location): Add PRINT_ADDRESS_BITS
	parameter.  Use it instead of gdbarch_addr_bit (current_gdbarch).
	(print_one_breakpoint): Add PRINT_ADDRESS_BITS parameter and pass it
	to print_one_breakpoint_location.
	(breakpoint_address_bits): New function.
	(do_captured_breakpoint_query): Compute number of address bits to print
	and pass it to print_one_breakpoint.
	(breakpoint_1): Likewise.  Use it instead of current_gdbarch.

	* breakpoint.h (create_thread_event_breakpoint): Add GDBARCH.
	* breakpoint.c (create_thread_event_breakpoint): Likewise.
	Update callers to create_thread_event_breakpoint:
	* aix-thread.c (pd_enable): Update.
	* linux-thread-db.c (enable_thread_event): Update.

	* breakpoint.h (create_solib_event_breakpoint): Add GDBARCH.
	* breakpoint.c (create_solib_event_breakpoint): Likewise.
	Update callers to create_solib_event_breakpoint:
	* solib-frv.c (enable_break, enable_break2): Update.
	* solib-pa64.c (pa64_solib_create_inferior_hook): Update.
	* solib-som.c (som_solib_create_inferior_hook): Update.
	* solib-darwin.c (darwin_solib_create_inferior_hook): Update.
	* solib-svr4.c (enable_break): Update.

	* breakpoint.h (insert_single_step_breakpoint): Add GDBARCH.
	* breakpoint.c (insert_single_step_breakpoint): Likewise.
	Update callers to insert_single_step_breakpoint:
	* alpha-tdep.c (alpha_software_single_step): Update.
	* arm-linux-tdep.c (arm_linux_software_single_step): Update.
	* arm-tdep.c (arm_software_single_step): Update.
	* cris-tdep.c (cris_software_single_step): Update.
	* rs6000-aix-tdep.c (rs6000_software_single_step): Update.
	* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Update.
	* sparc-tdep.c (sparc_software_single_step): Update.
	* spu-tdep.c (spu_software_single_step): Update.
	* mips-tdep.c (deal_with_atomic_sequence): Add GDBARCH parameter.
	Pass it to insert_single_step_breakpoint.
	(mips_software_single_step): Pass architecture to
	deal_with_atomic_sequence and insert_single_step_breakpoint.

	* breakpoint.h (deprecated_insert_raw_breakpoint): Add GDBARCH.
	(deprecated_remove_raw_breakpoint): Likewise.
	* breakpoint.c (deprecated_insert_raw_breakpoint): Add GDBARCH.
	(deprecated_remove_raw_breakpoint): Likewise.
	Update callers to deprecated_insert_raw_breakpoint and
	deprecated_remove_raw_breakpoint:
	* breakpoint.c (single_step_gdbarch): New static variable.
	(insert_single_step_breakpoint): Pass GDBARCH parameter to
	deprecated_insert_raw_breakpoint.  Store it in single_step_gdbarch.
	(remove_single_step_breakpoints): Pass architecture stored in
	single_step_gdbarch to deprecated_remove_raw_breakpoint.
	* rs6000-nat.c (exec_one_dummy_insn): Update.
	* solib-irix.c (enable_break, disable_break): Update.
	* procfs.c (procfs_mourn_inferior): Update.
	(remove_dbx_link_breakpoint): Update.

	* breakpoint.h (set_breakpoint): Add GDBARCH parameter.
	(set_momentary_breakpoint, set_momentary_breakpoint_at_pc): Likewise.
	* breakpoint.c (set_breakpoint): Add GDBARCH parameter.
	(set_momentary_breakpoint, set_momentary_breakpoint_at_pc): Likewise.
	Update callers to set_breakpoint, set_momentary_breakpoint and
	set_momentary_breakpoint_at_pc:
	* breakpoint.c (set_momentary_breakpoint_at_pc): Update.
	(until_break_command): Update.
	* infcall.c (call_function_by_hand): Update.
	* infcmd.c (finish_backward, finish_forward): Update.
	* infrun.c (insert_step_resume_breakpoint_at_sal): Add GDBARCH
	parameter.  Pass it to set_momentary_breakpoint.
	(insert_longjmp_resume_breakpoint): Add GDBARCH parameter.
	Pass it to set_momentary_breakpoint_at_pc.
	(handle_inferior_event): Update.
	(insert_step_resume_breakpoint_at_frame): Update.
	(insert_step_resume_breakpoint_at_caller): Update..
	* mi/mi-cmd-break.c: Include "arch-utils.h".
	(mi_cmd_break_insert): Update.

	* target.h (struct target_ops): Add GDBARCH parameter to
	to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint,
	and to_remove_hw_breakpoint members.
	(target_insert_breakpoint, target_remove_breakpoint,
	target_insert_hw_breakpoint, target_remove_hw_breakpoint): Add GDBARCH
	parameter, pass to target routine.
	(memory_remove_breakpoint, memory_insert_breakpoint): Add GDBARCH
	parameter.
	* target.c (debug_to_insert_breakpoint, debug_to_remove_breakpoint,
	debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Add
	GDBARCH parameter, pass to target routine.
	(update_current_target): Update function signature.
	* breakpoint.c (insert_bp_location, remove_breakpoint,
	deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint):
	Pass architecture to target_ routines.
	Update all implementations of the target breakpoint routines to take
	GDBARCH parameter and use it instead of GDBARCH as appropriate:
	* corelow.c (ignore): Update.
	* exec.c (ignore): Update.
	* mem-break.c (memory_insert_breakpoint): Update.
	(memory_remove_breakpoint): Update.
	* monitor.c (monitor_insert_breakpoint): Update.
	(monitor_remove_breakpoint): Update.
	* record.c (record_insert_breakpoint): Update.
	(record_beneath_to_insert_breakpoint): Update.
	(record_remove_breakpoint): Update.
	(record_beneath_to_remove_breakpoint): Update.
	* remote.c (remote_insert_breakpoint): Update.
	(remote_remove_breakpoint): Update.
	(remote_insert_hw_breakpoint): Update.
	(remote_remove_hw_breakpoint): Update.
	* remote-m32r-sdi.c (m32r_insert_breakpoint): Update.
	(m32r_remove_breakpoint): Update.
	* remote-mips.c (mips_insert_breakpoint): Update.
	(mips_remove_breakpoint): Update.
	* i386-nat.c (i386_insert_hw_breakpoint): Update.
	(i386_remove_hw_breakpoint): Update.
	* nto-procfs.c (procfs_insert_breakpoint):  Update.
	(procfs_remove_breakpoint): Update.
	(procfs_insert_hw_breakpoint): Update.
	(procfs_remove_hw_breakpoint): Update.

doc/ChangeLog:

	* gdbint.texi (Examples of Use of @code{ui_out} functions):
	Update example code extrated from breakpoint.c.
This commit is contained in:
Ulrich Weigand 2009-07-02 17:12:28 +00:00
parent 36f15f554f
commit a6d9a66e23
42 changed files with 632 additions and 251 deletions

View file

@ -20,6 +20,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "arch-utils.h"
#include <ctype.h>
#include "hashtab.h"
#include "symtab.h"
@ -104,13 +105,16 @@ static void break_command_1 (char *, int, int);
static void mention (struct breakpoint *);
struct breakpoint *set_raw_breakpoint (struct symtab_and_line, enum bptype);
static struct breakpoint *set_raw_breakpoint (struct gdbarch *gdbarch,
struct symtab_and_line,
enum bptype);
static void check_duplicates (struct breakpoint *);
static void breakpoint_adjustment_warning (CORE_ADDR, CORE_ADDR, int, int);
static CORE_ADDR adjust_breakpoint_address (CORE_ADDR bpaddr,
static CORE_ADDR adjust_breakpoint_address (struct gdbarch *gdbarch,
CORE_ADDR bpaddr,
enum bptype bptype);
static void describe_other_breakpoints (CORE_ADDR, struct obj_section *, int);
@ -1005,6 +1009,7 @@ update_watchpoint (struct breakpoint *b, int reparse)
for (tmp = &(b->loc); *tmp != NULL; tmp = &((*tmp)->next))
;
*tmp = loc;
loc->gdbarch = get_type_arch (value_type (v));
loc->address = addr;
loc->length = len;
loc->watchpoint_type = type;
@ -1147,9 +1152,11 @@ Note: automatically using hardware breakpoints for read-only addresses.\n"));
/* No overlay handling: just set the breakpoint. */
if (bpt->loc_type == bp_loc_hardware_breakpoint)
val = target_insert_hw_breakpoint (&bpt->target_info);
val = target_insert_hw_breakpoint (bpt->gdbarch,
&bpt->target_info);
else
val = target_insert_breakpoint (&bpt->target_info);
val = target_insert_breakpoint (bpt->gdbarch,
&bpt->target_info);
}
else
{
@ -1170,7 +1177,8 @@ Note: automatically using hardware breakpoints for read-only addresses.\n"));
/* Set a software (trap) breakpoint at the LMA. */
bpt->overlay_target_info = bpt->target_info;
bpt->overlay_target_info.placed_address = addr;
val = target_insert_breakpoint (&bpt->overlay_target_info);
val = target_insert_breakpoint (bpt->gdbarch,
&bpt->overlay_target_info);
if (val != 0)
fprintf_unfiltered (tmp_error_stream,
"Overlay breakpoint %d failed: in ROM?\n",
@ -1182,9 +1190,11 @@ Note: automatically using hardware breakpoints for read-only addresses.\n"));
{
/* Yes. This overlay section is mapped into memory. */
if (bpt->loc_type == bp_loc_hardware_breakpoint)
val = target_insert_hw_breakpoint (&bpt->target_info);
val = target_insert_hw_breakpoint (bpt->gdbarch,
&bpt->target_info);
else
val = target_insert_breakpoint (&bpt->target_info);
val = target_insert_breakpoint (bpt->gdbarch,
&bpt->target_info);
}
else
{
@ -1458,7 +1468,8 @@ reattach_breakpoints (int pid)
static int internal_breakpoint_number = -1;
static struct breakpoint *
create_internal_breakpoint (CORE_ADDR address, enum bptype type)
create_internal_breakpoint (struct gdbarch *gdbarch,
CORE_ADDR address, enum bptype type)
{
struct symtab_and_line sal;
struct breakpoint *b;
@ -1468,7 +1479,7 @@ create_internal_breakpoint (CORE_ADDR address, enum bptype type)
sal.pc = address;
sal.section = find_pc_overlay (sal.pc);
b = set_raw_breakpoint (sal, type);
b = set_raw_breakpoint (gdbarch, sal, type);
b->number = internal_breakpoint_number--;
b->disposition = disp_donttouch;
@ -1489,7 +1500,8 @@ create_overlay_event_breakpoint (char *func_name)
if (m == NULL)
continue;
b = create_internal_breakpoint (SYMBOL_VALUE_ADDRESS (m),
b = create_internal_breakpoint (get_objfile_arch (objfile),
SYMBOL_VALUE_ADDRESS (m),
bp_overlay_event);
b->addr_string = xstrdup (func_name);
@ -1524,7 +1536,8 @@ create_longjmp_master_breakpoint (char *func_name)
if (m == NULL)
continue;
b = create_internal_breakpoint (SYMBOL_VALUE_ADDRESS (m),
b = create_internal_breakpoint (get_objfile_arch (objfile),
SYMBOL_VALUE_ADDRESS (m),
bp_longjmp_master);
b->addr_string = xstrdup (func_name);
b->enable_state = bp_disabled;
@ -1696,9 +1709,9 @@ remove_breakpoint (struct bp_location *b, insertion_state_t is)
/* No overlay handling: just remove the breakpoint. */
if (b->loc_type == bp_loc_hardware_breakpoint)
val = target_remove_hw_breakpoint (&b->target_info);
val = target_remove_hw_breakpoint (b->gdbarch, &b->target_info);
else
val = target_remove_breakpoint (&b->target_info);
val = target_remove_breakpoint (b->gdbarch, &b->target_info);
}
else
{
@ -1712,9 +1725,11 @@ remove_breakpoint (struct bp_location *b, insertion_state_t is)
/* Ignore any failures: if the LMA is in ROM, we will
have already warned when we failed to insert it. */
if (b->loc_type == bp_loc_hardware_breakpoint)
target_remove_hw_breakpoint (&b->overlay_target_info);
target_remove_hw_breakpoint (b->gdbarch,
&b->overlay_target_info);
else
target_remove_breakpoint (&b->overlay_target_info);
target_remove_breakpoint (b->gdbarch,
&b->overlay_target_info);
}
/* Did we set a breakpoint at the VMA?
If so, we will have marked the breakpoint 'inserted'. */
@ -1725,13 +1740,15 @@ remove_breakpoint (struct bp_location *b, insertion_state_t is)
unmapped, but let's not rely on that being safe. We
don't know what the overlay manager might do. */
if (b->loc_type == bp_loc_hardware_breakpoint)
val = target_remove_hw_breakpoint (&b->target_info);
val = target_remove_hw_breakpoint (b->gdbarch,
&b->target_info);
/* However, we should remove *software* breakpoints only
if the section is still mapped, or else we overwrite
wrong code with the saved shadow contents. */
else if (section_is_mapped (b->section))
val = target_remove_breakpoint (&b->target_info);
val = target_remove_breakpoint (b->gdbarch,
&b->target_info);
else
val = 0;
}
@ -3541,7 +3558,8 @@ static void
print_one_breakpoint_location (struct breakpoint *b,
struct bp_location *loc,
int loc_number,
CORE_ADDR *last_addr)
struct bp_location **last_loc,
int print_address_bits)
{
struct command_line *l;
struct symbol *sym;
@ -3650,7 +3668,7 @@ print_one_breakpoint_location (struct breakpoint *b,
strcpy (wrap_indent, " ");
if (opts.addressprint)
{
if (gdbarch_addr_bit (current_gdbarch) <= 32)
if (print_address_bits <= 32)
strcat (wrap_indent, " ");
else
strcat (wrap_indent, " ");
@ -3663,7 +3681,7 @@ print_one_breakpoint_location (struct breakpoint *b,
to get any nice result. So, make sure there's
just one location. */
gdb_assert (b->loc == NULL || b->loc->next == NULL);
b->ops->print_one (b, last_addr);
b->ops->print_one (b, last_loc);
}
else
switch (b->type)
@ -3714,7 +3732,7 @@ print_one_breakpoint_location (struct breakpoint *b,
if (!header_of_multiple)
print_breakpoint_location (b, loc, wrap_indent, stb);
if (b->loc)
*last_addr = b->loc->address;
*last_loc = b->loc;
break;
}
@ -3850,9 +3868,9 @@ print_one_breakpoint_location (struct breakpoint *b,
static void
print_one_breakpoint (struct breakpoint *b,
CORE_ADDR *last_addr)
struct bp_location **last_loc, int print_address_bits)
{
print_one_breakpoint_location (b, NULL, 0, last_addr);
print_one_breakpoint_location (b, NULL, 0, last_loc, print_address_bits);
/* If this breakpoint has custom print function,
it's already printed. Otherwise, print individual
@ -3875,11 +3893,27 @@ print_one_breakpoint (struct breakpoint *b,
struct bp_location *loc;
int n = 1;
for (loc = b->loc; loc; loc = loc->next, ++n)
print_one_breakpoint_location (b, loc, n, last_addr);
print_one_breakpoint_location (b, loc, n, last_loc,
print_address_bits);
}
}
}
static int
breakpoint_address_bits (struct breakpoint *b)
{
int print_address_bits = 0;
struct bp_location *loc;
for (loc = b->loc; loc; loc = loc->next)
{
int addr_bit = gdbarch_addr_bit (b->gdbarch);
if (addr_bit > print_address_bits)
print_address_bits = addr_bit;
}
return print_address_bits;
}
struct captured_breakpoint_query_args
{
@ -3891,12 +3925,13 @@ do_captured_breakpoint_query (struct ui_out *uiout, void *data)
{
struct captured_breakpoint_query_args *args = data;
struct breakpoint *b;
CORE_ADDR dummy_addr = 0;
struct bp_location *dummy_loc = NULL;
ALL_BREAKPOINTS (b)
{
if (args->bnum == b->number)
{
print_one_breakpoint (b, &dummy_addr);
int print_address_bits = breakpoint_address_bits (b);
print_one_breakpoint (b, &dummy_loc, print_address_bits);
return GDB_RC_OK;
}
}
@ -3941,21 +3976,29 @@ static void
breakpoint_1 (int bnum, int allflag)
{
struct breakpoint *b;
CORE_ADDR last_addr = (CORE_ADDR) -1;
struct bp_location *last_loc = NULL;
int nr_printable_breakpoints;
struct cleanup *bkpttbl_chain;
struct value_print_options opts;
int print_address_bits = 0;
get_user_print_options (&opts);
/* Compute the number of rows in the table. */
/* Compute the number of rows in the table, as well as the
size required for address fields. */
nr_printable_breakpoints = 0;
ALL_BREAKPOINTS (b)
if (bnum == -1
|| bnum == b->number)
{
if (allflag || user_settable_breakpoint (b))
nr_printable_breakpoints++;
{
int addr_bit = breakpoint_address_bits (b);
if (addr_bit > print_address_bits)
print_address_bits = addr_bit;
nr_printable_breakpoints++;
}
}
if (opts.addressprint)
@ -3985,7 +4028,7 @@ breakpoint_1 (int bnum, int allflag)
{
if (nr_printable_breakpoints > 0)
annotate_field (4);
if (gdbarch_addr_bit (current_gdbarch) <= 32)
if (print_address_bits <= 32)
ui_out_table_header (uiout, 10, ui_left, "addr", "Address");/* 5 */
else
ui_out_table_header (uiout, 18, ui_left, "addr", "Address");/* 5 */
@ -4004,7 +4047,7 @@ breakpoint_1 (int bnum, int allflag)
/* We only print out user settable breakpoints unless the
allflag is set. */
if (allflag || user_settable_breakpoint (b))
print_one_breakpoint (b, &last_addr);
print_one_breakpoint (b, &last_loc, print_address_bits);
}
do_cleanups (bkpttbl_chain);
@ -4019,10 +4062,8 @@ breakpoint_1 (int bnum, int allflag)
}
else
{
/* Compare against (CORE_ADDR)-1 in case some compiler decides
that a comparison of an unsigned with -1 is always false. */
if (last_addr != (CORE_ADDR) -1 && !server_command)
set_next_address (current_gdbarch, last_addr);
if (last_loc && !server_command)
set_next_address (last_loc->gdbarch, last_loc->address);
}
/* FIXME? Should this be moved up so that it is only called when
@ -4251,9 +4292,10 @@ breakpoint_adjustment_warning (CORE_ADDR from_addr, CORE_ADDR to_addr,
this function is simply the identity function. */
static CORE_ADDR
adjust_breakpoint_address (CORE_ADDR bpaddr, enum bptype bptype)
adjust_breakpoint_address (struct gdbarch *gdbarch,
CORE_ADDR bpaddr, enum bptype bptype)
{
if (!gdbarch_adjust_breakpoint_address_p (current_gdbarch))
if (!gdbarch_adjust_breakpoint_address_p (gdbarch))
{
/* Very few targets need any kind of breakpoint adjustment. */
return bpaddr;
@ -4274,8 +4316,7 @@ adjust_breakpoint_address (CORE_ADDR bpaddr, enum bptype bptype)
/* Some targets have architectural constraints on the placement
of breakpoint instructions. Obtain the adjusted address. */
adjusted_bpaddr = gdbarch_adjust_breakpoint_address (current_gdbarch,
bpaddr);
adjusted_bpaddr = gdbarch_adjust_breakpoint_address (gdbarch, bpaddr);
/* An adjusted breakpoint address can significantly alter
a user's expectations. Print a warning if an adjustment
@ -4353,7 +4394,8 @@ static void free_bp_location (struct bp_location *loc)
that has type BPTYPE and has no locations as yet. */
static struct breakpoint *
set_raw_breakpoint_without_location (enum bptype bptype)
set_raw_breakpoint_without_location (struct gdbarch *gdbarch,
enum bptype bptype)
{
struct breakpoint *b, *b1;
@ -4361,6 +4403,7 @@ set_raw_breakpoint_without_location (enum bptype bptype)
memset (b, 0, sizeof (*b));
b->type = bptype;
b->gdbarch = gdbarch;
b->language = current_language->la_language;
b->input_radix = input_radix;
b->thread = -1;
@ -4406,6 +4449,18 @@ set_breakpoint_location_function (struct bp_location *loc)
}
}
/* Attempt to determine architecture of location identified by SAL. */
static struct gdbarch *
get_sal_arch (struct symtab_and_line sal)
{
if (sal.section)
return get_objfile_arch (sal.section->objfile);
if (sal.symtab)
return get_objfile_arch (sal.symtab->objfile);
return NULL;
}
/* set_raw_breakpoint is a low level routine for allocating and
partially initializing a breakpoint of type BPTYPE. The newly
created breakpoint's address, section, source file name, and line
@ -4421,11 +4476,17 @@ set_breakpoint_location_function (struct bp_location *loc)
prior to completing the initialization of the breakpoint. If this
should happen, a bogus breakpoint will be left on the chain. */
struct breakpoint *
set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
static struct breakpoint *
set_raw_breakpoint (struct gdbarch *gdbarch,
struct symtab_and_line sal, enum bptype bptype)
{
struct breakpoint *b = set_raw_breakpoint_without_location (bptype);
struct breakpoint *b = set_raw_breakpoint_without_location (gdbarch, bptype);
CORE_ADDR adjusted_address;
struct gdbarch *loc_gdbarch;
loc_gdbarch = get_sal_arch (sal);
if (!loc_gdbarch)
loc_gdbarch = b->gdbarch;
/* Adjust the breakpoint's address prior to allocating a location.
Once we call allocate_bp_location(), that mostly uninitialized
@ -4433,9 +4494,10 @@ set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
breakpoint may cause target_read_memory() to be called and we do
not want its scan of the location chain to find a breakpoint and
location that's only been partially initialized. */
adjusted_address = adjust_breakpoint_address (sal.pc, b->type);
adjusted_address = adjust_breakpoint_address (loc_gdbarch, sal.pc, b->type);
b->loc = allocate_bp_location (b);
b->loc->gdbarch = loc_gdbarch;
b->loc->requested_address = sal.pc;
b->loc->address = adjusted_address;
@ -4536,11 +4598,11 @@ disable_overlay_breakpoints (void)
}
struct breakpoint *
create_thread_event_breakpoint (CORE_ADDR address)
create_thread_event_breakpoint (struct gdbarch *gdbarch, CORE_ADDR address)
{
struct breakpoint *b;
b = create_internal_breakpoint (address, bp_thread_event);
b = create_internal_breakpoint (gdbarch, address, bp_thread_event);
b->enable_state = bp_enabled;
/* addr_string has to be used or breakpoint_re_set will delete me. */
@ -4587,11 +4649,11 @@ remove_solib_event_breakpoints (void)
}
struct breakpoint *
create_solib_event_breakpoint (CORE_ADDR address)
create_solib_event_breakpoint (struct gdbarch *gdbarch, CORE_ADDR address)
{
struct breakpoint *b;
b = create_internal_breakpoint (address, bp_shlib_event);
b = create_internal_breakpoint (gdbarch, address, bp_shlib_event);
update_global_location_list_nothrow (1);
return b;
}
@ -4711,7 +4773,7 @@ print_it_catch_fork (struct breakpoint *b)
/* Implement the "print_one" breakpoint_ops method for fork catchpoints. */
static void
print_one_catch_fork (struct breakpoint *b, CORE_ADDR *last_addr)
print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc)
{
struct value_print_options opts;
@ -4793,7 +4855,7 @@ print_it_catch_vfork (struct breakpoint *b)
/* Implement the "print_one" breakpoint_ops method for vfork catchpoints. */
static void
print_one_catch_vfork (struct breakpoint *b, CORE_ADDR *last_addr)
print_one_catch_vfork (struct breakpoint *b, struct bp_location **last_loc)
{
struct value_print_options opts;
@ -4843,8 +4905,8 @@ static struct breakpoint_ops catch_vfork_breakpoint_ops =
to the catchpoint. */
static struct breakpoint *
create_catchpoint (int tempflag, char *cond_string,
struct breakpoint_ops *ops)
create_catchpoint (struct gdbarch *gdbarch, int tempflag,
char *cond_string, struct breakpoint_ops *ops)
{
struct symtab_and_line sal;
struct breakpoint *b;
@ -4854,7 +4916,7 @@ create_catchpoint (int tempflag, char *cond_string,
sal.symtab = NULL;
sal.line = 0;
b = set_raw_breakpoint (sal, bp_catchpoint);
b = set_raw_breakpoint (gdbarch, sal, bp_catchpoint);
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
@ -4872,10 +4934,12 @@ create_catchpoint (int tempflag, char *cond_string,
}
static void
create_fork_vfork_event_catchpoint (int tempflag, char *cond_string,
create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch,
int tempflag, char *cond_string,
struct breakpoint_ops *ops)
{
struct breakpoint *b = create_catchpoint (tempflag, cond_string, ops);
struct breakpoint *b
= create_catchpoint (gdbarch, tempflag, cond_string, ops);
/* FIXME: We should put this information in a breakpoint private data
area. */
@ -4912,7 +4976,7 @@ print_it_catch_exec (struct breakpoint *b)
}
static void
print_one_catch_exec (struct breakpoint *b, CORE_ADDR *last_addr)
print_one_catch_exec (struct breakpoint *b, struct bp_location **last_loc)
{
struct value_print_options opts;
@ -5030,8 +5094,8 @@ enable_watchpoints_after_interactive_call_stop (void)
Restrict it to frame FRAME if FRAME is nonzero. */
struct breakpoint *
set_momentary_breakpoint (struct symtab_and_line sal, struct frame_id frame_id,
enum bptype type)
set_momentary_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal,
struct frame_id frame_id, enum bptype type)
{
struct breakpoint *b;
@ -5039,7 +5103,7 @@ set_momentary_breakpoint (struct symtab_and_line sal, struct frame_id frame_id,
one. */
gdb_assert (!frame_id_inlined_p (frame_id));
b = set_raw_breakpoint (sal, type);
b = set_raw_breakpoint (gdbarch, sal, type);
b->enable_state = bp_enabled;
b->disposition = disp_donttouch;
b->frame_id = frame_id;
@ -5067,10 +5131,11 @@ clone_momentary_breakpoint (struct breakpoint *orig)
if (orig == NULL)
return NULL;
copy = set_raw_breakpoint_without_location (orig->type);
copy = set_raw_breakpoint_without_location (orig->gdbarch, orig->type);
copy->loc = allocate_bp_location (copy);
set_breakpoint_location_function (copy->loc);
copy->loc->gdbarch = orig->loc->gdbarch;
copy->loc->requested_address = orig->loc->requested_address;
copy->loc->address = orig->loc->address;
copy->loc->section = orig->loc->section;
@ -5093,7 +5158,8 @@ clone_momentary_breakpoint (struct breakpoint *orig)
}
struct breakpoint *
set_momentary_breakpoint_at_pc (CORE_ADDR pc, enum bptype type)
set_momentary_breakpoint_at_pc (struct gdbarch *gdbarch, CORE_ADDR pc,
enum bptype type)
{
struct symtab_and_line sal;
@ -5102,7 +5168,7 @@ set_momentary_breakpoint_at_pc (CORE_ADDR pc, enum bptype type)
sal.section = find_pc_overlay (pc);
sal.explicit_pc = 1;
return set_momentary_breakpoint (sal, null_frame_id, type);
return set_momentary_breakpoint (gdbarch, sal, null_frame_id, type);
}
@ -5256,8 +5322,12 @@ add_location_to_breakpoint (struct breakpoint *b,
for (tmp = &(b->loc); *tmp != NULL; tmp = &((*tmp)->next))
;
*tmp = loc;
loc->gdbarch = get_sal_arch (*sal);
if (!loc->gdbarch)
loc->gdbarch = b->gdbarch;
loc->requested_address = sal->pc;
loc->address = adjust_breakpoint_address (loc->requested_address, b->type);
loc->address = adjust_breakpoint_address (loc->gdbarch,
loc->requested_address, b->type);
loc->section = sal->section;
set_breakpoint_location_function (loc);
@ -5281,7 +5351,7 @@ bp_loc_is_permanent (struct bp_location *loc)
gdb_assert (loc != NULL);
addr = loc->address;
brk = gdbarch_breakpoint_from_pc (current_gdbarch, &addr, &len);
brk = gdbarch_breakpoint_from_pc (loc->gdbarch, &addr, &len);
/* Software breakpoints unsupported? */
if (brk == NULL)
@ -5310,7 +5380,8 @@ bp_loc_is_permanent (struct bp_location *loc)
as condition expression. */
static void
create_breakpoint (struct symtabs_and_lines sals, char *addr_string,
create_breakpoint (struct gdbarch *gdbarch,
struct symtabs_and_lines sals, char *addr_string,
char *cond_string,
enum bptype type, enum bpdisp disposition,
int thread, int task, int ignore_count,
@ -5341,7 +5412,7 @@ create_breakpoint (struct symtabs_and_lines sals, char *addr_string,
if (i == 0)
{
b = set_raw_breakpoint (sal, type);
b = set_raw_breakpoint (gdbarch, sal, type);
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->thread = thread;
@ -5540,7 +5611,8 @@ expand_line_sal_maybe (struct symtab_and_line sal)
COND and SALS arrays and each of those arrays contents. */
static void
create_breakpoints (struct symtabs_and_lines sals, char **addr_string,
create_breakpoints (struct gdbarch *gdbarch,
struct symtabs_and_lines sals, char **addr_string,
char *cond_string,
enum bptype type, enum bpdisp disposition,
int thread, int task, int ignore_count,
@ -5553,7 +5625,7 @@ create_breakpoints (struct symtabs_and_lines sals, char **addr_string,
struct symtabs_and_lines expanded =
expand_line_sal_maybe (sals.sals[i]);
create_breakpoint (expanded, addr_string[i],
create_breakpoint (gdbarch, expanded, addr_string[i],
cond_string, type, disposition,
thread, task, ignore_count, ops, from_tty, enabled);
}
@ -5739,7 +5811,8 @@ find_condition_and_thread (char *tok, CORE_ADDR pc,
parameters. */
static void
break_command_really (char *arg, char *cond_string, int thread,
break_command_really (struct gdbarch *gdbarch,
char *arg, char *cond_string, int thread,
int parse_condition_and_thread,
int tempflag, int hardwareflag, int traceflag,
int ignore_count,
@ -5881,7 +5954,7 @@ break_command_really (char *arg, char *cond_string, int thread,
make_cleanup (xfree, cond_string);
}
}
create_breakpoints (sals, addr_string, cond_string, type_wanted,
create_breakpoints (gdbarch, sals, addr_string, cond_string, type_wanted,
tempflag ? disp_del : disp_donttouch,
thread, task, ignore_count, ops, from_tty, enabled);
}
@ -5892,7 +5965,7 @@ break_command_really (char *arg, char *cond_string, int thread,
make_cleanup (xfree, copy_arg);
b = set_raw_breakpoint_without_location (type_wanted);
b = set_raw_breakpoint_without_location (gdbarch, type_wanted);
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->thread = -1;
@ -5933,7 +6006,8 @@ break_command_1 (char *arg, int flag, int from_tty)
int hardwareflag = flag & BP_HARDWAREFLAG;
int tempflag = flag & BP_TEMPFLAG;
break_command_really (arg,
break_command_really (get_current_arch (),
arg,
NULL, 0, 1 /* parse arg */,
tempflag, hardwareflag, 0 /* traceflag */,
0 /* Ignore count */,
@ -5945,12 +6019,14 @@ break_command_1 (char *arg, int flag, int from_tty)
void
set_breakpoint (char *address, char *condition,
set_breakpoint (struct gdbarch *gdbarch,
char *address, char *condition,
int hardwareflag, int tempflag,
int thread, int ignore_count,
int pending, int enabled)
{
break_command_really (address, condition, thread,
break_command_really (gdbarch,
address, condition, thread,
0 /* condition and thread are valid. */,
tempflag, hardwareflag, 0 /* traceflag */,
ignore_count,
@ -6144,6 +6220,7 @@ stopat_command (char *arg, int from_tty)
static void
watch_command_1 (char *arg, int accessflag, int from_tty)
{
struct gdbarch *gdbarch = get_current_arch ();
struct breakpoint *b, *scope_breakpoint = NULL;
struct symtab_and_line sal;
struct expression *exp;
@ -6299,7 +6376,8 @@ watch_command_1 (char *arg, int accessflag, int from_tty)
if (frame_id_p (frame_unwind_caller_id (frame)))
{
scope_breakpoint
= create_internal_breakpoint (frame_unwind_caller_pc (frame),
= create_internal_breakpoint (frame_unwind_caller_arch (frame),
frame_unwind_caller_pc (frame),
bp_watchpoint_scope);
scope_breakpoint->enable_state = bp_enabled;
@ -6311,16 +6389,19 @@ watch_command_1 (char *arg, int accessflag, int from_tty)
scope_breakpoint->frame_id = frame_unwind_caller_id (frame);
/* Set the address at which we will stop. */
scope_breakpoint->loc->gdbarch
= frame_unwind_caller_arch (frame);
scope_breakpoint->loc->requested_address
= frame_unwind_caller_pc (frame);
scope_breakpoint->loc->address
= adjust_breakpoint_address (scope_breakpoint->loc->requested_address,
= adjust_breakpoint_address (scope_breakpoint->loc->gdbarch,
scope_breakpoint->loc->requested_address,
scope_breakpoint->type);
}
}
/* Now set up the breakpoint. */
b = set_raw_breakpoint (sal, bp_type);
b = set_raw_breakpoint (gdbarch, sal, bp_type);
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->thread = thread;
@ -6527,11 +6608,13 @@ until_break_command (char *arg, int from_tty, int anywhere)
if (anywhere)
/* If the user told us to continue until a specified location,
we don't specify a frame at which we need to stop. */
breakpoint = set_momentary_breakpoint (sal, null_frame_id, bp_until);
breakpoint = set_momentary_breakpoint (get_frame_arch (frame), sal,
null_frame_id, bp_until);
else
/* Otherwise, specify the selected frame, because we want to stop only
at the very same frame. */
breakpoint = set_momentary_breakpoint (sal, get_stack_frame_id (frame),
breakpoint = set_momentary_breakpoint (get_frame_arch (frame), sal,
get_stack_frame_id (frame),
bp_until);
old_chain = make_cleanup_delete_breakpoint (breakpoint);
@ -6543,7 +6626,8 @@ until_break_command (char *arg, int from_tty, int anywhere)
{
sal = find_pc_line (frame_unwind_caller_pc (frame), 0);
sal.pc = frame_unwind_caller_pc (frame);
breakpoint2 = set_momentary_breakpoint (sal,
breakpoint2 = set_momentary_breakpoint (frame_unwind_caller_arch (frame),
sal,
frame_unwind_caller_id (frame),
bp_until);
make_cleanup_delete_breakpoint (breakpoint2);
@ -6661,6 +6745,7 @@ catch_fork_kind;
static void
catch_fork_command_1 (char *arg, int from_tty, struct cmd_list_element *command)
{
struct gdbarch *gdbarch = get_current_arch ();
char *cond_string = NULL;
catch_fork_kind fork_kind;
int tempflag;
@ -6689,12 +6774,12 @@ catch_fork_command_1 (char *arg, int from_tty, struct cmd_list_element *command)
{
case catch_fork_temporary:
case catch_fork_permanent:
create_fork_vfork_event_catchpoint (tempflag, cond_string,
create_fork_vfork_event_catchpoint (gdbarch, tempflag, cond_string,
&catch_fork_breakpoint_ops);
break;
case catch_vfork_temporary:
case catch_vfork_permanent:
create_fork_vfork_event_catchpoint (tempflag, cond_string,
create_fork_vfork_event_catchpoint (gdbarch, tempflag, cond_string,
&catch_vfork_breakpoint_ops);
break;
default:
@ -6706,6 +6791,7 @@ catch_fork_command_1 (char *arg, int from_tty, struct cmd_list_element *command)
static void
catch_exec_command_1 (char *arg, int from_tty, struct cmd_list_element *command)
{
struct gdbarch *gdbarch = get_current_arch ();
int tempflag;
char *cond_string = NULL;
@ -6727,7 +6813,8 @@ catch_exec_command_1 (char *arg, int from_tty, struct cmd_list_element *command)
/* If this target supports it, create an exec catchpoint
and enable reporting of such events. */
create_catchpoint (tempflag, cond_string, &catch_exec_breakpoint_ops);
create_catchpoint (gdbarch, tempflag, cond_string,
&catch_exec_breakpoint_ops);
}
static enum print_stop_action
@ -6762,7 +6849,7 @@ print_exception_catchpoint (struct breakpoint *b)
}
static void
print_one_exception_catchpoint (struct breakpoint *b, CORE_ADDR *last_addr)
print_one_exception_catchpoint (struct breakpoint *b, struct bp_location **last_loc)
{
struct value_print_options opts;
get_user_print_options (&opts);
@ -6776,7 +6863,7 @@ print_one_exception_catchpoint (struct breakpoint *b, CORE_ADDR *last_addr)
}
annotate_field (5);
if (b->loc)
*last_addr = b->loc->address;
*last_loc = b->loc;
if (strstr (b->addr_string, "throw") != NULL)
ui_out_field_string (uiout, "what", "exception throw");
else
@ -6818,7 +6905,8 @@ handle_gnu_v3_exceptions (int tempflag, char *cond_string,
else
trigger_func_name = "__cxa_throw";
break_command_really (trigger_func_name, cond_string, -1,
break_command_really (get_current_arch (),
trigger_func_name, cond_string, -1,
0 /* condition and thread are valid. */,
tempflag, 0, 0,
0,
@ -6878,7 +6966,8 @@ catch_throw_command (char *arg, int from_tty, struct cmd_list_element *command)
/* Create a breakpoint struct for Ada exception catchpoints. */
static void
create_ada_exception_breakpoint (struct symtab_and_line sal,
create_ada_exception_breakpoint (struct gdbarch *gdbarch,
struct symtab_and_line sal,
char *addr_string,
char *exp_string,
char *cond_string,
@ -6902,7 +6991,7 @@ create_ada_exception_breakpoint (struct symtab_and_line sal,
enough for now, though. */
}
b = set_raw_breakpoint (sal, bp_breakpoint);
b = set_raw_breakpoint (gdbarch, sal, bp_breakpoint);
set_breakpoint_count (breakpoint_count + 1);
b->enable_state = bp_enabled;
@ -6927,6 +7016,7 @@ static void
catch_ada_exception_command (char *arg, int from_tty,
struct cmd_list_element *command)
{
struct gdbarch *gdbarch = get_current_arch ();
int tempflag;
struct symtab_and_line sal;
enum bptype type;
@ -6942,7 +7032,7 @@ catch_ada_exception_command (char *arg, int from_tty,
arg = "";
sal = ada_decode_exception_location (arg, &addr_string, &exp_string,
&cond_string, &cond, &ops);
create_ada_exception_breakpoint (sal, addr_string, exp_string,
create_ada_exception_breakpoint (gdbarch, sal, addr_string, exp_string,
cond_string, cond, ops, tempflag,
from_tty);
}
@ -6952,6 +7042,7 @@ catch_ada_exception_command (char *arg, int from_tty,
static void
catch_assert_command (char *arg, int from_tty, struct cmd_list_element *command)
{
struct gdbarch *gdbarch = get_current_arch ();
int tempflag;
struct symtab_and_line sal;
char *addr_string = NULL;
@ -6962,8 +7053,8 @@ catch_assert_command (char *arg, int from_tty, struct cmd_list_element *command)
if (!arg)
arg = "";
sal = ada_decode_assert_location (arg, &addr_string, &ops);
create_ada_exception_breakpoint (sal, addr_string, NULL, NULL, NULL, ops,
tempflag, from_tty);
create_ada_exception_breakpoint (gdbarch, sal, addr_string, NULL, NULL, NULL,
ops, tempflag, from_tty);
}
static void
@ -8230,7 +8321,7 @@ decode_line_spec_1 (char *string, int funfirstline)
someday. */
void *
deprecated_insert_raw_breakpoint (CORE_ADDR pc)
deprecated_insert_raw_breakpoint (struct gdbarch *gdbarch, CORE_ADDR pc)
{
struct bp_target_info *bp_tgt;
@ -8238,7 +8329,7 @@ deprecated_insert_raw_breakpoint (CORE_ADDR pc)
memset (bp_tgt, 0, sizeof (struct bp_target_info));
bp_tgt->placed_address = pc;
if (target_insert_breakpoint (bp_tgt) != 0)
if (target_insert_breakpoint (gdbarch, bp_tgt) != 0)
{
/* Could not insert the breakpoint. */
xfree (bp_tgt);
@ -8251,12 +8342,12 @@ deprecated_insert_raw_breakpoint (CORE_ADDR pc)
/* Remove a breakpoint BP inserted by deprecated_insert_raw_breakpoint. */
int
deprecated_remove_raw_breakpoint (void *bp)
deprecated_remove_raw_breakpoint (struct gdbarch *gdbarch, void *bp)
{
struct bp_target_info *bp_tgt = bp;
int ret;
ret = target_remove_breakpoint (bp_tgt);
ret = target_remove_breakpoint (gdbarch, bp_tgt);
xfree (bp_tgt);
return ret;
@ -8265,20 +8356,25 @@ deprecated_remove_raw_breakpoint (void *bp)
/* One (or perhaps two) breakpoints used for software single stepping. */
static void *single_step_breakpoints[2];
static struct gdbarch *single_step_gdbarch[2];
/* Create and insert a breakpoint for software single step. */
void
insert_single_step_breakpoint (CORE_ADDR next_pc)
insert_single_step_breakpoint (struct gdbarch *gdbarch, CORE_ADDR next_pc)
{
void **bpt_p;
if (single_step_breakpoints[0] == NULL)
bpt_p = &single_step_breakpoints[0];
{
bpt_p = &single_step_breakpoints[0];
single_step_gdbarch[0] = gdbarch;
}
else
{
gdb_assert (single_step_breakpoints[1] == NULL);
bpt_p = &single_step_breakpoints[1];
single_step_gdbarch[1] = gdbarch;
}
/* NOTE drow/2006-04-11: A future improvement to this function would be
@ -8288,7 +8384,7 @@ insert_single_step_breakpoint (CORE_ADDR next_pc)
corresponding changes elsewhere where single step breakpoints are
handled, however. So, for now, we use this. */
*bpt_p = deprecated_insert_raw_breakpoint (next_pc);
*bpt_p = deprecated_insert_raw_breakpoint (gdbarch, next_pc);
if (*bpt_p == NULL)
error (_("Could not insert single-step breakpoint at 0x%s"),
paddr_nz (next_pc));
@ -8303,12 +8399,16 @@ remove_single_step_breakpoints (void)
/* See insert_single_step_breakpoint for more about this deprecated
call. */
deprecated_remove_raw_breakpoint (single_step_breakpoints[0]);
deprecated_remove_raw_breakpoint (single_step_gdbarch[0],
single_step_breakpoints[0]);
single_step_gdbarch[0] = NULL;
single_step_breakpoints[0] = NULL;
if (single_step_breakpoints[1] != NULL)
{
deprecated_remove_raw_breakpoint (single_step_breakpoints[1]);
deprecated_remove_raw_breakpoint (single_step_gdbarch[1],
single_step_breakpoints[1]);
single_step_gdbarch[1] = NULL;
single_step_breakpoints[1] = NULL;
}
}
@ -8343,7 +8443,8 @@ set_tracepoint_count (int num)
void
trace_command (char *arg, int from_tty)
{
break_command_really (arg,
break_command_really (get_current_arch (),
arg,
NULL, 0, 1 /* parse arg */,
0 /* tempflag */, 0 /* hardwareflag */,
1 /* traceflag */,