PStack
2.0
Stack trace printer for MSVC and GCC binaries
|
Parse and maintain options that alter the execution of PStack. More...
#include <pstack_options.hpp>
Classes | |
struct | options_data |
The full set of options information available to pstack::pstack_options. More... | |
Type Definitions | |
using | pid_list = std::set< psystem::process_id_t > |
The a container for list of user-supplied process IDs. | |
Option Observers | |
static bool | get_image_symbols () noexcept |
Should PStack search modules on disk for symbols rather than using built-in libraries? More... | |
static pid_list const & | process_id_list () noexcept |
Access the list of process IDs specified on the command-line. More... | |
static psystem::tstring const & | program_name () noexcept |
Access the name this program was invoked with. More... | |
static bool | search_all_threads () noexcept |
Should PStack output stack traces for all threads? More... | |
static bool | show_frames () noexcept |
Should PStack output frame pointers for each stack frame? More... | |
static bool | show_debug () noexcept |
Should the user output verbose debug information? More... | |
static bool | show_error () noexcept |
Should the user output errors in the flow of execution? More... | |
static bool | show_info () noexcept |
Should the user output extra informational messaging? More... | |
Informational Functions | |
static void | print_usage () noexcept |
Print command-line help information to the screen. More... | |
static void | print_version_info () noexcept |
Output information about the PStack's version to the screen. More... | |
static void | print_usage (const char *const prog_name) noexcept |
Print command-line help information to the screen. More... | |
Construction / Destruction | |
pstack_options (int argc, char const *argv[]) | |
Construct the pstack_options instance. More... | |
~pstack_options () noexcept | |
Deallocate the options instance. More... | |
Private Utilities | |
static void | dump_arguments (pstack_options::options_data const &d) noexcept |
Output all the command-line data to stdout . More... | |
void | try_pid (char const *arg) |
Try to interpret a CLI parameter as a process ID. More... | |
void | try_switch (char arg) |
Try to alter the options data based on a single character CLI switch. More... | |
Member Data | |
std::unique_ptr< options_data > | m_data |
A pointer to the options data (PImpl pattern). | |
Additional Inherited Members | |
Private Member Functions inherited from psystem::not_copyable | |
not_copyable (not_copyable const &)=delete | |
Delete the copy constructor. | |
not_copyable & | operator= (not_copyable const &)=delete |
Delete the assignment operator. | |
constexpr | not_copyable () noexcept |
A simple CTOR suitable for noexcept and constexpr uses. | |
~not_copyable () noexcept | |
A simple CTOR suitable for noexcept uses. | |
Parse and maintain options that alter the execution of PStack.
None of the "Option Observers" will function in this interface until one (and only one) instance of pstack_options has been instantiated. Only the main
method is allowed to construct an instance of this class. This pstack_options is a singleton, and the lifetime is limited to a predictable scope in main
.
Since this uses the PImpl pattern, we will make this class not_copyable
, rather than redefining the copy constructor to do a deep copy of the "impl." Copying isn't useful at the moment anyway.
|
private |
Construct the pstack_options instance.
This method is private because it is only intended to be called from the main
function (main
is a friend of this class). This is because the constructor has a side-effect of populating a global (singleton) pointer with this
. When main
allocates the pstack_options instance, we at least know the lifetime of the singleton coincides with it.
[in] | argc | The command-line argument count. |
[in] | argv | The array of command-line arguments. |
psystem::exception::ui_exception | Under the following conditions:
|
false | In the event of a non-fatal operation that interrupts the option parsing (e.g., printing the help screen), this method throws a bool with the value false . |
main
can create and destroy the options data. Make sure to do both operations in a single-threaded context. This assumption prevents us from having to guard the global data, check for nullptr
, and so on.
|
noexcept |
Deallocate the options instance.
|
staticprivatenoexcept |
Output all the command-line data to stdout
.
[in] | d | The internal data of the pstack_options instance. |
|
staticnoexcept |
Should PStack search modules on disk for symbols rather than using built-in libraries?
The built-in debugging symbol libraries do not always find the symbols they need to generate a detailed stack trace. MinGW executables often cause this issue. This flag tells PStack to use our own home-grown solution.
true
if this option is active. The default is false
.
|
staticnoexcept |
Print command-line help information to the screen.
Essentially, this is instructing the user what parameters this pstack_options class understands.
|
staticprivatenoexcept |
Print command-line help information to the screen.
Essentially, this is instructing the user what parameters this pstack_options class understands. Because print_usage() relies on the option instance being initialized, this version exists to provide the required information without the requirement. The presence of prog_name
is illogical as a public API, hence the private access restriction.
[in] | prog_name | The name of the application from the command-line. |
|
staticnoexcept |
Output information about the PStack's version to the screen.
This also displays PSystem information, as PStack relies upon that system.
|
staticnoexcept |
Access the list of process IDs specified on the command-line.
|
staticnoexcept |
Access the name this program was invoked with.
|
staticnoexcept |
Should PStack output stack traces for all threads?
true
if this option is active. The default is true
.
|
staticnoexcept |
Should the user output verbose debug information?
true
if this option is active. The default is false
.
|
staticnoexcept |
Should the user output errors in the flow of execution?
true
if this option is active. The default is true
.
|
staticnoexcept |
Should PStack output frame pointers for each stack frame?
true
if this option is active. The default is false
.
|
staticnoexcept |
Should the user output extra informational messaging?
true
if this option is active. The default is false
.
|
private |
Try to interpret a CLI parameter as a process ID.
This method attempts to convert a string using the C++ numerical (literal) token's syntax. That is, strings that begin with "0x"
will be interpreted as hexadecimal, those that begin with "0"
will be assumed to be octal, and all others will be assumed to be decimal.
[in] | arg | The string to parse. It cannot be nullptr . |
psystem::exception::ui_exception | If arg input does not consist entirely of text that can be converted to a psystem::process_id_t data type. The resulting value must also be a positive integer that is less than ULONG_MAX . |
|
private |
Try to alter the options data based on a single character CLI switch.
If the user asks for version information or command-line option help, this method will print that to the command line.
[in] | arg | The single-letter command-line switch to parse. |
psystem::exception::ui_exception | If the user specified a switch that is not valid for PStack. |
false | In the event of a non-fatal operation that interrupts the option parsing (e.g., printing the help screen), this method throws a bool with the value false . |