From: Gabriel Corona Date: Tue, 25 Mar 2014 09:10:43 +0000 (+0100) Subject: [mc] Fix DW_OP_call_frame_cfa X-Git-Tag: v3_11~192^2^2~3 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/74ad67119d0dc499453bc53515f285e4b7c7c31c [mc] Fix DW_OP_call_frame_cfa UNW_X86_64_CFA does not work as expected --- diff --git a/src/mc/mc_dwarf_expression.c b/src/mc/mc_dwarf_expression.c index 09e4143927..92570ca9a8 100644 --- a/src/mc/mc_dwarf_expression.c +++ b/src/mc/mc_dwarf_expression.c @@ -43,27 +43,22 @@ int mc_dwarf_execute_expression( break; } - // Push the CFA (Call Frame Addresse): + // Push the CFA (Canonical Frame Addresse): case DW_OP_call_frame_cfa: { - unw_word_t res; - - int register_id = -#if defined(UNW_TARGET_X86_64) - UNW_X86_64_CFA -#elif defined(UNW_TARGET_X86) - UNW_X86_CFA -#else - -1; -#endif - ; - if(register_id<0) - xbt_die("Support for CFA not implemented for this achitecture."); + // UNW_X86_64_CFA does not return the CFA DWARF expects + // (it is a synonym for UNW_X86_64_RSP) so copy the cursor, + // unwind it once in order to find the parent SP: if(!state->cursor) return MC_EXPRESSION_E_MISSING_STACK_CONTEXT; - unw_get_reg(state->cursor, register_id, &res); + // Get frame: + unw_cursor_t cursor = *(state->cursor); + unw_step(&cursor); + + unw_word_t res; + unw_get_reg(&cursor, UNW_TDEP_SP, &res); error = mc_dwarf_push_value(state, res); break; }