PStack
2.0
Stack trace printer for MSVC and GCC binaries
|
Parse and maintain options that alter the execution of Addr2Ln. More...
#include <addr2ln_options.hpp>
Classes | |
struct | options_data |
The full set of options information available to addr2ln::addr2ln_options. More... | |
Type Definitions | |
using | address_list = std::set< psystem::address_t > |
The a container for list of user-supplied addresses to look up. | |
Option Observers | |
static psystem::address_t const * | get_module_base_address () noexcept |
Access the address to use as the module-base address for look-ups. More... | |
static address_list const & | get_address_list () noexcept |
Access the list of addresses for Addr2Ln to process. More... | |
static std::string const & | get_module_name () noexcept |
Access the name of the desired executable module that will be examined. 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 Addr2Ln'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 | |
addr2ln_options (int argc, char const *argv[]) | |
Construct the addr2ln_options instance. More... | |
~addr2ln_options () noexcept | |
Deallocate the options instance. More... | |
Private Utilities | |
static void | dump_arguments (addr2ln_options::options_data const &d) noexcept |
Output all the command-line data to stdout . More... | |
int | try_switch (int i, int argc, char const *argv[]) |
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 Addr2Ln.
None of the "Option Observers" will function in this interface until one (and only one) instance of addr2ln_options has been instantiated. Only the main
method is allowed to construct an instance of this class. This addr2ln_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 addr2ln_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 addr2ln_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 addr2ln_options instance. |
|
staticnoexcept |
Access the list of addresses for Addr2Ln to process.
|
staticnoexcept |
Access the address to use as the module-base address for look-ups.
nullptr
if unspecified.
|
staticnoexcept |
Access the name of the desired executable module that will be examined.
|
staticnoexcept |
Print command-line help information to the screen.
Essentially, this is instructing the user what parameters this addr2ln_options class understands.
|
staticprivatenoexcept |
Print command-line help information to the screen.
Essentially, this is instructing the user what parameters this addr2ln_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 Addr2Ln's version to the screen.
This also displays PSystem information, as Addr2Ln relies upon that system.
|
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] | i | The index (in argv ) to the command-line parameter that should be examined. |
[in] | argc | The total count of arguments that exist within argv . |
[in] | argv | The array of character arrays that represent what the user passed to Addr2Ln on the command-line. |
i
+ n. In all other cases, it will simply return i
.psystem::exception::ui_exception | If the user specified a switch that is not valid for Addr2Ln. |
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 . |
i
must be less than argc
, and argv
[i] must contain at least two characters.