so that we don't have "fprintf (stderr, ...)" calls sprinkled everywhere.
Changed all needed locations over to using this.
For non-darwin, we log to stderr only. On darwin, we log to stderr _and_
to ASL (Apple System Log facility). This will allow GUI apps to have a place
for these error and warning messages to go, and also allows the command line
apps to log directly to the terminal.
llvm-svn: 147596
void
ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+ // Only report an error once when the module is first detected to be modified
+ // so we don't spam the console with many messages.
+ void
+ ReportErrorIfModifyDetected (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+
+ bool
+ GetModified (bool use_cached_only);
+
+ bool
+ SetModified (bool b);
+
protected:
//------------------------------------------------------------------
// Member Variables
m_did_load_symbol_vendor:1,
m_did_parse_uuid:1,
m_did_init_ast:1,
- m_is_dynamic_loader_module:1;
+ m_is_dynamic_loader_module:1,
+ m_was_modified:1; /// See if the module was modified after it was initially opened.
//------------------------------------------------------------------
/// Resolve a file or load virtual address.
static const char *
GetGroupName (uint32_t gid, std::string &group_name);
-
+
+ enum SystemLogType
+ {
+ eSystemLogWarning,
+ eSystemLogError
+ };
+
+ static void
+ SystemLog (SystemLogType type, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+
+ static void
+ SystemLog (SystemLogType type, const char *format, va_list args);
+
//------------------------------------------------------------------
/// Gets the host architecture.
///
ObjectFile* GetObjectFile() { return m_obj_file; }
const ObjectFile* GetObjectFile() const { return m_obj_file; }
- // Special error functions that can do printf style formatting that will prepend the message with
- // something appropriate for this symbol file (like the architecture, path and object name). This
- // centralizes code so that everyone doesn't need to format their error and log messages on their
- // own and keeps the output a bit more consistent.
- void LogMessage (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
- void ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
- void ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
protected:
ObjectFile* m_obj_file; // The object file that symbols can be extracted from.
uint32_t m_abilities;
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
+#include "lldb/Host/Host.h"
#include "lldb/lldb-private-log.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
m_did_load_symbol_vendor (false),
m_did_parse_uuid (false),
m_did_init_ast (false),
- m_is_dynamic_loader_module (false)
+ m_is_dynamic_loader_module (false),
+ m_was_modified (false)
{
// Scope for locker below...
{
void
Module::ReportError (const char *format, ...)
{
- StreamString module_description;
- GetDescription(&module_description, lldb::eDescriptionLevelBrief);
- ::fprintf (stderr, "error: %s ", module_description.GetString().c_str());
-
- va_list args;
- va_start (args, format);
- vfprintf (stderr, format, args);
- va_end (args);
+ if (format && format[0])
+ {
+ StreamString strm;
+ strm.PutCString("error: ");
+ GetDescription(&strm, lldb::eDescriptionLevelBrief);
+
+ va_list args;
+ va_start (args, format);
+ strm.PrintfVarArg(format, args);
+ va_end (args);
+
+ const int format_len = strlen(format);
+ if (format_len > 0)
+ {
+ const char last_char = format[format_len-1];
+ if (last_char != '\n' || last_char != '\r')
+ strm.EOL();
+ }
+ Host::SystemLog (Host::eSystemLogError, "%s", strm.GetString().c_str());
+
+ }
+}
+
+void
+Module::ReportErrorIfModifyDetected (const char *format, ...)
+{
+ if (!GetModified(true) && GetModified(false))
+ {
+ if (format)
+ {
+ StreamString strm;
+ strm.PutCString("error: the object file ");
+ GetDescription(&strm, lldb::eDescriptionLevelFull);
+ strm.PutCString (" has been modified\n");
+
+ va_list args;
+ va_start (args, format);
+ strm.PrintfVarArg(format, args);
+ va_end (args);
+
+ const int format_len = strlen(format);
+ if (format_len > 0)
+ {
+ const char last_char = format[format_len-1];
+ if (last_char != '\n' || last_char != '\r')
+ strm.EOL();
+ }
+ strm.PutCString("The debug session should be aborted as the original debug information has been overwritten.\n");
+ Host::SystemLog (Host::eSystemLogError, "%s", strm.GetString().c_str());
+ }
+ }
}
void
Module::ReportWarning (const char *format, ...)
{
- StreamString module_description;
- GetDescription(&module_description, lldb::eDescriptionLevelBrief);
- ::fprintf (stderr, "warning: %s ", module_description.GetString().c_str());
-
- va_list args;
- va_start (args, format);
- vfprintf (stderr, format, args);
- va_end (args);
+ if (format && format[0])
+ {
+ StreamString strm;
+ strm.PutCString("warning: ");
+ GetDescription(&strm, lldb::eDescriptionLevelBrief);
+
+ va_list args;
+ va_start (args, format);
+ strm.PrintfVarArg(format, args);
+ va_end (args);
+
+ const int format_len = strlen(format);
+ if (format_len > 0)
+ {
+ const char last_char = format[format_len-1];
+ if (last_char != '\n' || last_char != '\r')
+ strm.EOL();
+ }
+ Host::SystemLog (Host::eSystemLogWarning, "%s", strm.GetString().c_str());
+ }
}
void
}
}
+bool
+Module::GetModified (bool use_cached_only)
+{
+ if (m_was_modified == false && use_cached_only == false)
+ {
+ TimeValue curr_mod_time (m_file.GetModificationTime());
+ m_was_modified = curr_mod_time != m_mod_time;
+ }
+ return m_was_modified;
+}
+
+bool
+Module::SetModified (bool b)
+{
+ const bool prev_value = m_was_modified;
+ m_was_modified = b;
+ return prev_value;
+}
+
+
void
Module::Dump(Stream *s)
{
// Project includes
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
+#include "lldb/Host/Host.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/ObjectFile.h"
char uuid_cstr[256];
const_cast<Module *>(module_ptr)->GetUUID().GetAsCString (uuid_cstr, sizeof(uuid_cstr));
const FileSpec &module_file_spec = module_ptr->GetFileSpec();
- fprintf (stderr, "warning: module not in shared module list: %s (%s) \"%s/%s\"\n",
- uuid_cstr,
- module_ptr->GetArchitecture().GetArchitectureName(),
- module_file_spec.GetDirectory().GetCString(),
- module_file_spec.GetFilename().GetCString());
+ Host::SystemLog (Host::eSystemLogWarning,
+ "warning: module not in shared module list: %s (%s) \"%s/%s\"\n",
+ uuid_cstr,
+ module_ptr->GetArchitecture().GetArchitectureName(),
+ module_file_spec.GetDirectory().GetCString(),
+ module_file_spec.GetFilename().GetCString());
}
}
return module_sp;
return NULL;
}
+
+void
+Host::SystemLog (SystemLogType type, const char *format, va_list args)
+{
+ vfprintf (stderr, format, args);
+}
+
#endif // #if !defined (__APPLE__)
+void
+Host::SystemLog (SystemLogType type, const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ SystemLog (type, format, args);
+ va_end (args);
+}
+
size_t
Host::GetPageSize()
{
#include "lldb/Host/Host.h"
+#include <asl.h>
#include <crt_externs.h>
#include <execinfo.h>
#include <grp.h>
}
return thread;
}
+
+//----------------------------------------------------------------------
+// Log to both stderr and to ASL Logging when running on MacOSX.
+//----------------------------------------------------------------------
+void
+Host::SystemLog (SystemLogType type, const char *format, va_list args)
+{
+ if (format && format[0])
+ {
+ static aslmsg g_aslmsg = NULL;
+ if (g_aslmsg == NULL)
+ {
+ g_aslmsg = ::asl_new (ASL_TYPE_MSG);
+ char asl_key_sender[PATH_MAX];
+ snprintf(asl_key_sender, sizeof(asl_key_sender), "com.apple.LLDB.framework");
+ ::asl_set (g_aslmsg, ASL_KEY_SENDER, asl_key_sender);
+ }
+
+ // Copy the va_list so we can log this message twice
+ va_list copy_args;
+ va_copy (copy_args, args);
+ // Log to stderr
+ ::vfprintf (stderr, format, copy_args);
+ va_end (copy_args);
+
+ int asl_level;
+ switch (type)
+ {
+ default:
+ case eSystemLogError:
+ asl_level = ASL_LEVEL_ERR;
+ break;
+
+ case eSystemLogWarning:
+ asl_level = ASL_LEVEL_WARNING;
+ break;
+ }
+
+ // Log to ASL
+ ::asl_vlog (NULL, g_aslmsg, asl_level, format, args);
+ }
+}
}
else
{
- fprintf (stderr,
- "warning: unable to find and load segment named '%s' at 0x%llx in '%s/%s' in macosx dynamic loader plug-in.\n",
- info.segments[i].name.AsCString("<invalid>"),
- (uint64_t)new_section_load_addr,
- image_object_file->GetFileSpec().GetDirectory().AsCString(),
- image_object_file->GetFileSpec().GetFilename().AsCString());
+ Host::SystemLog (Host::eSystemLogWarning, "warning: unable to find and load segment named '%s' at 0x%llx in '%s/%s' in macosx dynamic loader plug-in.\n",
+ info.segments[i].name.AsCString("<invalid>"),
+ (uint64_t)new_section_load_addr,
+ image_object_file->GetFileSpec().GetDirectory().AsCString(),
+ image_object_file->GetFileSpec().GetFilename().AsCString());
}
}
else
}
else
{
- fprintf (stderr,
- "warning: unable to find and unload segment named '%s' in '%s/%s' in macosx dynamic loader plug-in.\n",
- info.segments[i].name.AsCString("<invalid>"),
- image_object_file->GetFileSpec().GetDirectory().AsCString(),
- image_object_file->GetFileSpec().GetFilename().AsCString());
+ Host::SystemLog (Host::eSystemLogWarning,
+ "warning: unable to find and unload segment named '%s' in '%s/%s' in macosx dynamic loader plug-in.\n",
+ info.segments[i].name.AsCString("<invalid>"),
+ image_object_file->GetFileSpec().GetDirectory().AsCString(),
+ image_object_file->GetFileSpec().GetFilename().AsCString());
}
}
}
}
else
{
- fprintf (stderr,
- "warning: unable to find and load segment named '%s' at 0x%llx in '%s/%s' in macosx dynamic loader plug-in.\n",
- info.segments[i].name.AsCString("<invalid>"),
- (uint64_t)new_section_load_addr,
- image_object_file->GetFileSpec().GetDirectory().AsCString(),
- image_object_file->GetFileSpec().GetFilename().AsCString());
+ Host::SystemLog (Host::eSystemLogWarning,
+ "warning: unable to find and load segment named '%s' at 0x%llx in '%s/%s' in macosx dynamic loader plug-in.\n",
+ info.segments[i].name.AsCString("<invalid>"),
+ (uint64_t)new_section_load_addr,
+ image_object_file->GetFileSpec().GetDirectory().AsCString(),
+ image_object_file->GetFileSpec().GetFilename().AsCString());
}
}
}
}
else
{
- fprintf (stderr,
- "warning: unable to find and unload segment named '%s' in '%s/%s' in macosx dynamic loader plug-in.\n",
- info.segments[i].name.AsCString("<invalid>"),
- image_object_file->GetFileSpec().GetDirectory().AsCString(),
- image_object_file->GetFileSpec().GetFilename().AsCString());
+ Host::SystemLog (Host::eSystemLogWarning,
+ "warning: unable to find and unload segment named '%s' in '%s/%s' in macosx dynamic loader plug-in.\n",
+ info.segments[i].name.AsCString("<invalid>"),
+ image_object_file->GetFileSpec().GetDirectory().AsCString(),
+ image_object_file->GetFileSpec().GetFilename().AsCString());
}
}
}
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBuffer.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/UUID.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/ObjectFile.h"
}
else
{
- fprintf (stderr, "error: unable to find section for section %u\n", n_sect);
+ Host::SystemLog (Host::eSystemLogError, "error: unable to find section for section %u\n", n_sect);
}
}
if (m_section_infos[n_sect].vm_range.Contains(file_addr))
// No symbol should be NULL, even the symbols with no
// string values should have an offset zero which points
// to an empty C-string
- fprintf (stderr,
- "error: symbol[%u] has invalid string table offset 0x%x in %s/%s, ignoring symbol\n",
- nlist_idx,
- nlist.n_strx,
- m_module->GetFileSpec().GetDirectory().GetCString(),
- m_module->GetFileSpec().GetFilename().GetCString());
+ Host::SystemLog (Host::eSystemLogError,
+ "error: symbol[%u] has invalid string table offset 0x%x in %s/%s, ignoring symbol\n",
+ nlist_idx,
+ nlist.n_strx,
+ m_module->GetFileSpec().GetDirectory().GetCString(),
+ m_module->GetFileSpec().GetFilename().GetCString());
continue;
}
const char *symbol_name = &strtab_data[nlist.n_strx];
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
if (log)
{
- m_dwarf2Data->LogMessage (log.get(),
- "DWARFCompileUnit::ExtractDIEsIfNeeded () for compile unit at .debug_info[0x%8.8x]",
- GetOffset());
+ m_dwarf2Data->GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "DWARFCompileUnit::ExtractDIEsIfNeeded () for compile unit at .debug_info[0x%8.8x]",
+ GetOffset());
}
}
// unit header).
if (offset > next_cu_offset)
{
- m_dwarf2Data->ReportWarning ("DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x\n",
- GetOffset(),
- offset);
+ m_dwarf2Data->GetObjectFile()->GetModule()->ReportWarning ("DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x\n",
+ GetOffset(),
+ offset);
}
// Since std::vector objects will double their size, we really need to
if (log)
{
- m_dwarf2Data->LogMessage (log.get(),
- "DWARFCompileUnit::GetFunctionAranges() for compile unit at .debug_info[0x%8.8x]",
- GetOffset());
+ m_dwarf2Data->GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "DWARFCompileUnit::GetFunctionAranges() for compile unit at .debug_info[0x%8.8x]",
+ GetOffset());
}
DIE()->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get());
const bool minimize = false;
if (log)
{
- m_dwarf2Data->LogMessage (log.get(),
- "DWARFCompileUnit::Index() for compile unit at .debug_info[0x%8.8x]",
- GetOffset());
+ m_dwarf2Data->GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "DWARFCompileUnit::Index() for compile unit at .debug_info[0x%8.8x]",
+ GetOffset());
}
DWARFDebugInfoEntry::const_iterator pos;
{
if (specification_die_offset != DW_INVALID_OFFSET)
{
- const DWARFDebugInfoEntry *specification_die
- = m_dwarf2Data->DebugInfo()->GetDIEPtr (specification_die_offset, NULL);
+ const DWARFDebugInfoEntry *specification_die = m_dwarf2Data->DebugInfo()->GetDIEPtr (specification_die_offset, NULL);
if (specification_die)
{
parent = specification_die->GetParent();
#include <algorithm>
+#include "lldb/Core/Module.h"
#include "lldb/Core/Stream.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Symbol/ObjectFile.h"
if (abbrevDecl == NULL)
{
- cu->GetSymbolFileDWARF ()->ReportError ("{0x%8.8x}: invalid abbreviation code %u, please file a bug and attach the file at the start of this error message",
- m_offset,
- (unsigned)abbr_idx);
+ cu->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError ("{0x%8.8x}: invalid abbreviation code %u, please file a bug and attach the file at the start of this error message",
+ m_offset,
+ (unsigned)abbr_idx);
// WE can't parse anymore if the DWARF is borked...
*offset_ptr = UINT32_MAX;
return false;
if (abbrev_decl->Code() == abbrev_code)
return abbrev_decl;
-
- dwarf2Data->ReportError ("0x%8.8x: the DWARF debug info has been modified (abbrev code was %u, and is now %u)",
- GetOffset(),
- (uint32_t)abbrev_decl->Code(),
- (uint32_t)abbrev_code);
+
+ // Only log if we are the one to figure out that the module was modified
+ // which is indicated by SetModified() returning false.
+ dwarf2Data->GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("0x%8.8x: the DWARF debug information has been modified (abbrev code was %u, and is now %u)",
+ GetOffset(),
+ (uint32_t)abbrev_decl->Code(),
+ (uint32_t)abbrev_code);
}
offset = DW_INVALID_OFFSET;
return NULL;
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Timer.h"
+#include "lldb/Host/Host.h"
#include "SymbolFileDWARF.h"
#include "LogChannelDWARF.h"
if (*offset_ptr != end_prologue_offset)
{
- fprintf (stderr, "warning: parsing line table prologue at 0x%8.8x should have ended at 0x%8.8x but it ended ad 0x%8.8x\n",
- prologue_offset, end_prologue_offset, *offset_ptr);
+ Host::SystemLog (Host::eSystemLogWarning,
+ "warning: parsing line table prologue at 0x%8.8x should have ended at 0x%8.8x but it ended ad 0x%8.8x\n",
+ prologue_offset,
+ end_prologue_offset,
+ *offset_ptr);
}
return end_prologue_offset;
}
if (offset != end_prologue_offset)
{
- fprintf (stderr, "warning: parsing line table prologue at 0x%8.8x should have ended at 0x%8.8x but it ended ad 0x%8.8x\n",
- stmt_list, end_prologue_offset, offset);
+ Host::SystemLog (Host::eSystemLogError,
+ "warning: parsing line table prologue at 0x%8.8x should have ended at 0x%8.8x but it ended ad 0x%8.8x\n",
+ stmt_list,
+ end_prologue_offset,
+ offset);
}
return end_prologue_offset;
}
else
{
if (name)
- ReportError ("0x%8.8llx: DW_TAG_member '%s' refers to type 0x%8.8llx which was unable to be parsed",
- MakeUserID(die->GetOffset()),
- name,
- encoding_uid);
+ GetObjectFile()->GetModule()->ReportError ("0x%8.8llx: DW_TAG_member '%s' refers to type 0x%8.8llx which was unable to be parsed",
+ MakeUserID(die->GetOffset()),
+ name,
+ encoding_uid);
else
- ReportError ("0x%8.8llx: DW_TAG_member refers to type 0x%8.8llx which was unable to be parsed",
- MakeUserID(die->GetOffset()),
- encoding_uid);
+ GetObjectFile()->GetModule()->ReportError ("0x%8.8llx: DW_TAG_member refers to type 0x%8.8llx which was unable to be parsed",
+ MakeUserID(die->GetOffset()),
+ encoding_uid);
}
if (prop_name != NULL)
{
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
if (log)
- LogMessage (log.get(), "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s'",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, cu));
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s'",
+ die->GetOffset(),
+ DW_TAG_value_to_name(die->Tag()),
+ die->GetName(this, cu));
// We might be coming in in the middle of a type tree (a class
// withing a class, an enum within a class), so parse any needed
{
// Get the type, which could be a forward declaration
if (log)
- LogMessage (log.get(), "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' resolve parent forward type for 0x%8.8x",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, cu),
- decl_ctx_die->GetOffset());
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' resolve parent forward type for 0x%8.8x",
+ die->GetOffset(),
+ DW_TAG_value_to_name(die->Tag()),
+ die->GetName(this, cu),
+ decl_ctx_die->GetOffset());
Type *parent_type = ResolveTypeUID (cu, decl_ctx_die, assert_not_being_parsed);
if (DW_TAG_is_function_tag(die->Tag()))
{
if (log)
- LogMessage (log.get(), "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' resolve parent full type for 0x%8.8x since die is a function",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, cu),
- decl_ctx_die->GetOffset());
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' resolve parent full type for 0x%8.8x since die is a function",
+ die->GetOffset(),
+ DW_TAG_value_to_name(die->Tag()),
+ die->GetName(this, cu),
+ decl_ctx_die->GetOffset());
// Ask the type to complete itself if it already hasn't since if we
// want a function (method or static) from a class, the class must
// create itself and add it's own methods and class functions.
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
if (log)
- LogMessage (log.get(),
- "0x%8.8llx: %s '%s' resolving forward declaration...\n",
- MakeUserID(die->GetOffset()),
- DW_TAG_value_to_name(tag),
- type->GetName().AsCString());
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "0x%8.8llx: %s '%s' resolving forward declaration...\n",
+ MakeUserID(die->GetOffset()),
+ DW_TAG_value_to_name(tag),
+ type->GetName().AsCString());
assert (clang_type);
DWARFDebugInfoEntry::Attributes attributes;
{
if (m_using_apple_tables)
{
- ReportError (".apple_objc accelerator table had bad die 0x%8.8x for '%s'\n",
- die_offset, class_str.c_str());
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_objc accelerator table had bad die 0x%8.8x for '%s')\n",
+ die_offset, class_str.c_str());
}
}
}
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
if (log)
- LogMessage(log.get(), "Valid namespace does not match symbol file");
+ GetObjectFile()->GetModule()->LogMessage(log.get(), "Valid namespace does not match symbol file");
return false;
}
if (decl_ctx_die->Tag() != DW_TAG_namespace)
{
if (log)
- LogMessage(log.get(), "Found a match, but its parent is not a namespace");
+ GetObjectFile()->GetModule()->LogMessage(log.get(), "Found a match, but its parent is not a namespace");
return false;
}
if (pos == m_decl_ctx_to_die.end())
{
if (log)
- LogMessage(log.get(), "Found a match in a namespace, but its parent is not the requested namespace");
+ GetObjectFile()->GetModule()->LogMessage(log.get(), "Found a match in a namespace, but its parent is not the requested namespace");
return false;
}
}
if (log)
- LogMessage(log.get(), "Found a match, but its parent doesn't exist");
+ GetObjectFile()->GetModule()->LogMessage(log.get(), "Found a match, but its parent doesn't exist");
return false;
}
if (log)
{
- LogMessage (log.get(),
- "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", namespace_decl=%p, append=%u, max_matches=%u, variables)",
- name.GetCString(),
- namespace_decl,
- append,
- max_matches);
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", namespace_decl=%p, append=%u, max_matches=%u, variables)",
+ name.GetCString(),
+ namespace_decl,
+ append,
+ max_matches);
}
if (!NamespaceDeclMatchesThisSymbolFile(namespace_decl))
{
if (m_using_apple_tables)
{
- ReportError (".apple_names accelerator table had bad die 0x%8.8x for '%s'\n",
- die_offset, name.GetCString());
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')\n",
+ die_offset, name.GetCString());
}
}
}
if (log)
{
- LogMessage (log.get(),
- "SymbolFileDWARF::FindGlobalVariables (regex=\"%s\", append=%u, max_matches=%u, variables)",
- regex.GetText(),
- append,
- max_matches);
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF::FindGlobalVariables (regex=\"%s\", append=%u, max_matches=%u, variables)",
+ regex.GetText(),
+ append,
+ max_matches);
}
DWARFDebugInfo* info = DebugInfo();
{
if (m_using_apple_tables)
{
- ReportError (".apple_names accelerator table had bad die 0x%8.8x for regex '%s'\n",
- die_offset, regex.GetText());
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for regex '%s')\n",
+ die_offset, regex.GetText());
}
}
}
if (log)
{
- LogMessage (log.get(),
- "SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, append=%u, sc_list)",
- name.GetCString(),
- name_type_mask,
- append);
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, append=%u, sc_list)",
+ name.GetCString(),
+ name_type_mask,
+ append);
}
// If we aren't appending the results to this list, then clear the list
}
else
{
- ReportError (".apple_names accelerator table had bad die 0x%8.8x for '%s'\n",
- die_offset, name_cstr);
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')",
+ die_offset, name_cstr);
}
}
}
}
else
{
- ReportError (".apple_names accelerator table had bad die 0x%8.8x for '%s'\n",
- die_offset, name_cstr);
+ GetObjectFile()->GetModule()->ReportError ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')",
+ die_offset, name_cstr);
}
}
die_offsets.clear();
}
else
{
- ReportError (".apple_names accelerator table had bad die 0x%8.8x for '%s'\n",
- die_offset, name_cstr);
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')",
+ die_offset, name_cstr);
}
}
die_offsets.clear();
if (log)
{
- LogMessage (log.get(),
- "SymbolFileDWARF::FindFunctions (regex=\"%s\", append=%u, sc_list)",
- regex.GetText(),
- append);
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF::FindFunctions (regex=\"%s\", append=%u, sc_list)",
+ regex.GetText(),
+ append);
}
if (log)
{
- LogMessage (log.get(),
- "SymbolFileDWARF::FindTypes (sc, name=\"%s\", append=%u, max_matches=%u, type_list)",
- name.GetCString(),
- append,
- max_matches);
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF::FindTypes (sc, name=\"%s\", append=%u, max_matches=%u, type_list)",
+ name.GetCString(),
+ append,
+ max_matches);
}
// If we aren't appending the results to this list, then clear the list
{
if (m_using_apple_tables)
{
- ReportError (".apple_types accelerator table had bad die 0x%8.8x for '%s'\n",
- die_offset, name.GetCString());
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_types accelerator table had bad die 0x%8.8x for '%s')\n",
+ die_offset, name.GetCString());
}
}
if (log)
{
- LogMessage (log.get(),
- "SymbolFileDWARF::FindNamespace (sc, name=\"%s\")",
- name.GetCString());
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF::FindNamespace (sc, name=\"%s\")",
+ name.GetCString());
}
if (!NamespaceDeclMatchesThisSymbolFile(parent_namespace_decl))
{
if (m_using_apple_tables)
{
- ReportError (".apple_namespaces accelerator table had bad die 0x%8.8x for '%s'\n",
- die_offset, name.GetCString());
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_namespaces accelerator table had bad die 0x%8.8x for '%s')\n",
+ die_offset, name.GetCString());
}
}
{
if (namespace_name)
{
- LogMessage (log.get(),
- "ASTContext => %p: 0x%8.8llx: DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl *%p (original = %p)",
- GetClangASTContext().getASTContext(),
- MakeUserID(die->GetOffset()),
- namespace_name,
- namespace_decl,
- namespace_decl->getOriginalNamespace());
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "ASTContext => %p: 0x%8.8llx: DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl *%p (original = %p)",
+ GetClangASTContext().getASTContext(),
+ MakeUserID(die->GetOffset()),
+ namespace_name,
+ namespace_decl,
+ namespace_decl->getOriginalNamespace());
}
else
{
- LogMessage (log.get(),
- "ASTContext => %p: 0x%8.8llx: DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p (original = %p)",
- GetClangASTContext().getASTContext(),
- MakeUserID(die->GetOffset()),
- namespace_decl,
- namespace_decl->getOriginalNamespace());
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "ASTContext => %p: 0x%8.8llx: DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p (original = %p)",
+ GetClangASTContext().getASTContext(),
+ MakeUserID(die->GetOffset()),
+ namespace_decl,
+ namespace_decl->getOriginalNamespace());
}
}
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
if (log)
- LogMessage(log.get(), "SymbolFileDWARF::GetClangDeclContextForDIE (die = 0x%8.8x) %s '%s'", die->GetOffset(), DW_TAG_value_to_name(die->Tag()), die->GetName(this, cu));
+ GetObjectFile()->GetModule()->LogMessage(log.get(), "SymbolFileDWARF::GetClangDeclContextForDIE (die = 0x%8.8x) %s '%s'", die->GetOffset(), DW_TAG_value_to_name(die->Tag()), die->GetName(this, cu));
// This is the DIE we want. Parse it, then query our map.
bool assert_not_being_parsed = true;
ResolveTypeUID (cu, die, assert_not_being_parsed);
{
if (m_using_apple_tables)
{
- ReportError (".apple_types accelerator table had bad die 0x%8.8x for '%s'\n",
- die_offset, type_name.GetCString());
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_types accelerator table had bad die 0x%8.8x for '%s')\n",
+ die_offset, type_name.GetCString());
}
}
{
if (m_using_apple_tables)
{
- ReportError (".apple_types accelerator table had bad die 0x%8.8x for '%s'\n",
- die_offset, type_name.GetCString());
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_types accelerator table had bad die 0x%8.8x for '%s')\n",
+ die_offset, type_name.GetCString());
}
}
{
LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
if (log)
- LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s'",
+ GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s'",
die->GetOffset(),
DW_TAG_value_to_name(die->Tag()),
die->GetName(this, dwarf_cu));
// {
// StreamString s;
// die->DumpLocation (this, dwarf_cu, s);
-// LogMessage (log.get(), "SymbolFileDwarf::%s %s", __FUNCTION__, s.GetData());
+// GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDwarf::%s %s", __FUNCTION__, s.GetData());
//
// }
{
if (log)
{
- LogMessage (log.get(),
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an incomplete objc type, complete type is 0x%8.8llx",
- this,
- die->GetOffset(),
- DW_TAG_value_to_name(tag),
- type_name_cstr,
- type_sp->GetID());
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an incomplete objc type, complete type is 0x%8.8llx",
+ this,
+ die->GetOffset(),
+ DW_TAG_value_to_name(tag),
+ type_name_cstr,
+ type_sp->GetID());
}
// We found a real definition for this type elsewhere
// DWARF. If this fails, we need to look elsewhere...
if (log)
{
- LogMessage (log.get(),
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, trying to find complete type",
- this,
- die->GetOffset(),
- DW_TAG_value_to_name(tag),
- type_name_cstr);
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, trying to find complete type",
+ this,
+ die->GetOffset(),
+ DW_TAG_value_to_name(tag),
+ type_name_cstr);
}
type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
{
if (log)
{
- LogMessage (log.get(),
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, complete type is 0x%8.8llx",
- this,
- die->GetOffset(),
- DW_TAG_value_to_name(tag),
- type_name_cstr,
- type_sp->GetID());
+ GetObjectFile()->GetModule()->LogMessage (log.get(),
+ "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, complete type is 0x%8.8llx",
+ this,
+ die->GetOffset(),
+ DW_TAG_value_to_name(tag),
+ type_name_cstr,
+ type_sp->GetID());
}
// We found a real definition for this type elsewhere
}
else
{
- ReportWarning ("0x%8.8llx: DW_AT_specification(0x%8.8x) has no decl\n",
- MakeUserID(die->GetOffset()),
- specification_die_offset);
+ GetObjectFile()->GetModule()->ReportWarning ("0x%8.8llx: DW_AT_specification(0x%8.8x) has no decl\n",
+ MakeUserID(die->GetOffset()),
+ specification_die_offset);
}
type_handled = true;
}
}
else
{
- ReportWarning ("0x%8.8llx: DW_AT_abstract_origin(0x%8.8x) has no decl\n",
- MakeUserID(die->GetOffset()),
- abstract_origin_die_offset);
+ GetObjectFile()->GetModule()->ReportWarning ("0x%8.8llx: DW_AT_abstract_origin(0x%8.8x) has no decl\n",
+ MakeUserID(die->GetOffset()),
+ abstract_origin_die_offset);
}
type_handled = true;
}
const DWARFDebugInfoEntry *function_die = dwarf_cu->GetDIEPtr(sc.function->GetID());
dw_addr_t func_lo_pc = function_die->GetAttributeValueAsUnsigned (this, dwarf_cu, DW_AT_low_pc, DW_INVALID_ADDRESS);
- assert (func_lo_pc != DW_INVALID_ADDRESS);
-
- const size_t num_variables = ParseVariables(sc, dwarf_cu, func_lo_pc, function_die->GetFirstChild(), true, true);
+ if (func_lo_pc != DW_INVALID_ADDRESS)
+ {
+ const size_t num_variables = ParseVariables(sc, dwarf_cu, func_lo_pc, function_die->GetFirstChild(), true, true);
- // Let all blocks know they have parse all their variables
- sc.function->GetBlock (false).SetDidParseVariables (true, true);
-
- return num_variables;
+ // Let all blocks know they have parse all their variables
+ sc.function->GetBlock (false).SetDidParseVariables (true, true);
+ return num_variables;
+ }
}
else if (sc.comp_unit)
{
{
if (m_using_apple_tables)
{
- ReportError (".apple_names accelerator table had bad die 0x%8.8x\n", die_offset);
+ GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x)\n", die_offset);
}
}
{
StreamString strm;
location.DumpLocationForAddress (&strm, eDescriptionLevelFull, 0, 0, NULL);
- ReportError ("0x%8.8x: %s has an invalid location: %s", die->GetOffset(), DW_TAG_value_to_name(die->Tag()), strm.GetString().c_str());
+ GetObjectFile()->GetModule()->ReportError ("0x%8.8x: %s has an invalid location: %s", die->GetOffset(), DW_TAG_value_to_name(die->Tag()), strm.GetString().c_str());
}
}
}
else
{
- ReportError ("parent 0x%8.8llx %s with no valid compile unit in symbol context for 0x%8.8llx %s.\n",
- MakeUserID(sc_parent_die->GetOffset()),
- DW_TAG_value_to_name (parent_tag),
- MakeUserID(orig_die->GetOffset()),
- DW_TAG_value_to_name (orig_die->Tag()));
+ GetObjectFile()->GetModule()->ReportError ("parent 0x%8.8llx %s with no valid compile unit in symbol context for 0x%8.8llx %s.\n",
+ MakeUserID(sc_parent_die->GetOffset()),
+ DW_TAG_value_to_name (parent_tag),
+ MakeUserID(orig_die->GetOffset()),
+ DW_TAG_value_to_name (orig_die->Tag()));
}
break;
break;
default:
- ReportError ("didn't find appropriate parent DIE for variable list for 0x%8.8llx %s.\n",
- MakeUserID(orig_die->GetOffset()),
- DW_TAG_value_to_name (orig_die->Tag()));
+ GetObjectFile()->GetModule()->ReportError ("didn't find appropriate parent DIE for variable list for 0x%8.8llx %s.\n",
+ MakeUserID(orig_die->GetOffset()),
+ DW_TAG_value_to_name (orig_die->Tag()));
break;
}
}
// to fix any issues we run into.
if (type_name)
{
- fprintf (stderr, "error: need to add support for DW_TAG_base_type '%s' encoded with DW_ATE = 0x%x, bit_size = %u\n", type_name, dw_ate, bit_size);
+ Host::SystemLog (Host::eSystemLogError, "error: need to add support for DW_TAG_base_type '%s' encoded with DW_ATE = 0x%x, bit_size = %u\n", type_name, dw_ate, bit_size);
}
else
{
- fprintf (stderr, "error: need to add support for DW_TAG_base_type encoded with DW_ATE = 0x%x, bit_size = %u\n", dw_ate, bit_size);
+ Host::SystemLog (Host::eSystemLogError, "error: need to add support for DW_TAG_base_type encoded with DW_ATE = 0x%x, bit_size = %u\n", dw_ate, bit_size);
}
return NULL;
}
#include "lldb/Core/Log.h"
#include "lldb/Core/Section.h"
-#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/RegisterContext.h"
-#include "lldb/Core/Section.h"
#include "lldb/Target/Thread.h"
-#include "lldb/Symbol/UnwindPlan.h"
using namespace lldb;
using namespace lldb_private;
if (i == CFI_AUG_MAX_SIZE && cie_sp->augmentation[CFI_AUG_MAX_SIZE-1] != '\0')
{
- fprintf(stderr, "CIE parse error: CIE augmentation string was too large for the fixed sized buffer of %d bytes.\n", CFI_AUG_MAX_SIZE);
+ Host::SystemLog (Host::eSystemLogError, "CIE parse error: CIE augmentation string was too large for the fixed sized buffer of %d bytes.\n", CFI_AUG_MAX_SIZE);
return cie_sp;
}
cie_sp->code_align = (uint32_t)m_cfi_data.GetULEB128(&offset);
}
else
{
- fprintf (stderr,
- "error: unable to find CIE at 0x%8.8x for cie_id = 0x%8.8x for entry at 0x%8.8x.\n",
- cie_offset,
- cie_id,
- current_entry);
+ Host::SystemLog (Host::eSystemLogError,
+ "error: unable to find CIE at 0x%8.8x for cie_id = 0x%8.8x for entry at 0x%8.8x.\n",
+ cie_offset,
+ cie_id,
+ current_entry);
}
offset = next_entry;
}
#include "lldb/Symbol/Function.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
+#include "lldb/Host/Host.h"
#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
}
else
{
- ::fprintf (stderr,
- "unable to find module shared pointer for function '%s' in %s%s%s\n",
- GetName().GetCString(),
- m_comp_unit->GetDirectory().GetCString(),
- m_comp_unit->GetDirectory() ? "/" : "",
- m_comp_unit->GetFilename().GetCString());
+ Host::SystemLog (Host::eSystemLogError,
+ "error: unable to find module shared pointer for function '%s' in %s%s%s\n",
+ GetName().GetCString(),
+ m_comp_unit->GetDirectory().GetCString(),
+ m_comp_unit->GetDirectory() ? "/" : "",
+ m_comp_unit->GetFilename().GetCString());
}
m_block.SetBlockInfoHasBeenParsed (true, true);
}
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
+#include "lldb/Host/Host.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/ObjectFile.h"
}
if (objfile)
{
- fprintf (stderr, "warning: inlined block 0x%8.8llx doesn't have a range that contains file address 0x%llx in %s/%s\n",
- curr_inlined_block->GetID(),
- curr_frame_pc.GetFileAddress(),
- objfile->GetFileSpec().GetDirectory().GetCString(),
- objfile->GetFileSpec().GetFilename().GetCString());
+ Host::SystemLog (Host::eSystemLogWarning,
+ "warning: inlined block 0x%8.8llx doesn't have a range that contains file address 0x%llx in %s/%s\n",
+ curr_inlined_block->GetID(),
+ curr_frame_pc.GetFileAddress(),
+ objfile->GetFileSpec().GetDirectory().GetCString(),
+ objfile->GetFileSpec().GetFilename().GetCString());
}
else
{
- fprintf (stderr, "warning: inlined block 0x%8.8llx doesn't have a range that contains file address 0x%llx\n",
- curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress());
+ Host::SystemLog (Host::eSystemLogWarning,
+ "warning: inlined block 0x%8.8llx doesn't have a range that contains file address 0x%llx\n",
+ curr_inlined_block->GetID(),
+ curr_frame_pc.GetFileAddress());
}
}
#endif
{
return m_obj_file->GetModule()->GetClangASTContext();
}
-
-
-void
-SymbolFile::ReportError (const char *format, ...)
-{
- StreamString module_description;
- m_obj_file->GetModule()->GetDescription (&module_description, lldb::eDescriptionLevelBrief);
- ::fprintf (stderr, "error: %s ", module_description.GetString().c_str());
-
- va_list args;
- va_start (args, format);
- vfprintf (stderr, format, args);
- va_end (args);
-}
-
-void
-SymbolFile::ReportWarning (const char *format, ...)
-{
- StreamString module_description;
- m_obj_file->GetModule()->GetDescription (&module_description, lldb::eDescriptionLevelBrief);
- ::fprintf (stderr, "warning: %s ", module_description.GetString().c_str());
-
- va_list args;
- va_start (args, format);
- vfprintf (stderr, format, args);
- va_end (args);
-}
-
-void
-SymbolFile::LogMessage (Log *log, const char *format, ...)
-{
- if (log)
- {
- StreamString log_message;
- m_obj_file->GetModule()->GetDescription (&log_message, lldb::eDescriptionLevelBrief);
- log_message.PutChar(' ');
- va_list args;
- va_start (args, format);
- log_message.PrintfVarArg (format, args);
- va_end (args);
- log->PutCString (log_message.GetString().c_str());
- }
-}