#include "src/mc/inspect/Variable.hpp"
#include "src/mc/remote/RemoteSimulation.hpp"
+#include <array>
#include <cassert>
#include <cstdlib>
#include <cstring>
static std::default_random_engine rnd_engine;
-static simgrid::mc::RemoteSimulation* process;
-
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<Dwarf_Op, 15> ops;
ops[0].atom = DW_OP_const8u;
ops[0].number = a;
ops[1].atom = DW_OP_const8u;
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");
}
static void basic_test(simgrid::dwarf::ExpressionContext const& state)
{
try {
- Dwarf_Op ops[60];
+ std::array<Dwarf_Op, 60> ops;
uintptr_t a = rnd_engine();
uintptr_t b = rnd_engine();
bool caught_ex = false;
try {
ops[0].atom = DW_OP_drop;
- simgrid::dwarf::execute(ops, 1, state, stack);
+ simgrid::dwarf::execute(ops.data(), 1, state, stack);
} catch (const simgrid::dwarf::evaluation_error&) {
caught_ex = true;
}
fprintf(stderr, "Exception expected");
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);
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);
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);
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);
try {
uintptr_t foo = 42;
- Dwarf_Op ops[60];
+ std::array<Dwarf_Op, 60> 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&) {
int main()
{
- process = new simgrid::mc::RemoteSimulation(getpid());
+ auto* process = new simgrid::mc::RemoteSimulation(getpid());
process->init();
simgrid::dwarf::ExpressionContext state;