aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-02-21 16:53:56 -0700
committerTom Tromey <tom@tromey.com>2018-02-24 10:01:11 -0700
commit281d762b1a56317171e462666b98d50bfa31a08a (patch)
tree67e6831f0f8964dcd8ff2ae2bc123ad641b0ae87 /gdb
parentd4333bab0a097f4bfa36d2e49f4dfb12c73dce24 (diff)
downloadgdb-281d762b1a56317171e462666b98d50bfa31a08a.zip
gdb-281d762b1a56317171e462666b98d50bfa31a08a.tar.gz
gdb-281d762b1a56317171e462666b98d50bfa31a08a.tar.bz2
Remove cleanups from check_fast_tracepoint_sals
This changes the gdbarch fast_tracepoint_valid_at method to use a std::string as its out parameter, and then updates all the uses. This allows removing a cleanup from breakpoint.c. Regression tested by the buildbot. ChangeLog 2018-02-24 Tom Tromey <tom@tromey.com> * i386-tdep.c (i386_fast_tracepoint_valid_at): "msg" now a std::string. * gdbarch.sh (fast_tracepoint_valid_at): Change "msg" to a std::string*. * gdbarch.c: Rebuild. * gdbarch.h: Rebuild. * breakpoint.c (check_fast_tracepoint_sals): Use std::string. * arch-utils.h (default_fast_tracepoint_valid_at): Update. * arch-utils.c (default_fast_tracepoint_valid_at): "msg" now a std::string*.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/arch-utils.c4
-rw-r--r--gdb/arch-utils.h2
-rw-r--r--gdb/breakpoint.c14
-rw-r--r--gdb/gdbarch.c2
-rw-r--r--gdb/gdbarch.h4
-rwxr-xr-xgdb/gdbarch.sh2
-rw-r--r--gdb/i386-tdep.c10
8 files changed, 28 insertions, 23 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5297dcb..df920f8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,16 @@
+2018-02-24 Tom Tromey <tom@tromey.com>
+
+ * i386-tdep.c (i386_fast_tracepoint_valid_at): "msg" now a
+ std::string.
+ * gdbarch.sh (fast_tracepoint_valid_at): Change "msg" to a
+ std::string*.
+ * gdbarch.c: Rebuild.
+ * gdbarch.h: Rebuild.
+ * breakpoint.c (check_fast_tracepoint_sals): Use std::string.
+ * arch-utils.h (default_fast_tracepoint_valid_at): Update.
+ * arch-utils.c (default_fast_tracepoint_valid_at): "msg" now a
+ std::string*.
+
2018-02-23 Simon Marchi <simon.marchi@polymtl.ca>
* gdbtypes.h (sect_offset): Change type to uint64_t.
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 693d7e3..2ff0f4d 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -813,12 +813,12 @@ default_has_shared_address_space (struct gdbarch *gdbarch)
int
default_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr,
- char **msg)
+ std::string *msg)
{
/* We don't know if maybe the target has some way to do fast
tracepoints that doesn't need gdbarch, so always say yes. */
if (msg)
- *msg = NULL;
+ msg->clear ();
return 1;
}
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index b51a4ec..3407a16 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -202,7 +202,7 @@ extern struct gdbarch *get_current_arch (void);
extern int default_has_shared_address_space (struct gdbarch *);
extern int default_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
- CORE_ADDR addr, char **msg);
+ CORE_ADDR addr, std::string *msg);
extern const gdb_byte *default_breakpoint_from_pc (struct gdbarch *gdbarch,
CORE_ADDR *pcptr,
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 91ecca6..c56084c 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9177,10 +9177,6 @@ static void
check_fast_tracepoint_sals (struct gdbarch *gdbarch,
gdb::array_view<const symtab_and_line> sals)
{
- int rslt;
- char *msg;
- struct cleanup *old_chain;
-
for (const auto &sal : sals)
{
struct gdbarch *sarch;
@@ -9190,14 +9186,10 @@ check_fast_tracepoint_sals (struct gdbarch *gdbarch,
associated with SAL. */
if (sarch == NULL)
sarch = gdbarch;
- rslt = gdbarch_fast_tracepoint_valid_at (sarch, sal.pc, &msg);
- old_chain = make_cleanup (xfree, msg);
-
- if (!rslt)
+ std::string msg;
+ if (!gdbarch_fast_tracepoint_valid_at (sarch, sal.pc, &msg))
error (_("May not have a fast tracepoint at %s%s"),
- paddress (sarch, sal.pc), (msg ? msg : ""));
-
- do_cleanups (old_chain);
+ paddress (sarch, sal.pc), msg.c_str ());
}
}
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 62cb9a5..b8703e5 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -4650,7 +4650,7 @@ set_gdbarch_has_shared_address_space (struct gdbarch *gdbarch,
}
int
-gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, char **msg)
+gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, std::string *msg)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->fast_tracepoint_valid_at != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 30c2bf3..5cb131d 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -1366,8 +1366,8 @@ extern void set_gdbarch_has_shared_address_space (struct gdbarch *gdbarch, gdbar
/* True if a fast tracepoint can be set at an address. */
-typedef int (gdbarch_fast_tracepoint_valid_at_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr, char **msg);
-extern int gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, char **msg);
+typedef int (gdbarch_fast_tracepoint_valid_at_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr, std::string *msg);
+extern int gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, std::string *msg);
extern void set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at);
/* Guess register state based on tracepoint location. Used for tracepoints
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 10a2aa9..33dfa6b 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -1045,7 +1045,7 @@ v;int;has_global_breakpoints;;;0;0;;0
m;int;has_shared_address_space;void;;;default_has_shared_address_space;;0
# True if a fast tracepoint can be set at an address.
-m;int;fast_tracepoint_valid_at;CORE_ADDR addr, char **msg;addr, msg;;default_fast_tracepoint_valid_at;;0
+m;int;fast_tracepoint_valid_at;CORE_ADDR addr, std::string *msg;addr, msg;;default_fast_tracepoint_valid_at;;0
# Guess register state based on tracepoint location. Used for tracepoints
# where no registers have been collected, but there's only one location,
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 6b59278..60dc801 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -8111,7 +8111,7 @@ static const int i386_record_regmap[] =
static int
i386_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr,
- char **msg)
+ std::string *msg)
{
int len, jumplen;
@@ -8144,15 +8144,15 @@ i386_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr,
/* Return a bit of target-specific detail to add to the caller's
generic failure message. */
if (msg)
- *msg = xstrprintf (_("; instruction is only %d bytes long, "
- "need at least %d bytes for the jump"),
- len, jumplen);
+ *msg = string_printf (_("; instruction is only %d bytes long, "
+ "need at least %d bytes for the jump"),
+ len, jumplen);
return 0;
}
else
{
if (msg)
- *msg = NULL;
+ msg->clear ();
return 1;
}
}