X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/706dd4584b4002e0d948b81d103dd5c4b70db077..debe4e5871c0c3d1c714bbb1bd28ba7147454aa5:/src/mc/DwarfExpression.cpp diff --git a/src/mc/DwarfExpression.cpp b/src/mc/DwarfExpression.cpp index 6cdba68ae1..31852a6719 100644 --- a/src/mc/DwarfExpression.cpp +++ b/src/mc/DwarfExpression.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2014-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2014-2019. 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. */ @@ -7,24 +6,19 @@ #include #include -#include -#include - -#include "src/mc/mc_private.h" -#include "src/mc/LocationList.hpp" #include "src/mc/AddressSpace.hpp" +#include "src/mc/DwarfExpression.hpp" #include "src/mc/Frame.hpp" +#include "src/mc/LocationList.hpp" #include "src/mc/ObjectInformation.hpp" -#include "src/mc/DwarfExpression.hpp" #include "src/mc/mc_dwarf.hpp" +#include "src/mc/mc_private.hpp" using simgrid::mc::remote; namespace simgrid { namespace dwarf { -evaluation_error::~evaluation_error() noexcept(true) {} - void execute( const Dwarf_Op* ops, std::size_t n, const ExpressionContext& context, ExpressionStack& stack) @@ -32,6 +26,8 @@ void execute( for (size_t i = 0; i != n; ++i) { const Dwarf_Op *op = ops + i; std::uint8_t atom = op->atom; + intptr_t first; + intptr_t second; switch (atom) { @@ -73,7 +69,7 @@ void execute( int register_id = simgrid::dwarf::dwarf_register_to_libunwind( op->atom - DW_OP_breg0); unw_word_t res; - if (!context.cursor) + if (not context.cursor) throw evaluation_error("Missing stack context"); unw_get_reg(context.cursor, register_id, &res); stack.push(res + op->number); @@ -95,7 +91,7 @@ void execute( * Warning: the CFA returned by libunwind (UNW_X86_64_RSP, etc.) * is the SP of the *current* frame. */ - if (!context.cursor) + if (not context.cursor) throw evaluation_error("Missint cursor"); // Get frame: @@ -156,7 +152,7 @@ void execute( // Address from the base address of this ELF object. // Push the address on the stack (base_address + argument). case DW_OP_addr: { - if (!context.object_info) + if (not context.object_info) throw evaluation_error("No base address"); Dwarf_Off addr = (Dwarf_Off) (std::uintptr_t) context.object_info->base_address() + op->number; @@ -206,11 +202,15 @@ void execute( // (stack.top() += stack.before_top()). case DW_OP_plus: - stack.push(stack.pop() + stack.pop()); + first = stack.pop(); + second = stack.pop(); + stack.push(first + second); break; case DW_OP_mul: - stack.push(stack.pop() * stack.pop()); + first = stack.pop(); + second = stack.pop(); + stack.push(first * second); break; case DW_OP_plus_uconst: @@ -226,19 +226,27 @@ void execute( break; case DW_OP_minus: - stack.push(stack.pop() - stack.pop()); + first = stack.pop(); + second = stack.pop(); + stack.push(second - first); break; case DW_OP_and: - stack.push(stack.pop() & stack.pop()); + first = stack.pop(); + second = stack.pop(); + stack.push(first & second); break; case DW_OP_or: - stack.push(stack.pop() | stack.pop()); + first = stack.pop(); + second = stack.pop(); + stack.push(first | second); break; case DW_OP_xor: - stack.push(stack.pop() ^ stack.pop()); + first = stack.pop(); + second = stack.pop(); + stack.push(first ^ second); break; case DW_OP_nop: @@ -251,7 +259,7 @@ void execute( case DW_OP_deref: // Computed address: - if (!context.address_space) + if (not context.address_space) throw evaluation_error("Missing address space"); context.address_space->read_bytes( &stack.top(), sizeof(uintptr_t), remote(stack.top()),