[lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

Greg Clayton via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 16 16:07:13 PST 2023


================
@@ -62,15 +66,23 @@ bool canUseDebuginfod() {
 }
 
 SmallVector<StringRef> getDefaultDebuginfodUrls() {
-  const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS");
-  if (DebuginfodUrlsEnv == nullptr)
-    return SmallVector<StringRef>();
-
-  SmallVector<StringRef> DebuginfodUrls;
-  StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " ");
+  if (!DebuginfodUrlsSet) {
+    // Only read from the environment variable if the user hasn't already
+    // set the value
+    if (const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"))
+      StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " ", -1, false);
+    DebuginfodUrlsSet = true;
+  }
   return DebuginfodUrls;
 }
 
+// Set the default debuginfod URL list, override the environment variable
+void setDefaultDebuginfodUrls(SmallVector<StringRef> URLs) {
+  DebuginfodUrls.clear();
+  DebuginfodUrls.insert(DebuginfodUrls.begin(), URLs.begin(), URLs.end());
+  DebuginfodUrlsSet = true;
----------------
clayborg wrote:

If we use std::optional this becomes:
```
DebuginfodUrls = URLs;
```
And the std::optional will have a new value and the value will be set.

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


More information about the llvm-commits mailing list