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

The main entry point for the PStack executable. More...

Include dependency graph for pstack.cpp:

Namespaces

 anonymous_namespace{pstack.cpp}
 Functions that are local to this compilation unit.
 

Functions

template<typename SymbolEngine >
void anonymous_namespace{pstack.cpp}::output_stack_frame (SymbolEngine &symbol_eng, psystem::module_address_map const &modules, psystem::stack_frame const &frame)
 Prints a single stack from a stack trace to the console. More...
 
template<typename SymbolEngine >
void anonymous_namespace{pstack.cpp}::output_stack_trace (SymbolEngine &symbol_eng, psystem::process_info *const proc, psystem::thread_info *const thrd)
 Prints one thread's call stack to the screen. More...
 
void process_pid (proclib::debug_engine &engine, psystem::process_id_t const pid)
 Attach to a process and output stack traces for all threads. More...
 
int main (int const argc, char const *argv[])
 The main entry point for the PStack application. More...
 

Detailed Description

The main entry point for the PStack executable.

Author
Matt Bisson
Date
25 November, 2007 – 5 August, 2014
Since
PStack 1.0
Version
PStack 2.0

Function Documentation

int main ( int const  argc,
char const *  argv[] 
)

The main entry point for the PStack application.

See pstack::pstack_options for details on supported command-line options.

Parameters
[in]argcThe count of command-line arguments.
[in]argvThe array of strings that specify command-line arguments.
Returns
This is the return code that is passed to the parent process. The value is as follows:
  • 0: Successful execution of all specified workflows.
  • -1: Invalid command-line option passed.
  • -2: An "expected" exception caused a failure to execute the workflow.
  • -3: An unexpected exception caused a failure to execute the workflow.
  • -4: An unknown error caused a failure to execute the workflow.
  • >0: A system-native error occured. The result is the system error code.
Todo:
/I option (scan file for symbols) not implemented.
Todo:
/P option (administrative privs) not implemented.
void process_pid ( proclib::debug_engine engine,
psystem::process_id_t const  pid 
)

Attach to a process and output stack traces for all threads.

This is really the crux of the PStack application, as it attaches to a process, creates the utilities to analyze debugging symbols, and actually outputs the resulting stack traces.

Parameters
[in]engineThe debugging "engine" used to attach to a process and read information.
[in]pidThe system process ID (PID) of the process that will be examined.
Todo:

Document what exceptions this throws (there are many).

It would be nice if a problem with on PID didn't stop execution. Rearrange the exception handling a bit.

Todo:
Debug-only log message here
Todo:
Debug-only log message here