Skip to content

Commit bcaa372

Browse files
authored
Merge pull request #15 from JDevlieghere/cherrypick/tablegen-deps
[LLDB] Cherrypick tablegen dependencies
2 parents f3b73e5 + bd555c1 commit bcaa372

28 files changed

+1491
-499
lines changed

lldb/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ endif()
3333
if (NOT LLDB_DISABLE_PYTHON)
3434
add_subdirectory(scripts)
3535
endif ()
36+
37+
add_subdirectory(utils/TableGen)
3638
add_subdirectory(source)
3739
add_subdirectory(tools)
3840
add_subdirectory(docs)

lldb/cmake/modules/AddLLDB.cmake

+34-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
1+
function(lldb_tablegen)
2+
# Syntax:
3+
# lldb_tablegen output-file [tablegen-arg ...] SOURCE source-file
4+
# [[TARGET cmake-target-name] [DEPENDS extra-dependency ...]]
5+
#
6+
# Generates a custom command for invoking tblgen as
7+
#
8+
# tblgen source-file -o=output-file tablegen-arg ...
9+
#
10+
# and, if cmake-target-name is provided, creates a custom target for
11+
# executing the custom command depending on output-file. It is
12+
# possible to list more files to depend after DEPENDS.
13+
14+
cmake_parse_arguments(LTG "" "SOURCE;TARGET" "" ${ARGN})
15+
16+
if(NOT LTG_SOURCE)
17+
message(FATAL_ERROR "SOURCE source-file required by lldb_tablegen")
18+
endif()
19+
20+
set(LLVM_TARGET_DEFINITIONS ${LTG_SOURCE})
21+
tablegen(LLDB ${LTG_UNPARSED_ARGUMENTS})
22+
23+
if(LTG_TARGET)
24+
add_public_tablegen_target(${LTG_TARGET})
25+
set_target_properties( ${LTG_TARGET} PROPERTIES FOLDER "LLDB tablegenning")
26+
set_property(GLOBAL APPEND PROPERTY LLDB_TABLEGEN_TARGETS ${LTG_TARGET})
27+
endif()
28+
endfunction(lldb_tablegen)
29+
130
function(add_lldb_library name)
31+
include_directories(BEFORE
32+
${CMAKE_CURRENT_BINARY_DIR}
33+
)
34+
235
# only supported parameters to this macro are the optional
336
# MODULE;SHARED;STATIC library type and source files
437
cmake_parse_arguments(PARAM
@@ -236,4 +269,4 @@ function(lldb_setup_rpaths name)
236269
BUILD_RPATH "${LIST_BUILD_RPATH}"
237270
INSTALL_RPATH "${LIST_INSTALL_RPATH}"
238271
)
239-
endfunction()
272+
endfunction()

lldb/source/Commands/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
lldb_tablegen(Options.inc -gen-lldb-option-defs
2+
SOURCE Options.td
3+
TARGET LLDBOptionsGen)
4+
15
add_lldb_library(lldbCommands
26
CommandCompletions.cpp
37
CommandObjectApropos.cpp
@@ -45,3 +49,5 @@ add_lldb_library(lldbCommands
4549
LINK_COMPONENTS
4650
Support
4751
)
52+
53+
add_dependencies(lldbCommands LLDBOptionsGen)

lldb/source/Commands/CommandObjectBreakpoint.cpp

+20-133
Large diffs are not rendered by default.

lldb/source/Commands/CommandObjectBreakpointCommand.cpp

+4-10
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,8 @@ static constexpr OptionEnumValues ScriptOptionEnum() {
4545
}
4646

4747
static constexpr OptionDefinition g_breakpoint_add_options[] = {
48-
// clang-format off
49-
{ LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." },
50-
{ LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Specify whether breakpoint command execution should terminate on error." },
51-
{ LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, nullptr, ScriptOptionEnum(), 0, eArgTypeNone, "Specify the language for the commands - if none is specified, the lldb command interpreter will be used." },
52-
{ LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonFunction, "Give the name of a Python function to run as command for this breakpoint. Be sure to give a module name if appropriate." },
53-
{ LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Sets Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets." },
54-
// clang-format on
48+
#define LLDB_OPTIONS_breakpoint_command_add
49+
#include "CommandOptions.inc"
5550
};
5651

5752
class CommandObjectBreakpointCommandAdd : public CommandObjectParsed,
@@ -470,9 +465,8 @@ const char *CommandObjectBreakpointCommandAdd::g_reader_instructions =
470465
// CommandObjectBreakpointCommandDelete
471466

472467
static constexpr OptionDefinition g_breakpoint_delete_options[] = {
473-
// clang-format off
474-
{ LLDB_OPT_SET_1, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Delete commands from Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets." },
475-
// clang-format on
468+
#define LLDB_OPTIONS_breakpoint_command_delete
469+
#include "CommandOptions.inc"
476470
};
477471

478472
class CommandObjectBreakpointCommandDelete : public CommandObjectParsed {

lldb/source/Commands/CommandObjectCommands.cpp

+12-28
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,8 @@ using namespace lldb_private;
3232
// CommandObjectCommandsSource
3333

3434
static constexpr OptionDefinition g_history_options[] = {
35-
// clang-format off
36-
{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "How many history commands to print." },
37-
{ LLDB_OPT_SET_1, false, "start-index", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Index at which to start printing history commands (or end to mean tail mode)." },
38-
{ LLDB_OPT_SET_1, false, "end-index", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Index at which to stop printing history commands." },
39-
{ LLDB_OPT_SET_2, false, "clear", 'C', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeBoolean, "Clears the current command history." },
40-
// clang-format on
35+
#define LLDB_OPTIONS_history
36+
#include "CommandOptions.inc"
4137
};
4238

4339
class CommandObjectCommandsHistory : public CommandObjectParsed {
@@ -189,11 +185,8 @@ class CommandObjectCommandsHistory : public CommandObjectParsed {
189185
// CommandObjectCommandsSource
190186

191187
static constexpr OptionDefinition g_source_options[] = {
192-
// clang-format off
193-
{ LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, stop executing commands on error." },
194-
{ LLDB_OPT_SET_ALL, false, "stop-on-continue", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, stop executing commands on continue." },
195-
{ LLDB_OPT_SET_ALL, false, "silent-run", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true don't echo commands while executing." },
196-
// clang-format on
188+
#define LLDB_OPTIONS_source
189+
#include "CommandOptions.inc"
197190
};
198191

199192
class CommandObjectCommandsSource : public CommandObjectParsed {
@@ -344,10 +337,8 @@ class CommandObjectCommandsSource : public CommandObjectParsed {
344337
// CommandObjectCommandsAlias
345338

346339
static constexpr OptionDefinition g_alias_options[] = {
347-
// clang-format off
348-
{ LLDB_OPT_SET_ALL, false, "help", 'h', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeHelpText, "Help text for this command" },
349-
{ LLDB_OPT_SET_ALL, false, "long-help", 'H', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeHelpText, "Long help text for this command" },
350-
// clang-format on
340+
#define LLDB_OPTIONS_alias
341+
#include "CommandOptions.inc"
351342
};
352343

353344
static const char *g_python_command_instructions =
@@ -912,10 +903,8 @@ class CommandObjectCommandsDelete : public CommandObjectParsed {
912903
// CommandObjectCommandsAddRegex
913904

914905
static constexpr OptionDefinition g_regex_options[] = {
915-
// clang-format off
916-
{ LLDB_OPT_SET_1, false, "help" , 'h', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNone, "The help text to display for this command." },
917-
{ LLDB_OPT_SET_1, false, "syntax", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNone, "A syntax string showing the typical usage syntax." },
918-
// clang-format on
906+
#define LLDB_OPTIONS_regex
907+
#include "CommandOptions.inc"
919908
};
920909

921910
#pragma mark CommandObjectCommandsAddRegex
@@ -1387,9 +1376,8 @@ class CommandObjectScriptingObject : public CommandObjectRaw {
13871376
// CommandObjectCommandsScriptImport
13881377

13891378
static constexpr OptionDefinition g_script_import_options[] = {
1390-
// clang-format off
1391-
{ LLDB_OPT_SET_1, false, "allow-reload", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow the script to be loaded even if it was already loaded before. This argument exists for backwards compatibility, but reloading is always allowed, whether you specify it or not." },
1392-
// clang-format on
1379+
#define LLDB_OPTIONS_script_import
1380+
#include "CommandOptions.inc"
13931381
};
13941382

13951383
class CommandObjectCommandsScriptImport : public CommandObjectParsed {
@@ -1521,12 +1509,8 @@ static constexpr OptionEnumValues ScriptSynchroType() {
15211509
}
15221510

15231511
static constexpr OptionDefinition g_script_add_options[] = {
1524-
// clang-format off
1525-
{ LLDB_OPT_SET_1, false, "function", 'f', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonFunction, "Name of the Python function to bind to this command name." },
1526-
{ LLDB_OPT_SET_2, false, "class", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonClass, "Name of the Python class to bind to this command name." },
1527-
{ LLDB_OPT_SET_1, false, "help" , 'h', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeHelpText, "The help text to display for this command." },
1528-
{ LLDB_OPT_SET_ALL, false, "synchronicity", 's', OptionParser::eRequiredArgument, nullptr, ScriptSynchroType(), 0, eArgTypeScriptedCommandSynchronicity, "Set the synchronicity of this command's executions with regard to LLDB event system." },
1529-
// clang-format on
1512+
#define LLDB_OPTIONS_script_add
1513+
#include "CommandOptions.inc"
15301514
};
15311515

15321516
class CommandObjectCommandsScriptAdd : public CommandObjectParsed,

lldb/source/Commands/CommandObjectDisassemble.cpp

+2-24
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,8 @@ using namespace lldb;
3131
using namespace lldb_private;
3232

3333
static constexpr OptionDefinition g_disassemble_options[] = {
34-
// clang-format off
35-
{ LLDB_OPT_SET_ALL, false, "bytes", 'b', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Show opcode bytes when disassembling." },
36-
{ LLDB_OPT_SET_ALL, false, "context", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNumLines, "Number of context lines of source to show." },
37-
{ LLDB_OPT_SET_ALL, false, "mixed", 'm', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Enable mixed source and assembly display." },
38-
{ LLDB_OPT_SET_ALL, false, "raw", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Print raw disassembly with no symbol information." },
39-
{ LLDB_OPT_SET_ALL, false, "plugin", 'P', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePlugin, "Name of the disassembler plugin you want to use." },
40-
{ LLDB_OPT_SET_ALL, false, "flavor", 'F', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeDisassemblyFlavor, "Name of the disassembly flavor you want to use. "
41-
"Currently the only valid options are default, and for Intel "
42-
"architectures, att and intel." },
43-
{ LLDB_OPT_SET_ALL, false, "arch", 'A', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeArchitecture, "Specify the architecture to use from cross disassembly." },
44-
{ LLDB_OPT_SET_1 |
45-
LLDB_OPT_SET_2, true, "start-address", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Address at which to start disassembling." },
46-
{ LLDB_OPT_SET_1, false, "end-address", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Address at which to end disassembling." },
47-
{ LLDB_OPT_SET_2 |
48-
LLDB_OPT_SET_3 |
49-
LLDB_OPT_SET_4 |
50-
LLDB_OPT_SET_5, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNumLines, "Number of instructions to display." },
51-
{ LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Disassemble entire contents of the given function name." },
52-
{ LLDB_OPT_SET_4, false, "frame", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Disassemble from the start of the current frame's function." },
53-
{ LLDB_OPT_SET_5, false, "pc", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Disassemble around the current pc." },
54-
{ LLDB_OPT_SET_6, false, "line", 'l', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Disassemble the current frame's current source line instructions if there is debug line "
55-
"table information, else disassemble around the pc." },
56-
{ LLDB_OPT_SET_7, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Disassemble function containing this address." },
57-
// clang-format on
34+
#define LLDB_OPTIONS_disassemble
35+
#include "CommandOptions.inc"
5836
};
5937

6038
CommandObjectDisassemble::CommandOptions::CommandOptions()

lldb/source/Commands/CommandObjectExpression.cpp

+2-17
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,8 @@ static constexpr OptionEnumValues DescriptionVerbosityTypes() {
4848
}
4949

5050
static constexpr OptionDefinition g_expression_options[] = {
51-
// clang-format off
52-
{LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "all-threads", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Should we run all threads if the execution doesn't complete on one thread."},
53-
{LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "ignore-breakpoints", 'i', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Ignore breakpoint hits while running expressions"},
54-
{LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "timeout", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Timeout value (in microseconds) for running the expression."},
55-
{LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error", 'u', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, or raises a signal. "
56-
"Note, unlike gdb hitting a breakpoint is controlled by another option (-i)."},
57-
{LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "debug", 'g', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "When specified, debug the JIT code by setting a breakpoint on the first instruction "
58-
"and forcing breakpoints to not be ignored (-i0) and no unwinding to happen on error (-u0)."},
59-
{LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Specifies the Language to use when parsing the expression. If not set the target.language "
60-
"setting is used." },
61-
{LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "apply-fixits", 'X', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "If true, simple fix-it hints will be automatically applied to the expression." },
62-
{LLDB_OPT_SET_1, false, "description-verbosity", 'v', OptionParser::eOptionalArgument, nullptr, DescriptionVerbosityTypes(), 0, eArgTypeDescriptionVerbosity, "How verbose should the output of this expression be, if the object description is asked for."},
63-
{LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Interpret the expression as a complete translation unit, without injecting it into the local "
64-
"context. Allows declaration of persistent, top-level entities without a $ prefix."},
65-
{LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "allow-jit", 'j', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Controls whether the expression can fall back to being JITted if it's not supported by "
66-
"the interpreter (defaults to true)."}
67-
// clang-format on
51+
#define LLDB_OPTIONS_expression
52+
#include "CommandOptions.inc"
6853
};
6954

7055
Status CommandObjectExpression::CommandOptions::SetOptionValue(

lldb/source/Commands/CommandObjectFrame.cpp

+6-14
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,8 @@ using namespace lldb_private;
5555
// CommandObjectFrameDiagnose
5656

5757
static constexpr OptionDefinition g_frame_diag_options[] = {
58-
// clang-format off
59-
{ LLDB_OPT_SET_1, false, "register", 'r', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeRegisterName, "A register to diagnose." },
60-
{ LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddress, "An address to diagnose." },
61-
{ LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOffset, "An optional offset. Requires --register." }
62-
// clang-format on
58+
#define LLDB_OPTIONS_frame_diag
59+
#include "CommandOptions.inc"
6360
};
6461

6562
class CommandObjectFrameDiagnose : public CommandObjectParsed {
@@ -239,9 +236,8 @@ class CommandObjectFrameInfo : public CommandObjectParsed {
239236
// CommandObjectFrameSelect
240237

241238
static OptionDefinition g_frame_select_options[] = {
242-
// clang-format off
243-
{ LLDB_OPT_SET_1, false, "relative", 'r', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOffset, "A relative frame index offset from the current frame index." },
244-
// clang-format on
239+
#define LLDB_OPTIONS_frame_select
240+
#include "CommandOptions.inc"
245241
};
246242

247243
class CommandObjectFrameSelect : public CommandObjectParsed {
@@ -745,12 +741,8 @@ class CommandObjectFrameVariable : public CommandObjectParsed {
745741
#pragma mark CommandObjectFrameRecognizer
746742

747743
static OptionDefinition g_frame_recognizer_add_options[] = {
748-
// clang-format off
749-
{ LLDB_OPT_SET_ALL, false, "shlib", 's', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Name of the module or shared library that this recognizer applies to." },
750-
{ LLDB_OPT_SET_ALL, false, "function", 'n', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSymbolCompletion, eArgTypeName, "Name of the function that this recognizer applies to." },
751-
{ LLDB_OPT_SET_2, false, "python-class", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonClass, "Give the name of a Python class to use for this frame recognizer." },
752-
{ LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Function name and module name are actually regular expressions." }
753-
// clang-format on
744+
#define LLDB_OPTIONS_frame_recognizer_add
745+
#include "CommandOptions.inc"
754746
};
755747

756748
class CommandObjectFrameRecognizerAdd : public CommandObjectParsed {

0 commit comments

Comments
 (0)