This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Simplify MI breakpoint setting
- From: Vladimir Prus <vladimir at codesourcery dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 1 Aug 2009 11:13:32 +0400
- Subject: Simplify MI breakpoint setting
I've noticed that mi_cmd_break_insert does some fairly
contrived logic which amounts to passing either 0 or 1
as the value of 'hardware' parameter to set_breakpoint.
Further, set_breakpoint appears to be trivial and useless
wrapper over break_command_really. This patch cleans that
up. Are breakpoint.{c,h} changes OK?
- Volodya
commit 17e617aa040e44f97d89afe6b93d11e9a78beab7
Author: Vladimir Prus <vladimir@codesourcery.com>
Date: Sat Aug 1 11:09:08 2009 +0400
Simplify MI breakpoint setting.
* breakpoint.c (break_command_really): Make nonstatic.
(set_breakpoint): Remove.
* breakpoint.h: Adjust to above changes.
* mi/mi-cmd-break.c (mi_cmd_break_insert): Simplify.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 4b9b44e..4bfbb57 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5848,7 +5848,7 @@ find_condition_and_thread (char *tok, CORE_ADDR pc,
and thread specified by the COND_STRING and THREAD
parameters. */
-static void
+void
break_command_really (struct gdbarch *gdbarch,
char *arg, char *cond_string, int thread,
int parse_condition_and_thread,
@@ -6056,22 +6056,6 @@ break_command_1 (char *arg, int flag, int from_tty)
}
-void
-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 (gdbarch,
- address, condition, thread,
- 0 /* condition and thread are valid. */,
- tempflag, hardwareflag, 0 /* traceflag */,
- ignore_count,
- pending
- ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE,
- NULL, 0, enabled);
-}
/* Adjust SAL to the first instruction past the function prologue.
The end of the prologue is determined using the line table from
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 54e2ea0..65e21a5 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -733,12 +733,14 @@ extern void awatch_command_wrapper (char *, int);
extern void rwatch_command_wrapper (char *, int);
extern void tbreak_command (char *, int);
-extern void set_breakpoint (struct gdbarch *gdbarch,
- char *address, char *condition,
- int hardwareflag, int tempflag,
- int thread, int ignore_count,
- int pending,
- int enabled);
+extern void 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,
+ enum auto_boolean pending_break_support,
+ struct breakpoint_ops *ops,
+ int from_tty,
+ int enabled);
extern void insert_breakpoints (void);
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index 9ab8f2d..54d7fe7 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -67,18 +67,20 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
{
char *address = NULL;
enum bp_type type = REG_BP;
+ int hardware = 0;
int temp_p = 0;
int thread = -1;
int ignore_count = 0;
char *condition = NULL;
int pending = 0;
int enabled = 1;
+ struct cleanup *back_to;
struct gdb_exception e;
struct gdb_events *old_hooks;
enum opt
{
- HARDWARE_OPT, TEMP_OPT /*, REGEXP_OPT */ , CONDITION_OPT,
+ HARDWARE_OPT, TEMP_OPT, CONDITION_OPT,
IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT, DISABLE_OPT
};
static struct mi_opt opts[] =
@@ -108,13 +110,8 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
temp_p = 1;
break;
case HARDWARE_OPT:
- type = HW_BP;
+ hardware = 1;
break;
-#if 0
- case REGEXP_OPT:
- type = REGEXP_BP;
- break;
-#endif
case CONDITION_OPT:
condition = optarg;
break;
@@ -147,40 +144,16 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
mi_breakpoint_observers_installed = 1;
}
+ back_to = make_cleanup_restore_integer (&mi_can_breakpoint_notify);
mi_can_breakpoint_notify = 1;
- /* Make sure we restore hooks even if exception is thrown. */
- TRY_CATCH (e, RETURN_MASK_ALL)
- {
- switch (type)
- {
- case REG_BP:
- set_breakpoint (get_current_arch (), address, condition,
- 0 /*hardwareflag */ , temp_p,
- thread, ignore_count,
- pending, enabled);
- break;
- case HW_BP:
- set_breakpoint (get_current_arch (), address, condition,
- 1 /*hardwareflag */ , temp_p,
- thread, ignore_count,
- pending, enabled);
- break;
-#if 0
- case REGEXP_BP:
- if (temp_p)
- error (_("mi_cmd_break_insert: Unsupported tempoary regexp breakpoint"));
- else
- rbreak_command_wrapper (address, FROM_TTY);
- break;
-#endif
- default:
- internal_error (__FILE__, __LINE__,
- _("mi_cmd_break_insert: Bad switch."));
- }
- }
- mi_can_breakpoint_notify = 0;
- if (e.reason < 0)
- throw_exception (e);
+ break_command_really (get_current_arch (), address, condition, thread,
+ 0 /* condition and thread are valid. */,
+ temp_p, hardware, 0 /* traceflag */,
+ ignore_count,
+ pending ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE,
+ NULL, 0, enabled);
+ do_cleanups (back_to);
+
}
enum wp_type