Skip to content

Commit dc41629

Browse files
committed
Revert "[lldb] Remote disk file/directory completion for platform commands"
This reverts commit 7e4e29e. The test for that fails on Linux, probably because we need some other commits backported. Let's just revert it's lldb-server specific and that's anyway not very useful on macOS.
1 parent f2c339c commit dc41629

16 files changed

+2
-279
lines changed

lldb/docs/lldb-platform-packets.txt

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -237,27 +237,6 @@ incompatible with the flags that gdb specifies.
237237
// Continues to return the results of the qfProcessInfo. Once all matches
238238
// have been sent, Exx is returned to indicate end of matches.
239239

240-
//----------------------------------------------------------------------
241-
// qPathComplete
242-
//
243-
// BRIEF
244-
// Get a list of matched disk files/directories by passing a boolean flag
245-
// and a partial path.
246-
//
247-
// EXAMPLE
248-
//
249-
// receive: qPathComplete:0,6d61696e
250-
// send: M6d61696e2e637070
251-
// receive: qPathComplete:1,746573
252-
// send: M746573742f,74657374732f
253-
//
254-
// If the first argument is zero, the result should contain all
255-
// files (including directories) starting with the given path. If the
256-
// argument is one, the result should contain only directories.
257-
//
258-
// The result should be a comma-separated list of hex-encoded paths.
259-
// Paths denoting a directory should end with a directory separator ('/' or '\').
260-
261240
//----------------------------------------------------------------------
262241
// vFile:size:
263242
//

lldb/include/lldb/Interpreter/CommandCompletions.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ class CommandCompletions {
4747
eBreakpointNameCompletion = (1u << 19),
4848
eProcessIDCompletion = (1u << 20),
4949
eProcessNameCompletion = (1u << 21),
50-
eRemoteDiskFileCompletion = (1u << 22),
51-
eRemoteDiskDirectoryCompletion = (1u << 23),
5250
eTypeCategoryNameCompletion = (1u << 24),
5351
// This item serves two purposes. It is the last element in the enum, so
5452
// you can add custom enums starting from here in your Option class. Also
5553
// if you & in this bit the base code will not process the option.
56-
eCustomCompletion = (1u << 24)
54+
eCustomCompletion = (1u << 22)
5755
};
5856

5957
static bool InvokeCommonCompletionCallbacks(
@@ -75,14 +73,6 @@ class CommandCompletions {
7573
StringList &matches,
7674
TildeExpressionResolver &Resolver);
7775

78-
static void RemoteDiskFiles(CommandInterpreter &interpreter,
79-
CompletionRequest &request,
80-
SearchFilter *searcher);
81-
82-
static void RemoteDiskDirectories(CommandInterpreter &interpreter,
83-
CompletionRequest &request,
84-
SearchFilter *searcher);
85-
8676
static void SourceFiles(CommandInterpreter &interpreter,
8777
CompletionRequest &request, SearchFilter *searcher);
8878

lldb/include/lldb/Target/Platform.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,6 @@ class Platform : public PluginInterface {
523523
return UINT64_MAX;
524524
}
525525

526-
virtual void AutoCompleteDiskFileOrDirectory(CompletionRequest &request,
527-
bool only_dir) {}
528-
529526
virtual uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
530527
uint64_t dst_len, Status &error) {
531528
error.SetErrorStringWithFormat(

lldb/include/lldb/Utility/StringExtractorGDBRemote.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class StringExtractorGDBRemote : public StringExtractor {
7676
eServerPacketType_QSetSTDERR,
7777
eServerPacketType_QSetWorkingDir,
7878
eServerPacketType_QStartNoAckMode,
79-
eServerPacketType_qPathComplete,
8079
eServerPacketType_qPlatform_shell,
8180
eServerPacketType_qPlatform_mkdir,
8281
eServerPacketType_qPlatform_chmod,

lldb/source/Commands/CommandCompletions.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks(
7474
{eBreakpointNameCompletion, CommandCompletions::BreakpointNames},
7575
{eProcessIDCompletion, CommandCompletions::ProcessIDs},
7676
{eProcessNameCompletion, CommandCompletions::ProcessNames},
77-
{eRemoteDiskFileCompletion, CommandCompletions::RemoteDiskFiles},
78-
{eRemoteDiskDirectoryCompletion,
79-
CommandCompletions::RemoteDiskDirectories},
8077
{eTypeCategoryNameCompletion, CommandCompletions::TypeCategoryNames},
8178
{eNoCompletion, nullptr} // This one has to be last in the list.
8279
};
@@ -491,24 +488,6 @@ void CommandCompletions::DiskDirectories(const llvm::Twine &partial_file_name,
491488
DiskFilesOrDirectories(partial_file_name, true, matches, Resolver);
492489
}
493490

494-
void CommandCompletions::RemoteDiskFiles(CommandInterpreter &interpreter,
495-
CompletionRequest &request,
496-
SearchFilter *searcher) {
497-
lldb::PlatformSP platform_sp =
498-
interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
499-
if (platform_sp)
500-
platform_sp->AutoCompleteDiskFileOrDirectory(request, false);
501-
}
502-
503-
void CommandCompletions::RemoteDiskDirectories(CommandInterpreter &interpreter,
504-
CompletionRequest &request,
505-
SearchFilter *searcher) {
506-
lldb::PlatformSP platform_sp =
507-
interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
508-
if (platform_sp)
509-
platform_sp->AutoCompleteDiskFileOrDirectory(request, true);
510-
}
511-
512491
void CommandCompletions::Modules(CommandInterpreter &interpreter,
513492
CompletionRequest &request,
514493
SearchFilter *searcher) {

lldb/source/Commands/CommandObjectPlatform.cpp

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,7 @@ class CommandObjectPlatformSettings : public CommandObjectParsed {
392392
"or for a platform by name.",
393393
"platform settings", 0),
394394
m_options(),
395-
m_option_working_dir(LLDB_OPT_SET_1, false, "working-dir", 'w',
396-
CommandCompletions::eRemoteDiskDirectoryCompletion,
395+
m_option_working_dir(LLDB_OPT_SET_1, false, "working-dir", 'w', 0,
397396
eArgTypePath,
398397
"The working directory for the platform.") {
399398
m_options.Append(&m_option_working_dir, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
@@ -486,15 +485,6 @@ class CommandObjectPlatformFOpen : public CommandObjectParsed {
486485

487486
~CommandObjectPlatformFOpen() override = default;
488487

489-
void
490-
HandleArgumentCompletion(CompletionRequest &request,
491-
OptionElementVector &opt_element_vector) override {
492-
if (request.GetCursorIndex() == 0)
493-
CommandCompletions::InvokeCommonCompletionCallbacks(
494-
GetCommandInterpreter(),
495-
CommandCompletions::eRemoteDiskFileCompletion, request, nullptr);
496-
}
497-
498488
bool DoExecute(Args &args, CommandReturnObject &result) override {
499489
PlatformSP platform_sp(
500490
GetDebugger().GetPlatformList().GetSelectedPlatform());
@@ -827,19 +817,6 @@ class CommandObjectPlatformGetFile : public CommandObjectParsed {
827817

828818
~CommandObjectPlatformGetFile() override = default;
829819

830-
void
831-
HandleArgumentCompletion(CompletionRequest &request,
832-
OptionElementVector &opt_element_vector) override {
833-
if (request.GetCursorIndex() == 0)
834-
CommandCompletions::InvokeCommonCompletionCallbacks(
835-
GetCommandInterpreter(),
836-
CommandCompletions::eRemoteDiskFileCompletion, request, nullptr);
837-
else if (request.GetCursorIndex() == 1)
838-
CommandCompletions::InvokeCommonCompletionCallbacks(
839-
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
840-
request, nullptr);
841-
}
842-
843820
bool DoExecute(Args &args, CommandReturnObject &result) override {
844821
// If the number of arguments is incorrect, issue an error message.
845822
if (args.GetArgumentCount() != 2) {
@@ -905,17 +882,6 @@ class CommandObjectPlatformGetSize : public CommandObjectParsed {
905882

906883
~CommandObjectPlatformGetSize() override = default;
907884

908-
void
909-
HandleArgumentCompletion(CompletionRequest &request,
910-
OptionElementVector &opt_element_vector) override {
911-
if (request.GetCursorIndex() != 0)
912-
return;
913-
914-
CommandCompletions::InvokeCommonCompletionCallbacks(
915-
GetCommandInterpreter(), CommandCompletions::eRemoteDiskFileCompletion,
916-
request, nullptr);
917-
}
918-
919885
bool DoExecute(Args &args, CommandReturnObject &result) override {
920886
// If the number of arguments is incorrect, issue an error message.
921887
if (args.GetArgumentCount() != 1) {
@@ -961,19 +927,6 @@ class CommandObjectPlatformPutFile : public CommandObjectParsed {
961927

962928
~CommandObjectPlatformPutFile() override = default;
963929

964-
void
965-
HandleArgumentCompletion(CompletionRequest &request,
966-
OptionElementVector &opt_element_vector) override {
967-
if (request.GetCursorIndex() == 0)
968-
CommandCompletions::InvokeCommonCompletionCallbacks(
969-
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
970-
request, nullptr);
971-
else if (request.GetCursorIndex() == 1)
972-
CommandCompletions::InvokeCommonCompletionCallbacks(
973-
GetCommandInterpreter(),
974-
CommandCompletions::eRemoteDiskFileCompletion, request, nullptr);
975-
}
976-
977930
bool DoExecute(Args &args, CommandReturnObject &result) override {
978931
const char *src = args.GetArgumentAtIndex(0);
979932
const char *dst = args.GetArgumentAtIndex(1);

lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,6 @@ PlatformRemoteGDBServer::GetFileSize(const FileSpec &file_spec) {
661661
return m_gdb_client.GetFileSize(file_spec);
662662
}
663663

664-
void PlatformRemoteGDBServer::AutoCompleteDiskFileOrDirectory(
665-
CompletionRequest &request, bool only_dir) {
666-
m_gdb_client.AutoCompleteDiskFileOrDirectory(request, only_dir);
667-
}
668-
669664
uint64_t PlatformRemoteGDBServer::ReadFile(lldb::user_id_t fd, uint64_t offset,
670665
void *dst, uint64_t dst_len,
671666
Status &error) {

lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ class PlatformRemoteGDBServer : public Platform, private UserIDResolver {
127127

128128
lldb::user_id_t GetFileSize(const FileSpec &file_spec) override;
129129

130-
void AutoCompleteDiskFileOrDirectory(CompletionRequest &request,
131-
bool only_dir) override;
132-
133130
Status PutFile(const FileSpec &source, const FileSpec &destination,
134131
uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX) override;
135132

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2981,31 +2981,6 @@ lldb::user_id_t GDBRemoteCommunicationClient::GetFileSize(
29812981
return UINT64_MAX;
29822982
}
29832983

2984-
void GDBRemoteCommunicationClient::AutoCompleteDiskFileOrDirectory(
2985-
CompletionRequest &request, bool only_dir) {
2986-
lldb_private::StreamString stream;
2987-
stream.PutCString("qPathComplete:");
2988-
stream.PutHex32(only_dir ? 1 : 0);
2989-
stream.PutChar(',');
2990-
stream.PutStringAsRawHex8(request.GetCursorArgumentPrefix());
2991-
StringExtractorGDBRemote response;
2992-
if (SendPacketAndWaitForResponse(stream.GetString(), response, false) ==
2993-
PacketResult::Success) {
2994-
StreamString strm;
2995-
char ch = response.GetChar();
2996-
if (ch != 'M')
2997-
return;
2998-
while (response.Peek()) {
2999-
strm.Clear();
3000-
while ((ch = response.GetHexU8(0, false)) != '\0')
3001-
strm.PutChar(ch);
3002-
request.AddCompletion(strm.GetString());
3003-
if (response.GetChar() != ',')
3004-
break;
3005-
}
3006-
}
3007-
}
3008-
30092984
Status
30102985
GDBRemoteCommunicationClient::GetFilePermissions(const FileSpec &file_spec,
30112986
uint32_t &file_permissions) {

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,6 @@ class GDBRemoteCommunicationClient : public GDBRemoteClientBase {
375375

376376
lldb::user_id_t GetFileSize(const FileSpec &file_spec);
377377

378-
void AutoCompleteDiskFileOrDirectory(CompletionRequest &request,
379-
bool only_dir);
380-
381378
Status GetFilePermissions(const FileSpec &file_spec,
382379
uint32_t &file_permissions);
383380

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@
2626
#include "lldb/Host/FileAction.h"
2727
#include "lldb/Host/Host.h"
2828
#include "lldb/Host/HostInfo.h"
29-
#include "lldb/Interpreter/CommandCompletions.h"
3029
#include "lldb/Target/Platform.h"
3130
#include "lldb/Target/UnixSignals.h"
3231
#include "lldb/Utility/GDBRemote.h"
3332
#include "lldb/Utility/Log.h"
3433
#include "lldb/Utility/StreamString.h"
3534
#include "lldb/Utility/StructuredData.h"
36-
#include "lldb/Utility/TildeExpressionResolver.h"
3735
#include "lldb/Utility/UriParser.h"
3836

3937
#include "lldb/Utility/StringExtractorGDBRemote.h"
@@ -70,9 +68,6 @@ GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(
7068
RegisterMemberFunctionHandler(
7169
StringExtractorGDBRemote::eServerPacketType_qProcessInfo,
7270
&GDBRemoteCommunicationServerPlatform::Handle_qProcessInfo);
73-
RegisterMemberFunctionHandler(
74-
StringExtractorGDBRemote::eServerPacketType_qPathComplete,
75-
&GDBRemoteCommunicationServerPlatform::Handle_qPathComplete);
7671
RegisterMemberFunctionHandler(
7772
StringExtractorGDBRemote::eServerPacketType_QSetWorkingDir,
7873
&GDBRemoteCommunicationServerPlatform::Handle_QSetWorkingDir);
@@ -338,38 +333,6 @@ GDBRemoteCommunicationServerPlatform::Handle_qProcessInfo(
338333
return SendPacketNoLock(response.GetString());
339334
}
340335

341-
GDBRemoteCommunication::PacketResult
342-
GDBRemoteCommunicationServerPlatform::Handle_qPathComplete(
343-
StringExtractorGDBRemote &packet) {
344-
packet.SetFilePos(::strlen("qPathComplete:"));
345-
const bool only_dir = (packet.GetHexMaxU32(false, 0) == 1);
346-
if (packet.GetChar() != ',')
347-
return SendErrorResponse(85);
348-
std::string path;
349-
packet.GetHexByteString(path);
350-
351-
StringList matches;
352-
StandardTildeExpressionResolver resolver;
353-
if (only_dir)
354-
CommandCompletions::DiskDirectories(path, matches, resolver);
355-
else
356-
CommandCompletions::DiskFiles(path, matches, resolver);
357-
358-
StreamString response;
359-
response.PutChar('M');
360-
llvm::StringRef separator;
361-
std::sort(matches.begin(), matches.end());
362-
for (const auto &match : matches) {
363-
response << separator;
364-
separator = ",";
365-
// encode result strings into hex bytes to avoid unexpected error caused by
366-
// special characters like '$'.
367-
response.PutStringAsRawHex8(match.c_str());
368-
}
369-
370-
return SendPacketNoLock(response.GetString());
371-
}
372-
373336
GDBRemoteCommunication::PacketResult
374337
GDBRemoteCommunicationServerPlatform::Handle_qGetWorkingDir(
375338
StringExtractorGDBRemote &packet) {

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ class GDBRemoteCommunicationServerPlatform
8181

8282
PacketResult Handle_qKillSpawnedProcess(StringExtractorGDBRemote &packet);
8383

84-
PacketResult Handle_qPathComplete(StringExtractorGDBRemote &packet);
85-
8684
PacketResult Handle_qProcessInfo(StringExtractorGDBRemote &packet);
8785

8886
PacketResult Handle_qGetWorkingDir(StringExtractorGDBRemote &packet);

lldb/source/Utility/StringExtractorGDBRemote.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ StringExtractorGDBRemote::GetServerPacketType() const {
233233
return eServerPacketType_qPlatform_chmod;
234234
if (PACKET_MATCHES("qProcessInfo"))
235235
return eServerPacketType_qProcessInfo;
236-
if (PACKET_STARTS_WITH("qPathComplete:"))
237-
return eServerPacketType_qPathComplete;
238236
break;
239237

240238
case 'Q':

lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteDiskFileCompletion.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ def respond(self, packet):
178178
return self.qsProcessInfo()
179179
if packet.startswith("qfProcessInfo"):
180180
return self.qfProcessInfo(packet)
181-
if packet.startswith("qPathComplete:"):
182-
return self.qPathComplete()
183181

184182
return self.other(packet)
185183

@@ -284,9 +282,6 @@ def QListThreadsInStopReply(self):
284282
def qMemoryRegionInfo(self):
285283
return ""
286284

287-
def qPathComplete(self):
288-
return ""
289-
290285
"""
291286
Raised when we receive a packet for which there is no default action.
292287
Override the responder class to implement behavior suitable for the test at

0 commit comments

Comments
 (0)