3
* gdb-io-break.c - Breakpoint management functions for GDB wrapper library.
5
* See the file "gdb-io.h" for license information.
12
#include "gdb-io-priv.h"
16
static GdbListFunc gdbio_break_list_func = NULL;
18
static GSList *breakpoint_list = NULL;
22
free_breakpoint_list()
25
for (p = breakpoint_list; p; p = p->next)
27
GdbBreakPointInfo *bpi = p->data;
34
g_free(bpi->fullname);
46
g_slist_free(breakpoint_list);
47
breakpoint_list = NULL;
52
#define populate(rec, hash, key) \
53
rec->key=gdblx_lookup_string(hash, #key""); \
54
if (rec->key) {rec->key=g_strdup(rec->key);}
59
breakpoint_cb(gpointer data, gpointer user_data)
61
GdbLxValue *v = (GdbLxValue *) data;
62
if (v && (v->type == vt_HASH) && (v->hash))
64
GHashTable *bkpt = v->hash;
67
GdbBreakPointInfo *bpi = g_new0(GdbBreakPointInfo, 1);
68
populate(bpi, bkpt, addr);
69
populate(bpi, bkpt, disp);
70
populate(bpi, bkpt, enabled);
71
populate(bpi, bkpt, file);
72
populate(bpi, bkpt, fullname);
73
populate(bpi, bkpt, func);
74
populate(bpi, bkpt, line);
75
populate(bpi, bkpt, number);
76
populate(bpi, bkpt, times);
77
populate(bpi, bkpt, type);
78
populate(bpi, bkpt, what);
79
populate(bpi, bkpt, cond);
80
populate(bpi, bkpt, ignore);
81
breakpoint_list = g_slist_append(breakpoint_list, bpi);
88
parse_break_list(gint seq, gchar ** list, gchar * resp)
90
GHashTable *h = gdbio_get_results(resp, list);
91
HTAB(h, BreakpointTable);
93
if (BreakpointTable && gdbio_break_list_func)
95
HLST(BreakpointTable, body);
98
free_breakpoint_list();
99
g_slist_foreach(body, breakpoint_cb, NULL);
100
gdbio_break_list_func(breakpoint_list);
101
free_breakpoint_list();
105
gdbio_break_list_func(NULL);
109
g_hash_table_destroy(h);
115
gdbio_show_breaks(GdbListFunc func)
117
gdbio_break_list_func = func;
120
gdbio_send_seq_cmd(parse_break_list, "-break-list\n");
127
added_break(gint seq, gchar ** list, gchar * resp)
129
GHashTable *h = gdbio_get_results(resp, list);
142
gdbio_info_func(_("Added breakpoint #%s in %s() at %s:%s\n"), number,
147
gdbio_info_func(_("Added breakpoint #%s at %s:%s\n"), number, file,
159
gdbio_info_func(_("Added write watchpoint #%s for %s\n"), number, exp);
167
HSTR(hw_awpt, number);
168
gdbio_info_func(_("Added read/write watchpoint #%s for %s\n"),
177
HSTR(hw_rwpt, number);
179
(_("Added read watchpoint #%s for %s\n"),
185
g_hash_table_destroy(h);
187
if (gdbio_break_list_func)
189
gdbio_show_breaks(gdbio_break_list_func);
193
/* opt is "-r" (read) or "-a" (r/w) or NULL or empty (write) */
195
gdbio_add_watch(GdbListFunc func, const gchar * option, const gchar * varname)
197
gdbio_break_list_func = func;
198
gdbio_send_seq_cmd(added_break, "-break-watch %s %s\n", option ? option : "", varname);
204
gdbio_add_break(GdbListFunc func, const gchar * filename, const gchar * locn)
206
gdbio_break_list_func = func;
207
if (filename && *filename)
209
gdbio_send_seq_cmd(added_break, "-break-insert %s:%s\n", filename, locn);
213
gdbio_send_seq_cmd(added_break, "-break-insert %s\n", locn);
219
deleted_break(gint seq, gchar ** list, gchar * resp)
221
GHashTable *h = gdbio_get_results(resp, list);
225
g_hash_table_destroy(h);
226
gdbio_info_func(_("Watch/breakpoint deleted.\n"));
228
if (gdbio_break_list_func)
230
gdbio_show_breaks(gdbio_break_list_func);
237
toggled_break(gint seq, gchar ** list, gchar * resp)
240
if (strncmp(resp, "^error", 6) == 0)
244
GHashTable *h = gdblx_parse_results(resp + 7);
250
g_strconcat(_("Failed to toggle breakpoint -\n"), msg, NULL);
251
gdbio_error_func(tmp);
262
g_hash_table_destroy(h);
268
gdbio_info_func(_("Watch/breakpoint toggled.\n"));
275
edited_break(gint seq, gchar ** list, gchar * resp)
277
GHashTable *h = gdbio_get_results(resp, list);
281
g_hash_table_destroy(h);
282
gdbio_info_func(_("Watch/breakpoint modified.\n"));
288
gdbio_delete_break(GdbListFunc func, const gchar * number)
290
gdbio_break_list_func = func;
291
gdbio_send_seq_cmd(deleted_break, "-break-delete %s\n", number);
296
gdbio_enable_break(const gchar * number, gboolean enabled)
298
gdbio_send_seq_cmd(toggled_break, "-break-%s %s\n", enabled ? "enable" : "disable", number);
303
gdbio_ignore_break(const gchar * number, const gchar * times)
305
gdbio_send_seq_cmd(edited_break, "-break-after %s %s\n", number, times);
310
gdbio_break_cond(const gchar * number, const gchar * expr)
312
gdbio_send_seq_cmd(edited_break, "-break-condition %s %s\n", number, expr);