[Lldb-commits] [lldb] [lldb] Make timeout for HTTP send/receive in SymbolLocatorSymStore configurable (PR #192061)

Stefan Gränitz via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 20 02:58:41 PDT 2026


https://github.com/weliveindetail updated https://github.com/llvm/llvm-project/pull/192061

>From 658331832c90c55a4e1a988ff07cb575c45b6513 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Tue, 14 Apr 2026 15:06:04 +0200
Subject: [PATCH] [lldb] Make timeout for HTTP send/receive in
 SymbolLocatorSymStore configurable

---
 .../SymStore/SymbolLocatorSymStore.cpp        | 11 ++++--
 .../SymbolLocatorSymStoreProperties.td        |  8 ++--
 lldb/test/API/symstore/TestSymStore.py        | 38 +++++++++++++++++++
 3 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
index 78836b4f713c9..ed489c0f458f3 100644
--- a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
+++ b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
@@ -67,6 +67,12 @@ class PluginProperties : public Properties {
       return s->GetCurrentValue();
     return SymbolLocatorSymStore::GetSystemDefaultCachePath();
   }
+  
+  uint64_t GetTimeout() const {
+    const uint32_t idx = ePropertyTimeout;
+    return GetPropertyAtIndexAs<uint64_t>(
+        idx, g_symbollocatorsymstore_properties[idx].default_uint_value);
+  }
 };
 
 } // namespace
@@ -253,9 +259,8 @@ RequestFileFromSymStoreServerHTTP(llvm::StringRef base_url, llvm::StringRef key,
   }
 
   llvm::HTTPClient client;
-  // TODO: Since PDBs can be huge, we should distinguish between resolve,
-  // connect, send and receive.
-  client.setTimeout(std::chrono::seconds(60));
+  client.setTimeout(
+      std::chrono::seconds(GetGlobalPluginProperties().GetTimeout()));
 
   llvm::StreamedHTTPResponseHandler Handler(
       [dest = tmp_file.str().str()]()
diff --git a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStoreProperties.td b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStoreProperties.td
index cae023d3e08ac..3cd3408f1173d 100644
--- a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStoreProperties.td
+++ b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStoreProperties.td
@@ -2,10 +2,12 @@ include "../../../../include/lldb/Core/PropertiesBase.td"
 
 let Definition = "symbollocatorsymstore", Path = "plugin.symbol-locator.symstore" in {
   def SymStoreURLs : Property<"urls", "Array">,
-                     ElementType<"String">,
-                     Desc<"List of local symstore directories to query after "
-                          "_NT_SYMBOL_PATH">;
+    ElementType<"String">,
+    Desc<"List of local symstore directories to query after _NT_SYMBOL_PATH">;
   def CachePath : Property<"cache", "String">,
     DefaultStringValue<"">,
     Desc<"Default cache directory for downloaded symbol files. Used when no cache is specified in _NT_SYMBOL_PATH.">;
+  def Timeout : Property<"timeout", "UInt64">,
+    DefaultUnsignedValue<60>,
+    Desc<"Timeout in seconds for send/receive in HTTP connections to symbol servers.">;
 }
diff --git a/lldb/test/API/symstore/TestSymStore.py b/lldb/test/API/symstore/TestSymStore.py
index 91c74302b144b..1687cfbb95dde 100644
--- a/lldb/test/API/symstore/TestSymStore.py
+++ b/lldb/test/API/symstore/TestSymStore.py
@@ -4,6 +4,7 @@
 import socketserver
 import sys
 import threading
+import time
 from functools import partial
 
 import lldb
@@ -129,6 +130,23 @@ def do_GET(self):
         super().do_GET()
 
 
+class SlowHTTPHandler(http.server.BaseHTTPRequestHandler):
+    """HTTP request handler that delays responses to simulate a slow server."""
+
+    delay = 2  # seconds to sleep before responding; set per test
+
+    def do_GET(self):
+        try:
+            time.sleep(self.delay)
+            self.send_response(200)
+            self.end_headers()
+        except (BrokenPipeError, ConnectionResetError):
+            pass  # client disconnected after timeout, as expected
+
+    def log_message(self, *args):
+        pass  # suppress server-side output
+
+
 class SymStoreTests(TestBase):
     TEST_WITH_PDB_DEBUG_INFO = True
 
@@ -323,3 +341,23 @@ def test_lookup_order(self):
                 with NtSymbolPath(dir):
                     self.try_breakpoint(exe, should_have_loc=True)
             self.assertEqual(RequestCounter.requests, 0)
+
+    def test_http_timeout(self):
+        """
+        Check that a warning is emitted and no symbol is found when the server
+        takes longer to respond than the configured timeout.
+        """
+        exe, sym = self.build_inferior()
+        with MockedSymStore(self, exe, sym) as dir:
+            SlowHTTPHandler.delay = 3  # seconds; exceeds the 1s timeout below
+            self.runCmd("settings set plugin.symbol-locator.symstore.timeout 1")
+            with HTTPServer(dir, SlowHTTPHandler) as url:
+                self.runCmd(f"settings set plugin.symbol-locator.symstore.urls {url}")
+                warnings = ""
+                with open(self.getBuildArtifact("stderr.txt"), "w+b") as err_file:
+                    self.dbg.SetErrorFileHandle(err_file, False)
+                    self.try_breakpoint(exe, should_have_loc=False)
+                    self.dbg.SetErrorFileHandle(sys.stderr, False)
+                    err_file.seek(0)
+                    warnings = err_file.read().decode()
+                self.assertIn("failed to download", warnings)



More information about the lldb-commits mailing list