This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: RFA: Breakpoint infrastructure cleanups [3/8] - set type for impl_breakpoints
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 6 Nov 2003 13:19:12 -0500
- Subject: Re: RFA: Breakpoint infrastructure cleanups [3/8] - set type for impl_breakpoints
- References: <20031008170750.GA9238@nevyn.them.org>
On Wed, Oct 08, 2003 at 01:07:50PM -0400, Daniel Jacobowitz wrote:
> Sets the type field for impl_breakpoints. There are only four right now:
> impl_bp_software_breakpoint
> impl_bp_hardware_breakpoint
> impl_bp_hardware_watchpoint
> impl_bp_other
>
> The others are a grab bag, mostly catchpoints. This will collapse some
> lengthy duplicated tests for "is this really implemented by a breakpoint";
> it also would let us use hardware breakpoints for things like a solib event
> breakpoint if some system had enough hardware breakpoints to do it, by
> moving the is-hardware information out of the user-level breakpoint type
> field. Towards further object-orientation.
Here's part three. These are now bp_loc_*; I'm open to loc_* or other
conventions, but I've got no strong preference.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2003-11-06 Daniel Jacobowitz <drow@mvista.com>
* breakpoint.c (allocate_bp_location): Take bpt and bp_type
arguments. Initialize owner and type for the new breakpoint
location item.
(set_raw_breakpoint): Update call to allocate_bp_location.
Index: gdb/breakpoint.c
===================================================================
--- gdb.orig/breakpoint.c 2003-11-06 10:46:03.000000000 -0500
+++ gdb/breakpoint.c 2003-11-06 10:49:15.000000000 -0500
@@ -3910,13 +3910,53 @@ adjust_breakpoint_address (CORE_ADDR bpa
/* Allocate a struct bp_location. */
struct bp_location *
-allocate_bp_location (void)
+allocate_bp_location (struct breakpoint *bpt, enum bptype bp_type)
{
struct bp_location *loc, *loc_p;
loc = xmalloc (sizeof (struct bp_location));
memset (loc, 0, sizeof (*loc));
+ loc->owner = bpt;
+
+ switch (bp_type)
+ {
+ case bp_breakpoint:
+ case bp_until:
+ case bp_finish:
+ case bp_longjmp:
+ case bp_longjmp_resume:
+ case bp_step_resume:
+ case bp_through_sigtramp:
+ case bp_watchpoint_scope:
+ case bp_call_dummy:
+ case bp_shlib_event:
+ case bp_thread_event:
+ case bp_overlay_event:
+ case bp_catch_load:
+ case bp_catch_unload:
+ loc->loc_type = bp_loc_software_breakpoint;
+ break;
+ case bp_hardware_breakpoint:
+ loc->loc_type = bp_loc_hardware_breakpoint;
+ break;
+ case bp_hardware_watchpoint:
+ case bp_read_watchpoint:
+ case bp_access_watchpoint:
+ loc->loc_type = bp_loc_hardware_watchpoint;
+ break;
+ case bp_watchpoint:
+ case bp_catch_fork:
+ case bp_catch_vfork:
+ case bp_catch_exec:
+ case bp_catch_catch:
+ case bp_catch_throw:
+ loc->loc_type = bp_loc_other;
+ break;
+ default:
+ internal_error (__FILE__, __LINE__, "unknown breakpoint type");
+ }
+
/* Add this breakpoint to the end of the chain. */
loc_p = bp_location_chain;
@@ -3954,7 +3994,7 @@ set_raw_breakpoint (struct symtab_and_li
b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
memset (b, 0, sizeof (*b));
- b->loc = allocate_bp_location ();
+ b->loc = allocate_bp_location (b, bptype);
b->loc->requested_address = sal.pc;
b->loc->address = adjust_breakpoint_address (b->loc->requested_address);
if (sal.symtab == NULL)