2011-07-25 Pedro Alves <pedro@codesourcery.com>

Implement most breakpoint_ops methods for all breakpoint types,
	and move the default handlings to the proper callbacks.

	gdb/
	* breakpoint.c (update_watchpoint): Always call the breakpoint's
	works_in_software_mode method.
	(insert_bp_location): Go through breakpoint_ops->insert_location
	for software and hardware watchpoints.
	(create_internal_breakpoint): Pass bkpt_breakpoint_ops as
	breakpoint_ops.
	(remove_breakpoint_1): Go through breakpoint_ops->remove_location
	for software and hardware watchpoints.
	(print_it_typical): Delete.
	(print_bp_stop_message): Always call the breakpoint_ops->print_it
	method.
	(watchpoint_check): Adjust comment.
	(bpstat_check_location): Simply always call the breakpoint's
	breakpoint_hit method.
	(bpstat_stop_status): Always call the breakpoint's check_status
	method.  Remove special cases for watchpoints and internal event
	breakpoints from here (moved to the check_status implementations).
	(print_one_breakpoint_location): Assume b->ops is never NULL.
	Remove static tracepoint marker id printing from here (moved to
	the print_one_detail callback implementation of tracepoints).
	(init_bp_location): Assert OPS is never NULL.
	(allocate_bp_location): Always call the breakpoint's
	allocate_location method, and remove the default code from here.
	(free_bp_location): Always call the location's dtor method, and
	remove the default code from here.
	(init_raw_breakpoint_without_location): Assert OPS is never NULL.
	(set_raw_breakpoint_without_location): Add new breakpoint_ops
	parameter.  Pass it down.
	(set_raw_breakpoint): Ditto.
	(print_it_catch_fork): Adjust to take a bpstat as argument.
	(catch_fork_breakpoint_ops): Install methods.
	(print_it_catch_vfork): Adjust to take a bpstat as argument.
	(catch_vfork_breakpoint_ops): Install methods.
	(dtor_catch_syscall): Call the base dtor.
	(print_it_catch_syscall): Adjust to take a bpstat as argument.
	(catch_syscall_breakpoint_ops): Install methods.
	(dtor_catch_exec): Call the base dtor.
	(print_it_catch_exec): Adjust to take a bpstat as argument.
	(catch_exec_breakpoint_ops): Install methods.
	(hw_breakpoint_used_count, hw_watchpoint_used_count): Always call
	the breakpoint's resources_needed method, and remove the default
	code from here.
	(set_momentary_breakpoint): Pass bkpt_breakpoint_ops as
	breakpoint_ops.
	(clone_momentary_breakpoint): Clone the original's ops.
	(mention): Always call the breakpoint's print_mention method, and
	remove the default code from here.
	(create_breakpoint_sal): Adjust to pass the ops to
	set_raw_breakpoint rather than setting it manually.
	(create_breakpoint): Assert ops is never NULL.  Adjust to pass the
	ops to set_raw_breakpoint_without_location rather than setting it
	manually.
	(break_command_1): Pass bkpt_breakpoint_ops as breakpoint_ops.
	(print_it_ranged_breakpoint): Adjust to take a bpstat as argument.
	(ranged_breakpoint_ops): Install methods.
	(break_range_command): Adjust to pass the ops to
	set_raw_breakpoint rather than setting it manually.
	(re_set_watchpoint, breakpoint_hit_watchpoint)
	(check_status_watchpoint, resources_needed_watchpoint)
	(works_in_software_mode_watchpoint, print_it_watchpoint)
	(print_mention_watchpoint, print_recreate_watchpoint): New
	functions.
	(watchpoint_breakpoint_ops): Install new methods.
	(print_it_masked_watchpoint): New function.
	(masked_watchpoint_breakpoint_ops): Install new methods.
	(watch_command_1): Adjust to pass the right breakpoint_ops to
	set_raw_breakpoint_without_location rather than setting it
	manually later.  Record the current pspace.
	(print_it_exception_catchpoint): Adjust to take a bpstat as
	argument.
	(gnu_v3_exception_catchpoint_ops): Install new methods.
	(say_where): New function.
	(null_re_set, null_check_status, null_works_in_software_mode)
	(null_resources_needed, null_print_one_detail, bp_location_dtor):
	New functions.
	(bp_location_ops): New global.
	(bkpt_dtor, bkpt_allocate_location, bkpt_re_set)
	(bkpt_insert_location, bkpt_remove_location, bkpt_breakpoint_hit)
	(bkpt_check_status, bkpt_resources_needed)
	(bkpt_works_in_software_mode, bkpt_print_it, bkpt_print_mention)
	(bkpt_print_recreate): New functions.
	(bkpt_breakpoint_ops): New global.
	(tracepoint_re_set, tracepoint_insert_location)
	(tracepoint_remove_location, tracepoint_breakpoint_hit)
	(tracepoint_check_status, tracepoint_works_in_software_mode)
	(tracepoint_print_it, tracepoint_print_one_detail)
	(tracepoint_print_mention, tracepoint_print_recreate): New
	functions.
	(tracepoint_breakpoint_ops): New global.
	(delete_breakpoint): Always call the breakpoint's dtor method, and
	remove the default handling from here.
	(breakpoint_re_set_default): Make static.
	(breakpoint_re_set_one): Always call the breakpoints re_set
	method, and remove the default handling from here.
	(trace_command, ftrace_command, strace_command)
	(create_tracepoint_from_upload): Pass appropriate breakpoints_ops
	to create_breakpoint.
	(save_breakpoints): Always call the breakpoint's print_recreate
	method, and remove the default handling from here.

	* ada-lang.c (dtor_exception): Call the base dtor.
	(re_set_exception): Call the base method.
	(print_it_exception, print_it_catch_exception): Adjust to take a
	bpstat as argument.
	(catch_exception_breakpoint_ops): Install methods.
	(print_it_catch_exception_unhandled): Adjust to take a bpstat as
	argument.
	(catch_exception_unhandled_breakpoint_ops): Install methods.
	(print_it_catch_assert): Adjust to take a bpstat as argument.
	(catch_assert_breakpoint_ops): Install methods.

	* breakpoint.h (struct breakpoint_ops): Adjust the print_it method
	to take a bpstat as argument.
	(enum print_stop_action): Add describing comments to each enum
	value.
	(breakpoint_re_set_default): Delete declaration.
	(null_re_set, null_works_in_software_mode, null_resources_needed)
	(null_check_status, null_print_one_detail): Declare.
	(bkpt_breakpoint_ops): Declare.
	(bkpt_dtor, bkpt_allocate_location, bkpt_re_set)
	(bkpt_insert_location, bkpt_remove_location, bkpt_breakpoint_hit)
	(bkpt_check_status, bkpt_resources_needed)
	(bkpt_works_in_software_mode, bkpt_print_it)
	(null_print_one_detail, bkpt_print_mention, bkpt_print_recreate):
	Declare.

	* mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust to pass
	bkpt_breakpoint_ops.
	* python/py-breakpoint.c (bppy_init): Ditto.
This commit is contained in:
Pedro Alves 2011-07-25 11:16:49 +00:00
parent 4b9dc14e0c
commit 348d480fa9
6 changed files with 1175 additions and 826 deletions

View file

@ -1,3 +1,138 @@
2011-07-25 Pedro Alves <pedro@codesourcery.com>
Implement most breakpoint_ops methods for all breakpoint types,
and move the default handlings to the proper callbacks.
* breakpoint.c (update_watchpoint): Always call the breakpoint's
works_in_software_mode method.
(insert_bp_location): Go through breakpoint_ops->insert_location
for software and hardware watchpoints.
(create_internal_breakpoint): Pass bkpt_breakpoint_ops as
breakpoint_ops.
(remove_breakpoint_1): Go through breakpoint_ops->remove_location
for software and hardware watchpoints.
(print_it_typical): Delete.
(print_bp_stop_message): Always call the breakpoint_ops->print_it
method.
(watchpoint_check): Adjust comment.
(bpstat_check_location): Simply always call the breakpoint's
breakpoint_hit method.
(bpstat_stop_status): Always call the breakpoint's check_status
method. Remove special cases for watchpoints and internal event
breakpoints from here (moved to the check_status implementations).
(print_one_breakpoint_location): Assume b->ops is never NULL.
Remove static tracepoint marker id printing from here (moved to
the print_one_detail callback implementation of tracepoints).
(init_bp_location): Assert OPS is never NULL.
(allocate_bp_location): Always call the breakpoint's
allocate_location method, and remove the default code from here.
(free_bp_location): Always call the location's dtor method, and
remove the default code from here.
(init_raw_breakpoint_without_location): Assert OPS is never NULL.
(set_raw_breakpoint_without_location): Add new breakpoint_ops
parameter. Pass it down.
(set_raw_breakpoint): Ditto.
(print_it_catch_fork): Adjust to take a bpstat as argument.
(catch_fork_breakpoint_ops): Install methods.
(print_it_catch_vfork): Adjust to take a bpstat as argument.
(catch_vfork_breakpoint_ops): Install methods.
(dtor_catch_syscall): Call the base dtor.
(print_it_catch_syscall): Adjust to take a bpstat as argument.
(catch_syscall_breakpoint_ops): Install methods.
(dtor_catch_exec): Call the base dtor.
(print_it_catch_exec): Adjust to take a bpstat as argument.
(catch_exec_breakpoint_ops): Install methods.
(hw_breakpoint_used_count, hw_watchpoint_used_count): Always call
the breakpoint's resources_needed method, and remove the default
code from here.
(set_momentary_breakpoint): Pass bkpt_breakpoint_ops as
breakpoint_ops.
(clone_momentary_breakpoint): Clone the original's ops.
(mention): Always call the breakpoint's print_mention method, and
remove the default code from here.
(create_breakpoint_sal): Adjust to pass the ops to
set_raw_breakpoint rather than setting it manually.
(create_breakpoint): Assert ops is never NULL. Adjust to pass the
ops to set_raw_breakpoint_without_location rather than setting it
manually.
(break_command_1): Pass bkpt_breakpoint_ops as breakpoint_ops.
(print_it_ranged_breakpoint): Adjust to take a bpstat as argument.
(ranged_breakpoint_ops): Install methods.
(break_range_command): Adjust to pass the ops to
set_raw_breakpoint rather than setting it manually.
(re_set_watchpoint, breakpoint_hit_watchpoint)
(check_status_watchpoint, resources_needed_watchpoint)
(works_in_software_mode_watchpoint, print_it_watchpoint)
(print_mention_watchpoint, print_recreate_watchpoint): New
functions.
(watchpoint_breakpoint_ops): Install new methods.
(print_it_masked_watchpoint): New function.
(masked_watchpoint_breakpoint_ops): Install new methods.
(watch_command_1): Adjust to pass the right breakpoint_ops to
set_raw_breakpoint_without_location rather than setting it
manually later. Record the current pspace.
(print_it_exception_catchpoint): Adjust to take a bpstat as
argument.
(gnu_v3_exception_catchpoint_ops): Install new methods.
(say_where): New function.
(null_re_set, null_check_status, null_works_in_software_mode)
(null_resources_needed, null_print_one_detail, bp_location_dtor):
New functions.
(bp_location_ops): New global.
(bkpt_dtor, bkpt_allocate_location, bkpt_re_set)
(bkpt_insert_location, bkpt_remove_location, bkpt_breakpoint_hit)
(bkpt_check_status, bkpt_resources_needed)
(bkpt_works_in_software_mode, bkpt_print_it, bkpt_print_mention)
(bkpt_print_recreate): New functions.
(bkpt_breakpoint_ops): New global.
(tracepoint_re_set, tracepoint_insert_location)
(tracepoint_remove_location, tracepoint_breakpoint_hit)
(tracepoint_check_status, tracepoint_works_in_software_mode)
(tracepoint_print_it, tracepoint_print_one_detail)
(tracepoint_print_mention, tracepoint_print_recreate): New
functions.
(tracepoint_breakpoint_ops): New global.
(delete_breakpoint): Always call the breakpoint's dtor method, and
remove the default handling from here.
(breakpoint_re_set_default): Make static.
(breakpoint_re_set_one): Always call the breakpoints re_set
method, and remove the default handling from here.
(trace_command, ftrace_command, strace_command)
(create_tracepoint_from_upload): Pass appropriate breakpoints_ops
to create_breakpoint.
(save_breakpoints): Always call the breakpoint's print_recreate
method, and remove the default handling from here.
* ada-lang.c (dtor_exception): Call the base dtor.
(re_set_exception): Call the base method.
(print_it_exception, print_it_catch_exception): Adjust to take a
bpstat as argument.
(catch_exception_breakpoint_ops): Install methods.
(print_it_catch_exception_unhandled): Adjust to take a bpstat as
argument.
(catch_exception_unhandled_breakpoint_ops): Install methods.
(print_it_catch_assert): Adjust to take a bpstat as argument.
(catch_assert_breakpoint_ops): Install methods.
* breakpoint.h (struct breakpoint_ops): Adjust the print_it method
to take a bpstat as argument.
(enum print_stop_action): Add describing comments to each enum
value.
(breakpoint_re_set_default): Delete declaration.
(null_re_set, null_works_in_software_mode, null_resources_needed)
(null_check_status, null_print_one_detail): Declare.
(bkpt_breakpoint_ops): Declare.
(bkpt_dtor, bkpt_allocate_location, bkpt_re_set)
(bkpt_insert_location, bkpt_remove_location, bkpt_breakpoint_hit)
(bkpt_check_status, bkpt_resources_needed)
(bkpt_works_in_software_mode, bkpt_print_it)
(null_print_one_detail, bkpt_print_mention, bkpt_print_recreate):
Declare.
* mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust to pass
bkpt_breakpoint_ops.
* python/py-breakpoint.c (bppy_init): Ditto.
2011-07-15 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* MAINTAINERS (Write After Approval): Add myself to the list.

View file

@ -10988,6 +10988,8 @@ dtor_exception (enum exception_catchpoint_kind ex, struct breakpoint *b)
struct ada_catchpoint *c = (struct ada_catchpoint *) b;
xfree (c->excep_string);
bkpt_dtor (b);
}
/* Implement the ALLOCATE_LOCATION method in the breakpoint_ops
@ -11015,7 +11017,7 @@ re_set_exception (enum exception_catchpoint_kind ex, struct breakpoint *b)
/* Call the base class's method. This updates the catchpoint's
locations. */
breakpoint_re_set_default (b);
bkpt_re_set (b);
/* Reparse the exception conditional expressions. One for each
location. */
@ -11074,8 +11076,10 @@ check_status_exception (enum exception_catchpoint_kind ex, bpstat bs)
for all exception catchpoint kinds. */
static enum print_stop_action
print_it_exception (enum exception_catchpoint_kind ex, struct breakpoint *b)
print_it_exception (enum exception_catchpoint_kind ex, bpstat bs)
{
struct breakpoint *b = bs->breakpoint_at;
annotate_catchpoint (b->number);
if (ui_out_is_mi_like_p (uiout))
@ -11287,9 +11291,9 @@ check_status_catch_exception (bpstat bs)
}
static enum print_stop_action
print_it_catch_exception (struct breakpoint *b)
print_it_catch_exception (bpstat bs)
{
return print_it_exception (ex_catch_exception, b);
return print_it_exception (ex_catch_exception, bs);
}
static void
@ -11315,15 +11319,15 @@ static struct breakpoint_ops catch_exception_breakpoint_ops =
dtor_catch_exception,
allocate_location_catch_exception,
re_set_catch_exception,
NULL, /* insert */
NULL, /* remove */
NULL, /* breakpoint_hit */
bkpt_insert_location,
bkpt_remove_location,
bkpt_breakpoint_hit,
check_status_catch_exception,
NULL, /* resources_needed */
NULL, /* works_in_software_mode */
bkpt_resources_needed,
null_works_in_software_mode,
print_it_catch_exception,
print_one_catch_exception,
NULL, /* print_one_detail */
null_print_one_detail,
print_mention_catch_exception,
print_recreate_catch_exception
};
@ -11355,9 +11359,9 @@ check_status_catch_exception_unhandled (bpstat bs)
}
static enum print_stop_action
print_it_catch_exception_unhandled (struct breakpoint *b)
print_it_catch_exception_unhandled (bpstat bs)
{
return print_it_exception (ex_catch_exception_unhandled, b);
return print_it_exception (ex_catch_exception_unhandled, bs);
}
static void
@ -11384,15 +11388,15 @@ static struct breakpoint_ops catch_exception_unhandled_breakpoint_ops = {
dtor_catch_exception_unhandled,
allocate_location_catch_exception_unhandled,
re_set_catch_exception_unhandled,
NULL, /* insert */
NULL, /* remove */
NULL, /* breakpoint_hit */
bkpt_insert_location,
bkpt_remove_location,
bkpt_breakpoint_hit,
check_status_catch_exception_unhandled,
NULL, /* resources_needed */
NULL, /* works_in_software_mode */
bkpt_resources_needed,
null_works_in_software_mode,
print_it_catch_exception_unhandled,
print_one_catch_exception_unhandled,
NULL, /* print_one_detail */
null_print_one_detail,
print_mention_catch_exception_unhandled,
print_recreate_catch_exception_unhandled
};
@ -11424,9 +11428,9 @@ check_status_catch_assert (bpstat bs)
}
static enum print_stop_action
print_it_catch_assert (struct breakpoint *b)
print_it_catch_assert (bpstat bs)
{
return print_it_exception (ex_catch_assert, b);
return print_it_exception (ex_catch_assert, bs);
}
static void
@ -11451,15 +11455,15 @@ static struct breakpoint_ops catch_assert_breakpoint_ops = {
dtor_catch_assert,
allocate_location_catch_assert,
re_set_catch_assert,
NULL, /* insert */
NULL, /* remove */
NULL, /* breakpoint_hit */
bkpt_insert_location,
bkpt_remove_location,
bkpt_breakpoint_hit,
check_status_catch_assert,
NULL, /* resources_needed */
NULL, /* works_in_software_mode */
bkpt_resources_needed,
null_works_in_software_mode,
print_it_catch_assert,
print_one_catch_assert,
NULL, /* print_one_detail */
null_print_one_detail,
print_mention_catch_assert,
print_recreate_catch_assert
};

File diff suppressed because it is too large Load diff

View file

@ -422,8 +422,8 @@ struct breakpoint_ops
void (*re_set) (struct breakpoint *self);
/* Insert the breakpoint or watchpoint or activate the catchpoint.
Return 0 for success, 1 if the breakpoint, watchpoint or catchpoint
type is not supported, -1 for failure. */
Return 0 for success, 1 if the breakpoint, watchpoint or
catchpoint type is not supported, -1 for failure. */
int (*insert_location) (struct bp_location *);
/* Remove the breakpoint/catchpoint that was previously inserted
@ -454,7 +454,7 @@ struct breakpoint_ops
/* The normal print routine for this breakpoint, called when we
hit it. */
enum print_stop_action (*print_it) (struct breakpoint *);
enum print_stop_action (*print_it) (struct bpstats *bs);
/* Display information about this breakpoint, for "info
breakpoints". */
@ -801,9 +801,19 @@ struct bpstat_what
print_it_done, print_it_noop. */
enum print_stop_action
{
/* We printed nothing or we need to do some more analysis. */
PRINT_UNKNOWN = -1,
/* We printed something, and we *do* desire that something to be
followed by a location. */
PRINT_SRC_AND_LOC,
/* We printed something, and we do *not* desire that something to
be followed by a location. */
PRINT_SRC_ONLY,
/* We already printed all we needed to print, don't print anything
else. */
PRINT_NOTHING
};
@ -980,12 +990,6 @@ extern void breakpoint_re_set (void);
extern void breakpoint_re_set_thread (struct breakpoint *);
/* The default re_set method, for typical hardware or software
breakpoints. Reevaluate the breakpoint and recreate its
locations. */
extern void breakpoint_re_set_default (struct breakpoint *);
extern struct breakpoint *set_momentary_breakpoint
(struct gdbarch *, struct symtab_and_line, struct frame_id, enum bptype);
@ -1025,6 +1029,32 @@ extern void awatch_command_wrapper (char *, int, int);
extern void rwatch_command_wrapper (char *, int, int);
extern void tbreak_command (char *, int);
extern void null_re_set (struct breakpoint *b);
extern int null_works_in_software_mode (const struct breakpoint *b);
extern int null_resources_needed (const struct bp_location *bl);
extern void null_check_status (bpstat bs);
extern void null_print_one_detail (const struct breakpoint *self,
struct ui_out *uiout);
extern struct breakpoint_ops bkpt_breakpoint_ops;
extern void bkpt_dtor (struct breakpoint *self);
extern struct bp_location *bkpt_allocate_location (struct breakpoint *self);
extern void bkpt_re_set (struct breakpoint *b);
extern int bkpt_insert_location (struct bp_location *bl);
extern int bkpt_remove_location (struct bp_location *bl);
extern int bkpt_breakpoint_hit (const struct bp_location *bl,
struct address_space *aspace,
CORE_ADDR bp_addr);
extern void bkpt_check_status (bpstat bs);
extern int bkpt_resources_needed (const struct bp_location *bl);
extern int bkpt_works_in_software_mode (const struct breakpoint *b);
extern enum print_stop_action bkpt_print_it (bpstat bs);
extern void null_print_one_detail (const struct breakpoint *self,
struct ui_out *uiout);
extern void bkpt_print_mention (struct breakpoint *b);
extern void bkpt_print_recreate (struct breakpoint *tp, struct ui_file *fp);
/* Arguments to pass as context to some catch command handlers. */
#define CATCH_PERMANENT ((void *) (uintptr_t) 0)
#define CATCH_TEMPORARY ((void *) (uintptr_t) 1)

View file

@ -169,7 +169,7 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
temp_p, type_wanted,
ignore_count,
pending ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE,
NULL, 0, enabled, 0);
&bkpt_breakpoint_ops, 0, enabled, 0);
do_cleanups (back_to);
}

View file

@ -636,7 +636,8 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
0, bp_breakpoint,
0,
AUTO_BOOLEAN_TRUE,
NULL, 0, 1, internal_bp);
&bkpt_breakpoint_ops,
0, 1, internal_bp);
break;
}
case bp_watchpoint: