Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix compile_warnings
[simgrid.git] / testsuite / mc / dwarf_expression.c
index 1ff04d5..98ee29a 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "../src/mc/mc_private.h"
 
 
 #include "../src/mc/mc_private.h"
 
+static
 uintptr_t eval_binary_operation(mc_expression_state_t state, int op, uintptr_t a, uintptr_t b) {
   state->stack_size = 0;
 
 uintptr_t eval_binary_operation(mc_expression_state_t state, int op, uintptr_t a, uintptr_t b) {
   state->stack_size = 0;
 
@@ -23,6 +24,7 @@ uintptr_t eval_binary_operation(mc_expression_state_t state, int op, uintptr_t a
   return state->stack[state->stack_size - 1];
 }
 
   return state->stack[state->stack_size - 1];
 }
 
+static
 void basic_test(mc_expression_state_t state) {
   Dwarf_Op ops[60];
 
 void basic_test(mc_expression_state_t state) {
   Dwarf_Op ops[60];
 
@@ -88,6 +90,21 @@ void basic_test(mc_expression_state_t state) {
   assert(state->stack[state->stack_size-2]== b);
 }
 
   assert(state->stack[state->stack_size-2]== b);
 }
 
+static
+void test_deref(mc_expression_state_t state) {
+  uintptr_t foo = 42;
+
+  Dwarf_Op ops[60];
+  ops[0].atom = DW_OP_addr;
+  ops[0].number = (Dwarf_Word) &foo;
+  ops[1].atom = DW_OP_deref;
+  state->stack_size = 0;
+
+  assert(mc_dwarf_execute_expression(2, ops, state) == MC_EXPRESSION_OK);
+  assert(state->stack_size==1);
+  assert(state->stack[state->stack_size-1] == foo);
+}
+
 int main(int argc, char** argv) {
   s_mc_expression_state_t state;
   memset(&state, 0, sizeof(s_mc_expression_state_t));
 int main(int argc, char** argv) {
   s_mc_expression_state_t state;
   memset(&state, 0, sizeof(s_mc_expression_state_t));
@@ -118,5 +135,7 @@ int main(int argc, char** argv) {
     assert(eval_binary_operation(&state, DW_OP_xor, a, b) == (a ^ b));
   }
 
     assert(eval_binary_operation(&state, DW_OP_xor, a, b) == (a ^ b));
   }
 
+  test_deref(&state);
+
   return 0;
 }
   return 0;
 }