* [RFA 3/5] Remove make_cleanup_regcache_xfree
2017-09-24 2:46 [RFA 0/5] remove cleanups from regcache Tom Tromey
` (3 preceding siblings ...)
2017-09-24 2:46 ` [RFA 5/5] Remove the last cleanup from regcache.c Tom Tromey
@ 2017-09-24 2:46 ` Tom Tromey
2017-09-26 0:08 ` [RFA 0/5] remove cleanups from regcache Yao Qi
5 siblings, 0 replies; 12+ messages in thread
From: Tom Tromey @ 2017-09-24 2:46 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This removes make_cleanup_regcache_xfree in favor of using
std::unique_ptr as the return type of frame_save_as_regcache.
ChangeLog
2017-09-23 Tom Tromey <tom@tromey.com>
* spu-tdep.c (spu2ppu_sniffer): Update.
* regcache.h (make_cleanup_regcache_xfree): Don't declare.
* regcache.c (do_regcache_xfree, make_cleanup_regcache_xfree):
Remove.
* ppc-linux-tdep.c (ppu2spu_sniffer): Update.
* mi/mi-main.c (mi_cmd_data_list_changed_registers): Update.
* frame.h (frame_save_as_regcache): Return std::unique_ptr.
* frame.c (frame_save_as_regcache): Return std::unique_ptr.
(frame_pop): Update.
---
gdb/ChangeLog | 12 ++++++++++++
gdb/frame.c | 19 +++++++------------
gdb/frame.h | 3 ++-
gdb/mi/mi-main.c | 17 ++++++++---------
gdb/ppc-linux-tdep.c | 9 ++++-----
gdb/regcache.c | 12 ------------
gdb/regcache.h | 2 --
gdb/spu-tdep.c | 2 +-
8 files changed, 34 insertions(+), 42 deletions(-)
diff --git a/gdb/frame.c b/gdb/frame.c
index ad0cb92..a74deef 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1017,16 +1017,14 @@ do_frame_register_read (void *src, int regnum, gdb_byte *buf)
return REG_VALID;
}
-struct regcache *
+std::unique_ptr<struct regcache>
frame_save_as_regcache (struct frame_info *this_frame)
{
struct address_space *aspace = get_frame_address_space (this_frame);
- struct regcache *regcache = new regcache (get_frame_arch (this_frame),
- aspace);
- struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache);
+ std::unique_ptr<struct regcache> regcache
+ (new struct regcache (get_frame_arch (this_frame), aspace));
- regcache_save (regcache, do_frame_register_read, this_frame);
- discard_cleanups (cleanups);
+ regcache_save (regcache.get (), do_frame_register_read, this_frame);
return regcache;
}
@@ -1034,8 +1032,6 @@ void
frame_pop (struct frame_info *this_frame)
{
struct frame_info *prev_frame;
- struct regcache *scratch;
- struct cleanup *cleanups;
if (get_frame_type (this_frame) == DUMMY_FRAME)
{
@@ -1062,8 +1058,8 @@ frame_pop (struct frame_info *this_frame)
Save them in a scratch buffer so that there isn't a race between
trying to extract the old values from the current regcache while
at the same time writing new values into that same cache. */
- scratch = frame_save_as_regcache (prev_frame);
- cleanups = make_cleanup_regcache_xfree (scratch);
+ std::unique_ptr<struct regcache> scratch
+ = frame_save_as_regcache (prev_frame);
/* FIXME: cagney/2003-03-16: It should be possible to tell the
target's register cache that it is about to be hit with a burst
@@ -1075,8 +1071,7 @@ frame_pop (struct frame_info *this_frame)
(arguably a bug in the target code mind). */
/* Now copy those saved registers into the current regcache.
Here, regcache_cpy() calls regcache_restore(). */
- regcache_cpy (get_current_regcache (), scratch);
- do_cleanups (cleanups);
+ regcache_cpy (get_current_regcache (), scratch.get ());
/* We've made right mess of GDB's local state, just discard
everything. */
diff --git a/gdb/frame.h b/gdb/frame.h
index 3b00d36..0249857 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -679,7 +679,8 @@ extern void *frame_obstack_zalloc (unsigned long size);
((TYPE *) frame_obstack_zalloc ((NUMBER) * sizeof (TYPE)))
/* Create a regcache, and copy the frame's registers into it. */
-struct regcache *frame_save_as_regcache (struct frame_info *this_frame);
+std::unique_ptr<struct regcache> frame_save_as_regcache
+ (struct frame_info *this_frame);
extern const struct block *get_frame_block (struct frame_info *,
CORE_ADDR *addr_in_block);
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index c06ef18..5e71949 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1031,22 +1031,20 @@ mi_cmd_data_list_register_names (const char *command, char **argv, int argc)
void
mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc)
{
- static struct regcache *this_regs = NULL;
+ static std::unique_ptr<struct regcache> this_regs;
struct ui_out *uiout = current_uiout;
- struct regcache *prev_regs;
+ std::unique_ptr<struct regcache> prev_regs;
struct gdbarch *gdbarch;
int regnum, numregs, changed;
int i;
- struct cleanup *cleanup;
/* The last time we visited this function, the current frame's
register contents were saved in THIS_REGS. Move THIS_REGS over
to PREV_REGS, and refresh THIS_REGS with the now-current register
contents. */
- prev_regs = this_regs;
+ prev_regs = std::move (this_regs);
this_regs = frame_save_as_regcache (get_selected_frame (NULL));
- cleanup = make_cleanup_regcache_xfree (prev_regs);
/* Note that the test for a valid register must include checking the
gdbarch_register_name because gdbarch_num_regs may be allocated
@@ -1055,7 +1053,7 @@ mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc)
will change depending upon the particular processor being
debugged. */
- gdbarch = get_regcache_arch (this_regs);
+ gdbarch = get_regcache_arch (this_regs.get ());
numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
ui_out_emit_list list_emitter (uiout, "changed-registers");
@@ -1070,7 +1068,8 @@ mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc)
if (gdbarch_register_name (gdbarch, regnum) == NULL
|| *(gdbarch_register_name (gdbarch, regnum)) == '\0')
continue;
- changed = register_changed_p (regnum, prev_regs, this_regs);
+ changed = register_changed_p (regnum, prev_regs.get (),
+ this_regs.get ());
if (changed < 0)
error (_("-data-list-changed-registers: "
"Unable to read register contents."));
@@ -1089,7 +1088,8 @@ mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc)
&& gdbarch_register_name (gdbarch, regnum) != NULL
&& *gdbarch_register_name (gdbarch, regnum) != '\000')
{
- changed = register_changed_p (regnum, prev_regs, this_regs);
+ changed = register_changed_p (regnum, prev_regs.get (),
+ this_regs.get ());
if (changed < 0)
error (_("-data-list-changed-registers: "
"Unable to read register contents."));
@@ -1099,7 +1099,6 @@ mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc)
else
error (_("bad register number"));
}
- do_cleanups (cleanup);
}
static int
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 2faee42..5f313f8 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1363,13 +1363,12 @@ ppu2spu_sniffer (const struct frame_unwind *self,
= FRAME_OBSTACK_CALLOC (1, struct ppu2spu_cache);
struct address_space *aspace = get_frame_address_space (this_frame);
- struct regcache *regcache = new regcache (data.gdbarch, aspace);
- struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache);
- regcache_save (regcache, ppu2spu_unwind_register, &data);
- discard_cleanups (cleanups);
+ std::unique_ptr<struct regcache> regcache
+ (new struct regcache (data.gdbarch, aspace));
+ regcache_save (regcache.get (), ppu2spu_unwind_register, &data);
cache->frame_id = frame_id_build (base, func);
- cache->regcache = regcache;
+ cache->regcache = regcache.release ();
*this_prologue_cache = cache;
return 1;
}
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 54aed6c..ab6a651 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -241,18 +241,6 @@ regcache_get_ptid (const struct regcache *regcache)
return regcache->ptid ();
}
-static void
-do_regcache_xfree (void *data)
-{
- delete (struct regcache *) data;
-}
-
-struct cleanup *
-make_cleanup_regcache_xfree (struct regcache *regcache)
-{
- return make_cleanup (do_regcache_xfree, regcache);
-}
-
/* Cleanup routines for invalidating a register. */
struct register_to_invalidate
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 4a430ae..3ecdb3b 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -35,8 +35,6 @@ extern struct regcache *get_thread_arch_aspace_regcache (ptid_t,
struct gdbarch *,
struct address_space *);
-struct cleanup *make_cleanup_regcache_xfree (struct regcache *regcache);
-
/* Return REGCACHE's ptid. */
extern ptid_t regcache_get_ptid (const struct regcache *regcache);
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index f77e37f..6d7a35e 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -1267,7 +1267,7 @@ spu2ppu_sniffer (const struct frame_unwind *self,
if (fi)
{
- cache->regcache = frame_save_as_regcache (fi);
+ cache->regcache = frame_save_as_regcache (fi).release ();
*this_prologue_cache = cache;
return 1;
}
--
2.9.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [RFA 5/5] Remove the last cleanup from regcache.c
2017-09-24 2:46 [RFA 0/5] remove cleanups from regcache Tom Tromey
` (2 preceding siblings ...)
2017-09-24 2:46 ` [RFA 1/5] Remove regcache_xmalloc Tom Tromey
@ 2017-09-24 2:46 ` Tom Tromey
2017-09-24 2:46 ` [RFA 3/5] Remove make_cleanup_regcache_xfree Tom Tromey
2017-09-26 0:08 ` [RFA 0/5] remove cleanups from regcache Yao Qi
5 siblings, 0 replies; 12+ messages in thread
From: Tom Tromey @ 2017-09-24 2:46 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This removes the last cleanup from regcache.c by changing one function
to use std::string.
ChangeLog
2017-09-23 Tom Tromey <tom@tromey.com>
* regcache.c (regcache::dump): Use string_printf.
---
gdb/ChangeLog | 4 ++++
gdb/regcache.c | 11 ++++-------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 46d8cfb..0eefec6 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -1350,7 +1350,6 @@ reg_flush_command (char *command, int from_tty)
void
regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
{
- struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
struct gdbarch *gdbarch = m_descr->gdbarch;
int regnum;
int footnote_nr = 0;
@@ -1442,6 +1441,7 @@ regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
/* Type. */
{
const char *t;
+ std::string name_holder;
if (regnum < 0)
t = "Type";
@@ -1452,13 +1452,11 @@ regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
t = TYPE_NAME (register_type (arch (), regnum));
if (t == NULL)
{
- char *n;
-
if (!footnote_register_type_name_null)
footnote_register_type_name_null = ++footnote_nr;
- n = xstrprintf ("*%d", footnote_register_type_name_null);
- make_cleanup (xfree, n);
- t = n;
+ name_holder = string_printf ("*%d",
+ footnote_register_type_name_null);
+ t = name_holder.c_str ();
}
/* Chop a leading builtin_type. */
if (startswith (t, blt))
@@ -1592,7 +1590,6 @@ regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
fprintf_unfiltered (file,
"*%d: Register type's name NULL.\n",
footnote_register_type_name_null);
- do_cleanups (cleanups);
}
static void
--
2.9.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [RFA 1/5] Remove regcache_xmalloc
2017-09-24 2:46 [RFA 0/5] remove cleanups from regcache Tom Tromey
2017-09-24 2:46 ` [RFA 2/5] Remove regcache_xfree Tom Tromey
2017-09-24 2:46 ` [RFA 4/5] Remove make_cleanup_regcache_invalidate Tom Tromey
@ 2017-09-24 2:46 ` Tom Tromey
2017-09-26 4:55 ` Tom Tromey
2017-09-24 2:46 ` [RFA 5/5] Remove the last cleanup from regcache.c Tom Tromey
` (2 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2017-09-24 2:46 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This patch removes regcache_xmalloc in favor of plain "new".
ChangeLog
2017-09-23 Tom Tromey <tom@tromey.com>
* regcache.h (regcache_xmalloc): Don't declare.
(regcache_raw_set_cached_value): Update comment.
* regcache.c (regcache_xmalloc): Remove.
* ppc-linux-tdep.c (ppu2spu_sniffer): Use new.
* jit.c (jit_frame_sniffer): Use new.
* frame.c (frame_save_as_regcache): Use new.
---
gdb/ChangeLog | 9 +++++++++
gdb/frame.c | 4 ++--
gdb/jit.c | 2 +-
gdb/ppc-linux-tdep.c | 2 +-
gdb/regcache.c | 6 ------
gdb/regcache.h | 4 +---
6 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/gdb/frame.c b/gdb/frame.c
index f100da3..ad0cb92 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1021,8 +1021,8 @@ struct regcache *
frame_save_as_regcache (struct frame_info *this_frame)
{
struct address_space *aspace = get_frame_address_space (this_frame);
- struct regcache *regcache = regcache_xmalloc (get_frame_arch (this_frame),
- aspace);
+ struct regcache *regcache = new regcache (get_frame_arch (this_frame),
+ aspace);
struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache);
regcache_save (regcache, do_frame_register_read, this_frame);
diff --git a/gdb/jit.c b/gdb/jit.c
index fbfee99..6eea38f 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -1205,7 +1205,7 @@ jit_frame_sniffer (const struct frame_unwind *self,
*cache = XCNEW (struct jit_unwind_private);
priv_data = (struct jit_unwind_private *) *cache;
- priv_data->regcache = regcache_xmalloc (gdbarch, aspace);
+ priv_data->regcache = new regcache (gdbarch, aspace);
priv_data->this_frame = this_frame;
callbacks.priv_data = priv_data;
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index df664ea..4c851eb 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1363,7 +1363,7 @@ ppu2spu_sniffer (const struct frame_unwind *self,
= FRAME_OBSTACK_CALLOC (1, struct ppu2spu_cache);
struct address_space *aspace = get_frame_address_space (this_frame);
- struct regcache *regcache = regcache_xmalloc (data.gdbarch, aspace);
+ struct regcache *regcache = new regcache (data.gdbarch, aspace);
struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache);
regcache_save (regcache, ppu2spu_unwind_register, &data);
discard_cleanups (cleanups);
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 4ef9151..2a92cf0 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -241,12 +241,6 @@ regcache_get_ptid (const struct regcache *regcache)
return regcache->ptid ();
}
-struct regcache *
-regcache_xmalloc (struct gdbarch *gdbarch, struct address_space *aspace)
-{
- return new regcache (gdbarch, aspace);
-}
-
void
regcache_xfree (struct regcache *regcache)
{
diff --git a/gdb/regcache.h b/gdb/regcache.h
index eb0454a..877ed59 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -37,8 +37,6 @@ extern struct regcache *get_thread_arch_aspace_regcache (ptid_t,
void regcache_xfree (struct regcache *regcache);
struct cleanup *make_cleanup_regcache_xfree (struct regcache *regcache);
-struct regcache *regcache_xmalloc (struct gdbarch *gdbarch,
- struct address_space *aspace);
/* Return REGCACHE's ptid. */
@@ -84,7 +82,7 @@ extern LONGEST regcache_raw_get_signed (struct regcache *regcache,
/* Set a raw register's value in the regcache's buffer. Unlike
regcache_raw_write, this is not write-through. The intention is
allowing to change the buffer contents of a read-only regcache
- allocated with regcache_xmalloc. */
+ allocated with new. */
extern void regcache_raw_set_cached_value
(struct regcache *regcache, int regnum, const gdb_byte *buf);
--
2.9.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [RFA 0/5] remove cleanups from regcache
@ 2017-09-24 2:46 Tom Tromey
2017-09-24 2:46 ` [RFA 2/5] Remove regcache_xfree Tom Tromey
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: Tom Tromey @ 2017-09-24 2:46 UTC (permalink / raw)
To: gdb-patches
This series removes the remaining cleanups from regcache and related
code.
First, it removes regcache_xmalloc and regcache_xfree in favor of
using plain new and delete everywhere. These were already used under
the hood; this just removes a layer of indirection.
Second, the main patch, #3, removes a cleanup by using
std::unique_ptr.
The final two patches remove some cleanups locally in regcache.c by
using standard techniques.
Regression tested by the buildbot.
Tom
^ permalink raw reply [flat|nested] 12+ messages in thread
* [RFA 4/5] Remove make_cleanup_regcache_invalidate
2017-09-24 2:46 [RFA 0/5] remove cleanups from regcache Tom Tromey
2017-09-24 2:46 ` [RFA 2/5] Remove regcache_xfree Tom Tromey
@ 2017-09-24 2:46 ` Tom Tromey
2017-09-25 20:04 ` Yao Qi
2017-09-24 2:46 ` [RFA 1/5] Remove regcache_xmalloc Tom Tromey
` (3 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2017-09-24 2:46 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This removes make_cleanup_regcache_invalidate in favor of a simple
RAII class that handles register invalidation.
ChangeLog
2017-09-23 Tom Tromey <tom@tromey.com>
* regcache.c (class regcache_invalidator): New.
(struct register_to_invalidate): Remove.
(make_cleanup_regcache_invalidate): Remove.
(regcache::raw_write): Use regcache_invalidator.
---
gdb/ChangeLog | 7 +++++++
gdb/regcache.c | 56 ++++++++++++++++++++++++++++++--------------------------
2 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/gdb/regcache.c b/gdb/regcache.c
index ab6a651..46d8cfb 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -241,31 +241,36 @@ regcache_get_ptid (const struct regcache *regcache)
return regcache->ptid ();
}
-/* Cleanup routines for invalidating a register. */
+/* Cleanup class for invalidating a register. */
-struct register_to_invalidate
+class regcache_invalidator
{
- struct regcache *regcache;
- int regnum;
-};
+public:
-static void
-do_regcache_invalidate (void *data)
-{
- struct register_to_invalidate *reg = (struct register_to_invalidate *) data;
+ regcache_invalidator (struct regcache *regcache, int regnum)
+ : m_regcache (regcache),
+ m_regnum (regnum)
+ {
+ }
- regcache_invalidate (reg->regcache, reg->regnum);
-}
+ ~regcache_invalidator ()
+ {
+ if (m_regcache != nullptr)
+ regcache_invalidator (m_regcache, m_regnum);
+ }
-static struct cleanup *
-make_cleanup_regcache_invalidate (struct regcache *regcache, int regnum)
-{
- struct register_to_invalidate* reg = XNEW (struct register_to_invalidate);
+ DISABLE_COPY_AND_ASSIGN (regcache_invalidator);
- reg->regcache = regcache;
- reg->regnum = regnum;
- return make_cleanup_dtor (do_regcache_invalidate, (void *) reg, xfree);
-}
+ void release ()
+ {
+ m_regcache = nullptr;
+ }
+
+private:
+
+ struct regcache *m_regcache;
+ int m_regnum;
+};
/* Return REGCACHE's architecture. */
@@ -860,7 +865,6 @@ regcache_raw_write (struct regcache *regcache, int regnum,
void
regcache::raw_write (int regnum, const gdb_byte *buf)
{
- struct cleanup *old_chain;
gdb_assert (buf != NULL);
gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
@@ -881,15 +885,15 @@ regcache::raw_write (int regnum, const gdb_byte *buf)
target_prepare_to_store (this);
raw_set_cached_value (regnum, buf);
- /* Register a cleanup function for invalidating the register after it is
- written, in case of a failure. */
- old_chain = make_cleanup_regcache_invalidate (this, regnum);
+ /* Invalidate the register after it is written, in case of a
+ failure. */
+ regcache_invalidator invalidator (this, regnum);
target_store_registers (this, regnum);
- /* The target did not throw an error so we can discard invalidating the
- register and restore the cleanup chain to what it was. */
- discard_cleanups (old_chain);
+ /* The target did not throw an error so we can discard invalidating
+ the register. */
+ invalidator.release ();
}
void
--
2.9.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [RFA 2/5] Remove regcache_xfree
2017-09-24 2:46 [RFA 0/5] remove cleanups from regcache Tom Tromey
@ 2017-09-24 2:46 ` Tom Tromey
2017-09-24 2:46 ` [RFA 4/5] Remove make_cleanup_regcache_invalidate Tom Tromey
` (4 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Tom Tromey @ 2017-09-24 2:46 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This removes regcache_xfree in favor of plain "delete".
ChangeLog
2017-09-23 Tom Tromey <tom@tromey.com>
* spu-tdep.c (spu2ppu_dealloc_cache): Use delete.
* regcache.h (regcache_xfree): Don't declare.
* regcache.c (regcache_xfree): Remove.
(do_regcache_xfree): Use delete.
* ppc-linux-tdep.c (ppu2spu_dealloc_cache): Use delete.
* linux-fork.c (free_fork): Use delete.
(fork_save_infrun_state): Likewise.
* jit.c (jit_dealloc_cache): Use delete.
* infrun.c (discard_infcall_suspend_state): Use delete.
---
gdb/ChangeLog | 12 ++++++++++++
gdb/infrun.c | 2 +-
gdb/jit.c | 2 +-
gdb/linux-fork.c | 4 ++--
gdb/ppc-linux-tdep.c | 2 +-
gdb/regcache.c | 11 +----------
gdb/regcache.h | 1 -
gdb/spu-tdep.c | 2 +-
8 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 26853b1..f44ca91 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8921,7 +8921,7 @@ make_cleanup_restore_infcall_suspend_state
void
discard_infcall_suspend_state (struct infcall_suspend_state *inf_state)
{
- regcache_xfree (inf_state->registers);
+ delete inf_state->registers;
xfree (inf_state->siginfo_data);
xfree (inf_state);
}
diff --git a/gdb/jit.c b/gdb/jit.c
index 6eea38f..a8e63b3 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -1167,7 +1167,7 @@ jit_dealloc_cache (struct frame_info *this_frame, void *cache)
struct jit_unwind_private *priv_data = (struct jit_unwind_private *) cache;
gdb_assert (priv_data->regcache != NULL);
- regcache_xfree (priv_data->regcache);
+ delete priv_data->regcache;
xfree (priv_data);
}
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 22a11c6..6b9c6a8 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -126,7 +126,7 @@ free_fork (struct fork_info *fp)
if (fp)
{
if (fp->savedregs)
- regcache_xfree (fp->savedregs);
+ delete fp->savedregs;
if (fp->filepos)
xfree (fp->filepos);
xfree (fp);
@@ -292,7 +292,7 @@ fork_save_infrun_state (struct fork_info *fp, int clobber_regs)
DIR *d;
if (fp->savedregs)
- regcache_xfree (fp->savedregs);
+ delete fp->savedregs;
fp->savedregs = regcache_dup (get_current_regcache ());
fp->clobber_regs = clobber_regs;
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 4c851eb..2faee42 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1382,7 +1382,7 @@ static void
ppu2spu_dealloc_cache (struct frame_info *self, void *this_cache)
{
struct ppu2spu_cache *cache = (struct ppu2spu_cache *) this_cache;
- regcache_xfree (cache->regcache);
+ delete cache->regcache;
}
static const struct frame_unwind ppu2spu_unwind = {
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 2a92cf0..54aed6c 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -241,19 +241,10 @@ regcache_get_ptid (const struct regcache *regcache)
return regcache->ptid ();
}
-void
-regcache_xfree (struct regcache *regcache)
-{
- if (regcache == NULL)
- return;
-
- delete regcache;
-}
-
static void
do_regcache_xfree (void *data)
{
- regcache_xfree ((struct regcache *) data);
+ delete (struct regcache *) data;
}
struct cleanup *
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 877ed59..4a430ae 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -35,7 +35,6 @@ extern struct regcache *get_thread_arch_aspace_regcache (ptid_t,
struct gdbarch *,
struct address_space *);
-void regcache_xfree (struct regcache *regcache);
struct cleanup *make_cleanup_regcache_xfree (struct regcache *regcache);
/* Return REGCACHE's ptid. */
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index 4338d5c..f77e37f 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -1288,7 +1288,7 @@ static void
spu2ppu_dealloc_cache (struct frame_info *self, void *this_cache)
{
struct spu2ppu_cache *cache = (struct spu2ppu_cache *) this_cache;
- regcache_xfree (cache->regcache);
+ delete cache->regcache;
}
static const struct frame_unwind spu2ppu_unwind = {
--
2.9.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA 4/5] Remove make_cleanup_regcache_invalidate
2017-09-24 2:46 ` [RFA 4/5] Remove make_cleanup_regcache_invalidate Tom Tromey
@ 2017-09-25 20:04 ` Yao Qi
2017-09-26 1:36 ` Tom Tromey
0 siblings, 1 reply; 12+ messages in thread
From: Yao Qi @ 2017-09-25 20:04 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
[I am in the travel, and fighting with jet-lag. Forgive me if I make
any stupid mistakes.]
On 17-09-23 20:46:07, Tom Tromey wrote:
>
> - regcache_invalidate (reg->regcache, reg->regnum);
> -}
> + ~regcache_invalidator ()
> + {
> + if (m_regcache != nullptr)
> + regcache_invalidator (m_regcache, m_regnum);
m_regcache->invalidate (m_regnum)?
I don't see why we need to call ctor in dtor.
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA 0/5] remove cleanups from regcache
2017-09-24 2:46 [RFA 0/5] remove cleanups from regcache Tom Tromey
` (4 preceding siblings ...)
2017-09-24 2:46 ` [RFA 3/5] Remove make_cleanup_regcache_xfree Tom Tromey
@ 2017-09-26 0:08 ` Yao Qi
5 siblings, 0 replies; 12+ messages in thread
From: Yao Qi @ 2017-09-26 0:08 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 17-09-23 20:46:03, Tom Tromey wrote:
> This series removes the remaining cleanups from regcache and related
> code.
>
> First, it removes regcache_xmalloc and regcache_xfree in favor of
> using plain new and delete everywhere. These were already used under
> the hood; this just removes a layer of indirection.
>
> Second, the main patch, #3, removes a cleanup by using
> std::unique_ptr.
>
> The final two patches remove some cleanups locally in regcache.c by
> using standard techniques.
>
> Regression tested by the buildbot.
>
> Tom
>
Hi Tom,
I gave comments to one patch, but the rest of them are good to me. I
wanted to remove cleanup from regcache for a while, but don't have a
chance. Thanks for doing this.
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA 4/5] Remove make_cleanup_regcache_invalidate
2017-09-25 20:04 ` Yao Qi
@ 2017-09-26 1:36 ` Tom Tromey
2017-09-26 1:56 ` Tom Tromey
0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2017-09-26 1:36 UTC (permalink / raw)
To: Yao Qi; +Cc: Tom Tromey, gdb-patches
>>>>> "Yao" == Yao Qi <qiyaoltc@gmail.com> writes:
>> + regcache_invalidator (m_regcache, m_regnum);
m_regcache-> invalidate (m_regnum)?
Yao> I don't see why we need to call ctor in dtor.
Ouch, yeah.
I'll fix.
Tom
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA 4/5] Remove make_cleanup_regcache_invalidate
2017-09-26 1:36 ` Tom Tromey
@ 2017-09-26 1:56 ` Tom Tromey
0 siblings, 0 replies; 12+ messages in thread
From: Tom Tromey @ 2017-09-26 1:56 UTC (permalink / raw)
To: Tom Tromey; +Cc: Yao Qi, gdb-patches
>> m_regcache->invalidate (m_regnum)?
For the record, it was supposed to call regcache_invalidate here.
Tom
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA 1/5] Remove regcache_xmalloc
2017-09-24 2:46 ` [RFA 1/5] Remove regcache_xmalloc Tom Tromey
@ 2017-09-26 4:55 ` Tom Tromey
2017-09-26 5:10 ` Sergio Durigan Junior
0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2017-09-26 4:55 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> + struct regcache *regcache = new regcache (data.gdbarch, aspace);
The builder complained about this line.
It had to be 'new struct regcache' instead.
However, this was change in a subsequent commit, so my try run didn't
catch it. I suppose I will have to start doing try runs for each
individual patch; which is kind of a pain :(
Anyway, I'm sorry about this. The only good thing is that you probably
won't hit this problem unless you bisect.
Tom
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA 1/5] Remove regcache_xmalloc
2017-09-26 4:55 ` Tom Tromey
@ 2017-09-26 5:10 ` Sergio Durigan Junior
0 siblings, 0 replies; 12+ messages in thread
From: Sergio Durigan Junior @ 2017-09-26 5:10 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Tuesday, September 26 2017, Tom Tromey wrote:
>>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
>
> Tom> + struct regcache *regcache = new regcache (data.gdbarch, aspace);
>
> The builder complained about this line.
> It had to be 'new struct regcache' instead.
>
> However, this was change in a subsequent commit, so my try run didn't
> catch it. I suppose I will have to start doing try runs for each
> individual patch; which is kind of a pain :(
Yeah, sorry about that :-(.
On a side note, I was talking to mjw the other day about setting up
"special try branches" for some people. I still don't know how that
would work internally on BuildBot, but it would address this problem of
testing several commits.
A problem I foresee with this approach is the extra load on the slaves;
some of them are already working around the clock to keep up. Anyway, I
don't want to hijack the thread, just wanted to say something related to
what happened.
> Anyway, I'm sorry about this. The only good thing is that you probably
> won't hit this problem unless you bisect.
Before I get crucified because of the "spam" generated: each breakage
e-mail is related to one specific builder. Sometimes a breakage happens
only on e.g. ARM, so you'd get e-mails just for this architecture.
Anyway, sorry about the number of messages; it's currently not possible
to merge all of the reports into one single message, although it may be
possible to thread them. Unfortunately I don't have time right now to
look into this, but we don't have a lot of breakages anyway...
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2017-09-26 5:10 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-24 2:46 [RFA 0/5] remove cleanups from regcache Tom Tromey
2017-09-24 2:46 ` [RFA 2/5] Remove regcache_xfree Tom Tromey
2017-09-24 2:46 ` [RFA 4/5] Remove make_cleanup_regcache_invalidate Tom Tromey
2017-09-25 20:04 ` Yao Qi
2017-09-26 1:36 ` Tom Tromey
2017-09-26 1:56 ` Tom Tromey
2017-09-24 2:46 ` [RFA 1/5] Remove regcache_xmalloc Tom Tromey
2017-09-26 4:55 ` Tom Tromey
2017-09-26 5:10 ` Sergio Durigan Junior
2017-09-24 2:46 ` [RFA 5/5] Remove the last cleanup from regcache.c Tom Tromey
2017-09-24 2:46 ` [RFA 3/5] Remove make_cleanup_regcache_xfree Tom Tromey
2017-09-26 0:08 ` [RFA 0/5] remove cleanups from regcache Yao Qi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).