PStack  2.0
Stack trace printer for MSVC and GCC binaries
psystem::symbol_file_module Class Reference

Encapsulates a module (file) for the purpose of gathering debugging symbols. More...

#include <symbol_file_module.hpp>

Inheritance diagram for psystem::symbol_file_module:
Collaboration diagram for psystem::symbol_file_module:

Construction / Destruction

 symbol_file_module (std::string const &file_name)
 Construct an instance by loading file_name. More...
 
 symbol_file_module (symbol_file_module &&o) noexcept
 Move from an object of this type. More...
 
 ~symbol_file_module () noexcept
 Clean up resources used by the symbol_file_module instance. More...
 

Public Interface

void dump_module_info () const
 Prints executable image headers to the console. More...
 
uint8_t const * get_base_address () const noexcept
 Acquire the base memory address where this module has been loaded. More...
 
dll_export_view const * get_dll_export_view ()
 Obtain a "view" into the exported DLL symbols for this module. More...
 
symbol_view const * get_symbol_view ()
 Obtain a "view" into the debugging symbols for this module. More...
 

Member Data

std::unique_ptr< uint8_t, std::function< void(uint8_t *)> > m_view
 Address of the bytes for the memory mapped file.
 
psystem::unique_handle m_mapping_handle
 System handle to the memory mapping.
 
psystem::unique_handle m_file_handle
 Open handle to the file-system file (to be mapped).
 
std::unique_ptr< symbol_viewm_symbol_view
 Loaded view of debugging symbols (may be NULL).
 
std::unique_ptr< dll_export_viewm_dll_export_view
 Loaded view of DLL exports (may be NULL).
 

Additional Inherited Members

- Private Member Functions inherited from psystem::not_copyable
 not_copyable (not_copyable const &)=delete
 Delete the copy constructor.
 
not_copyableoperator= (not_copyable const &)=delete
 Delete the assignment operator.
 
constexpr not_copyable () noexcept
 A simple CTOR suitable for noexcept and constexpr uses.
 
 ~not_copyable () noexcept
 A simple CTOR suitable for noexcept uses.
 

Detailed Description

Encapsulates a module (file) for the purpose of gathering debugging symbols.

This class maps a physical file containing executable code or debugging symbols into memory, and provides views into both debugging symbols and exported (DLL) symbols. Currently, this only supports executable and DLL images.

Author
Matt Bisson
Date
8 February, 2015
Since
PSystem 2.0
Version
PSystem 2.0

Constructor & Destructor Documentation

psystem::symbol_file_module::symbol_file_module ( std::string const &  file_name)
explicit

Construct an instance by loading file_name.

This method maps an executable module into memory for later examination. It makes no validation of the contents of the file during construction, so later invocations may decide that file_name is not applicable for their purposes.

Parameters
[in]file_nameThe path of a file that will be checked for symbols. This may be a full path or simply a file; normal Win32 name resolution applies.
Exceptions
psystem::exception::system_exceptionIf the file specified by file_name did not exist, or could not be mapped into memory.
psystem::symbol_file_module::symbol_file_module ( symbol_file_module &&  o)
noexcept

Move from an object of this type.

Parameters
[in,out]oThe instance from which data will be moved.
Postcondition
Ownership of all "view" instances from o, transfer to this instance.
psystem::symbol_file_module::~symbol_file_module ( )
noexcept

Clean up resources used by the symbol_file_module instance.

Postcondition
The destruction of this class also destroys all "view" instances acquired from it.
Todo:
Remove noexcept on DTOR

Member Function Documentation

void psystem::symbol_file_module::dump_module_info ( ) const

Prints executable image headers to the console.

Exceptions
psystem::exception::system_exceptionIf the file backing this instance is not a Windows Portable Executable (PE), or the "optional" header is not present.
Todo:
Better exception.
Todo:
Better exception
Todo:
Better exception
Todo:
Better exception
uint8_t const * psystem::symbol_file_module::get_base_address ( ) const
noexcept

Acquire the base memory address where this module has been loaded.

Acquiring this "base" address gives a readable view of the raw bits the exist in the module that this instance represents.

Returns
The memory address pointing to the loaded module. This never returns NULL.
dll_export_view const * psystem::symbol_file_module::get_dll_export_view ( )

Obtain a "view" into the exported DLL symbols for this module.

Returns
This method may return NULL if no export table exists.
Exceptions
psystem::exception::system_exceptionIf the file backing this instance is not a Windows Portable Executable (PE).
Todo:
Better exception.
Todo:
Better exception
Todo:
Better exception
symbol_view const * psystem::symbol_file_module::get_symbol_view ( )

Obtain a "view" into the debugging symbols for this module.

Returns
This method may return NULL if there is no debugging information.
Exceptions
psystem::exception::system_exceptionIf the file backing this instance is not a Windows Portable Executable (PE), or the "optional" header is not present.
Todo:
Better exception.
Todo:
Better exception
Todo:
Better exception
Todo:
Better exception

The documentation for this class was generated from the following files: