mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 14:44:34 +00:00
Implement search for symbol matching function name when opening source view.
This commit is contained in:
parent
cf412bfb2e
commit
9a5fb0bb51
@ -159,6 +159,56 @@ void View::ViewSource( const char* fileName, int line )
|
|||||||
m_sourceView->OpenSource( fileName, line, *this, m_worker );
|
m_sourceView->OpenSource( fileName, line, *this, m_worker );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View::ViewSource( const char* fileName, int line, const char* functionName )
|
||||||
|
{
|
||||||
|
assert( functionName );
|
||||||
|
|
||||||
|
uint64_t addr = 0;
|
||||||
|
uint64_t base = 0;
|
||||||
|
const auto fnsz = strlen( functionName );
|
||||||
|
auto& symMap = m_worker.GetSymbolMap();
|
||||||
|
for( auto& sym : symMap )
|
||||||
|
{
|
||||||
|
const auto name = m_worker.GetString( sym.second.name );
|
||||||
|
const auto ptr = strstr( name, functionName );
|
||||||
|
if( ptr &&
|
||||||
|
( ptr[fnsz] == 0 || ptr[fnsz] == '(' || ptr[fnsz] == '<' ) &&
|
||||||
|
( ptr == name || ( ptr[-1] == ' ' || ptr[-1] == ':' ) ) )
|
||||||
|
{
|
||||||
|
if( addr != 0 )
|
||||||
|
{
|
||||||
|
// Ambiguous function name. Bail out.
|
||||||
|
ViewSource( fileName, line );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addr = sym.first;
|
||||||
|
if( sym.second.isInline )
|
||||||
|
{
|
||||||
|
base = m_worker.GetSymbolForAddress( addr );
|
||||||
|
if( base == 0 )
|
||||||
|
{
|
||||||
|
addr = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base = addr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( addr != 0 && base != 0 )
|
||||||
|
{
|
||||||
|
ViewSymbol( fileName, line, base, addr );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ViewSource( fileName, line );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void View::ViewSymbol( const char* fileName, int line, uint64_t baseAddr, uint64_t symAddr )
|
void View::ViewSymbol( const char* fileName, int line, uint64_t baseAddr, uint64_t symAddr )
|
||||||
{
|
{
|
||||||
assert( fileName || symAddr );
|
assert( fileName || symAddr );
|
||||||
|
@ -112,6 +112,7 @@ public:
|
|||||||
|
|
||||||
void NotifyRootWindowSize( float w, float h ) { m_rootWidth = w; m_rootHeight = h; }
|
void NotifyRootWindowSize( float w, float h ) { m_rootWidth = w; m_rootHeight = h; }
|
||||||
void ViewSource( const char* fileName, int line );
|
void ViewSource( const char* fileName, int line );
|
||||||
|
void ViewSource( const char* fileName, int line, const char* functionName );
|
||||||
void ViewSymbol( const char* fileName, int line, uint64_t baseAddr, uint64_t symAddr );
|
void ViewSymbol( const char* fileName, int line, uint64_t baseAddr, uint64_t symAddr );
|
||||||
bool ViewDispatch( const char* fileName, int line, uint64_t symAddr );
|
bool ViewDispatch( const char* fileName, int line, uint64_t symAddr );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user