Report symbol entry address in inline function discovery.

This commit is contained in:
Bartosz Taudul 2020-05-30 15:38:59 +02:00
parent ff27656533
commit 54eb75b063
3 changed files with 17 additions and 21 deletions

View File

@ -401,7 +401,7 @@ void InitCallstack()
cb_bts = backtrace_create_state( nullptr, 0, nullptr, nullptr ); cb_bts = backtrace_create_state( nullptr, 0, nullptr, nullptr );
} }
static int FastCallstackDataCb( void* data, uintptr_t pc, const char* fn, int lineno, const char* function ) static int FastCallstackDataCb( void* data, uintptr_t pc, uintptr_t lowaddr, const char* fn, int lineno, const char* function )
{ {
if( function ) if( function )
{ {
@ -440,7 +440,7 @@ const char* DecodeCallstackPtrFast( uint64_t ptr )
return ret; return ret;
} }
static int SymbolAddressDataCb( void* data, uintptr_t pc, const char* fn, int lineno, const char* function ) static int SymbolAddressDataCb( void* data, uintptr_t pc, uintptr_t lowaddr, const char* fn, int lineno, const char* function )
{ {
auto& sym = *(SymbolData*)data; auto& sym = *(SymbolData*)data;
if( !fn ) if( !fn )
@ -480,13 +480,13 @@ SymbolData DecodeCodeAddress( uint64_t ptr )
return DecodeSymbolAddress( ptr ); return DecodeSymbolAddress( ptr );
} }
static int CallstackDataCb( void* /*data*/, uintptr_t pc, const char* fn, int lineno, const char* function ) static int CallstackDataCb( void* /*data*/, uintptr_t pc, uintptr_t lowaddr, const char* fn, int lineno, const char* function )
{ {
enum { DemangleBufLen = 64*1024 }; enum { DemangleBufLen = 64*1024 };
char demangled[DemangleBufLen]; char demangled[DemangleBufLen];
cb_data[cb_num].symLen = 0; cb_data[cb_num].symLen = 0;
cb_data[cb_num].symAddr = (uint64_t)pc; cb_data[cb_num].symAddr = (uint64_t)lowaddr;
if( !fn && !function ) if( !fn && !function )
{ {
@ -597,14 +597,14 @@ static void CallstackErrorCb( void* /*data*/, const char* /*msg*/, int /*errnum*
void SymInfoCallback( void* /*data*/, uintptr_t pc, const char* symname, uintptr_t symval, uintptr_t symsize ) void SymInfoCallback( void* /*data*/, uintptr_t pc, const char* symname, uintptr_t symval, uintptr_t symsize )
{ {
cb_data[cb_fixup].symLen = (uint32_t)symsize; cb_data[cb_num-1].symLen = (uint32_t)symsize;
cb_data[cb_fixup].symAddr = (uint64_t)symval; cb_data[cb_num-1].symAddr = (uint64_t)symval;
} }
void SymInfoError( void* /*data*/, const char* /*msg*/, int /*errnum*/ ) void SymInfoError( void* /*data*/, const char* /*msg*/, int /*errnum*/ )
{ {
cb_data[cb_fixup].symLen = 0; cb_data[cb_num-1].symLen = 0;
cb_data[cb_fixup].symAddr = 0; cb_data[cb_num-1].symAddr = 0;
} }
CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
@ -613,11 +613,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
backtrace_pcinfo( cb_bts, ptr, CallstackDataCb, CallstackErrorCb, nullptr ); backtrace_pcinfo( cb_bts, ptr, CallstackDataCb, CallstackErrorCb, nullptr );
assert( cb_num > 0 ); assert( cb_num > 0 );
for( int i=0; i<cb_num; i++ ) backtrace_syminfo( cb_bts, ptr, SymInfoCallback, SymInfoError, nullptr );
{
cb_fixup = i;
backtrace_syminfo( cb_bts, cb_data[i].symAddr, SymInfoCallback, SymInfoError, nullptr );
}
const char* symloc = nullptr; const char* symloc = nullptr;
Dl_info dlinfo; Dl_info dlinfo;

View File

@ -95,7 +95,7 @@ extern struct backtrace_state *backtrace_create_state (
continuing tracing. The FILENAME and FUNCTION buffers may become continuing tracing. The FILENAME and FUNCTION buffers may become
invalid after this function returns. */ invalid after this function returns. */
typedef int (*backtrace_full_callback) (void *data, uintptr_t pc, typedef int (*backtrace_full_callback) (void *data, uintptr_t pc, uintptr_t lowaddr,
const char *filename, int lineno, const char *filename, int lineno,
const char *function); const char *function);

View File

@ -3874,7 +3874,7 @@ report_inlined_functions (uintptr_t pc, struct function *function,
return ret; return ret;
/* Report this inlined call. */ /* Report this inlined call. */
ret = callback (data, pc, *filename, *lineno, inlined->name); ret = callback (data, pc, function_addrs->low, *filename, *lineno, inlined->name);
if (ret != 0) if (ret != 0)
return ret; return ret;
@ -4026,7 +4026,7 @@ dwarf_lookup_pc (struct backtrace_state *state, struct dwarf_data *ddata,
if (new_data) if (new_data)
return dwarf_lookup_pc (state, ddata, pc, callback, error_callback, return dwarf_lookup_pc (state, ddata, pc, callback, error_callback,
data, found); data, found);
return callback (data, pc, NULL, 0, NULL); return callback (data, pc, 0, NULL, 0, NULL);
} }
/* Search for PC within this unit. */ /* Search for PC within this unit. */
@ -4073,13 +4073,13 @@ dwarf_lookup_pc (struct backtrace_state *state, struct dwarf_data *ddata,
entry->u->abs_filename = filename; entry->u->abs_filename = filename;
} }
return callback (data, pc, entry->u->abs_filename, 0, NULL); return callback (data, pc, 0, entry->u->abs_filename, 0, NULL);
} }
/* Search for function name within this unit. */ /* Search for function name within this unit. */
if (entry->u->function_addrs_count == 0) if (entry->u->function_addrs_count == 0)
return callback (data, pc, ln->filename, ln->lineno, NULL); return callback (data, pc, 0, ln->filename, ln->lineno, NULL);
function_addrs = ((struct function_addrs *) function_addrs = ((struct function_addrs *)
bsearch (&pc, entry->u->function_addrs, bsearch (&pc, entry->u->function_addrs,
@ -4087,7 +4087,7 @@ dwarf_lookup_pc (struct backtrace_state *state, struct dwarf_data *ddata,
sizeof (struct function_addrs), sizeof (struct function_addrs),
function_addrs_search)); function_addrs_search));
if (function_addrs == NULL) if (function_addrs == NULL)
return callback (data, pc, ln->filename, ln->lineno, NULL); return callback (data, pc, 0, ln->filename, ln->lineno, NULL);
/* If there are multiple function ranges that contain PC, use the /* If there are multiple function ranges that contain PC, use the
last one, in order to produce predictable results. */ last one, in order to produce predictable results. */
@ -4108,7 +4108,7 @@ dwarf_lookup_pc (struct backtrace_state *state, struct dwarf_data *ddata,
if (ret != 0) if (ret != 0)
return ret; return ret;
return callback (data, pc, filename, lineno, function->name); return callback (data, pc, function_addrs->low, filename, lineno, function->name);
} }
@ -4158,7 +4158,7 @@ dwarf_fileline (struct backtrace_state *state, uintptr_t pc,
/* FIXME: See if any libraries have been dlopen'ed. */ /* FIXME: See if any libraries have been dlopen'ed. */
return callback (data, pc, NULL, 0, NULL); return callback (data, pc, 0, NULL, 0, NULL);
} }
/* Initialize our data structures from the DWARF debug info for a /* Initialize our data structures from the DWARF debug info for a