X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/41c54c2772412935a5c8fc9f2d09e623c0383ae7..debe4e5871c0c3d1c714bbb1bd28ba7147454aa5:/src/mc/DwarfExpression.hpp diff --git a/src/mc/DwarfExpression.hpp b/src/mc/DwarfExpression.hpp index fda5c6aad6..b6713b22af 100644 --- a/src/mc/DwarfExpression.hpp +++ b/src/mc/DwarfExpression.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2015-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. */ @@ -9,13 +8,21 @@ #include #include -#include + +#include // runtime_error +#include +#include + +#include +#include #include "src/mc/AddressSpace.hpp" +#include "src/mc/mc_dwarf.hpp" +#include "src/mc/mc_forward.hpp" -/** @file DwarfExession.hpp +/** @file DwarfExpression.hpp * - * Evaluation of DWARF location expressions + * Evaluation of DWARF location expressions. */ namespace simgrid { @@ -24,7 +31,7 @@ namespace dwarf { /** A DWARF expression * * DWARF defines a simple stack-based VM for evaluating expressions - * (such as locations of variables, etc.): A DWARF expressions is + * (such as locations of variables, etc.): a DWARF expression is * just a sequence of dwarf instructions. We currently directly use * `Dwarf_Op` from `dwarf.h` for dwarf instructions. */ @@ -36,7 +43,8 @@ typedef std::vector DwarfExpression; * the process memory, etc. All those informations are gathered in * the evaluation context. */ -struct ExpressionContext { +class ExpressionContext { +public: ExpressionContext() : cursor(nullptr), frame_base(nullptr), address_space(nullptr), object_info(nullptr), process_index(simgrid::mc::ProcessIndexMissing) {} @@ -50,10 +58,9 @@ struct ExpressionContext { }; /** When an error happens in the execution of a DWARF expression */ -class evaluation_error : std::runtime_error { +class evaluation_error : public std::runtime_error { public: - evaluation_error(const char* what): std::runtime_error(what) {} - ~evaluation_error() noexcept(true); + explicit evaluation_error(const char* what) : std::runtime_error(what) {} }; /** A stack for evaluating a DWARF expression @@ -65,7 +72,8 @@ public: typedef std::uintptr_t value_type; static const std::size_t max_size = 64; private: - uintptr_t stack_[max_size]; + // Values of the stack (the top is stack_[size_ - 1]): + uintptr_t stack_[max_size] {0}; size_t size_; public: ExpressionStack() : size_(0) {} @@ -97,7 +105,7 @@ public: void push(value_type value) { if (size_ == max_size) - throw evaluation_error("Dwarf stack overflow"); + throw evaluation_error("DWARF stack overflow"); stack_[size_++] = value; } @@ -105,7 +113,7 @@ public: value_type pop() { if (size_ == 0) - throw evaluation_error("Stack underflow"); + throw evaluation_error("DWARF stack underflow"); return stack_[--size_]; }