|
|
|
|
@@ -31,49 +31,16 @@
|
|
|
|
|
#include "cli/cli-cmds.h"
|
|
|
|
|
#include "inferior.h"
|
|
|
|
|
|
|
|
|
|
struct frame_unwind_table_entry
|
|
|
|
|
/* If an unwinder should be prepended to the list, this is the
|
|
|
|
|
index in which it should be inserted. */
|
|
|
|
|
static int osabi_start = -1;
|
|
|
|
|
|
|
|
|
|
/* Start the table out with a few default sniffers. OSABI code
|
|
|
|
|
can't override this. */
|
|
|
|
|
static void
|
|
|
|
|
initialize_frame_unwind_table (std::vector<const frame_unwind*>& table)
|
|
|
|
|
{
|
|
|
|
|
const struct frame_unwind *unwinder;
|
|
|
|
|
struct frame_unwind_table_entry *next;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct frame_unwind_table
|
|
|
|
|
{
|
|
|
|
|
struct frame_unwind_table_entry *list = nullptr;
|
|
|
|
|
/* The head of the OSABI part of the search list. */
|
|
|
|
|
struct frame_unwind_table_entry **osabi_head = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const registry<gdbarch>::key<struct frame_unwind_table>
|
|
|
|
|
frame_unwind_data;
|
|
|
|
|
|
|
|
|
|
/* A helper function to add an unwinder to a list. LINK says where to
|
|
|
|
|
install the new unwinder. The new link is returned. */
|
|
|
|
|
|
|
|
|
|
static struct frame_unwind_table_entry **
|
|
|
|
|
add_unwinder (struct obstack *obstack, const struct frame_unwind *unwinder,
|
|
|
|
|
struct frame_unwind_table_entry **link)
|
|
|
|
|
{
|
|
|
|
|
*link = OBSTACK_ZALLOC (obstack, struct frame_unwind_table_entry);
|
|
|
|
|
(*link)->unwinder = unwinder;
|
|
|
|
|
return &(*link)->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct frame_unwind_table *
|
|
|
|
|
get_frame_unwind_table (struct gdbarch *gdbarch)
|
|
|
|
|
{
|
|
|
|
|
struct frame_unwind_table *table = frame_unwind_data.get (gdbarch);
|
|
|
|
|
if (table != nullptr)
|
|
|
|
|
return table;
|
|
|
|
|
|
|
|
|
|
table = new frame_unwind_table;
|
|
|
|
|
|
|
|
|
|
/* Start the table out with a few default sniffers. OSABI code
|
|
|
|
|
can't override this. */
|
|
|
|
|
struct frame_unwind_table_entry **link = &table->list;
|
|
|
|
|
|
|
|
|
|
struct obstack *obstack = gdbarch_obstack (gdbarch);
|
|
|
|
|
link = add_unwinder (obstack, &dummy_frame_unwind, link);
|
|
|
|
|
table.push_back (&dummy_frame_unwind);
|
|
|
|
|
/* The DWARF tailcall sniffer must come before the inline sniffer.
|
|
|
|
|
Otherwise, we can end up in a situation where a DWARF frame finds
|
|
|
|
|
tailcall information, but then the inline sniffer claims a frame
|
|
|
|
|
@@ -81,12 +48,22 @@ get_frame_unwind_table (struct gdbarch *gdbarch)
|
|
|
|
|
safe to do always because the tailcall sniffer can only ever be
|
|
|
|
|
activated if the newer frame was created using the DWARF
|
|
|
|
|
unwinder, and it also found tailcall information. */
|
|
|
|
|
link = add_unwinder (obstack, &dwarf2_tailcall_frame_unwind, link);
|
|
|
|
|
link = add_unwinder (obstack, &inline_frame_unwind, link);
|
|
|
|
|
table.push_back (&dwarf2_tailcall_frame_unwind);
|
|
|
|
|
table.push_back (&inline_frame_unwind);
|
|
|
|
|
|
|
|
|
|
/* The insertion point for OSABI sniffers. */
|
|
|
|
|
table->osabi_head = link;
|
|
|
|
|
frame_unwind_data.set (gdbarch, table);
|
|
|
|
|
osabi_start = table.size ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function call retrieves the list of frame unwinders available in
|
|
|
|
|
GDBARCH. If this list is empty, it is initialized before being
|
|
|
|
|
returned. */
|
|
|
|
|
static std::vector<const frame_unwind*>&
|
|
|
|
|
get_frame_unwind_table (struct gdbarch *gdbarch)
|
|
|
|
|
{
|
|
|
|
|
std::vector<const frame_unwind*>& table = gdbarch_get_unwinder_list (gdbarch);
|
|
|
|
|
if (table.size () == 0)
|
|
|
|
|
initialize_frame_unwind_table (table);
|
|
|
|
|
|
|
|
|
|
return table;
|
|
|
|
|
}
|
|
|
|
|
@@ -95,27 +72,25 @@ void
|
|
|
|
|
frame_unwind_prepend_unwinder (struct gdbarch *gdbarch,
|
|
|
|
|
const struct frame_unwind *unwinder)
|
|
|
|
|
{
|
|
|
|
|
struct frame_unwind_table *table = get_frame_unwind_table (gdbarch);
|
|
|
|
|
struct frame_unwind_table_entry *entry;
|
|
|
|
|
std::vector<const frame_unwind*>& table = get_frame_unwind_table (gdbarch);
|
|
|
|
|
|
|
|
|
|
/* Insert the new entry at the start of the list. */
|
|
|
|
|
entry = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_unwind_table_entry);
|
|
|
|
|
entry->unwinder = unwinder;
|
|
|
|
|
entry->next = (*table->osabi_head);
|
|
|
|
|
(*table->osabi_head) = entry;
|
|
|
|
|
gdb_assert (osabi_start >= 0);
|
|
|
|
|
|
|
|
|
|
table.push_back (unwinder);
|
|
|
|
|
|
|
|
|
|
/* Bubble the new entry up to where new unwinders are allowed to be
|
|
|
|
|
inserterd. */
|
|
|
|
|
for (int i = table.size() - 1; i > osabi_start; i--)
|
|
|
|
|
std::swap(table[i], table[i-1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
frame_unwind_append_unwinder (struct gdbarch *gdbarch,
|
|
|
|
|
const struct frame_unwind *unwinder)
|
|
|
|
|
{
|
|
|
|
|
struct frame_unwind_table *table = get_frame_unwind_table (gdbarch);
|
|
|
|
|
struct frame_unwind_table_entry **ip;
|
|
|
|
|
std::vector<const frame_unwind*>& table = get_frame_unwind_table (gdbarch);
|
|
|
|
|
|
|
|
|
|
/* Find the end of the list and insert the new entry there. */
|
|
|
|
|
for (ip = table->osabi_head; (*ip) != NULL; ip = &(*ip)->next);
|
|
|
|
|
(*ip) = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_unwind_table_entry);
|
|
|
|
|
(*ip)->unwinder = unwinder;
|
|
|
|
|
table.push_back (unwinder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Call SNIFFER from UNWINDER. If it succeeded set UNWINDER for
|
|
|
|
|
@@ -188,9 +163,6 @@ frame_unwind_find_by_frame (frame_info_ptr this_frame, void **this_cache)
|
|
|
|
|
FRAME_SCOPED_DEBUG_ENTER_EXIT;
|
|
|
|
|
frame_debug_printf ("this_frame=%d", frame_relative_level (this_frame));
|
|
|
|
|
|
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (this_frame);
|
|
|
|
|
struct frame_unwind_table *table = get_frame_unwind_table (gdbarch);
|
|
|
|
|
struct frame_unwind_table_entry *entry;
|
|
|
|
|
const struct frame_unwind *unwinder_from_target;
|
|
|
|
|
|
|
|
|
|
unwinder_from_target = target_get_unwinder ();
|
|
|
|
|
@@ -205,8 +177,10 @@ frame_unwind_find_by_frame (frame_info_ptr this_frame, void **this_cache)
|
|
|
|
|
unwinder_from_target))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (entry = table->list; entry != NULL; entry = entry->next)
|
|
|
|
|
if (frame_unwind_try_unwinder (this_frame, this_cache, entry->unwinder))
|
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (this_frame);
|
|
|
|
|
std::vector<const frame_unwind*> table = get_frame_unwind_table (gdbarch);
|
|
|
|
|
for (auto unwinder: table)
|
|
|
|
|
if (frame_unwind_try_unwinder (this_frame, this_cache, unwinder))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
internal_error (_("frame_unwind_find_by_frame failed"));
|
|
|
|
|
@@ -347,7 +321,7 @@ static void
|
|
|
|
|
maintenance_info_frame_unwinders (const char *args, int from_tty)
|
|
|
|
|
{
|
|
|
|
|
gdbarch *gdbarch = current_inferior ()->arch ();
|
|
|
|
|
struct frame_unwind_table *table = get_frame_unwind_table (gdbarch);
|
|
|
|
|
std::vector<const frame_unwind*> table = get_frame_unwind_table (gdbarch);
|
|
|
|
|
|
|
|
|
|
ui_out *uiout = current_uiout;
|
|
|
|
|
ui_out_emit_table table_emitter (uiout, 2, -1, "FrameUnwinders");
|
|
|
|
|
@@ -355,11 +329,10 @@ maintenance_info_frame_unwinders (const char *args, int from_tty)
|
|
|
|
|
uiout->table_header (25, ui_left, "type", "Type");
|
|
|
|
|
uiout->table_body ();
|
|
|
|
|
|
|
|
|
|
for (struct frame_unwind_table_entry *entry = table->list; entry != NULL;
|
|
|
|
|
entry = entry->next)
|
|
|
|
|
for (const struct frame_unwind* unwinder: table)
|
|
|
|
|
{
|
|
|
|
|
const char *name = entry->unwinder->name;
|
|
|
|
|
const char *type = frame_type_str (entry->unwinder->type);
|
|
|
|
|
const char *name = unwinder->name;
|
|
|
|
|
const char *type = frame_type_str (unwinder->type);
|
|
|
|
|
|
|
|
|
|
ui_out_emit_list tuple_emitter (uiout, nullptr);
|
|
|
|
|
uiout->field_string ("name", name);
|
|
|
|
|
|