PStack  2.0
Stack trace printer for MSVC and GCC binaries
pstack_event_handler.hpp
Go to the documentation of this file.
1 // ===-- include/pstack/pstack_event_handler.hpp ---------- -*- C++ -*- --=== //
2 // Copyright (c) 2014 Matt Bisson. All rights reserved.
3 
19 #pragma once
20 #ifndef PSTACK_EVENT_HANDLER_HPP
21 #define PSTACK_EVENT_HANDLER_HPP
22 
23 #include "pstack_ns.hpp"
24 
27 
28 namespace psystem
29 {
30  class process_info;
31 }
32 
33 namespace pstack {
34 
53 {
57 public:
60 
63 
67 public:
70  virtual bool create_process_event(
72  psystem::shared_handle<> const& file_handle,
73  CREATE_PROCESS_DEBUG_INFO const& info) noexcept override;
74  virtual bool create_thread_event(
76  CREATE_THREAD_DEBUG_INFO const& info) noexcept override;
77  virtual bool exception_event(
79  EXCEPTION_DEBUG_INFO const& info) noexcept override;
83  virtual bool exit_process_event(
85  EXIT_PROCESS_DEBUG_INFO const& info) noexcept override;
86  virtual bool exit_thread_event(
88  EXIT_THREAD_DEBUG_INFO const& info) noexcept override;
89  virtual bool load_dll_event(
91  psystem::shared_handle<> const& file_handle,
92  LOAD_DLL_DEBUG_INFO const& info) noexcept override;
93  virtual bool unload_dll_event(
95  UNLOAD_DLL_DEBUG_INFO const& info) noexcept override;
96 
100 public:
108 
121 
131  bool is_debugger_ready() const noexcept;
132 
136 private:
138  std::unique_ptr<psystem::process_info> m_process_info;
139 
146 
149 };
150 
151 } // namespace pstack
152 
153 #endif // PSTACK_EVENT_HANDLER_HPP
bool is_debugger_ready() const noexcept
Determines if the debugger is ready to give a valid stack trace for all threads.
Definition: pstack_event_handler.cpp:177
virtual bool unload_dll_event(psystem::process_id_t pid, psystem::thread_id_t tid, UNLOAD_DLL_DEBUG_INFO const &info) noexcept override
Invoked when the debugger encounters a DLL unload.
Definition: pstack_event_handler.cpp:151
virtual bool load_dll_event(psystem::process_id_t pid, psystem::thread_id_t tid, psystem::shared_handle<> const &file_handle, LOAD_DLL_DEBUG_INFO const &info) noexcept override
Invoked when the debugger sends an event to indicate that a DLL hase been loaded. ...
Definition: pstack_event_handler.cpp:137
Handle debugger events with the goal of generating stack traces.
Definition: pstack_event_handler.hpp:51
#define noexcept
Replace keyword with something useful.
Definition: platform.hpp:71
bool m_is_debugger_ready
The debugger is ready to make stack traces for all threads.
Definition: pstack_event_handler.hpp:145
Contains modules that make up the PStack stack-printing application.
Definition: debug_event_dumper.hpp:25
DWORD process_id_t
Data-type that stores a process ID (PID).
Definition: platform.hpp:241
A container object for a process's information.
Definition: process_info.hpp:50
psystem::thread_id_t get_active_thread_id() const noexcept
Access the ID for the thread that was executing when the debugger attached.
Definition: pstack_event_handler.cpp:165
Declares the proclib::base_debug_event_listener interface.
virtual bool exit_process_event(psystem::process_id_t pid, psystem::thread_id_t tid, EXIT_PROCESS_DEBUG_INFO const &info) noexcept override
Invoked when the debugger sends an event to indicate that the process has exited. ...
Definition: pstack_event_handler.cpp:117
psystem::process_info * get_process_info() const noexcept
Access information about the process that generated the events for this handler.
Definition: pstack_event_handler.cpp:171
virtual bool exception_event(psystem::process_id_t pid, psystem::thread_id_t tid, EXCEPTION_DEBUG_INFO const &info) noexcept override
Invoked when the debugger sends an event to indicate some exception in normal process execution...
Definition: pstack_event_handler.cpp:101
A polymorphic interface for detecting events received by the debugger.
Definition: base_debug_event_listener.hpp:44
Share management of a single "handle" between multiple owners.
Definition: shared_handle.hpp:98
Contains the process examination "system" and basic frameworks.
Definition: pstack_event_handler.hpp:28
psystem::thread_id_t m_active_thread
The thread that was executing code when the debugger attached.
Definition: pstack_event_handler.hpp:148
virtual bool create_thread_event(psystem::process_id_t pid, psystem::thread_id_t tid, CREATE_THREAD_DEBUG_INFO const &info) noexcept override
Invoked when the debugger sends an event to indicate thread creation.
Definition: pstack_event_handler.cpp:89
pstack_event_handler() noexcept
Construct the pstack_event_handler instance.
Definition: pstack_event_handler.cpp:32
virtual bool exit_thread_event(psystem::process_id_t pid, psystem::thread_id_t tid, EXIT_THREAD_DEBUG_INFO const &info) noexcept override
Invoked when the debugger sends an event to indicate that a thread has exited.
Definition: pstack_event_handler.cpp:127
std::unique_ptr< psystem::process_info > m_process_info
The process for which events will be dispatched to this handler.
Definition: pstack_event_handler.hpp:138
The basic header file for the PStack namespace.
Wraps the C++ standard header, memory, to provide a uniform interface.
DWORD thread_id_t
Data-type that stores a thread ID (TID).
Definition: platform.hpp:247
virtual ~pstack_event_handler() noexcept
Destroy the pstack_event_handler instance.
Definition: pstack_event_handler.cpp:38
virtual bool create_process_event(psystem::process_id_t pid, psystem::thread_id_t tid, psystem::shared_handle<> const &file_handle, CREATE_PROCESS_DEBUG_INFO const &info) noexcept override
Invoked when the debugger sends an event to indicate process creation.
Definition: pstack_event_handler.cpp:48