Added a new logging channel to the DWARF called "lookups":

(lldb) log enable dwarf lookups

This allows us to see when lookups are being done on functions, addresses,
and types by both name and regular expresssion.

llvm-svn: 141259
This commit is contained in:
Greg Clayton 2011-10-06 00:09:08 +00:00
parent 6e429a16fd
commit 21f2a4919b
8 changed files with 94 additions and 26 deletions

View File

@ -24,6 +24,7 @@
#include "NameToDIE.h"
#include "SymbolFileDWARF.h"
using namespace lldb;
using namespace lldb_private;
using namespace std;
@ -353,7 +354,7 @@ DWARFCompileUnit::GetFunctionAranges ()
if (m_func_aranges_ap.get() == NULL)
{
m_func_aranges_ap.reset (new DWARFDebugAranges());
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES);
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
if (log)
log->Printf ("DWARFCompileUnit::GetFunctionAranges() for \"%s/%s\" compile unit at 0x%8.8x",

View File

@ -23,6 +23,7 @@
#include "DWARFDebugInfo.h"
#include "DWARFCompileUnit.h"
using namespace lldb;
using namespace lldb_private;
//----------------------------------------------------------------------
@ -261,12 +262,12 @@ DWARFDebugAranges::Sort (bool minimize, uint32_t n)
Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p",
__PRETTY_FUNCTION__, this);
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES);
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
const size_t orig_arange_size = m_aranges.size();
if (log)
{
log->Printf ("DWARFDebugAranges::Sort(minimize = %u, n = %u) with %zu entries", minimize, n, orig_arange_size);
Dump (log);
Dump (log.get());
}
// Size of one? If so, no sorting is needed
@ -331,7 +332,7 @@ DWARFDebugAranges::Sort (bool minimize, uint32_t n)
size_t delta = orig_arange_size - m_aranges.size();
log->Printf ("DWARFDebugAranges::Sort() %zu entries after minimizing (%zu entries combined for %zu bytes saved)",
m_aranges.size(), delta, delta * sizeof(Range));
Dump (log);
Dump (log.get());
}
}

View File

@ -24,6 +24,7 @@
#include "DWARFFormValue.h"
#include "LogChannelDWARF.h"
using namespace lldb;
using namespace lldb_private;
using namespace std;
@ -53,7 +54,7 @@ DWARFDebugInfo::GetCompileUnitAranges ()
{
if (m_cu_aranges_ap.get() == NULL && m_dwarf2Data)
{
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES);
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
m_cu_aranges_ap.reset (new DWARFDebugAranges());
const DataExtractor &debug_aranges_data = m_dwarf2Data->get_debug_aranges_data();

View File

@ -19,6 +19,7 @@
#include "SymbolFileDWARF.h"
#include "LogChannelDWARF.h"
using namespace lldb;
using namespace lldb_private;
using namespace std;
@ -560,7 +561,7 @@ DWARFDebugLine::ParseStatementTable
void* userData
)
{
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_LINE);
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_LINE));
Prologue::shared_ptr prologue(new Prologue());
@ -580,11 +581,11 @@ DWARFDebugLine::ParseStatementTable
}
if (log)
prologue->Dump (log);
prologue->Dump (log.get());
const dw_offset_t end_offset = debug_line_offset + prologue->total_length + sizeof(prologue->total_length);
State state(prologue, log, callback, userData);
State state(prologue, log.get(), callback, userData);
while (*offset_ptr < end_offset)
{

View File

@ -20,6 +20,7 @@
#include "SymbolFileDWARF.h"
using namespace lldb;
using namespace lldb_private;
DWARFDebugPubnames::DWARFDebugPubnames() :
@ -33,7 +34,7 @@ DWARFDebugPubnames::Extract(const DataExtractor& data)
Timer scoped_timer (__PRETTY_FUNCTION__,
"DWARFDebugPubnames::Extract (byte_size = %zu)",
data.GetByteSize());
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES);
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES));
if (log)
log->Printf("DWARFDebugPubnames::Extract (byte_size = %zu)", data.GetByteSize());
@ -53,7 +54,7 @@ DWARFDebugPubnames::Extract(const DataExtractor& data)
break;
}
if (log)
Dump (log);
Dump (log.get());
return true;
}
return false;
@ -67,7 +68,7 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
"DWARFDebugPubnames::GeneratePubnames (data = %p)",
dwarf2Data);
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES);
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES));
if (log)
log->Printf("DWARFDebugPubnames::GeneratePubnames (data = %p)", dwarf2Data);
@ -207,7 +208,7 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
if (m_sets.empty())
return false;
if (log)
Dump (log);
Dump (log.get());
return true;
}

View File

@ -109,6 +109,7 @@ LogChannelDWARF::Disable (Args &categories, Stream *feedback_strm)
else if (::strcasecmp (arg, "pubnames") == 0 ) flag_bits &= ~DWARF_LOG_DEBUG_PUBNAMES;
else if (::strcasecmp (arg, "pubtypes") == 0 ) flag_bits &= ~DWARF_LOG_DEBUG_PUBTYPES;
else if (::strcasecmp (arg, "aranges") == 0 ) flag_bits &= ~DWARF_LOG_DEBUG_ARANGES;
else if (::strcasecmp (arg, "lookups") == 0 ) flag_bits &= ~DWARF_LOG_LOOKUPS;
else if (::strcasecmp (arg, "default") == 0 ) flag_bits &= ~DWARF_LOG_DEFAULT;
else
{
@ -151,6 +152,7 @@ LogChannelDWARF::Enable
else if (::strcasecmp (arg, "pubnames") == 0 ) flag_bits |= DWARF_LOG_DEBUG_PUBNAMES;
else if (::strcasecmp (arg, "pubtypes") == 0 ) flag_bits |= DWARF_LOG_DEBUG_PUBTYPES;
else if (::strcasecmp (arg, "aranges") == 0 ) flag_bits |= DWARF_LOG_DEBUG_ARANGES;
else if (::strcasecmp (arg, "lookups") == 0 ) flag_bits |= DWARF_LOG_LOOKUPS;
else if (::strcasecmp (arg, "default") == 0 ) flag_bits |= DWARF_LOG_DEFAULT;
else
{
@ -177,29 +179,29 @@ LogChannelDWARF::ListCategories (Stream *strm)
" info - log the parsing if .debug_info\n"
" line - log the parsing if .debug_line\n"
" pubnames - log the parsing if .debug_pubnames\n"
" pubtypes - log the parsing if .debug_pubtypes\n\n",
" pubtypes - log the parsing if .debug_pubtypes\n"
" lookups - log any lookups that happen by name, regex, or address\n\n",
SymbolFileDWARF::GetPluginNameStatic());
}
Log *
LogSP
LogChannelDWARF::GetLog ()
{
if (g_log_channel)
return g_log_channel->m_log_sp.get();
else
return NULL;
return g_log_channel->m_log_sp;
return LogSP();
}
Log *
LogSP
LogChannelDWARF::GetLogIfAll (uint32_t mask)
{
Log *log = GetLog();
if (log)
if (g_log_channel && g_log_channel->m_log_sp)
{
if (log->GetMask().AllSet(mask))
return log;
if (g_log_channel->m_log_sp->GetMask().AllSet(mask))
return g_log_channel->m_log_sp;
}
return NULL;
return LogSP();
}

View File

@ -23,6 +23,7 @@
#define DWARF_LOG_DEBUG_PUBNAMES (1u << 3)
#define DWARF_LOG_DEBUG_PUBTYPES (1u << 4)
#define DWARF_LOG_DEBUG_ARANGES (1u << 5)
#define DWARF_LOG_LOOKUPS (1u << 6)
#define DWARF_LOG_ALL (UINT32_MAX)
#define DWARF_LOG_DEFAULT (DWARF_LOG_DEBUG_INFO)
@ -73,10 +74,10 @@ public:
virtual void
ListCategories (lldb_private::Stream *strm);
static lldb_private::Log *
static lldb::LogSP
GetLog ();
static lldb_private::Log *
static lldb::LogSP
GetLogIfAll (uint32_t mask);
static void

View File

@ -1943,6 +1943,15 @@ SymbolFileDWARF::Index ()
uint32_t
SymbolFileDWARF::FindGlobalVariables (const ConstString &name, bool append, uint32_t max_matches, VariableList& variables)
{
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
if (log)
{
log->Printf ("SymbolFileDWARF::FindGlobalVariables (file=\"%s/%s\", name=\"%s\", append=%u, max_matches=%u, variables)",
m_obj_file->GetFileSpec().GetDirectory().GetCString(),
m_obj_file->GetFileSpec().GetFilename().GetCString(),
name.GetCString(), append, max_matches);
}
DWARFDebugInfo* info = DebugInfo();
if (info == NULL)
return 0;
@ -2007,6 +2016,16 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, bool append, uint
uint32_t
SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables)
{
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
if (log)
{
log->Printf ("SymbolFileDWARF::FindGlobalVariables (file=\"%s/%s\", regex=\"%s\", append=%u, max_matches=%u, variables)",
m_obj_file->GetFileSpec().GetDirectory().GetCString(),
m_obj_file->GetFileSpec().GetFilename().GetCString(),
regex.GetText(), append, max_matches);
}
DWARFDebugInfo* info = DebugInfo();
if (info == NULL)
return 0;
@ -2267,6 +2286,16 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
"SymbolFileDWARF::FindFunctions (name = '%s')",
name.AsCString());
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
if (log)
{
log->Printf ("SymbolFileDWARF::FindFunctions (file=\"%s/%s\", name=\"%s\", name_type_mask=0x%x, append=%u, sc_list)",
m_obj_file->GetFileSpec().GetDirectory().GetCString(),
m_obj_file->GetFileSpec().GetFilename().GetCString(),
name.GetCString(), name_type_mask, append);
}
// If we aren't appending the results to this list, then clear the list
if (!append)
sc_list.Clear();
@ -2315,6 +2344,17 @@ SymbolFileDWARF::FindFunctions(const RegularExpression& regex, bool append, Symb
"SymbolFileDWARF::FindFunctions (regex = '%s')",
regex.GetText());
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
if (log)
{
log->Printf ("SymbolFileDWARF::FindFunctions (file=\"%s/%s\", regex=\"%s\"append=%u, sc_list)",
m_obj_file->GetFileSpec().GetDirectory().GetCString(),
m_obj_file->GetFileSpec().GetFilename().GetCString(),
regex.GetText(), append);
}
// If we aren't appending the results to this list, then clear the list
if (!append)
sc_list.Clear();
@ -2383,6 +2423,16 @@ SymbolFileDWARF::FindTypes(const SymbolContext& sc, const ConstString &name, boo
if (info == NULL)
return 0;
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
if (log)
{
log->Printf ("SymbolFileDWARF::FindFunctions (file=\"%s/%s\", sc, name=\"%s\", append=%u, max_matches=%u, type_list)",
m_obj_file->GetFileSpec().GetDirectory().GetCString(),
m_obj_file->GetFileSpec().GetFilename().GetCString(),
name.GetCString(), append, max_matches);
}
// If we aren't appending the results to this list, then clear the list
if (!append)
types.Clear();
@ -2447,6 +2497,16 @@ ClangNamespaceDecl
SymbolFileDWARF::FindNamespace (const SymbolContext& sc,
const ConstString &name)
{
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
if (log)
{
log->Printf ("SymbolFileDWARF::FindNamespace (file=\"%s/%s\", sc, name=\"%s\")",
m_obj_file->GetFileSpec().GetDirectory().GetCString(),
m_obj_file->GetFileSpec().GetFilename().GetCString(),
name.GetCString());
}
ClangNamespaceDecl namespace_decl;
DWARFDebugInfo* info = DebugInfo();
if (info)
@ -3206,7 +3266,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
AccessType accessibility = eAccessNone;
if (die != NULL)
{
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
if (log && dwarf_cu)
{
StreamString s;