PStack  2.0
Stack trace printer for MSVC and GCC binaries
module_info.hpp
Go to the documentation of this file.
1 // ===-- include/psystem/module_info.hpp ------------------ -*- C++ -*- --=== //
2 // Copyright (c) 2014 Matt Bisson. All rights reserved.
3 
18 #pragma once
19 #ifndef PSYSTEM_MODULE_INFO_HPP
20 #define PSYSTEM_MODULE_INFO_HPP
21 
22 #include "psystem_ns.hpp"
23 
24 #include <mutex>
25 #include <string>
26 
28 
29 namespace psystem {
30 
49 {
53 public:
62  explicit module_info(
63  psystem::shared_handle<> const& file_handle,
64  CREATE_PROCESS_DEBUG_INFO const& info) noexcept;
65 
74  explicit module_info(
75  psystem::shared_handle<> const& file_handle,
76  LOAD_DLL_DEBUG_INFO const& info) noexcept;
77 
84 
87 
91 public:
103 
109  std::string const& get_file_name() const noexcept;
110 
116  std::string const& get_name() const noexcept;
117 
121 private:
134  static void init_file_name(HANDLE file_handle, std::string *out) noexcept;
135 
146  static void init_name(
147  std::string const& file_name,
148  std::string *out) noexcept;
149 
153 private:
156 
159 
165  std::string mutable m_file_name;
166 
174  std::once_flag mutable m_file_name_lock;
175 
181  std::string mutable m_name;
182 
190  std::once_flag mutable m_name_lock;
191 };
192 
193 } // namespace psystem
194 
195 #endif // PSYSTEM_MODULE_INFO_HPP
std::once_flag m_file_name_lock
Mutex for lazy generation of module_info::m_file_name.
Definition: module_info.hpp:174
static void init_file_name(HANDLE file_handle, std::string *out) noexcept
Lazy initialization used by the get_file_name() method.
Definition: module_info.cpp:98
Contains information about an executable image or shared library.
Definition: module_info.hpp:48
static void init_name(std::string const &file_name, std::string *out) noexcept
Lazy initialization used by the get_name() method.
Definition: module_info.cpp:137
#define noexcept
Replace keyword with something useful.
Definition: platform.hpp:71
address_t m_base_of_image
The base memory address into the module's data.
Definition: module_info.hpp:158
std::uintptr_t address_t
Container type for a memory address.
Definition: platform.hpp:221
Declare an RAII container for sharing system API handles (psystem::shared_handle).
address_t get_base_of_image() const noexcept
Access the base memory address for this module.
Definition: module_info.cpp:75
The basic header file for the PSystem namespce.
Share management of a single "handle" between multiple owners.
Definition: shared_handle.hpp:98
psystem::shared_handle m_file_handle
Shared ownership of the handle to the memory-mapped module.
Definition: module_info.hpp:155
Contains the process examination "system" and basic frameworks.
Definition: pstack_event_handler.hpp:28
~module_info() noexcept
Clean up resources used by the module_info instance.
Definition: module_info.cpp:69
std::string const & get_file_name() const noexcept
Access the module's full file name.
Definition: module_info.cpp:80
std::string m_file_name
The file name of the library / executable that defines this module.
Definition: module_info.hpp:165
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.
Definition: module_info.cpp:41
std::once_flag m_name_lock
Mutex for lazy generation of module_info::m_name.
Definition: module_info.hpp:190
std::string const & get_name() const noexcept
Access the module's base name.
Definition: module_info.cpp:87
Information logging as well as error.
std::string m_name
The brief name of the module.
Definition: module_info.hpp:181