-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
* just a sequence of dwarf instructions. We currently directly use
* `Dwarf_Op` from `dwarf.h` for dwarf instructions.
*/
-typedef std::vector<Dwarf_Op> DwarfExpression;
+using DwarfExpression = std::vector<Dwarf_Op>;
/** Context of evaluation of a DWARF expression
*
* Some DWARF instructions need to read the CPU registers,
- * the process memory, etc. All those informations are gathered in
+ * the process memory, etc. All those information are gathered in
* the evaluation context.
*/
-class ExpressionContext {
-public:
- ExpressionContext()
- : cursor(nullptr)
- , frame_base(nullptr)
- , address_space(nullptr)
- , object_info(nullptr)
- {
- }
+struct ExpressionContext {
/** CPU state (registers) */
- unw_cursor_t* cursor;
- void* frame_base;
- /** Address space used to read memory */
- const simgrid::mc::AddressSpace* address_space;
- simgrid::mc::ObjectInformation* object_info;
+ unw_cursor_t* cursor = nullptr;
+ void* frame_base = nullptr;
+ const mc::AddressSpace* address_space = nullptr; /** Address space used to read memory */
+ mc::ObjectInformation* object_info = nullptr;
};
/** When an error happens in the execution of a DWARF expression */
class evaluation_error : public std::runtime_error {
public:
- explicit evaluation_error(const char* what) : std::runtime_error(what) {}
+ using std::runtime_error::runtime_error;
};
/** A stack for evaluating a DWARF expression
*/
class ExpressionStack {
public:
- typedef std::uintptr_t value_type;
+ using value_type = std::uintptr_t;
static const std::size_t max_size = 64;
private:
// Values of the stack (the top is stack_[size_ - 1]):
uintptr_t stack_[max_size]{0};
- size_t size_;
+ size_t size_ = 0;
public:
- ExpressionStack() : size_(0) {}
-
// Access:
std::size_t size() const { return size_; }
bool empty() const { return size_ == 0; }