mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-10-17 04:43:17 +08:00
2003-08-09 Andrew Cagney <cagney@redhat.com>
* defs.h (xstrprintf): Declare. * utils.c (xstrprintf): New function. * breakpoint.c (insert_breakpoints): Replace sprintf and non-literal format strings, with xstrprintf and cleanups. (delete_breakpoint,breakpoint_re_set): Ditto. (commands_command, insert_breakpoints): Ditto. (bpstat_stop_status, break_at_finish_at_depth_command_1): Ditto. (break_at_finish_command_1): Ditto.
This commit is contained in:
@ -1,3 +1,14 @@
|
|||||||
|
2003-08-09 Andrew Cagney <cagney@redhat.com>
|
||||||
|
|
||||||
|
* defs.h (xstrprintf): Declare.
|
||||||
|
* utils.c (xstrprintf): New function.
|
||||||
|
* breakpoint.c (insert_breakpoints): Replace sprintf and
|
||||||
|
non-literal format strings, with xstrprintf and cleanups.
|
||||||
|
(delete_breakpoint,breakpoint_re_set): Ditto.
|
||||||
|
(commands_command, insert_breakpoints): Ditto.
|
||||||
|
(bpstat_stop_status, break_at_finish_at_depth_command_1): Ditto.
|
||||||
|
(break_at_finish_command_1): Ditto.
|
||||||
|
|
||||||
2003-08-09 Andrew Cagney <cagney@redhat.com>
|
2003-08-09 Andrew Cagney <cagney@redhat.com>
|
||||||
|
|
||||||
* MAINTAINERS (language support): List Adam Fedor as Objective C
|
* MAINTAINERS (language support): List Adam Fedor as Objective C
|
||||||
|
171
gdb/breakpoint.c
171
gdb/breakpoint.c
@ -584,17 +584,17 @@ commands_command (char *arg, int from_tty)
|
|||||||
|
|
||||||
ALL_BREAKPOINTS (b)
|
ALL_BREAKPOINTS (b)
|
||||||
if (b->number == bnum)
|
if (b->number == bnum)
|
||||||
{
|
{
|
||||||
char tmpbuf[128];
|
char *tmpbuf = xstrprintf ("Type commands for when breakpoint %d is hit, one per line.",
|
||||||
sprintf (tmpbuf,
|
bnum);
|
||||||
"Type commands for when breakpoint %d is hit, one per line.",
|
struct cleanup *cleanups = make_cleanup (xfree, tmpbuf);
|
||||||
bnum);
|
l = read_command_lines (tmpbuf, from_tty);
|
||||||
l = read_command_lines (tmpbuf, from_tty);
|
do_cleanups (cleanups);
|
||||||
free_command_lines (&b->commands);
|
free_command_lines (&b->commands);
|
||||||
b->commands = l;
|
b->commands = l;
|
||||||
breakpoints_changed ();
|
breakpoints_changed ();
|
||||||
breakpoint_modify_event (b->number);
|
breakpoint_modify_event (b->number);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
error ("No breakpoint number %d.", bnum);
|
error ("No breakpoint number %d.", bnum);
|
||||||
}
|
}
|
||||||
@ -749,9 +749,6 @@ insert_breakpoints (void)
|
|||||||
int process_warning = 0;
|
int process_warning = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char message1[] = "Error inserting catchpoint %d:\n";
|
|
||||||
static char message[sizeof (message1) + 30];
|
|
||||||
|
|
||||||
struct ui_file *tmp_error_stream = mem_fileopen ();
|
struct ui_file *tmp_error_stream = mem_fileopen ();
|
||||||
make_cleanup_ui_file_delete (tmp_error_stream);
|
make_cleanup_ui_file_delete (tmp_error_stream);
|
||||||
|
|
||||||
@ -912,9 +909,6 @@ insert_breakpoints (void)
|
|||||||
/* If we get here, we must have a callback mechanism for exception
|
/* If we get here, we must have a callback mechanism for exception
|
||||||
events -- with g++ style embedded label support, we insert
|
events -- with g++ style embedded label support, we insert
|
||||||
ordinary breakpoints and not catchpoints. */
|
ordinary breakpoints and not catchpoints. */
|
||||||
/* Format possible error message */
|
|
||||||
sprintf (message, message1, b->number);
|
|
||||||
|
|
||||||
val = target_insert_breakpoint (b->address, b->shadow_contents);
|
val = target_insert_breakpoint (b->address, b->shadow_contents);
|
||||||
if (val)
|
if (val)
|
||||||
{
|
{
|
||||||
@ -932,14 +926,18 @@ insert_breakpoints (void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Bp set, now make sure callbacks are enabled */
|
/* Bp set, now make sure callbacks are enabled */
|
||||||
|
/* Format possible error msg */
|
||||||
|
char *message = xstrprintf ("Error inserting catchpoint %d:\n",
|
||||||
|
b->number);
|
||||||
|
struct cleanup *cleanups = make_cleanup (xfree, message);
|
||||||
int val;
|
int val;
|
||||||
args_for_catchpoint_enable args;
|
args_for_catchpoint_enable args;
|
||||||
args.kind = b->type == bp_catch_catch ?
|
args.kind = b->type == bp_catch_catch ?
|
||||||
EX_EVENT_CATCH : EX_EVENT_THROW;
|
EX_EVENT_CATCH : EX_EVENT_THROW;
|
||||||
args.enable_p = 1;
|
args.enable_p = 1;
|
||||||
val = catch_errors (cover_target_enable_exception_callback,
|
val = catch_errors (cover_target_enable_exception_callback,
|
||||||
&args,
|
&args, message, RETURN_MASK_ALL);
|
||||||
message, RETURN_MASK_ALL);
|
do_cleanups (cleanups);
|
||||||
if (val != 0 && val != -1)
|
if (val != 0 && val != -1)
|
||||||
{
|
{
|
||||||
b->inserted = 1;
|
b->inserted = 1;
|
||||||
@ -1083,11 +1081,12 @@ insert_breakpoints (void)
|
|||||||
&& !b->inserted
|
&& !b->inserted
|
||||||
&& !b->duplicate)
|
&& !b->duplicate)
|
||||||
{
|
{
|
||||||
char prefix[64];
|
char *prefix = xstrprintf ("warning: inserting catchpoint %d: ",
|
||||||
|
b->number);
|
||||||
sprintf (prefix, "warning: inserting catchpoint %d: ", b->number);
|
struct cleanup *cleanups = make_cleanup (xfree, prefix);
|
||||||
val = catch_exceptions (uiout, insert_catchpoint, b, prefix,
|
val = catch_exceptions (uiout, insert_catchpoint, b, prefix,
|
||||||
RETURN_MASK_ERROR);
|
RETURN_MASK_ERROR);
|
||||||
|
do_cleanups (cleanups);
|
||||||
if (val < 0)
|
if (val < 0)
|
||||||
b->enable_state = bp_disabled;
|
b->enable_state = bp_disabled;
|
||||||
else
|
else
|
||||||
@ -2508,9 +2507,6 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_sw_breakpoint)
|
|||||||
struct bpstats root_bs[1];
|
struct bpstats root_bs[1];
|
||||||
/* Pointer to the last thing in the chain currently. */
|
/* Pointer to the last thing in the chain currently. */
|
||||||
bpstat bs = root_bs;
|
bpstat bs = root_bs;
|
||||||
static char message1[] =
|
|
||||||
"Error evaluating expression for watchpoint %d\n";
|
|
||||||
char message[sizeof (message1) + 30 /* slop */ ];
|
|
||||||
|
|
||||||
/* Get the address where the breakpoint would have been. The
|
/* Get the address where the breakpoint would have been. The
|
||||||
"not_a_sw_breakpoint" argument is meant to distinguish between a
|
"not_a_sw_breakpoint" argument is meant to distinguish between a
|
||||||
@ -2609,12 +2605,16 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_sw_breakpoint)
|
|||||||
bs->stop = 1;
|
bs->stop = 1;
|
||||||
bs->print = 1;
|
bs->print = 1;
|
||||||
|
|
||||||
sprintf (message, message1, b->number);
|
|
||||||
if (b->type == bp_watchpoint ||
|
if (b->type == bp_watchpoint ||
|
||||||
b->type == bp_hardware_watchpoint)
|
b->type == bp_hardware_watchpoint)
|
||||||
{
|
{
|
||||||
switch (catch_errors (watchpoint_check, bs, message,
|
char *message = xstrprintf ("Error evaluating expression for watchpoint %d\n",
|
||||||
RETURN_MASK_ALL))
|
b->number);
|
||||||
|
struct cleanup *cleanups = make_cleanup (xfree, message);
|
||||||
|
int e = catch_errors (watchpoint_check, bs, message,
|
||||||
|
RETURN_MASK_ALL);
|
||||||
|
do_cleanups (cleanups);
|
||||||
|
switch (e)
|
||||||
{
|
{
|
||||||
case WP_DELETED:
|
case WP_DELETED:
|
||||||
/* We've already printed what needs to be printed. */
|
/* We've already printed what needs to be printed. */
|
||||||
@ -2682,42 +2682,49 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_sw_breakpoint)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
switch (catch_errors (watchpoint_check, bs, message,
|
{
|
||||||
RETURN_MASK_ALL))
|
char *message = xstrprintf ("Error evaluating expression for watchpoint %d\n",
|
||||||
{
|
b->number);
|
||||||
case WP_DELETED:
|
struct cleanup *cleanups = make_cleanup (xfree, message);
|
||||||
/* We've already printed what needs to be printed. */
|
int e = catch_errors (watchpoint_check, bs, message,
|
||||||
bs->print_it = print_it_done;
|
RETURN_MASK_ALL);
|
||||||
/* Stop. */
|
do_cleanups (cleanups);
|
||||||
break;
|
switch (e)
|
||||||
case WP_VALUE_CHANGED:
|
{
|
||||||
if (b->type == bp_read_watchpoint)
|
case WP_DELETED:
|
||||||
{
|
/* We've already printed what needs to be printed. */
|
||||||
/* Don't stop: read watchpoints shouldn't fire if
|
bs->print_it = print_it_done;
|
||||||
the value has changed. This is for targets which
|
/* Stop. */
|
||||||
cannot set read-only watchpoints. */
|
break;
|
||||||
bs->print_it = print_it_noop;
|
case WP_VALUE_CHANGED:
|
||||||
bs->stop = 0;
|
if (b->type == bp_read_watchpoint)
|
||||||
continue;
|
{
|
||||||
}
|
/* Don't stop: read watchpoints shouldn't fire if
|
||||||
++(b->hit_count);
|
the value has changed. This is for targets
|
||||||
break;
|
which cannot set read-only watchpoints. */
|
||||||
case WP_VALUE_NOT_CHANGED:
|
bs->print_it = print_it_noop;
|
||||||
/* Stop. */
|
bs->stop = 0;
|
||||||
++(b->hit_count);
|
continue;
|
||||||
break;
|
}
|
||||||
default:
|
++(b->hit_count);
|
||||||
/* Can't happen. */
|
break;
|
||||||
case 0:
|
case WP_VALUE_NOT_CHANGED:
|
||||||
/* Error from catch_errors. */
|
/* Stop. */
|
||||||
printf_filtered ("Watchpoint %d deleted.\n", b->number);
|
++(b->hit_count);
|
||||||
if (b->related_breakpoint)
|
break;
|
||||||
b->related_breakpoint->disposition = disp_del_at_next_stop;
|
default:
|
||||||
b->disposition = disp_del_at_next_stop;
|
/* Can't happen. */
|
||||||
/* We've already printed what needs to be printed. */
|
case 0:
|
||||||
bs->print_it = print_it_done;
|
/* Error from catch_errors. */
|
||||||
break;
|
printf_filtered ("Watchpoint %d deleted.\n", b->number);
|
||||||
}
|
if (b->related_breakpoint)
|
||||||
|
b->related_breakpoint->disposition = disp_del_at_next_stop;
|
||||||
|
b->disposition = disp_del_at_next_stop;
|
||||||
|
/* We've already printed what needs to be printed. */
|
||||||
|
bs->print_it = print_it_done;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
else /* found == 0 */
|
else /* found == 0 */
|
||||||
{
|
{
|
||||||
/* This is a case where some watchpoint(s) triggered,
|
/* This is a case where some watchpoint(s) triggered,
|
||||||
@ -4985,7 +4992,6 @@ break_at_finish_at_depth_command_1 (char *arg, int flag, int from_tty)
|
|||||||
CORE_ADDR low, high, selected_pc = 0;
|
CORE_ADDR low, high, selected_pc = 0;
|
||||||
char *extra_args = NULL;
|
char *extra_args = NULL;
|
||||||
char *level_arg;
|
char *level_arg;
|
||||||
char *addr_string;
|
|
||||||
int extra_args_len = 0, if_arg = 0;
|
int extra_args_len = 0, if_arg = 0;
|
||||||
|
|
||||||
if (!arg ||
|
if (!arg ||
|
||||||
@ -5039,11 +5045,11 @@ break_at_finish_at_depth_command_1 (char *arg, int flag, int from_tty)
|
|||||||
{
|
{
|
||||||
if (find_pc_partial_function (selected_pc, (char **) NULL, &low, &high))
|
if (find_pc_partial_function (selected_pc, (char **) NULL, &low, &high))
|
||||||
{
|
{
|
||||||
addr_string = (char *) xmalloc (26 + extra_args_len);
|
char *addr_string;
|
||||||
if (extra_args_len)
|
if (extra_args_len)
|
||||||
sprintf (addr_string, "*0x%s %s", paddr_nz (high), extra_args);
|
addr_string = xstrprintf ("*0x%s %s", paddr_nz (high), extra_args);
|
||||||
else
|
else
|
||||||
sprintf (addr_string, "*0x%s", paddr_nz (high));
|
addr_string = xstrprintf ("*0x%s", paddr_nz (high));
|
||||||
break_command_1 (addr_string, flag, from_tty);
|
break_command_1 (addr_string, flag, from_tty);
|
||||||
xfree (addr_string);
|
xfree (addr_string);
|
||||||
}
|
}
|
||||||
@ -5074,9 +5080,8 @@ break_at_finish_command_1 (char *arg, int flag, int from_tty)
|
|||||||
{
|
{
|
||||||
if (deprecated_selected_frame)
|
if (deprecated_selected_frame)
|
||||||
{
|
{
|
||||||
addr_string = (char *) xmalloc (15);
|
addr_string = xstrprintf ("*0x%s",
|
||||||
sprintf (addr_string, "*0x%s",
|
paddr_nz (get_frame_pc (deprecated_selected_frame)));
|
||||||
paddr_nz (get_frame_pc (deprecated_selected_frame)));
|
|
||||||
if (arg)
|
if (arg)
|
||||||
if_arg = 1;
|
if_arg = 1;
|
||||||
}
|
}
|
||||||
@ -5122,11 +5127,12 @@ break_at_finish_command_1 (char *arg, int flag, int from_tty)
|
|||||||
sal = sals.sals[i];
|
sal = sals.sals[i];
|
||||||
if (find_pc_partial_function (sal.pc, (char **) NULL, &low, &high))
|
if (find_pc_partial_function (sal.pc, (char **) NULL, &low, &high))
|
||||||
{
|
{
|
||||||
break_string = (char *) xmalloc (extra_args_len + 26);
|
break_string;
|
||||||
if (extra_args_len)
|
if (extra_args_len)
|
||||||
sprintf (break_string, "*0x%s %s", paddr_nz (high), extra_args);
|
break_string = xstrprintf ("*0x%s %s", paddr_nz (high),
|
||||||
|
extra_args);
|
||||||
else
|
else
|
||||||
sprintf (break_string, "*0x%s", paddr_nz (high));
|
break_string = xstrprintf ("*0x%s", paddr_nz (high));
|
||||||
break_command_1 (break_string, flag, from_tty);
|
break_command_1 (break_string, flag, from_tty);
|
||||||
xfree (break_string);
|
xfree (break_string);
|
||||||
}
|
}
|
||||||
@ -6537,17 +6543,17 @@ delete_breakpoint (struct breakpoint *bpt)
|
|||||||
exceptions are supported in this way, it's OK for now. FIXME */
|
exceptions are supported in this way, it's OK for now. FIXME */
|
||||||
if (ep_is_exception_catchpoint (bpt) && target_has_execution)
|
if (ep_is_exception_catchpoint (bpt) && target_has_execution)
|
||||||
{
|
{
|
||||||
static char message1[] = "Error in deleting catchpoint %d:\n";
|
|
||||||
static char message[sizeof (message1) + 30];
|
|
||||||
args_for_catchpoint_enable args;
|
|
||||||
|
|
||||||
/* Format possible error msg */
|
/* Format possible error msg */
|
||||||
sprintf (message, message1, bpt->number);
|
char *message = xstrprintf ("Error in deleting catchpoint %d:\n",
|
||||||
|
bpt->number);
|
||||||
|
struct cleanup *cleanups = make_cleanup (xfree, message);
|
||||||
|
args_for_catchpoint_enable args;
|
||||||
args.kind = bpt->type == bp_catch_catch ?
|
args.kind = bpt->type == bp_catch_catch ?
|
||||||
EX_EVENT_CATCH : EX_EVENT_THROW;
|
EX_EVENT_CATCH : EX_EVENT_THROW;
|
||||||
args.enable_p = 0;
|
args.enable_p = 0;
|
||||||
catch_errors (cover_target_enable_exception_callback, &args,
|
catch_errors (cover_target_enable_exception_callback, &args,
|
||||||
message, RETURN_MASK_ALL);
|
message, RETURN_MASK_ALL);
|
||||||
|
do_cleanups (cleanups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -6937,16 +6943,17 @@ breakpoint_re_set (void)
|
|||||||
struct breakpoint *b, *temp;
|
struct breakpoint *b, *temp;
|
||||||
enum language save_language;
|
enum language save_language;
|
||||||
int save_input_radix;
|
int save_input_radix;
|
||||||
static char message1[] = "Error in re-setting breakpoint %d:\n";
|
|
||||||
char message[sizeof (message1) + 30 /* slop */ ];
|
|
||||||
|
|
||||||
save_language = current_language->la_language;
|
save_language = current_language->la_language;
|
||||||
save_input_radix = input_radix;
|
save_input_radix = input_radix;
|
||||||
ALL_BREAKPOINTS_SAFE (b, temp)
|
ALL_BREAKPOINTS_SAFE (b, temp)
|
||||||
{
|
{
|
||||||
/* Format possible error msg */
|
/* Format possible error msg */
|
||||||
sprintf (message, message1, b->number);
|
char *message = xstrprintf ("Error in re-setting breakpoint %d:\n",
|
||||||
|
b->number);
|
||||||
|
struct cleanup *cleanups = make_cleanup (xfree, message);
|
||||||
catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL);
|
catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL);
|
||||||
|
do_cleanups (cleanups);
|
||||||
}
|
}
|
||||||
set_language (save_language);
|
set_language (save_language);
|
||||||
input_radix = save_input_radix;
|
input_radix = save_input_radix;
|
||||||
|
@ -855,6 +855,9 @@ extern void xfree (void *);
|
|||||||
extern void xasprintf (char **ret, const char *format, ...) ATTR_FORMAT (printf, 2, 3);
|
extern void xasprintf (char **ret, const char *format, ...) ATTR_FORMAT (printf, 2, 3);
|
||||||
extern void xvasprintf (char **ret, const char *format, va_list ap);
|
extern void xvasprintf (char **ret, const char *format, va_list ap);
|
||||||
|
|
||||||
|
/* Like asprintf, but return the string, throw an error if no memory. */
|
||||||
|
extern char *xstrprintf (const char *format, ...) ATTR_FORMAT (printf, 1, 2);
|
||||||
|
|
||||||
extern int parse_escape (char **);
|
extern int parse_escape (char **);
|
||||||
|
|
||||||
/* Message to be printed before the error message, when an error occurs. */
|
/* Message to be printed before the error message, when an error occurs. */
|
||||||
|
11
gdb/utils.c
11
gdb/utils.c
@ -1178,6 +1178,17 @@ xfree (void *ptr)
|
|||||||
/* Like asprintf/vasprintf but get an internal_error if the call
|
/* Like asprintf/vasprintf but get an internal_error if the call
|
||||||
fails. */
|
fails. */
|
||||||
|
|
||||||
|
char *
|
||||||
|
xstrprintf (const char *format, ...)
|
||||||
|
{
|
||||||
|
char *ret;
|
||||||
|
va_list args;
|
||||||
|
va_start (args, format);
|
||||||
|
xvasprintf (&ret, format, args);
|
||||||
|
va_end (args);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xasprintf (char **ret, const char *format, ...)
|
xasprintf (char **ret, const char *format, ...)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user