[llvm] LLVM symbolizer gsym support (PR #134847)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 29 10:09:03 PDT 2025


================
@@ -498,6 +500,37 @@ bool LLVMSymbolizer::getOrFindDebugBinary(const ArrayRef<uint8_t> BuildID,
   return false;
 }
 
+std::string LLVMSymbolizer::lookUpGsymFile(const std::string &Path) {
+  if (Opts.DisableGsym)
+    return {};
+
+  auto CheckGsymFile = [](const llvm::StringRef &GsymPath) {
+    sys::fs::file_status Status;
+    std::error_code EC = llvm::sys::fs::status(GsymPath, Status);
+    return !EC && !llvm::sys::fs::is_directory(Status);
+  };
+
+  // First, look beside the binary file
+  {
+    const auto GsymPath = Path + ".gsym";
+    if (CheckGsymFile(GsymPath))
+      return GsymPath;
+  }
----------------
dwblaikie wrote:

Perhaps: 
```suggestion
  if (const auto GsymPath = Path + ".gsym"; CheckGsymFile(GsymPath))
    return GsymPath;
```
(we don't usually add explicit scopes for cheap-enough variables like this - but I guess you added it to avoid a shadow warning later, maybe (but I don't think we compile with shadow warnings enabled) - the if-with-initializer seems like a nice way to reduce the scope without making it more verbose/awkward)

https://github.com/llvm/llvm-project/pull/134847


More information about the llvm-commits mailing list