Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / teshsuite / mc / dwarf-expression / dwarf-expression.cpp
index 8945638..a317517 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2022. 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 "src/mc/inspect/ObjectInformation.hpp"
 #include "src/mc/inspect/Type.hpp"
 #include "src/mc/inspect/Variable.hpp"
-#include "src/mc/remote/RemoteSimulation.hpp"
+#include "src/mc/remote/RemoteProcess.hpp"
 
 #include <array>
 #include <cassert>
 #include <cstdlib>
-#include <cstring>
-#include <random>
+#include <limits>
+#include <xbt/random.hpp>
 
-static std::default_random_engine rnd_engine;
+static uintptr_t rnd_engine()
+{
+  return simgrid::xbt::random::uniform_int(std::numeric_limits<int>::min(), std::numeric_limits<int>::max());
+}
 
 static uintptr_t eval_binary_operation(simgrid::dwarf::ExpressionContext const& state, uint8_t op, uintptr_t a,
                                        uintptr_t b)
@@ -45,24 +48,24 @@ static uintptr_t eval_binary_operation(simgrid::dwarf::ExpressionContext const&
 
 static void basic_test(simgrid::dwarf::ExpressionContext const& state)
 {
-  try {
-    std::array<Dwarf_Op, 60> ops;
+  std::array<Dwarf_Op, 60> ops;
 
-    uintptr_t a = rnd_engine();
-    uintptr_t b = rnd_engine();
+  uintptr_t a = rnd_engine();
+  uintptr_t b = rnd_engine();
 
-    simgrid::dwarf::ExpressionStack stack;
+  simgrid::dwarf::ExpressionStack stack;
 
-    bool caught_ex = false;
-    try {
-      ops[0].atom = DW_OP_drop;
-      simgrid::dwarf::execute(ops.data(), 1, state, stack);
-    } catch (const simgrid::dwarf::evaluation_error&) {
-      caught_ex = true;
-    }
-    if (not caught_ex)
-      fprintf(stderr, "Exception expected");
+  bool caught_ex = false;
+  try {
+    ops[0].atom = DW_OP_drop;
+    simgrid::dwarf::execute(ops.data(), 1, state, stack);
+  } catch (const simgrid::dwarf::evaluation_error&) {
+    caught_ex = true;
+  }
+  if (not caught_ex)
+    fprintf(stderr, "Exception expected");
 
+  try {
     ops[0].atom = DW_OP_lit21;
     simgrid::dwarf::execute(ops.data(), 1, state, stack);
     assert(stack.size() == 1);
@@ -145,8 +148,8 @@ static void test_deref(simgrid::dwarf::ExpressionContext const& state)
 
 int main()
 {
-  auto* process = new simgrid::mc::RemoteSimulation(getpid());
-  process->init();
+  auto* process = new simgrid::mc::RemoteProcess(getpid());
+  process->init(nullptr, nullptr, nullptr, nullptr);
 
   simgrid::dwarf::ExpressionContext state;
   state.address_space = (simgrid::mc::AddressSpace*) process;