aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/breakpoint.c33
-rw-r--r--gdb/breakpoint.h6
-rw-r--r--gdb/guile/scm-breakpoint.c2
-rw-r--r--gdb/python/py-breakpoint.c2
4 files changed, 18 insertions, 25 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8016dd3..477c03b 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1844,7 +1844,9 @@ update_watchpoint (struct watchpoint *b, int reparse)
const char *s;
b->exp.reset ();
- s = b->exp_string_reparse ? b->exp_string_reparse : b->exp_string;
+ s = (b->exp_string_reparse
+ ? b->exp_string_reparse.get ()
+ : b->exp_string.get ());
b->exp = parse_exp_1 (&s, 0, b->exp_valid_block, 0);
/* If the meaning of expression itself changed, the old value is
no longer relevant. We don't want to report a watchpoint hit
@@ -6131,7 +6133,7 @@ print_one_breakpoint_location (struct breakpoint *b,
if (opts.addressprint)
uiout->field_skip ("addr");
annotate_field (5);
- uiout->field_string ("what", w->exp_string);
+ uiout->field_string ("what", w->exp_string.get ());
}
else if (!is_catchpoint (b) || is_exception_catchpoint (b)
|| is_ada_exception_catchpoint (b))
@@ -6358,7 +6360,7 @@ print_one_breakpoint_location (struct breakpoint *b,
{
struct watchpoint *w = (struct watchpoint *) b;
- uiout->field_string ("original-location", w->exp_string);
+ uiout->field_string ("original-location", w->exp_string.get ());
}
else if (b->location != NULL
&& event_location_to_string (b->location.get ()) != NULL)
@@ -10053,14 +10055,6 @@ watchpoint_exp_is_const (const struct expression *exp)
return exp->op->constant_p ();
}
-/* Watchpoint destructor. */
-
-watchpoint::~watchpoint ()
-{
- xfree (this->exp_string);
- xfree (this->exp_string_reparse);
-}
-
/* Implement the "re_set" breakpoint_ops method for watchpoints. */
static void
@@ -10295,7 +10289,7 @@ print_mention_watchpoint (struct breakpoint *b)
ui_out_emit_tuple tuple_emitter (uiout, tuple_name);
uiout->field_signed ("number", b->number);
uiout->text (": ");
- uiout->field_string ("exp", w->exp_string);
+ uiout->field_string ("exp", w->exp_string.get ());
}
/* Implement the "print_recreate" breakpoint_ops method for
@@ -10323,7 +10317,7 @@ print_recreate_watchpoint (struct breakpoint *b, struct ui_file *fp)
_("Invalid watchpoint type."));
}
- fprintf_unfiltered (fp, " %s", w->exp_string);
+ fprintf_unfiltered (fp, " %s", w->exp_string.get ());
print_recreate_thread (b, fp);
}
@@ -10488,7 +10482,7 @@ print_mention_masked_watchpoint (struct breakpoint *b)
ui_out_emit_tuple tuple_emitter (uiout, tuple_name);
uiout->field_signed ("number", b->number);
uiout->text (": ");
- uiout->field_string ("exp", w->exp_string);
+ uiout->field_string ("exp", w->exp_string.get ());
}
/* Implement the "print_recreate" breakpoint_ops method for
@@ -10515,7 +10509,7 @@ print_recreate_masked_watchpoint (struct breakpoint *b, struct ui_file *fp)
_("Invalid hardware watchpoint type."));
}
- fprintf_unfiltered (fp, " %s mask 0x%s", w->exp_string,
+ fprintf_unfiltered (fp, " %s mask 0x%s", w->exp_string.get (),
phex (w->hw_wp_mask, sizeof (CORE_ADDR)));
print_recreate_thread (b, fp);
}
@@ -10794,13 +10788,14 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
CORE_ADDR addr = value_as_address (val.get ());
w->exp_string_reparse
- = current_language->watch_location_expression (t, addr).release ();
+ = current_language->watch_location_expression (t, addr);
- w->exp_string = xstrprintf ("-location %.*s",
- (int) (exp_end - exp_start), exp_start);
+ w->exp_string.reset (xstrprintf ("-location %.*s",
+ (int) (exp_end - exp_start),
+ exp_start));
}
else
- w->exp_string = savestring (exp_start, exp_end - exp_start);
+ w->exp_string.reset (savestring (exp_start, exp_end - exp_start));
if (use_mask)
{
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 2b15622..ad64f83 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -831,13 +831,11 @@ struct breakpoint
struct watchpoint : public breakpoint
{
- ~watchpoint () override;
-
/* String form of exp to use for displaying to the user (malloc'd),
or NULL if none. */
- char *exp_string;
+ gdb::unique_xmalloc_ptr<char> exp_string;
/* String form to use for reparsing of EXP (malloc'd) or NULL. */
- char *exp_string_reparse;
+ gdb::unique_xmalloc_ptr<char> exp_string_reparse;
/* The expression we are watching, or NULL if not a watchpoint. */
expression_up exp;
diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c
index 67484e4..f48671f 100644
--- a/gdb/guile/scm-breakpoint.c
+++ b/gdb/guile/scm-breakpoint.c
@@ -883,7 +883,7 @@ gdbscm_breakpoint_expression (SCM self)
wp = (struct watchpoint *) bp_smob->bp;
- const char *str = wp->exp_string;
+ const char *str = wp->exp_string.get ();
if (! str)
str = "";
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index edff032..7ec73af 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -433,7 +433,7 @@ bppy_get_expression (PyObject *self, void *closure)
wp = (struct watchpoint *) obj->bp;
- str = wp->exp_string;
+ str = wp->exp_string.get ();
if (! str)
str = "";