20 {
LLDB_OPT_SET_1,
false,
"format",
'f', OptionParser::eRequiredArgument,
22 "Specify a format to be used for display."},
23 {
LLDB_OPT_SET_2,
false,
"gdb-format",
'G', OptionParser::eRequiredArgument,
25 "Specify a format using a GDB format specifier string."},
26 {
LLDB_OPT_SET_3,
false,
"size",
's', OptionParser::eRequiredArgument,
28 "The size in bytes to use when displaying with the selected format."},
29 {
LLDB_OPT_SET_4,
false,
"count",
'c', OptionParser::eRequiredArgument,
31 "The number of total items to display."},
34 OptionGroupFormat::OptionGroupFormat(
37 : m_format(default_format, default_format),
38 m_byte_size(default_byte_size, default_byte_size),
39 m_count(default_count, default_count), m_prev_gdb_format(
'x'),
40 m_prev_gdb_size(
'w') {
46 for (
auto usage_text_tuple : usage_text_vector) {
47 switch (std::get<0>(usage_text_tuple)) {
55 llvm_unreachable(
"Unimplemented option");
66 return result.take_front(3);
68 return result.take_front(2);
72 llvm::StringRef option_arg,
77 switch (short_option) {
84 error.SetErrorString(
"--count option is disabled");
88 error.SetErrorStringWithFormat(
"invalid --count option value '%s'",
89 option_arg.str().c_str());
95 error.SetErrorString(
"--size option is disabled");
99 error.SetErrorStringWithFormat(
"invalid --size option value '%s'",
100 option_arg.str().c_str());
106 llvm::StringRef gdb_format_str = option_arg;
107 gdb_format_str.consumeInteger(0, count);
112 while (!gdb_format_str.empty() &&
115 gdb_format_str = gdb_format_str.drop_front();
122 if (!gdb_format_str.empty() ||
125 error.SetErrorStringWithFormat(
"invalid gdb format string '%s'",
126 option_arg.str().c_str());
138 if (byte_size_enabled) {
147 error.SetErrorString(
148 "this command doesn't support specifying a byte size");
161 error.SetErrorString(
"this command doesn't support specifying a count");
168 if (byte_size_enabled) {
179 llvm_unreachable(
"Unimplemented option");
189 switch (format_letter) {
218 execution_context ? execution_context->
GetTargetSP() : TargetSP();
220 byte_size = target_sp->GetArchitecture().GetAddressByteSize();
254 if (format_letter ==
'b')
256 else if (format_letter ==
'h')
258 else if (format_letter ==
'w')
260 else if (format_letter ==
'g')