Skip to content

Commit

Permalink
[lldb][NFC] Tablegenify platform
Browse files Browse the repository at this point in the history
llvm-svn: 366891
  • Loading branch information
Teemperor committed Jul 24, 2019
1 parent c7e55d4 commit 2359fec
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 46 deletions.
58 changes: 12 additions & 46 deletions lldb/source/Commands/CommandObjectPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,8 @@ static mode_t ParsePermissionString(llvm::StringRef permissions) {
}

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

class OptionPermissions : public OptionGroup {
Expand Down Expand Up @@ -586,10 +575,8 @@ class CommandObjectPlatformFClose : public CommandObjectParsed {
// "platform fread"

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

class CommandObjectPlatformFRead : public CommandObjectParsed {
Expand Down Expand Up @@ -679,10 +666,8 @@ class CommandObjectPlatformFRead : public CommandObjectParsed {
// "platform fwrite"

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

class CommandObjectPlatformFWrite : public CommandObjectParsed {
Expand Down Expand Up @@ -1057,22 +1042,8 @@ class CommandObjectPlatformProcessLaunch : public CommandObjectParsed {
// "platform process list"

static OptionDefinition g_platform_process_list_options[] = {
// clang-format off
{ LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePid, "List the process info for a specific process ID." },
{ LLDB_OPT_SET_2, true, "name", 'n', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName, "Find processes with executable basenames that match a string." },
{ LLDB_OPT_SET_3, true, "ends-with", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName, "Find processes with executable basenames that end with a string." },
{ LLDB_OPT_SET_4, true, "starts-with", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName, "Find processes with executable basenames that start with a string." },
{ LLDB_OPT_SET_5, true, "contains", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName, "Find processes with executable basenames that contain a string." },
{ LLDB_OPT_SET_6, true, "regex", 'r', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeRegularExpression, "Find processes with executable basenames that match a regular expression." },
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "parent", 'P', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePid, "Find processes that have a matching parent process ID." },
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "uid", 'u', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Find processes that have a matching user ID." },
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "euid", 'U', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Find processes that have a matching effective user ID." },
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "gid", 'g', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Find processes that have a matching group ID." },
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "egid", 'G', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Find processes that have a matching effective group ID." },
{ LLDB_OPT_SET_FROM_TO(2, 6), false, "arch", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeArchitecture, "Find processes that have a matching architecture." },
{ 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." },
{ LLDB_OPT_SET_FROM_TO(1, 6), false, "verbose", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Enable verbose output." },
// clang-format on
#define LLDB_OPTIONS_platform_process_list
#include "CommandOptions.inc"
};

class CommandObjectPlatformProcessList : public CommandObjectParsed {
Expand Down Expand Up @@ -1437,12 +1408,8 @@ class CommandObjectPlatformProcessInfo : public CommandObjectParsed {
};

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

class CommandObjectPlatformProcessAttach : public CommandObjectParsed {
Expand Down Expand Up @@ -1616,9 +1583,8 @@ class CommandObjectPlatformProcess : public CommandObjectMultiword {

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

class CommandObjectPlatformShell : public CommandObjectRaw {
Expand Down
100 changes: 100 additions & 0 deletions lldb/source/Commands/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,106 @@ let Command = "regex" in {
Desc<"A syntax string showing the typical usage syntax.">;
}

let Command = "permissions" in {
def permissions_permissions_value : Option<"permissions-value", "v">,
Arg<"PermissionsNumber">,
Desc<"Give out the numeric value for permissions (e.g. 757)">;
def permissions_permissions_string : Option<"permissions-string", "s">,
Arg<"PermissionsString">,
Desc<"Give out the string value for permissions (e.g. rwxr-xr--).">;
def permissions_user_read : Option<"user-read", "r">,
Desc<"Allow user to read.">;
def permissions_user_write : Option<"user-write", "w">,
Desc<"Allow user to write.">;
def permissions_user_exec : Option<"user-exec", "x">,
Desc<"Allow user to execute.">;
def permissions_group_read : Option<"group-read", "R">,
Desc<"Allow group to read.">;
def permissions_group_write : Option<"group-write", "W">,
Desc<"Allow group to write.">;
def permissions_group_exec : Option<"group-exec", "X">,
Desc<"Allow group to execute.">;
def permissions_world_read : Option<"world-read", "d">,
Desc<"Allow world to read.">;
def permissions_world_write : Option<"world-write", "t">,
Desc<"Allow world to write.">;
def permissions_world_exec : Option<"world-exec", "e">,
Desc<"Allow world to execute.">;
}

let Command = "platform fread" in {
def platform_fread_offset : Option<"offset", "o">, Group<1>, Arg<"Index">,
Desc<"Offset into the file at which to start reading.">;
def platform_fread_count : Option<"count", "c">, Group<1>, Arg<"Count">,
Desc<"Number of bytes to read from the file.">;
}

let Command = "platform fwrite" in {
def platform_fwrite_offset : Option<"offset", "o">, Group<1>, Arg<"Index">,
Desc<"Offset into the file at which to start reading.">;
def platform_fwrite_data : Option<"data", "d">, Group<1>, Arg<"Value">,
Desc<"Text to write to the file.">;
}

let Command = "platform process list" in {
def platform_process_list_pid : Option<"pid", "p">, Group<1>, Arg<"Pid">,
Desc<"List the process info for a specific process ID.">;
def platform_process_list_name : Option<"name", "n">, Group<2>,
Arg<"ProcessName">, Required,
Desc<"Find processes with executable basenames that match a string.">;
def platform_process_list_ends_with : Option<"ends-with", "e">, Group<3>,
Arg<"ProcessName">, Required,
Desc<"Find processes with executable basenames that end with a string.">;
def platform_process_list_starts_with : Option<"starts-with", "s">, Group<4>,
Arg<"ProcessName">, Required,
Desc<"Find processes with executable basenames that start with a string.">;
def platform_process_list_contains : Option<"contains", "c">, Group<5>,
Arg<"ProcessName">, Required,
Desc<"Find processes with executable basenames that contain a string.">;
def platform_process_list_regex : Option<"regex", "r">, Group<6>,
Arg<"RegularExpression">, Required,
Desc<"Find processes with executable basenames that match a regular "
"expression.">;
def platform_process_list_parent : Option<"parent", "P">, OptionRange<2, 6>,
Arg<"Pid">, Desc<"Find processes that have a matching parent process ID.">;
def platform_process_list_uid : Option<"uid", "u">, OptionRange<2, 6>,
Arg<"UnsignedInteger">,
Desc<"Find processes that have a matching user ID.">;
def platform_process_list_euid : Option<"euid", "U">, OptionRange<2, 6>,
Arg<"UnsignedInteger">,
Desc<"Find processes that have a matching effective user ID.">;
def platform_process_list_gid : Option<"gid", "g">, OptionRange<2, 6>,
Arg<"UnsignedInteger">,
Desc<"Find processes that have a matching group ID.">;
def platform_process_list_egid : Option<"egid", "G">, OptionRange<2, 6>,
Arg<"UnsignedInteger">,
Desc<"Find processes that have a matching effective group ID.">;
def platform_process_list_arch : Option<"arch", "a">, OptionRange<2, 6>,
Arg<"Architecture">,
Desc<"Find processes that have a matching architecture.">;
def platform_process_list_show_args : Option<"show-args", "A">,
OptionRange<1, 6>,
Desc<"Show process arguments instead of the process executable basename.">;
def platform_process_list_verbose : Option<"verbose", "v">, OptionRange<1, 6>,
Desc<"Enable verbose output.">;
}

let Command = "platform process attach" in {
def platform_process_attach_plugin : Option<"plugin", "P">, Arg<"Plugin">,
Desc<"Name of the process plugin you want to use.">;
def platform_process_attach_pid : Option<"pid", "p">, Group<1>, Arg<"Pid">,
Desc<"The process ID of an existing process to attach to.">;
def platform_process_attach_name : Option<"name", "n">, Group<2>,
Arg<"ProcessName">, Desc<"The name of the process to attach to.">;
def platform_process_attach_waitfor : Option<"waitfor", "w">, Group<2>,
Desc<"Wait for the process with <process-name> to launch.">;
}

let Command = "platform shell" in {
def platform_shell_timeout : Option<"timeout", "t">, Arg<"Value">,
Desc<"Seconds to wait for the remote host to finish running the command.">;
}

let Command = "process attach" in {
def process_attach_continue : Option<"continue", "c">,
Desc<"Immediately continue the process once attached.">;
Expand Down

0 comments on commit 2359fec

Please sign in to comment.