* breakpoint.h (struct breakpoint_ops): New.

(struct breakpoint): Add ops member.

	* breakpoint.c (print_bp_stop_message, print_one_breakpoint)
	(mention): Use new breakpoint ops member.
	(set_raw_breakpoint): Initialize ops field to NULL.
	(print_exception_catchpoint, print_one_exception_catchpoint)
	(print_mention_exception_catchpoint, handle_gnu_v3_exceptions): New.
	(gnu_v3_exception_catchpoint_ops): New.
	(catch_exception_command_1): Call handle_gnu_v3_exceptions.
This commit is contained in:
Daniel Jacobowitz 2003-04-27 01:11:10 +00:00
parent 44c0647d80
commit 3086aeaed2
3 changed files with 368 additions and 232 deletions

View file

@ -1,3 +1,16 @@
2003-04-26 Daniel Jacobowitz <drow@mvista.com>
* breakpoint.h (struct breakpoint_ops): New.
(struct breakpoint): Add ops member.
* breakpoint.c (print_bp_stop_message, print_one_breakpoint)
(mention): Use new breakpoint ops member.
(set_raw_breakpoint): Initialize ops field to NULL.
(print_exception_catchpoint, print_one_exception_catchpoint)
(print_mention_exception_catchpoint, handle_gnu_v3_exceptions): New.
(gnu_v3_exception_catchpoint_ops): New.
(catch_exception_command_1): Call handle_gnu_v3_exceptions.
2003-04-25 Adam Fedor <fedor@gnu.org>
* Makefile.in (COMMON_OBS): Add objc-lang.o

View file

@ -2271,9 +2271,15 @@ print_bp_stop_message (bpstat bs)
break;
case print_it_normal:
/* Normal case, we handle everything in print_it_typical. */
/* Normal case. Call the breakpoint's print_it method, or
print_it_typical. */
if (bs->breakpoint_at != NULL && bs->breakpoint_at->ops != NULL
&& bs->breakpoint_at->ops->print_it != NULL)
return bs->breakpoint_at->ops->print_it (bs->breakpoint_at);
else
return print_it_typical (bs);
break;
default:
internal_error (__FILE__, __LINE__,
"print_bp_stop_message: unrecognized enum value");
@ -3265,6 +3271,10 @@ print_one_breakpoint (struct breakpoint *b,
else
strcat (wrap_indent, " ");
}
if (b->ops != NULL && b->ops->print_one != NULL)
b->ops->print_one (b, last_addr);
else
switch (b->type)
{
case bp_none:
@ -3851,6 +3861,7 @@ set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
b->triggered_dll_pathname = NULL;
b->forked_inferior_pid = 0;
b->exec_pathname = NULL;
b->ops = NULL;
/* Add this breakpoint to the end of the chain
so that a list of breakpoints will come out in order
@ -4413,6 +4424,9 @@ mention (struct breakpoint *b)
create_breakpoint_hook (b);
breakpoint_create_event (b->number);
if (b->ops != NULL && b->ops->print_mention != NULL)
b->ops->print_mention (b);
else
switch (b->type)
{
case bp_none:
@ -4510,6 +4524,7 @@ mention (struct breakpoint *b)
case bp_overlay_event:
break;
}
if (say_where)
{
if (addressprint || b->source_file == NULL)
@ -6004,6 +6019,90 @@ create_exception_catchpoint (int tempflag, char *cond_string,
mention (b);
}
static enum print_stop_action
print_exception_catchpoint (struct breakpoint *b)
{
annotate_catchpoint (b->number);
if (strstr (b->addr_string, "throw") != NULL)
printf_filtered ("\nCatchpoint %d (exception thrown)\n",
b->number);
else
printf_filtered ("\nCatchpoint %d (exception caught)\n",
b->number);
return PRINT_SRC_AND_LOC;
}
static void
print_one_exception_catchpoint (struct breakpoint *b, CORE_ADDR *last_addr)
{
if (addressprint)
{
annotate_field (4);
ui_out_field_core_addr (uiout, "addr", b->address);
}
annotate_field (5);
*last_addr = b->address;
if (strstr (b->addr_string, "throw") != NULL)
ui_out_field_string (uiout, "what", "exception throw");
else
ui_out_field_string (uiout, "what", "exception catch");
}
static void
print_mention_exception_catchpoint (struct breakpoint *b)
{
if (strstr (b->addr_string, "throw") != NULL)
printf_filtered ("Catchpoint %d (throw)", b->number);
else
printf_filtered ("Catchpoint %d (catch)", b->number);
}
static struct breakpoint_ops gnu_v3_exception_catchpoint_ops = {
print_exception_catchpoint,
print_one_exception_catchpoint,
print_mention_exception_catchpoint
};
static int
handle_gnu_v3_exceptions (int tempflag, char *cond_string,
enum exception_event_kind ex_event, int from_tty)
{
char *trigger_func_name, *nameptr;
struct symtabs_and_lines sals;
struct breakpoint *b;
if (ex_event == EX_EVENT_CATCH)
trigger_func_name = xstrdup ("__cxa_begin_catch");
else
trigger_func_name = xstrdup ("__cxa_throw");
nameptr = trigger_func_name;
sals = decode_line_1 (&nameptr, 1, NULL, 0, NULL);
if (sals.nelts == 0)
{
free (trigger_func_name);
return 0;
}
b = set_raw_breakpoint (sals.sals[0], bp_breakpoint);
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->cond = NULL;
b->cond_string = (cond_string == NULL) ?
NULL : savestring (cond_string, strlen (cond_string));
b->thread = -1;
b->addr_string = trigger_func_name;
b->enable_state = bp_enabled;
b->disposition = tempflag ? disp_del : disp_donttouch;
b->ops = &gnu_v3_exception_catchpoint_ops;
free (sals.sals);
mention (b);
return 1;
}
/* Deal with "catch catch" and "catch throw" commands */
static void
@ -6024,6 +6123,9 @@ catch_exception_command_1 (enum exception_event_kind ex_event, char *arg,
(ex_event != EX_EVENT_CATCH))
error ("Unsupported or unknown exception event; cannot catch it");
if (handle_gnu_v3_exceptions (tempflag, cond_string, ex_event, from_tty))
return;
/* See if we can find a callback routine */
sal = target_enable_exception_callback (ex_event, 1);

View file

@ -184,6 +184,24 @@ enum target_hw_bp_type
hw_execute = 3 /* Execute HW breakpoint */
};
/* This structure is a collection of function pointers that, if available,
will be called instead of the performing the default action for this
bptype. */
struct breakpoint_ops
{
/* The normal print routine for this breakpoint, called when we
hit it. */
enum print_stop_action (*print_it) (struct breakpoint *);
/* Display information about this breakpoint, for "info breakpoints". */
void (*print_one) (struct breakpoint *, CORE_ADDR *);
/* Display information about this breakpoint after setting it (roughly
speaking; this is called from "mention"). */
void (*print_mention) (struct breakpoint *);
};
/* Note that the ->silent field is not currently used by any commands
(though the code is in there if it was to be, and set_raw_breakpoint
does set it to 0). I implemented it because I thought it would be
@ -306,6 +324,9 @@ struct breakpoint
char *exec_pathname;
asection *section;
/* Methods associated with this breakpoint. */
struct breakpoint_ops *ops;
};
/* The following stuff is an abstract data type "bpstat" ("breakpoint