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

Contains information about an executable image or shared library. More...

#include <module_info.hpp>

Collaboration diagram for psystem::module_info:

Construction / Destruction

 module_info (psystem::shared_handle<> const &file_handle, CREATE_PROCESS_DEBUG_INFO const &info) noexcept
 Construct a module_info instance for a process's executable. More...
 
 module_info (psystem::shared_handle<> const &file_handle, LOAD_DLL_DEBUG_INFO const &info) noexcept
 Construct a module_info instance for a shared library. More...
 
 module_info (module_info &&o) noexcept
 Move from an object of this type. More...
 
 ~module_info () noexcept
 Clean up resources used by the module_info instance.
 

Public Interface

address_t get_base_of_image () const noexcept
 Access the base memory address for this module. More...
 
std::string const & get_file_name () const noexcept
 Access the module's full file name. More...
 
std::string const & get_name () const noexcept
 Access the module's base name. More...
 

Private Utilites

static void init_file_name (HANDLE file_handle, std::string *out) noexcept
 Lazy initialization used by the get_file_name() method. More...
 
static void init_name (std::string const &file_name, std::string *out) noexcept
 Lazy initialization used by the get_name() method. More...
 

Member Data

psystem::shared_handle m_file_handle
 Shared ownership of the handle to the memory-mapped module.
 
address_t m_base_of_image
 The base memory address into the module's data.
 
std::string m_file_name
 The file name of the library / executable that defines this module. More...
 
std::once_flag m_file_name_lock
 Mutex for lazy generation of module_info::m_file_name. More...
 
std::string m_name
 The brief name of the module. More...
 
std::once_flag m_name_lock
 Mutex for lazy generation of module_info::m_name. More...
 

Detailed Description

Contains information about an executable image or shared library.

In order to have a useful debugging experience, a debugger needs to be aware of all the modules used by an application, as well as where in memory they reside. This provides information about individual symbols, as well as a more reliable stack trace.

Author
Matt Bisson
Date
5 August, 2014
Since
PSystem 2.0
Version
PSystem 2.0
Todo:

Get module names

Move operations

Pass in needed data to be more platform compatible?

Constructor & Destructor Documentation

psystem::module_info::module_info ( psystem::shared_handle<> const &  file_handle,
CREATE_PROCESS_DEBUG_INFO const &  info 
)
explicitnoexcept

Construct a module_info instance for a process's executable.

Parameters
[in]file_handleThe handle to the file that relates to this code module.
[in]infoThe full set of information about the module.
psystem::module_info::module_info ( psystem::shared_handle<> const &  file_handle,
LOAD_DLL_DEBUG_INFO const &  info 
)
explicitnoexcept

Construct a module_info instance for a shared library.

Parameters
[in]file_handleThe handle to the file that relates to this code module.
[in]infoThe full set of information about the module.
psystem::module_info::module_info ( module_info &&  o)
noexcept

Move from an object of this type.

Parameters
[in,out]oThe instance from which data will be moved.

Member Function Documentation

address_t psystem::module_info::get_base_of_image ( ) const
noexcept

Access the base memory address for this module.

This information is useful for determining symbol information based on a memory address (e.g., a PC location in a stack trace). Once the module is determined, the symbol information can be gathered.

Returns
A memory address to the loaded module (as it exists in the debuggee process's address space).
std::string const & psystem::module_info::get_file_name ( ) const
noexcept

Access the module's full file name.

Returns
The path and name of the file that makes up this module. The return value is valid until this instance is destroyed.
std::string const & psystem::module_info::get_name ( ) const
noexcept

Access the module's base name.

Returns
The "base" name of the module. This is not a full path. The return value is valid until this instance is destroyed.
void psystem::module_info::init_file_name ( HANDLE  file_handle,
std::string *  out 
)
staticprivatenoexcept

Lazy initialization used by the get_file_name() method.

Given a file handle, this populates the out parameter with the name of that file.

Parameters
[in]file_handleAn open file to examine.
[in,out]outThe buffer to receive the name associated with file_handle. This may be nullptr (the method does nothing).
Warning
Using GetFinalPathNameByHandle(), a Vista and later API.
void psystem::module_info::init_name ( std::string const &  file_name,
std::string *  out 
)
staticprivatenoexcept

Lazy initialization used by the get_name() method.

Given a file name, this populates the out parameter with the module-name associated with the file.

Parameters
[in]file_nameThe module's file name.
[in,out]outThe buffer to receive the module name. This may be nullptr (the method does nothing).

Member Data Documentation

std::string psystem::module_info::m_file_name
mutableprivate

The file name of the library / executable that defines this module.

This is expensive to generate, and is only created lazily.

std::once_flag psystem::module_info::m_file_name_lock
mutableprivate

Mutex for lazy generation of module_info::m_file_name.

The module_info::m_file_name data is generated by the const member function, get_file_name(). Mutable data altered in a const context should always be protected by a threading guard.

std::string psystem::module_info::m_name
mutableprivate

The brief name of the module.

The name is generated from m_file_name, so it will be generated lazily.

std::once_flag psystem::module_info::m_name_lock
mutableprivate

Mutex for lazy generation of module_info::m_name.

The module_info::m_name data is generated by the const member function, get_name(). Mutable data altered in a const context should always be protected by a threading guard.


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