Given an address in an objective code file, extract from the gdb-related debug information, the equivalent source code file name and line and append it to a string buffer.
- Parameters
-
[in,out] | dst | the destination string |
[in] | path | the path of the objective code file |
[in] | addr | the address |
- Returns
- the first argument
- Note
- If the addr2line program fails to retreive the debug information, or if any other error or exception occurs, nothing is appended to the destination string
- See Also
- man addr2line
-
man g++ (-g family options)
Definition at line 398 of file tracer.cpp.
References __D_ASSERT, csdbg::string::append(), csdbg::string::cmp(), csdbg::string::cstr(), csdbg::util::dbg_error(), likely, csdbg::exception::msg(), and unlikely.
Referenced by trace().
407 string cmd(
"addr2line -se %s 0x%x", path, addr);
410 pipe = popen(cmd.cstr(),
"r");
413 "failed to open pipe for command '%s' (errno %d - %s)",
422 while (
likely(ch !=
'\n' && ch != EOF) ) {
428 throw exception(
"failed to read pipe for command '%s'", cmd.cstr());
430 if (
likely(buf.cmp(
"??:0") != 0) )
431 dst.append(
" (%s)", buf.cstr());
434 catch (exception &x) {
438 catch (std::exception &x) {
442 if (
likely(pipe != NULL) )
char i8
8-bit signed integer
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
static void dbg_error(const i8 *,...)
Print an error debug message on the standard error stream.
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
#define __D_ASSERT(x)
Assertion macro.