Skip to content

Commit 2359fec

Browse files
committed
[lldb][NFC] Tablegenify platform
llvm-svn: 366891
1 parent c7e55d4 commit 2359fec

File tree

2 files changed

+112
-46
lines changed

2 files changed

+112
-46
lines changed

lldb/source/Commands/CommandObjectPlatform.cpp

+12-46
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,8 @@ static mode_t ParsePermissionString(llvm::StringRef permissions) {
5959
}
6060

6161
static constexpr OptionDefinition g_permissions_options[] = {
62-
// clang-format off
63-
{LLDB_OPT_SET_ALL, false, "permissions-value", 'v', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePermissionsNumber, "Give out the numeric value for permissions (e.g. 757)"},
64-
{LLDB_OPT_SET_ALL, false, "permissions-string", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePermissionsString, "Give out the string value for permissions (e.g. rwxr-xr--)."},
65-
{LLDB_OPT_SET_ALL, false, "user-read", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow user to read."},
66-
{LLDB_OPT_SET_ALL, false, "user-write", 'w', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow user to write."},
67-
{LLDB_OPT_SET_ALL, false, "user-exec", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow user to execute."},
68-
{LLDB_OPT_SET_ALL, false, "group-read", 'R', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow group to read."},
69-
{LLDB_OPT_SET_ALL, false, "group-write", 'W', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow group to write."},
70-
{LLDB_OPT_SET_ALL, false, "group-exec", 'X', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow group to execute."},
71-
{LLDB_OPT_SET_ALL, false, "world-read", 'd', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow world to read."},
72-
{LLDB_OPT_SET_ALL, false, "world-write", 't', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow world to write."},
73-
{LLDB_OPT_SET_ALL, false, "world-exec", 'e', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow world to execute."},
74-
// clang-format on
62+
#define LLDB_OPTIONS_permissions
63+
#include "CommandObject.inc"
7564
};
7665

7766
class OptionPermissions : public OptionGroup {
@@ -586,10 +575,8 @@ class CommandObjectPlatformFClose : public CommandObjectParsed {
586575
// "platform fread"
587576

588577
static constexpr OptionDefinition g_platform_fread_options[] = {
589-
// clang-format off
590-
{ LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeIndex, "Offset into the file at which to start reading." },
591-
{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount, "Number of bytes to read from the file." },
592-
// clang-format on
578+
#define LLDB_OPTIONS_platform_fread
579+
#include "CommandOptions.inc"
593580
};
594581

595582
class CommandObjectPlatformFRead : public CommandObjectParsed {
@@ -679,10 +666,8 @@ class CommandObjectPlatformFRead : public CommandObjectParsed {
679666
// "platform fwrite"
680667

681668
static constexpr OptionDefinition g_platform_fwrite_options[] = {
682-
// clang-format off
683-
{ LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeIndex, "Offset into the file at which to start reading." },
684-
{ LLDB_OPT_SET_1, false, "data", 'd', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeValue, "Text to write to the file." },
685-
// clang-format on
669+
#define LLDB_OPTIONS_platform_fwrite
670+
#include "CommandOptions.inc"
686671
};
687672

688673
class CommandObjectPlatformFWrite : public CommandObjectParsed {
@@ -1057,22 +1042,8 @@ class CommandObjectPlatformProcessLaunch : public CommandObjectParsed {
10571042
// "platform process list"
10581043

10591044
static OptionDefinition g_platform_process_list_options[] = {
1060-
// clang-format off
1061-
{ LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePid, "List the process info for a specific process ID." },
1062-
{ LLDB_OPT_SET_2, true, "name", 'n', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName, "Find processes with executable basenames that match a string." },
1063-
{ LLDB_OPT_SET_3, true, "ends-with", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName, "Find processes with executable basenames that end with a string." },
1064-
{ LLDB_OPT_SET_4, true, "starts-with", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName, "Find processes with executable basenames that start with a string." },
1065-
{ LLDB_OPT_SET_5, true, "contains", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName, "Find processes with executable basenames that contain a string." },
1066-
{ LLDB_OPT_SET_6, true, "regex", 'r', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeRegularExpression, "Find processes with executable basenames that match a regular expression." },
1067-
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "parent", 'P', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePid, "Find processes that have a matching parent process ID." },
1068-
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "uid", 'u', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Find processes that have a matching user ID." },
1069-
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "euid", 'U', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Find processes that have a matching effective user ID." },
1070-
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "gid", 'g', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Find processes that have a matching group ID." },
1071-
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "egid", 'G', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Find processes that have a matching effective group ID." },
1072-
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "arch", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeArchitecture, "Find processes that have a matching architecture." },
1073-
{ LLDB_OPT_SET_FROM_TO(1, 6), false, "show-args", 'A', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Show process arguments instead of the process executable basename." },
1074-
{ LLDB_OPT_SET_FROM_TO(1, 6), false, "verbose", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Enable verbose output." },
1075-
// clang-format on
1045+
#define LLDB_OPTIONS_platform_process_list
1046+
#include "CommandOptions.inc"
10761047
};
10771048

10781049
class CommandObjectPlatformProcessList : public CommandObjectParsed {
@@ -1437,12 +1408,8 @@ class CommandObjectPlatformProcessInfo : public CommandObjectParsed {
14371408
};
14381409

14391410
static constexpr OptionDefinition g_platform_process_attach_options[] = {
1440-
// clang-format off
1441-
{ LLDB_OPT_SET_ALL, false, "plugin", 'P', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePlugin, "Name of the process plugin you want to use." },
1442-
{ LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePid, "The process ID of an existing process to attach to." },
1443-
{ LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName, "The name of the process to attach to." },
1444-
{ LLDB_OPT_SET_2, false, "waitfor", 'w', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Wait for the process with <process-name> to launch." },
1445-
// clang-format on
1411+
#define LLDB_OPTIONS_platform_process_attach
1412+
#include "CommandOptions.inc"
14461413
};
14471414

14481415
class CommandObjectPlatformProcessAttach : public CommandObjectParsed {
@@ -1616,9 +1583,8 @@ class CommandObjectPlatformProcess : public CommandObjectMultiword {
16161583

16171584
// "platform shell"
16181585
static constexpr OptionDefinition g_platform_shell_options[] = {
1619-
// clang-format off
1620-
{ LLDB_OPT_SET_ALL, false, "timeout", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeValue, "Seconds to wait for the remote host to finish running the command." },
1621-
// clang-format on
1586+
#define LLDB_OPTIONS_platform_shell
1587+
#include "CommandOptions.inc"
16221588
};
16231589

16241590
class CommandObjectPlatformShell : public CommandObjectRaw {

lldb/source/Commands/Options.td

+100
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,106 @@ let Command = "regex" in {
370370
Desc<"A syntax string showing the typical usage syntax.">;
371371
}
372372

373+
let Command = "permissions" in {
374+
def permissions_permissions_value : Option<"permissions-value", "v">,
375+
Arg<"PermissionsNumber">,
376+
Desc<"Give out the numeric value for permissions (e.g. 757)">;
377+
def permissions_permissions_string : Option<"permissions-string", "s">,
378+
Arg<"PermissionsString">,
379+
Desc<"Give out the string value for permissions (e.g. rwxr-xr--).">;
380+
def permissions_user_read : Option<"user-read", "r">,
381+
Desc<"Allow user to read.">;
382+
def permissions_user_write : Option<"user-write", "w">,
383+
Desc<"Allow user to write.">;
384+
def permissions_user_exec : Option<"user-exec", "x">,
385+
Desc<"Allow user to execute.">;
386+
def permissions_group_read : Option<"group-read", "R">,
387+
Desc<"Allow group to read.">;
388+
def permissions_group_write : Option<"group-write", "W">,
389+
Desc<"Allow group to write.">;
390+
def permissions_group_exec : Option<"group-exec", "X">,
391+
Desc<"Allow group to execute.">;
392+
def permissions_world_read : Option<"world-read", "d">,
393+
Desc<"Allow world to read.">;
394+
def permissions_world_write : Option<"world-write", "t">,
395+
Desc<"Allow world to write.">;
396+
def permissions_world_exec : Option<"world-exec", "e">,
397+
Desc<"Allow world to execute.">;
398+
}
399+
400+
let Command = "platform fread" in {
401+
def platform_fread_offset : Option<"offset", "o">, Group<1>, Arg<"Index">,
402+
Desc<"Offset into the file at which to start reading.">;
403+
def platform_fread_count : Option<"count", "c">, Group<1>, Arg<"Count">,
404+
Desc<"Number of bytes to read from the file.">;
405+
}
406+
407+
let Command = "platform fwrite" in {
408+
def platform_fwrite_offset : Option<"offset", "o">, Group<1>, Arg<"Index">,
409+
Desc<"Offset into the file at which to start reading.">;
410+
def platform_fwrite_data : Option<"data", "d">, Group<1>, Arg<"Value">,
411+
Desc<"Text to write to the file.">;
412+
}
413+
414+
let Command = "platform process list" in {
415+
def platform_process_list_pid : Option<"pid", "p">, Group<1>, Arg<"Pid">,
416+
Desc<"List the process info for a specific process ID.">;
417+
def platform_process_list_name : Option<"name", "n">, Group<2>,
418+
Arg<"ProcessName">, Required,
419+
Desc<"Find processes with executable basenames that match a string.">;
420+
def platform_process_list_ends_with : Option<"ends-with", "e">, Group<3>,
421+
Arg<"ProcessName">, Required,
422+
Desc<"Find processes with executable basenames that end with a string.">;
423+
def platform_process_list_starts_with : Option<"starts-with", "s">, Group<4>,
424+
Arg<"ProcessName">, Required,
425+
Desc<"Find processes with executable basenames that start with a string.">;
426+
def platform_process_list_contains : Option<"contains", "c">, Group<5>,
427+
Arg<"ProcessName">, Required,
428+
Desc<"Find processes with executable basenames that contain a string.">;
429+
def platform_process_list_regex : Option<"regex", "r">, Group<6>,
430+
Arg<"RegularExpression">, Required,
431+
Desc<"Find processes with executable basenames that match a regular "
432+
"expression.">;
433+
def platform_process_list_parent : Option<"parent", "P">, OptionRange<2, 6>,
434+
Arg<"Pid">, Desc<"Find processes that have a matching parent process ID.">;
435+
def platform_process_list_uid : Option<"uid", "u">, OptionRange<2, 6>,
436+
Arg<"UnsignedInteger">,
437+
Desc<"Find processes that have a matching user ID.">;
438+
def platform_process_list_euid : Option<"euid", "U">, OptionRange<2, 6>,
439+
Arg<"UnsignedInteger">,
440+
Desc<"Find processes that have a matching effective user ID.">;
441+
def platform_process_list_gid : Option<"gid", "g">, OptionRange<2, 6>,
442+
Arg<"UnsignedInteger">,
443+
Desc<"Find processes that have a matching group ID.">;
444+
def platform_process_list_egid : Option<"egid", "G">, OptionRange<2, 6>,
445+
Arg<"UnsignedInteger">,
446+
Desc<"Find processes that have a matching effective group ID.">;
447+
def platform_process_list_arch : Option<"arch", "a">, OptionRange<2, 6>,
448+
Arg<"Architecture">,
449+
Desc<"Find processes that have a matching architecture.">;
450+
def platform_process_list_show_args : Option<"show-args", "A">,
451+
OptionRange<1, 6>,
452+
Desc<"Show process arguments instead of the process executable basename.">;
453+
def platform_process_list_verbose : Option<"verbose", "v">, OptionRange<1, 6>,
454+
Desc<"Enable verbose output.">;
455+
}
456+
457+
let Command = "platform process attach" in {
458+
def platform_process_attach_plugin : Option<"plugin", "P">, Arg<"Plugin">,
459+
Desc<"Name of the process plugin you want to use.">;
460+
def platform_process_attach_pid : Option<"pid", "p">, Group<1>, Arg<"Pid">,
461+
Desc<"The process ID of an existing process to attach to.">;
462+
def platform_process_attach_name : Option<"name", "n">, Group<2>,
463+
Arg<"ProcessName">, Desc<"The name of the process to attach to.">;
464+
def platform_process_attach_waitfor : Option<"waitfor", "w">, Group<2>,
465+
Desc<"Wait for the process with <process-name> to launch.">;
466+
}
467+
468+
let Command = "platform shell" in {
469+
def platform_shell_timeout : Option<"timeout", "t">, Arg<"Value">,
470+
Desc<"Seconds to wait for the remote host to finish running the command.">;
471+
}
472+
373473
let Command = "process attach" in {
374474
def process_attach_continue : Option<"continue", "c">,
375475
Desc<"Immediately continue the process once attached.">;

0 commit comments

Comments
 (0)