Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Add basic test for lexical-block scoped variable
[simgrid.git] / testsuite / mc / dwarf.c
index c935a12..059062d 100644 (file)
@@ -1,3 +1,9 @@
+/* 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. */
+
 #ifdef NDEBUG
 #undef NDEBUG
 #endif
@@ -57,6 +63,13 @@ static dw_variable_t find_local_variable(dw_frame_t frame, const char* argument_
       return variable;
   }
 
+  dw_frame_t scope = NULL;
+  xbt_dynar_foreach(frame->scopes, cursor, scope) {
+    variable = find_local_variable(scope, argument_name);
+    if(variable)
+      return variable;
+  }
+
   return NULL;
 }
 
@@ -135,6 +148,11 @@ int main(int argc, char** argv) {
 
   test_local_variable(mc_binary_info, "main", "argc", &argc, &cursor);
 
+  {
+    int lexical_block_variable = 50;
+    test_local_variable(mc_binary_info, "main", "lexical_block_variable", &lexical_block_variable, &cursor);
+  }
+
   s_foo my_foo;
   test_type_by_name(my_foo);