Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Implement DW_OP_call_frame_cfa using libunwind
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 7 Mar 2014 11:49:47 +0000 (12:49 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 7 Mar 2014 11:52:46 +0000 (12:52 +0100)
This is used by DWARF4 for DW_AT_frame_base.

We need to implement this in order to use the new DWARf expression
code for DW_AT_frame_base resolution (used in DWARF4
libpthread_nonshared.a).

src/mc/mc_dwarf_expression.c

index 54f0d22..54183b4 100644 (file)
@@ -43,6 +43,31 @@ int mc_dwarf_execute_expression(
         break;
       }
 
+    // Push the CFA (Call 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.");
+
+      if(!state->cursor)
+        return MC_EXPRESSION_E_MISSING_STACK_CONTEXT;
+
+      unw_get_reg(state->cursor, register_id, &res);
+      error = mc_dwarf_push_value(state, res + op->number);
+      break;
+    }
+
     // Frame base:
 
     case DW_OP_fbreg: