aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/dwarf2/frame-tailcall.c11
-rw-r--r--gdb/dwarf2/loc.c16
-rw-r--r--gdb/dwarf2/loc.h5
4 files changed, 22 insertions, 19 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a79aabc..0999ae2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2020-02-14 Tom Tromey <tromey@adacore.com>
+
+ * dwarf2/frame-tailcall.c (dwarf2_tailcall_sniffer_first):
+ Update.
+ * dwarf2/loc.h (call_site_find_chain): Return unique_xmalloc_ptr.
+ * dwarf2/loc.c (call_site_find_chain_1): Return
+ unique_xmalloc_ptr.
+ (call_site_find_chain): Likewise.
+
2020-02-14 Richard Biener <rguenther@suse.de>
* dwarf2/read.c (lnp_state_machine::handle_special_opcode): Apply CSE
diff --git a/gdb/dwarf2/frame-tailcall.c b/gdb/dwarf2/frame-tailcall.c
index 3dc300d..2d219f1 100644
--- a/gdb/dwarf2/frame-tailcall.c
+++ b/gdb/dwarf2/frame-tailcall.c
@@ -368,7 +368,7 @@ dwarf2_tailcall_sniffer_first (struct frame_info *this_frame,
int prev_sp_p = 0;
CORE_ADDR this_pc;
struct gdbarch *prev_gdbarch;
- struct call_site_chain *chain = NULL;
+ gdb::unique_xmalloc_ptr<call_site_chain> chain;
struct tailcall_cache *cache;
gdb_assert (*tailcall_cachep == NULL);
@@ -409,16 +409,13 @@ dwarf2_tailcall_sniffer_first (struct frame_info *this_frame,
/* Ambiguous unwind or unambiguous unwind verified as matching. */
if (chain == NULL || chain->length == 0)
- {
- xfree (chain);
- return;
- }
+ return;
cache = cache_new_ref1 (this_frame);
*tailcall_cachep = cache;
- cache->chain = chain;
+ cache->chain = chain.release ();
cache->prev_pc = prev_pc;
- cache->chain_levels = pretended_chain_levels (chain);
+ cache->chain_levels = pretended_chain_levels (cache->chain);
cache->prev_sp_p = prev_sp_p;
if (cache->prev_sp_p)
{
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 7f27e45..a9523e9 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1091,11 +1091,10 @@ chain_candidate (struct gdbarch *gdbarch,
/* Create and return call_site_chain for CALLER_PC and CALLEE_PC. All the
assumed frames between them use GDBARCH. Use depth first search so we can
keep single CHAIN of call_site's back to CALLER_PC. Function recursion
- would have needless GDB stack overhead. Caller is responsible for xfree of
- the returned result. Any unreliability results in thrown
- NO_ENTRY_VALUE_ERROR. */
+ would have needless GDB stack overhead. Any unreliability results
+ in thrown NO_ENTRY_VALUE_ERROR. */
-static struct call_site_chain *
+static gdb::unique_xmalloc_ptr<call_site_chain>
call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
CORE_ADDR callee_pc)
{
@@ -1210,19 +1209,18 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
paddress (gdbarch, callee_pc));
}
- return retval.release ();
+ return retval;
}
/* Create and return call_site_chain for CALLER_PC and CALLEE_PC. All the
assumed frames between them use GDBARCH. If valid call_site_chain cannot be
- constructed return NULL. Caller is responsible for xfree of the returned
- result. */
+ constructed return NULL. */
-struct call_site_chain *
+gdb::unique_xmalloc_ptr<call_site_chain>
call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
CORE_ADDR callee_pc)
{
- struct call_site_chain *retval = NULL;
+ gdb::unique_xmalloc_ptr<call_site_chain> retval;
try
{
diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h
index 2cc7e06..8fff663 100644
--- a/gdb/dwarf2/loc.h
+++ b/gdb/dwarf2/loc.h
@@ -277,9 +277,8 @@ struct call_site_chain
};
struct call_site_stuff;
-extern struct call_site_chain *call_site_find_chain (struct gdbarch *gdbarch,
- CORE_ADDR caller_pc,
- CORE_ADDR callee_pc);
+extern gdb::unique_xmalloc_ptr<call_site_chain> call_site_find_chain
+ (struct gdbarch *gdbarch, CORE_ADDR caller_pc, CORE_ADDR callee_pc);
/* A helper function to convert a DWARF register to an arch register.
ARCH is the architecture.