PStack  2.0
Stack trace printer for MSVC and GCC binaries
debug_event_dumper.cpp File Reference

Declare an event listener to provide verbose information about events. More...

#include "pstack/debug_event_dumper.hpp"
#include <cstring>
#include <iostream>
#include <psystem/framework/iomanip.hpp>
#include <psystem/framework/memory.hpp>
Include dependency graph for debug_event_dumper.cpp:

Namespaces

 anonymous_namespace{debug_event_dumper.cpp}
 Data local to this compilation unit.
 
 pstack
 Contains modules that make up the PStack stack-printing application.
 

Variables

int const anonymous_namespace{debug_event_dumper.cpp}::kMaxExceptionRecordLevels = 8
 Do not recurse through exception records any more than this number of times.
 

Convenience Macros

#define EXTENDED_PATH_PREFIX   TEXT("\\\\?\\")
 The marker string at the beginning of a file name for an "extended" path.
 
#define EXTENDED_PATH_PREFIX_SZ   (sizeof(EXTENDED_PATH_PREFIX) / sizeof(*EXTENDED_PATH_PREFIX))
 String length (inlcuding null terminator) of EXTENDED_PATH_PREFIX.
 
#define PRINT_EXCEPTION_CODE(code)   case code: std::cout << #code; break
 Inline macro to serialize exception code values into text. More...
 

Compilation-Unit Utilities

static std::unique_ptr< TCHAR[]> get_file_name_from_handle (HANDLE const h_file) noexcept
 Find the name of a file when given a handle to that memory-mapped file. More...
 
static void print_common_data (psystem::process_id_t const pid, psystem::thread_id_t const tid)
 Print the data that exists for every debugger event. More...
 
static void print_exception_record (EXCEPTION_RECORD const &ex_rec, int const count=0) noexcept
 Print an EXCEPTION_RECORD structure. More...
 

Detailed Description

Declare an event listener to provide verbose information about events.

Author
Matt Bisson
Date
14 February, 2008 – 5 August, 2014
Since
PStack 1.2
Version
PStack 2.0

Macro Definition Documentation

#define PRINT_EXCEPTION_CODE (   code)    case code: std::cout << #code; break

Inline macro to serialize exception code values into text.

Parameters
codeThe exception code constant.
See also
print_exception_record()

Function Documentation

static std::unique_ptr<TCHAR[]> get_file_name_from_handle ( HANDLE const  h_file)
staticnoexcept

Find the name of a file when given a handle to that memory-mapped file.

Parameters
[in]h_fileThe handle to the memory-mapped file to gather a name for.
Returns
A file name, or the empty string if the file name cannot be retrieved.
Todo:
Merge this with the module_info.cpp version?
static void print_common_data ( psystem::process_id_t const  pid,
psystem::thread_id_t const  tid 
)
static

Print the data that exists for every debugger event.

Parameters
[in]pidThe process ID of the process that generated the event.
[in]tidThe thread ID for the active thread in the event.
static void print_exception_record ( EXCEPTION_RECORD const &  ex_rec,
int const  count = 0 
)
staticnoexcept

Print an EXCEPTION_RECORD structure.

EXCEPTION_RECORD is a recursively defined structure, so this method will recurse through the structure kMaxExceptionRecordLevels - count times (until it finds a nullptr value for the next EXCEPTION_RECORD).

Parameters
[in]ex_recThe exception record to display.
[in]countThe number of recursions already performed. The initial call should accept the default parameter (of 0).