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

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

Include dependency graph for addr2ln.cpp:

Functions

static std::unique_ptr< psystem::symbolcheck_debug_symbols (psystem::symbol_view const *sym_view, psystem::address_t const *module_base, psystem::address_t const address)
 Look for a symbol in a module's debug information. More...
 
static std::unique_ptr< psystem::symbolcheck_dll_exports (psystem::dll_export_view const *exp_view, psystem::address_t const *module_base, psystem::address_t const address)
 Assuming a DLL, look for a symbol in the DLL exports table. More...
 
static void dump_symbols (std::string const &file_name)
 Open an executable module and dump the list of symbols to stdout. More...
 
static std::unique_ptr< psystem::symbolfind_symbol (std::string const &file_name, psystem::address_t const *module_base, psystem::address_t const address)
 Given an executable file, find the symbol that resides at the given address. More...
 
int main (int argc, char const *argv[])
 The main entry point for the Addr2Ln application. More...
 

Detailed Description

The main entry point for the Addr2Ln executable.

Author
Matt Bisson
Date
7 July, 2008 – 4 March, 2016
Since
Addr2ln 0.1
Version
Addr2ln 0.1

Function Documentation

std::unique_ptr< psystem::symbol > check_debug_symbols ( psystem::symbol_view const *  sym_view,
psystem::address_t const *  module_base,
psystem::address_t const  address 
)
static

Look for a symbol in a module's debug information.

Todo:
Remove a bunch of unneeded casts for pointer arithmetic throughout the code.
Parameters
[in]sym_viewThe "view" instance to the debugging symbol information. This may be nullptr. If so, the function will interpret this as a no-op.
[in]module_base(Optional) A pointer to the address that specifies the base-address for file_name if it were loaded (e.g., as a DLL). This may be nullptr if you wish to use the "default" base address, which is usually encoded in the module itself.
[in]addressThe address to check for a symbol.
Returns
A pointer to the symbol that was found at (or near) the address, or nullptr if none was found.
Exceptions
psystem::exception::system_exceptionIf the file could not be opened, or if it is not a recognized file type.
std::unique_ptr< psystem::symbol > check_dll_exports ( psystem::dll_export_view const *  exp_view,
psystem::address_t const *  module_base,
psystem::address_t const  address 
)
static

Assuming a DLL, look for a symbol in the DLL exports table.

Parameters
[in]exp_viewThe "view" instance any DLL export information. This may be nullptr. If so, the function will interpret this as a no-op.
[in]module_base(Optional) A pointer to the address that specifies the base-address for file_name if it were loaded (e.g., as a DLL). This may be nullptr if you wish to use the "default" base address, which is usually encoded in the module itself.
[in]addressThe address to check for a symbol.
Returns
A pointer to the symbol that was found at (or near) the address, or nullptr if none was found.
Exceptions
psystem::exception::system_exceptionIf the file could not be opened, or if it is not a recognized file type.
void dump_symbols ( std::string const &  file_name)
static

Open an executable module and dump the list of symbols to stdout.

This is a debugging function. If the specified file does not point to a recognized file type, this method simply throws an exception. If it contains no symbols, the function succeeds, but does not print any output.

Parameters
[in]file_nameThe file to open, examine, and dump contents.
Exceptions
psystem::exception::system_exceptionIf the file could not be opened, or if it is not a recognized file type.
std::unique_ptr< psystem::symbol > find_symbol ( std::string const &  file_name,
psystem::address_t const *  module_base,
psystem::address_t const  address 
)
static

Given an executable file, find the symbol that resides at the given address.

This function checks both the debugging information and the DLL exports (if either are present).

As a side-effect of this method, the given file may be mapped into memory and un-mapped. The method caches nothing.

Parameters
[in]file_nameThe file to open and examine.
[in]module_base(Optional) A pointer to the address that specifies the base-address for file_name if it were loaded (e.g., as a DLL). This may be nullptr if you wish to use the "default" base address, which is usually encoded in the module itself.
[in]addressThe address to check for a symbol.
Returns
A pointer to the symbol that was found at (or near) the address, or nullptr if none was found.
Exceptions
psystem::exception::system_exceptionIf the file could not be opened, or if it is not a recognized file type.
int main ( int  argc,
char const *  argv[] 
)

The main entry point for the Addr2Ln application.

See addr2ln::addr2ln_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.