aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2015-02-06 21:38:51 +0000
committerEd Maste <emaste@FreeBSD.org>2015-02-06 21:38:51 +0000
commit205afe679855a4ce8149cdaa94d3f0868ce796dc (patch)
tree09bc83f73246ee3c7a779605cd0122093d2a8a19 /tools
parent0cac4ca3916ac24ab6139d03cbfd18db9e715bfe (diff)
downloadsrc-205afe679855a4ce8149cdaa94d3f0868ce796dc.tar.gz
src-205afe679855a4ce8149cdaa94d3f0868ce796dc.zip
Import LLDB as of upstream SVN r225923 (git 2b588ecd)vendor/lldb/lldb-r225923
This corresponds with the branchpoint for the 3.6 release. A number of files not required for the FreeBSD build have been removed. Sponsored by: DARPA, AFRL
Notes
Notes: svn path=/vendor/lldb/dist/; revision=278332 svn path=/vendor/lldb/lldb-r225923/; revision=278333; tag=vendor/lldb/lldb-r225923
Diffstat (limited to 'tools')
-rw-r--r--tools/compact-unwind/compact-unwind-dumper.c1215
-rw-r--r--tools/driver/Driver.cpp309
-rw-r--r--tools/driver/Driver.h30
-rw-r--r--tools/driver/Platform.h14
-rw-r--r--tools/lldb-mi/Driver.cpp1067
-rw-r--r--tools/lldb-mi/Driver.h153
-rw-r--r--tools/lldb-mi/MICmdArgContext.cpp388
-rw-r--r--tools/lldb-mi/MICmdArgContext.h72
-rw-r--r--tools/lldb-mi/MICmdArgSet.cpp672
-rw-r--r--tools/lldb-mi/MICmdArgSet.h147
-rw-r--r--tools/lldb-mi/MICmdArgValBase.cpp211
-rw-r--r--tools/lldb-mi/MICmdArgValBase.h202
-rw-r--r--tools/lldb-mi/MICmdArgValConsume.cpp150
-rw-r--r--tools/lldb-mi/MICmdArgValConsume.h70
-rw-r--r--tools/lldb-mi/MICmdArgValFile.cpp306
-rw-r--r--tools/lldb-mi/MICmdArgValFile.h64
-rw-r--r--tools/lldb-mi/MICmdArgValListBase.cpp318
-rw-r--r--tools/lldb-mi/MICmdArgValListBase.h137
-rw-r--r--tools/lldb-mi/MICmdArgValListOfN.cpp259
-rw-r--r--tools/lldb-mi/MICmdArgValListOfN.h119
-rw-r--r--tools/lldb-mi/MICmdArgValNumber.cpp231
-rw-r--r--tools/lldb-mi/MICmdArgValNumber.h72
-rw-r--r--tools/lldb-mi/MICmdArgValOptionLong.cpp498
-rw-r--r--tools/lldb-mi/MICmdArgValOptionLong.h141
-rw-r--r--tools/lldb-mi/MICmdArgValOptionShort.cpp152
-rw-r--r--tools/lldb-mi/MICmdArgValOptionShort.h71
-rw-r--r--tools/lldb-mi/MICmdArgValString.cpp827
-rw-r--r--tools/lldb-mi/MICmdArgValString.h95
-rw-r--r--tools/lldb-mi/MICmdArgValThreadGrp.cpp243
-rw-r--r--tools/lldb-mi/MICmdArgValThreadGrp.h74
-rw-r--r--tools/lldb-mi/MICmdBase.cpp344
-rw-r--r--tools/lldb-mi/MICmdBase.h218
-rw-r--r--tools/lldb-mi/MICmdCmd.cpp212
-rw-r--r--tools/lldb-mi/MICmdCmd.h117
-rw-r--r--tools/lldb-mi/MICmdCmdBreak.cpp1619
-rw-r--r--tools/lldb-mi/MICmdCmdBreak.h426
-rw-r--r--tools/lldb-mi/MICmdCmdData.cpp2107
-rw-r--r--tools/lldb-mi/MICmdCmdData.h596
-rw-r--r--tools/lldb-mi/MICmdCmdEnviro.cpp182
-rw-r--r--tools/lldb-mi/MICmdCmdEnviro.h75
-rw-r--r--tools/lldb-mi/MICmdCmdExec.cpp1341
-rw-r--r--tools/lldb-mi/MICmdCmdExec.h475
-rw-r--r--tools/lldb-mi/MICmdCmdFile.cpp248
-rw-r--r--tools/lldb-mi/MICmdCmdFile.h81
-rw-r--r--tools/lldb-mi/MICmdCmdGdbInfo.cpp334
-rw-r--r--tools/lldb-mi/MICmdCmdGdbInfo.h120
-rw-r--r--tools/lldb-mi/MICmdCmdGdbSet.cpp365
-rw-r--r--tools/lldb-mi/MICmdCmdGdbSet.h132
-rw-r--r--tools/lldb-mi/MICmdCmdGdbThread.cpp115
-rw-r--r--tools/lldb-mi/MICmdCmdGdbThread.h68
-rw-r--r--tools/lldb-mi/MICmdCmdMiscellanous.cpp879
-rw-r--r--tools/lldb-mi/MICmdCmdMiscellanous.h254
-rw-r--r--tools/lldb-mi/MICmdCmdStack.cpp958
-rw-r--r--tools/lldb-mi/MICmdCmdStack.h277
-rw-r--r--tools/lldb-mi/MICmdCmdSupportInfo.cpp156
-rw-r--r--tools/lldb-mi/MICmdCmdSupportInfo.h79
-rw-r--r--tools/lldb-mi/MICmdCmdSupportList.cpp115
-rw-r--r--tools/lldb-mi/MICmdCmdSupportList.h69
-rw-r--r--tools/lldb-mi/MICmdCmdTarget.cpp322
-rw-r--r--tools/lldb-mi/MICmdCmdTarget.h78
-rw-r--r--tools/lldb-mi/MICmdCmdThread.cpp306
-rw-r--r--tools/lldb-mi/MICmdCmdThread.h88
-rw-r--r--tools/lldb-mi/MICmdCmdTrace.cpp113
-rw-r--r--tools/lldb-mi/MICmdCmdTrace.h66
-rw-r--r--tools/lldb-mi/MICmdCmdVar.cpp2330
-rw-r--r--tools/lldb-mi/MICmdCmdVar.h602
-rw-r--r--tools/lldb-mi/MICmdCommands.cpp171
-rw-r--r--tools/lldb-mi/MICmdCommands.h25
-rw-r--r--tools/lldb-mi/MICmdData.cpp13
-rw-r--r--tools/lldb-mi/MICmdData.h93
-rw-r--r--tools/lldb-mi/MICmdFactory.cpp322
-rw-r--r--tools/lldb-mi/MICmdFactory.h117
-rw-r--r--tools/lldb-mi/MICmdInterpreter.cpp442
-rw-r--r--tools/lldb-mi/MICmdInterpreter.h88
-rw-r--r--tools/lldb-mi/MICmdInvoker.cpp498
-rw-r--r--tools/lldb-mi/MICmdInvoker.h155
-rw-r--r--tools/lldb-mi/MICmdMgr.cpp358
-rw-r--r--tools/lldb-mi/MICmdMgr.h90
-rw-r--r--tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp123
-rw-r--r--tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h86
-rw-r--r--tools/lldb-mi/MICmnBase.cpp178
-rw-r--r--tools/lldb-mi/MICmnBase.h66
-rw-r--r--tools/lldb-mi/MICmnConfig.h16
-rw-r--r--tools/lldb-mi/MICmnLLDBBroadcaster.cpp97
-rw-r--r--tools/lldb-mi/MICmnLLDBBroadcaster.h59
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp2284
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfo.h379
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp859
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h208
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugger.cpp1097
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugger.h172
-rw-r--r--tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp2731
-rw-r--r--tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h121
-rw-r--r--tools/lldb-mi/MICmnLLDBProxySBValue.cpp217
-rw-r--r--tools/lldb-mi/MICmnLLDBProxySBValue.h32
-rw-r--r--tools/lldb-mi/MICmnLLDBUtilSBValue.cpp460
-rw-r--r--tools/lldb-mi/MICmnLLDBUtilSBValue.h76
-rw-r--r--tools/lldb-mi/MICmnLog.cpp525
-rw-r--r--tools/lldb-mi/MICmnLog.h228
-rw-r--r--tools/lldb-mi/MICmnLogMediumFile.cpp590
-rw-r--r--tools/lldb-mi/MICmnLogMediumFile.h128
-rw-r--r--tools/lldb-mi/MICmnMIOutOfBandRecord.cpp210
-rw-r--r--tools/lldb-mi/MICmnMIOutOfBandRecord.h146
-rw-r--r--tools/lldb-mi/MICmnMIResultRecord.cpp174
-rw-r--r--tools/lldb-mi/MICmnMIResultRecord.h140
-rw-r--r--tools/lldb-mi/MICmnMIValue.cpp62
-rw-r--r--tools/lldb-mi/MICmnMIValue.h74
-rw-r--r--tools/lldb-mi/MICmnMIValueConst.cpp119
-rw-r--r--tools/lldb-mi/MICmnMIValueConst.h88
-rw-r--r--tools/lldb-mi/MICmnMIValueList.cpp276
-rw-r--r--tools/lldb-mi/MICmnMIValueList.h84
-rw-r--r--tools/lldb-mi/MICmnMIValueResult.cpp171
-rw-r--r--tools/lldb-mi/MICmnMIValueResult.h94
-rw-r--r--tools/lldb-mi/MICmnMIValueTuple.cpp315
-rw-r--r--tools/lldb-mi/MICmnMIValueTuple.h92
-rw-r--r--tools/lldb-mi/MICmnResources.cpp699
-rw-r--r--tools/lldb-mi/MICmnResources.h623
-rw-r--r--tools/lldb-mi/MICmnStreamStderr.cpp350
-rw-r--r--tools/lldb-mi/MICmnStreamStderr.h88
-rw-r--r--tools/lldb-mi/MICmnStreamStdin.cpp594
-rw-r--r--tools/lldb-mi/MICmnStreamStdin.h182
-rw-r--r--tools/lldb-mi/MICmnStreamStdinLinux.cpp307
-rw-r--r--tools/lldb-mi/MICmnStreamStdinLinux.h87
-rw-r--r--tools/lldb-mi/MICmnStreamStdinWindows.cpp336
-rw-r--r--tools/lldb-mi/MICmnStreamStdinWindows.h102
-rw-r--r--tools/lldb-mi/MICmnStreamStdout.cpp310
-rw-r--r--tools/lldb-mi/MICmnStreamStdout.h86
-rw-r--r--tools/lldb-mi/MICmnThreadMgrStd.cpp224
-rw-r--r--tools/lldb-mi/MICmnThreadMgrStd.h202
-rw-r--r--tools/lldb-mi/MIDataTypes.h84
-rw-r--r--tools/lldb-mi/MIDriver.cpp1923
-rw-r--r--tools/lldb-mi/MIDriver.h290
-rw-r--r--tools/lldb-mi/MIDriverBase.cpp239
-rw-r--r--tools/lldb-mi/MIDriverBase.h95
-rw-r--r--tools/lldb-mi/MIDriverMain.cpp540
-rw-r--r--tools/lldb-mi/MIDriverMgr.cpp1254
-rw-r--r--tools/lldb-mi/MIDriverMgr.h201
-rw-r--r--tools/lldb-mi/MIUtilDateTimeStd.cpp89
-rw-r--r--tools/lldb-mi/MIUtilDateTimeStd.h56
-rw-r--r--tools/lldb-mi/MIUtilDebug.cpp131
-rw-r--r--tools/lldb-mi/MIUtilDebug.h104
-rw-r--r--tools/lldb-mi/MIUtilFileStd.cpp417
-rw-r--r--tools/lldb-mi/MIUtilFileStd.h75
-rw-r--r--tools/lldb-mi/MIUtilMapIdToVariant.cpp145
-rw-r--r--tools/lldb-mi/MIUtilMapIdToVariant.h216
-rw-r--r--tools/lldb-mi/MIUtilSingletonBase.h79
-rw-r--r--tools/lldb-mi/MIUtilSingletonHelper.h115
-rw-r--r--tools/lldb-mi/MIUtilString.cpp1054
-rw-r--r--tools/lldb-mi/MIUtilString.h108
-rw-r--r--tools/lldb-mi/MIUtilSystemLinux.cpp138
-rw-r--r--tools/lldb-mi/MIUtilSystemLinux.h56
-rw-r--r--tools/lldb-mi/MIUtilSystemOsx.cpp144
-rw-r--r--tools/lldb-mi/MIUtilSystemOsx.h56
-rw-r--r--tools/lldb-mi/MIUtilSystemWindows.cpp196
-rw-r--r--tools/lldb-mi/MIUtilSystemWindows.h56
-rw-r--r--tools/lldb-mi/MIUtilTermios.cpp54
-rw-r--r--tools/lldb-mi/MIUtilTermios.h16
-rw-r--r--tools/lldb-mi/MIUtilThreadBaseStd.cpp441
-rw-r--r--tools/lldb-mi/MIUtilThreadBaseStd.h251
-rw-r--r--tools/lldb-mi/MIUtilVariant.cpp474
-rw-r--r--tools/lldb-mi/MIUtilVariant.h393
-rw-r--r--tools/lldb-mi/Platform.cpp69
-rw-r--r--tools/lldb-mi/Platform.h182
-rw-r--r--tools/lldb-platform/lldb-platform.cpp6
164 files changed, 27723 insertions, 25537 deletions
diff --git a/tools/compact-unwind/compact-unwind-dumper.c b/tools/compact-unwind/compact-unwind-dumper.c
new file mode 100644
index 000000000000..fd8ea2161896
--- /dev/null
+++ b/tools/compact-unwind/compact-unwind-dumper.c
@@ -0,0 +1,1215 @@
+#include <stdint.h>
+#include <mach-o/loader.h>
+#include <mach-o/compact_unwind_encoding.h>
+#include <mach/machine.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/errno.h>
+#include <sys/stat.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <mach-o/nlist.h>
+
+#define EXTRACT_BITS(value, mask) \
+ ( (value >> __builtin_ctz(mask)) & (((1 << __builtin_popcount(mask)))-1) )
+
+
+// A quick sketch of a program which can parse the compact unwind info
+// used on Darwin systems for exception handling. The output of
+// unwinddump will be more authoritative/reliable but this program
+// can dump at least the UNWIND_X86_64_MODE_RBP_FRAME format entries
+// correctly.
+
+struct symbol
+{
+ uint64_t file_address;
+ const char *name;
+};
+
+int
+symbol_compare (const void *a, const void *b)
+{
+ return (int) ((struct symbol *)a)->file_address - ((struct symbol *)b)->file_address;
+}
+
+struct baton
+{
+ cpu_type_t cputype;
+
+ uint8_t *mach_header_start; // pointer into this program's address space
+ uint8_t *compact_unwind_start; // pointer into this program's address space
+
+ int addr_size; // 4 or 8 bytes, the size of addresses in this file
+
+ uint64_t text_segment_vmaddr; // __TEXT segment vmaddr
+ uint64_t text_segment_file_offset;
+
+ uint64_t text_section_vmaddr; // __TEXT,__text section vmaddr
+ uint64_t text_section_file_offset;
+
+ uint64_t eh_section_file_address; // the file address of the __TEXT,__eh_frame section
+
+ uint8_t *lsda_array_start; // for the currently-being-processed first-level index
+ uint8_t *lsda_array_end; // the lsda_array_start for the NEXT first-level index
+
+ struct symbol *symbols;
+ int symbols_count;
+
+ uint64_t *function_start_addresses;
+ int function_start_addresses_count;
+
+ int current_index_table_number;
+
+ struct unwind_info_section_header unwind_header;
+ struct unwind_info_section_header_index_entry first_level_index_entry;
+ struct unwind_info_compressed_second_level_page_header compressed_second_level_page_header;
+ struct unwind_info_regular_second_level_page_header regular_second_level_page_header;
+};
+
+
+uint64_t
+read_leb128 (uint8_t **offset)
+{
+ uint64_t result = 0;
+ int shift = 0;
+ while (1)
+ {
+ uint8_t byte = **offset;
+ *offset = *offset + 1;
+ result |= (byte & 0x7f) << shift;
+ if ((byte & 0x80) == 0)
+ break;
+ shift += 7;
+ }
+
+ return result;
+}
+
+// step through the load commands in a thin mach-o binary,
+// find the cputype and the start of the __TEXT,__unwind_info
+// section, return a pointer to that section or NULL if not found.
+
+static void
+scan_macho_load_commands (struct baton *baton)
+{
+ struct symtab_command symtab_cmd;
+ uint64_t linkedit_segment_vmaddr;
+ uint64_t linkedit_segment_file_offset;
+
+ baton->compact_unwind_start = 0;
+
+ uint32_t *magic = (uint32_t *) baton->mach_header_start;
+
+ if (*magic != MH_MAGIC && *magic != MH_MAGIC_64)
+ {
+ printf ("Unexpected magic number 0x%x in header, exiting.", *magic);
+ exit (1);
+ }
+
+ bool is_64bit = false;
+ if (*magic == MH_MAGIC_64)
+ is_64bit = true;
+
+ uint8_t *offset = baton->mach_header_start;
+
+ struct mach_header mh;
+ memcpy (&mh, offset, sizeof (struct mach_header));
+ if (is_64bit)
+ offset += sizeof (struct mach_header_64);
+ else
+ offset += sizeof (struct mach_header);
+
+ if (is_64bit)
+ baton->addr_size = 8;
+ else
+ baton->addr_size = 4;
+
+ baton->cputype = mh.cputype;
+
+ uint8_t *start_of_load_commands = offset;
+
+ uint32_t cur_cmd = 0;
+ while (cur_cmd < mh.ncmds && (offset - start_of_load_commands) < mh.sizeofcmds)
+ {
+ struct load_command lc;
+ uint32_t *lc_cmd = (uint32_t *) offset;
+ uint32_t *lc_cmdsize = (uint32_t *) offset + 1;
+ uint8_t *start_of_this_load_cmd = offset;
+
+ if (*lc_cmd == LC_SEGMENT || *lc_cmd == LC_SEGMENT_64)
+ {
+ char segment_name[17];
+ segment_name[0] = '\0';
+ uint32_t nsects = 0;
+ uint64_t segment_offset = 0;
+ uint64_t segment_vmaddr = 0;
+
+ if (*lc_cmd == LC_SEGMENT_64)
+ {
+ struct segment_command_64 seg;
+ memcpy (&seg, offset, sizeof (struct segment_command_64));
+ memcpy (&segment_name, &seg.segname, 16);
+ segment_name[16] = '\0';
+ nsects = seg.nsects;
+ segment_offset = seg.fileoff;
+ segment_vmaddr = seg.vmaddr;
+ offset += sizeof (struct segment_command_64);
+ if ((seg.flags & SG_PROTECTED_VERSION_1) == SG_PROTECTED_VERSION_1)
+ {
+ printf ("Segment '%s' is encrypted.\n", segment_name);
+ }
+ }
+
+ if (*lc_cmd == LC_SEGMENT)
+ {
+ struct segment_command seg;
+ memcpy (&seg, offset, sizeof (struct segment_command));
+ memcpy (&segment_name, &seg.segname, 16);
+ segment_name[16] = '\0';
+ nsects = seg.nsects;
+ segment_offset = seg.fileoff;
+ segment_vmaddr = seg.vmaddr;
+ offset += sizeof (struct segment_command);
+ if ((seg.flags & SG_PROTECTED_VERSION_1) == SG_PROTECTED_VERSION_1)
+ {
+ printf ("Segment '%s' is encrypted.\n", segment_name);
+ }
+ }
+
+ if (nsects != 0 && strcmp (segment_name, "__TEXT") == 0)
+ {
+ baton->text_segment_vmaddr = segment_vmaddr;
+ baton->text_segment_file_offset = segment_offset;
+
+ uint32_t current_sect = 0;
+ while (current_sect < nsects && (offset - start_of_this_load_cmd) < *lc_cmdsize)
+ {
+ char sect_name[17];
+ memcpy (&sect_name, offset, 16);
+ sect_name[16] = '\0';
+ if (strcmp (sect_name, "__unwind_info") == 0)
+ {
+ if (is_64bit)
+ {
+ struct section_64 sect;
+ memcpy (&sect, offset, sizeof (struct section_64));
+ baton->compact_unwind_start = baton->mach_header_start + sect.offset;
+ }
+ else
+ {
+ struct section sect;
+ memcpy (&sect, offset, sizeof (struct section));
+ baton->compact_unwind_start = baton->mach_header_start + sect.offset;
+ }
+ }
+ if (strcmp (sect_name, "__eh_frame") == 0)
+ {
+ if (is_64bit)
+ {
+ struct section_64 sect;
+ memcpy (&sect, offset, sizeof (struct section_64));
+ baton->eh_section_file_address = sect.addr;
+ }
+ else
+ {
+ struct section sect;
+ memcpy (&sect, offset, sizeof (struct section));
+ baton->eh_section_file_address = sect.addr;
+ }
+ }
+ if (strcmp (sect_name, "__text") == 0)
+ {
+ if (is_64bit)
+ {
+ struct section_64 sect;
+ memcpy (&sect, offset, sizeof (struct section_64));
+ baton->text_section_vmaddr = sect.addr;
+ baton->text_section_file_offset = sect.offset;
+ }
+ else
+ {
+ struct section sect;
+ memcpy (&sect, offset, sizeof (struct section));
+ baton->text_section_vmaddr = sect.addr;
+ }
+ }
+ if (is_64bit)
+ {
+ offset += sizeof (struct section_64);
+ }
+ else
+ {
+ offset += sizeof (struct section);
+ }
+ }
+ }
+
+ if (strcmp (segment_name, "__LINKEDIT") == 0)
+ {
+ linkedit_segment_vmaddr = segment_vmaddr;
+ linkedit_segment_file_offset = segment_offset;
+ }
+ }
+
+ if (*lc_cmd == LC_SYMTAB)
+ {
+ memcpy (&symtab_cmd, offset, sizeof (struct symtab_command));
+ }
+
+ if (*lc_cmd == LC_DYSYMTAB)
+ {
+ struct dysymtab_command dysymtab_cmd;
+ memcpy (&dysymtab_cmd, offset, sizeof (struct dysymtab_command));
+
+ int nlist_size = 12;
+ if (is_64bit)
+ nlist_size = 16;
+
+ char *string_table = (char *) (baton->mach_header_start + symtab_cmd.stroff);
+ uint8_t *local_syms = baton->mach_header_start + symtab_cmd.symoff + (dysymtab_cmd.ilocalsym * nlist_size);
+ int local_syms_count = dysymtab_cmd.nlocalsym;
+ uint8_t *exported_syms = baton->mach_header_start + symtab_cmd.symoff + (dysymtab_cmd.iextdefsym * nlist_size);
+ int exported_syms_count = dysymtab_cmd.nextdefsym;
+
+ // We're only going to create records for a small number of these symbols but to
+ // simplify the memory management I'll allocate enough space to store all of them.
+ baton->symbols = (struct symbol *) malloc (sizeof (struct symbol) * (local_syms_count + exported_syms_count));
+ baton->symbols_count = 0;
+
+ for (int i = 0; i < local_syms_count; i++)
+ {
+ struct nlist_64 nlist;
+ if (is_64bit)
+ {
+ memcpy (&nlist, local_syms + (i * nlist_size), sizeof (struct nlist_64));
+ }
+ else
+ {
+ struct nlist nlist_32;
+ memcpy (&nlist_32, local_syms + (i * nlist_size), sizeof (struct nlist));
+ nlist.n_un.n_strx = nlist_32.n_un.n_strx;
+ nlist.n_type = nlist_32.n_type;
+ nlist.n_sect = nlist_32.n_sect;
+ nlist.n_desc = nlist_32.n_desc;
+ nlist.n_value = nlist_32.n_value;
+ }
+ if ((nlist.n_type & N_STAB) == 0
+ && ((nlist.n_type & N_EXT) == 1 ||
+ ((nlist.n_type & N_TYPE) == N_TYPE && nlist.n_sect != NO_SECT))
+ && nlist.n_value != 0
+ && nlist.n_value != baton->text_segment_vmaddr)
+ {
+ baton->symbols[baton->symbols_count].file_address = nlist.n_value;
+ baton->symbols[baton->symbols_count].name = string_table + nlist.n_un.n_strx;
+ baton->symbols_count++;
+ }
+ }
+
+ for (int i = 0; i < exported_syms_count; i++)
+ {
+ struct nlist_64 nlist;
+ if (is_64bit)
+ {
+ memcpy (&nlist, exported_syms + (i * nlist_size), sizeof (struct nlist_64));
+ }
+ else
+ {
+ struct nlist nlist_32;
+ memcpy (&nlist_32, exported_syms + (i * nlist_size), sizeof (struct nlist));
+ nlist.n_un.n_strx = nlist_32.n_un.n_strx;
+ nlist.n_type = nlist_32.n_type;
+ nlist.n_sect = nlist_32.n_sect;
+ nlist.n_desc = nlist_32.n_desc;
+ nlist.n_value = nlist_32.n_value;
+ }
+ if ((nlist.n_type & N_STAB) == 0
+ && ((nlist.n_type & N_EXT) == 1 ||
+ ((nlist.n_type & N_TYPE) == N_TYPE && nlist.n_sect != NO_SECT))
+ && nlist.n_value != 0
+ && nlist.n_value != baton->text_segment_vmaddr)
+ {
+ baton->symbols[baton->symbols_count].file_address = nlist.n_value;
+ baton->symbols[baton->symbols_count].name = string_table + nlist.n_un.n_strx;
+ baton->symbols_count++;
+ }
+ }
+
+ qsort (baton->symbols, baton->symbols_count, sizeof (struct symbol), symbol_compare);
+ }
+
+ if (*lc_cmd == LC_FUNCTION_STARTS)
+ {
+ struct linkedit_data_command function_starts_cmd;
+ memcpy (&function_starts_cmd, offset, sizeof (struct linkedit_data_command));
+
+ uint8_t *funcstarts_offset = baton->mach_header_start + function_starts_cmd.dataoff;
+ uint8_t *function_end = funcstarts_offset + function_starts_cmd.datasize;
+ int count = 0;
+
+ while (funcstarts_offset < function_end)
+ {
+ if (read_leb128 (&funcstarts_offset) != 0)
+ {
+ count++;
+ }
+ }
+
+ baton->function_start_addresses = (uint64_t *) malloc (sizeof (uint64_t) * count);
+ baton->function_start_addresses_count = count;
+
+ funcstarts_offset = baton->mach_header_start + function_starts_cmd.dataoff;
+ uint64_t current_pc = baton->text_segment_vmaddr;
+ int i = 0;
+ while (funcstarts_offset < function_end)
+ {
+ uint64_t func_start = read_leb128 (&funcstarts_offset);
+ if (func_start != 0)
+ {
+ current_pc += func_start;
+ baton->function_start_addresses[i++] = current_pc;
+ }
+ }
+ }
+
+ offset = start_of_this_load_cmd + *lc_cmdsize;
+ cur_cmd++;
+ }
+
+
+ // Augment the symbol table with the function starts table -- adding symbol entries
+ // for functions that were stripped.
+
+ int unnamed_functions_to_add = 0;
+ for (int i = 0; i < baton->function_start_addresses_count; i++)
+ {
+ struct symbol search_key;
+ search_key.file_address = baton->function_start_addresses[i];
+ struct symbol *sym = bsearch (&search_key, baton->symbols, baton->symbols_count, sizeof (struct symbol), symbol_compare);
+ if (sym == NULL)
+ unnamed_functions_to_add++;
+ }
+
+ baton->symbols = (struct symbol *) realloc (baton->symbols, sizeof (struct symbol) * (baton->symbols_count + unnamed_functions_to_add));
+
+ int current_unnamed_symbol = 1;
+ int number_symbols_added = 0;
+ for (int i = 0; i < baton->function_start_addresses_count; i++)
+ {
+ struct symbol search_key;
+ search_key.file_address = baton->function_start_addresses[i];
+ struct symbol *sym = bsearch (&search_key, baton->symbols, baton->symbols_count, sizeof (struct symbol), symbol_compare);
+ if (sym == NULL)
+ {
+ char *name;
+ asprintf (&name, "unnamed function #%d", current_unnamed_symbol++);
+ baton->symbols[baton->symbols_count + number_symbols_added].file_address = baton->function_start_addresses[i];
+ baton->symbols[baton->symbols_count + number_symbols_added].name = name;
+ number_symbols_added++;
+ }
+ }
+ baton->symbols_count += number_symbols_added;
+ qsort (baton->symbols, baton->symbols_count, sizeof (struct symbol), symbol_compare);
+
+
+// printf ("function start addresses\n");
+// for (int i = 0; i < baton->function_start_addresses_count; i++)
+// {
+// printf ("0x%012llx\n", baton->function_start_addresses[i]);
+// }
+
+// printf ("symbol table names & addresses\n");
+// for (int i = 0; i < baton->symbols_count; i++)
+// {
+// printf ("0x%012llx %s\n", baton->symbols[i].file_address, baton->symbols[i].name);
+// }
+
+}
+
+void
+print_encoding_x86_64 (struct baton baton, uint8_t *function_start, uint32_t encoding)
+{
+ int mode = encoding & UNWIND_X86_64_MODE_MASK;
+ switch (mode)
+ {
+ case UNWIND_X86_64_MODE_RBP_FRAME:
+ {
+ printf ("frame func: CFA is rbp+%d ", 16);
+ printf (" rip=[CFA-8] rbp=[CFA-16]");
+ uint32_t saved_registers_offset = EXTRACT_BITS (encoding, UNWIND_X86_64_RBP_FRAME_OFFSET);
+
+ uint32_t saved_registers_locations = EXTRACT_BITS (encoding, UNWIND_X86_64_RBP_FRAME_REGISTERS);
+
+
+ saved_registers_offset += 2;
+
+ for (int i = 0; i < 5; i++)
+ {
+ switch (saved_registers_locations & 0x7)
+ {
+ case UNWIND_X86_64_REG_NONE:
+ break;
+ case UNWIND_X86_64_REG_RBX:
+ printf (" rbx=[CFA-%d]", saved_registers_offset * 8);
+ break;
+ case UNWIND_X86_64_REG_R12:
+ printf (" r12=[CFA-%d]", saved_registers_offset * 8);
+ break;
+ case UNWIND_X86_64_REG_R13:
+ printf (" r13=[CFA-%d]", saved_registers_offset * 8);
+ break;
+ case UNWIND_X86_64_REG_R14:
+ printf (" r14=[CFA-%d]", saved_registers_offset * 8);
+ break;
+ case UNWIND_X86_64_REG_R15:
+ printf (" r15=[CFA-%d]", saved_registers_offset * 8);
+ break;
+ }
+ saved_registers_offset--;
+ saved_registers_locations >>= 3;
+ }
+ }
+ break;
+
+ case UNWIND_X86_64_MODE_STACK_IND:
+ case UNWIND_X86_64_MODE_STACK_IMMD:
+ {
+ uint32_t stack_size = EXTRACT_BITS (encoding, UNWIND_X86_64_FRAMELESS_STACK_SIZE);
+ uint32_t register_count = EXTRACT_BITS (encoding, UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT);
+ uint32_t permutation = EXTRACT_BITS (encoding, UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION);
+
+ if (mode == UNWIND_X86_64_MODE_STACK_IND && function_start)
+ {
+ uint32_t stack_adjust = EXTRACT_BITS (encoding, UNWIND_X86_64_FRAMELESS_STACK_ADJUST);
+
+ // offset into the function instructions; 0 == beginning of first instruction
+ uint32_t offset_to_subl_insn = EXTRACT_BITS (encoding, UNWIND_X86_64_FRAMELESS_STACK_SIZE);
+
+ stack_size = *((uint32_t*) (function_start + offset_to_subl_insn));
+
+ stack_size += stack_adjust * 8;
+
+ printf ("large stack ");
+ }
+
+ printf ("frameless function: stack size %d, register count %d ", stack_size * 8, register_count);
+
+ if (register_count == 0)
+ {
+ printf (" no registers saved");
+ }
+ else
+ {
+
+ // We need to include (up to) 6 registers in 10 bits.
+ // That would be 18 bits if we just used 3 bits per reg to indicate
+ // the order they're saved on the stack.
+ //
+ // This is done with Lehmer code permutation, e.g. see
+ // http://stackoverflow.com/questions/1506078/fast-permutation-number-permutation-mapping-algorithms
+ int permunreg[6];
+
+ // This decodes the variable-base number in the 10 bits
+ // and gives us the Lehmer code sequence which can then
+ // be decoded.
+
+ switch (register_count)
+ {
+ case 6:
+ permunreg[0] = permutation/120; // 120 == 5!
+ permutation -= (permunreg[0]*120);
+ permunreg[1] = permutation/24; // 24 == 4!
+ permutation -= (permunreg[1]*24);
+ permunreg[2] = permutation/6; // 6 == 3!
+ permutation -= (permunreg[2]*6);
+ permunreg[3] = permutation/2; // 2 == 2!
+ permutation -= (permunreg[3]*2);
+ permunreg[4] = permutation; // 1 == 1!
+ permunreg[5] = 0;
+ break;
+ case 5:
+ permunreg[0] = permutation/120;
+ permutation -= (permunreg[0]*120);
+ permunreg[1] = permutation/24;
+ permutation -= (permunreg[1]*24);
+ permunreg[2] = permutation/6;
+ permutation -= (permunreg[2]*6);
+ permunreg[3] = permutation/2;
+ permutation -= (permunreg[3]*2);
+ permunreg[4] = permutation;
+ break;
+ case 4:
+ permunreg[0] = permutation/60;
+ permutation -= (permunreg[0]*60);
+ permunreg[1] = permutation/12;
+ permutation -= (permunreg[1]*12);
+ permunreg[2] = permutation/3;
+ permutation -= (permunreg[2]*3);
+ permunreg[3] = permutation;
+ break;
+ case 3:
+ permunreg[0] = permutation/20;
+ permutation -= (permunreg[0]*20);
+ permunreg[1] = permutation/4;
+ permutation -= (permunreg[1]*4);
+ permunreg[2] = permutation;
+ break;
+ case 2:
+ permunreg[0] = permutation/5;
+ permutation -= (permunreg[0]*5);
+ permunreg[1] = permutation;
+ break;
+ case 1:
+ permunreg[0] = permutation;
+ break;
+ }
+
+ // Decode the Lehmer code for this permutation of
+ // the registers v. http://en.wikipedia.org/wiki/Lehmer_code
+
+ int registers[6];
+ bool used[7] = { false, false, false, false, false, false, false };
+ for (int i = 0; i < register_count; i++)
+ {
+ int renum = 0;
+ for (int j = 1; j < 7; j++)
+ {
+ if (used[j] == false)
+ {
+ if (renum == permunreg[i])
+ {
+ registers[i] = j;
+ used[j] = true;
+ break;
+ }
+ renum++;
+ }
+ }
+ }
+
+
+ printf (" CFA is rsp+%d ", stack_size * 8);
+
+ uint32_t saved_registers_offset = 1;
+ printf (" rip=[CFA-%d]", saved_registers_offset * 8);
+ saved_registers_offset++;
+
+ for (int i = (sizeof (registers) / sizeof (int)) - 1; i >= 0; i--)
+ {
+ switch (registers[i])
+ {
+ case UNWIND_X86_64_REG_NONE:
+ break;
+ case UNWIND_X86_64_REG_RBX:
+ printf (" rbx=[CFA-%d]", saved_registers_offset * 8);
+ break;
+ case UNWIND_X86_64_REG_R12:
+ printf (" r12=[CFA-%d]", saved_registers_offset * 8);
+ break;
+ case UNWIND_X86_64_REG_R13:
+ printf (" r13=[CFA-%d]", saved_registers_offset * 8);
+ break;
+ case UNWIND_X86_64_REG_R14:
+ printf (" r14=[CFA-%d]", saved_registers_offset * 8);
+ break;
+ case UNWIND_X86_64_REG_R15:
+ printf (" r15=[CFA-%d]", saved_registers_offset * 8);
+ break;
+ case UNWIND_X86_64_REG_RBP:
+ printf (" rbp=[CFA-%d]", saved_registers_offset * 8);
+ break;
+ }
+ saved_registers_offset++;
+ }
+
+ }
+
+ }
+ break;
+
+ case UNWIND_X86_64_MODE_DWARF:
+ {
+ uint32_t dwarf_offset = encoding & UNWIND_X86_DWARF_SECTION_OFFSET;
+ printf ("DWARF unwind instructions: FDE at offset %d (file address 0x%" PRIx64 ")",
+ dwarf_offset, dwarf_offset + baton.eh_section_file_address);
+ }
+ break;
+
+ case 0:
+ {
+ printf (" no unwind information");
+ }
+ break;
+ }
+}
+
+void
+print_encoding_i386 (struct baton baton, uint8_t *function_start, uint32_t encoding)
+{
+ int mode = encoding & UNWIND_X86_MODE_MASK;
+ switch (mode)
+ {
+ case UNWIND_X86_MODE_EBP_FRAME:
+ {
+ printf ("frame func: CFA is ebp+%d ", 8);
+ printf (" eip=[CFA-4] ebp=[CFA-8]");
+ uint32_t saved_registers_offset = EXTRACT_BITS (encoding, UNWIND_X86_EBP_FRAME_OFFSET);
+
+ uint32_t saved_registers_locations = EXTRACT_BITS (encoding, UNWIND_X86_EBP_FRAME_REGISTERS);
+
+
+ saved_registers_offset += 2;
+
+ for (int i = 0; i < 5; i++)
+ {
+ switch (saved_registers_locations & 0x7)
+ {
+ case UNWIND_X86_REG_NONE:
+ break;
+ case UNWIND_X86_REG_EBX:
+ printf (" ebx=[CFA-%d]", saved_registers_offset * 4);
+ break;
+ case UNWIND_X86_REG_ECX:
+ printf (" ecx=[CFA-%d]", saved_registers_offset * 4);
+ break;
+ case UNWIND_X86_REG_EDX:
+ printf (" edx=[CFA-%d]", saved_registers_offset * 4);
+ break;
+ case UNWIND_X86_REG_EDI:
+ printf (" edi=[CFA-%d]", saved_registers_offset * 4);
+ break;
+ case UNWIND_X86_REG_ESI:
+ printf (" esi=[CFA-%d]", saved_registers_offset * 4);
+ break;
+ }
+ saved_registers_offset--;
+ saved_registers_locations >>= 3;
+ }
+ }
+ break;
+
+ case UNWIND_X86_MODE_STACK_IND:
+ case UNWIND_X86_MODE_STACK_IMMD:
+ {
+ uint32_t stack_size = EXTRACT_BITS (encoding, UNWIND_X86_FRAMELESS_STACK_SIZE);
+ uint32_t register_count = EXTRACT_BITS (encoding, UNWIND_X86_FRAMELESS_STACK_REG_COUNT);
+ uint32_t permutation = EXTRACT_BITS (encoding, UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION);
+
+ if (mode == UNWIND_X86_MODE_STACK_IND && function_start)
+ {
+ uint32_t stack_adjust = EXTRACT_BITS (encoding, UNWIND_X86_FRAMELESS_STACK_ADJUST);
+
+ // offset into the function instructions; 0 == beginning of first instruction
+ uint32_t offset_to_subl_insn = EXTRACT_BITS (encoding, UNWIND_X86_FRAMELESS_STACK_SIZE);
+
+ stack_size = *((uint32_t*) (function_start + offset_to_subl_insn));
+
+ stack_size += stack_adjust * 4;
+
+ printf ("large stack ");
+ }
+
+ printf ("frameless function: stack size %d, register count %d ", stack_size * 4, register_count);
+
+ if (register_count == 0)
+ {
+ printf (" no registers saved");
+ }
+ else
+ {
+
+ // We need to include (up to) 6 registers in 10 bits.
+ // That would be 18 bits if we just used 3 bits per reg to indicate
+ // the order they're saved on the stack.
+ //
+ // This is done with Lehmer code permutation, e.g. see
+ // http://stackoverflow.com/questions/1506078/fast-permutation-number-permutation-mapping-algorithms
+ int permunreg[6];
+
+ // This decodes the variable-base number in the 10 bits
+ // and gives us the Lehmer code sequence which can then
+ // be decoded.
+
+ switch (register_count)
+ {
+ case 6:
+ permunreg[0] = permutation/120; // 120 == 5!
+ permutation -= (permunreg[0]*120);
+ permunreg[1] = permutation/24; // 24 == 4!
+ permutation -= (permunreg[1]*24);
+ permunreg[2] = permutation/6; // 6 == 3!
+ permutation -= (permunreg[2]*6);
+ permunreg[3] = permutation/2; // 2 == 2!
+ permutation -= (permunreg[3]*2);
+ permunreg[4] = permutation; // 1 == 1!
+ permunreg[5] = 0;
+ break;
+ case 5:
+ permunreg[0] = permutation/120;
+ permutation -= (permunreg[0]*120);
+ permunreg[1] = permutation/24;
+ permutation -= (permunreg[1]*24);
+ permunreg[2] = permutation/6;
+ permutation -= (permunreg[2]*6);
+ permunreg[3] = permutation/2;
+ permutation -= (permunreg[3]*2);
+ permunreg[4] = permutation;
+ break;
+ case 4:
+ permunreg[0] = permutation/60;
+ permutation -= (permunreg[0]*60);
+ permunreg[1] = permutation/12;
+ permutation -= (permunreg[1]*12);
+ permunreg[2] = permutation/3;
+ permutation -= (permunreg[2]*3);
+ permunreg[3] = permutation;
+ break;
+ case 3:
+ permunreg[0] = permutation/20;
+ permutation -= (permunreg[0]*20);
+ permunreg[1] = permutation/4;
+ permutation -= (permunreg[1]*4);
+ permunreg[2] = permutation;
+ break;
+ case 2:
+ permunreg[0] = permutation/5;
+ permutation -= (permunreg[0]*5);
+ permunreg[1] = permutation;
+ break;
+ case 1:
+ permunreg[0] = permutation;
+ break;
+ }
+
+ // Decode the Lehmer code for this permutation of
+ // the registers v. http://en.wikipedia.org/wiki/Lehmer_code
+
+ int registers[6];
+ bool used[7] = { false, false, false, false, false, false, false };
+ for (int i = 0; i < register_count; i++)
+ {
+ int renum = 0;
+ for (int j = 1; j < 7; j++)
+ {
+ if (used[j] == false)
+ {
+ if (renum == permunreg[i])
+ {
+ registers[i] = j;
+ used[j] = true;
+ break;
+ }
+ renum++;
+ }
+ }
+ }
+
+
+ printf (" CFA is esp+%d ", stack_size * 4);
+
+ uint32_t saved_registers_offset = 1;
+ printf (" eip=[CFA-%d]", saved_registers_offset * 4);
+ saved_registers_offset++;
+
+ for (int i = (sizeof (registers) / sizeof (int)) - 1; i >= 0; i--)
+ {
+ switch (registers[i])
+ {
+ case UNWIND_X86_REG_NONE:
+ break;
+ case UNWIND_X86_REG_EBX:
+ printf (" ebx=[CFA-%d]", saved_registers_offset * 4);
+ break;
+ case UNWIND_X86_REG_ECX:
+ printf (" ecx=[CFA-%d]", saved_registers_offset * 4);
+ break;
+ case UNWIND_X86_REG_EDX:
+ printf (" edx=[CFA-%d]", saved_registers_offset * 4);
+ break;
+ case UNWIND_X86_REG_EDI:
+ printf (" edi=[CFA-%d]", saved_registers_offset * 4);
+ break;
+ case UNWIND_X86_REG_ESI:
+ printf (" esi=[CFA-%d]", saved_registers_offset * 4);
+ break;
+ case UNWIND_X86_REG_EBP:
+ printf (" ebp=[CFA-%d]", saved_registers_offset * 4);
+ break;
+ }
+ saved_registers_offset++;
+ }
+
+ }
+
+ }
+ break;
+
+ case UNWIND_X86_MODE_DWARF:
+ {
+ uint32_t dwarf_offset = encoding & UNWIND_X86_DWARF_SECTION_OFFSET;
+ printf ("DWARF unwind instructions: FDE at offset %d (file address 0x%" PRIx64 ")",
+ dwarf_offset, dwarf_offset + baton.eh_section_file_address);
+ }
+ break;
+
+ case 0:
+ {
+ printf (" no unwind information");
+ }
+ break;
+ }
+}
+
+
+void print_encoding (struct baton baton, uint8_t *function_start, uint32_t encoding)
+{
+
+ if (baton.cputype == CPU_TYPE_X86_64)
+ {
+ print_encoding_x86_64 (baton, function_start, encoding);
+ }
+ else if (baton.cputype == CPU_TYPE_I386)
+ {
+ print_encoding_i386 (baton, function_start, encoding);
+ }
+ else
+ {
+ printf (" -- unsupported encoding arch -- ");
+ }
+}
+
+void
+print_function_encoding (struct baton baton, uint32_t idx, uint32_t encoding, uint32_t entry_encoding_index, uint32_t entry_func_offset)
+{
+
+ char *entry_encoding_index_str = "";
+ if (entry_encoding_index != (uint32_t) -1)
+ {
+ asprintf (&entry_encoding_index_str, ", encoding #%d", entry_encoding_index);
+ }
+ else
+ {
+ asprintf (&entry_encoding_index_str, "");
+ }
+
+ uint64_t file_address = baton.first_level_index_entry.functionOffset + entry_func_offset + baton.text_segment_vmaddr;
+
+ printf (" func [%d] offset %d (file addr 0x%" PRIx64 ")%s, encoding is 0x%x",
+ idx, entry_func_offset,
+ file_address,
+ entry_encoding_index_str,
+ encoding);
+
+ struct symbol *symbol = NULL;
+ for (int i = 0; i < baton.symbols_count; i++)
+ {
+ if (i == baton.symbols_count - 1 && baton.symbols[i].file_address <= file_address)
+ {
+ symbol = &(baton.symbols[i]);
+ break;
+ }
+ else
+ {
+ if (baton.symbols[i].file_address <= file_address && baton.symbols[i + 1].file_address > file_address)
+ {
+ symbol = &(baton.symbols[i]);
+ break;
+ }
+ }
+ }
+
+ printf ("\n ");
+ if (symbol)
+ {
+ int offset = file_address - symbol->file_address;
+
+ // FIXME this is a poor heuristic - if we're greater than 16 bytes past the
+ // start of the function, this is the unwind info for a stripped function.
+ // In reality the compact unwind entry may not line up exactly with the
+ // function bounds.
+ if (offset >= 0)
+ {
+ printf ("name: %s", symbol->name);
+ if (offset > 0)
+ {
+ printf (" + %d", offset);
+ }
+ }
+ printf ("\n ");
+ }
+
+ print_encoding (baton, baton.mach_header_start + baton.first_level_index_entry.functionOffset + baton.text_section_file_offset + entry_func_offset, encoding);
+
+ bool has_lsda = encoding & UNWIND_HAS_LSDA;
+
+ if (has_lsda)
+ {
+ uint32_t func_offset = entry_func_offset + baton.first_level_index_entry.functionOffset;
+
+ int lsda_entry_number = -1;
+
+ uint32_t low = 0;
+ uint32_t high = (baton.lsda_array_end - baton.lsda_array_start) / sizeof (struct unwind_info_section_header_lsda_index_entry);
+
+ while (low < high)
+ {
+ uint32_t mid = (low + high) / 2;
+
+ uint8_t *mid_lsda_entry_addr = (baton.lsda_array_start + (mid * sizeof (struct unwind_info_section_header_lsda_index_entry)));
+ struct unwind_info_section_header_lsda_index_entry mid_lsda_entry;
+ memcpy (&mid_lsda_entry, mid_lsda_entry_addr, sizeof (struct unwind_info_section_header_lsda_index_entry));
+ if (mid_lsda_entry.functionOffset == func_offset)
+ {
+ lsda_entry_number = (mid_lsda_entry_addr - baton.lsda_array_start) / sizeof (struct unwind_info_section_header_lsda_index_entry);
+ break;
+ }
+ else if (mid_lsda_entry.functionOffset < func_offset)
+ {
+ low = mid + 1;
+ }
+ else
+ {
+ high = mid;
+ }
+ }
+
+ if (lsda_entry_number != -1)
+ {
+ printf (", LSDA entry #%d", lsda_entry_number);
+ }
+ else
+ {
+ printf (", LSDA entry not found");
+ }
+ }
+
+ uint32_t pers_idx = EXTRACT_BITS (encoding, UNWIND_PERSONALITY_MASK);
+ if (pers_idx != 0)
+ {
+ pers_idx--; // Change 1-based to 0-based index
+ printf (", personality entry #%d", pers_idx);
+ }
+
+ printf ("\n");
+}
+
+void
+print_second_level_index_regular (struct baton baton)
+{
+ uint8_t *page_entries = baton.compact_unwind_start + baton.first_level_index_entry.secondLevelPagesSectionOffset + baton.regular_second_level_page_header.entryPageOffset;
+ uint32_t entries_count = baton.regular_second_level_page_header.entryCount;
+
+ uint8_t *offset = page_entries;
+
+ uint32_t idx = 0;
+ while (idx < entries_count)
+ {
+ uint32_t func_offset = *((uint32_t *) (offset));
+ uint32_t encoding = *((uint32_t *) (offset + 4));
+
+ // UNWIND_SECOND_LEVEL_REGULAR entries have a funcOffset which includes the
+ // functionOffset from the containing index table already. UNWIND_SECOND_LEVEL_COMPRESSED
+ // entries only have the offset from the containing index table functionOffset.
+ // So strip off the contianing index table functionOffset value here so they can
+ // be treated the same at the lower layers.
+
+ print_function_encoding (baton, idx, encoding, (uint32_t) -1, func_offset - baton.first_level_index_entry.functionOffset);
+ idx++;
+ offset += 8;
+ }
+}
+
+void
+print_second_level_index_compressed (struct baton baton)
+{
+ uint8_t *this_index = baton.compact_unwind_start + baton.first_level_index_entry.secondLevelPagesSectionOffset;
+ uint8_t *start_of_entries = this_index + baton.compressed_second_level_page_header.entryPageOffset;
+ uint8_t *offset = start_of_entries;
+ for (uint16_t idx = 0; idx < baton.compressed_second_level_page_header.entryCount; idx++)
+ {
+ uint32_t entry = *((uint32_t*) offset);
+ offset += 4;
+ uint32_t encoding;
+
+ uint32_t entry_encoding_index = UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX (entry);
+ uint32_t entry_func_offset = UNWIND_INFO_COMPRESSED_ENTRY_FUNC_OFFSET (entry);
+
+ if (entry_encoding_index < baton.unwind_header.commonEncodingsArrayCount)
+ {
+ // encoding is in common table in section header
+ encoding = *((uint32_t*) (baton.compact_unwind_start + baton.unwind_header.commonEncodingsArraySectionOffset + (entry_encoding_index * sizeof (uint32_t))));
+ }
+ else
+ {
+ // encoding is in page specific table
+ uint32_t page_encoding_index = entry_encoding_index - baton.unwind_header.commonEncodingsArrayCount;
+ encoding = *((uint32_t*) (this_index + baton.compressed_second_level_page_header.encodingsPageOffset + (page_encoding_index * sizeof (uint32_t))));
+ }
+
+
+ print_function_encoding (baton, idx, encoding, entry_encoding_index, entry_func_offset);
+ }
+}
+
+void
+print_second_level_index (struct baton baton)
+{
+ uint8_t *index_start = baton.compact_unwind_start + baton.first_level_index_entry.secondLevelPagesSectionOffset;
+
+ if ((*(uint32_t*) index_start) == UNWIND_SECOND_LEVEL_REGULAR)
+ {
+ struct unwind_info_regular_second_level_page_header header;
+ memcpy (&header, index_start, sizeof (struct unwind_info_regular_second_level_page_header));
+ printf (" UNWIND_SECOND_LEVEL_REGULAR #%d entryPageOffset %d, entryCount %d\n", baton.current_index_table_number, header.entryPageOffset, header.entryCount);
+ baton.regular_second_level_page_header = header;
+ print_second_level_index_regular (baton);
+ }
+
+ if ((*(uint32_t*) index_start) == UNWIND_SECOND_LEVEL_COMPRESSED)
+ {
+ struct unwind_info_compressed_second_level_page_header header;
+ memcpy (&header, index_start, sizeof (struct unwind_info_compressed_second_level_page_header));
+ printf (" UNWIND_SECOND_LEVEL_COMPRESSED #%d entryPageOffset %d, entryCount %d, encodingsPageOffset %d, encodingsCount %d\n", baton.current_index_table_number, header.entryPageOffset, header.entryCount, header.encodingsPageOffset, header.encodingsCount);
+ baton.compressed_second_level_page_header = header;
+ print_second_level_index_compressed (baton);
+ }
+}
+
+
+void
+print_index_sections (struct baton baton)
+{
+ uint8_t *index_section_offset = baton.compact_unwind_start + baton.unwind_header.indexSectionOffset;
+ uint32_t index_count = baton.unwind_header.indexCount;
+
+ uint32_t cur_idx = 0;
+
+ uint8_t *offset = index_section_offset;
+ while (cur_idx < index_count)
+ {
+ baton.current_index_table_number = cur_idx;
+ struct unwind_info_section_header_index_entry index_entry;
+ memcpy (&index_entry, offset, sizeof (struct unwind_info_section_header_index_entry));
+ printf ("index section #%d: functionOffset %d, secondLevelPagesSectionOffset %d, lsdaIndexArraySectionOffset %d\n", cur_idx, index_entry.functionOffset, index_entry.secondLevelPagesSectionOffset, index_entry.lsdaIndexArraySectionOffset);
+
+ // secondLevelPagesSectionOffset == 0 means this is a sentinel entry
+ if (index_entry.secondLevelPagesSectionOffset != 0)
+ {
+ struct unwind_info_section_header_index_entry next_index_entry;
+ memcpy (&next_index_entry, offset + sizeof (struct unwind_info_section_header_index_entry), sizeof (struct unwind_info_section_header_index_entry));
+
+ baton.lsda_array_start = baton.compact_unwind_start + index_entry.lsdaIndexArraySectionOffset;
+ baton.lsda_array_end = baton.compact_unwind_start + next_index_entry.lsdaIndexArraySectionOffset;
+
+ uint8_t *lsda_entry_offset = baton.lsda_array_start;
+ uint32_t lsda_count = 0;
+ while (lsda_entry_offset < baton.lsda_array_end)
+ {
+ struct unwind_info_section_header_lsda_index_entry lsda_entry;
+ memcpy (&lsda_entry, lsda_entry_offset, sizeof (struct unwind_info_section_header_lsda_index_entry));
+ uint64_t function_file_address = baton.first_level_index_entry.functionOffset + lsda_entry.functionOffset + baton.text_segment_vmaddr;
+ uint64_t lsda_file_address = lsda_entry.lsdaOffset + baton.text_segment_vmaddr;
+ printf (" LSDA [%d] functionOffset %d (%d) (file address 0x%" PRIx64 "), lsdaOffset %d (file address 0x%" PRIx64 ")\n",
+ lsda_count, lsda_entry.functionOffset,
+ lsda_entry.functionOffset - index_entry.functionOffset,
+ function_file_address,
+ lsda_entry.lsdaOffset, lsda_file_address);
+ lsda_count++;
+ lsda_entry_offset += sizeof (struct unwind_info_section_header_lsda_index_entry);
+ }
+
+ printf ("\n");
+
+ baton.first_level_index_entry = index_entry;
+ print_second_level_index (baton);
+ }
+
+ printf ("\n");
+
+ cur_idx++;
+ offset += sizeof (struct unwind_info_section_header_index_entry);
+ }
+}
+
+int main (int argc, char **argv)
+{
+ struct stat st;
+ char *file = argv[0];
+ if (argc > 1)
+ file = argv[1];
+ int fd = open (file, O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("Failed to open '%s'\n", file);
+ exit (1);
+ }
+ fstat (fd, &st);
+ uint8_t *file_mem = (uint8_t*) mmap (0, st.st_size, PROT_READ, MAP_PRIVATE | MAP_FILE, fd, 0);
+ if (file_mem == MAP_FAILED)
+ {
+ printf ("Failed to mmap() '%s'\n", file);
+ }
+
+ FILE *f = fopen ("a.out", "r");
+
+ struct baton baton;
+ baton.mach_header_start = file_mem;
+ baton.symbols = NULL;
+ baton.symbols_count = 0;
+ baton.function_start_addresses = NULL;
+ baton.function_start_addresses_count = 0;
+
+ scan_macho_load_commands (&baton);
+
+ if (baton.compact_unwind_start == NULL)
+ {
+ printf ("could not find __TEXT,__unwind_info section\n");
+ exit (1);
+ }
+
+
+ struct unwind_info_section_header header;
+ memcpy (&header, baton.compact_unwind_start, sizeof (struct unwind_info_section_header));
+ printf ("Header:\n");
+ printf (" version %u\n", header.version);
+ printf (" commonEncodingsArraySectionOffset is %d\n", header.commonEncodingsArraySectionOffset);
+ printf (" commonEncodingsArrayCount is %d\n", header.commonEncodingsArrayCount);
+ printf (" personalityArraySectionOffset is %d\n", header.personalityArraySectionOffset);
+ printf (" personalityArrayCount is %d\n", header.personalityArrayCount);
+ printf (" indexSectionOffset is %d\n", header.indexSectionOffset);
+ printf (" indexCount is %d\n", header.indexCount);
+
+ uint8_t *common_encodings = baton.compact_unwind_start + header.commonEncodingsArraySectionOffset;
+ uint32_t encoding_idx = 0;
+ while (encoding_idx < header.commonEncodingsArrayCount)
+ {
+ uint32_t encoding = *((uint32_t*) common_encodings);
+ printf (" Common Encoding [%d]: 0x%x ", encoding_idx, encoding);
+ print_encoding (baton, NULL, encoding);
+ printf ("\n");
+ common_encodings += sizeof (uint32_t);
+ encoding_idx++;
+ }
+
+ uint8_t *pers_arr = baton.compact_unwind_start + header.personalityArraySectionOffset;
+ uint32_t pers_idx = 0;
+ while (pers_idx < header.personalityArrayCount)
+ {
+ int32_t pers_delta = *((int32_t*) (baton.compact_unwind_start + header.personalityArraySectionOffset + (pers_idx * sizeof (uint32_t))));
+ printf (" Personality [%d]: personality function ptr @ offset %d (file address 0x%" PRIx64 ")\n", pers_idx, pers_delta, baton.text_segment_vmaddr + pers_delta);
+ pers_idx++;
+ pers_arr += sizeof (uint32_t);
+ }
+
+ printf ("\n");
+
+ baton.unwind_header = header;
+
+ print_index_sections (baton);
+
+
+ return 0;
+}
diff --git a/tools/driver/Driver.cpp b/tools/driver/Driver.cpp
index 854310031c37..f02b081b8f0f 100644
--- a/tools/driver/Driver.cpp
+++ b/tools/driver/Driver.cpp
@@ -19,6 +19,8 @@
#if defined(_WIN32)
#include <io.h>
#include <fcntl.h>
+#elif defined(__ANDROID_NDK__)
+#include <errno.h>
#else
#include <unistd.h>
#endif
@@ -39,6 +41,10 @@
#include "lldb/API/SBThread.h"
#include "lldb/API/SBProcess.h"
+#if !defined(__APPLE__)
+#include "llvm/Support/DataTypes.h"
+#endif
+
using namespace lldb;
static void reset_stdin_termios ();
@@ -104,8 +110,15 @@ static OptionDefinition g_options[] =
"Tells the debugger to read in and execute the lldb commands in the given file, before any file provided on the command line has been loaded." },
{ LLDB_3_TO_5, false, "one-line-before-file" , 'O', required_argument, 0, eArgTypeNone,
"Tells the debugger to execute this one-line lldb command before any file provided on the command line has been loaded." },
+ { LLDB_3_TO_5, false, "one-line-on-crash" , 'k', required_argument, 0, eArgTypeNone,
+ "When in batch mode, tells the debugger to execute this one-line lldb command if the target crashes." },
+ { LLDB_3_TO_5, false, "source-on-crash" , 'K', required_argument, 0, eArgTypeFilename,
+ "When in batch mode, tells the debugger to source this file of lldb commands if the target crashes." },
{ LLDB_3_TO_5, false, "source-quietly" , 'Q', no_argument , 0, eArgTypeNone,
- "Tells the debugger suppress output from commands provided in the -s, -S, -O and -o commands." },
+ "Tells the debugger to execute this one-line lldb command before any file provided on the command line has been loaded." },
+ { LLDB_3_TO_5, false, "batch" , 'b', no_argument , 0, eArgTypeNone,
+ "Tells the debugger to running the commands from -s, -S, -o & -O, and then quit. However if any run command stopped due to a signal or crash, "
+ "the debugger will return to the interactive prompt at the place of the crash." },
{ LLDB_3_TO_5, false, "editor" , 'e', no_argument , 0, eArgTypeNone,
"Tells the debugger to open source files using the host's \"external editor\" mechanism." },
{ LLDB_3_TO_5, false, "no-lldbinit" , 'x', no_argument , 0, eArgTypeNone,
@@ -393,6 +406,7 @@ Driver::OptionData::OptionData () :
m_crash_log (),
m_initial_commands (),
m_after_file_commands (),
+ m_after_crash_commands(),
m_debug_mode (false),
m_source_quietly(false),
m_print_version (false),
@@ -402,6 +416,7 @@ Driver::OptionData::OptionData () :
m_process_name(),
m_process_pid(LLDB_INVALID_PROCESS_ID),
m_use_external_editor(false),
+ m_batch(false),
m_seen_options()
{
}
@@ -417,6 +432,16 @@ Driver::OptionData::Clear ()
m_script_lang = lldb::eScriptLanguageDefault;
m_initial_commands.clear ();
m_after_file_commands.clear ();
+ // If there is a local .lldbinit, source that:
+ SBFileSpec local_lldbinit("./.lldbinit", true);
+ if (local_lldbinit.Exists())
+ {
+ char path[2048];
+ local_lldbinit.GetPath(path, 2047);
+ InitialCmdEntry entry(path, true, true);
+ m_after_file_commands.push_back (entry);
+ }
+
m_debug_mode = false;
m_source_quietly = false;
m_print_help = false;
@@ -425,35 +450,45 @@ Driver::OptionData::Clear ()
m_use_external_editor = false;
m_wait_for = false;
m_process_name.erase();
+ m_batch = false;
+ m_after_crash_commands.clear();
+
m_process_pid = LLDB_INVALID_PROCESS_ID;
}
void
-Driver::OptionData::AddInitialCommand (const char *command, bool before_file, bool is_file, SBError &error)
+Driver::OptionData::AddInitialCommand (const char *command, CommandPlacement placement, bool is_file, bool silent, SBError &error)
{
- std::vector<std::pair<bool, std::string> > *command_set;
- if (before_file)
+ std::vector<InitialCmdEntry> *command_set;
+ switch (placement)
+ {
+ case eCommandPlacementBeforeFile:
command_set = &(m_initial_commands);
- else
+ break;
+ case eCommandPlacementAfterFile:
command_set = &(m_after_file_commands);
+ break;
+ case eCommandPlacementAfterCrash:
+ command_set = &(m_after_crash_commands);
+ break;
+ }
if (is_file)
{
SBFileSpec file(command);
if (file.Exists())
- command_set->push_back (std::pair<bool, std::string> (true, optarg));
+ command_set->push_back (InitialCmdEntry(command, is_file, silent));
else if (file.ResolveExecutableLocation())
{
char final_path[PATH_MAX];
file.GetPath (final_path, sizeof(final_path));
- std::string path_str (final_path);
- command_set->push_back (std::pair<bool, std::string> (true, path_str));
+ command_set->push_back (InitialCmdEntry(final_path, is_file, silent));
}
else
error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg);
}
else
- command_set->push_back (std::pair<bool, std::string> (false, optarg));
+ command_set->push_back (InitialCmdEntry(command, is_file, silent));
}
void
@@ -485,16 +520,30 @@ Driver::GetScriptLanguage() const
}
void
-Driver::WriteInitialCommands (bool before_file, SBStream &strm)
+Driver::WriteCommandsForSourcing (CommandPlacement placement, SBStream &strm)
{
- std::vector<std::pair<bool, std::string> > &command_set = before_file ? m_option_data.m_initial_commands :
- m_option_data.m_after_file_commands;
+ std::vector<OptionData::InitialCmdEntry> *command_set;
+ switch (placement)
+ {
+ case eCommandPlacementBeforeFile:
+ command_set = &m_option_data.m_initial_commands;
+ break;
+ case eCommandPlacementAfterFile:
+ command_set = &m_option_data.m_after_file_commands;
+ break;
+ case eCommandPlacementAfterCrash:
+ command_set = &m_option_data.m_after_crash_commands;
+ break;
+ }
- for (const auto &command_pair : command_set)
+ for (const auto &command_entry : *command_set)
{
- const char *command = command_pair.second.c_str();
- if (command_pair.first)
- strm.Printf("command source -s %i '%s'\n", m_option_data.m_source_quietly, command);
+ const char *command = command_entry.contents.c_str();
+ if (command_entry.is_file)
+ {
+ bool source_quietly = m_option_data.m_source_quietly || command_entry.source_quietly;
+ strm.Printf("command source -s %i '%s'\n", source_quietly, command);
+ }
else
strm.Printf("%s\n", command);
}
@@ -637,6 +686,10 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
m_option_data.m_print_python_path = true;
break;
+ case 'b':
+ m_option_data.m_batch = true;
+ break;
+
case 'c':
{
SBFileSpec file(optarg);
@@ -697,6 +750,13 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
m_option_data.m_source_quietly = true;
break;
+ case 'K':
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash, true, true, error);
+ break;
+ case 'k':
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash, false, true, error);
+ break;
+
case 'n':
m_option_data.m_process_name = optarg;
break;
@@ -715,16 +775,16 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
}
break;
case 's':
- m_option_data.AddInitialCommand(optarg, false, true, error);
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, true, true, error);
break;
case 'o':
- m_option_data.AddInitialCommand(optarg, false, false, error);
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, false, true, error);
break;
case 'S':
- m_option_data.AddInitialCommand(optarg, true, true, error);
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile, true, true, error);
break;
case 'O':
- m_option_data.AddInitialCommand(optarg, true, false, error);
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile, false, true, error);
break;
default:
m_option_data.m_print_help = true;
@@ -807,6 +867,95 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
return error;
}
+static ::FILE *
+PrepareCommandsForSourcing (const char *commands_data, size_t commands_size, int fds[2])
+{
+ enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
+
+ bool success = true;
+ ::FILE *commands_file = NULL;
+ fds[0] = -1;
+ fds[1] = -1;
+ int err = 0;
+#ifdef _WIN32
+ err = _pipe(fds, commands_size, O_BINARY);
+#else
+ err = pipe(fds);
+#endif
+ if (err == 0)
+ {
+ ssize_t nrwr = write(fds[WRITE], commands_data, commands_size);
+ if (nrwr < 0)
+ {
+ fprintf(stderr, "error: write(%i, %p, %zd) failed (errno = %i) "
+ "when trying to open LLDB commands pipe\n",
+ fds[WRITE], commands_data, commands_size, errno);
+ success = false;
+ }
+ else if (static_cast<size_t>(nrwr) == commands_size)
+ {
+ // Close the write end of the pipe so when we give the read end to
+ // the debugger/command interpreter it will exit when it consumes all
+ // of the data
+#ifdef _WIN32
+ _close(fds[WRITE]); fds[WRITE] = -1;
+#else
+ close(fds[WRITE]); fds[WRITE] = -1;
+#endif
+ // Now open the read file descriptor in a FILE * that we can give to
+ // the debugger as an input handle
+ commands_file = fdopen(fds[READ], "r");
+ if (commands_file)
+ {
+ fds[READ] = -1; // The FILE * 'commands_file' now owns the read descriptor
+ // Hand ownership if the FILE * over to the debugger for "commands_file".
+ }
+ else
+ {
+ fprintf(stderr,
+ "error: fdopen(%i, \"r\") failed (errno = %i) when "
+ "trying to open LLDB commands pipe\n",
+ fds[READ], errno);
+ success = false;
+ }
+ }
+ }
+ else
+ {
+ fprintf(stderr, "error: can't create pipe file descriptors for LLDB commands\n");
+ success = false;
+ }
+
+ return commands_file;
+}
+
+void
+CleanupAfterCommandSourcing (int fds[2])
+{
+ enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
+
+ // Close any pipes that we still have ownership of
+ if ( fds[WRITE] != -1)
+ {
+#ifdef _WIN32
+ _close(fds[WRITE]); fds[WRITE] = -1;
+#else
+ close(fds[WRITE]); fds[WRITE] = -1;
+#endif
+
+ }
+
+ if ( fds[READ] != -1)
+ {
+#ifdef _WIN32
+ _close(fds[READ]); fds[READ] = -1;
+#else
+ close(fds[READ]); fds[READ] = -1;
+#endif
+ }
+
+}
+
void
Driver::MainLoop ()
{
@@ -849,7 +998,7 @@ Driver::MainLoop ()
SBStream commands_stream;
// First source in the commands specified to be run before the file arguments are processed.
- WriteInitialCommands(true, commands_stream);
+ WriteCommandsForSourcing(eCommandPlacementBeforeFile, commands_stream);
const size_t num_args = m_option_data.m_args.size();
if (num_args > 0)
@@ -899,11 +1048,8 @@ Driver::MainLoop ()
commands_stream.Printf ("process attach --pid %" PRIu64 "\n", m_option_data.m_process_pid);
}
- WriteInitialCommands(false, commands_stream);
+ WriteCommandsForSourcing(eCommandPlacementAfterFile, commands_stream);
- // Now that all option parsing is done, we try and parse the .lldbinit
- // file in the current working directory
- sb_interpreter.SourceInitFileInCurrentWorkingDirectory (result);
if (GetDebugMode())
{
result.PutError(m_debugger.GetErrorFileHandle());
@@ -917,72 +1063,69 @@ Driver::MainLoop ()
// so we can then run the command interpreter using the file contents.
const char *commands_data = commands_stream.GetData();
const size_t commands_size = commands_stream.GetSize();
+
+ // The command file might have requested that we quit, this variable will track that.
+ bool quit_requested = false;
+ bool stopped_for_crash = false;
if (commands_data && commands_size)
{
- enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
-
+ int initial_commands_fds[2];
bool success = true;
- int fds[2] = { -1, -1 };
- int err = 0;
-#ifdef _WIN32
- err = _pipe(fds, commands_size, O_BINARY);
-#else
- err = pipe(fds);
-#endif
- if (err == 0)
+ FILE *commands_file = PrepareCommandsForSourcing (commands_data, commands_size, initial_commands_fds);
+ if (commands_file)
{
- if (write (fds[WRITE], commands_data, commands_size) == commands_size)
+ m_debugger.SetInputFileHandle (commands_file, true);
+
+ // Set the debugger into Sync mode when running the command file. Otherwise command files
+ // that run the target won't run in a sensible way.
+ bool old_async = m_debugger.GetAsync();
+ m_debugger.SetAsync(false);
+ int num_errors;
+
+ SBCommandInterpreterRunOptions options;
+ options.SetStopOnError (true);
+ if (m_option_data.m_batch)
+ options.SetStopOnCrash (true);
+
+ m_debugger.RunCommandInterpreter(handle_events,
+ spawn_thread,
+ options,
+ num_errors,
+ quit_requested,
+ stopped_for_crash);
+
+ if (m_option_data.m_batch && stopped_for_crash && !m_option_data.m_after_crash_commands.empty())
{
- // Close the write end of the pipe so when we give the read end to
- // the debugger/command interpreter it will exit when it consumes all
- // of the data
-#ifdef _WIN32
- _close(fds[WRITE]); fds[WRITE] = -1;
-#else
- close(fds[WRITE]); fds[WRITE] = -1;
-#endif
- // Now open the read file descriptor in a FILE * that we can give to
- // the debugger as an input handle
- FILE *commands_file = fdopen(fds[READ], "r");
+ int crash_command_fds[2];
+ SBStream crash_commands_stream;
+ WriteCommandsForSourcing (eCommandPlacementAfterCrash, crash_commands_stream);
+ const char *crash_commands_data = crash_commands_stream.GetData();
+ const size_t crash_commands_size = crash_commands_stream.GetSize();
+ commands_file = PrepareCommandsForSourcing (crash_commands_data, crash_commands_size, crash_command_fds);
if (commands_file)
{
- fds[READ] = -1; // The FILE * 'commands_file' now owns the read descriptor
- // Hand ownership if the FILE * over to the debugger for "commands_file".
+ bool local_quit_requested;
+ bool local_stopped_for_crash;
m_debugger.SetInputFileHandle (commands_file, true);
- m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
- }
- else
- {
- fprintf(stderr, "error: fdopen(%i, \"r\") failed (errno = %i) when trying to open LLDB commands pipe\n", fds[READ], errno);
- success = false;
+
+ m_debugger.RunCommandInterpreter(handle_events,
+ spawn_thread,
+ options,
+ num_errors,
+ local_quit_requested,
+ local_stopped_for_crash);
+ if (local_quit_requested)
+ quit_requested = true;
+
}
}
+ m_debugger.SetAsync(old_async);
}
else
- {
- fprintf(stderr, "error: can't create pipe file descriptors for LLDB commands\n");
success = false;
- }
// Close any pipes that we still have ownership of
- if ( fds[WRITE] != -1)
- {
-#ifdef _WIN32
- _close(fds[WRITE]); fds[WRITE] = -1;
-#else
- close(fds[WRITE]); fds[WRITE] = -1;
-#endif
-
- }
-
- if ( fds[READ] != -1)
- {
-#ifdef _WIN32
- _close(fds[READ]); fds[READ] = -1;
-#else
- close(fds[READ]); fds[READ] = -1;
-#endif
- }
+ CleanupAfterCommandSourcing(initial_commands_fds);
// Something went wrong with command pipe
if (!success)
@@ -995,8 +1138,18 @@ Driver::MainLoop ()
// Now set the input file handle to STDIN and run the command
// interpreter again in interactive mode and let the debugger
// take ownership of stdin
- m_debugger.SetInputFileHandle (stdin, true);
- m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
+
+ bool go_interactive = true;
+ if (quit_requested)
+ go_interactive = false;
+ else if (m_option_data.m_batch && !stopped_for_crash)
+ go_interactive = false;
+
+ if (go_interactive)
+ {
+ m_debugger.SetInputFileHandle (stdin, true);
+ m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
+ }
reset_stdin_termios();
fclose (stdin);
diff --git a/tools/driver/Driver.h b/tools/driver/Driver.h
index 8b6c6eebdd56..38b125481d92 100644
--- a/tools/driver/Driver.h
+++ b/tools/driver/Driver.h
@@ -28,6 +28,13 @@ class IOChannel;
class Driver : public lldb::SBBroadcaster
{
public:
+ typedef enum CommandPlacement
+ {
+ eCommandPlacementBeforeFile,
+ eCommandPlacementAfterFile,
+ eCommandPlacementAfterCrash,
+ } CommandPlacement;
+
Driver ();
virtual
@@ -52,7 +59,7 @@ public:
GetScriptLanguage() const;
void
- WriteInitialCommands (bool before_file, lldb::SBStream &strm);
+ WriteCommandsForSourcing (CommandPlacement placement, lldb::SBStream &strm);
bool
GetDebugMode() const;
@@ -68,16 +75,30 @@ public:
Clear();
void
- AddInitialCommand (const char *command, bool before_file, bool is_file, lldb::SBError &error);
+ AddInitialCommand (const char *command, CommandPlacement placement, bool is_file, bool quietly, lldb::SBError &error);
//static OptionDefinition m_cmd_option_table[];
+ struct InitialCmdEntry
+ {
+ InitialCmdEntry (const char *in_contents, bool in_is_file, bool in_quiet = false) :
+ contents (in_contents),
+ is_file (in_is_file),
+ source_quietly(in_quiet)
+ {}
+
+ std::string contents;
+ bool is_file;
+ bool source_quietly;
+ };
+
std::vector<std::string> m_args;
lldb::ScriptLanguage m_script_lang;
std::string m_core_file;
std::string m_crash_log;
- std::vector<std::pair<bool,std::string> > m_initial_commands;
- std::vector<std::pair<bool,std::string> > m_after_file_commands;
+ std::vector<InitialCmdEntry> m_initial_commands;
+ std::vector<InitialCmdEntry> m_after_file_commands;
+ std::vector<InitialCmdEntry> m_after_crash_commands;
bool m_debug_mode;
bool m_source_quietly;
bool m_print_version;
@@ -87,6 +108,7 @@ public:
std::string m_process_name;
lldb::pid_t m_process_pid;
bool m_use_external_editor; // FIXME: When we have set/show variables we can remove this from here.
+ bool m_batch;
typedef std::set<char> OptionSet;
OptionSet m_seen_options;
};
diff --git a/tools/driver/Platform.h b/tools/driver/Platform.h
index e26610711aca..8995512a0f8f 100644
--- a/tools/driver/Platform.h
+++ b/tools/driver/Platform.h
@@ -101,15 +101,17 @@
#include <termios.h>
#include <unistd.h>
- #include <histedit.h>
#include <pthread.h>
#include <sys/time.h>
- #if defined(__FreeBSD__) || defined(__NetBSD__)
- #include <readline/readline.h>
- #else
- #include <editline/readline.h>
- #endif
+#if !defined(__ANDROID_NDK__)
+ #include <histedit.h>
+ #if defined(__FreeBSD__) || defined(__NetBSD__)
+ #include <readline/readline.h>
+ #else
+ #include <editline/readline.h>
+ #endif
+#endif
#endif
diff --git a/tools/lldb-mi/Driver.cpp b/tools/lldb-mi/Driver.cpp
index a59b4b74eb0a..34a2471e9672 100644
--- a/tools/lldb-mi/Driver.cpp
+++ b/tools/lldb-mi/Driver.cpp
@@ -33,7 +33,7 @@
#include <lldb/API/SBCommunication.h>
#include <lldb/API/SBEvent.h>
#include <lldb/API/SBHostOS.h>
-#include <lldb/API/SBListener.h>
+#include <lldb/API/SBListener.h>
#include <lldb/API/SBStream.h>
#include <lldb/API/SBTarget.h>
#include <lldb/API/SBThread.h>
@@ -41,22 +41,22 @@
using namespace lldb;
-static void reset_stdin_termios ();
+static void reset_stdin_termios();
static bool g_old_stdin_termios_is_valid = false;
static struct termios g_old_stdin_termios;
-static char *g_debugger_name = (char *) "";
+static char *g_debugger_name = (char *)"";
Driver *g_driver = NULL;
// In the Driver::MainLoop, we change the terminal settings. This function is
// added as an atexit handler to make sure we clean them up.
static void
-reset_stdin_termios ()
+reset_stdin_termios()
{
if (g_old_stdin_termios_is_valid)
{
g_old_stdin_termios_is_valid = false;
- ::tcsetattr (STDIN_FILENO, TCSANOW, &g_old_stdin_termios);
+ ::tcsetattr(STDIN_FILENO, TCSANOW, &g_old_stdin_termios);
}
}
@@ -65,99 +65,94 @@ typedef struct
uint32_t usage_mask; // Used to mark options that can be used together. If (1 << n & usage_mask) != 0
// then this option belongs to option set n.
bool required; // This option is required (in the current usage level)
- const char * long_option; // Full name for this option.
+ const char *long_option; // Full name for this option.
int short_option; // Single character for this option.
int option_has_arg; // no_argument, required_argument or optional_argument
uint32_t completion_type; // Cookie the option class can use to do define the argument completion.
lldb::CommandArgumentType argument_type; // Type of argument this option takes
- const char * usage_text; // Full text explaining what this options does and what (if any) argument to
+ const char *usage_text; // Full text explaining what this options does and what (if any) argument to
// pass it.
} OptionDefinition;
-#define LLDB_3_TO_5 LLDB_OPT_SET_3|LLDB_OPT_SET_4|LLDB_OPT_SET_5
-#define LLDB_4_TO_5 LLDB_OPT_SET_4|LLDB_OPT_SET_5
-
-static OptionDefinition g_options[] =
-{
- { LLDB_OPT_SET_1, true , "help" , 'h', no_argument , 0, eArgTypeNone,
- "Prints out the usage information for the LLDB debugger." },
- { LLDB_OPT_SET_2, true , "version" , 'v', no_argument , 0, eArgTypeNone,
- "Prints out the current version number of the LLDB debugger." },
- { LLDB_OPT_SET_3, true , "arch" , 'a', required_argument, 0, eArgTypeArchitecture,
- "Tells the debugger to use the specified architecture when starting and running the program. <architecture> must "
- "be one of the architectures for which the program was compiled." },
- { LLDB_OPT_SET_3, true , "file" , 'f', required_argument, 0, eArgTypeFilename,
- "Tells the debugger to use the file <filename> as the program to be debugged." },
- { LLDB_OPT_SET_3, false, "core" , 'c', required_argument, 0, eArgTypeFilename,
- "Tells the debugger to use the fullpath to <path> as the core file." },
- { LLDB_OPT_SET_5, true , "attach-pid" , 'p', required_argument, 0, eArgTypePid,
- "Tells the debugger to attach to a process with the given pid." },
- { LLDB_OPT_SET_4, true , "attach-name" , 'n', required_argument, 0, eArgTypeProcessName,
- "Tells the debugger to attach to a process with the given name." },
- { LLDB_OPT_SET_4, true , "wait-for" , 'w', no_argument , 0, eArgTypeNone,
- "Tells the debugger to wait for a process with the given pid or name to launch before attaching." },
- { LLDB_3_TO_5, false, "source" , 's', required_argument, 0, eArgTypeFilename,
- "Tells the debugger to read in and execute the lldb commands in the given file, after any file provided on the command line has been loaded." },
- { LLDB_3_TO_5, false, "one-line" , 'o', required_argument, 0, eArgTypeNone,
- "Tells the debugger to execute this one-line lldb command after any file provided on the command line has been loaded." },
- { LLDB_3_TO_5, false, "source-before-file" , 'S', required_argument, 0, eArgTypeFilename,
- "Tells the debugger to read in and execute the lldb commands in the given file, before any file provided on the command line has been loaded." },
- { LLDB_3_TO_5, false, "one-line-before-file" , 'O', required_argument, 0, eArgTypeNone,
- "Tells the debugger to execute this one-line lldb command before any file provided on the command line has been loaded." },
- { LLDB_3_TO_5, false, "source-quietly" , 'Q', no_argument , 0, eArgTypeNone,
- "Tells the debugger suppress output from commands provided in the -s, -S, -O and -o commands." },
- { LLDB_3_TO_5, false, "editor" , 'e', no_argument , 0, eArgTypeNone,
- "Tells the debugger to open source files using the host's \"external editor\" mechanism." },
- { LLDB_3_TO_5, false, "no-lldbinit" , 'x', no_argument , 0, eArgTypeNone,
- "Do not automatically parse any '.lldbinit' files." },
- { LLDB_3_TO_5, false, "no-use-colors" , 'X', no_argument , 0, eArgTypeNone,
- "Do not use colors." },
- { LLDB_OPT_SET_6, true , "python-path" , 'P', no_argument , 0, eArgTypeNone,
- "Prints out the path to the lldb.py file for this version of lldb." },
- { LLDB_3_TO_5, false, "script-language", 'l', required_argument, 0, eArgTypeScriptLang,
- "Tells the debugger to use the specified scripting language for user-defined scripts, rather than the default. "
- "Valid scripting languages that can be specified include Python, Perl, Ruby and Tcl. Currently only the Python "
- "extensions have been implemented." },
- { LLDB_3_TO_5, false, "debug" , 'd', no_argument , 0, eArgTypeNone,
- "Tells the debugger to print out extra information for debugging itself." },
- { 0, false, NULL , 0 , 0 , 0, eArgTypeNone, NULL }
-};
+#define LLDB_3_TO_5 LLDB_OPT_SET_3 | LLDB_OPT_SET_4 | LLDB_OPT_SET_5
+#define LLDB_4_TO_5 LLDB_OPT_SET_4 | LLDB_OPT_SET_5
+
+static OptionDefinition g_options[] = {
+ {LLDB_OPT_SET_1, true, "help", 'h', no_argument, 0, eArgTypeNone, "Prints out the usage information for the LLDB debugger."},
+ {LLDB_OPT_SET_2, true, "version", 'v', no_argument, 0, eArgTypeNone, "Prints out the current version number of the LLDB debugger."},
+ {LLDB_OPT_SET_3, true, "arch", 'a', required_argument, 0, eArgTypeArchitecture,
+ "Tells the debugger to use the specified architecture when starting and running the program. <architecture> must "
+ "be one of the architectures for which the program was compiled."},
+ {LLDB_OPT_SET_3, true, "file", 'f', required_argument, 0, eArgTypeFilename,
+ "Tells the debugger to use the file <filename> as the program to be debugged."},
+ {LLDB_OPT_SET_3, false, "core", 'c', required_argument, 0, eArgTypeFilename,
+ "Tells the debugger to use the fullpath to <path> as the core file."},
+ {LLDB_OPT_SET_5, true, "attach-pid", 'p', required_argument, 0, eArgTypePid,
+ "Tells the debugger to attach to a process with the given pid."},
+ {LLDB_OPT_SET_4, true, "attach-name", 'n', required_argument, 0, eArgTypeProcessName,
+ "Tells the debugger to attach to a process with the given name."},
+ {LLDB_OPT_SET_4, true, "wait-for", 'w', no_argument, 0, eArgTypeNone,
+ "Tells the debugger to wait for a process with the given pid or name to launch before attaching."},
+ {LLDB_3_TO_5, false, "source", 's', required_argument, 0, eArgTypeFilename, "Tells the debugger to read in and execute the lldb "
+ "commands in the given file, after any file provided on "
+ "the command line has been loaded."},
+ {LLDB_3_TO_5, false, "one-line", 'o', required_argument, 0, eArgTypeNone,
+ "Tells the debugger to execute this one-line lldb command after any file provided on the command line has been loaded."},
+ {LLDB_3_TO_5, false, "source-before-file", 'S', required_argument, 0, eArgTypeFilename,
+ "Tells the debugger to read in and execute the lldb commands in the given file, before any file provided on the command line has been "
+ "loaded."},
+ {LLDB_3_TO_5, false, "one-line-before-file", 'O', required_argument, 0, eArgTypeNone,
+ "Tells the debugger to execute this one-line lldb command before any file provided on the command line has been loaded."},
+ {LLDB_3_TO_5, false, "source-quietly", 'Q', no_argument, 0, eArgTypeNone,
+ "Tells the debugger suppress output from commands provided in the -s, -S, -O and -o commands."},
+ {LLDB_3_TO_5, false, "editor", 'e', no_argument, 0, eArgTypeNone,
+ "Tells the debugger to open source files using the host's \"external editor\" mechanism."},
+ {LLDB_3_TO_5, false, "no-lldbinit", 'x', no_argument, 0, eArgTypeNone, "Do not automatically parse any '.lldbinit' files."},
+ {LLDB_3_TO_5, false, "no-use-colors", 'X', no_argument, 0, eArgTypeNone, "Do not use colors."},
+ {LLDB_OPT_SET_6, true, "python-path", 'P', no_argument, 0, eArgTypeNone,
+ "Prints out the path to the lldb.py file for this version of lldb."},
+ {LLDB_3_TO_5, false, "script-language", 'l', required_argument, 0, eArgTypeScriptLang,
+ "Tells the debugger to use the specified scripting language for user-defined scripts, rather than the default. "
+ "Valid scripting languages that can be specified include Python, Perl, Ruby and Tcl. Currently only the Python "
+ "extensions have been implemented."},
+ {LLDB_3_TO_5, false, "debug", 'd', no_argument, 0, eArgTypeNone,
+ "Tells the debugger to print out extra information for debugging itself."},
+ {0, false, NULL, 0, 0, 0, eArgTypeNone, NULL}};
static const uint32_t last_option_set_with_args = 2;
-Driver::Driver () :
- SBBroadcaster ("Driver"),
- m_debugger (SBDebugger::Create(false)),
- m_option_data ()
+Driver::Driver()
+ : SBBroadcaster("Driver")
+ , m_debugger(SBDebugger::Create(false))
+ , m_option_data()
{
// We want to be able to handle CTRL+D in the terminal to have it terminate
// certain input
- m_debugger.SetCloseInputOnEOF (false);
- g_debugger_name = (char *) m_debugger.GetInstanceName();
+ m_debugger.SetCloseInputOnEOF(false);
+ g_debugger_name = (char *)m_debugger.GetInstanceName();
if (g_debugger_name == NULL)
- g_debugger_name = (char *) "";
+ g_debugger_name = (char *)"";
g_driver = this;
}
-Driver::~Driver ()
+Driver::~Driver()
{
g_driver = NULL;
g_debugger_name = NULL;
}
-
// This function takes INDENT, which tells how many spaces to output at the front
-// of each line; TEXT, which is the text that is to be output. It outputs the
-// text, on multiple lines if necessary, to RESULT, with INDENT spaces at the
-// front of each line. It breaks lines on spaces, tabs or newlines, shortening
-// the line if necessary to not break in the middle of a word. It assumes that
+// of each line; TEXT, which is the text that is to be output. It outputs the
+// text, on multiple lines if necessary, to RESULT, with INDENT spaces at the
+// front of each line. It breaks lines on spaces, tabs or newlines, shortening
+// the line if necessary to not break in the middle of a word. It assumes that
// each output line should contain a maximum of OUTPUT_MAX_COLUMNS characters.
void
-OutputFormattedUsageText (FILE *out, int indent, const char *text, int output_max_columns)
+OutputFormattedUsageText(FILE *out, int indent, const char *text, int output_max_columns)
{
- int len = strlen (text);
- std::string text_string (text);
+ int len = strlen(text);
+ std::string text_string(text);
// Force indentation to be reasonable.
if (indent >= output_max_columns)
@@ -167,7 +162,7 @@ OutputFormattedUsageText (FILE *out, int indent, const char *text, int output_ma
if (len + indent < output_max_columns)
// Output as a single line
- fprintf (out, "%*s%s\n", indent, "", text);
+ fprintf(out, "%*s%s\n", indent, "", text);
else
{
// We need to break it up into multiple lines.
@@ -179,39 +174,37 @@ OutputFormattedUsageText (FILE *out, int indent, const char *text, int output_ma
while (end < final_end)
{
- // Dont start the 'text' on a space, since we're already outputting the indentation.
- while ((start < final_end) && (text[start] == ' '))
- start++;
-
- end = start + text_width;
- if (end > final_end)
- end = final_end;
- else
- {
- // If we're not at the end of the text, make sure we break the line on white space.
- while (end > start
- && text[end] != ' ' && text[end] != '\t' && text[end] != '\n')
- end--;
- }
- sub_len = end - start;
- std::string substring = text_string.substr (start, sub_len);
- fprintf (out, "%*s%s\n", indent, "", substring.c_str());
- start = end + 1;
+ // Dont start the 'text' on a space, since we're already outputting the indentation.
+ while ((start < final_end) && (text[start] == ' '))
+ start++;
+
+ end = start + text_width;
+ if (end > final_end)
+ end = final_end;
+ else
+ {
+ // If we're not at the end of the text, make sure we break the line on white space.
+ while (end > start && text[end] != ' ' && text[end] != '\t' && text[end] != '\n')
+ end--;
+ }
+ sub_len = end - start;
+ std::string substring = text_string.substr(start, sub_len);
+ fprintf(out, "%*s%s\n", indent, "", substring.c_str());
+ start = end + 1;
}
}
}
void
-ShowUsage (FILE *out, OptionDefinition *option_table, Driver::OptionData data)
+ShowUsage(FILE *out, OptionDefinition *option_table, Driver::OptionData data)
{
uint32_t screen_width = 80;
uint32_t indent_level = 0;
const char *name = "lldb";
-
- fprintf (out, "\nUsage:\n\n");
- indent_level += 2;
+ fprintf(out, "\nUsage:\n\n");
+ indent_level += 2;
// First, show each usage level set of options, e.g. <cmd> [options-for-level-0]
// <cmd> [options-for-level-1]
@@ -219,7 +212,7 @@ ShowUsage (FILE *out, OptionDefinition *option_table, Driver::OptionData data)
uint32_t num_options;
uint32_t num_option_sets = 0;
-
+
for (num_options = 0; option_table[num_options].long_option != NULL; ++num_options)
{
uint32_t this_usage_mask = option_table[num_options].usage_mask;
@@ -244,50 +237,50 @@ ShowUsage (FILE *out, OptionDefinition *option_table, Driver::OptionData data)
for (uint32_t opt_set = 0; opt_set < num_option_sets; opt_set++)
{
uint32_t opt_set_mask;
-
+
opt_set_mask = 1 << opt_set;
-
+
if (opt_set > 0)
- fprintf (out, "\n");
- fprintf (out, "%*s%s", indent_level, "", name);
+ fprintf(out, "\n");
+ fprintf(out, "%*s%s", indent_level, "", name);
bool is_help_line = false;
-
+
for (uint32_t i = 0; i < num_options; ++i)
{
if (option_table[i].usage_mask & opt_set_mask)
{
CommandArgumentType arg_type = option_table[i].argument_type;
- const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString (arg_type);
+ const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString(arg_type);
// This is a bit of a hack, but there's no way to say certain options don't have arguments yet...
// so we do it by hand here.
if (option_table[i].short_option == 'h')
is_help_line = true;
-
+
if (option_table[i].required)
{
if (option_table[i].option_has_arg == required_argument)
- fprintf (out, " -%c <%s>", option_table[i].short_option, arg_name);
+ fprintf(out, " -%c <%s>", option_table[i].short_option, arg_name);
else if (option_table[i].option_has_arg == optional_argument)
- fprintf (out, " -%c [<%s>]", option_table[i].short_option, arg_name);
+ fprintf(out, " -%c [<%s>]", option_table[i].short_option, arg_name);
else
- fprintf (out, " -%c", option_table[i].short_option);
+ fprintf(out, " -%c", option_table[i].short_option);
}
else
{
if (option_table[i].option_has_arg == required_argument)
- fprintf (out, " [-%c <%s>]", option_table[i].short_option, arg_name);
+ fprintf(out, " [-%c <%s>]", option_table[i].short_option, arg_name);
else if (option_table[i].option_has_arg == optional_argument)
- fprintf (out, " [-%c [<%s>]]", option_table[i].short_option, arg_name);
+ fprintf(out, " [-%c [<%s>]]", option_table[i].short_option, arg_name);
else
- fprintf (out, " [-%c]", option_table[i].short_option);
+ fprintf(out, " [-%c]", option_table[i].short_option);
}
}
}
if (!is_help_line && (opt_set <= last_option_set_with_args))
- fprintf (out, " [[--] <PROGRAM-ARG-1> [<PROGRAM_ARG-2> ...]]");
+ fprintf(out, " [[--] <PROGRAM-ARG-1> [<PROGRAM_ARG-2> ...]]");
}
- fprintf (out, "\n\n");
+ fprintf(out, "\n\n");
// Now print out all the detailed information about the various options: long form, short form and help text:
// -- long_name <argument>
@@ -305,55 +298,47 @@ ShowUsage (FILE *out, OptionDefinition *option_table, Driver::OptionData data)
for (uint32_t i = 0; i < num_options; ++i)
{
// Only print this option if we haven't already seen it.
- pos = options_seen.find (option_table[i].short_option);
+ pos = options_seen.find(option_table[i].short_option);
if (pos == options_seen.end())
{
CommandArgumentType arg_type = option_table[i].argument_type;
- const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString (arg_type);
+ const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString(arg_type);
- options_seen.insert (option_table[i].short_option);
- fprintf (out, "%*s-%c ", indent_level, "", option_table[i].short_option);
+ options_seen.insert(option_table[i].short_option);
+ fprintf(out, "%*s-%c ", indent_level, "", option_table[i].short_option);
if (arg_type != eArgTypeNone)
- fprintf (out, "<%s>", arg_name);
- fprintf (out, "\n");
- fprintf (out, "%*s--%s ", indent_level, "", option_table[i].long_option);
+ fprintf(out, "<%s>", arg_name);
+ fprintf(out, "\n");
+ fprintf(out, "%*s--%s ", indent_level, "", option_table[i].long_option);
if (arg_type != eArgTypeNone)
- fprintf (out, "<%s>", arg_name);
- fprintf (out, "\n");
+ fprintf(out, "<%s>", arg_name);
+ fprintf(out, "\n");
indent_level += 5;
- OutputFormattedUsageText (out, indent_level, option_table[i].usage_text, screen_width);
+ OutputFormattedUsageText(out, indent_level, option_table[i].usage_text, screen_width);
indent_level -= 5;
- fprintf (out, "\n");
+ fprintf(out, "\n");
}
}
indent_level -= 5;
-
- fprintf (out, "\n%*sNotes:\n",
- indent_level, "");
+
+ fprintf(out, "\n%*sNotes:\n", indent_level, "");
indent_level += 5;
-
- fprintf (out, "\n%*sMultiple \"-s\" and \"-o\" options can be provided. They will be processed from left to right in order, "
- "\n%*swith the source files and commands interleaved. The same is true of the \"-S\" and \"-O\" options."
- "\n%*sThe before file and after file sets can intermixed freely, the command parser will sort them out."
- "\n%*sThe order of the file specifiers (\"-c\", \"-f\", etc.) is not significant in this regard.\n\n",
- indent_level, "",
- indent_level, "",
- indent_level, "",
- indent_level, "");
-
- fprintf (out, "\n%*sIf you don't provide -f then the first argument will be the file to be debugged"
- "\n%*swhich means that '%s -- <filename> [<ARG1> [<ARG2>]]' also works."
- "\n%*sBut remember to end the options with \"--\" if any of your arguments have a \"-\" in them.\n\n",
- indent_level, "",
- indent_level, "",
- name,
- indent_level, "");
+
+ fprintf(out, "\n%*sMultiple \"-s\" and \"-o\" options can be provided. They will be processed from left to right in order, "
+ "\n%*swith the source files and commands interleaved. The same is true of the \"-S\" and \"-O\" options."
+ "\n%*sThe before file and after file sets can intermixed freely, the command parser will sort them out."
+ "\n%*sThe order of the file specifiers (\"-c\", \"-f\", etc.) is not significant in this regard.\n\n",
+ indent_level, "", indent_level, "", indent_level, "", indent_level, "");
+
+ fprintf(out, "\n%*sIf you don't provide -f then the first argument will be the file to be debugged"
+ "\n%*swhich means that '%s -- <filename> [<ARG1> [<ARG2>]]' also works."
+ "\n%*sBut remember to end the options with \"--\" if any of your arguments have a \"-\" in them.\n\n",
+ indent_level, "", indent_level, "", name, indent_level, "");
}
void
-BuildGetOptTable (OptionDefinition *expanded_option_table, std::vector<struct option> &getopt_table,
- uint32_t num_options)
+BuildGetOptTable(OptionDefinition *expanded_option_table, std::vector<struct option> &getopt_table, uint32_t num_options)
{
if (num_options == 0)
return;
@@ -362,61 +347,60 @@ BuildGetOptTable (OptionDefinition *expanded_option_table, std::vector<struct op
uint32_t j;
std::bitset<256> option_seen;
- getopt_table.resize (num_options + 1);
+ getopt_table.resize(num_options + 1);
for (i = 0, j = 0; i < num_options; ++i)
{
char short_opt = expanded_option_table[i].short_option;
-
+
if (option_seen.test(short_opt) == false)
{
- getopt_table[j].name = expanded_option_table[i].long_option;
+ getopt_table[j].name = expanded_option_table[i].long_option;
getopt_table[j].has_arg = expanded_option_table[i].option_has_arg;
- getopt_table[j].flag = NULL;
- getopt_table[j].val = expanded_option_table[i].short_option;
+ getopt_table[j].flag = NULL;
+ getopt_table[j].val = expanded_option_table[i].short_option;
option_seen.set(short_opt);
++j;
}
}
- getopt_table[j].name = NULL;
+ getopt_table[j].name = NULL;
getopt_table[j].has_arg = 0;
- getopt_table[j].flag = NULL;
- getopt_table[j].val = 0;
-
+ getopt_table[j].flag = NULL;
+ getopt_table[j].val = 0;
}
-Driver::OptionData::OptionData () :
- m_args(),
- m_script_lang (lldb::eScriptLanguageDefault),
- m_core_file (),
- m_crash_log (),
- m_initial_commands (),
- m_after_file_commands (),
- m_debug_mode (false),
- m_source_quietly(false),
- m_print_version (false),
- m_print_python_path (false),
- m_print_help (false),
- m_wait_for(false),
- m_process_name(),
- m_process_pid(LLDB_INVALID_PROCESS_ID),
- m_use_external_editor(false),
- m_seen_options()
+Driver::OptionData::OptionData()
+ : m_args()
+ , m_script_lang(lldb::eScriptLanguageDefault)
+ , m_core_file()
+ , m_crash_log()
+ , m_initial_commands()
+ , m_after_file_commands()
+ , m_debug_mode(false)
+ , m_source_quietly(false)
+ , m_print_version(false)
+ , m_print_python_path(false)
+ , m_print_help(false)
+ , m_wait_for(false)
+ , m_process_name()
+ , m_process_pid(LLDB_INVALID_PROCESS_ID)
+ , m_use_external_editor(false)
+ , m_seen_options()
{
}
-Driver::OptionData::~OptionData ()
+Driver::OptionData::~OptionData()
{
}
void
-Driver::OptionData::Clear ()
+Driver::OptionData::Clear()
{
- m_args.clear ();
+ m_args.clear();
m_script_lang = lldb::eScriptLanguageDefault;
- m_initial_commands.clear ();
- m_after_file_commands.clear ();
+ m_initial_commands.clear();
+ m_after_file_commands.clear();
m_debug_mode = false;
m_source_quietly = false;
m_print_help = false;
@@ -429,9 +413,9 @@ Driver::OptionData::Clear ()
}
void
-Driver::OptionData::AddInitialCommand (const char *command, bool before_file, bool is_file, SBError &error)
+Driver::OptionData::AddInitialCommand(const char *command, bool before_file, bool is_file, SBError &error)
{
- std::vector<std::pair<bool, std::string> > *command_set;
+ std::vector<std::pair<bool, std::string>> *command_set;
if (before_file)
command_set = &(m_initial_commands);
else
@@ -441,25 +425,25 @@ Driver::OptionData::AddInitialCommand (const char *command, bool before_file, bo
{
SBFileSpec file(command);
if (file.Exists())
- command_set->push_back (std::pair<bool, std::string> (true, optarg));
+ command_set->push_back(std::pair<bool, std::string>(true, optarg));
else if (file.ResolveExecutableLocation())
{
char final_path[PATH_MAX];
- file.GetPath (final_path, sizeof(final_path));
- std::string path_str (final_path);
- command_set->push_back (std::pair<bool, std::string> (true, path_str));
+ file.GetPath(final_path, sizeof(final_path));
+ std::string path_str(final_path);
+ command_set->push_back(std::pair<bool, std::string>(true, path_str));
}
else
error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg);
}
else
- command_set->push_back (std::pair<bool, std::string> (false, optarg));
+ command_set->push_back(std::pair<bool, std::string>(false, optarg));
}
void
-Driver::ResetOptionValues ()
+Driver::ResetOptionValues()
{
- m_option_data.Clear ();
+ m_option_data.Clear();
}
const char *
@@ -485,15 +469,15 @@ Driver::GetScriptLanguage() const
}
void
-Driver::ExecuteInitialCommands (bool before_file)
+Driver::ExecuteInitialCommands(bool before_file)
{
size_t num_commands;
- std::vector<std::pair<bool, std::string> > *command_set;
+ std::vector<std::pair<bool, std::string>> *command_set;
if (before_file)
command_set = &(m_option_data.m_initial_commands);
else
command_set = &(m_option_data.m_after_file_commands);
-
+
num_commands = command_set->size();
SBCommandReturnObject result;
bool old_async = GetDebugger().GetAsync();
@@ -507,11 +491,11 @@ Driver::ExecuteInitialCommands (bool before_file)
const char *executed_command = command;
if (is_file)
{
- ::snprintf (command_string, sizeof(command_string), "command source -s %i '%s'", m_option_data.m_source_quietly, command);
+ ::snprintf(command_string, sizeof(command_string), "command source -s %i '%s'", m_option_data.m_source_quietly, command);
executed_command = command_string;
}
-
- m_debugger.GetCommandInterpreter().HandleCommand (executed_command, result, false);
+
+ m_debugger.GetCommandInterpreter().HandleCommand(executed_command, result, false);
if (!m_option_data.m_source_quietly || result.Succeeded() == false)
{
const size_t output_size = result.GetOutputSize();
@@ -519,17 +503,17 @@ Driver::ExecuteInitialCommands (bool before_file)
{
const char *cstr = result.GetOutput(dump_stream_only_if_no_immediate);
if (cstr)
- printf ("%s", cstr);
+ printf("%s", cstr);
}
const size_t error_size = result.GetErrorSize();
if (error_size > 0)
{
const char *cstr = result.GetError(dump_stream_only_if_no_immediate);
if (cstr)
- printf ("%s", cstr);
+ printf("%s", cstr);
}
}
-
+
if (result.Succeeded() == false)
{
const char *type = before_file ? "before file" : "after_file";
@@ -550,16 +534,15 @@ Driver::GetDebugMode() const
return m_option_data.m_debug_mode;
}
-
// Check the arguments that were passed to this program to make sure they are valid and to get their
// argument values (if any). Return a boolean value indicating whether or not to start up the full
// debugger (i.e. the Command Interpreter) or not. Return FALSE if the arguments were invalid OR
// if the user only wanted help or version information.
SBError
-Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
+Driver::ParseArgs(int argc, const char *argv[], FILE *out_fh, bool &exiting)
{
- ResetOptionValues ();
+ ResetOptionValues();
SBCommandReturnObject result;
@@ -575,11 +558,11 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
if (num_options == 0)
{
if (argc > 1)
- error.SetErrorStringWithFormat ("invalid number of options");
+ error.SetErrorStringWithFormat("invalid number of options");
return error;
}
- BuildGetOptTable (g_options, long_options_vector, num_options);
+ BuildGetOptTable(g_options, long_options_vector, num_options);
if (long_options_vector.empty())
long_options = NULL;
@@ -588,7 +571,7 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
if (long_options == NULL)
{
- error.SetErrorStringWithFormat ("invalid long options");
+ error.SetErrorStringWithFormat("invalid long options");
return error;
}
@@ -598,17 +581,17 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
{
if (long_options[i].flag == NULL)
{
- option_string.push_back ((char) long_options[i].val);
+ option_string.push_back((char)long_options[i].val);
switch (long_options[i].has_arg)
{
default:
case no_argument:
break;
case required_argument:
- option_string.push_back (':');
+ option_string.push_back(':');
break;
case optional_argument:
- option_string.append ("::");
+ option_string.append("::");
break;
}
}
@@ -619,11 +602,11 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
// Driver constructor, then set the flags back to "read them in" here, and then if we see the
// "-n" flag, we'll turn it off again. Finally we have to read them in by hand later in the
// main loop.
-
- m_debugger.SkipLLDBInitFiles (false);
- m_debugger.SkipAppInitFiles (false);
- // Prepare for & make calls to getopt_long_only.
+ m_debugger.SkipLLDBInitFiles(false);
+ m_debugger.SkipAppInitFiles(false);
+
+// Prepare for & make calls to getopt_long_only.
#if __GLIBC__
optind = 0;
#else
@@ -634,26 +617,24 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
while (1)
{
int long_options_index = -1;
- val = ::getopt_long_only (argc, const_cast<char **>(argv), option_string.c_str(), long_options, &long_options_index);
+ val = ::getopt_long_only(argc, const_cast<char **>(argv), option_string.c_str(), long_options, &long_options_index);
if (val == -1)
break;
else if (val == '?')
{
m_option_data.m_print_help = true;
- error.SetErrorStringWithFormat ("unknown or ambiguous option");
+ error.SetErrorStringWithFormat("unknown or ambiguous option");
break;
}
else if (val == 0)
continue;
else
{
- m_option_data.m_seen_options.insert ((char) val);
+ m_option_data.m_seen_options.insert((char)val);
if (long_options_index == -1)
{
- for (int i = 0;
- long_options[i].name || long_options[i].has_arg || long_options[i].flag || long_options[i].val;
- ++i)
+ for (int i = 0; long_options[i].name || long_options[i].has_arg || long_options[i].flag || long_options[i].val; ++i)
{
if (long_options[i].val == val)
{
@@ -682,55 +663,55 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
break;
case 'c':
+ {
+ SBFileSpec file(optarg);
+ if (file.Exists())
{
- SBFileSpec file(optarg);
- if (file.Exists())
- {
- m_option_data.m_core_file = optarg;
- }
- else
- error.SetErrorStringWithFormat("file specified in --core (-c) option doesn't exist: '%s'", optarg);
+ m_option_data.m_core_file = optarg;
}
- break;
-
+ else
+ error.SetErrorStringWithFormat("file specified in --core (-c) option doesn't exist: '%s'", optarg);
+ }
+ break;
+
case 'e':
m_option_data.m_use_external_editor = true;
break;
case 'x':
- m_debugger.SkipLLDBInitFiles (true);
- m_debugger.SkipAppInitFiles (true);
+ m_debugger.SkipLLDBInitFiles(true);
+ m_debugger.SkipAppInitFiles(true);
break;
case 'X':
- m_debugger.SetUseColor (false);
+ m_debugger.SetUseColor(false);
break;
case 'f':
+ {
+ SBFileSpec file(optarg);
+ if (file.Exists())
{
- SBFileSpec file(optarg);
- if (file.Exists())
- {
- m_option_data.m_args.push_back (optarg);
- }
- else if (file.ResolveExecutableLocation())
- {
- char path[PATH_MAX];
- file.GetPath (path, sizeof(path));
- m_option_data.m_args.push_back (path);
- }
- else
- error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", optarg);
+ m_option_data.m_args.push_back(optarg);
}
- break;
+ else if (file.ResolveExecutableLocation())
+ {
+ char path[PATH_MAX];
+ file.GetPath(path, sizeof(path));
+ m_option_data.m_args.push_back(path);
+ }
+ else
+ error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", optarg);
+ }
+ break;
case 'a':
- if (!m_debugger.SetDefaultArchitecture (optarg))
+ if (!m_debugger.SetDefaultArchitecture(optarg))
error.SetErrorStringWithFormat("invalid architecture in the -a or --arch option: '%s'", optarg);
break;
case 'l':
- m_option_data.m_script_lang = m_debugger.GetScriptingLanguage (optarg);
+ m_option_data.m_script_lang = m_debugger.GetScriptingLanguage(optarg);
break;
case 'd':
@@ -744,20 +725,19 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
case 'n':
m_option_data.m_process_name = optarg;
break;
-
+
case 'w':
m_option_data.m_wait_for = true;
break;
-
+
case 'p':
- {
- char *remainder;
- m_option_data.m_process_pid = strtol (optarg, &remainder, 0);
- if (remainder == optarg || *remainder != '\0')
- error.SetErrorStringWithFormat ("Could not convert process PID: \"%s\" into a pid.",
- optarg);
- }
- break;
+ {
+ char *remainder;
+ m_option_data.m_process_pid = strtol(optarg, &remainder, 0);
+ if (remainder == optarg || *remainder != '\0')
+ error.SetErrorStringWithFormat("Could not convert process PID: \"%s\" into a pid.", optarg);
+ }
+ break;
case 's':
m_option_data.AddInitialCommand(optarg, false, true, error);
break;
@@ -772,13 +752,13 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
break;
default:
m_option_data.m_print_help = true;
- error.SetErrorStringWithFormat ("unrecognized option %c", short_option);
+ error.SetErrorStringWithFormat("unrecognized option %c", short_option);
break;
}
}
else
{
- error.SetErrorStringWithFormat ("invalid option with value %i", val);
+ error.SetErrorStringWithFormat("invalid option with value %i", val);
}
if (error.Fail())
{
@@ -786,15 +766,15 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
}
}
}
-
+
if (error.Fail() || m_option_data.m_print_help)
{
- ShowUsage (out_fh, g_options, m_option_data);
+ ShowUsage(out_fh, g_options, m_option_data);
exiting = true;
}
else if (m_option_data.m_print_version)
{
- ::fprintf (out_fh, "%s\n", m_debugger.GetVersionString());
+ ::fprintf(out_fh, "%s\n", m_debugger.GetVersionString());
exiting = true;
}
else if (m_option_data.m_print_python_path)
@@ -806,13 +786,13 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
size_t num_chars = python_file_spec.GetPath(python_path, PATH_MAX);
if (num_chars < PATH_MAX)
{
- ::fprintf (out_fh, "%s\n", python_path);
+ ::fprintf(out_fh, "%s\n", python_path);
}
else
- ::fprintf (out_fh, "<PATH TOO LONG>\n");
+ ::fprintf(out_fh, "<PATH TOO LONG>\n");
}
else
- ::fprintf (out_fh, "<COULD NOT FIND PATH>\n");
+ ::fprintf(out_fh, "<COULD NOT FIND PATH>\n");
exiting = true;
}
else if (m_option_data.m_process_name.empty() && m_option_data.m_process_pid == LLDB_INVALID_PROCESS_ID)
@@ -829,471 +809,468 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
if (argc > 0)
{
- for (int arg_idx=0; arg_idx<argc; ++arg_idx)
+ for (int arg_idx = 0; arg_idx < argc; ++arg_idx)
{
const char *arg = argv[arg_idx];
if (arg)
- m_option_data.m_args.push_back (arg);
+ m_option_data.m_args.push_back(arg);
}
}
-
}
else
{
// Skip any options we consumed with getopt_long_only
argc -= optind;
- //argv += optind; // Commented out to keep static analyzer happy
+ // argv += optind; // Commented out to keep static analyzer happy
if (argc > 0)
- ::fprintf (out_fh, "Warning: program arguments are ignored when attaching.\n");
+ ::fprintf(out_fh, "Warning: program arguments are ignored when attaching.\n");
}
return error;
}
void
-Driver::MainLoop ()
+Driver::MainLoop()
{
if (::tcgetattr(STDIN_FILENO, &g_old_stdin_termios) == 0)
{
g_old_stdin_termios_is_valid = true;
- atexit (reset_stdin_termios);
+ atexit(reset_stdin_termios);
}
- ::setbuf (stdin, NULL);
- ::setbuf (stdout, NULL);
+ ::setbuf(stdin, NULL);
+ ::setbuf(stdout, NULL);
+
+ m_debugger.SetErrorFileHandle(stderr, false);
+ m_debugger.SetOutputFileHandle(stdout, false);
+ m_debugger.SetInputFileHandle(stdin, true);
- m_debugger.SetErrorFileHandle (stderr, false);
- m_debugger.SetOutputFileHandle (stdout, false);
- m_debugger.SetInputFileHandle (stdin, true);
-
m_debugger.SetUseExternalEditor(m_option_data.m_use_external_editor);
struct winsize window_size;
- if (isatty (STDIN_FILENO)
- && ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0)
+ if (isatty(STDIN_FILENO) && ::ioctl(STDIN_FILENO, TIOCGWINSZ, &window_size) == 0)
{
if (window_size.ws_col > 0)
- m_debugger.SetTerminalWidth (window_size.ws_col);
+ m_debugger.SetTerminalWidth(window_size.ws_col);
}
SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter();
-
+
// Before we handle any options from the command line, we parse the
// .lldbinit file in the user's home directory.
SBCommandReturnObject result;
sb_interpreter.SourceInitFileInHomeDirectory(result);
if (GetDebugMode())
{
- result.PutError (m_debugger.GetErrorFileHandle());
- result.PutOutput (m_debugger.GetOutputFileHandle());
+ result.PutError(m_debugger.GetErrorFileHandle());
+ result.PutOutput(m_debugger.GetOutputFileHandle());
}
// Now we handle options we got from the command line
// First source in the commands specified to be run before the file arguments are processed.
ExecuteInitialCommands(true);
-
+
// Was there a core file specified?
std::string core_file_spec("");
if (!m_option_data.m_core_file.empty())
core_file_spec.append("--core ").append(m_option_data.m_core_file);
-
+
char command_string[PATH_MAX * 2];
const size_t num_args = m_option_data.m_args.size();
if (num_args > 0)
{
char arch_name[64];
- if (m_debugger.GetDefaultArchitecture (arch_name, sizeof (arch_name)))
- ::snprintf (command_string,
- sizeof (command_string),
- "target create --arch=%s %s \"%s\"",
- arch_name,
- core_file_spec.c_str(),
- m_option_data.m_args[0].c_str());
+ if (m_debugger.GetDefaultArchitecture(arch_name, sizeof(arch_name)))
+ ::snprintf(command_string, sizeof(command_string), "target create --arch=%s %s \"%s\"", arch_name, core_file_spec.c_str(),
+ m_option_data.m_args[0].c_str());
else
- ::snprintf (command_string,
- sizeof(command_string),
- "target create %s \"%s\"",
- core_file_spec.c_str(),
- m_option_data.m_args[0].c_str());
-
- m_debugger.HandleCommand (command_string);
-
+ ::snprintf(command_string, sizeof(command_string), "target create %s \"%s\"", core_file_spec.c_str(),
+ m_option_data.m_args[0].c_str());
+
+ m_debugger.HandleCommand(command_string);
+
if (num_args > 1)
{
- m_debugger.HandleCommand ("settings clear target.run-args");
+ m_debugger.HandleCommand("settings clear target.run-args");
char arg_cstr[1024];
for (size_t arg_idx = 1; arg_idx < num_args; ++arg_idx)
{
- ::snprintf (arg_cstr,
- sizeof(arg_cstr),
- "settings append target.run-args \"%s\"",
- m_option_data.m_args[arg_idx].c_str());
- m_debugger.HandleCommand (arg_cstr);
+ ::snprintf(arg_cstr, sizeof(arg_cstr), "settings append target.run-args \"%s\"", m_option_data.m_args[arg_idx].c_str());
+ m_debugger.HandleCommand(arg_cstr);
}
}
}
else if (!core_file_spec.empty())
{
- ::snprintf (command_string,
- sizeof(command_string),
- "target create %s",
- core_file_spec.c_str());
- m_debugger.HandleCommand (command_string);;
+ ::snprintf(command_string, sizeof(command_string), "target create %s", core_file_spec.c_str());
+ m_debugger.HandleCommand(command_string);
+ ;
}
else if (!m_option_data.m_process_name.empty())
{
- ::snprintf (command_string,
- sizeof(command_string),
- "process attach --name '%s'%s",
- m_option_data.m_process_name.c_str(),
- m_option_data.m_wait_for ? " --waitfor" : "");
- m_debugger.HandleCommand (command_string);
+ ::snprintf(command_string, sizeof(command_string), "process attach --name '%s'%s", m_option_data.m_process_name.c_str(),
+ m_option_data.m_wait_for ? " --waitfor" : "");
+ m_debugger.HandleCommand(command_string);
}
else if (LLDB_INVALID_PROCESS_ID != m_option_data.m_process_pid)
{
- ::snprintf (command_string,
- sizeof(command_string),
- "process attach --pid %" PRIu64,
- m_option_data.m_process_pid);
- m_debugger.HandleCommand (command_string);
+ ::snprintf(command_string, sizeof(command_string), "process attach --pid %" PRIu64, m_option_data.m_process_pid);
+ m_debugger.HandleCommand(command_string);
}
ExecuteInitialCommands(false);
// Now that all option parsing is done, we try and parse the .lldbinit
// file in the current working directory
- sb_interpreter.SourceInitFileInCurrentWorkingDirectory (result);
+ sb_interpreter.SourceInitFileInCurrentWorkingDirectory(result);
if (GetDebugMode())
{
result.PutError(m_debugger.GetErrorFileHandle());
result.PutOutput(m_debugger.GetOutputFileHandle());
}
-
+
bool handle_events = true;
bool spawn_thread = false;
m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
-
+
reset_stdin_termios();
- fclose (stdin);
-
- SBDebugger::Destroy (m_debugger);
+ fclose(stdin);
+
+ SBDebugger::Destroy(m_debugger);
}
void
-Driver::ResizeWindow (unsigned short col)
+Driver::ResizeWindow(unsigned short col)
{
- GetDebugger().SetTerminalWidth (col);
+ GetDebugger().SetTerminalWidth(col);
}
//++ ------------------------------------------------------------------------------------
-// Details: Setup *this driver so it works as pass through (child) driver for the MI
-// driver. Called by the parent (MI driver) driver.
-// This driver has setup code in two places. The original in MainLoop() and
-// in int main() (when MICONFIG_COMPILE_MIDRIVER_VERSION == 0) so that code can
-// remain as much near to the original code as possible. If MI driver is the main
-// driver (when MICONFIG_COMPILE_MIDRIVER_VERSION == 1) then this function is
-// used to set up the Driver to work with the MI driver.
-// Type: Method.
-// Args: vwErrMsg - (W) On failure current error discription.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Setup *this driver so it works as pass through (child) driver for the MI
+// driver. Called by the parent (MI driver) driver.
+// This driver has setup code in two places. The original in MainLoop() and
+// in int main() (when MICONFIG_COMPILE_MIDRIVER_VERSION == 0) so that code can
+// remain as much near to the original code as possible. If MI driver is the main
+// driver (when MICONFIG_COMPILE_MIDRIVER_VERSION == 1) then this function is
+// used to set up the Driver to work with the MI driver.
+// Type: Method.
+// Args: vwErrMsg - (W) On failure current error discription.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool Driver::MISetup( CMIUtilString & vwErrMsg )
+bool
+Driver::MISetup(CMIUtilString &vwErrMsg)
{
- bool bOk = MIstatus::success;
-
- // Is *this driver a pass through driver to the MI driver
- CMIDriverBase * pParent = GetDriversParent();
- if( pParent == nullptr )
- {
- // No it is not.
- // If MI is the main driver (which passes through to *this driver) then
- // *this driver needs to be initialized after MI is initialize to have a valid
- // pointer to the parent driver. *this is the parent's pass thru driver.
- assert( pParent == nullptr );
- return MIstatus::success; // Allow success for if Driver is the main driver
- }
-
- // MI driver may have streams it wants *this driver to use - still to be sorted
- m_debugger.SetErrorFileHandle( pParent->GetStderr(), false ); // MI may redirect to its own stream
- m_debugger.SetOutputFileHandle( pParent->GetStdout(), false ); // MI likely to NULL this
- m_debugger.SetInputFileHandle( pParent->GetStdin(), false ); // MI could use this to feed input
-
+ bool bOk = MIstatus::success;
+
+ // Is *this driver a pass through driver to the MI driver
+ CMIDriverBase *pParent = GetDriversParent();
+ if (pParent == nullptr)
+ {
+ // No it is not.
+ // If MI is the main driver (which passes through to *this driver) then
+ // *this driver needs to be initialized after MI is initialize to have a valid
+ // pointer to the parent driver. *this is the parent's pass thru driver.
+ assert(pParent == nullptr);
+ return MIstatus::success; // Allow success for if Driver is the main driver
+ }
+
+ // MI driver may have streams it wants *this driver to use - still to be sorted
+ m_debugger.SetErrorFileHandle(pParent->GetStderr(), false); // MI may redirect to its own stream
+ m_debugger.SetOutputFileHandle(pParent->GetStdout(), false); // MI likely to NULL this
+ m_debugger.SetInputFileHandle(pParent->GetStdin(), false); // MI could use this to feed input
+
// ToDo: Do I need this?
- m_debugger.SetUseExternalEditor( m_option_data.m_use_external_editor );
+ m_debugger.SetUseExternalEditor(m_option_data.m_use_external_editor);
// ToDo: Do I need this?
- struct winsize window_size;
- if( isatty( STDIN_FILENO ) && ::ioctl( STDIN_FILENO, TIOCGWINSZ, &window_size ) == 0 )
- {
- if( window_size.ws_col > 0 )
- m_debugger.SetTerminalWidth( window_size.ws_col );
- }
-
- return bOk;
+ struct winsize window_size;
+ if (isatty(STDIN_FILENO) && ::ioctl(STDIN_FILENO, TIOCGWINSZ, &window_size) == 0)
+ {
+ if (window_size.ws_col > 0)
+ m_debugger.SetTerminalWidth(window_size.ws_col);
+ }
+
+ return bOk;
}
//++ ------------------------------------------------------------------------------------
-// Details: Initialize setup *this driver ready for use.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Initialize setup *this driver ready for use.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool Driver::DoInitialize( void )
+bool
+Driver::DoInitialize(void)
{
- // Do nothing
- return MIstatus::success;
+ // Do nothing
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Unbind detach or release resources used by *this driver.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Unbind detach or release resources used by *this driver.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool Driver::DoShutdown( void )
+bool
+Driver::DoShutdown(void)
{
- SBDebugger::Destroy( m_debugger );
-
- // Is *this driver a pass through driver to the MI driver
- CMIDriverBase * pParent = GetDriversParent();
- if( pParent == nullptr )
- {
- // See DoInitialize().
- assert( pParent == nullptr );
- return MIstatus::success;
- }
-
- // Put stuff here when *this driver is a pass thru driver to the MI driver
-
- return MIstatus::success;
+ SBDebugger::Destroy(m_debugger);
+
+ // Is *this driver a pass through driver to the MI driver
+ CMIDriverBase *pParent = GetDriversParent();
+ if (pParent == nullptr)
+ {
+ // See DoInitialize().
+ assert(pParent == nullptr);
+ return MIstatus::success;
+ }
+
+ // Put stuff here when *this driver is a pass thru driver to the MI driver
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the name for *this driver.
-// Type: Overridden.
-// Args: None.
-// Return: CMIUtilString & - Driver name.
-// Throws: None.
+// Details: Retrieve the name for *this driver.
+// Type: Overridden.
+// Args: None.
+// Return: CMIUtilString & - Driver name.
+// Throws: None.
//--
-const CMIUtilString & Driver::GetName( void ) const
+const CMIUtilString &
+Driver::GetName(void) const
{
- static CMIUtilString name( "LLDB driver" );
- return name;
+ static CMIUtilString name("LLDB driver");
+ return name;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve *this driver's last error condition.
-// Type: Overridden.
-// Args: None.
-// Return: CMIUtilString - Text description.
-// Throws: None.
+// Details: Retrieve *this driver's last error condition.
+// Type: Overridden.
+// Args: None.
+// Return: CMIUtilString - Text description.
+// Throws: None.
//--
-CMIUtilString Driver::GetError( void ) const
+CMIUtilString
+Driver::GetError(void) const
{
- // Do nothing - to implement
- return CMIUtilString();
+ // Do nothing - to implement
+ return CMIUtilString();
}
//++ ------------------------------------------------------------------------------------
-// Details: Call this function puts *this driver to work.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Call this function puts *this driver to work.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool Driver::DoMainLoop( void )
+bool
+Driver::DoMainLoop(void)
{
- MainLoop();
+ MainLoop();
- return MIstatus::success;
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Call *this driver to resize the console window.
-// Type: Overridden.
-// Args: vTermWidth - (R) New window column size.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Call *this driver to resize the console window.
+// Type: Overridden.
+// Args: vTermWidth - (R) New window column size.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-void Driver::DoResizeWindow( const uint32_t vTermWidth )
+void
+Driver::DoResizeWindow(const uint32_t vTermWidth)
{
- ResizeWindow( (unsigned short) vTermWidth );
+ ResizeWindow((unsigned short)vTermWidth);
}
//++ ------------------------------------------------------------------------------------
-// Details: Call *this driver to return it's debugger.
-// Type: Overridden.
-// Args: None.
-// Return: lldb::SBDebugger & - LLDB debugger object reference.
-// Throws: None.
+// Details: Call *this driver to return it's debugger.
+// Type: Overridden.
+// Args: None.
+// Return: lldb::SBDebugger & - LLDB debugger object reference.
+// Throws: None.
//--
-lldb::SBDebugger & Driver::GetTheDebugger( void )
+lldb::SBDebugger &
+Driver::GetTheDebugger(void)
{
- return GetDebugger();
+ return GetDebugger();
}
//++ ------------------------------------------------------------------------------------
-// Details: Proxy function to allow the driver implementation to validate executable
-// command line arguments.
-// Type: Overrideable.
-// Args: argc - (R) An integer that contains the count of arguments that follow in
-// argv. The argc parameter is always greater than or equal to 1.
-// argv - (R) An array of null-terminated strings representing command-line
-// arguments entered by the user of the program. By convention,
-// argv[0] is the command with which the program is invoked.
-// vpStdOut - (R) Pointer to a standard output stream.
-// vwbExiting - (W) True = *this want to exit, Reasons: help, invalid arg(s),
-// version information only.
-// False = Continue to work, start debugger i.e. Command
-// interpreter.
-// Return: lldb::SBError - LLDB current error status.
-// Throws: None.
+// Details: Proxy function to allow the driver implementation to validate executable
+// command line arguments.
+// Type: Overrideable.
+// Args: argc - (R) An integer that contains the count of arguments that follow in
+// argv. The argc parameter is always greater than or equal to 1.
+// argv - (R) An array of null-terminated strings representing command-line
+// arguments entered by the user of the program. By convention,
+// argv[0] is the command with which the program is invoked.
+// vpStdOut - (R) Pointer to a standard output stream.
+// vwbExiting - (W) True = *this want to exit, Reasons: help, invalid arg(s),
+// version information only.
+// False = Continue to work, start debugger i.e. Command
+// interpreter.
+// Return: lldb::SBError - LLDB current error status.
+// Throws: None.
//--
-lldb::SBError Driver::DoParseArgs( const int argc, const char * argv[], FILE * vpStdOut, bool & vwbExiting )
+lldb::SBError
+Driver::DoParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &vwbExiting)
{
- return ParseArgs( argc, argv, vpStdOut, vwbExiting );
+ return ParseArgs(argc, argv, vpStdOut, vwbExiting);
}
-
+
//++ ------------------------------------------------------------------------------------
-// Details: A client can ask if *this driver is GDB/MI compatible.
-// Type: Overridden.
-// Args: None.
-// Return: True - GBD/MI compatible LLDB front end.
-// False - Not GBD/MI compatible LLDB front end.
-// Throws: None.
+// Details: A client can ask if *this driver is GDB/MI compatible.
+// Type: Overridden.
+// Args: None.
+// Return: True - GBD/MI compatible LLDB front end.
+// False - Not GBD/MI compatible LLDB front end.
+// Throws: None.
//--
-bool Driver::GetDriverIsGDBMICompatibleDriver( void ) const
+bool
+Driver::GetDriverIsGDBMICompatibleDriver(void) const
{
- return false;
+ return false;
}
//++ ------------------------------------------------------------------------------------
-// Details: This function allows *this driver to call on another driver to perform work
-// should this driver not be able to handle the client data input.
-// SetDriverToFallThruTo() specifies the fall through to driver.
-// Check the error message if the function returns a failure.
-// Type: Overridden.
-// Args: vCmd - (R) Command instruction to interpret.
-// vwErrMsg - (W) Error description on command failing.
-// Return: MIstatus::success - Command succeeded.
-// MIstatus::failure - Command failed.
-// Throws: None.
+// Details: This function allows *this driver to call on another driver to perform work
+// should this driver not be able to handle the client data input.
+// SetDriverToFallThruTo() specifies the fall through to driver.
+// Check the error message if the function returns a failure.
+// Type: Overridden.
+// Args: vCmd - (R) Command instruction to interpret.
+// vwErrMsg - (W) Error description on command failing.
+// Return: MIstatus::success - Command succeeded.
+// MIstatus::failure - Command failed.
+// Throws: None.
//--
-bool Driver::DoFallThruToAnotherDriver( const CMIUtilString & vCmd, CMIUtilString & vwErrMsg )
+bool
+Driver::DoFallThruToAnotherDriver(const CMIUtilString &vCmd, CMIUtilString &vwErrMsg)
{
- bool bOk = MIstatus::success;
- vwErrMsg.empty();
-
- // ToDo: Implement do work on other driver after this driver said "Give up you try"
- // This may nto be required if the feature to 'fall through' is not required
- SBCommandReturnObject returnObj = lldb::SBCommandReturnObject();
- SBCommandInterpreter cmdIntrp = m_debugger.GetCommandInterpreter();
- const lldb::ReturnStatus cmdResult = cmdIntrp.HandleCommand( vCmd.c_str(), returnObj ); MIunused( cmdResult );
- if( returnObj.Succeeded() == false )
- {
- bOk = MIstatus::failure;
- vwErrMsg = returnObj.GetError();
- }
-
- return bOk;
+ bool bOk = MIstatus::success;
+ vwErrMsg.empty();
+
+ // ToDo: Implement do work on other driver after this driver said "Give up you try"
+ // This may nto be required if the feature to 'fall through' is not required
+ SBCommandReturnObject returnObj = lldb::SBCommandReturnObject();
+ SBCommandInterpreter cmdIntrp = m_debugger.GetCommandInterpreter();
+ const lldb::ReturnStatus cmdResult = cmdIntrp.HandleCommand(vCmd.c_str(), returnObj);
+ MIunused(cmdResult);
+ if (returnObj.Succeeded() == false)
+ {
+ bOk = MIstatus::failure;
+ vwErrMsg = returnObj.GetError();
+ }
+
+ return bOk;
}
//++ ------------------------------------------------------------------------------------
-// Details: This function allows *this driver to call functionality on the parent driver
-// ask for information for example.
-// Type: Overridden.
-// Args: vrOtherDriver - (R) Reference to another driver object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: This function allows *this driver to call functionality on the parent driver
+// ask for information for example.
+// Type: Overridden.
+// Args: vrOtherDriver - (R) Reference to another driver object.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool Driver::SetDriverParent( const CMIDriverBase & vrOtherDriver )
+bool
+Driver::SetDriverParent(const CMIDriverBase &vrOtherDriver)
{
- m_pDriverParent = const_cast< CMIDriverBase * >( &vrOtherDriver );
-
- return MIstatus::success;
+ m_pDriverParent = const_cast<CMIDriverBase *>(&vrOtherDriver);
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Set a unique ID for *this driver. It cannot be empty.
-// Type: Overridden.
-// Args: vId - (R) Text description.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Set a unique ID for *this driver. It cannot be empty.
+// Type: Overridden.
+// Args: vId - (R) Text description.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool Driver::SetId( const CMIUtilString & vId )
+bool
+Driver::SetId(const CMIUtilString &vId)
{
- if( vId.empty() )
- {
- // Invalid to have it empty
- return MIstatus::failure;
- }
-
- m_strDriverId = vId;
- return MIstatus::success;
+ if (vId.empty())
+ {
+ // Invalid to have it empty
+ return MIstatus::failure;
+ }
+
+ m_strDriverId = vId;
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Get the unique ID for *this driver.
-// Type: Overridden.
-// Args: None.
-// Return: CMIUtilString & - Text description.
-// Throws: None.
+// Details: Get the unique ID for *this driver.
+// Type: Overridden.
+// Args: None.
+// Return: CMIUtilString & - Text description.
+// Throws: None.
//--
-const CMIUtilString & Driver::GetId( void ) const
+const CMIUtilString &
+Driver::GetId(void) const
{
- return m_strDriverId;
+ return m_strDriverId;
}
//++ ------------------------------------------------------------------------------------
-// Details: Create *this driver. Function contains functionality that needs to be called
-// prior to constructing the *this driver.
-// Type: Static method.
-// Args: None.
-// Return: Driver * - Ptr to the LLDB driver object.
-// Throws: None.
+// Details: Create *this driver. Function contains functionality that needs to be called
+// prior to constructing the *this driver.
+// Type: Static method.
+// Args: None.
+// Return: Driver * - Ptr to the LLDB driver object.
+// Throws: None.
//--
-Driver * Driver::CreateSelf( void )
+Driver *
+Driver::CreateSelf(void)
{
- lldb::SBDebugger::Initialize();
-
- Driver * pDriver = new Driver;
- return pDriver;
+ lldb::SBDebugger::Initialize();
+
+ Driver *pDriver = new Driver;
+ return pDriver;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the name for *this driver.
-// Type: Overridden.
-// Args: None.
-// Return: CMIUtilString - Driver name.
-// Throws: None.
+// Details: Retrieve the name for *this driver.
+// Type: Overridden.
+// Args: None.
+// Return: CMIUtilString - Driver name.
+// Throws: None.
//--
-const CMIUtilString & Driver::GetDriverName( void ) const
+const CMIUtilString &
+Driver::GetDriverName(void) const
{
- return GetName();
+ return GetName();
}
//++ ------------------------------------------------------------------------------------
-// Details: Get the unique ID for *this driver.
-// Type: Overridden.
-// Args: None.
-// Return: CMIUtilString & - Text description.
-// Throws: None.
+// Details: Get the unique ID for *this driver.
+// Type: Overridden.
+// Args: None.
+// Return: CMIUtilString & - Text description.
+// Throws: None.
//--
-const CMIUtilString & Driver::GetDriverId( void ) const
+const CMIUtilString &
+Driver::GetDriverId(void) const
{
- return GetId();
+ return GetId();
}
#endif // MICONFIG_COMPILE_MIDRIVER_WITH_LLDBDRIVER
-
diff --git a/tools/lldb-mi/Driver.h b/tools/lldb-mi/Driver.h
index 39577c49bf05..41fc21da407e 100644
--- a/tools/lldb-mi/Driver.h
+++ b/tools/lldb-mi/Driver.h
@@ -36,86 +36,75 @@ class IOChannel;
class Driver : public lldb::SBBroadcaster, public CMIDriverBase, public CMIDriverMgr::IDriver
{
-// MI required code:
-// Static:
-public:
- static Driver * CreateSelf( void );
-
-// Methods:
-public:
- bool MISetup( CMIUtilString & vwErrMsg );
-
-// Overridden:
-public:
- // From CMIDriverMgr::IDriver
- virtual bool DoInitialize( void );
- virtual bool DoShutdown( void );
- virtual bool DoMainLoop( void );
- virtual void DoResizeWindow( const uint32_t vWindowSizeWsCol );
- virtual lldb::SBError DoParseArgs( const int argc, const char * argv[], FILE * vpStdOut, bool & vwbExiting );
- virtual CMIUtilString GetError( void ) const;
- virtual const CMIUtilString & GetName( void ) const;
- virtual lldb::SBDebugger & GetTheDebugger( void );
- virtual bool GetDriverIsGDBMICompatibleDriver( void ) const;
- virtual bool SetId( const CMIUtilString & vID );
- virtual const CMIUtilString & GetId( void ) const;
- // From CMIDriverBase
- virtual bool DoFallThruToAnotherDriver( const CMIUtilString & vCmd, CMIUtilString & vwErrMsg );
- virtual bool SetDriverParent( const CMIDriverBase & vrOtherDriver );
- virtual const CMIUtilString & GetDriverName( void ) const;
- virtual const CMIUtilString & GetDriverId( void ) const;
-
-// Original code:
-public:
- Driver ();
-
- virtual
- ~Driver ();
-
- void
- MainLoop ();
-
- lldb::SBError
- ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &do_exit);
-
- const char *
- GetFilename() const;
-
- const char *
- GetCrashLogFilename() const;
-
- const char *
- GetArchName() const;
-
- lldb::ScriptLanguage
- GetScriptLanguage() const;
-
- void
- ExecuteInitialCommands (bool before_file);
-
- bool
- GetDebugMode() const;
+ // MI required code:
+ // Static:
+ public:
+ static Driver *CreateSelf(void);
+
+ // Methods:
+ public:
+ bool MISetup(CMIUtilString &vwErrMsg);
+
+ // Overridden:
+ public:
+ // From CMIDriverMgr::IDriver
+ virtual bool DoInitialize(void);
+ virtual bool DoShutdown(void);
+ virtual bool DoMainLoop(void);
+ virtual void DoResizeWindow(const uint32_t vWindowSizeWsCol);
+ virtual lldb::SBError DoParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &vwbExiting);
+ virtual CMIUtilString GetError(void) const;
+ virtual const CMIUtilString &GetName(void) const;
+ virtual lldb::SBDebugger &GetTheDebugger(void);
+ virtual bool GetDriverIsGDBMICompatibleDriver(void) const;
+ virtual bool SetId(const CMIUtilString &vID);
+ virtual const CMIUtilString &GetId(void) const;
+ // From CMIDriverBase
+ virtual bool DoFallThruToAnotherDriver(const CMIUtilString &vCmd, CMIUtilString &vwErrMsg);
+ virtual bool SetDriverParent(const CMIDriverBase &vrOtherDriver);
+ virtual const CMIUtilString &GetDriverName(void) const;
+ virtual const CMIUtilString &GetDriverId(void) const;
+
+ // Original code:
+ public:
+ Driver();
+
+ virtual ~Driver();
+
+ void MainLoop();
+
+ lldb::SBError ParseArgs(int argc, const char *argv[], FILE *out_fh, bool &do_exit);
+
+ const char *GetFilename() const;
+
+ const char *GetCrashLogFilename() const;
+
+ const char *GetArchName() const;
+
+ lldb::ScriptLanguage GetScriptLanguage() const;
+
+ void ExecuteInitialCommands(bool before_file);
+
+ bool GetDebugMode() const;
class OptionData
{
- public:
- OptionData ();
- ~OptionData ();
+ public:
+ OptionData();
+ ~OptionData();
- void
- Clear();
+ void Clear();
- void
- AddInitialCommand (const char *command, bool before_file, bool is_file, lldb::SBError &error);
-
- //static OptionDefinition m_cmd_option_table[];
+ void AddInitialCommand(const char *command, bool before_file, bool is_file, lldb::SBError &error);
+
+ // static OptionDefinition m_cmd_option_table[];
std::vector<std::string> m_args;
lldb::ScriptLanguage m_script_lang;
std::string m_core_file;
std::string m_crash_log;
- std::vector<std::pair<bool,std::string> > m_initial_commands;
- std::vector<std::pair<bool,std::string> > m_after_file_commands;
+ std::vector<std::pair<bool, std::string>> m_initial_commands;
+ std::vector<std::pair<bool, std::string>> m_after_file_commands;
bool m_debug_mode;
bool m_source_quietly;
bool m_print_version;
@@ -124,39 +113,31 @@ public:
bool m_wait_for;
std::string m_process_name;
lldb::pid_t m_process_pid;
- bool m_use_external_editor; // FIXME: When we have set/show variables we can remove this from here.
+ bool m_use_external_editor; // FIXME: When we have set/show variables we can remove this from here.
typedef std::set<char> OptionSet;
OptionSet m_seen_options;
};
-
- static lldb::SBError
- SetOptionValue (int option_idx,
- const char *option_arg,
- Driver::OptionData &data);
-
+ static lldb::SBError SetOptionValue(int option_idx, const char *option_arg, Driver::OptionData &data);
lldb::SBDebugger &
GetDebugger()
{
return m_debugger;
}
-
- void
- ResizeWindow (unsigned short col);
-private:
+ void ResizeWindow(unsigned short col);
+
+ private:
lldb::SBDebugger m_debugger;
OptionData m_option_data;
- void
- ResetOptionValues ();
+ void ResetOptionValues();
- void
- ReadyForCommand ();
+ void ReadyForCommand();
};
-extern Driver * g_driver;
+extern Driver *g_driver;
#endif // lldb_Driver_h_
diff --git a/tools/lldb-mi/MICmdArgContext.cpp b/tools/lldb-mi/MICmdArgContext.cpp
index b6efa9660c3b..217913cff175 100644
--- a/tools/lldb-mi/MICmdArgContext.cpp
+++ b/tools/lldb-mi/MICmdArgContext.cpp
@@ -8,248 +8,254 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmnArgContext.cpp
+// File: MICmnArgContext.cpp
//
-// Overview: CMICmdArgContext implementation.
+// Overview: CMICmdArgContext implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
#include "MICmdArgContext.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgContext constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgContext constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgContext::CMICmdArgContext( void )
-: m_constCharSpace( ' ' )
-, m_constStrSpace( " " )
+CMICmdArgContext::CMICmdArgContext(void)
+ : m_constCharSpace(' ')
+ , m_constStrSpace(" ")
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgContext constructor.
-// Type: Method.
-// Args: vrCmdLineArgsRaw - (R) The text description of the arguments options.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgContext constructor.
+// Type: Method.
+// Args: vrCmdLineArgsRaw - (R) The text description of the arguments options.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgContext::CMICmdArgContext( const CMIUtilString & vrCmdLineArgsRaw )
-: m_strCmdArgsAndOptions( vrCmdLineArgsRaw )
-, m_constCharSpace( ' ' )
-, m_constStrSpace( " " )
+CMICmdArgContext::CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw)
+ : m_strCmdArgsAndOptions(vrCmdLineArgsRaw)
+ , m_constCharSpace(' ')
+ , m_constStrSpace(" ")
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgContext destructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgContext destructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgContext::~CMICmdArgContext( void )
+CMICmdArgContext::~CMICmdArgContext(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the remainder of the command's argument options left to parse.
-// Type: Method.
-// Args: None.
-// Return: CMIUtilString & - Argument options text.
-// Throws: None.
+// Details: Retrieve the remainder of the command's argument options left to parse.
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString & - Argument options text.
+// Throws: None.
//--
-const CMIUtilString & CMICmdArgContext::GetArgsLeftToParse( void ) const
+const CMIUtilString &
+CMICmdArgContext::GetArgsLeftToParse(void) const
{
- return m_strCmdArgsAndOptions;
+ return m_strCmdArgsAndOptions;
}
//++ ------------------------------------------------------------------------------------
-// Details: Ask if this arguments string has any arguments.
-// Type: Method.
-// Args: None.
-// Return: bool - True = Has one or more arguments present, false = no arguments.
-// Throws: None.
+// Details: Ask if this arguments string has any arguments.
+// Type: Method.
+// Args: None.
+// Return: bool - True = Has one or more arguments present, false = no arguments.
+// Throws: None.
//--
-bool CMICmdArgContext::IsEmpty( void ) const
+bool
+CMICmdArgContext::IsEmpty(void) const
{
- return m_strCmdArgsAndOptions.empty();
+ return m_strCmdArgsAndOptions.empty();
}
-
+
//++ ------------------------------------------------------------------------------------
-// Details: Remove the argument from the options text and any space after the argument
-// if applicable.
-// Type: Method.
-// Args: vArg - (R) The name of the argument.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Remove the argument from the options text and any space after the argument
+// if applicable.
+// Type: Method.
+// Args: vArg - (R) The name of the argument.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgContext::RemoveArg( const CMIUtilString & vArg )
+bool
+CMICmdArgContext::RemoveArg(const CMIUtilString &vArg)
{
- if( vArg.empty() )
- return MIstatus::success;
-
- const MIuint nLen = vArg.length();
- const MIuint nLenCntxt = m_strCmdArgsAndOptions.length();
- if( nLen > nLenCntxt )
- return MIstatus::failure;
-
- MIuint nExtraSpace = 0;
- MIint nPos = m_strCmdArgsAndOptions.find( vArg );
- while( 1 )
- {
- if( nPos == (MIint) std::string::npos )
- return MIstatus::success;
-
- bool bPass1 = false;
- if( nPos != 0 )
- {
- if( m_strCmdArgsAndOptions[ nPos - 1 ] == m_constCharSpace )
- bPass1 = true;
- }
- else
- bPass1 = true;
-
- const MIuint nEnd = nPos + nLen;
-
- if( bPass1 )
- {
- bool bPass2 = false;
- if( nEnd < nLenCntxt )
- {
- if( m_strCmdArgsAndOptions[ nEnd ] == m_constCharSpace )
- {
- bPass2 = true;
- nExtraSpace = 1;
- }
- }
- else
- bPass2 = true;
-
- if( bPass2 )
- break;
- }
-
- nPos = m_strCmdArgsAndOptions.find( vArg, nEnd );
- }
-
- const MIuint nPosEnd = nLen + nExtraSpace;
- m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace( nPos, nPosEnd, "" ).c_str();
- m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
-
- return MIstatus::success;
+ if (vArg.empty())
+ return MIstatus::success;
+
+ const MIuint nLen = vArg.length();
+ const MIuint nLenCntxt = m_strCmdArgsAndOptions.length();
+ if (nLen > nLenCntxt)
+ return MIstatus::failure;
+
+ MIuint nExtraSpace = 0;
+ MIint nPos = m_strCmdArgsAndOptions.find(vArg);
+ while (1)
+ {
+ if (nPos == (MIint)std::string::npos)
+ return MIstatus::success;
+
+ bool bPass1 = false;
+ if (nPos != 0)
+ {
+ if (m_strCmdArgsAndOptions[nPos - 1] == m_constCharSpace)
+ bPass1 = true;
+ }
+ else
+ bPass1 = true;
+
+ const MIuint nEnd = nPos + nLen;
+
+ if (bPass1)
+ {
+ bool bPass2 = false;
+ if (nEnd < nLenCntxt)
+ {
+ if (m_strCmdArgsAndOptions[nEnd] == m_constCharSpace)
+ {
+ bPass2 = true;
+ nExtraSpace = 1;
+ }
+ }
+ else
+ bPass2 = true;
+
+ if (bPass2)
+ break;
+ }
+
+ nPos = m_strCmdArgsAndOptions.find(vArg, nEnd);
+ }
+
+ const MIuint nPosEnd = nLen + nExtraSpace;
+ m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, "").c_str();
+ m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Remove the argument at the Nth word position along in the context string.
-// Any space after the argument is removed if applicable. A search is not
-// performed as there may be more than one vArg with the same 'name' in the
-// context string.
-// Type: Method.
-// Args: vArg - (R) The name of the argument.
-// nArgIndex - (R) The word count position to which to remove the vArg word.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Remove the argument at the Nth word position along in the context string.
+// Any space after the argument is removed if applicable. A search is not
+// performed as there may be more than one vArg with the same 'name' in the
+// context string.
+// Type: Method.
+// Args: vArg - (R) The name of the argument.
+// nArgIndex - (R) The word count position to which to remove the vArg word.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgContext::RemoveArgAtPos( const CMIUtilString & vArg, const MIuint nArgIndex )
+bool
+CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg, const MIuint nArgIndex)
{
- MIuint nWordIndex = 0;
- CMIUtilString strBuildContextUp;
- const CMIUtilString::VecString_t vecWords( GetArgs() );
- const bool bSpaceRequired( GetNumberArgsPresent() > 2 );
-
- CMIUtilString::VecString_t::const_iterator it = vecWords.begin();
- const CMIUtilString::VecString_t::const_iterator itEnd = vecWords.end();
- while( it != itEnd )
- {
- const CMIUtilString & rWord( *it );
- if( nWordIndex++ != nArgIndex )
- {
- // Single words
- strBuildContextUp += rWord;
- if( bSpaceRequired )
- strBuildContextUp += m_constStrSpace;
- }
- else
- {
- // If quoted loose quoted text
- if( ++it != itEnd )
- {
- CMIUtilString words = rWord;
- while( vArg != words )
- {
- if( bSpaceRequired )
- words += m_constStrSpace;
- words += *it;
- if( ++it == itEnd )
- break;
- }
- if( it != itEnd )
- --it;
- }
- }
-
- // Next
- if( it != itEnd )
- ++it;
- }
-
- m_strCmdArgsAndOptions = strBuildContextUp;
- m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
-
- return MIstatus::success;
+ MIuint nWordIndex = 0;
+ CMIUtilString strBuildContextUp;
+ const CMIUtilString::VecString_t vecWords(GetArgs());
+ const bool bSpaceRequired(GetNumberArgsPresent() > 2);
+
+ CMIUtilString::VecString_t::const_iterator it = vecWords.begin();
+ const CMIUtilString::VecString_t::const_iterator itEnd = vecWords.end();
+ while (it != itEnd)
+ {
+ const CMIUtilString &rWord(*it);
+ if (nWordIndex++ != nArgIndex)
+ {
+ // Single words
+ strBuildContextUp += rWord;
+ if (bSpaceRequired)
+ strBuildContextUp += m_constStrSpace;
+ }
+ else
+ {
+ // If quoted loose quoted text
+ if (++it != itEnd)
+ {
+ CMIUtilString words = rWord;
+ while (vArg != words)
+ {
+ if (bSpaceRequired)
+ words += m_constStrSpace;
+ words += *it;
+ if (++it == itEnd)
+ break;
+ }
+ if (it != itEnd)
+ --it;
+ }
+ }
+
+ // Next
+ if (it != itEnd)
+ ++it;
+ }
+
+ m_strCmdArgsAndOptions = strBuildContextUp;
+ m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve number of arguments or options present in the command's option text.
-// Type: Method.
-// Args: None.
-// Return: MIuint - 0 to n arguments present.
-// Throws: None.
+// Details: Retrieve number of arguments or options present in the command's option text.
+// Type: Method.
+// Args: None.
+// Return: MIuint - 0 to n arguments present.
+// Throws: None.
//--
-MIuint CMICmdArgContext::GetNumberArgsPresent( void ) const
+MIuint
+CMICmdArgContext::GetNumberArgsPresent(void) const
{
- CMIUtilString::VecString_t vecOptions;
- return m_strCmdArgsAndOptions.SplitConsiderQuotes( m_constStrSpace, vecOptions );
+ CMIUtilString::VecString_t vecOptions;
+ return m_strCmdArgsAndOptions.SplitConsiderQuotes(m_constStrSpace, vecOptions);
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve all the arguments or options remaining in *this context.
-// Type: Method.
-// Args: None.
-// Return: MIUtilString::VecString_t - List of args remaining.
-// Throws: None.
+// Details: Retrieve all the arguments or options remaining in *this context.
+// Type: Method.
+// Args: None.
+// Return: MIUtilString::VecString_t - List of args remaining.
+// Throws: None.
//--
-CMIUtilString::VecString_t CMICmdArgContext::GetArgs( void ) const
+CMIUtilString::VecString_t
+CMICmdArgContext::GetArgs(void) const
{
- CMIUtilString::VecString_t vecOptions;
- m_strCmdArgsAndOptions.SplitConsiderQuotes( m_constStrSpace, vecOptions );
- return vecOptions;
+ CMIUtilString::VecString_t vecOptions;
+ m_strCmdArgsAndOptions.SplitConsiderQuotes(m_constStrSpace, vecOptions);
+ return vecOptions;
}
-
+
//++ ------------------------------------------------------------------------------------
-// Details: Copy assignment operator.
-// Type: Method.
-// Args: vOther - (R) The variable to copy from.
-// Return: CMIUtilString & - this object.
-// Throws: None.
+// Details: Copy assignment operator.
+// Type: Method.
+// Args: vOther - (R) The variable to copy from.
+// Return: CMIUtilString & - this object.
+// Throws: None.
//--
-CMICmdArgContext & CMICmdArgContext::operator= ( const CMICmdArgContext & vOther )
+CMICmdArgContext &CMICmdArgContext::operator=(const CMICmdArgContext &vOther)
{
- if( this != &vOther )
- {
- m_strCmdArgsAndOptions = vOther.m_strCmdArgsAndOptions;
- }
-
- return *this;
-} \ No newline at end of file
+ if (this != &vOther)
+ {
+ m_strCmdArgsAndOptions = vOther.m_strCmdArgsAndOptions;
+ }
+
+ return *this;
+}
diff --git a/tools/lldb-mi/MICmdArgContext.h b/tools/lldb-mi/MICmdArgContext.h
index 699bac13e014..7178373ce380 100644
--- a/tools/lldb-mi/MICmdArgContext.h
+++ b/tools/lldb-mi/MICmdArgContext.h
@@ -8,54 +8,54 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgContext.h
+// File: MICmdArgContext.h
//
-// Overview: CMICmdArgContext interface.
+// Overview: CMICmdArgContext interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
// In-house headers:
-#include "MIUtilString.h"
+#include "MIUtilString.h"
//++ ============================================================================
-// Details: MI common code class. Command arguments and options string. Holds
-// the context string.
-// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 14/04/2014.
-// Changes: None.
+// Details: MI common code class. Command arguments and options string. Holds
+// the context string.
+// Based on the Interpreter pattern.
+// Gotchas: None.
+// Authors: Illya Rudkin 14/04/2014.
+// Changes: None.
//--
class CMICmdArgContext
{
-// Methods:
-public:
- /* ctor */ CMICmdArgContext( void );
- /* ctor */ CMICmdArgContext( const CMIUtilString & vrCmdLineArgsRaw );
- //
- const CMIUtilString & GetArgsLeftToParse( void ) const;
- MIuint GetNumberArgsPresent( void ) const;
- CMIUtilString::VecString_t GetArgs( void ) const;
- bool IsEmpty( void ) const;
- bool RemoveArg( const CMIUtilString & vArg );
- bool RemoveArgAtPos( const CMIUtilString & vArg, const MIuint nArgIndex );
- //
- CMICmdArgContext & operator= ( const CMICmdArgContext & vOther );
-
-// Overridden:
-public:
- // From CMIUtilString
- /* dtor */ virtual ~CMICmdArgContext( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgContext(void);
+ /* ctor */ CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw);
+ //
+ const CMIUtilString &GetArgsLeftToParse(void) const;
+ MIuint GetNumberArgsPresent(void) const;
+ CMIUtilString::VecString_t GetArgs(void) const;
+ bool IsEmpty(void) const;
+ bool RemoveArg(const CMIUtilString &vArg);
+ bool RemoveArgAtPos(const CMIUtilString &vArg, const MIuint nArgIndex);
+ //
+ CMICmdArgContext &operator=(const CMICmdArgContext &vOther);
-// Attributes:
-private:
- CMIUtilString m_strCmdArgsAndOptions;
- const MIchar m_constCharSpace;
- const CMIUtilString m_constStrSpace;
+ // Overridden:
+ public:
+ // From CMIUtilString
+ /* dtor */ virtual ~CMICmdArgContext(void);
+
+ // Attributes:
+ private:
+ CMIUtilString m_strCmdArgsAndOptions;
+ const MIchar m_constCharSpace;
+ const CMIUtilString m_constStrSpace;
};
diff --git a/tools/lldb-mi/MICmdArgSet.cpp b/tools/lldb-mi/MICmdArgSet.cpp
index b0bee357cd6b..290f9eef8a9d 100644
--- a/tools/lldb-mi/MICmdArgSet.cpp
+++ b/tools/lldb-mi/MICmdArgSet.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgSet.cpp
+// File: MICmdArgSet.cpp
//
-// Overview: CMICmdArgSet implementation.
+// Overview: CMICmdArgSet implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -26,395 +26,409 @@
#include "MICmnLog.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgSet constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgSet constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgSet::CMICmdArgSet( void )
-: m_bIsArgsPresentButNotHandledByCmd( false )
-, m_constStrCommaSpc( ", " )
+CMICmdArgSet::CMICmdArgSet(void)
+ : m_bIsArgsPresentButNotHandledByCmd(false)
+ , m_constStrCommaSpc(", ")
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgSet destructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgSet destructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgSet::~CMICmdArgSet( void )
+CMICmdArgSet::~CMICmdArgSet(void)
{
- // Tidy up
- Destroy();
+ // Tidy up
+ Destroy();
}
//++ ------------------------------------------------------------------------------------
-// Details: Release resources used by *this container object.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: Release resources used by *this container object.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-void CMICmdArgSet::Destroy( void )
+void
+CMICmdArgSet::Destroy(void)
{
- // Delete command argument objects
- if( !m_setCmdArgs.empty() )
- {
- SetCmdArgs_t::iterator it = m_setCmdArgs.begin();
- while( it != m_setCmdArgs.end() )
- {
- CMICmdArgValBase * pArg( *it );
- delete pArg;
-
- // Next
- ++it;
- }
- m_setCmdArgs.clear();
- }
-
- m_setCmdArgsThatNotValid.clear();
- m_setCmdArgsThatAreMissing.clear();
- m_setCmdArgsNotHandledByCmd.clear();
- m_setCmdArgsMissingInfo.clear();
- m_bIsArgsPresentButNotHandledByCmd = false;
+ // Delete command argument objects
+ if (!m_setCmdArgs.empty())
+ {
+ SetCmdArgs_t::iterator it = m_setCmdArgs.begin();
+ while (it != m_setCmdArgs.end())
+ {
+ CMICmdArgValBase *pArg(*it);
+ delete pArg;
+
+ // Next
+ ++it;
+ }
+ m_setCmdArgs.clear();
+ }
+
+ m_setCmdArgsThatNotValid.clear();
+ m_setCmdArgsThatAreMissing.clear();
+ m_setCmdArgsNotHandledByCmd.clear();
+ m_setCmdArgsMissingInfo.clear();
+ m_bIsArgsPresentButNotHandledByCmd = false;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag indicating that the command set up ready to parse
-// command arguments or options found that one or more arguments was indeed
-// present but not handled. This is given as a warning in the MI log file.
-// Type: Method.
-// Args: None.
-// Return: bool - True = one or more args not handled, false = all args handled
-// Throws: None.
+// Details: Retrieve the state flag indicating that the command set up ready to parse
+// command arguments or options found that one or more arguments was indeed
+// present but not handled. This is given as a warning in the MI log file.
+// Type: Method.
+// Args: None.
+// Return: bool - True = one or more args not handled, false = all args handled
+// Throws: None.
//--
-bool CMICmdArgSet::IsArgsPresentButNotHandledByCmd( void ) const
+bool
+CMICmdArgSet::IsArgsPresentButNotHandledByCmd(void) const
{
- return m_bIsArgsPresentButNotHandledByCmd;
+ return m_bIsArgsPresentButNotHandledByCmd;
}
-
+
//++ ------------------------------------------------------------------------------------
-// Details: Add the list of command's arguments to parse and validate another one.
-// Type: Method.
-// Args: vArg - (R) A command argument object.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Add the list of command's arguments to parse and validate another one.
+// Type: Method.
+// Args: vArg - (R) A command argument object.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgSet::Add( const CMICmdArgValBase & vArg )
+bool
+CMICmdArgSet::Add(const CMICmdArgValBase &vArg)
{
- CMICmdArgValBase * pArg = const_cast< CMICmdArgValBase * >( &vArg );
- m_setCmdArgs.push_back( pArg );
+ CMICmdArgValBase *pArg = const_cast<CMICmdArgValBase *>(&vArg);
+ m_setCmdArgs.push_back(pArg);
- return MIstatus::success;
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: After validating an options line of text (the context) and there is a failure,
-// it is likely a mandatory command argument that is required is missing. This
-// function returns the argument that should be present.
-// Type: Method.
-// Args: None.
-// Return: SetCmdArgs_t & - Set of argument objects.
-// Throws: None.
+// Details: After validating an options line of text (the context) and there is a failure,
+// it is likely a mandatory command argument that is required is missing. This
+// function returns the argument that should be present.
+// Type: Method.
+// Args: None.
+// Return: SetCmdArgs_t & - Set of argument objects.
+// Throws: None.
//--
-const CMICmdArgSet::SetCmdArgs_t & CMICmdArgSet::GetArgsThatAreMissing( void ) const
+const CMICmdArgSet::SetCmdArgs_t &
+CMICmdArgSet::GetArgsThatAreMissing(void) const
{
- return m_setCmdArgsThatAreMissing;
+ return m_setCmdArgsThatAreMissing;
}
//++ ------------------------------------------------------------------------------------
-// Details: After validating an options line of text (the context) and there is a failure,
-// it may be because one or more arguments were unable to extract a value. This
-// function returns the argument that were found to be invalid.
-// Type: Method.
-// Args: None.
-// Return: SetCmdArgs_t & - Set of argument objects.
-// Throws: None.
+// Details: After validating an options line of text (the context) and there is a failure,
+// it may be because one or more arguments were unable to extract a value. This
+// function returns the argument that were found to be invalid.
+// Type: Method.
+// Args: None.
+// Return: SetCmdArgs_t & - Set of argument objects.
+// Throws: None.
//--
-const CMICmdArgSet::SetCmdArgs_t & CMICmdArgSet::GetArgsThatInvalid( void ) const
+const CMICmdArgSet::SetCmdArgs_t &
+CMICmdArgSet::GetArgsThatInvalid(void) const
{
- return m_setCmdArgsThatNotValid;
-}
+ return m_setCmdArgsThatNotValid;
+}
//++ ------------------------------------------------------------------------------------
-// Details: The list of argument or option (objects) that were specified by the command
-// and so recognised when parsed but were not handled. Ideally the command
-// should handle all arguments and options presented to it. The command sends
-// warning to the MI log file to say that these options were not handled.
-// Used as one way to determine option that maybe should really be implemented
-// and not just ignored.
-// Type: Method.
-// Args: None.
-// Return: SetCmdArgs_t & - Set of argument objects.
-// Throws: None.
+// Details: The list of argument or option (objects) that were specified by the command
+// and so recognised when parsed but were not handled. Ideally the command
+// should handle all arguments and options presented to it. The command sends
+// warning to the MI log file to say that these options were not handled.
+// Used as one way to determine option that maybe should really be implemented
+// and not just ignored.
+// Type: Method.
+// Args: None.
+// Return: SetCmdArgs_t & - Set of argument objects.
+// Throws: None.
//--
-const CMICmdArgSet::SetCmdArgs_t & CMICmdArgSet::GetArgsNotHandledByCmd( void ) const
+const CMICmdArgSet::SetCmdArgs_t &
+CMICmdArgSet::GetArgsNotHandledByCmd(void) const
{
- return m_setCmdArgsNotHandledByCmd;
+ return m_setCmdArgsNotHandledByCmd;
}
//++ ------------------------------------------------------------------------------------
-// Details: Given a set of command argument objects parse the context option string to
-// find those argument and retrieve their value. If the function fails call
-// GetArgsThatAreMissing() to see which commands that were mandatory were
-// missing or failed to parse.
-// Type: Method.
-// Args: vStrMiCmd - (R) Command's name.
-// vCmdArgsText - (RW) A command's options or argument.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Given a set of command argument objects parse the context option string to
+// find those argument and retrieve their value. If the function fails call
+// GetArgsThatAreMissing() to see which commands that were mandatory were
+// missing or failed to parse.
+// Type: Method.
+// Args: vStrMiCmd - (R) Command's name.
+// vCmdArgsText - (RW) A command's options or argument.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgSet::Validate( const CMIUtilString & vStrMiCmd, CMICmdArgContext & vwCmdArgsText )
+bool
+CMICmdArgSet::Validate(const CMIUtilString &vStrMiCmd, CMICmdArgContext &vwCmdArgsText)
{
- m_cmdArgContext = vwCmdArgsText;
-
- // Iterate all the arguments or options required by a command
- const MIuint nArgs = vwCmdArgsText.GetNumberArgsPresent();
- MIuint nArgsMandatoryCnt = 0;
- SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin();
- while( it != m_setCmdArgs.end() )
- {
- const CMICmdArgValBase * pArg( *it );
- const CMIUtilString & rArgName( pArg->GetName() ); MIunused( rArgName );
- if( pArg->GetIsMandatory() )
- nArgsMandatoryCnt++;
- if( !const_cast< CMICmdArgValBase * >( pArg )->Validate( vwCmdArgsText ) )
- {
- if( pArg->GetIsMandatory() && !pArg->GetFound() )
- m_setCmdArgsThatAreMissing.push_back( const_cast< CMICmdArgValBase * >( pArg ) );
- else if( pArg->GetFound() )
- {
- if( pArg->GetIsMissingOptions() )
- m_setCmdArgsMissingInfo.push_back( const_cast< CMICmdArgValBase * >( pArg ) );
- else if( !pArg->GetValid() )
- m_setCmdArgsThatNotValid.push_back( const_cast< CMICmdArgValBase * >( pArg ) );
- }
- }
- if( pArg->GetFound() && !pArg->GetIsHandledByCmd() )
- {
- m_bIsArgsPresentButNotHandledByCmd = true;
- m_setCmdArgsNotHandledByCmd.push_back( const_cast< CMICmdArgValBase * >( pArg ) );
- }
-
- // Next
- ++it;
- }
-
- // Check that one or more argument objects have any issues to report...
-
- if( nArgs < nArgsMandatoryCnt )
- {
- SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_N_OPTIONS_REQUIRED ), nArgsMandatoryCnt ) );
- return MIstatus::failure;
- }
-
- if( IsArgsPresentButNotHandledByCmd() )
- WarningArgsNotHandledbyCmdLogFile( vStrMiCmd );
-
- return ValidationFormErrorMessages( vwCmdArgsText );
+ m_cmdArgContext = vwCmdArgsText;
+
+ // Iterate all the arguments or options required by a command
+ const MIuint nArgs = vwCmdArgsText.GetNumberArgsPresent();
+ MIuint nArgsMandatoryCnt = 0;
+ SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin();
+ while (it != m_setCmdArgs.end())
+ {
+ const CMICmdArgValBase *pArg(*it);
+ const CMIUtilString &rArgName(pArg->GetName());
+ MIunused(rArgName);
+ if (pArg->GetIsMandatory())
+ nArgsMandatoryCnt++;
+ if (!const_cast<CMICmdArgValBase *>(pArg)->Validate(vwCmdArgsText))
+ {
+ if (pArg->GetIsMandatory() && !pArg->GetFound())
+ m_setCmdArgsThatAreMissing.push_back(const_cast<CMICmdArgValBase *>(pArg));
+ else if (pArg->GetFound())
+ {
+ if (pArg->GetIsMissingOptions())
+ m_setCmdArgsMissingInfo.push_back(const_cast<CMICmdArgValBase *>(pArg));
+ else if (!pArg->GetValid())
+ m_setCmdArgsThatNotValid.push_back(const_cast<CMICmdArgValBase *>(pArg));
+ }
+ }
+ if (pArg->GetFound() && !pArg->GetIsHandledByCmd())
+ {
+ m_bIsArgsPresentButNotHandledByCmd = true;
+ m_setCmdArgsNotHandledByCmd.push_back(const_cast<CMICmdArgValBase *>(pArg));
+ }
+
+ // Next
+ ++it;
+ }
+
+ // Check that one or more argument objects have any issues to report...
+
+ if (nArgs < nArgsMandatoryCnt)
+ {
+ SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_N_OPTIONS_REQUIRED), nArgsMandatoryCnt));
+ return MIstatus::failure;
+ }
+
+ if (IsArgsPresentButNotHandledByCmd())
+ WarningArgsNotHandledbyCmdLogFile(vStrMiCmd);
+
+ return ValidationFormErrorMessages(vwCmdArgsText);
}
//++ ------------------------------------------------------------------------------------
-// Details: Having validated the command's options text and failed for some reason form
-// the error message made up with the faults found.
-// Type: Method.
-// vCmdArgsText - (RW) A command's options or argument.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Having validated the command's options text and failed for some reason form
+// the error message made up with the faults found.
+// Type: Method.
+// vCmdArgsText - (RW) A command's options or argument.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgSet::ValidationFormErrorMessages( const CMICmdArgContext & vwCmdArgsText )
+bool
+CMICmdArgSet::ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText)
{
- CMIUtilString strListMissing;
- CMIUtilString strListInvalid;
- CMIUtilString strListMissingInfo;
- const bool bArgsMissing = (m_setCmdArgsThatAreMissing.size() > 0);
- const bool bArgsInvalid = (m_setCmdArgsThatNotValid.size() > 0);
- const bool bArgsMissingInfo = (m_setCmdArgsMissingInfo.size() > 0);
- if( !(bArgsMissing || bArgsInvalid || bArgsMissingInfo) )
- return MIstatus::success;
- if( bArgsMissing )
- {
- MIuint i = 0;
- SetCmdArgs_t::const_iterator it = m_setCmdArgsThatAreMissing.begin();
- while( it != m_setCmdArgsThatAreMissing.end() )
- {
- if( i++ > 0 )
- strListMissing += m_constStrCommaSpc;
-
- const CMICmdArgValBase * pArg( *it );
- strListMissing += pArg->GetName();
-
- // Next
- ++it;
- }
- }
- if( bArgsInvalid )
- {
- MIuint i = 0;
- SetCmdArgs_t::const_iterator it = m_setCmdArgsThatNotValid.begin();
- while( it != m_setCmdArgsThatNotValid.end() )
- {
- if( i++ > 0 )
- strListMissing += m_constStrCommaSpc;
-
- const CMICmdArgValBase * pArg( *it );
- strListInvalid += pArg->GetName();
-
- // Next
- ++it;
- }
- }
- if( bArgsMissingInfo )
- {
- MIuint i = 0;
- SetCmdArgs_t::const_iterator it = m_setCmdArgsMissingInfo.begin();
- while( it != m_setCmdArgsMissingInfo.end() )
- {
- if( i++ > 0 )
- strListMissingInfo += m_constStrCommaSpc;
-
- const CMICmdArgValBase * pArg( *it );
- strListMissingInfo += pArg->GetName();
-
- // Next
- ++it;
- }
- }
-
- bool bHaveOneError = false;
- CMIUtilString strError = MIRSRC( IDS_CMD_ARGS_ERR_PREFIX_MSG );
- if( bArgsMissing && bArgsInvalid )
- {
- bHaveOneError = true;
- strError += CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_MAN_INVALID ), strListMissing.c_str(), strListInvalid.c_str() );
- }
- if( bArgsMissing )
- {
- if( bHaveOneError )
- strError += ". ";
- bHaveOneError = true;
- strError += CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY ), strListMissing.c_str() );
- }
- if( bArgsMissingInfo )
- {
- if( bHaveOneError )
- strError += ". ";
- bHaveOneError = true;
- strError += CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_MISSING_INF ), strListMissingInfo.c_str() );
- }
- if( bArgsInvalid )
- {
- if( bHaveOneError )
- strError += ". ";
- bHaveOneError = true;
- strError += CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_INVALID ), strListInvalid.c_str() );
- }
- if( !vwCmdArgsText.IsEmpty() )
- {
- if( bHaveOneError )
- strError += ". ";
- bHaveOneError = true;
- strError += CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_CONTEXT_NOT_ALL_EATTEN ), vwCmdArgsText.GetArgsLeftToParse().c_str() );
- }
-
- if( bHaveOneError )
- {
- SetErrorDescription( strError );
- return MIstatus::failure;
- }
-
- return MIstatus::success;
+ CMIUtilString strListMissing;
+ CMIUtilString strListInvalid;
+ CMIUtilString strListMissingInfo;
+ const bool bArgsMissing = (m_setCmdArgsThatAreMissing.size() > 0);
+ const bool bArgsInvalid = (m_setCmdArgsThatNotValid.size() > 0);
+ const bool bArgsMissingInfo = (m_setCmdArgsMissingInfo.size() > 0);
+ if (!(bArgsMissing || bArgsInvalid || bArgsMissingInfo))
+ return MIstatus::success;
+ if (bArgsMissing)
+ {
+ MIuint i = 0;
+ SetCmdArgs_t::const_iterator it = m_setCmdArgsThatAreMissing.begin();
+ while (it != m_setCmdArgsThatAreMissing.end())
+ {
+ if (i++ > 0)
+ strListMissing += m_constStrCommaSpc;
+
+ const CMICmdArgValBase *pArg(*it);
+ strListMissing += pArg->GetName();
+
+ // Next
+ ++it;
+ }
+ }
+ if (bArgsInvalid)
+ {
+ MIuint i = 0;
+ SetCmdArgs_t::const_iterator it = m_setCmdArgsThatNotValid.begin();
+ while (it != m_setCmdArgsThatNotValid.end())
+ {
+ if (i++ > 0)
+ strListMissing += m_constStrCommaSpc;
+
+ const CMICmdArgValBase *pArg(*it);
+ strListInvalid += pArg->GetName();
+
+ // Next
+ ++it;
+ }
+ }
+ if (bArgsMissingInfo)
+ {
+ MIuint i = 0;
+ SetCmdArgs_t::const_iterator it = m_setCmdArgsMissingInfo.begin();
+ while (it != m_setCmdArgsMissingInfo.end())
+ {
+ if (i++ > 0)
+ strListMissingInfo += m_constStrCommaSpc;
+
+ const CMICmdArgValBase *pArg(*it);
+ strListMissingInfo += pArg->GetName();
+
+ // Next
+ ++it;
+ }
+ }
+
+ bool bHaveOneError = false;
+ CMIUtilString strError = MIRSRC(IDS_CMD_ARGS_ERR_PREFIX_MSG);
+ if (bArgsMissing && bArgsInvalid)
+ {
+ bHaveOneError = true;
+ strError += CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_MAN_INVALID), strListMissing.c_str(), strListInvalid.c_str());
+ }
+ if (bArgsMissing)
+ {
+ if (bHaveOneError)
+ strError += ". ";
+ bHaveOneError = true;
+ strError += CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY), strListMissing.c_str());
+ }
+ if (bArgsMissingInfo)
+ {
+ if (bHaveOneError)
+ strError += ". ";
+ bHaveOneError = true;
+ strError += CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_MISSING_INF), strListMissingInfo.c_str());
+ }
+ if (bArgsInvalid)
+ {
+ if (bHaveOneError)
+ strError += ". ";
+ bHaveOneError = true;
+ strError += CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_INVALID), strListInvalid.c_str());
+ }
+ if (!vwCmdArgsText.IsEmpty())
+ {
+ if (bHaveOneError)
+ strError += ". ";
+ bHaveOneError = true;
+ strError += CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_CONTEXT_NOT_ALL_EATTEN), vwCmdArgsText.GetArgsLeftToParse().c_str());
+ }
+
+ if (bHaveOneError)
+ {
+ SetErrorDescription(strError);
+ return MIstatus::failure;
+ }
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Ask if the command's argument options text had any arguments.
-// Type: Method.
-// Args: None.
-// Return: bool - True = Has one or more arguments present, false = no arguments.
-// Throws: None.
+// Details: Ask if the command's argument options text had any arguments.
+// Type: Method.
+// Args: None.
+// Return: bool - True = Has one or more arguments present, false = no arguments.
+// Throws: None.
//--
-bool CMICmdArgSet::IsArgContextEmpty( void ) const
+bool
+CMICmdArgSet::IsArgContextEmpty(void) const
{
- return m_cmdArgContext.IsEmpty();
+ return m_cmdArgContext.IsEmpty();
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the number of arguments that are being used for the command.
-// Type: Method.
-// Args: None.
-// Return: MIuint - Argument count.
-// Throws: None.
+// Details: Retrieve the number of arguments that are being used for the command.
+// Type: Method.
+// Args: None.
+// Return: MIuint - Argument count.
+// Throws: None.
//--
-MIuint CMICmdArgSet::GetCount( void ) const
+MIuint
+CMICmdArgSet::GetCount(void) const
{
- return m_setCmdArgs.size();
+ return m_setCmdArgs.size();
}
-
+
//++ ------------------------------------------------------------------------------------
-// Details: Given a set of command argument objects retrieve the argument with the
-// specified name.
-// Type: Method.
-// Args: vpArg - (W) A pointer to a command's argument object.
-// Return: True - Argument found.
-// False - Argument not found.
-// Throws: None.
+// Details: Given a set of command argument objects retrieve the argument with the
+// specified name.
+// Type: Method.
+// Args: vpArg - (W) A pointer to a command's argument object.
+// Return: True - Argument found.
+// False - Argument not found.
+// Throws: None.
//--
-bool CMICmdArgSet::GetArg( const CMIUtilString & vArgName, CMICmdArgValBase *& vpArg ) const
+bool
+CMICmdArgSet::GetArg(const CMIUtilString &vArgName, CMICmdArgValBase *&vpArg) const
{
- bool bFound = false;
- SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin();
- while( it != m_setCmdArgs.end() )
- {
- CMICmdArgValBase * pArg( *it );
- if( pArg->GetName() == vArgName )
- {
- bFound = true;
- vpArg = pArg;
- break;
- }
-
- // Next
- ++it;
- }
-
- return bFound;
+ bool bFound = false;
+ SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin();
+ while (it != m_setCmdArgs.end())
+ {
+ CMICmdArgValBase *pArg(*it);
+ if (pArg->GetName() == vArgName)
+ {
+ bFound = true;
+ vpArg = pArg;
+ break;
+ }
+
+ // Next
+ ++it;
+ }
+
+ return bFound;
}
-
+
//++ ------------------------------------------------------------------------------------
-// Details: Write a warning message to the MI Log file about the command's arguments or
-// options that were found present but not handled.
-// Type: Method.
-// Args: vrCmdName - (R) The command's name.
-// Return: None.
-// Throws: None.
+// Details: Write a warning message to the MI Log file about the command's arguments or
+// options that were found present but not handled.
+// Type: Method.
+// Args: vrCmdName - (R) The command's name.
+// Return: None.
+// Throws: None.
//--
-void CMICmdArgSet::WarningArgsNotHandledbyCmdLogFile( const CMIUtilString & vrCmdName )
+void
+CMICmdArgSet::WarningArgsNotHandledbyCmdLogFile(const CMIUtilString &vrCmdName)
{
#if MICONFIG_GIVE_WARNING_CMD_ARGS_NOT_HANDLED
- CMIUtilString strArgsNotHandled;
- const CMICmdArgSet::SetCmdArgs_t & rSetArgs = GetArgsNotHandledByCmd();
- MIuint nCnt = 0;
- CMICmdArgSet::SetCmdArgs_t::const_iterator it = rSetArgs.begin();
- while( it != rSetArgs.end() )
- {
- if( nCnt++ > 0 )
- strArgsNotHandled += m_constStrCommaSpc;
- const CMICmdArgValBase * pArg = *it;
- strArgsNotHandled += pArg->GetName();
-
- // Next
- ++it;
- }
-
- const CMIUtilString strWarningMsg( CMIUtilString::Format( MIRSRC( IDS_CMD_WRN_ARGS_NOT_HANDLED ), vrCmdName.c_str(), strArgsNotHandled.c_str() ) );
- m_pLog->WriteLog( strWarningMsg );
+ CMIUtilString strArgsNotHandled;
+ const CMICmdArgSet::SetCmdArgs_t &rSetArgs = GetArgsNotHandledByCmd();
+ MIuint nCnt = 0;
+ CMICmdArgSet::SetCmdArgs_t::const_iterator it = rSetArgs.begin();
+ while (it != rSetArgs.end())
+ {
+ if (nCnt++ > 0)
+ strArgsNotHandled += m_constStrCommaSpc;
+ const CMICmdArgValBase *pArg = *it;
+ strArgsNotHandled += pArg->GetName();
+
+ // Next
+ ++it;
+ }
+
+ const CMIUtilString strWarningMsg(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_WRN_ARGS_NOT_HANDLED), vrCmdName.c_str(), strArgsNotHandled.c_str()));
+ m_pLog->WriteLog(strWarningMsg);
#endif // MICONFIG_GIVE_WARNING_CMD_ARGS_NOT_HANDLED
}
diff --git a/tools/lldb-mi/MICmdArgSet.h b/tools/lldb-mi/MICmdArgSet.h
index 5f8f5049d9af..eed667071733 100644
--- a/tools/lldb-mi/MICmdArgSet.h
+++ b/tools/lldb-mi/MICmdArgSet.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgSet.h
+// File: MICmdArgSet.h
//
-// Overview: CMICmdArgSet interface.
+// Overview: CMICmdArgSet interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -32,78 +32,81 @@
class CMICmdArgValBase;
//++ ============================================================================
-// Details: MI common code class. Command arguments container class.
-// A command may have one or more arguments of which some may be optional.
-// *this class contains a list of the command's arguments which are
-// validates against the commands argument options string (context string).
-// Each argument tries to extract the value it is looking for.
-// Argument objects added to *this container are owned by this container
-// and are deleted when this container goes out of scope. Allocate argument
-// objects on the heap.
-// It is assummed the arguments to be parsed are read from left to right in
-// order. The order added to *this container is the order they will parsed.
-// Gotchas: None.
-// Authors: Illya Rudkin 14/04/2014.
-// Changes: None.
+// Details: MI common code class. Command arguments container class.
+// A command may have one or more arguments of which some may be optional.
+// *this class contains a list of the command's arguments which are
+// validates against the commands argument options string (context string).
+// Each argument tries to extract the value it is looking for.
+// Argument objects added to *this container are owned by this container
+// and are deleted when this container goes out of scope. Allocate argument
+// objects on the heap.
+// It is assummed the arguments to be parsed are read from left to right in
+// order. The order added to *this container is the order they will parsed.
+// Gotchas: None.
+// Authors: Illya Rudkin 14/04/2014.
+// Changes: None.
//--
class CMICmdArgSet : public CMICmnBase
{
-// Classes:
-public:
- //++
- // Description: ArgSet's interface for command arguments to implement.
- //--
- class IArg
- {
- public:
- virtual bool GetFound( void ) const = 0;
- virtual bool GetIsHandledByCmd( void ) const = 0;
- virtual bool GetIsMandatory( void ) const = 0;
- virtual bool GetIsMissingOptions( void ) const = 0;
- virtual const CMIUtilString & GetName( void ) const = 0;
- virtual bool GetValid( void ) const = 0;
- virtual bool Validate( CMICmdArgContext & vwArgContext ) = 0;
-
- /* dtor */ virtual ~IArg( void ) {};
- };
+ // Classes:
+ public:
+ //++
+ // Description: ArgSet's interface for command arguments to implement.
+ //--
+ class IArg
+ {
+ public:
+ virtual bool GetFound(void) const = 0;
+ virtual bool GetIsHandledByCmd(void) const = 0;
+ virtual bool GetIsMandatory(void) const = 0;
+ virtual bool GetIsMissingOptions(void) const = 0;
+ virtual const CMIUtilString &GetName(void) const = 0;
+ virtual bool GetValid(void) const = 0;
+ virtual bool Validate(CMICmdArgContext &vwArgContext) = 0;
-// Typedefs:
-public:
- typedef std::vector< CMICmdArgValBase * > SetCmdArgs_t;
+ /* dtor */ virtual ~IArg(void){};
+ };
-// Methods:
-public:
- /* ctor */ CMICmdArgSet( void );
-
- bool Add( const CMICmdArgValBase & vArg );
- bool GetArg( const CMIUtilString & vArgName, CMICmdArgValBase *& vpArg ) const;
- const SetCmdArgs_t & GetArgsThatAreMissing( void ) const;
- const SetCmdArgs_t & GetArgsThatInvalid( void ) const;
- MIuint GetCount( void ) const;
- bool IsArgContextEmpty( void ) const;
- bool IsArgsPresentButNotHandledByCmd( void ) const;
- void WarningArgsNotHandledbyCmdLogFile( const CMIUtilString & vrCmdName );
- bool Validate( const CMIUtilString & vStrMiCmd, CMICmdArgContext & vwCmdArgsText );
+ // Typedefs:
+ public:
+ typedef std::vector<CMICmdArgValBase *> SetCmdArgs_t;
-// Overrideable:
-public:
- /* dtor */ virtual ~CMICmdArgSet( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgSet(void);
-// Methods:
-private:
- const SetCmdArgs_t & GetArgsNotHandledByCmd( void ) const;
- void Destroy( void ); // Release resources used by *this object
- bool ValidationFormErrorMessages( const CMICmdArgContext & vwCmdArgsText );
+ bool Add(const CMICmdArgValBase &vArg);
+ bool GetArg(const CMIUtilString &vArgName, CMICmdArgValBase *&vpArg) const;
+ const SetCmdArgs_t &GetArgsThatAreMissing(void) const;
+ const SetCmdArgs_t &GetArgsThatInvalid(void) const;
+ MIuint GetCount(void) const;
+ bool IsArgContextEmpty(void) const;
+ bool IsArgsPresentButNotHandledByCmd(void) const;
+ void WarningArgsNotHandledbyCmdLogFile(const CMIUtilString &vrCmdName);
+ bool Validate(const CMIUtilString &vStrMiCmd, CMICmdArgContext &vwCmdArgsText);
-// Attributes:
-private:
- bool m_bIsArgsPresentButNotHandledByCmd; // True = The driver's client presented the command with options recognised but not handled by a command, false = all args handled
- SetCmdArgs_t m_setCmdArgs; // The set of arguments that are that the command is expecting to find in the options string
- SetCmdArgs_t m_setCmdArgsThatAreMissing; // The set of arguments that are required by the command but are missing
- SetCmdArgs_t m_setCmdArgsThatNotValid; // The set of arguments found in the text but for some reason unable to extract a value
- SetCmdArgs_t m_setCmdArgsNotHandledByCmd; // The set of arguments specified by the command which were present to the command but not handled
- SetCmdArgs_t m_setCmdArgsMissingInfo; // The set of arguments that were present but were found to be missing additional information i.e. --thread 3 but 3 is missing
- CMICmdArgContext m_cmdArgContext; // Copy of the command's argument options text before validate takes place (empties it of content)
- const CMIUtilString m_constStrCommaSpc;
-};
+ // Overrideable:
+ public:
+ /* dtor */ virtual ~CMICmdArgSet(void);
+ // Methods:
+ private:
+ const SetCmdArgs_t &GetArgsNotHandledByCmd(void) const;
+ void
+ Destroy(void); // Release resources used by *this object
+ bool ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText);
+
+ // Attributes:
+ private:
+ bool m_bIsArgsPresentButNotHandledByCmd; // True = The driver's client presented the command with options recognised but not handled by
+ // a command, false = all args handled
+ SetCmdArgs_t m_setCmdArgs; // The set of arguments that are that the command is expecting to find in the options string
+ SetCmdArgs_t m_setCmdArgsThatAreMissing; // The set of arguments that are required by the command but are missing
+ SetCmdArgs_t m_setCmdArgsThatNotValid; // The set of arguments found in the text but for some reason unable to extract a value
+ SetCmdArgs_t
+ m_setCmdArgsNotHandledByCmd; // The set of arguments specified by the command which were present to the command but not handled
+ SetCmdArgs_t m_setCmdArgsMissingInfo; // The set of arguments that were present but were found to be missing additional information i.e.
+ // --thread 3 but 3 is missing
+ CMICmdArgContext m_cmdArgContext; // Copy of the command's argument options text before validate takes place (empties it of content)
+ const CMIUtilString m_constStrCommaSpc;
+};
diff --git a/tools/lldb-mi/MICmdArgValBase.cpp b/tools/lldb-mi/MICmdArgValBase.cpp
index ceab1a494865..1419df3206c8 100644
--- a/tools/lldb-mi/MICmdArgValBase.cpp
+++ b/tools/lldb-mi/MICmdArgValBase.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValBase.cpp
+// File: MICmdArgValBase.cpp
//
-// Overview: CMICmdArgValBase implementation.
+// Overview: CMICmdArgValBase implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -25,147 +25,154 @@
#include "MICmdArgContext.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValBase constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValBase constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValBase::CMICmdArgValBase( void )
-: m_bFound( false )
-, m_bValid( false )
-, m_bMandatory( false )
-, m_bHandled( false )
-, m_bIsMissingOptions( false )
+CMICmdArgValBase::CMICmdArgValBase(void)
+ : m_bFound(false)
+ , m_bValid(false)
+ , m_bMandatory(false)
+ , m_bHandled(false)
+ , m_bIsMissingOptions(false)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValBase constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValBase constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValBase::CMICmdArgValBase( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd )
-: m_bFound( false )
-, m_bValid( false )
-, m_bMandatory( vbMandatory )
-, m_strArgName( vrArgName )
-, m_bHandled( vbHandleByCmd )
-, m_bIsMissingOptions( false )
+CMICmdArgValBase::CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
+ : m_bFound(false)
+ , m_bValid(false)
+ , m_bMandatory(vbMandatory)
+ , m_strArgName(vrArgName)
+ , m_bHandled(vbHandleByCmd)
+ , m_bIsMissingOptions(false)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValBase destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValBase destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValBase::~CMICmdArgValBase( void )
+CMICmdArgValBase::~CMICmdArgValBase(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag of whether the argument is handled by the command or
-// not.
-// Type: Method.
-// Args: None.
-// Return: True - Command needs more information.
-// False - All information is present as expected.
-// Throws: None.
+// Details: Retrieve the state flag of whether the argument is handled by the command or
+// not.
+// Type: Method.
+// Args: None.
+// Return: True - Command needs more information.
+// False - All information is present as expected.
+// Throws: None.
//--
-bool CMICmdArgValBase::GetIsMissingOptions( void ) const
+bool
+CMICmdArgValBase::GetIsMissingOptions(void) const
{
- return m_bIsMissingOptions;
+ return m_bIsMissingOptions;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag of whether the argument is handled by the command or
-// not.
-// Type: Method.
-// Args: None.
-// Return: True - Command handles *this argument or option.
-// False - Not handled (argument specified but ignored).
-// Throws: None.
+// Details: Retrieve the state flag of whether the argument is handled by the command or
+// not.
+// Type: Method.
+// Args: None.
+// Return: True - Command handles *this argument or option.
+// False - Not handled (argument specified but ignored).
+// Throws: None.
//--
-bool CMICmdArgValBase::GetIsHandledByCmd( void ) const
+bool
+CMICmdArgValBase::GetIsHandledByCmd(void) const
{
- return m_bHandled;
+ return m_bHandled;
}
-
+
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the name of *this argument.
-// Type: Method.
-// Args: None.
-// Return: CMIUtilString & - Return the text name.
-// Throws: None.
+// Details: Retrieve the name of *this argument.
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString & - Return the text name.
+// Throws: None.
//--
-const CMIUtilString & CMICmdArgValBase::GetName( void ) const
+const CMIUtilString &
+CMICmdArgValBase::GetName(void) const
{
- return m_strArgName;
+ return m_strArgName;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag of whether the argument was found in the command's
-// argument / options string.
-// Type: Method.
-// Args: None.
-// Return: True - Argument found.
-// False - Argument not found.
-// Throws: None.
+// Details: Retrieve the state flag of whether the argument was found in the command's
+// argument / options string.
+// Type: Method.
+// Args: None.
+// Return: True - Argument found.
+// False - Argument not found.
+// Throws: None.
//--
-bool CMICmdArgValBase::GetFound( void ) const
+bool
+CMICmdArgValBase::GetFound(void) const
{
- return m_bFound;
+ return m_bFound;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag indicating whether the value was obtained from the
-// text arguments string and is valid.
-// Type: Method.
-// Args: None.
-// Return: True - Argument valid.
-// False - Argument not valid.
-// Throws: None.
+// Details: Retrieve the state flag indicating whether the value was obtained from the
+// text arguments string and is valid.
+// Type: Method.
+// Args: None.
+// Return: True - Argument valid.
+// False - Argument not valid.
+// Throws: None.
//--
-bool CMICmdArgValBase::GetValid( void ) const
+bool
+CMICmdArgValBase::GetValid(void) const
{
- return m_bValid;
+ return m_bValid;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag indicating whether *this argument is a mandatory
-// argument for the command or is optional to be present.
-// Type: Method.
-// Args: None.
-// Return: True - Mandatory.
-// False - Optional.
-// Throws: None.
+// Details: Retrieve the state flag indicating whether *this argument is a mandatory
+// argument for the command or is optional to be present.
+// Type: Method.
+// Args: None.
+// Return: True - Mandatory.
+// False - Optional.
+// Throws: None.
//--
-bool CMICmdArgValBase::GetIsMandatory( void ) const
+bool
+CMICmdArgValBase::GetIsMandatory(void) const
{
- return m_bMandatory;
+ return m_bMandatory;
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
-// argument is looking for.
-// Type: Overrideable.
-// Args: vArgContext - (RW) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract the value *this
+// argument is looking for.
+// Type: Overrideable.
+// Args: vArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValBase::Validate( CMICmdArgContext & vwArgContext )
+bool
+CMICmdArgValBase::Validate(CMICmdArgContext &vwArgContext)
{
- MIunused( vwArgContext );
+ MIunused(vwArgContext);
- // Override to implement
+ // Override to implement
- return MIstatus::failure;
-} \ No newline at end of file
+ return MIstatus::failure;
+}
diff --git a/tools/lldb-mi/MICmdArgValBase.h b/tools/lldb-mi/MICmdArgValBase.h
index b367cb88ce29..0afe8d9bab6a 100644
--- a/tools/lldb-mi/MICmdArgValBase.h
+++ b/tools/lldb-mi/MICmdArgValBase.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValBase.h
+// File: MICmdArgValBase.h
//
-// Overview: CMICmdArgValBase interface.
+// Overview: CMICmdArgValBase interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -26,132 +26,130 @@
#include "MICmdArgSet.h"
//++ ============================================================================
-// Details: MI common code class. Command argument base class. Arguments objects
-// needing specialization derived from *this class. An argument knows
-// what type of argument it is and how it is to interpret the options
-// (context) string to find and validate a matching argument and so
-// extract a value from it.
-// Argument objects are added to the CMICmdArgSet container object.
-// Once added the container they belong to that contain and will be
-// deleted when the container goes out of scope. Allocate argument
-// objects on the heap and pass in to the Add().
-// Note the code is written such that a command will produce an error
-// should it be presented with arguments or options it does not understand.
-// A command can recognise an option or argument then ignore if it
-// wishes (a warning is sent to the MI's Log file). This is so it is
-// hardwired to fail and catch arguments or options that presented by
-// different driver clients.
-// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 14/04/2014.
-// Changes: None.
+// Details: MI common code class. Command argument base class. Arguments objects
+// needing specialization derived from *this class. An argument knows
+// what type of argument it is and how it is to interpret the options
+// (context) string to find and validate a matching argument and so
+// extract a value from it.
+// Argument objects are added to the CMICmdArgSet container object.
+// Once added the container they belong to that contain and will be
+// deleted when the container goes out of scope. Allocate argument
+// objects on the heap and pass in to the Add().
+// Note the code is written such that a command will produce an error
+// should it be presented with arguments or options it does not understand.
+// A command can recognise an option or argument then ignore if it
+// wishes (a warning is sent to the MI's Log file). This is so it is
+// hardwired to fail and catch arguments or options that presented by
+// different driver clients.
+// Based on the Interpreter pattern.
+// Gotchas: None.
+// Authors: Illya Rudkin 14/04/2014.
+// Changes: None.
//--
class CMICmdArgValBase : public CMICmdArgSet::IArg
{
-// Methods:
-public:
- /* ctor */ CMICmdArgValBase( void );
- /* ctor */ CMICmdArgValBase( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd );
-
-// Overrideable:
-public:
- /* dtor */ virtual ~CMICmdArgValBase( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgValBase(void);
+ /* ctor */ CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
-// Overridden:
-public:
- // From CMICmdArgSet::IArg
- virtual bool GetFound( void ) const;
- virtual bool GetIsHandledByCmd( void ) const;
- virtual bool GetIsMandatory( void ) const;
- virtual bool GetIsMissingOptions( void ) const;
- virtual const CMIUtilString & GetName( void ) const;
- virtual bool GetValid( void ) const;
- virtual bool Validate( CMICmdArgContext & vwArgContext );
+ // Overrideable:
+ public:
+ /* dtor */ virtual ~CMICmdArgValBase(void);
-// Attributes:
-protected:
- bool m_bFound; // True = yes found in arguments options text, false = not found
- bool m_bValid; // True = yes argument parsed and valid, false = not valid
- bool m_bMandatory; // True = yes arg must be present, false = optional argument
- CMIUtilString m_strArgName;
- bool m_bHandled; // True = Command processes *this option, false = not handled
- bool m_bIsMissingOptions; // True = Command needs more information, false = ok
+ // Overridden:
+ public:
+ // From CMICmdArgSet::IArg
+ virtual bool GetFound(void) const;
+ virtual bool GetIsHandledByCmd(void) const;
+ virtual bool GetIsMandatory(void) const;
+ virtual bool GetIsMissingOptions(void) const;
+ virtual const CMIUtilString &GetName(void) const;
+ virtual bool GetValid(void) const;
+ virtual bool Validate(CMICmdArgContext &vwArgContext);
+
+ // Attributes:
+ protected:
+ bool m_bFound; // True = yes found in arguments options text, false = not found
+ bool m_bValid; // True = yes argument parsed and valid, false = not valid
+ bool m_bMandatory; // True = yes arg must be present, false = optional argument
+ CMIUtilString m_strArgName;
+ bool m_bHandled; // True = Command processes *this option, false = not handled
+ bool m_bIsMissingOptions; // True = Command needs more information, false = ok
};
//++ ============================================================================
-// Details: MI common code class. Templated command argument base class.
-// Gotchas: None.
-// Authors: Illya Rudkin 14/04/2014.
-// Changes: None.
+// Details: MI common code class. Templated command argument base class.
+// Gotchas: None.
+// Authors: Illya Rudkin 14/04/2014.
+// Changes: None.
//--
-template< class T >
-class CMICmdArgValBaseTemplate : public CMICmdArgValBase
+template <class T> class CMICmdArgValBaseTemplate : public CMICmdArgValBase
{
-// Methods:
-public:
- /* ctor */ CMICmdArgValBaseTemplate( void );
- /* ctor */ CMICmdArgValBaseTemplate( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd );
- //
- const T & GetValue( void ) const;
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgValBaseTemplate(void);
+ /* ctor */ CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
+ //
+ const T &GetValue(void) const;
-// Overrideable:
-public:
- /* dtor */ virtual ~CMICmdArgValBaseTemplate( void );
+ // Overrideable:
+ public:
+ /* dtor */ virtual ~CMICmdArgValBaseTemplate(void);
-// Attributes:
-protected:
- T m_argValue;
+ // Attributes:
+ protected:
+ T m_argValue;
};
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValBaseTemplate constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValBaseTemplate constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-template< class T >
-CMICmdArgValBaseTemplate< T >::CMICmdArgValBaseTemplate( void )
+template <class T> CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValBaseTemplate constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValBaseTemplate constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// Return: None.
+// Throws: None.
//--
-template< class T >
-CMICmdArgValBaseTemplate< T >::CMICmdArgValBaseTemplate( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd )
-: CMICmdArgValBase( vrArgName, vbMandatory, vbHandleByCmd )
+template <class T>
+CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
+ : CMICmdArgValBase(vrArgName, vbMandatory, vbHandleByCmd)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValBaseTemplate destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValBaseTemplate destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-template< class T >
-CMICmdArgValBaseTemplate< T >::~CMICmdArgValBaseTemplate( void )
+template <class T> CMICmdArgValBaseTemplate<T>::~CMICmdArgValBaseTemplate(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the value the argument parsed from the command's argument / options
-// text string.
-// Type: Method.
-// Args: None.
-// Return: Template type & - The arg value of *this object.
-// Throws: None.
+// Details: Retrieve the value the argument parsed from the command's argument / options
+// text string.
+// Type: Method.
+// Args: None.
+// Return: Template type & - The arg value of *this object.
+// Throws: None.
//--
-template< class T >
-const T & CMICmdArgValBaseTemplate< T >::GetValue( void ) const
+template <class T>
+const T &
+CMICmdArgValBaseTemplate<T>::GetValue(void) const
{
- return m_argValue;
+ return m_argValue;
}
diff --git a/tools/lldb-mi/MICmdArgValConsume.cpp b/tools/lldb-mi/MICmdArgValConsume.cpp
index 72a57f870ad4..3a01db4bc4f8 100644
--- a/tools/lldb-mi/MICmdArgValConsume.cpp
+++ b/tools/lldb-mi/MICmdArgValConsume.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValConsume.cpp
+// File: MICmdArgValConsume.cpp
//
-// Overview: CMICmdArgValConsume implementation.
+// Overview: CMICmdArgValConsume implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -24,96 +24,98 @@
#include "MICmdArgContext.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValConsume constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValConsume constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValConsume::CMICmdArgValConsume( void )
+CMICmdArgValConsume::CMICmdArgValConsume(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValConsume constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValConsume constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValConsume::CMICmdArgValConsume( const CMIUtilString & vrArgName, const bool vbMandatory )
-: CMICmdArgValBaseTemplate( vrArgName, vbMandatory, true )
+CMICmdArgValConsume::CMICmdArgValConsume(const CMIUtilString &vrArgName, const bool vbMandatory)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, true)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValConsume destructor.
-// Type: Overidden.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValConsume destructor.
+// Type: Overidden.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValConsume::~CMICmdArgValConsume( void )
+CMICmdArgValConsume::~CMICmdArgValConsume(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
-// argument is looking for.
-// Type: Overridden.
-// Args: vwArgContext - (R) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract the value *this
+// argument is looking for.
+// Type: Overridden.
+// Args: vwArgContext - (R) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValConsume::Validate( CMICmdArgContext & vwArgContext )
+bool
+CMICmdArgValConsume::Validate(CMICmdArgContext &vwArgContext)
{
- if( vwArgContext.IsEmpty() )
- return MIstatus::success;
+ if (vwArgContext.IsEmpty())
+ return MIstatus::success;
- if( vwArgContext.GetNumberArgsPresent() == 1 )
- {
- const CMIUtilString & rArg( vwArgContext.GetArgsLeftToParse() );
- m_bFound = true;
- m_bValid = true;
- vwArgContext.RemoveArg( rArg );
- return MIstatus::success;
- }
-
- // In reality there are more than one option, if so the file option
- // is the last one (don't handle that here - find the best looking one)
- const CMIUtilString::VecString_t vecOptions( vwArgContext.GetArgs() );
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while( it != vecOptions.end() )
- {
- const CMIUtilString & rTxt( *it );
- m_bFound = true;
-
- if( vwArgContext.RemoveArg( rTxt ) )
- {
- m_bValid = true;
- return MIstatus::success;
- }
- else
- return MIstatus::success;
-
- // Next
- ++it;
- }
+ if (vwArgContext.GetNumberArgsPresent() == 1)
+ {
+ const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
+ m_bFound = true;
+ m_bValid = true;
+ vwArgContext.RemoveArg(rArg);
+ return MIstatus::success;
+ }
- return MIstatus::failure;
+ // In reality there are more than one option, if so the file option
+ // is the last one (don't handle that here - find the best looking one)
+ const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end())
+ {
+ const CMIUtilString &rTxt(*it);
+ m_bFound = true;
+
+ if (vwArgContext.RemoveArg(rTxt))
+ {
+ m_bValid = true;
+ return MIstatus::success;
+ }
+ else
+ return MIstatus::success;
+
+ // Next
+ ++it;
+ }
+
+ return MIstatus::failure;
}
//++ ------------------------------------------------------------------------------------
-// Details: Nothing to examine as we just want to consume the argument or option (ignore
-// it).
-// Type: Method.
-// Args: None.
-// Return: bool - True = yes ok, false = not ok.
-// Throws: None.
+// Details: Nothing to examine as we just want to consume the argument or option (ignore
+// it).
+// Type: Method.
+// Args: None.
+// Return: bool - True = yes ok, false = not ok.
+// Throws: None.
//--
-bool CMICmdArgValConsume::IsOk( void ) const
+bool
+CMICmdArgValConsume::IsOk(void) const
{
- return true;
+ return true;
}
diff --git a/tools/lldb-mi/MICmdArgValConsume.h b/tools/lldb-mi/MICmdArgValConsume.h
index a113d89458f3..2b26e33aa8c1 100644
--- a/tools/lldb-mi/MICmdArgValConsume.h
+++ b/tools/lldb-mi/MICmdArgValConsume.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValConsume.h
+// File: MICmdArgValConsume.h
//
-// Overview: CMICmdArgValConsume interface.
+// Overview: CMICmdArgValConsume interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -28,36 +28,36 @@
class CMICmdArgContext;
//++ ============================================================================
-// Details: MI common code class. Command argument class. Arguments object
-// needing specialization derived from the CMICmdArgValBase class.
-// An argument knows what type of argument it is and how it is to
-// interpret the options (context) string to find and validate a matching
-// argument. This type having recognised its argument name just consumes
-// that argument or option (ignores it). This is the so the validation
-// process can then ask if all arguments or options have been recognised
-// other an error will occurred "argument not recognised". For example
-// this can be used to consume the "--" text which is not an argument in
-// itself. Normally the GetValue() function (in base class) would return
-// a value for the argument but is not the case for *this argument type
-// object.
-// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 20/05/2014.
-// Changes: None.
+// Details: MI common code class. Command argument class. Arguments object
+// needing specialization derived from the CMICmdArgValBase class.
+// An argument knows what type of argument it is and how it is to
+// interpret the options (context) string to find and validate a matching
+// argument. This type having recognised its argument name just consumes
+// that argument or option (ignores it). This is the so the validation
+// process can then ask if all arguments or options have been recognised
+// other an error will occurred "argument not recognised". For example
+// this can be used to consume the "--" text which is not an argument in
+// itself. Normally the GetValue() function (in base class) would return
+// a value for the argument but is not the case for *this argument type
+// object.
+// Based on the Interpreter pattern.
+// Gotchas: None.
+// Authors: Illya Rudkin 20/05/2014.
+// Changes: None.
//--
-class CMICmdArgValConsume : public CMICmdArgValBaseTemplate< CMIUtilString >
+class CMICmdArgValConsume : public CMICmdArgValBaseTemplate<CMIUtilString>
{
-// Methods:
-public:
- /* ctor */ CMICmdArgValConsume( void );
- /* ctor */ CMICmdArgValConsume( const CMIUtilString & vrArgName, const bool vbMandatory );
- //
- bool IsOk( void ) const;
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgValConsume(void);
+ /* ctor */ CMICmdArgValConsume(const CMIUtilString &vrArgName, const bool vbMandatory);
+ //
+ bool IsOk(void) const;
-// Overridden:
-public:
- // From CMICmdArgValBase
- /* dtor */ virtual ~CMICmdArgValConsume( void );
- // From CMICmdArgSet::IArg
- virtual bool Validate( CMICmdArgContext & vwArgContext );
+ // Overridden:
+ public:
+ // From CMICmdArgValBase
+ /* dtor */ virtual ~CMICmdArgValConsume(void);
+ // From CMICmdArgSet::IArg
+ virtual bool Validate(CMICmdArgContext &vwArgContext);
};
diff --git a/tools/lldb-mi/MICmdArgValFile.cpp b/tools/lldb-mi/MICmdArgValFile.cpp
index d5cc52b90b44..cee811f24dee 100644
--- a/tools/lldb-mi/MICmdArgValFile.cpp
+++ b/tools/lldb-mi/MICmdArgValFile.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValFile.cpp
+// File: MICmdArgValFile.cpp
//
-// Overview: CMICmdArgValFile implementation.
+// Overview: CMICmdArgValFile implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -24,181 +24,185 @@
#include "MICmdArgContext.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValFile constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValFile constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValFile::CMICmdArgValFile( void )
+CMICmdArgValFile::CMICmdArgValFile(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValFile constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValFile constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValFile::CMICmdArgValFile( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd )
-: CMICmdArgValBaseTemplate( vrArgName, vbMandatory, vbHandleByCmd )
+CMICmdArgValFile::CMICmdArgValFile(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValFile destructor.
-// Type: Overridden.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValFile destructor.
+// Type: Overridden.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValFile::~CMICmdArgValFile( void )
+CMICmdArgValFile::~CMICmdArgValFile(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
-// argument is looking for.
-// Type: Overridden.
-// Args: vwArgContext - (R) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract the value *this
+// argument is looking for.
+// Type: Overridden.
+// Args: vwArgContext - (R) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValFile::Validate( CMICmdArgContext & vwArgContext )
+bool
+CMICmdArgValFile::Validate(CMICmdArgContext &vwArgContext)
{
- if( vwArgContext.IsEmpty() )
- return MIstatus::success;
-
- // The GDB/MI spec suggests there is only parameter
-
- if( vwArgContext.GetNumberArgsPresent() == 1 )
- {
- const CMIUtilString & rFile( vwArgContext.GetArgsLeftToParse() );
- if( IsFilePath( rFile ) )
- {
- m_bFound = true;
- m_bValid = true;
- m_argValue = rFile.Trim( '"' );
- vwArgContext.RemoveArg( rFile );
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
- }
-
- // In reality there are more than one option, if so the file option
- // is the last one (don't handle that here - find the best looking one)
- const CMIUtilString::VecString_t vecOptions( vwArgContext.GetArgs() );
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while( it != vecOptions.end() )
- {
- const CMIUtilString & rTxt( *it );
- if( IsFilePath( rTxt ) )
- {
- m_bFound = true;
-
- if( vwArgContext.RemoveArg( rTxt ) )
- {
- m_bValid = true;
- m_argValue = rTxt.Trim( '"' );
- return MIstatus::success;
- }
- else
- return MIstatus::success;
- }
-
- // Next
- ++it;
- }
-
- return MIstatus::failure;
+ if (vwArgContext.IsEmpty())
+ return MIstatus::success;
+
+ // The GDB/MI spec suggests there is only parameter
+
+ if (vwArgContext.GetNumberArgsPresent() == 1)
+ {
+ const CMIUtilString &rFile(vwArgContext.GetArgsLeftToParse());
+ if (IsFilePath(rFile))
+ {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = rFile.Trim('"');
+ vwArgContext.RemoveArg(rFile);
+ return MIstatus::success;
+ }
+ else
+ return MIstatus::failure;
+ }
+
+ // In reality there are more than one option, if so the file option
+ // is the last one (don't handle that here - find the best looking one)
+ const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end())
+ {
+ const CMIUtilString &rTxt(*it);
+ if (IsFilePath(rTxt))
+ {
+ m_bFound = true;
+
+ if (vwArgContext.RemoveArg(rTxt))
+ {
+ m_bValid = true;
+ m_argValue = rTxt.Trim('"');
+ return MIstatus::success;
+ }
+ else
+ return MIstatus::success;
+ }
+
+ // Next
+ ++it;
+ }
+
+ return MIstatus::failure;
}
//++ ------------------------------------------------------------------------------------
-// Details: Given some text extract the file name path from it. If a space is found in
-// path done return the path surrounded in quotes.
-// Type: Method.
-// Args: vrTxt - (R) The text to extract the file name path from.
-// Return: CMIUtilString - File name and or path.
-// Throws: None.
+// Details: Given some text extract the file name path from it. If a space is found in
+// path done return the path surrounded in quotes.
+// Type: Method.
+// Args: vrTxt - (R) The text to extract the file name path from.
+// Return: CMIUtilString - File name and or path.
+// Throws: None.
//--
-CMIUtilString CMICmdArgValFile::GetFileNamePath( const CMIUtilString & vrTxt ) const
+CMIUtilString
+CMICmdArgValFile::GetFileNamePath(const CMIUtilString &vrTxt) const
{
- CMIUtilString fileNamePath( vrTxt );
-
- // Look for a space in the path
- const MIchar cSpace = ' ';
- const MIint nPos = fileNamePath.find( cSpace );
- if( nPos != (MIint) std::string::npos )
- fileNamePath = CMIUtilString::Format( "\"%s\"", fileNamePath.c_str() );
-
- return fileNamePath;
+ CMIUtilString fileNamePath(vrTxt);
+
+ // Look for a space in the path
+ const MIchar cSpace = ' ';
+ const MIint nPos = fileNamePath.find(cSpace);
+ if (nPos != (MIint)std::string::npos)
+ fileNamePath = CMIUtilString::Format("\"%s\"", fileNamePath.c_str());
+
+ return fileNamePath;
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid file name path.
-// Type: Method.
-// Args: vrFileNamePath - (R) File's name and directory path.
-// Return: bool - True = yes valid file path, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid file name path.
+// Type: Method.
+// Args: vrFileNamePath - (R) File's name and directory path.
+// Return: bool - True = yes valid file path, false = no.
+// Throws: None.
//--
-bool CMICmdArgValFile::IsFilePath( const CMIUtilString & vrFileNamePath ) const
+bool
+CMICmdArgValFile::IsFilePath(const CMIUtilString &vrFileNamePath) const
{
- if( vrFileNamePath.empty() )
- return false;
-
- const bool bHavePosSlash = (vrFileNamePath.find_first_of( "/" ) != std::string::npos);
- const bool bHaveBckSlash = (vrFileNamePath.find_first_of( "\\" ) != std::string::npos);
-
- // Look for --someLongOption
- MIint nPos = vrFileNamePath.find_first_of( "--" );
- const bool bLong = (nPos == 0);
- if( bLong )
- return false;
-
- // Look for -f type short parameters
- nPos = vrFileNamePath.find_first_of( "-" );
- const bool bShort = (nPos == 0);
- if( bShort )
- return false;
-
- // Look for i1 i2 i3....
- nPos = vrFileNamePath.find_first_of( "i" );
- const bool bFoundI1 = ((nPos == 0) && (::isdigit( vrFileNamePath[ 1 ] )) );
- if( bFoundI1 )
- return false;
-
- const bool bValidChars = IsValidChars( vrFileNamePath );
- if( bValidChars || bHavePosSlash || bHaveBckSlash )
- return true;
-
- return false;
+ if (vrFileNamePath.empty())
+ return false;
+
+ const bool bHavePosSlash = (vrFileNamePath.find_first_of("/") != std::string::npos);
+ const bool bHaveBckSlash = (vrFileNamePath.find_first_of("\\") != std::string::npos);
+
+ // Look for --someLongOption
+ MIint nPos = vrFileNamePath.find_first_of("--");
+ const bool bLong = (nPos == 0);
+ if (bLong)
+ return false;
+
+ // Look for -f type short parameters
+ nPos = vrFileNamePath.find_first_of("-");
+ const bool bShort = (nPos == 0);
+ if (bShort)
+ return false;
+
+ // Look for i1 i2 i3....
+ nPos = vrFileNamePath.find_first_of("i");
+ const bool bFoundI1 = ((nPos == 0) && (::isdigit(vrFileNamePath[1])));
+ if (bFoundI1)
+ return false;
+
+ const bool bValidChars = IsValidChars(vrFileNamePath);
+ if (bValidChars || bHavePosSlash || bHaveBckSlash)
+ return true;
+
+ return false;
}
//++ ------------------------------------------------------------------------------------
-// Details: Determine if the path contains valid characters for a file path. Letters can be
-// either upper or lower case.
-// Type: Method.
-// Args: vrText - (R) The text data to examine.
-// Return: bool - True = yes valid, false = one or more chars is valid.
-// Throws: None.
+// Details: Determine if the path contains valid characters for a file path. Letters can be
+// either upper or lower case.
+// Type: Method.
+// Args: vrText - (R) The text data to examine.
+// Return: bool - True = yes valid, false = one or more chars is valid.
+// Throws: None.
//--
-bool CMICmdArgValFile::IsValidChars( const CMIUtilString & vrText ) const
+bool
+CMICmdArgValFile::IsValidChars(const CMIUtilString &vrText) const
{
- const MIchar * pPtr = const_cast< MIchar * >( vrText.c_str() );
- for( MIuint i = 0; i < vrText.length(); i++, pPtr++ )
- {
- const MIchar c = *pPtr;
- if( ::isalnum( (int) c ) == 0 )
- {
- if( (c != '.') && (c != '-') && (c != '_') )
- return false;
- }
- }
-
- return true;
+ const MIchar *pPtr = const_cast<MIchar *>(vrText.c_str());
+ for (MIuint i = 0; i < vrText.length(); i++, pPtr++)
+ {
+ const MIchar c = *pPtr;
+ if (::isalnum((int)c) == 0)
+ {
+ if ((c != '.') && (c != '-') && (c != '_'))
+ return false;
+ }
+ }
+
+ return true;
}
diff --git a/tools/lldb-mi/MICmdArgValFile.h b/tools/lldb-mi/MICmdArgValFile.h
index 071727401454..db5380885783 100644
--- a/tools/lldb-mi/MICmdArgValFile.h
+++ b/tools/lldb-mi/MICmdArgValFile.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValFile.h
+// File: MICmdArgValFile.h
//
-// Overview: CMICmdArgValFile interface.
+// Overview: CMICmdArgValFile interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -28,34 +28,34 @@
class CMICmdArgContext;
//++ ============================================================================
-// Details: MI common code class. Command argument class. Arguments object
-// needing specialization derived from the CMICmdArgValBase class.
-// An argument knows what type of argument it is and how it is to
-// interpret the options (context) string to find and validate a matching
-// argument and so extract a value from it .
-// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 15/04/2014.
-// Changes: None.
+// Details: MI common code class. Command argument class. Arguments object
+// needing specialization derived from the CMICmdArgValBase class.
+// An argument knows what type of argument it is and how it is to
+// interpret the options (context) string to find and validate a matching
+// argument and so extract a value from it .
+// Based on the Interpreter pattern.
+// Gotchas: None.
+// Authors: Illya Rudkin 15/04/2014.
+// Changes: None.
//--
-class CMICmdArgValFile : public CMICmdArgValBaseTemplate< CMIUtilString >
+class CMICmdArgValFile : public CMICmdArgValBaseTemplate<CMIUtilString>
{
-// Methods:
-public:
- /* ctor */ CMICmdArgValFile( void );
- /* ctor */ CMICmdArgValFile( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd );
- //
- bool IsFilePath( const CMIUtilString & vrFileNamePath ) const;
- CMIUtilString GetFileNamePath( const CMIUtilString & vrTxt ) const;
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgValFile(void);
+ /* ctor */ CMICmdArgValFile(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
+ //
+ bool IsFilePath(const CMIUtilString &vrFileNamePath) const;
+ CMIUtilString GetFileNamePath(const CMIUtilString &vrTxt) const;
-// Overridden:
-public:
- // From CMICmdArgValBase
- /* dtor */ virtual ~CMICmdArgValFile( void );
- // From CMICmdArgSet::IArg
- virtual bool Validate( CMICmdArgContext & vwArgContext );
+ // Overridden:
+ public:
+ // From CMICmdArgValBase
+ /* dtor */ virtual ~CMICmdArgValFile(void);
+ // From CMICmdArgSet::IArg
+ virtual bool Validate(CMICmdArgContext &vwArgContext);
-// Methods:
-private:
- bool IsValidChars( const CMIUtilString & vrText ) const;
+ // Methods:
+ private:
+ bool IsValidChars(const CMIUtilString &vrText) const;
};
diff --git a/tools/lldb-mi/MICmdArgValListBase.cpp b/tools/lldb-mi/MICmdArgValListBase.cpp
index 37b729e42741..b992b307e346 100644
--- a/tools/lldb-mi/MICmdArgValListBase.cpp
+++ b/tools/lldb-mi/MICmdArgValListBase.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValListBase.cpp
+// File: MICmdArgValListBase.cpp
//
-// Overview: CMICmdArgValListBase implementation.
+// Overview: CMICmdArgValListBase implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -31,191 +31,195 @@
#include "MICmdArgValConsume.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValListBase constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValListBase constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValListBase::CMICmdArgValListBase( void )
-: m_eArgType( eArgValType_invalid )
+CMICmdArgValListBase::CMICmdArgValListBase(void)
+ : m_eArgType(eArgValType_invalid)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValListBase constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValListBase constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValListBase::CMICmdArgValListBase( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd )
-: CMICmdArgValBaseTemplate( vrArgName, vbMandatory, vbHandleByCmd )
-, m_eArgType( eArgValType_invalid )
+CMICmdArgValListBase::CMICmdArgValListBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
+ , m_eArgType(eArgValType_invalid)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValListBase constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// veType - (R) The type of argument to look for and create argument object of a certain type.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValListBase constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// veType - (R) The type of argument to look for and create argument object of a certain type.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValListBase::CMICmdArgValListBase( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const ArgValType_e veType )
-: CMICmdArgValBaseTemplate( vrArgName, vbMandatory, vbHandleByCmd )
-, m_eArgType( veType )
+CMICmdArgValListBase::CMICmdArgValListBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+ const ArgValType_e veType)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
+ , m_eArgType(veType)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValListBase destructor.
-// Type: Overridden.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValListBase destructor.
+// Type: Overridden.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValListBase::~CMICmdArgValListBase( void )
+CMICmdArgValListBase::~CMICmdArgValListBase(void)
{
- // Tidy up
- Destroy();
+ // Tidy up
+ Destroy();
}
//++ ------------------------------------------------------------------------------------
-// Details: Tear down resources used by *this object.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: Tear down resources used by *this object.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-void CMICmdArgValListBase::Destroy( void )
+void
+CMICmdArgValListBase::Destroy(void)
{
- // Tidy up
- VecArgObjPtr_t::const_iterator it = m_argValue.begin();
- while( it != m_argValue.end() )
- {
- CMICmdArgValBase * pArgObj = *it;
- delete pArgObj;
+ // Tidy up
+ VecArgObjPtr_t::const_iterator it = m_argValue.begin();
+ while (it != m_argValue.end())
+ {
+ CMICmdArgValBase *pArgObj = *it;
+ delete pArgObj;
- // Next
- ++it;
- }
- m_argValue.clear();
+ // Next
+ ++it;
+ }
+ m_argValue.clear();
}
//++ ------------------------------------------------------------------------------------
-// Details: Create an CMICmdArgValBase derived object matching the type specified
-// and put the option or argument's value inside it.
-// Type: Method.
-// Args: vrTxt - (R) Text version the option or argument.
-// veType - (R) The type of argument or option object to create.
-// Return: CMICmdArgValBase * - Option object holding the value.
-// - NULL = Functional failed.
-// Throws: None.
+// Details: Create an CMICmdArgValBase derived object matching the type specified
+// and put the option or argument's value inside it.
+// Type: Method.
+// Args: vrTxt - (R) Text version the option or argument.
+// veType - (R) The type of argument or option object to create.
+// Return: CMICmdArgValBase * - Option object holding the value.
+// - NULL = Functional failed.
+// Throws: None.
//--
-CMICmdArgValBase * CMICmdArgValListBase::CreationObj( const CMIUtilString & vrTxt, const ArgValType_e veType ) const
+CMICmdArgValBase *
+CMICmdArgValListBase::CreationObj(const CMIUtilString &vrTxt, const ArgValType_e veType) const
{
- CMICmdArgValBase * pOptionObj = nullptr;
- switch( veType )
- {
- case eArgValType_File:
- pOptionObj = new CMICmdArgValFile();
- break;
- case eArgValType_Consume:
- pOptionObj = new CMICmdArgValConsume();
- break;
- case eArgValType_Number:
- pOptionObj = new CMICmdArgValNumber();
- break;
- case eArgValType_OptionLong:
- pOptionObj = new CMICmdArgValOptionLong();
- break;
- case eArgValType_OptionShort:
- pOptionObj = new CMICmdArgValOptionShort();
- break;
- case eArgValType_String:
- pOptionObj = new CMICmdArgValString();
- break;
- case eArgValType_StringQuoted:
- pOptionObj = new CMICmdArgValString( true, false, false );
- break;
- case eArgValType_StringQuotedNumber:
- pOptionObj = new CMICmdArgValString( true, true, false );
- break;
- case eArgValType_StringQuotedNumberPath:
- pOptionObj = new CMICmdArgValString( true, true, true );
- break;
- case eArgValType_StringAnything:
- pOptionObj = new CMICmdArgValString( true );
- break;
- case eArgValType_ThreadGrp:
- pOptionObj = new CMICmdArgValThreadGrp();
- break;
- default:
- return nullptr;
- }
+ CMICmdArgValBase *pOptionObj = nullptr;
+ switch (veType)
+ {
+ case eArgValType_File:
+ pOptionObj = new CMICmdArgValFile();
+ break;
+ case eArgValType_Consume:
+ pOptionObj = new CMICmdArgValConsume();
+ break;
+ case eArgValType_Number:
+ pOptionObj = new CMICmdArgValNumber();
+ break;
+ case eArgValType_OptionLong:
+ pOptionObj = new CMICmdArgValOptionLong();
+ break;
+ case eArgValType_OptionShort:
+ pOptionObj = new CMICmdArgValOptionShort();
+ break;
+ case eArgValType_String:
+ pOptionObj = new CMICmdArgValString();
+ break;
+ case eArgValType_StringQuoted:
+ pOptionObj = new CMICmdArgValString(true, false, false);
+ break;
+ case eArgValType_StringQuotedNumber:
+ pOptionObj = new CMICmdArgValString(true, true, false);
+ break;
+ case eArgValType_StringQuotedNumberPath:
+ pOptionObj = new CMICmdArgValString(true, true, true);
+ break;
+ case eArgValType_StringAnything:
+ pOptionObj = new CMICmdArgValString(true);
+ break;
+ case eArgValType_ThreadGrp:
+ pOptionObj = new CMICmdArgValThreadGrp();
+ break;
+ default:
+ return nullptr;
+ }
- CMICmdArgContext argCntxt( vrTxt );
- if( !pOptionObj->Validate( argCntxt ) )
- return nullptr;
+ CMICmdArgContext argCntxt(vrTxt);
+ if (!pOptionObj->Validate(argCntxt))
+ return nullptr;
- return pOptionObj;
+ return pOptionObj;
}
//++ ------------------------------------------------------------------------------------
-// Details: Validate the option or argument is the correct type.
-// Type: Method.
-// Args: vrTxt - (R) Text version the option or argument.
-// veType - (R) The type of value to expect.
-// Return: bool - True = Yes expected type present, False = no.
-// Throws: None.
+// Details: Validate the option or argument is the correct type.
+// Type: Method.
+// Args: vrTxt - (R) Text version the option or argument.
+// veType - (R) The type of value to expect.
+// Return: bool - True = Yes expected type present, False = no.
+// Throws: None.
//--
-bool CMICmdArgValListBase::IsExpectedCorrectType( const CMIUtilString & vrTxt, const ArgValType_e veType ) const
+bool
+CMICmdArgValListBase::IsExpectedCorrectType(const CMIUtilString &vrTxt, const ArgValType_e veType) const
{
- bool bValid = false;
- switch( veType )
- {
- case eArgValType_File:
- bValid = CMICmdArgValFile().IsFilePath( vrTxt );
- break;
- case eArgValType_Consume:
- bValid = CMICmdArgValConsume().IsOk();
- break;
- case eArgValType_Number:
- bValid = CMICmdArgValNumber().IsArgNumber( vrTxt );
- break;
- case eArgValType_OptionLong:
- bValid = CMICmdArgValOptionLong().IsArgLongOption( vrTxt );
- break;
- case eArgValType_OptionShort:
- bValid = CMICmdArgValOptionShort().IsArgShortOption( vrTxt );
- break;
- case eArgValType_String:
- bValid = CMICmdArgValString().IsStringArg( vrTxt );
- break;
- case eArgValType_StringQuoted:
- bValid = CMICmdArgValString( true, false, false ).IsStringArg( vrTxt );
- break;
- case eArgValType_StringQuotedNumber:
- bValid = CMICmdArgValString( true, true, false ).IsStringArg( vrTxt );
- break;
- case eArgValType_StringQuotedNumberPath:
- bValid = CMICmdArgValString( true, true, true ).IsStringArg( vrTxt );
- break;
- case eArgValType_StringAnything:
- bValid = CMICmdArgValString( true ).IsStringArg( vrTxt );
- break;
- case eArgValType_ThreadGrp:
- bValid = CMICmdArgValThreadGrp().IsArgThreadGrp( vrTxt );
- break;
- default:
- return false;
- }
+ bool bValid = false;
+ switch (veType)
+ {
+ case eArgValType_File:
+ bValid = CMICmdArgValFile().IsFilePath(vrTxt);
+ break;
+ case eArgValType_Consume:
+ bValid = CMICmdArgValConsume().IsOk();
+ break;
+ case eArgValType_Number:
+ bValid = CMICmdArgValNumber().IsArgNumber(vrTxt);
+ break;
+ case eArgValType_OptionLong:
+ bValid = CMICmdArgValOptionLong().IsArgLongOption(vrTxt);
+ break;
+ case eArgValType_OptionShort:
+ bValid = CMICmdArgValOptionShort().IsArgShortOption(vrTxt);
+ break;
+ case eArgValType_String:
+ bValid = CMICmdArgValString().IsStringArg(vrTxt);
+ break;
+ case eArgValType_StringQuoted:
+ bValid = CMICmdArgValString(true, false, false).IsStringArg(vrTxt);
+ break;
+ case eArgValType_StringQuotedNumber:
+ bValid = CMICmdArgValString(true, true, false).IsStringArg(vrTxt);
+ break;
+ case eArgValType_StringQuotedNumberPath:
+ bValid = CMICmdArgValString(true, true, true).IsStringArg(vrTxt);
+ break;
+ case eArgValType_StringAnything:
+ bValid = CMICmdArgValString(true).IsStringArg(vrTxt);
+ break;
+ case eArgValType_ThreadGrp:
+ bValid = CMICmdArgValThreadGrp().IsArgThreadGrp(vrTxt);
+ break;
+ default:
+ return false;
+ }
- return bValid;
+ return bValid;
}
diff --git a/tools/lldb-mi/MICmdArgValListBase.h b/tools/lldb-mi/MICmdArgValListBase.h
index 2798efa19a48..0e56f6dac021 100644
--- a/tools/lldb-mi/MICmdArgValListBase.h
+++ b/tools/lldb-mi/MICmdArgValListBase.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValListBase.h
+// File: MICmdArgValListBase.h
//
-// Overview: CMICmdArgValListBase interface.
+// Overview: CMICmdArgValListBase interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -31,73 +31,74 @@
class CMICmdArgContext;
//++ ============================================================================
-// Details: MI common code class. Command argument with addition options class.
-// For example --recurse 1 2 4 [group ...]. Arguments object that
-// require a list of options associated with them derive from the
-// CMICmdArgValListBase class. Additional options are also extracted from
-// the command arguments text string.
-// An argument knows what type of argument it is and how it is to
-// interpret the options (context) string to find and validate a matching
-// options and so extract a values from it .
-// The CMICmdArgValBase objects are added to the derived argument class's
-// container. The option arguments belong to that derived class and will
-// be deleted that object goes out of scope.
-// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 16/04/2014.
-// Changes: None.
+// Details: MI common code class. Command argument with addition options class.
+// For example --recurse 1 2 4 [group ...]. Arguments object that
+// require a list of options associated with them derive from the
+// CMICmdArgValListBase class. Additional options are also extracted from
+// the command arguments text string.
+// An argument knows what type of argument it is and how it is to
+// interpret the options (context) string to find and validate a matching
+// options and so extract a values from it .
+// The CMICmdArgValBase objects are added to the derived argument class's
+// container. The option arguments belong to that derived class and will
+// be deleted that object goes out of scope.
+// Based on the Interpreter pattern.
+// Gotchas: None.
+// Authors: Illya Rudkin 16/04/2014.
+// Changes: None.
//--
-class CMICmdArgValListBase : public CMICmdArgValBaseTemplate< std::vector< CMICmdArgValBase * > >
+class CMICmdArgValListBase : public CMICmdArgValBaseTemplate<std::vector<CMICmdArgValBase *>>
{
-// Typedef:
-public:
- typedef std::vector< CMICmdArgValBase * > VecArgObjPtr_t;
+ // Typedef:
+ public:
+ typedef std::vector<CMICmdArgValBase *> VecArgObjPtr_t;
-// Enums:
-public:
- //++ ---------------------------------------------------------------------------------
- // Details: CMICmdArgValListBase needs to know what type of argument to look for in
- // the command options text. It also needs to create argument objects of
- // a specific type.
- //--
- enum ArgValType_e
- {
- eArgValType_File = 0,
- eArgValType_Consume,
- eArgValType_Number,
- eArgValType_OptionLong,
- eArgValType_OptionShort,
- eArgValType_String,
- eArgValType_StringQuoted,
- eArgValType_StringQuotedNumber,
- eArgValType_StringQuotedNumberPath,
- eArgValType_StringAnything, // Accept any words for a string 'type' even if they look like --longOptions for example
- eArgValType_ThreadGrp,
- eArgValType_count, // Always the last one
- eArgValType_invalid
- };
+ // Enums:
+ public:
+ //++ ---------------------------------------------------------------------------------
+ // Details: CMICmdArgValListBase needs to know what type of argument to look for in
+ // the command options text. It also needs to create argument objects of
+ // a specific type.
+ //--
+ enum ArgValType_e
+ {
+ eArgValType_File = 0,
+ eArgValType_Consume,
+ eArgValType_Number,
+ eArgValType_OptionLong,
+ eArgValType_OptionShort,
+ eArgValType_String,
+ eArgValType_StringQuoted,
+ eArgValType_StringQuotedNumber,
+ eArgValType_StringQuotedNumberPath,
+ eArgValType_StringAnything, // Accept any words for a string 'type' even if they look like --longOptions for example
+ eArgValType_ThreadGrp,
+ eArgValType_count, // Always the last one
+ eArgValType_invalid
+ };
-// Methods:
-public:
- /* ctor */ CMICmdArgValListBase( void );
- /* ctor */ CMICmdArgValListBase( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd );
- /* ctor */ CMICmdArgValListBase( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const ArgValType_e veType );
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgValListBase(void);
+ /* ctor */ CMICmdArgValListBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
+ /* ctor */ CMICmdArgValListBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+ const ArgValType_e veType);
-// Overridden:
-public:
- // From CMICmdArgValBase
- /* dtor */ virtual ~CMICmdArgValListBase( void );
+ // Overridden:
+ public:
+ // From CMICmdArgValBase
+ /* dtor */ virtual ~CMICmdArgValListBase(void);
-// Methods:
-protected:
- bool IsExpectedCorrectType( const CMIUtilString & vrTxt, const ArgValType_e veType ) const;
- CMICmdArgValBase * CreationObj( const CMIUtilString & vrTxt, const ArgValType_e veType ) const;
-
-// Attributes:
-protected:
- ArgValType_e m_eArgType;
+ // Methods:
+ protected:
+ bool IsExpectedCorrectType(const CMIUtilString &vrTxt, const ArgValType_e veType) const;
+ CMICmdArgValBase *CreationObj(const CMIUtilString &vrTxt, const ArgValType_e veType) const;
-// Methods:
-private:
- void Destroy( void );
+ // Attributes:
+ protected:
+ ArgValType_e m_eArgType;
+
+ // Methods:
+ private:
+ void Destroy(void);
};
diff --git a/tools/lldb-mi/MICmdArgValListOfN.cpp b/tools/lldb-mi/MICmdArgValListOfN.cpp
index 246fa2c9445d..9a4711485f0b 100644
--- a/tools/lldb-mi/MICmdArgValListOfN.cpp
+++ b/tools/lldb-mi/MICmdArgValListOfN.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValListOfN.cpp
+// File: MICmdArgValListOfN.cpp
//
-// Overview: CMICmdArgValListOfN implementation.
+// Overview: CMICmdArgValListOfN implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -30,160 +30,159 @@
#include "MICmdArgValThreadGrp.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValListOfN constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValListOfN constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValListOfN::CMICmdArgValListOfN( void )
+CMICmdArgValListOfN::CMICmdArgValListOfN(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValListOfN constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// veType - (R) The type of argument to look for and create argument object of a certain type.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValListOfN constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// veType - (R) The type of argument to look for and create argument object of a certain type.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValListOfN::CMICmdArgValListOfN( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const ArgValType_e veType )
-: CMICmdArgValListBase( vrArgName, vbMandatory, vbHandleByCmd, veType )
+CMICmdArgValListOfN::CMICmdArgValListOfN(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+ const ArgValType_e veType)
+ : CMICmdArgValListBase(vrArgName, vbMandatory, vbHandleByCmd, veType)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValListOfN destructor.
-// Type: Overridden.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValListOfN destructor.
+// Type: Overridden.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValListOfN::~CMICmdArgValListOfN( void )
+CMICmdArgValListOfN::~CMICmdArgValListOfN(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the list of
-// arguments based on the argument object type to look for.
-// Type: Overridden.
-// Args: vwArgContext - (RW) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract the list of
+// arguments based on the argument object type to look for.
+// Type: Overridden.
+// Args: vwArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValListOfN::Validate( CMICmdArgContext & vwArgContext )
+bool
+CMICmdArgValListOfN::Validate(CMICmdArgContext &vwArgContext)
{
- if( m_eArgType >= eArgValType_count )
- {
- m_eArgType = eArgValType_invalid;
- return MIstatus::failure;
- }
-
- if( vwArgContext.IsEmpty() )
- return MIstatus::success;
-
- const CMIUtilString & rArg( vwArgContext.GetArgsLeftToParse() );
- if( IsListOfN( rArg ) && CreateList( rArg ) )
- {
- m_bFound = true;
- m_bValid = true;
- vwArgContext.RemoveArg( rArg );
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
+ if (m_eArgType >= eArgValType_count)
+ {
+ m_eArgType = eArgValType_invalid;
+ return MIstatus::failure;
+ }
+
+ if (vwArgContext.IsEmpty())
+ return MIstatus::success;
+
+ const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
+ if (IsListOfN(rArg) && CreateList(rArg))
+ {
+ m_bFound = true;
+ m_bValid = true;
+ vwArgContext.RemoveArg(rArg);
+ return MIstatus::success;
+ }
+ else
+ return MIstatus::failure;
}
//++ ------------------------------------------------------------------------------------
-// Details: Create list of argument objects each holding a value extract from the command
-// options line.
-// Type: Method.
-// Args: vrTxt - (R) Some options text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Create list of argument objects each holding a value extract from the command
+// options line.
+// Type: Method.
+// Args: vrTxt - (R) Some options text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValListOfN::CreateList( const CMIUtilString & vrTxt )
+bool
+CMICmdArgValListOfN::CreateList(const CMIUtilString &vrTxt)
{
- CMIUtilString::VecString_t vecOptions;
- if( (m_eArgType == eArgValType_StringQuoted) ||
- (m_eArgType == eArgValType_StringQuotedNumber) ||
- (m_eArgType == eArgValType_StringQuotedNumberPath) ||
- (m_eArgType == eArgValType_StringAnything) )
- {
- if( vrTxt.SplitConsiderQuotes( " ", vecOptions ) == 0 )
- return MIstatus::failure;
- }
- else
- if( vrTxt.Split( " ", vecOptions ) == 0 )
- return MIstatus::failure;
-
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while( it != vecOptions.end() )
- {
- const CMIUtilString & rOption = *it;
- CMICmdArgValBase * pOption = CreationObj( rOption, m_eArgType );
- if( pOption != nullptr )
- m_argValue.push_back( pOption );
- else
- return MIstatus::failure;
-
- // Next
- ++it;
- }
-
- return MIstatus::success;
+ CMIUtilString::VecString_t vecOptions;
+ if ((m_eArgType == eArgValType_StringQuoted) || (m_eArgType == eArgValType_StringQuotedNumber) ||
+ (m_eArgType == eArgValType_StringQuotedNumberPath) || (m_eArgType == eArgValType_StringAnything))
+ {
+ if (vrTxt.SplitConsiderQuotes(" ", vecOptions) == 0)
+ return MIstatus::failure;
+ }
+ else if (vrTxt.Split(" ", vecOptions) == 0)
+ return MIstatus::failure;
+
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end())
+ {
+ const CMIUtilString &rOption = *it;
+ CMICmdArgValBase *pOption = CreationObj(rOption, m_eArgType);
+ if (pOption != nullptr)
+ m_argValue.push_back(pOption);
+ else
+ return MIstatus::failure;
+
+ // Next
+ ++it;
+ }
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid string type argument.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValListOfN::IsListOfN( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValListOfN::IsListOfN(const CMIUtilString &vrTxt) const
{
- CMIUtilString::VecString_t vecOptions;
- if( (m_eArgType == eArgValType_StringQuoted) ||
- (m_eArgType == eArgValType_StringQuotedNumber) ||
- (m_eArgType == eArgValType_StringQuotedNumberPath) ||
- (m_eArgType == eArgValType_StringAnything) )
- {
- if( vrTxt.SplitConsiderQuotes( " ", vecOptions ) == 0 )
- return false;
- }
- else
- if( vrTxt.Split( " ", vecOptions ) == 0 )
- return false;
-
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while( it != vecOptions.end() )
- {
- const CMIUtilString & rOption = *it;
- if( !IsExpectedCorrectType( rOption, m_eArgType ) )
- break;
-
- // Next
- ++it;
- }
-
- return true;
+ CMIUtilString::VecString_t vecOptions;
+ if ((m_eArgType == eArgValType_StringQuoted) || (m_eArgType == eArgValType_StringQuotedNumber) ||
+ (m_eArgType == eArgValType_StringQuotedNumberPath) || (m_eArgType == eArgValType_StringAnything))
+ {
+ if (vrTxt.SplitConsiderQuotes(" ", vecOptions) == 0)
+ return false;
+ }
+ else if (vrTxt.Split(" ", vecOptions) == 0)
+ return false;
+
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end())
+ {
+ const CMIUtilString &rOption = *it;
+ if (!IsExpectedCorrectType(rOption, m_eArgType))
+ break;
+
+ // Next
+ ++it;
+ }
+
+ return true;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the list of CMICmdArgValBase derived option objects found following
-// *this long option argument. For example "list-thread-groups [ --recurse 1 ]"
-// where 1 is the list of expected option to follow.
-// Type: Method.
-// Args: None.
-// Return: CMICmdArgValListBase::VecArgObjPtr_t & - List of options.
-// Throws: None.
+// Details: Retrieve the list of CMICmdArgValBase derived option objects found following
+// *this long option argument. For example "list-thread-groups [ --recurse 1 ]"
+// where 1 is the list of expected option to follow.
+// Type: Method.
+// Args: None.
+// Return: CMICmdArgValListBase::VecArgObjPtr_t & - List of options.
+// Throws: None.
//--
-const CMICmdArgValListBase::VecArgObjPtr_t & CMICmdArgValListOfN::GetExpectedOptions( void ) const
+const CMICmdArgValListBase::VecArgObjPtr_t &
+CMICmdArgValListOfN::GetExpectedOptions(void) const
{
- return m_argValue;
+ return m_argValue;
}
diff --git a/tools/lldb-mi/MICmdArgValListOfN.h b/tools/lldb-mi/MICmdArgValListOfN.h
index 0fe5d2f4f831..48ee77f79e72 100644
--- a/tools/lldb-mi/MICmdArgValListOfN.h
+++ b/tools/lldb-mi/MICmdArgValListOfN.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValListOfN.h
+// File: MICmdArgValListOfN.h
//
-// Overview: CMICmdArgValListOfN interface.
+// Overview: CMICmdArgValListOfN interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -31,68 +31,69 @@
class CMICmdArgContext;
//++ ============================================================================
-// Details: MI common code class. Command argument class. Arguments object
-// needing specialization derived from the CMICmdArgValBase class.
-// An argument knows what type of argument it is and how it is to
-// interpret the options (context) string to find and validate a matching
-// argument and so extract a value from it .
-// The CMICmdArgValBase objects added to *this ListOfN container belong
-// to this container and will be deleted when *this object goes out of
-// scope.
-// To parse arguments like 'thread-id ...' i.e. 1 10 12 13 ...
-// If vbMandatory argument is true it takes on the (...)+ specification
-// otherwise assumed to be (...)* specification.
-// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 16/04/2014.
-// Changes: None.
+// Details: MI common code class. Command argument class. Arguments object
+// needing specialization derived from the CMICmdArgValBase class.
+// An argument knows what type of argument it is and how it is to
+// interpret the options (context) string to find and validate a matching
+// argument and so extract a value from it .
+// The CMICmdArgValBase objects added to *this ListOfN container belong
+// to this container and will be deleted when *this object goes out of
+// scope.
+// To parse arguments like 'thread-id ...' i.e. 1 10 12 13 ...
+// If vbMandatory argument is true it takes on the (...)+ specification
+// otherwise assumed to be (...)* specification.
+// Based on the Interpreter pattern.
+// Gotchas: None.
+// Authors: Illya Rudkin 16/04/2014.
+// Changes: None.
//--
class CMICmdArgValListOfN : public CMICmdArgValListBase
{
-// Methods:
-public:
- /* ctor */ CMICmdArgValListOfN( void );
- /* ctor */ CMICmdArgValListOfN( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const ArgValType_e veType );
- //
- const VecArgObjPtr_t & GetExpectedOptions( void ) const;
- template< class T1, typename T2 >
- bool GetExpectedOption( T2 & vrwValue ) const;
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgValListOfN(void);
+ /* ctor */ CMICmdArgValListOfN(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+ const ArgValType_e veType);
+ //
+ const VecArgObjPtr_t &GetExpectedOptions(void) const;
+ template <class T1, typename T2> bool GetExpectedOption(T2 &vrwValue) const;
-// Overridden:
-public:
- // From CMICmdArgValBase
- /* dtor */ virtual ~CMICmdArgValListOfN( void );
- // From CMICmdArgSet::IArg
- virtual bool Validate( CMICmdArgContext & vArgContext );
+ // Overridden:
+ public:
+ // From CMICmdArgValBase
+ /* dtor */ virtual ~CMICmdArgValListOfN(void);
+ // From CMICmdArgSet::IArg
+ virtual bool Validate(CMICmdArgContext &vArgContext);
-// Methods:
-private:
- bool IsListOfN( const CMIUtilString & vrTxt ) const;
- bool CreateList( const CMIUtilString & vrTxt );
+ // Methods:
+ private:
+ bool IsListOfN(const CMIUtilString &vrTxt) const;
+ bool CreateList(const CMIUtilString &vrTxt);
};
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the first argument or option value from the list of 1 or more options
-// parsed from the command's options string.
-// Type: Template method.
-// Args: vrwValue - (W) Templated type return value.
-// T1 - The argument value's class type of the data hold in the list of options.
-// T2 - The type pf the variable which holds the value wanted.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed. List of object was empty.
-// Throws: None.
+// Details: Retrieve the first argument or option value from the list of 1 or more options
+// parsed from the command's options string.
+// Type: Template method.
+// Args: vrwValue - (W) Templated type return value.
+// T1 - The argument value's class type of the data hold in the list of options.
+// T2 - The type pf the variable which holds the value wanted.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed. List of object was empty.
+// Throws: None.
//--
-template< class T1, typename T2 >
-bool CMICmdArgValListOfN::GetExpectedOption( T2 & vrwValue ) const
+template <class T1, typename T2>
+bool
+CMICmdArgValListOfN::GetExpectedOption(T2 &vrwValue) const
{
- const VecArgObjPtr_t & rVecOptions( GetExpectedOptions() );
- VecArgObjPtr_t::const_iterator it2 = rVecOptions.begin();
- if( it2 != rVecOptions.end() )
- {
- const T1 * pOption = static_cast< T1 * >( *it2 );
- vrwValue = pOption->GetValue();
- return MIstatus::success;
- }
+ const VecArgObjPtr_t &rVecOptions(GetExpectedOptions());
+ VecArgObjPtr_t::const_iterator it2 = rVecOptions.begin();
+ if (it2 != rVecOptions.end())
+ {
+ const T1 *pOption = static_cast<T1 *>(*it2);
+ vrwValue = pOption->GetValue();
+ return MIstatus::success;
+ }
- return MIstatus::failure;
+ return MIstatus::failure;
}
diff --git a/tools/lldb-mi/MICmdArgValNumber.cpp b/tools/lldb-mi/MICmdArgValNumber.cpp
index 18bdccdc9ac5..8b1878df028b 100644
--- a/tools/lldb-mi/MICmdArgValNumber.cpp
+++ b/tools/lldb-mi/MICmdArgValNumber.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValNumber.cpp
+// File: MICmdArgValNumber.cpp
//
-// Overview: CMICmdArgValNumber implementation.
+// Overview: CMICmdArgValNumber implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -24,144 +24,147 @@
#include "MICmdArgContext.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValNumber constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValNumber constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValNumber::CMICmdArgValNumber( void )
-: m_nNumber( 0 )
+CMICmdArgValNumber::CMICmdArgValNumber(void)
+ : m_nNumber(0)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValNumber constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValNumber constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValNumber::CMICmdArgValNumber( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd )
-: CMICmdArgValBaseTemplate( vrArgName, vbMandatory, vbHandleByCmd )
-, m_nNumber( 0 )
+CMICmdArgValNumber::CMICmdArgValNumber(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
+ , m_nNumber(0)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValNumber destructor.
-// Type: Overridden.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValNumber destructor.
+// Type: Overridden.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValNumber::~CMICmdArgValNumber( void )
+CMICmdArgValNumber::~CMICmdArgValNumber(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
-// argument is looking for.
-// Type: Overridden.
-// Args: vwArgContext - (RW) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract the value *this
+// argument is looking for.
+// Type: Overridden.
+// Args: vwArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValNumber::Validate( CMICmdArgContext & vwArgContext )
+bool
+CMICmdArgValNumber::Validate(CMICmdArgContext &vwArgContext)
{
- if( vwArgContext.IsEmpty() )
- return MIstatus::success;
-
- if( vwArgContext.GetNumberArgsPresent() == 1 )
- {
- const CMIUtilString & rArg( vwArgContext.GetArgsLeftToParse() );
- if( IsArgNumber( rArg ) && ExtractNumber( rArg ) )
- {
- m_bFound = true;
- m_bValid = true;
- m_argValue = GetNumber();
- vwArgContext.RemoveArg( rArg );
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
- }
-
- // More than one option...
- const CMIUtilString::VecString_t vecOptions( vwArgContext.GetArgs() );
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while( it != vecOptions.end() )
- {
- const CMIUtilString & rArg( *it );
- if( IsArgNumber( rArg ) && ExtractNumber( rArg ) )
- {
- m_bFound = true;
-
- if( vwArgContext.RemoveArg( rArg ) )
- {
- m_bValid = true;
- m_argValue = GetNumber();
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
- }
-
- // Next
- ++it;
- }
-
- return MIstatus::failure;
+ if (vwArgContext.IsEmpty())
+ return MIstatus::success;
+
+ if (vwArgContext.GetNumberArgsPresent() == 1)
+ {
+ const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
+ if (IsArgNumber(rArg) && ExtractNumber(rArg))
+ {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = GetNumber();
+ vwArgContext.RemoveArg(rArg);
+ return MIstatus::success;
+ }
+ else
+ return MIstatus::failure;
+ }
+
+ // More than one option...
+ const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end())
+ {
+ const CMIUtilString &rArg(*it);
+ if (IsArgNumber(rArg) && ExtractNumber(rArg))
+ {
+ m_bFound = true;
+
+ if (vwArgContext.RemoveArg(rArg))
+ {
+ m_bValid = true;
+ m_argValue = GetNumber();
+ return MIstatus::success;
+ }
+ else
+ return MIstatus::failure;
+ }
+
+ // Next
+ ++it;
+ }
+
+ return MIstatus::failure;
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid string type argument.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValNumber::IsArgNumber( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValNumber::IsArgNumber(const CMIUtilString &vrTxt) const
{
- // Look for --someLongOption
- if( std::string::npos != vrTxt.find( "--" ) )
- return false;
-
- return vrTxt.IsNumber();
+ // Look for --someLongOption
+ if (std::string::npos != vrTxt.find("--"))
+ return false;
+
+ return vrTxt.IsNumber();
}
//++ ------------------------------------------------------------------------------------
-// Details: Extract the thread group number from the thread group argument.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Extract the thread group number from the thread group argument.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValNumber::ExtractNumber( const CMIUtilString & vrTxt )
+bool
+CMICmdArgValNumber::ExtractNumber(const CMIUtilString &vrTxt)
{
- MIint64 nNumber = 0;
- bool bOk = vrTxt.ExtractNumber( nNumber );
- if( bOk )
- {
- m_nNumber = static_cast< MIint >( nNumber );
- }
-
- return bOk;
+ MIint64 nNumber = 0;
+ bool bOk = vrTxt.ExtractNumber(nNumber);
+ if (bOk)
+ {
+ m_nNumber = static_cast<MIint>(nNumber);
+ }
+
+ return bOk;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the thread group ID found in the argument.
-// Type: Method.
-// Args: None.
-// Return: MIuint - Thread group ID.
-// Throws: None.
+// Details: Retrieve the thread group ID found in the argument.
+// Type: Method.
+// Args: None.
+// Return: MIuint - Thread group ID.
+// Throws: None.
//--
-MIint64 CMICmdArgValNumber::GetNumber( void ) const
+MIint64
+CMICmdArgValNumber::GetNumber(void) const
{
- return m_nNumber;
+ return m_nNumber;
}
-
diff --git a/tools/lldb-mi/MICmdArgValNumber.h b/tools/lldb-mi/MICmdArgValNumber.h
index 219b040a257d..1a782e1af388 100644
--- a/tools/lldb-mi/MICmdArgValNumber.h
+++ b/tools/lldb-mi/MICmdArgValNumber.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValNumber.h
+// File: MICmdArgValNumber.h
//
-// Overview: CMICmdArgValNumber interface.
+// Overview: CMICmdArgValNumber interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -28,38 +28,38 @@
class CMICmdArgContext;
//++ ============================================================================
-// Details: MI common code class. Command argument class. Arguments object
-// needing specialization derived from the CMICmdArgValBase class.
-// An argument knows what type of argument it is and how it is to
-// interpret the options (context) string to find and validate a matching
-// argument and so extract a value from it .
-// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 14/04/2014.
-// Changes: None.
+// Details: MI common code class. Command argument class. Arguments object
+// needing specialization derived from the CMICmdArgValBase class.
+// An argument knows what type of argument it is and how it is to
+// interpret the options (context) string to find and validate a matching
+// argument and so extract a value from it .
+// Based on the Interpreter pattern.
+// Gotchas: None.
+// Authors: Illya Rudkin 14/04/2014.
+// Changes: None.
//--
-class CMICmdArgValNumber : public CMICmdArgValBaseTemplate< MIint64 >
+class CMICmdArgValNumber : public CMICmdArgValBaseTemplate<MIint64>
{
-// Methods:
-public:
- /* ctor */ CMICmdArgValNumber( void );
- /* ctor */ CMICmdArgValNumber( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd );
- //
- bool IsArgNumber( const CMIUtilString & vrTxt ) const;
-
-// Overridden:
-public:
- // From CMICmdArgValBase
- /* dtor */ virtual ~CMICmdArgValNumber( void );
- // From CMICmdArgSet::IArg
- virtual bool Validate( CMICmdArgContext & vwArgContext );
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgValNumber(void);
+ /* ctor */ CMICmdArgValNumber(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
+ //
+ bool IsArgNumber(const CMIUtilString &vrTxt) const;
-// Methods:
-private:
- bool ExtractNumber( const CMIUtilString & vrTxt );
- MIint64 GetNumber( void ) const;
+ // Overridden:
+ public:
+ // From CMICmdArgValBase
+ /* dtor */ virtual ~CMICmdArgValNumber(void);
+ // From CMICmdArgSet::IArg
+ virtual bool Validate(CMICmdArgContext &vwArgContext);
-// Attributes:
-private:
- MIint64 m_nNumber;
+ // Methods:
+ private:
+ bool ExtractNumber(const CMIUtilString &vrTxt);
+ MIint64 GetNumber(void) const;
+
+ // Attributes:
+ private:
+ MIint64 m_nNumber;
};
diff --git a/tools/lldb-mi/MICmdArgValOptionLong.cpp b/tools/lldb-mi/MICmdArgValOptionLong.cpp
index 6c87984ba811..0c29982e2634 100644
--- a/tools/lldb-mi/MICmdArgValOptionLong.cpp
+++ b/tools/lldb-mi/MICmdArgValOptionLong.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValOptionLong.cpp
+// File: MICmdArgValOptionLong.cpp
//
-// Overview: CMICmdArgValOptionLong implementation.
+// Overview: CMICmdArgValOptionLong implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -24,296 +24,302 @@
#include "MICmdArgContext.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValOptionLong constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValOptionLong constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValOptionLong::CMICmdArgValOptionLong( void )
-: m_nExpectingNOptions( 0 )
-, m_eExpectingOptionType( eArgValType_invalid )
+CMICmdArgValOptionLong::CMICmdArgValOptionLong(void)
+ : m_nExpectingNOptions(0)
+ , m_eExpectingOptionType(eArgValType_invalid)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValOptionLong constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValOptionLong constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValOptionLong::CMICmdArgValOptionLong( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd )
-: CMICmdArgValListBase( vrArgName, vbMandatory, vbHandleByCmd )
-, m_nExpectingNOptions( 0 )
-, m_eExpectingOptionType( eArgValType_invalid )
+CMICmdArgValOptionLong::CMICmdArgValOptionLong(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
+ : CMICmdArgValListBase(vrArgName, vbMandatory, vbHandleByCmd)
+ , m_nExpectingNOptions(0)
+ , m_eExpectingOptionType(eArgValType_invalid)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValOptionLong constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// veType - (R) The type of argument to look for and create argument object of a certain type.
-// vnExpectingNOptions - (R) The number of options expected to read following *this argument.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValOptionLong constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// veType - (R) The type of argument to look for and create argument object of a certain type.
+// vnExpectingNOptions - (R) The number of options expected to read following *this argument.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValOptionLong::CMICmdArgValOptionLong( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const ArgValType_e veType, const MIuint vnExpectingNOptions )
-: CMICmdArgValListBase( vrArgName, vbMandatory, vbHandleByCmd )
-, m_nExpectingNOptions( vnExpectingNOptions )
-, m_eExpectingOptionType( veType )
+CMICmdArgValOptionLong::CMICmdArgValOptionLong(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+ const ArgValType_e veType, const MIuint vnExpectingNOptions)
+ : CMICmdArgValListBase(vrArgName, vbMandatory, vbHandleByCmd)
+ , m_nExpectingNOptions(vnExpectingNOptions)
+ , m_eExpectingOptionType(veType)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValOptionLong destructor.
-// Type: Overridden.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValOptionLong destructor.
+// Type: Overridden.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValOptionLong::~CMICmdArgValOptionLong( void )
+CMICmdArgValOptionLong::~CMICmdArgValOptionLong(void)
{
- // Tidy up
- Destroy();
+ // Tidy up
+ Destroy();
}
//++ ------------------------------------------------------------------------------------
-// Details: Tear down resources used by *this object.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: Tear down resources used by *this object.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-void CMICmdArgValOptionLong::Destroy( void )
+void
+CMICmdArgValOptionLong::Destroy(void)
{
- // Tidy up
- VecArgObjPtr_t::const_iterator it = m_vecArgsExpected.begin();
- while( it != m_vecArgsExpected.end() )
- {
- CMICmdArgValBase * pOptionObj = *it;
- delete pOptionObj;
-
- // Next
- ++it;
- }
- m_vecArgsExpected.clear();
+ // Tidy up
+ VecArgObjPtr_t::const_iterator it = m_vecArgsExpected.begin();
+ while (it != m_vecArgsExpected.end())
+ {
+ CMICmdArgValBase *pOptionObj = *it;
+ delete pOptionObj;
+
+ // Next
+ ++it;
+ }
+ m_vecArgsExpected.clear();
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the long
-// argument *this argument type is looking for.
-// Type: Overridden.
-// Args: vwArgContext - (RW) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract the long
+// argument *this argument type is looking for.
+// Type: Overridden.
+// Args: vwArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValOptionLong::Validate( CMICmdArgContext & vwArgContext )
+bool
+CMICmdArgValOptionLong::Validate(CMICmdArgContext &vwArgContext)
{
- if( vwArgContext.IsEmpty() )
- return MIstatus::success;
-
- if( vwArgContext.GetNumberArgsPresent() == 1 )
- {
- const CMIUtilString & rArg( vwArgContext.GetArgsLeftToParse() );
- if( IsArgLongOption( rArg ) && ArgNameMatch( rArg ) )
- {
- m_bFound = true;
-
- if( !vwArgContext.RemoveArg( rArg ) )
- return MIstatus::failure;
-
- if( m_nExpectingNOptions == 0 )
- {
- m_bValid = true;
- return MIstatus::success;
- }
-
- m_bIsMissingOptions = true;
- return MIstatus::failure;
- }
- else
- return MIstatus::failure;
- }
-
- // More than one option...
- MIuint nArgIndex = 0;
- const CMIUtilString::VecString_t vecOptions( vwArgContext.GetArgs() );
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while( it != vecOptions.end() )
- {
- const CMIUtilString & rArg( *it );
- if( IsArgOptionCorrect( rArg ) && ArgNameMatch( rArg ) )
- {
- m_bFound = true;
-
- if( !vwArgContext.RemoveArg( rArg ) )
- return MIstatus::failure;
-
- if( m_nExpectingNOptions != 0 )
- {
- if( ExtractExpectedOptions( vwArgContext, nArgIndex ) )
- {
- m_bValid = true;
- return MIstatus::success;
- }
-
- m_bIsMissingOptions = true;
- return MIstatus::failure;
- }
- else
- {
- m_bValid = true;
- return MIstatus::success;
- }
- }
-
- // Next
- ++it;
- ++nArgIndex;
- }
-
- return MIstatus::failure;
+ if (vwArgContext.IsEmpty())
+ return MIstatus::success;
+
+ if (vwArgContext.GetNumberArgsPresent() == 1)
+ {
+ const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
+ if (IsArgLongOption(rArg) && ArgNameMatch(rArg))
+ {
+ m_bFound = true;
+
+ if (!vwArgContext.RemoveArg(rArg))
+ return MIstatus::failure;
+
+ if (m_nExpectingNOptions == 0)
+ {
+ m_bValid = true;
+ return MIstatus::success;
+ }
+
+ m_bIsMissingOptions = true;
+ return MIstatus::failure;
+ }
+ else
+ return MIstatus::failure;
+ }
+
+ // More than one option...
+ MIuint nArgIndex = 0;
+ const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end())
+ {
+ const CMIUtilString &rArg(*it);
+ if (IsArgOptionCorrect(rArg) && ArgNameMatch(rArg))
+ {
+ m_bFound = true;
+
+ if (!vwArgContext.RemoveArg(rArg))
+ return MIstatus::failure;
+
+ if (m_nExpectingNOptions != 0)
+ {
+ if (ExtractExpectedOptions(vwArgContext, nArgIndex))
+ {
+ m_bValid = true;
+ return MIstatus::success;
+ }
+
+ m_bIsMissingOptions = true;
+ return MIstatus::failure;
+ }
+ else
+ {
+ m_bValid = true;
+ return MIstatus::success;
+ }
+ }
+
+ // Next
+ ++it;
+ ++nArgIndex;
+ }
+
+ return MIstatus::failure;
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the text following *this argument and extract the options the values of
-// CMICmdArgValListBase::m_eArgType forming argument objects for each of those
-// options extracted.
-// Type: Method.
-// Args: vrwTxt - (RW) The command's argument options string.
-// nArgIndex - (R) The Nth arg position in argument context from the left.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the text following *this argument and extract the options the values of
+// CMICmdArgValListBase::m_eArgType forming argument objects for each of those
+// options extracted.
+// Type: Method.
+// Args: vrwTxt - (RW) The command's argument options string.
+// nArgIndex - (R) The Nth arg position in argument context from the left.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValOptionLong::ExtractExpectedOptions( CMICmdArgContext & vrwTxt, const MIuint nArgIndex )
+bool
+CMICmdArgValOptionLong::ExtractExpectedOptions(CMICmdArgContext &vrwTxt, const MIuint nArgIndex)
{
- CMIUtilString::VecString_t vecOptions;
- MIuint nOptionsPresent = 0;
- if( (m_eExpectingOptionType != eArgValType_StringQuoted) &&
- (m_eExpectingOptionType != eArgValType_StringQuotedNumber) &&
- (m_eExpectingOptionType != eArgValType_StringQuotedNumberPath) )
- nOptionsPresent = vrwTxt.GetArgsLeftToParse().Split( " ", vecOptions );
- else
- nOptionsPresent = vrwTxt.GetArgsLeftToParse().SplitConsiderQuotes( " ", vecOptions );
- if( nOptionsPresent == 0 )
- return MIstatus::failure;
-
- MIuint nArgIndexCnt = 0;
- MIuint nTypeCnt = 0;
- MIuint nTypeCnt2 = 0;
- MIuint nFoundNOptionsCnt = 0;
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while( it != vecOptions.end() )
- {
- // Move to the Nth argument position from left before do validation/checking
- if( nArgIndexCnt++ == nArgIndex )
- {
- nTypeCnt++;
- const CMIUtilString & rOption( *it );
- if( IsExpectedCorrectType( rOption, m_eExpectingOptionType ) )
- {
- nTypeCnt2++;
- CMICmdArgValBase * pOptionObj = CreationObj( rOption, m_eExpectingOptionType );
- if( (pOptionObj != nullptr) && vrwTxt.RemoveArgAtPos( rOption, nArgIndex ) )
- {
- nFoundNOptionsCnt++;
- m_vecArgsExpected.push_back( pOptionObj );
- }
- }
-
- // Is the sequence 'options' of same type broken. Expecting the same type until the
- // next argument.
- if( nTypeCnt != nTypeCnt2 )
- return MIstatus::failure;
-
- if( nFoundNOptionsCnt == m_nExpectingNOptions )
- return MIstatus::success;
- }
-
- // Next
- ++it;
- }
- if( nFoundNOptionsCnt != m_nExpectingNOptions )
- return MIstatus::failure;
-
- return MIstatus::success;
+ CMIUtilString::VecString_t vecOptions;
+ MIuint nOptionsPresent = 0;
+ if ((m_eExpectingOptionType != eArgValType_StringQuoted) && (m_eExpectingOptionType != eArgValType_StringQuotedNumber) &&
+ (m_eExpectingOptionType != eArgValType_StringQuotedNumberPath))
+ nOptionsPresent = vrwTxt.GetArgsLeftToParse().Split(" ", vecOptions);
+ else
+ nOptionsPresent = vrwTxt.GetArgsLeftToParse().SplitConsiderQuotes(" ", vecOptions);
+ if (nOptionsPresent == 0)
+ return MIstatus::failure;
+
+ MIuint nArgIndexCnt = 0;
+ MIuint nTypeCnt = 0;
+ MIuint nTypeCnt2 = 0;
+ MIuint nFoundNOptionsCnt = 0;
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end())
+ {
+ // Move to the Nth argument position from left before do validation/checking
+ if (nArgIndexCnt++ == nArgIndex)
+ {
+ nTypeCnt++;
+ const CMIUtilString &rOption(*it);
+ if (IsExpectedCorrectType(rOption, m_eExpectingOptionType))
+ {
+ nTypeCnt2++;
+ CMICmdArgValBase *pOptionObj = CreationObj(rOption, m_eExpectingOptionType);
+ if ((pOptionObj != nullptr) && vrwTxt.RemoveArgAtPos(rOption, nArgIndex))
+ {
+ nFoundNOptionsCnt++;
+ m_vecArgsExpected.push_back(pOptionObj);
+ }
+ }
+
+ // Is the sequence 'options' of same type broken. Expecting the same type until the
+ // next argument.
+ if (nTypeCnt != nTypeCnt2)
+ return MIstatus::failure;
+
+ if (nFoundNOptionsCnt == m_nExpectingNOptions)
+ return MIstatus::success;
+ }
+
+ // Next
+ ++it;
+ }
+ if (nFoundNOptionsCnt != m_nExpectingNOptions)
+ return MIstatus::failure;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid long type option argument.
-// Long type argument looks like --someLongOption.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid long type option argument.
+// Long type argument looks like --someLongOption.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValOptionLong::IsArgLongOption( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValOptionLong::IsArgLongOption(const CMIUtilString &vrTxt) const
{
- const bool bHavePosSlash = (vrTxt.find_first_of( "/" ) != std::string::npos);
- const bool bHaveBckSlash = (vrTxt.find_first_of( "\\" ) != std::string::npos);
- if( bHavePosSlash || bHaveBckSlash )
- return false;
-
- const MIint nPos = vrTxt.find_first_of( "--" );
- if( nPos != 0 )
- return false;
-
- if( vrTxt.length() < 3 )
- return false;
-
- const CMIUtilString strArg = vrTxt.substr( 2 ).c_str();
- if( strArg.IsNumber() )
- return false;
-
- return true;
+ const bool bHavePosSlash = (vrTxt.find_first_of("/") != std::string::npos);
+ const bool bHaveBckSlash = (vrTxt.find_first_of("\\") != std::string::npos);
+ if (bHavePosSlash || bHaveBckSlash)
+ return false;
+
+ const MIint nPos = vrTxt.find_first_of("--");
+ if (nPos != 0)
+ return false;
+
+ if (vrTxt.length() < 3)
+ return false;
+
+ const CMIUtilString strArg = vrTxt.substr(2).c_str();
+ if (strArg.IsNumber())
+ return false;
+
+ return true;
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid long type option argument.
-// Long type argument looks like --someLongOption.
-// Type: Overideable.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid long type option argument.
+// Long type argument looks like --someLongOption.
+// Type: Overideable.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValOptionLong::IsArgOptionCorrect( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValOptionLong::IsArgOptionCorrect(const CMIUtilString &vrTxt) const
{
- return IsArgLongOption( vrTxt );
+ return IsArgLongOption(vrTxt);
}
//++ ------------------------------------------------------------------------------------
-// Details: Does the argument name of the argument being parsed ATM match the name of
-// *this argument object.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes arg name matched, false = no.
-// Throws: None.
+// Details: Does the argument name of the argument being parsed ATM match the name of
+// *this argument object.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes arg name matched, false = no.
+// Throws: None.
//--
-bool CMICmdArgValOptionLong::ArgNameMatch( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValOptionLong::ArgNameMatch(const CMIUtilString &vrTxt) const
{
- const CMIUtilString strArg = vrTxt.substr( 2 ).c_str();
- return (strArg == GetName() );
+ const CMIUtilString strArg = vrTxt.substr(2).c_str();
+ return (strArg == GetName());
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the list of CMICmdArgValBase derived option objects found following
-// *this long option argument. For example "list-thread-groups [ --recurse 1 ]"
-// where 1 is the list of expected option to follow.
-// Type: Method.
-// Args: None.
-// Return: CMICmdArgValListBase::VecArgObjPtr_t & - List of options.
-// Throws: None.
+// Details: Retrieve the list of CMICmdArgValBase derived option objects found following
+// *this long option argument. For example "list-thread-groups [ --recurse 1 ]"
+// where 1 is the list of expected option to follow.
+// Type: Method.
+// Args: None.
+// Return: CMICmdArgValListBase::VecArgObjPtr_t & - List of options.
+// Throws: None.
//--
-const CMICmdArgValListBase::VecArgObjPtr_t & CMICmdArgValOptionLong::GetExpectedOptions( void ) const
+const CMICmdArgValListBase::VecArgObjPtr_t &
+CMICmdArgValOptionLong::GetExpectedOptions(void) const
{
- return m_vecArgsExpected;
+ return m_vecArgsExpected;
}
-
diff --git a/tools/lldb-mi/MICmdArgValOptionLong.h b/tools/lldb-mi/MICmdArgValOptionLong.h
index 3baae416c93a..8ff92bf84369 100644
--- a/tools/lldb-mi/MICmdArgValOptionLong.h
+++ b/tools/lldb-mi/MICmdArgValOptionLong.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValOptionLong.h
+// File: MICmdArgValOptionLong.h
//
-// Overview: CMICmdArgValOptionLong interface.
+// Overview: CMICmdArgValOptionLong interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -29,81 +29,82 @@ class CMICmdArgContext;
class CMIUtilString;
//++ ============================================================================
-// Details: MI common code class. Command argument class. Arguments object
-// needing specialization derived from the CMICmdArgValBase class.
-// An argument knows what type of argument it is and how it is to
-// interpret the options (context) string to find and validate a matching
-// argument and so extract a value from it.
-// If *this argument has expected options following it the option objects
-// created to hold each of those option's values belong to *this argument
-// object and so are deleted when *this object goes out of scope.
-// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 16/04/2014.
-// Changes: None.
+// Details: MI common code class. Command argument class. Arguments object
+// needing specialization derived from the CMICmdArgValBase class.
+// An argument knows what type of argument it is and how it is to
+// interpret the options (context) string to find and validate a matching
+// argument and so extract a value from it.
+// If *this argument has expected options following it the option objects
+// created to hold each of those option's values belong to *this argument
+// object and so are deleted when *this object goes out of scope.
+// Based on the Interpreter pattern.
+// Gotchas: None.
+// Authors: Illya Rudkin 16/04/2014.
+// Changes: None.
//--
class CMICmdArgValOptionLong : public CMICmdArgValListBase
{
-// Methods:
-public:
- /* ctor */ CMICmdArgValOptionLong( void );
- /* ctor */ CMICmdArgValOptionLong( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd );
- /* ctor */ CMICmdArgValOptionLong( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const ArgValType_e veType, const MIuint vnExpectingNOptions );
- //
- bool IsArgLongOption( const CMIUtilString & vrTxt ) const;
- const VecArgObjPtr_t & GetExpectedOptions( void ) const;
- template< class T1, typename T2 >
- bool GetExpectedOption( T2 & vrwValue ) const;
-
-// Overridden:
-public:
- // From CMICmdArgValBase
- /* dtor */ virtual ~CMICmdArgValOptionLong( void );
- // From CMICmdArgSet::IArg
- virtual bool Validate( CMICmdArgContext & vArgContext );
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgValOptionLong(void);
+ /* ctor */ CMICmdArgValOptionLong(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
+ /* ctor */ CMICmdArgValOptionLong(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+ const ArgValType_e veType, const MIuint vnExpectingNOptions);
+ //
+ bool IsArgLongOption(const CMIUtilString &vrTxt) const;
+ const VecArgObjPtr_t &GetExpectedOptions(void) const;
+ template <class T1, typename T2> bool GetExpectedOption(T2 &vrwValue) const;
-// Methods:
-protected:
- bool ExtractExpectedOptions( CMICmdArgContext & vrwTxt, const MIuint nArgIndex );
+ // Overridden:
+ public:
+ // From CMICmdArgValBase
+ /* dtor */ virtual ~CMICmdArgValOptionLong(void);
+ // From CMICmdArgSet::IArg
+ virtual bool Validate(CMICmdArgContext &vArgContext);
-// Overrideable:
-protected:
- virtual bool IsArgOptionCorrect( const CMIUtilString & vrTxt ) const;
- virtual bool ArgNameMatch( const CMIUtilString & vrTxt ) const;
+ // Methods:
+ protected:
+ bool ExtractExpectedOptions(CMICmdArgContext &vrwTxt, const MIuint nArgIndex);
-// Methods:
-private:
- void Destroy( void );
+ // Overrideable:
+ protected:
+ virtual bool IsArgOptionCorrect(const CMIUtilString &vrTxt) const;
+ virtual bool ArgNameMatch(const CMIUtilString &vrTxt) const;
-// Attributes:
-private:
- MIuint m_nExpectingNOptions; // The number of options expected to read following *this argument
- VecArgObjPtr_t m_vecArgsExpected; // The option objects holding the value extracted following *this argument
- ArgValType_e m_eExpectingOptionType; // The type of options expected to read following *this argument
+ // Methods:
+ private:
+ void Destroy(void);
+
+ // Attributes:
+ private:
+ MIuint m_nExpectingNOptions; // The number of options expected to read following *this argument
+ VecArgObjPtr_t m_vecArgsExpected; // The option objects holding the value extracted following *this argument
+ ArgValType_e m_eExpectingOptionType; // The type of options expected to read following *this argument
};
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the first argument or option value from the list of 1 or more options
-// parsed from the command's options string.
-// Type: Template method.
-// Args: vrwValue - (W) Templated type return value.
-// T1 - The argument value's class type of the data hold in the list of options.
-// T2 - The type pf the variable which holds the value wanted.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed. List of object was empty.
-// Throws: None.
+// Details: Retrieve the first argument or option value from the list of 1 or more options
+// parsed from the command's options string.
+// Type: Template method.
+// Args: vrwValue - (W) Templated type return value.
+// T1 - The argument value's class type of the data hold in the list of options.
+// T2 - The type pf the variable which holds the value wanted.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed. List of object was empty.
+// Throws: None.
//--
-template< class T1, typename T2 >
-bool CMICmdArgValOptionLong::GetExpectedOption( T2 & vrwValue ) const
+template <class T1, typename T2>
+bool
+CMICmdArgValOptionLong::GetExpectedOption(T2 &vrwValue) const
{
- const VecArgObjPtr_t & rVecOptions( GetExpectedOptions() );
- VecArgObjPtr_t::const_iterator it2 = rVecOptions.begin();
- if( it2 != rVecOptions.end() )
- {
- const T1 * pOption = static_cast< T1 * >( *it2 );
- vrwValue = pOption->GetValue();
- return MIstatus::success;
- }
+ const VecArgObjPtr_t &rVecOptions(GetExpectedOptions());
+ VecArgObjPtr_t::const_iterator it2 = rVecOptions.begin();
+ if (it2 != rVecOptions.end())
+ {
+ const T1 *pOption = static_cast<T1 *>(*it2);
+ vrwValue = pOption->GetValue();
+ return MIstatus::success;
+ }
- return MIstatus::failure;
+ return MIstatus::failure;
}
diff --git a/tools/lldb-mi/MICmdArgValOptionShort.cpp b/tools/lldb-mi/MICmdArgValOptionShort.cpp
index 76adb7f11493..5a2b491d3c72 100644
--- a/tools/lldb-mi/MICmdArgValOptionShort.cpp
+++ b/tools/lldb-mi/MICmdArgValOptionShort.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValOptionShort.cpp
+// File: MICmdArgValOptionShort.cpp
//
-// Overview: CMICmdArgValOptionShort implementation.
+// Overview: CMICmdArgValOptionShort implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -24,105 +24,109 @@
#include "MICmdArgContext.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValOptionShort constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValOptionShort constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValOptionShort::CMICmdArgValOptionShort( void )
+CMICmdArgValOptionShort::CMICmdArgValOptionShort(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValOptionShort constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValOptionShort constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValOptionShort::CMICmdArgValOptionShort( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd )
-: CMICmdArgValOptionLong( vrArgName, vbMandatory, vbHandleByCmd )
+CMICmdArgValOptionShort::CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
+ : CMICmdArgValOptionLong(vrArgName, vbMandatory, vbHandleByCmd)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValOptionLong constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// veType - (R) The type of argument to look for and create argument object of a certain type.
-// vnExpectingNOptions - (R) The number of options expected to read following *this argument.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValOptionLong constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// veType - (R) The type of argument to look for and create argument object of a certain type.
+// vnExpectingNOptions - (R) The number of options expected to read following *this argument.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValOptionShort::CMICmdArgValOptionShort( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const ArgValType_e veType, const MIuint vnExpectingNOptions )
-: CMICmdArgValOptionLong( vrArgName, vbMandatory, vbHandleByCmd, veType, vnExpectingNOptions )
+CMICmdArgValOptionShort::CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+ const ArgValType_e veType, const MIuint vnExpectingNOptions)
+ : CMICmdArgValOptionLong(vrArgName, vbMandatory, vbHandleByCmd, veType, vnExpectingNOptions)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValOptionShort destructor.
-// Type: Overridden.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValOptionShort destructor.
+// Type: Overridden.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValOptionShort::~CMICmdArgValOptionShort( void )
+CMICmdArgValOptionShort::~CMICmdArgValOptionShort(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid short type option argument.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid short type option argument.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValOptionShort::IsArgShortOption( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValOptionShort::IsArgShortOption(const CMIUtilString &vrTxt) const
{
- // Look for --someLongOption
- MIint nPos = vrTxt.find( "--" );
- if( nPos == 0 )
- return false;
-
- // Look for -f short option
- nPos = vrTxt.find( "-" );
- if( nPos != 0 )
- return false;
-
- if( vrTxt.length() > 2 )
- return false;
+ // Look for --someLongOption
+ MIint nPos = vrTxt.find("--");
+ if (nPos == 0)
+ return false;
- return true;
+ // Look for -f short option
+ nPos = vrTxt.find("-");
+ if (nPos != 0)
+ return false;
+
+ if (vrTxt.length() > 2)
+ return false;
+
+ return true;
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid short type option argument.
-// Long type argument looks like -f some short option.
-// Type: Overridden.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid short type option argument.
+// Long type argument looks like -f some short option.
+// Type: Overridden.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValOptionShort::IsArgOptionCorrect( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValOptionShort::IsArgOptionCorrect(const CMIUtilString &vrTxt) const
{
- return IsArgShortOption( vrTxt );
+ return IsArgShortOption(vrTxt);
}
//++ ------------------------------------------------------------------------------------
-// Details: Does the argument name of the argument being parsed ATM match the name of
-// *this argument object.
-// Type: Overridden.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes arg name matched, false = no.
-// Throws: None.
+// Details: Does the argument name of the argument being parsed ATM match the name of
+// *this argument object.
+// Type: Overridden.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes arg name matched, false = no.
+// Throws: None.
//--
-bool CMICmdArgValOptionShort::ArgNameMatch( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValOptionShort::ArgNameMatch(const CMIUtilString &vrTxt) const
{
- const CMIUtilString strArg = vrTxt.substr( 1 ).c_str();
- return (strArg == GetName() );
+ const CMIUtilString strArg = vrTxt.substr(1).c_str();
+ return (strArg == GetName());
}
diff --git a/tools/lldb-mi/MICmdArgValOptionShort.h b/tools/lldb-mi/MICmdArgValOptionShort.h
index 7af038377123..3bd38ac72d20 100644
--- a/tools/lldb-mi/MICmdArgValOptionShort.h
+++ b/tools/lldb-mi/MICmdArgValOptionShort.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValOptionShort.h
+// File: MICmdArgValOptionShort.h
//
-// Overview: CMICmdArgValOptionShort interface.
+// Overview: CMICmdArgValOptionShort interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -29,37 +29,38 @@ class CMICmdArgContext;
class CMIUtilString;
//++ ============================================================================
-// Details: MI common code class. Command argument class. Arguments object
-// needing specialization derived from the CMICmdArgValOptionLong class.
-// An argument knows what type of argument it is and how it is to
-// interpret the options (context) string to find and validate a matching
-// argument and so extract a value from it.
-// If *this argument has expected options following it the option objects
-// created to hold each of those option's values belong to *this argument
-// object and so are deleted when *this object goes out of scope.
-// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 16/04/2014.
-// Changes: None.
+// Details: MI common code class. Command argument class. Arguments object
+// needing specialization derived from the CMICmdArgValOptionLong class.
+// An argument knows what type of argument it is and how it is to
+// interpret the options (context) string to find and validate a matching
+// argument and so extract a value from it.
+// If *this argument has expected options following it the option objects
+// created to hold each of those option's values belong to *this argument
+// object and so are deleted when *this object goes out of scope.
+// Based on the Interpreter pattern.
+// Gotchas: None.
+// Authors: Illya Rudkin 16/04/2014.
+// Changes: None.
//--
class CMICmdArgValOptionShort : public CMICmdArgValOptionLong
{
-// Methods:
-public:
- /* ctor */ CMICmdArgValOptionShort( void );
- /* ctor */ CMICmdArgValOptionShort( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd );
- /* ctor */ CMICmdArgValOptionShort( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const ArgValType_e veType, const MIuint vnExpectingNOptions );
- //
- bool IsArgShortOption( const CMIUtilString & vrTxt ) const;
-
-// Overridden:
-public:
- // From CMICmdArgValBase
- /* dtor */ virtual ~CMICmdArgValOptionShort( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgValOptionShort(void);
+ /* ctor */ CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
+ /* ctor */ CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+ const ArgValType_e veType, const MIuint vnExpectingNOptions);
+ //
+ bool IsArgShortOption(const CMIUtilString &vrTxt) const;
-// Overridden:
-private:
- // From CMICmdArgValOptionLong
- virtual bool IsArgOptionCorrect( const CMIUtilString & vrTxt ) const;
- virtual bool ArgNameMatch( const CMIUtilString & vrTxt ) const;
+ // Overridden:
+ public:
+ // From CMICmdArgValBase
+ /* dtor */ virtual ~CMICmdArgValOptionShort(void);
+
+ // Overridden:
+ private:
+ // From CMICmdArgValOptionLong
+ virtual bool IsArgOptionCorrect(const CMIUtilString &vrTxt) const;
+ virtual bool ArgNameMatch(const CMIUtilString &vrTxt) const;
};
diff --git a/tools/lldb-mi/MICmdArgValString.cpp b/tools/lldb-mi/MICmdArgValString.cpp
index 06818b1dc571..c09eead072d1 100644
--- a/tools/lldb-mi/MICmdArgValString.cpp
+++ b/tools/lldb-mi/MICmdArgValString.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValString.cpp
+// File: MICmdArgValString.cpp
//
-// Overview: CMICmdArgValString implementation.
+// Overview: CMICmdArgValString implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -24,479 +24,492 @@
#include "MICmdArgContext.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValString constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValString constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValString::CMICmdArgValString( void )
-: m_bHandleQuotedString( false )
-, m_bAcceptNumbers( false )
-, m_bHandleDirPaths( false )
-, m_bHandleAnything( false )
+CMICmdArgValString::CMICmdArgValString(void)
+ : m_bHandleQuotedString(false)
+ , m_bAcceptNumbers(false)
+ , m_bHandleDirPaths(false)
+ , m_bHandleAnything(false)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValString constructor.
-// Type: Method.
-// Args: vbAnything - (R) True = Parse a string and accept anything, false = do not accept anything.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValString constructor.
+// Type: Method.
+// Args: vbAnything - (R) True = Parse a string and accept anything, false = do not accept anything.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValString::CMICmdArgValString( const bool vbAnything )
-: m_bHandleQuotedString( false )
-, m_bAcceptNumbers( false )
-, m_bHandleDirPaths( false )
-, m_bHandleAnything( vbAnything )
+CMICmdArgValString::CMICmdArgValString(const bool vbAnything)
+ : m_bHandleQuotedString(false)
+ , m_bAcceptNumbers(false)
+ , m_bHandleDirPaths(false)
+ , m_bHandleAnything(vbAnything)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValString constructor.
-// Type: Method.
-// Args: vbHandleQuotes - (R) True = Parse a string surrounded by quotes spaces are not delimitors, false = only text up to next delimiting space character.
-// vbAcceptNumbers - (R) True = Parse a string and accept as a number if number, false = numbers not recognised as string types.
-// vbHandleDirPaths - (R) True = Parse a string and accept as a file path if a path, false = file paths are not recognised as string types.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValString constructor.
+// Type: Method.
+// Args: vbHandleQuotes - (R) True = Parse a string surrounded by quotes spaces are not delimitors, false = only text up to
+// next delimiting space character.
+// vbAcceptNumbers - (R) True = Parse a string and accept as a number if number, false = numbers not recognised
+// as string types.
+// vbHandleDirPaths - (R) True = Parse a string and accept as a file path if a path, false = file paths are not
+// recognised as string types.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValString::CMICmdArgValString( const bool vbHandleQuotes, const bool vbAcceptNumbers, const bool vbHandleDirPaths )
-: m_bHandleQuotedString( vbHandleQuotes )
-, m_bAcceptNumbers( vbAcceptNumbers )
-, m_bHandleDirPaths( vbHandleDirPaths )
-, m_bHandleAnything( false )
+CMICmdArgValString::CMICmdArgValString(const bool vbHandleQuotes, const bool vbAcceptNumbers, const bool vbHandleDirPaths)
+ : m_bHandleQuotedString(vbHandleQuotes)
+ , m_bAcceptNumbers(vbAcceptNumbers)
+ , m_bHandleDirPaths(vbHandleDirPaths)
+ , m_bHandleAnything(false)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValString constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// vbHandleQuotes - (R) True = Parse a string surrounded by quotes spaces are not delimitors, false = only text up to next delimiting space character. (Dflt = false)
-// vbAcceptNumbers - (R) True = Parse a string and accept as a number if number, false = numbers not recognised as string types. (Dflt = false)
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValString constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// vbHandleQuotes - (R) True = Parse a string surrounded by quotes spaces are not delimitors, false = only text up to
+// next delimiting space character. (Dflt = false)
+// vbAcceptNumbers - (R) True = Parse a string and accept as a number if number, false = numbers not recognised as
+// string types. (Dflt = false)
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValString::CMICmdArgValString( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const bool vbHandleQuotes /* = false */, const bool vbAcceptNumbers /* = false */ )
-: CMICmdArgValBaseTemplate( vrArgName, vbMandatory, vbHandleByCmd )
-, m_bHandleQuotedString( vbHandleQuotes )
-, m_bAcceptNumbers( vbAcceptNumbers )
-, m_bHandleDirPaths( false )
-, m_bHandleAnything( false )
+CMICmdArgValString::CMICmdArgValString(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+ const bool vbHandleQuotes /* = false */, const bool vbAcceptNumbers /* = false */)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
+ , m_bHandleQuotedString(vbHandleQuotes)
+ , m_bAcceptNumbers(vbAcceptNumbers)
+ , m_bHandleDirPaths(false)
+ , m_bHandleAnything(false)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValString destructor.
-// Type: Overridden.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValString destructor.
+// Type: Overridden.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValString::~CMICmdArgValString( void )
+CMICmdArgValString::~CMICmdArgValString(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
-// argument is looking for.
-// Type: Overridden.
-// Args: vrwArgContext - (RW) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract the value *this
+// argument is looking for.
+// Type: Overridden.
+// Args: vrwArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValString::Validate( CMICmdArgContext & vrwArgContext )
+bool
+CMICmdArgValString::Validate(CMICmdArgContext &vrwArgContext)
{
- if( vrwArgContext.IsEmpty() )
- return MIstatus::success;
+ if (vrwArgContext.IsEmpty())
+ return MIstatus::success;
- if( m_bHandleQuotedString )
- return (ValidateQuotedText( vrwArgContext ) || ValidateQuotedTextEmbedded( vrwArgContext ) );
+ if (m_bHandleQuotedString)
+ return (ValidateQuotedText(vrwArgContext) || ValidateQuotedTextEmbedded(vrwArgContext));
- return ValidateSingleText( vrwArgContext );
+ return ValidateSingleText(vrwArgContext);
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract only the next
-// word delimited by the next space.
-// Type: Method.
-// Args: vrwArgContext - (RW) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract only the next
+// word delimited by the next space.
+// Type: Method.
+// Args: vrwArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValString::ValidateSingleText( CMICmdArgContext & vrwArgContext )
+bool
+CMICmdArgValString::ValidateSingleText(CMICmdArgContext &vrwArgContext)
{
- if( vrwArgContext.GetNumberArgsPresent() == 1 )
- {
- const CMIUtilString & rArg( vrwArgContext.GetArgsLeftToParse() );
- if( IsStringArg( rArg ) )
- {
- m_bFound = true;
- m_bValid = true;
- m_argValue = rArg;
- vrwArgContext.RemoveArg( rArg );
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
- }
-
- // More than one option...
- const CMIUtilString::VecString_t vecOptions( vrwArgContext.GetArgs() );
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while( it != vecOptions.end() )
- {
- const CMIUtilString & rArg( *it );
- if( IsStringArg( rArg ) )
- {
- m_bFound = true;
-
- if( vrwArgContext.RemoveArg( rArg ) )
- {
- m_bValid = true;
- m_argValue = rArg;
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
- }
-
- // Next
- ++it;
- }
-
- return MIstatus::failure;
+ if (vrwArgContext.GetNumberArgsPresent() == 1)
+ {
+ const CMIUtilString &rArg(vrwArgContext.GetArgsLeftToParse());
+ if (IsStringArg(rArg))
+ {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = rArg;
+ vrwArgContext.RemoveArg(rArg);
+ return MIstatus::success;
+ }
+ else
+ return MIstatus::failure;
+ }
+
+ // More than one option...
+ const CMIUtilString::VecString_t vecOptions(vrwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end())
+ {
+ const CMIUtilString &rArg(*it);
+ if (IsStringArg(rArg))
+ {
+ m_bFound = true;
+
+ if (vrwArgContext.RemoveArg(rArg))
+ {
+ m_bValid = true;
+ m_argValue = rArg;
+ return MIstatus::success;
+ }
+ else
+ return MIstatus::failure;
+ }
+
+ // Next
+ ++it;
+ }
+
+ return MIstatus::failure;
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract all the words
-// between quotes then delimited by the next space. Can fall through to
-// ValidateSingleText() or ValidateQuotedQuotedTextEmbedded().
-// Type: Method.
-// Args: vrwArgContext - (RW) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract all the words
+// between quotes then delimited by the next space. Can fall through to
+// ValidateSingleText() or ValidateQuotedQuotedTextEmbedded().
+// Type: Method.
+// Args: vrwArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValString::ValidateQuotedText( CMICmdArgContext & vrwArgContext )
+bool
+CMICmdArgValString::ValidateQuotedText(CMICmdArgContext &vrwArgContext)
{
- // CODETAG_QUOTEDTEXT_SIMILAR_CODE
- CMIUtilString strOptions = vrwArgContext.GetArgsLeftToParse();
- const MIchar cQuote = '"';
-
- // Look for first quote of two
- MIint nPos = strOptions.find( cQuote );
- if( nPos == (MIint) std::string::npos )
- return ValidateSingleText( vrwArgContext );
-
- // Is one and only quote at end of the string
- const MIint nLen = strOptions.length();
- if( nPos == (MIint)(nLen - 1) )
- return MIstatus::failure;
-
- // Quote must be the first character in the string or be preceeded by a space
- if( (nPos > 0) && (strOptions[ nPos - 1 ] != ' ') )
- return MIstatus::failure;
-
- // Need to find the other quote
- const MIint nPos2 = strOptions.rfind( cQuote );
- if( nPos2 == (MIint) std::string::npos )
- return MIstatus::failure;
-
- // Is there quotes surrounding string formatting embedded quotes
- if( IsStringArgQuotedQuotedTextEmbedded( strOptions ) )
- return ValidateQuotedQuotedTextEmbedded( vrwArgContext );
-
- // Make sure not same back quote, need two quotes
- if( nPos == nPos2 )
- return MIstatus::failure;
-
- // Extract quoted text
- const CMIUtilString strQuotedTxt = strOptions.substr( nPos, nPos2 - nPos + 1 ).c_str();
- if( vrwArgContext.RemoveArg( strQuotedTxt ) )
- {
- m_bFound = true;
- m_bValid = true;
- m_argValue = strOptions.substr( nPos + 1, nPos2 - nPos - 1 ).c_str();
- return MIstatus::success;
- }
-
- return MIstatus::failure;
+ // CODETAG_QUOTEDTEXT_SIMILAR_CODE
+ CMIUtilString strOptions = vrwArgContext.GetArgsLeftToParse();
+ const MIchar cQuote = '"';
+
+ // Look for first quote of two
+ MIint nPos = strOptions.find(cQuote);
+ if (nPos == (MIint)std::string::npos)
+ return ValidateSingleText(vrwArgContext);
+
+ // Is one and only quote at end of the string
+ const MIint nLen = strOptions.length();
+ if (nPos == (MIint)(nLen - 1))
+ return MIstatus::failure;
+
+ // Quote must be the first character in the string or be preceeded by a space
+ if ((nPos > 0) && (strOptions[nPos - 1] != ' '))
+ return MIstatus::failure;
+
+ // Need to find the other quote
+ const MIint nPos2 = strOptions.rfind(cQuote);
+ if (nPos2 == (MIint)std::string::npos)
+ return MIstatus::failure;
+
+ // Is there quotes surrounding string formatting embedded quotes
+ if (IsStringArgQuotedQuotedTextEmbedded(strOptions))
+ return ValidateQuotedQuotedTextEmbedded(vrwArgContext);
+
+ // Make sure not same back quote, need two quotes
+ if (nPos == nPos2)
+ return MIstatus::failure;
+
+ // Extract quoted text
+ const CMIUtilString strQuotedTxt = strOptions.substr(nPos, nPos2 - nPos + 1).c_str();
+ if (vrwArgContext.RemoveArg(strQuotedTxt))
+ {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = strOptions.substr(nPos + 1, nPos2 - nPos - 1).c_str();
+ return MIstatus::success;
+ }
+
+ return MIstatus::failure;
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract all the words
-// between quotes then delimited by the next space. If there any string format
-// characters '\\' used to embed quotes these are ignored i.e. "\\\"%5d\\\""
-// becomes "%5d". Can fall through to ValidateQuotedText().
-// Type: Method.
-// Args: vrwArgContext - (RW) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract all the words
+// between quotes then delimited by the next space. If there any string format
+// characters '\\' used to embed quotes these are ignored i.e. "\\\"%5d\\\""
+// becomes "%5d". Can fall through to ValidateQuotedText().
+// Type: Method.
+// Args: vrwArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValString::ValidateQuotedTextEmbedded( CMICmdArgContext & vrwArgContext )
+bool
+CMICmdArgValString::ValidateQuotedTextEmbedded(CMICmdArgContext &vrwArgContext)
{
- // CODETAG_QUOTEDTEXT_SIMILAR_CODE
- CMIUtilString strOptions = vrwArgContext.GetArgsLeftToParse();
- const MIchar cBckSlash = '\\';
- const MIint nPos = strOptions.find( cBckSlash );
- if( nPos == (MIint) std::string::npos )
- return ValidateQuotedText( vrwArgContext );
-
- // Back slash must be the first character in the string or be preceeded by a space
- // or '\\'
- const MIchar cSpace = ' ';
- if( (nPos > 0) && (strOptions[ nPos - 1 ] != cSpace) )
- return MIstatus::failure;
-
- // Need to find the other back slash
- const MIint nPos2 = strOptions.rfind( cBckSlash );
- if( nPos2 == (MIint) std::string::npos )
- return MIstatus::failure;
-
- // Make sure not same back slash, need two slashs
- if( nPos == nPos2 )
- return MIstatus::failure;
-
- // Look for the two quotes
- const MIint nLen = strOptions.length();
- const MIchar cQuote = '"';
- const MIint nPosQuote1 = nPos + 1;
- const MIint nPosQuote2 = (nPos2 < nLen) ? nPos2 + 1 : nPos2;
- if( (nPosQuote1 != nPosQuote2) &&
- (strOptions[ nPosQuote1 ] != cQuote) && (strOptions[ nPosQuote2 ] != cQuote) )
- return MIstatus::failure;
-
- // Extract quoted text
- const CMIUtilString strQuotedTxt = strOptions.substr( nPos, nPosQuote2 - nPos + 1 ).c_str();
- if( vrwArgContext.RemoveArg( strQuotedTxt ) )
- {
- m_bFound = true;
- m_bValid = true;
- m_argValue = strQuotedTxt;
- return MIstatus::success;
- }
-
- return MIstatus::failure;
+ // CODETAG_QUOTEDTEXT_SIMILAR_CODE
+ CMIUtilString strOptions = vrwArgContext.GetArgsLeftToParse();
+ const MIchar cBckSlash = '\\';
+ const MIint nPos = strOptions.find(cBckSlash);
+ if (nPos == (MIint)std::string::npos)
+ return ValidateQuotedText(vrwArgContext);
+
+ // Back slash must be the first character in the string or be preceeded by a space
+ // or '\\'
+ const MIchar cSpace = ' ';
+ if ((nPos > 0) && (strOptions[nPos - 1] != cSpace))
+ return MIstatus::failure;
+
+ // Need to find the other back slash
+ const MIint nPos2 = strOptions.rfind(cBckSlash);
+ if (nPos2 == (MIint)std::string::npos)
+ return MIstatus::failure;
+
+ // Make sure not same back slash, need two slashs
+ if (nPos == nPos2)
+ return MIstatus::failure;
+
+ // Look for the two quotes
+ const MIint nLen = strOptions.length();
+ const MIchar cQuote = '"';
+ const MIint nPosQuote1 = nPos + 1;
+ const MIint nPosQuote2 = (nPos2 < nLen) ? nPos2 + 1 : nPos2;
+ if ((nPosQuote1 != nPosQuote2) && (strOptions[nPosQuote1] != cQuote) && (strOptions[nPosQuote2] != cQuote))
+ return MIstatus::failure;
+
+ // Extract quoted text
+ const CMIUtilString strQuotedTxt = strOptions.substr(nPos, nPosQuote2 - nPos + 1).c_str();
+ if (vrwArgContext.RemoveArg(strQuotedTxt))
+ {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = strQuotedTxt;
+ return MIstatus::success;
+ }
+
+ return MIstatus::failure;
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract all the words
-// between quotes then delimited by the next space. If there any string format
-// characters '\\' used to embed quotes these are ignored i.e. "\\\"%5d\\\""
-// becomes "%5d".
-// Type: Method.
-// Args: vrwArgContext - (RW) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract all the words
+// between quotes then delimited by the next space. If there any string format
+// characters '\\' used to embed quotes these are ignored i.e. "\\\"%5d\\\""
+// becomes "%5d".
+// Type: Method.
+// Args: vrwArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValString::ValidateQuotedQuotedTextEmbedded( CMICmdArgContext & vrwArgContext )
+bool
+CMICmdArgValString::ValidateQuotedQuotedTextEmbedded(CMICmdArgContext &vrwArgContext)
{
- // CODETAG_QUOTEDTEXT_SIMILAR_CODE
- CMIUtilString strOptions = vrwArgContext.GetArgsLeftToParse();
- const MIint nPos = strOptions.find( "\"\\\"" );
- if( nPos == (MIint) std::string::npos )
- return MIstatus::failure;
-
- const MIint nPos2 = strOptions.rfind( "\\\"\"" );
- if( nPos2 == (MIint) std::string::npos )
- return MIstatus::failure;
-
- const MIint nLen = strOptions.length();
- if( (nLen > 5) && ((nPos + 2) == (nPos2 - 2)) )
- return MIstatus::failure;
-
- // Quote must be the first character in the string or be preceeded by a space
- // or '\\'
- const MIchar cSpace = ' ';
- if( (nPos > 0) && (strOptions[ nPos - 1 ] != cSpace) )
- return MIstatus::failure;
-
- // Extract quoted text
- const CMIUtilString strQuotedTxt = strOptions.substr( nPos, nPos2 - nPos + 3 ).c_str();
- if( vrwArgContext.RemoveArg( strQuotedTxt ) )
- {
- m_bFound = true;
- m_bValid = true;
- m_argValue = strQuotedTxt;
- return MIstatus::success;
- }
-
- return MIstatus::failure;
+ // CODETAG_QUOTEDTEXT_SIMILAR_CODE
+ CMIUtilString strOptions = vrwArgContext.GetArgsLeftToParse();
+ const MIint nPos = strOptions.find("\"\\\"");
+ if (nPos == (MIint)std::string::npos)
+ return MIstatus::failure;
+
+ const MIint nPos2 = strOptions.rfind("\\\"\"");
+ if (nPos2 == (MIint)std::string::npos)
+ return MIstatus::failure;
+
+ const MIint nLen = strOptions.length();
+ if ((nLen > 5) && ((nPos + 2) == (nPos2 - 2)))
+ return MIstatus::failure;
+
+ // Quote must be the first character in the string or be preceeded by a space
+ // or '\\'
+ const MIchar cSpace = ' ';
+ if ((nPos > 0) && (strOptions[nPos - 1] != cSpace))
+ return MIstatus::failure;
+
+ // Extract quoted text
+ const CMIUtilString strQuotedTxt = strOptions.substr(nPos, nPos2 - nPos + 3).c_str();
+ if (vrwArgContext.RemoveArg(strQuotedTxt))
+ {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = strQuotedTxt;
+ return MIstatus::success;
+ }
+
+ return MIstatus::failure;
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid string type argument.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValString::IsStringArg( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValString::IsStringArg(const CMIUtilString &vrTxt) const
{
- if( m_bHandleQuotedString )
- return (IsStringArgQuotedText( vrTxt ) ||
- IsStringArgQuotedTextEmbedded( vrTxt ) ||
- IsStringArgQuotedQuotedTextEmbedded( vrTxt ) ||
- IsStringArgSingleText( vrTxt ) ); // Still test for this as could just be one word still
-
- return IsStringArgSingleText( vrTxt );
+ if (m_bHandleQuotedString)
+ return (IsStringArgQuotedText(vrTxt) || IsStringArgQuotedTextEmbedded(vrTxt) || IsStringArgQuotedQuotedTextEmbedded(vrTxt) ||
+ IsStringArgSingleText(vrTxt)); // Still test for this as could just be one word still
+
+ return IsStringArgSingleText(vrTxt);
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument or
-// option value. If the string looks like a long option, short option, a thread
-// group ID or just a number it is rejected as a string type value. There is an
-// option to allow the string to accept a number as a string type.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid argument value, false = something else.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid string type argument or
+// option value. If the string looks like a long option, short option, a thread
+// group ID or just a number it is rejected as a string type value. There is an
+// option to allow the string to accept a number as a string type.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid argument value, false = something else.
+// Throws: None.
//--
-bool CMICmdArgValString::IsStringArgSingleText( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValString::IsStringArgSingleText(const CMIUtilString &vrTxt) const
{
- // Accept anything as string word
- if( m_bHandleAnything )
- return true;
-
- if( !m_bHandleDirPaths )
- {
- // Look for directory file paths, if found reject
- const bool bHavePosSlash = (vrTxt.find_first_of( "/" ) != std::string::npos);
- const bool bHaveBckSlash = (vrTxt.find_first_of( "\\" ) != std::string::npos);
- if( bHavePosSlash || bHaveBckSlash )
- return false;
- }
-
- // Look for --someLongOption, if found reject
- if( 0 == vrTxt.find( "--" ) )
- return false;
-
- // Look for -f type short options, if found reject
- if( (0 == vrTxt.find( "-" )) && (vrTxt.length() == 2) )
- return false;
-
- // Look for thread group i1 i2 i3...., if found reject
- if( (vrTxt.find( "i" ) == 0) && ::isdigit( vrTxt[ 1 ]) )
- return false;
-
- // Look for numbers, if found reject
- if( !m_bAcceptNumbers && vrTxt.IsNumber() )
- return false;
-
- return true;
+ // Accept anything as string word
+ if (m_bHandleAnything)
+ return true;
+
+ if (!m_bHandleDirPaths)
+ {
+ // Look for directory file paths, if found reject
+ const bool bHavePosSlash = (vrTxt.find_first_of("/") != std::string::npos);
+ const bool bHaveBckSlash = (vrTxt.find_first_of("\\") != std::string::npos);
+ if (bHavePosSlash || bHaveBckSlash)
+ return false;
+ }
+
+ // Look for --someLongOption, if found reject
+ if (0 == vrTxt.find("--"))
+ return false;
+
+ // Look for -f type short options, if found reject
+ if ((0 == vrTxt.find("-")) && (vrTxt.length() == 2))
+ return false;
+
+ // Look for thread group i1 i2 i3...., if found reject
+ if ((vrTxt.find("i") == 0) && ::isdigit(vrTxt[1]))
+ return false;
+
+ // Look for numbers, if found reject
+ if (!m_bAcceptNumbers && vrTxt.IsNumber())
+ return false;
+
+ return true;
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
-// Take into account quotes surrounding the text. Note this function falls
-// through to IsStringArgSingleText() should the criteria match fail.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid string type argument.
+// Take into account quotes surrounding the text. Note this function falls
+// through to IsStringArgSingleText() should the criteria match fail.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValString::IsStringArgQuotedText( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValString::IsStringArgQuotedText(const CMIUtilString &vrTxt) const
{
- // CODETAG_QUOTEDTEXT_SIMILAR_CODE
- const MIchar cQuote = '"';
- const MIint nPos = vrTxt.find( cQuote );
- if( nPos == (MIint) std::string::npos )
- return false;
-
- // Is one and only quote at end of the string
- if( nPos == (MIint)(vrTxt.length() - 1) )
- return false;
-
- // Quote must be the first character in the string or be preceeded by a space
- // Also check for embedded string formating quote
- const MIchar cBckSlash = '\\';
- const MIchar cSpace = ' ';
- if( (nPos > 1) && (vrTxt[ nPos - 1 ] == cBckSlash) && (vrTxt[ nPos - 2 ] != cSpace) )
- {
- return false;
- }
- if( (nPos > 0) && (vrTxt[ nPos - 1 ] != cSpace) )
- return false;
-
- // Need to find the other quote
- const MIint nPos2 = vrTxt.rfind( cQuote );
- if( nPos2 == (MIint) std::string::npos )
- return false;
-
- // Make sure not same quote, need two quotes
- if( nPos == nPos2 )
- return MIstatus::failure;
-
- return true;
+ // CODETAG_QUOTEDTEXT_SIMILAR_CODE
+ const MIchar cQuote = '"';
+ const MIint nPos = vrTxt.find(cQuote);
+ if (nPos == (MIint)std::string::npos)
+ return false;
+
+ // Is one and only quote at end of the string
+ if (nPos == (MIint)(vrTxt.length() - 1))
+ return false;
+
+ // Quote must be the first character in the string or be preceeded by a space
+ // Also check for embedded string formating quote
+ const MIchar cBckSlash = '\\';
+ const MIchar cSpace = ' ';
+ if ((nPos > 1) && (vrTxt[nPos - 1] == cBckSlash) && (vrTxt[nPos - 2] != cSpace))
+ {
+ return false;
+ }
+ if ((nPos > 0) && (vrTxt[nPos - 1] != cSpace))
+ return false;
+
+ // Need to find the other quote
+ const MIint nPos2 = vrTxt.rfind(cQuote);
+ if (nPos2 == (MIint)std::string::npos)
+ return false;
+
+ // Make sure not same quote, need two quotes
+ if (nPos == nPos2)
+ return MIstatus::failure;
+
+ return true;
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
-// Take into account quotes surrounding the text. Take into account string format
-// embedded quotes surrounding the text i.e. "\\\"%5d\\\"". Note this function falls
-// through to IsStringArgQuotedText() should the criteria match fail.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid string type argument.
+// Take into account quotes surrounding the text. Take into account string format
+// embedded quotes surrounding the text i.e. "\\\"%5d\\\"". Note this function falls
+// through to IsStringArgQuotedText() should the criteria match fail.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValString::IsStringArgQuotedTextEmbedded( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValString::IsStringArgQuotedTextEmbedded(const CMIUtilString &vrTxt) const
{
- // CODETAG_QUOTEDTEXT_SIMILAR_CODE
- const MIchar cBckSlash = '\\';
- const MIint nPos = vrTxt.find( cBckSlash );
- if( nPos == (MIint) std::string::npos )
- return false;
-
- // Slash must be the first character in the string or be preceeded by a space
- const MIchar cSpace = ' ';
- if( (nPos > 0) && (vrTxt[ nPos - 1 ] != cSpace) )
- return false;
-
- // Need to find the other matching slash
- const MIint nPos2 = vrTxt.rfind( cBckSlash );
- if( nPos2 == (MIint) std::string::npos )
- return false;
-
- // Make sure not same back slash, need two slashs
- if( nPos == nPos2 )
- return MIstatus::failure;
-
- return false;
+ // CODETAG_QUOTEDTEXT_SIMILAR_CODE
+ const MIchar cBckSlash = '\\';
+ const MIint nPos = vrTxt.find(cBckSlash);
+ if (nPos == (MIint)std::string::npos)
+ return false;
+
+ // Slash must be the first character in the string or be preceeded by a space
+ const MIchar cSpace = ' ';
+ if ((nPos > 0) && (vrTxt[nPos - 1] != cSpace))
+ return false;
+
+ // Need to find the other matching slash
+ const MIint nPos2 = vrTxt.rfind(cBckSlash);
+ if (nPos2 == (MIint)std::string::npos)
+ return false;
+
+ // Make sure not same back slash, need two slashs
+ if (nPos == nPos2)
+ return MIstatus::failure;
+
+ return false;
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
-// Take into account quotes surrounding the text. Take into account string format
-// embedded quotes surrounding the text i.e. "\\\"%5d\\\"". Note this function falls
-// through to IsStringArgQuotedTextEmbedded() should the criteria match fail.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid string type argument.
+// Take into account quotes surrounding the text. Take into account string format
+// embedded quotes surrounding the text i.e. "\\\"%5d\\\"". Note this function falls
+// through to IsStringArgQuotedTextEmbedded() should the criteria match fail.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValString::IsStringArgQuotedQuotedTextEmbedded( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValString::IsStringArgQuotedQuotedTextEmbedded(const CMIUtilString &vrTxt) const
{
- const MIint nPos = vrTxt.find( "\"\\\"" );
- if( nPos == (MIint) std::string::npos )
- return false;
-
- const MIint nPos2 = vrTxt.rfind( "\\\"\"" );
- if( nPos2 == (MIint) std::string::npos )
- return false;
-
- const MIint nLen = vrTxt.length();
- if( (nLen > 5) && ((nPos + 2) == (nPos2 - 2)) )
- return false;
-
- return true;
+ const MIint nPos = vrTxt.find("\"\\\"");
+ if (nPos == (MIint)std::string::npos)
+ return false;
+
+ const MIint nPos2 = vrTxt.rfind("\\\"\"");
+ if (nPos2 == (MIint)std::string::npos)
+ return false;
+
+ const MIint nLen = vrTxt.length();
+ if ((nLen > 5) && ((nPos + 2) == (nPos2 - 2)))
+ return false;
+
+ return true;
}
diff --git a/tools/lldb-mi/MICmdArgValString.h b/tools/lldb-mi/MICmdArgValString.h
index ab411a02dc88..58f9ee4f32c3 100644
--- a/tools/lldb-mi/MICmdArgValString.h
+++ b/tools/lldb-mi/MICmdArgValString.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValString.h
+// File: MICmdArgValString.h
//
-// Overview: CMICmdArgValString interface.
+// Overview: CMICmdArgValString interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -28,49 +28,52 @@
class CMICmdArgContext;
//++ ============================================================================
-// Details: MI common code class. Command argument class. Arguments object
-// needing specialization derived from the CMICmdArgValBase class.
-// An argument knows what type of argument it is and how it is to
-// interpret the options (context) string to find and validate a matching
-// argument and so extract a value from it .
-// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 15/04/2014.
-// Changes: None.
+// Details: MI common code class. Command argument class. Arguments object
+// needing specialization derived from the CMICmdArgValBase class.
+// An argument knows what type of argument it is and how it is to
+// interpret the options (context) string to find and validate a matching
+// argument and so extract a value from it .
+// Based on the Interpreter pattern.
+// Gotchas: None.
+// Authors: Illya Rudkin 15/04/2014.
+// Changes: None.
//--
-class CMICmdArgValString : public CMICmdArgValBaseTemplate< CMIUtilString >
+class CMICmdArgValString : public CMICmdArgValBaseTemplate<CMIUtilString>
{
-// Methods:
-public:
- /* ctor */ CMICmdArgValString( void );
- /* ctor */ CMICmdArgValString( const bool vbAnything );
- /* ctor */ CMICmdArgValString( const bool vbHandleQuotes, const bool vbAcceptNumbers, const bool vbHandleDirPaths );
- /* ctor */ CMICmdArgValString( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const bool vbHandleQuotes = false, const bool vbAcceptNumbers = false );
- //
- bool IsStringArg( const CMIUtilString & vrTxt ) const;
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgValString(void);
+ /* ctor */ CMICmdArgValString(const bool vbAnything);
+ /* ctor */ CMICmdArgValString(const bool vbHandleQuotes, const bool vbAcceptNumbers, const bool vbHandleDirPaths);
+ /* ctor */ CMICmdArgValString(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+ const bool vbHandleQuotes = false, const bool vbAcceptNumbers = false);
+ //
+ bool IsStringArg(const CMIUtilString &vrTxt) const;
-// Overridden:
-public:
- // From CMICmdArgValBase
- /* dtor */ virtual ~CMICmdArgValString( void );
- // From CMICmdArgSet::IArg
- virtual bool Validate( CMICmdArgContext & vrwArgContext );
+ // Overridden:
+ public:
+ // From CMICmdArgValBase
+ /* dtor */ virtual ~CMICmdArgValString(void);
+ // From CMICmdArgSet::IArg
+ virtual bool Validate(CMICmdArgContext &vrwArgContext);
-// Methods:
-private:
- bool ValidateSingleText( CMICmdArgContext & vrwArgContext );
- bool ValidateQuotedText( CMICmdArgContext & vrwArgContext );
- bool ValidateQuotedTextEmbedded( CMICmdArgContext & vrwArgContext );
- bool ValidateQuotedQuotedTextEmbedded( CMICmdArgContext & vrwArgContext );
- bool IsStringArgSingleText( const CMIUtilString & vrTxt ) const;
- bool IsStringArgQuotedText( const CMIUtilString & vrTxt ) const;
- bool IsStringArgQuotedTextEmbedded( const CMIUtilString & vrTxt ) const;
- bool IsStringArgQuotedQuotedTextEmbedded( const CMIUtilString & vrTxt ) const;
+ // Methods:
+ private:
+ bool ValidateSingleText(CMICmdArgContext &vrwArgContext);
+ bool ValidateQuotedText(CMICmdArgContext &vrwArgContext);
+ bool ValidateQuotedTextEmbedded(CMICmdArgContext &vrwArgContext);
+ bool ValidateQuotedQuotedTextEmbedded(CMICmdArgContext &vrwArgContext);
+ bool IsStringArgSingleText(const CMIUtilString &vrTxt) const;
+ bool IsStringArgQuotedText(const CMIUtilString &vrTxt) const;
+ bool IsStringArgQuotedTextEmbedded(const CMIUtilString &vrTxt) const;
+ bool IsStringArgQuotedQuotedTextEmbedded(const CMIUtilString &vrTxt) const;
-// Attribute:
-private:
- bool m_bHandleQuotedString; // True = Parse a string surrounded by quotes spaces are not delimitors, false = only text up to next delimiting space character
- bool m_bAcceptNumbers; // True = Parse a string and accept as a number if number, false = numbers not recognised as string types
- bool m_bHandleDirPaths; // True = Parse a string and accept directory file style string if present, false = directory file path not accepted
- bool m_bHandleAnything; // True = Parse a string and accept anything if present, false = validate for criteria matches
+ // Attribute:
+ private:
+ bool m_bHandleQuotedString; // True = Parse a string surrounded by quotes spaces are not delimitors, false = only text up to next
+ // delimiting space character
+ bool m_bAcceptNumbers; // True = Parse a string and accept as a number if number, false = numbers not recognised as string types
+ bool m_bHandleDirPaths; // True = Parse a string and accept directory file style string if present, false = directory file path not
+ // accepted
+ bool m_bHandleAnything; // True = Parse a string and accept anything if present, false = validate for criteria matches
};
diff --git a/tools/lldb-mi/MICmdArgValThreadGrp.cpp b/tools/lldb-mi/MICmdArgValThreadGrp.cpp
index 7d3290482119..606c615dfca2 100644
--- a/tools/lldb-mi/MICmdArgValThreadGrp.cpp
+++ b/tools/lldb-mi/MICmdArgValThreadGrp.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValThreadGrp.cpp
+// File: MICmdArgValThreadGrp.cpp
//
-// Overview: CMICmdArgValThreadGrp implementation.
+// Overview: CMICmdArgValThreadGrp implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -24,150 +24,153 @@
#include "MICmdArgContext.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValThreadGrp constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValThreadGrp constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValThreadGrp::CMICmdArgValThreadGrp( void )
-: m_nThreadGrp( 0 )
+CMICmdArgValThreadGrp::CMICmdArgValThreadGrp(void)
+ : m_nThreadGrp(0)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValThreadGrp constructor.
-// Type: Method.
-// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValThreadGrp constructor.
+// Type: Method.
+// Args: vrArgName - (R) Argument's name to search by.
+// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValThreadGrp::CMICmdArgValThreadGrp( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd )
-: CMICmdArgValBaseTemplate( vrArgName, vbMandatory, vbHandleByCmd )
-, m_nThreadGrp( 0 )
+CMICmdArgValThreadGrp::CMICmdArgValThreadGrp(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
+ , m_nThreadGrp(0)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdArgValThreadGrp destructor.
-// Type: Overridden.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdArgValThreadGrp destructor.
+// Type: Overridden.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdArgValThreadGrp::~CMICmdArgValThreadGrp( void )
+CMICmdArgValThreadGrp::~CMICmdArgValThreadGrp(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
-// argument is looking for.
-// Type: Overridden.
-// Args: vwArgContext - (RW) The command's argument options string.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Parse the command's argument options string and try to extract the value *this
+// argument is looking for.
+// Type: Overridden.
+// Args: vwArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValThreadGrp::Validate( CMICmdArgContext & vwArgContext )
+bool
+CMICmdArgValThreadGrp::Validate(CMICmdArgContext &vwArgContext)
{
- if( vwArgContext.IsEmpty() )
- return MIstatus::success;
-
- if( vwArgContext.GetNumberArgsPresent() == 1 )
- {
- const CMIUtilString & rArg( vwArgContext.GetArgsLeftToParse() );
- if( IsArgThreadGrp( rArg ) && ExtractNumber( rArg ) )
- {
- m_bFound = true;
- m_bValid = true;
- m_argValue = GetNumber();
- vwArgContext.RemoveArg( rArg );
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
- }
-
- // More than one option...
- const CMIUtilString::VecString_t vecOptions( vwArgContext.GetArgs() );
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while( it != vecOptions.end() )
- {
- const CMIUtilString & rArg( *it );
- if( IsArgThreadGrp( rArg ) && ExtractNumber( rArg ) )
- {
- m_bFound = true;
-
- if( vwArgContext.RemoveArg( rArg ) )
- {
- m_bValid = true;
- m_argValue = GetNumber();
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
- }
-
- // Next
- ++it;
- }
-
- return MIstatus::failure;
+ if (vwArgContext.IsEmpty())
+ return MIstatus::success;
+
+ if (vwArgContext.GetNumberArgsPresent() == 1)
+ {
+ const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
+ if (IsArgThreadGrp(rArg) && ExtractNumber(rArg))
+ {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = GetNumber();
+ vwArgContext.RemoveArg(rArg);
+ return MIstatus::success;
+ }
+ else
+ return MIstatus::failure;
+ }
+
+ // More than one option...
+ const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end())
+ {
+ const CMIUtilString &rArg(*it);
+ if (IsArgThreadGrp(rArg) && ExtractNumber(rArg))
+ {
+ m_bFound = true;
+
+ if (vwArgContext.RemoveArg(rArg))
+ {
+ m_bValid = true;
+ m_argValue = GetNumber();
+ return MIstatus::success;
+ }
+ else
+ return MIstatus::failure;
+ }
+
+ // Next
+ ++it;
+ }
+
+ return MIstatus::failure;
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: bool - True = yes valid arg, false = no.
-// Throws: None.
+// Details: Examine the string and determine if it is a valid string type argument.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
//--
-bool CMICmdArgValThreadGrp::IsArgThreadGrp( const CMIUtilString & vrTxt ) const
+bool
+CMICmdArgValThreadGrp::IsArgThreadGrp(const CMIUtilString &vrTxt) const
{
- // Look for i1 i2 i3....
- const MIint nPos = vrTxt.find_first_of( "i" );
- if( nPos != 0 )
- return false;
-
- const CMIUtilString strNum = vrTxt.substr( 1 ).c_str();
- if( !strNum.IsNumber() )
- return false;
-
- return true;
+ // Look for i1 i2 i3....
+ const MIint nPos = vrTxt.find_first_of("i");
+ if (nPos != 0)
+ return false;
+
+ const CMIUtilString strNum = vrTxt.substr(1).c_str();
+ if (!strNum.IsNumber())
+ return false;
+
+ return true;
}
//++ ------------------------------------------------------------------------------------
-// Details: Extract the thread group number from the thread group argument.
-// Type: Method.
-// Args: vrTxt - (R) Some text.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Extract the thread group number from the thread group argument.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdArgValThreadGrp::ExtractNumber( const CMIUtilString & vrTxt )
+bool
+CMICmdArgValThreadGrp::ExtractNumber(const CMIUtilString &vrTxt)
{
- const CMIUtilString strNum = vrTxt.substr( 1 ).c_str();
- MIint64 nNumber = 0;
- bool bOk = strNum.ExtractNumber( nNumber );
- if( bOk )
- {
- m_nThreadGrp = static_cast< MIuint >( nNumber );
- }
-
- return bOk;
+ const CMIUtilString strNum = vrTxt.substr(1).c_str();
+ MIint64 nNumber = 0;
+ bool bOk = strNum.ExtractNumber(nNumber);
+ if (bOk)
+ {
+ m_nThreadGrp = static_cast<MIuint>(nNumber);
+ }
+
+ return bOk;
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the thread group ID found in the argument.
-// Type: Method.
-// Args: None.
-// Return: MIuint - Thread group ID.
-// Throws: None.
+// Details: Retrieve the thread group ID found in the argument.
+// Type: Method.
+// Args: None.
+// Return: MIuint - Thread group ID.
+// Throws: None.
//--
-MIuint CMICmdArgValThreadGrp::GetNumber( void ) const
+MIuint
+CMICmdArgValThreadGrp::GetNumber(void) const
{
- return m_nThreadGrp;
+ return m_nThreadGrp;
}
-
diff --git a/tools/lldb-mi/MICmdArgValThreadGrp.h b/tools/lldb-mi/MICmdArgValThreadGrp.h
index 8903597dbca1..d82b89ff5017 100644
--- a/tools/lldb-mi/MICmdArgValThreadGrp.h
+++ b/tools/lldb-mi/MICmdArgValThreadGrp.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdArgValThreadGrp.h
+// File: MICmdArgValThreadGrp.h
//
-// Overview: CMICmdArgValThreadGrp interface.
+// Overview: CMICmdArgValThreadGrp interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -28,39 +28,39 @@
class CMICmdArgContext;
//++ ============================================================================
-// Details: MI common code class. Command argument class. Arguments object
-// needing specialization derived from the CMICmdArgValBase class.
-// An argument knows what type of argument it is and how it is to
-// interpret the options (context) string to find and validate a matching
-// argument and so extract a value from it. Thread group looks like
-// "i1" in the options text.
-// Based on the Interpreter pattern.
-// Gotchas: None.
-// Authors: Illya Rudkin 15/04/2014.
-// Changes: None.
+// Details: MI common code class. Command argument class. Arguments object
+// needing specialization derived from the CMICmdArgValBase class.
+// An argument knows what type of argument it is and how it is to
+// interpret the options (context) string to find and validate a matching
+// argument and so extract a value from it. Thread group looks like
+// "i1" in the options text.
+// Based on the Interpreter pattern.
+// Gotchas: None.
+// Authors: Illya Rudkin 15/04/2014.
+// Changes: None.
//--
-class CMICmdArgValThreadGrp : public CMICmdArgValBaseTemplate< MIuint >
+class CMICmdArgValThreadGrp : public CMICmdArgValBaseTemplate<MIuint>
{
-// Methods:
-public:
- /* ctor */ CMICmdArgValThreadGrp( void );
- /* ctor */ CMICmdArgValThreadGrp( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd );
- //
- bool IsArgThreadGrp( const CMIUtilString & vrTxt ) const;
-
-// Overridden:
-public:
- // From CMICmdArgValBase
- /* dtor */ virtual ~CMICmdArgValThreadGrp( void );
- // From CMICmdArgSet::IArg
- virtual bool Validate( CMICmdArgContext & vArgContext );
+ // Methods:
+ public:
+ /* ctor */ CMICmdArgValThreadGrp(void);
+ /* ctor */ CMICmdArgValThreadGrp(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
+ //
+ bool IsArgThreadGrp(const CMIUtilString &vrTxt) const;
-// Methods:
-private:
- bool ExtractNumber( const CMIUtilString & vrTxt );
- MIuint GetNumber( void ) const;
+ // Overridden:
+ public:
+ // From CMICmdArgValBase
+ /* dtor */ virtual ~CMICmdArgValThreadGrp(void);
+ // From CMICmdArgSet::IArg
+ virtual bool Validate(CMICmdArgContext &vArgContext);
-// Attributes:
-private:
- MIuint m_nThreadGrp;
+ // Methods:
+ private:
+ bool ExtractNumber(const CMIUtilString &vrTxt);
+ MIuint GetNumber(void) const;
+
+ // Attributes:
+ private:
+ MIuint m_nThreadGrp;
};
diff --git a/tools/lldb-mi/MICmdBase.cpp b/tools/lldb-mi/MICmdBase.cpp
index cedcba7e042f..d08dcb90f65f 100644
--- a/tools/lldb-mi/MICmdBase.cpp
+++ b/tools/lldb-mi/MICmdBase.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdBase.cpp
+// File: MICmdBase.cpp
//
-// Overview: CMICmdBase implementation.
+// Overview: CMICmdBase implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
@@ -25,239 +25,253 @@
#include "MICmnLLDBDebugSessionInfo.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdBase constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdBase constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdBase::CMICmdBase( void )
-: m_pSelfCreatorFn( nullptr )
-, m_rLLDBDebugSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() )
-, m_bHasResultRecordExtra( false )
+CMICmdBase::CMICmdBase(void)
+ : m_pSelfCreatorFn(nullptr)
+ , m_rLLDBDebugSessionInfo(CMICmnLLDBDebugSessionInfo::Instance())
+ , m_bHasResultRecordExtra(false)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdBase destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdBase destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdBase::~CMICmdBase( void )
+CMICmdBase::~CMICmdBase(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function.
-// Type: Overridden.
-// Args: None.
-// Return: SMICmdData & - *this command's present status/data/information.
-// Throws: None.
+// Details: The invoker requires this function.
+// Type: Overridden.
+// Args: None.
+// Return: SMICmdData & - *this command's present status/data/information.
+// Throws: None.
//--
-const SMICmdData & CMICmdBase::GetCmdData( void ) const
+const SMICmdData &
+CMICmdBase::GetCmdData(void) const
{
- return m_cmdData;
+ return m_cmdData;
}
-
+
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function.
-// Type: Overridden.
-// Args: None.
-// Return: CMIUtilString & - *this command's current error description.
-// Empty string indicates command status ok.
-// Throws: None.
+// Details: The invoker requires this function.
+// Type: Overridden.
+// Args: None.
+// Return: CMIUtilString & - *this command's current error description.
+// Empty string indicates command status ok.
+// Throws: None.
//--
-const CMIUtilString & CMICmdBase::GetErrorDescription( void ) const
+const CMIUtilString &
+CMICmdBase::GetErrorDescription(void) const
{
- return m_strCurrentErrDescription;
+ return m_strCurrentErrDescription;
}
//++ ------------------------------------------------------------------------------------
-// Details: The CMICmdFactory requires this function. Retrieve the command and argument
-// options description string.
-// Type: Overridden.
-// Args: None.
-// Return: CMIUtilString & - Command decription.
-// Throws: None.
+// Details: The CMICmdFactory requires this function. Retrieve the command and argument
+// options description string.
+// Type: Overridden.
+// Args: None.
+// Return: CMIUtilString & - Command decription.
+// Throws: None.
//--
-const CMIUtilString & CMICmdBase::GetMiCmd( void ) const
-{
- return m_strMiCmd;
+const CMIUtilString &
+CMICmdBase::GetMiCmd(void) const
+{
+ return m_strMiCmd;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. A command must be given working data and
-// provide data about its status or provide information to other objects.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. A command must be given working data and
+// provide data about its status or provide information to other objects.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdBase::SetCmdData( const SMICmdData & vCmdData )
+bool
+CMICmdBase::SetCmdData(const SMICmdData &vCmdData)
{
- m_cmdData = vCmdData;
+ m_cmdData = vCmdData;
- return MIstatus::success;
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The command factory requires this function. The factory calls this function
-// so it can obtain *this command's creation function.
-// Type: Overridden.
-// Args: None.
-// Return: CMICmdFactory::CmdCreatorFnPtr - Function pointer.
-// Throws: None.
+// Details: The command factory requires this function. The factory calls this function
+// so it can obtain *this command's creation function.
+// Type: Overridden.
+// Args: None.
+// Return: CMICmdFactory::CmdCreatorFnPtr - Function pointer.
+// Throws: None.
//--
-CMICmdFactory::CmdCreatorFnPtr CMICmdBase::GetCmdCreatorFn( void ) const
+CMICmdFactory::CmdCreatorFnPtr
+CMICmdBase::GetCmdCreatorFn(void) const
{
- return m_pSelfCreatorFn;
+ return m_pSelfCreatorFn;
}
//++ ------------------------------------------------------------------------------------
-// Details: If a command is an event type (has callbacks registered with SBListener) it
-// needs to inform the Invoker that it has finished its work so that the
-// Invoker can tidy up and call the commands Acknowledge function (yes the
-// command itself could call the Acknowledge itself but not doing that way).
-// Type: Overridden.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: If a command is an event type (has callbacks registered with SBListener) it
+// needs to inform the Invoker that it has finished its work so that the
+// Invoker can tidy up and call the commands Acknowledge function (yes the
+// command itself could call the Acknowledge itself but not doing that way).
+// Type: Overridden.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-void CMICmdBase::CmdFinishedTellInvoker( void ) const
+void
+CMICmdBase::CmdFinishedTellInvoker(void) const
{
- CMICmdInvoker::Instance().CmdExecuteFinished( const_cast< CMICmdBase & >( *this ) );
+ CMICmdInvoker::Instance().CmdExecuteFinished(const_cast<CMICmdBase &>(*this));
}
//++ ------------------------------------------------------------------------------------
-// Details: Returns the final version of the MI result record built up in the command's
-// Acknowledge function. The one line text of MI result.
-// Type: Overridden.
-// Args: None.
-// Return: CMIUtilString & - MI text version of the MI result record.
-// Throws: None.
+// Details: Returns the final version of the MI result record built up in the command's
+// Acknowledge function. The one line text of MI result.
+// Type: Overridden.
+// Args: None.
+// Return: CMIUtilString & - MI text version of the MI result record.
+// Throws: None.
//--
-const CMIUtilString & CMICmdBase::GetMIResultRecord( void ) const
+const CMIUtilString &
+CMICmdBase::GetMIResultRecord(void) const
{
- return m_miResultRecord.GetString();
+ return m_miResultRecord.GetString();
}
-
+
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve from the command additional MI result to its 1 line response.
-// Because of using LLDB addtional 'fake'/hack output is sometimes required to
-// help the driver client operate i.e. Eclipse.
-// Type: Overridden.
-// Args: None.
-// Return: CMIUtilString & - MI text version of the MI result record.
-// Throws: None.
+// Details: Retrieve from the command additional MI result to its 1 line response.
+// Because of using LLDB addtional 'fake'/hack output is sometimes required to
+// help the driver client operate i.e. Eclipse.
+// Type: Overridden.
+// Args: None.
+// Return: CMIUtilString & - MI text version of the MI result record.
+// Throws: None.
//--
-const CMIUtilString & CMICmdBase::GetMIResultRecordExtra( void ) const
+const CMIUtilString &
+CMICmdBase::GetMIResultRecordExtra(void) const
{
- return m_miResultRecordExtra;
+ return m_miResultRecordExtra;
}
//++ ------------------------------------------------------------------------------------
-// Details: Hss *this command got additional MI result to its 1 line response.
-// Because of using LLDB addtional 'fake'/hack output is sometimes required to
-// help the driver client operate i.e. Eclipse.
-// Type: Overridden.
-// Args: None.
-// Return: bool - True = Yes have additional MI output, false = no nothing extra.
-// Throws: None.
+// Details: Hss *this command got additional MI result to its 1 line response.
+// Because of using LLDB addtional 'fake'/hack output is sometimes required to
+// help the driver client operate i.e. Eclipse.
+// Type: Overridden.
+// Args: None.
+// Return: bool - True = Yes have additional MI output, false = no nothing extra.
+// Throws: None.
//--
-bool CMICmdBase::HasMIResultRecordExtra( void ) const
+bool
+CMICmdBase::HasMIResultRecordExtra(void) const
{
- return m_bHasResultRecordExtra;
+ return m_bHasResultRecordExtra;
}
//++ ------------------------------------------------------------------------------------
-// Details: Short cut function to enter error information into the command's metadata
-// object and set the command's error status.
-// Type: Method.
-// Args: rErrMsg - (R) Error description.
-// Return: None.
-// Throws: None.
+// Details: Short cut function to enter error information into the command's metadata
+// object and set the command's error status.
+// Type: Method.
+// Args: rErrMsg - (R) Error description.
+// Return: None.
+// Throws: None.
//--
-void CMICmdBase::SetError( const CMIUtilString & rErrMsg )
+void
+CMICmdBase::SetError(const CMIUtilString &rErrMsg)
{
- m_cmdData.bCmdValid = false;
- m_cmdData.strErrorDescription = rErrMsg;
- m_cmdData.bCmdExecutedSuccessfully = false;
-
- const CMICmnMIValueResult valueResult( "msg", CMICmnMIValueConst( rErrMsg ) );
- const CMICmnMIResultRecord miResultRecord( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, valueResult );
- m_miResultRecord = miResultRecord;
- m_cmdData.strMiCmdResultRecord = miResultRecord.GetString();
+ m_cmdData.bCmdValid = false;
+ m_cmdData.strErrorDescription = rErrMsg;
+ m_cmdData.bCmdExecutedSuccessfully = false;
+
+ const CMICmnMIValueResult valueResult("msg", CMICmnMIValueConst(rErrMsg));
+ const CMICmnMIResultRecord miResultRecord(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, valueResult);
+ m_miResultRecord = miResultRecord;
+ m_cmdData.strMiCmdResultRecord = miResultRecord.GetString();
}
//++ ------------------------------------------------------------------------------------
-// Details: Ask a command to provide its unique identifier.
-// Type: Method.
-// Args: A unique identifier for this command class.
-// Return: None.
-// Throws: None.
+// Details: Ask a command to provide its unique identifier.
+// Type: Method.
+// Args: A unique identifier for this command class.
+// Return: None.
+// Throws: None.
//--
-MIuint CMICmdBase::GetGUID( void )
+MIuint
+CMICmdBase::GetGUID(void)
{
- MIuint64 vptr = reinterpret_cast< MIuint64 >( this );
- MIuint id = (vptr ) & 0xFFFFFFFF;
- id ^= (vptr >> 32) & 0xFFFFFFFF;
+ MIuint64 vptr = reinterpret_cast<MIuint64>(this);
+ MIuint id = (vptr)&0xFFFFFFFF;
+ id ^= (vptr >> 32) & 0xFFFFFFFF;
- return id;
+ return id;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdBase::ParseArgs( void )
-{
- // Do nothing - override to implement
+bool
+CMICmdBase::ParseArgs(void)
+{
+ // Do nothing - override to implement
- return MIstatus::success;
+ return MIstatus::success;
}
-
+
//++ ------------------------------------------------------------------------------------
-// Details: Having previously given CMICmdArgSet m_setCmdArgs all the argument or option
-// definitions for the command to handle proceed to parse and validate the
-// command's options text for those arguments and extract the values for each if
-// any.
-// Type: Method.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: Having previously given CMICmdArgSet m_setCmdArgs all the argument or option
+// definitions for the command to handle proceed to parse and validate the
+// command's options text for those arguments and extract the values for each if
+// any.
+// Type: Method.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdBase::ParseValidateCmdOptions( void )
+bool
+CMICmdBase::ParseValidateCmdOptions(void)
{
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- return MIstatus::success;
-
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
+ CMICmdArgContext argCntxt(m_cmdData.strMiCmdOption);
+ if (m_setCmdArgs.Validate(m_cmdData.strMiCmd, argCntxt))
+ return MIstatus::success;
+
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_ARGS), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str()));
- return MIstatus::failure;
+ return MIstatus::failure;
}
//++ ------------------------------------------------------------------------------------
-// Details: If the MI Driver is not operating via a client i.e. Eclipse but say operating
-// on a executable passed in as a argument to the drive then what should the driver
-// do on a command failing? Either continue operating or exit the application.
-// Override this function where a command failure cannot allow the driver to
-// continue operating.
-// Type: Overrideable.
-// Args: None.
-// Return: bool - True = Fatal if command fails, false = can continue if command fails.
-// Throws: None.
+// Details: If the MI Driver is not operating via a client i.e. Eclipse but say operating
+// on a executable passed in as a argument to the drive then what should the driver
+// do on a command failing? Either continue operating or exit the application.
+// Override this function where a command failure cannot allow the driver to
+// continue operating.
+// Type: Overrideable.
+// Args: None.
+// Return: bool - True = Fatal if command fails, false = can continue if command fails.
+// Throws: None.
//--
-bool CMICmdBase::GetExitAppOnCommandFailure( void ) const
+bool
+CMICmdBase::GetExitAppOnCommandFailure(void) const
{
- return false;
+ return false;
}
diff --git a/tools/lldb-mi/MICmdBase.h b/tools/lldb-mi/MICmdBase.h
index b05e97d2082d..c2a8fe030310 100644
--- a/tools/lldb-mi/MICmdBase.h
+++ b/tools/lldb-mi/MICmdBase.h
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdBase.h
+// File: MICmdBase.h
//
-// Overview: CMICmdBase interface.
+// Overview: CMICmdBase interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -35,122 +35,124 @@
class CMICmnLLDBDebugSessionInfo;
//++ ============================================================================
-// Details: MI command base class. MI commands derive from this base class.
-// The Command Factory creates command objects and passes them to the
-// Command Invoker. The Invoker takes ownersip of any commands created
-// which means it is the only object to delete them when a command is
-// finished working. Commands do not delete themselves.
-// There are two types of command implicitly defined by the state of
-// the m_bWaitForEventFromSBDebugger flag. There is the event type
-// command which registers (command fn) callbacks with the SBListener
-// does some work then wakes up again when called back, does more work
-// perhaps, ends, then the Invoker calls the command's Acknowledge
-// function. The other type of command is one that just does some work,
-// ends, then the Invoker calls the command's Acknowledge function. No
-// events set up.
-// A command's Execute(), Acknowledge() and event callback functions are
-// carried out in the main thread.
-// A command may use the argument derived object classes (CMICmdArgValBase)
-// to factor handling and parsing of different types of arguments
-// presented to a command. A command will produce an error should it
-// be presented with arguments or options it does not understand.
-// Gotchas: None.
-// Authors: Illya Rudkin 18/02/2014.
-// Changes: None.
+// Details: MI command base class. MI commands derive from this base class.
+// The Command Factory creates command objects and passes them to the
+// Command Invoker. The Invoker takes ownersip of any commands created
+// which means it is the only object to delete them when a command is
+// finished working. Commands do not delete themselves.
+// There are two types of command implicitly defined by the state of
+// the m_bWaitForEventFromSBDebugger flag. There is the event type
+// command which registers (command fn) callbacks with the SBListener
+// does some work then wakes up again when called back, does more work
+// perhaps, ends, then the Invoker calls the command's Acknowledge
+// function. The other type of command is one that just does some work,
+// ends, then the Invoker calls the command's Acknowledge function. No
+// events set up.
+// A command's Execute(), Acknowledge() and event callback functions are
+// carried out in the main thread.
+// A command may use the argument derived object classes (CMICmdArgValBase)
+// to factor handling and parsing of different types of arguments
+// presented to a command. A command will produce an error should it
+// be presented with arguments or options it does not understand.
+// Gotchas: None.
+// Authors: Illya Rudkin 18/02/2014.
+// Changes: None.
//--
-class CMICmdBase
-: public CMICmnBase
-, public CMICmdInvoker::ICmd
-, public CMICmdFactory::ICmd
+class CMICmdBase : public CMICmnBase, public CMICmdInvoker::ICmd, public CMICmdFactory::ICmd
{
-// Methods:
-public:
- /* ctor */ CMICmdBase( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdBase(void);
-// Overridden:
-public:
- // From CMICmdInvoker::ICmd
- virtual const SMICmdData & GetCmdData( void ) const;
- virtual const CMIUtilString & GetErrorDescription( void ) const;
- virtual bool SetCmdData( const SMICmdData & vCmdData );
- virtual void CmdFinishedTellInvoker( void ) const;
- virtual const CMIUtilString & GetMIResultRecord( void ) const;
- virtual const CMIUtilString & GetMIResultRecordExtra( void ) const;
- virtual bool HasMIResultRecordExtra( void ) const;
- virtual bool ParseArgs( void );
- // From CMICmdFactory::ICmd
- virtual const CMIUtilString & GetMiCmd( void ) const;
- virtual CMICmdFactory::CmdCreatorFnPtr GetCmdCreatorFn( void ) const;
+ // Overridden:
+ public:
+ // From CMICmdInvoker::ICmd
+ virtual const SMICmdData &GetCmdData(void) const;
+ virtual const CMIUtilString &GetErrorDescription(void) const;
+ virtual bool SetCmdData(const SMICmdData &vCmdData);
+ virtual void CmdFinishedTellInvoker(void) const;
+ virtual const CMIUtilString &GetMIResultRecord(void) const;
+ virtual const CMIUtilString &GetMIResultRecordExtra(void) const;
+ virtual bool HasMIResultRecordExtra(void) const;
+ virtual bool ParseArgs(void);
+ // From CMICmdFactory::ICmd
+ virtual const CMIUtilString &GetMiCmd(void) const;
+ virtual CMICmdFactory::CmdCreatorFnPtr GetCmdCreatorFn(void) const;
- virtual MIuint GetGUID( void );
+ virtual MIuint GetGUID(void);
-// Overrideable:
-public:
- /* dtor */ virtual ~CMICmdBase( void );
- virtual bool GetExitAppOnCommandFailure( void ) const;
+ // Overrideable:
+ public:
+ /* dtor */ virtual ~CMICmdBase(void);
+ virtual bool GetExitAppOnCommandFailure(void) const;
-// Methods:
-protected:
- void SetError( const CMIUtilString & rErrMsg );
- template< class T >
- T * GetOption( const CMIUtilString & vStrOptionName );
- bool ParseValidateCmdOptions( void );
-
-// Attributes:
-protected:
- CMICmdFactory::CmdCreatorFnPtr m_pSelfCreatorFn;
- CMIUtilString m_strCurrentErrDescription; // Reason for Execute or Acknowledge function failure
- SMICmdData m_cmdData; // Holds information/status of *this command. Used by other MI code to report or determine state of a command.
- bool m_bWaitForEventFromSBDebugger; // True = yes event type command wait, false = command calls Acknowledge() straight after Execute() no waiting
- CMIUtilString m_strMiCmd; // The MI text identifying *this command i.e. 'break-insert'
- CMICmnMIResultRecord m_miResultRecord; // This is completed in the Acknowledge() function and returned to the Command Invoker to proceed stdout output. Each command forms 1 response to its input.
- CMIUtilString m_miResultRecordExtra; // This is completed in the Acknowledge() function and returned to the Command Invoker to proceed stdout output. Hack command produce more response text to help the client because of using LLDB
- CMICmnLLDBDebugSessionInfo & m_rLLDBDebugSessionInfo; // Access to command sharing information or data across any and all command based derived classes.
- bool m_bHasResultRecordExtra; // True = Yes command produced additional MI output to its 1 line response, false = no extra MI output formed.
- CMICmdArgSet m_setCmdArgs; // The list of arguments *this command needs to parse from the options string to carry out work.
+ // Methods:
+ protected:
+ void SetError(const CMIUtilString &rErrMsg);
+ template <class T> T *GetOption(const CMIUtilString &vStrOptionName);
+ bool ParseValidateCmdOptions(void);
+
+ // Attributes:
+ protected:
+ CMICmdFactory::CmdCreatorFnPtr m_pSelfCreatorFn;
+ CMIUtilString m_strCurrentErrDescription; // Reason for Execute or Acknowledge function failure
+ SMICmdData m_cmdData; // Holds information/status of *this command. Used by other MI code to report or determine state of a command.
+ bool m_bWaitForEventFromSBDebugger; // True = yes event type command wait, false = command calls Acknowledge() straight after Execute()
+ // no waiting
+ CMIUtilString m_strMiCmd; // The MI text identifying *this command i.e. 'break-insert'
+ CMICmnMIResultRecord m_miResultRecord; // This is completed in the Acknowledge() function and returned to the Command Invoker to proceed
+ // stdout output. Each command forms 1 response to its input.
+ CMIUtilString m_miResultRecordExtra; // This is completed in the Acknowledge() function and returned to the Command Invoker to proceed
+ // stdout output. Hack command produce more response text to help the client because of using LLDB
+ CMICmnLLDBDebugSessionInfo &
+ m_rLLDBDebugSessionInfo; // Access to command sharing information or data across any and all command based derived classes.
+ bool m_bHasResultRecordExtra; // True = Yes command produced additional MI output to its 1 line response, false = no extra MI output
+ // formed.
+ CMICmdArgSet m_setCmdArgs; // The list of arguments *this command needs to parse from the options string to carry out work.
};
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the command argument or option object pointer so that it can be
-// examined. If the option found and valid get the value (number, string or list
-// - see CMICmdArgValBase class) from it to use with the command's decision
-// making. If the argument is not found the command's error description is set
-// describing the error condition.
-// Type: Template method.
-// Args: vStrOptionName - (R) The text name of the argument or option to search for in
-// the list of the command's possible arguments or options.
-// Return: T * - CMICmdArgValBase derived object.
-// - NULL = function has failed, unable to retrieve the option/arg object.
-// Throws: None.
+// Details: Retrieve the command argument or option object pointer so that it can be
+// examined. If the option found and valid get the value (number, string or list
+// - see CMICmdArgValBase class) from it to use with the command's decision
+// making. If the argument is not found the command's error description is set
+// describing the error condition.
+// Type: Template method.
+// Args: vStrOptionName - (R) The text name of the argument or option to search for in
+// the list of the command's possible arguments or options.
+// Return: T * - CMICmdArgValBase derived object.
+// - NULL = function has failed, unable to retrieve the option/arg object.
+// Throws: None.
//--
-template< class T >
-T * CMICmdBase::GetOption( const CMIUtilString & vStrOptionName )
+template <class T>
+T *
+CMICmdBase::GetOption(const CMIUtilString &vStrOptionName)
{
- CMICmdArgValBase * pPtrBase = nullptr;
- if( !m_setCmdArgs.GetArg( vStrOptionName, pPtrBase ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_OPTION_NOT_FOUND ), m_cmdData.strMiCmd.c_str(), vStrOptionName.c_str() ) );
- return nullptr;
- }
+ CMICmdArgValBase *pPtrBase = nullptr;
+ if (!m_setCmdArgs.GetArg(vStrOptionName, pPtrBase))
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), vStrOptionName.c_str()));
+ return nullptr;
+ }
- return static_cast< T * >( pPtrBase );
+ return static_cast<T *>(pPtrBase);
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the command argument or option object pointer using template function
-// CMICmdBase::GetOption(). Should the argument (by name) not be found the
-// command will exit with a failure (set in GetOption()).
-// Type: Preprocessor macro.
-// Args: a - (R) The actual variable's name.
-// b - (R) The type of variable (appended to CMICmdArgVal i.e. CMICmdArgValString).
-// c - (R) The text name of the argument or option to search for in the list of
-// the command's possible arguments or options.
-// Return: T * - CMICmdArgValBase derived object.
-// - NULL = function has failed, unable to retrieve the option/arg object.
-// Throws: None.
+// Details: Retrieve the command argument or option object pointer using template function
+// CMICmdBase::GetOption(). Should the argument (by name) not be found the
+// command will exit with a failure (set in GetOption()).
+// Type: Preprocessor macro.
+// Args: a - (R) The actual variable's name.
+// b - (R) The type of variable (appended to CMICmdArgVal i.e. CMICmdArgValString).
+// c - (R) The text name of the argument or option to search for in the list of
+// the command's possible arguments or options.
+// Return: T * - CMICmdArgValBase derived object.
+// - NULL = function has failed, unable to retrieve the option/arg object.
+// Throws: None.
//--
-#define CMICMDBASE_GETOPTION( a, b, c ) \
- CMICmdArgVal##b * a = CMICmdBase::GetOption< CMICmdArgVal##b >( c );\
- if( a == nullptr ) \
- return MIstatus::failure;
+#define CMICMDBASE_GETOPTION(a, b, c) \
+ CMICmdArgVal##b *a = CMICmdBase::GetOption<CMICmdArgVal##b>(c); \
+ if (a == nullptr) \
+ return MIstatus::failure;
// This comment is to stop compile warning for #define
diff --git a/tools/lldb-mi/MICmdCmd.cpp b/tools/lldb-mi/MICmdCmd.cpp
index 3c6d52b24769..50f651f634f6 100644
--- a/tools/lldb-mi/MICmdCmd.cpp
+++ b/tools/lldb-mi/MICmdCmd.cpp
@@ -8,93 +8,96 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdCmd.cpp
+// File: MICmdCmd.cpp
//
-// Overview: CMICmdCmdEnablePrettyPrinting implementation.
-// CMICmdCmdSource implementation.
+// Overview: CMICmdCmdEnablePrettyPrinting implementation.
+// CMICmdCmdSource implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// In-house headers:
#include "MICmdCmd.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdEnablePrettyPrinting constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdEnablePrettyPrinting constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting( void )
+CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting(void)
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "enable-pretty-printing";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdEnablePrettyPrinting::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "enable-pretty-printing";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdEnablePrettyPrinting::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdEnablePrettyPrinting destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdEnablePrettyPrinting destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdEnablePrettyPrinting::~CMICmdCmdEnablePrettyPrinting( void )
+CMICmdCmdEnablePrettyPrinting::~CMICmdCmdEnablePrettyPrinting(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdEnablePrettyPrinting::Execute( void )
+bool
+CMICmdCmdEnablePrettyPrinting::Execute(void)
{
- // Do nothing
- return MIstatus::success;
+ // Do nothing
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdEnablePrettyPrinting::Acknowledge( void )
+bool
+CMICmdCmdEnablePrettyPrinting::Acknowledge(void)
{
- const CMICmnMIValueConst miValueConst( "0" );
- const CMICmnMIValueResult miValueResult( "supported", miValueConst );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult );
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+ const CMICmnMIValueConst miValueConst("0");
+ const CMICmnMIValueResult miValueResult("supported", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdEnablePrettyPrinting::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdEnablePrettyPrinting::CreateSelf(void)
{
- return new CMICmdCmdEnablePrettyPrinting();
+ return new CMICmdCmdEnablePrettyPrinting();
}
//---------------------------------------------------------------------------------------
@@ -102,73 +105,76 @@ CMICmdBase * CMICmdCmdEnablePrettyPrinting::CreateSelf( void )
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdSource constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdSource constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdSource::CMICmdCmdSource( void )
+CMICmdCmdSource::CMICmdCmdSource(void)
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "source";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdSource::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "source";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdSource::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdSource destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdSource destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdSource::~CMICmdCmdSource( void )
+CMICmdCmdSource::~CMICmdCmdSource(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdSource::Execute( void )
+bool
+CMICmdCmdSource::Execute(void)
{
- // Do nothing
- return MIstatus::success;
+ // Do nothing
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdSource::Acknowledge( void )
+bool
+CMICmdCmdSource::Acknowledge(void)
{
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done );
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdSource::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdSource::CreateSelf(void)
{
- return new CMICmdCmdSource();
+ return new CMICmdCmdSource();
}
diff --git a/tools/lldb-mi/MICmdCmd.h b/tools/lldb-mi/MICmdCmd.h
index c2ab6896e689..b51318fa9dff 100644
--- a/tools/lldb-mi/MICmdCmd.h
+++ b/tools/lldb-mi/MICmdCmd.h
@@ -8,30 +8,30 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdCmd.h
+// File: MICmdCmd.h
//
-// Overview: CMICmdCmdEnablePrettyPrinting interface.
-// CMICmdCmdSource interface.
+// Overview: CMICmdCmdEnablePrettyPrinting interface.
+// CMICmdCmdSource interface.
//
-// To implement new MI commands derive a new command class from the command base
-// class. To enable the new command for interpretation add the new command class
-// to the command factory. The files of relevance are:
-// MICmdCommands.cpp
-// MICmdBase.h / .cpp
-// MICmdCmd.h / .cpp
-// For an introduction to adding a new command see CMICmdCmdSupportInfoMiCmdQuery
-// command class as an example.
+// To implement new MI commands derive a new command class from the command base
+// class. To enable the new command for interpretation add the new command class
+// to the command factory. The files of relevance are:
+// MICmdCommands.cpp
+// MICmdBase.h / .cpp
+// MICmdCmd.h / .cpp
+// For an introduction to adding a new command see CMICmdCmdSupportInfoMiCmdQuery
+// command class as an example.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
-/*
+/*
MI commands implemented are:
- See MICmdCommands.cpp
+ See MICmdCommands.cpp
*/
#pragma once
@@ -47,58 +47,57 @@ MI commands implemented are:
#include "MICmnMIValueList.h"
//++ ============================================================================
-// Details: MI command class. MI commands derived from the command base class.
-// *this class implements MI command "enable-pretty-printing".
-// Enables Python base pretty printing.
-// Ref: http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html
-// Gotchas: None.
-// Authors: Illya Rudkin 03/03/2014.
-// Changes: None.
+// Details: MI command class. MI commands derived from the command base class.
+// *this class implements MI command "enable-pretty-printing".
+// Enables Python base pretty printing.
+// Ref: http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html
+// Gotchas: None.
+// Authors: Illya Rudkin 03/03/2014.
+// Changes: None.
//--
class CMICmdCmdEnablePrettyPrinting : public CMICmdBase
{
-// Statics:
-public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase * CreateSelf( void );
+ // Statics:
+ public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf(void);
-// Methods:
-public:
- /* ctor */ CMICmdCmdEnablePrettyPrinting( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdCmdEnablePrettyPrinting(void);
-// Overridden:
-public:
- // From CMICmdInvoker::ICmd
- virtual bool Execute( void );
- virtual bool Acknowledge( void );
- // From CMICmnBase
- /* dtor */ virtual ~CMICmdCmdEnablePrettyPrinting( void );
+ // Overridden:
+ public:
+ // From CMICmdInvoker::ICmd
+ virtual bool Execute(void);
+ virtual bool Acknowledge(void);
+ // From CMICmnBase
+ /* dtor */ virtual ~CMICmdCmdEnablePrettyPrinting(void);
};
//++ ============================================================================
-// Details: MI command class. MI commands derived from the command base class.
-// *this class implements MI command "source".
-// Gotchas: None.
-// Authors: Illya Rudkin 05/03/2014.
-// Changes: None.
+// Details: MI command class. MI commands derived from the command base class.
+// *this class implements MI command "source".
+// Gotchas: None.
+// Authors: Illya Rudkin 05/03/2014.
+// Changes: None.
//--
-class CMICmdCmdSource
- : public CMICmdBase
+class CMICmdCmdSource : public CMICmdBase
{
-// Statics:
-public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase * CreateSelf( void );
+ // Statics:
+ public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf(void);
-// Methods:
-public:
- /* ctor */ CMICmdCmdSource( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdCmdSource(void);
-// Overridden:
-public:
- // From CMICmdInvoker::ICmd
- virtual bool Execute( void );
- virtual bool Acknowledge( void );
- // From CMICmnBase
- /* dtor */ virtual ~CMICmdCmdSource( void );
+ // Overridden:
+ public:
+ // From CMICmdInvoker::ICmd
+ virtual bool Execute(void);
+ virtual bool Acknowledge(void);
+ // From CMICmnBase
+ /* dtor */ virtual ~CMICmdCmdSource(void);
};
diff --git a/tools/lldb-mi/MICmdCmdBreak.cpp b/tools/lldb-mi/MICmdCmdBreak.cpp
index f0e9acfe9082..c338cf0a363d 100644
--- a/tools/lldb-mi/MICmdCmdBreak.cpp
+++ b/tools/lldb-mi/MICmdCmdBreak.cpp
@@ -8,20 +8,20 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdCmdBreak.cpp
+// File: MICmdCmdBreak.cpp
//
-// Overview: CMICmdCmdBreakInsert implementation.
-// CMICmdCmdBreakDelete implementation.
-// CMICmdCmdBreakDisable implementation.
-// CMICmdCmdBreakEnable implementation.
-// CMICmdCmdBreakAfter implementation.
-// CMICmdCmdBreakCondition implementation.
+// Overview: CMICmdCmdBreakInsert implementation.
+// CMICmdCmdBreakDelete implementation.
+// CMICmdCmdBreakDisable implementation.
+// CMICmdCmdBreakEnable implementation.
+// CMICmdCmdBreakAfter implementation.
+// CMICmdCmdBreakCondition implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// Third Party Headers:
@@ -44,308 +44,325 @@
#include "MICmnStreamStdout.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakInsert constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakInsert constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakInsert::CMICmdCmdBreakInsert( void )
-: m_bBrkPtIsTemp( false )
-, m_bBrkPtIsPending( false )
-, m_nBrkPtIgnoreCount( 0 )
-, m_bBrkPtEnabled( false )
-, m_bBrkPtCondition( false )
-, m_bBrkPtThreadId( false )
-, m_nBrkPtThreadId( 0 )
-, m_constStrArgNamedTempBrkPt( "t" )
-, m_constStrArgNamedHWBrkPt( "h" )
-, m_constStrArgNamedPendinfBrkPt( "f" )
-, m_constStrArgNamedDisableBrkPt( "d" )
-, m_constStrArgNamedTracePt( "a" )
-, m_constStrArgNamedConditionalBrkPt( "c" )
-, m_constStrArgNamedInoreCnt( "i" )
-, m_constStrArgNamedRestrictBrkPtToThreadId( "p" )
-, m_constStrArgNamedLocation( "location" )
-, m_constStrArgNamedThreadGroup( "thread-group" )
+CMICmdCmdBreakInsert::CMICmdCmdBreakInsert(void)
+ : m_bBrkPtIsTemp(false)
+ , m_bBrkPtIsPending(false)
+ , m_nBrkPtIgnoreCount(0)
+ , m_bBrkPtEnabled(false)
+ , m_bBrkPtCondition(false)
+ , m_bBrkPtThreadId(false)
+ , m_nBrkPtThreadId(0)
+ , m_constStrArgNamedTempBrkPt("t")
+ , m_constStrArgNamedHWBrkPt("h")
+ , m_constStrArgNamedPendinfBrkPt("f")
+ , m_constStrArgNamedDisableBrkPt("d")
+ , m_constStrArgNamedTracePt("a")
+ , m_constStrArgNamedConditionalBrkPt("c")
+ , m_constStrArgNamedInoreCnt("i")
+ , m_constStrArgNamedRestrictBrkPtToThreadId("p")
+ , m_constStrArgNamedLocation("location")
+ , m_constStrArgNamedThreadGroup("thread-group")
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-insert";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakInsert::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-insert";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakInsert::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakInsert destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakInsert destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakInsert::~CMICmdCmdBreakInsert( void )
+CMICmdCmdBreakInsert::~CMICmdCmdBreakInsert(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakInsert::ParseArgs( void )
+bool
+CMICmdCmdBreakInsert::ParseArgs(void)
{
- bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedTempBrkPt, false, true )) );
- //Not implemented bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedHWBrkPt, false, false ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedPendinfBrkPt, false, true, CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedDisableBrkPt, false, false ) ) );
- //Not implemented bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedTracePt, false, false ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedConditionalBrkPt, false, true, CMICmdArgValListBase::eArgValType_StringQuoted, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedInoreCnt, false, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedRestrictBrkPtToThreadId, false, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgNamedLocation, false, true ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedThreadGroup, false, true, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
- return (bOk && ParseValidateCmdOptions() );
+ bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedTempBrkPt, false, true)));
+ // Not implemented bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedHWBrkPt, false, false ) ) );
+ bOk = bOk &&
+ m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedPendinfBrkPt, false, true,
+ CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedDisableBrkPt, false, false)));
+ // Not implemented bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedTracePt, false, false ) ) );
+ bOk = bOk &&
+ m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedConditionalBrkPt, false, true,
+ CMICmdArgValListBase::eArgValType_StringQuoted, 1)));
+ bOk = bOk &&
+ m_setCmdArgs.Add(
+ *(new CMICmdArgValOptionShort(m_constStrArgNamedInoreCnt, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
+ bOk = bOk &&
+ m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedRestrictBrkPtToThreadId, false, true,
+ CMICmdArgValListBase::eArgValType_Number, 1)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedLocation, false, true)));
+ bOk = bOk &&
+ m_setCmdArgs.Add(
+ *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGroup, false, true, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
+ return (bOk && ParseValidateCmdOptions());
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakInsert::Execute( void )
+bool
+CMICmdCmdBreakInsert::Execute(void)
{
- CMICMDBASE_GETOPTION( pArgTempBrkPt, OptionShort, m_constStrArgNamedTempBrkPt );
- CMICMDBASE_GETOPTION( pArgThreadGroup, OptionLong, m_constStrArgNamedThreadGroup );
- CMICMDBASE_GETOPTION( pArgLocation, String, m_constStrArgNamedLocation );
- CMICMDBASE_GETOPTION( pArgIgnoreCnt, OptionShort, m_constStrArgNamedInoreCnt );
- CMICMDBASE_GETOPTION( pArgPendingBrkPt, OptionShort, m_constStrArgNamedPendinfBrkPt );
- CMICMDBASE_GETOPTION( pArgDisableBrkPt, OptionShort, m_constStrArgNamedDisableBrkPt );
- CMICMDBASE_GETOPTION( pArgConditionalBrkPt, OptionShort, m_constStrArgNamedConditionalBrkPt );
- CMICMDBASE_GETOPTION( pArgRestrictBrkPtToThreadId, OptionShort, m_constStrArgNamedRestrictBrkPtToThreadId );
-
- m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound();
- m_bBrkPtIsTemp = pArgTempBrkPt->GetFound();
- m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound();
- if( m_bHaveArgOptionThreadGrp )
- {
- MIuint nThreadGrp = 0;
- pArgThreadGroup->GetExpectedOption< CMICmdArgValThreadGrp, MIuint >( nThreadGrp );
- m_strArgOptionThreadGrp = CMIUtilString::Format( "i%d", nThreadGrp );
- }
- m_bBrkPtIsPending = pArgPendingBrkPt->GetFound();
- if( pArgLocation->GetFound() )
- m_brkName = pArgLocation->GetValue();
- else if( m_bBrkPtIsPending )
- {
- pArgPendingBrkPt->GetExpectedOption< CMICmdArgValString, CMIUtilString >( m_brkName );
- }
- if( pArgIgnoreCnt->GetFound() )
- {
- pArgIgnoreCnt->GetExpectedOption< CMICmdArgValNumber, MIuint >( m_nBrkPtIgnoreCount );
- }
- m_bBrkPtCondition = pArgConditionalBrkPt->GetFound();
- if( m_bBrkPtCondition )
- {
- pArgConditionalBrkPt->GetExpectedOption< CMICmdArgValString, CMIUtilString >( m_brkPtCondition );
- }
- m_bBrkPtThreadId = pArgRestrictBrkPtToThreadId->GetFound();
- if( m_bBrkPtCondition )
- {
- pArgRestrictBrkPtToThreadId->GetExpectedOption< CMICmdArgValNumber, MIuint >( m_nBrkPtThreadId );
- }
-
- // Determine if break on a file line or at a function
- BreakPoint_e eBrkPtType = eBreakPoint_NotDefineYet;
- const CMIUtilString cColon = ":";
- CMIUtilString fileName;
- MIuint nFileLine = 0;
- CMIUtilString strFileFn;
- const MIint nPosColon = m_brkName.find( cColon );
- if( nPosColon != (MIint) std::string::npos )
- {
- CMIUtilString::VecString_t vecFileAndLocation;
- const MIuint nSplits = m_brkName.Split( cColon, vecFileAndLocation ); MIunused( nSplits );
- if( vecFileAndLocation.size() != 2 )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_LOCATION_FORMAT ), m_cmdData.strMiCmd.c_str(), m_brkName.c_str() ) );
- return MIstatus::failure;
- }
- fileName = vecFileAndLocation.at( 0 );
- const CMIUtilString & rStrLineOrFn( vecFileAndLocation.at( 1 ) );
- if( rStrLineOrFn.empty() )
- eBrkPtType = eBreakPoint_ByName;
- else
- {
- MIint64 nValue = 0;
- if( rStrLineOrFn.ExtractNumber( nValue ) )
- {
- nFileLine = static_cast< MIuint >( nValue );
- eBrkPtType = eBreakPoint_ByFileLine;
- }
- else
- {
- strFileFn = rStrLineOrFn;
- eBrkPtType = eBreakPoint_ByFileFn;
- }
- }
- }
-
- // Determine if break defined as an address
- lldb::addr_t nAddress = 0;
- if( eBrkPtType == eBreakPoint_NotDefineYet )
- {
- MIint64 nValue = 0;
- if( m_brkName.ExtractNumber( nValue ) )
- {
- nAddress = static_cast< lldb::addr_t >( nValue );
- eBrkPtType = eBreakPoint_ByAddress;
- }
- }
-
- // Break defined as an function
- if( eBrkPtType == eBreakPoint_NotDefineYet )
- {
- eBrkPtType = eBreakPoint_ByName;
- }
-
- // Ask LLDB to create a breakpoint
- bool bOk = MIstatus::success;
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- lldb::SBTarget & rTarget = rSessionInfo.m_lldbTarget;
- switch( eBrkPtType )
- {
- case eBreakPoint_ByAddress:
- m_brkPt = rTarget.BreakpointCreateByAddress( nAddress );
- break;
- case eBreakPoint_ByFileFn:
- m_brkPt = rTarget.BreakpointCreateByName( strFileFn.c_str(), fileName.c_str() );
- break;
- case eBreakPoint_ByFileLine:
- m_brkPt = rTarget.BreakpointCreateByLocation( fileName.c_str(), nFileLine );
- break;
- case eBreakPoint_ByName:
- m_brkPt = rTarget.BreakpointCreateByName( m_brkName.c_str(), rTarget.GetExecutable().GetFilename() );
- break;
- case eBreakPoint_count:
- case eBreakPoint_NotDefineYet:
- case eBreakPoint_Invalid:
- bOk = MIstatus::failure;
- break;
- }
-
- if( bOk )
- {
- m_brkPt.SetEnabled( m_bBrkPtEnabled );
- m_brkPt.SetIgnoreCount( m_nBrkPtIgnoreCount );
- if( m_bBrkPtCondition )
- m_brkPt.SetCondition( m_brkPtCondition.c_str() );
- if( m_bBrkPtThreadId )
- m_brkPt.SetThreadID( m_nBrkPtThreadId );
- if( !m_brkPt.IsValid() )
- m_bBrkPtIsPending = pArgPendingBrkPt->GetFound();
- }
-
- // CODETAG_LLDB_BREAKPOINT_CREATION
- // This is in the main thread
- // Record break point information to be by LLDB event handler function
- CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
- sBrkPtInfo.m_id = m_brkPt.GetID();
- sBrkPtInfo.m_bDisp = m_bBrkPtIsTemp;
- sBrkPtInfo.m_bEnabled = m_bBrkPtEnabled;
- sBrkPtInfo.m_bHaveArgOptionThreadGrp = m_bHaveArgOptionThreadGrp;
- sBrkPtInfo.m_strOptThrdGrp = m_strArgOptionThreadGrp;
- sBrkPtInfo.m_strOrigLoc = m_brkName;
- sBrkPtInfo.m_nIgnore = m_nBrkPtIgnoreCount;
- sBrkPtInfo.m_bPending = m_bBrkPtIsPending;
- sBrkPtInfo.m_bCondition = m_bBrkPtCondition;
- sBrkPtInfo.m_strCondition = m_brkPtCondition;
- sBrkPtInfo.m_bBrkPtThreadId = m_bBrkPtThreadId;
- sBrkPtInfo.m_nBrkPtThreadId = m_nBrkPtThreadId;
- bOk = bOk && rSessionInfo.RecordBrkPtInfo( m_brkPt.GetID(), sBrkPtInfo );
-
- if( !bOk )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INVALID ), m_cmdData.strMiCmd.c_str(), m_brkName.c_str() ) );
- return MIstatus::failure;
- }
-
- // CODETAG_LLDB_BRKPT_ID_MAX
- if( m_brkPt.GetID() > (lldb::break_id_t) rSessionInfo.m_nBrkPointCntMax )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_CNT_EXCEEDED ), m_cmdData.strMiCmd.c_str(), rSessionInfo.m_nBrkPointCntMax, m_brkName.c_str() ) );
- return MIstatus::failure;
- }
-
- return MIstatus::success;
+ CMICMDBASE_GETOPTION(pArgTempBrkPt, OptionShort, m_constStrArgNamedTempBrkPt);
+ CMICMDBASE_GETOPTION(pArgThreadGroup, OptionLong, m_constStrArgNamedThreadGroup);
+ CMICMDBASE_GETOPTION(pArgLocation, String, m_constStrArgNamedLocation);
+ CMICMDBASE_GETOPTION(pArgIgnoreCnt, OptionShort, m_constStrArgNamedInoreCnt);
+ CMICMDBASE_GETOPTION(pArgPendingBrkPt, OptionShort, m_constStrArgNamedPendinfBrkPt);
+ CMICMDBASE_GETOPTION(pArgDisableBrkPt, OptionShort, m_constStrArgNamedDisableBrkPt);
+ CMICMDBASE_GETOPTION(pArgConditionalBrkPt, OptionShort, m_constStrArgNamedConditionalBrkPt);
+ CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort, m_constStrArgNamedRestrictBrkPtToThreadId);
+
+ m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound();
+ m_bBrkPtIsTemp = pArgTempBrkPt->GetFound();
+ m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound();
+ if (m_bHaveArgOptionThreadGrp)
+ {
+ MIuint nThreadGrp = 0;
+ pArgThreadGroup->GetExpectedOption<CMICmdArgValThreadGrp, MIuint>(nThreadGrp);
+ m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp);
+ }
+ m_bBrkPtIsPending = pArgPendingBrkPt->GetFound();
+ if (pArgLocation->GetFound())
+ m_brkName = pArgLocation->GetValue();
+ else if (m_bBrkPtIsPending)
+ {
+ pArgPendingBrkPt->GetExpectedOption<CMICmdArgValString, CMIUtilString>(m_brkName);
+ }
+ if (pArgIgnoreCnt->GetFound())
+ {
+ pArgIgnoreCnt->GetExpectedOption<CMICmdArgValNumber, MIuint>(m_nBrkPtIgnoreCount);
+ }
+ m_bBrkPtCondition = pArgConditionalBrkPt->GetFound();
+ if (m_bBrkPtCondition)
+ {
+ pArgConditionalBrkPt->GetExpectedOption<CMICmdArgValString, CMIUtilString>(m_brkPtCondition);
+ }
+ m_bBrkPtThreadId = pArgRestrictBrkPtToThreadId->GetFound();
+ if (m_bBrkPtCondition)
+ {
+ pArgRestrictBrkPtToThreadId->GetExpectedOption<CMICmdArgValNumber, MIuint>(m_nBrkPtThreadId);
+ }
+
+ // Determine if break on a file line or at a function
+ BreakPoint_e eBrkPtType = eBreakPoint_NotDefineYet;
+ const CMIUtilString cColon = ":";
+ CMIUtilString fileName;
+ MIuint nFileLine = 0;
+ CMIUtilString strFileFn;
+ const MIint nPosColon = m_brkName.find(cColon);
+ if (nPosColon != (MIint)std::string::npos)
+ {
+ CMIUtilString::VecString_t vecFileAndLocation;
+ const MIuint nSplits = m_brkName.Split(cColon, vecFileAndLocation);
+ MIunused(nSplits);
+ if (vecFileAndLocation.size() != 2)
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_LOCATION_FORMAT), m_cmdData.strMiCmd.c_str(), m_brkName.c_str()));
+ return MIstatus::failure;
+ }
+ fileName = vecFileAndLocation.at(0);
+ const CMIUtilString &rStrLineOrFn(vecFileAndLocation.at(1));
+ if (rStrLineOrFn.empty())
+ eBrkPtType = eBreakPoint_ByName;
+ else
+ {
+ MIint64 nValue = 0;
+ if (rStrLineOrFn.ExtractNumber(nValue))
+ {
+ nFileLine = static_cast<MIuint>(nValue);
+ eBrkPtType = eBreakPoint_ByFileLine;
+ }
+ else
+ {
+ strFileFn = rStrLineOrFn;
+ eBrkPtType = eBreakPoint_ByFileFn;
+ }
+ }
+ }
+
+ // Determine if break defined as an address
+ lldb::addr_t nAddress = 0;
+ if (eBrkPtType == eBreakPoint_NotDefineYet)
+ {
+ MIint64 nValue = 0;
+ if (m_brkName.ExtractNumber(nValue))
+ {
+ nAddress = static_cast<lldb::addr_t>(nValue);
+ eBrkPtType = eBreakPoint_ByAddress;
+ }
+ }
+
+ // Break defined as an function
+ if (eBrkPtType == eBreakPoint_NotDefineYet)
+ {
+ eBrkPtType = eBreakPoint_ByName;
+ }
+
+ // Ask LLDB to create a breakpoint
+ bool bOk = MIstatus::success;
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBTarget &rTarget = rSessionInfo.m_lldbTarget;
+ switch (eBrkPtType)
+ {
+ case eBreakPoint_ByAddress:
+ m_brkPt = rTarget.BreakpointCreateByAddress(nAddress);
+ break;
+ case eBreakPoint_ByFileFn:
+ m_brkPt = rTarget.BreakpointCreateByName(strFileFn.c_str(), fileName.c_str());
+ break;
+ case eBreakPoint_ByFileLine:
+ m_brkPt = rTarget.BreakpointCreateByLocation(fileName.c_str(), nFileLine);
+ break;
+ case eBreakPoint_ByName:
+ m_brkPt = rTarget.BreakpointCreateByName(m_brkName.c_str(), rTarget.GetExecutable().GetFilename());
+ break;
+ case eBreakPoint_count:
+ case eBreakPoint_NotDefineYet:
+ case eBreakPoint_Invalid:
+ bOk = MIstatus::failure;
+ break;
+ }
+
+ if (bOk)
+ {
+ m_brkPt.SetEnabled(m_bBrkPtEnabled);
+ m_brkPt.SetIgnoreCount(m_nBrkPtIgnoreCount);
+ if (m_bBrkPtCondition)
+ m_brkPt.SetCondition(m_brkPtCondition.c_str());
+ if (m_bBrkPtThreadId)
+ m_brkPt.SetThreadID(m_nBrkPtThreadId);
+ if (!m_brkPt.IsValid())
+ m_bBrkPtIsPending = pArgPendingBrkPt->GetFound();
+ }
+
+ // CODETAG_LLDB_BREAKPOINT_CREATION
+ // This is in the main thread
+ // Record break point information to be by LLDB event handler function
+ CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
+ sBrkPtInfo.m_id = m_brkPt.GetID();
+ sBrkPtInfo.m_bDisp = m_bBrkPtIsTemp;
+ sBrkPtInfo.m_bEnabled = m_bBrkPtEnabled;
+ sBrkPtInfo.m_bHaveArgOptionThreadGrp = m_bHaveArgOptionThreadGrp;
+ sBrkPtInfo.m_strOptThrdGrp = m_strArgOptionThreadGrp;
+ sBrkPtInfo.m_strOrigLoc = m_brkName;
+ sBrkPtInfo.m_nIgnore = m_nBrkPtIgnoreCount;
+ sBrkPtInfo.m_bPending = m_bBrkPtIsPending;
+ sBrkPtInfo.m_bCondition = m_bBrkPtCondition;
+ sBrkPtInfo.m_strCondition = m_brkPtCondition;
+ sBrkPtInfo.m_bBrkPtThreadId = m_bBrkPtThreadId;
+ sBrkPtInfo.m_nBrkPtThreadId = m_nBrkPtThreadId;
+ bOk = bOk && rSessionInfo.RecordBrkPtInfo(m_brkPt.GetID(), sBrkPtInfo);
+
+ if (!bOk)
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), m_brkName.c_str()));
+ return MIstatus::failure;
+ }
+
+ // CODETAG_LLDB_BRKPT_ID_MAX
+ if (m_brkPt.GetID() > (lldb::break_id_t)rSessionInfo.m_nBrkPointCntMax)
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_CNT_EXCEEDED), m_cmdData.strMiCmd.c_str(), rSessionInfo.m_nBrkPointCntMax,
+ m_brkName.c_str()));
+ return MIstatus::failure;
+ }
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakInsert::Acknowledge( void )
+bool
+CMICmdCmdBreakInsert::Acknowledge(void)
{
- // Get breakpoint information
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
- if( !rSessionInfo.GetBrkPtInfo( m_brkPt, sBrkPtInfo ) )
- {
- return MIstatus::failure;
- }
-
- // CODETAG_LLDB_BREAKPOINT_CREATION
- // Add more breakpoint information or overwrite existing information
- sBrkPtInfo.m_bDisp = m_bBrkPtIsTemp;
- sBrkPtInfo.m_bEnabled = m_bBrkPtEnabled;
- sBrkPtInfo.m_bHaveArgOptionThreadGrp = m_bHaveArgOptionThreadGrp;
- sBrkPtInfo.m_strOptThrdGrp = m_strArgOptionThreadGrp;
- sBrkPtInfo.m_nTimes = m_brkPt.GetNumLocations();
- sBrkPtInfo.m_strOrigLoc = m_brkName;
- sBrkPtInfo.m_nIgnore = m_nBrkPtIgnoreCount;
- sBrkPtInfo.m_bPending = m_bBrkPtIsPending;
- sBrkPtInfo.m_bCondition = m_bBrkPtCondition;
- sBrkPtInfo.m_strCondition = m_brkPtCondition;
- sBrkPtInfo.m_bBrkPtThreadId = m_bBrkPtThreadId;
- sBrkPtInfo.m_nBrkPtThreadId = m_nBrkPtThreadId;
-
- // MI print "^done,bkpt={number=\"%d\",type=\"breakpoint\",disp=\"%s\",enabled=\"%c\",addr=\"0x%08x\",func=\"%s\",file=\"%s\",fullname=\"%s/%s\",line=\"%d\",thread-groups=[\"%s\"],times=\"%d\",original-location=\"%s\"}"
- CMICmnMIValueTuple miValueTuple;
- if( !rSessionInfo.MIResponseFormBrkPtInfo( sBrkPtInfo, miValueTuple ) )
- {
- return MIstatus::failure;
- }
-
- const CMICmnMIValueResult miValueResultD( "bkpt", miValueTuple );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResultD );
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+ // Get breakpoint information
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
+ if (!rSessionInfo.GetBrkPtInfo(m_brkPt, sBrkPtInfo))
+ {
+ return MIstatus::failure;
+ }
+
+ // CODETAG_LLDB_BREAKPOINT_CREATION
+ // Add more breakpoint information or overwrite existing information
+ sBrkPtInfo.m_bDisp = m_bBrkPtIsTemp;
+ sBrkPtInfo.m_bEnabled = m_bBrkPtEnabled;
+ sBrkPtInfo.m_bHaveArgOptionThreadGrp = m_bHaveArgOptionThreadGrp;
+ sBrkPtInfo.m_strOptThrdGrp = m_strArgOptionThreadGrp;
+ sBrkPtInfo.m_nTimes = m_brkPt.GetNumLocations();
+ sBrkPtInfo.m_strOrigLoc = m_brkName;
+ sBrkPtInfo.m_nIgnore = m_nBrkPtIgnoreCount;
+ sBrkPtInfo.m_bPending = m_bBrkPtIsPending;
+ sBrkPtInfo.m_bCondition = m_bBrkPtCondition;
+ sBrkPtInfo.m_strCondition = m_brkPtCondition;
+ sBrkPtInfo.m_bBrkPtThreadId = m_bBrkPtThreadId;
+ sBrkPtInfo.m_nBrkPtThreadId = m_nBrkPtThreadId;
+
+ // MI print
+ // "^done,bkpt={number=\"%d\",type=\"breakpoint\",disp=\"%s\",enabled=\"%c\",addr=\"0x%08x\",func=\"%s\",file=\"%s\",fullname=\"%s/%s\",line=\"%d\",thread-groups=[\"%s\"],times=\"%d\",original-location=\"%s\"}"
+ CMICmnMIValueTuple miValueTuple;
+ if (!rSessionInfo.MIResponseFormBrkPtInfo(sBrkPtInfo, miValueTuple))
+ {
+ return MIstatus::failure;
+ }
+
+ const CMICmnMIValueResult miValueResultD("bkpt", miValueTuple);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResultD);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdBreakInsert::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdBreakInsert::CreateSelf(void)
{
- return new CMICmdCmdBreakInsert();
+ return new CMICmdCmdBreakInsert();
}
//---------------------------------------------------------------------------------------
@@ -353,111 +370,117 @@ CMICmdBase * CMICmdCmdBreakInsert::CreateSelf( void )
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakDelete constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakDelete constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakDelete::CMICmdCmdBreakDelete( void )
-: m_constStrArgNamedBrkPt( "breakpoint" )
-, m_constStrArgNamedThreadGrp( "thread-group" )
+CMICmdCmdBreakDelete::CMICmdCmdBreakDelete(void)
+ : m_constStrArgNamedBrkPt("breakpoint")
+ , m_constStrArgNamedThreadGrp("thread-group")
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-delete";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakDelete::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-delete";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakDelete::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakDelete destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakDelete destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakDelete::~CMICmdCmdBreakDelete( void )
+CMICmdCmdBreakDelete::~CMICmdCmdBreakDelete(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakDelete::ParseArgs( void )
+bool
+CMICmdCmdBreakDelete::ParseArgs(void)
{
- bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number ) ) );
- return (bOk && ParseValidateCmdOptions() );
+ bool bOk = m_setCmdArgs.Add(
+ *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
+ bOk =
+ bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number)));
+ return (bOk && ParseValidateCmdOptions());
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakDelete::Execute( void )
+bool
+CMICmdCmdBreakDelete::Execute(void)
{
- CMICMDBASE_GETOPTION( pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt );
-
- // ATM we only handle one break point ID
- MIuint64 nBrk = UINT64_MAX;
- if( !pArgBrkPt->GetExpectedOption< CMICmdArgValNumber, MIuint64 >( nBrk ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INVALID ), m_cmdData.strMiCmd.c_str(), m_constStrArgNamedBrkPt.c_str() ) );
- return MIstatus::failure;
- }
-
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- const bool bBrkPt = rSessionInfo.m_lldbTarget.BreakpointDelete( static_cast< lldb::break_id_t >( nBrk ) );
- if( !bBrkPt )
- {
- const CMIUtilString strBrkNum( CMIUtilString::Format( "%d", nBrk ) );
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INVALID ), m_cmdData.strMiCmd.c_str(), strBrkNum.c_str() ) );
- return MIstatus::failure;
- }
-
- return MIstatus::success;
+ CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
+
+ // ATM we only handle one break point ID
+ MIuint64 nBrk = UINT64_MAX;
+ if (!pArgBrkPt->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nBrk))
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgNamedBrkPt.c_str()));
+ return MIstatus::failure;
+ }
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ const bool bBrkPt = rSessionInfo.m_lldbTarget.BreakpointDelete(static_cast<lldb::break_id_t>(nBrk));
+ if (!bBrkPt)
+ {
+ const CMIUtilString strBrkNum(CMIUtilString::Format("%d", nBrk));
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), strBrkNum.c_str()));
+ return MIstatus::failure;
+ }
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakDelete::Acknowledge( void )
+bool
+CMICmdCmdBreakDelete::Acknowledge(void)
{
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done );
- m_miResultRecord = miRecordResult;
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
- return MIstatus::success;
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdBreakDelete::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdBreakDelete::CreateSelf(void)
{
- return new CMICmdCmdBreakDelete();
+ return new CMICmdCmdBreakDelete();
}
//---------------------------------------------------------------------------------------
@@ -465,133 +488,139 @@ CMICmdBase * CMICmdCmdBreakDelete::CreateSelf( void )
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakDisable constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakDisable constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakDisable::CMICmdCmdBreakDisable( void )
-: m_constStrArgNamedThreadGrp( "thread-group" )
-, m_constStrArgNamedBrkPt( "breakpoint" )
-, m_bBrkPtDisabledOk( false )
-, m_nBrkPtId( 0 )
+CMICmdCmdBreakDisable::CMICmdCmdBreakDisable(void)
+ : m_constStrArgNamedThreadGrp("thread-group")
+ , m_constStrArgNamedBrkPt("breakpoint")
+ , m_bBrkPtDisabledOk(false)
+ , m_nBrkPtId(0)
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-disable";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakDisable::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-disable";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakDisable::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakDisable destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakDisable destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakDisable::~CMICmdCmdBreakDisable( void )
+CMICmdCmdBreakDisable::~CMICmdCmdBreakDisable(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakDisable::ParseArgs( void )
+bool
+CMICmdCmdBreakDisable::ParseArgs(void)
{
- bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number ) ) );
- return (bOk && ParseValidateCmdOptions() );
+ bool bOk = m_setCmdArgs.Add(
+ *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
+ bOk =
+ bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number)));
+ return (bOk && ParseValidateCmdOptions());
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakDisable::Execute( void )
+bool
+CMICmdCmdBreakDisable::Execute(void)
{
- CMICMDBASE_GETOPTION( pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt );
-
- // ATM we only handle one break point ID
- MIuint64 nBrk = UINT64_MAX;
- if( !pArgBrkPt->GetExpectedOption< CMICmdArgValNumber, MIuint64 >( nBrk ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INVALID ), m_cmdData.strMiCmd.c_str(), m_constStrArgNamedBrkPt.c_str() ) );
- return MIstatus::failure;
- }
-
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID( static_cast< lldb::break_id_t >( nBrk ) );
- if( brkPt.IsValid() )
- {
- m_bBrkPtDisabledOk = true;
- brkPt.SetEnabled( false );
- m_nBrkPtId = nBrk;
- }
-
- return MIstatus::success;
+ CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
+
+ // ATM we only handle one break point ID
+ MIuint64 nBrk = UINT64_MAX;
+ if (!pArgBrkPt->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nBrk))
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgNamedBrkPt.c_str()));
+ return MIstatus::failure;
+ }
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID(static_cast<lldb::break_id_t>(nBrk));
+ if (brkPt.IsValid())
+ {
+ m_bBrkPtDisabledOk = true;
+ brkPt.SetEnabled(false);
+ m_nBrkPtId = nBrk;
+ }
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakDisable::Acknowledge( void )
+bool
+CMICmdCmdBreakDisable::Acknowledge(void)
{
- if( m_bBrkPtDisabledOk )
- {
- const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "%d", m_nBrkPtId ) );
- const CMICmnMIValueResult miValueResult( "number", miValueConst );
- CMICmnMIValueTuple miValueTuple( miValueResult );
- const CMICmnMIValueConst miValueConst2( "n" );
- const CMICmnMIValueResult miValueResult2( "enabled", miValueConst2 );
- bool bOk = miValueTuple.Add( miValueResult2 );
- const CMICmnMIValueResult miValueResult3( "bkpt", miValueTuple );
- const CMICmnMIOutOfBandRecord miOutOfBandRecord( CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3 );
- bOk = bOk && CMICmnStreamStdout::TextToStdout( miOutOfBandRecord.GetString() );
-
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done );
- m_miResultRecord = miRecordResult;
- return bOk;
- }
-
- const CMIUtilString strBrkPtId( CMIUtilString::Format( "%d", m_nBrkPtId ) );
- const CMICmnMIValueConst miValueConst( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INVALID ), strBrkPtId.c_str() ) );
- const CMICmnMIValueResult miValueResult( "msg", miValueConst );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult );
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+ if (m_bBrkPtDisabledOk)
+ {
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", m_nBrkPtId));
+ const CMICmnMIValueResult miValueResult("number", miValueConst);
+ CMICmnMIValueTuple miValueTuple(miValueResult);
+ const CMICmnMIValueConst miValueConst2("n");
+ const CMICmnMIValueResult miValueResult2("enabled", miValueConst2);
+ bool bOk = miValueTuple.Add(miValueResult2);
+ const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple);
+ const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3);
+ bOk = bOk && CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString());
+
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+ return bOk;
+ }
+
+ const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), strBrkPtId.c_str()));
+ const CMICmnMIValueResult miValueResult("msg", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdBreakDisable::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdBreakDisable::CreateSelf(void)
{
- return new CMICmdCmdBreakDisable();
+ return new CMICmdCmdBreakDisable();
}
//---------------------------------------------------------------------------------------
@@ -599,133 +628,139 @@ CMICmdBase * CMICmdCmdBreakDisable::CreateSelf( void )
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakEnable constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakEnable constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakEnable::CMICmdCmdBreakEnable( void )
-: m_constStrArgNamedThreadGrp( "thread-group" )
-, m_constStrArgNamedBrkPt( "breakpoint" )
-, m_bBrkPtEnabledOk( false )
-, m_nBrkPtId( 0 )
+CMICmdCmdBreakEnable::CMICmdCmdBreakEnable(void)
+ : m_constStrArgNamedThreadGrp("thread-group")
+ , m_constStrArgNamedBrkPt("breakpoint")
+ , m_bBrkPtEnabledOk(false)
+ , m_nBrkPtId(0)
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-enable";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakEnable::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-enable";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakEnable::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakEnable destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakEnable destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakEnable::~CMICmdCmdBreakEnable( void )
+CMICmdCmdBreakEnable::~CMICmdCmdBreakEnable(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakEnable::ParseArgs( void )
+bool
+CMICmdCmdBreakEnable::ParseArgs(void)
{
- bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number ) ) );
- return (bOk && ParseValidateCmdOptions() );
+ bool bOk = m_setCmdArgs.Add(
+ *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
+ bOk =
+ bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number)));
+ return (bOk && ParseValidateCmdOptions());
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakEnable::Execute( void )
+bool
+CMICmdCmdBreakEnable::Execute(void)
{
- CMICMDBASE_GETOPTION( pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt );
-
- // ATM we only handle one break point ID
- MIuint64 nBrk = UINT64_MAX;
- if( !pArgBrkPt->GetExpectedOption< CMICmdArgValNumber, MIuint64 >( nBrk ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INVALID ), m_cmdData.strMiCmd.c_str(), m_constStrArgNamedBrkPt.c_str() ) );
- return MIstatus::failure;
- }
-
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID( static_cast< lldb::break_id_t >( nBrk ) );
- if( brkPt.IsValid() )
- {
- m_bBrkPtEnabledOk = true;
- brkPt.SetEnabled( false );
- m_nBrkPtId = nBrk;
- }
-
- return MIstatus::success;
+ CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
+
+ // ATM we only handle one break point ID
+ MIuint64 nBrk = UINT64_MAX;
+ if (!pArgBrkPt->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nBrk))
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgNamedBrkPt.c_str()));
+ return MIstatus::failure;
+ }
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID(static_cast<lldb::break_id_t>(nBrk));
+ if (brkPt.IsValid())
+ {
+ m_bBrkPtEnabledOk = true;
+ brkPt.SetEnabled(false);
+ m_nBrkPtId = nBrk;
+ }
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakEnable::Acknowledge( void )
+bool
+CMICmdCmdBreakEnable::Acknowledge(void)
{
- if( m_bBrkPtEnabledOk )
- {
- const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "%d", m_nBrkPtId ) );
- const CMICmnMIValueResult miValueResult( "number", miValueConst );
- CMICmnMIValueTuple miValueTuple( miValueResult );
- const CMICmnMIValueConst miValueConst2( "y" );
- const CMICmnMIValueResult miValueResult2( "enabled", miValueConst2 );
- bool bOk = miValueTuple.Add( miValueResult2 );
- const CMICmnMIValueResult miValueResult3( "bkpt", miValueTuple );
- const CMICmnMIOutOfBandRecord miOutOfBandRecord( CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3 );
- bOk = bOk && CMICmnStreamStdout::TextToStdout( miOutOfBandRecord.GetString() );
-
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done );
- m_miResultRecord = miRecordResult;
- return bOk;
- }
-
- const CMIUtilString strBrkPtId( CMIUtilString::Format( "%d", m_nBrkPtId ) );
- const CMICmnMIValueConst miValueConst( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INVALID ), strBrkPtId.c_str() ) );
- const CMICmnMIValueResult miValueResult( "msg", miValueConst );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult );
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+ if (m_bBrkPtEnabledOk)
+ {
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", m_nBrkPtId));
+ const CMICmnMIValueResult miValueResult("number", miValueConst);
+ CMICmnMIValueTuple miValueTuple(miValueResult);
+ const CMICmnMIValueConst miValueConst2("y");
+ const CMICmnMIValueResult miValueResult2("enabled", miValueConst2);
+ bool bOk = miValueTuple.Add(miValueResult2);
+ const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple);
+ const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3);
+ bOk = bOk && CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString());
+
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+ return bOk;
+ }
+
+ const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), strBrkPtId.c_str()));
+ const CMICmnMIValueResult miValueResult("msg", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdBreakEnable::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdBreakEnable::CreateSelf(void)
{
- return new CMICmdCmdBreakEnable();
+ return new CMICmdCmdBreakEnable();
}
//---------------------------------------------------------------------------------------
@@ -733,124 +768,129 @@ CMICmdBase * CMICmdCmdBreakEnable::CreateSelf( void )
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakAfter constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakAfter constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakAfter::CMICmdCmdBreakAfter( void )
-: m_constStrArgNamedThreadGrp( "thread-group" )
-, m_constStrArgNamedNumber( "number" )
-, m_constStrArgNamedCount( "count" )
-, m_nBrkPtId( 0 )
-, m_nBrkPtCount( 0 )
+CMICmdCmdBreakAfter::CMICmdCmdBreakAfter(void)
+ : m_constStrArgNamedThreadGrp("thread-group")
+ , m_constStrArgNamedNumber("number")
+ , m_constStrArgNamedCount("count")
+ , m_nBrkPtId(0)
+ , m_nBrkPtCount(0)
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-after";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakAfter::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-after";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakAfter::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakAfter destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakAfter destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakAfter::~CMICmdCmdBreakAfter( void )
+CMICmdCmdBreakAfter::~CMICmdCmdBreakAfter(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakAfter::ParseArgs( void )
+bool
+CMICmdCmdBreakAfter::ParseArgs(void)
{
- bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNamedNumber, true, true ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNamedCount, true, true ) ) );
- return (bOk && ParseValidateCmdOptions() );
+ bool bOk = m_setCmdArgs.Add(
+ *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNamedCount, true, true)));
+ return (bOk && ParseValidateCmdOptions());
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakAfter::Execute( void )
+bool
+CMICmdCmdBreakAfter::Execute(void)
{
- CMICMDBASE_GETOPTION( pArgNumber, Number, m_constStrArgNamedNumber );
- CMICMDBASE_GETOPTION( pArgCount, Number, m_constStrArgNamedCount );
-
- m_nBrkPtId = pArgNumber->GetValue();
- m_nBrkPtCount = pArgCount->GetValue();
-
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID( static_cast< lldb::break_id_t >( m_nBrkPtId ) );
- if( brkPt.IsValid() )
- {
- brkPt.SetIgnoreCount( m_nBrkPtCount );
-
- CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
- if( !rSessionInfo.RecordBrkPtInfoGet( m_nBrkPtId, sBrkPtInfo ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INFO_OBJ_NOT_FOUND ), m_cmdData.strMiCmd.c_str(), m_nBrkPtId ) );
- return MIstatus::failure;
- }
- sBrkPtInfo.m_nIgnore = m_nBrkPtCount;
- rSessionInfo.RecordBrkPtInfo( m_nBrkPtId, sBrkPtInfo );
- }
- else
- {
- const CMIUtilString strBrkPtId( CMIUtilString::Format( "%d", m_nBrkPtId ) );
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INVALID ), m_cmdData.strMiCmd.c_str(), strBrkPtId.c_str() ) );
- return MIstatus::failure;
- }
-
- return MIstatus::success;
+ CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNamedNumber);
+ CMICMDBASE_GETOPTION(pArgCount, Number, m_constStrArgNamedCount);
+
+ m_nBrkPtId = pArgNumber->GetValue();
+ m_nBrkPtCount = pArgCount->GetValue();
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID(static_cast<lldb::break_id_t>(m_nBrkPtId));
+ if (brkPt.IsValid())
+ {
+ brkPt.SetIgnoreCount(m_nBrkPtCount);
+
+ CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
+ if (!rSessionInfo.RecordBrkPtInfoGet(m_nBrkPtId, sBrkPtInfo))
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INFO_OBJ_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_nBrkPtId));
+ return MIstatus::failure;
+ }
+ sBrkPtInfo.m_nIgnore = m_nBrkPtCount;
+ rSessionInfo.RecordBrkPtInfo(m_nBrkPtId, sBrkPtInfo);
+ }
+ else
+ {
+ const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), strBrkPtId.c_str()));
+ return MIstatus::failure;
+ }
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakAfter::Acknowledge( void )
+bool
+CMICmdCmdBreakAfter::Acknowledge(void)
{
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done );
- m_miResultRecord = miRecordResult;
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
- return MIstatus::success;
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdBreakAfter::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdBreakAfter::CreateSelf(void)
{
- return new CMICmdCmdBreakAfter();
+ return new CMICmdCmdBreakAfter();
}
//---------------------------------------------------------------------------------------
@@ -858,169 +898,178 @@ CMICmdBase * CMICmdCmdBreakAfter::CreateSelf( void )
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakCondition constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakCondition constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakCondition::CMICmdCmdBreakCondition( void )
-: m_constStrArgNamedThreadGrp( "thread-group" )
-, m_constStrArgNamedNumber( "number" )
-, m_constStrArgNamedExpr( "expr" )
-, m_constStrArgNamedExprNoQuotes( "expression not surround by quotes" ) // Not specified in MI spec, we need to handle expressions not surrounded by quotes
-, m_nBrkPtId( 0 )
+CMICmdCmdBreakCondition::CMICmdCmdBreakCondition(void)
+ : m_constStrArgNamedThreadGrp("thread-group")
+ , m_constStrArgNamedNumber("number")
+ , m_constStrArgNamedExpr("expr")
+ , m_constStrArgNamedExprNoQuotes(
+ "expression not surround by quotes") // Not specified in MI spec, we need to handle expressions not surrounded by quotes
+ , m_nBrkPtId(0)
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-condition";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakCondition::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-condition";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakCondition::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdBreakCondition destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdBreakCondition destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdBreakCondition::~CMICmdCmdBreakCondition( void )
+CMICmdCmdBreakCondition::~CMICmdCmdBreakCondition(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakCondition::ParseArgs( void )
+bool
+CMICmdCmdBreakCondition::ParseArgs(void)
{
- bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNamedNumber, true, true ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgNamedExpr, true, true, true, true ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgNamedExprNoQuotes, true, false, CMICmdArgValListBase::eArgValType_StringQuotedNumber ) ) );
- return (bOk && ParseValidateCmdOptions() );
+ bool bOk = m_setCmdArgs.Add(
+ *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedExpr, true, true, true, true)));
+ bOk = bOk &&
+ m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgNamedExprNoQuotes, true, false,
+ CMICmdArgValListBase::eArgValType_StringQuotedNumber)));
+ return (bOk && ParseValidateCmdOptions());
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakCondition::Execute( void )
+bool
+CMICmdCmdBreakCondition::Execute(void)
{
- CMICMDBASE_GETOPTION( pArgNumber, Number, m_constStrArgNamedNumber );
- CMICMDBASE_GETOPTION( pArgExpr, String, m_constStrArgNamedExpr );
-
- m_nBrkPtId = pArgNumber->GetValue();
- m_strBrkPtExpr = pArgExpr->GetValue();
- m_strBrkPtExpr += GetRestOfExpressionNotSurroundedInQuotes();
-
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID( static_cast< lldb::break_id_t >( m_nBrkPtId ) );
- if( brkPt.IsValid() )
- {
- brkPt.SetCondition( m_strBrkPtExpr.c_str() );
-
- CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
- if( !rSessionInfo.RecordBrkPtInfoGet( m_nBrkPtId, sBrkPtInfo ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INFO_OBJ_NOT_FOUND ), m_cmdData.strMiCmd.c_str(), m_nBrkPtId ) );
- return MIstatus::failure;
- }
- sBrkPtInfo.m_strCondition = m_strBrkPtExpr;
- rSessionInfo.RecordBrkPtInfo( m_nBrkPtId, sBrkPtInfo );
- }
- else
- {
- const CMIUtilString strBrkPtId( CMIUtilString::Format( "%d", m_nBrkPtId ) );
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INVALID ), m_cmdData.strMiCmd.c_str(), strBrkPtId.c_str() ) );
- return MIstatus::failure;
- }
-
- return MIstatus::success;
+ CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNamedNumber);
+ CMICMDBASE_GETOPTION(pArgExpr, String, m_constStrArgNamedExpr);
+
+ m_nBrkPtId = pArgNumber->GetValue();
+ m_strBrkPtExpr = pArgExpr->GetValue();
+ m_strBrkPtExpr += GetRestOfExpressionNotSurroundedInQuotes();
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID(static_cast<lldb::break_id_t>(m_nBrkPtId));
+ if (brkPt.IsValid())
+ {
+ brkPt.SetCondition(m_strBrkPtExpr.c_str());
+
+ CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
+ if (!rSessionInfo.RecordBrkPtInfoGet(m_nBrkPtId, sBrkPtInfo))
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INFO_OBJ_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_nBrkPtId));
+ return MIstatus::failure;
+ }
+ sBrkPtInfo.m_strCondition = m_strBrkPtExpr;
+ rSessionInfo.RecordBrkPtInfo(m_nBrkPtId, sBrkPtInfo);
+ }
+ else
+ {
+ const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), strBrkPtId.c_str()));
+ return MIstatus::failure;
+ }
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdBreakCondition::Acknowledge( void )
+bool
+CMICmdCmdBreakCondition::Acknowledge(void)
{
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done );
- m_miResultRecord = miRecordResult;
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
- return MIstatus::success;
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdBreakCondition::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdBreakCondition::CreateSelf(void)
{
- return new CMICmdCmdBreakCondition();
+ return new CMICmdCmdBreakCondition();
}
//++ ------------------------------------------------------------------------------------
-// Details: A breakpoint expression can be passed to *this command as:
-// a single string i.e. '2' -> ok.
-// a quoted string i.e. "a > 100" -> ok
-// a non quoted string i.e. 'a > 100' -> not ok
-// CMICmdArgValString only extracts the first space seperated string, the "a".
-// This function using the optional argument type CMICmdArgValListOfN collects
-// the rest of the expression so that is may be added to the 'a' part to form a
-// complete expression string i.e. "a > 100".
-// If the expression value was guaranteed to be surrounded by quotes them this
-// function would not be necessary.
-// Type: Method.
-// Args: None.
-// Return: CMIUtilString - Rest of the breakpoint expression.
-// Throws: None.
+// Details: A breakpoint expression can be passed to *this command as:
+// a single string i.e. '2' -> ok.
+// a quoted string i.e. "a > 100" -> ok
+// a non quoted string i.e. 'a > 100' -> not ok
+// CMICmdArgValString only extracts the first space seperated string, the "a".
+// This function using the optional argument type CMICmdArgValListOfN collects
+// the rest of the expression so that is may be added to the 'a' part to form a
+// complete expression string i.e. "a > 100".
+// If the expression value was guaranteed to be surrounded by quotes them this
+// function would not be necessary.
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString - Rest of the breakpoint expression.
+// Throws: None.
//--
-CMIUtilString CMICmdCmdBreakCondition::GetRestOfExpressionNotSurroundedInQuotes( void )
+CMIUtilString
+CMICmdCmdBreakCondition::GetRestOfExpressionNotSurroundedInQuotes(void)
{
- CMIUtilString strExpression;
-
- CMICmdArgValListOfN * pArgExprNoQuotes = CMICmdBase::GetOption< CMICmdArgValListOfN >( m_constStrArgNamedExprNoQuotes );
- if( pArgExprNoQuotes != nullptr )
- {
- CMIUtilString strExpression;
- const CMICmdArgValListBase::VecArgObjPtr_t & rVecExprParts( pArgExprNoQuotes->GetExpectedOptions() );
- if( !rVecExprParts.empty() )
- {
- CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecExprParts.begin();
- while( it != rVecExprParts.end() )
- {
- const CMICmdArgValString * pPartExpr = static_cast< CMICmdArgValString * >( *it );
- const CMIUtilString & rPartExpr = pPartExpr->GetValue();
- strExpression += " ";
- strExpression += rPartExpr;
-
- // Next
- ++it;
- }
- strExpression = strExpression.Trim();
- }
- }
-
- return strExpression;
+ CMIUtilString strExpression;
+
+ CMICmdArgValListOfN *pArgExprNoQuotes = CMICmdBase::GetOption<CMICmdArgValListOfN>(m_constStrArgNamedExprNoQuotes);
+ if (pArgExprNoQuotes != nullptr)
+ {
+ CMIUtilString strExpression;
+ const CMICmdArgValListBase::VecArgObjPtr_t &rVecExprParts(pArgExprNoQuotes->GetExpectedOptions());
+ if (!rVecExprParts.empty())
+ {
+ CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecExprParts.begin();
+ while (it != rVecExprParts.end())
+ {
+ const CMICmdArgValString *pPartExpr = static_cast<CMICmdArgValString *>(*it);
+ const CMIUtilString &rPartExpr = pPartExpr->GetValue();
+ strExpression += " ";
+ strExpression += rPartExpr;
+
+ // Next
+ ++it;
+ }
+ strExpression = strExpression.Trim();
+ }
+ }
+
+ return strExpression;
}
diff --git a/tools/lldb-mi/MICmdCmdBreak.h b/tools/lldb-mi/MICmdCmdBreak.h
index e5283d609905..c9540b0521eb 100644
--- a/tools/lldb-mi/MICmdCmdBreak.h
+++ b/tools/lldb-mi/MICmdCmdBreak.h
@@ -8,29 +8,29 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdCmdBreak.h
+// File: MICmdCmdBreak.h
//
-// Overview: CMICmdCmdBreakInsert interface.
-// CMICmdCmdBreakDelete interface.
-// CMICmdCmdBreakDisable interface.
-// CMICmdCmdBreakEnable interface.
-// CMICmdCmdBreakAfter interface.
-// CMICmdCmdBreakCondition interface.
+// Overview: CMICmdCmdBreakInsert interface.
+// CMICmdCmdBreakDelete interface.
+// CMICmdCmdBreakDisable interface.
+// CMICmdCmdBreakEnable interface.
+// CMICmdCmdBreakAfter interface.
+// CMICmdCmdBreakCondition interface.
//
-// To implement new MI commands derive a new command class from the command base
-// class. To enable the new command for interpretation add the new command class
-// to the command factory. The files of relevance are:
-// MICmdCommands.cpp
-// MICmdBase.h / .cpp
-// MICmdCmd.h / .cpp
-// For an introduction to adding a new command see CMICmdCmdSupportInfoMiCmdQuery
-// command class as an example.
+// To implement new MI commands derive a new command class from the command base
+// class. To enable the new command for interpretation add the new command class
+// to the command factory. The files of relevance are:
+// MICmdCommands.cpp
+// MICmdBase.h / .cpp
+// MICmdCmd.h / .cpp
+// For an introduction to adding a new command see CMICmdCmdSupportInfoMiCmdQuery
+// command class as an example.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
@@ -42,251 +42,251 @@
#include "MICmdBase.h"
//++ ============================================================================
-// Details: MI command class. MI commands derived from the command base class.
-// *this class implements MI command "break-insert".
-// This command does not follow the MI documentation exactly.
-// Gotchas: None.
-// Authors: Illya Rudkin 11/03/2014.
-// Changes: None.
+// Details: MI command class. MI commands derived from the command base class.
+// *this class implements MI command "break-insert".
+// This command does not follow the MI documentation exactly.
+// Gotchas: None.
+// Authors: Illya Rudkin 11/03/2014.
+// Changes: None.
//--
class CMICmdCmdBreakInsert : public CMICmdBase
{
-// Statics:
-public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase * CreateSelf( void );
+ // Statics:
+ public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf(void);
-// Methods:
-public:
- /* ctor */ CMICmdCmdBreakInsert( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdCmdBreakInsert(void);
-// Overridden:
-public:
- // From CMICmdInvoker::ICmd
- virtual bool Execute( void );
- virtual bool Acknowledge( void );
- virtual bool ParseArgs( void );
- // From CMICmnBase
- /* dtor */ virtual ~CMICmdCmdBreakInsert( void );
+ // Overridden:
+ public:
+ // From CMICmdInvoker::ICmd
+ virtual bool Execute(void);
+ virtual bool Acknowledge(void);
+ virtual bool ParseArgs(void);
+ // From CMICmnBase
+ /* dtor */ virtual ~CMICmdCmdBreakInsert(void);
-// Enumerations:
-private:
- //++ ===================================================================
- // Details: The type of break point give in the MI command text.
- //--
- enum BreakPoint_e
- {
- eBreakPoint_Invalid = 0,
- eBreakPoint_ByFileLine,
- eBreakPoint_ByFileFn,
- eBreakPoint_ByName,
- eBreakPoint_ByAddress,
- eBreakPoint_count,
- eBreakPoint_NotDefineYet
- };
+ // Enumerations:
+ private:
+ //++ ===================================================================
+ // Details: The type of break point give in the MI command text.
+ //--
+ enum BreakPoint_e
+ {
+ eBreakPoint_Invalid = 0,
+ eBreakPoint_ByFileLine,
+ eBreakPoint_ByFileFn,
+ eBreakPoint_ByName,
+ eBreakPoint_ByAddress,
+ eBreakPoint_count,
+ eBreakPoint_NotDefineYet
+ };
-// Attributes:
-private:
- bool m_bBrkPtIsTemp;
- bool m_bHaveArgOptionThreadGrp;
- CMIUtilString m_brkName;
- CMIUtilString m_strArgOptionThreadGrp;
- lldb::SBBreakpoint m_brkPt;
- bool m_bBrkPtIsPending;
- MIuint m_nBrkPtIgnoreCount;
- bool m_bBrkPtEnabled;
- bool m_bBrkPtCondition;
- CMIUtilString m_brkPtCondition;
- bool m_bBrkPtThreadId;
- MIuint m_nBrkPtThreadId;
- const CMIUtilString m_constStrArgNamedTempBrkPt;
- const CMIUtilString m_constStrArgNamedHWBrkPt; // Not handled by *this command
- const CMIUtilString m_constStrArgNamedPendinfBrkPt;
- const CMIUtilString m_constStrArgNamedDisableBrkPt;
- const CMIUtilString m_constStrArgNamedTracePt; // Not handled by *this command
- const CMIUtilString m_constStrArgNamedConditionalBrkPt;
- const CMIUtilString m_constStrArgNamedInoreCnt;
- const CMIUtilString m_constStrArgNamedRestrictBrkPtToThreadId;
- const CMIUtilString m_constStrArgNamedLocation;
- const CMIUtilString m_constStrArgNamedThreadGroup; // Not specified in MI spec but Eclipse gives this option sometimes
+ // Attributes:
+ private:
+ bool m_bBrkPtIsTemp;
+ bool m_bHaveArgOptionThreadGrp;
+ CMIUtilString m_brkName;
+ CMIUtilString m_strArgOptionThreadGrp;
+ lldb::SBBreakpoint m_brkPt;
+ bool m_bBrkPtIsPending;
+ MIuint m_nBrkPtIgnoreCount;
+ bool m_bBrkPtEnabled;
+ bool m_bBrkPtCondition;
+ CMIUtilString m_brkPtCondition;
+ bool m_bBrkPtThreadId;
+ MIuint m_nBrkPtThreadId;
+ const CMIUtilString m_constStrArgNamedTempBrkPt;
+ const CMIUtilString m_constStrArgNamedHWBrkPt; // Not handled by *this command
+ const CMIUtilString m_constStrArgNamedPendinfBrkPt;
+ const CMIUtilString m_constStrArgNamedDisableBrkPt;
+ const CMIUtilString m_constStrArgNamedTracePt; // Not handled by *this command
+ const CMIUtilString m_constStrArgNamedConditionalBrkPt;
+ const CMIUtilString m_constStrArgNamedInoreCnt;
+ const CMIUtilString m_constStrArgNamedRestrictBrkPtToThreadId;
+ const CMIUtilString m_constStrArgNamedLocation;
+ const CMIUtilString m_constStrArgNamedThreadGroup; // Not specified in MI spec but Eclipse gives this option sometimes
};
//++ ============================================================================
-// Details: MI command class. MI commands derived from the command base class.
-// *this class implements MI command "break-delete".
-// Gotchas: None.
-// Authors: Illya Rudkin 11/03/2014.
-// Changes: None.
+// Details: MI command class. MI commands derived from the command base class.
+// *this class implements MI command "break-delete".
+// Gotchas: None.
+// Authors: Illya Rudkin 11/03/2014.
+// Changes: None.
//--
class CMICmdCmdBreakDelete : public CMICmdBase
{
-// Statics:
-public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase * CreateSelf( void );
+ // Statics:
+ public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf(void);
-// Methods:
-public:
- /* ctor */ CMICmdCmdBreakDelete( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdCmdBreakDelete(void);
-// Overridden:
-public:
- // From CMICmdInvoker::ICmd
- virtual bool Execute( void );
- virtual bool Acknowledge( void );
- virtual bool ParseArgs( void );
- // From CMICmnBase
- /* dtor */ virtual ~CMICmdCmdBreakDelete( void );
+ // Overridden:
+ public:
+ // From CMICmdInvoker::ICmd
+ virtual bool Execute(void);
+ virtual bool Acknowledge(void);
+ virtual bool ParseArgs(void);
+ // From CMICmnBase
+ /* dtor */ virtual ~CMICmdCmdBreakDelete(void);
-// Attributes:
-private:
- const CMIUtilString m_constStrArgNamedBrkPt;
- const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
+ // Attributes:
+ private:
+ const CMIUtilString m_constStrArgNamedBrkPt;
+ const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
};
//++ ============================================================================
-// Details: MI command class. MI commands derived from the command base class.
-// *this class implements MI command "break-disable".
-// Gotchas: None.
-// Authors: Illya Rudkin 19/05/2014.
-// Changes: None.
+// Details: MI command class. MI commands derived from the command base class.
+// *this class implements MI command "break-disable".
+// Gotchas: None.
+// Authors: Illya Rudkin 19/05/2014.
+// Changes: None.
//--
class CMICmdCmdBreakDisable : public CMICmdBase
{
-// Statics:
-public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase * CreateSelf( void );
+ // Statics:
+ public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf(void);
-// Methods:
-public:
- /* ctor */ CMICmdCmdBreakDisable( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdCmdBreakDisable(void);
-// Overridden:
-public:
- // From CMICmdInvoker::ICmd
- virtual bool Execute( void );
- virtual bool Acknowledge( void );
- virtual bool ParseArgs( void );
- // From CMICmnBase
- /* dtor */ virtual ~CMICmdCmdBreakDisable( void );
+ // Overridden:
+ public:
+ // From CMICmdInvoker::ICmd
+ virtual bool Execute(void);
+ virtual bool Acknowledge(void);
+ virtual bool ParseArgs(void);
+ // From CMICmnBase
+ /* dtor */ virtual ~CMICmdCmdBreakDisable(void);
-// Attributes:
-private:
- const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
- const CMIUtilString m_constStrArgNamedBrkPt;
- bool m_bBrkPtDisabledOk;
- MIuint m_nBrkPtId;
+ // Attributes:
+ private:
+ const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
+ const CMIUtilString m_constStrArgNamedBrkPt;
+ bool m_bBrkPtDisabledOk;
+ MIuint m_nBrkPtId;
};
//++ ============================================================================
-// Details: MI command class. MI commands derived from the command base class.
-// *this class implements MI command "break-enable".
-// Gotchas: None.
-// Authors: Illya Rudkin 19/05/2014.
-// Changes: None.
+// Details: MI command class. MI commands derived from the command base class.
+// *this class implements MI command "break-enable".
+// Gotchas: None.
+// Authors: Illya Rudkin 19/05/2014.
+// Changes: None.
//--
class CMICmdCmdBreakEnable : public CMICmdBase
{
-// Statics:
-public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase * CreateSelf( void );
+ // Statics:
+ public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf(void);
-// Methods:
-public:
- /* ctor */ CMICmdCmdBreakEnable( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdCmdBreakEnable(void);
-// Overridden:
-public:
- // From CMICmdInvoker::ICmd
- virtual bool Execute( void );
- virtual bool Acknowledge( void );
- virtual bool ParseArgs( void );
- // From CMICmnBase
- /* dtor */ virtual ~CMICmdCmdBreakEnable( void );
+ // Overridden:
+ public:
+ // From CMICmdInvoker::ICmd
+ virtual bool Execute(void);
+ virtual bool Acknowledge(void);
+ virtual bool ParseArgs(void);
+ // From CMICmnBase
+ /* dtor */ virtual ~CMICmdCmdBreakEnable(void);
-// Attributes:
-private:
- const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
- const CMIUtilString m_constStrArgNamedBrkPt;
- bool m_bBrkPtEnabledOk;
- MIuint m_nBrkPtId;
+ // Attributes:
+ private:
+ const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
+ const CMIUtilString m_constStrArgNamedBrkPt;
+ bool m_bBrkPtEnabledOk;
+ MIuint m_nBrkPtId;
};
//++ ============================================================================
-// Details: MI command class. MI commands derived from the command base class.
-// *this class implements MI command "break-after".
-// Gotchas: None.
-// Authors: Illya Rudkin 29/05/2014.
-// Changes: None.
+// Details: MI command class. MI commands derived from the command base class.
+// *this class implements MI command "break-after".
+// Gotchas: None.
+// Authors: Illya Rudkin 29/05/2014.
+// Changes: None.
//--
class CMICmdCmdBreakAfter : public CMICmdBase
{
-// Statics:
-public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase * CreateSelf( void );
+ // Statics:
+ public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf(void);
-// Methods:
-public:
- /* ctor */ CMICmdCmdBreakAfter( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdCmdBreakAfter(void);
-// Overridden:
-public:
- // From CMICmdInvoker::ICmd
- virtual bool Execute( void );
- virtual bool Acknowledge( void );
- virtual bool ParseArgs( void );
- // From CMICmnBase
- /* dtor */ virtual ~CMICmdCmdBreakAfter( void );
+ // Overridden:
+ public:
+ // From CMICmdInvoker::ICmd
+ virtual bool Execute(void);
+ virtual bool Acknowledge(void);
+ virtual bool ParseArgs(void);
+ // From CMICmnBase
+ /* dtor */ virtual ~CMICmdCmdBreakAfter(void);
-// Attributes:
-private:
- const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
- const CMIUtilString m_constStrArgNamedNumber;
- const CMIUtilString m_constStrArgNamedCount;
- MIuint m_nBrkPtId;
- MIuint m_nBrkPtCount;
+ // Attributes:
+ private:
+ const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
+ const CMIUtilString m_constStrArgNamedNumber;
+ const CMIUtilString m_constStrArgNamedCount;
+ MIuint m_nBrkPtId;
+ MIuint m_nBrkPtCount;
};
//++ ============================================================================
-// Details: MI command class. MI commands derived from the command base class.
-// *this class implements MI command "break-condition".
-// Gotchas: None.
-// Authors: Illya Rudkin 29/05/2014.
-// Changes: None.
+// Details: MI command class. MI commands derived from the command base class.
+// *this class implements MI command "break-condition".
+// Gotchas: None.
+// Authors: Illya Rudkin 29/05/2014.
+// Changes: None.
//--
class CMICmdCmdBreakCondition : public CMICmdBase
{
-// Statics:
-public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase * CreateSelf( void );
+ // Statics:
+ public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf(void);
-// Methods:
-public:
- /* ctor */ CMICmdCmdBreakCondition( void );
+ // Methods:
+ public:
+ /* ctor */ CMICmdCmdBreakCondition(void);
-// Overridden:
-public:
- // From CMICmdInvoker::ICmd
- virtual bool Execute( void );
- virtual bool Acknowledge( void );
- virtual bool ParseArgs( void );
- // From CMICmnBase
- /* dtor */ virtual ~CMICmdCmdBreakCondition( void );
+ // Overridden:
+ public:
+ // From CMICmdInvoker::ICmd
+ virtual bool Execute(void);
+ virtual bool Acknowledge(void);
+ virtual bool ParseArgs(void);
+ // From CMICmnBase
+ /* dtor */ virtual ~CMICmdCmdBreakCondition(void);
-// Methods:
-private:
- CMIUtilString GetRestOfExpressionNotSurroundedInQuotes( void );
+ // Methods:
+ private:
+ CMIUtilString GetRestOfExpressionNotSurroundedInQuotes(void);
-// Attributes:
-private:
- const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
- const CMIUtilString m_constStrArgNamedNumber;
- const CMIUtilString m_constStrArgNamedExpr;
- const CMIUtilString m_constStrArgNamedExprNoQuotes; // Not specified in MI spec, we need to handle expressions not surrounded by quotes
- MIuint m_nBrkPtId;
- CMIUtilString m_strBrkPtExpr;
+ // Attributes:
+ private:
+ const CMIUtilString m_constStrArgNamedThreadGrp; // Not specified in MI spec but Eclipse gives this option
+ const CMIUtilString m_constStrArgNamedNumber;
+ const CMIUtilString m_constStrArgNamedExpr;
+ const CMIUtilString m_constStrArgNamedExprNoQuotes; // Not specified in MI spec, we need to handle expressions not surrounded by quotes
+ MIuint m_nBrkPtId;
+ CMIUtilString m_strBrkPtExpr;
};
diff --git a/tools/lldb-mi/MICmdCmdData.cpp b/tools/lldb-mi/MICmdCmdData.cpp
index 69012ef042c4..e1abe83b9165 100644
--- a/tools/lldb-mi/MICmdCmdData.cpp
+++ b/tools/lldb-mi/MICmdCmdData.cpp
@@ -8,23 +8,23 @@
//===----------------------------------------------------------------------===//
//++
-// File: MICmdCmdData.cpp
+// File: MICmdCmdData.cpp
//
-// Overview: CMICmdCmdDataEvaluateExpression implementation.
-// CMICmdCmdDataDisassemble implementation.
-// CMICmdCmdDataReadMemoryBytes implementation.
-// CMICmdCmdDataReadMemory implementation.
-// CMICmdCmdDataListRegisterNames implementation.
-// CMICmdCmdDataListRegisterValues implementation.
-// CMICmdCmdDataListRegisterChanged implementation.
-// CMICmdCmdDataWriteMemoryBytes implementation.
-// CMICmdCmdDataWriteMemory implementation.
+// Overview: CMICmdCmdDataEvaluateExpression implementation.
+// CMICmdCmdDataDisassemble implementation.
+// CMICmdCmdDataReadMemoryBytes implementation.
+// CMICmdCmdDataReadMemory implementation.
+// CMICmdCmdDataListRegisterNames implementation.
+// CMICmdCmdDataListRegisterValues implementation.
+// CMICmdCmdDataListRegisterChanged implementation.
+// CMICmdCmdDataWriteMemoryBytes implementation.
+// CMICmdCmdDataWriteMemory implementation.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Copyright: None.
+// Copyright: None.
//--
// Third Party Headers:
@@ -51,235 +51,245 @@
#include "MICmnLLDBUtilSBValue.h"
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataEvaluateExpression constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataEvaluateExpression constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression( void )
-: m_bExpressionValid( true )
-, m_bEvaluatedExpression( true )
-, m_strValue( "??" )
-, m_bCompositeVarType( false )
-, m_bFoundInvalidChar( false )
-, m_cExpressionInvalidChar( 0x00 )
-, m_constStrArgThread( "thread" )
-, m_constStrArgFrame( "frame" )
-, m_constStrArgExpr( "expr" )
+CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression(void)
+ : m_bExpressionValid(true)
+ , m_bEvaluatedExpression(true)
+ , m_strValue("??")
+ , m_bCompositeVarType(false)
+ , m_bFoundInvalidChar(false)
+ , m_cExpressionInvalidChar(0x00)
+ , m_constStrArgThread("thread")
+ , m_constStrArgFrame("frame")
+ , m_constStrArgExpr("expr")
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-evaluate-expression";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataEvaluateExpression::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-evaluate-expression";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataEvaluateExpression::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataEvaluateExpression destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataEvaluateExpression destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataEvaluateExpression::~CMICmdCmdDataEvaluateExpression( void )
+CMICmdCmdDataEvaluateExpression::~CMICmdCmdDataEvaluateExpression(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataEvaluateExpression::ParseArgs( void )
+bool
+CMICmdCmdDataEvaluateExpression::ParseArgs(void)
{
- bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgFrame, false, false, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgExpr, true, true, true, true ) ) );
- return (bOk && ParseValidateCmdOptions() );
+ bool bOk =
+ m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1)));
+ bOk = bOk &&
+ m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, false, CMICmdArgValListBase::eArgValType_Number, 1)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgExpr, true, true, true, true)));
+ return (bOk && ParseValidateCmdOptions());
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataEvaluateExpression::Execute( void )
+bool
+CMICmdCmdDataEvaluateExpression::Execute(void)
{
- CMICMDBASE_GETOPTION( pArgExpr, String, m_constStrArgExpr );
-
- const CMIUtilString & rExpression( pArgExpr->GetValue() );
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- lldb::SBProcess & rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBThread thread = rProcess.GetSelectedThread();
- m_bExpressionValid = (thread.GetNumFrames() > 0);
- if( !m_bExpressionValid )
- return MIstatus::success;
-
- lldb::SBFrame frame = thread.GetSelectedFrame();
- lldb::SBValue value = frame.EvaluateExpression( rExpression.c_str() );
- if( !value.IsValid() )
- value = frame.FindVariable( rExpression.c_str() );
- if( !value.IsValid() )
- {
- m_bEvaluatedExpression = false;
- return MIstatus::success;
- }
- const CMICmnLLDBUtilSBValue utilValue( value );
- if( !utilValue.HasName() )
- {
- if( HaveInvalidCharacterInExpression( rExpression, m_cExpressionInvalidChar ) )
- {
- m_bFoundInvalidChar = true;
- return MIstatus::success;
- }
-
- m_strValue = rExpression;
- return MIstatus::success;
- }
- if( rExpression.IsQuoted() )
- {
- m_strValue = rExpression.Trim( '\"' );
- return MIstatus::success;
- }
-
- MIuint64 nNumber = 0;
- if( CMICmnLLDBProxySBValue::GetValueAsUnsigned( value, nNumber ) == MIstatus::success )
- {
- const lldb::ValueType eValueType = value.GetValueType(); MIunused( eValueType );
- m_strValue = utilValue.GetValue();
- CMIUtilString strCString;
- if( CMICmnLLDBProxySBValue::GetCString( value, strCString ) )
- {
- m_strValue += CMIUtilString::Format( " '%s'", strCString.c_str() );
- }
- return MIstatus::success;
- }
-
- // Composite type i.e. struct
- m_bCompositeVarType = true;
- const MIuint nChild = value.GetNumChildren();
- for( MIuint i = 0; i < nChild; i++ )
- {
- lldb::SBValue member = value.GetChildAtIndex( i );
- const bool bValid = member.IsValid();
- CMIUtilString strType( MIRSRC( IDS_WORD_UNKNOWNTYPE_BRKTS ) );
- if( bValid )
- {
- const CMIUtilString strValue( CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted( member, CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Natural ) );
- const char * pTypeName = member.GetName();
- if( pTypeName != nullptr )
- strType = pTypeName;
-
- // MI print "{variable = 1, variable2 = 3, variable3 = 5}"
- const bool bNoQuotes = true;
- const CMICmnMIValueConst miValueConst( strValue, bNoQuotes );
- const bool bUseSpaces = true;
- const CMICmnMIValueResult miValueResult( strType, miValueConst, bUseSpaces );
- m_miValueTuple.Add( miValueResult, bUseSpaces );
- }
- }
-
- return MIstatus::success;
+ CMICMDBASE_GETOPTION(pArgExpr, String, m_constStrArgExpr);
+
+ const CMIUtilString &rExpression(pArgExpr->GetValue());
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
+ lldb::SBThread thread = rProcess.GetSelectedThread();
+ m_bExpressionValid = (thread.GetNumFrames() > 0);
+ if (!m_bExpressionValid)
+ return MIstatus::success;
+
+ lldb::SBFrame frame = thread.GetSelectedFrame();
+ lldb::SBValue value = frame.EvaluateExpression(rExpression.c_str());
+ if (!value.IsValid())
+ value = frame.FindVariable(rExpression.c_str());
+ if (!value.IsValid())
+ {
+ m_bEvaluatedExpression = false;
+ return MIstatus::success;
+ }
+ const CMICmnLLDBUtilSBValue utilValue(value);
+ if (!utilValue.HasName())
+ {
+ if (HaveInvalidCharacterInExpression(rExpression, m_cExpressionInvalidChar))
+ {
+ m_bFoundInvalidChar = true;
+ return MIstatus::success;
+ }
+
+ m_strValue = rExpression;
+ return MIstatus::success;
+ }
+ if (rExpression.IsQuoted())
+ {
+ m_strValue = rExpression.Trim('\"');
+ return MIstatus::success;
+ }
+
+ MIuint64 nNumber = 0;
+ if (CMICmnLLDBProxySBValue::GetValueAsUnsigned(value, nNumber) == MIstatus::success)
+ {
+ const lldb::ValueType eValueType = value.GetValueType();
+ MIunused(eValueType);
+ m_strValue = utilValue.GetValue();
+ CMIUtilString strCString;
+ if (CMICmnLLDBProxySBValue::GetCString(value, strCString))
+ {
+ m_strValue += CMIUtilString::Format(" '%s'", strCString.c_str());
+ }
+ return MIstatus::success;
+ }
+
+ // Composite type i.e. struct
+ m_bCompositeVarType = true;
+ const MIuint nChild = value.GetNumChildren();
+ for (MIuint i = 0; i < nChild; i++)
+ {
+ lldb::SBValue member = value.GetChildAtIndex(i);
+ const bool bValid = member.IsValid();
+ CMIUtilString strType(MIRSRC(IDS_WORD_UNKNOWNTYPE_BRKTS));
+ if (bValid)
+ {
+ const CMIUtilString strValue(
+ CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(member, CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Natural));
+ const char *pTypeName = member.GetName();
+ if (pTypeName != nullptr)
+ strType = pTypeName;
+
+ // MI print "{variable = 1, variable2 = 3, variable3 = 5}"
+ const bool bNoQuotes = true;
+ const CMICmnMIValueConst miValueConst(strValue, bNoQuotes);
+ const bool bUseSpaces = true;
+ const CMICmnMIValueResult miValueResult(strType, miValueConst, bUseSpaces);
+ m_miValueTuple.Add(miValueResult, bUseSpaces);
+ }
+ }
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataEvaluateExpression::Acknowledge( void )
+bool
+CMICmdCmdDataEvaluateExpression::Acknowledge(void)
{
- if( m_bExpressionValid )
- {
- if( m_bEvaluatedExpression )
- {
- if( m_bCompositeVarType )
- {
- const CMICmnMIValueConst miValueConst( m_miValueTuple.GetString() );
- const CMICmnMIValueResult miValueResult( "value", miValueConst );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult );
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
-
- if( m_bFoundInvalidChar )
- {
- const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "Invalid character '%c' in expression", m_cExpressionInvalidChar ) );
- const CMICmnMIValueResult miValueResult( "msg", miValueConst );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult );
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
-
- const CMICmnMIValueConst miValueConst( m_strValue );
- const CMICmnMIValueResult miValueResult( "value", miValueConst );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult );
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
-
- const CMICmnMIValueConst miValueConst( "Could not evaluate expression" );
- const CMICmnMIValueResult miValueResult( "msg", miValueConst );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult );
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
-
- const CMICmnMIValueConst miValueConst( "Invalid expression" );
- const CMICmnMIValueResult miValueResult( "msg", miValueConst );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult );
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+ if (m_bExpressionValid)
+ {
+ if (m_bEvaluatedExpression)
+ {
+ if (m_bCompositeVarType)
+ {
+ const CMICmnMIValueConst miValueConst(m_miValueTuple.GetString());
+ const CMICmnMIValueResult miValueResult("value", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
+ m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+ }
+
+ if (m_bFoundInvalidChar)
+ {
+ const CMICmnMIValueConst miValueConst(
+ CMIUtilString::Format("Invalid character '%c' in expression", m_cExpressionInvalidChar));
+ const CMICmnMIValueResult miValueResult("msg", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+ m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+ }
+
+ const CMICmnMIValueConst miValueConst(m_strValue);
+ const CMICmnMIValueResult miValueResult("value", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
+ m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+ }
+
+ const CMICmnMIValueConst miValueConst("Could not evaluate expression");
+ const CMICmnMIValueResult miValueResult("msg", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+ m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+ }
+
+ const CMICmnMIValueConst miValueConst("Invalid expression");
+ const CMICmnMIValueResult miValueResult("msg", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdDataEvaluateExpression::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdDataEvaluateExpression::CreateSelf(void)
{
- return new CMICmdCmdDataEvaluateExpression();
+ return new CMICmdCmdDataEvaluateExpression();
}
//++ ------------------------------------------------------------------------------------
-// Details: Examine the expression string to see if it contains invalid characters.
-// Type: Method.
-// Args: vrExpr - (R) Expression string given to *this command.
-// vrwInvalidChar - (W) True = Invalid character found, false = nothing found.
-// Return: bool - True = Invalid character found, false = nothing found.
-// Throws: None.
+// Details: Examine the expression string to see if it contains invalid characters.
+// Type: Method.
+// Args: vrExpr - (R) Expression string given to *this command.
+// vrwInvalidChar - (W) True = Invalid character found, false = nothing found.
+// Return: bool - True = Invalid character found, false = nothing found.
+// Throws: None.
//--
-bool CMICmdCmdDataEvaluateExpression::HaveInvalidCharacterInExpression( const CMIUtilString & vrExpr, MIchar & vrwInvalidChar )
+bool
+CMICmdCmdDataEvaluateExpression::HaveInvalidCharacterInExpression(const CMIUtilString &vrExpr, MIchar &vrwInvalidChar)
{
- bool bFoundInvalidCharInExpression = false;
- vrwInvalidChar = 0x00;
-
- if( vrExpr.at( 0 ) == '\\' )
- {
- // Example: Mouse hover over "%5d" expression has \"%5d\" in it
- bFoundInvalidCharInExpression = true;
- vrwInvalidChar = '\\';
- }
-
- return bFoundInvalidCharInExpression;
+ bool bFoundInvalidCharInExpression = false;
+ vrwInvalidChar = 0x00;
+
+ if (vrExpr.at(0) == '\\')
+ {
+ // Example: Mouse hover over "%5d" expression has \"%5d\" in it
+ bFoundInvalidCharInExpression = true;
+ vrwInvalidChar = '\\';
+ }
+
+ return bFoundInvalidCharInExpression;
}
//---------------------------------------------------------------------------------------
@@ -287,198 +297,211 @@ bool CMICmdCmdDataEvaluateExpression::HaveInvalidCharacterInExpression( const CM
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataDisassemble constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataDisassemble constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataDisassemble::CMICmdCmdDataDisassemble( void )
-: m_constStrArgThread( "thread" )
-, m_constStrArgAddrStart( "s" )
-, m_constStrArgAddrEnd( "e" )
-, m_constStrArgConsume( "--" )
-, m_constStrArgMode( "mode" )
-, m_miValueList( true )
+CMICmdCmdDataDisassemble::CMICmdCmdDataDisassemble(void)
+ : m_constStrArgThread("thread")
+ , m_constStrArgAddrStart("s")
+ , m_constStrArgAddrEnd("e")
+ , m_constStrArgConsume("--")
+ , m_constStrArgMode("mode")
+ , m_miValueList(true)
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-disassemble";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataDisassemble::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-disassemble";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataDisassemble::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataDisassemble destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataDisassemble destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataDisassemble::~CMICmdCmdDataDisassemble( void )
+CMICmdCmdDataDisassemble::~CMICmdCmdDataDisassemble(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataDisassemble::ParseArgs( void )
+bool
+CMICmdCmdDataDisassemble::ParseArgs(void)
{
- bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgAddrStart, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgAddrEnd, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValConsume( m_constStrArgConsume, true ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgMode, true, true ) ) );
- return (bOk && ParseValidateCmdOptions() );
+ bool bOk =
+ m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1)));
+ bOk = bOk &&
+ m_setCmdArgs.Add(
+ *(new CMICmdArgValOptionShort(m_constStrArgAddrStart, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1)));
+ bOk = bOk &&
+ m_setCmdArgs.Add(
+ *(new CMICmdArgValOptionShort(m_constStrArgAddrEnd, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValConsume(m_constStrArgConsume, true)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgMode, true, true)));
+ return (bOk && ParseValidateCmdOptions());
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataDisassemble::Execute( void )
+bool
+CMICmdCmdDataDisassemble::Execute(void)
{
- CMICMDBASE_GETOPTION( pArgThread, OptionLong, m_constStrArgThread );
- CMICMDBASE_GETOPTION( pArgAddrStart, OptionShort, m_constStrArgAddrStart );
- CMICMDBASE_GETOPTION( pArgAddrEnd, OptionShort, m_constStrArgAddrEnd );
- CMICMDBASE_GETOPTION( pArgMode, Number, m_constStrArgMode );
-
- // Retrieve the --thread option's thread ID (only 1)
- MIuint64 nThreadId = UINT64_MAX;
- if( !pArgThread->GetExpectedOption< CMICmdArgValNumber, MIuint64 >( nThreadId ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_THREAD_INVALID ), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str() ) );
- return MIstatus::failure;
- }
- CMIUtilString strAddrStart;
- if( !pArgAddrStart->GetExpectedOption< CMICmdArgValString, CMIUtilString >( strAddrStart ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_DISASM_ADDR_START_INVALID ), m_cmdData.strMiCmd.c_str(), m_constStrArgAddrStart.c_str() ) );
- return MIstatus::failure;
- }
- MIint64 nAddrStart = 0;
- if( !strAddrStart.ExtractNumber( nAddrStart ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_DISASM_ADDR_START_INVALID ), m_cmdData.strMiCmd.c_str(), m_constStrArgAddrStart.c_str() ) );
- return MIstatus::failure;
- }
-
- CMIUtilString strAddrEnd;
- if( !pArgAddrEnd->GetExpectedOption< CMICmdArgValString, CMIUtilString >( strAddrEnd ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_DISASM_ADDR_END_INVALID ), m_cmdData.strMiCmd.c_str(), m_constStrArgAddrEnd.c_str() ) );
- return MIstatus::failure;
- }
- MIint64 nAddrEnd = 0;
- if( !strAddrEnd.ExtractNumber( nAddrEnd ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_DISASM_ADDR_END_INVALID ), m_cmdData.strMiCmd.c_str(), m_constStrArgAddrEnd.c_str() ) );
- return MIstatus::failure;
- }
- const MIuint nDisasmMode = pArgMode->GetValue();
-
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- lldb::SBTarget & rTarget = rSessionInfo.m_lldbTarget;
- lldb::addr_t lldbStartAddr = static_cast< lldb::addr_t >( nAddrStart );
- lldb::SBInstructionList instructions = rTarget.ReadInstructions( lldb::SBAddress( lldbStartAddr, rTarget ), nAddrEnd - nAddrStart );
- const MIuint nInstructions = instructions.GetSize();
- for( size_t i = 0; i < nInstructions; i++ )
- {
- const MIchar * pUnknown = "??";
- lldb::SBInstruction instrt = instructions.GetInstructionAtIndex( i );
- const MIchar * pStrMnemonic = instrt.GetMnemonic( rTarget );
- pStrMnemonic = (pStrMnemonic != nullptr) ? pStrMnemonic : pUnknown;
- lldb::SBAddress address = instrt.GetAddress();
- lldb::addr_t addr = address.GetLoadAddress( rTarget );
- const MIchar * pFnName = address.GetFunction().GetName();
- pFnName = (pFnName != nullptr) ? pFnName : pUnknown;
- lldb::addr_t addrOffSet = address.GetOffset();
- const MIchar * pStrOperands = instrt.GetOperands( rTarget );
- pStrOperands = (pStrOperands != nullptr) ? pStrOperands : pUnknown;
-
- // MI "{address=\"0x%08llx\",func-name=\"%s\",offset=\"%lld\",inst=\"%s %s\"}"
- const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "0x%08llx", addr ) );
- const CMICmnMIValueResult miValueResult( "address", miValueConst );
- CMICmnMIValueTuple miValueTuple( miValueResult );
- const CMICmnMIValueConst miValueConst2( pFnName );
- const CMICmnMIValueResult miValueResult2( "func-name", miValueConst2 );
- miValueTuple.Add( miValueResult2 );
- const CMICmnMIValueConst miValueConst3( CMIUtilString::Format( "0x%lld", addrOffSet ) );
- const CMICmnMIValueResult miValueResult3( "offset", miValueConst3 );
- miValueTuple.Add( miValueResult3 );
- const CMICmnMIValueConst miValueConst4( CMIUtilString::Format( "%s %s", pStrMnemonic, pStrOperands ) );
- const CMICmnMIValueResult miValueResult4( "inst", miValueConst4 );
- miValueTuple.Add( miValueResult4 );
-
- if( nDisasmMode == 1 )
- {
- lldb::SBLineEntry lineEntry = address.GetLineEntry();
- const MIuint nLine = lineEntry.GetLine();
- const MIchar * pFileName = lineEntry.GetFileSpec().GetFilename();
- pFileName = (pFileName != nullptr) ? pFileName : pUnknown;
-
- // MI "src_and_asm_line={line=\"%u\",file=\"%s\",line_asm_insn=[ ]}"
- const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "0x%u", nLine ) );
- const CMICmnMIValueResult miValueResult( "line", miValueConst );
- CMICmnMIValueTuple miValueTuple2( miValueResult );
- const CMICmnMIValueConst miValueConst2( pFileName );
- const CMICmnMIValueResult miValueResult2( "file", miValueConst2 );
- miValueTuple2.Add( miValueResult2 );
- const CMICmnMIValueList miValueList( miValueTuple );
- const CMICmnMIValueResult miValueResult3( "line_asm_insn", miValueList );
- miValueTuple2.Add( miValueResult3 );
- const CMICmnMIValueResult miValueResult4( "src_and_asm_line", miValueTuple2 );
- m_miValueList.Add( miValueResult4 );
- }
- else
- {
- m_miValueList.Add( miValueTuple );
- }
- }
-
- return MIstatus::success;
+ CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
+ CMICMDBASE_GETOPTION(pArgAddrStart, OptionShort, m_constStrArgAddrStart);
+ CMICMDBASE_GETOPTION(pArgAddrEnd, OptionShort, m_constStrArgAddrEnd);
+ CMICMDBASE_GETOPTION(pArgMode, Number, m_constStrArgMode);
+
+ // Retrieve the --thread option's thread ID (only 1)
+ MIuint64 nThreadId = UINT64_MAX;
+ if (!pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId))
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str()));
+ return MIstatus::failure;
+ }
+ CMIUtilString strAddrStart;
+ if (!pArgAddrStart->GetExpectedOption<CMICmdArgValString, CMIUtilString>(strAddrStart))
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_DISASM_ADDR_START_INVALID), m_cmdData.strMiCmd.c_str(),
+ m_constStrArgAddrStart.c_str()));
+ return MIstatus::failure;
+ }
+ MIint64 nAddrStart = 0;
+ if (!strAddrStart.ExtractNumber(nAddrStart))
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_DISASM_ADDR_START_INVALID), m_cmdData.strMiCmd.c_str(),
+ m_constStrArgAddrStart.c_str()));
+ return MIstatus::failure;
+ }
+
+ CMIUtilString strAddrEnd;
+ if (!pArgAddrEnd->GetExpectedOption<CMICmdArgValString, CMIUtilString>(strAddrEnd))
+ {
+ SetError(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_DISASM_ADDR_END_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgAddrEnd.c_str()));
+ return MIstatus::failure;
+ }
+ MIint64 nAddrEnd = 0;
+ if (!strAddrEnd.ExtractNumber(nAddrEnd))
+ {
+ SetError(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_DISASM_ADDR_END_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgAddrEnd.c_str()));
+ return MIstatus::failure;
+ }
+ const MIuint nDisasmMode = pArgMode->GetValue();
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBTarget &rTarget = rSessionInfo.m_lldbTarget;
+ lldb::addr_t lldbStartAddr = static_cast<lldb::addr_t>(nAddrStart);
+ lldb::SBInstructionList instructions = rTarget.ReadInstructions(lldb::SBAddress(lldbStartAddr, rTarget), nAddrEnd - nAddrStart);
+ const MIuint nInstructions = instructions.GetSize();
+ for (size_t i = 0; i < nInstructions; i++)
+ {
+ const MIchar *pUnknown = "??";
+ lldb::SBInstruction instrt = instructions.GetInstructionAtIndex(i);
+ const MIchar *pStrMnemonic = instrt.GetMnemonic(rTarget);
+ pStrMnemonic = (pStrMnemonic != nullptr) ? pStrMnemonic : pUnknown;
+ lldb::SBAddress address = instrt.GetAddress();
+ lldb::addr_t addr = address.GetLoadAddress(rTarget);
+ const MIchar *pFnName = address.GetFunction().GetName();
+ pFnName = (pFnName != nullptr) ? pFnName : pUnknown;
+ lldb::addr_t addrOffSet = address.GetOffset();
+ const MIchar *pStrOperands = instrt.GetOperands(rTarget);
+ pStrOperands = (pStrOperands != nullptr) ? pStrOperands : pUnknown;
+
+ // MI "{address=\"0x%08llx\",func-name=\"%s\",offset=\"%lld\",inst=\"%s %s\"}"
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format("0x%08llx", addr));
+ const CMICmnMIValueResult miValueResult("address", miValueConst);
+ CMICmnMIValueTuple miValueTuple(miValueResult);
+ const CMICmnMIValueConst miValueConst2(pFnName);
+ const CMICmnMIValueResult miValueResult2("func-name", miValueConst2);
+ miValueTuple.Add(miValueResult2);
+ const CMICmnMIValueConst miValueConst3(CMIUtilString::Format("0x%lld", addrOffSet));
+ const CMICmnMIValueResult miValueResult3("offset", miValueConst3);
+ miValueTuple.Add(miValueResult3);
+ const CMICmnMIValueConst miValueConst4(CMIUtilString::Format("%s %s", pStrMnemonic, pStrOperands));
+ const CMICmnMIValueResult miValueResult4("inst", miValueConst4);
+ miValueTuple.Add(miValueResult4);
+
+ if (nDisasmMode == 1)
+ {
+ lldb::SBLineEntry lineEntry = address.GetLineEntry();
+ const MIuint nLine = lineEntry.GetLine();
+ const MIchar *pFileName = lineEntry.GetFileSpec().GetFilename();
+ pFileName = (pFileName != nullptr) ? pFileName : pUnknown;
+
+ // MI "src_and_asm_line={line=\"%u\",file=\"%s\",line_asm_insn=[ ]}"
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format("0x%u", nLine));
+ const CMICmnMIValueResult miValueResult("line", miValueConst);
+ CMICmnMIValueTuple miValueTuple2(miValueResult);
+ const CMICmnMIValueConst miValueConst2(pFileName);
+ const CMICmnMIValueResult miValueResult2("file", miValueConst2);
+ miValueTuple2.Add(miValueResult2);
+ const CMICmnMIValueList miValueList(miValueTuple);
+ const CMICmnMIValueResult miValueResult3("line_asm_insn", miValueList);
+ miValueTuple2.Add(miValueResult3);
+ const CMICmnMIValueResult miValueResult4("src_and_asm_line", miValueTuple2);
+ m_miValueList.Add(miValueResult4);
+ }
+ else
+ {
+ m_miValueList.Add(miValueTuple);
+ }
+ }
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataDisassemble::Acknowledge( void )
+bool
+CMICmdCmdDataDisassemble::Acknowledge(void)
{
- const CMICmnMIValueResult miValueResult( "asm_insns", m_miValueList );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult );
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+ const CMICmnMIValueResult miValueResult("asm_insns", m_miValueList);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdDataDisassemble::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdDataDisassemble::CreateSelf(void)
{
- return new CMICmdCmdDataDisassemble();
+ return new CMICmdCmdDataDisassemble();
}
//---------------------------------------------------------------------------------------
@@ -486,165 +509,175 @@ CMICmdBase * CMICmdCmdDataDisassemble::CreateSelf( void )
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataReadMemoryBytes constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataReadMemoryBytes constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataReadMemoryBytes::CMICmdCmdDataReadMemoryBytes( void )
-: m_constStrArgThread( "thread" )
-, m_constStrArgByteOffset( "o" )
-, m_constStrArgAddrStart( "address" )
-, m_constStrArgNumBytes( "count" )
-, m_pBufferMemory( nullptr )
-, m_nAddrStart( 0 )
-, m_nAddrNumBytesToRead( 0 )
-, m_nAddrOffset( 0 )
+CMICmdCmdDataReadMemoryBytes::CMICmdCmdDataReadMemoryBytes(void)
+ : m_constStrArgThread("thread")
+ , m_constStrArgByteOffset("o")
+ , m_constStrArgAddrStart("address")
+ , m_constStrArgNumBytes("count")
+ , m_pBufferMemory(nullptr)
+ , m_nAddrStart(0)
+ , m_nAddrNumBytesToRead(0)
+ , m_nAddrOffset(0)
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-read-memory-bytes";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataReadMemoryBytes::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-read-memory-bytes";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataReadMemoryBytes::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataReadMemoryBytes destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataReadMemoryBytes destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataReadMemoryBytes::~CMICmdCmdDataReadMemoryBytes( void )
+CMICmdCmdDataReadMemoryBytes::~CMICmdCmdDataReadMemoryBytes(void)
{
- if( m_pBufferMemory != nullptr )
- {
- delete [] m_pBufferMemory;
- m_pBufferMemory = nullptr;
- }
+ if (m_pBufferMemory != nullptr)
+ {
+ delete[] m_pBufferMemory;
+ m_pBufferMemory = nullptr;
+ }
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataReadMemoryBytes::ParseArgs( void )
+bool
+CMICmdCmdDataReadMemoryBytes::ParseArgs(void)
{
- bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgByteOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgAddrStart, true, true ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNumBytes, true, true ) ) );
- return (bOk && ParseValidateCmdOptions() );
+ bool bOk =
+ m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1)));
+ bOk =
+ bOk &&
+ m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgByteOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgAddrStart, true, true)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumBytes, true, true)));
+ return (bOk && ParseValidateCmdOptions());
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataReadMemoryBytes::Execute( void )
+bool
+CMICmdCmdDataReadMemoryBytes::Execute(void)
{
- CMICMDBASE_GETOPTION( pArgAddrStart, Number, m_constStrArgAddrStart );
- CMICMDBASE_GETOPTION( pArgAddrOffset, Number, m_constStrArgByteOffset );
- CMICMDBASE_GETOPTION( pArgNumBytes, Number, m_constStrArgNumBytes );
-
- const MIuint64 nAddrStart = pArgAddrStart->GetValue();
- const MIuint64 nAddrNumBytes = pArgNumBytes->GetValue();
- if( pArgAddrOffset->GetFound() )
- m_nAddrOffset = pArgAddrOffset->GetValue();
-
- m_pBufferMemory = new MIuchar[ nAddrNumBytes ];
- if( m_pBufferMemory == nullptr )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_MEMORY_ALLOC_FAILURE ), m_cmdData.strMiCmd.c_str(), nAddrNumBytes ) );
- return MIstatus::failure;
- }
-
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- lldb::SBProcess & rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBError error;
- const MIuint64 nReadBytes = rProcess.ReadMemory( static_cast< lldb::addr_t >( nAddrStart ), (void *) m_pBufferMemory, nAddrNumBytes, error );
- if( nReadBytes != nAddrNumBytes )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_LLDB_ERR_NOT_READ_WHOLE_BLK ), m_cmdData.strMiCmd.c_str(), nAddrNumBytes, nAddrStart ) );
- return MIstatus::failure;
- }
- if( error.Fail() )
- {
- lldb::SBStream err;
- const bool bOk = error.GetDescription( err ); MIunused( bOk );
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_LLDB_ERR_READ_MEM_BYTES ), m_cmdData.strMiCmd.c_str(), nAddrNumBytes, nAddrStart, err.GetData() ) );
- return MIstatus::failure;
- }
-
- m_nAddrStart = nAddrStart;
- m_nAddrNumBytesToRead = nAddrNumBytes;
-
- return MIstatus::success;
+ CMICMDBASE_GETOPTION(pArgAddrStart, Number, m_constStrArgAddrStart);
+ CMICMDBASE_GETOPTION(pArgAddrOffset, Number, m_constStrArgByteOffset);
+ CMICMDBASE_GETOPTION(pArgNumBytes, Number, m_constStrArgNumBytes);
+
+ const MIuint64 nAddrStart = pArgAddrStart->GetValue();
+ const MIuint64 nAddrNumBytes = pArgNumBytes->GetValue();
+ if (pArgAddrOffset->GetFound())
+ m_nAddrOffset = pArgAddrOffset->GetValue();
+
+ m_pBufferMemory = new MIuchar[nAddrNumBytes];
+ if (m_pBufferMemory == nullptr)
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_MEMORY_ALLOC_FAILURE), m_cmdData.strMiCmd.c_str(), nAddrNumBytes));
+ return MIstatus::failure;
+ }
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
+ lldb::SBError error;
+ const MIuint64 nReadBytes = rProcess.ReadMemory(static_cast<lldb::addr_t>(nAddrStart), (void *)m_pBufferMemory, nAddrNumBytes, error);
+ if (nReadBytes != nAddrNumBytes)
+ {
+ SetError(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDB_ERR_NOT_READ_WHOLE_BLK), m_cmdData.strMiCmd.c_str(), nAddrNumBytes, nAddrStart));
+ return MIstatus::failure;
+ }
+ if (error.Fail())
+ {
+ lldb::SBStream err;
+ const bool bOk = error.GetDescription(err);
+ MIunused(bOk);
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDB_ERR_READ_MEM_BYTES), m_cmdData.strMiCmd.c_str(), nAddrNumBytes, nAddrStart,
+ err.GetData()));
+ return MIstatus::failure;
+ }
+
+ m_nAddrStart = nAddrStart;
+ m_nAddrNumBytesToRead = nAddrNumBytes;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataReadMemoryBytes::Acknowledge( void )
+bool
+CMICmdCmdDataReadMemoryBytes::Acknowledge(void)
{
- // MI: memory=[{begin=\"0x%08x\",offset=\"0x%08x\",end=\"0x%08x\",contents=\" \" }]"
- const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "0x%08x", m_nAddrStart ) );
- const CMICmnMIValueResult miValueResult( "begin", miValueConst );
- CMICmnMIValueTuple miValueTuple( miValueResult );
- const CMICmnMIValueConst miValueConst2( CMIUtilString::Format( "0x%08x", m_nAddrOffset ) );
- const CMICmnMIValueResult miValueResult2( "offset", miValueConst2 );
- miValueTuple.Add( miValueResult2 );
- const CMICmnMIValueConst miValueConst3( CMIUtilString::Format( "0x%08x", m_nAddrStart + m_nAddrNumBytesToRead ) );
- const CMICmnMIValueResult miValueResult3( "end", miValueConst3 );
- miValueTuple.Add( miValueResult3 );
-
- // MI: contents=\" \"
- CMIUtilString strContent;
- strContent.reserve( (m_nAddrNumBytesToRead << 1) + 1 );
- for( MIuint64 i = 0; i < m_nAddrNumBytesToRead; i ++ )
- {
- strContent += CMIUtilString::Format( "%02x", m_pBufferMemory[ i ] );
- }
- const CMICmnMIValueConst miValueConst4( strContent );
- const CMICmnMIValueResult miValueResult4( "contents", miValueConst4 );
- miValueTuple.Add( miValueResult4 );
- const CMICmnMIValueList miValueList( miValueTuple );
- const CMICmnMIValueResult miValueResult5( "memory", miValueList );
-
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult5 );
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+ // MI: memory=[{begin=\"0x%08x\",offset=\"0x%08x\",end=\"0x%08x\",contents=\" \" }]"
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format("0x%08x", m_nAddrStart));
+ const CMICmnMIValueResult miValueResult("begin", miValueConst);
+ CMICmnMIValueTuple miValueTuple(miValueResult);
+ const CMICmnMIValueConst miValueConst2(CMIUtilString::Format("0x%08x", m_nAddrOffset));
+ const CMICmnMIValueResult miValueResult2("offset", miValueConst2);
+ miValueTuple.Add(miValueResult2);
+ const CMICmnMIValueConst miValueConst3(CMIUtilString::Format("0x%08x", m_nAddrStart + m_nAddrNumBytesToRead));
+ const CMICmnMIValueResult miValueResult3("end", miValueConst3);
+ miValueTuple.Add(miValueResult3);
+
+ // MI: contents=\" \"
+ CMIUtilString strContent;
+ strContent.reserve((m_nAddrNumBytesToRead << 1) + 1);
+ for (MIuint64 i = 0; i < m_nAddrNumBytesToRead; i++)
+ {
+ strContent += CMIUtilString::Format("%02x", m_pBufferMemory[i]);
+ }
+ const CMICmnMIValueConst miValueConst4(strContent);
+ const CMICmnMIValueResult miValueResult4("contents", miValueConst4);
+ miValueTuple.Add(miValueResult4);
+ const CMICmnMIValueList miValueList(miValueTuple);
+ const CMICmnMIValueResult miValueResult5("memory", miValueList);
+
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult5);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdDataReadMemoryBytes::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdDataReadMemoryBytes::CreateSelf(void)
{
- return new CMICmdCmdDataReadMemoryBytes();
+ return new CMICmdCmdDataReadMemoryBytes();
}
//---------------------------------------------------------------------------------------
@@ -652,78 +685,81 @@ CMICmdBase * CMICmdCmdDataReadMemoryBytes::CreateSelf( void )
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataReadMemory constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataReadMemory constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory( void )
+CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory(void)
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-read-memory";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataReadMemory::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-read-memory";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataReadMemory::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataReadMemory destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataReadMemory destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataReadMemory::~CMICmdCmdDataReadMemory( void )
+CMICmdCmdDataReadMemory::~CMICmdCmdDataReadMemory(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataReadMemory::Execute( void )
+bool
+CMICmdCmdDataReadMemory::Execute(void)
{
- // Do nothing - command deprecated use "data-read-memory-bytes" command
- return MIstatus::success;
+ // Do nothing - command deprecated use "data-read-memory-bytes" command
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataReadMemory::Acknowledge( void )
+bool
+CMICmdCmdDataReadMemory::Acknowledge(void)
{
- // Command CMICmdCmdSupportListFeatures sends "data-read-memory-bytes" which causes this command not to be called
- const CMICmnMIValueConst miValueConst( MIRSRC( IDS_CMD_ERR_NOT_IMPLEMENTED_DEPRECATED ) );
- const CMICmnMIValueResult miValueResult( "msg", miValueConst );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult );
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+ // Command CMICmdCmdSupportListFeatures sends "data-read-memory-bytes" which causes this command not to be called
+ const CMICmnMIValueConst miValueConst(MIRSRC(IDS_CMD_ERR_NOT_IMPLEMENTED_DEPRECATED));
+ const CMICmnMIValueResult miValueResult("msg", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdDataReadMemory::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdDataReadMemory::CreateSelf(void)
{
- return new CMICmdCmdDataReadMemory();
+ return new CMICmdCmdDataReadMemory();
}
//---------------------------------------------------------------------------------------
@@ -731,121 +767,126 @@ CMICmdBase * CMICmdCmdDataReadMemory::CreateSelf( void )
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataListRegisterNames constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataListRegisterNames constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataListRegisterNames::CMICmdCmdDataListRegisterNames( void )
-: m_constStrArgThreadGroup( "thread-group" )
-, m_constStrArgRegNo( "regno" )
-, m_miValueList( true )
+CMICmdCmdDataListRegisterNames::CMICmdCmdDataListRegisterNames(void)
+ : m_constStrArgThreadGroup("thread-group")
+ , m_constStrArgRegNo("regno")
+ , m_miValueList(true)
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-list-register-names";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataListRegisterNames::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-list-register-names";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataListRegisterNames::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataReadMemoryBytes destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataReadMemoryBytes destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataListRegisterNames::~CMICmdCmdDataListRegisterNames( void )
+CMICmdCmdDataListRegisterNames::~CMICmdCmdDataListRegisterNames(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataListRegisterNames::ParseArgs( void )
+bool
+CMICmdCmdDataListRegisterNames::ParseArgs(void)
{
- bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThreadGroup, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgRegNo, false, false, CMICmdArgValListBase::eArgValType_Number ) ) );
- return (bOk && ParseValidateCmdOptions() );
+ bool bOk = m_setCmdArgs.Add(
+ *(new CMICmdArgValOptionLong(m_constStrArgThreadGroup, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgRegNo, false, false, CMICmdArgValListBase::eArgValType_Number)));
+ return (bOk && ParseValidateCmdOptions());
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataListRegisterNames::Execute( void )
+bool
+CMICmdCmdDataListRegisterNames::Execute(void)
{
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- lldb::SBProcess & rProcess = rSessionInfo.m_lldbProcess;
- if( !rProcess.IsValid() )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_INVALID_PROCESS ), m_cmdData.strMiCmd.c_str() ) );
- return MIstatus::failure;
- }
-
- lldb::SBThread thread = rProcess.GetSelectedThread();
- lldb::SBFrame frame = thread.GetSelectedFrame();
- lldb::SBValueList registers = frame.GetRegisters();
- const MIuint nRegisters = registers.GetSize();
- for( MIuint i = 0; i < nRegisters; i++ )
- {
- lldb::SBValue value = registers.GetValueAtIndex( i );
- const MIuint nRegChildren = value.GetNumChildren();
- for( MIuint j = 0; j < nRegChildren; j++ )
- {
- lldb::SBValue value2 = value.GetChildAtIndex( j );
- if( value2.IsValid() )
- {
- const CMICmnMIValueConst miValueConst( CMICmnLLDBUtilSBValue( value2 ).GetName() );
- m_miValueList.Add( miValueConst );
- }
- }
- }
-
- return MIstatus::success;
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
+ if (!rProcess.IsValid())
+ {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str()));
+ return MIstatus::failure;
+ }
+
+ lldb::SBThread thread = rProcess.GetSelectedThread();
+ lldb::SBFrame frame = thread.GetSelectedFrame();
+ lldb::SBValueList registers = frame.GetRegisters();
+ const MIuint nRegisters = registers.GetSize();
+ for (MIuint i = 0; i < nRegisters; i++)
+ {
+ lldb::SBValue value = registers.GetValueAtIndex(i);
+ const MIuint nRegChildren = value.GetNumChildren();
+ for (MIuint j = 0; j < nRegChildren; j++)
+ {
+ lldb::SBValue value2 = value.GetChildAtIndex(j);
+ if (value2.IsValid())
+ {
+ const CMICmnMIValueConst miValueConst(CMICmnLLDBUtilSBValue(value2).GetName());
+ m_miValueList.Add(miValueConst);
+ }
+ }
+ }
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
-// for the work carried out in the Execute().
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataListRegisterNames::Acknowledge( void )
+bool
+CMICmdCmdDataListRegisterNames::Acknowledge(void)
{
- const CMICmnMIValueResult miValueResult( "register-names", m_miValueList );
- const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult );
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+ const CMICmnMIValueResult miValueResult("register-names", m_miValueList);
+ const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
-// calls this function to create an instance of *this command.
-// Type: Static method.
-// Args: None.
-// Return: CMICmdBase * - Pointer to a new command.
-// Throws: None.
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
//--
-CMICmdBase * CMICmdCmdDataListRegisterNames::CreateSelf( void )
+CMICmdBase *
+CMICmdCmdDataListRegisterNames::CreateSelf(void)
{
- return new CMICmdCmdDataListRegisterNames();
+ return new CMICmdCmdDataListRegisterNames();
}
//---------------------------------------------------------------------------------------
@@ -853,176 +894,182 @@ CMICmdBase * CMICmdCmdDataListRegisterNames::CreateSelf( void )
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataListRegisterValues constructor.
-// Type: Method.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataListRegisterValues constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues( void )
-: m_constStrArgThread( "thread" )
-, m_constStrArgSkip( "skip-unavailable" )
-, m_constStrArgFormat( "fmt" )
-, m_constStrArgRegNo( "regno" )
-, m_miValueList( true )
-, m_pProcess( nullptr )
+CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues(void)
+ : m_constStrArgThread("thread")
+ , m_constStrArgSkip("skip-unavailable")
+ , m_constStrArgFormat("fmt")
+ , m_constStrArgRegNo("regno")
+ , m_miValueList(true)
+ , m_pProcess(nullptr)
{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-list-register-values";
-
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataListRegisterValues::CreateSelf;
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-list-register-values";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataListRegisterValues::CreateSelf;
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmdCmdDataListRegisterValues destructor.
-// Type: Overrideable.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: CMICmdCmdDataListRegisterValues destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-CMICmdCmdDataListRegisterValues::~CMICmdCmdDataListRegisterValues( void )
+CMICmdCmdDataListRegisterValues::~CMICmdCmdDataListRegisterValues(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
-// arguments to extract values for each of those arguments.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The parses the command line options
+// arguments to extract values for each of those arguments.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataListRegisterValues::ParseArgs( void )
+bool
+CMICmdCmdDataListRegisterValues::ParseArgs(void)
{
- bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgSkip, false, false ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgFormat, true, true ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgRegNo, false, true, CMICmdArgValListBase::eArgValType_Number ) ) );
- return (bOk && ParseValidateCmdOptions() );
+ bool bOk =
+ m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSkip, false, false)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgFormat, true, true)));
+ bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgRegNo, false, true, CMICmdArgValListBase::eArgValType_Number)));
+ return (bOk && ParseValidateCmdOptions());
}
//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command does work in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
-// Type: Overridden.
-// Args: None.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
//--
-bool CMICmdCmdDataListRegisterValues::Execute( void )
+bool
+CMICmdCmdDataListRegisterValues::Execute(void)
{
- CMICMDBASE_GETOPTION( pArgFormat, String, m_constStrArgFormat );
- CMICMDBASE_GETOPTION( pArgRegNo, ListOfN, m_constStrArgRegNo );
-
- const CMIUtilString & rStrFormat( pArgFormat->GetValue() );
- if( rStrFormat.length() != 1 )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_INVALID_FORMAT_TYPE ), m_cmdData.strMiCmd.c_str(), rStrFormat.c_str() ) );
- return MIstatus::failure;
- }
- const CMICmnLLDBDebugSessionInfoVarObj::varFormat_e eFormat = CMICmnLLDBDebugSessionInfoVarObj::GetVarFormatForChar( rStrFormat[ 0 ] );
- if( eFormat == CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_INVALID_FORMAT_TYPE ), m_cmdData.strMiCmd.c_str(), rStrFormat.c_str() ) );
- return MIstatus::failure;
- }
-
- CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- lldb::SBProcess & rProcess = rSessionInfo.m_lldbProcess;
- if( !rProcess.IsValid() )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_INVALID_PROCESS ), m_cmdData.strMiCmd.c_str() ) );
- return MIstatus::failure;
- }
- m_pProcess = &rProcess;
-
- const CMICmdArgValListBase::VecArgObjPtr_t & rVecRegNo( pArgRegNo->GetExpectedOptions() );
- CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecRegNo.begin();
- while( it != rVecRegNo.end() )
- {
- const CMICmdArgValNumber * pRegNo = static_cast< CMICmdArg