X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/421864cfa538f76e5c01cd41e8cca8d105b350b1..341cb255f174254622d3ab6c52dd6d3256b46465:/src/mc/DwarfExpression.cpp diff --git a/src/mc/DwarfExpression.cpp b/src/mc/DwarfExpression.cpp index 472a2a5cf3..fe55a37adf 100644 --- a/src/mc/DwarfExpression.cpp +++ b/src/mc/DwarfExpression.cpp @@ -4,20 +4,19 @@ /* 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 #include -#include #include #include -#include "mc_object_info.h" -#include "mc_private.h" +#include "src/mc/mc_private.h" #include "src/mc/LocationList.hpp" #include "src/mc/AddressSpace.hpp" #include "src/mc/Frame.hpp" #include "src/mc/ObjectInformation.hpp" #include "src/mc/DwarfExpression.hpp" -#include "mc_dwarf.hpp" +#include "src/mc/mc_dwarf.hpp" using simgrid::mc::remote; @@ -70,17 +69,18 @@ void execute( case DW_OP_breg29: case DW_OP_breg30: case DW_OP_breg31:{ + // Push register + constant: int register_id = simgrid::dwarf::dwarf_register_to_libunwind( op->atom - DW_OP_breg0); unw_word_t res; - if (!context.cursor) - throw evaluation_error("Missin stack context"); + if (not context.cursor) + throw evaluation_error("Missing stack context"); unw_get_reg(context.cursor, register_id, &res); stack.push(res + op->number); break; } - // Push the CFA (Canonical Frame Addresse): + // Push the CFA (Canonical Frame Address): case DW_OP_call_frame_cfa: { /* See 6.4 of DWARF4 (http://dwarfstd.org/doc/DWARF4.pdf#page=140): @@ -95,7 +95,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: @@ -117,7 +117,6 @@ void execute( // ***** Constants: // Short constant literals: - // DW_OP_lit15 pushed the 15 on the stack. case DW_OP_lit0: case DW_OP_lit1: case DW_OP_lit2: @@ -150,13 +149,14 @@ void execute( case DW_OP_lit29: case DW_OP_lit30: case DW_OP_lit31: + // Push a literal/constant on the stack: stack.push(atom - DW_OP_lit0); break; // 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; @@ -191,9 +191,8 @@ void execute( stack.pop(); break; - // Swap the two top-most value of the stack: case DW_OP_swap: - std::swap(stack.top(), stack.top(1)); + stack.swap(); break; // Duplicate the value under the top of the stack: @@ -206,13 +205,19 @@ void execute( // and replace the top of the stack with the computed value // (stack.top() += stack.before_top()). - case DW_OP_plus: - stack.push(stack.pop() + stack.pop()); + case DW_OP_plus: { + intptr_t first = stack.pop(); + intptr_t second = stack.pop(); + stack.push(first + second); break; + } - case DW_OP_mul: - stack.push(stack.pop() * stack.pop()); + case DW_OP_mul: { + intptr_t first = stack.pop(); + intptr_t second = stack.pop(); + stack.push(first * second); break; + } case DW_OP_plus_uconst: stack.top() += op->number; @@ -226,21 +231,33 @@ void execute( stack.top() = - (intptr_t) stack.top(); break; - case DW_OP_minus: - stack.push(stack.pop() - stack.pop()); + case DW_OP_minus: { + intptr_t first = stack.pop(); + intptr_t second = stack.pop(); + stack.push(second - first); break; + } - case DW_OP_and: - stack.push(stack.pop() & stack.pop()); + case DW_OP_and: { + intptr_t first = stack.pop(); + intptr_t second = stack.pop(); + stack.push(first & second); break; + } - case DW_OP_or: - stack.push(stack.pop() | stack.pop()); + case DW_OP_or: { + intptr_t first = stack.pop(); + intptr_t second = stack.pop(); + stack.push(first | second); break; + } - case DW_OP_xor: - stack.push(stack.pop() ^ stack.pop()); + case DW_OP_xor: { + intptr_t first = stack.pop(); + intptr_t second = stack.pop(); + stack.push(first ^ second); break; + } case DW_OP_nop: break; @@ -252,7 +269,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()),