Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1567f02

Browse files
authored
Merge pull request swiftlang#7015 from medismailben/file-completion-improvements
[lldb] Add file path completion in for `crashlog` & `process save-core`
2 parents 4723674 + 46ed794 commit 1567f02

39 files changed

+535
-414
lines changed

lldb/docs/python_api_enums.rst

+1
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ CommandArgumentType
875875
.. py:data:: eArgTypeColumnNum
876876
.. py:data:: eArgTypeModuleUUID
877877
.. py:data:: eArgTypeLastArg
878+
.. py:data:: eArgTypeCompletionType
878879
879880
.. _SymbolType:
880881

lldb/examples/python/crashlog.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -1301,13 +1301,7 @@ def add_module(image, target, obj_dir):
13011301
print(error)
13021302

13031303

1304-
def load_crashlog_in_scripted_process(debugger, crash_log_file, options, result):
1305-
crashlog_path = os.path.expanduser(crash_log_file)
1306-
if not os.path.exists(crashlog_path):
1307-
raise InteractiveCrashLogException(
1308-
"crashlog file %s does not exist" % crashlog_path
1309-
)
1310-
1304+
def load_crashlog_in_scripted_process(debugger, crashlog_path, options, result):
13111305
crashlog = CrashLogParser.create(debugger, crashlog_path, False).parse()
13121306

13131307
target = lldb.SBTarget()
@@ -1594,17 +1588,22 @@ def should_run_in_interactive_mode(options, ci):
15941588
ci = debugger.GetCommandInterpreter()
15951589

15961590
if args:
1597-
for crash_log_file in args:
1591+
for crashlog_file in args:
1592+
crashlog_path = os.path.expanduser(crashlog_file)
1593+
if not os.path.exists(crashlog_path):
1594+
raise FileNotFoundError(
1595+
"crashlog file %s does not exist" % crashlog_path
1596+
)
15981597
if should_run_in_interactive_mode(options, ci):
15991598
try:
16001599
load_crashlog_in_scripted_process(
1601-
debugger, crash_log_file, options, result
1600+
debugger, crashlog_path, options, result
16021601
)
16031602
except InteractiveCrashLogException as e:
16041603
result.SetError(str(e))
16051604
else:
16061605
crash_log = CrashLogParser.create(
1607-
debugger, crash_log_file, options.verbose
1606+
debugger, crashlog_path, options.verbose
16081607
).parse()
16091608
SymbolicateCrashLog(crash_log, options)
16101609

@@ -1619,10 +1618,10 @@ def should_run_in_interactive_mode(options, ci):
16191618

16201619
def __lldb_init_module(debugger, internal_dict):
16211620
debugger.HandleCommand(
1622-
"command script add -o -c lldb.macosx.crashlog.Symbolicate crashlog"
1621+
"command script add -o -c lldb.macosx.crashlog.Symbolicate -C disk-file crashlog"
16231622
)
16241623
debugger.HandleCommand(
1625-
"command script add -o -f lldb.macosx.crashlog.save_crashlog save_crashlog"
1624+
"command script add -o -f lldb.macosx.crashlog.save_crashlog -C disk-file save_crashlog"
16261625
)
16271626
print(
16281627
'"crashlog" and "save_crashlog" commands have been installed, use '

lldb/include/lldb/Interpreter/CommandCompletions.h

-33
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,6 @@ namespace lldb_private {
2424
class TildeExpressionResolver;
2525
class CommandCompletions {
2626
public:
27-
enum CommonCompletionTypes {
28-
eNoCompletion = 0u,
29-
eSourceFileCompletion = (1u << 0),
30-
eDiskFileCompletion = (1u << 1),
31-
eDiskDirectoryCompletion = (1u << 2),
32-
eSymbolCompletion = (1u << 3),
33-
eModuleCompletion = (1u << 4),
34-
eSettingsNameCompletion = (1u << 5),
35-
ePlatformPluginCompletion = (1u << 6),
36-
eArchitectureCompletion = (1u << 7),
37-
eVariablePathCompletion = (1u << 8),
38-
eRegisterCompletion = (1u << 9),
39-
eBreakpointCompletion = (1u << 10),
40-
eProcessPluginCompletion = (1u << 11),
41-
eDisassemblyFlavorCompletion = (1u << 12),
42-
eTypeLanguageCompletion = (1u << 13),
43-
eFrameIndexCompletion = (1u << 14),
44-
eModuleUUIDCompletion = (1u << 15),
45-
eStopHookIDCompletion = (1u << 16),
46-
eThreadIndexCompletion = (1u << 17),
47-
eWatchPointIDCompletion = (1u << 18),
48-
eBreakpointNameCompletion = (1u << 19),
49-
eProcessIDCompletion = (1u << 20),
50-
eProcessNameCompletion = (1u << 21),
51-
eRemoteDiskFileCompletion = (1u << 22),
52-
eRemoteDiskDirectoryCompletion = (1u << 23),
53-
eTypeCategoryNameCompletion = (1u << 24),
54-
// This item serves two purposes. It is the last element in the enum, so
55-
// you can add custom enums starting from here in your Option class. Also
56-
// if you & in this bit the base code will not process the option.
57-
eCustomCompletion = (1u << 24)
58-
};
59-
6027
static bool InvokeCommonCompletionCallbacks(
6128
CommandInterpreter &interpreter, uint32_t completion_mask,
6229
lldb_private::CompletionRequest &request, SearchFilter *searcher);

lldb/include/lldb/Interpreter/CommandObject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class CommandObject : public std::enable_shared_from_this<CommandObject> {
8282
struct ArgumentTableEntry {
8383
lldb::CommandArgumentType arg_type;
8484
const char *arg_name;
85-
CommandCompletions::CommonCompletionTypes completion_type;
85+
lldb::CompletionType completion_type;
8686
OptionEnumValues enum_values;
8787
ArgumentHelpCallback help_function;
8888
const char *help_text;

0 commit comments

Comments
 (0)