Skip to content

[lldb] Show module name in progress update for downloading symbols #85342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

JDevlieghere
Copy link
Member

Currently, we always show the argument passed to dsymForUUID in the corresponding progress update. Most of the time this is a UUID, but it can also be an absolute path. The former is pretty uninformative and the latter needlessly noisy.

This changes the progress update to print the UUID and the module name, if both are available. Otherwise, we print the UUID or the module name depending on which one is available.

We now also unconditionally pass the module file spec and architecture to DownloadObjectAndSymbolFile, while previously this was conditional on the file existing on-disk. This should be harmless:

  • We already check that the file exists in DownloadObjectAndSymbolFile.
  • It doesn't make sense to check the filesystem for the architecutre.

rdar://124643548

Currently, we always show the argument passed to dsymForUUID in the
corresponding progress update. Most of the time this is a UUID, but it
can also be an absolute path. The former is pretty uninformative and the
latter needlessly noisy.

This changes the progress update to print the UUID and the module name,
if both are available. Otherwise, we print the UUID or the module name
depending on which one is available.

We now also unconditionally pass the module file spec and architecture
to DownloadObjectAndSymbolFile, while previously this was conditional on
the file existing on-disk. This should be harmless:

  - We already check that the file exists in DownloadObjectAndSymbolFile.
  - It doesn't make sense to check the filesystem for the architecutre.

rdar://124643548
@llvmbot
Copy link
Member

llvmbot commented Mar 15, 2024

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

Currently, we always show the argument passed to dsymForUUID in the corresponding progress update. Most of the time this is a UUID, but it can also be an absolute path. The former is pretty uninformative and the latter needlessly noisy.

This changes the progress update to print the UUID and the module name, if both are available. Otherwise, we print the UUID or the module name depending on which one is available.

We now also unconditionally pass the module file spec and architecture to DownloadObjectAndSymbolFile, while previously this was conditional on the file existing on-disk. This should be harmless:

  • We already check that the file exists in DownloadObjectAndSymbolFile.
  • It doesn't make sense to check the filesystem for the architecutre.

rdar://124643548


Full diff: https://github.com/llvm/llvm-project/pull/85342.diff

2 Files Affected:

  • (modified) lldb/source/Commands/CommandObjectTarget.cpp (+5-12)
  • (modified) lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp (+12-2)
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index b2346c2402a81d..ae6c6d5479a198 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -3377,7 +3377,7 @@ class CommandObjectTargetModulesList : public CommandObjectParsed {
       case 'r': {
         size_t ref_count = 0;
         char in_shared_cache = 'Y';
-        
+
         ModuleSP module_sp(module->shared_from_this());
         if (!ModuleList::ModuleIsInCache(module))
           in_shared_cache = 'N';
@@ -4508,11 +4508,8 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed {
 
     ModuleSpec module_spec;
     module_spec.GetUUID() = frame_module_sp->GetUUID();
-
-    if (FileSystem::Instance().Exists(frame_module_sp->GetPlatformFileSpec())) {
-      module_spec.GetArchitecture() = frame_module_sp->GetArchitecture();
-      module_spec.GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
-    }
+    module_spec.GetArchitecture() = frame_module_sp->GetArchitecture();
+    module_spec.GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
 
     if (!DownloadObjectAndSymbolFile(module_spec, result, flush)) {
       result.AppendError("unable to find debug symbols for the current frame");
@@ -4557,12 +4554,8 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed {
 
       ModuleSpec module_spec;
       module_spec.GetUUID() = frame_module_sp->GetUUID();
-
-      if (FileSystem::Instance().Exists(
-              frame_module_sp->GetPlatformFileSpec())) {
-        module_spec.GetArchitecture() = frame_module_sp->GetArchitecture();
-        module_spec.GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
-      }
+      module_spec.GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
+      module_spec.GetArchitecture() = frame_module_sp->GetArchitecture();
 
       bool current_frame_flush = false;
       if (DownloadObjectAndSymbolFile(module_spec, result, current_frame_flush))
diff --git a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
index f7df4650941a80..acdf962a447266 100644
--- a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
+++ b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
@@ -1066,11 +1066,21 @@ bool SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile(
   command << lookup_arg;
 
   // Log and report progress.
+  std::string lookup_desc;
+  if (uuid_ptr && file_spec_ptr)
+    lookup_desc =
+        llvm::formatv("{0} ({1})", file_spec_ptr->GetFilename().GetString(),
+                      uuid_ptr->GetAsString());
+  else if (uuid_ptr)
+    lookup_desc = uuid_ptr->GetAsString();
+  else if (file_spec_ptr)
+    lookup_desc = file_spec_ptr->GetFilename().GetString();
+
   Log *log = GetLog(LLDBLog::Host);
   LLDB_LOG(log, "Calling {0} with {1} to find dSYM: {2}", dsymForUUID_exe_path,
-           lookup_arg, command.GetString());
+           lookup_desc, command.GetString());
 
-  Progress progress("Downloading symbol file", lookup_arg);
+  Progress progress("Downloading symbol file", lookup_desc);
 
   // Invoke dsymForUUID.
   int exit_status = -1;

Copy link
Contributor

@chelcassanova chelcassanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@medismailben
Copy link
Member

LGTM!


Progress progress("Downloading symbol file", lookup_arg);
Progress progress("Downloading symbol file", lookup_desc);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to say Downloading symbol file for now, because otherwise it sounds like we're downloading file_spec?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 3 possible status messages are:

Downloading symbol file: libfoo.dylib (00000000-0000-0000-0000-000000000000)
Downloading symbol file: 00000000-0000-0000-0000-000000000000
Downloading symbol file: libfoo.dylib

For when we have both the file and UUID, only the UUID or only the file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this makes it sounds as if we are downloading libfoo.dylib. But we're downloading the symbol file for libfoo.dylib, which is, e.g., libfoo.dylib.dSYM. Hence the "for"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like Adrian's proposal. We could also do "Downloading symbols for" or "Downloading debug info for" as options.

Copy link
Member

@bulbazord bulbazord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to Adrian's suggestion.

LGTM since you've addressed that now

Log *log = GetLog(LLDBLog::Host);
LLDB_LOG(log, "Calling {0} with {1} to find dSYM: {2}", dsymForUUID_exe_path,
lookup_arg, command.GetString());
lookup_desc, command.GetString());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this log message also needs updating...

@JDevlieghere JDevlieghere merged commit b7dd601 into llvm:main Mar 15, 2024
@JDevlieghere JDevlieghere deleted the rdar124643548 branch March 15, 2024 19:34
JDevlieghere added a commit to swiftlang/llvm-project that referenced this pull request Mar 15, 2024
…lvm#85342)

Currently, we always show the argument passed to dsymForUUID in the
corresponding progress update. Most of the time this is a UUID, but it
can also be an absolute path. The former is pretty uninformative and the
latter needlessly noisy.

This changes the progress update to print the UUID and the module name,
if both are available. Otherwise, we print the UUID or the module name
depending on which one is available.

We now also unconditionally pass the module file spec and architecture
to DownloadObjectAndSymbolFile, while previously this was conditional on
the file existing on-disk. This should be harmless:

  - We already check that the file exists in DownloadObjectAndSymbolFile.
  - It doesn't make sense to check the filesystem for the architecutre.

rdar://124643548
(cherry picked from commit b7dd601)
JDevlieghere added a commit to swiftlang/llvm-project that referenced this pull request Mar 16, 2024
[lldb] Show module name in progress update for downloading symbols (llvm#85342)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants