PStack  2.0
Stack trace printer for MSVC and GCC binaries
symbol_file_module.hpp
Go to the documentation of this file.
1 // ===-- include/psystem/symbol_file_module.hpp ----------- -*- C++ -*- --=== //
2 // Copyright (c) 2015 Matt Bisson. All rights reserved.
3 
19 #pragma once
20 #ifndef PSYSTEM_SYMBOL_FILE_MODULE_HPP
21 #define PSYSTEM_SYMBOL_FILE_MODULE_HPP
22 
23 #include "psystem_ns.hpp"
24 
25 #include <functional>
26 
30 
31 namespace psystem {
32 
33 class dll_export_view;
34 class symbol_view;
35 
52 {
56 public:
73  explicit symbol_file_module(std::string const& file_name);
74 
85 
96 
100 public:
109  void dump_module_info() const;
110 
121  uint8_t const *get_base_address() const noexcept;
122 
133 
144  symbol_view const *get_symbol_view();
145 
149 private:
150  //
151  // Resources consumed for the lifetime of this instance:
152  //
153 
155  std::unique_ptr< uint8_t, std::function<void(uint8_t*)> > m_view;
156 
159 
162 
163  //
164  // Lazily loaded resources:
165  //
166 
168  std::unique_ptr<symbol_view> m_symbol_view;
169 
171  std::unique_ptr<dll_export_view> m_dll_export_view;
172 };
173 
174 } // namespace psystem
175 
176 #endif // PSYSTEM_SYMBOL_FILE_MODULE_HPP
std::unique_ptr< uint8_t, std::function< void(uint8_t *)> > m_view
Address of the bytes for the memory mapped file.
Definition: symbol_file_module.hpp:155
std::unique_ptr< dll_export_view > m_dll_export_view
Loaded view of DLL exports (may be NULL).
Definition: symbol_file_module.hpp:171
Uniquely manage a single "handle".
Definition: unique_handle.hpp:249
psystem::unique_handle m_mapping_handle
System handle to the memory mapping.
Definition: symbol_file_module.hpp:158
~symbol_file_module() noexcept
Clean up resources used by the symbol_file_module instance.
Definition: symbol_file_module.cpp:238
Defines the psystem::not_assignable interface.
Exposes a DLL's symbol export table.
Definition: dll_export_view.hpp:40
symbol_file_module(std::string const &file_name)
Construct an instance by loading file_name.
Definition: symbol_file_module.cpp:179
#define noexcept
Replace keyword with something useful.
Definition: platform.hpp:71
symbol_view const * get_symbol_view()
Obtain a "view" into the debugging symbols for this module.
Definition: symbol_file_module.cpp:400
Remove the ability to copy or reassign from derived classes.
Definition: not_copyable.hpp:43
std::unique_ptr< symbol_view > m_symbol_view
Loaded view of debugging symbols (may be NULL).
Definition: symbol_file_module.hpp:168
Encapsulates a module (file) for the purpose of gathering debugging symbols.
Definition: symbol_file_module.hpp:50
Declare an RAII container for system API handles (psystem::unique_handle).
uint8_t const * get_base_address() const noexcept
Acquire the base memory address where this module has been loaded.
Definition: symbol_file_module.cpp:302
void dump_module_info() const
Prints executable image headers to the console.
Definition: symbol_file_module.cpp:247
The basic header file for the PSystem namespce.
Exposes an executable image's debugging symbol data.
Definition: symbol_view.hpp:40
Contains the process examination "system" and basic frameworks.
Definition: pstack_event_handler.hpp:28
psystem::unique_handle m_file_handle
Open handle to the file-system file (to be mapped).
Definition: symbol_file_module.hpp:161
Wraps the C++ standard header, memory, to provide a uniform interface.
dll_export_view const * get_dll_export_view()
Obtain a "view" into the exported DLL symbols for this module.
Definition: symbol_file_module.cpp:308