Added the ability to log a message with a backtrace when verbose logging is enabled to the Module class. Used this new function in the DWARF parser.

llvm-svn: 155404
This commit is contained in:
Greg Clayton 2012-04-23 22:55:20 +00:00
parent 7fd160700f
commit d61c0fc049
4 changed files with 29 additions and 15 deletions

View File

@ -1016,6 +1016,9 @@ public:
void
LogMessage (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
void
LogMessageVerboseBacktrace (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
void
ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3)));

View File

@ -879,6 +879,24 @@ Module::LogMessage (Log *log, const char *format, ...)
}
}
void
Module::LogMessageVerboseBacktrace (Log *log, const char *format, ...)
{
if (log)
{
StreamString log_message;
GetDescription(&log_message, lldb::eDescriptionLevelFull);
log_message.PutCString (": ");
va_list args;
va_start (args, format);
log_message.PrintfVarArg (format, args);
va_end (args);
if (log->GetVerbose())
Host::Backtrace (log_message, 1024);
log->PutCString(log_message.GetString().c_str());
}
}
bool
Module::GetModified (bool use_cached_only)
{

View File

@ -172,9 +172,9 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only)
LogSP log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO | DWARF_LOG_LOOKUPS));
if (log)
{
m_dwarf2Data->GetObjectFile()->GetModule()->LogMessage (log.get(),
"DWARFCompileUnit::ExtractDIEsIfNeeded () for compile unit at .debug_info[0x%8.8x]",
GetOffset());
m_dwarf2Data->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log.get(),
"DWARFCompileUnit::ExtractDIEsIfNeeded () for compile unit at .debug_info[0x%8.8x]",
GetOffset());
}
}

View File

@ -1995,19 +1995,12 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type
LogSP log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
if (log)
{
GetObjectFile()->GetModule()->LogMessage (log.get(),
"0x%8.8llx: %s '%s' resolving forward declaration...",
MakeUserID(die->GetOffset()),
DW_TAG_value_to_name(tag),
type->GetName().AsCString());
GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log.get(),
"0x%8.8llx: %s '%s' resolving forward declaration...",
MakeUserID(die->GetOffset()),
DW_TAG_value_to_name(tag),
type->GetName().AsCString());
if (log->GetVerbose())
{
StreamString strm;
Host::Backtrace (strm, 1024);
if (strm.GetData())
log->PutCString(strm.GetData());
}
}
assert (clang_type);
DWARFDebugInfoEntry::Attributes attributes;