From 57d96d2cf3a593395ef6657f07c06b57dcdac400 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 7 Feb 2014 15:44:15 +0100 Subject: [PATCH] [mc] Fix sefault where a variable has no name This happen when optimisation is enabled. As the current code needs a name for the variable, we generate a fake one. We might want to remove this assumption. --- src/mc/mc_dwarf.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mc/mc_dwarf.c b/src/mc/mc_dwarf.c index 84e42607ce..5839708020 100644 --- a/src/mc/mc_dwarf.c +++ b/src/mc/mc_dwarf.c @@ -795,6 +795,8 @@ static dw_location_t MC_dwarf_get_expression(Dwarf_Op* expr, size_t len) { return loc; } +static int mc_anonymous_variable_index = 0; + static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame) { // Drop declaration: if (MC_dwarf_attr_flag(die, DW_AT_declaration, false)) @@ -848,6 +850,12 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, D klass, klass, (void*) variable->dwarf_offset, variable->name); } + // The current code needs a variable name, + // generate a fake one: + if(!variable->name) { + variable->name = bprintf("@anonymous#%i", mc_anonymous_variable_index++); + } + return variable; } -- 2.20.1