From e1b68aded6003d6915b68fca7c7e2417467108af Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Wed, 5 Dec 2012 00:25:49 +0000 Subject: [PATCH] Add an LLDB_LOG_TARGET logging channel (log eanble lldb target). Update the Target methods which can change the target log to this channel. llvm-svn: 169342 --- lldb/include/lldb/lldb-private-log.h | 2 ++ lldb/source/Target/Target.cpp | 19 ++++++++++++++++++- lldb/source/lldb-log.cpp | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lldb/include/lldb/lldb-private-log.h b/lldb/include/lldb/lldb-private-log.h index 907a25f..7c5bbdf 100644 --- a/lldb/include/lldb/lldb-private-log.h +++ b/lldb/include/lldb/lldb-private-log.h @@ -41,6 +41,7 @@ #define LIBLLDB_LOG_TYPES (1u << 19) #define LIBLLDB_LOG_SYMBOLS (1u << 20) #define LIBLLDB_LOG_MODULES (1u << 21) +#define LIBLLDB_LOG_TARGET (1u << 22) #define LIBLLDB_LOG_ALL (UINT32_MAX) #define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\ LIBLLDB_LOG_THREAD |\ @@ -50,6 +51,7 @@ LIBLLDB_LOG_STEP |\ LIBLLDB_LOG_STATE |\ LIBLLDB_LOG_SYMBOLS |\ + LIBLLDB_LOG_TARGET |\ LIBLLDB_LOG_COMMANDS) namespace lldb_private { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index f614af1..78047bd 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -94,6 +94,11 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::Plat LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) log->Printf ("%p Target::Target()", this); + if (m_arch.IsValid()) + { + LogSP log_target(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET)); + log_target->Printf("Target::Target created with architecture %s (%s)", m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str()); + } } //---------------------------------------------------------------------- @@ -978,6 +983,7 @@ LoadScriptingResourceForModule (const ModuleSP &module_sp, Target *target) void Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files) { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET)); m_images.Clear(); m_scratch_ast_context_ap.reset(); m_scratch_ast_source_ap.reset(); @@ -994,8 +1000,12 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files) // If we haven't set an architecture yet, reset our architecture based on what we found in the executable module. if (!m_arch.IsValid()) + { m_arch = executable_sp->GetArchitecture(); - + if (log) + log->Printf ("Target::SetExecutableModule setting architecture to %s (%s) based on executable file", m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str()); + } + FileSpecList dependent_files; ObjectFile *executable_objfile = executable_sp->GetObjectFile(); @@ -1028,6 +1038,7 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files) bool Target::SetArchitecture (const ArchSpec &arch_spec) { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET)); if (m_arch == arch_spec || !m_arch.IsValid()) { // If we haven't got a valid arch spec, or the architectures are @@ -1035,11 +1046,15 @@ Target::SetArchitecture (const ArchSpec &arch_spec) // equal, yet the triple OS and vendor might change, so we need to do // the assignment here just in case. m_arch = arch_spec; + if (log) + log->Printf ("Target::SetArchitecture setting architecture to %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str()); return true; } else { // If we have an executable file, try to reset the executable to the desired architecture + if (log) + printf ("Target::SetArchitecture changing architecture to %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str()); m_arch = arch_spec; ModuleSP executable_sp = GetExecutableModule (); m_images.Clear(); @@ -1050,6 +1065,8 @@ Target::SetArchitecture (const ArchSpec &arch_spec) if (executable_sp) { + if (log) + log->Printf("Target::SetArchitecture Trying to select executable file architecture %s (%s)", arch_spec.GetArchitectureName(), arch_spec.GetTriple().getTriple().c_str()); ModuleSpec module_spec (executable_sp->GetFileSpec(), arch_spec); Error error = ModuleList::GetSharedModule (module_spec, executable_sp, diff --git a/lldb/source/lldb-log.cpp b/lldb/source/lldb-log.cpp index 71c5460..880598c 100644 --- a/lldb/source/lldb-log.cpp +++ b/lldb/source/lldb-log.cpp @@ -126,6 +126,7 @@ lldb_private::DisableLog (const char **categories, Stream *feedback_strm) else if (0 == ::strcasecmp(arg, "state")) flag_bits &= ~LIBLLDB_LOG_STATE; else if (0 == ::strcasecmp(arg, "step")) flag_bits &= ~LIBLLDB_LOG_STEP; else if (0 == ::strcasecmp(arg, "thread")) flag_bits &= ~LIBLLDB_LOG_THREAD; + else if (0 == ::strcasecmp(arg, "target")) flag_bits &= ~LIBLLDB_LOG_TARGET; else if (0 == ::strcasecmp(arg, "verbose")) flag_bits &= ~LIBLLDB_LOG_VERBOSE; else if (0 == ::strncasecmp(arg, "watch", 5)) flag_bits &= ~LIBLLDB_LOG_WATCHPOINTS; else if (0 == ::strncasecmp(arg, "temp", 4)) flag_bits &= ~LIBLLDB_LOG_TEMPORARY; @@ -193,6 +194,7 @@ lldb_private::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const ch else if (0 == ::strcasecmp(arg, "state")) flag_bits |= LIBLLDB_LOG_STATE; else if (0 == ::strcasecmp(arg, "step")) flag_bits |= LIBLLDB_LOG_STEP; else if (0 == ::strcasecmp(arg, "thread")) flag_bits |= LIBLLDB_LOG_THREAD; + else if (0 == ::strcasecmp(arg, "target")) flag_bits |= LIBLLDB_LOG_TARGET; else if (0 == ::strcasecmp(arg, "verbose")) flag_bits |= LIBLLDB_LOG_VERBOSE; else if (0 == ::strncasecmp(arg, "watch", 5)) flag_bits |= LIBLLDB_LOG_WATCHPOINTS; else if (0 == ::strncasecmp(arg, "temp", 4)) flag_bits |= LIBLLDB_LOG_TEMPORARY; @@ -237,6 +239,7 @@ lldb_private::ListLogCategories (Stream *strm) " state - log private and public process state changes\n" " step - log step related activities\n" " symbol - log symbol related issues and warnings\n" + " target - log target events and activities\n" " thread - log thread events and activities\n" " types - log type system related activities\n" " unwind - log stack unwind activities\n" -- 2.7.4