diff options
author | Jason Molenda <jmolenda@apple.com> | 2015-07-25 02:39:42 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2015-07-25 02:39:42 +0000 |
commit | 08a3258bd839041bc8e6ef974b46fc784e93504b (patch) | |
tree | ed7dcb62771ebd16f09f0c0e3ae731fcfa42c95a /lldb | |
parent | a265b01353673e544e2236bd7f3ed5d5fc20657a (diff) | |
download | bcm5719-llvm-08a3258bd839041bc8e6ef974b46fc784e93504b.tar.gz bcm5719-llvm-08a3258bd839041bc8e6ef974b46fc784e93504b.zip |
Add some initial logging for when lldb is searching for binaries,
dSYMs, or reading binaries out of memory to the 'Host' log channel.
There's more to be done here, both for Mac and for other platforms,
but the initial set of new loggings are useful enough to check in
at this point.
llvm-svn: 243200
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/source/Host/common/Symbols.cpp | 21 | ||||
-rw-r--r-- | lldb/source/Host/macosx/Symbols.cpp | 76 | ||||
-rw-r--r-- | lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp | 60 | ||||
-rw-r--r-- | lldb/source/Target/Process.cpp | 5 |
5 files changed, 172 insertions, 0 deletions
diff --git a/lldb/source/Host/common/Symbols.cpp b/lldb/source/Host/common/Symbols.cpp index 2b63f46c02e..f24423da6f9 100644 --- a/lldb/source/Host/common/Symbols.cpp +++ b/lldb/source/Host/common/Symbols.cpp @@ -11,6 +11,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/DataBuffer.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/StreamString.h" @@ -79,6 +80,7 @@ FileAtPathContainsArchAndUUID (const FileSpec &file_fspec, const ArchSpec *arch, static bool LocateDSYMInVincinityOfExecutable (const ModuleSpec &module_spec, FileSpec &dsym_fspec) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); const FileSpec *exec_fspec = module_spec.GetFileSpecPtr(); if (exec_fspec) { @@ -88,6 +90,17 @@ LocateDSYMInVincinityOfExecutable (const ModuleSpec &module_spec, FileSpec &dsym // Make sure the module isn't already just a dSYM file... if (strcasestr(path, ".dSYM/Contents/Resources/DWARF") == NULL) { + if (log) + { + if (module_spec.GetUUIDPtr() && module_spec.GetUUIDPtr()->IsValid()) + { + log->Printf ("Searching for dSYM bundle next to executable %s, UUID %s", path, module_spec.GetUUIDPtr()->GetAsString().c_str()); + } + else + { + log->Printf ("Searching for dSYM bundle next to executable %s", path); + } + } size_t obj_file_path_length = strlen(path); ::strncat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path) - strlen(path) - 1); ::strncat(path, exec_fspec->GetFilename().AsCString(), sizeof(path) - strlen(path) - 1); @@ -99,6 +112,10 @@ LocateDSYMInVincinityOfExecutable (const ModuleSpec &module_spec, FileSpec &dsym if (dsym_fspec.Exists() && FileAtPathContainsArchAndUUID(dsym_fspec, module_spec.GetArchitecturePtr(), module_spec.GetUUIDPtr())) { + if (log) + { + log->Printf ("dSYM with matching UUID & arch found at %s", path); + } return true; } else @@ -118,6 +135,10 @@ LocateDSYMInVincinityOfExecutable (const ModuleSpec &module_spec, FileSpec &dsym if (dsym_fspec.Exists() && FileAtPathContainsArchAndUUID(dsym_fspec, module_spec.GetArchitecturePtr(), module_spec.GetUUIDPtr())) { + if (log) + { + log->Printf ("dSYM with matching UUID & arch found at %s", path); + } return true; } else diff --git a/lldb/source/Host/macosx/Symbols.cpp b/lldb/source/Host/macosx/Symbols.cpp index a86a7739f9d..344cce1cb90 100644 --- a/lldb/source/Host/macosx/Symbols.cpp +++ b/lldb/source/Host/macosx/Symbols.cpp @@ -22,6 +22,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/DataBuffer.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/StreamString.h" @@ -99,6 +100,7 @@ LocateMacOSXFilesUsingDebugSymbols { CFCReleaser<CFURLRef> exec_url; const FileSpec *exec_fspec = module_spec.GetFileSpecPtr(); + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (exec_fspec) { char exec_cf_path[PATH_MAX]; @@ -108,6 +110,23 @@ LocateMacOSXFilesUsingDebugSymbols strlen(exec_cf_path), FALSE)); } + if (log) + { + std::string searching_for; + if (out_exec_fspec && out_dsym_fspec) + { + searching_for = "executable binary and dSYM"; + } + else if (out_exec_fspec) + { + searching_for = "executable binary"; + } + else + { + searching_for = "dSYM bundle"; + } + log->Printf ("Calling DebugSymbols framework to locate dSYM bundle for UUID %s, searching for %s", uuid->GetAsString().c_str(), searching_for.c_str()); + } CFCReleaser<CFURLRef> dsym_url (::DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(), exec_url.get())); char path[PATH_MAX]; @@ -118,6 +137,10 @@ LocateMacOSXFilesUsingDebugSymbols { if (::CFURLGetFileSystemRepresentation (dsym_url.get(), true, (UInt8*)path, sizeof(path)-1)) { + if (log) + { + log->Printf ("DebugSymbols framework returned dSYM path of %s for UUID %s -- looking for the dSYM", path, uuid->GetAsString().c_str()); + } out_dsym_fspec->SetFile(path, path[0] == '~'); if (out_dsym_fspec->GetFileType () == FileSpec::eFileTypeDirectory) @@ -136,6 +159,14 @@ LocateMacOSXFilesUsingDebugSymbols if (out_exec_fspec) { bool success = false; + if (log) + { + if (::CFURLGetFileSystemRepresentation (dsym_url.get(), true, (UInt8*)path, sizeof(path)-1)) + { + log->Printf ("DebugSymbols framework returned dSYM path of %s for UUID %s -- looking for an exec file", path, uuid->GetAsString().c_str()); + } + + } CFCReleaser<CFDictionaryRef> dict(::DBGCopyDSYMPropertyLists (dsym_url.get())); CFDictionaryRef uuid_dict = NULL; if (dict.get()) @@ -148,6 +179,10 @@ LocateMacOSXFilesUsingDebugSymbols CFStringRef exec_cf_path = static_cast<CFStringRef>(::CFDictionaryGetValue (uuid_dict, CFSTR("DBGSymbolRichExecutable"))); if (exec_cf_path && ::CFStringGetFileSystemRepresentation (exec_cf_path, path, sizeof(path))) { + if (log) + { + log->Printf ("plist bundle has exec path of %s for UUID %s", path, uuid->GetAsString().c_str()); + } ++items_found; out_exec_fspec->SetFile(path, path[0] == '~'); if (out_exec_fspec->Exists()) @@ -164,6 +199,10 @@ LocateMacOSXFilesUsingDebugSymbols if (dsym_extension_pos) { *dsym_extension_pos = '\0'; + if (log) + { + log->Printf ("Looking for executable binary next to dSYM bundle with name with name %s", path); + } FileSpec file_spec (path, true); ModuleSpecList module_specs; ModuleSpec matched_module_spec; @@ -184,6 +223,10 @@ LocateMacOSXFilesUsingDebugSymbols { ++items_found; *out_exec_fspec = bundle_exe_file_spec; + if (log) + { + log->Printf ("Executable binary %s next to dSYM is compatible; using", path); + } } } } @@ -205,6 +248,10 @@ LocateMacOSXFilesUsingDebugSymbols { ++items_found; *out_exec_fspec = file_spec; + if (log) + { + log->Printf ("Executable binary %s next to dSYM is compatible; using", path); + } } break; } @@ -279,6 +326,7 @@ Symbols::FindSymbolFileInBundle (const FileSpec& dsym_bundle_fspec, static bool GetModuleSpecInfoFromUUIDDictionary (CFDictionaryRef uuid_dict, ModuleSpec &module_spec) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); bool success = false; if (uuid_dict != NULL && CFGetTypeID (uuid_dict) == CFDictionaryGetTypeID ()) { @@ -289,7 +337,13 @@ GetModuleSpecInfoFromUUIDDictionary (CFDictionaryRef uuid_dict, ModuleSpec &modu if (cf_str && CFGetTypeID (cf_str) == CFStringGetTypeID ()) { if (CFCString::FileSystemRepresentation(cf_str, str)) + { module_spec.GetFileSpec().SetFile (str.c_str(), true); + if (log) + { + log->Printf ("From dsymForUUID plist: Symbol rich executable is at '%s'", str.c_str()); + } + } } cf_str = (CFStringRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGDSYMPath")); @@ -299,6 +353,10 @@ GetModuleSpecInfoFromUUIDDictionary (CFDictionaryRef uuid_dict, ModuleSpec &modu { module_spec.GetSymbolFileSpec().SetFile (str.c_str(), true); success = true; + if (log) + { + log->Printf ("From dsymForUUID plist: dSYM is at '%s'", str.c_str()); + } } } @@ -439,9 +497,17 @@ Symbols::DownloadObjectAndSymbolFile (ModuleSpec &module_spec, bool force_lookup if (!command.GetString().empty()) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); int exit_status = -1; int signo = -1; std::string command_output; + if (log) + { + if (!uuid_str.empty()) + log->Printf("Calling %s with UUID %s to find dSYM", g_dsym_for_uuid_exe_path, uuid_str.c_str()); + else if (file_path[0] != '\0') + log->Printf("Calling %s with file %s to find dSYM", g_dsym_for_uuid_exe_path, file_path); + } Error error = Host::RunShellCommand (command.GetData(), NULL, // current working directory &exit_status, // Exit status @@ -497,6 +563,16 @@ Symbols::DownloadObjectAndSymbolFile (ModuleSpec &module_spec, bool force_lookup } } } + else + { + if (log) + { + if (!uuid_str.empty()) + log->Printf("Called %s on %s, no matches", g_dsym_for_uuid_exe_path, uuid_str.c_str()); + else if (file_path[0] != '\0') + log->Printf("Called %s on %s, no matches", g_dsym_for_uuid_exe_path, file_path); + } + } } } } diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index bec5ca4098e..086d641b8d2 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -668,6 +668,7 @@ DynamicLoaderDarwinKernel::KextImageInfo::GetUUID () const bool DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule (Process *process) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (m_memory_module_sp.get() != NULL) return true; if (m_load_address == LLDB_INVALID_ADDRESS) @@ -702,6 +703,10 @@ DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule (Process *process) { if (m_uuid != memory_module_sp->GetUUID()) { + if (log) + { + log->Printf ("KextImageInfo::ReadMemoryModule the kernel said to find uuid %s at 0x%" PRIx64 " but instead we found uuid %s, throwing it away", m_uuid.GetAsString().c_str(), m_load_address, memory_module_sp->GetUUID().GetAsString().c_str()); + } return false; } } @@ -716,6 +721,11 @@ DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule (Process *process) m_kernel_image = is_kernel; if (is_kernel) { + if (log) + { + // This is unusual and probably not intended + log->Printf ("KextImageInfo::ReadMemoryModule read the kernel binary out of memory"); + } if (memory_module_sp->GetArchitecture().IsValid()) { process->GetTarget().SetArchitecture(memory_module_sp->GetArchitecture()); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp index 37226e41a64..3fb1ca4f4fc 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -16,6 +16,7 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Error.h" +#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" @@ -302,6 +303,7 @@ PlatformRemoteiOS::GetContainedFilesIntoVectorOfStringsCallback (void *baton, bool PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded() { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (m_sdk_directory_infos.empty()) { // A --sysroot option was supplied - add it to our list of SDKs to check @@ -310,9 +312,17 @@ PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded() FileSpec sdk_sysroot_fspec(m_sdk_sysroot.GetCString(), true); const SDKDirectoryInfo sdk_sysroot_directory_info(sdk_sysroot_fspec); m_sdk_directory_infos.push_back(sdk_sysroot_directory_info); + if (log) + { + log->Printf ("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded added --sysroot SDK directory %s", m_sdk_sysroot.GetCString()); + } return true; } const char *device_support_dir = GetDeviceSupportDirectory(); + if (log) + { + log->Printf ("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded Got DeviceSupport directory %s", device_support_dir); + } if (device_support_dir) { const bool find_directories = true; @@ -337,6 +347,10 @@ PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded() if (sdk_symbols_symlink_fspec.Exists()) { m_sdk_directory_infos.push_back(sdk_directory_info); + if (log) + { + log->Printf ("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str()); + } } } @@ -344,6 +358,10 @@ PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded() FileSpec local_sdk_cache("~/Library/Developer/Xcode/iOS DeviceSupport", true); if (local_sdk_cache.Exists()) { + if (log) + { + log->Printf ("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded searching %s for additional SDKs", local_sdk_cache.GetPath().c_str()); + } char path[PATH_MAX]; if (local_sdk_cache.GetPath(path, sizeof(path))) { @@ -358,6 +376,10 @@ PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded() for (uint32_t i=num_installed; i<num_sdk_infos; ++i) { m_sdk_directory_infos[i].user_cached = true; + if (log) + { + log->Printf ("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded user SDK directory %s", m_sdk_directory_infos[i].directory.GetPath().c_str()); + } } } } @@ -592,6 +614,7 @@ PlatformRemoteiOS::GetFileInSDKRoot (const char *platform_file_path, bool symbols_dirs_only, lldb_private::FileSpec &local_file) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (sdkroot_path && sdkroot_path[0] && platform_file_path && platform_file_path[0]) { char resolved_path[PATH_MAX]; @@ -606,7 +629,13 @@ PlatformRemoteiOS::GetFileInSDKRoot (const char *platform_file_path, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the SDK dir %s", platform_file_path, sdkroot_path); + } return true; + } } ::snprintf (resolved_path, @@ -617,7 +646,13 @@ PlatformRemoteiOS::GetFileInSDKRoot (const char *platform_file_path, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the SDK dir %s/Symbols.Internal", platform_file_path, sdkroot_path); + } return true; + } ::snprintf (resolved_path, sizeof(resolved_path), "%s/Symbols%s", @@ -626,7 +661,13 @@ PlatformRemoteiOS::GetFileInSDKRoot (const char *platform_file_path, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the SDK dir %s/Symbols", platform_file_path, sdkroot_path); + } return true; + } } return false; } @@ -637,6 +678,7 @@ PlatformRemoteiOS::GetSymbolFile (const FileSpec &platform_file, const UUID *uuid_ptr, FileSpec &local_file) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); Error error; char platform_file_path[PATH_MAX]; if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) @@ -654,7 +696,13 @@ PlatformRemoteiOS::GetSymbolFile (const FileSpec &platform_file, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the DeviceSupport dir %s", platform_file_path, os_version_dir); + } return error; + } ::snprintf (resolved_path, sizeof(resolved_path), @@ -664,7 +712,13 @@ PlatformRemoteiOS::GetSymbolFile (const FileSpec &platform_file, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal", platform_file_path, os_version_dir); + } return error; + } ::snprintf (resolved_path, sizeof(resolved_path), "%s/Symbols/%s", @@ -673,7 +727,13 @@ PlatformRemoteiOS::GetSymbolFile (const FileSpec &platform_file, local_file.SetFile(resolved_path, true); if (local_file.Exists()) + { + if (log) + { + log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols", platform_file_path, os_version_dir); + } return error; + } } local_file = platform_file; diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 17318e7a82b..9594a8ae434 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -3049,6 +3049,11 @@ Process::ReadModuleFromMemory (const FileSpec& file_spec, lldb::addr_t header_addr, size_t size_to_read) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); + if (log) + { + log->Printf ("Process::ReadModuleFromMemory reading %s binary from memory", file_spec.GetPath().c_str()); + } ModuleSP module_sp (new Module (file_spec, ArchSpec())); if (module_sp) { |