X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2dab73b61a6ad4feb7d2d267bf5621c7b95926b3..5a006fa396cfcc8a91a8284f0d625b2a9a2565c9:/teshsuite/mc/dwarf-expression/dwarf-expression.cpp diff --git a/teshsuite/mc/dwarf-expression/dwarf-expression.cpp b/teshsuite/mc/dwarf-expression/dwarf-expression.cpp index 32f8ecff38..3853ce5f78 100644 --- a/teshsuite/mc/dwarf-expression/dwarf-expression.cpp +++ b/teshsuite/mc/dwarf-expression/dwarf-expression.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2014-2023. 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. */ @@ -12,20 +12,23 @@ #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 #include #include -#include -#include +#include +#include -static std::default_random_engine rnd_engine; - -static simgrid::mc::RemoteSimulation* process; +static uintptr_t rnd_engine() +{ + return simgrid::xbt::random::uniform_int(std::numeric_limits::min(), std::numeric_limits::max()); +} -static uintptr_t eval_binary_operation(simgrid::dwarf::ExpressionContext const& state, int op, uintptr_t a, uintptr_t b) +static uintptr_t eval_binary_operation(simgrid::dwarf::ExpressionContext const& state, uint8_t op, uintptr_t a, + uintptr_t b) { - Dwarf_Op ops[15]; + std::array ops; ops[0].atom = DW_OP_const8u; ops[0].number = a; ops[1].atom = DW_OP_const8u; @@ -34,7 +37,7 @@ static uintptr_t eval_binary_operation(simgrid::dwarf::ExpressionContext const& simgrid::dwarf::ExpressionStack stack; try { - simgrid::dwarf::execute(ops, 3, state, stack); + simgrid::dwarf::execute(ops.data(), 3, state, stack); } catch (const simgrid::dwarf::evaluation_error&) { fprintf(stderr,"Expression evaluation error"); } @@ -45,45 +48,45 @@ static uintptr_t eval_binary_operation(simgrid::dwarf::ExpressionContext const& static void basic_test(simgrid::dwarf::ExpressionContext const& state) { - try { - Dwarf_Op ops[60]; + std::array 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, 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, 1, state, stack); + simgrid::dwarf::execute(ops.data(), 1, state, stack); assert(stack.size() == 1); assert(stack.top() == 21); ops[0].atom = DW_OP_const8u; ops[0].number = a; - simgrid::dwarf::execute(ops, 1, state, stack); + simgrid::dwarf::execute(ops.data(), 1, state, stack); assert(stack.size() == 2); assert(stack.top() == a); ops[0].atom = DW_OP_drop; ops[1].atom = DW_OP_drop; - simgrid::dwarf::execute(ops, 2, state, stack); + simgrid::dwarf::execute(ops.data(), 2, state, stack); assert(stack.empty()); stack.clear(); ops[0].atom = DW_OP_lit21; ops[1].atom = DW_OP_plus_uconst; ops[1].number = a; - simgrid::dwarf::execute(ops, 2, state, stack); + simgrid::dwarf::execute(ops.data(), 2, state, stack); assert(stack.size() == 1); assert(stack.top() == a + 21); @@ -92,7 +95,7 @@ static void basic_test(simgrid::dwarf::ExpressionContext const& state) ops[0].number = a; ops[1].atom = DW_OP_dup; ops[2].atom = DW_OP_plus; - simgrid::dwarf::execute(ops, 3, state, stack); + simgrid::dwarf::execute(ops.data(), 3, state, stack); assert(stack.size() == 1); assert(stack.top() == a + a); @@ -102,7 +105,7 @@ static void basic_test(simgrid::dwarf::ExpressionContext const& state) ops[1].atom = DW_OP_const8u; ops[1].number = b; ops[2].atom = DW_OP_over; - simgrid::dwarf::execute(ops, 3, state, stack); + simgrid::dwarf::execute(ops.data(), 3, state, stack); assert(stack.size() == 3); assert(stack.top() == a); assert(stack.top(1) == b); @@ -114,7 +117,7 @@ static void basic_test(simgrid::dwarf::ExpressionContext const& state) ops[1].atom = DW_OP_const8u; ops[1].number = b; ops[2].atom = DW_OP_swap; - simgrid::dwarf::execute(ops, 3, state, stack); + simgrid::dwarf::execute(ops.data(), 3, state, stack); assert(stack.size() == 2); assert(stack.top() == a); assert(stack.top(1) == b); @@ -128,14 +131,14 @@ static void test_deref(simgrid::dwarf::ExpressionContext const& state) try { uintptr_t foo = 42; - Dwarf_Op ops[60]; + std::array ops; ops[0].atom = DW_OP_const8u; ops[0].number = (uintptr_t)&foo; ops[1].atom = DW_OP_deref; simgrid::dwarf::ExpressionStack stack; - simgrid::dwarf::execute(ops, 2, state, stack); + simgrid::dwarf::execute(ops.data(), 2, state, stack); assert(stack.size() == 1); assert(stack.top() == foo); } catch (const simgrid::dwarf::evaluation_error&) { @@ -145,8 +148,8 @@ static void test_deref(simgrid::dwarf::ExpressionContext const& state) int main() { - process = new simgrid::mc::RemoteSimulation(getpid()); - process->init(); + auto* process = new simgrid::mc::RemoteProcess(getpid()); + process->init(nullptr, nullptr); simgrid::dwarf::ExpressionContext state; state.address_space = (simgrid::mc::AddressSpace*) process;