[Lldb-commits] [lldb] f083764 - [lldb] Optimized lldb-server memory usage (#100666)

via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 26 08:12:08 PDT 2024


Author: Dmitry Vasilyev
Date: 2024-07-26T19:12:05+04:00
New Revision: f083764ba1ca35016c929683c8a5d918b5048100

URL: https://github.com/llvm/llvm-project/commit/f083764ba1ca35016c929683c8a5d918b5048100
DIFF: https://github.com/llvm/llvm-project/commit/f083764ba1ca35016c929683c8a5d918b5048100.diff

LOG: [lldb] Optimized lldb-server memory usage (#100666)

MAX_PATH is definitely larger than 6 bytes we are expecting for this
message, and could be rather large depending on the target OS (4K for
some Linux OSs).

Since the buffer gets allocated on the stack we better be conservative
and allocate what we actually need.

Added: 
    

Modified: 
    lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 187370eb36cae..5d0a3e31d0437 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1145,8 +1145,8 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
       if (socket_pipe.CanWrite())
         socket_pipe.CloseWriteFileDescriptor();
       if (socket_pipe.CanRead()) {
-        char port_cstr[PATH_MAX] = {0};
-        port_cstr[0] = '\0';
+        // The port number may be up to "65535\0".
+        char port_cstr[6] = {0};
         size_t num_bytes = sizeof(port_cstr);
         // Read port from pipe with 10 second timeout.
         error = socket_pipe.ReadWithTimeout(


        


More information about the lldb-commits mailing list