Skip to content

Commit 0cadf7b

Browse files
committed
[lldb] Tablegenify thread commands and fix completion bug for thread step-*
Beside turning the options into the new tablegen format, this patch also fixes that a few commands had source file completions for the "count" and "end-linenumber" arguments (which both accepted only integers). Reason for that are that somehow we added a '1' instead of our usual '0' value to the initial value for completion. llvm-svn: 366425
1 parent 7823902 commit 0cadf7b

File tree

2 files changed

+100
-39
lines changed

2 files changed

+100
-39
lines changed

lldb/source/Commands/CommandObjectThread.cpp

+14-39
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,8 @@ class CommandObjectIterateOverThreads : public CommandObjectParsed {
239239
// CommandObjectThreadBacktrace
240240

241241
static constexpr OptionDefinition g_thread_backtrace_options[] = {
242-
// clang-format off
243-
{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount, "How many frames to display (-1 for all)" },
244-
{ LLDB_OPT_SET_1, false, "start", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace" },
245-
{ LLDB_OPT_SET_1, false, "extended", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Show the extended backtrace, if available" }
246-
// clang-format on
242+
#define LLDB_OPTIONS_thread_backtrace
243+
#include "CommandOptions.inc"
247244
};
248245

249246
class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads {
@@ -407,16 +404,8 @@ static constexpr OptionEnumValues TriRunningModes() {
407404
}
408405

409406
static constexpr OptionDefinition g_thread_step_scope_options[] = {
410-
// clang-format off
411-
{ LLDB_OPT_SET_1, false, "step-in-avoids-no-debug", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "A boolean value that sets whether stepping into functions will step over functions with no debug information." },
412-
{ LLDB_OPT_SET_1, false, "step-out-avoids-no-debug", 'A', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "A boolean value, if true stepping out of functions will continue to step out till it hits a function with debug information." },
413-
{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 1, eArgTypeCount, "How many times to perform the stepping operation - currently only supported for step-inst and next-inst." },
414-
{ LLDB_OPT_SET_1, false, "end-linenumber", 'e', OptionParser::eRequiredArgument, nullptr, {}, 1, eArgTypeLineNum, "The line at which to stop stepping - defaults to the next line and only supported for step-in and step-over. You can also pass the string 'block' to step to the end of the current block. This is particularly useful in conjunction with --step-target to step through a complex calling sequence." },
415-
{ LLDB_OPT_SET_1, false, "run-mode", 'm', OptionParser::eRequiredArgument, nullptr, TriRunningModes(), 0, eArgTypeRunMode, "Determine how to run other threads while stepping the current thread." },
416-
{ LLDB_OPT_SET_1, false, "step-over-regexp", 'r', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeRegularExpression, "A regular expression that defines function names to not to stop at when stepping in." },
417-
{ LLDB_OPT_SET_1, false, "step-in-target", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFunctionName, "The name of the directly called function step in should stop at when stepping into." },
418-
{ LLDB_OPT_SET_2, false, "python-class", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonClass, "The name of the class that will manage this step - only supported for Scripted Step." }
419-
// clang-format on
407+
#define LLDB_OPTIONS_thread_step_scope
408+
#include "CommandOptions.inc"
420409
};
421410

422411
class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed {
@@ -995,12 +984,8 @@ static constexpr OptionEnumValues DuoRunningModes() {
995984
}
996985

997986
static constexpr OptionDefinition g_thread_until_options[] = {
998-
// clang-format off
999-
{ LLDB_OPT_SET_1, false, "frame", 'f', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0" },
1000-
{ LLDB_OPT_SET_1, false, "thread", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation" },
1001-
{ LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, nullptr, DuoRunningModes(), 0, eArgTypeRunMode, "Determine how to run other threads while stepping this one" },
1002-
{ LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Run until we reach the specified address, or leave the function - can be specified multiple times." }
1003-
// clang-format on
987+
#define LLDB_OPTIONS_thread_until
988+
#include "CommandOptions.inc"
1004989
};
1005990

1006991
class CommandObjectThreadUntil : public CommandObjectParsed {
@@ -1419,10 +1404,8 @@ class CommandObjectThreadList : public CommandObjectParsed {
14191404
// CommandObjectThreadInfo
14201405

14211406
static constexpr OptionDefinition g_thread_info_options[] = {
1422-
// clang-format off
1423-
{ LLDB_OPT_SET_ALL, false, "json", 'j', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the thread info in JSON format." },
1424-
{ LLDB_OPT_SET_ALL, false, "stop-info", 's', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the extended stop info in JSON format." }
1425-
// clang-format on
1407+
#define LLDB_OPTIONS_thread_info
1408+
#include "CommandOptions.inc"
14261409
};
14271410

14281411
class CommandObjectThreadInfo : public CommandObjectIterateOverThreads {
@@ -1555,9 +1538,8 @@ class CommandObjectThreadException : public CommandObjectIterateOverThreads {
15551538
// CommandObjectThreadReturn
15561539

15571540
static constexpr OptionDefinition g_thread_return_options[] = {
1558-
// clang-format off
1559-
{ LLDB_OPT_SET_ALL, false, "from-expression", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Return from the innermost expression evaluation." }
1560-
// clang-format on
1541+
#define LLDB_OPTIONS_thread_return
1542+
#include "CommandOptions.inc"
15611543
};
15621544

15631545
class CommandObjectThreadReturn : public CommandObjectRaw {
@@ -1731,13 +1713,8 @@ class CommandObjectThreadReturn : public CommandObjectRaw {
17311713
// CommandObjectThreadJump
17321714

17331715
static constexpr OptionDefinition g_thread_jump_options[] = {
1734-
// clang-format off
1735-
{ LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "Specifies the source file to jump to." },
1736-
{ LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLineNum, "Specifies the line number to jump to." },
1737-
{ LLDB_OPT_SET_2, true, "by", 'b', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOffset, "Jumps by a relative line offset from the current line." },
1738-
{ LLDB_OPT_SET_3, true, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Jumps to a specific address." },
1739-
{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "force", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allows the PC to leave the current function." }
1740-
// clang-format on
1716+
#define LLDB_OPTIONS_thread_jump
1717+
#include "CommandOptions.inc"
17411718
};
17421719

17431720
class CommandObjectThreadJump : public CommandObjectParsed {
@@ -1879,10 +1856,8 @@ class CommandObjectThreadJump : public CommandObjectParsed {
18791856
// CommandObjectThreadPlanList
18801857

18811858
static constexpr OptionDefinition g_thread_plan_list_options[] = {
1882-
// clang-format off
1883-
{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display more information about the thread plans" },
1884-
{ LLDB_OPT_SET_1, false, "internal", 'i', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display internal as well as user thread plans" }
1885-
// clang-format on
1859+
#define LLDB_OPTIONS_thread_plan_list
1860+
#include "CommandOptions.inc"
18861861
};
18871862

18881863
class CommandObjectThreadPlanList : public CommandObjectIterateOverThreads {

lldb/source/Commands/Options.td

+86
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,92 @@ let Command = "breakpoint list" in {
5252
"provided, which prime new targets.">;
5353
}
5454

55+
let Command = "thread backtrace" in {
56+
def thread_backtrace_count : Option<"count", "c">, Group<1>, Arg<"Count">,
57+
Desc<"How many frames to display (-1 for all)">;
58+
def thread_backtrace_start : Option<"start", "s">, Group<1>,
59+
Arg<"FrameIndex">, Desc<"Frame in which to start the backtrace">;
60+
def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
61+
Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
62+
}
63+
64+
let Command = "thread step scope" in {
65+
def thread_step_scope_step_in_avoids_no_debug :
66+
Option<"step-in-avoids-no-debug", "a">, Group<1>, Arg<"Boolean">,
67+
Desc<"A boolean value that sets whether stepping into functions will step "
68+
"over functions with no debug information.">;
69+
def thread_step_scope_step_out_avoids_no_debug :
70+
Option<"step-out-avoids-no-debug", "A">, Group<1>, Arg<"Boolean">,
71+
Desc<"A boolean value, if true stepping out of functions will continue to"
72+
" step out till it hits a function with debug information.">;
73+
def thread_step_scope_count : Option<"count", "c">, Group<1>, Arg<"Count">,
74+
Desc<"How many times to perform the stepping operation - currently only "
75+
"supported for step-inst and next-inst.">;
76+
def thread_step_scope_end_linenumber : Option<"end-linenumber", "e">,
77+
Group<1>, Arg<"LineNum">, Desc<"The line at which to stop stepping - "
78+
"defaults to the next line and only supported for step-in and step-over."
79+
" You can also pass the string 'block' to step to the end of the current"
80+
" block. This is particularly use in conjunction with --step-target to"
81+
" step through a complex calling sequence.">;
82+
def thread_step_scope_run_mode : Option<"run-mode", "m">, Group<1>,
83+
EnumArg<"RunMode", "TriRunningModes()">, Desc<"Determine how to run other "
84+
"threads while stepping the current thread.">;
85+
def thread_step_scope_step_over_regexp : Option<"step-over-regexp", "r">,
86+
Group<1>, Arg<"RegularExpression">, Desc<"A regular expression that defines"
87+
"function names to not to stop at when stepping in.">;
88+
def thread_step_scope_step_in_target : Option<"step-in-target", "t">,
89+
Group<1>, Arg<"FunctionName">, Desc<"The name of the directly called "
90+
"function step in should stop at when stepping into.">;
91+
def thread_step_scope_python_class : Option<"python-class", "C">, Group<2>,
92+
Arg<"PythonClass">, Desc<"The name of the class that will manage this step "
93+
"- only supported for Scripted Step.">;
94+
}
95+
96+
let Command = "thread until" in {
97+
def thread_until_frame : Option<"frame", "f">, Group<1>, Arg<"FrameIndex">,
98+
Desc<"Frame index for until operation - defaults to 0">;
99+
def thread_until_thread : Option<"thread", "t">, Group<1>, Arg<"ThreadIndex">,
100+
Desc<"Thread index for the thread for until operation">;
101+
def thread_until_run_mode : Option<"run-mode", "m">, Group<1>,
102+
EnumArg<"RunMode", "DuoRunningModes()">, Desc<"Determine how to run other"
103+
"threads while stepping this one">;
104+
def thread_until_address : Option<"address", "a">, Group<1>,
105+
Arg<"AddressOrExpression">, Desc<"Run until we reach the specified address,"
106+
"or leave the function - can be specified multiple times.">;
107+
}
108+
109+
let Command = "thread info" in {
110+
def thread_info_json : Option<"json", "j">, Desc<"Display the thread info in"
111+
" JSON format.">;
112+
def thread_info_stop_info : Option<"stop-info", "s">, Desc<"Display the "
113+
"extended stop info in JSON format.">;
114+
}
115+
116+
let Command = "thread return" in {
117+
def thread_return_from_expression : Option<"from-expression", "x">,
118+
Desc<"Return from the innermost expression evaluation.">;
119+
}
120+
121+
let Command = "thread jump" in {
122+
def thread_jump_file : Option<"file", "f">, Group<1>, Arg<"Filename">,
123+
Completion<"SourceFile">, Desc<"Specifies the source file to jump to.">;
124+
def thread_jump_line : Option<"line", "l">, Group<1>, Arg<"LineNum">,
125+
Required, Desc<"Specifies the line number to jump to.">;
126+
def thread_jump_by : Option<"by", "b">, Group<2>, Arg<"Offset">, Required,
127+
Desc<"Jumps by a relative line offset from the current line.">;
128+
def thread_jump_address : Option<"address", "a">, Group<3>,
129+
Arg<"AddressOrExpression">, Required, Desc<"Jumps to a specific address.">;
130+
def thread_jump_force : Option<"force", "r">, Groups<[1,2,3]>,
131+
Desc<"Allows the PC to leave the current function.">;
132+
}
133+
134+
let Command = "thread plan list" in {
135+
def thread_plan_list_verbose : Option<"verbose", "v">, Group<1>,
136+
Desc<"Display more information about the thread plans">;
137+
def thread_plan_list_internal : Option<"internal", "i">, Group<1>,
138+
Desc<"Display internal as well as user thread plans">;
139+
}
140+
55141
let Command = "type summary add" in {
56142
def type_summary_add_category : Option<"category", "w">, Arg<"Name">, Desc<"Add this to the given category instead of the default one.">;
57143
def type_summary_add_cascade : Option<"cascade", "C">, Arg<"Boolean">, Desc<"If true, cascade through typedef chains.">;

0 commit comments

Comments
 (0)