PStack  2.0
Stack trace printer for MSVC and GCC binaries
pstack_options.hpp
Go to the documentation of this file.
1 // ===-- include/pstack/pstack_options.hpp ---------------- -*- C++ -*- --=== //
2 // Copyright (c) 2014 Matt Bisson. All rights reserved.
3 
18 #pragma once
19 #ifndef PSTACK_PSTACK_OPTIONS_HPP
20 #define PSTACK_PSTACK_OPTIONS_HPP
21 
22 #include "pstack_ns.hpp"
23 
24 #include <set>
27 
29 // Declare this so the friend relationship below will work
30 int main(int argc, char const *argv[]);
32 
33 namespace pstack {
34 
58 class pstack_options final
60 {
64 public:
66  using pid_list = std::set<psystem::process_id_t>;
67 
68  // Forward declaration of the PImpl details.
69  struct options_data;
70 
74 public:
87  static bool get_image_symbols() noexcept;
88 
94  static pid_list const& process_id_list() noexcept;
95 
101  static psystem::tstring const& program_name() noexcept;
102 
107  static bool search_all_threads() noexcept;
108 
111  static bool show_frames() noexcept;
112 
115  static bool show_debug() noexcept;
116 
119  static bool show_error() noexcept;
120 
123  static bool show_info() noexcept;
124 
128 public:
135  static void print_usage() noexcept;
136 
142  static void print_version_info() noexcept;
143 
144 private:
157  static void print_usage(const char *const prog_name) noexcept;
158 
162 private:
197  pstack_options(int argc, char const *argv[]);
198 
199 public:
204  ~pstack_options() noexcept;
205 
209 private:
215  static void dump_arguments(pstack_options::options_data const& d) noexcept;
216 
231  void try_pid(char const *arg);
232 
252  void try_switch(char arg);
253 
257 private:
259  std::unique_ptr<options_data> m_data;
260 
262  // Doxygen doesn't parse "int ::main" (it sees "int::main"). Skip this bit.
263 
264  // Section 7.3.1.2 [namespace.memdef] --
265  // "If a friend declaration in a nonlocal class first declares a class or
266  // function, the friend class or function is a member of the innermost
267  // enclosing namespace."
268  //
269  // Since we don't want to mysteriously inject main() into the pstack
270  // namespace, we make sure to declare it above, and be explicit about the
271  // global namespace.
272  friend int ::main(int argc, char const *argv[]);
274 };
275 
276 } // namespace pstack
277 
278 #endif // PSTACK_PSTACK_OPTIONS_HPP
static bool show_debug() noexcept
Should the user output verbose debug information?
Definition: pstack_options.cpp:197
The full set of options information available to pstack::pstack_options.
Definition: pstack_options.cpp:112
static bool show_error() noexcept
Should the user output errors in the flow of execution?
Definition: pstack_options.cpp:206
int main(int argc, char const *argv[])
The main entry point for the Addr2Ln application.
Definition: addr2ln.cpp:391
static bool search_all_threads() noexcept
Should PStack output stack traces for all threads?
Definition: pstack_options.cpp:179
std::set< psystem::process_id_t > pid_list
The a container for list of user-supplied process IDs.
Definition: pstack_options.hpp:66
Defines the psystem::not_assignable interface.
Definition: shared_handle.hpp:782
static void dump_arguments(pstack_options::options_data const &d) noexcept
Output all the command-line data to stdout.
Definition: pstack_options.cpp:387
#define noexcept
Replace keyword with something useful.
Definition: platform.hpp:71
std::string tstring
A std::string implementation based on the UNICODE macro.
Definition: platform.hpp:266
Remove the ability to copy or reassign from derived classes.
Definition: not_copyable.hpp:43
Contains modules that make up the PStack stack-printing application.
Definition: debug_event_dumper.hpp:25
void try_pid(char const *arg)
Try to interpret a CLI parameter as a process ID.
Definition: pstack_options.cpp:411
static bool show_frames() noexcept
Should PStack output frame pointers for each stack frame?
Definition: pstack_options.cpp:188
static void print_version_info() noexcept
Output information about the PStack's version to the screen.
Definition: pstack_options.cpp:236
static psystem::tstring const & program_name() noexcept
Access the name this program was invoked with.
Definition: pstack_options.cpp:170
static pid_list const & process_id_list() noexcept
Access the list of process IDs specified on the command-line.
Definition: pstack_options.cpp:161
void try_switch(char arg)
Try to alter the options data based on a single character CLI switch.
Definition: pstack_options.cpp:436
Contains the process examination "system" and basic frameworks.
Definition: pstack_event_handler.hpp:28
static bool get_image_symbols() noexcept
Should PStack search modules on disk for symbols rather than using built-in libraries?
Definition: pstack_options.cpp:152
std::unique_ptr< options_data > m_data
A pointer to the options data (PImpl pattern).
Definition: pstack_options.hpp:259
static bool show_info() noexcept
Should the user output extra informational messaging?
Definition: pstack_options.cpp:215
Parse and maintain options that alter the execution of PStack.
Definition: pstack_options.hpp:58
static void print_usage() noexcept
Print command-line help information to the screen.
Definition: pstack_options.cpp:228
The basic header file for the PStack namespace.
Wraps the C++ standard header, memory, to provide a uniform interface.