Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Initialize expression->ops before calling mc_dwarf_expression_init.
[simgrid.git] / src / mc / mc_dwarf_expression.c
index caaf932..f143a37 100644 (file)
@@ -1,3 +1,8 @@
+/* Copyright (c) 2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <stdint.h>
 #include <stdarg.h>
@@ -92,7 +97,8 @@ int mc_dwarf_execute_expression(
         return MC_EXPRESSION_E_NO_BASE_ADDRESS;
       if(state->stack_size==MC_EXPRESSION_STACK_SIZE)
         return MC_EXPRESSION_E_STACK_OVERFLOW;
-      error = mc_dwarf_push_value(state,  (Dwarf_Off)MC_object_base_address(state->object_info) + op->number);
+      error = mc_dwarf_push_value(state,
+        (Dwarf_Off)(uintptr_t)MC_object_base_address(state->object_info) + op->number);
       break;
 
     case DW_OP_const1u:
@@ -260,7 +266,7 @@ int mc_dwarf_execute_expression(
 /** \brief Resolve a location expression
  *  \deprecated Use mc_dwarf_resolve_expression
  */
-Dwarf_Off mc_dwarf_resolve_location(mc_expression_t expression, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot) {
+uintptr_t mc_dwarf_resolve_location(mc_expression_t expression, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot) {
   s_mc_expression_state_t state;
   memset(&state, 0, sizeof(s_mc_expression_state_t));
   state.frame_base = frame_pointer_address;
@@ -273,10 +279,10 @@ Dwarf_Off mc_dwarf_resolve_location(mc_expression_t expression, mc_object_info_t
   if(state.stack_size==0)
     xbt_die("No value on the stack");
   else
-    return (Dwarf_Off) state.stack[state.stack_size-1];
+    return state.stack[state.stack_size-1];
 }
 
-Dwarf_Off mc_dwarf_resolve_locations(mc_location_list_t locations, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot) {
+uintptr_t mc_dwarf_resolve_locations(mc_location_list_t locations, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot) {
 
   unw_word_t ip;
   if(c) {
@@ -363,10 +369,10 @@ void mc_dwarf_location_list_init(mc_location_list_t list, mc_object_info_t info,
     list->size++;
     list->locations = (mc_expression_t) realloc(list->locations, list->size*sizeof(s_mc_expression_t));
     mc_expression_t expression = list->locations + i;
-
-    void* base = info->flags & MC_OBJECT_INFO_EXECUTABLE ? 0 : MC_object_base_address(info);
+    expression->ops = NULL;
     mc_dwarf_expression_init(expression, len, ops);
 
+    void* base = info->flags & MC_OBJECT_INFO_EXECUTABLE ? 0 : MC_object_base_address(info);
     // If start == 0, this is not a location list:
     expression->lowpc = start == 0 ? NULL : (char*) base + start;
     expression->highpc = start == 0 ? NULL : (char*) base + end;