libcwdversion 2.0.0
The C++ Debugging Support Library
Loading...
Searching...
No Matches
Source-File:Line-Number Information

Translating a program address into its source file and line number. More...

Classes

class  libcwd::Location
 A source file location. More...
class  libcwd::ObjectFileName
 An object representing the main executable or a shared library. More...

Typedefs

using libcwd::location_format_t = unsigned short int
 The type of the argument of location_format.

Functions

char const * libcwd::pc_mangled_function_name (void const *pc)
 Find the mangled function name of the address addr.
location_format_t libcwd::location_format (location_format_t format)
 Set the output format of Location.
std::ostream & libcwd::operator<< (std::ostream &os, Location const &location)
 Write location to ostream os.

Variables

char const *const libcwd::unknown_function_c = "<unknown function>"
 This constant (pointer) is returned by Location::mangled_function_name() when no function is known.
location_format_t const libcwd::show_path = 1
 Show the full source path when printing a location.
location_format_t const libcwd::show_objectfile = 2
 Show the shared library or executable that owns the location.
location_format_t const libcwd::show_function = 4
 Show the mangled function name for the location.

Detailed Description

If libcwd is configured with ‑DEnableLibcwdLocation:BOOL=ON, it allows you to easily obtain source-file & line-number information of a given address using the Location class.

Typedef Documentation

◆ location_format_t

using libcwd::location_format_t = unsigned short int

This type is used together with the bit masks show_objectfile, show_function and show_path.

Function Documentation

◆ location_format()

location_format_t libcwd::location_format ( location_format_t format)
inline

This function can be used to specify the format of how a Location will be printed when it is written to an ostream. The format is thread-specific: only the calling thread will be influenced.

The argument format is a bit-wise OR-ed value of three possible bit masks: show_function : Include the mangled function name. show_object : Include the name of the shared library or the executable name. show_path : Print the full path of the source file.

Returns
the previous value of the format.

◆ operator<<()

std::ostream & libcwd::operator<< ( std::ostream & os,
Location const & location )
inline

Write the contents of a Location object to an ostream in the form source-file:line-number, or writes objectfile:mangledfuncname when the location is unknown. If the source-file:line-number is known, then it may be prepended by the object file and/or the mangled function name anyway if this was requested through libcwd::location_format. That function can also be used to cause the source-file to be printed with its full path.

◆ pc_mangled_function_name()

char const * libcwd::pc_mangled_function_name ( void const * pc)
Returns
the same pointer that is returned by Location::mangled_function_name() on success, otherwise unknown_function_c is returned.

Note: the returned pointer is invalidated by calling dlclose(3) on the DSO that contains the returned function!

References unknown_function_c.