PStack  2.0
Stack trace printer for MSVC and GCC binaries
addr2ln_options.hpp
Go to the documentation of this file.
1 // ===-- include/addr2ln/addr2ln_options.hpp -------------- -*- C++ -*- --=== //
2 // Copyright (c) 2016 Matt Bisson. All rights reserved.
3 
18 #pragma once
19 #ifndef ADDR2LN_ADDR2LN_OPTIONS_HPP
20 #define ADDR2LN_ADDR2LN_OPTIONS_HPP
21 
22 #include "addr2ln_ns.hpp"
23 
24 #include <set>
25 #include <string>
26 
29 
31 // Declare this so the friend relationship below will work
32 int main(int argc, char const *argv[]);
34 
35 namespace addr2ln {
36 
60 class addr2ln_options final
62 {
66 public:
68  using address_list = std::set<psystem::address_t>;
69 
70  // Forward declaration of the PImpl details.
71  struct options_data;
72 
76 public:
82 
88  static address_list const& get_address_list() noexcept;
89 
96  static std::string const& get_module_name() noexcept;
97 
101 public:
108  static void print_usage() noexcept;
109 
116  static void print_version_info() noexcept;
117 
118 private:
131  static void print_usage(const char *const prog_name) noexcept;
132 
136 private:
171  addr2ln_options(int argc, char const *argv[]);
172 
173 public:
178  ~addr2ln_options() noexcept;
179 
183 private:
189  static void dump_arguments(addr2ln_options::options_data const& d) noexcept;
190 
224  int try_switch(int i, int argc, char const *argv[]);
225 
229 private:
231  std::unique_ptr<options_data> m_data;
232 
234  // Doxygen doesn't parse "int ::main" (it sees "int::main"). Skip this bit.
235 
236  // Section 7.3.1.2 [namespace.memdef] --
237  // "If a friend declaration in a nonlocal class first declares a class or
238  // function, the friend class or function is a member of the innermost
239  // enclosing namespace."
240  //
241  // Since we don't want to mysteriously inject main() into the addr2ln
242  // namespace, we make sure to declare it above, and be explicit about the
243  // global namespace.
244  friend int ::main(int argc, char const *argv[]);
246 };
247 
248 } // namespace addr2ln
249 
250 #endif // ADDR2LN_ADDR2LN_OPTIONS_HPP
int main(int argc, char const *argv[])
The main entry point for the Addr2Ln application.
Definition: addr2ln.cpp:391
Parse and maintain options that alter the execution of Addr2Ln.
Definition: addr2ln_options.hpp:60
int try_switch(int i, int argc, char const *argv[])
Try to alter the options data based on a single character CLI switch.
Definition: addr2ln_options.cpp:376
Defines the psystem::not_assignable interface.
static psystem::address_t const * get_module_base_address() noexcept
Access the address to use as the module-base address for look-ups.
Definition: addr2ln_options.cpp:187
Contains functionality required to map addresses to source code information.
Definition: addr2ln_ns.hpp:89
Definition: shared_handle.hpp:782
The basic header file for the Addr2Ln namespce.
static void print_version_info() noexcept
Output information about the Addr2Ln's version to the screen.
Definition: addr2ln_options.cpp:226
#define noexcept
Replace keyword with something useful.
Definition: platform.hpp:71
static void dump_arguments(addr2ln_options::options_data const &d) noexcept
Output all the command-line data to stdout.
Definition: addr2ln_options.cpp:350
std::uintptr_t address_t
Container type for a memory address.
Definition: platform.hpp:221
Remove the ability to copy or reassign from derived classes.
Definition: not_copyable.hpp:43
std::set< psystem::address_t > address_list
The a container for list of user-supplied addresses to look up.
Definition: addr2ln_options.hpp:68
The full set of options information available to addr2ln::addr2ln_options.
Definition: addr2ln_options.cpp:155
static address_list const & get_address_list() noexcept
Access the list of addresses for Addr2Ln to process.
Definition: addr2ln_options.cpp:196
static void print_usage() noexcept
Print command-line help information to the screen.
Definition: addr2ln_options.cpp:218
static std::string const & get_module_name() noexcept
Access the name of the desired executable module that will be examined.
Definition: addr2ln_options.cpp:205
std::unique_ptr< options_data > m_data
A pointer to the options data (PImpl pattern).
Definition: addr2ln_options.hpp:231
Wraps the C++ standard header, memory, to provide a uniform interface.