/* Virtual tail call frames unwinder for GDB.
- Copyright (C) 2010-2015 Free Software Foundation, Inc.
+ Copyright (C) 2010-2019 Free Software Foundation, Inc.
This file is part of GDB.
#include "regcache.h"
#include "value.h"
#include "dwarf2-frame.h"
+#include "gdbarch.h"
/* Contains struct tailcall_cache indexed by next_bottom_frame. */
static htab_t cache_htab;
static hashval_t
cache_hash (const void *arg)
{
- const struct tailcall_cache *cache = arg;
+ const struct tailcall_cache *cache = (const struct tailcall_cache *) arg;
return htab_hash_pointer (cache->next_bottom_frame);
}
static int
cache_eq (const void *arg1, const void *arg2)
{
- const struct tailcall_cache *cache1 = arg1;
- const struct tailcall_cache *cache2 = arg2;
+ const struct tailcall_cache *cache1 = (const struct tailcall_cache *) arg1;
+ const struct tailcall_cache *cache2 = (const struct tailcall_cache *) arg2;
return cache1->next_bottom_frame == cache2->next_bottom_frame;
}
static struct tailcall_cache *
cache_new_ref1 (struct frame_info *next_bottom_frame)
{
- struct tailcall_cache *cache;
+ struct tailcall_cache *cache = XCNEW (struct tailcall_cache);
void **slot;
- cache = xzalloc (sizeof (*cache));
-
cache->next_bottom_frame = next_bottom_frame;
cache->refc = 1;
if (slot == NULL)
return NULL;
- cache = *slot;
+ cache = (struct tailcall_cache *) *slot;
gdb_assert (cache != NULL);
return cache;
}
return chain->length;
chain_levels = chain->callers + chain->callees;
- gdb_assert (chain_levels < chain->length);
+ gdb_assert (chain_levels <= chain->length);
return chain_levels;
}
tailcall_frame_this_id (struct frame_info *this_frame, void **this_cache,
struct frame_id *this_id)
{
- struct tailcall_cache *cache = *this_cache;
+ struct tailcall_cache *cache = (struct tailcall_cache *) *this_cache;
struct frame_info *next_frame;
/* Tail call does not make sense for a sentinel frame. */
void **tailcall_cachep, int regnum)
{
struct gdbarch *this_gdbarch = get_frame_arch (this_frame);
- struct tailcall_cache *cache = *tailcall_cachep;
+ struct tailcall_cache *cache = (struct tailcall_cache *) *tailcall_cachep;
CORE_ADDR addr;
if (regnum == gdbarch_pc_regnum (this_gdbarch))
tailcall_frame_prev_register (struct frame_info *this_frame,
void **this_cache, int regnum)
{
- struct tailcall_cache *cache = *this_cache;
+ struct tailcall_cache *cache = (struct tailcall_cache *) *this_cache;
struct value *val;
gdb_assert (this_frame != cache->next_bottom_frame);
int next_levels;
struct tailcall_cache *cache;
+ if (!dwarf2_frame_unwinders_enabled_p)
+ return 0;
+
/* Inner tail call element does not make sense for a sentinel frame. */
next_frame = get_next_frame (this_frame);
if (next_frame == NULL)
struct gdbarch *prev_gdbarch;
struct call_site_chain *chain = NULL;
struct tailcall_cache *cache;
- volatile struct gdb_exception except;
gdb_assert (*tailcall_cachep == NULL);
this_pc = get_frame_address_in_block (this_frame);
/* Catch any unwinding errors. */
- TRY_CATCH (except, RETURN_MASK_ERROR)
+ try
{
int sp_regnum;
/* call_site_find_chain can throw an exception. */
chain = call_site_find_chain (prev_gdbarch, prev_pc, this_pc);
- if (entry_cfa_sp_offsetp == NULL)
- break;
- sp_regnum = gdbarch_sp_regnum (prev_gdbarch);
- if (sp_regnum == -1)
- break;
- prev_sp = frame_unwind_register_unsigned (this_frame, sp_regnum);
- prev_sp_p = 1;
+ if (entry_cfa_sp_offsetp != NULL)
+ {
+ sp_regnum = gdbarch_sp_regnum (prev_gdbarch);
+ if (sp_regnum != -1)
+ {
+ prev_sp = frame_unwind_register_unsigned (this_frame, sp_regnum);
+ prev_sp_p = 1;
+ }
+ }
}
- if (except.reason < 0)
+ catch (const gdb_exception_error &except)
{
if (entry_values_debug)
exception_print (gdb_stdout, except);
static void
tailcall_frame_dealloc_cache (struct frame_info *self, void *this_cache)
{
- struct tailcall_cache *cache = this_cache;
+ struct tailcall_cache *cache = (struct tailcall_cache *) this_cache;
cache_unref (cache);
}
tailcall_frame_prev_arch (struct frame_info *this_frame,
void **this_prologue_cache)
{
- struct tailcall_cache *cache = *this_prologue_cache;
+ struct tailcall_cache *cache = (struct tailcall_cache *) *this_prologue_cache;
return get_frame_arch (cache->next_bottom_frame);
}
tailcall_frame_prev_arch
};
-/* Provide a prototype to silence -Wmissing-prototypes. */
-extern initialize_file_ftype _initialize_tailcall_frame;
-
void
_initialize_tailcall_frame (void)
{