https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/100666
>From 0e451f16b91bab2bc2cd1375eb02e4fe71998790 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev <dvassil...@accesssoftek.com> Date: Fri, 26 Jul 2024 02:40:49 +0400 Subject: [PATCH 1/2] [lldb] Optimized lldb-server memory usage 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. --- .../Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 187370eb36cae..b961c0e42469a 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -1145,7 +1145,8 @@ Status GDBRemoteCommunication::StartDebugserverProcess( if (socket_pipe.CanWrite()) socket_pipe.CloseWriteFileDescriptor(); if (socket_pipe.CanRead()) { - char port_cstr[PATH_MAX] = {0}; + // The port number may be "1024\0".."65535\0". + char port_cstr[6] = {0}; port_cstr[0] = '\0'; size_t num_bytes = sizeof(port_cstr); // Read port from pipe with 10 second timeout. >From 4562af94a7417575fec100e5bbe745b21870e6fc Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev <dvassil...@accesssoftek.com> Date: Fri, 26 Jul 2024 11:55:08 +0400 Subject: [PATCH 2/2] Removed the redundant line. --- .../source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index b961c0e42469a..07aa8209ca4ba 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -1147,7 +1147,6 @@ Status GDBRemoteCommunication::StartDebugserverProcess( if (socket_pipe.CanRead()) { // The port number may be "1024\0".."65535\0". char port_cstr[6] = {0}; - port_cstr[0] = '\0'; size_t num_bytes = sizeof(port_cstr); // Read port from pipe with 10 second timeout. error = socket_pipe.ReadWithTimeout( _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits