diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:55:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:55:28 +0000 |
commit | e81d9d49145e432d917eea3a70d2ae74dcad1d89 (patch) | |
tree | 9ed5e1a91f242e2cb5911577356e487a55c01b78 /tools | |
parent | 85d8ef8f1f0e0e063a8571944302be2d2026f823 (diff) | |
download | src-e81d9d49145e432d917eea3a70d2ae74dcad1d89.tar.gz src-e81d9d49145e432d917eea3a70d2ae74dcad1d89.zip |
Vendor import of stripped lldb trunk r256633:
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=292932
Diffstat (limited to 'tools')
165 files changed, 3329 insertions, 3881 deletions
diff --git a/tools/argdumper/exports b/tools/argdumper/argdumper.exports index e69de29bb2d1..e69de29bb2d1 100644 --- a/tools/argdumper/exports +++ b/tools/argdumper/argdumper.exports diff --git a/tools/driver/Driver.cpp b/tools/driver/Driver.cpp index 3b2eadd836b3..0b72e22c80c8 100644 --- a/tools/driver/Driver.cpp +++ b/tools/driver/Driver.cpp @@ -35,6 +35,7 @@ #include "lldb/API/SBDebugger.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBHostOS.h" +#include "lldb/API/SBLanguageRuntime.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTarget.h" @@ -132,6 +133,10 @@ static OptionDefinition g_options[] = "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." }, + { LLDB_OPT_SET_7, true , "repl" , 'r', optional_argument, 0, eArgTypeNone, + "Runs lldb in REPL mode with a stub process." }, + { LLDB_OPT_SET_7, true , "repl-language" , 'R', required_argument, 0, eArgTypeNone, + "Chooses the language for the REPL." }, { 0, false, NULL , 0 , 0 , 0, eArgTypeNone, NULL } }; @@ -341,21 +346,27 @@ ShowUsage (FILE *out, OptionDefinition *option_table, Driver::OptionData data) 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", + fprintf (out, "\n%*sMultiple \"-s\" and \"-o\" options can be provided. They will be processed" + "\n%*sfrom left to right in order, with the source files and commands" + "\n%*sinterleaved. The same is true of the \"-S\" and \"-O\" options. The before" + "\n%*sfile and after file sets can intermixed freely, the command parser will" + "\n%*ssort them out. The order of the file specifiers (\"-c\", \"-f\", etc.) is" + "\n%*snot significant in this regard.\n\n", indent_level, "", indent_level, "", 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", + fprintf (out, "\n%*sIf you don't provide -f then the first argument will be the file to be" + "\n%*sdebugged which means that '%s -- <filename> [<ARG1> [<ARG2>]]' also" + "\n%*sworks. But remember to end the options with \"--\" if any of your" + "\n%*sarguments have a \"-\" in them.\n\n", indent_level, "", indent_level, "", name, + indent_level, "", indent_level, ""); } @@ -408,6 +419,9 @@ Driver::OptionData::OptionData () : m_print_python_path (false), m_print_help (false), m_wait_for(false), + m_repl (false), + m_repl_lang (eLanguageTypeUnknown), + m_repl_options (), m_process_name(), m_process_pid(LLDB_INVALID_PROCESS_ID), m_use_external_editor(false), @@ -769,6 +783,23 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting) optarg); } break; + + case 'r': + m_option_data.m_repl = true; + if (optarg && optarg[0]) + m_option_data.m_repl_options = optarg; + else + m_option_data.m_repl_options.clear(); + break; + + case 'R': + m_option_data.m_repl_lang = SBLanguageRuntime::GetLanguageTypeFromString (optarg); + if (m_option_data.m_repl_lang == eLanguageTypeUnknown) + { + error.SetErrorStringWithFormat ("Unrecognized language name: \"%s\"", optarg); + } + break; + case 's': m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, true, error); break; @@ -1056,96 +1087,114 @@ Driver::MainLoop () bool handle_events = true; bool spawn_thread = false; - // Check if we have any data in the commands stream, and if so, save it to a temp file - // 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) + if (m_option_data.m_repl) { - int initial_commands_fds[2]; - bool success = true; - FILE *commands_file = PrepareCommandsForSourcing (commands_data, commands_size, initial_commands_fds); - if (commands_file) + const char *repl_options = NULL; + if (!m_option_data.m_repl_options.empty()) + repl_options = m_option_data.m_repl_options.c_str(); + SBError error (m_debugger.RunREPL(m_option_data.m_repl_lang, repl_options)); + if (error.Fail()) { - 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()) + const char *error_cstr = error.GetCString(); + if (error_cstr && error_cstr[0]) + fprintf (stderr, "error: %s\n", error_cstr); + else + fprintf (stderr, "error: %u\n", error.GetError()); + } + } + else + { + // Check if we have any data in the commands stream, and if so, save it to a temp file + // 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) + { + int initial_commands_fds[2]; + bool success = true; + FILE *commands_file = PrepareCommandsForSourcing (commands_data, commands_size, initial_commands_fds); + if (commands_file) { - 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) + 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()) { - bool local_quit_requested; - bool local_stopped_for_crash; - m_debugger.SetInputFileHandle (commands_file, true); - - m_debugger.RunCommandInterpreter(handle_events, - spawn_thread, - options, - num_errors, - local_quit_requested, - local_stopped_for_crash); - if (local_quit_requested) - quit_requested = true; + 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) + { + bool local_quit_requested; + bool local_stopped_for_crash; + m_debugger.SetInputFileHandle (commands_file, true); + + 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); } - m_debugger.SetAsync(old_async); - } - else - success = false; + else + success = false; - // Close any pipes that we still have ownership of - CleanupAfterCommandSourcing(initial_commands_fds); + // Close any pipes that we still have ownership of + CleanupAfterCommandSourcing(initial_commands_fds); - // Something went wrong with command pipe - if (!success) - { - exit(1); - } + // Something went wrong with command pipe + if (!success) + { + exit(1); + } - } + } - // 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 + // 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 - bool go_interactive = true; - if (quit_requested) - go_interactive = false; - else if (m_option_data.m_batch && !stopped_for_crash) - go_interactive = false; + 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); + if (go_interactive) + { + m_debugger.SetInputFileHandle (stdin, true); + m_debugger.RunCommandInterpreter(handle_events, spawn_thread); + } } reset_stdin_termios(); diff --git a/tools/driver/Driver.h b/tools/driver/Driver.h index b1e536d43c05..639ac41d7fe6 100644 --- a/tools/driver/Driver.h +++ b/tools/driver/Driver.h @@ -105,6 +105,9 @@ public: bool m_print_python_path; bool m_print_help; bool m_wait_for; + bool m_repl; + lldb::LanguageType m_repl_lang; + std::string m_repl_options; 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. diff --git a/tools/lldb-mi/MICmdArgContext.cpp b/tools/lldb-mi/MICmdArgContext.cpp index 7a1bbf77d31a..8ce5bfb3c88f 100644 --- a/tools/lldb-mi/MICmdArgContext.cpp +++ b/tools/lldb-mi/MICmdArgContext.cpp @@ -1,4 +1,4 @@ -//===-- MICmnArgContext.cpp -------------------------------------*- C++ -*-===// +//===-- MICmdArgContext.cpp -------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,7 +17,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgContext::CMICmdArgContext(void) +CMICmdArgContext::CMICmdArgContext() { } @@ -40,7 +40,7 @@ CMICmdArgContext::CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw) // Return: None. // Throws: None. //-- -CMICmdArgContext::~CMICmdArgContext(void) +CMICmdArgContext::~CMICmdArgContext() { } @@ -52,7 +52,7 @@ CMICmdArgContext::~CMICmdArgContext(void) // Throws: None. //-- const CMIUtilString & -CMICmdArgContext::GetArgsLeftToParse(void) const +CMICmdArgContext::GetArgsLeftToParse() const { return m_strCmdArgsAndOptions; } @@ -65,7 +65,7 @@ CMICmdArgContext::GetArgsLeftToParse(void) const // Throws: None. //-- bool -CMICmdArgContext::IsEmpty(void) const +CMICmdArgContext::IsEmpty() const { return m_strCmdArgsAndOptions.empty(); } @@ -130,7 +130,7 @@ CMICmdArgContext::RemoveArg(const CMIUtilString &vArg) } const size_t nPosEnd = nLen + nExtraSpace; - m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, "").c_str(); + m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, ""); m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim(); return MIstatus::success; @@ -149,9 +149,9 @@ CMICmdArgContext::RemoveArg(const CMIUtilString &vArg) // Throws: None. //-- bool -CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg, const MIuint nArgIndex) +CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg, size_t nArgIndex) { - MIuint nWordIndex = 0; + size_t nWordIndex = 0; CMIUtilString strBuildContextUp; const CMIUtilString::VecString_t vecWords(GetArgs()); const bool bSpaceRequired(GetNumberArgsPresent() > 2); @@ -202,11 +202,11 @@ CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg, const MIuint nArgInd // 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. +// Return: size_t - 0 to n arguments present. // Throws: None. //-- -MIuint -CMICmdArgContext::GetNumberArgsPresent(void) const +size_t +CMICmdArgContext::GetNumberArgsPresent() const { CMIUtilString::VecString_t vecOptions; return m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions); @@ -220,7 +220,7 @@ CMICmdArgContext::GetNumberArgsPresent(void) const // Throws: None. //-- CMIUtilString::VecString_t -CMICmdArgContext::GetArgs(void) const +CMICmdArgContext::GetArgs() const { CMIUtilString::VecString_t vecOptions; m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions); diff --git a/tools/lldb-mi/MICmdArgContext.h b/tools/lldb-mi/MICmdArgContext.h index baeb9232ef50..2b32c4b84276 100644 --- a/tools/lldb-mi/MICmdArgContext.h +++ b/tools/lldb-mi/MICmdArgContext.h @@ -16,30 +16,27 @@ // 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(); /* ctor */ CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw); // - const CMIUtilString &GetArgsLeftToParse(void) const; - MIuint GetNumberArgsPresent(void) const; - CMIUtilString::VecString_t GetArgs(void) const; - bool IsEmpty(void) const; + const CMIUtilString &GetArgsLeftToParse() const; + size_t GetNumberArgsPresent() const; + CMIUtilString::VecString_t GetArgs() const; + bool IsEmpty() const; bool RemoveArg(const CMIUtilString &vArg); - bool RemoveArgAtPos(const CMIUtilString &vArg, const MIuint nArgIndex); + bool RemoveArgAtPos(const CMIUtilString &vArg, size_t nArgIndex); // CMICmdArgContext &operator=(const CMICmdArgContext &vOther); // Overridden: public: // From CMIUtilString - /* dtor */ virtual ~CMICmdArgContext(void); + /* dtor */ virtual ~CMICmdArgContext(); // Attributes: private: diff --git a/tools/lldb-mi/MICmdArgSet.cpp b/tools/lldb-mi/MICmdArgSet.cpp index 3d63a6138f7f..9fe5b2d97dc2 100644 --- a/tools/lldb-mi/MICmdArgSet.cpp +++ b/tools/lldb-mi/MICmdArgSet.cpp @@ -20,7 +20,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgSet::CMICmdArgSet(void) +CMICmdArgSet::CMICmdArgSet() : m_bIsArgsPresentButNotHandledByCmd(false) , m_constStrCommaSpc(", ") { @@ -33,7 +33,7 @@ CMICmdArgSet::CMICmdArgSet(void) // Return: None. // Throws: None. //-- -CMICmdArgSet::~CMICmdArgSet(void) +CMICmdArgSet::~CMICmdArgSet() { // Tidy up Destroy(); @@ -47,7 +47,7 @@ CMICmdArgSet::~CMICmdArgSet(void) // Throws: None. //-- void -CMICmdArgSet::Destroy(void) +CMICmdArgSet::Destroy() { // Delete command argument objects if (!m_setCmdArgs.empty()) @@ -81,7 +81,7 @@ CMICmdArgSet::Destroy(void) // Throws: None. //-- bool -CMICmdArgSet::IsArgsPresentButNotHandledByCmd(void) const +CMICmdArgSet::IsArgsPresentButNotHandledByCmd() const { return m_bIsArgsPresentButNotHandledByCmd; } @@ -90,17 +90,13 @@ CMICmdArgSet::IsArgsPresentButNotHandledByCmd(void) const // 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. +// Return: None. // Throws: None. //-- -bool -CMICmdArgSet::Add(const CMICmdArgValBase &vArg) +void +CMICmdArgSet::Add(CMICmdArgValBase *vArg) { - CMICmdArgValBase *pArg = const_cast<CMICmdArgValBase *>(&vArg); - m_setCmdArgs.push_back(pArg); - - return MIstatus::success; + m_setCmdArgs.push_back(vArg); } //++ ------------------------------------------------------------------------------------ @@ -113,7 +109,7 @@ CMICmdArgSet::Add(const CMICmdArgValBase &vArg) // Throws: None. //-- const CMICmdArgSet::SetCmdArgs_t & -CMICmdArgSet::GetArgsThatAreMissing(void) const +CMICmdArgSet::GetArgsThatAreMissing() const { return m_setCmdArgsThatAreMissing; } @@ -128,7 +124,7 @@ CMICmdArgSet::GetArgsThatAreMissing(void) const // Throws: None. //-- const CMICmdArgSet::SetCmdArgs_t & -CMICmdArgSet::GetArgsThatInvalid(void) const +CMICmdArgSet::GetArgsThatInvalid() const { return m_setCmdArgsThatNotValid; } @@ -146,7 +142,7 @@ CMICmdArgSet::GetArgsThatInvalid(void) const // Throws: None. //-- const CMICmdArgSet::SetCmdArgs_t & -CMICmdArgSet::GetArgsNotHandledByCmd(void) const +CMICmdArgSet::GetArgsNotHandledByCmd() const { return m_setCmdArgsNotHandledByCmd; } @@ -172,25 +168,25 @@ CMICmdArgSet::Validate(const CMIUtilString &vStrMiCmd, CMICmdArgContext &vwCmdAr SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin(); while (it != m_setCmdArgs.end()) { - const CMICmdArgValBase *pArg(*it); + CMICmdArgValBase *pArg = *it; - if (!const_cast<CMICmdArgValBase *>(pArg)->Validate(vwCmdArgsText)) + if (!pArg->Validate(vwCmdArgsText)) { if (pArg->GetFound()) { if (pArg->GetIsMissingOptions()) - m_setCmdArgsMissingInfo.push_back(const_cast<CMICmdArgValBase *>(pArg)); + m_setCmdArgsMissingInfo.push_back(pArg); else if (!pArg->GetValid()) - m_setCmdArgsThatNotValid.push_back(const_cast<CMICmdArgValBase *>(pArg)); + m_setCmdArgsThatNotValid.push_back(pArg); } else if (pArg->GetIsMandatory()) - m_setCmdArgsThatAreMissing.push_back(const_cast<CMICmdArgValBase *>(pArg)); + m_setCmdArgsThatAreMissing.push_back(pArg); } if (pArg->GetFound() && !pArg->GetIsHandledByCmd()) { m_bIsArgsPresentButNotHandledByCmd = true; - m_setCmdArgsNotHandledByCmd.push_back(const_cast<CMICmdArgValBase *>(pArg)); + m_setCmdArgsNotHandledByCmd.push_back(pArg); } // Next @@ -326,7 +322,7 @@ CMICmdArgSet::ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText) // Throws: None. //-- bool -CMICmdArgSet::IsArgContextEmpty(void) const +CMICmdArgSet::IsArgContextEmpty() const { return m_cmdArgContext.IsEmpty(); } @@ -335,11 +331,11 @@ CMICmdArgSet::IsArgContextEmpty(void) const // Details: Retrieve the number of arguments that are being used for the command. // Type: Method. // Args: None. -// Return: MIuint - Argument count. +// Return: size_t - Argument count. // Throws: None. //-- -MIuint -CMICmdArgSet::GetCount(void) const +size_t +CMICmdArgSet::GetCount() const { return m_setCmdArgs.size(); } diff --git a/tools/lldb-mi/MICmdArgSet.h b/tools/lldb-mi/MICmdArgSet.h index 0dd2933f3bb8..2b4392565e05 100644 --- a/tools/lldb-mi/MICmdArgSet.h +++ b/tools/lldb-mi/MICmdArgSet.h @@ -9,10 +9,12 @@ #pragma once -// Third party headers: +// C Includes +// C++ Includes #include <vector> -// In-house headers: +// Other libraries and framework includes +// Project includes #include "MICmnBase.h" #include "MICmdArgContext.h" @@ -30,9 +32,6 @@ class CMICmdArgValBase; // objects on the heap. // It is assumed 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 { @@ -44,48 +43,44 @@ class CMICmdArgSet : public CMICmnBase 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 GetFound() const = 0; + virtual bool GetIsHandledByCmd() const = 0; + virtual bool GetIsMandatory() const = 0; + virtual bool GetIsMissingOptions() const = 0; + virtual const CMIUtilString &GetName() const = 0; + virtual bool GetValid() const = 0; virtual bool Validate(CMICmdArgContext &vwArgContext) = 0; - /* dtor */ virtual ~IArg(void){}; + virtual ~IArg() = default; }; // Typedefs: - public: typedef std::vector<CMICmdArgValBase *> SetCmdArgs_t; // Methods: - public: - /* ctor */ CMICmdArgSet(void); + CMICmdArgSet(); - bool Add(const CMICmdArgValBase &vArg); + void Add(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; + const SetCmdArgs_t &GetArgsThatAreMissing() const; + const SetCmdArgs_t &GetArgsThatInvalid() const; + size_t GetCount() const; + bool IsArgContextEmpty() const; + bool IsArgsPresentButNotHandledByCmd() const; void WarningArgsNotHandledbyCmdLogFile(const CMIUtilString &vrCmdName); bool Validate(const CMIUtilString &vStrMiCmd, CMICmdArgContext &vwCmdArgsText); // Overrideable: - public: - /* dtor */ virtual ~CMICmdArgSet(void); + ~CMICmdArgSet() override; // Methods: private: - const SetCmdArgs_t &GetArgsNotHandledByCmd(void) const; + const SetCmdArgs_t &GetArgsNotHandledByCmd() const; void - Destroy(void); // Release resources used by *this object + Destroy(); // 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 diff --git a/tools/lldb-mi/MICmdArgValBase.cpp b/tools/lldb-mi/MICmdArgValBase.cpp index dfaacbc6e7b2..ddbf957ea477 100644 --- a/tools/lldb-mi/MICmdArgValBase.cpp +++ b/tools/lldb-mi/MICmdArgValBase.cpp @@ -7,7 +7,10 @@ // //===----------------------------------------------------------------------===// -// In-house headers: +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "MICmdArgValBase.h" #include "MIUtilString.h" #include "MICmdArgContext.h" @@ -19,7 +22,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgValBase::CMICmdArgValBase(void) +CMICmdArgValBase::CMICmdArgValBase() : m_bFound(false) , m_bValid(false) , m_bMandatory(false) @@ -48,17 +51,6 @@ CMICmdArgValBase::CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vb } //++ ------------------------------------------------------------------------------------ -// Details: CMICmdArgValBase destructor. -// Type: Overrideable. -// Args: None. -// Return: None. -// Throws: None. -//-- -CMICmdArgValBase::~CMICmdArgValBase(void) -{ -} - -//++ ------------------------------------------------------------------------------------ // Details: Retrieve the state flag of whether the argument is handled by the command or // not. // Type: Method. @@ -68,7 +60,7 @@ CMICmdArgValBase::~CMICmdArgValBase(void) // Throws: None. //-- bool -CMICmdArgValBase::GetIsMissingOptions(void) const +CMICmdArgValBase::GetIsMissingOptions() const { return m_bIsMissingOptions; } @@ -83,7 +75,7 @@ CMICmdArgValBase::GetIsMissingOptions(void) const // Throws: None. //-- bool -CMICmdArgValBase::GetIsHandledByCmd(void) const +CMICmdArgValBase::GetIsHandledByCmd() const { return m_bHandled; } @@ -96,7 +88,7 @@ CMICmdArgValBase::GetIsHandledByCmd(void) const // Throws: None. //-- const CMIUtilString & -CMICmdArgValBase::GetName(void) const +CMICmdArgValBase::GetName() const { return m_strArgName; } @@ -111,7 +103,7 @@ CMICmdArgValBase::GetName(void) const // Throws: None. //-- bool -CMICmdArgValBase::GetFound(void) const +CMICmdArgValBase::GetFound() const { return m_bFound; } @@ -126,7 +118,7 @@ CMICmdArgValBase::GetFound(void) const // Throws: None. //-- bool -CMICmdArgValBase::GetValid(void) const +CMICmdArgValBase::GetValid() const { return m_bValid; } @@ -141,7 +133,7 @@ CMICmdArgValBase::GetValid(void) const // Throws: None. //-- bool -CMICmdArgValBase::GetIsMandatory(void) const +CMICmdArgValBase::GetIsMandatory() const { return m_bMandatory; } diff --git a/tools/lldb-mi/MICmdArgValBase.h b/tools/lldb-mi/MICmdArgValBase.h index 3aaae499e5fc..c343b3338c3f 100644 --- a/tools/lldb-mi/MICmdArgValBase.h +++ b/tools/lldb-mi/MICmdArgValBase.h @@ -1,4 +1,4 @@ -//===-- CMICmdArgValBase.h --------------------------------------*- C++ -*-===// +//===-- MICmdArgValBase.h ---------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -9,7 +9,10 @@ #pragma once -// In-house headers: +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "MIUtilString.h" #include "MICmdArgSet.h" @@ -30,30 +33,25 @@ // 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); + CMICmdArgValBase(); + CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd); // Overrideable: - public: - /* dtor */ ~CMICmdArgValBase(void) override; + ~CMICmdArgValBase() override = default; // Overridden: - public: // From CMICmdArgSet::IArg - bool GetFound(void) const override; - bool GetIsHandledByCmd(void) const override; - bool GetIsMandatory(void) const override; - bool GetIsMissingOptions(void) const override; - const CMIUtilString &GetName(void) const override; - bool GetValid(void) const override; + bool GetFound() const override; + bool GetIsHandledByCmd() const override; + bool GetIsMandatory() const override; + bool GetIsMissingOptions() const override; + const CMIUtilString &GetName() const override; + bool GetValid() const override; bool Validate(CMICmdArgContext &vwArgContext) override; // Attributes: @@ -68,22 +66,18 @@ class CMICmdArgValBase : public CMICmdArgSet::IArg //++ ============================================================================ // 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 { // Methods: public: - /* ctor */ CMICmdArgValBaseTemplate(void); - /* ctor */ CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd); + CMICmdArgValBaseTemplate() = default; + CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd); // - const T &GetValue(void) const; + const T &GetValue() const; // Overrideable: - public: - /* dtor */ virtual ~CMICmdArgValBaseTemplate(void); + ~CMICmdArgValBaseTemplate() override = default; // Attributes: protected: @@ -93,17 +87,6 @@ template <class T> class CMICmdArgValBaseTemplate : public CMICmdArgValBase //++ ------------------------------------------------------------------------------------ // Details: CMICmdArgValBaseTemplate constructor. // Type: Method. -// Args: None. -// Return: None. -// Throws: None. -//-- -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. @@ -117,17 +100,6 @@ CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate(const CMIUtilString &vrArg } //++ ------------------------------------------------------------------------------------ -// Details: CMICmdArgValBaseTemplate destructor. -// Type: Overrideable. -// Args: None. -// Return: None. -// Throws: None. -//-- -template <class T> CMICmdArgValBaseTemplate<T>::~CMICmdArgValBaseTemplate(void) -{ -} - -//++ ------------------------------------------------------------------------------------ // Details: Retrieve the value the argument parsed from the command's argument / options // text string. // Type: Method. @@ -137,7 +109,7 @@ template <class T> CMICmdArgValBaseTemplate<T>::~CMICmdArgValBaseTemplate(void) //-- template <class T> const T & -CMICmdArgValBaseTemplate<T>::GetValue(void) const +CMICmdArgValBaseTemplate<T>::GetValue() const { return m_argValue; } diff --git a/tools/lldb-mi/MICmdArgValConsume.cpp b/tools/lldb-mi/MICmdArgValConsume.cpp index c2fe9940d878..12d32912c370 100644 --- a/tools/lldb-mi/MICmdArgValConsume.cpp +++ b/tools/lldb-mi/MICmdArgValConsume.cpp @@ -1,4 +1,4 @@ -//===-- MICmdArgValConsume.cpp -------------------------------------*- C++ -*-===// +//===-- MICmdArgValConsume.cpp ----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -18,7 +18,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgValConsume::CMICmdArgValConsume(void) +CMICmdArgValConsume::CMICmdArgValConsume() { } @@ -42,7 +42,7 @@ CMICmdArgValConsume::CMICmdArgValConsume(const CMIUtilString &vrArgName, const b // Return: None. // Throws: None. //-- -CMICmdArgValConsume::~CMICmdArgValConsume(void) +CMICmdArgValConsume::~CMICmdArgValConsume() { } @@ -72,12 +72,10 @@ CMICmdArgValConsume::Validate(CMICmdArgContext &vwArgContext) { m_bFound = true; m_bValid = true; + if ( !vwArgContext.RemoveArg( rTxt ) ) + return MIstatus::failure; return MIstatus::success; } - - if ( !vwArgContext.RemoveArg( rTxt ) ) - return MIstatus::failure; - // Next ++it; } @@ -94,7 +92,7 @@ CMICmdArgValConsume::Validate(CMICmdArgContext &vwArgContext) // Throws: None. //-- bool -CMICmdArgValConsume::IsOk(void) const +CMICmdArgValConsume::IsOk() const { return true; } diff --git a/tools/lldb-mi/MICmdArgValConsume.h b/tools/lldb-mi/MICmdArgValConsume.h index 75768ff52e61..792a9bed6480 100644 --- a/tools/lldb-mi/MICmdArgValConsume.h +++ b/tools/lldb-mi/MICmdArgValConsume.h @@ -1,4 +1,4 @@ -//===-- MICmdArgValConsume.h ---------------------------------------*- C++ -*-===// +//===-- MICmdArgValConsume.h ------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -29,23 +29,20 @@ class CMICmdArgContext; // 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> { // Methods: public: - /* ctor */ CMICmdArgValConsume(void); + /* ctor */ CMICmdArgValConsume(); /* ctor */ CMICmdArgValConsume(const CMIUtilString &vrArgName, const bool vbMandatory); // - bool IsOk(void) const; + bool IsOk() const; // Overridden: public: // From CMICmdArgValBase - /* dtor */ ~CMICmdArgValConsume(void) override; + /* dtor */ ~CMICmdArgValConsume() override; // From CMICmdArgSet::IArg bool Validate(CMICmdArgContext &vwArgContext) override; }; diff --git a/tools/lldb-mi/MICmdArgValFile.cpp b/tools/lldb-mi/MICmdArgValFile.cpp index 400610ff6ba6..7f5b20ec3140 100644 --- a/tools/lldb-mi/MICmdArgValFile.cpp +++ b/tools/lldb-mi/MICmdArgValFile.cpp @@ -18,7 +18,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgValFile::CMICmdArgValFile(void) +CMICmdArgValFile::CMICmdArgValFile() { } @@ -43,7 +43,7 @@ CMICmdArgValFile::CMICmdArgValFile(const CMIUtilString &vrArgName, const bool vb // Return: None. // Throws: None. //-- -CMICmdArgValFile::~CMICmdArgValFile(void) +CMICmdArgValFile::~CMICmdArgValFile() { } @@ -142,23 +142,23 @@ 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); + const bool bHavePosSlash = (vrFileNamePath.find('/') != std::string::npos); + const bool bHaveBckSlash = (vrFileNamePath.find('\\') != std::string::npos); // Look for --someLongOption - size_t nPos = vrFileNamePath.find_first_of("--"); + size_t nPos = vrFileNamePath.find("--"); const bool bLong = (nPos == 0); if (bLong) return false; // Look for -f type short parameters - nPos = vrFileNamePath.find_first_of("-"); + nPos = vrFileNamePath.find('-'); const bool bShort = (nPos == 0); if (bShort) return false; // Look for i1 i2 i3.... - nPos = vrFileNamePath.find_first_of("i"); + nPos = vrFileNamePath.find('i'); const bool bFoundI1 = ((nPos == 0) && (::isdigit(vrFileNamePath[1]))); if (bFoundI1) return false; diff --git a/tools/lldb-mi/MICmdArgValFile.h b/tools/lldb-mi/MICmdArgValFile.h index 07abc4baa242..25d9842ec07c 100644 --- a/tools/lldb-mi/MICmdArgValFile.h +++ b/tools/lldb-mi/MICmdArgValFile.h @@ -22,15 +22,12 @@ class CMICmdArgContext; // 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> { // Methods: public: - /* ctor */ CMICmdArgValFile(void); + /* ctor */ CMICmdArgValFile(); /* ctor */ CMICmdArgValFile(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd); // bool IsFilePath(const CMIUtilString &vrFileNamePath) const; @@ -39,7 +36,7 @@ class CMICmdArgValFile : public CMICmdArgValBaseTemplate<CMIUtilString> // Overridden: public: // From CMICmdArgValBase - /* dtor */ ~CMICmdArgValFile(void) override; + /* dtor */ ~CMICmdArgValFile() override; // From CMICmdArgSet::IArg bool Validate(CMICmdArgContext &vwArgContext) override; diff --git a/tools/lldb-mi/MICmdArgValListBase.cpp b/tools/lldb-mi/MICmdArgValListBase.cpp index 61d72fb823c7..05396284e225 100644 --- a/tools/lldb-mi/MICmdArgValListBase.cpp +++ b/tools/lldb-mi/MICmdArgValListBase.cpp @@ -25,7 +25,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgValListBase::CMICmdArgValListBase(void) +CMICmdArgValListBase::CMICmdArgValListBase() : m_eArgType(eArgValType_invalid) { } @@ -69,7 +69,7 @@ CMICmdArgValListBase::CMICmdArgValListBase(const CMIUtilString &vrArgName, const // Return: None. // Throws: None. //-- -CMICmdArgValListBase::~CMICmdArgValListBase(void) +CMICmdArgValListBase::~CMICmdArgValListBase() { // Tidy up Destroy(); @@ -83,7 +83,7 @@ CMICmdArgValListBase::~CMICmdArgValListBase(void) // Throws: None. //-- void -CMICmdArgValListBase::Destroy(void) +CMICmdArgValListBase::Destroy() { // Tidy up VecArgObjPtr_t::const_iterator it = m_argValue.begin(); diff --git a/tools/lldb-mi/MICmdArgValListBase.h b/tools/lldb-mi/MICmdArgValListBase.h index f0135620321f..59ef3bb6019d 100644 --- a/tools/lldb-mi/MICmdArgValListBase.h +++ b/tools/lldb-mi/MICmdArgValListBase.h @@ -31,9 +31,6 @@ class CMICmdArgContext; // 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 *>> { @@ -67,7 +64,7 @@ class CMICmdArgValListBase : public CMICmdArgValBaseTemplate<std::vector<CMICmdA // Methods: public: - /* ctor */ CMICmdArgValListBase(void); + /* ctor */ CMICmdArgValListBase(); /* 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); @@ -75,7 +72,7 @@ class CMICmdArgValListBase : public CMICmdArgValBaseTemplate<std::vector<CMICmdA // Overridden: public: // From CMICmdArgValBase - /* dtor */ ~CMICmdArgValListBase(void) override; + /* dtor */ ~CMICmdArgValListBase() override; // Methods: protected: @@ -88,5 +85,5 @@ class CMICmdArgValListBase : public CMICmdArgValBaseTemplate<std::vector<CMICmdA // Methods: private: - void Destroy(void); + void Destroy(); }; diff --git a/tools/lldb-mi/MICmdArgValListOfN.cpp b/tools/lldb-mi/MICmdArgValListOfN.cpp index 8e479d52e79a..78f5fdc65f49 100644 --- a/tools/lldb-mi/MICmdArgValListOfN.cpp +++ b/tools/lldb-mi/MICmdArgValListOfN.cpp @@ -24,7 +24,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgValListOfN::CMICmdArgValListOfN(void) +CMICmdArgValListOfN::CMICmdArgValListOfN() { } @@ -51,7 +51,7 @@ CMICmdArgValListOfN::CMICmdArgValListOfN(const CMIUtilString &vrArgName, const b // Return: None. // Throws: None. //-- -CMICmdArgValListOfN::~CMICmdArgValListOfN(void) +CMICmdArgValListOfN::~CMICmdArgValListOfN() { } @@ -170,7 +170,7 @@ CMICmdArgValListOfN::IsListOfN(const CMIUtilString &vrTxt) const // Throws: None. //-- const CMICmdArgValListBase::VecArgObjPtr_t & -CMICmdArgValListOfN::GetExpectedOptions(void) const +CMICmdArgValListOfN::GetExpectedOptions() const { return m_argValue; } diff --git a/tools/lldb-mi/MICmdArgValListOfN.h b/tools/lldb-mi/MICmdArgValListOfN.h index 496bc6581117..7499a7f7e91b 100644 --- a/tools/lldb-mi/MICmdArgValListOfN.h +++ b/tools/lldb-mi/MICmdArgValListOfN.h @@ -31,25 +31,22 @@ class CMICmdArgContext; // 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(); /* ctor */ CMICmdArgValListOfN(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const ArgValType_e veType); // - const VecArgObjPtr_t &GetExpectedOptions(void) const; + const VecArgObjPtr_t &GetExpectedOptions() const; template <class T1, typename T2> bool GetExpectedOption(T2 &vrwValue, const VecArgObjPtr_t::size_type vnAt = 0) const; // Overridden: public: // From CMICmdArgValBase - /* dtor */ ~CMICmdArgValListOfN(void) override; + /* dtor */ ~CMICmdArgValListOfN() override; // From CMICmdArgSet::IArg bool Validate(CMICmdArgContext &vArgContext) override; diff --git a/tools/lldb-mi/MICmdArgValNumber.cpp b/tools/lldb-mi/MICmdArgValNumber.cpp index 75e9700c874d..5d907ca9f1ed 100644 --- a/tools/lldb-mi/MICmdArgValNumber.cpp +++ b/tools/lldb-mi/MICmdArgValNumber.cpp @@ -18,7 +18,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgValNumber::CMICmdArgValNumber(void) +CMICmdArgValNumber::CMICmdArgValNumber() : m_nNumberFormatMask(CMICmdArgValNumber::eArgValNumberFormat_Decimal) , m_nNumber(0) { @@ -49,7 +49,7 @@ CMICmdArgValNumber::CMICmdArgValNumber(const CMIUtilString &vrArgName, const boo // Return: None. // Throws: None. //-- -CMICmdArgValNumber::~CMICmdArgValNumber(void) +CMICmdArgValNumber::~CMICmdArgValNumber() { } @@ -165,7 +165,7 @@ CMICmdArgValNumber::ExtractNumber(const CMIUtilString &vrTxt) // Throws: None. //-- MIint64 -CMICmdArgValNumber::GetNumber(void) const +CMICmdArgValNumber::GetNumber() const { return m_nNumber; } diff --git a/tools/lldb-mi/MICmdArgValNumber.h b/tools/lldb-mi/MICmdArgValNumber.h index 58a28b379e3e..0b05e57c6bff 100644 --- a/tools/lldb-mi/MICmdArgValNumber.h +++ b/tools/lldb-mi/MICmdArgValNumber.h @@ -22,9 +22,6 @@ class CMICmdArgContext; // 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> { @@ -43,7 +40,7 @@ class CMICmdArgValNumber : public CMICmdArgValBaseTemplate<MIint64> // Methods: public: - /* ctor */ CMICmdArgValNumber(void); + /* ctor */ CMICmdArgValNumber(); /* ctor */ CMICmdArgValNumber(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const MIuint vnNumberFormatMask = eArgValNumberFormat_Decimal); // @@ -52,14 +49,14 @@ class CMICmdArgValNumber : public CMICmdArgValBaseTemplate<MIint64> // Overridden: public: // From CMICmdArgValBase - /* dtor */ ~CMICmdArgValNumber(void) override; + /* dtor */ ~CMICmdArgValNumber() override; // From CMICmdArgSet::IArg bool Validate(CMICmdArgContext &vwArgContext) override; // Methods: private: bool ExtractNumber(const CMIUtilString &vrTxt); - MIint64 GetNumber(void) const; + MIint64 GetNumber() const; // Attributes: private: diff --git a/tools/lldb-mi/MICmdArgValOptionLong.cpp b/tools/lldb-mi/MICmdArgValOptionLong.cpp index 0eaf6e0d055f..3c9578943072 100644 --- a/tools/lldb-mi/MICmdArgValOptionLong.cpp +++ b/tools/lldb-mi/MICmdArgValOptionLong.cpp @@ -18,7 +18,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgValOptionLong::CMICmdArgValOptionLong(void) +CMICmdArgValOptionLong::CMICmdArgValOptionLong() : m_nExpectingNOptions(0) , m_eExpectingOptionType(eArgValType_invalid) { @@ -66,7 +66,7 @@ CMICmdArgValOptionLong::CMICmdArgValOptionLong(const CMIUtilString &vrArgName, c // Return: None. // Throws: None. //-- -CMICmdArgValOptionLong::~CMICmdArgValOptionLong(void) +CMICmdArgValOptionLong::~CMICmdArgValOptionLong() { // Tidy up Destroy(); @@ -80,7 +80,7 @@ CMICmdArgValOptionLong::~CMICmdArgValOptionLong(void) // Throws: None. //-- void -CMICmdArgValOptionLong::Destroy(void) +CMICmdArgValOptionLong::Destroy() { // Tidy up VecArgObjPtr_t::const_iterator it = m_vecArgsExpected.begin(); @@ -249,19 +249,19 @@ CMICmdArgValOptionLong::ExtractExpectedOptions(CMICmdArgContext &vrwTxt, const M 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); + const bool bHavePosSlash = (vrTxt.find('/') != std::string::npos); + const bool bHaveBckSlash = (vrTxt.find('\\') != std::string::npos); if (bHavePosSlash || bHaveBckSlash) return false; - const size_t nPos = vrTxt.find_first_of("--"); + const size_t nPos = vrTxt.find("--"); if (nPos != 0) return false; if (vrTxt.length() < 3) return false; - const CMIUtilString strArg = vrTxt.substr(2).c_str(); + const CMIUtilString strArg = vrTxt.substr(2); if (strArg.IsNumber()) return false; @@ -293,7 +293,7 @@ CMICmdArgValOptionLong::IsArgOptionCorrect(const CMIUtilString &vrTxt) const bool CMICmdArgValOptionLong::ArgNameMatch(const CMIUtilString &vrTxt) const { - const CMIUtilString strArg = vrTxt.substr(2).c_str(); + const CMIUtilString strArg = vrTxt.substr(2); return (strArg == GetName()); } @@ -307,7 +307,7 @@ CMICmdArgValOptionLong::ArgNameMatch(const CMIUtilString &vrTxt) const // Throws: None. //-- const CMICmdArgValListBase::VecArgObjPtr_t & -CMICmdArgValOptionLong::GetExpectedOptions(void) const +CMICmdArgValOptionLong::GetExpectedOptions() const { return m_vecArgsExpected; } diff --git a/tools/lldb-mi/MICmdArgValOptionLong.h b/tools/lldb-mi/MICmdArgValOptionLong.h index ac55c47fb7af..9d074fc07459 100644 --- a/tools/lldb-mi/MICmdArgValOptionLong.h +++ b/tools/lldb-mi/MICmdArgValOptionLong.h @@ -26,27 +26,24 @@ class CMIUtilString; // 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(); /* 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; + const VecArgObjPtr_t &GetExpectedOptions() const; template <class T1, typename T2> bool GetExpectedOption(T2 &vrwValue) const; // Overridden: public: // From CMICmdArgValBase - /* dtor */ ~CMICmdArgValOptionLong(void) override; + /* dtor */ ~CMICmdArgValOptionLong() override; // From CMICmdArgSet::IArg bool Validate(CMICmdArgContext &vArgContext) override; @@ -61,7 +58,7 @@ class CMICmdArgValOptionLong : public CMICmdArgValListBase // Methods: private: - void Destroy(void); + void Destroy(); // Attributes: private: diff --git a/tools/lldb-mi/MICmdArgValOptionShort.cpp b/tools/lldb-mi/MICmdArgValOptionShort.cpp index d18f72eaa8b1..d5bdfa0fa2cb 100644 --- a/tools/lldb-mi/MICmdArgValOptionShort.cpp +++ b/tools/lldb-mi/MICmdArgValOptionShort.cpp @@ -18,7 +18,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgValOptionShort::CMICmdArgValOptionShort(void) +CMICmdArgValOptionShort::CMICmdArgValOptionShort() { } @@ -60,7 +60,7 @@ CMICmdArgValOptionShort::CMICmdArgValOptionShort(const CMIUtilString &vrArgName, // Return: None. // Throws: None. //-- -CMICmdArgValOptionShort::~CMICmdArgValOptionShort(void) +CMICmdArgValOptionShort::~CMICmdArgValOptionShort() { } @@ -115,6 +115,6 @@ CMICmdArgValOptionShort::IsArgOptionCorrect(const CMIUtilString &vrTxt) const bool CMICmdArgValOptionShort::ArgNameMatch(const CMIUtilString &vrTxt) const { - const CMIUtilString strArg = vrTxt.substr(1).c_str(); + const CMIUtilString strArg = vrTxt.substr(1); return (strArg == GetName()); } diff --git a/tools/lldb-mi/MICmdArgValOptionShort.h b/tools/lldb-mi/MICmdArgValOptionShort.h index 9157b37bb8dc..0f1c2fc12c3d 100644 --- a/tools/lldb-mi/MICmdArgValOptionShort.h +++ b/tools/lldb-mi/MICmdArgValOptionShort.h @@ -26,15 +26,12 @@ class CMIUtilString; // 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(); /* 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); @@ -44,7 +41,7 @@ class CMICmdArgValOptionShort : public CMICmdArgValOptionLong // Overridden: public: // From CMICmdArgValBase - /* dtor */ ~CMICmdArgValOptionShort(void) override; + /* dtor */ ~CMICmdArgValOptionShort() override; // Overridden: private: diff --git a/tools/lldb-mi/MICmdArgValPrintValues.cpp b/tools/lldb-mi/MICmdArgValPrintValues.cpp index 3030782a3a29..3b6eddd315ac 100644 --- a/tools/lldb-mi/MICmdArgValPrintValues.cpp +++ b/tools/lldb-mi/MICmdArgValPrintValues.cpp @@ -18,7 +18,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgValPrintValues::CMICmdArgValPrintValues(void) +CMICmdArgValPrintValues::CMICmdArgValPrintValues() : m_nPrintValues(0) { } @@ -45,7 +45,7 @@ CMICmdArgValPrintValues::CMICmdArgValPrintValues(const CMIUtilString &vrArgName, // Return: None. // Throws: None. //-- -CMICmdArgValPrintValues::~CMICmdArgValPrintValues(void) +CMICmdArgValPrintValues::~CMICmdArgValPrintValues() { } @@ -123,7 +123,7 @@ CMICmdArgValPrintValues::ExtractPrintValues(const CMIUtilString &vrTxt) // Throws: None. //-- MIuint -CMICmdArgValPrintValues::GetPrintValues(void) const +CMICmdArgValPrintValues::GetPrintValues() const { return m_nPrintValues; } diff --git a/tools/lldb-mi/MICmdArgValPrintValues.h b/tools/lldb-mi/MICmdArgValPrintValues.h index 9ac3238aeb75..fa8ec8a54773 100644 --- a/tools/lldb-mi/MICmdArgValPrintValues.h +++ b/tools/lldb-mi/MICmdArgValPrintValues.h @@ -30,7 +30,7 @@ class CMICmdArgValPrintValues : public CMICmdArgValBaseTemplate<MIuint> { // Methods: public: - /* ctor */ CMICmdArgValPrintValues(void); + /* ctor */ CMICmdArgValPrintValues(); /* ctor */ CMICmdArgValPrintValues(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd); // bool IsArgPrintValues(const CMIUtilString &vrTxt) const; @@ -38,14 +38,14 @@ class CMICmdArgValPrintValues : public CMICmdArgValBaseTemplate<MIuint> // Overridden: public: // From CMICmdArgValBase - /* dtor */ ~CMICmdArgValPrintValues(void) override; + /* dtor */ ~CMICmdArgValPrintValues() override; // From CMICmdArgSet::IArg bool Validate(CMICmdArgContext &vArgContext) override; // Methods: private: bool ExtractPrintValues(const CMIUtilString &vrTxt); - MIuint GetPrintValues(void) const; + MIuint GetPrintValues() const; // Attributes: private: diff --git a/tools/lldb-mi/MICmdArgValString.cpp b/tools/lldb-mi/MICmdArgValString.cpp index 1c3e5f84d3dd..bea593552327 100644 --- a/tools/lldb-mi/MICmdArgValString.cpp +++ b/tools/lldb-mi/MICmdArgValString.cpp @@ -18,7 +18,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgValString::CMICmdArgValString(void) +CMICmdArgValString::CMICmdArgValString() : m_bHandleQuotedString(false) , m_bAcceptNumbers(false) , m_bHandleDirPaths(false) @@ -91,7 +91,7 @@ CMICmdArgValString::CMICmdArgValString(const CMIUtilString &vrArgName, const boo // Return: None. // Throws: None. //-- -CMICmdArgValString::~CMICmdArgValString(void) +CMICmdArgValString::~CMICmdArgValString() { } @@ -220,8 +220,8 @@ CMICmdArgValString::IsStringArgSingleText(const CMIUtilString &vrTxt) const 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); + const bool bHavePosSlash = (vrTxt.find('/') != std::string::npos); + const bool bHaveBckSlash = (vrTxt.find('\\') != std::string::npos); if (bHavePosSlash || bHaveBckSlash) return false; } diff --git a/tools/lldb-mi/MICmdArgValString.h b/tools/lldb-mi/MICmdArgValString.h index 8b58a0a88dd6..cf4d00e192cc 100644 --- a/tools/lldb-mi/MICmdArgValString.h +++ b/tools/lldb-mi/MICmdArgValString.h @@ -22,15 +22,12 @@ class CMICmdArgContext; // 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> { // Methods: public: - /* ctor */ CMICmdArgValString(void); + /* ctor */ CMICmdArgValString(); /* 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, @@ -41,7 +38,7 @@ class CMICmdArgValString : public CMICmdArgValBaseTemplate<CMIUtilString> // Overridden: public: // From CMICmdArgValBase - /* dtor */ ~CMICmdArgValString(void) override; + /* dtor */ ~CMICmdArgValString() override; // From CMICmdArgSet::IArg bool Validate(CMICmdArgContext &vrwArgContext) override; diff --git a/tools/lldb-mi/MICmdArgValThreadGrp.cpp b/tools/lldb-mi/MICmdArgValThreadGrp.cpp index c7e663c4721b..43e9c724dca1 100644 --- a/tools/lldb-mi/MICmdArgValThreadGrp.cpp +++ b/tools/lldb-mi/MICmdArgValThreadGrp.cpp @@ -18,7 +18,7 @@ // Return: None. // Throws: None. //-- -CMICmdArgValThreadGrp::CMICmdArgValThreadGrp(void) +CMICmdArgValThreadGrp::CMICmdArgValThreadGrp() : m_nThreadGrp(0) { } @@ -45,7 +45,7 @@ CMICmdArgValThreadGrp::CMICmdArgValThreadGrp(const CMIUtilString &vrArgName, con // Return: None. // Throws: None. //-- -CMICmdArgValThreadGrp::~CMICmdArgValThreadGrp(void) +CMICmdArgValThreadGrp::~CMICmdArgValThreadGrp() { } @@ -117,11 +117,11 @@ bool CMICmdArgValThreadGrp::IsArgThreadGrp(const CMIUtilString &vrTxt) const { // Look for i1 i2 i3.... - const MIint nPos = vrTxt.find_first_of("i"); + const MIint nPos = vrTxt.find('i'); if (nPos != 0) return false; - const CMIUtilString strNum = vrTxt.substr(1).c_str(); + const CMIUtilString strNum = vrTxt.substr(1); if (!strNum.IsNumber()) return false; @@ -139,7 +139,7 @@ CMICmdArgValThreadGrp::IsArgThreadGrp(const CMIUtilString &vrTxt) const bool CMICmdArgValThreadGrp::ExtractNumber(const CMIUtilString &vrTxt) { - const CMIUtilString strNum = vrTxt.substr(1).c_str(); + const CMIUtilString strNum = vrTxt.substr(1); MIint64 nNumber = 0; bool bOk = strNum.ExtractNumber(nNumber); if (bOk) @@ -158,7 +158,7 @@ CMICmdArgValThreadGrp::ExtractNumber(const CMIUtilString &vrTxt) // Throws: None. //-- MIuint -CMICmdArgValThreadGrp::GetNumber(void) const +CMICmdArgValThreadGrp::GetNumber() const { return m_nThreadGrp; } diff --git a/tools/lldb-mi/MICmdArgValThreadGrp.h b/tools/lldb-mi/MICmdArgValThreadGrp.h index 64c11405e8ab..5c4936c01520 100644 --- a/tools/lldb-mi/MICmdArgValThreadGrp.h +++ b/tools/lldb-mi/MICmdArgValThreadGrp.h @@ -23,15 +23,12 @@ class CMICmdArgContext; // 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> { // Methods: public: - /* ctor */ CMICmdArgValThreadGrp(void); + /* ctor */ CMICmdArgValThreadGrp(); /* ctor */ CMICmdArgValThreadGrp(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd); // bool IsArgThreadGrp(const CMIUtilString &vrTxt) const; @@ -39,14 +36,14 @@ class CMICmdArgValThreadGrp : public CMICmdArgValBaseTemplate<MIuint> // Overridden: public: // From CMICmdArgValBase - /* dtor */ ~CMICmdArgValThreadGrp(void) override; + /* dtor */ ~CMICmdArgValThreadGrp() override; // From CMICmdArgSet::IArg bool Validate(CMICmdArgContext &vArgContext) override; // Methods: private: bool ExtractNumber(const CMIUtilString &vrTxt); - MIuint GetNumber(void) const; + MIuint GetNumber() const; // Attributes: private: diff --git a/tools/lldb-mi/MICmdBase.cpp b/tools/lldb-mi/MICmdBase.cpp index 97bf5a074d6d..2f63205dd9b7 100644 --- a/tools/lldb-mi/MICmdBase.cpp +++ b/tools/lldb-mi/MICmdBase.cpp @@ -11,6 +11,8 @@ #include "MICmdBase.h" #include "MICmnMIValueConst.h" #include "MICmnLLDBDebugSessionInfo.h" +#include "MICmdArgValOptionLong.h" +#include "MICmdArgValConsume.h" //++ ------------------------------------------------------------------------------------ // Details: CMICmdBase constructor. @@ -19,10 +21,17 @@ // Return: None. // Throws: None. //-- -CMICmdBase::CMICmdBase(void) +CMICmdBase::CMICmdBase() : m_pSelfCreatorFn(nullptr) , m_rLLDBDebugSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()) , m_bHasResultRecordExtra(false) + , m_constStrArgThreadGroup("thread-group") + , m_constStrArgThread("thread") + , m_constStrArgFrame("frame") + , m_constStrArgConsume("--") + , m_ThreadGrpArgMandatory(false) + , m_ThreadArgMandatory(false) + , m_FrameArgMandatory(false) { } @@ -33,7 +42,7 @@ CMICmdBase::CMICmdBase(void) // Return: None. // Throws: None. //-- -CMICmdBase::~CMICmdBase(void) +CMICmdBase::~CMICmdBase() { } @@ -45,7 +54,7 @@ CMICmdBase::~CMICmdBase(void) // Throws: None. //-- const SMICmdData & -CMICmdBase::GetCmdData(void) const +CMICmdBase::GetCmdData() const { return m_cmdData; } @@ -59,7 +68,7 @@ CMICmdBase::GetCmdData(void) const // Throws: None. //-- const CMIUtilString & -CMICmdBase::GetErrorDescription(void) const +CMICmdBase::GetErrorDescription() const { return m_strCurrentErrDescription; } @@ -73,26 +82,38 @@ CMICmdBase::GetErrorDescription(void) const // Throws: None. //-- const CMIUtilString & -CMICmdBase::GetMiCmd(void) const +CMICmdBase::GetMiCmd() const { return m_strMiCmd; } //++ ------------------------------------------------------------------------------------ +// Details: Help parse the arguments that are common to all commands. +// Args: None. +// Return: None +// Throws: None. +//-- +void +CMICmdBase::AddCommonArgs() +{ + m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgThreadGroup, m_ThreadGrpArgMandatory, true, CMICmdArgValListBase::eArgValType_ThreadGrp, 1)); + m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgThread, m_ThreadArgMandatory, true, CMICmdArgValListBase::eArgValType_Number, 1)); + m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgFrame, m_FrameArgMandatory, true, CMICmdArgValListBase::eArgValType_Number, 1)); + m_setCmdArgs.Add(new CMICmdArgValConsume(m_constStrArgConsume, false)); +} + +//++ ------------------------------------------------------------------------------------ // 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. +// Return: None. // Throws: None. //-- -bool +void CMICmdBase::SetCmdData(const SMICmdData &vCmdData) { m_cmdData = vCmdData; - - return MIstatus::success; } //++ ------------------------------------------------------------------------------------ @@ -104,7 +125,7 @@ CMICmdBase::SetCmdData(const SMICmdData &vCmdData) // Throws: None. //-- CMICmdFactory::CmdCreatorFnPtr -CMICmdBase::GetCmdCreatorFn(void) const +CMICmdBase::GetCmdCreatorFn() const { return m_pSelfCreatorFn; } @@ -120,7 +141,7 @@ CMICmdBase::GetCmdCreatorFn(void) const // Throws: None. //-- void -CMICmdBase::CmdFinishedTellInvoker(void) const +CMICmdBase::CmdFinishedTellInvoker() const { CMICmdInvoker::Instance().CmdExecuteFinished(const_cast<CMICmdBase &>(*this)); } @@ -134,7 +155,7 @@ CMICmdBase::CmdFinishedTellInvoker(void) const // Throws: None. //-- const CMIUtilString & -CMICmdBase::GetMIResultRecord(void) const +CMICmdBase::GetMIResultRecord() const { return m_miResultRecord.GetString(); } @@ -149,7 +170,7 @@ CMICmdBase::GetMIResultRecord(void) const // Throws: None. //-- const CMIUtilString & -CMICmdBase::GetMIResultRecordExtra(void) const +CMICmdBase::GetMIResultRecordExtra() const { return m_miResultRecordExtra; } @@ -164,7 +185,7 @@ CMICmdBase::GetMIResultRecordExtra(void) const // Throws: None. //-- bool -CMICmdBase::HasMIResultRecordExtra(void) const +CMICmdBase::HasMIResultRecordExtra() const { return m_bHasResultRecordExtra; } @@ -198,7 +219,7 @@ CMICmdBase::SetError(const CMIUtilString &rErrMsg) // Throws: None. //-- MIuint -CMICmdBase::GetGUID(void) +CMICmdBase::GetGUID() { MIuint64 vptr = reinterpret_cast<MIuint64>(this); MIuint id = (vptr)&0xFFFFFFFF; @@ -217,7 +238,7 @@ CMICmdBase::GetGUID(void) // Throws: None. //-- bool -CMICmdBase::ParseArgs(void) +CMICmdBase::ParseArgs() { // Do nothing - override to implement @@ -236,7 +257,7 @@ CMICmdBase::ParseArgs(void) // Throws: None. //-- bool -CMICmdBase::ParseValidateCmdOptions(void) +CMICmdBase::ParseValidateCmdOptions() { CMICmdArgContext argCntxt(m_cmdData.strMiCmdOption); if (m_setCmdArgs.Validate(m_cmdData.strMiCmd, argCntxt)) @@ -259,7 +280,7 @@ CMICmdBase::ParseValidateCmdOptions(void) // Throws: None. //-- bool -CMICmdBase::GetExitAppOnCommandFailure(void) const +CMICmdBase::GetExitAppOnCommandFailure() const { return false; } diff --git a/tools/lldb-mi/MICmdBase.h b/tools/lldb-mi/MICmdBase.h index df1e429bdce6..aa5674823965 100644 --- a/tools/lldb-mi/MICmdBase.h +++ b/tools/lldb-mi/MICmdBase.h @@ -9,7 +9,10 @@ #pragma once -// In-house headers: +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "MIUtilString.h" #include "MICmnBase.h" #include "MICmnResources.h" @@ -42,46 +45,41 @@ class CMICmnLLDBDebugSessionInfo; // 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 { // Methods: public: - /* ctor */ CMICmdBase(void); + CMICmdBase(); // 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); + const SMICmdData &GetCmdData() const override; + const CMIUtilString &GetErrorDescription() const override; + void SetCmdData(const SMICmdData &vCmdData) override; + void CmdFinishedTellInvoker() const override; + const CMIUtilString &GetMIResultRecord() const override; + const CMIUtilString &GetMIResultRecordExtra() const override; + bool HasMIResultRecordExtra() const override; + bool ParseArgs() override; // From CMICmdFactory::ICmd - virtual const CMIUtilString &GetMiCmd(void) const; - virtual CMICmdFactory::CmdCreatorFnPtr GetCmdCreatorFn(void) const; + const CMIUtilString &GetMiCmd() const override; + CMICmdFactory::CmdCreatorFnPtr GetCmdCreatorFn() const override; - virtual MIuint GetGUID(void); + virtual MIuint GetGUID(); + void AddCommonArgs(); // Overrideable: - public: - /* dtor */ virtual ~CMICmdBase(void); - virtual bool GetExitAppOnCommandFailure(void) const; + ~CMICmdBase() override; + virtual bool GetExitAppOnCommandFailure() const; // Methods: protected: void SetError(const CMIUtilString &rErrMsg); template <class T> T *GetOption(const CMIUtilString &vStrOptionName); - bool ParseValidateCmdOptions(void); + bool ParseValidateCmdOptions(); // 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. @@ -97,6 +95,16 @@ class CMICmdBase : public CMICmnBase, public CMICmdInvoker::ICmd, public CMICmdF 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. + const CMIUtilString m_constStrArgThreadGroup; + const CMIUtilString m_constStrArgThread; + const CMIUtilString m_constStrArgFrame; + const CMIUtilString m_constStrArgConsume; + + // These 3 members can be used by the derived classes to make any of + // "thread", "frame" or "thread-group" mandatory. + bool m_ThreadGrpArgMandatory; + bool m_ThreadArgMandatory; + bool m_FrameArgMandatory; }; //++ ------------------------------------------------------------------------------------ @@ -109,7 +117,7 @@ class CMICmdBase : public CMICmnBase, public CMICmdInvoker::ICmd, public CMICmdF // 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. +// - nullptr = function has failed, unable to retrieve the option/arg object. // Throws: None. //-- template <class T> @@ -136,7 +144,7 @@ CMICmdBase::GetOption(const CMIUtilString &vStrOptionName) // 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. +// - nullptr = function has failed, unable to retrieve the option/arg object. // Throws: None. //-- #define CMICMDBASE_GETOPTION(a, b, c) \ diff --git a/tools/lldb-mi/MICmdCmd.cpp b/tools/lldb-mi/MICmdCmd.cpp index fbfc60995c5a..c6661112ea3e 100644 --- a/tools/lldb-mi/MICmdCmd.cpp +++ b/tools/lldb-mi/MICmdCmd.cpp @@ -22,7 +22,7 @@ // Return: None. // Throws: None. //-- -CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting(void) +CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "enable-pretty-printing"; @@ -38,7 +38,7 @@ CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting(void) // Return: None. // Throws: None. //-- -CMICmdCmdEnablePrettyPrinting::~CMICmdCmdEnablePrettyPrinting(void) +CMICmdCmdEnablePrettyPrinting::~CMICmdCmdEnablePrettyPrinting() { } @@ -52,7 +52,7 @@ CMICmdCmdEnablePrettyPrinting::~CMICmdCmdEnablePrettyPrinting(void) // Throws: None. //-- bool -CMICmdCmdEnablePrettyPrinting::Execute(void) +CMICmdCmdEnablePrettyPrinting::Execute() { // Do nothing return MIstatus::success; @@ -68,7 +68,7 @@ CMICmdCmdEnablePrettyPrinting::Execute(void) // Throws: None. //-- bool -CMICmdCmdEnablePrettyPrinting::Acknowledge(void) +CMICmdCmdEnablePrettyPrinting::Acknowledge() { const CMICmnMIValueConst miValueConst("0"); const CMICmnMIValueResult miValueResult("supported", miValueConst); @@ -87,7 +87,7 @@ CMICmdCmdEnablePrettyPrinting::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdEnablePrettyPrinting::CreateSelf(void) +CMICmdCmdEnablePrettyPrinting::CreateSelf() { return new CMICmdCmdEnablePrettyPrinting(); } @@ -103,7 +103,7 @@ CMICmdCmdEnablePrettyPrinting::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdSource::CMICmdCmdSource(void) +CMICmdCmdSource::CMICmdCmdSource() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "source"; @@ -119,7 +119,7 @@ CMICmdCmdSource::CMICmdCmdSource(void) // Return: None. // Throws: None. //-- -CMICmdCmdSource::~CMICmdCmdSource(void) +CMICmdCmdSource::~CMICmdCmdSource() { } @@ -133,7 +133,7 @@ CMICmdCmdSource::~CMICmdCmdSource(void) // Throws: None. //-- bool -CMICmdCmdSource::Execute(void) +CMICmdCmdSource::Execute() { // Do nothing return MIstatus::success; @@ -149,7 +149,7 @@ CMICmdCmdSource::Execute(void) // Throws: None. //-- bool -CMICmdCmdSource::Acknowledge(void) +CMICmdCmdSource::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -166,7 +166,7 @@ CMICmdCmdSource::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdSource::CreateSelf(void) +CMICmdCmdSource::CreateSelf() { return new CMICmdCmdSource(); } diff --git a/tools/lldb-mi/MICmdCmd.h b/tools/lldb-mi/MICmdCmd.h index 26697643c5e3..6753c3b53909 100644 --- a/tools/lldb-mi/MICmdCmd.h +++ b/tools/lldb-mi/MICmdCmd.h @@ -41,53 +41,47 @@ MI commands implemented are: // *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); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdEnablePrettyPrinting(void); + /* ctor */ CMICmdCmdEnablePrettyPrinting(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdEnablePrettyPrinting(void) override; + /* dtor */ ~CMICmdCmdEnablePrettyPrinting() override; }; //++ ============================================================================ // 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 { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdSource(void); + /* ctor */ CMICmdCmdSource(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdSource(void) override; + /* dtor */ ~CMICmdCmdSource() override; }; diff --git a/tools/lldb-mi/MICmdCmdBreak.cpp b/tools/lldb-mi/MICmdCmdBreak.cpp index 8a310c79d02b..e758a3dcccef 100644 --- a/tools/lldb-mi/MICmdCmdBreak.cpp +++ b/tools/lldb-mi/MICmdCmdBreak.cpp @@ -40,7 +40,7 @@ // Return: None. // Throws: None. //-- -CMICmdCmdBreakInsert::CMICmdCmdBreakInsert(void) +CMICmdCmdBreakInsert::CMICmdCmdBreakInsert() : m_bBrkPtIsTemp(false) , m_bBrkPtIsPending(false) , m_nBrkPtIgnoreCount(0) @@ -57,7 +57,6 @@ CMICmdCmdBreakInsert::CMICmdCmdBreakInsert(void) , 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"; @@ -73,7 +72,7 @@ CMICmdCmdBreakInsert::CMICmdCmdBreakInsert(void) // Return: None. // Throws: None. //-- -CMICmdCmdBreakInsert::~CMICmdCmdBreakInsert(void) +CMICmdCmdBreakInsert::~CMICmdCmdBreakInsert() { } @@ -87,29 +86,41 @@ CMICmdCmdBreakInsert::~CMICmdCmdBreakInsert(void) // Throws: None. //-- bool -CMICmdCmdBreakInsert::ParseArgs(void) +CMICmdCmdBreakInsert::ParseArgs() { - 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()); + m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedTempBrkPt, false, true)); + // Not implemented m_setCmdArgs.Add(new CMICmdArgValOptionShort( m_constStrArgNamedHWBrkPt, false, false)); + m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedPendinfBrkPt, false, true, + CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1)); + m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedDisableBrkPt, false, false)); + // Not implemented m_setCmdArgs.Add(new CMICmdArgValOptionShort( m_constStrArgNamedTracePt, false, false)); + m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedConditionalBrkPt, false, true, + CMICmdArgValListBase::eArgValType_StringQuoted, 1)); + m_setCmdArgs.Add( + new CMICmdArgValOptionShort(m_constStrArgNamedInoreCnt, false, true, CMICmdArgValListBase::eArgValType_Number, 1)); + m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedRestrictBrkPtToThreadId, false, true, + CMICmdArgValListBase::eArgValType_Number, 1)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedLocation, false, true)); + return ParseValidateCmdOptions(); +} + +//++ ------------------------------------------------------------------------------------ +// Helper function for CMICmdCmdBreakInsert::Execute(). +// +// Given a string, return the position of the ':' separator in 'file:func' +// or 'file:line', if any. If not found, return npos. For example, return +// 5 for 'foo.c:std::string'. +//-- +static size_t findFileSeparatorPos(const std::string& x) +{ + // Full paths in windows can have ':' after a drive letter, so we + // search backwards, taking care to skip C++ namespace tokens '::'. + size_t n = x.rfind(':'); + while (n != std::string::npos && n > 1 && x[n-1] == ':') + { + n = x.rfind(':', n - 2); + } + return n; } //++ ------------------------------------------------------------------------------------ @@ -122,10 +133,10 @@ CMICmdCmdBreakInsert::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdBreakInsert::Execute(void) +CMICmdCmdBreakInsert::Execute() { CMICMDBASE_GETOPTION(pArgTempBrkPt, OptionShort, m_constStrArgNamedTempBrkPt); - CMICMDBASE_GETOPTION(pArgThreadGroup, OptionLong, m_constStrArgNamedThreadGroup); + CMICMDBASE_GETOPTION(pArgThreadGroup, OptionLong, m_constStrArgThreadGroup); CMICMDBASE_GETOPTION(pArgLocation, String, m_constStrArgNamedLocation); CMICMDBASE_GETOPTION(pArgIgnoreCnt, OptionShort, m_constStrArgNamedInoreCnt); CMICMDBASE_GETOPTION(pArgPendingBrkPt, OptionShort, m_constStrArgNamedPendinfBrkPt); @@ -166,17 +177,16 @@ CMICmdCmdBreakInsert::Execute(void) // 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; CMIUtilString rStrLineOrFn; - // Full path in windows can have : after drive letter. So look for the - // last colon - const size_t nPosColon = m_brkName.find_last_of(cColon); + // Is the string in the form 'file:func' or 'file:line'? + // If so, find the position of the ':' separator. + const size_t nPosColon = findFileSeparatorPos(m_brkName); if (nPosColon != std::string::npos) { - // extract file name and line number from it + // Extract file name and line number from it fileName = m_brkName.substr(0, nPosColon); rStrLineOrFn = m_brkName.substr(nPosColon + 1, m_brkName.size() - nPosColon - 1); @@ -226,8 +236,13 @@ CMICmdCmdBreakInsert::Execute(void) m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress); break; case eBreakPoint_ByFileFn: - m_brkPt = sbTarget.BreakpointCreateByName(strFileFn.c_str(), fileName.c_str()); + { + lldb::SBFileSpecList module; // search in all modules + lldb::SBFileSpecList compUnit; + compUnit.Append (lldb::SBFileSpec(fileName.c_str())); + m_brkPt = sbTarget.BreakpointCreateByName(strFileFn.c_str(), module, compUnit); break; + } case eBreakPoint_ByFileLine: m_brkPt = sbTarget.BreakpointCreateByLocation(fileName.c_str(), nFileLine); break; @@ -306,7 +321,7 @@ CMICmdCmdBreakInsert::Execute(void) // Throws: None. //-- bool -CMICmdCmdBreakInsert::Acknowledge(void) +CMICmdCmdBreakInsert::Acknowledge() { // Get breakpoint information CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); @@ -336,7 +351,7 @@ CMICmdCmdBreakInsert::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdBreakInsert::CreateSelf(void) +CMICmdCmdBreakInsert::CreateSelf() { return new CMICmdCmdBreakInsert(); } @@ -352,9 +367,8 @@ CMICmdCmdBreakInsert::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdBreakDelete::CMICmdCmdBreakDelete(void) +CMICmdCmdBreakDelete::CMICmdCmdBreakDelete() : m_constStrArgNamedBrkPt("breakpoint") - , m_constStrArgNamedThreadGrp("thread-group") { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "break-delete"; @@ -370,7 +384,7 @@ CMICmdCmdBreakDelete::CMICmdCmdBreakDelete(void) // Return: None. // Throws: None. //-- -CMICmdCmdBreakDelete::~CMICmdCmdBreakDelete(void) +CMICmdCmdBreakDelete::~CMICmdCmdBreakDelete() { } @@ -384,13 +398,10 @@ CMICmdCmdBreakDelete::~CMICmdCmdBreakDelete(void) // Throws: None. //-- bool -CMICmdCmdBreakDelete::ParseArgs(void) +CMICmdCmdBreakDelete::ParseArgs() { - 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()); + m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -403,7 +414,7 @@ CMICmdCmdBreakDelete::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdBreakDelete::Execute(void) +CMICmdCmdBreakDelete::Execute() { CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt); @@ -437,7 +448,7 @@ CMICmdCmdBreakDelete::Execute(void) // Throws: None. //-- bool -CMICmdCmdBreakDelete::Acknowledge(void) +CMICmdCmdBreakDelete::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -454,7 +465,7 @@ CMICmdCmdBreakDelete::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdBreakDelete::CreateSelf(void) +CMICmdCmdBreakDelete::CreateSelf() { return new CMICmdCmdBreakDelete(); } @@ -470,9 +481,8 @@ CMICmdCmdBreakDelete::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdBreakDisable::CMICmdCmdBreakDisable(void) - : m_constStrArgNamedThreadGrp("thread-group") - , m_constStrArgNamedBrkPt("breakpoint") +CMICmdCmdBreakDisable::CMICmdCmdBreakDisable() + : m_constStrArgNamedBrkPt("breakpoint") , m_bBrkPtDisabledOk(false) , m_nBrkPtId(0) { @@ -490,7 +500,7 @@ CMICmdCmdBreakDisable::CMICmdCmdBreakDisable(void) // Return: None. // Throws: None. //-- -CMICmdCmdBreakDisable::~CMICmdCmdBreakDisable(void) +CMICmdCmdBreakDisable::~CMICmdCmdBreakDisable() { } @@ -504,13 +514,10 @@ CMICmdCmdBreakDisable::~CMICmdCmdBreakDisable(void) // Throws: None. //-- bool -CMICmdCmdBreakDisable::ParseArgs(void) +CMICmdCmdBreakDisable::ParseArgs() { - 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()); + m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -523,7 +530,7 @@ CMICmdCmdBreakDisable::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdBreakDisable::Execute(void) +CMICmdCmdBreakDisable::Execute() { CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt); @@ -557,7 +564,7 @@ CMICmdCmdBreakDisable::Execute(void) // Throws: None. //-- bool -CMICmdCmdBreakDisable::Acknowledge(void) +CMICmdCmdBreakDisable::Acknowledge() { if (m_bBrkPtDisabledOk) { @@ -566,10 +573,10 @@ CMICmdCmdBreakDisable::Acknowledge(void) CMICmnMIValueTuple miValueTuple(miValueResult); const CMICmnMIValueConst miValueConst2("n"); const CMICmnMIValueResult miValueResult2("enabled", miValueConst2); - bool bOk = miValueTuple.Add(miValueResult2); + miValueTuple.Add(miValueResult2); const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple); const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3); - bOk = bOk && CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString()); + bool bOk = CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString()); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -594,7 +601,7 @@ CMICmdCmdBreakDisable::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdBreakDisable::CreateSelf(void) +CMICmdCmdBreakDisable::CreateSelf() { return new CMICmdCmdBreakDisable(); } @@ -610,9 +617,8 @@ CMICmdCmdBreakDisable::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdBreakEnable::CMICmdCmdBreakEnable(void) - : m_constStrArgNamedThreadGrp("thread-group") - , m_constStrArgNamedBrkPt("breakpoint") +CMICmdCmdBreakEnable::CMICmdCmdBreakEnable() + : m_constStrArgNamedBrkPt("breakpoint") , m_bBrkPtEnabledOk(false) , m_nBrkPtId(0) { @@ -630,7 +636,7 @@ CMICmdCmdBreakEnable::CMICmdCmdBreakEnable(void) // Return: None. // Throws: None. //-- -CMICmdCmdBreakEnable::~CMICmdCmdBreakEnable(void) +CMICmdCmdBreakEnable::~CMICmdCmdBreakEnable() { } @@ -644,13 +650,10 @@ CMICmdCmdBreakEnable::~CMICmdCmdBreakEnable(void) // Throws: None. //-- bool -CMICmdCmdBreakEnable::ParseArgs(void) +CMICmdCmdBreakEnable::ParseArgs() { - 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()); + m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -663,7 +666,7 @@ CMICmdCmdBreakEnable::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdBreakEnable::Execute(void) +CMICmdCmdBreakEnable::Execute() { CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt); @@ -697,7 +700,7 @@ CMICmdCmdBreakEnable::Execute(void) // Throws: None. //-- bool -CMICmdCmdBreakEnable::Acknowledge(void) +CMICmdCmdBreakEnable::Acknowledge() { if (m_bBrkPtEnabledOk) { @@ -706,10 +709,10 @@ CMICmdCmdBreakEnable::Acknowledge(void) CMICmnMIValueTuple miValueTuple(miValueResult); const CMICmnMIValueConst miValueConst2("y"); const CMICmnMIValueResult miValueResult2("enabled", miValueConst2); - bool bOk = miValueTuple.Add(miValueResult2); + miValueTuple.Add(miValueResult2); const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple); const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3); - bOk = bOk && CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString()); + bool bOk = CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString()); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -734,7 +737,7 @@ CMICmdCmdBreakEnable::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdBreakEnable::CreateSelf(void) +CMICmdCmdBreakEnable::CreateSelf() { return new CMICmdCmdBreakEnable(); } @@ -750,9 +753,8 @@ CMICmdCmdBreakEnable::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdBreakAfter::CMICmdCmdBreakAfter(void) - : m_constStrArgNamedThreadGrp("thread-group") - , m_constStrArgNamedNumber("number") +CMICmdCmdBreakAfter::CMICmdCmdBreakAfter() + : m_constStrArgNamedNumber("number") , m_constStrArgNamedCount("count") , m_nBrkPtId(0) , m_nBrkPtCount(0) @@ -771,7 +773,7 @@ CMICmdCmdBreakAfter::CMICmdCmdBreakAfter(void) // Return: None. // Throws: None. //-- -CMICmdCmdBreakAfter::~CMICmdCmdBreakAfter(void) +CMICmdCmdBreakAfter::~CMICmdCmdBreakAfter() { } @@ -785,13 +787,11 @@ CMICmdCmdBreakAfter::~CMICmdCmdBreakAfter(void) // Throws: None. //-- bool -CMICmdCmdBreakAfter::ParseArgs(void) +CMICmdCmdBreakAfter::ParseArgs() { - 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()); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true)); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedCount, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -804,7 +804,7 @@ CMICmdCmdBreakAfter::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdBreakAfter::Execute(void) +CMICmdCmdBreakAfter::Execute() { CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNamedNumber); CMICMDBASE_GETOPTION(pArgCount, Number, m_constStrArgNamedCount); @@ -847,7 +847,7 @@ CMICmdCmdBreakAfter::Execute(void) // Throws: None. //-- bool -CMICmdCmdBreakAfter::Acknowledge(void) +CMICmdCmdBreakAfter::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -864,7 +864,7 @@ CMICmdCmdBreakAfter::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdBreakAfter::CreateSelf(void) +CMICmdCmdBreakAfter::CreateSelf() { return new CMICmdCmdBreakAfter(); } @@ -880,9 +880,8 @@ CMICmdCmdBreakAfter::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdBreakCondition::CMICmdCmdBreakCondition(void) - : m_constStrArgNamedThreadGrp("thread-group") - , m_constStrArgNamedNumber("number") +CMICmdCmdBreakCondition::CMICmdCmdBreakCondition() + : 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 @@ -902,7 +901,7 @@ CMICmdCmdBreakCondition::CMICmdCmdBreakCondition(void) // Return: None. // Throws: None. //-- -CMICmdCmdBreakCondition::~CMICmdCmdBreakCondition(void) +CMICmdCmdBreakCondition::~CMICmdCmdBreakCondition() { } @@ -916,16 +915,13 @@ CMICmdCmdBreakCondition::~CMICmdCmdBreakCondition(void) // Throws: None. //-- bool -CMICmdCmdBreakCondition::ParseArgs(void) +CMICmdCmdBreakCondition::ParseArgs() { - 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()); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedExpr, true, true, true, true)); + m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedExprNoQuotes, false, false, + CMICmdArgValListBase::eArgValType_StringQuotedNumber)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -938,7 +934,7 @@ CMICmdCmdBreakCondition::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdBreakCondition::Execute(void) +CMICmdCmdBreakCondition::Execute() { CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNamedNumber); CMICMDBASE_GETOPTION(pArgExpr, String, m_constStrArgNamedExpr); @@ -982,7 +978,7 @@ CMICmdCmdBreakCondition::Execute(void) // Throws: None. //-- bool -CMICmdCmdBreakCondition::Acknowledge(void) +CMICmdCmdBreakCondition::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -999,7 +995,7 @@ CMICmdCmdBreakCondition::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdBreakCondition::CreateSelf(void) +CMICmdCmdBreakCondition::CreateSelf() { return new CMICmdCmdBreakCondition(); } @@ -1021,14 +1017,13 @@ CMICmdCmdBreakCondition::CreateSelf(void) // Throws: None. //-- CMIUtilString -CMICmdCmdBreakCondition::GetRestOfExpressionNotSurroundedInQuotes(void) +CMICmdCmdBreakCondition::GetRestOfExpressionNotSurroundedInQuotes() { CMIUtilString strExpression; CMICmdArgValListOfN *pArgExprNoQuotes = CMICmdBase::GetOption<CMICmdArgValListOfN>(m_constStrArgNamedExprNoQuotes); if (pArgExprNoQuotes != nullptr) { - CMIUtilString strExpression; const CMICmdArgValListBase::VecArgObjPtr_t &rVecExprParts(pArgExprNoQuotes->GetExpectedOptions()); if (!rVecExprParts.empty()) { diff --git a/tools/lldb-mi/MICmdCmdBreak.h b/tools/lldb-mi/MICmdCmdBreak.h index 476ab45762de..b8c4240a8a57 100644 --- a/tools/lldb-mi/MICmdCmdBreak.h +++ b/tools/lldb-mi/MICmdCmdBreak.h @@ -35,29 +35,26 @@ // 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); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdBreakInsert(void); + /* ctor */ CMICmdCmdBreakInsert(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdBreakInsert(void) override; + /* dtor */ ~CMICmdCmdBreakInsert() override; // Enumerations: private: @@ -98,72 +95,63 @@ class CMICmdCmdBreakInsert : public CMICmdBase 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. //-- class CMICmdCmdBreakDelete : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdBreakDelete(void); + /* ctor */ CMICmdCmdBreakDelete(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdBreakDelete(void) override; + /* dtor */ ~CMICmdCmdBreakDelete() override; // 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. //-- class CMICmdCmdBreakDisable : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdBreakDisable(void); + /* ctor */ CMICmdCmdBreakDisable(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdBreakDisable(void) override; + /* dtor */ ~CMICmdCmdBreakDisable() override; // 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; @@ -172,33 +160,29 @@ class CMICmdCmdBreakDisable : public CMICmdBase //++ ============================================================================ // 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); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdBreakEnable(void); + /* ctor */ CMICmdCmdBreakEnable(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdBreakEnable(void) override; + /* dtor */ ~CMICmdCmdBreakEnable() override; // 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; @@ -207,33 +191,29 @@ class CMICmdCmdBreakEnable : public CMICmdBase //++ ============================================================================ // 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); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdBreakAfter(void); + /* ctor */ CMICmdCmdBreakAfter(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdBreakAfter(void) override; + /* dtor */ ~CMICmdCmdBreakAfter() override; // 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; @@ -243,37 +223,33 @@ class CMICmdCmdBreakAfter : public CMICmdBase //++ ============================================================================ // 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); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdBreakCondition(void); + /* ctor */ CMICmdCmdBreakCondition(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdBreakCondition(void) override; + /* dtor */ ~CMICmdCmdBreakCondition() override; // Methods: private: - CMIUtilString GetRestOfExpressionNotSurroundedInQuotes(void); + CMIUtilString GetRestOfExpressionNotSurroundedInQuotes(); // 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 diff --git a/tools/lldb-mi/MICmdCmdData.cpp b/tools/lldb-mi/MICmdCmdData.cpp index 21036f865d9e..0e0cf12b0080 100644 --- a/tools/lldb-mi/MICmdCmdData.cpp +++ b/tools/lldb-mi/MICmdCmdData.cpp @@ -42,6 +42,7 @@ #include "MICmdArgValConsume.h" #include "MICmnLLDBDebugSessionInfoVarObj.h" #include "MICmnLLDBUtilSBValue.h" +#include "MIUtilParse.h" //++ ------------------------------------------------------------------------------------ // Details: CMICmdCmdDataEvaluateExpression constructor. @@ -50,15 +51,12 @@ // Return: None. // Throws: None. //-- -CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression(void) +CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression() : 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 @@ -75,7 +73,7 @@ CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataEvaluateExpression::~CMICmdCmdDataEvaluateExpression(void) +CMICmdCmdDataEvaluateExpression::~CMICmdCmdDataEvaluateExpression() { } @@ -89,14 +87,10 @@ CMICmdCmdDataEvaluateExpression::~CMICmdCmdDataEvaluateExpression(void) // Throws: None. //-- bool -CMICmdCmdDataEvaluateExpression::ParseArgs(void) +CMICmdCmdDataEvaluateExpression::ParseArgs() { - 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()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgExpr, true, true, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -109,7 +103,7 @@ CMICmdCmdDataEvaluateExpression::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdDataEvaluateExpression::Execute(void) +CMICmdCmdDataEvaluateExpression::Execute() { CMICMDBASE_GETOPTION(pArgExpr, String, m_constStrArgExpr); @@ -147,41 +141,7 @@ CMICmdCmdDataEvaluateExpression::Execute(void) 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().Escape().AddSlashes(); - 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); - } - } - + m_strValue = utilValue.GetValue(true).Escape().AddSlashes(); return MIstatus::success; } @@ -195,21 +155,12 @@ CMICmdCmdDataEvaluateExpression::Execute(void) // Throws: None. //-- bool -CMICmdCmdDataEvaluateExpression::Acknowledge(void) +CMICmdCmdDataEvaluateExpression::Acknowledge() { 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( @@ -251,7 +202,7 @@ CMICmdCmdDataEvaluateExpression::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdDataEvaluateExpression::CreateSelf(void) +CMICmdCmdDataEvaluateExpression::CreateSelf() { return new CMICmdCmdDataEvaluateExpression(); } @@ -285,11 +236,9 @@ CMICmdCmdDataEvaluateExpression::HaveInvalidCharacterInExpression(const CMIUtilS // Return: None. // Throws: None. //-- -CMICmdCmdDataDisassemble::CMICmdCmdDataDisassemble(void) - : m_constStrArgThread("thread") - , m_constStrArgAddrStart("s") +CMICmdCmdDataDisassemble::CMICmdCmdDataDisassemble() + : m_constStrArgAddrStart("s") , m_constStrArgAddrEnd("e") - , m_constStrArgConsume("--") , m_constStrArgMode("mode") , m_miValueList(true) { @@ -307,7 +256,7 @@ CMICmdCmdDataDisassemble::CMICmdCmdDataDisassemble(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataDisassemble::~CMICmdCmdDataDisassemble(void) +CMICmdCmdDataDisassemble::~CMICmdCmdDataDisassemble() { } @@ -321,19 +270,14 @@ CMICmdCmdDataDisassemble::~CMICmdCmdDataDisassemble(void) // Throws: None. //-- bool -CMICmdCmdDataDisassemble::ParseArgs(void) +CMICmdCmdDataDisassemble::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, 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()); + m_setCmdArgs.Add( + new CMICmdArgValOptionShort(m_constStrArgAddrStart, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1)); + m_setCmdArgs.Add( + new CMICmdArgValOptionShort(m_constStrArgAddrEnd, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1)); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgMode, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -346,7 +290,7 @@ CMICmdCmdDataDisassemble::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdDataDisassemble::Execute(void) +CMICmdCmdDataDisassemble::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgAddrStart, OptionShort, m_constStrArgAddrStart); @@ -476,7 +420,7 @@ CMICmdCmdDataDisassemble::Execute(void) // Throws: None. //-- bool -CMICmdCmdDataDisassemble::Acknowledge(void) +CMICmdCmdDataDisassemble::Acknowledge() { const CMICmnMIValueResult miValueResult("asm_insns", m_miValueList); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult); @@ -494,7 +438,7 @@ CMICmdCmdDataDisassemble::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdDataDisassemble::CreateSelf(void) +CMICmdCmdDataDisassemble::CreateSelf() { return new CMICmdCmdDataDisassemble(); } @@ -510,10 +454,8 @@ CMICmdCmdDataDisassemble::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataReadMemoryBytes::CMICmdCmdDataReadMemoryBytes(void) - : m_constStrArgThread("thread") - , m_constStrArgFrame("frame") - , m_constStrArgByteOffset("o") +CMICmdCmdDataReadMemoryBytes::CMICmdCmdDataReadMemoryBytes() + : m_constStrArgByteOffset("o") , m_constStrArgAddrExpr("address") , m_constStrArgNumBytes("count") , m_pBufferMemory(nullptr) @@ -534,7 +476,7 @@ CMICmdCmdDataReadMemoryBytes::CMICmdCmdDataReadMemoryBytes(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataReadMemoryBytes::~CMICmdCmdDataReadMemoryBytes(void) +CMICmdCmdDataReadMemoryBytes::~CMICmdCmdDataReadMemoryBytes() { if (m_pBufferMemory != nullptr) { @@ -553,18 +495,12 @@ CMICmdCmdDataReadMemoryBytes::~CMICmdCmdDataReadMemoryBytes(void) // Throws: None. //-- bool -CMICmdCmdDataReadMemoryBytes::ParseArgs(void) +CMICmdCmdDataReadMemoryBytes::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, true, 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 CMICmdArgValString(m_constStrArgAddrExpr, true, true, true, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumBytes, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgByteOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgAddrExpr, true, true, true, true)); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumBytes, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -577,7 +513,7 @@ CMICmdCmdDataReadMemoryBytes::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdDataReadMemoryBytes::Execute(void) +CMICmdCmdDataReadMemoryBytes::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame); @@ -700,7 +636,7 @@ CMICmdCmdDataReadMemoryBytes::Execute(void) // Throws: None. //-- bool -CMICmdCmdDataReadMemoryBytes::Acknowledge(void) +CMICmdCmdDataReadMemoryBytes::Acknowledge() { // MI: memory=[{begin=\"0x%016" PRIx64 "\",offset=\"0x%016" PRIx64" \",end=\"0x%016" PRIx64 "\",contents=\" \" }]" const CMICmnMIValueConst miValueConst(CMIUtilString::Format("0x%016" PRIx64, m_nAddrStart)); @@ -742,7 +678,7 @@ CMICmdCmdDataReadMemoryBytes::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdDataReadMemoryBytes::CreateSelf(void) +CMICmdCmdDataReadMemoryBytes::CreateSelf() { return new CMICmdCmdDataReadMemoryBytes(); } @@ -758,7 +694,7 @@ CMICmdCmdDataReadMemoryBytes::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory(void) +CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "data-read-memory"; @@ -774,7 +710,7 @@ CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataReadMemory::~CMICmdCmdDataReadMemory(void) +CMICmdCmdDataReadMemory::~CMICmdCmdDataReadMemory() { } @@ -788,7 +724,7 @@ CMICmdCmdDataReadMemory::~CMICmdCmdDataReadMemory(void) // Throws: None. //-- bool -CMICmdCmdDataReadMemory::Execute(void) +CMICmdCmdDataReadMemory::Execute() { // Do nothing - command deprecated use "data-read-memory-bytes" command return MIstatus::success; @@ -804,7 +740,7 @@ CMICmdCmdDataReadMemory::Execute(void) // Throws: None. //-- bool -CMICmdCmdDataReadMemory::Acknowledge(void) +CMICmdCmdDataReadMemory::Acknowledge() { // 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)); @@ -824,7 +760,7 @@ CMICmdCmdDataReadMemory::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdDataReadMemory::CreateSelf(void) +CMICmdCmdDataReadMemory::CreateSelf() { return new CMICmdCmdDataReadMemory(); } @@ -840,9 +776,8 @@ CMICmdCmdDataReadMemory::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataListRegisterNames::CMICmdCmdDataListRegisterNames(void) - : m_constStrArgThreadGroup("thread-group") - , m_constStrArgRegNo("regno") +CMICmdCmdDataListRegisterNames::CMICmdCmdDataListRegisterNames() + : m_constStrArgRegNo("regno") , m_miValueList(true) { // Command factory matches this name with that received from the stdin stream @@ -859,7 +794,7 @@ CMICmdCmdDataListRegisterNames::CMICmdCmdDataListRegisterNames(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataListRegisterNames::~CMICmdCmdDataListRegisterNames(void) +CMICmdCmdDataListRegisterNames::~CMICmdCmdDataListRegisterNames() { } @@ -873,12 +808,10 @@ CMICmdCmdDataListRegisterNames::~CMICmdCmdDataListRegisterNames(void) // Throws: None. //-- bool -CMICmdCmdDataListRegisterNames::ParseArgs(void) +CMICmdCmdDataListRegisterNames::ParseArgs() { - 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()); + m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgRegNo, false, false, CMICmdArgValListBase::eArgValType_Number)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -891,7 +824,7 @@ CMICmdCmdDataListRegisterNames::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdDataListRegisterNames::Execute(void) +CMICmdCmdDataListRegisterNames::Execute() { CMICMDBASE_GETOPTION(pArgRegNo, ListOfN, m_constStrArgRegNo); @@ -940,9 +873,7 @@ CMICmdCmdDataListRegisterNames::Execute(void) if (regValue.IsValid()) { const CMICmnMIValueConst miValueConst(CMICmnLLDBUtilSBValue(regValue).GetName()); - const bool bOk = m_miValueList.Add(miValueConst); - if (!bOk) - return MIstatus::failure; + m_miValueList.Add(miValueConst); } } } @@ -961,7 +892,7 @@ CMICmdCmdDataListRegisterNames::Execute(void) // Throws: None. //-- bool -CMICmdCmdDataListRegisterNames::Acknowledge(void) +CMICmdCmdDataListRegisterNames::Acknowledge() { const CMICmnMIValueResult miValueResult("register-names", m_miValueList); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult); @@ -979,7 +910,7 @@ CMICmdCmdDataListRegisterNames::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdDataListRegisterNames::CreateSelf(void) +CMICmdCmdDataListRegisterNames::CreateSelf() { return new CMICmdCmdDataListRegisterNames(); } @@ -1031,9 +962,8 @@ CMICmdCmdDataListRegisterNames::GetRegister(const MIuint vRegisterIndex) const // Return: None. // Throws: None. //-- -CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues(void) - : m_constStrArgThread("thread") - , m_constStrArgSkip("skip-unavailable") +CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues() + : m_constStrArgSkip("skip-unavailable") , m_constStrArgFormat("fmt") , m_constStrArgRegNo("regno") , m_miValueList(true) @@ -1052,7 +982,7 @@ CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataListRegisterValues::~CMICmdCmdDataListRegisterValues(void) +CMICmdCmdDataListRegisterValues::~CMICmdCmdDataListRegisterValues() { } @@ -1066,14 +996,13 @@ CMICmdCmdDataListRegisterValues::~CMICmdCmdDataListRegisterValues(void) // Throws: None. //-- bool -CMICmdCmdDataListRegisterValues::ParseArgs(void) +CMICmdCmdDataListRegisterValues::ParseArgs() { - 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()); + m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1)); + m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgSkip, false, false)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgFormat, true, true)); + m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgRegNo, false, true, CMICmdArgValListBase::eArgValType_Number)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -1086,7 +1015,7 @@ CMICmdCmdDataListRegisterValues::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdDataListRegisterValues::Execute(void) +CMICmdCmdDataListRegisterValues::Execute() { CMICMDBASE_GETOPTION(pArgFormat, String, m_constStrArgFormat); CMICMDBASE_GETOPTION(pArgRegNo, ListOfN, m_constStrArgRegNo); @@ -1124,9 +1053,7 @@ CMICmdCmdDataListRegisterValues::Execute(void) lldb::SBValue regValue = GetRegister(nRegIndex); if (regValue.IsValid()) { - const bool bOk = AddToOutput(nRegIndex, regValue, eFormat); - if (!bOk) - return MIstatus::failure; + AddToOutput(nRegIndex, regValue, eFormat); } // Next @@ -1150,9 +1077,7 @@ CMICmdCmdDataListRegisterValues::Execute(void) lldb::SBValue regValue = value.GetChildAtIndex(j); if (regValue.IsValid()) { - const bool bOk = AddToOutput(nRegIndex, regValue, eFormat); - if (!bOk) - return MIstatus::failure; + AddToOutput(nRegIndex, regValue, eFormat); } // Next @@ -1174,7 +1099,7 @@ CMICmdCmdDataListRegisterValues::Execute(void) // Throws: None. //-- bool -CMICmdCmdDataListRegisterValues::Acknowledge(void) +CMICmdCmdDataListRegisterValues::Acknowledge() { const CMICmnMIValueResult miValueResult("register-values", m_miValueList); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult); @@ -1192,7 +1117,7 @@ CMICmdCmdDataListRegisterValues::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdDataListRegisterValues::CreateSelf(void) +CMICmdCmdDataListRegisterValues::CreateSelf() { return new CMICmdCmdDataListRegisterValues(); } @@ -1240,7 +1165,7 @@ CMICmdCmdDataListRegisterValues::GetRegister(const MIuint vRegisterIndex) const // Return: None // Throws: None. //-- -bool +void CMICmdCmdDataListRegisterValues::AddToOutput(const MIuint vnIndex, const lldb::SBValue &vrValue, CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat) { @@ -1250,8 +1175,8 @@ CMICmdCmdDataListRegisterValues::AddToOutput(const MIuint vnIndex, const lldb::S const CMIUtilString strRegValue(CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(vrValue, veVarFormat)); const CMICmnMIValueConst miValueConst2(strRegValue); const CMICmnMIValueResult miValueResult2("value", miValueConst2); - bool bOk = miValueTuple.Add(miValueResult2); - return bOk && m_miValueList.Add(miValueTuple); + miValueTuple.Add(miValueResult2); + m_miValueList.Add(miValueTuple); } //--------------------------------------------------------------------------------------- @@ -1265,7 +1190,7 @@ CMICmdCmdDataListRegisterValues::AddToOutput(const MIuint vnIndex, const lldb::S // Return: None. // Throws: None. //-- -CMICmdCmdDataListRegisterChanged::CMICmdCmdDataListRegisterChanged(void) +CMICmdCmdDataListRegisterChanged::CMICmdCmdDataListRegisterChanged() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "data-list-changed-registers"; @@ -1281,7 +1206,7 @@ CMICmdCmdDataListRegisterChanged::CMICmdCmdDataListRegisterChanged(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataListRegisterChanged::~CMICmdCmdDataListRegisterChanged(void) +CMICmdCmdDataListRegisterChanged::~CMICmdCmdDataListRegisterChanged() { } @@ -1295,7 +1220,7 @@ CMICmdCmdDataListRegisterChanged::~CMICmdCmdDataListRegisterChanged(void) // Throws: None. //-- bool -CMICmdCmdDataListRegisterChanged::Execute(void) +CMICmdCmdDataListRegisterChanged::Execute() { // Do nothing @@ -1312,7 +1237,7 @@ CMICmdCmdDataListRegisterChanged::Execute(void) // Throws: None. //-- bool -CMICmdCmdDataListRegisterChanged::Acknowledge(void) +CMICmdCmdDataListRegisterChanged::Acknowledge() { const CMICmnMIValueConst miValueConst(MIRSRC(IDS_WORD_NOT_IMPLEMENTED)); const CMICmnMIValueResult miValueResult("msg", miValueConst); @@ -1331,7 +1256,7 @@ CMICmdCmdDataListRegisterChanged::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdDataListRegisterChanged::CreateSelf(void) +CMICmdCmdDataListRegisterChanged::CreateSelf() { return new CMICmdCmdDataListRegisterChanged(); } @@ -1347,9 +1272,8 @@ CMICmdCmdDataListRegisterChanged::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataWriteMemoryBytes::CMICmdCmdDataWriteMemoryBytes(void) - : m_constStrArgThread("thread") - , m_constStrArgAddr("address") +CMICmdCmdDataWriteMemoryBytes::CMICmdCmdDataWriteMemoryBytes() + : m_constStrArgAddr("address") , m_constStrArgContents("contents") , m_constStrArgCount("count") { @@ -1367,7 +1291,7 @@ CMICmdCmdDataWriteMemoryBytes::CMICmdCmdDataWriteMemoryBytes(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataWriteMemoryBytes::~CMICmdCmdDataWriteMemoryBytes(void) +CMICmdCmdDataWriteMemoryBytes::~CMICmdCmdDataWriteMemoryBytes() { } @@ -1381,14 +1305,12 @@ CMICmdCmdDataWriteMemoryBytes::~CMICmdCmdDataWriteMemoryBytes(void) // Throws: None. //-- bool -CMICmdCmdDataWriteMemoryBytes::ParseArgs(void) +CMICmdCmdDataWriteMemoryBytes::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgAddr, true, true, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgContents, true, true, true, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgCount, false, true, false, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgAddr, true, true, false, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgContents, true, true, true, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgCount, false, true, false, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -1401,7 +1323,7 @@ CMICmdCmdDataWriteMemoryBytes::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdDataWriteMemoryBytes::Execute(void) +CMICmdCmdDataWriteMemoryBytes::Execute() { // Do nothing - not reproduceable (yet) in Eclipse // CMICMDBASE_GETOPTION( pArgOffset, OptionShort, m_constStrArgOffset ); @@ -1425,7 +1347,7 @@ CMICmdCmdDataWriteMemoryBytes::Execute(void) // Throws: None. //-- bool -CMICmdCmdDataWriteMemoryBytes::Acknowledge(void) +CMICmdCmdDataWriteMemoryBytes::Acknowledge() { const CMICmnMIValueConst miValueConst(MIRSRC(IDS_WORD_NOT_IMPLEMENTED)); const CMICmnMIValueResult miValueResult("msg", miValueConst); @@ -1444,7 +1366,7 @@ CMICmdCmdDataWriteMemoryBytes::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdDataWriteMemoryBytes::CreateSelf(void) +CMICmdCmdDataWriteMemoryBytes::CreateSelf() { return new CMICmdCmdDataWriteMemoryBytes(); } @@ -1460,9 +1382,8 @@ CMICmdCmdDataWriteMemoryBytes::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataWriteMemory::CMICmdCmdDataWriteMemory(void) - : m_constStrArgThread("thread") - , m_constStrArgOffset("o") +CMICmdCmdDataWriteMemory::CMICmdCmdDataWriteMemory() + : m_constStrArgOffset("o") , m_constStrArgAddr("address") , m_constStrArgD("d") , m_constStrArgNumber("a number") @@ -1485,7 +1406,7 @@ CMICmdCmdDataWriteMemory::CMICmdCmdDataWriteMemory(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataWriteMemory::~CMICmdCmdDataWriteMemory(void) +CMICmdCmdDataWriteMemory::~CMICmdCmdDataWriteMemory() { if (m_pBufferMemory != nullptr) { @@ -1504,17 +1425,14 @@ CMICmdCmdDataWriteMemory::~CMICmdCmdDataWriteMemory(void) // Throws: None. //-- bool -CMICmdCmdDataWriteMemory::ParseArgs(void) +CMICmdCmdDataWriteMemory::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && - m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgAddr, true, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgD, true, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumber, true, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgContents, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1)); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgAddr, true, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgD, true, true)); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, true, true)); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgContents, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -1527,7 +1445,7 @@ CMICmdCmdDataWriteMemory::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdDataWriteMemory::Execute(void) +CMICmdCmdDataWriteMemory::Execute() { CMICMDBASE_GETOPTION(pArgOffset, OptionShort, m_constStrArgOffset); CMICMDBASE_GETOPTION(pArgAddr, Number, m_constStrArgAddr); @@ -1585,7 +1503,7 @@ CMICmdCmdDataWriteMemory::Execute(void) // Throws: None. //-- bool -CMICmdCmdDataWriteMemory::Acknowledge(void) +CMICmdCmdDataWriteMemory::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -1602,7 +1520,7 @@ CMICmdCmdDataWriteMemory::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdDataWriteMemory::CreateSelf(void) +CMICmdCmdDataWriteMemory::CreateSelf() { return new CMICmdCmdDataWriteMemory(); } @@ -1618,7 +1536,7 @@ CMICmdCmdDataWriteMemory::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataInfoLine::CMICmdCmdDataInfoLine(void) +CMICmdCmdDataInfoLine::CMICmdCmdDataInfoLine() : m_constStrArgLocation("location") { // Command factory matches this name with that received from the stdin stream @@ -1635,7 +1553,7 @@ CMICmdCmdDataInfoLine::CMICmdCmdDataInfoLine(void) // Return: None. // Throws: None. //-- -CMICmdCmdDataInfoLine::~CMICmdCmdDataInfoLine(void) +CMICmdCmdDataInfoLine::~CMICmdCmdDataInfoLine() { } @@ -1649,10 +1567,10 @@ CMICmdCmdDataInfoLine::~CMICmdCmdDataInfoLine(void) // Throws: None. //-- bool -CMICmdCmdDataInfoLine::ParseArgs(void) +CMICmdCmdDataInfoLine::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgLocation, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgLocation, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -1665,7 +1583,7 @@ CMICmdCmdDataInfoLine::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdDataInfoLine::Execute(void) +CMICmdCmdDataInfoLine::Execute() { CMICMDBASE_GETOPTION(pArgLocation, String, m_constStrArgLocation); @@ -1676,7 +1594,7 @@ CMICmdCmdDataInfoLine::Execute(void) // Parse argument: // *0x12345 // ^^^^^^^ -- address - const CMIUtilString strAddress(strLocation.c_str() + 1); + const CMIUtilString strAddress(strLocation.substr(1)); strCmdOptionsLocation = CMIUtilString::Format("--address %s", strAddress.c_str()); } else @@ -1692,8 +1610,8 @@ CMICmdCmdDataInfoLine::Execute(void) // hello.cpp:5 // ^^^^^^^^^ -- file // ^ -- line - const CMIUtilString strFile(strLocation.substr(0, nLineStartPos).c_str()); - const CMIUtilString strLine(strLocation.substr(nLineStartPos + 1).c_str()); + const CMIUtilString strFile(strLocation.substr(0, nLineStartPos)); + const CMIUtilString strLine(strLocation.substr(nLineStartPos + 1)); strCmdOptionsLocation = CMIUtilString::Format("--file \"%s\" --line %s", strFile.AddSlashes().c_str(), strLine.c_str()); } const CMIUtilString strCmd(CMIUtilString::Format("target modules lookup -v %s", strCmdOptionsLocation.c_str())); @@ -1706,6 +1624,53 @@ CMICmdCmdDataInfoLine::Execute(void) } //++ ------------------------------------------------------------------------------------ +// Details: Helper function for parsing a line entry returned from lldb for the command: +// target modules lookup -v <location> +// where the line entry is of the format: +// LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/file:3[:1] +// start end file line column(opt) +// Args: input - (R) Input string to parse. +// start - (W) String representing the start address. +// end - (W) String representing the end address. +// file - (W) String representing the file. +// line - (W) String representing the line. +// Return: bool - True = input was parsed successfully, false = input could not be parsed. +// Throws: None. +//-- +static bool +ParseLLDBLineEntry(const char *input, CMIUtilString &start, CMIUtilString &end, + CMIUtilString &file, CMIUtilString &line) +{ + // Note: Ambiguities arise because the column is optional, and + // because : can appear in filenames or as a byte in a multibyte + // UTF8 character. We keep those cases to a minimum by using regex + // to work on the string from both the left and right, so that what + // is remains is assumed to be the filename. + + // Match LineEntry using regex. + static MIUtilParse::CRegexParser g_lineentry_nocol_regex( + "^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+)$"); + static MIUtilParse::CRegexParser g_lineentry_col_regex( + "^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+):[0-9]+$"); + // ^1=start ^2=end ^3=f ^4=line ^5=:col(opt) + + MIUtilParse::CRegexParser::Match match(6); + + // First try matching the LineEntry with the column, + // then try without the column. + const bool ok = g_lineentry_col_regex.Execute(input, match) || + g_lineentry_nocol_regex.Execute(input, match); + if (ok) + { + start = match.GetMatchAtIndex(1); + end = match.GetMatchAtIndex(2); + file = match.GetMatchAtIndex(3); + line = match.GetMatchAtIndex(4); + } + return ok; +} + +//++ ------------------------------------------------------------------------------------ // Details: The invoker requires this function. The command prepares a MI Record Result // for the work carried out in the Execute(). // Type: Overridden. @@ -1715,7 +1680,7 @@ CMICmdCmdDataInfoLine::Execute(void) // Throws: None. //-- bool -CMICmdCmdDataInfoLine::Acknowledge(void) +CMICmdCmdDataInfoLine::Acknowledge() { if (m_lldbResult.GetErrorSize() > 0) { @@ -1736,67 +1701,28 @@ CMICmdCmdDataInfoLine::Acknowledge(void) // String looks like: // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1] const CMIUtilString &rLine(vecLines[i]); + CMIUtilString strStart; + CMIUtilString strEnd; + CMIUtilString strFile; + CMIUtilString strLine; - // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1] - // ^^^^^^^^^ -- property - const size_t nPropertyStartPos = rLine.find_first_not_of(' '); - const size_t nPropertyEndPos = rLine.find(':'); - const size_t nPropertyLen = nPropertyEndPos - nPropertyStartPos; - const CMIUtilString strProperty(rLine.substr(nPropertyStartPos, nPropertyLen).c_str()); - - // Skip all except LineEntry - if (!CMIUtilString::Compare(strProperty, "LineEntry")) + if (!ParseLLDBLineEntry(rLine.c_str(), strStart, strEnd, strFile, strLine)) continue; - // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1] - // ^^^^^^^^^^^^^^^^^^ -- start address - const size_t nStartAddressStartPos = rLine.find('['); - const size_t nStartAddressEndPos = rLine.find('-'); - const size_t nStartAddressLen = nStartAddressEndPos - nStartAddressStartPos - 1; - const CMIUtilString strStartAddress(rLine.substr(nStartAddressStartPos + 1, nStartAddressLen).c_str()); - const CMICmnMIValueConst miValueConst(strStartAddress); + const CMICmnMIValueConst miValueConst(strStart); const CMICmnMIValueResult miValueResult("start", miValueConst); - CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult); - - // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1] - // ^^^^^^^^^^^^^^^^^^ -- end address - const size_t nEndAddressEndPos = rLine.find(')'); - const size_t nEndAddressLen = nEndAddressEndPos - nStartAddressEndPos - 1; - const CMIUtilString strEndAddress(rLine.substr(nStartAddressEndPos + 1, nEndAddressLen).c_str()); - const CMICmnMIValueConst miValueConst2(strEndAddress); + CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, + CMICmnMIResultRecord::eResultClass_Done, + miValueResult); + const CMICmnMIValueConst miValueConst2(strEnd); const CMICmnMIValueResult miValueResult2("end", miValueConst2); - bool bOk = miRecordResult.Add(miValueResult2); - if (!bOk) - return MIstatus::failure; - - // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1] - // ^^^^^^^^^^^^^ -- file - // ^ -- line - // ^ -- column (optional) - const size_t nFileStartPos = rLine.find_first_not_of(' ', nEndAddressEndPos + 2); - const size_t nFileOrLineEndPos = rLine.rfind(':'); - const size_t nFileOrLineStartPos = rLine.rfind(':', nFileOrLineEndPos - 1); - const size_t nFileEndPos = nFileStartPos < nFileOrLineStartPos ? nFileOrLineStartPos : nFileOrLineEndPos; - const size_t nFileLen = nFileEndPos - nFileStartPos; - const CMIUtilString strFile(rLine.substr(nFileStartPos, nFileLen).c_str()); + miRecordResult.Add(miValueResult2); const CMICmnMIValueConst miValueConst3(strFile); const CMICmnMIValueResult miValueResult3("file", miValueConst3); - bOk = miRecordResult.Add(miValueResult3); - if (!bOk) - return MIstatus::failure; - - // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1] - // ^ -- line - const size_t nLineStartPos = nFileEndPos + 1; - const size_t nLineEndPos = rLine.find(':', nLineStartPos); - const size_t nLineLen = nLineEndPos != std::string::npos ? nLineEndPos - nLineStartPos - : std::string::npos; - const CMIUtilString strLine(rLine.substr(nLineStartPos, nLineLen).c_str()); + miRecordResult.Add(miValueResult3); const CMICmnMIValueConst miValueConst4(strLine); const CMICmnMIValueResult miValueResult4("line", miValueConst4); - bOk = miRecordResult.Add(miValueResult4); - if (!bOk) - return MIstatus::failure; + miRecordResult.Add(miValueResult4); // MI print "%s^done,start=\"%d\",end=\"%d\"",file=\"%s\",line=\"%d\" m_miResultRecord = miRecordResult; @@ -1823,7 +1749,7 @@ CMICmdCmdDataInfoLine::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdDataInfoLine::CreateSelf(void) +CMICmdCmdDataInfoLine::CreateSelf() { return new CMICmdCmdDataInfoLine(); } diff --git a/tools/lldb-mi/MICmdCmdData.h b/tools/lldb-mi/MICmdCmdData.h index 576441024a37..028c71387f31 100644 --- a/tools/lldb-mi/MICmdCmdData.h +++ b/tools/lldb-mi/MICmdCmdData.h @@ -42,29 +42,26 @@ //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "data-evaluate-expression". -// Gotchas: None. -// Authors: Illya Rudkin 26/03/2014. -// Changes: None. //-- class CMICmdCmdDataEvaluateExpression : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdDataEvaluateExpression(void); + /* ctor */ CMICmdCmdDataEvaluateExpression(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdDataEvaluateExpression(void) override; + /* dtor */ ~CMICmdCmdDataEvaluateExpression() override; // Methods: private: @@ -76,47 +73,39 @@ class CMICmdCmdDataEvaluateExpression : public CMICmdBase bool m_bEvaluatedExpression; // True = yes is expression evaluated, false = failed CMIUtilString m_strValue; CMICmnMIValueTuple m_miValueTuple; - bool m_bCompositeVarType; // True = yes composite type, false = internal type bool m_bFoundInvalidChar; // True = yes found unexpected character in the expression, false = all ok char m_cExpressionInvalidChar; - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option. Not handled by command. - const CMIUtilString m_constStrArgFrame; // Not specified in MI spec but Eclipse gives this option. Not handled by command. const CMIUtilString m_constStrArgExpr; }; //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "data-disassemble". -// Gotchas: None. -// Authors: Illya Rudkin 19/05/2014. -// Changes: None. //-- class CMICmdCmdDataDisassemble : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdDataDisassemble(void); + /* ctor */ CMICmdCmdDataDisassemble(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdDataDisassemble(void) override; + /* dtor */ ~CMICmdCmdDataDisassemble() override; // Attributes: private: - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option. Not handled by command. const CMIUtilString m_constStrArgAddrStart; // MI spec non mandatory, *this command mandatory const CMIUtilString m_constStrArgAddrEnd; // MI spec non mandatory, *this command mandatory - const CMIUtilString m_constStrArgConsume; const CMIUtilString m_constStrArgMode; CMICmnMIValueList m_miValueList; }; @@ -124,34 +113,29 @@ class CMICmdCmdDataDisassemble : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "data-read-memory-bytes". -// Gotchas: None. -// Authors: Illya Rudkin 20/05/2014. -// Changes: None. //-- class CMICmdCmdDataReadMemoryBytes : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdDataReadMemoryBytes(void); + /* ctor */ CMICmdCmdDataReadMemoryBytes(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdDataReadMemoryBytes(void) override; + /* dtor */ ~CMICmdCmdDataReadMemoryBytes() override; // Attributes: private: - const CMIUtilString m_constStrArgThread; // Not in the MI spec but implemented by GDB. - const CMIUtilString m_constStrArgFrame; // Not in the MI spec but implemented by GDB. const CMIUtilString m_constStrArgByteOffset; const CMIUtilString m_constStrArgAddrExpr; const CMIUtilString m_constStrArgNumBytes; @@ -163,56 +147,50 @@ class CMICmdCmdDataReadMemoryBytes : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "data-read-memory". -// Gotchas: None. -// Authors: Illya Rudkin 21/05/2014. -// Changes: None. //-- class CMICmdCmdDataReadMemory : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdDataReadMemory(void); + /* ctor */ CMICmdCmdDataReadMemory(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdDataReadMemory(void) override; + /* dtor */ ~CMICmdCmdDataReadMemory() override; }; //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "data-list-register-names". -// Gotchas: None. -// Authors: Illya Rudkin 21/05/2014. -// Changes: None. //-- class CMICmdCmdDataListRegisterNames : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdDataListRegisterNames(void); + /* ctor */ CMICmdCmdDataListRegisterNames(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdDataListRegisterNames(void) override; + /* dtor */ ~CMICmdCmdDataListRegisterNames() override; // Methods: private: @@ -220,7 +198,6 @@ class CMICmdCmdDataListRegisterNames : public CMICmdBase // Attributes: private: - const CMIUtilString m_constStrArgThreadGroup; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgRegNo; // Not handled by *this command CMICmnMIValueList m_miValueList; }; @@ -228,38 +205,34 @@ class CMICmdCmdDataListRegisterNames : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "data-list-register-values". -// Gotchas: None. -// Authors: Illya Rudkin 21/05/2014. -// Changes: None. //-- class CMICmdCmdDataListRegisterValues : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdDataListRegisterValues(void); + /* ctor */ CMICmdCmdDataListRegisterValues(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdDataListRegisterValues(void) override; + /* dtor */ ~CMICmdCmdDataListRegisterValues() override; // Methods: private: lldb::SBValue GetRegister(const MIuint vRegisterIndex) const; - bool AddToOutput(const MIuint vnIndex, const lldb::SBValue &vrValue, CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat); + void AddToOutput(const MIuint vnIndex, const lldb::SBValue &vrValue, CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat); // Attributes: private: - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgSkip; // Not handled by *this command const CMIUtilString m_constStrArgFormat; const CMIUtilString m_constStrArgRegNo; @@ -269,60 +242,53 @@ class CMICmdCmdDataListRegisterValues : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "data-list-changed-registers". -// Gotchas: None. -// Authors: Illya Rudkin 22/05/2014. -// Changes: None. //-- class CMICmdCmdDataListRegisterChanged : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdDataListRegisterChanged(void); + /* ctor */ CMICmdCmdDataListRegisterChanged(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdDataListRegisterChanged(void) override; + /* dtor */ ~CMICmdCmdDataListRegisterChanged() override; }; //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "data-read-memory-bytes". -// Gotchas: None. -// Authors: Illya Rudkin 30/05/2014. -// Changes: None. //-- class CMICmdCmdDataWriteMemoryBytes : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdDataWriteMemoryBytes(void); + /* ctor */ CMICmdCmdDataWriteMemoryBytes(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdDataWriteMemoryBytes(void) override; + /* dtor */ ~CMICmdCmdDataWriteMemoryBytes() override; // Attributes: private: - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option. Not handled by command. const CMIUtilString m_constStrArgAddr; const CMIUtilString m_constStrArgContents; const CMIUtilString m_constStrArgCount; @@ -333,33 +299,29 @@ class CMICmdCmdDataWriteMemoryBytes : public CMICmdBase // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "data-read-memory". // Not specified in MI spec but Eclipse gives *this command. -// Gotchas: None. -// Authors: Illya Rudkin 02/05/2014. -// Changes: None. //-- class CMICmdCmdDataWriteMemory : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdDataWriteMemory(void); + /* ctor */ CMICmdCmdDataWriteMemory(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdDataWriteMemory(void) override; + /* dtor */ ~CMICmdCmdDataWriteMemory() override; // Attributes: private: - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option. Not handled by command. const CMIUtilString m_constStrArgOffset; // Not specified in MI spec but Eclipse gives this option. const CMIUtilString m_constStrArgAddr; // Not specified in MI spec but Eclipse gives this option. const CMIUtilString m_constStrArgD; // Not specified in MI spec but Eclipse gives this option. @@ -381,20 +343,20 @@ class CMICmdCmdDataInfoLine : public CMICmdBase // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdDataInfoLine(void); + /* ctor */ CMICmdCmdDataInfoLine(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdDataInfoLine(void) override; + /* dtor */ ~CMICmdCmdDataInfoLine() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmdCmdEnviro.cpp b/tools/lldb-mi/MICmdCmdEnviro.cpp index dd167841032a..adacc2a5780b 100644 --- a/tools/lldb-mi/MICmdCmdEnviro.cpp +++ b/tools/lldb-mi/MICmdCmdEnviro.cpp @@ -24,7 +24,7 @@ // Return: None. // Throws: None. //-- -CMICmdCmdEnvironmentCd::CMICmdCmdEnvironmentCd(void) +CMICmdCmdEnvironmentCd::CMICmdCmdEnvironmentCd() : m_constStrArgNamePathDir("pathdir") { // Command factory matches this name with that received from the stdin stream @@ -41,7 +41,7 @@ CMICmdCmdEnvironmentCd::CMICmdCmdEnvironmentCd(void) // Return: None. // Throws: None. //-- -CMICmdCmdEnvironmentCd::~CMICmdCmdEnvironmentCd(void) +CMICmdCmdEnvironmentCd::~CMICmdCmdEnvironmentCd() { } @@ -55,11 +55,11 @@ CMICmdCmdEnvironmentCd::~CMICmdCmdEnvironmentCd(void) // Throws: None. //-- bool -CMICmdCmdEnvironmentCd::ParseArgs(void) +CMICmdCmdEnvironmentCd::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValFile(m_constStrArgNamePathDir, true, true))); + m_setCmdArgs.Add(new CMICmdArgValFile(m_constStrArgNamePathDir, true, true)); CMICmdArgContext argCntxt(m_cmdData.strMiCmdOption); - return (bOk && ParseValidateCmdOptions()); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -72,7 +72,7 @@ CMICmdCmdEnvironmentCd::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdEnvironmentCd::Execute(void) +CMICmdCmdEnvironmentCd::Execute() { CMICMDBASE_GETOPTION(pArgPathDir, File, m_constStrArgNamePathDir); const CMIUtilString &strWkDir(pArgPathDir->GetValue()); @@ -104,7 +104,7 @@ CMICmdCmdEnvironmentCd::Execute(void) // Throws: None. //-- bool -CMICmdCmdEnvironmentCd::Acknowledge(void) +CMICmdCmdEnvironmentCd::Acknowledge() { const CMIUtilString &rStrKeyWkDir(m_rLLDBDebugSessionInfo.m_constStrSharedDataKeyWkDir); CMIUtilString strWkDir; @@ -131,7 +131,7 @@ CMICmdCmdEnvironmentCd::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdEnvironmentCd::CreateSelf(void) +CMICmdCmdEnvironmentCd::CreateSelf() { return new CMICmdCmdEnvironmentCd(); } diff --git a/tools/lldb-mi/MICmdCmdEnviro.h b/tools/lldb-mi/MICmdCmdEnviro.h index 7d5cf98dd4bc..6f06cb69c7ec 100644 --- a/tools/lldb-mi/MICmdCmdEnviro.h +++ b/tools/lldb-mi/MICmdCmdEnviro.h @@ -28,29 +28,26 @@ //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "environment-cd". -// Gotchas: None. -// Authors: Illya Rudkin 03/03/2014. -// Changes: None. //-- class CMICmdCmdEnvironmentCd : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdEnvironmentCd(void); + /* ctor */ CMICmdCmdEnvironmentCd(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdEnvironmentCd(void) override; + /* dtor */ ~CMICmdCmdEnvironmentCd() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmdCmdExec.cpp b/tools/lldb-mi/MICmdCmdExec.cpp index f0208c83d58d..dccfe129b2c0 100644 --- a/tools/lldb-mi/MICmdCmdExec.cpp +++ b/tools/lldb-mi/MICmdCmdExec.cpp @@ -47,7 +47,8 @@ // Return: None. // Throws: None. //-- -CMICmdCmdExecRun::CMICmdCmdExecRun(void) +CMICmdCmdExecRun::CMICmdCmdExecRun() + : m_constStrArgStart("start") { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "exec-run"; @@ -63,11 +64,28 @@ CMICmdCmdExecRun::CMICmdCmdExecRun(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecRun::~CMICmdCmdExecRun(void) +CMICmdCmdExecRun::~CMICmdCmdExecRun() { } //++ ------------------------------------------------------------------------------------ +// Details: The invoker requires this function. It 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 +CMICmdCmdExecRun::ParseArgs() +{ + m_setCmdArgs.Add( + new CMICmdArgValOptionLong(m_constStrArgStart, false, true, CMICmdArgValListBase::eArgValType_OptionLong, 0)); + return 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. @@ -77,13 +95,21 @@ CMICmdCmdExecRun::~CMICmdCmdExecRun(void) // Throws: None. //-- bool -CMICmdCmdExecRun::Execute(void) +CMICmdCmdExecRun::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); lldb::SBError error; lldb::SBStream errMsg; lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo(); launchInfo.SetListener(rSessionInfo.GetListener()); + + // Run to first instruction or main() requested? + CMICMDBASE_GETOPTION(pArgStart, OptionLong, m_constStrArgStart); + if (pArgStart->GetFound()) + { + launchInfo.SetLaunchFlags(launchInfo.GetLaunchFlags() | lldb::eLaunchFlagStopAtEntry); + } + lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error); if ((!process.IsValid()) || (error.Fail())) { @@ -103,6 +129,7 @@ CMICmdCmdExecRun::Execute(void) //++ ------------------------------------------------------------------------------------ // Details: The invoker requires this function. The command prepares a MI Record Result // for the work carried out in the Execute(). +// Called only if Execute() set status as successful on completion. // Type: Overridden. // Args: None. // Return: MIstatus::success - Functional succeeded. @@ -110,33 +137,23 @@ CMICmdCmdExecRun::Execute(void) // Throws: None. //-- bool -CMICmdCmdExecRun::Acknowledge(void) +CMICmdCmdExecRun::Acknowledge() { - if (m_lldbResult.GetErrorSize() > 0) - { - const CMICmnMIValueConst miValueConst(m_lldbResult.GetError()); - const CMICmnMIValueResult miValueResult("message", miValueConst); - const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult); - m_miResultRecord = miRecordResult; - } - else - { - const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); - m_miResultRecord = miRecordResult; + const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); + m_miResultRecord = miRecordResult; - CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); - lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID(); - // Give the client '=thread-group-started,id="i1" pid="xyz"' - m_bHasResultRecordExtra = true; - const CMICmnMIValueConst miValueConst2("i1"); - const CMICmnMIValueResult miValueResult2("id", miValueConst2); - const CMIUtilString strPid(CMIUtilString::Format("%lld", pid)); - const CMICmnMIValueConst miValueConst(strPid); - const CMICmnMIValueResult miValueResult("pid", miValueConst); - CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, miValueResult2); - miOutOfBand.Add(miValueResult); - m_miResultRecordExtra = miOutOfBand.GetString(); - } + CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); + lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID(); + // Give the client '=thread-group-started,id="i1" pid="xyz"' + m_bHasResultRecordExtra = true; + const CMICmnMIValueConst miValueConst2("i1"); + const CMICmnMIValueResult miValueResult2("id", miValueConst2); + const CMIUtilString strPid(CMIUtilString::Format("%lld", pid)); + const CMICmnMIValueConst miValueConst(strPid); + const CMICmnMIValueResult miValueResult("pid", miValueConst); + CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, miValueResult2); + miOutOfBand.Add(miValueResult); + m_miResultRecordExtra = miOutOfBand.GetString(); return MIstatus::success; } @@ -150,7 +167,7 @@ CMICmdCmdExecRun::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdExecRun::CreateSelf(void) +CMICmdCmdExecRun::CreateSelf() { return new CMICmdCmdExecRun(); } @@ -166,7 +183,7 @@ CMICmdCmdExecRun::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecContinue::CMICmdCmdExecContinue(void) +CMICmdCmdExecContinue::CMICmdCmdExecContinue() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "exec-continue"; @@ -182,7 +199,7 @@ CMICmdCmdExecContinue::CMICmdCmdExecContinue(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecContinue::~CMICmdCmdExecContinue(void) +CMICmdCmdExecContinue::~CMICmdCmdExecContinue() { } @@ -196,7 +213,7 @@ CMICmdCmdExecContinue::~CMICmdCmdExecContinue(void) // Throws: None. //-- bool -CMICmdCmdExecContinue::Execute(void) +CMICmdCmdExecContinue::Execute() { const char *pCmd = "continue"; CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); @@ -238,7 +255,7 @@ CMICmdCmdExecContinue::Execute(void) // Throws: None. //-- bool -CMICmdCmdExecContinue::Acknowledge(void) +CMICmdCmdExecContinue::Acknowledge() { if (m_lldbResult.GetErrorSize() > 0) { @@ -265,7 +282,7 @@ CMICmdCmdExecContinue::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdExecContinue::CreateSelf(void) +CMICmdCmdExecContinue::CreateSelf() { return new CMICmdCmdExecContinue(); } @@ -281,9 +298,8 @@ CMICmdCmdExecContinue::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecNext::CMICmdCmdExecNext(void) - : m_constStrArgThread("thread") - , m_constStrArgNumber("number") +CMICmdCmdExecNext::CMICmdCmdExecNext() + : m_constStrArgNumber("number") { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "exec-next"; @@ -299,7 +315,7 @@ CMICmdCmdExecNext::CMICmdCmdExecNext(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecNext::~CMICmdCmdExecNext(void) +CMICmdCmdExecNext::~CMICmdCmdExecNext() { } @@ -313,12 +329,10 @@ CMICmdCmdExecNext::~CMICmdCmdExecNext(void) // Throws: None. //-- bool -CMICmdCmdExecNext::ParseArgs(void) +CMICmdCmdExecNext::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumber, false, false))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -331,7 +345,7 @@ CMICmdCmdExecNext::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdExecNext::Execute(void) +CMICmdCmdExecNext::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); @@ -363,7 +377,7 @@ CMICmdCmdExecNext::Execute(void) // Throws: None. //-- bool -CMICmdCmdExecNext::Acknowledge(void) +CMICmdCmdExecNext::Acknowledge() { if (m_lldbResult.GetErrorSize() > 0) { @@ -392,7 +406,7 @@ CMICmdCmdExecNext::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdExecNext::CreateSelf(void) +CMICmdCmdExecNext::CreateSelf() { return new CMICmdCmdExecNext(); } @@ -408,9 +422,8 @@ CMICmdCmdExecNext::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecStep::CMICmdCmdExecStep(void) - : m_constStrArgThread("thread") - , m_constStrArgNumber("number") +CMICmdCmdExecStep::CMICmdCmdExecStep() + : m_constStrArgNumber("number") { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "exec-step"; @@ -426,7 +439,7 @@ CMICmdCmdExecStep::CMICmdCmdExecStep(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecStep::~CMICmdCmdExecStep(void) +CMICmdCmdExecStep::~CMICmdCmdExecStep() { } @@ -440,12 +453,10 @@ CMICmdCmdExecStep::~CMICmdCmdExecStep(void) // Throws: None. //-- bool -CMICmdCmdExecStep::ParseArgs(void) +CMICmdCmdExecStep::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumber, false, false))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -458,7 +469,7 @@ CMICmdCmdExecStep::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdExecStep::Execute(void) +CMICmdCmdExecStep::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); @@ -490,7 +501,7 @@ CMICmdCmdExecStep::Execute(void) // Throws: None. //-- bool -CMICmdCmdExecStep::Acknowledge(void) +CMICmdCmdExecStep::Acknowledge() { if (m_lldbResult.GetErrorSize() > 0) { @@ -519,7 +530,7 @@ CMICmdCmdExecStep::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdExecStep::CreateSelf(void) +CMICmdCmdExecStep::CreateSelf() { return new CMICmdCmdExecStep(); } @@ -535,9 +546,8 @@ CMICmdCmdExecStep::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecNextInstruction::CMICmdCmdExecNextInstruction(void) - : m_constStrArgThread("thread") - , m_constStrArgNumber("number") +CMICmdCmdExecNextInstruction::CMICmdCmdExecNextInstruction() + : m_constStrArgNumber("number") { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "exec-next-instruction"; @@ -553,7 +563,7 @@ CMICmdCmdExecNextInstruction::CMICmdCmdExecNextInstruction(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecNextInstruction::~CMICmdCmdExecNextInstruction(void) +CMICmdCmdExecNextInstruction::~CMICmdCmdExecNextInstruction() { } @@ -567,12 +577,10 @@ CMICmdCmdExecNextInstruction::~CMICmdCmdExecNextInstruction(void) // Throws: None. //-- bool -CMICmdCmdExecNextInstruction::ParseArgs(void) +CMICmdCmdExecNextInstruction::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumber, false, false))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -585,7 +593,7 @@ CMICmdCmdExecNextInstruction::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdExecNextInstruction::Execute(void) +CMICmdCmdExecNextInstruction::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); @@ -617,7 +625,7 @@ CMICmdCmdExecNextInstruction::Execute(void) // Throws: None. //-- bool -CMICmdCmdExecNextInstruction::Acknowledge(void) +CMICmdCmdExecNextInstruction::Acknowledge() { if (m_lldbResult.GetErrorSize() > 0) { @@ -646,7 +654,7 @@ CMICmdCmdExecNextInstruction::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdExecNextInstruction::CreateSelf(void) +CMICmdCmdExecNextInstruction::CreateSelf() { return new CMICmdCmdExecNextInstruction(); } @@ -662,9 +670,8 @@ CMICmdCmdExecNextInstruction::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecStepInstruction::CMICmdCmdExecStepInstruction(void) - : m_constStrArgThread("thread") - , m_constStrArgNumber("number") +CMICmdCmdExecStepInstruction::CMICmdCmdExecStepInstruction() + : m_constStrArgNumber("number") { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "exec-step-instruction"; @@ -680,7 +687,7 @@ CMICmdCmdExecStepInstruction::CMICmdCmdExecStepInstruction(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecStepInstruction::~CMICmdCmdExecStepInstruction(void) +CMICmdCmdExecStepInstruction::~CMICmdCmdExecStepInstruction() { } @@ -694,12 +701,10 @@ CMICmdCmdExecStepInstruction::~CMICmdCmdExecStepInstruction(void) // Throws: None. //-- bool -CMICmdCmdExecStepInstruction::ParseArgs(void) +CMICmdCmdExecStepInstruction::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNumber, false, false))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -712,7 +717,7 @@ CMICmdCmdExecStepInstruction::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdExecStepInstruction::Execute(void) +CMICmdCmdExecStepInstruction::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); @@ -744,7 +749,7 @@ CMICmdCmdExecStepInstruction::Execute(void) // Throws: None. //-- bool -CMICmdCmdExecStepInstruction::Acknowledge(void) +CMICmdCmdExecStepInstruction::Acknowledge() { if (m_lldbResult.GetErrorSize() > 0) { @@ -773,7 +778,7 @@ CMICmdCmdExecStepInstruction::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdExecStepInstruction::CreateSelf(void) +CMICmdCmdExecStepInstruction::CreateSelf() { return new CMICmdCmdExecStepInstruction(); } @@ -789,9 +794,7 @@ CMICmdCmdExecStepInstruction::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecFinish::CMICmdCmdExecFinish(void) - : m_constStrArgThread("thread") - , m_constStrArgFrame("frame") +CMICmdCmdExecFinish::CMICmdCmdExecFinish() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "exec-finish"; @@ -807,7 +810,7 @@ CMICmdCmdExecFinish::CMICmdCmdExecFinish(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecFinish::~CMICmdCmdExecFinish(void) +CMICmdCmdExecFinish::~CMICmdCmdExecFinish() { } @@ -821,13 +824,9 @@ CMICmdCmdExecFinish::~CMICmdCmdExecFinish(void) // Throws: None. //-- bool -CMICmdCmdExecFinish::ParseArgs(void) +CMICmdCmdExecFinish::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, false, CMICmdArgValListBase::eArgValType_Number, 1))); - return (bOk && ParseValidateCmdOptions()); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -840,7 +839,7 @@ CMICmdCmdExecFinish::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdExecFinish::Execute(void) +CMICmdCmdExecFinish::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); @@ -872,7 +871,7 @@ CMICmdCmdExecFinish::Execute(void) // Throws: None. //-- bool -CMICmdCmdExecFinish::Acknowledge(void) +CMICmdCmdExecFinish::Acknowledge() { if (m_lldbResult.GetErrorSize() > 0) { @@ -901,7 +900,7 @@ CMICmdCmdExecFinish::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdExecFinish::CreateSelf(void) +CMICmdCmdExecFinish::CreateSelf() { return new CMICmdCmdExecFinish(); } @@ -917,7 +916,7 @@ CMICmdCmdExecFinish::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecInterrupt::CMICmdCmdExecInterrupt(void) +CMICmdCmdExecInterrupt::CMICmdCmdExecInterrupt() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "exec-interrupt"; @@ -933,7 +932,7 @@ CMICmdCmdExecInterrupt::CMICmdCmdExecInterrupt(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecInterrupt::~CMICmdCmdExecInterrupt(void) +CMICmdCmdExecInterrupt::~CMICmdCmdExecInterrupt() { } @@ -947,7 +946,7 @@ CMICmdCmdExecInterrupt::~CMICmdCmdExecInterrupt(void) // Throws: None. //-- bool -CMICmdCmdExecInterrupt::Execute(void) +CMICmdCmdExecInterrupt::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); @@ -976,7 +975,7 @@ CMICmdCmdExecInterrupt::Execute(void) // Throws: None. //-- bool -CMICmdCmdExecInterrupt::Acknowledge(void) +CMICmdCmdExecInterrupt::Acknowledge() { if (m_lldbResult.GetErrorSize() > 0) { @@ -1003,7 +1002,7 @@ CMICmdCmdExecInterrupt::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdExecInterrupt::CreateSelf(void) +CMICmdCmdExecInterrupt::CreateSelf() { return new CMICmdCmdExecInterrupt(); } @@ -1019,7 +1018,7 @@ CMICmdCmdExecInterrupt::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecArguments::CMICmdCmdExecArguments(void) +CMICmdCmdExecArguments::CMICmdCmdExecArguments() : m_constStrArgArguments("arguments") { // Command factory matches this name with that received from the stdin stream @@ -1036,7 +1035,7 @@ CMICmdCmdExecArguments::CMICmdCmdExecArguments(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecArguments::~CMICmdCmdExecArguments(void) +CMICmdCmdExecArguments::~CMICmdCmdExecArguments() { } @@ -1050,11 +1049,11 @@ CMICmdCmdExecArguments::~CMICmdCmdExecArguments(void) // Throws: None. //-- bool -CMICmdCmdExecArguments::ParseArgs(void) +CMICmdCmdExecArguments::ParseArgs() { - bool bOk = m_setCmdArgs.Add( - *(new CMICmdArgValListOfN(m_constStrArgArguments, false, true, CMICmdArgValListBase::eArgValType_StringAnything))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add( + new CMICmdArgValListOfN(m_constStrArgArguments, false, true, CMICmdArgValListBase::eArgValType_StringAnything)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -1067,7 +1066,7 @@ CMICmdCmdExecArguments::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdExecArguments::Execute(void) +CMICmdCmdExecArguments::Execute() { CMICMDBASE_GETOPTION(pArgArguments, ListOfN, m_constStrArgArguments); @@ -1106,7 +1105,7 @@ CMICmdCmdExecArguments::Execute(void) // Throws: None. //-- bool -CMICmdCmdExecArguments::Acknowledge(void) +CMICmdCmdExecArguments::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -1123,7 +1122,7 @@ CMICmdCmdExecArguments::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdExecArguments::CreateSelf(void) +CMICmdCmdExecArguments::CreateSelf() { return new CMICmdCmdExecArguments(); } @@ -1139,7 +1138,7 @@ CMICmdCmdExecArguments::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecAbort::CMICmdCmdExecAbort(void) +CMICmdCmdExecAbort::CMICmdCmdExecAbort() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "exec-abort"; @@ -1155,7 +1154,7 @@ CMICmdCmdExecAbort::CMICmdCmdExecAbort(void) // Return: None. // Throws: None. //-- -CMICmdCmdExecAbort::~CMICmdCmdExecAbort(void) +CMICmdCmdExecAbort::~CMICmdCmdExecAbort() { } @@ -1169,7 +1168,7 @@ CMICmdCmdExecAbort::~CMICmdCmdExecAbort(void) // Throws: None. //-- bool -CMICmdCmdExecAbort::Execute(void) +CMICmdCmdExecAbort::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); lldb::SBProcess sbProcess = rSessionInfo.GetProcess(); @@ -1199,7 +1198,7 @@ CMICmdCmdExecAbort::Execute(void) // Throws: None. //-- bool -CMICmdCmdExecAbort::Acknowledge(void) +CMICmdCmdExecAbort::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -1215,7 +1214,7 @@ CMICmdCmdExecAbort::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdExecAbort::CreateSelf(void) +CMICmdCmdExecAbort::CreateSelf() { return new CMICmdCmdExecAbort(); } diff --git a/tools/lldb-mi/MICmdCmdExec.h b/tools/lldb-mi/MICmdCmdExec.h index 94d646fd8325..c131132870bc 100644 --- a/tools/lldb-mi/MICmdCmdExec.h +++ b/tools/lldb-mi/MICmdCmdExec.h @@ -38,59 +38,55 @@ //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "exec-run". -// Gotchas: None. -// Authors: Illya Rudkin 07/03/2014. -// Changes: None. //-- class CMICmdCmdExecRun : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdExecRun(void); + /* ctor */ CMICmdCmdExecRun(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdExecRun(void) override; + /* dtor */ ~CMICmdCmdExecRun() override; // Attributes: private: + const CMIUtilString m_constStrArgStart; // StopAtEntry - run to first instruction or main() if specified lldb::SBCommandReturnObject m_lldbResult; }; //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "exec-continue". -// Gotchas: None. -// Authors: Illya Rudkin 07/03/2014. -// Changes: None. //-- class CMICmdCmdExecContinue : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdExecContinue(void); + /* ctor */ CMICmdCmdExecContinue(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdExecContinue(void) override; + /* dtor */ ~CMICmdCmdExecContinue() override; // Attributes: private: @@ -100,171 +96,150 @@ class CMICmdCmdExecContinue : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "exec-next". -// Gotchas: None. -// Authors: Illya Rudkin 25/03/2014. -// Changes: None. //-- class CMICmdCmdExecNext : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdExecNext(void); + /* ctor */ CMICmdCmdExecNext(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdExecNext(void) override; + /* dtor */ ~CMICmdCmdExecNext() override; // Attributes: private: lldb::SBCommandReturnObject m_lldbResult; - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgNumber; // 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 "exec-step". -// Gotchas: None. -// Authors: Illya Rudkin 25/03/2014. -// Changes: None. //-- class CMICmdCmdExecStep : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdExecStep(void); + /* ctor */ CMICmdCmdExecStep(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdExecStep(void) override; + /* dtor */ ~CMICmdCmdExecStep() override; // Attributes: private: lldb::SBCommandReturnObject m_lldbResult; - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgNumber; // 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 "exec-next-instruction". -// Gotchas: None. -// Authors: Illya Rudkin 25/03/2014. -// Changes: None. //-- class CMICmdCmdExecNextInstruction : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdExecNextInstruction(void); + /* ctor */ CMICmdCmdExecNextInstruction(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdExecNextInstruction(void) override; + /* dtor */ ~CMICmdCmdExecNextInstruction() override; // Attributes: private: lldb::SBCommandReturnObject m_lldbResult; - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgNumber; // 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 "exec-step-instruction". -// Gotchas: None. -// Authors: Illya Rudkin 25/03/2014. -// Changes: None. //-- class CMICmdCmdExecStepInstruction : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdExecStepInstruction(void); + /* ctor */ CMICmdCmdExecStepInstruction(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdExecStepInstruction(void) override; + /* dtor */ ~CMICmdCmdExecStepInstruction() override; // Attributes: private: lldb::SBCommandReturnObject m_lldbResult; - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgNumber; // 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 "exec-finish". -// Gotchas: None. -// Authors: Illya Rudkin 25/03/2014. -// Changes: None. //-- class CMICmdCmdExecFinish : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdExecFinish(void); + /* ctor */ CMICmdCmdExecFinish(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdExecFinish(void) override; + /* dtor */ ~CMICmdCmdExecFinish() override; // Attributes: private: lldb::SBCommandReturnObject m_lldbResult; - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option - const CMIUtilString m_constStrArgFrame; // Not specified in MI spec but Eclipse gives this option }; // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM @@ -273,27 +248,25 @@ class CMICmdCmdExecFinish : public CMICmdBase // *this class implements MI command "exec-interrupt". // Gotchas: Using Eclipse this command is injected into the command system when a // SIGINT signal is received while running an inferior program. -// Authors: Illya Rudkin 03/06/2014. -// Changes: None. //-- class CMICmdCmdExecInterrupt : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdExecInterrupt(void); + /* ctor */ CMICmdCmdExecInterrupt(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdExecInterrupt(void) override; + /* dtor */ ~CMICmdCmdExecInterrupt() override; // Attributes: private: @@ -303,29 +276,26 @@ class CMICmdCmdExecInterrupt : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "exec-arguments". -// Gotchas: None. -// Authors: Ilia Kirianovskii 25/11/2014. -// Changes: None. //-- class CMICmdCmdExecArguments : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdExecArguments(void); + /* ctor */ CMICmdCmdExecArguments(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdExecArguments(void) override; + /* dtor */ ~CMICmdCmdExecArguments() override; // Attributes: private: @@ -341,17 +311,17 @@ class CMICmdCmdExecAbort : public CMICmdBase // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdExecAbort(void); + /* ctor */ CMICmdCmdExecAbort(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdExecAbort(void) override; + /* dtor */ ~CMICmdCmdExecAbort() override; }; diff --git a/tools/lldb-mi/MICmdCmdFile.cpp b/tools/lldb-mi/MICmdCmdFile.cpp index b28060e29f25..3316c8eccaf9 100644 --- a/tools/lldb-mi/MICmdCmdFile.cpp +++ b/tools/lldb-mi/MICmdCmdFile.cpp @@ -30,9 +30,8 @@ // Return: None. // Throws: None. //-- -CMICmdCmdFileExecAndSymbols::CMICmdCmdFileExecAndSymbols(void) +CMICmdCmdFileExecAndSymbols::CMICmdCmdFileExecAndSymbols() : m_constStrArgNameFile("file") - , m_constStrArgThreadGrp("thread-group") , m_constStrArgNamedPlatformName("p") , m_constStrArgNamedRemotePath("r") { @@ -50,7 +49,7 @@ CMICmdCmdFileExecAndSymbols::CMICmdCmdFileExecAndSymbols(void) // Return: None. // Throws: None. //-- -CMICmdCmdFileExecAndSymbols::~CMICmdCmdFileExecAndSymbols(void) +CMICmdCmdFileExecAndSymbols::~CMICmdCmdFileExecAndSymbols() { } @@ -64,18 +63,14 @@ CMICmdCmdFileExecAndSymbols::~CMICmdCmdFileExecAndSymbols(void) // Throws: None. //-- bool -CMICmdCmdFileExecAndSymbols::ParseArgs(void) +CMICmdCmdFileExecAndSymbols::ParseArgs() { - bool bOk = m_setCmdArgs.Add( - *(new CMICmdArgValOptionLong(m_constStrArgThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValFile(m_constStrArgNameFile, true, true))); - bOk = bOk && - m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedPlatformName, false, true, - CMICmdArgValListBase::eArgValType_String, 1))); - bOk = bOk && - m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedRemotePath, false, true, - CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValFile(m_constStrArgNameFile, true, true)); + m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedPlatformName, false, true, + CMICmdArgValListBase::eArgValType_String, 1)); + m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedRemotePath, false, true, + CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -90,7 +85,7 @@ CMICmdCmdFileExecAndSymbols::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdFileExecAndSymbols::Execute(void) +CMICmdCmdFileExecAndSymbols::Execute() { CMICMDBASE_GETOPTION(pArgNamedFile, File, m_constStrArgNameFile); CMICMDBASE_GETOPTION(pArgPlatformName, OptionShort, m_constStrArgNamedPlatformName); @@ -168,7 +163,7 @@ CMICmdCmdFileExecAndSymbols::Execute(void) // Throws: None. //-- bool -CMICmdCmdFileExecAndSymbols::Acknowledge(void) +CMICmdCmdFileExecAndSymbols::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -185,7 +180,7 @@ CMICmdCmdFileExecAndSymbols::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdFileExecAndSymbols::CreateSelf(void) +CMICmdCmdFileExecAndSymbols::CreateSelf() { return new CMICmdCmdFileExecAndSymbols(); } @@ -202,7 +197,7 @@ CMICmdCmdFileExecAndSymbols::CreateSelf(void) // Throws: None. //-- bool -CMICmdCmdFileExecAndSymbols::GetExitAppOnCommandFailure(void) const +CMICmdCmdFileExecAndSymbols::GetExitAppOnCommandFailure() const { return true; } diff --git a/tools/lldb-mi/MICmdCmdFile.h b/tools/lldb-mi/MICmdCmdFile.h index 2c1b59ca47ad..b6bf5e5ccc6c 100644 --- a/tools/lldb-mi/MICmdCmdFile.h +++ b/tools/lldb-mi/MICmdCmdFile.h @@ -31,35 +31,31 @@ // This command does not follow the MI documentation exactly. // Gotchas: This command has additional flags that were not available in GDB MI. // See MIextensions.txt for details. -// Authors: Illya Rudkin 25/02/2014. -// Changes: None. //-- class CMICmdCmdFileExecAndSymbols : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdFileExecAndSymbols(void); + /* ctor */ CMICmdCmdFileExecAndSymbols(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdFileExecAndSymbols(void) override; - bool GetExitAppOnCommandFailure(void) const override; + /* dtor */ ~CMICmdCmdFileExecAndSymbols() override; + bool GetExitAppOnCommandFailure() const override; // Attributes: private: const CMIUtilString m_constStrArgNameFile; - const CMIUtilString - m_constStrArgThreadGrp; // Not handled by *this command. Not specified in MI spec but Eclipse gives this option sometimes const CMIUtilString m_constStrArgNamedPlatformName; // Added to support iOS platform selection const CMIUtilString m_constStrArgNamedRemotePath; // Added to support iOS device remote file location }; diff --git a/tools/lldb-mi/MICmdCmdGdbInfo.cpp b/tools/lldb-mi/MICmdCmdGdbInfo.cpp index 25e0ff4ffbe8..c57c4ac6f02b 100644 --- a/tools/lldb-mi/MICmdCmdGdbInfo.cpp +++ b/tools/lldb-mi/MICmdCmdGdbInfo.cpp @@ -1,4 +1,4 @@ -//===-- MICmdCmdGdbInfo.cpp ------------------------*- C++ -*-===// +//===-- MICmdCmdGdbInfo.cpp -------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -32,7 +32,7 @@ const CMICmdCmdGdbInfo::MapPrintFnNameToPrintFn_t CMICmdCmdGdbInfo::ms_mapPrintF // Return: None. // Throws: None. //-- -CMICmdCmdGdbInfo::CMICmdCmdGdbInfo(void) +CMICmdCmdGdbInfo::CMICmdCmdGdbInfo() : m_constStrArgNamedPrint("print") , m_bPrintFnRecognised(true) , m_bPrintFnSuccessful(false) @@ -52,7 +52,7 @@ CMICmdCmdGdbInfo::CMICmdCmdGdbInfo(void) // Return: None. // Throws: None. //-- -CMICmdCmdGdbInfo::~CMICmdCmdGdbInfo(void) +CMICmdCmdGdbInfo::~CMICmdCmdGdbInfo() { } @@ -66,10 +66,10 @@ CMICmdCmdGdbInfo::~CMICmdCmdGdbInfo(void) // Throws: None. //-- bool -CMICmdCmdGdbInfo::ParseArgs(void) +CMICmdCmdGdbInfo::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedPrint, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedPrint, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -82,7 +82,7 @@ CMICmdCmdGdbInfo::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdGdbInfo::Execute(void) +CMICmdCmdGdbInfo::Execute() { CMICMDBASE_GETOPTION(pArgPrint, String, m_constStrArgNamedPrint); const CMIUtilString &rPrintRequest(pArgPrint->GetValue()); @@ -110,7 +110,7 @@ CMICmdCmdGdbInfo::Execute(void) // Throws: None. //-- bool -CMICmdCmdGdbInfo::Acknowledge(void) +CMICmdCmdGdbInfo::Acknowledge() { if (!m_bPrintFnRecognised) { @@ -145,7 +145,7 @@ CMICmdCmdGdbInfo::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdGdbInfo::CreateSelf(void) +CMICmdCmdGdbInfo::CreateSelf() { return new CMICmdCmdGdbInfo(); } @@ -183,7 +183,7 @@ CMICmdCmdGdbInfo::GetPrintFn(const CMIUtilString &vrPrintFnName, FnPrintPtr &vrw // Throws: None. //-- bool -CMICmdCmdGdbInfo::PrintFnSharedLibrary(void) +CMICmdCmdGdbInfo::PrintFnSharedLibrary() { CMICmnStreamStdout &rStdout = CMICmnStreamStdout::Instance(); bool bOk = rStdout.TextToStdout("~\"From To Syms Read Shared Object Library\""); diff --git a/tools/lldb-mi/MICmdCmdGdbInfo.h b/tools/lldb-mi/MICmdCmdGdbInfo.h index a1b5770e200b..6a7a2137ff45 100644 --- a/tools/lldb-mi/MICmdCmdGdbInfo.h +++ b/tools/lldb-mi/MICmdCmdGdbInfo.h @@ -1,4 +1,4 @@ -//===-- MICmdCmdGdbInfo.h --------------------------*- C++ -*-===// +//===-- MICmdCmdGdbInfo.h ---------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -37,29 +37,26 @@ // class instantiates a request info command for a matching request. The // design/code of *this class then does not then become bloated. Use a // lightweight version of the current MI command system. -// Gotchas: None. -// Authors: Illya Rudkin 05/06/2014. -// Changes: None. //-- class CMICmdCmdGdbInfo : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdGdbInfo(void); + /* ctor */ CMICmdCmdGdbInfo(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdGdbInfo(void) override; + /* dtor */ ~CMICmdCmdGdbInfo() override; // Typedefs: private: @@ -69,7 +66,7 @@ class CMICmdCmdGdbInfo : public CMICmdBase // Methods: private: bool GetPrintFn(const CMIUtilString &vrPrintFnName, FnPrintPtr &vrwpFn) const; - bool PrintFnSharedLibrary(void); + bool PrintFnSharedLibrary(); // Attributes: private: diff --git a/tools/lldb-mi/MICmdCmdGdbSet.cpp b/tools/lldb-mi/MICmdCmdGdbSet.cpp index 452ac516f2e4..1d68b0b5e27f 100644 --- a/tools/lldb-mi/MICmdCmdGdbSet.cpp +++ b/tools/lldb-mi/MICmdCmdGdbSet.cpp @@ -34,9 +34,8 @@ const CMICmdCmdGdbSet::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbSet::ms_ma // Return: None. // Throws: None. //-- -CMICmdCmdGdbSet::CMICmdCmdGdbSet(void) - : m_constStrArgNamedThreadGrp("thread-group") - , m_constStrArgNamedGdbOption("option") +CMICmdCmdGdbSet::CMICmdCmdGdbSet() + : m_constStrArgNamedGdbOption("option") , m_bGdbOptionRecognised(true) , m_bGdbOptionFnSuccessful(false) , m_bGbbOptionFnHasError(false) @@ -56,7 +55,7 @@ CMICmdCmdGdbSet::CMICmdCmdGdbSet(void) // Return: None. // Throws: None. //-- -CMICmdCmdGdbSet::~CMICmdCmdGdbSet(void) +CMICmdCmdGdbSet::~CMICmdCmdGdbSet() { } @@ -70,14 +69,11 @@ CMICmdCmdGdbSet::~CMICmdCmdGdbSet(void) // Throws: None. //-- bool -CMICmdCmdGdbSet::ParseArgs(void) +CMICmdCmdGdbSet::ParseArgs() { - bool bOk = m_setCmdArgs.Add( - *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1))); - bOk = bOk && - m_setCmdArgs.Add( - *(new CMICmdArgValListOfN(m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringAnything))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add( + new CMICmdArgValListOfN(m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringAnything)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -90,7 +86,7 @@ CMICmdCmdGdbSet::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdGdbSet::Execute(void) +CMICmdCmdGdbSet::Execute() { CMICMDBASE_GETOPTION(pArgGdbOption, ListOfN, m_constStrArgNamedGdbOption); const CMICmdArgValListBase::VecArgObjPtr_t &rVecWords(pArgGdbOption->GetExpectedOptions()); @@ -143,7 +139,7 @@ CMICmdCmdGdbSet::Execute(void) // Throws: None. //-- bool -CMICmdCmdGdbSet::Acknowledge(void) +CMICmdCmdGdbSet::Acknowledge() { // Print error if option isn't recognized: // ^error,msg="The request '%s' was not recognized, not implemented" @@ -184,7 +180,7 @@ CMICmdCmdGdbSet::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdGdbSet::CreateSelf(void) +CMICmdCmdGdbSet::CreateSelf() { return new CMICmdCmdGdbSet(); } diff --git a/tools/lldb-mi/MICmdCmdGdbSet.h b/tools/lldb-mi/MICmdCmdGdbSet.h index 84d21f0557b7..db33f6580a26 100644 --- a/tools/lldb-mi/MICmdCmdGdbSet.h +++ b/tools/lldb-mi/MICmdCmdGdbSet.h @@ -37,29 +37,26 @@ // class instantiates a request info command for a matching request. The // design/code of *this class then does not then become bloated. Use a // lightweight version of the current MI command system. -// Gotchas: None. -// Authors: Illya Rudkin 03/03/2014. -// Changes: None. //-- class CMICmdCmdGdbSet : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdGdbSet(void); + /* ctor */ CMICmdCmdGdbSet(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdGdbSet(void) override; + /* dtor */ ~CMICmdCmdGdbSet() override; // Typedefs: private: @@ -79,7 +76,6 @@ class CMICmdCmdGdbSet : public CMICmdBase private: const static MapGdbOptionNameToFnGdbOptionPtr_t ms_mapGdbOptionNameToFnGdbOptionPtr; // - const CMIUtilString m_constStrArgNamedThreadGrp; const CMIUtilString m_constStrArgNamedGdbOption; bool m_bGdbOptionRecognised; // True = This command has a function with a name that matches the Print argument, false = not found bool m_bGdbOptionFnSuccessful; // True = The print function completed its task ok, false = function failed for some reason diff --git a/tools/lldb-mi/MICmdCmdGdbShow.cpp b/tools/lldb-mi/MICmdCmdGdbShow.cpp index f1f40ccbed1a..147e76798bfa 100644 --- a/tools/lldb-mi/MICmdCmdGdbShow.cpp +++ b/tools/lldb-mi/MICmdCmdGdbShow.cpp @@ -38,9 +38,8 @@ const CMICmdCmdGdbShow::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbShow::ms_ // Return: None. // Throws: None. //-- -CMICmdCmdGdbShow::CMICmdCmdGdbShow(void) - : m_constStrArgNamedThreadGrp("thread-group") - , m_constStrArgNamedGdbOption("option") +CMICmdCmdGdbShow::CMICmdCmdGdbShow() + : m_constStrArgNamedGdbOption("option") , m_bGdbOptionRecognised(true) , m_bGdbOptionFnSuccessful(false) , m_bGbbOptionFnHasError(false) @@ -60,7 +59,7 @@ CMICmdCmdGdbShow::CMICmdCmdGdbShow(void) // Return: None. // Throws: None. //-- -CMICmdCmdGdbShow::~CMICmdCmdGdbShow(void) +CMICmdCmdGdbShow::~CMICmdCmdGdbShow() { } @@ -74,14 +73,11 @@ CMICmdCmdGdbShow::~CMICmdCmdGdbShow(void) // Throws: None. //-- bool -CMICmdCmdGdbShow::ParseArgs(void) +CMICmdCmdGdbShow::ParseArgs() { - bool bOk = m_setCmdArgs.Add( - *(new CMICmdArgValOptionLong(m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1))); - bOk = bOk && - m_setCmdArgs.Add( - *(new CMICmdArgValListOfN(m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringAnything))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add( + new CMICmdArgValListOfN(m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringAnything)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -93,7 +89,7 @@ CMICmdCmdGdbShow::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdGdbShow::Execute(void) +CMICmdCmdGdbShow::Execute() { CMICMDBASE_GETOPTION(pArgGdbOption, ListOfN, m_constStrArgNamedGdbOption); const CMICmdArgValListBase::VecArgObjPtr_t &rVecWords(pArgGdbOption->GetExpectedOptions()); @@ -146,7 +142,7 @@ CMICmdCmdGdbShow::Execute(void) // Throws: None. //-- bool -CMICmdCmdGdbShow::Acknowledge(void) +CMICmdCmdGdbShow::Acknowledge() { // Print error if option isn't recognized: // ^error,msg="The request '%s' was not recognized, not implemented" @@ -196,7 +192,7 @@ CMICmdCmdGdbShow::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdGdbShow::CreateSelf(void) +CMICmdCmdGdbShow::CreateSelf() { return new CMICmdCmdGdbShow(); } diff --git a/tools/lldb-mi/MICmdCmdGdbShow.h b/tools/lldb-mi/MICmdCmdGdbShow.h index 6ca5ef8781a0..934105312da3 100644 --- a/tools/lldb-mi/MICmdCmdGdbShow.h +++ b/tools/lldb-mi/MICmdCmdGdbShow.h @@ -43,20 +43,20 @@ class CMICmdCmdGdbShow : public CMICmdBase // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdGdbShow(void); + /* ctor */ CMICmdCmdGdbShow(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdGdbShow(void) override; + /* dtor */ ~CMICmdCmdGdbShow() override; // Typedefs: private: @@ -74,8 +74,7 @@ class CMICmdCmdGdbShow : public CMICmdBase // Attributes: private: const static MapGdbOptionNameToFnGdbOptionPtr_t ms_mapGdbOptionNameToFnGdbOptionPtr; - // - const CMIUtilString m_constStrArgNamedThreadGrp; + const CMIUtilString m_constStrArgNamedGdbOption; bool m_bGdbOptionRecognised; // True = This command has a function with a name that matches the Print argument, false = not found bool m_bGdbOptionFnSuccessful; // True = The print function completed its task ok, false = function failed for some reason diff --git a/tools/lldb-mi/MICmdCmdGdbThread.cpp b/tools/lldb-mi/MICmdCmdGdbThread.cpp index 40f2eeccb6b4..5f71b0547609 100644 --- a/tools/lldb-mi/MICmdCmdGdbThread.cpp +++ b/tools/lldb-mi/MICmdCmdGdbThread.cpp @@ -21,7 +21,7 @@ // Return: None. // Throws: None. //-- -CMICmdCmdGdbThread::CMICmdCmdGdbThread(void) +CMICmdCmdGdbThread::CMICmdCmdGdbThread() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "thread"; @@ -37,7 +37,7 @@ CMICmdCmdGdbThread::CMICmdCmdGdbThread(void) // Return: None. // Throws: None. //-- -CMICmdCmdGdbThread::~CMICmdCmdGdbThread(void) +CMICmdCmdGdbThread::~CMICmdCmdGdbThread() { } @@ -51,7 +51,7 @@ CMICmdCmdGdbThread::~CMICmdCmdGdbThread(void) // Throws: None. //-- bool -CMICmdCmdGdbThread::Execute(void) +CMICmdCmdGdbThread::Execute() { // Do nothing @@ -68,7 +68,7 @@ CMICmdCmdGdbThread::Execute(void) // Throws: None. //-- bool -CMICmdCmdGdbThread::Acknowledge(void) +CMICmdCmdGdbThread::Acknowledge() { const CMICmnMIValueConst miValueConst(MIRSRC(IDS_WORD_NOT_IMPLEMENTED)); const CMICmnMIValueResult miValueResult("msg", miValueConst); @@ -87,7 +87,7 @@ CMICmdCmdGdbThread::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdGdbThread::CreateSelf(void) +CMICmdCmdGdbThread::CreateSelf() { return new CMICmdCmdGdbThread(); } diff --git a/tools/lldb-mi/MICmdCmdGdbThread.h b/tools/lldb-mi/MICmdCmdGdbThread.h index 6a3804a1c89b..40d8b7837898 100644 --- a/tools/lldb-mi/MICmdCmdGdbThread.h +++ b/tools/lldb-mi/MICmdCmdGdbThread.h @@ -26,26 +26,23 @@ //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements GDB command "thread". -// Gotchas: None. -// Authors: Illya Rudkin 25/02/2014. -// Changes: None. //-- class CMICmdCmdGdbThread : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdGdbThread(void); + /* ctor */ CMICmdCmdGdbThread(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdGdbThread(void) override; + /* dtor */ ~CMICmdCmdGdbThread() override; }; diff --git a/tools/lldb-mi/MICmdCmdMiscellanous.cpp b/tools/lldb-mi/MICmdCmdMiscellanous.cpp index 3abc7c488d8b..d534a6fafa0d 100644 --- a/tools/lldb-mi/MICmdCmdMiscellanous.cpp +++ b/tools/lldb-mi/MICmdCmdMiscellanous.cpp @@ -41,7 +41,7 @@ // Return: None. // Throws: None. //-- -CMICmdCmdGdbExit::CMICmdCmdGdbExit(void) +CMICmdCmdGdbExit::CMICmdCmdGdbExit() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "gdb-exit"; @@ -57,7 +57,7 @@ CMICmdCmdGdbExit::CMICmdCmdGdbExit(void) // Return: None. // Throws: None. //-- -CMICmdCmdGdbExit::~CMICmdCmdGdbExit(void) +CMICmdCmdGdbExit::~CMICmdCmdGdbExit() { } @@ -71,7 +71,7 @@ CMICmdCmdGdbExit::~CMICmdCmdGdbExit(void) // Throws: None. //-- bool -CMICmdCmdGdbExit::Execute(void) +CMICmdCmdGdbExit::Execute() { CMICmnLLDBDebugger::Instance().GetDriver().SetExitApplicationFlag(true); const lldb::SBError sbErr = m_rLLDBDebugSessionInfo.GetProcess().Destroy(); @@ -90,7 +90,7 @@ CMICmdCmdGdbExit::Execute(void) // Throws: None. //-- bool -CMICmdCmdGdbExit::Acknowledge(void) +CMICmdCmdGdbExit::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Exit); m_miResultRecord = miRecordResult; @@ -115,7 +115,7 @@ CMICmdCmdGdbExit::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdGdbExit::CreateSelf(void) +CMICmdCmdGdbExit::CreateSelf() { return new CMICmdCmdGdbExit(); } @@ -131,7 +131,7 @@ CMICmdCmdGdbExit::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdListThreadGroups::CMICmdCmdListThreadGroups(void) +CMICmdCmdListThreadGroups::CMICmdCmdListThreadGroups() : m_bIsI1(false) , m_bHaveArgOption(false) , m_bHaveArgRecurse(false) @@ -154,7 +154,7 @@ CMICmdCmdListThreadGroups::CMICmdCmdListThreadGroups(void) // Return: None. // Throws: None. //-- -CMICmdCmdListThreadGroups::~CMICmdCmdListThreadGroups(void) +CMICmdCmdListThreadGroups::~CMICmdCmdListThreadGroups() { m_vecMIValueTuple.clear(); } @@ -169,16 +169,14 @@ CMICmdCmdListThreadGroups::~CMICmdCmdListThreadGroups(void) // Throws: None. //-- bool -CMICmdCmdListThreadGroups::ParseArgs(void) +CMICmdCmdListThreadGroups::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgNamedAvailable, false, true))); - bOk = bOk && - m_setCmdArgs.Add( - *(new CMICmdArgValOptionLong(m_constStrArgNamedRecurse, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = - bOk && m_setCmdArgs.Add(*(new CMICmdArgValListOfN(m_constStrArgNamedGroup, false, true, CMICmdArgValListBase::eArgValType_Number))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValThreadGrp(m_constStrArgNamedThreadGroup, false, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgNamedAvailable, false, true)); + m_setCmdArgs.Add( + new CMICmdArgValOptionLong(m_constStrArgNamedRecurse, false, true, CMICmdArgValListBase::eArgValType_Number, 1)); + m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedGroup, false, true, CMICmdArgValListBase::eArgValType_Number)); + m_setCmdArgs.Add(new CMICmdArgValThreadGrp(m_constStrArgNamedThreadGroup, false, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -196,7 +194,7 @@ CMICmdCmdListThreadGroups::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdListThreadGroups::Execute(void) +CMICmdCmdListThreadGroups::Execute() { if (m_setCmdArgs.IsArgContextEmpty()) // No options so "top level thread groups" @@ -259,7 +257,7 @@ CMICmdCmdListThreadGroups::Execute(void) // Throws: None. //-- bool -CMICmdCmdListThreadGroups::Acknowledge(void) +CMICmdCmdListThreadGroups::Acknowledge() { if (m_bHaveArgOption) { @@ -382,7 +380,7 @@ CMICmdCmdListThreadGroups::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdListThreadGroups::CreateSelf(void) +CMICmdCmdListThreadGroups::CreateSelf() { return new CMICmdCmdListThreadGroups(); } @@ -398,7 +396,7 @@ CMICmdCmdListThreadGroups::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdInterpreterExec::CMICmdCmdInterpreterExec(void) +CMICmdCmdInterpreterExec::CMICmdCmdInterpreterExec() : m_constStrArgNamedInterpreter("interpreter") , m_constStrArgNamedCommand("command") { @@ -416,7 +414,7 @@ CMICmdCmdInterpreterExec::CMICmdCmdInterpreterExec(void) // Return: None. // Throws: None. //-- -CMICmdCmdInterpreterExec::~CMICmdCmdInterpreterExec(void) +CMICmdCmdInterpreterExec::~CMICmdCmdInterpreterExec() { } @@ -430,11 +428,11 @@ CMICmdCmdInterpreterExec::~CMICmdCmdInterpreterExec(void) // Throws: None. //-- bool -CMICmdCmdInterpreterExec::ParseArgs(void) +CMICmdCmdInterpreterExec::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedInterpreter, true, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedCommand, true, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedInterpreter, true, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedCommand, true, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -447,7 +445,7 @@ CMICmdCmdInterpreterExec::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdInterpreterExec::Execute(void) +CMICmdCmdInterpreterExec::Execute() { CMICMDBASE_GETOPTION(pArgInterpreter, String, m_constStrArgNamedInterpreter); CMICMDBASE_GETOPTION(pArgCommand, String, m_constStrArgNamedCommand); @@ -476,7 +474,7 @@ CMICmdCmdInterpreterExec::Execute(void) // Throws: None. //-- bool -CMICmdCmdInterpreterExec::Acknowledge(void) +CMICmdCmdInterpreterExec::Acknowledge() { if (m_lldbResult.GetOutputSize() > 0) { @@ -506,7 +504,7 @@ CMICmdCmdInterpreterExec::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdInterpreterExec::CreateSelf(void) +CMICmdCmdInterpreterExec::CreateSelf() { return new CMICmdCmdInterpreterExec(); } @@ -522,7 +520,7 @@ CMICmdCmdInterpreterExec::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdInferiorTtySet::CMICmdCmdInferiorTtySet(void) +CMICmdCmdInferiorTtySet::CMICmdCmdInferiorTtySet() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "inferior-tty-set"; @@ -538,7 +536,7 @@ CMICmdCmdInferiorTtySet::CMICmdCmdInferiorTtySet(void) // Return: None. // Throws: None. //-- -CMICmdCmdInferiorTtySet::~CMICmdCmdInferiorTtySet(void) +CMICmdCmdInferiorTtySet::~CMICmdCmdInferiorTtySet() { } @@ -552,7 +550,7 @@ CMICmdCmdInferiorTtySet::~CMICmdCmdInferiorTtySet(void) // Throws: None. //-- bool -CMICmdCmdInferiorTtySet::Execute(void) +CMICmdCmdInferiorTtySet::Execute() { // Do nothing @@ -569,7 +567,7 @@ CMICmdCmdInferiorTtySet::Execute(void) // Throws: None. //-- bool -CMICmdCmdInferiorTtySet::Acknowledge(void) +CMICmdCmdInferiorTtySet::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error); m_miResultRecord = miRecordResult; @@ -586,7 +584,7 @@ CMICmdCmdInferiorTtySet::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdInferiorTtySet::CreateSelf(void) +CMICmdCmdInferiorTtySet::CreateSelf() { return new CMICmdCmdInferiorTtySet(); } diff --git a/tools/lldb-mi/MICmdCmdMiscellanous.h b/tools/lldb-mi/MICmdCmdMiscellanous.h index 876554981e34..9f82195c9980 100644 --- a/tools/lldb-mi/MICmdCmdMiscellanous.h +++ b/tools/lldb-mi/MICmdCmdMiscellanous.h @@ -34,28 +34,25 @@ //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "gdb-exit". -// Gotchas: None. -// Authors: Illya Rudkin 04/03/2014. -// Changes: None. //-- class CMICmdCmdGdbExit : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdGdbExit(void); + /* ctor */ CMICmdCmdGdbExit(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdGdbExit(void) override; + /* dtor */ ~CMICmdCmdGdbExit() override; }; //++ ============================================================================ @@ -63,29 +60,26 @@ class CMICmdCmdGdbExit : public CMICmdBase // *this class implements MI command "list-thread-groups". // This command does not follow the MI documentation exactly. // http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Miscellaneous-Commands.html#GDB_002fMI-Miscellaneous-Commands -// Gotchas: None. -// Authors: Illya Rudkin 06/03/2014. -// Changes: None. //-- class CMICmdCmdListThreadGroups : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdListThreadGroups(void); + /* ctor */ CMICmdCmdListThreadGroups(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdListThreadGroups(void) override; + /* dtor */ ~CMICmdCmdListThreadGroups() override; // Typedefs: private: @@ -106,29 +100,26 @@ class CMICmdCmdListThreadGroups : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "interpreter-exec". -// Gotchas: None. -// Authors: Illya Rudkin 16/05/2014. -// Changes: None. //-- class CMICmdCmdInterpreterExec : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdInterpreterExec(void); + /* ctor */ CMICmdCmdInterpreterExec(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdInterpreterExec(void) override; + /* dtor */ ~CMICmdCmdInterpreterExec() override; // Attributes: private: @@ -140,26 +131,23 @@ class CMICmdCmdInterpreterExec : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "inferior-tty-set". -// Gotchas: None. -// Authors: Illya Rudkin 22/07/2014. -// Changes: None. //-- class CMICmdCmdInferiorTtySet : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdInferiorTtySet(void); + /* ctor */ CMICmdCmdInferiorTtySet(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdInferiorTtySet(void) override; + /* dtor */ ~CMICmdCmdInferiorTtySet() override; }; diff --git a/tools/lldb-mi/MICmdCmdStack.cpp b/tools/lldb-mi/MICmdCmdStack.cpp index 7f767e727f97..bc3483313f37 100644 --- a/tools/lldb-mi/MICmdCmdStack.cpp +++ b/tools/lldb-mi/MICmdCmdStack.cpp @@ -39,9 +39,8 @@ // Return: None. // Throws: None. //-- -CMICmdCmdStackInfoDepth::CMICmdCmdStackInfoDepth(void) +CMICmdCmdStackInfoDepth::CMICmdCmdStackInfoDepth() : m_nThreadFrames(0) - , m_constStrArgThread("thread") , m_constStrArgMaxDepth("max-depth") { // Command factory matches this name with that received from the stdin stream @@ -58,7 +57,7 @@ CMICmdCmdStackInfoDepth::CMICmdCmdStackInfoDepth(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackInfoDepth::~CMICmdCmdStackInfoDepth(void) +CMICmdCmdStackInfoDepth::~CMICmdCmdStackInfoDepth() { } @@ -72,12 +71,10 @@ CMICmdCmdStackInfoDepth::~CMICmdCmdStackInfoDepth(void) // Throws: None. //-- bool -CMICmdCmdStackInfoDepth::ParseArgs(void) +CMICmdCmdStackInfoDepth::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgMaxDepth, false, false))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgMaxDepth, false, false)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -90,7 +87,7 @@ CMICmdCmdStackInfoDepth::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdStackInfoDepth::Execute(void) +CMICmdCmdStackInfoDepth::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgMaxDepth, Number, m_constStrArgMaxDepth); @@ -121,7 +118,7 @@ CMICmdCmdStackInfoDepth::Execute(void) // Throws: None. //-- bool -CMICmdCmdStackInfoDepth::Acknowledge(void) +CMICmdCmdStackInfoDepth::Acknowledge() { const CMIUtilString strDepth(CMIUtilString::Format("%d", m_nThreadFrames)); const CMICmnMIValueConst miValueConst(strDepth); @@ -141,7 +138,7 @@ CMICmdCmdStackInfoDepth::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdStackInfoDepth::CreateSelf(void) +CMICmdCmdStackInfoDepth::CreateSelf() { return new CMICmdCmdStackInfoDepth(); } @@ -157,7 +154,7 @@ CMICmdCmdStackInfoDepth::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackInfoFrame::CMICmdCmdStackInfoFrame(void) +CMICmdCmdStackInfoFrame::CMICmdCmdStackInfoFrame() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "stack-info-frame"; @@ -173,7 +170,7 @@ CMICmdCmdStackInfoFrame::CMICmdCmdStackInfoFrame(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackInfoFrame::~CMICmdCmdStackInfoFrame(void) +CMICmdCmdStackInfoFrame::~CMICmdCmdStackInfoFrame() { } @@ -187,7 +184,7 @@ CMICmdCmdStackInfoFrame::~CMICmdCmdStackInfoFrame(void) // Throws: None. //-- bool -CMICmdCmdStackInfoFrame::ParseArgs(void) +CMICmdCmdStackInfoFrame::ParseArgs() { return ParseValidateCmdOptions(); } @@ -202,7 +199,7 @@ CMICmdCmdStackInfoFrame::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdStackInfoFrame::Execute(void) +CMICmdCmdStackInfoFrame::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); lldb::SBProcess sbProcess = rSessionInfo.GetProcess(); @@ -230,7 +227,7 @@ CMICmdCmdStackInfoFrame::Execute(void) // Throws: None. //-- bool -CMICmdCmdStackInfoFrame::Acknowledge(void) +CMICmdCmdStackInfoFrame::Acknowledge() { const CMICmnMIValueResult miValueResult("frame", m_miValueTuple); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult); @@ -248,7 +245,7 @@ CMICmdCmdStackInfoFrame::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdStackInfoFrame::CreateSelf(void) +CMICmdCmdStackInfoFrame::CreateSelf() { return new CMICmdCmdStackInfoFrame(); } @@ -264,9 +261,8 @@ CMICmdCmdStackInfoFrame::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackListFrames::CMICmdCmdStackListFrames(void) +CMICmdCmdStackListFrames::CMICmdCmdStackListFrames() : m_nThreadFrames(0) - , m_constStrArgThread("thread") , m_constStrArgFrameLow("low-frame") , m_constStrArgFrameHigh("high-frame") { @@ -284,7 +280,7 @@ CMICmdCmdStackListFrames::CMICmdCmdStackListFrames(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackListFrames::~CMICmdCmdStackListFrames(void) +CMICmdCmdStackListFrames::~CMICmdCmdStackListFrames() { m_vecMIValueResult.clear(); } @@ -299,13 +295,11 @@ CMICmdCmdStackListFrames::~CMICmdCmdStackListFrames(void) // Throws: None. //-- bool -CMICmdCmdStackListFrames::ParseArgs(void) +CMICmdCmdStackListFrames::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrameLow, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrameHigh, false, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrameLow, false, true)); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrameHigh, false, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -318,7 +312,7 @@ CMICmdCmdStackListFrames::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdStackListFrames::Execute(void) +CMICmdCmdStackListFrames::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgFrameLow, Number, m_constStrArgFrameLow); @@ -377,7 +371,7 @@ CMICmdCmdStackListFrames::Execute(void) // Throws: None. //-- bool -CMICmdCmdStackListFrames::Acknowledge(void) +CMICmdCmdStackListFrames::Acknowledge() { if (m_nThreadFrames == 0) { @@ -429,7 +423,7 @@ CMICmdCmdStackListFrames::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdStackListFrames::CreateSelf(void) +CMICmdCmdStackListFrames::CreateSelf() { return new CMICmdCmdStackListFrames(); } @@ -445,10 +439,9 @@ CMICmdCmdStackListFrames::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackListArguments::CMICmdCmdStackListArguments(void) +CMICmdCmdStackListArguments::CMICmdCmdStackListArguments() : m_bThreadInvalid(false) , m_miValueList(true) - , m_constStrArgThread("thread") , m_constStrArgPrintValues("print-values") , m_constStrArgFrameLow("low-frame") , m_constStrArgFrameHigh("high-frame") @@ -467,7 +460,7 @@ CMICmdCmdStackListArguments::CMICmdCmdStackListArguments(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackListArguments::~CMICmdCmdStackListArguments(void) +CMICmdCmdStackListArguments::~CMICmdCmdStackListArguments() { } @@ -481,14 +474,12 @@ CMICmdCmdStackListArguments::~CMICmdCmdStackListArguments(void) // Throws: None. //-- bool -CMICmdCmdStackListArguments::ParseArgs(void) +CMICmdCmdStackListArguments::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrameLow, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrameHigh, false, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true)); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrameLow, false, true)); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrameHigh, false, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -501,7 +492,7 @@ CMICmdCmdStackListArguments::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdStackListArguments::Execute(void) +CMICmdCmdStackListArguments::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues); @@ -587,7 +578,7 @@ CMICmdCmdStackListArguments::Execute(void) // Throws: None. //-- bool -CMICmdCmdStackListArguments::Acknowledge(void) +CMICmdCmdStackListArguments::Acknowledge() { if (m_bThreadInvalid) { @@ -616,7 +607,7 @@ CMICmdCmdStackListArguments::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdStackListArguments::CreateSelf(void) +CMICmdCmdStackListArguments::CreateSelf() { return new CMICmdCmdStackListArguments(); } @@ -632,11 +623,9 @@ CMICmdCmdStackListArguments::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackListLocals::CMICmdCmdStackListLocals(void) +CMICmdCmdStackListLocals::CMICmdCmdStackListLocals() : m_bThreadInvalid(false) , m_miValueList(true) - , m_constStrArgThread("thread") - , m_constStrArgFrame("frame") , m_constStrArgPrintValues("print-values") { // Command factory matches this name with that received from the stdin stream @@ -653,7 +642,7 @@ CMICmdCmdStackListLocals::CMICmdCmdStackListLocals(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackListLocals::~CMICmdCmdStackListLocals(void) +CMICmdCmdStackListLocals::~CMICmdCmdStackListLocals() { } @@ -667,14 +656,10 @@ CMICmdCmdStackListLocals::~CMICmdCmdStackListLocals(void) // Throws: None. //-- bool -CMICmdCmdStackListLocals::ParseArgs(void) +CMICmdCmdStackListLocals::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -687,7 +672,7 @@ CMICmdCmdStackListLocals::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdStackListLocals::Execute(void) +CMICmdCmdStackListLocals::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame); @@ -752,7 +737,7 @@ CMICmdCmdStackListLocals::Execute(void) // Throws: None. //-- bool -CMICmdCmdStackListLocals::Acknowledge(void) +CMICmdCmdStackListLocals::Acknowledge() { if (m_bThreadInvalid) { @@ -781,7 +766,7 @@ CMICmdCmdStackListLocals::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdStackListLocals::CreateSelf(void) +CMICmdCmdStackListLocals::CreateSelf() { return new CMICmdCmdStackListLocals(); } @@ -797,11 +782,9 @@ CMICmdCmdStackListLocals::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackListVariables::CMICmdCmdStackListVariables(void) +CMICmdCmdStackListVariables::CMICmdCmdStackListVariables() : m_bThreadInvalid(false) , m_miValueList(true) - , m_constStrArgThread("thread") - , m_constStrArgFrame("frame") , m_constStrArgPrintValues("print-values") { // Command factory matches this name with that received from the stdin stream @@ -818,7 +801,7 @@ CMICmdCmdStackListVariables::CMICmdCmdStackListVariables(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackListVariables::~CMICmdCmdStackListVariables(void) +CMICmdCmdStackListVariables::~CMICmdCmdStackListVariables() { } @@ -832,14 +815,10 @@ CMICmdCmdStackListVariables::~CMICmdCmdStackListVariables(void) // Throws: None. //-- bool -CMICmdCmdStackListVariables::ParseArgs(void) +CMICmdCmdStackListVariables::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -852,7 +831,7 @@ CMICmdCmdStackListVariables::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdStackListVariables::Execute(void) +CMICmdCmdStackListVariables::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame); @@ -916,7 +895,7 @@ CMICmdCmdStackListVariables::Execute(void) // Throws: None. //-- bool -CMICmdCmdStackListVariables::Acknowledge(void) +CMICmdCmdStackListVariables::Acknowledge() { if (m_bThreadInvalid) { @@ -945,7 +924,7 @@ CMICmdCmdStackListVariables::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdStackListVariables::CreateSelf(void) +CMICmdCmdStackListVariables::CreateSelf() { return new CMICmdCmdStackListVariables(); } @@ -961,9 +940,9 @@ CMICmdCmdStackListVariables::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackSelectFrame::CMICmdCmdStackSelectFrame(void) +CMICmdCmdStackSelectFrame::CMICmdCmdStackSelectFrame() : m_bFrameInvalid(false) - , m_constStrArgFrame("frame") + , m_constStrArgFrameId("frame_id") { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "stack-select-frame"; @@ -979,7 +958,7 @@ CMICmdCmdStackSelectFrame::CMICmdCmdStackSelectFrame(void) // Return: None. // Throws: None. //-- -CMICmdCmdStackSelectFrame::~CMICmdCmdStackSelectFrame(void) +CMICmdCmdStackSelectFrame::~CMICmdCmdStackSelectFrame() { } @@ -993,10 +972,10 @@ CMICmdCmdStackSelectFrame::~CMICmdCmdStackSelectFrame(void) // Throws: None. //-- bool -CMICmdCmdStackSelectFrame::ParseArgs(void) +CMICmdCmdStackSelectFrame::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrame, true, false))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrameId, true, false)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -1009,9 +988,9 @@ CMICmdCmdStackSelectFrame::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdStackSelectFrame::Execute(void) +CMICmdCmdStackSelectFrame::Execute() { - CMICMDBASE_GETOPTION(pArgFrame, Number, m_constStrArgFrame); + CMICMDBASE_GETOPTION(pArgFrame, Number, m_constStrArgFrameId); CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); lldb::SBThread sbThread = rSessionInfo.GetProcess().GetSelectedThread(); @@ -1037,7 +1016,7 @@ CMICmdCmdStackSelectFrame::Execute(void) // Throws: None. //-- bool -CMICmdCmdStackSelectFrame::Acknowledge(void) +CMICmdCmdStackSelectFrame::Acknowledge() { if (m_bFrameInvalid) { @@ -1066,7 +1045,7 @@ CMICmdCmdStackSelectFrame::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdStackSelectFrame::CreateSelf(void) +CMICmdCmdStackSelectFrame::CreateSelf() { return new CMICmdCmdStackSelectFrame(); } diff --git a/tools/lldb-mi/MICmdCmdStack.h b/tools/lldb-mi/MICmdCmdStack.h index 274415aaafc4..e22a703545bb 100644 --- a/tools/lldb-mi/MICmdCmdStack.h +++ b/tools/lldb-mi/MICmdCmdStack.h @@ -33,34 +33,30 @@ //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "stack-info-depth". -// Gotchas: None. -// Authors: Illya Rudkin 21/03/2014. -// Changes: None. //-- class CMICmdCmdStackInfoDepth : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdStackInfoDepth(void); + /* ctor */ CMICmdCmdStackInfoDepth(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdStackInfoDepth(void) override; + /* dtor */ ~CMICmdCmdStackInfoDepth() override; // Attributes: private: MIuint m_nThreadFrames; - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgMaxDepth; // Not handled by *this command }; @@ -73,20 +69,20 @@ class CMICmdCmdStackInfoFrame : public CMICmdBase // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdStackInfoFrame(void); + /* ctor */ CMICmdCmdStackInfoFrame(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdStackInfoFrame(void) override; + /* dtor */ ~CMICmdCmdStackInfoFrame() override; // Attributes: private: @@ -96,29 +92,26 @@ class CMICmdCmdStackInfoFrame : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "stack-list-frames". -// Gotchas: None. -// Authors: Illya Rudkin 21/03/2014. -// Changes: None. //-- class CMICmdCmdStackListFrames : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdStackListFrames(void); + /* ctor */ CMICmdCmdStackListFrames(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdStackListFrames(void) override; + /* dtor */ ~CMICmdCmdStackListFrames() override; // Typedefs: private: @@ -128,7 +121,6 @@ class CMICmdCmdStackListFrames : public CMICmdBase private: MIuint m_nThreadFrames; VecMIValueResult_t m_vecMIValueResult; - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgFrameLow; const CMIUtilString m_constStrArgFrameHigh; }; @@ -136,35 +128,31 @@ class CMICmdCmdStackListFrames : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "stack-list-arguments". -// Gotchas: None. -// Authors: Illya Rudkin 24/03/2014. -// Changes: None. //-- class CMICmdCmdStackListArguments : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdStackListArguments(void); + /* ctor */ CMICmdCmdStackListArguments(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdStackListArguments(void) override; + /* dtor */ ~CMICmdCmdStackListArguments() override; // Attributes: private: bool m_bThreadInvalid; // True = yes invalid thread, false = thread object valid CMICmnMIValueList m_miValueList; - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgPrintValues; const CMIUtilString m_constStrArgFrameLow; const CMIUtilString m_constStrArgFrameHigh; @@ -173,36 +161,31 @@ class CMICmdCmdStackListArguments : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "stack-list-locals". -// Gotchas: None. -// Authors: Illya Rudkin 24/03/2014. -// Changes: None. //-- class CMICmdCmdStackListLocals : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdStackListLocals(void); + /* ctor */ CMICmdCmdStackListLocals(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdStackListLocals(void) override; + /* dtor */ ~CMICmdCmdStackListLocals() override; // Attributes: private: bool m_bThreadInvalid; // True = yes invalid thread, false = thread object valid CMICmnMIValueList m_miValueList; - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option - const CMIUtilString m_constStrArgFrame; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgPrintValues; }; @@ -215,27 +198,25 @@ class CMICmdCmdStackListVariables : public CMICmdBase // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdStackListVariables(void); + /* ctor */ CMICmdCmdStackListVariables(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdStackListVariables(void) override; + /* dtor */ ~CMICmdCmdStackListVariables() override; // Attributes private: bool m_bThreadInvalid; // True = yes invalid thread, false = thread object valid CMICmnMIValueList m_miValueList; - const CMIUtilString m_constStrArgThread; - const CMIUtilString m_constStrArgFrame; const CMIUtilString m_constStrArgPrintValues; }; @@ -248,23 +229,23 @@ class CMICmdCmdStackSelectFrame : public CMICmdBase // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdStackSelectFrame(void); + /* ctor */ CMICmdCmdStackSelectFrame(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdStackSelectFrame(void) override; + /* dtor */ ~CMICmdCmdStackSelectFrame() override; // Attributes: private: bool m_bFrameInvalid; // True = yes invalid frame, false = ok - const CMIUtilString m_constStrArgFrame; + const CMIUtilString m_constStrArgFrameId; }; diff --git a/tools/lldb-mi/MICmdCmdSupportInfo.cpp b/tools/lldb-mi/MICmdCmdSupportInfo.cpp index 2d04ef8dddf9..9d926441dd2f 100644 --- a/tools/lldb-mi/MICmdCmdSupportInfo.cpp +++ b/tools/lldb-mi/MICmdCmdSupportInfo.cpp @@ -24,7 +24,7 @@ // Return: None. // Throws: None. //-- -CMICmdCmdSupportInfoMiCmdQuery::CMICmdCmdSupportInfoMiCmdQuery(void) +CMICmdCmdSupportInfoMiCmdQuery::CMICmdCmdSupportInfoMiCmdQuery() : m_bCmdFound(false) , m_constStrArgCmdName("cmd_name") { @@ -42,7 +42,7 @@ CMICmdCmdSupportInfoMiCmdQuery::CMICmdCmdSupportInfoMiCmdQuery(void) // Return: None. // Throws: None. //-- -CMICmdCmdSupportInfoMiCmdQuery::~CMICmdCmdSupportInfoMiCmdQuery(void) +CMICmdCmdSupportInfoMiCmdQuery::~CMICmdCmdSupportInfoMiCmdQuery() { } @@ -56,10 +56,10 @@ CMICmdCmdSupportInfoMiCmdQuery::~CMICmdCmdSupportInfoMiCmdQuery(void) // Throws: None. //-- bool -CMICmdCmdSupportInfoMiCmdQuery::ParseArgs(void) +CMICmdCmdSupportInfoMiCmdQuery::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgCmdName, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgCmdName, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -72,7 +72,7 @@ CMICmdCmdSupportInfoMiCmdQuery::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdSupportInfoMiCmdQuery::Execute(void) +CMICmdCmdSupportInfoMiCmdQuery::Execute() { CMICMDBASE_GETOPTION(pArgNamedCmdName, String, m_constStrArgCmdName); const CMIUtilString &rCmdToQuery(pArgNamedCmdName->GetValue()); @@ -96,7 +96,7 @@ CMICmdCmdSupportInfoMiCmdQuery::Execute(void) // Throws: None. //-- bool -CMICmdCmdSupportInfoMiCmdQuery::Acknowledge(void) +CMICmdCmdSupportInfoMiCmdQuery::Acknowledge() { const CMICmnMIValueConst miValueConst(m_bCmdFound ? "true" : "false"); const CMICmnMIValueResult miValueResult("exists", miValueConst); @@ -117,7 +117,7 @@ CMICmdCmdSupportInfoMiCmdQuery::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdSupportInfoMiCmdQuery::CreateSelf(void) +CMICmdCmdSupportInfoMiCmdQuery::CreateSelf() { return new CMICmdCmdSupportInfoMiCmdQuery(); } diff --git a/tools/lldb-mi/MICmdCmdSupportInfo.h b/tools/lldb-mi/MICmdCmdSupportInfo.h index 8dfcfba8ed7d..62b71261f188 100644 --- a/tools/lldb-mi/MICmdCmdSupportInfo.h +++ b/tools/lldb-mi/MICmdCmdSupportInfo.h @@ -27,29 +27,26 @@ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "info-gdb-mi-command". // This command does not follow the MI documentation exactly. -// Gotchas: None. -// Authors: Illya Rudkin 06/05/2014. -// Changes: None. //-- class CMICmdCmdSupportInfoMiCmdQuery : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdSupportInfoMiCmdQuery(void); + /* ctor */ CMICmdCmdSupportInfoMiCmdQuery(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdSupportInfoMiCmdQuery(void) override; + /* dtor */ ~CMICmdCmdSupportInfoMiCmdQuery() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmdCmdSupportList.cpp b/tools/lldb-mi/MICmdCmdSupportList.cpp index 6cf4b0b533bc..06d63612de6e 100644 --- a/tools/lldb-mi/MICmdCmdSupportList.cpp +++ b/tools/lldb-mi/MICmdCmdSupportList.cpp @@ -22,7 +22,7 @@ // Return: None. // Throws: None. //-- -CMICmdCmdSupportListFeatures::CMICmdCmdSupportListFeatures(void) +CMICmdCmdSupportListFeatures::CMICmdCmdSupportListFeatures() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "list-features"; @@ -38,7 +38,7 @@ CMICmdCmdSupportListFeatures::CMICmdCmdSupportListFeatures(void) // Return: None. // Throws: None. //-- -CMICmdCmdSupportListFeatures::~CMICmdCmdSupportListFeatures(void) +CMICmdCmdSupportListFeatures::~CMICmdCmdSupportListFeatures() { } @@ -52,7 +52,7 @@ CMICmdCmdSupportListFeatures::~CMICmdCmdSupportListFeatures(void) // Throws: None. //-- bool -CMICmdCmdSupportListFeatures::Execute(void) +CMICmdCmdSupportListFeatures::Execute() { // Do nothing @@ -69,10 +69,15 @@ CMICmdCmdSupportListFeatures::Execute(void) // Throws: None. //-- bool -CMICmdCmdSupportListFeatures::Acknowledge(void) +CMICmdCmdSupportListFeatures::Acknowledge() { - const CMICmnMIValueConst miValueConst("data-read-memory-bytes"); - const CMICmnMIValueList miValueList(miValueConst); + // Declare supported features here + const CMICmnMIValueConst miValueConst1("data-read-memory-bytes"); + const CMICmnMIValueConst miValueConst2("exec-run-start-option"); + // Some features may depend on host and/or target, decide what to add below + CMICmnMIValueList miValueList(true); + miValueList.Add(miValueConst1); + miValueList.Add(miValueConst2); const CMICmnMIValueResult miValueResult("features", miValueList); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult); m_miResultRecord = miRecordResult; @@ -89,7 +94,7 @@ CMICmdCmdSupportListFeatures::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdSupportListFeatures::CreateSelf(void) +CMICmdCmdSupportListFeatures::CreateSelf() { return new CMICmdCmdSupportListFeatures(); } diff --git a/tools/lldb-mi/MICmdCmdSupportList.h b/tools/lldb-mi/MICmdCmdSupportList.h index a317b079247b..5ac95a34c3bb 100644 --- a/tools/lldb-mi/MICmdCmdSupportList.h +++ b/tools/lldb-mi/MICmdCmdSupportList.h @@ -27,26 +27,23 @@ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "list-features". // This command does not follow the MI documentation exactly. -// Gotchas: None. -// Authors: Illya Rudkin 03/03/2014. -// Changes: None. //-- class CMICmdCmdSupportListFeatures : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdSupportListFeatures(void); + /* ctor */ CMICmdCmdSupportListFeatures(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdSupportListFeatures(void) override; + /* dtor */ ~CMICmdCmdSupportListFeatures() override; }; diff --git a/tools/lldb-mi/MICmdCmdSymbol.cpp b/tools/lldb-mi/MICmdCmdSymbol.cpp index 2649389d7686..d99ceef22498 100644 --- a/tools/lldb-mi/MICmdCmdSymbol.cpp +++ b/tools/lldb-mi/MICmdCmdSymbol.cpp @@ -19,6 +19,7 @@ #include "MICmnMIResultRecord.h" #include "MICmnMIValueList.h" #include "MICmnMIValueTuple.h" +#include "MIUtilParse.h" //++ ------------------------------------------------------------------------------------ // Details: CMICmdCmdSymbolListLines constructor. @@ -27,7 +28,7 @@ // Return: None. // Throws: None. //-- -CMICmdCmdSymbolListLines::CMICmdCmdSymbolListLines(void) +CMICmdCmdSymbolListLines::CMICmdCmdSymbolListLines() : m_constStrArgNameFile("file") { // Command factory matches this name with that received from the stdin stream @@ -44,7 +45,7 @@ CMICmdCmdSymbolListLines::CMICmdCmdSymbolListLines(void) // Return: None. // Throws: None. //-- -CMICmdCmdSymbolListLines::~CMICmdCmdSymbolListLines(void) +CMICmdCmdSymbolListLines::~CMICmdCmdSymbolListLines() { } @@ -58,10 +59,10 @@ CMICmdCmdSymbolListLines::~CMICmdCmdSymbolListLines(void) // Throws: None. //-- bool -CMICmdCmdSymbolListLines::ParseArgs(void) +CMICmdCmdSymbolListLines::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValFile(m_constStrArgNameFile, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValFile(m_constStrArgNameFile, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -76,11 +77,15 @@ CMICmdCmdSymbolListLines::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdSymbolListLines::Execute(void) +CMICmdCmdSymbolListLines::Execute() { CMICMDBASE_GETOPTION(pArgFile, File, m_constStrArgNameFile); const CMIUtilString &strFilePath(pArgFile->GetValue()); + // FIXME: this won't work for header files! To try and use existing + // commands to get this to work for header files would be too slow. + // Instead, this code should be rewritten to use APIs and/or support + // should be added to lldb which would work for header files. const CMIUtilString strCmd(CMIUtilString::Format("target modules dump line-table \"%s\"", strFilePath.AddSlashes().c_str())); CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); @@ -91,6 +96,77 @@ CMICmdCmdSymbolListLines::Execute(void) } //++ ------------------------------------------------------------------------------------ +// Details: Helper function for parsing the header returned from lldb for the command: +// target modules dump line-table <file> +// where the header is of the format: +// Line table for /path/to/file in `/path/to/module +// Args: input - (R) Input string to parse. +// file - (W) String representing the file. +// Return: bool - True = input was parsed successfully, false = input could not be parsed. +// Throws: None. +//-- +static bool +ParseLLDBLineAddressHeader(const char *input, CMIUtilString &file) +{ + // Match LineEntry using regex. + static MIUtilParse::CRegexParser g_lineentry_header_regex( + "^ *Line table for (.+) in `(.+)$"); + // ^1=file ^2=module + + MIUtilParse::CRegexParser::Match match(3); + + const bool ok = g_lineentry_header_regex.Execute(input, match); + if (ok) + file = match.GetMatchAtIndex(1); + return ok; +} + +//++ ------------------------------------------------------------------------------------ +// Details: Helper function for parsing a line entry returned from lldb for the command: +// target modules dump line-table <file> +// where the line entry is of the format: +// 0x0000000100000e70: /path/to/file:3002[:4] +// addr file line column(opt) +// Args: input - (R) Input string to parse. +// addr - (W) String representing the pc address. +// file - (W) String representing the file. +// line - (W) String representing the line. +// Return: bool - True = input was parsed successfully, false = input could not be parsed. +// Throws: None. +//-- +static bool +ParseLLDBLineAddressEntry(const char *input, CMIUtilString &addr, + CMIUtilString &file, CMIUtilString &line) +{ + // Note: Ambiguities arise because the column is optional, and + // because : can appear in filenames or as a byte in a multibyte + // UTF8 character. We keep those cases to a minimum by using regex + // to work on the string from both the left and right, so that what + // is remains is assumed to be the filename. + + // Match LineEntry using regex. + static MIUtilParse::CRegexParser g_lineentry_nocol_regex( + "^ *(0x[0-9a-fA-F]+): (.+):([0-9]+)$"); + static MIUtilParse::CRegexParser g_lineentry_col_regex( + "^ *(0x[0-9a-fA-F]+): (.+):([0-9]+):[0-9]+$"); + // ^1=addr ^2=f ^3=line ^4=:col(opt) + + MIUtilParse::CRegexParser::Match match(5); + + // First try matching the LineEntry with the column, + // then try without the column. + const bool ok = g_lineentry_col_regex.Execute(input, match) || + g_lineentry_nocol_regex.Execute(input, match); + if (ok) + { + addr = match.GetMatchAtIndex(1); + file = match.GetMatchAtIndex(2); + line = match.GetMatchAtIndex(3); + } + return ok; +} + +//++ ------------------------------------------------------------------------------------ // Details: The invoker requires this function. The command prepares a MI Record Result // for the work carried out in the Execute(). // Type: Overridden. @@ -100,7 +176,7 @@ CMICmdCmdSymbolListLines::Execute(void) // Throws: None. //-- bool -CMICmdCmdSymbolListLines::Acknowledge(void) +CMICmdCmdSymbolListLines::Acknowledge() { if (m_lldbResult.GetErrorSize() > 0) { @@ -117,36 +193,48 @@ CMICmdCmdSymbolListLines::Acknowledge(void) const CMIUtilString strLldbMsg(m_lldbResult.GetOutput()); const MIuint nLines(strLldbMsg.SplitLines(vecLines)); + // Parse the file from the header. + const CMIUtilString &rWantFile(vecLines[0]); + CMIUtilString strWantFile; + if (!ParseLLDBLineAddressHeader(rWantFile.c_str(), strWantFile)) + { + // Unexpected error - parsing failed. + // MI print "%s^error,msg=\"Command '-symbol-list-lines'. Error: Line address header is absent or has an unknown format.\"" + const CMICmnMIValueConst miValueConst(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SOME_ERROR), m_cmdData.strMiCmd.c_str(), "Line address header is absent or has an unknown format.")); + const CMICmnMIValueResult miValueResult("msg", miValueConst); + const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult); + m_miResultRecord = miRecordResult; + + return MIstatus::success; + } + + // Parse the line address entries. CMICmnMIValueList miValueList(true); for (MIuint i = 1; i < nLines; ++i) { // String looks like: // 0x0000000100000e70: /path/to/file:3[:4] const CMIUtilString &rLine(vecLines[i]); + CMIUtilString strAddr; + CMIUtilString strFile; + CMIUtilString strLine; + + if (!ParseLLDBLineAddressEntry(rLine.c_str(), strAddr, strFile, strLine)) + continue; + + // Skip entries which don't match the desired source. + if (strWantFile != strFile) + continue; - // 0x0000000100000e70: /path/to/file:3[:4] - // ^^^^^^^^^^^^^^^^^^ -- pc - const size_t nAddrEndPos = rLine.find(':'); - const CMIUtilString strAddr(rLine.substr(0, nAddrEndPos).c_str()); const CMICmnMIValueConst miValueConst(strAddr); const CMICmnMIValueResult miValueResult("pc", miValueConst); CMICmnMIValueTuple miValueTuple(miValueResult); - // 0x0000000100000e70: /path/to/file:3[:4] - // ^ -- line - const size_t nLineOrColumnStartPos = rLine.rfind(':'); - const CMIUtilString strLineOrColumn(rLine.substr(nLineOrColumnStartPos + 1).c_str()); - const size_t nPathOrLineStartPos = rLine.rfind(':', nLineOrColumnStartPos - 1); - const size_t nPathOrLineLen = nLineOrColumnStartPos - nPathOrLineStartPos - 1; - const CMIUtilString strPathOrLine(rLine.substr(nPathOrLineStartPos + 1, nPathOrLineLen).c_str()); - const CMIUtilString strLine(strPathOrLine.IsNumber() ? strPathOrLine : strLineOrColumn); const CMICmnMIValueConst miValueConst2(strLine); const CMICmnMIValueResult miValueResult2("line", miValueConst2); - bool bOk = miValueTuple.Add(miValueResult2); + miValueTuple.Add(miValueResult2); - bOk = bOk && miValueList.Add(miValueTuple); - if (!bOk) - return MIstatus::failure; + miValueList.Add(miValueTuple); } // MI print "%s^done,lines=[{pc=\"%d\",line=\"%d\"}...]" @@ -167,7 +255,7 @@ CMICmdCmdSymbolListLines::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdSymbolListLines::CreateSelf(void) +CMICmdCmdSymbolListLines::CreateSelf() { return new CMICmdCmdSymbolListLines(); } diff --git a/tools/lldb-mi/MICmdCmdSymbol.h b/tools/lldb-mi/MICmdCmdSymbol.h index ef268bbdb598..5bffd4fe91db 100644 --- a/tools/lldb-mi/MICmdCmdSymbol.h +++ b/tools/lldb-mi/MICmdCmdSymbol.h @@ -35,20 +35,20 @@ class CMICmdCmdSymbolListLines : public CMICmdBase // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdSymbolListLines(void); + /* ctor */ CMICmdCmdSymbolListLines(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdSymbolListLines(void) override; + /* dtor */ ~CMICmdCmdSymbolListLines() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmdCmdTarget.cpp b/tools/lldb-mi/MICmdCmdTarget.cpp index 6655682eee38..030024bb267e 100644 --- a/tools/lldb-mi/MICmdCmdTarget.cpp +++ b/tools/lldb-mi/MICmdCmdTarget.cpp @@ -33,7 +33,7 @@ // Return: None. // Throws: None. //-- -CMICmdCmdTargetSelect::CMICmdCmdTargetSelect(void) +CMICmdCmdTargetSelect::CMICmdCmdTargetSelect() : m_constStrArgNamedType("type") , m_constStrArgNamedParameters("parameters") { @@ -51,7 +51,7 @@ CMICmdCmdTargetSelect::CMICmdCmdTargetSelect(void) // Return: None. // Throws: None. //-- -CMICmdCmdTargetSelect::~CMICmdCmdTargetSelect(void) +CMICmdCmdTargetSelect::~CMICmdCmdTargetSelect() { } @@ -65,11 +65,11 @@ CMICmdCmdTargetSelect::~CMICmdCmdTargetSelect(void) // Throws: None. //-- bool -CMICmdCmdTargetSelect::ParseArgs(void) +CMICmdCmdTargetSelect::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedType, true, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgNamedParameters, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedType, true, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedParameters, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -84,7 +84,7 @@ CMICmdCmdTargetSelect::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdTargetSelect::Execute(void) +CMICmdCmdTargetSelect::Execute() { CMICMDBASE_GETOPTION(pArgType, String, m_constStrArgNamedType); CMICMDBASE_GETOPTION(pArgParameters, String, m_constStrArgNamedParameters); @@ -172,7 +172,7 @@ CMICmdCmdTargetSelect::Execute(void) // Throws: None. //-- bool -CMICmdCmdTargetSelect::Acknowledge(void) +CMICmdCmdTargetSelect::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Connected); m_miResultRecord = miRecordResult; @@ -203,7 +203,7 @@ CMICmdCmdTargetSelect::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdTargetSelect::CreateSelf(void) +CMICmdCmdTargetSelect::CreateSelf() { return new CMICmdCmdTargetSelect(); } @@ -215,7 +215,7 @@ CMICmdCmdTargetSelect::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdTargetAttach::CMICmdCmdTargetAttach(void) +CMICmdCmdTargetAttach::CMICmdCmdTargetAttach() : m_constStrArgPid("pid") , m_constStrArgNamedFile("n") , m_constStrArgWaitFor("waitfor") @@ -234,7 +234,7 @@ CMICmdCmdTargetAttach::CMICmdCmdTargetAttach(void) // Return: None. // Throws: None. //-- -CMICmdCmdTargetAttach::~CMICmdCmdTargetAttach(void) +CMICmdCmdTargetAttach::~CMICmdCmdTargetAttach() { } @@ -248,13 +248,13 @@ CMICmdCmdTargetAttach::~CMICmdCmdTargetAttach(void) // Throws: None. //-- bool -CMICmdCmdTargetAttach::ParseArgs(void) +CMICmdCmdTargetAttach::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgPid, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionShort(m_constStrArgNamedFile, false, true, - CMICmdArgValListBase::eArgValType_String, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgWaitFor, false, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgPid, false, true)); + m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedFile, false, true, + CMICmdArgValListBase::eArgValType_String, 1)); + m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgWaitFor, false, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -269,7 +269,7 @@ CMICmdCmdTargetAttach::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdTargetAttach::Execute(void) +CMICmdCmdTargetAttach::Execute() { CMICMDBASE_GETOPTION(pArgPid, Number, m_constStrArgPid); CMICMDBASE_GETOPTION(pArgFile, OptionShort, m_constStrArgNamedFile); @@ -330,7 +330,7 @@ CMICmdCmdTargetAttach::Execute(void) // Throws: None. //-- bool -CMICmdCmdTargetAttach::Acknowledge(void) +CMICmdCmdTargetAttach::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -361,7 +361,7 @@ CMICmdCmdTargetAttach::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdTargetAttach::CreateSelf(void) +CMICmdCmdTargetAttach::CreateSelf() { return new CMICmdCmdTargetAttach(); } @@ -389,7 +389,7 @@ CMICmdCmdTargetDetach::CMICmdCmdTargetDetach() // Return: None. // Throws: None. //-- -CMICmdCmdTargetDetach::~CMICmdCmdTargetDetach(void) +CMICmdCmdTargetDetach::~CMICmdCmdTargetDetach() { } @@ -403,7 +403,7 @@ CMICmdCmdTargetDetach::~CMICmdCmdTargetDetach(void) // Throws: None. //-- bool -CMICmdCmdTargetDetach::ParseArgs(void) +CMICmdCmdTargetDetach::ParseArgs() { return MIstatus::success; } @@ -420,7 +420,7 @@ CMICmdCmdTargetDetach::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdTargetDetach::Execute(void) +CMICmdCmdTargetDetach::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); @@ -447,7 +447,7 @@ CMICmdCmdTargetDetach::Execute(void) // Throws: None. //-- bool -CMICmdCmdTargetDetach::Acknowledge(void) +CMICmdCmdTargetDetach::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -463,7 +463,7 @@ CMICmdCmdTargetDetach::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdTargetDetach::CreateSelf(void) +CMICmdCmdTargetDetach::CreateSelf() { return new CMICmdCmdTargetDetach(); } diff --git a/tools/lldb-mi/MICmdCmdTarget.h b/tools/lldb-mi/MICmdCmdTarget.h index 62f77eed47c5..e4c04b11145f 100644 --- a/tools/lldb-mi/MICmdCmdTarget.h +++ b/tools/lldb-mi/MICmdCmdTarget.h @@ -29,29 +29,26 @@ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "target-select". // http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Target-Manipulation.html#GDB_002fMI-Target-Manipulation -// Gotchas: None. -// Authors: Illya Rudkin 05/03/2014. -// Changes: None. //-- class CMICmdCmdTargetSelect : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdTargetSelect(void); + /* ctor */ CMICmdCmdTargetSelect(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdTargetSelect(void) override; + /* dtor */ ~CMICmdCmdTargetSelect() override; // Attributes: private: @@ -69,20 +66,20 @@ class CMICmdCmdTargetAttach : public CMICmdBase // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdTargetAttach(void); + /* ctor */ CMICmdCmdTargetAttach(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdTargetAttach(void) override; + /* dtor */ ~CMICmdCmdTargetAttach() override; // Attributes: private: @@ -101,19 +98,19 @@ class CMICmdCmdTargetDetach : public CMICmdBase // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdTargetDetach(void); + /* ctor */ CMICmdCmdTargetDetach(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdTargetDetach(void) override; + /* dtor */ ~CMICmdCmdTargetDetach() override; }; diff --git a/tools/lldb-mi/MICmdCmdThread.cpp b/tools/lldb-mi/MICmdCmdThread.cpp index df6de269bd49..823a3748248c 100644 --- a/tools/lldb-mi/MICmdCmdThread.cpp +++ b/tools/lldb-mi/MICmdCmdThread.cpp @@ -28,7 +28,7 @@ // Return: None. // Throws: None. //-- -CMICmdCmdThreadInfo::CMICmdCmdThreadInfo(void) +CMICmdCmdThreadInfo::CMICmdCmdThreadInfo() : m_bSingleThread(false) , m_bThreadInvalid(true) , m_constStrArgNamedThreadId("thread-id") @@ -47,7 +47,7 @@ CMICmdCmdThreadInfo::CMICmdCmdThreadInfo(void) // Return: None. // Throws: None. //-- -CMICmdCmdThreadInfo::~CMICmdCmdThreadInfo(void) +CMICmdCmdThreadInfo::~CMICmdCmdThreadInfo() { m_vecMIValueTuple.clear(); } @@ -62,10 +62,10 @@ CMICmdCmdThreadInfo::~CMICmdCmdThreadInfo(void) // Throws: None. //-- bool -CMICmdCmdThreadInfo::ParseArgs(void) +CMICmdCmdThreadInfo::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgNamedThreadId, false, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedThreadId, false, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -78,7 +78,7 @@ CMICmdCmdThreadInfo::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdThreadInfo::Execute(void) +CMICmdCmdThreadInfo::Execute() { CMICMDBASE_GETOPTION(pArgThreadId, Number, m_constStrArgNamedThreadId); MIuint nThreadId = 0; @@ -137,7 +137,7 @@ CMICmdCmdThreadInfo::Execute(void) // Throws: None. //-- bool -CMICmdCmdThreadInfo::Acknowledge(void) +CMICmdCmdThreadInfo::Acknowledge() { if (m_bSingleThread) { @@ -195,7 +195,7 @@ CMICmdCmdThreadInfo::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdThreadInfo::CreateSelf(void) +CMICmdCmdThreadInfo::CreateSelf() { return new CMICmdCmdThreadInfo(); } diff --git a/tools/lldb-mi/MICmdCmdThread.h b/tools/lldb-mi/MICmdCmdThread.h index 7bce823a0b24..7031eabddc33 100644 --- a/tools/lldb-mi/MICmdCmdThread.h +++ b/tools/lldb-mi/MICmdCmdThread.h @@ -28,29 +28,26 @@ //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "thread-info". -// Gotchas: None. -// Authors: Illya Rudkin 07/03/2014. -// Changes: None. //-- class CMICmdCmdThreadInfo : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdThreadInfo(void); + /* ctor */ CMICmdCmdThreadInfo(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdThreadInfo(void) override; + /* dtor */ ~CMICmdCmdThreadInfo() override; // Typedefs: private: diff --git a/tools/lldb-mi/MICmdCmdTrace.cpp b/tools/lldb-mi/MICmdCmdTrace.cpp index c0d5fc920373..4eab75bc71f6 100644 --- a/tools/lldb-mi/MICmdCmdTrace.cpp +++ b/tools/lldb-mi/MICmdCmdTrace.cpp @@ -21,7 +21,7 @@ // Return: None. // Throws: None. //-- -CMICmdCmdTraceStatus::CMICmdCmdTraceStatus(void) +CMICmdCmdTraceStatus::CMICmdCmdTraceStatus() { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "trace-status"; @@ -37,7 +37,7 @@ CMICmdCmdTraceStatus::CMICmdCmdTraceStatus(void) // Return: None. // Throws: None. //-- -CMICmdCmdTraceStatus::~CMICmdCmdTraceStatus(void) +CMICmdCmdTraceStatus::~CMICmdCmdTraceStatus() { } @@ -51,7 +51,7 @@ CMICmdCmdTraceStatus::~CMICmdCmdTraceStatus(void) // Throws: None. //-- bool -CMICmdCmdTraceStatus::Execute(void) +CMICmdCmdTraceStatus::Execute() { // Do nothing return MIstatus::success; @@ -67,7 +67,7 @@ CMICmdCmdTraceStatus::Execute(void) // Throws: None. //-- bool -CMICmdCmdTraceStatus::Acknowledge(void) +CMICmdCmdTraceStatus::Acknowledge() { const CMICmnMIValueConst miValueConst(MIRSRC(IDS_CMD_ERR_NOT_IMPLEMENTED)); const CMICmnMIValueResult miValueResult("msg", miValueConst); @@ -86,7 +86,7 @@ CMICmdCmdTraceStatus::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdTraceStatus::CreateSelf(void) +CMICmdCmdTraceStatus::CreateSelf() { return new CMICmdCmdTraceStatus(); } diff --git a/tools/lldb-mi/MICmdCmdTrace.h b/tools/lldb-mi/MICmdCmdTrace.h index cafe2d89420e..d3751607338d 100644 --- a/tools/lldb-mi/MICmdCmdTrace.h +++ b/tools/lldb-mi/MICmdCmdTrace.h @@ -26,26 +26,23 @@ //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "trace-status". -// Gotchas: None. -// Authors: Illya Rudkin 07/03/2014. -// Changes: None. //-- class CMICmdCmdTraceStatus : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdTraceStatus(void); + /* ctor */ CMICmdCmdTraceStatus(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; + bool Execute() override; + bool Acknowledge() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdTraceStatus(void) override; + /* dtor */ ~CMICmdCmdTraceStatus() override; }; diff --git a/tools/lldb-mi/MICmdCmdVar.cpp b/tools/lldb-mi/MICmdCmdVar.cpp index 8c4abbda1128..8e30a2ad0da4 100644 --- a/tools/lldb-mi/MICmdCmdVar.cpp +++ b/tools/lldb-mi/MICmdCmdVar.cpp @@ -45,15 +45,12 @@ // Return: None. // Throws: None. //-- -CMICmdCmdVarCreate::CMICmdCmdVarCreate(void) +CMICmdCmdVarCreate::CMICmdCmdVarCreate() : m_nChildren(0) , m_nThreadId(0) , m_strType("??") , m_bValid(false) , m_strValue("??") - , m_constStrArgThread("thread") - , m_constStrArgThreadGroup("thread-group") - , m_constStrArgFrame("frame") , m_constStrArgName("name") , m_constStrArgFrameAddr("frame-addr") , m_constStrArgExpression("expression") @@ -72,7 +69,7 @@ CMICmdCmdVarCreate::CMICmdCmdVarCreate(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarCreate::~CMICmdCmdVarCreate(void) +CMICmdCmdVarCreate::~CMICmdCmdVarCreate() { } @@ -86,19 +83,12 @@ CMICmdCmdVarCreate::~CMICmdCmdVarCreate(void) // Throws: None. //-- bool -CMICmdCmdVarCreate::ParseArgs(void) +CMICmdCmdVarCreate::ParseArgs() { - bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && - m_setCmdArgs.Add( - *(new CMICmdArgValOptionLong(m_constStrArgThreadGroup, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1))); - bOk = bOk && - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgFrameAddr, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgExpression, true, true, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, false, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgFrameAddr, false, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgExpression, true, true, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -111,7 +101,7 @@ CMICmdCmdVarCreate::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdVarCreate::Execute(void) +CMICmdCmdVarCreate::Execute() { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame); @@ -182,7 +172,7 @@ CMICmdCmdVarCreate::Execute(void) if (rStrExpression[0] == '$') { - const CMIUtilString rStrRegister(rStrExpression.substr(1).c_str()); + const CMIUtilString rStrRegister(rStrExpression.substr(1)); value = frame.FindRegister(rStrRegister.c_str()); } else @@ -229,7 +219,7 @@ CMICmdCmdVarCreate::Execute(void) // Throws: None. //-- bool -CMICmdCmdVarCreate::Acknowledge(void) +CMICmdCmdVarCreate::Acknowledge() { if (m_bValid) { @@ -258,7 +248,7 @@ CMICmdCmdVarCreate::Acknowledge(void) CMIUtilString strErrMsg(m_strValue); if (m_strValue.empty()) strErrMsg = CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_VARIABLE_CREATION_FAILED), m_strExpression.c_str()); - const CMICmnMIValueConst miValueConst(strErrMsg); + const CMICmnMIValueConst miValueConst(strErrMsg.Escape(true /* vbEscapeQuotes */)); CMICmnMIValueResult miValueResult("msg", miValueConst); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult); m_miResultRecord = miRecordResult; @@ -275,7 +265,7 @@ CMICmdCmdVarCreate::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdVarCreate::CreateSelf(void) +CMICmdCmdVarCreate::CreateSelf() { return new CMICmdCmdVarCreate(); } @@ -320,7 +310,7 @@ CMICmdCmdVarCreate::CompleteSBValue(lldb::SBValue &vrwValue) // Return: None. // Throws: None. //-- -CMICmdCmdVarUpdate::CMICmdCmdVarUpdate(void) +CMICmdCmdVarUpdate::CMICmdCmdVarUpdate() : m_constStrArgPrintValues("print-values") , m_constStrArgName("name") , m_bValueChanged(false) @@ -340,7 +330,7 @@ CMICmdCmdVarUpdate::CMICmdCmdVarUpdate(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarUpdate::~CMICmdCmdVarUpdate(void) +CMICmdCmdVarUpdate::~CMICmdCmdVarUpdate() { } @@ -354,11 +344,11 @@ CMICmdCmdVarUpdate::~CMICmdCmdVarUpdate(void) // Throws: None. //-- bool -CMICmdCmdVarUpdate::ParseArgs(void) +CMICmdCmdVarUpdate::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValPrintValues(m_constStrArgPrintValues, false, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -371,7 +361,7 @@ CMICmdCmdVarUpdate::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdVarUpdate::Execute(void) +CMICmdCmdVarUpdate::Execute() { CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues); CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName); @@ -399,7 +389,7 @@ CMICmdCmdVarUpdate::Execute(void) (eVarInfoFormat == CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues && rValue.GetNumChildren() == 0)); const CMIUtilString strValue(bPrintValue ? varObj.GetValueFormatted() : ""); const CMIUtilString strInScope(rValue.IsInScope() ? "true" : "false"); - return MIFormResponse(rVarObjName, bPrintValue ? strValue.c_str() : nullptr, strInScope); + MIFormResponse(rVarObjName, bPrintValue ? strValue.c_str() : nullptr, strInScope); } return MIstatus::success; @@ -415,7 +405,7 @@ CMICmdCmdVarUpdate::Execute(void) // Throws: None. //-- bool -CMICmdCmdVarUpdate::Acknowledge(void) +CMICmdCmdVarUpdate::Acknowledge() { if (m_bValueChanged) { @@ -445,7 +435,7 @@ CMICmdCmdVarUpdate::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdVarUpdate::CreateSelf(void) +CMICmdCmdVarUpdate::CreateSelf() { return new CMICmdCmdVarUpdate(); } @@ -456,36 +446,32 @@ CMICmdCmdVarUpdate::CreateSelf(void) // Args: vrStrVarName - (R) Session var object's name. // vpValue - (R) Text version of the value held in the variable. // vrStrScope - (R) In scope "yes" or "no". -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmdCmdVarUpdate::MIFormResponse(const CMIUtilString &vrStrVarName, const char *const vpValue, const CMIUtilString &vrStrScope) { // MI print "[{name=\"%s\",value=\"%s\",in_scope=\"%s\",type_changed=\"false\",has_more=\"0\"}]" const CMICmnMIValueConst miValueConst(vrStrVarName); const CMICmnMIValueResult miValueResult("name", miValueConst); CMICmnMIValueTuple miValueTuple(miValueResult); - bool bOk = true; if (vpValue != nullptr) { const CMICmnMIValueConst miValueConst2(vpValue); const CMICmnMIValueResult miValueResult2("value", miValueConst2); - bOk = bOk && miValueTuple.Add(miValueResult2); + miValueTuple.Add(miValueResult2); } const CMICmnMIValueConst miValueConst3(vrStrScope); const CMICmnMIValueResult miValueResult3("in_scope", miValueConst3); - bOk = bOk && miValueTuple.Add(miValueResult3); + miValueTuple.Add(miValueResult3); const CMICmnMIValueConst miValueConst4("false"); const CMICmnMIValueResult miValueResult4("type_changed", miValueConst4); - bOk = bOk && miValueTuple.Add(miValueResult4); + miValueTuple.Add(miValueResult4); const CMICmnMIValueConst miValueConst5("0"); const CMICmnMIValueResult miValueResult5("has_more", miValueConst5); - bOk = bOk && miValueTuple.Add(miValueResult5); - bOk = bOk && m_miValueList.Add(miValueTuple); - - return bOk; + miValueTuple.Add(miValueResult5); + m_miValueList.Add(miValueTuple); } //++ ------------------------------------------------------------------------------------ @@ -543,7 +529,7 @@ CMICmdCmdVarUpdate::ExamineSBValueForChange(lldb::SBValue &vrwValue, bool &vrwbC // Return: None. // Throws: None. //-- -CMICmdCmdVarDelete::CMICmdCmdVarDelete(void) +CMICmdCmdVarDelete::CMICmdCmdVarDelete() : m_constStrArgName("name") { // Command factory matches this name with that received from the stdin stream @@ -563,10 +549,10 @@ CMICmdCmdVarDelete::CMICmdCmdVarDelete(void) // Throws: None. //-- bool -CMICmdCmdVarDelete::ParseArgs(void) +CMICmdCmdVarDelete::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -576,7 +562,7 @@ CMICmdCmdVarDelete::ParseArgs(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarDelete::~CMICmdCmdVarDelete(void) +CMICmdCmdVarDelete::~CMICmdCmdVarDelete() { } @@ -590,7 +576,7 @@ CMICmdCmdVarDelete::~CMICmdCmdVarDelete(void) // Throws: None. //-- bool -CMICmdCmdVarDelete::Execute(void) +CMICmdCmdVarDelete::Execute() { CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName); @@ -610,7 +596,7 @@ CMICmdCmdVarDelete::Execute(void) // Throws: None. //-- bool -CMICmdCmdVarDelete::Acknowledge(void) +CMICmdCmdVarDelete::Acknowledge() { const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; @@ -627,7 +613,7 @@ CMICmdCmdVarDelete::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdVarDelete::CreateSelf(void) +CMICmdCmdVarDelete::CreateSelf() { return new CMICmdCmdVarDelete(); } @@ -643,7 +629,7 @@ CMICmdCmdVarDelete::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarAssign::CMICmdCmdVarAssign(void) +CMICmdCmdVarAssign::CMICmdCmdVarAssign() : m_bOk(true) , m_constStrArgName("name") , m_constStrArgExpression("expression") @@ -662,7 +648,7 @@ CMICmdCmdVarAssign::CMICmdCmdVarAssign(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarAssign::~CMICmdCmdVarAssign(void) +CMICmdCmdVarAssign::~CMICmdCmdVarAssign() { } @@ -676,11 +662,11 @@ CMICmdCmdVarAssign::~CMICmdCmdVarAssign(void) // Throws: None. //-- bool -CMICmdCmdVarAssign::ParseArgs(void) +CMICmdCmdVarAssign::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgExpression, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgExpression, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -693,7 +679,7 @@ CMICmdCmdVarAssign::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdVarAssign::Execute(void) +CMICmdCmdVarAssign::Execute() { CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName); CMICMDBASE_GETOPTION(pArgExpression, String, m_constStrArgExpression); @@ -729,7 +715,7 @@ CMICmdCmdVarAssign::Execute(void) // Throws: None. //-- bool -CMICmdCmdVarAssign::Acknowledge(void) +CMICmdCmdVarAssign::Acknowledge() { if (m_bOk) { @@ -761,7 +747,7 @@ CMICmdCmdVarAssign::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdVarAssign::CreateSelf(void) +CMICmdCmdVarAssign::CreateSelf() { return new CMICmdCmdVarAssign(); } @@ -777,7 +763,7 @@ CMICmdCmdVarAssign::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarSetFormat::CMICmdCmdVarSetFormat(void) +CMICmdCmdVarSetFormat::CMICmdCmdVarSetFormat() : m_constStrArgName("name") , m_constStrArgFormatSpec("format-spec") { @@ -795,7 +781,7 @@ CMICmdCmdVarSetFormat::CMICmdCmdVarSetFormat(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarSetFormat::~CMICmdCmdVarSetFormat(void) +CMICmdCmdVarSetFormat::~CMICmdCmdVarSetFormat() { } @@ -809,11 +795,11 @@ CMICmdCmdVarSetFormat::~CMICmdCmdVarSetFormat(void) // Throws: None. //-- bool -CMICmdCmdVarSetFormat::ParseArgs(void) +CMICmdCmdVarSetFormat::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgFormatSpec, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgFormatSpec, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -826,7 +812,7 @@ CMICmdCmdVarSetFormat::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdVarSetFormat::Execute(void) +CMICmdCmdVarSetFormat::Execute() { CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName); CMICMDBASE_GETOPTION(pArgFormatSpec, String, m_constStrArgFormatSpec); @@ -863,7 +849,7 @@ CMICmdCmdVarSetFormat::Execute(void) // Throws: None. //-- bool -CMICmdCmdVarSetFormat::Acknowledge(void) +CMICmdCmdVarSetFormat::Acknowledge() { // MI print "%s^done,changelist=[{name=\"%s\",value=\"%s\",in_scope=\"%s\",type_changed=\"false\",has_more=\"0\"}]" CMICmnLLDBDebugSessionInfoVarObj varObj; @@ -902,7 +888,7 @@ CMICmdCmdVarSetFormat::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdVarSetFormat::CreateSelf(void) +CMICmdCmdVarSetFormat::CreateSelf() { return new CMICmdCmdVarSetFormat(); } @@ -918,7 +904,7 @@ CMICmdCmdVarSetFormat::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarListChildren::CMICmdCmdVarListChildren(void) +CMICmdCmdVarListChildren::CMICmdCmdVarListChildren() : m_constStrArgPrintValues("print-values") , m_constStrArgName("name") , m_constStrArgFrom("from") @@ -942,7 +928,7 @@ CMICmdCmdVarListChildren::CMICmdCmdVarListChildren(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarListChildren::~CMICmdCmdVarListChildren(void) +CMICmdCmdVarListChildren::~CMICmdCmdVarListChildren() { } @@ -956,13 +942,13 @@ CMICmdCmdVarListChildren::~CMICmdCmdVarListChildren(void) // Throws: None. //-- bool -CMICmdCmdVarListChildren::ParseArgs(void) +CMICmdCmdVarListChildren::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrom, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgTo, false, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValPrintValues(m_constStrArgPrintValues, false, true)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true, true)); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgFrom, false, true)); + m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgTo, false, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -975,7 +961,7 @@ CMICmdCmdVarListChildren::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdVarListChildren::Execute(void) +CMICmdCmdVarListChildren::Execute() { CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues); CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName); @@ -1022,46 +1008,47 @@ CMICmdCmdVarListChildren::Execute(void) lldb::SBValue member = rValue.GetChildAtIndex(i); const CMICmnLLDBUtilSBValue utilValue(member); const CMIUtilString strExp = utilValue.GetName(); - const CMIUtilString name(CMIUtilString::Format("%s.%s", rVarObjName.c_str(), strExp.c_str())); + const CMIUtilString name(strExp.empty() ? + CMIUtilString::Format("%s.$%u", rVarObjName.c_str(), i) : + CMIUtilString::Format("%s.%s", rVarObjName.c_str(), strExp.c_str())); const MIuint nChildren = member.GetNumChildren(); const CMIUtilString strThreadId(CMIUtilString::Format("%u", member.GetThread().GetIndexID())); + // Varobj gets added to CMICmnLLDBDebugSessionInfoVarObj static container of varObjs + CMICmnLLDBDebugSessionInfoVarObj var(strExp, name, member, rVarObjName); + // MI print "child={name=\"%s\",exp=\"%s\",numchild=\"%d\",value=\"%s\",type=\"%s\",thread-id=\"%u\",has_more=\"%u\"}" const CMICmnMIValueConst miValueConst(name); const CMICmnMIValueResult miValueResult("name", miValueConst); CMICmnMIValueTuple miValueTuple(miValueResult); const CMICmnMIValueConst miValueConst2(strExp); const CMICmnMIValueResult miValueResult2("exp", miValueConst2); - bool bOk = miValueTuple.Add(miValueResult2); + miValueTuple.Add(miValueResult2); const CMIUtilString strNumChild(CMIUtilString::Format("%u", nChildren)); const CMICmnMIValueConst miValueConst3(strNumChild); const CMICmnMIValueResult miValueResult3("numchild", miValueConst3); - bOk = bOk && miValueTuple.Add(miValueResult3); + miValueTuple.Add(miValueResult3); const CMICmnMIValueConst miValueConst5(utilValue.GetTypeNameDisplay()); const CMICmnMIValueResult miValueResult5("type", miValueConst5); - bOk = bOk && miValueTuple.Add(miValueResult5); + miValueTuple.Add(miValueResult5); const CMICmnMIValueConst miValueConst6(strThreadId); const CMICmnMIValueResult miValueResult6("thread-id", miValueConst6); - bOk = bOk && miValueTuple.Add(miValueResult6); + miValueTuple.Add(miValueResult6); // nChildren == 0 is used to check for simple values if (eVarInfoFormat == CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues || (eVarInfoFormat == CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues && nChildren == 0)) { - // Varobj gets added to CMICmnLLDBDebugSessionInfoVarObj static container of varObjs - CMICmnLLDBDebugSessionInfoVarObj var(strExp, name, member, rVarObjName); const CMIUtilString strValue( CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(member, CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Natural)); const CMICmnMIValueConst miValueConst7(strValue); const CMICmnMIValueResult miValueResult7("value", miValueConst7); - bOk = bOk && miValueTuple.Add(miValueResult7); + miValueTuple.Add(miValueResult7); } const CMICmnMIValueConst miValueConst8("0"); const CMICmnMIValueResult miValueResult8("has_more", miValueConst8); - bOk = bOk && miValueTuple.Add(miValueResult8); + miValueTuple.Add(miValueResult8); const CMICmnMIValueResult miValueResult9("child", miValueTuple); - bOk = bOk && m_miValueList.Add(miValueResult9); - if (!bOk) - return MIstatus::failure; + m_miValueList.Add(miValueResult9); } return MIstatus::success; @@ -1077,7 +1064,7 @@ CMICmdCmdVarListChildren::Execute(void) // Throws: None. //-- bool -CMICmdCmdVarListChildren::Acknowledge(void) +CMICmdCmdVarListChildren::Acknowledge() { if (m_bValueValid) { @@ -1085,14 +1072,11 @@ CMICmdCmdVarListChildren::Acknowledge(void) const CMIUtilString strNumChild(CMIUtilString::Format("%u", m_nChildren)); const CMICmnMIValueConst miValueConst(strNumChild); CMICmnMIValueResult miValueResult("numchild", miValueConst); - bool bOk = MIstatus::success; if (m_nChildren != 0) - bOk = bOk && miValueResult.Add("children", m_miValueList); + miValueResult.Add("children", m_miValueList); const CMIUtilString strHasMore(m_bHasMore ? "1" : "0"); const CMICmnMIValueConst miValueConst2(strHasMore); - bOk = bOk && miValueResult.Add("has_more", miValueConst2); - if (!bOk) - return MIstatus::failure; + miValueResult.Add("has_more", miValueConst2); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult); m_miResultRecord = miRecordResult; @@ -1118,7 +1102,7 @@ CMICmdCmdVarListChildren::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdVarListChildren::CreateSelf(void) +CMICmdCmdVarListChildren::CreateSelf() { return new CMICmdCmdVarListChildren(); } @@ -1134,7 +1118,7 @@ CMICmdCmdVarListChildren::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarEvaluateExpression::CMICmdCmdVarEvaluateExpression(void) +CMICmdCmdVarEvaluateExpression::CMICmdCmdVarEvaluateExpression() : m_bValueValid(true) , m_constStrArgFormatSpec("-f") , m_constStrArgName("name") @@ -1153,7 +1137,7 @@ CMICmdCmdVarEvaluateExpression::CMICmdCmdVarEvaluateExpression(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarEvaluateExpression::~CMICmdCmdVarEvaluateExpression(void) +CMICmdCmdVarEvaluateExpression::~CMICmdCmdVarEvaluateExpression() { } @@ -1167,12 +1151,12 @@ CMICmdCmdVarEvaluateExpression::~CMICmdCmdVarEvaluateExpression(void) // Throws: None. //-- bool -CMICmdCmdVarEvaluateExpression::ParseArgs(void) +CMICmdCmdVarEvaluateExpression::ParseArgs() { - bool bOk = m_setCmdArgs.Add( - *(new CMICmdArgValOptionShort(m_constStrArgFormatSpec, false, false, CMICmdArgValListBase::eArgValType_String, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add( + new CMICmdArgValOptionShort(m_constStrArgFormatSpec, false, false, CMICmdArgValListBase::eArgValType_String, 1)); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -1185,7 +1169,7 @@ CMICmdCmdVarEvaluateExpression::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdVarEvaluateExpression::Execute(void) +CMICmdCmdVarEvaluateExpression::Execute() { CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName); @@ -1218,7 +1202,7 @@ CMICmdCmdVarEvaluateExpression::Execute(void) // Throws: None. //-- bool -CMICmdCmdVarEvaluateExpression::Acknowledge(void) +CMICmdCmdVarEvaluateExpression::Acknowledge() { if (m_bValueValid) { @@ -1247,7 +1231,7 @@ CMICmdCmdVarEvaluateExpression::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdVarEvaluateExpression::CreateSelf(void) +CMICmdCmdVarEvaluateExpression::CreateSelf() { return new CMICmdCmdVarEvaluateExpression(); } @@ -1263,7 +1247,7 @@ CMICmdCmdVarEvaluateExpression::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarInfoPathExpression::CMICmdCmdVarInfoPathExpression(void) +CMICmdCmdVarInfoPathExpression::CMICmdCmdVarInfoPathExpression() : m_bValueValid(true) , m_constStrArgName("name") { @@ -1281,7 +1265,7 @@ CMICmdCmdVarInfoPathExpression::CMICmdCmdVarInfoPathExpression(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarInfoPathExpression::~CMICmdCmdVarInfoPathExpression(void) +CMICmdCmdVarInfoPathExpression::~CMICmdCmdVarInfoPathExpression() { } @@ -1295,10 +1279,10 @@ CMICmdCmdVarInfoPathExpression::~CMICmdCmdVarInfoPathExpression(void) // Throws: None. //-- bool -CMICmdCmdVarInfoPathExpression::ParseArgs(void) +CMICmdCmdVarInfoPathExpression::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -1311,7 +1295,7 @@ CMICmdCmdVarInfoPathExpression::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdVarInfoPathExpression::Execute(void) +CMICmdCmdVarInfoPathExpression::Execute() { CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName); @@ -1380,7 +1364,7 @@ CMICmdCmdVarInfoPathExpression::Execute(void) // Throws: None. //-- bool -CMICmdCmdVarInfoPathExpression::Acknowledge(void) +CMICmdCmdVarInfoPathExpression::Acknowledge() { if (m_bValueValid) { @@ -1408,7 +1392,7 @@ CMICmdCmdVarInfoPathExpression::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdVarInfoPathExpression::CreateSelf(void) +CMICmdCmdVarInfoPathExpression::CreateSelf() { return new CMICmdCmdVarInfoPathExpression(); } @@ -1424,7 +1408,7 @@ CMICmdCmdVarInfoPathExpression::CreateSelf(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarShowAttributes::CMICmdCmdVarShowAttributes(void) +CMICmdCmdVarShowAttributes::CMICmdCmdVarShowAttributes() : m_constStrArgName("name") { // Command factory matches this name with that received from the stdin stream @@ -1441,7 +1425,7 @@ CMICmdCmdVarShowAttributes::CMICmdCmdVarShowAttributes(void) // Return: None. // Throws: None. //-- -CMICmdCmdVarShowAttributes::~CMICmdCmdVarShowAttributes(void) +CMICmdCmdVarShowAttributes::~CMICmdCmdVarShowAttributes() { } @@ -1455,10 +1439,10 @@ CMICmdCmdVarShowAttributes::~CMICmdCmdVarShowAttributes(void) // Throws: None. //-- bool -CMICmdCmdVarShowAttributes::ParseArgs(void) +CMICmdCmdVarShowAttributes::ParseArgs() { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true))); - return (bOk && ParseValidateCmdOptions()); + m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgName, true, true)); + return ParseValidateCmdOptions(); } //++ ------------------------------------------------------------------------------------ @@ -1471,7 +1455,7 @@ CMICmdCmdVarShowAttributes::ParseArgs(void) // Throws: None. //-- bool -CMICmdCmdVarShowAttributes::Execute(void) +CMICmdCmdVarShowAttributes::Execute() { CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName); @@ -1496,7 +1480,7 @@ CMICmdCmdVarShowAttributes::Execute(void) // Throws: None. //-- bool -CMICmdCmdVarShowAttributes::Acknowledge(void) +CMICmdCmdVarShowAttributes::Acknowledge() { // MI output: "%s^done,status=\"editable\"]" const CMICmnMIValueConst miValueConst("editable"); @@ -1516,7 +1500,7 @@ CMICmdCmdVarShowAttributes::Acknowledge(void) // Throws: None. //-- CMICmdBase * -CMICmdCmdVarShowAttributes::CreateSelf(void) +CMICmdCmdVarShowAttributes::CreateSelf() { return new CMICmdCmdVarShowAttributes(); } diff --git a/tools/lldb-mi/MICmdCmdVar.h b/tools/lldb-mi/MICmdCmdVar.h index 9f5ad1c3a11c..a6790877346f 100644 --- a/tools/lldb-mi/MICmdCmdVar.h +++ b/tools/lldb-mi/MICmdCmdVar.h @@ -41,32 +41,29 @@ class CMICmnLLDBDebugSessionInfoVarObj; //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "var-create". -// Gotchas: None. -// Authors: Illya Rudkin 24/03/2014. -// Changes: None. //-- class CMICmdCmdVarCreate : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdVarCreate(void); + /* ctor */ CMICmdCmdVarCreate(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // Overridden: public: // From CMICmnBase - /* dtor */ ~CMICmdCmdVarCreate(void) override; + /* dtor */ ~CMICmdCmdVarCreate() override; // Methods: private: @@ -81,9 +78,6 @@ class CMICmdCmdVarCreate : public CMICmdBase bool m_bValid; // True = Variable is valid, false = not valid CMIUtilString m_strExpression; CMIUtilString m_strValue; - const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option - const CMIUtilString m_constStrArgThreadGroup; // Not specified in MI spec but Eclipse gives this option - const CMIUtilString m_constStrArgFrame; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgName; const CMIUtilString m_constStrArgFrameAddr; const CMIUtilString m_constStrArgExpression; @@ -92,37 +86,34 @@ class CMICmdCmdVarCreate : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "var-update". -// Gotchas: None. -// Authors: Illya Rudkin 25/03/2014. -// Changes: None. //-- class CMICmdCmdVarUpdate : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdVarUpdate(void); + /* ctor */ CMICmdCmdVarUpdate(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // Overridden: public: // From CMICmnBase - /* dtor */ ~CMICmdCmdVarUpdate(void) override; + /* dtor */ ~CMICmdCmdVarUpdate() override; // Methods: private: bool ExamineSBValueForChange(lldb::SBValue &vrwValue, bool &vrwbChanged); - bool MIFormResponse(const CMIUtilString &vrStrVarName, const char *const vpValue, const CMIUtilString &vrStrScope); + void MIFormResponse(const CMIUtilString &vrStrVarName, const char *const vpValue, const CMIUtilString &vrStrScope); // Attribute: private: @@ -135,29 +126,26 @@ class CMICmdCmdVarUpdate : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "var-delete". -// Gotchas: None. -// Authors: Illya Rudkin 25/03/2014. -// Changes: None. //-- class CMICmdCmdVarDelete : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdVarDelete(void); + /* ctor */ CMICmdCmdVarDelete(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdVarDelete(void) override; + /* dtor */ ~CMICmdCmdVarDelete() override; // Attribute: private: @@ -167,29 +155,26 @@ class CMICmdCmdVarDelete : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "var-assign". -// Gotchas: None. -// Authors: Illya Rudkin 25/03/2014. -// Changes: None. //-- class CMICmdCmdVarAssign : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdVarAssign(void); + /* ctor */ CMICmdCmdVarAssign(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdVarAssign(void) override; + /* dtor */ ~CMICmdCmdVarAssign() override; // Attributes: private: @@ -202,29 +187,26 @@ class CMICmdCmdVarAssign : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "var-set-format". -// Gotchas: None. -// Authors: Illya Rudkin 26/03/2014. -// Changes: None. //-- class CMICmdCmdVarSetFormat : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdVarSetFormat(void); + /* ctor */ CMICmdCmdVarSetFormat(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdVarSetFormat(void) override; + /* dtor */ ~CMICmdCmdVarSetFormat() override; // Attributes: private: @@ -236,29 +218,26 @@ class CMICmdCmdVarSetFormat : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "var-list-children". -// Gotchas: None. -// Authors: Illya Rudkin 26/03/2014. -// Changes: None. //-- class CMICmdCmdVarListChildren : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdVarListChildren(void); + /* ctor */ CMICmdCmdVarListChildren(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdVarListChildren(void) override; + /* dtor */ ~CMICmdCmdVarListChildren() override; // Attributes: private: @@ -275,29 +254,26 @@ class CMICmdCmdVarListChildren : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "var-evaluate-expression". -// Gotchas: None. -// Authors: Illya Rudkin 26/03/2014. -// Changes: None. //-- class CMICmdCmdVarEvaluateExpression : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdVarEvaluateExpression(void); + /* ctor */ CMICmdCmdVarEvaluateExpression(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdVarEvaluateExpression(void) override; + /* dtor */ ~CMICmdCmdVarEvaluateExpression() override; // Attributes: private: @@ -310,29 +286,26 @@ class CMICmdCmdVarEvaluateExpression : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "var-info-path-expression". -// Gotchas: None. -// Authors: Illya Rudkin 26/03/2014. -// Changes: None. //-- class CMICmdCmdVarInfoPathExpression : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdVarInfoPathExpression(void); + /* ctor */ CMICmdCmdVarInfoPathExpression(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdVarInfoPathExpression(void) override; + /* dtor */ ~CMICmdCmdVarInfoPathExpression() override; // Attributes: private: @@ -344,29 +317,26 @@ class CMICmdCmdVarInfoPathExpression : public CMICmdBase //++ ============================================================================ // Details: MI command class. MI commands derived from the command base class. // *this class implements MI command "var-show-attributes". -// Gotchas: None. -// Authors: Illya Rudkin 19/05/2014. -// Changes: None. //-- class CMICmdCmdVarShowAttributes : public CMICmdBase { // Statics: public: // Required by the CMICmdFactory when registering *this command - static CMICmdBase *CreateSelf(void); + static CMICmdBase *CreateSelf(); // Methods: public: - /* ctor */ CMICmdCmdVarShowAttributes(void); + /* ctor */ CMICmdCmdVarShowAttributes(); // Overridden: public: // From CMICmdInvoker::ICmd - bool Execute(void) override; - bool Acknowledge(void) override; - bool ParseArgs(void) override; + bool Execute() override; + bool Acknowledge() override; + bool ParseArgs() override; // From CMICmnBase - /* dtor */ ~CMICmdCmdVarShowAttributes(void) override; + /* dtor */ ~CMICmdCmdVarShowAttributes() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmdCommands.cpp b/tools/lldb-mi/MICmdCommands.cpp index 90a5d651f2af..e97cc72f0770 100644 --- a/tools/lldb-mi/MICmdCommands.cpp +++ b/tools/lldb-mi/MICmdCommands.cpp @@ -41,7 +41,7 @@ namespace MICmnCommands { -template <typename T> static bool Register(void); +template <typename T> static bool Register(); } //++ ------------------------------------------------------------------------------------ @@ -53,7 +53,7 @@ template <typename T> static bool Register(void); //-- template <typename T> static bool -MICmnCommands::Register(void) +MICmnCommands::Register() { static CMICmdFactory &rCmdFactory = CMICmdFactory::Instance(); const CMIUtilString strMiCmd = T().GetMiCmd(); @@ -70,7 +70,7 @@ MICmnCommands::Register(void) // Throws: None. //-- bool -MICmnCommands::RegisterAll(void) +MICmnCommands::RegisterAll() { bool bOk = MIstatus::success; diff --git a/tools/lldb-mi/MICmdCommands.h b/tools/lldb-mi/MICmdCommands.h index a99d09c8057a..27f128ef4bd4 100644 --- a/tools/lldb-mi/MICmdCommands.h +++ b/tools/lldb-mi/MICmdCommands.h @@ -15,9 +15,6 @@ namespace MICmnCommands //++ ============================================================================ // Details: MI Command are instantiated and registered automatically with the // Command Factory -// Gotchas: None. -// Authors: Illya Rudkin 18/02/2014. -// Changes: None. //-- -bool RegisterAll(void); +bool RegisterAll(); } diff --git a/tools/lldb-mi/MICmdData.h b/tools/lldb-mi/MICmdData.h index d58de903a68f..dcd5754617f5 100644 --- a/tools/lldb-mi/MICmdData.h +++ b/tools/lldb-mi/MICmdData.h @@ -15,18 +15,15 @@ //++ ============================================================================ // Details: MI command metadata. Holds the command's name, MI number and options // as found on stdin. Holds the command's MI output (written to stdout). -// Gotchas: None. -// Authors: Illya Rudkin 18/02/2014. -// Changes: None. //-- struct SMICmdData { - SMICmdData(void) + SMICmdData() : id(0) , bCmdValid(false) , bCmdExecutedSuccessfully(false) , bMIOldStyle(false) - , bHasResultRecordExtra(false){}; + , bHasResultRecordExtra(false){} MIuint id; // A command's unique ID i.e. GUID CMIUtilString strMiCmdToken; // The command's MI token (a number) @@ -43,7 +40,7 @@ struct SMICmdData bHasResultRecordExtra; // True = Yes command produced additional MI output to its 1 line response, false = no extra MI output formed void - Clear(void) + Clear() { id = 0; strMiCmdToken.clear(); diff --git a/tools/lldb-mi/MICmdFactory.cpp b/tools/lldb-mi/MICmdFactory.cpp index 717a497a96be..e2a8b5bc2cae 100644 --- a/tools/lldb-mi/MICmdFactory.cpp +++ b/tools/lldb-mi/MICmdFactory.cpp @@ -21,7 +21,7 @@ // Return: None. // Throws: None. //-- -CMICmdFactory::CMICmdFactory(void) +CMICmdFactory::CMICmdFactory() { } @@ -32,7 +32,7 @@ CMICmdFactory::CMICmdFactory(void) // Return: None. // Throws: None. //-- -CMICmdFactory::~CMICmdFactory(void) +CMICmdFactory::~CMICmdFactory() { Shutdown(); } @@ -46,7 +46,7 @@ CMICmdFactory::~CMICmdFactory(void) // Throws: None. //-- bool -CMICmdFactory::Initialize(void) +CMICmdFactory::Initialize() { m_clientUsageRefCnt++; @@ -69,7 +69,7 @@ CMICmdFactory::Initialize(void) // Throws: None. //-- bool -CMICmdFactory::Shutdown(void) +CMICmdFactory::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -194,8 +194,6 @@ CMICmdFactory::CmdExist(const CMIUtilString &vMiCmd) const bool CMICmdFactory::CmdCreate(const CMIUtilString &vMiCmd, const SMICmdData &vCmdData, CMICmdBase *&vpNewCmd) { - bool bOk = MIstatus::success; - vpNewCmd = nullptr; if (!IsValid(vMiCmd)) @@ -217,9 +215,8 @@ CMICmdFactory::CmdCreate(const CMIUtilString &vMiCmd, const SMICmdData &vCmdData SMICmdData cmdData(vCmdData); cmdData.id = pCmd->GetGUID(); - bOk = pCmd->SetCmdData(cmdData); - if (bOk) - vpNewCmd = pCmd; + pCmd->SetCmdData(cmdData); + vpNewCmd = pCmd; - return bOk; + return MIstatus::success; } diff --git a/tools/lldb-mi/MICmdFactory.h b/tools/lldb-mi/MICmdFactory.h index 9a5e07690a34..99f6f0cb2396 100644 --- a/tools/lldb-mi/MICmdFactory.h +++ b/tools/lldb-mi/MICmdFactory.h @@ -25,9 +25,6 @@ struct SMICmdData; // MI application understands to interpret. Creates commands objects. // The Command Factory is carried out in the main thread. // A singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 19/02/2014. -// Changes: None. //-- class CMICmdFactory : public CMICmnBase, public MI::ISingleton<CMICmdFactory> { @@ -35,7 +32,7 @@ class CMICmdFactory : public CMICmnBase, public MI::ISingleton<CMICmdFactory> // Typedefs: public: - typedef CMICmdBase *(*CmdCreatorFnPtr)(void); + typedef CMICmdBase *(*CmdCreatorFnPtr)(); // Class: public: @@ -45,25 +42,25 @@ class CMICmdFactory : public CMICmnBase, public MI::ISingleton<CMICmdFactory> class ICmd { public: - virtual const CMIUtilString &GetMiCmd(void) const = 0; - virtual CmdCreatorFnPtr GetCmdCreatorFn(void) const = 0; + virtual const CMIUtilString &GetMiCmd() const = 0; + virtual CmdCreatorFnPtr GetCmdCreatorFn() const = 0; // virtual CMICmdBase * CreateSelf( void ) = 0; // Not possible as require a static creator // function in the command class, here for awareness - /* dtor */ virtual ~ICmd(void){}; + /* dtor */ virtual ~ICmd(){} }; // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; bool CmdRegister(const CMIUtilString &vMiCmd, CmdCreatorFnPtr vCmdCreateFn); bool CmdCreate(const CMIUtilString &vMiCmd, const SMICmdData &vCmdData, CMICmdBase *&vpNewCmd); bool CmdExist(const CMIUtilString &vMiCmd) const; // Methods: private: - /* ctor */ CMICmdFactory(void); + /* ctor */ CMICmdFactory(); /* ctor */ CMICmdFactory(const CMICmdFactory &); void operator=(const CMICmdFactory &); @@ -73,7 +70,7 @@ class CMICmdFactory : public CMICmnBase, public MI::ISingleton<CMICmdFactory> // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmdFactory(void) override; + /* dtor */ ~CMICmdFactory() override; // Typedefs: private: diff --git a/tools/lldb-mi/MICmdInterpreter.cpp b/tools/lldb-mi/MICmdInterpreter.cpp index 3c5285fc8cc8..1abcc9a3f427 100644 --- a/tools/lldb-mi/MICmdInterpreter.cpp +++ b/tools/lldb-mi/MICmdInterpreter.cpp @@ -18,7 +18,7 @@ // Return: None. // Throws: None. //-- -CMICmdInterpreter::CMICmdInterpreter(void) +CMICmdInterpreter::CMICmdInterpreter() : m_rCmdFactory(CMICmdFactory::Instance()) { } @@ -30,7 +30,7 @@ CMICmdInterpreter::CMICmdInterpreter(void) // Return: None. // Throws: None. //-- -CMICmdInterpreter::~CMICmdInterpreter(void) +CMICmdInterpreter::~CMICmdInterpreter() { Shutdown(); } @@ -44,7 +44,7 @@ CMICmdInterpreter::~CMICmdInterpreter(void) // Throws: None. //-- bool -CMICmdInterpreter::Initialize(void) +CMICmdInterpreter::Initialize() { m_clientUsageRefCnt++; @@ -65,7 +65,7 @@ CMICmdInterpreter::Initialize(void) // Throws: None. //-- bool -CMICmdInterpreter::Shutdown(void) +CMICmdInterpreter::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -160,10 +160,10 @@ CMICmdInterpreter::MiHasCmdTokenEndingHyphen(const CMIUtilString &vTextLine) if (MiHasCmdTokenPresent(vTextLine)) { const std::string strNum = vTextLine.substr(0, nPos); - if (!CMIUtilString(strNum.c_str()).IsNumber()) + if (!CMIUtilString(strNum).IsNumber()) return false; - m_miCmdData.strMiCmdToken = strNum.c_str(); + m_miCmdData.strMiCmdToken = strNum; } m_miCmdData.bMIOldStyle = false; @@ -256,20 +256,20 @@ CMICmdInterpreter::MiHasCmd(const CMIUtilString &vTextLine) { if (nPos2 == nLen) return false; - const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nPos2 - nPos - 1).c_str()); + const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nPos2 - nPos - 1)); if (cmd.empty()) return false; m_miCmdData.strMiCmd = cmd; if (nPos2 < nLen) - m_miCmdData.strMiCmdOption = CMIUtilString(vTextLine.substr(nPos2 + 1, nLen - nPos2 - 1).c_str()); + m_miCmdData.strMiCmdOption = CMIUtilString(vTextLine.substr(nPos2 + 1, nLen - nPos2 - 1)); bFoundCmd = true; } else { - const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nLen - nPos - 1).c_str()); + const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nLen - nPos - 1)); if (cmd.empty()) return false; m_miCmdData.strMiCmd = cmd; @@ -291,7 +291,7 @@ CMICmdInterpreter::MiHasCmd(const CMIUtilString &vTextLine) // Throws: None. //-- const SMICmdData & -CMICmdInterpreter::MiGetCmdData(void) const +CMICmdInterpreter::MiGetCmdData() const { return m_miCmdData; } diff --git a/tools/lldb-mi/MICmdInterpreter.h b/tools/lldb-mi/MICmdInterpreter.h index e24308484d23..5aa9445c97c0 100644 --- a/tools/lldb-mi/MICmdInterpreter.h +++ b/tools/lldb-mi/MICmdInterpreter.h @@ -23,9 +23,6 @@ class CMICmdFactory; // matches Machine Interface (MI) format and commands defined in the // MI application. // A singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 18/02/2014. -// Changes: None. //-- class CMICmdInterpreter : public CMICmnBase, public MI::ISingleton<CMICmdInterpreter> { @@ -35,13 +32,13 @@ class CMICmdInterpreter : public CMICmnBase, public MI::ISingleton<CMICmdInterpr public: // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; bool ValidateIsMi(const CMIUtilString &vTextLine, bool &vwbYesValid, bool &vwbCmdNotInCmdFactor, SMICmdData &rwCmdData); // Methods: private: - /* ctor */ CMICmdInterpreter(void); + /* ctor */ CMICmdInterpreter(); /* ctor */ CMICmdInterpreter(const CMICmdInterpreter &); void operator=(const CMICmdInterpreter &); @@ -55,7 +52,7 @@ class CMICmdInterpreter : public CMICmnBase, public MI::ISingleton<CMICmdInterpr // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmdInterpreter(void) override; + /* dtor */ ~CMICmdInterpreter() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmdInvoker.cpp b/tools/lldb-mi/MICmdInvoker.cpp index 9f82e92dc4bb..124a82d162e7 100644 --- a/tools/lldb-mi/MICmdInvoker.cpp +++ b/tools/lldb-mi/MICmdInvoker.cpp @@ -22,7 +22,7 @@ // Return: None. // Throws: None. //-- -CMICmdInvoker::CMICmdInvoker(void) +CMICmdInvoker::CMICmdInvoker() : m_rStreamOut(CMICmnStreamStdout::Instance()) { } @@ -34,7 +34,7 @@ CMICmdInvoker::CMICmdInvoker(void) // Return: None. // Throws: None. //-- -CMICmdInvoker::~CMICmdInvoker(void) +CMICmdInvoker::~CMICmdInvoker() { Shutdown(); } @@ -48,7 +48,7 @@ CMICmdInvoker::~CMICmdInvoker(void) // Throws: None. //-- bool -CMICmdInvoker::Initialize(void) +CMICmdInvoker::Initialize() { m_clientUsageRefCnt++; @@ -69,7 +69,7 @@ CMICmdInvoker::Initialize(void) // Throws: None. //-- bool -CMICmdInvoker::Shutdown(void) +CMICmdInvoker::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -92,7 +92,7 @@ CMICmdInvoker::Shutdown(void) // Throws: None. //-- void -CMICmdInvoker::CmdDeleteAll(void) +CMICmdInvoker::CmdDeleteAll() { CMICmdMgr &rMgr = CMICmdMgr::Instance(); MapCmdIdToCmd_t::const_iterator it = m_mapCmdIdToCmd.begin(); @@ -189,16 +189,20 @@ CMICmdInvoker::CmdExecute(CMICmdBase &vCmd) { bool bOk = CmdAdd(vCmd); - if (bOk && !vCmd.ParseArgs()) + if (bOk) { - // Report command execution failed - const SMICmdData cmdData(vCmd.GetCmdData()); - CmdStdout(cmdData); - CmdCauseAppExit(vCmd); - CmdDelete(cmdData.id); - - // Proceed to wait or execute next command - return MIstatus::success; + vCmd.AddCommonArgs(); + if (!vCmd.ParseArgs()) + { + // Report command execution failed + const SMICmdData cmdData(vCmd.GetCmdData()); + CmdStdout(cmdData); + CmdCauseAppExit(vCmd); + CmdDelete(cmdData.id); + + // Proceed to wait or execute next command + return MIstatus::success; + } } if (bOk && !vCmd.Execute()) diff --git a/tools/lldb-mi/MICmdInvoker.h b/tools/lldb-mi/MICmdInvoker.h index b178d4322577..d70a5296c9f3 100644 --- a/tools/lldb-mi/MICmdInvoker.h +++ b/tools/lldb-mi/MICmdInvoker.h @@ -36,9 +36,6 @@ class CMICmnStreamStdout; // The Invoker takes ownership of any commands created which means it // is the only object to delete them when a command is finished working. // A singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 19/02/2014. -// Changes: None. //-- class CMICmdInvoker : public CMICmnBase, public CMICmdMgrSetCmdDeleteCallback::ICallback, public MI::ISingleton<CMICmdInvoker> { @@ -52,24 +49,24 @@ class CMICmdInvoker : public CMICmnBase, public CMICmdMgrSetCmdDeleteCallback::I class ICmd { public: - virtual bool Acknowledge(void) = 0; - virtual bool Execute(void) = 0; - virtual bool ParseArgs(void) = 0; - virtual bool SetCmdData(const SMICmdData &vCmdData) = 0; - virtual const SMICmdData &GetCmdData(void) const = 0; - virtual const CMIUtilString &GetErrorDescription(void) const = 0; - virtual void CmdFinishedTellInvoker(void) const = 0; - virtual const CMIUtilString &GetMIResultRecord(void) const = 0; - virtual const CMIUtilString &GetMIResultRecordExtra(void) const = 0; - virtual bool HasMIResultRecordExtra(void) const = 0; + virtual bool Acknowledge() = 0; + virtual bool Execute() = 0; + virtual bool ParseArgs() = 0; + virtual void SetCmdData(const SMICmdData &vCmdData) = 0; + virtual const SMICmdData &GetCmdData() const = 0; + virtual const CMIUtilString &GetErrorDescription() const = 0; + virtual void CmdFinishedTellInvoker() const = 0; + virtual const CMIUtilString &GetMIResultRecord() const = 0; + virtual const CMIUtilString &GetMIResultRecordExtra() const = 0; + virtual bool HasMIResultRecordExtra() const = 0; - /* dtor */ virtual ~ICmd(void){}; + /* dtor */ virtual ~ICmd(){} }; // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; bool CmdExecute(CMICmdBase &vCmd); bool CmdExecuteFinished(CMICmdBase &vCmd); @@ -80,10 +77,10 @@ class CMICmdInvoker : public CMICmnBase, public CMICmdMgrSetCmdDeleteCallback::I // Methods: private: - /* ctor */ CMICmdInvoker(void); + /* ctor */ CMICmdInvoker(); /* ctor */ CMICmdInvoker(const CMICmdInvoker &); void operator=(const CMICmdInvoker &); - void CmdDeleteAll(void); + void CmdDeleteAll(); bool CmdDelete(const MIuint vCmdId, const bool vbYesDeleteCmd = false); bool CmdAdd(const CMICmdBase &vCmd); bool CmdStdout(const SMICmdData &vCmdData) const; @@ -92,7 +89,7 @@ class CMICmdInvoker : public CMICmnBase, public CMICmdMgrSetCmdDeleteCallback::I // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmdInvoker(void) override; + /* dtor */ ~CMICmdInvoker() override; // From CMICmdMgrSetCmdDeleteCallback::ICallback void Delete(SMICmdData &vCmd) override; diff --git a/tools/lldb-mi/MICmdMgr.cpp b/tools/lldb-mi/MICmdMgr.cpp index 76dbff69dbe7..449be44e1152 100644 --- a/tools/lldb-mi/MICmdMgr.cpp +++ b/tools/lldb-mi/MICmdMgr.cpp @@ -25,7 +25,7 @@ // Return: None. // Throws: None. //-- -CMICmdMgr::CMICmdMgr(void) +CMICmdMgr::CMICmdMgr() : m_interpretor(CMICmdInterpreter::Instance()) , m_factory(CMICmdFactory::Instance()) , m_invoker(CMICmdInvoker::Instance()) @@ -39,7 +39,7 @@ CMICmdMgr::CMICmdMgr(void) // Return: None. // Throws: None. //-- -CMICmdMgr::~CMICmdMgr(void) +CMICmdMgr::~CMICmdMgr() { Shutdown(); } @@ -53,7 +53,7 @@ CMICmdMgr::~CMICmdMgr(void) // Throws: None. //-- bool -CMICmdMgr::Initialize(void) +CMICmdMgr::Initialize() { m_clientUsageRefCnt++; @@ -102,7 +102,7 @@ CMICmdMgr::Initialize(void) // Throws: None. //-- bool -CMICmdMgr::Shutdown(void) +CMICmdMgr::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; diff --git a/tools/lldb-mi/MICmdMgr.h b/tools/lldb-mi/MICmdMgr.h index 4956d5c3a376..31363594a9de 100644 --- a/tools/lldb-mi/MICmdMgr.h +++ b/tools/lldb-mi/MICmdMgr.h @@ -30,9 +30,6 @@ class CMICmdBase; // Command Invoker, Command Factory and Command Monitor while independent // units are overseen/managed by *this manager. // A singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 19/02/2014. -// Changes: None. //-- class CMICmdMgr : public CMICmnBase, public MI::ISingleton<CMICmdMgr> { @@ -40,8 +37,8 @@ class CMICmdMgr : public CMICmnBase, public MI::ISingleton<CMICmdMgr> // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; bool CmdInterpret(const CMIUtilString &vTextLine, bool &vwbYesValid, bool &vwbCmdNotInCmdFactor, SMICmdData &rwCmdData); bool CmdExecute(const SMICmdData &vCmdData); @@ -51,14 +48,14 @@ class CMICmdMgr : public CMICmnBase, public MI::ISingleton<CMICmdMgr> // Methods: private: - /* ctor */ CMICmdMgr(void); + /* ctor */ CMICmdMgr(); /* ctor */ CMICmdMgr(const CMICmdMgr &); void operator=(const CMICmdMgr &); // Overridden: public: // From CMICmnBase - /* dtor */ ~CMICmdMgr(void) override; + /* dtor */ ~CMICmdMgr() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp index 3f2ccfd10ce6..3bef535390f7 100644 --- a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp +++ b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp @@ -20,7 +20,7 @@ namespace CMICmdMgrSetCmdDeleteCallback // Return: None. // Throws: None. //-- -CSetClients::CSetClients(void) +CSetClients::CSetClients() : m_bClientUnregistered(false) { } @@ -32,7 +32,7 @@ CSetClients::CSetClients(void) // Return: None. // Throws: None. //-- -CSetClients::~CSetClients(void) +CSetClients::~CSetClients() { } diff --git a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h index 1c9be826c516..7e95d67d8716 100644 --- a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h +++ b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h @@ -28,16 +28,13 @@ namespace CMICmdMgrSetCmdDeleteCallback // inherit this interface and register interest in command object // deletion. An object deleting a command must not do it itself but call // the Command Manager CmdDelete() function to delete a command object. -// Gotchas: None. -// Authors: Illya Rudkin 21/02/2014. -// Changes: None. //-- class ICallback { public: virtual void Delete(SMICmdData &vCmd) = 0; - /* dtor */ virtual ~ICallback(void){}; + /* dtor */ virtual ~ICallback(){} }; //++ ============================================================================ @@ -47,15 +44,12 @@ class ICallback // Manager to delete the command object. In so do all other registered // objects get called to about the deletion including the object wanting // to do the delete in the first place. -// Gotchas: None. -// Authors: Illya Rudkin 21/02/2014. -// Changes: None. //-- class CSetClients : public std::set<class ICallback *>, public CMICmnBase { // Methods: public: - /* ctor */ CSetClients(void); + /* ctor */ CSetClients(); bool Register(class ICallback &vObject); bool Unregister(class ICallback &vObject); @@ -64,7 +58,7 @@ class CSetClients : public std::set<class ICallback *>, public CMICmnBase // Overridden: public: // From CMICmnBase - /* dtor */ ~CSetClients(void) override; + /* dtor */ ~CSetClients() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmnBase.cpp b/tools/lldb-mi/MICmnBase.cpp index 0d9eda70f0b0..1240df7802d2 100644 --- a/tools/lldb-mi/MICmnBase.cpp +++ b/tools/lldb-mi/MICmnBase.cpp @@ -22,7 +22,7 @@ // Return: None. // Throws: None. //-- -CMICmnBase::CMICmnBase(void) +CMICmnBase::CMICmnBase() : m_strMILastErrorDescription(CMIUtilString()) , m_bInitialized(false) , m_pLog(&CMICmnLog::Instance()) @@ -37,7 +37,7 @@ CMICmnBase::CMICmnBase(void) // Return: None. // Throws: None. //-- -CMICmnBase::~CMICmnBase(void) +CMICmnBase::~CMICmnBase() { m_pLog = NULL; } @@ -50,7 +50,7 @@ CMICmnBase::~CMICmnBase(void) // Throws: None. //-- bool -CMICmnBase::HaveErrorDescription(void) const +CMICmnBase::HaveErrorDescription() const { return m_strMILastErrorDescription.empty(); } @@ -63,7 +63,7 @@ CMICmnBase::HaveErrorDescription(void) const // Throws: None. //-- const CMIUtilString & -CMICmnBase::GetErrorDescription(void) const +CMICmnBase::GetErrorDescription() const { return m_strMILastErrorDescription; } @@ -111,7 +111,7 @@ CMICmnBase::SetErrorDescriptionNoLog(const CMIUtilString &vrTxt) const // Throws: None. //-- void -CMICmnBase::ClrErrorDescription(void) const +CMICmnBase::ClrErrorDescription() const { m_strMILastErrorDescription.clear(); } diff --git a/tools/lldb-mi/MICmnBase.h b/tools/lldb-mi/MICmnBase.h index d2e2bcdf10d2..befadbeeba88 100644 --- a/tools/lldb-mi/MICmnBase.h +++ b/tools/lldb-mi/MICmnBase.h @@ -18,26 +18,23 @@ class CMICmnLog; //++ ============================================================================ // Details: MI common code implementation base class. -// Gotchas: None. -// Authors: Illya Rudkin 28/01/2014. -// Changes: None. //-- class CMICmnBase { // Methods: public: - /* ctor */ CMICmnBase(void); + /* ctor */ CMICmnBase(); - bool HaveErrorDescription(void) const; - const CMIUtilString &GetErrorDescription(void) const; + bool HaveErrorDescription() const; + const CMIUtilString &GetErrorDescription() const; void SetErrorDescription(const CMIUtilString &vrTxt) const; void SetErrorDescriptionn(const CMIUtilString vFormat, ...) const; void SetErrorDescriptionNoLog(const CMIUtilString &vrTxt) const; - void ClrErrorDescription(void) const; + void ClrErrorDescription() const; // Overrideable: public: - /* dtor */ virtual ~CMICmnBase(void); + /* dtor */ virtual ~CMICmnBase(); // Attributes: protected: diff --git a/tools/lldb-mi/MICmnLLDBBroadcaster.cpp b/tools/lldb-mi/MICmnLLDBBroadcaster.cpp index 8bad24313b78..1d51abd1320d 100644 --- a/tools/lldb-mi/MICmnLLDBBroadcaster.cpp +++ b/tools/lldb-mi/MICmnLLDBBroadcaster.cpp @@ -17,7 +17,7 @@ // Return: None. // Throws: None. //-- -CMICmnLLDBBroadcaster::CMICmnLLDBBroadcaster(void) +CMICmnLLDBBroadcaster::CMICmnLLDBBroadcaster() : lldb::SBBroadcaster("MI driver") { } @@ -29,7 +29,7 @@ CMICmnLLDBBroadcaster::CMICmnLLDBBroadcaster(void) // Return: None. // Throws: None. //-- -CMICmnLLDBBroadcaster::~CMICmnLLDBBroadcaster(void) +CMICmnLLDBBroadcaster::~CMICmnLLDBBroadcaster() { Shutdown(); } @@ -43,7 +43,7 @@ CMICmnLLDBBroadcaster::~CMICmnLLDBBroadcaster(void) // Throws: None. //-- bool -CMICmnLLDBBroadcaster::Initialize(void) +CMICmnLLDBBroadcaster::Initialize() { m_clientUsageRefCnt++; @@ -64,7 +64,7 @@ CMICmnLLDBBroadcaster::Initialize(void) // Throws: None. //-- bool -CMICmnLLDBBroadcaster::Shutdown(void) +CMICmnLLDBBroadcaster::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; diff --git a/tools/lldb-mi/MICmnLLDBBroadcaster.h b/tools/lldb-mi/MICmnLLDBBroadcaster.h index dc0de47d3bb3..09b95f482a79 100644 --- a/tools/lldb-mi/MICmnLLDBBroadcaster.h +++ b/tools/lldb-mi/MICmnLLDBBroadcaster.h @@ -21,9 +21,6 @@ // *** not // // A singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 28/02/2014. -// Changes: None. //-- class CMICmnLLDBBroadcaster : public CMICmnBase, public lldb::SBBroadcaster, public MI::ISingleton<CMICmnLLDBBroadcaster> { @@ -31,16 +28,16 @@ class CMICmnLLDBBroadcaster : public CMICmnBase, public lldb::SBBroadcaster, pub // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; // Methods: private: - /* ctor */ CMICmnLLDBBroadcaster(void); + /* ctor */ CMICmnLLDBBroadcaster(); /* ctor */ CMICmnLLDBBroadcaster(const CMICmnLLDBBroadcaster &); void operator=(const CMICmnLLDBBroadcaster &); // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmnLLDBBroadcaster(void) override; + /* dtor */ ~CMICmnLLDBBroadcaster() override; }; diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp index cf74fe58fbd9..ef99ac9a4207 100644 --- a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -35,7 +35,7 @@ // Return: None. // Throws: None. //-- -CMICmnLLDBDebugSessionInfo::CMICmnLLDBDebugSessionInfo(void) +CMICmnLLDBDebugSessionInfo::CMICmnLLDBDebugSessionInfo() : m_nBrkPointCntMax(INT32_MAX) , m_currentSelectedThread(LLDB_INVALID_THREAD_ID) , m_constStrSharedDataKeyWkDir("Working Directory") @@ -53,7 +53,7 @@ CMICmnLLDBDebugSessionInfo::CMICmnLLDBDebugSessionInfo(void) // Return: None. // Throws: None. //-- -CMICmnLLDBDebugSessionInfo::~CMICmnLLDBDebugSessionInfo(void) +CMICmnLLDBDebugSessionInfo::~CMICmnLLDBDebugSessionInfo() { Shutdown(); } @@ -67,7 +67,7 @@ CMICmnLLDBDebugSessionInfo::~CMICmnLLDBDebugSessionInfo(void) // Throws: None. //-- bool -CMICmnLLDBDebugSessionInfo::Initialize(void) +CMICmnLLDBDebugSessionInfo::Initialize() { m_clientUsageRefCnt++; @@ -91,7 +91,7 @@ CMICmnLLDBDebugSessionInfo::Initialize(void) // Throws: None. //-- bool -CMICmnLLDBDebugSessionInfo::Shutdown(void) +CMICmnLLDBDebugSessionInfo::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -99,16 +99,9 @@ CMICmnLLDBDebugSessionInfo::Shutdown(void) if (!m_bInitialized) return MIstatus::success; - bool bOk = MIstatus::success; - CMIUtilString errMsg; - // Tidy up - bOk = SharedDataDestroy(); - if (!bOk) - { - errMsg = CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_RELEASE)); - errMsg += "\n"; - } + SharedDataDestroy(); + m_vecActiveThreadId.clear(); CMICmnLLDBDebugSessionInfoVarObj::VarObjClear(); @@ -125,18 +118,15 @@ CMICmnLLDBDebugSessionInfo::Shutdown(void) // stopped i.e. application shutdown. // Type: Method. // Args: None. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool -CMICmnLLDBDebugSessionInfo::SharedDataDestroy(void) +void +CMICmnLLDBDebugSessionInfo::SharedDataDestroy() { m_mapIdToSessionData.Clear(); m_vecVarObj.clear(); m_mapBrkPtIdToBrkPtInfo.clear(); - - return MIstatus::success; } //++ ------------------------------------------------------------------------------------ @@ -376,8 +366,7 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo(const SMICmdData &vCmdData, const CMIUtilString strId(CMIUtilString::Format("%d", rThread.GetIndexID())); const CMICmnMIValueConst miValueConst1(strId); const CMICmnMIValueResult miValueResult1("id", miValueConst1); - if (!vwrMIValueTuple.Add(miValueResult1)) - return MIstatus::failure; + vwrMIValueTuple.Add(miValueResult1); // Add "target-id" const char *pThreadName = rThread.GetName(); @@ -392,8 +381,7 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo(const SMICmdData &vCmdData, strThread = CMIUtilString::Format(pThrdFmt, rThread.GetIndexID()); const CMICmnMIValueConst miValueConst2(strThread); const CMICmnMIValueResult miValueResult2("target-id", miValueConst2); - if (!vwrMIValueTuple.Add(miValueResult2)) - return MIstatus::failure; + vwrMIValueTuple.Add(miValueResult2); // Add "frame" if (veThreadInfoFormat != eThreadInfoFormat_NoFrames) @@ -403,15 +391,13 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo(const SMICmdData &vCmdData, return MIstatus::failure; const CMICmnMIValueConst miValueConst3(strFrames, true); - if (!vwrMIValueTuple.Add(miValueConst3, false)) - return MIstatus::failure; + vwrMIValueTuple.Add(miValueConst3, false); } // Add "state" const CMICmnMIValueConst miValueConst4(strState); const CMICmnMIValueResult miValueResult4("state", miValueConst4); - if (!vwrMIValueTuple.Add(miValueResult4)) - return MIstatus::failure; + vwrMIValueTuple.Add(miValueResult4); return MIstatus::success; } @@ -461,9 +447,8 @@ CMICmnLLDBDebugSessionInfo::MIResponseForVariableInfoInternal(const VariableInfo const bool vbIsArgs, const bool vbMarkArgs) { - bool bOk = MIstatus::success; const MIuint nArgs = vwrSBValueList.GetSize(); - for (MIuint i = 0; bOk && (i < nArgs); i++) + for (MIuint i = 0; i < nArgs; i++) { CMICmnMIValueTuple miValueTuple; lldb::SBValue value = vwrSBValueList.GetValueAtIndex(i); @@ -514,7 +499,7 @@ CMICmnLLDBDebugSessionInfo::MIResponseForVariableInfoInternal(const VariableInfo vwrMiValueList.Add(miValueResultName); } } - return bOk; + return MIstatus::success; } //++ ------------------------------------------------------------------------------------ @@ -567,17 +552,14 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo(const lldb::SBThread &vrThre const CMIUtilString strLevel(CMIUtilString::Format("%d", vnLevel)); const CMICmnMIValueConst miValueConst(strLevel); const CMICmnMIValueResult miValueResult("level", miValueConst); - if (!vwrMiValueTuple.Add(miValueResult)) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult); const CMIUtilString strAddr(CMIUtilString::Format("0x%016" PRIx64, pc)); const CMICmnMIValueConst miValueConst2(strAddr); const CMICmnMIValueResult miValueResult2("addr", miValueConst2); - if (!vwrMiValueTuple.Add(miValueResult2)) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult2); const CMICmnMIValueConst miValueConst3(fnName); const CMICmnMIValueResult miValueResult3("func", miValueConst3); - if (!vwrMiValueTuple.Add(miValueResult3)) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult3); if (veFrameInfoFormat != eFrameInfoFormat_NoArguments) { CMICmnMIValueList miValueList(true); @@ -592,22 +574,18 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo(const lldb::SBThread &vrThre return MIstatus::failure; const CMICmnMIValueResult miValueResult4("args", miValueList); - if (!vwrMiValueTuple.Add(miValueResult4)) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult4); } const CMICmnMIValueConst miValueConst5(fileName); const CMICmnMIValueResult miValueResult5("file", miValueConst5); - if (!vwrMiValueTuple.Add(miValueResult5)) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult5); const CMICmnMIValueConst miValueConst6(path); const CMICmnMIValueResult miValueResult6("fullname", miValueConst6); - if (!vwrMiValueTuple.Add(miValueResult6)) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult6); const CMIUtilString strLine(CMIUtilString::Format("%d", nLine)); const CMICmnMIValueConst miValueConst7(strLine); const CMICmnMIValueResult miValueResult7("line", miValueConst7); - if (!vwrMiValueTuple.Add(miValueResult7)) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult7); return MIstatus::success; } @@ -659,38 +637,30 @@ CMICmnLLDBDebugSessionInfo::GetFrameInfo(const lldb::SBFrame &vrFrame, lldb::add // Type: Method. // Args: vrBrkPtInfo - (R) Break point information object. // vwrMIValueTuple - (W) MI value tuple object. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnLLDBDebugSessionInfo::MIResponseFormBrkPtFrameInfo(const SBrkPtInfo &vrBrkPtInfo, CMICmnMIValueTuple &vwrMiValueTuple) { const CMIUtilString strAddr(CMIUtilString::Format("0x%016" PRIx64, vrBrkPtInfo.m_pc)); const CMICmnMIValueConst miValueConst2(strAddr); const CMICmnMIValueResult miValueResult2("addr", miValueConst2); - if (!vwrMiValueTuple.Add(miValueResult2)) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult2); const CMICmnMIValueConst miValueConst3(vrBrkPtInfo.m_fnName); const CMICmnMIValueResult miValueResult3("func", miValueConst3); - if (!vwrMiValueTuple.Add(miValueResult3)) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult3); const CMICmnMIValueConst miValueConst5(vrBrkPtInfo.m_fileName); const CMICmnMIValueResult miValueResult5("file", miValueConst5); - if (!vwrMiValueTuple.Add(miValueResult5)) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult5); const CMIUtilString strN5 = CMIUtilString::Format("%s/%s", vrBrkPtInfo.m_path.c_str(), vrBrkPtInfo.m_fileName.c_str()); const CMICmnMIValueConst miValueConst6(strN5); const CMICmnMIValueResult miValueResult6("fullname", miValueConst6); - if (!vwrMiValueTuple.Add(miValueResult6)) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult6); const CMIUtilString strLine(CMIUtilString::Format("%d", vrBrkPtInfo.m_nLine)); const CMICmnMIValueConst miValueConst7(strLine); const CMICmnMIValueResult miValueResult7("line", miValueConst7); - if (!vwrMiValueTuple.Add(miValueResult7)) - return MIstatus::failure; - - return MIstatus::success; + vwrMiValueTuple.Add(miValueResult7); } //++ ------------------------------------------------------------------------------------ @@ -716,65 +686,65 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormBrkPtInfo(const SBrkPtInfo &vrBrkPtInf // "type=" const CMICmnMIValueConst miValueConst2(vrBrkPtInfo.m_strType); const CMICmnMIValueResult miValueResult2("type", miValueConst2); - bool bOk = miValueTuple.Add(miValueResult2); + miValueTuple.Add(miValueResult2); // "disp=" const CMICmnMIValueConst miValueConst3(vrBrkPtInfo.m_bDisp ? "del" : "keep"); const CMICmnMIValueResult miValueResult3("disp", miValueConst3); - bOk = bOk && miValueTuple.Add(miValueResult3); + miValueTuple.Add(miValueResult3); // "enabled=" const CMICmnMIValueConst miValueConst4(vrBrkPtInfo.m_bEnabled ? "y" : "n"); const CMICmnMIValueResult miValueResult4("enabled", miValueConst4); - bOk = bOk && miValueTuple.Add(miValueResult4); + miValueTuple.Add(miValueResult4); // "addr=" // "func=" // "file=" // "fullname=" // "line=" - bOk = bOk && MIResponseFormBrkPtFrameInfo(vrBrkPtInfo, miValueTuple); + MIResponseFormBrkPtFrameInfo(vrBrkPtInfo, miValueTuple); // "pending=" if (vrBrkPtInfo.m_bPending) { const CMICmnMIValueConst miValueConst(vrBrkPtInfo.m_strOrigLoc); const CMICmnMIValueList miValueList(miValueConst); const CMICmnMIValueResult miValueResult("pending", miValueList); - bOk = bOk && miValueTuple.Add(miValueResult); + miValueTuple.Add(miValueResult); } if (vrBrkPtInfo.m_bHaveArgOptionThreadGrp) { const CMICmnMIValueConst miValueConst(vrBrkPtInfo.m_strOptThrdGrp); const CMICmnMIValueList miValueList(miValueConst); const CMICmnMIValueResult miValueResult("thread-groups", miValueList); - bOk = bOk && miValueTuple.Add(miValueResult); + miValueTuple.Add(miValueResult); } // "times=" const CMICmnMIValueConst miValueConstB(CMIUtilString::Format("%d", vrBrkPtInfo.m_nTimes)); const CMICmnMIValueResult miValueResultB("times", miValueConstB); - bOk = bOk && miValueTuple.Add(miValueResultB); + miValueTuple.Add(miValueResultB); // "thread=" if (vrBrkPtInfo.m_bBrkPtThreadId) { const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", vrBrkPtInfo.m_nBrkPtThreadId)); const CMICmnMIValueResult miValueResult("thread", miValueConst); - bOk = bOk && miValueTuple.Add(miValueResult); + miValueTuple.Add(miValueResult); } // "cond=" if (vrBrkPtInfo.m_bCondition) { const CMICmnMIValueConst miValueConst(vrBrkPtInfo.m_strCondition); const CMICmnMIValueResult miValueResult("cond", miValueConst); - bOk = bOk && miValueTuple.Add(miValueResult); + miValueTuple.Add(miValueResult); } // "ignore=" if (vrBrkPtInfo.m_nIgnore != 0) { const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", vrBrkPtInfo.m_nIgnore)); const CMICmnMIValueResult miValueResult("ignore", miValueConst); - bOk = bOk && miValueTuple.Add(miValueResult); + miValueTuple.Add(miValueResult); } // "original-location=" const CMICmnMIValueConst miValueConstC(vrBrkPtInfo.m_strOrigLoc); const CMICmnMIValueResult miValueResultC("original-location", miValueConstC); - bOk = bOk && miValueTuple.Add(miValueResultC); + miValueTuple.Add(miValueResultC); vwrMiValueTuple = miValueTuple; diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h index 7e0ce6ab8246..dbad0c86159a 100644 --- a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h +++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h @@ -38,9 +38,6 @@ class CMICmnMIValueList; // retrieved by the same or other subsequent commands. // It primarily holds LLDB type objects. // A singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 04/03/2014. -// Changes: None. //-- class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMICmnLLDBDebugSessionInfo> { @@ -55,7 +52,7 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC //-- struct SBrkPtInfo { - SBrkPtInfo(void) + SBrkPtInfo() : m_id(0) , m_bDisp(false) , m_bEnabled(false) @@ -140,13 +137,13 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; // Variant type data which can be assigned and retrieved across all command instances template <typename T> bool SharedDataAdd(const CMIUtilString &vKey, const T &vData); template <typename T> bool SharedDataRetrieve(const CMIUtilString &vKey, T &vwData); - bool SharedDataDestroy(void); + void SharedDataDestroy(); // Common command required functionality bool AccessPath(const CMIUtilString &vPath, bool &vwbYesAccessible); @@ -159,7 +156,7 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC bool MIResponseFormVariableInfo(const lldb::SBFrame &vrFrame, const MIuint vMaskVarTypes, const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList, const MIuint vnMaxDepth = 10, const bool vbMarkArgs = false); - bool MIResponseFormBrkPtFrameInfo(const SBrkPtInfo &vrBrkPtInfo, CMICmnMIValueTuple &vwrMiValueTuple); + void MIResponseFormBrkPtFrameInfo(const SBrkPtInfo &vrBrkPtInfo, CMICmnMIValueTuple &vwrMiValueTuple); bool MIResponseFormBrkPtInfo(const SBrkPtInfo &vrBrkPtInfo, CMICmnMIValueTuple &vwrMiValueTuple); bool GetBrkPtInfo(const lldb::SBBreakpoint &vBrkPt, SBrkPtInfo &vrwBrkPtInfo) const; bool RecordBrkPtInfo(const MIuint vnBrkPtId, const SBrkPtInfo &vrBrkPtInfo); @@ -194,7 +191,7 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC // Methods: private: - /* ctor */ CMICmnLLDBDebugSessionInfo(void); + /* ctor */ CMICmnLLDBDebugSessionInfo(); /* ctor */ CMICmnLLDBDebugSessionInfo(const CMICmnLLDBDebugSessionInfo &); void operator=(const CMICmnLLDBDebugSessionInfo &); // @@ -209,7 +206,7 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmnLLDBDebugSessionInfo(void) override; + /* dtor */ ~CMICmnLLDBDebugSessionInfo() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp index 62130844d22d..d4d2896f7eeb 100644 --- a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp +++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp @@ -32,7 +32,7 @@ CMICmnLLDBDebugSessionInfoVarObj::varFormat_e CMICmnLLDBDebugSessionInfoVarObj:: // Return: None. // Throws: None. //-- -CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj(void) +CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj() : m_eVarFormat(eVarFormat_Natural) , m_eVarType(eVarType_Internal) { @@ -205,7 +205,7 @@ CMICmnLLDBDebugSessionInfoVarObj::MoveOther(CMICmnLLDBDebugSessionInfoVarObj &vr // Return: None. // Throws: None. //-- -CMICmnLLDBDebugSessionInfoVarObj::~CMICmnLLDBDebugSessionInfoVarObj(void) +CMICmnLLDBDebugSessionInfoVarObj::~CMICmnLLDBDebugSessionInfoVarObj() { } @@ -285,7 +285,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(const lldb::SBValue &v } } - return utilValue.GetValue().Escape().AddSlashes(); + return utilValue.GetValue().AddSlashes(); } //++ ------------------------------------------------------------------------------------ @@ -340,7 +340,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetStringFormatted(const MIuint64 vnValue, con // Throws: None. //-- void -CMICmnLLDBDebugSessionInfoVarObj::VarObjClear(void) +CMICmnLLDBDebugSessionInfoVarObj::VarObjClear() { ms_mapVarIdToVarObj.clear(); } @@ -421,7 +421,7 @@ CMICmnLLDBDebugSessionInfoVarObj::VarObjGet(const CMIUtilString &vrVarName, CMIC // Throws: None. //-- void -CMICmnLLDBDebugSessionInfoVarObj::VarObjIdResetToZero(void) +CMICmnLLDBDebugSessionInfoVarObj::VarObjIdResetToZero() { ms_nVarUniqueId = 0; } @@ -449,7 +449,7 @@ CMICmnLLDBDebugSessionInfoVarObj::VarObjSetFormat(varFormat_e eDefaultFormat) // Throws: None. //-- void -CMICmnLLDBDebugSessionInfoVarObj::VarObjIdInc(void) +CMICmnLLDBDebugSessionInfoVarObj::VarObjIdInc() { ms_nVarUniqueId++; } @@ -463,7 +463,7 @@ CMICmnLLDBDebugSessionInfoVarObj::VarObjIdInc(void) // Throws: None. //-- MIuint -CMICmnLLDBDebugSessionInfoVarObj::VarObjIdGet(void) +CMICmnLLDBDebugSessionInfoVarObj::VarObjIdGet() { return ms_nVarUniqueId; } @@ -476,7 +476,7 @@ CMICmnLLDBDebugSessionInfoVarObj::VarObjIdGet(void) // Throws: None. //-- const CMIUtilString & -CMICmnLLDBDebugSessionInfoVarObj::GetName(void) const +CMICmnLLDBDebugSessionInfoVarObj::GetName() const { return m_strName; } @@ -490,7 +490,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetName(void) const // Throws: None. //-- const CMIUtilString & -CMICmnLLDBDebugSessionInfoVarObj::GetNameReal(void) const +CMICmnLLDBDebugSessionInfoVarObj::GetNameReal() const { return m_strNameReal; } @@ -503,7 +503,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetNameReal(void) const // Throws: None. //-- const CMIUtilString & -CMICmnLLDBDebugSessionInfoVarObj::GetValueFormatted(void) const +CMICmnLLDBDebugSessionInfoVarObj::GetValueFormatted() const { return m_strFormattedValue; } @@ -516,7 +516,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetValueFormatted(void) const // Throws: None. //-- lldb::SBValue & -CMICmnLLDBDebugSessionInfoVarObj::GetValue(void) +CMICmnLLDBDebugSessionInfoVarObj::GetValue() { return m_SBValue; } @@ -529,7 +529,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetValue(void) // Throws: None. //-- const lldb::SBValue & -CMICmnLLDBDebugSessionInfoVarObj::GetValue(void) const +CMICmnLLDBDebugSessionInfoVarObj::GetValue() const { return m_SBValue; } @@ -561,7 +561,7 @@ CMICmnLLDBDebugSessionInfoVarObj::SetVarFormat(const varFormat_e veVarFormat) // Throws: None. //-- void -CMICmnLLDBDebugSessionInfoVarObj::UpdateValue(void) +CMICmnLLDBDebugSessionInfoVarObj::UpdateValue() { m_strFormattedValue = GetValueStringFormatted(m_SBValue, m_eVarFormat); @@ -580,7 +580,7 @@ CMICmnLLDBDebugSessionInfoVarObj::UpdateValue(void) // Throws: None. //-- CMICmnLLDBDebugSessionInfoVarObj::varType_e -CMICmnLLDBDebugSessionInfoVarObj::GetType(void) const +CMICmnLLDBDebugSessionInfoVarObj::GetType() const { return m_eVarType; } @@ -595,7 +595,7 @@ CMICmnLLDBDebugSessionInfoVarObj::GetType(void) const // Throws: None. //-- const CMIUtilString & -CMICmnLLDBDebugSessionInfoVarObj::GetVarParentName(void) const +CMICmnLLDBDebugSessionInfoVarObj::GetVarParentName() const { return m_strVarObjParentName; } diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h index e768c5fdf0cc..c4ae8e8e44b3 100644 --- a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h +++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h @@ -19,9 +19,6 @@ //++ ============================================================================ // Details: MI debug session variable object. The static functionality in *this // class manages a map container of *these variable objects. -// Gotchas: None. -// Authors: Illya Rudkin 24/03/2014. -// Changes: None. //-- class CMICmnLLDBDebugSessionInfoVarObj { @@ -63,15 +60,15 @@ class CMICmnLLDBDebugSessionInfoVarObj static void VarObjDelete(const CMIUtilString &vrVarName); static bool VarObjGet(const CMIUtilString &vrVarName, CMICmnLLDBDebugSessionInfoVarObj &vrwVarObj); static void VarObjUpdate(const CMICmnLLDBDebugSessionInfoVarObj &vrVarObj); - static void VarObjIdInc(void); - static MIuint VarObjIdGet(void); - static void VarObjIdResetToZero(void); - static void VarObjClear(void); + static void VarObjIdInc(); + static MIuint VarObjIdGet(); + static void VarObjIdResetToZero(); + static void VarObjClear(); static void VarObjSetFormat(varFormat_e eDefaultFormat); // Methods: public: - /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(void); + /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(); /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(const CMIUtilString &vrStrNameReal, const CMIUtilString &vrStrName, const lldb::SBValue &vrValue); /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(const CMIUtilString &vrStrNameReal, const CMIUtilString &vrStrName, @@ -83,20 +80,20 @@ class CMICmnLLDBDebugSessionInfoVarObj CMICmnLLDBDebugSessionInfoVarObj &operator=(const CMICmnLLDBDebugSessionInfoVarObj &vrOther); CMICmnLLDBDebugSessionInfoVarObj &operator=(CMICmnLLDBDebugSessionInfoVarObj &&vrwOther); // - const CMIUtilString &GetName(void) const; - const CMIUtilString &GetNameReal(void) const; - const CMIUtilString &GetValueFormatted(void) const; - lldb::SBValue &GetValue(void); - const lldb::SBValue &GetValue(void) const; - varType_e GetType(void) const; + const CMIUtilString &GetName() const; + const CMIUtilString &GetNameReal() const; + const CMIUtilString &GetValueFormatted() const; + lldb::SBValue &GetValue(); + const lldb::SBValue &GetValue() const; + varType_e GetType() const; bool SetVarFormat(const varFormat_e veVarFormat); - const CMIUtilString &GetVarParentName(void) const; - void UpdateValue(void); + const CMIUtilString &GetVarParentName() const; + void UpdateValue(); // Overridden: public: // From CMICmnBase - /* dtor */ virtual ~CMICmnLLDBDebugSessionInfoVarObj(void); + /* dtor */ virtual ~CMICmnLLDBDebugSessionInfoVarObj(); // Typedefs: private: diff --git a/tools/lldb-mi/MICmnLLDBDebugger.cpp b/tools/lldb-mi/MICmnLLDBDebugger.cpp index b626ccc3f12d..3042e1c8125d 100644 --- a/tools/lldb-mi/MICmnLLDBDebugger.cpp +++ b/tools/lldb-mi/MICmnLLDBDebugger.cpp @@ -12,6 +12,11 @@ #include "lldb/API/SBThread.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBCommandInterpreter.h" +#include "lldb/API/SBTypeSummary.h" +#include "lldb/API/SBTypeCategory.h" +#include "lldb/API/SBTypeNameSpecifier.h" +#include "lldb/API/SBStream.h" +#include "lldb/API/SBType.h" // In-house headers: #include "MICmnLLDBDebugger.h" @@ -24,13 +29,50 @@ #include "MIUtilSingletonHelper.h" //++ ------------------------------------------------------------------------------------ +// MI private summary providers +static inline bool +MI_char_summary_provider(lldb::SBValue value, lldb::SBTypeSummaryOptions options, lldb::SBStream &stream) +{ + if (!value.IsValid()) + return false; + + lldb::SBType value_type = value.GetType(); + if(!value_type.IsValid()) + return false; + + lldb::BasicType type_code = value_type.GetBasicType(); + if (type_code == lldb::eBasicTypeSignedChar) + stream.Printf("%d %s", (int)value.GetValueAsSigned(), value.GetValue()); + else if (type_code == lldb::eBasicTypeUnsignedChar) + stream.Printf("%u %s", (unsigned)value.GetValueAsUnsigned(), value.GetValue()); + else + return false; + + return true; +} + +//++ ------------------------------------------------------------------------------------ +// MI summary helper routines +static inline bool +MI_add_summary(lldb::SBTypeCategory category, const char *typeName, lldb::SBTypeSummary::FormatCallback cb, + uint32_t options, bool regex = false) +{ +#if defined(LLDB_DISABLE_PYTHON) + return false; +#else + lldb::SBTypeSummary summary = lldb::SBTypeSummary::CreateWithCallback(cb, options); + return summary.IsValid() ? category.AddTypeSummary(lldb::SBTypeNameSpecifier(typeName, regex), summary) : false; +#endif +} + +//++ ------------------------------------------------------------------------------------ // Details: CMICmnLLDBDebugger constructor. // Type: Method. // Args: None. // Return: None. // Throws: None. //-- -CMICmnLLDBDebugger::CMICmnLLDBDebugger(void) +CMICmnLLDBDebugger::CMICmnLLDBDebugger() : m_constStrThisThreadId("MI debugger event") { } @@ -42,7 +84,7 @@ CMICmnLLDBDebugger::CMICmnLLDBDebugger(void) // Return: None. // Throws: None. //-- -CMICmnLLDBDebugger::~CMICmnLLDBDebugger(void) +CMICmnLLDBDebugger::~CMICmnLLDBDebugger() { Shutdown(); } @@ -56,7 +98,7 @@ CMICmnLLDBDebugger::~CMICmnLLDBDebugger(void) // Throws: None. //-- bool -CMICmnLLDBDebugger::Initialize(void) +CMICmnLLDBDebugger::Initialize() { m_clientUsageRefCnt++; @@ -98,7 +140,7 @@ CMICmnLLDBDebugger::Initialize(void) errMsg += GetErrorDescription().c_str(); } bOk = bOk && InitStdStreams(); - + bOk = bOk && RegisterMISummaryProviders(); m_bInitialized = bOk; if (!bOk && !HaveErrorDescription()) @@ -119,7 +161,7 @@ CMICmnLLDBDebugger::Initialize(void) // Throws: None. //-- bool -CMICmnLLDBDebugger::Shutdown(void) +CMICmnLLDBDebugger::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -173,7 +215,7 @@ CMICmnLLDBDebugger::Shutdown(void) // Throws: None. //-- lldb::SBDebugger & -CMICmnLLDBDebugger::GetTheDebugger(void) +CMICmnLLDBDebugger::GetTheDebugger() { return m_lldbDebugger; } @@ -186,7 +228,7 @@ CMICmnLLDBDebugger::GetTheDebugger(void) // Throws: None. //-- lldb::SBListener & -CMICmnLLDBDebugger::GetTheListener(void) +CMICmnLLDBDebugger::GetTheListener() { return m_lldbListener; } @@ -216,7 +258,7 @@ CMICmnLLDBDebugger::SetDriver(const CMIDriverBase &vClientDriver) // Throws: None. //-- CMIDriverBase & -CMICmnLLDBDebugger::GetDriver(void) const +CMICmnLLDBDebugger::GetDriver() const { return *m_pClientDriver; } @@ -234,7 +276,7 @@ CMICmnLLDBDebugger::GetDriver(void) const // Throws: None. //-- void -CMICmnLLDBDebugger::WaitForHandleEvent(void) +CMICmnLLDBDebugger::WaitForHandleEvent() { std::unique_lock<std::mutex> lock(m_mutexEventQueue); @@ -254,7 +296,7 @@ CMICmnLLDBDebugger::WaitForHandleEvent(void) // Throws: None. //-- bool -CMICmnLLDBDebugger::CheckIfNeedToRebroadcastStopEvent(void) +CMICmnLLDBDebugger::CheckIfNeedToRebroadcastStopEvent() { CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); if (!rSessionInfo.GetDebugger().GetAsync()) @@ -276,7 +318,7 @@ CMICmnLLDBDebugger::CheckIfNeedToRebroadcastStopEvent(void) // Throws: None. //-- void -CMICmnLLDBDebugger::RebroadcastStopEvent(void) +CMICmnLLDBDebugger::RebroadcastStopEvent() { lldb::SBProcess process = CMICmnLLDBDebugSessionInfo::Instance().GetProcess(); const bool include_expression_stops = false; @@ -297,7 +339,7 @@ CMICmnLLDBDebugger::RebroadcastStopEvent(void) // Throws: None. //-- bool -CMICmnLLDBDebugger::InitSBDebugger(void) +CMICmnLLDBDebugger::InitSBDebugger() { m_lldbDebugger = lldb::SBDebugger::Create(false); if (!m_lldbDebugger.IsValid()) @@ -321,7 +363,7 @@ CMICmnLLDBDebugger::InitSBDebugger(void) // Throws: None. //-- bool -CMICmnLLDBDebugger::InitStdStreams(void) +CMICmnLLDBDebugger::InitStdStreams() { // This is not required when operating the MI driver's code as it has its own // streams. Setting the Stdin for the lldbDebugger especially on LINUX will cause @@ -342,7 +384,7 @@ CMICmnLLDBDebugger::InitStdStreams(void) // Throws: None. //-- bool -CMICmnLLDBDebugger::InitSBListener(void) +CMICmnLLDBDebugger::InitSBListener() { m_lldbListener = m_lldbDebugger.GetListener(); if (!m_lldbListener.IsValid()) @@ -585,7 +627,7 @@ CMICmnLLDBDebugger::ClientGetMaskForAllClients(const CMIUtilString &vBroadcaster while (it != m_mapIdToEventMask.end()) { const CMIUtilString &rId((*it).first); - if (rId.find(vBroadcasterClass.c_str()) != std::string::npos) + if (rId.find(vBroadcasterClass) != std::string::npos) { const MIuint clientsMask = (*it).second; mask |= clientsMask; @@ -678,9 +720,7 @@ CMICmnLLDBDebugger::ClientGetTheirMask(const CMIUtilString &vClientName, const C return MIstatus::failure; } - CMIUtilString strId(vBroadcasterClass.c_str()); - strId += vClientName; - + const CMIUtilString strId(vBroadcasterClass + vClientName); const MapIdToEventMask_t::const_iterator it = m_mapIdToEventMask.find(strId); if (it != m_mapIdToEventMask.end()) { @@ -776,7 +816,7 @@ CMICmnLLDBDebugger::ThreadRun(bool &vrbIsAlive) // Throws: None. //-- bool -CMICmnLLDBDebugger::ThreadFinish(void) +CMICmnLLDBDebugger::ThreadFinish() { return MIstatus::success; } @@ -789,7 +829,58 @@ CMICmnLLDBDebugger::ThreadFinish(void) // Throws: None. //-- const CMIUtilString & -CMICmnLLDBDebugger::ThreadGetName(void) const +CMICmnLLDBDebugger::ThreadGetName() const { return m_constStrThisThreadId; } + +//++ ------------------------------------------------------------------------------------ +// Details: Loads lldb-mi formatters +// Type: Method. +// Args: None. +// Return: true - Functionality succeeded. +// false - Functionality failed. +// Throws: None. +//-- +bool +CMICmnLLDBDebugger::LoadMIFormatters(lldb::SBTypeCategory miCategory) +{ + if (!MI_add_summary(miCategory, "char", MI_char_summary_provider, + lldb::eTypeOptionHideValue | lldb::eTypeOptionSkipPointers)) + return false; + + if (!MI_add_summary(miCategory, "unsigned char", MI_char_summary_provider, + lldb::eTypeOptionHideValue | lldb::eTypeOptionSkipPointers)) + return false; + + if (!MI_add_summary(miCategory, "signed char", MI_char_summary_provider, + lldb::eTypeOptionHideValue | lldb::eTypeOptionSkipPointers)) + return false; + + return true; +} + +//++ ------------------------------------------------------------------------------------ +// Details: Registers lldb-mi custom summary providers +// Type: Method. +// Args: None. +// Return: true - Functionality succeeded. +// false - Functionality failed. +// Throws: None. +//-- +bool +CMICmnLLDBDebugger::RegisterMISummaryProviders() +{ + static const char* miCategoryName = "lldb-mi"; + lldb::SBTypeCategory miCategory = m_lldbDebugger.CreateCategory(miCategoryName); + if (!miCategory.IsValid()) + return false; + + if (!LoadMIFormatters(miCategory)) + { + m_lldbDebugger.DeleteCategory(miCategoryName); + return false; + } + miCategory.SetEnabled(true); + return true; +} diff --git a/tools/lldb-mi/MICmnLLDBDebugger.h b/tools/lldb-mi/MICmnLLDBDebugger.h index de7611221522..83bc3c06bf69 100644 --- a/tools/lldb-mi/MICmnLLDBDebugger.h +++ b/tools/lldb-mi/MICmnLLDBDebugger.h @@ -32,9 +32,6 @@ class CMICmnLLDBDebuggerHandleEvents; // to facilitate their work effort. The instance runs in its own worker // thread. // A singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 26/02/2014. -// Changes: None. //-- class CMICmnLLDBDebugger : public CMICmnBase, public CMIUtilThreadActiveObjBase, public MI::ISingleton<CMICmnLLDBDebugger> { @@ -42,16 +39,16 @@ class CMICmnLLDBDebugger : public CMICmnBase, public CMIUtilThreadActiveObjBase, // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; bool SetDriver(const CMIDriverBase &vClientDriver); - CMIDriverBase &GetDriver(void) const; - lldb::SBDebugger &GetTheDebugger(void); - lldb::SBListener &GetTheListener(void); - void WaitForHandleEvent(void); - bool CheckIfNeedToRebroadcastStopEvent(void); - void RebroadcastStopEvent(void); + CMIDriverBase &GetDriver() const; + lldb::SBDebugger &GetTheDebugger(); + lldb::SBListener &GetTheListener(); + void WaitForHandleEvent(); + bool CheckIfNeedToRebroadcastStopEvent(); + void RebroadcastStopEvent(); // MI Commands can use these functions to listen for events they require bool RegisterForEvent(const CMIUtilString &vClientName, const CMIUtilString &vBroadcasterClass, const MIuint vEventMask); @@ -62,13 +59,13 @@ class CMICmnLLDBDebugger : public CMICmnBase, public CMIUtilThreadActiveObjBase, // Overridden: public: // From CMIUtilThreadActiveObjBase - const CMIUtilString &ThreadGetName(void) const override; + const CMIUtilString &ThreadGetName() const override; // Overridden: protected: // From CMIUtilThreadActiveObjBase bool ThreadRun(bool &vrIsAlive) override; - bool ThreadFinish(void) override; + bool ThreadFinish() override; // Typedefs: private: @@ -79,13 +76,13 @@ class CMICmnLLDBDebugger : public CMICmnBase, public CMIUtilThreadActiveObjBase, // Methods: private: - /* ctor */ CMICmnLLDBDebugger(void); + /* ctor */ CMICmnLLDBDebugger(); /* ctor */ CMICmnLLDBDebugger(const CMICmnLLDBDebugger &); void operator=(const CMICmnLLDBDebugger &); - bool InitSBDebugger(void); - bool InitSBListener(void); - bool InitStdStreams(void); + bool InitSBDebugger(); + bool InitSBListener(); + bool InitStdStreams(); bool MonitorSBListenerEvents(bool &vrbYesExit); bool BroadcasterGetMask(const CMIUtilString &vBroadcasterClass, MIuint &vEventMask) const; @@ -96,11 +93,12 @@ class CMICmnLLDBDebugger : public CMICmnBase, public CMIUtilThreadActiveObjBase, bool ClientSaveMask(const CMIUtilString &vClientName, const CMIUtilString &vBroadcasterClass, const MIuint vEventMask); bool ClientRemoveTheirMask(const CMIUtilString &vClientName, const CMIUtilString &vBroadcasterClass); bool ClientGetTheirMask(const CMIUtilString &vClientName, const CMIUtilString &vBroadcasterClass, MIuint &vwEventMask); - + bool LoadMIFormatters(lldb::SBTypeCategory miCategory); + bool RegisterMISummaryProviders(); // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmnLLDBDebugger(void) override; + /* dtor */ ~CMICmnLLDBDebugger() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp index 29ff15c92f44..848529f0b46a 100644 --- a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp +++ b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp @@ -1,4 +1,4 @@ -//===-- MICmnLLDBDebuggerHandleEvents.cpp --------------------------------------------*- C++ -*-===// +//===-- MICmnLLDBDebuggerHandleEvents.cpp -----------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -47,7 +47,7 @@ // Return: None. // Throws: None. //-- -CMICmnLLDBDebuggerHandleEvents::CMICmnLLDBDebuggerHandleEvents(void) +CMICmnLLDBDebuggerHandleEvents::CMICmnLLDBDebuggerHandleEvents() { } @@ -58,7 +58,7 @@ CMICmnLLDBDebuggerHandleEvents::CMICmnLLDBDebuggerHandleEvents(void) // Return: None. // Throws: None. //-- -CMICmnLLDBDebuggerHandleEvents::~CMICmnLLDBDebuggerHandleEvents(void) +CMICmnLLDBDebuggerHandleEvents::~CMICmnLLDBDebuggerHandleEvents() { Shutdown(); } @@ -72,7 +72,7 @@ CMICmnLLDBDebuggerHandleEvents::~CMICmnLLDBDebuggerHandleEvents(void) // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::Initialize(void) +CMICmnLLDBDebuggerHandleEvents::Initialize() { m_clientUsageRefCnt++; @@ -98,7 +98,7 @@ CMICmnLLDBDebuggerHandleEvents::Initialize(void) // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::Shutdown(void) +CMICmnLLDBDebuggerHandleEvents::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -351,7 +351,8 @@ CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakpointCmn(const lldb::SBEvent & const CMICmnMIValueResult miValueResultC("bkpt", miValueTuple); const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResultC); - const bool bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord); + bool bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord); + bOk = bOk && CMICmnStreamStdout::WritePrompt(); return bOk; } @@ -440,6 +441,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakpointAdded(const lldb::SBEvent const CMICmnMIValueResult miValueResult("bkpt", miValueTuple); const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult); bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord); + bOk = bOk && CMICmnStreamStdout::WritePrompt(); } else { @@ -462,6 +464,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakpointAdded(const lldb::SBEvent const CMICmnMIValueResult miValueResult("bkpt", miValueTuple); const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, miValueResult); bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord); + bOk = bOk && CMICmnStreamStdout::WritePrompt(); } return bOk; @@ -543,10 +546,8 @@ CMICmnLLDBDebuggerHandleEvents::HandleEventSBThreadSuspended(const lldb::SBEvent const CMIUtilString strSignal(CMIUtilString::Format("%lld", nId)); const CMICmnMIValueConst miValueConst2(strSignal); const CMICmnMIValueResult miValueResult2("signal", miValueConst2); - bool bOk = miOutOfBandRecord.Add(miValueResult2); - bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord); - - return bOk; + miOutOfBandRecord.Add(miValueResult2); + return MiOutOfBandRecordToStdout(miOutOfBandRecord); } //++ ------------------------------------------------------------------------------------ @@ -690,19 +691,19 @@ CMICmnLLDBDebuggerHandleEvents::MiHelpGetModuleInfo(const lldb::SBModule &vModul std::unique_ptr<char[]> apPath(new char[PATH_MAX]); vModule.GetFileSpec().GetPath(apPath.get(), PATH_MAX); const CMIUtilString strTargetPath(apPath.get()); - const CMICmnMIValueConst miValueConst(strTargetPath); + const CMICmnMIValueConst miValueConst(strTargetPath.AddSlashes()); const CMICmnMIValueResult miValueResult("id", miValueConst); - bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult); + vwrMiOutOfBandRecord.Add(miValueResult); // Build "target-name" field - const CMICmnMIValueConst miValueConst2(strTargetPath); + const CMICmnMIValueConst miValueConst2(strTargetPath.AddSlashes()); const CMICmnMIValueResult miValueResult2("target-name", miValueConst2); - bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult2); + vwrMiOutOfBandRecord.Add(miValueResult2); // Build "host-name" field vModule.GetPlatformFileSpec().GetPath(apPath.get(), PATH_MAX); const CMIUtilString strHostPath(apPath.get()); - const CMICmnMIValueConst miValueConst3(strHostPath); + const CMICmnMIValueConst miValueConst3(strHostPath.AddSlashes()); const CMICmnMIValueResult miValueResult3("host-name", miValueConst3); - bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult3); + vwrMiOutOfBandRecord.Add(miValueResult3); // Then build extra fields if needed: if (vbWithExtraFields) @@ -713,23 +714,30 @@ CMICmnLLDBDebuggerHandleEvents::MiHelpGetModuleInfo(const lldb::SBModule &vModul const bool bSymbolsLoaded = !CMIUtilString::Compare(strHostPath, strSymbolsPath); const CMICmnMIValueConst miValueConst4(CMIUtilString::Format("%d", bSymbolsLoaded)); const CMICmnMIValueResult miValueResult4("symbols-loaded", miValueConst4); - bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult4); + vwrMiOutOfBandRecord.Add(miValueResult4); // Build "symbols-path" field if (bSymbolsLoaded) { - const CMICmnMIValueConst miValueConst5(strSymbolsPath); + const CMICmnMIValueConst miValueConst5(strSymbolsPath.AddSlashes()); const CMICmnMIValueResult miValueResult5("symbols-path", miValueConst5); - bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult5); + vwrMiOutOfBandRecord.Add(miValueResult5); } // Build "loaded_addr" field - const lldb::SBAddress sbAddress(vModule.GetObjectFileHeaderAddress()); + lldb::SBAddress sbAddress(vModule.GetObjectFileHeaderAddress()); CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); const lldb::addr_t nLoadAddress(sbAddress.GetLoadAddress(rSessionInfo.GetTarget())); const CMIUtilString strLoadedAddr(nLoadAddress != LLDB_INVALID_ADDRESS ? CMIUtilString::Format("0x%016" PRIx64, nLoadAddress) : "-"); const CMICmnMIValueConst miValueConst6(strLoadedAddr); const CMICmnMIValueResult miValueResult6("loaded_addr", miValueConst6); - bOk = bOk && vwrMiOutOfBandRecord.Add(miValueResult6); + vwrMiOutOfBandRecord.Add(miValueResult6); + + // Build "size" field + lldb::SBSection sbSection = sbAddress.GetSection(); + const CMIUtilString strSize(CMIUtilString::Format("%" PRIu64, sbSection.GetByteSize())); + const CMICmnMIValueConst miValueConst7(strSize); + const CMICmnMIValueResult miValueResult7("size", miValueConst7); + vwrMiOutOfBandRecord.Add(miValueResult7); } return bOk; @@ -1018,21 +1026,21 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(const lldb::SBEvent CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult); const CMICmnMIValueConst miValueConst2("SIGINT"); const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2); - bOk = miOutOfBandRecord.Add(miValueResult2); + miOutOfBandRecord.Add(miValueResult2); const CMICmnMIValueConst miValueConst3("Interrupt"); const CMICmnMIValueResult miValueResult3("signal-meaning", miValueConst3); - bOk = bOk && miOutOfBandRecord.Add(miValueResult3); + miOutOfBandRecord.Add(miValueResult3); CMICmnMIValueTuple miValueTuple; bOk = bOk && MiHelpGetCurrentThreadFrame(miValueTuple); const CMICmnMIValueResult miValueResult4("frame", miValueTuple); - bOk = bOk && miOutOfBandRecord.Add(miValueResult4); + miOutOfBandRecord.Add(miValueResult4); const CMIUtilString strThreadId(CMIUtilString::Format("%" PRIu32, sbProcess.GetSelectedThread().GetIndexID())); const CMICmnMIValueConst miValueConst5(strThreadId); const CMICmnMIValueResult miValueResult5("thread-id", miValueConst5); - bOk = bOk && miOutOfBandRecord.Add(miValueResult5); + miOutOfBandRecord.Add(miValueResult5); const CMICmnMIValueConst miValueConst6("all"); const CMICmnMIValueResult miValueResult6("stopped-threads", miValueConst6); - bOk = bOk && miOutOfBandRecord.Add(miValueResult6); + miOutOfBandRecord.Add(miValueResult6); bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord); bOk = bOk && CMICmnStreamStdout::WritePrompt(); } @@ -1044,21 +1052,21 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(const lldb::SBEvent CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult); const CMICmnMIValueConst miValueConst2("SIGSTOP"); const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2); - bOk = miOutOfBandRecord.Add(miValueResult2); + miOutOfBandRecord.Add(miValueResult2); const CMICmnMIValueConst miValueConst3("Stop"); const CMICmnMIValueResult miValueResult3("signal-meaning", miValueConst3); - bOk = bOk && miOutOfBandRecord.Add(miValueResult3); + miOutOfBandRecord.Add(miValueResult3); CMICmnMIValueTuple miValueTuple; bOk = bOk && MiHelpGetCurrentThreadFrame(miValueTuple); const CMICmnMIValueResult miValueResult4("frame", miValueTuple); - bOk = bOk && miOutOfBandRecord.Add(miValueResult4); + miOutOfBandRecord.Add(miValueResult4); const CMIUtilString strThreadId(CMIUtilString::Format("%" PRIu32, sbProcess.GetSelectedThread().GetIndexID())); const CMICmnMIValueConst miValueConst5(strThreadId); const CMICmnMIValueResult miValueResult5("thread-id", miValueConst5); - bOk = bOk && miOutOfBandRecord.Add(miValueResult5); + miOutOfBandRecord.Add(miValueResult5); const CMICmnMIValueConst miValueConst6("all"); const CMICmnMIValueResult miValueResult6("stopped-threads", miValueConst6); - bOk = bOk && miOutOfBandRecord.Add(miValueResult6); + miOutOfBandRecord.Add(miValueResult6); bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord); bOk = bOk && CMICmnStreamStdout::WritePrompt(); } @@ -1070,18 +1078,18 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(const lldb::SBEvent CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult); const CMICmnMIValueConst miValueConst2("SIGSEGV"); const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2); - bOk = miOutOfBandRecord.Add(miValueResult2); + miOutOfBandRecord.Add(miValueResult2); const CMICmnMIValueConst miValueConst3("Segmentation fault"); const CMICmnMIValueResult miValueResult3("signal-meaning", miValueConst3); - bOk = bOk && miOutOfBandRecord.Add(miValueResult3); + miOutOfBandRecord.Add(miValueResult3); CMICmnMIValueTuple miValueTuple; bOk = bOk && MiHelpGetCurrentThreadFrame(miValueTuple); const CMICmnMIValueResult miValueResult4("frame", miValueTuple); - bOk = bOk && miOutOfBandRecord.Add(miValueResult4); + miOutOfBandRecord.Add(miValueResult4); const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID())); const CMICmnMIValueConst miValueConst5(strThreadId); const CMICmnMIValueResult miValueResult5("thread-id", miValueConst5); - bOk = bOk && miOutOfBandRecord.Add(miValueResult5); + miOutOfBandRecord.Add(miValueResult5); bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord); // Note no "(gdb)" output here } @@ -1119,22 +1127,22 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(const lldb::SBEvent { const CMICmnMIValueConst miValueConst2(pSignal); const CMICmnMIValueResult miValueResult2("signal-name", miValueConst2); - bOk = miOutOfBandRecord.Add(miValueResult2); + miOutOfBandRecord.Add(miValueResult2); } else { const CMIUtilString strSignal(CMIUtilString::Format("%" PRIu64, nStopReason)); const CMICmnMIValueConst miValueConst2(strSignal); const CMICmnMIValueResult miValueResult2("signal", miValueConst2); - bOk = miOutOfBandRecord.Add(miValueResult2); + miOutOfBandRecord.Add(miValueResult2); } const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID())); const CMICmnMIValueConst miValueConst3(strThreadId); const CMICmnMIValueResult miValueResult3("thread-id", miValueConst3); - bOk = bOk && miOutOfBandRecord.Add(miValueResult3); + miOutOfBandRecord.Add(miValueResult3); const CMICmnMIValueConst miValueConst4("all"); const CMICmnMIValueResult miValueResult4("stopped-threads", miValueConst4); - bOk = bOk && miOutOfBandRecord.Add(miValueResult4); + miOutOfBandRecord.Add(miValueResult4); bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord); bOk = bOk && CMICmnStreamStdout::WritePrompt(); } @@ -1150,7 +1158,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(const lldb::SBEvent // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopException(void) +CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopException() { const lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess(); lldb::SBThread sbThread = sbProcess.GetSelectedThread(); @@ -1165,15 +1173,15 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopException(void) const CMIUtilString strReason(apStopDescription.get()); const CMICmnMIValueConst miValueConst2(strReason); const CMICmnMIValueResult miValueResult2("exception", miValueConst2); - bool bOk = miOutOfBandRecord.Add(miValueResult2); + miOutOfBandRecord.Add(miValueResult2); const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbThread.GetIndexID())); const CMICmnMIValueConst miValueConst3(strThreadId); const CMICmnMIValueResult miValueResult3("thread-id", miValueConst3); - bOk = bOk && miOutOfBandRecord.Add(miValueResult3); + miOutOfBandRecord.Add(miValueResult3); const CMICmnMIValueConst miValueConst4("all"); const CMICmnMIValueResult miValueResult4("stopped-threads", miValueConst4); - bOk = bOk && miOutOfBandRecord.Add(miValueResult4); - bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord); + miOutOfBandRecord.Add(miValueResult4); + bool bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord); bOk = bOk && CMICmnStreamStdout::WritePrompt(); return bOk; @@ -1235,7 +1243,7 @@ CMICmnLLDBDebuggerHandleEvents::MiHelpGetCurrentThreadFrame(CMICmnMIValueTuple & // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonBreakpoint(void) +CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonBreakpoint() { // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM if (!CMIDriver::Instance().SetDriverStateRunningNotDebugging()) @@ -1278,21 +1286,21 @@ CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, c CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult); const CMICmnMIValueConst miValueConst2("del"); const CMICmnMIValueResult miValueResult2("disp", miValueConst2); - bOk = miOutOfBandRecord.Add(miValueResult2); + miOutOfBandRecord.Add(miValueResult2); const CMIUtilString strBkp(CMIUtilString::Format("%d", vBrkPtId)); const CMICmnMIValueConst miValueConst3(strBkp); CMICmnMIValueResult miValueResult3("bkptno", miValueConst3); - bOk = bOk && miOutOfBandRecord.Add(miValueResult3); + miOutOfBandRecord.Add(miValueResult3); const CMICmnMIValueConst miValueConst4("{}"); const CMICmnMIValueResult miValueResult4("frame", miValueConst4); - bOk = bOk && miOutOfBandRecord.Add(miValueResult4); + miOutOfBandRecord.Add(miValueResult4); const CMIUtilString strThreadId(CMIUtilString::Format("%d", vBrkPt.GetThreadIndex())); const CMICmnMIValueConst miValueConst5(strThreadId); const CMICmnMIValueResult miValueResult5("thread-id", miValueConst5); - bOk = bOk && miOutOfBandRecord.Add(miValueResult5); + miOutOfBandRecord.Add(miValueResult5); const CMICmnMIValueConst miValueConst6("all"); const CMICmnMIValueResult miValueResult6("stopped-threads", miValueConst6); - bOk = bOk && miOutOfBandRecord.Add(miValueResult6); + miOutOfBandRecord.Add(miValueResult6); bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord); bOk = bOk && CMICmnStreamStdout::WritePrompt(); return bOk; @@ -1307,11 +1315,11 @@ CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, c CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult); const CMICmnMIValueConst miValueConstA("del"); const CMICmnMIValueResult miValueResultA("disp", miValueConstA); - bOk = miOutOfBandRecord.Add(miValueResultA); + miOutOfBandRecord.Add(miValueResultA); const CMIUtilString strBkp(CMIUtilString::Format("%d", vBrkPtId)); const CMICmnMIValueConst miValueConstB(strBkp); CMICmnMIValueResult miValueResultB("bkptno", miValueConstB); - bOk = bOk && miOutOfBandRecord.Add(miValueResultB); + miOutOfBandRecord.Add(miValueResultB); // frame={addr=\"0x%016" PRIx64 "\",func=\"%s\",args=[],file=\"%s\",fullname=\"%s\",line=\"%d\"} if (bOk) @@ -1319,7 +1327,7 @@ CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, c CMICmnMIValueTuple miValueTuple; bOk = bOk && rSessionInfo.MIResponseFormFrameInfo(thread, 0, CMICmnLLDBDebugSessionInfo::eFrameInfoFormat_AllArguments, miValueTuple); const CMICmnMIValueResult miValueResult8("frame", miValueTuple); - bOk = bOk && miOutOfBandRecord.Add(miValueResult8); + miOutOfBandRecord.Add(miValueResult8); } // Add to MI thread-id=\"%d\",stopped-threads=\"all\" @@ -1328,13 +1336,13 @@ CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, c const CMIUtilString strThreadId(CMIUtilString::Format("%d", thread.GetIndexID())); const CMICmnMIValueConst miValueConst8(strThreadId); const CMICmnMIValueResult miValueResult8("thread-id", miValueConst8); - bOk = miOutOfBandRecord.Add(miValueResult8); + miOutOfBandRecord.Add(miValueResult8); } if (bOk) { const CMICmnMIValueConst miValueConst9("all"); const CMICmnMIValueResult miValueResult9("stopped-threads", miValueConst9); - bOk = miOutOfBandRecord.Add(miValueResult9); + miOutOfBandRecord.Add(miValueResult9); bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord); bOk = bOk && CMICmnStreamStdout::WritePrompt(); } @@ -1351,7 +1359,7 @@ CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, c // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace(void) +CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace() { bool bOk = true; lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess(); @@ -1365,7 +1373,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace(void) CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult); const CMICmnMIValueConst miValueConst2("all"); const CMICmnMIValueResult miValueResult2("stopped-threads", miValueConst2); - bOk = miOutOfBandRecord.Add(miValueResult2); + miOutOfBandRecord.Add(miValueResult2); bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord); bOk = bOk && CMICmnStreamStdout::WritePrompt(); return bOk; @@ -1385,24 +1393,19 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace(void) const CMICmnMIValueResult miValueResult("reason", miValueConst); CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult); const CMICmnMIValueResult miValueResult2("frame", miValueTuple); - bOk = miOutOfBandRecord.Add(miValueResult2); + miOutOfBandRecord.Add(miValueResult2); // Add to MI thread-id=\"%d\",stopped-threads=\"all\" - if (bOk) - { - const CMIUtilString strThreadId(CMIUtilString::Format("%d", thread.GetIndexID())); - const CMICmnMIValueConst miValueConst8(strThreadId); - const CMICmnMIValueResult miValueResult8("thread-id", miValueConst8); - bOk = miOutOfBandRecord.Add(miValueResult8); - } - if (bOk) - { - const CMICmnMIValueConst miValueConst9("all"); - const CMICmnMIValueResult miValueResult9("stopped-threads", miValueConst9); - bOk = miOutOfBandRecord.Add(miValueResult9); - bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord); - bOk = bOk && CMICmnStreamStdout::WritePrompt(); - } + const CMIUtilString strThreadId(CMIUtilString::Format("%d", thread.GetIndexID())); + const CMICmnMIValueConst miValueConst8(strThreadId); + const CMICmnMIValueResult miValueResult8("thread-id", miValueConst8); + miOutOfBandRecord.Add(miValueResult8); + + const CMICmnMIValueConst miValueConst9("all"); + const CMICmnMIValueResult miValueResult9("stopped-threads", miValueConst9); + miOutOfBandRecord.Add(miValueResult9); + bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord); + bOk = bOk && CMICmnStreamStdout::WritePrompt(); return bOk; } @@ -1416,7 +1419,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace(void) // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::UpdateSelectedThread(void) +CMICmnLLDBDebuggerHandleEvents::UpdateSelectedThread() { lldb::SBProcess process = CMICmnLLDBDebugSessionInfo::Instance().GetDebugger().GetSelectedTarget().GetProcess(); if (!process.IsValid()) @@ -1487,7 +1490,7 @@ CMICmnLLDBDebuggerHandleEvents::UpdateSelectedThread(void) // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateRunning(void) +CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateRunning() { CMICmnMIValueConst miValueConst("all"); CMICmnMIValueResult miValueResult("thread-id", miValueConst); @@ -1510,7 +1513,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateRunning(void) // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateExited(void) +CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateExited() { const CMIUtilString strId(CMIUtilString::Format("%ld", 1)); CMICmnMIValueConst miValueConst(strId); @@ -1518,8 +1521,8 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateExited(void) CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, miValueResult); CMICmnMIValueConst miValueConst2("i1"); CMICmnMIValueResult miValueResult2("group-id", miValueConst2); - bool bOk = miOutOfBandRecord.Add(miValueResult2); - bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord); + miOutOfBandRecord.Add(miValueResult2); + bool bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord); if (bOk) { CMICmnMIValueConst miValueConst3("i1"); @@ -1527,7 +1530,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateExited(void) CMICmnMIOutOfBandRecord miOutOfBandRecord2(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, miValueResult3); CMICmnMIValueConst miValueConst2("0"); CMICmnMIValueResult miValueResult2("exit-code", miValueConst2); - bOk = miOutOfBandRecord2.Add(miValueResult2); + miOutOfBandRecord2.Add(miValueResult2); bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBandRecord2); } if (bOk) @@ -1553,7 +1556,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateExited(void) // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::GetProcessStdout(void) +CMICmnLLDBDebuggerHandleEvents::GetProcessStdout() { CMIUtilString text; std::unique_ptr<char[]> apStdoutBuffer(new char[1024]); @@ -1569,7 +1572,7 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStdout(void) if (nNewLine == std::string::npos) break; - const CMIUtilString line(text.substr(0, nNewLine + 1).c_str()); + const CMIUtilString line(text.substr(0, nNewLine + 1)); text.erase(0, nNewLine + 1); const bool bEscapeQuotes(true); CMICmnMIValueConst miValueConst(line.Escape(bEscapeQuotes)); @@ -1606,7 +1609,7 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStdout(void) // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::GetProcessStderr(void) +CMICmnLLDBDebuggerHandleEvents::GetProcessStderr() { CMIUtilString text; std::unique_ptr<char[]> apStderrBuffer(new char[1024]); @@ -1622,7 +1625,7 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStderr(void) if (nNewLine == std::string::npos) break; - const CMIUtilString line(text.substr(0, nNewLine + 1).c_str()); + const CMIUtilString line(text.substr(0, nNewLine + 1)); const bool bEscapeQuotes(true); CMICmnMIValueConst miValueConst(line.Escape(bEscapeQuotes)); CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, miValueConst); @@ -1656,7 +1659,7 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStderr(void) // Throws: None. //-- bool -CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void) +CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges() { CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); lldb::SBProcess sbProcess = rSessionInfo.GetProcess(); @@ -1686,8 +1689,8 @@ CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void) CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, miValueResult); const CMICmnMIValueConst miValueConst2("i1"); const CMICmnMIValueResult miValueResult2("group-id", miValueConst2); - bool bOk = miOutOfBand.Add(miValueResult2); - bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBand); + miOutOfBand.Add(miValueResult2); + bool bOk = MiOutOfBandRecordToStdout(miOutOfBand); if (!bOk) return MIstatus::failure; } @@ -1726,8 +1729,8 @@ CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void) CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, miValueResult); const CMICmnMIValueConst miValueConst2("i1"); const CMICmnMIValueResult miValueResult2("group-id", miValueConst2); - bool bOk = miOutOfBand.Add(miValueResult2); - bOk = bOk && MiOutOfBandRecordToStdout(miOutOfBand); + miOutOfBand.Add(miValueResult2); + bool bOk = MiOutOfBandRecordToStdout(miOutOfBand); if (!bOk) return MIstatus::failure; diff --git a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h index 1abb52012979..f5075d10209c 100644 --- a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h +++ b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h @@ -26,9 +26,6 @@ class CMICmnMIOutOfBandRecord; // MI Out-of-band records from the information inside the event object. // These records are then pushed to stdout. // A singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 02/03/2014. -// Changes: None. //-- class CMICmnLLDBDebuggerHandleEvents : public CMICmnBase, public MI::ISingleton<CMICmnLLDBDebuggerHandleEvents> { @@ -36,20 +33,20 @@ class CMICmnLLDBDebuggerHandleEvents : public CMICmnBase, public MI::ISingleton< // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; // bool HandleEvent(const lldb::SBEvent &vEvent, bool &vrbHandledEvent); // Methods: private: - /* ctor */ CMICmnLLDBDebuggerHandleEvents(void); + /* ctor */ CMICmnLLDBDebuggerHandleEvents(); /* ctor */ CMICmnLLDBDebuggerHandleEvents(const CMICmnLLDBDebuggerHandleEvents &); void operator=(const CMICmnLLDBDebuggerHandleEvents &); // - bool ChkForStateChanges(void); - bool GetProcessStdout(void); - bool GetProcessStderr(void); + bool ChkForStateChanges(); + bool GetProcessStdout(); + bool GetProcessStderr(); bool HandleEventSBBreakPoint(const lldb::SBEvent &vEvent); bool HandleEventSBBreakpointCmn(const lldb::SBEvent &vEvent); bool HandleEventSBBreakpointAdded(const lldb::SBEvent &vEvent); @@ -61,13 +58,13 @@ class CMICmnLLDBDebuggerHandleEvents : public CMICmnBase, public MI::ISingleton< bool HandleEventSBThreadSuspended(const lldb::SBEvent &vEvent); bool HandleEventSBCommandInterpreter(const lldb::SBEvent &vEvent); bool HandleProcessEventBroadcastBitStateChanged(const lldb::SBEvent &vEvent); - bool HandleProcessEventStateRunning(void); - bool HandleProcessEventStateExited(void); + bool HandleProcessEventStateRunning(); + bool HandleProcessEventStateExited(); bool HandleProcessEventStateStopped(const lldb::SBEvent &vrEvent, bool &vwrbShouldBrk); - bool HandleProcessEventStopReasonTrace(void); - bool HandleProcessEventStopReasonBreakpoint(void); + bool HandleProcessEventStopReasonTrace(); + bool HandleProcessEventStopReasonBreakpoint(); bool HandleProcessEventStopSignal(const lldb::SBEvent &vrEvent); - bool HandleProcessEventStopException(void); + bool HandleProcessEventStopException(); bool HandleProcessEventStateSuspended(const lldb::SBEvent &vEvent); bool HandleTargetEventBroadcastBitModulesLoaded(const lldb::SBEvent &vEvent); bool HandleTargetEventBroadcastBitModulesUnloaded(const lldb::SBEvent &vEvent); @@ -79,12 +76,12 @@ class CMICmnLLDBDebuggerHandleEvents : public CMICmnBase, public MI::ISingleton< bool MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, const lldb::SBBreakpoint &vBrkPt); bool TextToStdout(const CMIUtilString &vrTxt); bool TextToStderr(const CMIUtilString &vrTxt); - bool UpdateSelectedThread(void); + bool UpdateSelectedThread(); // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmnLLDBDebuggerHandleEvents(void) override; + /* dtor */ ~CMICmnLLDBDebuggerHandleEvents() override; void InitializeSignals(); bool m_bSignalsInitialized; MIuint64 m_SIGINT; diff --git a/tools/lldb-mi/MICmnLLDBProxySBValue.h b/tools/lldb-mi/MICmnLLDBProxySBValue.h index c9cd3a9f995f..2ae3acf3d7e7 100644 --- a/tools/lldb-mi/MICmnLLDBProxySBValue.h +++ b/tools/lldb-mi/MICmnLLDBProxySBValue.h @@ -21,9 +21,6 @@ class CMIUtilString; //++ ============================================================================ // Details: MI proxy wrapper class to lldb::SBValue. The class provides functionality // to assist in the use of SBValue's particular function usage. -// Gotchas: None. -// Authors: Illya Rudkin 03/04/2014. -// Changes: None. //-- class CMICmnLLDBProxySBValue { diff --git a/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp b/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp index 45f030bf535f..d3d85d32c038 100644 --- a/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp +++ b/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp @@ -9,6 +9,7 @@ // Third party headers: #include <cinttypes> +#include "lldb/API/SBTypeSummary.h" // In-house headers: #include "MICmnLLDBUtilSBValue.h" @@ -44,7 +45,7 @@ CMICmnLLDBUtilSBValue::CMICmnLLDBUtilSBValue(const lldb::SBValue &vrValue, const // Return: None. // Throws: None. //-- -CMICmnLLDBUtilSBValue::~CMICmnLLDBUtilSBValue(void) +CMICmnLLDBUtilSBValue::~CMICmnLLDBUtilSBValue() { } @@ -57,10 +58,10 @@ CMICmnLLDBUtilSBValue::~CMICmnLLDBUtilSBValue(void) // Throws: None. //-- CMIUtilString -CMICmnLLDBUtilSBValue::GetName(void) const +CMICmnLLDBUtilSBValue::GetName() const { const char *pName = m_bValidSBValue ? m_rValue.GetName() : nullptr; - const CMIUtilString text((pName != nullptr) ? pName : m_pUnkwn); + const CMIUtilString text((pName != nullptr) ? pName : CMIUtilString()); return text; } @@ -122,31 +123,13 @@ CMICmnLLDBUtilSBValue::GetSimpleValue(const bool vbHandleArrayType, CMIUtilStrin const MIuint nChildren = m_rValue.GetNumChildren(); if (nChildren == 0) { - if (m_bHandleCharType && IsCharType()) - { - vwrValue = GetSimpleValueChar(); - return MIstatus::success; - } - else - { - const char *pValue = m_rValue.GetValue(); - vwrValue = pValue != nullptr ? pValue : m_pUnkwn; - return MIstatus::success; - } + vwrValue = GetValueSummary(!m_bHandleCharType && IsCharType(), m_pUnkwn); + return MIstatus::success; } else if (IsPointerType()) { - if (m_bHandleCharType && IsFirstChildCharType()) - { - vwrValue = GetSimpleValueCStringPointer(); - return MIstatus::success; - } - else - { - const char *pValue = m_rValue.GetValue(); - vwrValue = pValue != nullptr ? pValue : m_pUnkwn; - return MIstatus::success; - } + vwrValue = GetValueSummary(!m_bHandleCharType && IsPointeeCharType(), m_pUnkwn); + return MIstatus::success; } else if (IsArrayType()) { @@ -156,7 +139,7 @@ CMICmnLLDBUtilSBValue::GetSimpleValue(const bool vbHandleArrayType, CMIUtilStrin bPrintCharArrayAsString) && bPrintCharArrayAsString; if (bPrintCharArrayAsString && m_bHandleCharType && IsFirstChildCharType()) { - vwrValue = GetSimpleValueCStringArray(); + vwrValue = GetValueSummary(false); return MIstatus::success; } else if (vbHandleArrayType) @@ -165,140 +148,17 @@ CMICmnLLDBUtilSBValue::GetSimpleValue(const bool vbHandleArrayType, CMIUtilStrin return MIstatus::success; } } - - // Composite variable type i.e. struct - return MIstatus::failure; -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieve from the LLDB SB Value object the char value of the variable. -// Type: Method. -// Args: None. -// Return: CMIUtilString - The char value of the variable. -// Throws: None. -//-- -CMIUtilString -CMICmnLLDBUtilSBValue::GetSimpleValueChar(void) const -{ - const uint64_t value = m_rValue.GetValueAsUnsigned(); - if (value == 0) - { - const uint64_t nFailValue = 1; - if (nFailValue == m_rValue.GetValueAsUnsigned(nFailValue)) - return m_pUnkwn; - } - - const lldb::BasicType eType = m_rValue.GetType().GetBasicType(); - switch (eType) - { - default: - assert(0 && "value must be a char type"); - case lldb::eBasicTypeChar: - case lldb::eBasicTypeSignedChar: - case lldb::eBasicTypeUnsignedChar: - { - const CMIUtilString prefix(CMIUtilString::ConvertToPrintableASCII((char)value)); - return CMIUtilString::Format("%" PRIu8 " '%s'", (uint8_t)value, prefix.c_str()); - } - case lldb::eBasicTypeChar16: - { - const CMIUtilString prefix(CMIUtilString::ConvertToPrintableASCII((char16_t)value)); - return CMIUtilString::Format("U+%04" PRIx16 " u'%s'", (uint16_t)value, prefix.c_str()); - } - case lldb::eBasicTypeChar32: - { - const CMIUtilString prefix(CMIUtilString::ConvertToPrintableASCII((char32_t)value)); - return CMIUtilString::Format("U+%08" PRIx32 " U'%s'", (uint32_t)value, prefix.c_str()); - } - } -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieve from the LLDB SB Value object of type char* the c-string value. -// Type: Method. -// Args: None. -// Return: CMIUtilString - The c-string value of the variable. -// Throws: None. -//-- -CMIUtilString -CMICmnLLDBUtilSBValue::GetSimpleValueCStringPointer(void) const -{ - const char *value = m_rValue.GetValue(); - if (value == nullptr) - return m_pUnkwn; - - lldb::SBValue child = m_rValue.GetChildAtIndex(0); - const lldb::BasicType eType = child.GetType().GetBasicType(); - switch (eType) + else { - default: - assert(0 && "child must be a char type"); - case lldb::eBasicTypeChar: - case lldb::eBasicTypeSignedChar: - case lldb::eBasicTypeUnsignedChar: - { - // FIXME Add slashes before double quotes - const CMIUtilString prefix(ReadCStringFromHostMemory<char>(child).AddSlashes()); - // Note code that has const in will not show the text suffix to the string pointer - // i.e. const char * pMyStr = "blah"; ==> "0x00007000"" <-- Eclipse shows this - // but char * pMyStr = "blah"; ==> "0x00007000" "blah"" <-- Eclipse shows this - return CMIUtilString::Format("%s \"%s\"", value, prefix.c_str()); - } - case lldb::eBasicTypeChar16: - { - // FIXME Add slashes before double quotes - const CMIUtilString prefix(ReadCStringFromHostMemory<char16_t>(child).AddSlashes()); - return CMIUtilString::Format("%s u\"%s\"", value, prefix.c_str()); - } - case lldb::eBasicTypeChar32: - { - // FIXME Add slashes before double quotes - const CMIUtilString prefix(ReadCStringFromHostMemory<char32_t>(child).AddSlashes()); - return CMIUtilString::Format("%s U\"%s\"", value, prefix.c_str()); - } + // Treat composite value which has registered summary + // (for example with AddCXXSummary) as simple value + vwrValue = GetValueSummary(false); + if (!vwrValue.empty()) + return MIstatus::success; } -} -//++ ------------------------------------------------------------------------------------ -// Details: Retrieve from the LLDB SB Value object of type char[] the c-string value. -// Type: Method. -// Args: None. -// Return: CMIUtilString - The c-string value of the variable. -// Throws: None. -//-- -CMIUtilString -CMICmnLLDBUtilSBValue::GetSimpleValueCStringArray(void) const -{ - const MIuint nChildren = m_rValue.GetNumChildren(); - lldb::SBValue child = m_rValue.GetChildAtIndex(0); - const lldb::BasicType eType = child.GetType().GetBasicType(); - switch (eType) - { - default: - assert(0 && "value must be a char[] type"); - case lldb::eBasicTypeChar: - case lldb::eBasicTypeSignedChar: - case lldb::eBasicTypeUnsignedChar: - { - // FIXME Add slashes before double quotes - const CMIUtilString prefix(ReadCStringFromHostMemory<char>(m_rValue, nChildren).AddSlashes()); - // TODO: to match char* it should be the following - // return CMIUtilString::Format("[%u] \"%s\"", nChildren, prefix.c_str()); - return CMIUtilString::Format("\"%s\"", prefix.c_str()); - } - case lldb::eBasicTypeChar16: - { - // FIXME Add slashes before double quotes - const CMIUtilString prefix(ReadCStringFromHostMemory<char16_t>(m_rValue, nChildren).AddSlashes()); - return CMIUtilString::Format("u\"%s\"", prefix.c_str()); - } - case lldb::eBasicTypeChar32: - { - // FIXME Add slashes before double quotes - const CMIUtilString prefix(ReadCStringFromHostMemory<char32_t>(m_rValue, nChildren).AddSlashes()); - return CMIUtilString::Format("U\"%s\"", prefix.c_str()); - } - } + // Composite variable type i.e. struct + return MIstatus::failure; } bool @@ -341,34 +201,61 @@ CMICmnLLDBUtilSBValue::GetCompositeValue(const bool vbPrintFieldNames, CMICmnMIV { const bool bUseSpacing = true; const CMICmnMIValueResult miValueResult(utilMember.GetName(), miValueConst, bUseSpacing); - const bool bOk = vwrMiValueTuple.Add(miValueResult, bUseSpacing); - if (!bOk) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueResult, bUseSpacing); } else { const bool bUseSpacing = false; - const bool bOk = vwrMiValueTuple.Add(miValueConst, bUseSpacing); - if (!bOk) - return MIstatus::failure; + vwrMiValueTuple.Add(miValueConst, bUseSpacing); } } return MIstatus::success; } +// Returns value or value + summary, depending on valueOnly parameter value. +// If result is an empty string returns failVal. +CMIUtilString +CMICmnLLDBUtilSBValue::GetValueSummary(bool valueOnly, const CMIUtilString& failVal) const +{ + if (!m_rValue.IsValid()) + return failVal; + + CMIUtilString value, valSummary; + const char* c_value = m_rValue.GetValue(); + if (valueOnly) + return c_value == nullptr ? failVal : c_value; + + const char* c_summary = m_rValue.GetSummary(); + if (c_value) + value = c_value; + else if (c_summary == nullptr) + return failVal; + + if (c_summary && c_summary[0]) + { + valSummary = c_summary; + lldb::SBTypeSummary summary = m_rValue.GetTypeSummary(); + if (summary.IsValid() && summary.DoesPrintValue(m_rValue) && !value.empty()) + { + valSummary.insert(0, value + " "); + } + return valSummary; + } + // no summary - return just value + return value; +} + //++ ------------------------------------------------------------------------------------ -// Details: Retrieve the flag stating whether this value object is a char type or some -// other type. Char type can be signed or unsigned. -// Type: Method. -// Args: None. +// Details: Check that basic type is a char type. Char type can be signed or unsigned. +// Type: Static. +// Args: eType - type to check // Return: bool - True = Yes is a char type, false = some other type. // Throws: None. //-- bool -CMICmnLLDBUtilSBValue::IsCharType(void) const +CMICmnLLDBUtilSBValue::IsCharBasicType(lldb::BasicType eType) { - const lldb::BasicType eType = m_rValue.GetType().GetBasicType(); switch (eType) { case lldb::eBasicTypeChar: @@ -383,6 +270,21 @@ CMICmnLLDBUtilSBValue::IsCharType(void) const } //++ ------------------------------------------------------------------------------------ +// Details: Retrieve the flag stating whether this value object is a char type or some +// other type. Char type can be signed or unsigned. +// Type: Method. +// Args: None. +// Return: bool - True = Yes is a char type, false = some other type. +// Throws: None. +//-- +bool +CMICmnLLDBUtilSBValue::IsCharType() const +{ + const lldb::BasicType eType = m_rValue.GetType().GetBasicType(); + return IsCharBasicType(eType); +} + +//++ ------------------------------------------------------------------------------------ // Details: Retrieve the flag stating whether first child value object of *this object is // a char type or some other type. Returns false if there are not children. Char // type can be signed or unsigned. @@ -392,7 +294,7 @@ CMICmnLLDBUtilSBValue::IsCharType(void) const // Throws: None. //-- bool -CMICmnLLDBUtilSBValue::IsFirstChildCharType(void) const +CMICmnLLDBUtilSBValue::IsFirstChildCharType() const { const MIuint nChildren = m_rValue.GetNumChildren(); @@ -406,6 +308,28 @@ CMICmnLLDBUtilSBValue::IsFirstChildCharType(void) const } //++ ------------------------------------------------------------------------------------ +// Details: Retrieve the flag stating whether pointee object of *this object is +// a char type or some other type. Returns false if there are not children. Char +// type can be signed or unsigned. +// Type: Method. +// Args: None. +// Return: bool - True = Yes is a char type, false = some other type. +// Throws: None. +//-- +bool +CMICmnLLDBUtilSBValue::IsPointeeCharType() const +{ + const MIuint nChildren = m_rValue.GetNumChildren(); + + // Is it a basic type + if (nChildren == 0) + return false; + + const lldb::BasicType eType = m_rValue.GetType().GetPointeeType().GetBasicType(); + return IsCharBasicType(eType); +} + +//++ ------------------------------------------------------------------------------------ // Details: Retrieve the flag stating whether this value object is a integer type or some // other type. Char type can be signed or unsigned and short or long/very long. // Type: Method. @@ -414,7 +338,7 @@ CMICmnLLDBUtilSBValue::IsFirstChildCharType(void) const // Throws: None. //-- bool -CMICmnLLDBUtilSBValue::IsIntegerType(void) const +CMICmnLLDBUtilSBValue::IsIntegerType() const { const lldb::BasicType eType = m_rValue.GetType().GetBasicType(); return ((eType == lldb::eBasicTypeShort) || (eType == lldb::eBasicTypeUnsignedShort) || @@ -433,7 +357,7 @@ CMICmnLLDBUtilSBValue::IsIntegerType(void) const // Throws: None. //-- bool -CMICmnLLDBUtilSBValue::IsPointerType(void) const +CMICmnLLDBUtilSBValue::IsPointerType() const { return m_rValue.GetType().IsPointerType(); } @@ -447,7 +371,7 @@ CMICmnLLDBUtilSBValue::IsPointerType(void) const // Throws: None. //-- bool -CMICmnLLDBUtilSBValue::IsArrayType(void) const +CMICmnLLDBUtilSBValue::IsArrayType() const { return m_rValue.GetType().IsArrayType(); } @@ -476,11 +400,11 @@ CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory(lldb::SBValue &vrValue, const M return m_pUnkwn; else if (ch == 0) break; - result.append(CMIUtilString::ConvertToPrintableASCII(ch)); + result.append(CMIUtilString::ConvertToPrintableASCII(ch, true /* bEscapeQuotes */)); addr += sizeof(ch); } - return result.c_str(); + return result; } //++ ------------------------------------------------------------------------------------ @@ -491,7 +415,7 @@ CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory(lldb::SBValue &vrValue, const M // Throws: None. //-- bool -CMICmnLLDBUtilSBValue::IsNameUnknown(void) const +CMICmnLLDBUtilSBValue::IsNameUnknown() const { const CMIUtilString name(GetName()); return (name == m_pUnkwn); @@ -505,7 +429,7 @@ CMICmnLLDBUtilSBValue::IsNameUnknown(void) const // Throws: None. //-- bool -CMICmnLLDBUtilSBValue::IsValueUnknown(void) const +CMICmnLLDBUtilSBValue::IsValueUnknown() const { const CMIUtilString value(GetValue()); return (value == m_pUnkwn); @@ -519,7 +443,7 @@ CMICmnLLDBUtilSBValue::IsValueUnknown(void) const // Throws: None. //-- CMIUtilString -CMICmnLLDBUtilSBValue::GetTypeName(void) const +CMICmnLLDBUtilSBValue::GetTypeName() const { const char *pName = m_bValidSBValue ? m_rValue.GetTypeName() : nullptr; const CMIUtilString text((pName != nullptr) ? pName : m_pUnkwn); @@ -535,7 +459,7 @@ CMICmnLLDBUtilSBValue::GetTypeName(void) const // Throws: None. //-- CMIUtilString -CMICmnLLDBUtilSBValue::GetTypeNameDisplay(void) const +CMICmnLLDBUtilSBValue::GetTypeNameDisplay() const { const char *pName = m_bValidSBValue ? m_rValue.GetDisplayTypeName() : nullptr; const CMIUtilString text((pName != nullptr) ? pName : m_pUnkwn); @@ -551,7 +475,7 @@ CMICmnLLDBUtilSBValue::GetTypeNameDisplay(void) const // Throws: None. //-- bool -CMICmnLLDBUtilSBValue::IsValid(void) const +CMICmnLLDBUtilSBValue::IsValid() const { return m_bValidSBValue; } @@ -565,7 +489,7 @@ CMICmnLLDBUtilSBValue::IsValid(void) const // Throws: None. //-- bool -CMICmnLLDBUtilSBValue::HasName(void) const +CMICmnLLDBUtilSBValue::HasName() const { bool bHasAName = false; @@ -586,7 +510,7 @@ CMICmnLLDBUtilSBValue::HasName(void) const // Throws: None. //-- bool -CMICmnLLDBUtilSBValue::IsLLDBVariable(void) const +CMICmnLLDBUtilSBValue::IsLLDBVariable() const { return (GetName().at(0) == '$'); } diff --git a/tools/lldb-mi/MICmnLLDBUtilSBValue.h b/tools/lldb-mi/MICmnLLDBUtilSBValue.h index 8bb6783a2a34..36264da1e16d 100644 --- a/tools/lldb-mi/MICmnLLDBUtilSBValue.h +++ b/tools/lldb-mi/MICmnLLDBUtilSBValue.h @@ -22,9 +22,6 @@ class CMIUtilString; //++ ============================================================================ // Details: Utility helper class to lldb::SBValue. Using a lldb::SBValue extract // value object information to help form verbose debug information. -// Gotchas: None. -// Authors: Illya Rudkin 08/07/2014. -// Changes: None. //-- class CMICmnLLDBUtilSBValue { @@ -32,31 +29,34 @@ class CMICmnLLDBUtilSBValue public: /* ctor */ CMICmnLLDBUtilSBValue(const lldb::SBValue &vrValue, const bool vbHandleCharType = false, const bool vbHandleArrayType = true); - /* dtor */ ~CMICmnLLDBUtilSBValue(void); + /* dtor */ ~CMICmnLLDBUtilSBValue(); // - CMIUtilString GetName(void) const; + CMIUtilString GetName() const; CMIUtilString GetValue(const bool vbExpandAggregates = false) const; - CMIUtilString GetTypeName(void) const; - CMIUtilString GetTypeNameDisplay(void) const; - bool IsCharType(void) const; - bool IsFirstChildCharType(void) const; - bool IsIntegerType(void) const; - bool IsPointerType(void) const; - bool IsArrayType(void) const; - bool IsLLDBVariable(void) const; - bool IsNameUnknown(void) const; - bool IsValueUnknown(void) const; - bool IsValid(void) const; - bool HasName(void) const; + CMIUtilString GetTypeName() const; + CMIUtilString GetTypeNameDisplay() const; + bool IsCharType() const; + bool IsFirstChildCharType() const; + bool IsPointeeCharType() const; + bool IsIntegerType() const; + bool IsPointerType() const; + bool IsArrayType() const; + bool IsLLDBVariable() const; + bool IsNameUnknown() const; + bool IsValueUnknown() const; + bool IsValid() const; + bool HasName() const; // Methods: private: template <typename charT> CMIUtilString ReadCStringFromHostMemory(lldb::SBValue &vrValue, const MIuint vnMaxLen = UINT32_MAX) const; bool GetSimpleValue(const bool vbHandleArrayType, CMIUtilString &vrValue) const; - CMIUtilString GetSimpleValueChar(void) const; - CMIUtilString GetSimpleValueCStringPointer(void) const; - CMIUtilString GetSimpleValueCStringArray(void) const; bool GetCompositeValue(const bool vbPrintFieldNames, CMICmnMIValueTuple &vwrMiValueTuple, const MIuint vnDepth = 1) const; + CMIUtilString GetValueSummary(bool valueOnly, const CMIUtilString& failVal = CMIUtilString()) const; + + // Statics: + private: + static bool IsCharBasicType(lldb::BasicType eType); // Attributes: private: diff --git a/tools/lldb-mi/MICmnLog.cpp b/tools/lldb-mi/MICmnLog.cpp index a88ba6b5782a..e85ddba316a4 100644 --- a/tools/lldb-mi/MICmnLog.cpp +++ b/tools/lldb-mi/MICmnLog.cpp @@ -21,7 +21,7 @@ // Return: None. // Throws: None. //-- -CMICmnLog::CMICmnLog(void) +CMICmnLog::CMICmnLog() : m_bEnabled(false) , m_bInitializingATM(false) { @@ -35,7 +35,7 @@ CMICmnLog::CMICmnLog(void) // Return: None. // Throws: None. //-- -CMICmnLog::~CMICmnLog(void) +CMICmnLog::~CMICmnLog() { Shutdown(); } @@ -49,7 +49,7 @@ CMICmnLog::~CMICmnLog(void) // Throws: None. //-- bool -CMICmnLog::Initialize(void) +CMICmnLog::Initialize() { m_clientUsageRefCnt++; @@ -102,7 +102,7 @@ CMICmnLog::Initialize(void) // Throws: None. //-- bool -CMICmnLog::Shutdown(void) +CMICmnLog::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -144,7 +144,7 @@ CMICmnLog::SetEnabled(const bool vbYes) // Throws: None. //-- bool -CMICmnLog::GetEnabled(void) const +CMICmnLog::GetEnabled() const { return m_bEnabled; } @@ -158,7 +158,7 @@ CMICmnLog::GetEnabled(void) const // Throws: None. //-- bool -CMICmnLog::UnregisterMediumAll(void) +CMICmnLog::UnregisterMediumAll() { MapMediumToName_t::const_iterator it = m_mapMediumToName.begin(); for (; it != m_mapMediumToName.end(); it++) @@ -325,7 +325,7 @@ CMICmnLog::WriteLog(const CMIUtilString &vData) // Throws: None. //-- const CMIUtilString & -CMICmnLog::GetErrorDescription(void) const +CMICmnLog::GetErrorDescription() const { return m_strMILastErrorDescription; } @@ -351,7 +351,7 @@ CMICmnLog::SetErrorDescription(const CMIUtilString &vrTxt) const // Throws: None. //-- void -CMICmnLog::ClrErrorDescription(void) const +CMICmnLog::ClrErrorDescription() const { m_strMILastErrorDescription = CMIUtilString(""); } diff --git a/tools/lldb-mi/MICmnLog.h b/tools/lldb-mi/MICmnLog.h index f0ae534e840b..a346cf4bd1db 100644 --- a/tools/lldb-mi/MICmnLog.h +++ b/tools/lldb-mi/MICmnLog.h @@ -26,9 +26,6 @@ // *this logs initialization so it will always have a file log for the // application. // Singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 01/02/2012. -// Changes: None. //-- class CMICmnLog : public MI::ISingleton<CMICmnLog> { @@ -59,17 +56,17 @@ class CMICmnLog : public MI::ISingleton<CMICmnLog> class IMedium { public: - virtual bool Initialize(void) = 0; - virtual const CMIUtilString &GetName(void) const = 0; + virtual bool Initialize() = 0; + virtual const CMIUtilString &GetName() const = 0; virtual bool Write(const CMIUtilString &vData, const ELogVerbosity veType) = 0; - virtual const CMIUtilString &GetError(void) const = 0; - virtual bool Shutdown(void) = 0; + virtual const CMIUtilString &GetError() const = 0; + virtual bool Shutdown() = 0; // Not part of the interface, ignore // AD: This virtual destructor seems to hit a bug in the stdlib // where vector delete is incorrectly called. Workaround is // to comment this out while I investigate. - /* dtor */ virtual ~IMedium(void) {} + /* dtor */ virtual ~IMedium() {} }; // Statics: @@ -82,30 +79,30 @@ class CMICmnLog : public MI::ISingleton<CMICmnLog> bool UnregisterMedium(const IMedium &vrMedium); bool Write(const CMIUtilString &vData, const ELogVerbosity veType); bool SetEnabled(const bool vbYes); - bool GetEnabled(void) const; + bool GetEnabled() const; // MI common object handling - duplicate of CMICmnBase functions, necessary for LINUX build // Done to stop locking on object construction init circular dependency. - const CMIUtilString &GetErrorDescription(void) const; + const CMIUtilString &GetErrorDescription() const; void SetErrorDescription(const CMIUtilString &vrTxt) const; - void ClrErrorDescription(void) const; + void ClrErrorDescription() const; // Overridden: public: // From MI::ISingleton - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; // Methods: private: - /* ctor */ CMICmnLog(void); + /* ctor */ CMICmnLog(); /* ctor */ CMICmnLog(const CMICmnLog &); void operator=(const CMICmnLog &); // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmnLog(void) override; + /* dtor */ ~CMICmnLog() override; // Typedef: private: @@ -115,7 +112,7 @@ class CMICmnLog : public MI::ISingleton<CMICmnLog> // Methods: private: bool HaveMediumAlready(const IMedium &vrMedium) const; - bool UnregisterMediumAll(void); + bool UnregisterMediumAll(); // Attributes: private: diff --git a/tools/lldb-mi/MICmnLogMediumFile.cpp b/tools/lldb-mi/MICmnLogMediumFile.cpp index 67b8086221cd..e74fca9aa5b0 100644 --- a/tools/lldb-mi/MICmnLogMediumFile.cpp +++ b/tools/lldb-mi/MICmnLogMediumFile.cpp @@ -10,13 +10,6 @@ // In-house headers: #include "MICmnLogMediumFile.h" #include "MICmnResources.h" -#if defined(_MSC_VER) -#include "MIUtilSystemWindows.h" -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__linux__) -#include "MIUtilSystemLinux.h" -#elif defined(__APPLE__) -#include "MIUtilSystemOsx.h" -#endif // defined( _MSC_VER ) //++ ------------------------------------------------------------------------------------ // Details: CMICmnLogMediumFile constructor. @@ -25,11 +18,11 @@ // Return: None. // Throws: None. //-- -CMICmnLogMediumFile::CMICmnLogMediumFile(void) +CMICmnLogMediumFile::CMICmnLogMediumFile() : m_constThisMediumName(MIRSRC(IDS_MEDIUMFILE_NAME)) , m_constMediumFileNameFormat("lldb-mi-%s.log") , m_strMediumFileName(MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH)) - , m_strMediumFileDirectory(MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH)) + , m_strMediumFileDirectory(".") , m_fileNamePath(MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH)) , m_eVerbosityType(CMICmnLog::eLogVerbosity_Log) , m_strDate(CMIUtilDateTimeStd().GetDate()) @@ -44,7 +37,7 @@ CMICmnLogMediumFile::CMICmnLogMediumFile(void) // Return: None. // Throws: None. //-- -CMICmnLogMediumFile::~CMICmnLogMediumFile(void) +CMICmnLogMediumFile::~CMICmnLogMediumFile() { } @@ -56,7 +49,7 @@ CMICmnLogMediumFile::~CMICmnLogMediumFile(void) // Throws: None. //-- CMICmnLogMediumFile & -CMICmnLogMediumFile::Instance(void) +CMICmnLogMediumFile::Instance() { static CMICmnLogMediumFile instance; @@ -72,12 +65,10 @@ CMICmnLogMediumFile::Instance(void) // Throws: None. //-- bool -CMICmnLogMediumFile::Initialize(void) +CMICmnLogMediumFile::Initialize() { - m_bInitialized = CMIUtilSystem().GetLogFilesPath(m_strMediumFileDirectory); - m_bInitialized &= FileFormFileNamePath(); - - return m_bInitialized; + m_bInitialized = true; + return FileFormFileNamePath(); } //++ ------------------------------------------------------------------------------------ @@ -88,7 +79,7 @@ CMICmnLogMediumFile::Initialize(void) // Throws: None. //-- bool -CMICmnLogMediumFile::Shutdown(void) +CMICmnLogMediumFile::Shutdown() { if (m_bInitialized) { @@ -106,7 +97,7 @@ CMICmnLogMediumFile::Shutdown(void) // Throws: None. //-- const CMIUtilString & -CMICmnLogMediumFile::GetName(void) const +CMICmnLogMediumFile::GetName() const { return m_constThisMediumName; } @@ -155,7 +146,7 @@ CMICmnLogMediumFile::Write(const CMIUtilString &vData, const CMICmnLog::ELogVerb // Throws: None. //-- const CMIUtilString & -CMICmnLogMediumFile::GetError(void) const +CMICmnLogMediumFile::GetError() const { return m_strMILastErrorDescription; } @@ -183,7 +174,7 @@ CMICmnLogMediumFile::SetVerbosity(const MIuint veType) // Throws: None. //-- MIuint -CMICmnLogMediumFile::GetVerbosity(void) const +CMICmnLogMediumFile::GetVerbosity() const { return m_eVerbosityType; } @@ -210,29 +201,22 @@ CMICmnLogMediumFile::FileWriteEnglish(const CMIUtilString &vData) // Throws: None. //-- bool -CMICmnLogMediumFile::FileFormFileNamePath(void) +CMICmnLogMediumFile::FileFormFileNamePath() { ClrErrorDescription(); m_fileNamePath = MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH); - if (m_strMediumFileDirectory.compare(MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH)) != 0) - { - CMIUtilDateTimeStd date; - m_strMediumFileName = CMIUtilString::Format(m_constMediumFileNameFormat.c_str(), date.GetDateTimeLogFilename().c_str()); + CMIUtilDateTimeStd date; + m_strMediumFileName = CMIUtilString::Format(m_constMediumFileNameFormat.c_str(), date.GetDateTimeLogFilename().c_str()); #if defined(_MSC_VER) - m_fileNamePath = CMIUtilString::Format("%s\\%s", m_strMediumFileDirectory.c_str(), m_strMediumFileName.c_str()); + m_fileNamePath = CMIUtilString::Format("%s\\%s", m_strMediumFileDirectory.c_str(), m_strMediumFileName.c_str()); #else - m_fileNamePath = CMIUtilString::Format("%s/%s", m_strMediumFileDirectory.c_str(), m_strMediumFileName.c_str()); + m_fileNamePath = CMIUtilString::Format("%s/%s", m_strMediumFileDirectory.c_str(), m_strMediumFileName.c_str()); #endif // defined ( _MSC_VER ) - return MIstatus::success; - } - - SetErrorDescription(MIRSRC(IDE_MEDIUMFILE_ERR_GET_FILE_PATHNAME_SYS)); - - return MIstatus::failure; + return MIstatus::success; } //++ ------------------------------------------------------------------------------------ @@ -243,7 +227,7 @@ CMICmnLogMediumFile::FileFormFileNamePath(void) // Throws: None. //-- const CMIUtilString & -CMICmnLogMediumFile::GetFileNamePath(void) const +CMICmnLogMediumFile::GetFileNamePath() const { return m_fileNamePath; } @@ -256,7 +240,7 @@ CMICmnLogMediumFile::GetFileNamePath(void) const // Throws: None. //-- const CMIUtilString & -CMICmnLogMediumFile::GetFileName(void) const +CMICmnLogMediumFile::GetFileName() const { return m_strMediumFileName; } @@ -332,7 +316,7 @@ CMICmnLogMediumFile::ConvertLogVerbosityTypeToId(const CMICmnLog::ELogVerbosity // Throws: None. //-- bool -CMICmnLogMediumFile::IsOk(void) const +CMICmnLogMediumFile::IsOk() const { return m_file.IsOk(); } @@ -346,7 +330,7 @@ CMICmnLogMediumFile::IsOk(void) const // Throws: None. //-- bool -CMICmnLogMediumFile::IsFileExist(void) const +CMICmnLogMediumFile::IsFileExist() const { return m_file.IsFileExist(GetFileNamePath()); } @@ -360,7 +344,7 @@ CMICmnLogMediumFile::IsFileExist(void) const // Throws: None. //-- bool -CMICmnLogMediumFile::FileWriteHeader(void) +CMICmnLogMediumFile::FileWriteHeader() { return FileWriteEnglish(ConvertCr(m_fileHeaderTxt)); } @@ -419,7 +403,7 @@ CMICmnLogMediumFile::SetHeaderTxt(const CMIUtilString &vText) // Throws: None. //-- const CMIUtilString & -CMICmnLogMediumFile::GetLineReturn(void) const +CMICmnLogMediumFile::GetLineReturn() const { return m_file.GetLineReturn(); } diff --git a/tools/lldb-mi/MICmnLogMediumFile.h b/tools/lldb-mi/MICmnLogMediumFile.h index b79baf184880..249da71a42c0 100644 --- a/tools/lldb-mi/MICmnLogMediumFile.h +++ b/tools/lldb-mi/MICmnLogMediumFile.h @@ -23,49 +23,46 @@ // which the Logger when given data to write to registered medium comes // *this medium. // Singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 30/01/2014. -// Changes: None. //-- class CMICmnLogMediumFile : public CMICmnBase, public CMICmnLog::IMedium { // Statics: public: - static CMICmnLogMediumFile &Instance(void); + static CMICmnLogMediumFile &Instance(); // Methods: public: bool SetHeaderTxt(const CMIUtilString &vText); bool SetVerbosity(const MIuint veType); - MIuint GetVerbosity(void) const; - const CMIUtilString &GetFileName(void) const; - const CMIUtilString &GetFileNamePath(void) const; - bool IsOk(void) const; - bool IsFileExist(void) const; - const CMIUtilString &GetLineReturn(void) const; + MIuint GetVerbosity() const; + const CMIUtilString &GetFileName() const; + const CMIUtilString &GetFileNamePath() const; + bool IsOk() const; + bool IsFileExist() const; + const CMIUtilString &GetLineReturn() const; bool SetDirectory(const CMIUtilString &vPath); // Overridden: public: // From CMICmnBase - /* dtor */ ~CMICmnLogMediumFile(void) override; + /* dtor */ ~CMICmnLogMediumFile() override; // From CMICmnLog::IMedium - bool Initialize(void) override; - const CMIUtilString &GetName(void) const override; + bool Initialize() override; + const CMIUtilString &GetName() const override; bool Write(const CMIUtilString &vData, const CMICmnLog::ELogVerbosity veType) override; - const CMIUtilString &GetError(void) const override; - bool Shutdown(void) override; + const CMIUtilString &GetError() const override; + bool Shutdown() override; // Methods: private: - /* ctor */ CMICmnLogMediumFile(void); + /* ctor */ CMICmnLogMediumFile(); /* ctor */ CMICmnLogMediumFile(const CMICmnLogMediumFile &); void operator=(const CMICmnLogMediumFile &); bool FileWriteEnglish(const CMIUtilString &vData); - bool FileFormFileNamePath(void); + bool FileFormFileNamePath(); CMIUtilString MassagedData(const CMIUtilString &vData, const CMICmnLog::ELogVerbosity veType); - bool FileWriteHeader(void); + bool FileWriteHeader(); char ConvertLogVerbosityTypeToId(const CMICmnLog::ELogVerbosity veType) const; CMIUtilString ConvertCr(const CMIUtilString &vData) const; diff --git a/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp b/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp index 84c6695de354..e633e5a61fa9 100644 --- a/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp +++ b/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp @@ -1,4 +1,4 @@ -//===-- MICmnMIOutOfBandRecord.cpp --------------------------------------------*- C++ -*-===// +//===-- MICmnMIOutOfBandRecord.cpp ------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,43 +7,106 @@ // //===----------------------------------------------------------------------===// +// Third Party Headers: +#include <assert.h> + // In-house headers: #include "MICmnMIOutOfBandRecord.h" #include "MICmnResources.h" // Instantiations: -CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_MapOutOfBandToOutOfBandText = { - {CMICmnMIOutOfBandRecord::eOutOfBand_Running, "running"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "stopped"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "breakpoint-created"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "breakpoint-modified"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_Thread, ""}, // "" Meant to be empty - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "thread-group-added"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "thread-group-exited"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "thread-group-removed"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "thread-group-started"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "thread-created"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "thread-exited"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "thread-selected"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded, "library-loaded"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded, "library-unloaded"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, ""}}; -CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_constMapAsyncRecordTextToToken = { - {CMICmnMIOutOfBandRecord::eOutOfBand_Running, "*"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "*"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "="}, - {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "="}, - {CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "@"}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "="}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "="}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "="}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "="}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "="}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "="}, - {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "="}, - {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded, "="}, - {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded, "="}, - {CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, "@"}}; +static const char * +MapOutOfBandToText(CMICmnMIOutOfBandRecord::OutOfBand_e veType) +{ + switch (veType) + { + case CMICmnMIOutOfBandRecord::eOutOfBand_Running: + return "running"; + case CMICmnMIOutOfBandRecord::eOutOfBand_Stopped: + return "stopped"; + case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated: + return "breakpoint-created"; + case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified: + return "breakpoint-modified"; + case CMICmnMIOutOfBandRecord::eOutOfBand_Thread: + return ""; // "" Meant to be empty + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded: + return "thread-group-added"; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited: + return "thread-group-exited"; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved: + return "thread-group-removed"; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted: + return "thread-group-started"; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated: + return "thread-created"; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited: + return "thread-exited"; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected: + return "thread-selected"; + case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded: + return "library-loaded"; + case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded: + return "library-unloaded"; + case CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput: + return ""; + } + assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e"); + return NULL; +} + +static const char * +MapOutOfBandToToken(CMICmnMIOutOfBandRecord::OutOfBand_e veType) +{ + switch (veType) + { + case CMICmnMIOutOfBandRecord::eOutOfBand_Running: + return "*"; + case CMICmnMIOutOfBandRecord::eOutOfBand_Stopped: + return "*"; + case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated: + return "="; + case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified: + return "="; + case CMICmnMIOutOfBandRecord::eOutOfBand_Thread: + return "@"; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded: + return "="; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited: + return "="; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved: + return "="; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted: + return "="; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated: + return "="; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited: + return "="; + case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected: + return "="; + case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded: + return "="; + case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded: + return "="; + case CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput: + return "@"; + } + assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e"); + return NULL; +} + +//++ ------------------------------------------------------------------------------------ +// Details: Build the Out-of-band record's mandatory data part. The part up to the first +// (additional) result i.e. async-record ==> "*" type. +// Args: veType - (R) A MI Out-of-Band enumeration. +// Return: CMIUtilString - The async record text. +// Throws: None. +//-- +static CMIUtilString +BuildAsyncRecord(CMICmnMIOutOfBandRecord::OutOfBand_e veType) +{ + return CMIUtilString::Format("%s%s", MapOutOfBandToToken(veType), MapOutOfBandToText(veType)); +} //++ ------------------------------------------------------------------------------------ // Details: CMICmnMIOutOfBandRecord constructor. @@ -52,7 +115,7 @@ CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_constMapAsyncRecordTex // Return: None. // Throws: None. //-- -CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(void) +CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord() : m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION)) { } @@ -64,11 +127,9 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(void) // Return: None. // Throws: None. //-- -CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType) - : m_eResultAsyncRecordClass(veType) - , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION)) +CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType) + : m_strAsyncRecord(BuildAsyncRecord(veType)) { - BuildAsyncRecord(); } //++ ------------------------------------------------------------------------------------ @@ -79,11 +140,9 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType) // Return: None. // Throws: None. //-- -CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const CMICmnMIValueConst &vConst) - : m_eResultAsyncRecordClass(veType) - , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION)) +CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType, const CMICmnMIValueConst &vConst) + : m_strAsyncRecord(BuildAsyncRecord(veType)) { - BuildAsyncRecord(); m_strAsyncRecord += vConst.GetString(); } @@ -95,13 +154,10 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const // Return: None. // Throws: None. //-- -CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const CMICmnMIValueResult &vResult) - : m_eResultAsyncRecordClass(veType) - , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION)) - , m_partResult(vResult) +CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType, const CMICmnMIValueResult &vResult) + : m_strAsyncRecord(BuildAsyncRecord(veType)) { - BuildAsyncRecord(); - Add(m_partResult); + Add(vResult); } //++ ------------------------------------------------------------------------------------ @@ -111,7 +167,7 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const // Return: None. // Throws: None. //-- -CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord(void) +CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord() { } @@ -126,44 +182,21 @@ CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord(void) // Throws: None. //-- const CMIUtilString & -CMICmnMIOutOfBandRecord::GetString(void) const +CMICmnMIOutOfBandRecord::GetString() const { return m_strAsyncRecord; } //++ ------------------------------------------------------------------------------------ -// Details: Build the Out-of-band record's mandatory data part. The part up to the first -// (additional) result i.e. async-record ==> "*" type. -// Type: Method. -// Args: None. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMICmnMIOutOfBandRecord::BuildAsyncRecord(void) -{ - const char *pFormat = "%s%s"; - const CMIUtilString &rStrAsyncRecord(ms_MapOutOfBandToOutOfBandText[m_eResultAsyncRecordClass]); - const CMIUtilString &rStrToken(ms_constMapAsyncRecordTextToToken[m_eResultAsyncRecordClass]); - m_strAsyncRecord = CMIUtilString::Format(pFormat, rStrToken.c_str(), rStrAsyncRecord.c_str()); - - return MIstatus::success; -} - -//++ ------------------------------------------------------------------------------------ // Details: Add to *this Out-of-band record additional information. // Type: Method. // Args: vResult - (R) A MI result object. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIOutOfBandRecord::Add(const CMICmnMIValueResult &vResult) { m_strAsyncRecord += ","; m_strAsyncRecord += vResult.GetString(); - - return MIstatus::success; } diff --git a/tools/lldb-mi/MICmnMIOutOfBandRecord.h b/tools/lldb-mi/MICmnMIOutOfBandRecord.h index 6277e860878f..ad18e6ccac9c 100644 --- a/tools/lldb-mi/MICmnMIOutOfBandRecord.h +++ b/tools/lldb-mi/MICmnMIOutOfBandRecord.h @@ -9,9 +9,6 @@ #pragma once -// Third party headers: -#include <map> - // In-house headers: #include "MICmnBase.h" #include "MIUtilString.h" @@ -37,9 +34,6 @@ // // More information see: // http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html// -// Gotchas: None. -// Authors: Illya Rudkin 24/02/2014. -// Changes: None. //-- class CMICmnMIOutOfBandRecord : public CMICmnBase { @@ -64,40 +58,25 @@ class CMICmnMIOutOfBandRecord : public CMICmnBase eOutOfBand_ThreadSelected, eOutOfBand_TargetModuleLoaded, eOutOfBand_TargetModuleUnloaded, - eOutOfBand_TargetStreamOutput, - eOutOfBand_count // Always the last one + eOutOfBand_TargetStreamOutput }; - // Typedefs: - public: - typedef std::map<OutOfBand_e, CMIUtilString> MapOutOfBandToOutOfBandText_t; - typedef std::map<OutOfBand_e, CMIUtilString> MapOutOfBandToToken_t; - // Methods: public: - /* ctor */ CMICmnMIOutOfBandRecord(void); - /* ctor */ CMICmnMIOutOfBandRecord(const OutOfBand_e veType); - /* ctor */ CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const CMICmnMIValueConst &vConst); - /* ctor */ CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const CMICmnMIValueResult &vResult); + /* ctor */ CMICmnMIOutOfBandRecord(); + /* ctor */ CMICmnMIOutOfBandRecord(OutOfBand_e veType); + /* ctor */ CMICmnMIOutOfBandRecord(OutOfBand_e veType, const CMICmnMIValueConst &vConst); + /* ctor */ CMICmnMIOutOfBandRecord(OutOfBand_e veType, const CMICmnMIValueResult &vResult); // - const CMIUtilString &GetString(void) const; - bool Add(const CMICmnMIValueResult &vResult); + const CMIUtilString &GetString() const; + void Add(const CMICmnMIValueResult &vResult); // Overridden: public: // From CMICmnBase - /* dtor */ ~CMICmnMIOutOfBandRecord(void) override; - - // Methods: - private: - bool BuildAsyncRecord(void); + /* dtor */ ~CMICmnMIOutOfBandRecord() override; // Attributes: private: - static MapOutOfBandToOutOfBandText_t ms_constMapOutOfBandToAsyncRecordText; - static MapOutOfBandToToken_t ms_constMapOutOfBandTextToToken; - // - OutOfBand_e m_eResultAsyncRecordClass; CMIUtilString m_strAsyncRecord; // Holds the text version of the result record to date - CMICmnMIValueResult m_partResult; }; diff --git a/tools/lldb-mi/MICmnMIResultRecord.cpp b/tools/lldb-mi/MICmnMIResultRecord.cpp index 49a31c87519f..0348f8941316 100644 --- a/tools/lldb-mi/MICmnMIResultRecord.cpp +++ b/tools/lldb-mi/MICmnMIResultRecord.cpp @@ -1,4 +1,4 @@ -//===-- Platform.cpp --------------------------------------------*- C++ -*-===// +//===-- MICmnMIResultRecord.cpp ---------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,18 +7,53 @@ // //===----------------------------------------------------------------------===// +// Third Party Headers: +#include <assert.h> + // In-house headers: #include "MICmnMIResultRecord.h" #include "MICmnResources.h" -// Instantiations: -CMICmnMIResultRecord::MapResultClassToResultClassText_t ms_MapResultClassToResultClassText = { - {CMICmnMIResultRecord::eResultClass_Done, "done"}, - {CMICmnMIResultRecord::eResultClass_Running, "running"}, - {CMICmnMIResultRecord::eResultClass_Connected, "connected"}, - {CMICmnMIResultRecord::eResultClass_Error, "error"}, - {CMICmnMIResultRecord::eResultClass_Exit, "exit"}}; -const CMIUtilString CMICmnMIResultRecord::ms_constStrResultRecordHat("^"); +//++ ------------------------------------------------------------------------------------ +// Details: Map a result class to the corresponding string. +// Args: veType - (R) A MI result class enumeration. +// Return: const char* - The string corresponding to the result class. +// Throws: None. +//-- +static const char* +MapResultClassToResultClassText(CMICmnMIResultRecord::ResultClass_e veType) +{ + switch (veType) + { + case CMICmnMIResultRecord::eResultClass_Done: + return "done"; + case CMICmnMIResultRecord::eResultClass_Running: + return "running"; + case CMICmnMIResultRecord::eResultClass_Connected: + return "connected"; + case CMICmnMIResultRecord::eResultClass_Error: + return "error"; + case CMICmnMIResultRecord::eResultClass_Exit: + return "exit"; + } + assert(false && "unknown CMICmnMIResultRecord::ResultClass_e"); + return NULL; +} + +//++ ------------------------------------------------------------------------------------ +// Details: Build the result record's mandatory data part. The part up to the first +// (additional) result i.e. result-record ==> [ token ] "^" result-class. +// Args: vrToken - (R) The command's transaction ID or token. +// veType - (R) A MI result class enumeration. +// Return: CMIUtilString & - MI result record mandatory data +// Throws: None. +//-- +static const CMIUtilString +BuildResultRecord(const CMIUtilString &vrToken, CMICmnMIResultRecord::ResultClass_e veType) +{ + const char *pStrResultRecord = MapResultClassToResultClassText(veType); + return CMIUtilString::Format("%s^%s", vrToken.c_str(), pStrResultRecord); +} //++ ------------------------------------------------------------------------------------ // Details: CMICmnMIResultRecord constructor. @@ -27,7 +62,7 @@ const CMIUtilString CMICmnMIResultRecord::ms_constStrResultRecordHat("^"); // Return: None. // Throws: None. //-- -CMICmnMIResultRecord::CMICmnMIResultRecord(void) +CMICmnMIResultRecord::CMICmnMIResultRecord() : m_strResultRecord(MIRSRC(IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION)) { } @@ -40,12 +75,9 @@ CMICmnMIResultRecord::CMICmnMIResultRecord(void) // Return: None. // Throws: None. //-- -CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType) - : m_strResultRecordToken(vrToken) - , m_eResultRecordResultClass(veType) - , m_strResultRecord(MIRSRC(IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION)) +CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType) + : m_strResultRecord(BuildResultRecord(vrToken, veType)) { - BuildResultRecord(); } //++ ------------------------------------------------------------------------------------ @@ -57,14 +89,10 @@ CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, const R // Return: None. // Throws: None. //-- -CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType, const CMICmnMIValueResult &vValue) - : m_strResultRecordToken(vrToken) - , m_eResultRecordResultClass(veType) - , m_strResultRecord(MIRSRC(IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION)) - , m_partResult(vValue) +CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType, const CMICmnMIValueResult &vValue) + : m_strResultRecord(BuildResultRecord(vrToken, veType)) { - BuildResultRecord(); - Add(m_partResult); + Add(vValue); } //++ ------------------------------------------------------------------------------------ @@ -74,7 +102,7 @@ CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, const R // Return: None. // Throws: None. //-- -CMICmnMIResultRecord::~CMICmnMIResultRecord(void) +CMICmnMIResultRecord::~CMICmnMIResultRecord() { } @@ -89,44 +117,21 @@ CMICmnMIResultRecord::~CMICmnMIResultRecord(void) // Throws: None. //-- const CMIUtilString & -CMICmnMIResultRecord::GetString(void) const +CMICmnMIResultRecord::GetString() const { return m_strResultRecord; } //++ ------------------------------------------------------------------------------------ -// Details: Build the result record's mandatory data part. The part up to the first -// (additional) result i.e. result-record ==> [ token ] "^" result-class. -// Type: Method. -// Args: None. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMICmnMIResultRecord::BuildResultRecord(void) -{ - const char *pFormat = "%s%s%s"; - const CMIUtilString &rStrResultRecord(ms_MapResultClassToResultClassText[m_eResultRecordResultClass]); - m_strResultRecord = - CMIUtilString::Format(pFormat, m_strResultRecordToken.c_str(), ms_constStrResultRecordHat.c_str(), rStrResultRecord.c_str()); - - return MIstatus::success; -} - -//++ ------------------------------------------------------------------------------------ // Details: Add to *this result record additional information. // Type: Method. // Args: vMIValue - (R) A MI value derived object. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIResultRecord::Add(const CMICmnMIValue &vMIValue) { m_strResultRecord += ","; m_strResultRecord += vMIValue.GetString(); - - return MIstatus::success; } diff --git a/tools/lldb-mi/MICmnMIResultRecord.h b/tools/lldb-mi/MICmnMIResultRecord.h index 981cf3635d53..4408324a3709 100644 --- a/tools/lldb-mi/MICmnMIResultRecord.h +++ b/tools/lldb-mi/MICmnMIResultRecord.h @@ -9,9 +9,6 @@ #pragma once -// Third party headers: -#include <map> - // In-house headers: #include "MICmnBase.h" #include "MIUtilString.h" @@ -39,9 +36,6 @@ // be returned. // More information see: // http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html -// Gotchas: None. -// Authors: Illya Rudkin 24/02/2014. -// Changes: None. //-- class CMICmnMIResultRecord : public CMICmnBase { @@ -56,39 +50,24 @@ class CMICmnMIResultRecord : public CMICmnBase eResultClass_Running, eResultClass_Connected, eResultClass_Error, - eResultClass_Exit, - eResultClass_count // Always the last one + eResultClass_Exit }; - // Typedefs: - public: - typedef std::map<ResultClass_e, CMIUtilString> MapResultClassToResultClassText_t; - // Methods: public: - /* ctor */ CMICmnMIResultRecord(void); - /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType); - /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType, const CMICmnMIValueResult &vValue); + /* ctor */ CMICmnMIResultRecord(); + /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType); + /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType, const CMICmnMIValueResult &vValue); // - const CMIUtilString &GetString(void) const; - bool Add(const CMICmnMIValue &vMIValue); + const CMIUtilString &GetString() const; + void Add(const CMICmnMIValue &vMIValue); // Overridden: public: // From CMICmnBase - /* dtor */ ~CMICmnMIResultRecord(void) override; - - // Methods: - private: - bool BuildResultRecord(void); + /* dtor */ ~CMICmnMIResultRecord() override; // Attributes: private: - static const CMIUtilString ms_constStrResultRecordHat; - static MapResultClassToResultClassText_t ms_constMapResultClassToResultClassText; - // - CMIUtilString m_strResultRecordToken; - ResultClass_e m_eResultRecordResultClass; CMIUtilString m_strResultRecord; // Holds the text version of the result record to date - CMICmnMIValueResult m_partResult; }; diff --git a/tools/lldb-mi/MICmnMIValue.cpp b/tools/lldb-mi/MICmnMIValue.cpp index 2f7041427d2b..d5895d70099b 100644 --- a/tools/lldb-mi/MICmnMIValue.cpp +++ b/tools/lldb-mi/MICmnMIValue.cpp @@ -1,4 +1,4 @@ -//===-- Platform.cpp --------------------------------------------*- C++ -*-===// +//===-- MICmnMIValue.cpp ----------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -18,7 +18,7 @@ // Return: None. // Throws: None. //-- -CMICmnMIValue::CMICmnMIValue(void) +CMICmnMIValue::CMICmnMIValue() : m_strValue(MIRSRC(IDS_WORD_INVALIDBRKTS)) , m_bJustConstructed(true) { @@ -31,7 +31,7 @@ CMICmnMIValue::CMICmnMIValue(void) // Return: None. // Throws: None. //-- -CMICmnMIValue::~CMICmnMIValue(void) +CMICmnMIValue::~CMICmnMIValue() { } @@ -46,7 +46,7 @@ CMICmnMIValue::~CMICmnMIValue(void) // Throws: None. //-- const CMIUtilString & -CMICmnMIValue::GetString(void) const +CMICmnMIValue::GetString() const { return m_strValue; } diff --git a/tools/lldb-mi/MICmnMIValue.h b/tools/lldb-mi/MICmnMIValue.h index 6a372e600146..dd11d6a8d118 100644 --- a/tools/lldb-mi/MICmnMIValue.h +++ b/tools/lldb-mi/MICmnMIValue.h @@ -28,22 +28,19 @@ // list ==> "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]" // More information see: // http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html -// Gotchas: None. -// Authors: Illya Rudkin 24/02/2014. -// Changes: None. //-- class CMICmnMIValue : public CMICmnBase { // Methods: public: - /* ctor */ CMICmnMIValue(void); + /* ctor */ CMICmnMIValue(); // - const CMIUtilString &GetString(void) const; + const CMIUtilString &GetString() const; // Overridden: public: // From CMICmnBase - /* dtor */ ~CMICmnMIValue(void) override; + /* dtor */ ~CMICmnMIValue() override; // Attributes: protected: diff --git a/tools/lldb-mi/MICmnMIValueConst.cpp b/tools/lldb-mi/MICmnMIValueConst.cpp index dd4b99344293..d8b11e9cb064 100644 --- a/tools/lldb-mi/MICmnMIValueConst.cpp +++ b/tools/lldb-mi/MICmnMIValueConst.cpp @@ -1,4 +1,4 @@ -//===-- Platform.cpp --------------------------------------------*- C++ -*-===// +//===-- MICmnMIValueConst.cpp -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -49,7 +49,7 @@ CMICmnMIValueConst::CMICmnMIValueConst(const CMIUtilString &vString, const bool // Return: None. // Throws: None. //-- -CMICmnMIValueConst::~CMICmnMIValueConst(void) +CMICmnMIValueConst::~CMICmnMIValueConst() { } @@ -62,7 +62,7 @@ CMICmnMIValueConst::~CMICmnMIValueConst(void) // Throws: None. //-- bool -CMICmnMIValueConst::BuildConst(void) +CMICmnMIValueConst::BuildConst() { if (m_strPartConst.length() != 0) { diff --git a/tools/lldb-mi/MICmnMIValueConst.h b/tools/lldb-mi/MICmnMIValueConst.h index 403619438919..7f6333e12f45 100644 --- a/tools/lldb-mi/MICmnMIValueConst.h +++ b/tools/lldb-mi/MICmnMIValueConst.h @@ -30,10 +30,6 @@ // http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html // // The text formed in *this Result class is stripped of any '\n' characters. -// -// Gotchas: None. -// Authors: Illya Rudkin 24/02/2014. -// Changes: None. //-- class CMICmnMIValueConst : public CMICmnMIValue { @@ -45,11 +41,11 @@ class CMICmnMIValueConst : public CMICmnMIValue // Overridden: public: // From CMICmnBase - /* dtor */ ~CMICmnMIValueConst(void) override; + /* dtor */ ~CMICmnMIValueConst() override; // Methods: private: - bool BuildConst(void); + bool BuildConst(); // Attributes: private: diff --git a/tools/lldb-mi/MICmnMIValueList.cpp b/tools/lldb-mi/MICmnMIValueList.cpp index 30888cfbb59c..e4d3f408422b 100644 --- a/tools/lldb-mi/MICmnMIValueList.cpp +++ b/tools/lldb-mi/MICmnMIValueList.cpp @@ -1,4 +1,4 @@ -//===-- Platform.cpp --------------------------------------------*- C++ -*-===// +//===-- MICmnMIValueList.cpp ------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -61,7 +61,7 @@ CMICmnMIValueList::CMICmnMIValueList(const CMICmnMIValue &vValue) // Return: None. // Throws: None. //-- -CMICmnMIValueList::~CMICmnMIValueList(void) +CMICmnMIValueList::~CMICmnMIValueList() { } @@ -69,17 +69,14 @@ CMICmnMIValueList::~CMICmnMIValueList(void) // Details: Build the result value's mandatory data part, one tuple // Type: Method. // Args: None. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool -CMICmnMIValueList::BuildList(void) +void +CMICmnMIValueList::BuildList() { const char *pFormat = "[%s]"; m_strValue = CMIUtilString::Format(pFormat, m_strValue.c_str()); - - return MIstatus::success; } //++ ------------------------------------------------------------------------------------ @@ -88,14 +85,13 @@ CMICmnMIValueList::BuildList(void) // will return MIstatus::failure. // Type: Method. // Args: vResult - (R) The MI result object. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIValueList::Add(const CMICmnMIValueResult &vResult) { - return BuildList(vResult); + BuildList(vResult); } //++ ------------------------------------------------------------------------------------ @@ -104,14 +100,13 @@ CMICmnMIValueList::Add(const CMICmnMIValueResult &vResult) // will return MIstatus::failure. // Type: Method. // Args: vValue - (R) The MI value object. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIValueList::Add(const CMICmnMIValue &vValue) { - return BuildList(vValue); + BuildList(vValue); } //++ ------------------------------------------------------------------------------------ @@ -120,11 +115,10 @@ CMICmnMIValueList::Add(const CMICmnMIValue &vValue) // will return MIstatus::failure. // Type: Method. // Args: vResult - (R) The MI result object. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIValueList::BuildList(const CMICmnMIValueResult &vResult) { // Clear out the default "<Invalid>" text @@ -132,14 +126,13 @@ CMICmnMIValueList::BuildList(const CMICmnMIValueResult &vResult) { m_bJustConstructed = false; m_strValue = vResult.GetString(); - return BuildList(); + BuildList(); + return; } const CMIUtilString data(ExtractContentNoBrackets()); const char *pFormat = "[%s,%s]"; m_strValue = CMIUtilString::Format(pFormat, data.c_str(), vResult.GetString().c_str()); - - return MIstatus::success; } //++ ------------------------------------------------------------------------------------ @@ -148,11 +141,10 @@ CMICmnMIValueList::BuildList(const CMICmnMIValueResult &vResult) // will return MIstatus::failure. // Type: Method. // Args: vValue - (R) The MI value object. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIValueList::BuildList(const CMICmnMIValue &vValue) { // Clear out the default "<Invalid>" text @@ -160,7 +152,8 @@ CMICmnMIValueList::BuildList(const CMICmnMIValue &vValue) { m_bJustConstructed = false; m_strValue = vValue.GetString(); - return BuildList(); + BuildList(); + return; } // Remove already present '[' and ']' from the start and end @@ -170,8 +163,6 @@ CMICmnMIValueList::BuildList(const CMICmnMIValue &vValue) m_strValue = m_strValue.substr(1, len - 2); const char *pFormat = "[%s,%s]"; m_strValue = CMIUtilString::Format(pFormat, m_strValue.c_str(), vValue.GetString().c_str()); - - return MIstatus::success; } //++ ------------------------------------------------------------------------------------ @@ -183,7 +174,7 @@ CMICmnMIValueList::BuildList(const CMICmnMIValue &vValue) // Throws: None. //-- CMIUtilString -CMICmnMIValueList::ExtractContentNoBrackets(void) const +CMICmnMIValueList::ExtractContentNoBrackets() const { CMIUtilString data(m_strValue); diff --git a/tools/lldb-mi/MICmnMIValueList.h b/tools/lldb-mi/MICmnMIValueList.h index 26a217dfc77b..0796cbe575c1 100644 --- a/tools/lldb-mi/MICmnMIValueList.h +++ b/tools/lldb-mi/MICmnMIValueList.h @@ -29,9 +29,6 @@ // list ==> "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]" // More information see: // http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html -// Gotchas: None. -// Authors: Illya Rudkin 24/02/2014. -// Changes: None. //-- class CMICmnMIValueList : public CMICmnMIValue { @@ -41,18 +38,18 @@ class CMICmnMIValueList : public CMICmnMIValue /* ctor */ CMICmnMIValueList(const CMICmnMIValueResult &vResult); /* ctor */ CMICmnMIValueList(const CMICmnMIValue &vValue); // - bool Add(const CMICmnMIValueResult &vResult); - bool Add(const CMICmnMIValue &vValue); - CMIUtilString ExtractContentNoBrackets(void) const; + void Add(const CMICmnMIValueResult &vResult); + void Add(const CMICmnMIValue &vValue); + CMIUtilString ExtractContentNoBrackets() const; // Overridden: public: // From CMICmnBase - /* dtor */ ~CMICmnMIValueList(void) override; + /* dtor */ ~CMICmnMIValueList() override; // Methods: private: - bool BuildList(void); - bool BuildList(const CMICmnMIValueResult &vResult); - bool BuildList(const CMICmnMIValue &vResult); + void BuildList(); + void BuildList(const CMICmnMIValueResult &vResult); + void BuildList(const CMICmnMIValue &vResult); }; diff --git a/tools/lldb-mi/MICmnMIValueResult.cpp b/tools/lldb-mi/MICmnMIValueResult.cpp index 55d93ce40ca7..d86f724b7cf9 100644 --- a/tools/lldb-mi/MICmnMIValueResult.cpp +++ b/tools/lldb-mi/MICmnMIValueResult.cpp @@ -1,4 +1,4 @@ -//===-- Platform.cpp --------------------------------------------*- C++ -*-===// +//===-- MICmnMIValueResult.cpp ----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -21,7 +21,7 @@ const CMIUtilString CMICmnMIValueResult::ms_constStrEqual("="); // Return: None. // Throws: None. //-- -CMICmnMIValueResult::CMICmnMIValueResult(void) +CMICmnMIValueResult::CMICmnMIValueResult() : m_bEmptyConstruction(true) { } @@ -68,7 +68,7 @@ CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable, const // Return: None. // Throws: None. //-- -CMICmnMIValueResult::~CMICmnMIValueResult(void) +CMICmnMIValueResult::~CMICmnMIValueResult() { } @@ -76,17 +76,14 @@ CMICmnMIValueResult::~CMICmnMIValueResult(void) // Details: Build the MI value result string. // Type: Method. // Args: None. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool -CMICmnMIValueResult::BuildResult(void) +void +CMICmnMIValueResult::BuildResult() { const char *pFormat = m_bUseSpacing ? "%s %s %s" : "%s%s%s"; m_strValue = CMIUtilString::Format(pFormat, m_strPartVariable.c_str(), ms_constStrEqual.c_str(), m_partMIValue.GetString().c_str()); - - return MIstatus::success; } //++ ------------------------------------------------------------------------------------ @@ -94,18 +91,15 @@ CMICmnMIValueResult::BuildResult(void) // Type: Method. // Args: vrVariable - (R) MI value's name. // vrValue - (R) The MI value. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIValueResult::BuildResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue) { const char *pFormat = m_bUseSpacing ? "%s, %s %s %s" : "%s,%s%s%s"; m_strValue = CMIUtilString::Format(pFormat, m_strValue.c_str(), vVariable.c_str(), ms_constStrEqual.c_str(), vValue.GetString().c_str()); - - return MIstatus::success; } //++ ------------------------------------------------------------------------------------ @@ -117,16 +111,16 @@ CMICmnMIValueResult::BuildResult(const CMIUtilString &vVariable, const CMICmnMIV // MIstatus::failure - Functional failed. // Throws: None. //-- -bool +void CMICmnMIValueResult::Add(const CMIUtilString &vrVariable, const CMICmnMIValue &vrValue) { if (!m_bEmptyConstruction) - return BuildResult(vrVariable, vrValue); + BuildResult(vrVariable, vrValue); else { m_bEmptyConstruction = false; m_strPartVariable = vrVariable; m_partMIValue = vrValue; - return BuildResult(); + BuildResult(); } } diff --git a/tools/lldb-mi/MICmnMIValueResult.h b/tools/lldb-mi/MICmnMIValueResult.h index 7c8e9801e4a0..cd96520b98f9 100644 --- a/tools/lldb-mi/MICmnMIValueResult.h +++ b/tools/lldb-mi/MICmnMIValueResult.h @@ -28,29 +28,26 @@ // list ==> "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]" // More information see: // http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html -// Gotchas: None. -// Authors: Illya Rudkin 24/02/2014. -// Changes: None. //-- class CMICmnMIValueResult : public CMICmnMIValue { // Methods: public: - /* ctor */ CMICmnMIValueResult(void); + /* ctor */ CMICmnMIValueResult(); /* ctor */ CMICmnMIValueResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue); /* ctor */ CMICmnMIValueResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue, const bool vbUseSpacing); // - bool Add(const CMIUtilString &vVariable, const CMICmnMIValue &vValue); + void Add(const CMIUtilString &vVariable, const CMICmnMIValue &vValue); // Overridden: public: // From CMICmnBase - /* dtor */ ~CMICmnMIValueResult(void) override; + /* dtor */ ~CMICmnMIValueResult() override; // Methods: private: - bool BuildResult(void); - bool BuildResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue); + void BuildResult(); + void BuildResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue); // Attributes: private: diff --git a/tools/lldb-mi/MICmnMIValueTuple.cpp b/tools/lldb-mi/MICmnMIValueTuple.cpp index aa92b1f62280..4ff1d6ce1fa5 100644 --- a/tools/lldb-mi/MICmnMIValueTuple.cpp +++ b/tools/lldb-mi/MICmnMIValueTuple.cpp @@ -1,4 +1,4 @@ -//===-- Platform.cpp --------------------------------------------*- C++ -*-===// +//===-- MICmnMIValueTuple.cpp -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,7 +17,7 @@ // Return: None. // Throws: None. //-- -CMICmnMIValueTuple::CMICmnMIValueTuple(void) +CMICmnMIValueTuple::CMICmnMIValueTuple() : m_bSpaceAfterComma(false) { m_strValue = "{}"; @@ -61,7 +61,7 @@ CMICmnMIValueTuple::CMICmnMIValueTuple(const CMICmnMIValueResult &vResult, const // Return: None. // Throws: None. //-- -CMICmnMIValueTuple::~CMICmnMIValueTuple(void) +CMICmnMIValueTuple::~CMICmnMIValueTuple() { } @@ -69,28 +69,24 @@ CMICmnMIValueTuple::~CMICmnMIValueTuple(void) // Details: Build the result value's mandatory data part, one tuple // Type: Method. // Args: None. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool -CMICmnMIValueTuple::BuildTuple(void) +void +CMICmnMIValueTuple::BuildTuple() { const char *pFormat = "{%s}"; m_strValue = CMIUtilString::Format(pFormat, m_strValue.c_str()); - - return MIstatus::success; } //++ ------------------------------------------------------------------------------------ // Details: Add another MI result object to the value's list of tuples. // Type: Method. // Args: vResult - (R) The MI result object. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIValueTuple::BuildTuple(const CMICmnMIValueResult &vResult) { // Clear out the default "<Invalid>" text @@ -98,7 +94,8 @@ CMICmnMIValueTuple::BuildTuple(const CMICmnMIValueResult &vResult) { m_bJustConstructed = false; m_strValue = vResult.GetString(); - return BuildTuple(); + BuildTuple(); + return; } if (m_strValue[0] == '{') @@ -112,19 +109,16 @@ CMICmnMIValueTuple::BuildTuple(const CMICmnMIValueResult &vResult) const char *pFormat = m_bSpaceAfterComma ? "{%s, %s}" : "{%s,%s}"; m_strValue = CMIUtilString::Format(pFormat, m_strValue.c_str(), vResult.GetString().c_str()); - - return MIstatus::success; } //++ ------------------------------------------------------------------------------------ // Details: Add string value to the value's list of tuples. // Type: Method. // Args: vValue - (R) The string object. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIValueTuple::BuildTuple(const CMIUtilString &vValue) { // Clear out the default "<Invalid>" text @@ -132,14 +126,13 @@ CMICmnMIValueTuple::BuildTuple(const CMIUtilString &vValue) { m_bJustConstructed = false; m_strValue = vValue; - return BuildTuple(); + BuildTuple(); + return; } const CMIUtilString data(ExtractContentNoBrackets()); const char *pFormat = m_bSpaceAfterComma ? "{%s, %s}" : "{%s,%s}"; m_strValue = CMIUtilString::Format(pFormat, data.c_str(), vValue.c_str()); - - return MIstatus::success; } //++ ------------------------------------------------------------------------------------ @@ -148,14 +141,13 @@ CMICmnMIValueTuple::BuildTuple(const CMIUtilString &vValue) // will return MIstatus::failure. // Type: Method. // Args: vValue - (R) The MI value object. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIValueTuple::Add(const CMICmnMIValueResult &vResult) { - return BuildTuple(vResult); + BuildTuple(vResult); } //++ ------------------------------------------------------------------------------------ @@ -165,15 +157,14 @@ CMICmnMIValueTuple::Add(const CMICmnMIValueResult &vResult) // Type: Method. // Args: vValue - (R) The MI value object. // vbUseSpacing - (R) True = put space separators into the string, false = no spaces used. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIValueTuple::Add(const CMICmnMIValueResult &vResult, const bool vbUseSpacing) { m_bSpaceAfterComma = vbUseSpacing; - return BuildTuple(vResult); + BuildTuple(vResult); } //++ ------------------------------------------------------------------------------------ @@ -183,15 +174,14 @@ CMICmnMIValueTuple::Add(const CMICmnMIValueResult &vResult, const bool vbUseSpac // Type: Method. // Args: vValue - (R) The MI value object. // vbUseSpacing - (R) True = put space separators into the string, false = no spaces used. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. +// Return: None. // Throws: None. //-- -bool +void CMICmnMIValueTuple::Add(const CMICmnMIValueConst &vValue, const bool vbUseSpacing) { m_bSpaceAfterComma = vbUseSpacing; - return BuildTuple(vValue.GetString()); + BuildTuple(vValue.GetString()); } //++ ------------------------------------------------------------------------------------ @@ -203,7 +193,7 @@ CMICmnMIValueTuple::Add(const CMICmnMIValueConst &vValue, const bool vbUseSpacin // Throws: None. //-- CMIUtilString -CMICmnMIValueTuple::ExtractContentNoBrackets(void) const +CMICmnMIValueTuple::ExtractContentNoBrackets() const { CMIUtilString data(m_strValue); diff --git a/tools/lldb-mi/MICmnMIValueTuple.h b/tools/lldb-mi/MICmnMIValueTuple.h index ecf5402dc54c..8f36b4f69d01 100644 --- a/tools/lldb-mi/MICmnMIValueTuple.h +++ b/tools/lldb-mi/MICmnMIValueTuple.h @@ -30,33 +30,30 @@ // list ==> "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]" // More information see: // http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_22.html -// Gotchas: None. -// Authors: Illya Rudkin 24/02/2014. -// Changes: None. //-- class CMICmnMIValueTuple : public CMICmnMIValue { // Methods: public: - /* ctor */ CMICmnMIValueTuple(void); + /* ctor */ CMICmnMIValueTuple(); /* ctor */ CMICmnMIValueTuple(const CMICmnMIValueResult &vResult); /* ctor */ CMICmnMIValueTuple(const CMICmnMIValueResult &vResult, const bool vbUseSpacing); // - bool Add(const CMICmnMIValueResult &vResult); - bool Add(const CMICmnMIValueResult &vResult, const bool vbUseSpacing); - bool Add(const CMICmnMIValueConst &vValue, const bool vbUseSpacing); - CMIUtilString ExtractContentNoBrackets(void) const; + void Add(const CMICmnMIValueResult &vResult); + void Add(const CMICmnMIValueResult &vResult, const bool vbUseSpacing); + void Add(const CMICmnMIValueConst &vValue, const bool vbUseSpacing); + CMIUtilString ExtractContentNoBrackets() const; // Overridden: public: // From CMICmnBase - /* dtor */ ~CMICmnMIValueTuple(void) override; + /* dtor */ ~CMICmnMIValueTuple() override; // Methods: private: - bool BuildTuple(void); - bool BuildTuple(const CMICmnMIValueResult &vResult); - bool BuildTuple(const CMIUtilString &vValue); + void BuildTuple(); + void BuildTuple(const CMICmnMIValueResult &vResult); + void BuildTuple(const CMIUtilString &vValue); // Attributes: private: diff --git a/tools/lldb-mi/MICmnResources.cpp b/tools/lldb-mi/MICmnResources.cpp index ee9c93d7eba2..50d6b795def6 100644 --- a/tools/lldb-mi/MICmnResources.cpp +++ b/tools/lldb-mi/MICmnResources.cpp @@ -45,7 +45,6 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[] {IDS_MEDIUMFILE_ERR_INVALID_PATH, "<Invalid - not set>"}, {IDS_MEDIUMFILE_ERR_FILE_HEADER, "<Invalid - header not set>"}, {IDS_MEDIUMFILE_NAME_LOG, "File medium. %s"}, - {IDE_MEDIUMFILE_ERR_GET_FILE_PATHNAME_SYS, "File Medium. Failed to retrieve the system/executable path for the Log file"}, {IDE_OS_ERR_UNKNOWN, "Unknown OS error"}, {IDE_OS_ERR_RETRIEVING, "Unabled to retrieve OS error message"}, {IDS_DRIVERMGR_DRIVER_ERR_INIT, "Driver Manager. Driver '%s' (ID:'%s') initialise failed. %s"}, @@ -142,8 +141,6 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[] "LLDB Out-of-band. %s. Event handler tried to set new MI Driver running state and failed. %s"}, {IDS_LLDBOUTOFBAND_ERR_BRKPT_CNT_EXCEEDED, "LLDB Out-of-band. '%s'. Number of valid breakpoint exceeded %d. Cannot create new breakpoint with ID %d"}, - {IDS_DBGSESSION_ERR_SHARED_DATA_RELEASE, - "LLDB debug session info. Release some or all of the data shared across command instances failed"}, {IDS_DBGSESSION_ERR_SHARED_DATA_ADD, "LLDB debug session info. Failed to add '%s' data to the shared data command container"}, {IDS_MI_SHTDWN_ERR_LOG, "Log. Error occurred during shutdown. %s"}, {IDS_MI_SHUTDOWN_ERR, "Server shutdown failure. %s"}, @@ -265,7 +262,7 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[] // Return: None. // Throws: None. //-- -CMICmnResources::CMICmnResources(void) +CMICmnResources::CMICmnResources() : m_nResourceId2TextDataSize(0) { // Do not use this constructor, use Initialize() @@ -278,7 +275,7 @@ CMICmnResources::CMICmnResources(void) // Return: None. // Throws: None. //-- -CMICmnResources::~CMICmnResources(void) +CMICmnResources::~CMICmnResources() { // Do not use this destructor, use Shutdown() } @@ -292,7 +289,7 @@ CMICmnResources::~CMICmnResources(void) // Throws: None. //-- bool -CMICmnResources::Initialize(void) +CMICmnResources::Initialize() { m_clientUsageRefCnt++; @@ -313,7 +310,7 @@ CMICmnResources::Initialize(void) // Throws: None. //-- bool -CMICmnResources::Shutdown(void) +CMICmnResources::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -338,7 +335,7 @@ CMICmnResources::Shutdown(void) // Throws: None. //-- bool -CMICmnResources::ReadResourceStringData(void) +CMICmnResources::ReadResourceStringData() { m_nResourceId2TextDataSize = sizeof ms_pResourceId2TextData / sizeof ms_pResourceId2TextData[0]; for (MIuint i = 0; i < m_nResourceId2TextDataSize; i++) diff --git a/tools/lldb-mi/MICmnResources.h b/tools/lldb-mi/MICmnResources.h index 633eba8de9e4..dc9c52c6df60 100644 --- a/tools/lldb-mi/MICmnResources.h +++ b/tools/lldb-mi/MICmnResources.h @@ -50,7 +50,6 @@ enum IDS_LOG_MEDIUM_ERR_INIT, IDS_LOG_MEDIUM_ERR_WRITE_ANY, IDS_LOG_MEDIUM_ERR_WRITE_MEDIUMFAIL, - IDE_MEDIUMFILE_ERR_GET_FILE_PATHNAME_SYS, IDS_MEDIUMFILE_NAME, IDS_MEDIUMFILE_ERR_INVALID_PATH, @@ -153,7 +152,6 @@ enum IDS_LLDBOUTOFBAND_ERR_SETNEWDRIVERSTATE, IDS_LLDBOUTOFBAND_ERR_BRKPT_CNT_EXCEEDED, - IDS_DBGSESSION_ERR_SHARED_DATA_RELEASE, IDS_DBGSESSION_ERR_SHARED_DATA_ADD, IDS_MI_SHTDWN_ERR_LOG, @@ -279,9 +277,6 @@ enum // Details: MI common code implementation class. Handle application resources // and locality. // Singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 29/01/2014. -// Changes: None. //-- class CMICmnResources : public CMICmnBase, public MI::ISingleton<CMICmnResources> { @@ -289,8 +284,8 @@ class CMICmnResources : public CMICmnBase, public MI::ISingleton<CMICmnResources // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; CMIUtilString GetString(const MIuint vResourceId) const; bool HasString(const MIuint vResourceId) const; @@ -317,17 +312,17 @@ class CMICmnResources : public CMICmnBase, public MI::ISingleton<CMICmnResources // Methods: private: - /* ctor */ CMICmnResources(void); + /* ctor */ CMICmnResources(); /* ctor */ CMICmnResources(const CMICmnResources &); void operator=(const CMICmnResources &); bool GetStringFromResource(const MIuint vResourceId, CMIUtilString &vrwResourceString) const; - bool ReadResourceStringData(void); + bool ReadResourceStringData(); // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmnResources(void) override; + /* dtor */ ~CMICmnResources() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmnStreamStderr.cpp b/tools/lldb-mi/MICmnStreamStderr.cpp index 5a18951b271c..e5c494ba38fd 100644 --- a/tools/lldb-mi/MICmnStreamStderr.cpp +++ b/tools/lldb-mi/MICmnStreamStderr.cpp @@ -20,7 +20,7 @@ // Return: None. // Throws: None. //-- -CMICmnStreamStderr::CMICmnStreamStderr(void) +CMICmnStreamStderr::CMICmnStreamStderr() { } @@ -31,7 +31,7 @@ CMICmnStreamStderr::CMICmnStreamStderr(void) // Return: None. // Throws: None. //-- -CMICmnStreamStderr::~CMICmnStreamStderr(void) +CMICmnStreamStderr::~CMICmnStreamStderr() { Shutdown(); } @@ -45,7 +45,7 @@ CMICmnStreamStderr::~CMICmnStreamStderr(void) // Throws: None. //-- bool -CMICmnStreamStderr::Initialize(void) +CMICmnStreamStderr::Initialize() { m_clientUsageRefCnt++; @@ -76,7 +76,7 @@ CMICmnStreamStderr::Initialize(void) // Throws: None. //-- bool -CMICmnStreamStderr::Shutdown(void) +CMICmnStreamStderr::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -191,7 +191,7 @@ CMICmnStreamStderr::WritePriv(const CMIUtilString &vText, const CMIUtilString &v // Throws: None. //-- bool -CMICmnStreamStderr::Lock(void) +CMICmnStreamStderr::Lock() { m_mutex.Lock(); return MIstatus::success; @@ -206,7 +206,7 @@ CMICmnStreamStderr::Lock(void) // Throws: None. //-- bool -CMICmnStreamStderr::Unlock(void) +CMICmnStreamStderr::Unlock() { m_mutex.Unlock(); return MIstatus::success; diff --git a/tools/lldb-mi/MICmnStreamStderr.h b/tools/lldb-mi/MICmnStreamStderr.h index afceada9ff2e..95085a2a3275 100644 --- a/tools/lldb-mi/MICmnStreamStderr.h +++ b/tools/lldb-mi/MICmnStreamStderr.h @@ -20,9 +20,6 @@ // CMICmnStreamStderr sets up and tears downs stderr for the driver. // // Singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 19/03/2014. -// Changes: None. //-- class CMICmnStreamStderr : public CMICmnBase, public MI::ISingleton<CMICmnStreamStderr> { @@ -35,17 +32,17 @@ class CMICmnStreamStderr : public CMICmnBase, public MI::ISingleton<CMICmnStream // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; // - bool Lock(void); - bool Unlock(void); + bool Lock(); + bool Unlock(); bool Write(const CMIUtilString &vText, const bool vbSendToLog = true); bool WriteLLDBMsg(const CMIUtilString &vText, const bool vbSendToLog = true); // Methods: private: - /* ctor */ CMICmnStreamStderr(void); + /* ctor */ CMICmnStreamStderr(); /* ctor */ CMICmnStreamStderr(const CMICmnStreamStderr &); void operator=(const CMICmnStreamStderr &); // @@ -54,7 +51,7 @@ class CMICmnStreamStderr : public CMICmnBase, public MI::ISingleton<CMICmnStream // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmnStreamStderr(void) override; + /* dtor */ ~CMICmnStreamStderr() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmnStreamStdin.cpp b/tools/lldb-mi/MICmnStreamStdin.cpp index 891b1c9bb994..60fa49c4988f 100644 --- a/tools/lldb-mi/MICmnStreamStdin.cpp +++ b/tools/lldb-mi/MICmnStreamStdin.cpp @@ -1,4 +1,4 @@ -//===-- MIUtilStreamStdin.cpp -----------------------------------*- C++ -*-===// +//===-- MICmnStreamStdin.cpp ------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -28,7 +28,7 @@ // Return: None. // Throws: None. //-- -CMICmnStreamStdin::CMICmnStreamStdin(void) +CMICmnStreamStdin::CMICmnStreamStdin() : m_strPromptCurrent("(gdb)") , m_bShowPrompt(true) , m_pCmdBuffer(nullptr) @@ -42,7 +42,7 @@ CMICmnStreamStdin::CMICmnStreamStdin(void) // Return: None. // Throws: None. //-- -CMICmnStreamStdin::~CMICmnStreamStdin(void) +CMICmnStreamStdin::~CMICmnStreamStdin() { Shutdown(); } @@ -56,7 +56,7 @@ CMICmnStreamStdin::~CMICmnStreamStdin(void) // Throws: None. //-- bool -CMICmnStreamStdin::Initialize(void) +CMICmnStreamStdin::Initialize() { m_clientUsageRefCnt++; @@ -95,7 +95,7 @@ CMICmnStreamStdin::Initialize(void) // Throws: None. //-- bool -CMICmnStreamStdin::Shutdown(void) +CMICmnStreamStdin::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -158,7 +158,7 @@ CMICmnStreamStdin::SetPrompt(const CMIUtilString &vNewPrompt) // Throws: None. //-- const CMIUtilString & -CMICmnStreamStdin::GetPrompt(void) const +CMICmnStreamStdin::GetPrompt() const { return m_strPromptCurrent; } @@ -189,7 +189,7 @@ CMICmnStreamStdin::SetEnablePrompt(const bool vbYes) // Throws: None. //-- bool -CMICmnStreamStdin::GetEnablePrompt(void) const +CMICmnStreamStdin::GetEnablePrompt() const { return m_bShowPrompt; } diff --git a/tools/lldb-mi/MICmnStreamStdin.h b/tools/lldb-mi/MICmnStreamStdin.h index 71076d6dcd4e..a4b12a594125 100644 --- a/tools/lldb-mi/MICmnStreamStdin.h +++ b/tools/lldb-mi/MICmnStreamStdin.h @@ -1,4 +1,4 @@ -//===-- MIUtilStreamStdin.h -------------------------------------*- C++ -*-===// +//===-- MICmnStreamStdin.h --------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -21,9 +21,6 @@ // provide can receive callbacks when a new line of data is received. // Each line is determined by a carriage return. // A singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 10/02/2014. -// Changes: Factored out OS specific handling of reading stdin - IOR 16/06/2014. //-- class CMICmnStreamStdin : public CMICmnBase, public MI::ISingleton<CMICmnStreamStdin> { @@ -32,25 +29,25 @@ class CMICmnStreamStdin : public CMICmnBase, public MI::ISingleton<CMICmnStreamS // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; // - const CMIUtilString &GetPrompt(void) const; + const CMIUtilString &GetPrompt() const; bool SetPrompt(const CMIUtilString &vNewPrompt); void SetEnablePrompt(const bool vbYes); - bool GetEnablePrompt(void) const; + bool GetEnablePrompt() const; const char *ReadLine(CMIUtilString &vwErrMsg); // Methods: private: - /* ctor */ CMICmnStreamStdin(void); + /* ctor */ CMICmnStreamStdin(); /* ctor */ CMICmnStreamStdin(const CMICmnStreamStdin &); void operator=(const CMICmnStreamStdin &); // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmnStreamStdin(void) override; + /* dtor */ ~CMICmnStreamStdin() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmnStreamStdout.cpp b/tools/lldb-mi/MICmnStreamStdout.cpp index 2c93c99e6c8a..8b65251423b5 100644 --- a/tools/lldb-mi/MICmnStreamStdout.cpp +++ b/tools/lldb-mi/MICmnStreamStdout.cpp @@ -1,4 +1,4 @@ -//===-- MIUtilStreamStdout.cpp ----------------------------------*- C++ -*-===// +//===-- MICmnStreamStdout.cpp -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -20,7 +20,7 @@ // Return: None. // Throws: None. //-- -CMICmnStreamStdout::CMICmnStreamStdout(void) +CMICmnStreamStdout::CMICmnStreamStdout() { } @@ -31,7 +31,7 @@ CMICmnStreamStdout::CMICmnStreamStdout(void) // Return: None. // Throws: None. //-- -CMICmnStreamStdout::~CMICmnStreamStdout(void) +CMICmnStreamStdout::~CMICmnStreamStdout() { Shutdown(); } @@ -45,7 +45,7 @@ CMICmnStreamStdout::~CMICmnStreamStdout(void) // Throws: None. //-- bool -CMICmnStreamStdout::Initialize(void) +CMICmnStreamStdout::Initialize() { m_clientUsageRefCnt++; @@ -76,7 +76,7 @@ CMICmnStreamStdout::Initialize(void) // Throws: None. //-- bool -CMICmnStreamStdout::Shutdown(void) +CMICmnStreamStdout::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -183,7 +183,7 @@ CMICmnStreamStdout::WritePriv(const CMIUtilString &vText, const CMIUtilString &v // Throws: None. //-- bool -CMICmnStreamStdout::Lock(void) +CMICmnStreamStdout::Lock() { m_mutex.Lock(); return MIstatus::success; @@ -198,7 +198,7 @@ CMICmnStreamStdout::Lock(void) // Throws: None. //-- bool -CMICmnStreamStdout::Unlock(void) +CMICmnStreamStdout::Unlock() { m_mutex.Unlock(); return MIstatus::success; @@ -229,7 +229,7 @@ CMICmnStreamStdout::TextToStdout(const CMIUtilString &vrTxt) // Throws: None. //-- bool -CMICmnStreamStdout::WritePrompt(void) +CMICmnStreamStdout::WritePrompt() { const CMICmnStreamStdin &rStdinMan = CMICmnStreamStdin::Instance(); if (rStdinMan.GetEnablePrompt()) diff --git a/tools/lldb-mi/MICmnStreamStdout.h b/tools/lldb-mi/MICmnStreamStdout.h index 664faae863da..9d7f91a1504b 100644 --- a/tools/lldb-mi/MICmnStreamStdout.h +++ b/tools/lldb-mi/MICmnStreamStdout.h @@ -20,9 +20,6 @@ // CMICmnStreamStdout sets up and tears downs stdout for the driver. // // Singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 12/02/2014. -// Changes: None. //-- class CMICmnStreamStdout : public CMICmnBase, public MI::ISingleton<CMICmnStreamStdout> { @@ -31,21 +28,21 @@ class CMICmnStreamStdout : public CMICmnBase, public MI::ISingleton<CMICmnStream // Statics: public: static bool TextToStdout(const CMIUtilString &vrTxt); - static bool WritePrompt(void); + static bool WritePrompt(); // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; // - bool Lock(void); - bool Unlock(void); + bool Lock(); + bool Unlock(); bool Write(const CMIUtilString &vText, const bool vbSendToLog = true); bool WriteMIResponse(const CMIUtilString &vText, const bool vbSendToLog = true); // Methods: private: - /* ctor */ CMICmnStreamStdout(void); + /* ctor */ CMICmnStreamStdout(); /* ctor */ CMICmnStreamStdout(const CMICmnStreamStdout &); void operator=(const CMICmnStreamStdout &); // @@ -54,7 +51,7 @@ class CMICmnStreamStdout : public CMICmnBase, public MI::ISingleton<CMICmnStream // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmnStreamStdout(void) override; + /* dtor */ ~CMICmnStreamStdout() override; // Attributes: private: diff --git a/tools/lldb-mi/MICmnThreadMgrStd.cpp b/tools/lldb-mi/MICmnThreadMgrStd.cpp index f0185b8fcf1d..ec223b802f8e 100644 --- a/tools/lldb-mi/MICmnThreadMgrStd.cpp +++ b/tools/lldb-mi/MICmnThreadMgrStd.cpp @@ -1,4 +1,4 @@ -//===-- MICmnThreadMgr.cpp --------------------------------------*- C++ -*-===// +//===-- MICmnThreadMgrStd.cpp -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -20,7 +20,7 @@ // Return: None. // Throws: None. //-- -CMICmnThreadMgrStd::CMICmnThreadMgrStd(void) +CMICmnThreadMgrStd::CMICmnThreadMgrStd() { } @@ -31,7 +31,7 @@ CMICmnThreadMgrStd::CMICmnThreadMgrStd(void) // Return: None. // Throws: None. //-- -CMICmnThreadMgrStd::~CMICmnThreadMgrStd(void) +CMICmnThreadMgrStd::~CMICmnThreadMgrStd() { Shutdown(); } @@ -45,7 +45,7 @@ CMICmnThreadMgrStd::~CMICmnThreadMgrStd(void) // Throws: None. //-- bool -CMICmnThreadMgrStd::Initialize(void) +CMICmnThreadMgrStd::Initialize() { m_clientUsageRefCnt++; @@ -82,7 +82,7 @@ CMICmnThreadMgrStd::Initialize(void) // Throws: None. //-- bool -CMICmnThreadMgrStd::Shutdown(void) +CMICmnThreadMgrStd::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -121,7 +121,7 @@ CMICmnThreadMgrStd::Shutdown(void) // Throws: None. //-- bool -CMICmnThreadMgrStd::ThreadAllTerminate(void) +CMICmnThreadMgrStd::ThreadAllTerminate() { ThreadList_t::const_iterator it = m_threadList.begin(); for (; it != m_threadList.end(); ++it) diff --git a/tools/lldb-mi/MICmnThreadMgrStd.h b/tools/lldb-mi/MICmnThreadMgrStd.h index fef999b2a7b1..fc0013f99498 100644 --- a/tools/lldb-mi/MICmnThreadMgrStd.h +++ b/tools/lldb-mi/MICmnThreadMgrStd.h @@ -25,9 +25,6 @@ // This manager will stop and delete all threads on *this manager's // shutdown. // Singleton class. -// Gotchas: None. -// Authors: Aidan Dodds 12/03/2014. -// Changes: None. //-- class CMICmnThreadMgrStd : public CMICmnBase, public MI::ISingleton<CMICmnThreadMgrStd> { @@ -35,10 +32,10 @@ class CMICmnThreadMgrStd : public CMICmnBase, public MI::ISingleton<CMICmnThread // Methods: public: - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; bool - ThreadAllTerminate(void); // Ask all threads to stop (caution) + ThreadAllTerminate(); // Ask all threads to stop (caution) template <typename T> // Ask the thread manager to start and stop threads on our behalf bool ThreadStart(T &vrwObject); @@ -48,7 +45,7 @@ class CMICmnThreadMgrStd : public CMICmnBase, public MI::ISingleton<CMICmnThread // Methods: private: - /* ctor */ CMICmnThreadMgrStd(void); + /* ctor */ CMICmnThreadMgrStd(); /* ctor */ CMICmnThreadMgrStd(const CMICmnThreadMgrStd &); void operator=(const CMICmnThreadMgrStd &); // @@ -58,7 +55,7 @@ class CMICmnThreadMgrStd : public CMICmnBase, public MI::ISingleton<CMICmnThread // Overridden: private: // From CMICmnBase - /* dtor */ ~CMICmnThreadMgrStd(void) override; + /* dtor */ ~CMICmnThreadMgrStd() override; // Attributes: private: diff --git a/tools/lldb-mi/MIDataTypes.h b/tools/lldb-mi/MIDataTypes.h index 33c5b20095d9..d749b0c661a8 100644 --- a/tools/lldb-mi/MIDataTypes.h +++ b/tools/lldb-mi/MIDataTypes.h @@ -39,15 +39,6 @@ const bool failure = false; // Use to avoid "unused parameter" compiler warnings: #define MIunused(x) (void) x; -#ifdef _WIN32 -#define MI_NO_INITIALIZE_VTABLE __declspec(novtable) -#define MI_FORCE_INLINE __forceinline -#else -#define MI_NO_INITIALIZE_VTABLE -#define MI_FORCE_INLINE inline -// __attribute__( ( always_inline ) ) -#endif // _WIN32 - // Portability issues #ifdef _WIN64 typedef unsigned __int64 size_t; @@ -72,10 +63,3 @@ typedef unsigned int MIuint; // Fundamentals: typedef long long MIint64; // 64bit signed integer. typedef unsigned long long MIuint64; // 64bit unsigned integer. - -// using namespace std; // Better to put this or std:: at translation units scope. - -//-------------------------------------------------------------------------------------- -// Common routines: - -//-------------------------------------------------------------------------------------- diff --git a/tools/lldb-mi/MIDriver.cpp b/tools/lldb-mi/MIDriver.cpp index d4a31958d9ec..78172375b3d0 100644 --- a/tools/lldb-mi/MIDriver.cpp +++ b/tools/lldb-mi/MIDriver.cpp @@ -45,7 +45,7 @@ const CMIUtilString CMIDriver::ms_constAppNameLong(MIRSRC(IDS_MI_APPNAME_LONG)); // Return: None. // Throws: None. //-- -CMIDriver::CMIDriver(void) +CMIDriver::CMIDriver() : m_bFallThruToOtherDriverEnabled(false) , m_bDriverIsExiting(false) , m_handleMainThread(0) @@ -66,7 +66,7 @@ CMIDriver::CMIDriver(void) // Return: None. // Throws: None. //-- -CMIDriver::~CMIDriver(void) +CMIDriver::~CMIDriver() { } @@ -97,7 +97,7 @@ CMIDriver::SetEnableFallThru(const bool vbYes) // Throws: None. //-- bool -CMIDriver::GetEnableFallThru(void) const +CMIDriver::GetEnableFallThru() const { return m_bFallThruToOtherDriverEnabled; } @@ -110,7 +110,7 @@ CMIDriver::GetEnableFallThru(void) const // Throws: None. //-- const CMIUtilString & -CMIDriver::GetAppNameShort(void) const +CMIDriver::GetAppNameShort() const { return ms_constAppNameShort; } @@ -123,7 +123,7 @@ CMIDriver::GetAppNameShort(void) const // Throws: None. //-- const CMIUtilString & -CMIDriver::GetAppNameLong(void) const +CMIDriver::GetAppNameLong() const { return ms_constAppNameLong; } @@ -136,7 +136,7 @@ CMIDriver::GetAppNameLong(void) const // Throws: None. //-- const CMIUtilString & -CMIDriver::GetVersionDescription(void) const +CMIDriver::GetVersionDescription() const { return ms_constMIVersion; } @@ -150,7 +150,7 @@ CMIDriver::GetVersionDescription(void) const // Throws: None. //-- bool -CMIDriver::Initialize(void) +CMIDriver::Initialize() { m_eCurrentDriverState = eDriverState_Initialising; m_clientUsageRefCnt++; @@ -199,7 +199,7 @@ CMIDriver::Initialize(void) // Throws: None. //-- bool -CMIDriver::Shutdown(void) +CMIDriver::Shutdown() { if (--m_clientUsageRefCnt > 0) return MIstatus::success; @@ -260,7 +260,7 @@ CMIDriver::WriteMessageToLog(const CMIUtilString &vMessage) // Throws: None. //-- bool -CMIDriver::DoInitialize(void) +CMIDriver::DoInitialize() { return CMIDriver::Instance().Initialize(); } @@ -275,7 +275,7 @@ CMIDriver::DoInitialize(void) // Throws: None. //-- bool -CMIDriver::DoShutdown(void) +CMIDriver::DoShutdown() { return CMIDriver::Instance().Shutdown(); } @@ -288,7 +288,7 @@ CMIDriver::DoShutdown(void) // Throws: None. //-- const CMIUtilString & -CMIDriver::GetName(void) const +CMIDriver::GetName() const { const CMIUtilString &rName = GetAppNameLong(); const CMIUtilString &rVsn = GetVersionDescription(); @@ -305,7 +305,7 @@ CMIDriver::GetName(void) const // Throws: None. //-- CMIUtilString -CMIDriver::GetError(void) const +CMIDriver::GetError() const { return GetErrorDescription(); } @@ -318,7 +318,7 @@ CMIDriver::GetError(void) const // Throws: None. //-- lldb::SBDebugger & -CMIDriver::GetTheDebugger(void) +CMIDriver::GetTheDebugger() { return m_rLldbDebugger.GetTheDebugger(); } @@ -465,7 +465,7 @@ CMIDriver::ParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &v // Throws: None. //-- bool -CMIDriver::GetDriverIsGDBMICompatibleDriver(void) const +CMIDriver::GetDriverIsGDBMICompatibleDriver() const { return true; } @@ -479,7 +479,7 @@ CMIDriver::GetDriverIsGDBMICompatibleDriver(void) const // Throws: None. //-- bool -CMIDriver::StartWorkerThreads(void) +CMIDriver::StartWorkerThreads() { bool bOk = MIstatus::success; @@ -507,7 +507,7 @@ CMIDriver::StartWorkerThreads(void) // Throws: None. //-- bool -CMIDriver::StopWorkerThreads(void) +CMIDriver::StopWorkerThreads() { CMICmnThreadMgrStd &rThreadMgr = CMICmnThreadMgrStd::Instance(); return rThreadMgr.ThreadAllTerminate(); @@ -523,7 +523,7 @@ CMIDriver::StopWorkerThreads(void) // Throws: None. //-- bool -CMIDriver::DoMainLoop(void) +CMIDriver::DoMainLoop() { if (!InitClientIDEToMIDriver()) // Init Eclipse IDE { @@ -607,7 +607,7 @@ CMIDriver::DoMainLoop(void) // Throws: None. //-- bool -CMIDriver::DoAppQuit(void) +CMIDriver::DoAppQuit() { bool bYesQuit = true; @@ -675,7 +675,7 @@ CMIDriver::InterpretCommandFallThruDriver(const CMIUtilString &vTextLine, bool & // Throws: None. //-- const CMIUtilString & -CMIDriver::GetDriverName(void) const +CMIDriver::GetDriverName() const { return GetName(); } @@ -688,7 +688,7 @@ CMIDriver::GetDriverName(void) const // Throws: None. //-- const CMIUtilString & -CMIDriver::GetDriverId(void) const +CMIDriver::GetDriverId() const { return GetId(); } @@ -727,7 +727,7 @@ CMIDriver::DoFallThruToAnotherDriver(const CMIUtilString &vCmd, CMIUtilString &v // Throws: None. //-- FILE * -CMIDriver::GetStdin(void) const +CMIDriver::GetStdin() const { // Note this fn is called on CMIDriverMgr register driver so stream has to be // available before *this driver has been initialized! Flaw? @@ -746,7 +746,7 @@ CMIDriver::GetStdin(void) const // Throws: None. //-- FILE * -CMIDriver::GetStdout(void) const +CMIDriver::GetStdout() const { // Note this fn is called on CMIDriverMgr register driver so stream has to be // available before *this driver has been initialized! Flaw? @@ -764,7 +764,7 @@ CMIDriver::GetStdout(void) const // Throws: None. //-- FILE * -CMIDriver::GetStderr(void) const +CMIDriver::GetStderr() const { // Note this fn is called on CMIDriverMgr register driver so stream has to be // available before *this driver has been initialized! Flaw? @@ -803,7 +803,7 @@ CMIDriver::SetId(const CMIUtilString &vId) // Throws: None. //-- const CMIUtilString & -CMIDriver::GetId(void) const +CMIDriver::GetId() const { return m_strDriverId; } @@ -893,7 +893,7 @@ CMIDriver::WrapCLICommandIntoMICommand(const CMIUtilString &vTextLine) const const std::string vToken(vTextLine.begin(), vTextLine.begin() + nCommandOffset); // 001target create "/path/to/file" // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- CLI command - const CMIUtilString vCliCommand(std::string(vTextLine, nCommandOffset).c_str()); + const CMIUtilString vCliCommand(std::string(vTextLine, nCommandOffset)); // 5. Escape special characters and embed the command in a string // Result: it looks like -- target create \"/path/to/file\". @@ -1033,7 +1033,7 @@ CMIDriver::SetExitApplicationFlag(const bool vbForceExit) // Throws: None. //-- bool -CMIDriver::GetExitApplicationFlag(void) const +CMIDriver::GetExitApplicationFlag() const { return m_bExitApp; } @@ -1046,7 +1046,7 @@ CMIDriver::GetExitApplicationFlag(void) const // Throws: None. //-- CMIDriver::DriverState_e -CMIDriver::GetCurrentDriverState(void) const +CMIDriver::GetCurrentDriverState() const { return m_eCurrentDriverState; } @@ -1061,7 +1061,7 @@ CMIDriver::GetCurrentDriverState(void) const // Throws: None. //-- bool -CMIDriver::SetDriverStateRunningNotDebugging(void) +CMIDriver::SetDriverStateRunningNotDebugging() { // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM @@ -1110,7 +1110,7 @@ CMIDriver::SetDriverStateRunningNotDebugging(void) // Throws: None. //-- bool -CMIDriver::SetDriverStateRunningDebugging(void) +CMIDriver::SetDriverStateRunningDebugging() { // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM @@ -1157,7 +1157,7 @@ CMIDriver::SetDriverStateRunningDebugging(void) // Throws: None. //-- bool -CMIDriver::InitClientIDEToMIDriver(void) const +CMIDriver::InitClientIDEToMIDriver() const { // Put other IDE init functions here return InitClientIDEEclipse(); @@ -1174,7 +1174,7 @@ CMIDriver::InitClientIDEToMIDriver(void) const // Throws: None. //-- bool -CMIDriver::InitClientIDEEclipse(void) const +CMIDriver::InitClientIDEEclipse() const { return CMICmnStreamStdout::WritePrompt(); } @@ -1191,7 +1191,7 @@ CMIDriver::InitClientIDEEclipse(void) const // Throws: None. //-- bool -CMIDriver::HaveExecutableFileNamePathOnCmdLine(void) const +CMIDriver::HaveExecutableFileNamePathOnCmdLine() const { return m_bHaveExecutableFileNamePathOnCmdLine; } @@ -1205,7 +1205,7 @@ CMIDriver::HaveExecutableFileNamePathOnCmdLine(void) const // Throws: None. //-- const CMIUtilString & -CMIDriver::GetExecutableFileNamePathOnCmdLine(void) const +CMIDriver::GetExecutableFileNamePathOnCmdLine() const { return m_strCmdLineArgExecuteableFileNamePath; } @@ -1221,7 +1221,7 @@ CMIDriver::GetExecutableFileNamePathOnCmdLine(void) const // Throws: None. //-- bool -CMIDriver::LocalDebugSessionStartupExecuteCommands(void) +CMIDriver::LocalDebugSessionStartupExecuteCommands() { const CMIUtilString strCmd(CMIUtilString::Format("-file-exec-and-symbols \"%s\"", m_strCmdLineArgExecuteableFileNamePath.AddSlashes().c_str())); bool bOk = CMICmnStreamStdout::TextToStdout(strCmd); @@ -1239,7 +1239,7 @@ CMIDriver::LocalDebugSessionStartupExecuteCommands(void) // Throws: None. //-- void -CMIDriver::SetDriverDebuggingArgExecutable(void) +CMIDriver::SetDriverDebuggingArgExecutable() { m_bDriverDebuggingArgExecutable = true; } @@ -1254,7 +1254,7 @@ CMIDriver::SetDriverDebuggingArgExecutable(void) // Throws: None. //-- bool -CMIDriver::IsDriverDebuggingArgExecutable(void) const +CMIDriver::IsDriverDebuggingArgExecutable() const { return m_bDriverDebuggingArgExecutable; } diff --git a/tools/lldb-mi/MIDriver.h b/tools/lldb-mi/MIDriver.h index 55c662494e21..a90c31fbc757 100644 --- a/tools/lldb-mi/MIDriver.h +++ b/tools/lldb-mi/MIDriver.h @@ -32,9 +32,6 @@ class CMICmnStreamStdout; // work depending on the one selected to work. A driver can if not able // to handle an instruction or 'command' can pass that command onto // another driver object registered with the Driver Manager. -// Gotchas: None. -// Authors: Illya Rudkin 29/01/2014. -// Changes: None. //-- class CMIDriver : public CMICmnBase, public CMIDriverMgr::IDriver, @@ -68,51 +65,51 @@ class CMIDriver : public CMICmnBase, // Methods: public: // MI system - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; // MI state - bool GetExitApplicationFlag(void) const; - DriverState_e GetCurrentDriverState(void) const; - bool SetDriverStateRunningNotDebugging(void); - bool SetDriverStateRunningDebugging(void); - void SetDriverDebuggingArgExecutable(void); - bool IsDriverDebuggingArgExecutable(void) const; + bool GetExitApplicationFlag() const; + DriverState_e GetCurrentDriverState() const; + bool SetDriverStateRunningNotDebugging(); + bool SetDriverStateRunningDebugging(); + void SetDriverDebuggingArgExecutable(); + bool IsDriverDebuggingArgExecutable() const; // MI information about itself - const CMIUtilString &GetAppNameShort(void) const; - const CMIUtilString &GetAppNameLong(void) const; - const CMIUtilString &GetVersionDescription(void) const; + const CMIUtilString &GetAppNameShort() const; + const CMIUtilString &GetAppNameLong() const; + const CMIUtilString &GetVersionDescription() const; // MI do work bool WriteMessageToLog(const CMIUtilString &vMessage); bool SetEnableFallThru(const bool vbYes); - bool GetEnableFallThru(void) const; - bool HaveExecutableFileNamePathOnCmdLine(void) const; - const CMIUtilString &GetExecutableFileNamePathOnCmdLine(void) const; + bool GetEnableFallThru() const; + bool HaveExecutableFileNamePathOnCmdLine() const; + const CMIUtilString &GetExecutableFileNamePathOnCmdLine() const; // Overridden: public: // From CMIDriverMgr::IDriver - bool DoInitialize(void) override; - bool DoShutdown(void) override; - bool DoMainLoop(void) override; + bool DoInitialize() override; + bool DoShutdown() override; + bool DoMainLoop() override; lldb::SBError DoParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &vwbExiting) override; - CMIUtilString GetError(void) const override; - const CMIUtilString &GetName(void) const override; - lldb::SBDebugger &GetTheDebugger(void) override; - bool GetDriverIsGDBMICompatibleDriver(void) const override; + CMIUtilString GetError() const override; + const CMIUtilString &GetName() const override; + lldb::SBDebugger &GetTheDebugger() override; + bool GetDriverIsGDBMICompatibleDriver() const override; bool SetId(const CMIUtilString &vId) override; - const CMIUtilString &GetId(void) const override; + const CMIUtilString &GetId() const override; // From CMIDriverBase void SetExitApplicationFlag(const bool vbForceExit) override; bool DoFallThruToAnotherDriver(const CMIUtilString &vCmd, CMIUtilString &vwErrMsg) override; bool SetDriverToFallThruTo(const CMIDriverBase &vrOtherDriver) override; - FILE *GetStdin(void) const override; - FILE *GetStdout(void) const override; - FILE *GetStderr(void) const override; - const CMIUtilString &GetDriverName(void) const override; - const CMIUtilString &GetDriverId(void) const override; + FILE *GetStdin() const override; + FILE *GetStdout() const override; + FILE *GetStderr() const override; + const CMIUtilString &GetDriverName() const override; + const CMIUtilString &GetDriverId() const override; void DeliverSignal(int signal) override; // Typedefs: @@ -121,28 +118,28 @@ class CMIDriver : public CMICmnBase, // Methods: private: - /* ctor */ CMIDriver(void); + /* ctor */ CMIDriver(); /* ctor */ CMIDriver(const CMIDriver &); void operator=(const CMIDriver &); lldb::SBError ParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &vwbExiting); - bool DoAppQuit(void); + bool DoAppQuit(); bool InterpretCommand(const CMIUtilString &vTextLine); bool InterpretCommandThisDriver(const CMIUtilString &vTextLine, bool &vwbCmdYesValid); CMIUtilString WrapCLICommandIntoMICommand(const CMIUtilString &vTextLine) const; bool InterpretCommandFallThruDriver(const CMIUtilString &vTextLine, bool &vwbCmdYesValid); bool ExecuteCommand(const SMICmdData &vCmdData); - bool StartWorkerThreads(void); - bool StopWorkerThreads(void); - bool InitClientIDEToMIDriver(void) const; - bool InitClientIDEEclipse(void) const; - bool LocalDebugSessionStartupExecuteCommands(void); + bool StartWorkerThreads(); + bool StopWorkerThreads(); + bool InitClientIDEToMIDriver() const; + bool InitClientIDEEclipse() const; + bool LocalDebugSessionStartupExecuteCommands(); bool ExecuteCommandFile(const bool vbAsyncMode); // Overridden: private: // From CMICmnBase - /* dtor */ ~CMIDriver(void) override; + /* dtor */ ~CMIDriver() override; // Attributes: private: diff --git a/tools/lldb-mi/MIDriverBase.cpp b/tools/lldb-mi/MIDriverBase.cpp index 6bf5ab6e3bec..6738497de75e 100644 --- a/tools/lldb-mi/MIDriverBase.cpp +++ b/tools/lldb-mi/MIDriverBase.cpp @@ -21,7 +21,7 @@ // Return: None. // Throws: None. //-- -CMIDriverBase::CMIDriverBase(void) +CMIDriverBase::CMIDriverBase() : m_pDriverFallThru(nullptr) , m_pDriverParent(nullptr) , m_bExitApp(false) @@ -35,7 +35,7 @@ CMIDriverBase::CMIDriverBase(void) // Return: None. // Throws: None. //-- -CMIDriverBase::~CMIDriverBase(void) +CMIDriverBase::~CMIDriverBase() { m_pDriverFallThru = NULL; } @@ -107,7 +107,7 @@ CMIDriverBase::SetDriverParent(const CMIDriverBase &vrOtherDriver) // Throws: None. //-- CMIDriverBase * -CMIDriverBase::GetDriversParent(void) const +CMIDriverBase::GetDriversParent() const { return m_pDriverParent; } @@ -122,7 +122,7 @@ CMIDriverBase::GetDriversParent(void) const // Throws: None. //-- CMIDriverBase * -CMIDriverBase::GetDriverToFallThruTo(void) const +CMIDriverBase::GetDriverToFallThruTo() const { return m_pDriverFallThru; } @@ -137,7 +137,7 @@ CMIDriverBase::GetDriverToFallThruTo(void) const // Throws: None. //-- FILE * -CMIDriverBase::GetStdin(void) const +CMIDriverBase::GetStdin() const { // Do nothing - override and implement return nullptr; @@ -152,7 +152,7 @@ CMIDriverBase::GetStdin(void) const // Throws: None. //-- FILE * -CMIDriverBase::GetStdout(void) const +CMIDriverBase::GetStdout() const { // Do nothing - override and implement return nullptr; @@ -167,7 +167,7 @@ CMIDriverBase::GetStdout(void) const // Throws: None. //-- FILE * -CMIDriverBase::GetStderr(void) const +CMIDriverBase::GetStderr() const { // Do nothing - override and implement return nullptr; diff --git a/tools/lldb-mi/MIDriverBase.h b/tools/lldb-mi/MIDriverBase.h index ad242116b5f0..9be407e0c147 100644 --- a/tools/lldb-mi/MIDriverBase.h +++ b/tools/lldb-mi/MIDriverBase.h @@ -31,34 +31,31 @@ class SBBroadcaster; // CDriverMgr to manage either (any) driver to be operated on. // Each driver instance (the CMIDriver, LLDB::Driver) has its own // LLDB::SBDebugger object. -// Gotchas: None. -// Authors: Illya Rudkin 30/01/2014. -// Changes: None. //-- class CMIDriverBase { // Methods: public: - /* ctor */ CMIDriverBase(void); + /* ctor */ CMIDriverBase(); - CMIDriverBase *GetDriverToFallThruTo(void) const; - CMIDriverBase *GetDriversParent(void) const; + CMIDriverBase *GetDriverToFallThruTo() const; + CMIDriverBase *GetDriversParent() const; // Overrideable: public: - /* dtor */ virtual ~CMIDriverBase(void); + /* dtor */ virtual ~CMIDriverBase(); virtual bool DoFallThruToAnotherDriver(const CMIUtilString &vCmd, CMIUtilString &vwErrMsg); virtual bool SetDriverToFallThruTo(const CMIDriverBase &vrOtherDriver); virtual bool SetDriverParent(const CMIDriverBase &vrOtherDriver); - virtual const CMIUtilString &GetDriverName(void) const = 0; - virtual const CMIUtilString &GetDriverId(void) const = 0; + virtual const CMIUtilString &GetDriverName() const = 0; + virtual const CMIUtilString &GetDriverId() const = 0; virtual void SetExitApplicationFlag(const bool vbForceExit); // MI provide information for the pass through (child) assigned driver - virtual FILE *GetStdin(void) const; - virtual FILE *GetStdout(void) const; - virtual FILE *GetStderr(void) const; + virtual FILE *GetStdin() const; + virtual FILE *GetStdout() const; + virtual FILE *GetStderr() const; // Attributes: protected: diff --git a/tools/lldb-mi/MIDriverMain.cpp b/tools/lldb-mi/MIDriverMain.cpp index 2f469bf6d976..ccbaf77f09e1 100644 --- a/tools/lldb-mi/MIDriverMain.cpp +++ b/tools/lldb-mi/MIDriverMain.cpp @@ -89,7 +89,7 @@ sigint_handler(int vSigno) // Throws: None. //-- bool -DriverSystemInit(void) +DriverSystemInit() { bool bOk = MIstatus::success; CMIDriver &rMIDriver = CMIDriver::Instance(); diff --git a/tools/lldb-mi/MIDriverMgr.cpp b/tools/lldb-mi/MIDriverMgr.cpp index f4987dba90bc..472fc60f6439 100644 --- a/tools/lldb-mi/MIDriverMgr.cpp +++ b/tools/lldb-mi/MIDriverMgr.cpp @@ -26,7 +26,7 @@ // Return: None. // Throws: None. //-- -CMIDriverMgr::CMIDriverMgr(void) +CMIDriverMgr::CMIDriverMgr() : m_pDriverCurrent(nullptr) , m_bInMi2Mode(false) { @@ -39,7 +39,7 @@ CMIDriverMgr::CMIDriverMgr(void) // Return: None. // Throws: None. //-- -CMIDriverMgr::~CMIDriverMgr(void) +CMIDriverMgr::~CMIDriverMgr() { Shutdown(); } @@ -53,7 +53,7 @@ CMIDriverMgr::~CMIDriverMgr(void) // Throws: None. //-- bool -CMIDriverMgr::Initialize(void) +CMIDriverMgr::Initialize() { m_clientUsageRefCnt++; @@ -91,7 +91,7 @@ CMIDriverMgr::Initialize(void) // Throws: None. //-- bool -CMIDriverMgr::Shutdown(void) +CMIDriverMgr::Shutdown() { // Do not want a ref counter because this function needs to be called how ever this // application stops running @@ -132,7 +132,7 @@ CMIDriverMgr::Shutdown(void) // Throws: None. //-- bool -CMIDriverMgr::UnregisterDriverAll(void) +CMIDriverMgr::UnregisterDriverAll() { MapDriverIdToDriver_t::const_iterator it = m_mapDriverIdToDriver.begin(); while (it != m_mapDriverIdToDriver.end()) @@ -273,7 +273,7 @@ CMIDriverMgr::SetUseThisDriverToDoWork(const IDriver &vrADriver) // Throws: None. //-- CMIDriverMgr::IDriver * -CMIDriverMgr::GetUseThisDriverToDoWork(void) const +CMIDriverMgr::GetUseThisDriverToDoWork() const { return m_pDriverCurrent; } @@ -287,7 +287,7 @@ CMIDriverMgr::GetUseThisDriverToDoWork(void) const // Throws: None. //-- bool -CMIDriverMgr::DriverMainLoop(void) +CMIDriverMgr::DriverMainLoop() { if (m_pDriverCurrent != nullptr) { @@ -300,7 +300,7 @@ CMIDriverMgr::DriverMainLoop(void) } else { - const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET))); + const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)); CMICmnStreamStdout::Instance().Write(errMsg, true); return MIstatus::failure; } @@ -327,7 +327,7 @@ CMIDriverMgr::DriverParseArgs(const int argc, const char *argv[], FILE *vpStdOut { if (m_pDriverCurrent == nullptr) { - const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET))); + const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)); CMICmnStreamStdout::Instance().Write(errMsg, true); return MIstatus::failure; } @@ -357,13 +357,13 @@ CMIDriverMgr::DriverParseArgs(const int argc, const char *argv[], FILE *vpStdOut // Throws: None. //-- CMIUtilString -CMIDriverMgr::DriverGetError(void) const +CMIDriverMgr::DriverGetError() const { if (m_pDriverCurrent != nullptr) return m_pDriverCurrent->GetError(); else { - const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET))); + const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)); CMICmnStreamStdout::Instance().Write(errMsg, true); } @@ -379,13 +379,13 @@ CMIDriverMgr::DriverGetError(void) const // Throws: None. //-- CMIUtilString -CMIDriverMgr::DriverGetName(void) const +CMIDriverMgr::DriverGetName() const { if (m_pDriverCurrent != nullptr) return m_pDriverCurrent->GetName(); else { - const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET))); + const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)); CMICmnStreamStdout::Instance().Write(errMsg, true); } @@ -401,14 +401,14 @@ CMIDriverMgr::DriverGetName(void) const // Throws: None. //-- lldb::SBDebugger * -CMIDriverMgr::DriverGetTheDebugger(void) +CMIDriverMgr::DriverGetTheDebugger() { lldb::SBDebugger *pDebugger = nullptr; if (m_pDriverCurrent != nullptr) pDebugger = &m_pDriverCurrent->GetTheDebugger(); else { - const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET))); + const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)); CMICmnStreamStdout::Instance().Write(errMsg, true); } @@ -598,7 +598,7 @@ CMIDriverMgr::ParseArgs(const int argc, const char *argv[], bool &vwbExiting) // Throws: None. //-- CMIUtilString -CMIDriverMgr::GetAppVersion(void) const +CMIDriverMgr::GetAppVersion() const { const CMIUtilString strProj(MIRSRC(IDS_PROJNAME)); const CMIUtilString strVsn(CMIDriver::Instance().GetVersionDescription()); @@ -616,7 +616,7 @@ CMIDriverMgr::GetAppVersion(void) const // Throws: None. //-- CMIUtilString -CMIDriverMgr::GetHelpOnCmdLineArgOptions(void) const +CMIDriverMgr::GetHelpOnCmdLineArgOptions() const { const CMIUtilString pHelp[] = { MIRSRC(IDE_MI_APP_DESCRIPTION), @@ -653,7 +653,7 @@ CMIDriverMgr::GetHelpOnCmdLineArgOptions(void) const // Throws: None. //-- CMIDriverMgr::IDriver * -CMIDriverMgr::GetFirstMIDriver(void) const +CMIDriverMgr::GetFirstMIDriver() const { IDriver *pDriver = nullptr; MapDriverIdToDriver_t::const_iterator it = m_mapDriverIdToDriver.begin(); @@ -684,7 +684,7 @@ CMIDriverMgr::GetFirstMIDriver(void) const // Throws: None. //-- CMIDriverMgr::IDriver * -CMIDriverMgr::GetFirstNonMIDriver(void) const +CMIDriverMgr::GetFirstNonMIDriver() const { IDriver *pDriver = nullptr; MapDriverIdToDriver_t::const_iterator it = m_mapDriverIdToDriver.begin(); diff --git a/tools/lldb-mi/MIDriverMgr.h b/tools/lldb-mi/MIDriverMgr.h index c84ef04c75c4..016e722ed7ba 100644 --- a/tools/lldb-mi/MIDriverMgr.h +++ b/tools/lldb-mi/MIDriverMgr.h @@ -39,9 +39,6 @@ // Each driver instance (the CMIDriver, LLDB::Driver) has its own // LLDB::SBDebugger. // Singleton class. -// Gotchas: None. -// Authors: Illya Rudkin 28/02/2014. -// Changes: None. //-- class CMIDriverMgr : public CMICmnBase, public MI::ISingleton<CMIDriverMgr> { @@ -56,43 +53,43 @@ class CMIDriverMgr : public CMICmnBase, public MI::ISingleton<CMIDriverMgr> class IDriver { public: - virtual bool DoInitialize(void) = 0; - virtual bool DoShutdown(void) = 0; - virtual bool DoMainLoop(void) = 0; + virtual bool DoInitialize() = 0; + virtual bool DoShutdown() = 0; + virtual bool DoMainLoop() = 0; virtual lldb::SBError DoParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &vwbExiting) = 0; - virtual CMIUtilString GetError(void) const = 0; - virtual const CMIUtilString &GetName(void) const = 0; - virtual lldb::SBDebugger &GetTheDebugger(void) = 0; - virtual bool GetDriverIsGDBMICompatibleDriver(void) const = 0; + virtual CMIUtilString GetError() const = 0; + virtual const CMIUtilString &GetName() const = 0; + virtual lldb::SBDebugger &GetTheDebugger() = 0; + virtual bool GetDriverIsGDBMICompatibleDriver() const = 0; virtual bool SetId(const CMIUtilString &vId) = 0; - virtual const CMIUtilString &GetId(void) const = 0; + virtual const CMIUtilString &GetId() const = 0; virtual void DeliverSignal(int signal) = 0; // Not part of the interface, ignore - /* dtor */ virtual ~IDriver(void) {} + /* dtor */ virtual ~IDriver() {} }; // Methods: public: // MI system - bool Initialize(void) override; - bool Shutdown(void) override; + bool Initialize() override; + bool Shutdown() override; // - CMIUtilString GetAppVersion(void) const; + CMIUtilString GetAppVersion() const; bool RegisterDriver(const IDriver &vrADriver, const CMIUtilString &vrDriverID); bool UnregisterDriver(const IDriver &vrADriver); bool SetUseThisDriverToDoWork(const IDriver &vrADriver); // Specify working main driver - IDriver *GetUseThisDriverToDoWork(void) const; + IDriver *GetUseThisDriverToDoWork() const; bool ParseArgs(const int argc, const char *argv[], bool &vwbExiting); IDriver *GetDriver(const CMIUtilString &vrDriverId) const; // // MI Proxy fn to current specified working driver - bool DriverMainLoop(void); + bool DriverMainLoop(); bool DriverParseArgs(const int argc, const char *argv[], FILE *vpStdOut, bool &vwbExiting); - CMIUtilString DriverGetError(void) const; - CMIUtilString DriverGetName(void) const; - lldb::SBDebugger *DriverGetTheDebugger(void); + CMIUtilString DriverGetError() const; + CMIUtilString DriverGetName() const; + lldb::SBDebugger *DriverGetTheDebugger(); void DeliverSignal(int signal); // Typedef: @@ -102,20 +99,20 @@ class CMIDriverMgr : public CMICmnBase, public MI::ISingleton<CMIDriverMgr> // Methods: private: - /* ctor */ CMIDriverMgr(void); + /* ctor */ CMIDriverMgr(); /* ctor */ CMIDriverMgr(const CMIDriverMgr &); void operator=(const CMIDriverMgr &); // bool HaveDriverAlready(const IDriver &vrMedium) const; - bool UnregisterDriverAll(void); - IDriver *GetFirstMIDriver(void) const; - IDriver *GetFirstNonMIDriver(void) const; - CMIUtilString GetHelpOnCmdLineArgOptions(void) const; + bool UnregisterDriverAll(); + IDriver *GetFirstMIDriver() const; + IDriver *GetFirstNonMIDriver() const; + CMIUtilString GetHelpOnCmdLineArgOptions() const; // Overridden: private: // From CMICmnBase - /* dtor */ ~CMIDriverMgr(void) override; + /* dtor */ ~CMIDriverMgr() override; // Attributes: private: diff --git a/tools/lldb-mi/MIExtensions.txt b/tools/lldb-mi/MIExtensions.txt index 966cb2f074c9..70508b1d37bd 100644 --- a/tools/lldb-mi/MIExtensions.txt +++ b/tools/lldb-mi/MIExtensions.txt @@ -83,21 +83,22 @@ Example: # =library-loaded notification -The =library-loaded notification has 3 extra fields: +The =library-loaded notification has 4 extra fields: symbols-loaded - indicates that there are symbols for the loaded library symbols-path - if symbols are exist then it contains a path for symbols of the loaded library loaded_addr - contains an address of the loaded library or "-" if address isn't resolved yet + size - contains the size in bytes of the section loaded at 'loaded_addr' For example: - =library-loaded,id="/Users/IliaK/p/hello",target-name="/Users/IliaK/p/hello",host-name="/Users/IliaK/p/hello",symbols-loaded="1",symbols-path="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello",loaded_addr="-" - =library-loaded,id="/usr/lib/dyld",target-name="/usr/lib/dyld",host-name="/usr/lib/dyld",symbols-loaded="0",loaded_addr="0x00007fff5fc00000" + =library-loaded,id="/Users/IliaK/p/hello",target-name="/Users/IliaK/p/hello",host-name="/Users/IliaK/p/hello",symbols-loaded="1",symbols-path="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello",loaded_addr="-",size="4096" + =library-loaded,id="/usr/lib/dyld",target-name="/usr/lib/dyld",host-name="/usr/lib/dyld",symbols-loaded="0",loaded_addr="0x00007fff5fc00000",size="4096" # -target-attach Synopsis Additional syntax provided by lldb-mi: - -target-attach -n <executable-name> [--waitfor] + -target-attach -n <executable-name> [--waitfor] Attach to an executable. Using -n allows specifying an executable name to attach to. Using this with --watifor can do a deffered attach. The flags -n and --waitfor match the syntax of lldb proper's 'process attach' command. diff --git a/tools/lldb-mi/MIUtilDateTimeStd.cpp b/tools/lldb-mi/MIUtilDateTimeStd.cpp index 995441fb4dec..db730daeefc2 100644 --- a/tools/lldb-mi/MIUtilDateTimeStd.cpp +++ b/tools/lldb-mi/MIUtilDateTimeStd.cpp @@ -18,7 +18,7 @@ // Return: None. // Throws: None. //-- -CMIUtilDateTimeStd::CMIUtilDateTimeStd(void) +CMIUtilDateTimeStd::CMIUtilDateTimeStd() { } @@ -29,7 +29,7 @@ CMIUtilDateTimeStd::CMIUtilDateTimeStd(void) // Return: None. // Throws: None. //-- -CMIUtilDateTimeStd::~CMIUtilDateTimeStd(void) +CMIUtilDateTimeStd::~CMIUtilDateTimeStd() { } @@ -41,7 +41,7 @@ CMIUtilDateTimeStd::~CMIUtilDateTimeStd(void) // Throws: None. //-- CMIUtilString -CMIUtilDateTimeStd::GetDate(void) +CMIUtilDateTimeStd::GetDate() { CMIUtilString strDate(MIRSRC(IDS_WORD_INVALIDBRKTS)); @@ -61,7 +61,7 @@ CMIUtilDateTimeStd::GetDate(void) // Throws: None. //-- CMIUtilString -CMIUtilDateTimeStd::GetTime(void) +CMIUtilDateTimeStd::GetTime() { std::time(&m_rawTime); const std::tm *pTi = std::localtime(&m_rawTime); @@ -80,7 +80,7 @@ CMIUtilDateTimeStd::GetTime(void) // Throws: None. //-- CMIUtilString -CMIUtilDateTimeStd::GetDateTimeLogFilename(void) +CMIUtilDateTimeStd::GetDateTimeLogFilename() { std::time(&m_rawTime); const std::tm *pTi = std::localtime(&m_rawTime); diff --git a/tools/lldb-mi/MIUtilDateTimeStd.h b/tools/lldb-mi/MIUtilDateTimeStd.h index 4bc5e5815959..cb5f4988700e 100644 --- a/tools/lldb-mi/MIUtilDateTimeStd.h +++ b/tools/lldb-mi/MIUtilDateTimeStd.h @@ -18,24 +18,21 @@ //++ ============================================================================ // Details: MI common code utility class. Used to retrieve system local date // time. -// Gotchas: None. -// Authors: Illya Rudkin 16/07/2014. -// Changes: None. //-- class CMIUtilDateTimeStd { // Methods: public: - /* ctor */ CMIUtilDateTimeStd(void); + /* ctor */ CMIUtilDateTimeStd(); - CMIUtilString GetDate(void); - CMIUtilString GetTime(void); - CMIUtilString GetDateTimeLogFilename(void); + CMIUtilString GetDate(); + CMIUtilString GetTime(); + CMIUtilString GetDateTimeLogFilename(); // Overrideable: public: // From CMICmnBase - /* dtor */ virtual ~CMIUtilDateTimeStd(void); + /* dtor */ virtual ~CMIUtilDateTimeStd(); // Attributes: private: diff --git a/tools/lldb-mi/MIUtilDebug.cpp b/tools/lldb-mi/MIUtilDebug.cpp index f7d461bfcd28..d49aaa20a8f9 100644 --- a/tools/lldb-mi/MIUtilDebug.cpp +++ b/tools/lldb-mi/MIUtilDebug.cpp @@ -24,7 +24,7 @@ // Return: None. // Throws: None. //-- -CMIUtilDebug::CMIUtilDebug(void) +CMIUtilDebug::CMIUtilDebug() { } @@ -35,7 +35,7 @@ CMIUtilDebug::CMIUtilDebug(void) // Return: None. // Throws: None. //-- -CMIUtilDebug::~CMIUtilDebug(void) +CMIUtilDebug::~CMIUtilDebug() { } @@ -48,7 +48,7 @@ CMIUtilDebug::~CMIUtilDebug(void) // Throws: None. //-- void -CMIUtilDebug::ShowDlgWaitForDbgAttach(void) +CMIUtilDebug::ShowDlgWaitForDbgAttach() { const CMIUtilString strCaption(CMIDriver::Instance().GetAppNameShort()); #ifdef _WIN32 @@ -71,7 +71,7 @@ CMIUtilDebug::ShowDlgWaitForDbgAttach(void) // Throws: None. //-- void -CMIUtilDebug::WaitForDbgAttachInfinteLoop(void) +CMIUtilDebug::WaitForDbgAttachInfinteLoop() { MIuint i = 0; while (i == 0) @@ -110,7 +110,7 @@ CMIUtilDebugFnTrace::CMIUtilDebugFnTrace(const CMIUtilString &vFnName) // Return: None. // Throws: None. //-- -CMIUtilDebugFnTrace::~CMIUtilDebugFnTrace(void) +CMIUtilDebugFnTrace::~CMIUtilDebugFnTrace() { const CMIUtilString txt(CMIUtilString::Format("%d<%s", ms_fnDepthCnt--, m_strFnName.c_str())); ms_rLog.Write(txt, CMICmnLog::eLogVerbosity_FnTrace); diff --git a/tools/lldb-mi/MIUtilDebug.h b/tools/lldb-mi/MIUtilDebug.h index b309c5dc2871..c5383883f522 100644 --- a/tools/lldb-mi/MIUtilDebug.h +++ b/tools/lldb-mi/MIUtilDebug.h @@ -19,25 +19,22 @@ class CMICmnLog; //++ ============================================================================ // Details: MI debugging aid utility class. -// Gotchas: None. -// Authors: -// Changes: None. //-- class CMIUtilDebug { // Statics: public: - static void ShowDlgWaitForDbgAttach(void); - static void WaitForDbgAttachInfinteLoop(void); + static void ShowDlgWaitForDbgAttach(); + static void WaitForDbgAttachInfinteLoop(); // Methods: public: - /* ctor */ CMIUtilDebug(void); + /* ctor */ CMIUtilDebug(); // Overrideable: public: // From CMICmnBase - /* dtor */ virtual ~CMIUtilDebug(void); + /* dtor */ virtual ~CMIUtilDebug(); }; //++ ============================================================================ @@ -48,9 +45,6 @@ class CMIUtilDebug // the functions you wish to build up a trace off. // Use preprocessor definition MI_USE_DEBUG_TRACE_FN to turn off or on // tracing code. -// Gotchas: None. -// Authors: Illya Rudkin 07/03/2014. -// Changes: None. //-- class CMIUtilDebugFnTrace { @@ -61,7 +55,7 @@ class CMIUtilDebugFnTrace // Overrideable: public: // From CMICmnBase - /* dtor */ virtual ~CMIUtilDebugFnTrace(void); + /* dtor */ virtual ~CMIUtilDebugFnTrace(); // Attributes: private: diff --git a/tools/lldb-mi/MIUtilFileStd.cpp b/tools/lldb-mi/MIUtilFileStd.cpp index a0fce65880c6..9e5d10d6ba38 100644 --- a/tools/lldb-mi/MIUtilFileStd.cpp +++ b/tools/lldb-mi/MIUtilFileStd.cpp @@ -24,7 +24,7 @@ // Return: None. // Throws: None. //-- -CMIUtilFileStd::CMIUtilFileStd(void) +CMIUtilFileStd::CMIUtilFileStd() : m_fileNamePath(CMIUtilString()) , m_pFileHandle(nullptr) #if defined(_MSC_VER) @@ -43,7 +43,7 @@ CMIUtilFileStd::CMIUtilFileStd(void) // Return: None. // Throws: None. //-- -CMIUtilFileStd::~CMIUtilFileStd(void) +CMIUtilFileStd::~CMIUtilFileStd() { Close(); } @@ -183,7 +183,7 @@ CMIUtilFileStd::Write(const char *vpData, const MIuint vCharCnt) // Throws: None. //-- void -CMIUtilFileStd::Close(void) +CMIUtilFileStd::Close() { if (m_pFileHandle == nullptr) return; @@ -202,7 +202,7 @@ CMIUtilFileStd::Close(void) // Throws: None. //-- bool -CMIUtilFileStd::IsOk(void) const +CMIUtilFileStd::IsOk() const { return !m_bFileError; } @@ -240,7 +240,7 @@ CMIUtilFileStd::IsFileExist(const CMIUtilString &vFileNamePath) const // Throws: None. //-- const CMIUtilString & -CMIUtilFileStd::GetLineReturn(void) const +CMIUtilFileStd::GetLineReturn() const { return m_constCharNewLine; } @@ -277,7 +277,7 @@ CMIUtilFileStd::StripOffFileName(const CMIUtilString &vDirectoryPath) // Throws: None. //-- char -CMIUtilFileStd::GetSlash(void) +CMIUtilFileStd::GetSlash() { #if !defined(_MSC_VER) return '/'; diff --git a/tools/lldb-mi/MIUtilFileStd.h b/tools/lldb-mi/MIUtilFileStd.h index 5a2234897768..458f64a75df8 100644 --- a/tools/lldb-mi/MIUtilFileStd.h +++ b/tools/lldb-mi/MIUtilFileStd.h @@ -15,33 +15,30 @@ //++ ============================================================================ // Details: MI common code utility class. File handling. -// Gotchas: None. -// Authors: Aidan Dodds 10/03/2014. -// Changes: None. //-- class CMIUtilFileStd : public CMICmnBase { // Static: public: - static char GetSlash(void); + static char GetSlash(); // Methods: public: - /* ctor */ CMIUtilFileStd(void); + /* ctor */ CMIUtilFileStd(); // bool CreateWrite(const CMIUtilString &vFileNamePath, bool &vwrbNewCreated); bool Write(const CMIUtilString &vData); bool Write(const char *vpData, const MIuint vCharCnt); - void Close(void); - bool IsOk(void) const; + void Close(); + bool IsOk() const; bool IsFileExist(const CMIUtilString &vFileNamePath) const; - const CMIUtilString &GetLineReturn(void) const; + const CMIUtilString &GetLineReturn() const; static CMIUtilString StripOffFileName(const CMIUtilString &vDirectoryPath); // Overridden: public: // From CMICmnBase - /* dtor */ ~CMIUtilFileStd(void) override; + /* dtor */ ~CMIUtilFileStd() override; // Attributes: private: diff --git a/tools/lldb-mi/MIUtilMapIdToVariant.cpp b/tools/lldb-mi/MIUtilMapIdToVariant.cpp index debac2081b8b..b35d97a20d19 100644 --- a/tools/lldb-mi/MIUtilMapIdToVariant.cpp +++ b/tools/lldb-mi/MIUtilMapIdToVariant.cpp @@ -17,7 +17,7 @@ // Return: None. // Throws: None. //-- -CMIUtilMapIdToVariant::CMIUtilMapIdToVariant(void) +CMIUtilMapIdToVariant::CMIUtilMapIdToVariant() { } @@ -28,7 +28,7 @@ CMIUtilMapIdToVariant::CMIUtilMapIdToVariant(void) // Return: None. // Throws: None. //-- -CMIUtilMapIdToVariant::~CMIUtilMapIdToVariant(void) +CMIUtilMapIdToVariant::~CMIUtilMapIdToVariant() { } @@ -40,7 +40,7 @@ CMIUtilMapIdToVariant::~CMIUtilMapIdToVariant(void) // Throws: None. //-- void -CMIUtilMapIdToVariant::Clear(void) +CMIUtilMapIdToVariant::Clear() { m_mapKeyToVariantValue.clear(); } @@ -71,7 +71,7 @@ CMIUtilMapIdToVariant::HaveAlready(const CMIUtilString &vId) const // Throws: None. //-- bool -CMIUtilMapIdToVariant::IsEmpty(void) const +CMIUtilMapIdToVariant::IsEmpty() const { return m_mapKeyToVariantValue.empty(); } diff --git a/tools/lldb-mi/MIUtilMapIdToVariant.h b/tools/lldb-mi/MIUtilMapIdToVariant.h index c77f0b946683..1a164907dd06 100644 --- a/tools/lldb-mi/MIUtilMapIdToVariant.h +++ b/tools/lldb-mi/MIUtilMapIdToVariant.h @@ -22,27 +22,24 @@ // Details: MI common code utility class. Map type container that hold general // object types (by being a variant wrapper) // objects by ID. -// Gotchas: None. -// Authors: Illya Rudkin 19/06/2014. -// Changes: None. //-- class CMIUtilMapIdToVariant : public CMICmnBase { // Methods: public: - /* ctor */ CMIUtilMapIdToVariant(void); + /* ctor */ CMIUtilMapIdToVariant(); template <typename T> bool Add(const CMIUtilString &vId, const T &vData); - void Clear(void); + void Clear(); template <typename T> bool Get(const CMIUtilString &vId, T &vrwData, bool &vrwbFound) const; bool HaveAlready(const CMIUtilString &vId) const; - bool IsEmpty(void) const; + bool IsEmpty() const; bool Remove(const CMIUtilString &vId); // Overridden: public: // From CMICmnBase - /* dtor */ ~CMIUtilMapIdToVariant(void) override; + /* dtor */ ~CMIUtilMapIdToVariant() override; // Typedefs: private: diff --git a/tools/lldb-mi/MIUtilParse.cpp b/tools/lldb-mi/MIUtilParse.cpp new file mode 100644 index 000000000000..27e25b8b7431 --- /dev/null +++ b/tools/lldb-mi/MIUtilParse.cpp @@ -0,0 +1,75 @@ +//===-- MIUtilParse.cpp ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Third party headers: +#include <memory> + +// In-house headers: +#include "MIUtilParse.h" + +//++ ------------------------------------------------------------------------------------ +// Details: CRegexParser constructor. +// Type: Method. +// Args: regexStr - Pointer to the regular expression to compile. +// Return: None. +// Throws: None. +//-- +MIUtilParse::CRegexParser::CRegexParser(const char *regexStr) + : m_isValid(llvm_regcomp(&m_emma, regexStr, REG_EXTENDED) == 0) +{ +} + +//++ ------------------------------------------------------------------------------------ +// Details: CRegexParser destructor. +// Type: Method. +// Args: None. +// Return: None. +// Throws: None. +//-- +MIUtilParse::CRegexParser::~CRegexParser() +{ + // Free up memory held within regex. + if (m_isValid) + llvm_regfree(&m_emma); +} + +//++ ------------------------------------------------------------------------------------ +// Details: CRegexParser regex executer. +// Match the input against the regular expression. Return an error +// if the number of matches is less than minMatches. If the default +// minMatches value of 0 is passed, an error will be returned if +// the number of matches is less than the maxMatches value used to +// initialize Match. +// Type: Method. +// Args: input (R) - Pointer to UTF8 text data to be parsed. +// match (RW) - Reference to Match class. +// minMatches (R) - Minimum number of regex matches expected. +// Return: bool - True = minimum matches were met, +// false = minimum matches were not met or regex failed. +// Throws: None. +//-- +bool +MIUtilParse::CRegexParser::Execute(const char *input, Match& match, size_t minMatches) +{ + if (!m_isValid) + return false; + + std::unique_ptr<llvm_regmatch_t[]> matches(new llvm_regmatch_t[match.m_maxMatches]); // Array of matches + + if (llvm_regexec(&m_emma, input, match.m_maxMatches, matches.get(), 0) != 0) + return false; + + size_t i; + for (i = 0; i < match.m_maxMatches && matches[i].rm_so >= 0; i++) + { + const int n = matches[i].rm_eo - matches[i].rm_so; + match.m_matchStrs[i].assign(input + matches[i].rm_so, n); + } + return i >= minMatches; +} diff --git a/tools/lldb-mi/MIUtilParse.h b/tools/lldb-mi/MIUtilParse.h new file mode 100644 index 000000000000..d3569586f819 --- /dev/null +++ b/tools/lldb-mi/MIUtilParse.h @@ -0,0 +1,93 @@ +//===-- MIUtilParse.h ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#pragma once + +// Third party headers: +#include "../lib/Support/regex_impl.h" + +// In-house headers: +#include "MIUtilString.h" + +namespace MIUtilParse +{ + +//++ ============================================================================ +// Details: MI common code utility class. Used to parse the output +// returned from lldb commands using regex. +//-- +class CRegexParser +{ + public: + // Helper class for keeping track of regex matches. + class Match + { + friend CRegexParser; + public: + /* ctor */ explicit Match(size_t nmatches) + : m_matchStrs(nmatches), m_maxMatches(nmatches) + { + } + size_t + GetMatchCount() const + { + return m_matchStrs.size(); + } + CMIUtilString + GetMatchAtIndex(size_t i) const + { + if (m_matchStrs.size() > i) + return m_matchStrs[i]; + return CMIUtilString(); + } + private: + CMIUtilString::VecString_t m_matchStrs; + const size_t m_maxMatches; + }; + + // Methods: + // Compile the regular expression. + /* ctor */ explicit CRegexParser(const char *regexStr); + + // Free the memory used by the regular expression. + /* dtor */ ~CRegexParser(); + + // No copies + CRegexParser(const CRegexParser&) = delete; + void operator=(CRegexParser&) = delete; + + // Return the match at the index. + int + GetMatchCount(const Match& match) const + { + if (m_isValid) + return match.GetMatchCount(); + return 0; + } + + bool + IsValid() const + { + return m_isValid; + } + + // Match the input against the regular expression. Return an error + // if the number of matches is less than minMatches. If the default + // minMatches value of 0 is passed, an error will be returned if + // the number of matches is less than the maxMatches value used to + // initialize Match. + bool + Execute(const char *input, Match& match, size_t minMatches = 0); + + private: + llvm_regex_t m_emma; + const bool m_isValid; +}; + +} diff --git a/tools/lldb-mi/MIUtilSingletonBase.h b/tools/lldb-mi/MIUtilSingletonBase.h index 3649a73b9fa5..03ce8c8aa443 100644 --- a/tools/lldb-mi/MIUtilSingletonBase.h +++ b/tools/lldb-mi/MIUtilSingletonBase.h @@ -22,15 +22,13 @@ namespace MI // // Overridden: // public: // // From MI::ISingleton -// bool Initialize(void) override; -// bool Shutdown(void) override; +// bool Initialize() override; +// bool Shutdown() override; // }; //++ ============================================================================ // Details: Base class for the singleton pattern. // Gotchas: Derived class must specify MI::ISingleton<> as a friend class. -// Authors: Aidan Dodds 17/03/2014. -// Changes: None. //-- template <typename T> class ISingleton { @@ -38,7 +36,7 @@ template <typename T> class ISingleton public: // Return an instance of the derived class static T & - Instance(void) + Instance() { // This will fail if the derived class has not // declared itself to be a friend of MI::ISingleton @@ -49,10 +47,10 @@ template <typename T> class ISingleton // Overrideable: public: - virtual bool Initialize(void) = 0; - virtual bool Shutdown(void) = 0; + virtual bool Initialize() = 0; + virtual bool Shutdown() = 0; // - /* dtor */ virtual ~ISingleton(void){}; + /* dtor */ virtual ~ISingleton(){} }; } // namespace MI diff --git a/tools/lldb-mi/MIUtilSingletonHelper.h b/tools/lldb-mi/MIUtilSingletonHelper.h index 19cc3a92e82f..2b9f4c416651 100644 --- a/tools/lldb-mi/MIUtilSingletonHelper.h +++ b/tools/lldb-mi/MIUtilSingletonHelper.h @@ -6,9 +6,6 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// -// Copyright: None. -//-- #pragma once @@ -29,8 +26,6 @@ namespace MI // vwrErrMsg - (W) MI driver module initialise error description on failure. // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. -// Authors: Aidan Dodds 17/03/2014. -// Changes: None. //-- template <typename T> bool @@ -58,8 +53,6 @@ ModuleInit(const MIint vErrorResrcId, bool &vwrbOk, CMIUtilString &vwrErrMsg) // failure. // Return: True - Module shutdown succeeded. // False - Module shutdown failed. -// Authors: Aidan Dodds 17/03/2014. -// Changes: None. //-- template <typename T> bool diff --git a/tools/lldb-mi/MIUtilString.cpp b/tools/lldb-mi/MIUtilString.cpp index fc7717749da8..176d9a6de74a 100644 --- a/tools/lldb-mi/MIUtilString.cpp +++ b/tools/lldb-mi/MIUtilString.cpp @@ -25,7 +25,7 @@ // Return: None. // Throws: None. //-- -CMIUtilString::CMIUtilString(void) +CMIUtilString::CMIUtilString() : std::string() { } @@ -45,12 +45,12 @@ CMIUtilString::CMIUtilString(const char *vpData) //++ ------------------------------------------------------------------------------------ // Details: CMIUtilString constructor. // Type: Method. -// Args: vpData - Pointer to UTF8 text data. +// Args: vpStr - Text data. // Return: None. // Throws: None. //-- -CMIUtilString::CMIUtilString(const char *const *vpData) - : std::string((const char *)vpData) +CMIUtilString::CMIUtilString(const std::string& vrStr) + : std::string(vrStr) { } @@ -63,14 +63,7 @@ CMIUtilString::CMIUtilString(const char *const *vpData) //-- CMIUtilString &CMIUtilString::operator=(const char *vpRhs) { - if (*this == vpRhs) - return *this; - - if (vpRhs != nullptr) - { - assign(vpRhs); - } - + assign(vpRhs); return *this; } @@ -83,11 +76,7 @@ CMIUtilString &CMIUtilString::operator=(const char *vpRhs) //-- CMIUtilString &CMIUtilString::operator=(const std::string &vrRhs) { - if (*this == vrRhs) - return *this; - assign(vrRhs); - return *this; } @@ -98,7 +87,7 @@ CMIUtilString &CMIUtilString::operator=(const std::string &vrRhs) // Return: None. // Throws: None. //-- -CMIUtilString::~CMIUtilString(void) +CMIUtilString::~CMIUtilString() { } @@ -230,7 +219,7 @@ CMIUtilString::Split(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits) // Extract string between delimiters const size_t nSectionLen(nNextDelimiterPos - nSectionPos); const std::string strSection(substr(nSectionPos, nSectionLen)); - vwVecSplits.push_back(strSection.c_str()); + vwVecSplits.push_back(strSection); // Next nOffset = nNextDelimiterPos + 1; @@ -286,7 +275,7 @@ CMIUtilString::SplitConsiderQuotes(const CMIUtilString &vDelimiter, VecString_t // Extract string between delimiters const size_t nSectionLen(nNextDelimiterPos - nSectionPos); const std::string strSection(substr(nSectionPos, nSectionLen)); - vwVecSplits.push_back(strSection.c_str()); + vwVecSplits.push_back(strSection); // Next nOffset = nNextDelimiterPos + 1; @@ -318,13 +307,13 @@ CMIUtilString::SplitLines(VecString_t &vwVecSplits) const // Throws: None. //-- CMIUtilString -CMIUtilString::StripCREndOfLine(void) const +CMIUtilString::StripCREndOfLine() const { const size_t nPos = rfind('\n'); if (nPos == std::string::npos) return *this; - const CMIUtilString strNew(substr(0, nPos).c_str()); + const CMIUtilString strNew(substr(0, nPos)); return strNew; } @@ -338,7 +327,7 @@ CMIUtilString::StripCREndOfLine(void) const // Throws: None. //-- CMIUtilString -CMIUtilString::StripCRAll(void) const +CMIUtilString::StripCRAll() const { return FindAndReplace("\n", " "); } @@ -381,7 +370,7 @@ CMIUtilString::FindAndReplace(const CMIUtilString &vFind, const CMIUtilString &v // Throws: None. //-- bool -CMIUtilString::IsNumber(void) const +CMIUtilString::IsNumber() const { if (empty()) return false; @@ -404,7 +393,7 @@ CMIUtilString::IsNumber(void) const // Throws: None. //-- bool -CMIUtilString::IsHexadecimalNumber(void) const +CMIUtilString::IsHexadecimalNumber() const { // Compare '0x..' prefix if ((strncmp(c_str(), "0x", 2) != 0) && (strncmp(c_str(), "0X", 2) != 0)) @@ -522,19 +511,19 @@ CMIUtilString::Compare(const CMIUtilString &vrLhs, const CMIUtilString &vrRhs) // Throws: None. //-- CMIUtilString -CMIUtilString::Trim(void) const +CMIUtilString::Trim() const { CMIUtilString strNew(*this); const char *pWhiteSpace = " \t\n\v\f\r"; const size_t nPos = find_last_not_of(pWhiteSpace); if (nPos != std::string::npos) { - strNew = substr(0, nPos + 1).c_str(); + strNew = substr(0, nPos + 1); } const size_t nPos2 = strNew.find_first_not_of(pWhiteSpace); if (nPos2 != std::string::npos) { - strNew = strNew.substr(nPos2).c_str(); + strNew = strNew.substr(nPos2); } return strNew; @@ -555,7 +544,7 @@ CMIUtilString::Trim(const char vChar) const if (nLen > 1) { if ((strNew[0] == vChar) && (strNew[nLen - 1] == vChar)) - strNew = strNew.substr(1, nLen - 2).c_str(); + strNew = strNew.substr(1, nLen - 2); } return strNew; @@ -652,7 +641,7 @@ CMIUtilString::RemoveRepeatedCharacters(size_t vnPos, const char vChar) // Throws: None. //-- bool -CMIUtilString::IsQuoted(void) const +CMIUtilString::IsQuoted() const { const char cQuote = '"'; @@ -819,7 +808,7 @@ CMIUtilString::Escape(bool vbEscapeQuotes /* = false */) const // Throws: None. //-- CMIUtilString -CMIUtilString::AddSlashes(void) const +CMIUtilString::AddSlashes() const { const char cBckSlash('\\'); const size_t nLen(length()); @@ -856,7 +845,7 @@ CMIUtilString::AddSlashes(void) const // Throws: None. //-- CMIUtilString -CMIUtilString::StripSlashes(void) const +CMIUtilString::StripSlashes() const { const char cBckSlash('\\'); const size_t nLen(length()); @@ -895,7 +884,7 @@ CMIUtilString::StripSlashes(void) const } CMIUtilString -CMIUtilString::ConvertToPrintableASCII(const char vChar) +CMIUtilString::ConvertToPrintableASCII(const char vChar, bool bEscapeQuotes) { switch (vChar) { @@ -917,6 +906,10 @@ CMIUtilString::ConvertToPrintableASCII(const char vChar) return "\\e"; case '\\': return "\\\\"; + case '"': + if (bEscapeQuotes) + return "\\\""; + // fall thru default: if (::isprint(vChar)) return Format("%c", vChar); @@ -926,24 +919,65 @@ CMIUtilString::ConvertToPrintableASCII(const char vChar) } CMIUtilString -CMIUtilString::ConvertToPrintableASCII(const char16_t vChar16) +CMIUtilString::ConvertCharValueToPrintableASCII(char vChar, bool bEscapeQuotes) +{ + switch (vChar) + { + case '\a': + return "\\a"; + case '\b': + return "\\b"; + case '\t': + return "\\t"; + case '\n': + return "\\n"; + case '\v': + return "\\v"; + case '\f': + return "\\f"; + case '\r': + return "\\r"; + case '\033': + return "\\e"; + case '\\': + return "\\\\"; + case '"': + if (bEscapeQuotes) + return "\\\""; + // fall thru + default: + if (::isprint(vChar)) + return Format("%c", vChar); + else + return CMIUtilString(); + } +} + +CMIUtilString +CMIUtilString::ConvertToPrintableASCII(const char16_t vChar16, bool bEscapeQuotes) { - if (vChar16 == (char16_t)(char)vChar16 && ::isprint(vChar16)) + if (vChar16 == (char16_t)(char)vChar16) + { // Convert char16_t to char (if possible) - return Format("%c", vChar16); - else - return Format("\\u%02" PRIx8 "%02" PRIx8, + CMIUtilString str = ConvertCharValueToPrintableASCII((char)vChar16, bEscapeQuotes); + if (str.length() > 0) + return str; + } + return Format("\\u%02" PRIx8 "%02" PRIx8, (vChar16 >> 8) & 0xff, vChar16 & 0xff); } CMIUtilString -CMIUtilString::ConvertToPrintableASCII(const char32_t vChar32) +CMIUtilString::ConvertToPrintableASCII(const char32_t vChar32, bool bEscapeQuotes) { - if (vChar32 == (char32_t)(char)vChar32 && ::isprint(vChar32)) + if (vChar32 == (char32_t)(char)vChar32) + { // Convert char32_t to char (if possible) - return Format("%c", vChar32); - else - return Format("\\U%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8, + CMIUtilString str = ConvertCharValueToPrintableASCII((char)vChar32, bEscapeQuotes); + if (str.length() > 0) + return str; + } + return Format("\\U%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8, (vChar32 >> 24) & 0xff, (vChar32 >> 16) & 0xff, (vChar32 >> 8) & 0xff, vChar32 & 0xff); } diff --git a/tools/lldb-mi/MIUtilString.h b/tools/lldb-mi/MIUtilString.h index 7b188edefefa..23261605f3db 100644 --- a/tools/lldb-mi/MIUtilString.h +++ b/tools/lldb-mi/MIUtilString.h @@ -13,6 +13,7 @@ #include <string> #include <vector> #include <cinttypes> +#include <cstdarg> // In-house headers: #include "MIDataTypes.h" @@ -20,9 +21,6 @@ //++ ============================================================================ // Details: MI common code utility class. Used to help handle text. // Derived from std::string -// Gotchas: None. -// Authors: Illya Rudkin 02/02/2014. -// Changes: None. //-- class CMIUtilString : public std::string { @@ -37,47 +35,48 @@ class CMIUtilString : public std::string static CMIUtilString FormatValist(const CMIUtilString &vrFormating, va_list vArgs); static bool IsAllValidAlphaAndNumeric(const char *vpText); static bool Compare(const CMIUtilString &vrLhs, const CMIUtilString &vrRhs); - static CMIUtilString ConvertToPrintableASCII(const char vChar); - static CMIUtilString ConvertToPrintableASCII(const char16_t vChar16); - static CMIUtilString ConvertToPrintableASCII(const char32_t vChar32); + static CMIUtilString ConvertToPrintableASCII(const char vChar, bool bEscapeQuotes = false); + static CMIUtilString ConvertToPrintableASCII(const char16_t vChar16, bool bEscapeQuotes = false); + static CMIUtilString ConvertToPrintableASCII(const char32_t vChar32, bool bEscapeQuotes = false); // Methods: public: - /* ctor */ CMIUtilString(void); + /* ctor */ CMIUtilString(); /* ctor */ CMIUtilString(const char *vpData); - /* ctor */ CMIUtilString(const char *const *vpData); + /* ctor */ CMIUtilString(const std::string& vrStr); // bool ExtractNumber(MIint64 &vwrNumber) const; CMIUtilString FindAndReplace(const CMIUtilString &vFind, const CMIUtilString &vReplaceWith) const; - bool IsNumber(void) const; - bool IsHexadecimalNumber(void) const; - bool IsQuoted(void) const; + bool IsNumber() const; + bool IsHexadecimalNumber() const; + bool IsQuoted() const; CMIUtilString RemoveRepeatedCharacters(const char vChar); size_t Split(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits) const; size_t SplitConsiderQuotes(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits) const; size_t SplitLines(VecString_t &vwVecSplits) const; - CMIUtilString StripCREndOfLine(void) const; - CMIUtilString StripCRAll(void) const; - CMIUtilString Trim(void) const; + CMIUtilString StripCREndOfLine() const; + CMIUtilString StripCRAll() const; + CMIUtilString Trim() const; CMIUtilString Trim(const char vChar) const; size_t FindFirst(const CMIUtilString &vrPattern, size_t vnPos = 0) const; size_t FindFirst(const CMIUtilString &vrPattern, bool vbSkipQuotedText, bool &vrwbNotFoundClosedQuote, size_t vnPos = 0) const; size_t FindFirstNot(const CMIUtilString &vrPattern, size_t vnPos = 0) const; CMIUtilString Escape(bool vbEscapeQuotes = false) const; - CMIUtilString AddSlashes(void) const; - CMIUtilString StripSlashes(void) const; + CMIUtilString AddSlashes() const; + CMIUtilString StripSlashes() const; // CMIUtilString &operator=(const char *vpRhs); CMIUtilString &operator=(const std::string &vrRhs); // Overrideable: public: - /* dtor */ virtual ~CMIUtilString(void); + /* dtor */ virtual ~CMIUtilString(); // Static method: private: static CMIUtilString FormatPriv(const CMIUtilString &vrFormat, va_list vArgs); + static CMIUtilString ConvertCharValueToPrintableASCII(char vChar, bool bEscapeQuotes); // Methods: private: diff --git a/tools/lldb-mi/MIUtilSystemLinux.cpp b/tools/lldb-mi/MIUtilSystemLinux.cpp deleted file mode 100644 index 8fd2470c992b..000000000000 --- a/tools/lldb-mi/MIUtilSystemLinux.cpp +++ /dev/null @@ -1,111 +0,0 @@ -//===-- MIUtilSystemLinux.cpp -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__linux__) - -// In-house headers: -#include "MIUtilSystemLinux.h" -#include "MICmnResources.h" - -//++ ------------------------------------------------------------------------------------ -// Details: CMIUtilSystemLinux constructor. -// Type: Method. -// Args: None. -// Return: None. -// Throws: None. -//-- -CMIUtilSystemLinux::CMIUtilSystemLinux(void) -{ -} - -//++ ------------------------------------------------------------------------------------ -// Details: CMIUtilSystemLinux destructor. -// Type: Method. -// Args: None. -// Return: None. -// Throws: None. -//-- -CMIUtilSystemLinux::~CMIUtilSystemLinux(void) -{ -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieve the OS system error message for the given system error code. -// Type: Method. -// Args: vError - (R) OS error code value. -// vrwErrorMsg - (W) The error message. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMIUtilSystemLinux::GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const -{ - // Reset - vrwErrorMsg.clear(); - - bool bOk = MIstatus::failure; - - // ToDo: Implement LINUX version - - return bOk; -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieve if possible the OS last error description. -// Type: Method. -// Args: None. -// Return: CMIUtilString - Error description. -// Throws: None. -//-- -CMIUtilString -CMIUtilSystemLinux::GetOSLastError(void) const -{ - CMIUtilString errorMsg("Error fn not implemented "); - - // ToDo: Implement LINUX version - - return errorMsg; -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieves the fully qualified path for the this application. If the function -// fails the string is filled with the error message. -// Type: Method. -// Args: vrwFileNamePath - (W) The executable's name and path or last error description. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMIUtilSystemLinux::GetExecutablesPath(CMIUtilString &vrwFileNamePath) const -{ - vrwFileNamePath = CMIUtilString("."); - return MIstatus::success; -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieves the fully qualified path for the Log file for this application. -// If the function fails the string is filled with the error message. -// Append a dummy file name on the end of the path. This will be stripped off -// later and the real log file name replaces it. -// Type: Method. -// Args: vrwFileNamePath - (W) The Log file's name and path or last error description. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMIUtilSystemLinux::GetLogFilesPath(CMIUtilString &vrwFileNamePath) const -{ - vrwFileNamePath = CMIUtilString("."); - return MIstatus::success; -} - -#endif // #if defined( __linux__ ) diff --git a/tools/lldb-mi/MIUtilSystemLinux.h b/tools/lldb-mi/MIUtilSystemLinux.h deleted file mode 100644 index 975714bd6f47..000000000000 --- a/tools/lldb-mi/MIUtilSystemLinux.h +++ /dev/null @@ -1,45 +0,0 @@ -//===-- CMIUtilSystemLinux.h ------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#pragma once - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__linux__) - -// In-house headers: -#include "MIUtilString.h" - -//++ ============================================================================ -// Details: MI common code utility class. Used to set or retrieve information -// about the current system or user. -// *** If you change, remove or add functionality it must be replicated -// *** for the all platforms supported; Windows, OSX, LINUX -// Gotchas: None. -// Authors: Illya Rudkin 29/01/2014. -// Changes: None. -//-- -class CMIUtilSystemLinux -{ - // Methods: - public: - /* ctor */ CMIUtilSystemLinux(void); - - bool GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const; - CMIUtilString GetOSLastError(void) const; - bool GetExecutablesPath(CMIUtilString &vrwFileNamePath) const; - bool GetLogFilesPath(CMIUtilString &vrwFileNamePath) const; - - // Overrideable: - public: - // From CMICmnBase - /* dtor */ virtual ~CMIUtilSystemLinux(void); -}; - -typedef CMIUtilSystemLinux CMIUtilSystem; - -#endif // #if defined( __linux__ ) diff --git a/tools/lldb-mi/MIUtilSystemOsx.cpp b/tools/lldb-mi/MIUtilSystemOsx.cpp deleted file mode 100644 index b926342973a6..000000000000 --- a/tools/lldb-mi/MIUtilSystemOsx.cpp +++ /dev/null @@ -1,111 +0,0 @@ -//===-- MIUtilSystemOsx.cpp -------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#if defined(__APPLE__) - -// In-house headers: -#include "MIUtilSystemOsx.h" -#include "MICmnResources.h" - -//++ ------------------------------------------------------------------------------------ -// Details: CMIUtilSystemOsx constructor. -// Type: Method. -// Args: None. -// Return: None. -// Throws: None. -//-- -CMIUtilSystemOsx::CMIUtilSystemOsx(void) -{ -} - -//++ ------------------------------------------------------------------------------------ -// Details: CMIUtilSystemOsx destructor. -// Type: Method. -// Args: None. -// Return: None. -// Throws: None. -//-- -CMIUtilSystemOsx::~CMIUtilSystemOsx(void) -{ -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieve the OS system error message for the given system error code. -// Type: Method. -// Args: vError - (R) OS error code value. -// vrwErrorMsg - (W) The error message. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMIUtilSystemOsx::GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const -{ - // Reset - vrwErrorMsg.clear(); - - bool bOk = MIstatus::failure; - - // ToDo: Implement LINUX version - - return bOk; -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieve if possible the OS last error description. -// Type: Method. -// Args: None. -// Return: CMIUtilString - Error description. -// Throws: None. -//-- -CMIUtilString -CMIUtilSystemOsx::GetOSLastError(void) const -{ - CMIUtilString errorMsg("Error fn not implemented"); - - // ToDo: Implement LINUX version - - return errorMsg; -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieves the fully qualified path for the this application. If the function -// fails the string is filled with the error message. -// Type: Method. -// Args: vrwFileNamePath - (W) The executable's name and path or last error description. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMIUtilSystemOsx::GetExecutablesPath(CMIUtilString &vrwFileNamePath) const -{ - vrwFileNamePath = CMIUtilString("."); - return MIstatus::success; -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieves the fully qualified path for the Log file for this application. -// If the function fails the string is filled with the error message. -// Append a dummy file name on the end of the path. This will be stripped off -// later and the real log file name replaces it. -// Type: Method. -// Args: vrwFileNamePath - (W) The Log file's name and path or last error description. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMIUtilSystemOsx::GetLogFilesPath(CMIUtilString &vrwFileNamePath) const -{ - vrwFileNamePath = CMIUtilString("."); - return MIstatus::success; -} - -#endif // #if defined( __APPLE__ ) diff --git a/tools/lldb-mi/MIUtilSystemOsx.h b/tools/lldb-mi/MIUtilSystemOsx.h deleted file mode 100644 index b30e258626bd..000000000000 --- a/tools/lldb-mi/MIUtilSystemOsx.h +++ /dev/null @@ -1,45 +0,0 @@ -//===-- MICmnConfig.h -------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#pragma once - -#if defined(__APPLE__) - -// In-house headers: -#include "MIUtilString.h" - -//++ ============================================================================ -// Details: MI common code utility class. Used to set or retrieve information -// about the current system or user. -// *** If you change, remove or add functionality it must be replicated -// *** for the all platforms supported; Windows, OSX, LINUX -// Gotchas: None. -// Authors: Illya Rudkin 29/01/2014. -// Changes: None. -//-- -class CMIUtilSystemOsx -{ - // Methods: - public: - /* ctor */ CMIUtilSystemOsx(void); - - bool GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const; - CMIUtilString GetOSLastError(void) const; - bool GetExecutablesPath(CMIUtilString &vrwFileNamePath) const; - bool GetLogFilesPath(CMIUtilString &vrwFileNamePath) const; - - // Overrideable: - public: - // From CMICmnBase - /* dtor */ virtual ~CMIUtilSystemOsx(void); -}; - -typedef CMIUtilSystemOsx CMIUtilSystem; - -#endif // #if defined( __APPLE__ ) diff --git a/tools/lldb-mi/MIUtilSystemWindows.cpp b/tools/lldb-mi/MIUtilSystemWindows.cpp deleted file mode 100644 index 80f4aac7b63a..000000000000 --- a/tools/lldb-mi/MIUtilSystemWindows.cpp +++ /dev/null @@ -1,141 +0,0 @@ -//===-- MIUtilSystemWindows.cpp ---------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#if defined(_MSC_VER) - -// Third party headers -#include <memory> // std::unique_ptr -#include <Windows.h> -#include <WinBase.h> // ::FormatMessage() - -// In-house headers: -#include "MIUtilSystemWindows.h" -#include "MICmnResources.h" -#include "MIUtilFileStd.h" - -//++ ------------------------------------------------------------------------------------ -// Details: CMIUtilSystemWindows constructor. -// Type: Method. -// Args: None. -// Return: None. -// Throws: None. -//-- -CMIUtilSystemWindows::CMIUtilSystemWindows(void) -{ -} - -//++ ------------------------------------------------------------------------------------ -// Details: CMIUtilSystemWindows destructor. -// Type: Method. -// Args: None. -// Return: None. -// Throws: None. -//-- -CMIUtilSystemWindows::~CMIUtilSystemWindows(void) -{ -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieve the OS system error message for the given system error code. -// Type: Method. -// Args: vError - (R) OS error code value. -// vrwErrorMsg - (W) The error message. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMIUtilSystemWindows::GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const -{ - // Reset - vrwErrorMsg.clear(); - - const MIuint nBufLen = 1024; - std::unique_ptr<char[]> pBuffer; - pBuffer.reset(new char[nBufLen]); - - // CMIUtilString Format is not used as cannot replicate the behavior of ::FormatMessage which - // can take into account locality while retrieving the error message from the system. - const int nLength = ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, (DWORD)vError, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>(&pBuffer[0]), nBufLen, nullptr); - bool bOk = MIstatus::success; - if (nLength != 0) - vrwErrorMsg = &pBuffer[0]; - else - bOk = MIstatus::failure; - - return bOk; -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieve if possible the OS last error description. -// Type: Method. -// Args: None. -// Return: CMIUtilString - Error description. -// Throws: None. -//-- -CMIUtilString -CMIUtilSystemWindows::GetOSLastError(void) const -{ - CMIUtilString errorMsg; - const DWORD dwLastError = ::GetLastError(); - if (dwLastError != 0) - { - if (!GetOSErrorMsg(dwLastError, errorMsg)) - errorMsg = MIRSRC(IDE_OS_ERR_RETRIEVING); - } - else - errorMsg = MIRSRC(IDE_OS_ERR_UNKNOWN); - - return errorMsg; -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieves the fully qualified path for the this application. If the function -// fails the string is filled with the error message. -// Type: Method. -// Args: vrwFileNamePath - (W) The executable's name and path or last error description. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMIUtilSystemWindows::GetExecutablesPath(CMIUtilString &vrwFileNamePath) const -{ - bool bOk = MIstatus::success; - HMODULE hModule = ::GetModuleHandle(nullptr); - char pPath[MAX_PATH]; - if (!::GetModuleFileName(hModule, &pPath[0], MAX_PATH)) - { - bOk = MIstatus::failure; - vrwFileNamePath = GetOSLastError(); - } - else - vrwFileNamePath = &pPath[0]; - - return bOk; -} - -//++ ------------------------------------------------------------------------------------ -// Details: Retrieves the fully qualified path for the Log file for this application. -// If the function fails the string is filled with the error message. -// Type: Method. -// Args: vrwFileNamePath - (W) The Log file's name and path or last error description. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMIUtilSystemWindows::GetLogFilesPath(CMIUtilString &vrwFileNamePath) const -{ - vrwFileNamePath = CMIUtilString("."); - return MIstatus::success; -} - -#endif // #if defined( _MSC_VER ) diff --git a/tools/lldb-mi/MIUtilSystemWindows.h b/tools/lldb-mi/MIUtilSystemWindows.h deleted file mode 100644 index 696c2b286dfc..000000000000 --- a/tools/lldb-mi/MIUtilSystemWindows.h +++ /dev/null @@ -1,44 +0,0 @@ -//===-- MIUtilSystemWindows.h -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#pragma once - -#if defined(_MSC_VER) - -// In-house headers: -#include "MIUtilString.h" - -//++ ============================================================================ -// Details: MI common code utility class. Used to set or retrieve information -// about the current system or user. -// *** If you change, remove or add functionality it must be replicated -// *** for the all platforms supported; Windows, OSX, LINUX -// Gotchas: None. -// Authors: Illya Rudkin 29/01/2014. -// Changes: None. -//-- -class CMIUtilSystemWindows -{ - // Methods: - public: - /* ctor */ CMIUtilSystemWindows(void); - - bool GetOSErrorMsg(const MIint vError, CMIUtilString &vrwErrorMsg) const; - CMIUtilString GetOSLastError(void) const; - bool GetExecutablesPath(CMIUtilString &vrwFileNamePath) const; - bool GetLogFilesPath(CMIUtilString &vrwFileNamePath) const; - - // Overrideable: - public: - // From CMICmnBase - /* dtor */ virtual ~CMIUtilSystemWindows(void); -}; - -typedef CMIUtilSystemWindows CMIUtilSystem; - -#endif // #if defined( _MSC_VER ) diff --git a/tools/lldb-mi/MIUtilThreadBaseStd.cpp b/tools/lldb-mi/MIUtilThreadBaseStd.cpp index 96f53ff65bf5..fac0aa61729c 100644 --- a/tools/lldb-mi/MIUtilThreadBaseStd.cpp +++ b/tools/lldb-mi/MIUtilThreadBaseStd.cpp @@ -6,8 +6,6 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// Copyright: None. -//-- // Third Party Headers: #include <assert.h> @@ -23,7 +21,7 @@ // Return: None. // Throws: None. //-- -CMIUtilThreadActiveObjBase::CMIUtilThreadActiveObjBase(void) +CMIUtilThreadActiveObjBase::CMIUtilThreadActiveObjBase() : m_references(0) , m_bHasBeenKilled(false) { @@ -36,7 +34,7 @@ CMIUtilThreadActiveObjBase::CMIUtilThreadActiveObjBase(void) // Return: None. // Throws: None. //-- -CMIUtilThreadActiveObjBase::~CMIUtilThreadActiveObjBase(void) +CMIUtilThreadActiveObjBase::~CMIUtilThreadActiveObjBase() { // Make sure our thread is not alive before we die m_thread.Join(); @@ -51,7 +49,7 @@ CMIUtilThreadActiveObjBase::~CMIUtilThreadActiveObjBase(void) // Throws: None. //-- bool -CMIUtilThreadActiveObjBase::ThreadIsActive(void) +CMIUtilThreadActiveObjBase::ThreadIsActive() { // Create a new thread to occupy this threads Run() function return m_thread.IsActive(); @@ -66,7 +64,7 @@ CMIUtilThreadActiveObjBase::ThreadIsActive(void) // Throws: None. //-- bool -CMIUtilThreadActiveObjBase::ThreadExecute(void) +CMIUtilThreadActiveObjBase::ThreadExecute() { // Create a new thread to occupy this threads Run() function return m_thread.Start(ThreadEntry, this); @@ -81,7 +79,7 @@ CMIUtilThreadActiveObjBase::ThreadExecute(void) // Throws: None. //-- bool -CMIUtilThreadActiveObjBase::Acquire(void) +CMIUtilThreadActiveObjBase::Acquire() { // Access to this function is serial CMIUtilThreadLock serial(m_mutex); @@ -101,7 +99,7 @@ CMIUtilThreadActiveObjBase::Acquire(void) // Throws: None. //-- bool -CMIUtilThreadActiveObjBase::Release(void) +CMIUtilThreadActiveObjBase::Release() { // Access to this function is serial CMIUtilThreadLock serial(m_mutex); @@ -121,7 +119,7 @@ CMIUtilThreadActiveObjBase::Release(void) // Throws: None. //-- bool -CMIUtilThreadActiveObjBase::ThreadKill(void) +CMIUtilThreadActiveObjBase::ThreadKill() { // Access to this function is serial CMIUtilThreadLock serial(m_mutex); @@ -141,7 +139,7 @@ CMIUtilThreadActiveObjBase::ThreadKill(void) // Throws: None. //-- bool -CMIUtilThreadActiveObjBase::ThreadJoin(void) +CMIUtilThreadActiveObjBase::ThreadJoin() { return m_thread.Join(); } @@ -177,7 +175,7 @@ CMIUtilThreadActiveObjBase::ThreadEntry(void *vpThisClass) // Throws: None. //-- void -CMIUtilThreadActiveObjBase::ThreadManage(void) +CMIUtilThreadActiveObjBase::ThreadManage() { bool bAlive = true; @@ -214,7 +212,7 @@ CMIUtilThreadActiveObjBase::ThreadManage(void) //--------------------------------------------------------------------------------------- // -CMIUtilThread::CMIUtilThread(void) +CMIUtilThread::CMIUtilThread() : m_pThread(nullptr) , m_bIsActive(false) { @@ -227,7 +225,7 @@ CMIUtilThread::CMIUtilThread(void) // Return: None. // Throws: None. //-- -CMIUtilThread::~CMIUtilThread(void) +CMIUtilThread::~CMIUtilThread() { Join(); } @@ -241,7 +239,7 @@ CMIUtilThread::~CMIUtilThread(void) // Throws: None. //-- bool -CMIUtilThread::Join(void) +CMIUtilThread::Join() { if (m_pThread != nullptr) { @@ -267,7 +265,7 @@ CMIUtilThread::Join(void) // Throws: None. //-- bool -CMIUtilThread::IsActive(void) +CMIUtilThread::IsActive() { // Lock while we access the thread status CMIUtilThreadLock _lock(m_mutex); @@ -282,7 +280,7 @@ CMIUtilThread::IsActive(void) // Throws: None. //-- void -CMIUtilThread::Finish(void) +CMIUtilThread::Finish() { // Lock while we access the thread status CMIUtilThreadLock _lock(m_mutex); @@ -326,7 +324,7 @@ CMIUtilThread::Start(FnThreadProc vpFn, void *vpArg) // Throws: None. //-- void -CMIUtilThreadMutex::Lock(void) +CMIUtilThreadMutex::Lock() { m_mutex.lock(); } @@ -339,7 +337,7 @@ CMIUtilThreadMutex::Lock(void) // Throws: None. //-- void -CMIUtilThreadMutex::Unlock(void) +CMIUtilThreadMutex::Unlock() { m_mutex.unlock(); } @@ -353,7 +351,7 @@ CMIUtilThreadMutex::Unlock(void) // Throws: None. //-- bool -CMIUtilThreadMutex::TryLock(void) +CMIUtilThreadMutex::TryLock() { return m_mutex.try_lock(); } diff --git a/tools/lldb-mi/MIUtilThreadBaseStd.h b/tools/lldb-mi/MIUtilThreadBaseStd.h index 504d8303de1d..738f295b657a 100644 --- a/tools/lldb-mi/MIUtilThreadBaseStd.h +++ b/tools/lldb-mi/MIUtilThreadBaseStd.h @@ -6,9 +6,6 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// -// Copyright: None. -//-- #pragma once @@ -26,27 +23,24 @@ //++ ============================================================================ // Details: MI common code utility class. Handle thread mutual exclusion. // Embed Mutexes in your Active Object and then use them through Locks. -// Gotchas: None. -// Authors: Aidan Dodds 10/03/2014. -// Changes: None. //-- class CMIUtilThreadMutex { // Methods: public: - /* ctor */ CMIUtilThreadMutex(void){}; + /* ctor */ CMIUtilThreadMutex(){} // void - Lock(void); // Wait until mutex can be obtained + Lock(); // Wait until mutex can be obtained void - Unlock(void); // Release the mutex + Unlock(); // Release the mutex bool - TryLock(void); // Gain the lock if available + TryLock(); // Gain the lock if available // Overrideable: public: // From CMICmnBase - /* dtor */ virtual ~CMIUtilThreadMutex(void){}; + /* dtor */ virtual ~CMIUtilThreadMutex(){} // Attributes: private: @@ -55,9 +49,6 @@ class CMIUtilThreadMutex //++ ============================================================================ // Details: MI common code utility class. Thread object. -// Gotchas: None. -// Authors: Aidan Dodds 10/03/2014. -// Changes: None. //-- class CMIUtilThread { @@ -67,20 +58,20 @@ class CMIUtilThread // Methods: public: - /* ctor */ CMIUtilThread(void); + /* ctor */ CMIUtilThread(); // bool Start(FnThreadProc vpFn, void *vpArg); // Start execution of this thread bool - Join(void); // Wait for this thread to stop + Join(); // Wait for this thread to stop bool - IsActive(void); // Returns true if this thread is running + IsActive(); // Returns true if this thread is running void - Finish(void); // Finish this thread + Finish(); // Finish this thread // Overrideable: public: - /* dtor */ virtual ~CMIUtilThread(void); + /* dtor */ virtual ~CMIUtilThread(); // Methods: private: @@ -92,36 +83,33 @@ class CMIUtilThread //++ ============================================================================ // Details: MI common code utility class. Base class for a worker thread active // object. Runs an 'captive thread'. -// Gotchas: None. -// Authors: Aidan Dodds 10/03/2014.. -// Changes: None. //-- class CMIUtilThreadActiveObjBase { // Methods: public: - /* ctor */ CMIUtilThreadActiveObjBase(void); + /* ctor */ CMIUtilThreadActiveObjBase(); // bool - Acquire(void); // Obtain a reference to this object + Acquire(); // Obtain a reference to this object bool - Release(void); // Release a reference to this object + Release(); // Release a reference to this object bool - ThreadIsActive(void); // Return true if this object is running + ThreadIsActive(); // Return true if this object is running bool - ThreadJoin(void); // Wait for this thread to stop running + ThreadJoin(); // Wait for this thread to stop running bool - ThreadKill(void); // Force this thread to stop, regardless of references + ThreadKill(); // Force this thread to stop, regardless of references bool - ThreadExecute(void); // Start this objects execution in another thread - void ThreadManage(void); + ThreadExecute(); // Start this objects execution in another thread + void ThreadManage(); // Overrideable: public: - /* dtor */ virtual ~CMIUtilThreadActiveObjBase(void); + /* dtor */ virtual ~CMIUtilThreadActiveObjBase(); // // Each thread object must supple a unique name that can be used to locate it - virtual const CMIUtilString &ThreadGetName(void) const = 0; + virtual const CMIUtilString &ThreadGetName() const = 0; // Statics: protected: @@ -133,7 +121,7 @@ class CMIUtilThreadActiveObjBase virtual bool ThreadRun(bool &vrIsAlive) = 0; // Call the main worker method virtual bool - ThreadFinish(void) = 0; // Finish of what you were doing + ThreadFinish() = 0; // Finish of what you were doing // Attributes: protected: @@ -148,9 +136,6 @@ class CMIUtilThreadActiveObjBase // Details: MI common code utility class. Handle thread resource locking. // Put Locks inside all the methods of your Active Object that access // data shared with the captive thread. -// Gotchas: None. -// Authors: Aidan Dodds 10/03/2014. -// Changes: None. //-- class CMIUtilThreadLock { @@ -166,7 +151,7 @@ class CMIUtilThreadLock // Overrideable: public: /* dtor */ - virtual ~CMIUtilThreadLock(void) { m_rMutex.Unlock(); } + virtual ~CMIUtilThreadLock() { m_rMutex.Unlock(); } // Attributes: private: diff --git a/tools/lldb-mi/MIUtilVariant.cpp b/tools/lldb-mi/MIUtilVariant.cpp index dff8072aa105..c5e864332420 100644 --- a/tools/lldb-mi/MIUtilVariant.cpp +++ b/tools/lldb-mi/MIUtilVariant.cpp @@ -6,8 +6,6 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// Copyright: None. -//-- // In-house headers: #include "MIUtilVariant.h" @@ -19,7 +17,7 @@ // Return: None. // Throws: None. //-- -CMIUtilVariant::CDataObjectBase::CDataObjectBase(void) +CMIUtilVariant::CDataObjectBase::CDataObjectBase() { } @@ -66,7 +64,7 @@ CMIUtilVariant::CDataObjectBase::CDataObjectBase(CDataObjectBase &&vrwOther) // Return: None. // Throws: None. //-- -CMIUtilVariant::CDataObjectBase::~CDataObjectBase(void) +CMIUtilVariant::CDataObjectBase::~CDataObjectBase() { Destroy(); } @@ -106,7 +104,7 @@ CMIUtilVariant::CDataObjectBase &CMIUtilVariant::CDataObjectBase::operator=(CDat // Throws: None. //-- CMIUtilVariant::CDataObjectBase * -CMIUtilVariant::CDataObjectBase::CreateCopyOfSelf(void) +CMIUtilVariant::CDataObjectBase::CreateCopyOfSelf() { // Override to implement copying of variant's data object return new CDataObjectBase(); @@ -120,7 +118,7 @@ CMIUtilVariant::CDataObjectBase::CreateCopyOfSelf(void) // Throws: None. //-- bool -CMIUtilVariant::CDataObjectBase::GetIsDerivedClass(void) const +CMIUtilVariant::CDataObjectBase::GetIsDerivedClass() const { // Override to in the derived class and return true return false; @@ -148,7 +146,7 @@ CMIUtilVariant::CDataObjectBase::Copy(const CDataObjectBase &vrOther) // Throws: None. //-- void -CMIUtilVariant::CDataObjectBase::Destroy(void) +CMIUtilVariant::CDataObjectBase::Destroy() { // Do nothing - override to implement } @@ -247,7 +245,7 @@ template <typename T> CMIUtilVariant::CDataObject<T> &CMIUtilVariant::CDataObjec // Return: None. // Throws: None. //-- -CMIUtilVariant::CMIUtilVariant(void) +CMIUtilVariant::CMIUtilVariant() : m_pDataObject(nullptr) { } @@ -308,7 +306,7 @@ CMIUtilVariant::CMIUtilVariant(CMIUtilVariant &&vrwOther) // Return: None. // Throws: None. //-- -CMIUtilVariant::~CMIUtilVariant(void) +CMIUtilVariant::~CMIUtilVariant() { Destroy(); } @@ -354,7 +352,7 @@ CMIUtilVariant &CMIUtilVariant::operator=(CMIUtilVariant &&vrwOther) // Throws: None. //-- void -CMIUtilVariant::Destroy(void) +CMIUtilVariant::Destroy() { if (m_pDataObject != nullptr) delete m_pDataObject; diff --git a/tools/lldb-mi/MIUtilVariant.h b/tools/lldb-mi/MIUtilVariant.h index a6c3ba439031..7fddb9ffda2f 100644 --- a/tools/lldb-mi/MIUtilVariant.h +++ b/tools/lldb-mi/MIUtilVariant.h @@ -6,8 +6,6 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// Copyright: None. -//-- #pragma once @@ -20,22 +18,19 @@ // data object specified is made and stored in *this wrapper. When the // *this object is destroyed the data object hold within calls its // destructor should it have one. -// Gotchas: None. -// Authors: Illya Rudkin 18/06/2014. -// Changes: None. //-- class CMIUtilVariant { // Methods: public: - /* ctor */ CMIUtilVariant(void); + /* ctor */ CMIUtilVariant(); /* ctor */ CMIUtilVariant(const CMIUtilVariant &vrOther); /* ctor */ CMIUtilVariant(CMIUtilVariant &vrOther); /* ctor */ CMIUtilVariant(CMIUtilVariant &&vrwOther); - /* dtor */ ~CMIUtilVariant(void); + /* dtor */ ~CMIUtilVariant(); template <typename T> void Set(const T &vArg); - template <typename T> T *Get(void) const; + template <typename T> T *Get() const; CMIUtilVariant &operator=(const CMIUtilVariant &vrOther); CMIUtilVariant &operator=(CMIUtilVariant &&vrwOther); @@ -52,7 +47,7 @@ class CMIUtilVariant { // Methods: public: - /* ctor */ CDataObjectBase(void); + /* ctor */ CDataObjectBase(); /* ctor */ CDataObjectBase(const CDataObjectBase &vrOther); /* ctor */ CDataObjectBase(CDataObjectBase &vrOther); /* ctor */ CDataObjectBase(CDataObjectBase &&vrwOther); @@ -62,14 +57,14 @@ class CMIUtilVariant // Overrideable: public: - virtual ~CDataObjectBase(void); - virtual CDataObjectBase *CreateCopyOfSelf(void); - virtual bool GetIsDerivedClass(void) const; + virtual ~CDataObjectBase(); + virtual CDataObjectBase *CreateCopyOfSelf(); + virtual bool GetIsDerivedClass() const; // Overrideable: protected: virtual void Copy(const CDataObjectBase &vrOther); - virtual void Destroy(void); + virtual void Destroy(); }; //++ ---------------------------------------------------------------------- @@ -81,7 +76,7 @@ class CMIUtilVariant { // Methods: public: - /* ctor */ CDataObject(void); + /* ctor */ CDataObject(); /* ctor */ CDataObject(const T &vArg); /* ctor */ CDataObject(const CDataObject &vrOther); /* ctor */ CDataObject(CDataObject &vrOther); @@ -90,14 +85,14 @@ class CMIUtilVariant CDataObject &operator=(const CDataObject &vrOther); CDataObject &operator=(CDataObject &&vrwOther); // - T &GetDataObject(void); + T &GetDataObject(); // Overridden: public: // From CDataObjectBase - ~CDataObject(void) override; - CDataObjectBase *CreateCopyOfSelf(void) override; - bool GetIsDerivedClass(void) const override; + ~CDataObject() override; + CDataObjectBase *CreateCopyOfSelf() override; + bool GetIsDerivedClass() const override; // Overrideable: private: @@ -106,7 +101,7 @@ class CMIUtilVariant // Overridden: private: // From CDataObjectBase - void Destroy(void) override; + void Destroy() override; // Attributes: private: @@ -115,7 +110,7 @@ class CMIUtilVariant // Methods private: - void Destroy(void); + void Destroy(); void Copy(const CMIUtilVariant &vrOther); // Attributes: @@ -134,7 +129,7 @@ class CMIUtilVariant // Return: None. // Throws: None. //-- -template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(void) +template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject() { } @@ -158,7 +153,7 @@ template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(const T &vArg) // Return: None. // Throws: None. //-- -template <typename T> CMIUtilVariant::CDataObject<T>::~CDataObject(void) +template <typename T> CMIUtilVariant::CDataObject<T>::~CDataObject() { Destroy(); } @@ -172,7 +167,7 @@ template <typename T> CMIUtilVariant::CDataObject<T>::~CDataObject(void) //-- template <typename T> T & -CMIUtilVariant::CDataObject<T>::GetDataObject(void) +CMIUtilVariant::CDataObject<T>::GetDataObject() { return m_dataObj; } @@ -186,7 +181,7 @@ CMIUtilVariant::CDataObject<T>::GetDataObject(void) //-- template <typename T> CMIUtilVariant::CDataObjectBase * -CMIUtilVariant::CDataObject<T>::CreateCopyOfSelf(void) +CMIUtilVariant::CDataObject<T>::CreateCopyOfSelf() { CDataObject *pCopy = new CDataObject<T>(m_dataObj); @@ -203,7 +198,7 @@ CMIUtilVariant::CDataObject<T>::CreateCopyOfSelf(void) //-- template <typename T> bool -CMIUtilVariant::CDataObject<T>::GetIsDerivedClass(void) const +CMIUtilVariant::CDataObject<T>::GetIsDerivedClass() const { return true; } @@ -233,7 +228,7 @@ CMIUtilVariant::CDataObject<T>::Duplicate(const CDataObject &vrOther) //-- template <typename T> void -CMIUtilVariant::CDataObject<T>::Destroy(void) +CMIUtilVariant::CDataObject<T>::Destroy() { CDataObjectBase::Destroy(); } @@ -266,7 +261,7 @@ CMIUtilVariant::Set(const T &vArg) //-- template <typename T> T * -CMIUtilVariant::Get(void) const +CMIUtilVariant::Get() const { if ((m_pDataObject != nullptr) && m_pDataObject->GetIsDerivedClass()) { diff --git a/tools/lldb-server/exports b/tools/lldb-mi/lldb-mi.exports index e69de29bb2d1..e69de29bb2d1 100644 --- a/tools/lldb-server/exports +++ b/tools/lldb-mi/lldb-mi.exports diff --git a/tools/lldb-server/Acceptor.cpp b/tools/lldb-server/Acceptor.cpp new file mode 100644 index 000000000000..634319594853 --- /dev/null +++ b/tools/lldb-server/Acceptor.cpp @@ -0,0 +1,170 @@ +//===-- Acceptor.cpp --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "Acceptor.h" + +#include "llvm/ADT/StringRef.h" + +#include "lldb/Core/StreamString.h" +#include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/common/TCPSocket.h" + +#include "Utility/UriParser.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::lldb_server; +using namespace llvm; + +namespace { + +struct SocketScheme +{ + const char* m_scheme; + const Socket::SocketProtocol m_protocol; +}; + +SocketScheme socket_schemes[] = { + {"tcp", Socket::ProtocolTcp}, + {"udp", Socket::ProtocolUdp}, + {"unix", Socket::ProtocolUnixDomain}, + {"unix-abstract", Socket::ProtocolUnixAbstract}, +}; + +bool +FindProtocolByScheme(const char* scheme, Socket::SocketProtocol& protocol) +{ + for (auto s: socket_schemes) + { + if (!strcmp(s.m_scheme, scheme)) + { + protocol = s.m_protocol; + return true; + } + } + return false; +} + +const char* +FindSchemeByProtocol(const Socket::SocketProtocol protocol) +{ + for (auto s: socket_schemes) + { + if (s.m_protocol == protocol) + return s.m_scheme; + } + return nullptr; +} + +} + +Error +Acceptor::Listen(int backlog) +{ + return m_listener_socket_up->Listen(StringRef(m_name.c_str()), + backlog); +} + +Error +Acceptor::Accept(const bool child_processes_inherit, Connection *&conn) +{ + Socket* conn_socket = nullptr; + auto error = m_listener_socket_up->Accept(StringRef(m_name.c_str()), + child_processes_inherit, + conn_socket); + if (error.Success()) + conn = new ConnectionFileDescriptor(conn_socket); + + return error; +} + +Socket::SocketProtocol +Acceptor::GetSocketProtocol() const +{ + return m_listener_socket_up->GetSocketProtocol(); +} + +const char* +Acceptor::GetSocketScheme() const +{ + return FindSchemeByProtocol(GetSocketProtocol()); +} + +std::string +Acceptor::GetLocalSocketId() const +{ + return m_local_socket_id(); +} + +std::unique_ptr<Acceptor> +Acceptor::Create(StringRef name, const bool child_processes_inherit, Error &error) +{ + error.Clear(); + + Socket::SocketProtocol socket_protocol = Socket::ProtocolUnixDomain; + int port; + std::string scheme, host, path; + // Try to match socket name as URL - e.g., tcp://localhost:5555 + if (UriParser::Parse(name.str(), scheme, host, port, path)) + { + if (!FindProtocolByScheme(scheme.c_str(), socket_protocol)) + error.SetErrorStringWithFormat("Unknown protocol scheme \"%s\"", scheme.c_str()); + else + name = name.drop_front(scheme.size() + strlen("://")); + } + else + { + std::string host_str; + std::string port_str; + int32_t port = INT32_MIN; + // Try to match socket name as $host:port - e.g., localhost:5555 + if (Socket::DecodeHostAndPort (name, host_str, port_str, port, nullptr)) + socket_protocol = Socket::ProtocolTcp; + } + + if (error.Fail()) + return std::unique_ptr<Acceptor>(); + + std::unique_ptr<Socket> listener_socket_up = Socket::Create( + socket_protocol, child_processes_inherit, error); + + LocalSocketIdFunc local_socket_id; + if (error.Success()) + { + if (listener_socket_up->GetSocketProtocol() == Socket::ProtocolTcp) + { + TCPSocket* tcp_socket = static_cast<TCPSocket*>(listener_socket_up.get()); + local_socket_id = [tcp_socket]() { + auto local_port = tcp_socket->GetLocalPortNumber(); + return (local_port != 0) ? std::to_string(local_port) : ""; + }; + } + else + { + const std::string socket_name = name; + local_socket_id = [socket_name](){ + return socket_name; + }; + } + + return std::unique_ptr<Acceptor>( + new Acceptor(std::move(listener_socket_up), name, local_socket_id)); + } + + return std::unique_ptr<Acceptor>(); +} + +Acceptor::Acceptor(std::unique_ptr<Socket> &&listener_socket, + StringRef name, + const LocalSocketIdFunc &local_socket_id) + : m_listener_socket_up(std::move(listener_socket)), + m_name(name.str()), + m_local_socket_id(local_socket_id) +{ +} diff --git a/tools/lldb-server/Acceptor.h b/tools/lldb-server/Acceptor.h new file mode 100644 index 000000000000..37fba26c881f --- /dev/null +++ b/tools/lldb-server/Acceptor.h @@ -0,0 +1,68 @@ +//===-- Acceptor.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#ifndef lldb_server_Acceptor_h_ +#define lldb_server_Acceptor_h_ + +#include "lldb/Core/Connection.h" +#include "lldb/Core/Error.h" +#include "lldb/Host/Socket.h" + +#include <functional> +#include <memory> +#include <string> + +namespace llvm +{ + class StringRef; +} + +namespace lldb_private { +namespace lldb_server { + +class Acceptor +{ +public: + virtual ~Acceptor() = default; + + Error + Listen(int backlog); + + Error + Accept(const bool child_processes_inherit, Connection *&conn); + + static std::unique_ptr<Acceptor> + Create(llvm::StringRef name, const bool child_processes_inherit, Error &error); + + Socket::SocketProtocol + GetSocketProtocol() const; + + const char* + GetSocketScheme() const; + + // Returns either TCP port number as string or domain socket path. + // Empty string is returned in case of error. + std::string + GetLocalSocketId() const; + +private: + typedef std::function<std::string()> LocalSocketIdFunc; + + Acceptor(std::unique_ptr<Socket> &&listener_socket, + llvm::StringRef name, + const LocalSocketIdFunc &local_socket_id); + + const std::unique_ptr<Socket> m_listener_socket_up; + const std::string m_name; + const LocalSocketIdFunc m_local_socket_id; +}; + +} // namespace lldb_server +} // namespace lldb_private + +#endif // lldb_server_Acceptor_h_ diff --git a/tools/lldb-server/LLDBServerUtilities.cpp b/tools/lldb-server/LLDBServerUtilities.cpp index 8df4875e5d1d..438d9f127d63 100644 --- a/tools/lldb-server/LLDBServerUtilities.cpp +++ b/tools/lldb-server/LLDBServerUtilities.cpp @@ -42,7 +42,7 @@ LLDBServerUtilities::SetupLogging(const std::string& log_file, } SmallVector<StringRef, 32> channel_array; - log_channels.split(channel_array, ":"); + log_channels.split(channel_array, ":", /*MaxSplit*/ -1, /*KeepEmpty*/ false); for (auto channel_with_categories : channel_array) { StreamString error_stream; diff --git a/tools/lldb-server/lldb-gdbserver.cpp b/tools/lldb-server/lldb-gdbserver.cpp index 30bb2d686770..df8cb6e68554 100644 --- a/tools/lldb-server/lldb-gdbserver.cpp +++ b/tools/lldb-server/lldb-gdbserver.cpp @@ -9,7 +9,6 @@ // C Includes #include <errno.h> -#include <getopt.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -25,17 +24,16 @@ // Other libraries and framework includes #include "llvm/ADT/StringRef.h" -#include "lldb/Core/ConnectionMachPort.h" #include "lldb/Core/Error.h" #include "lldb/Core/PluginManager.h" #include "lldb/Host/ConnectionFileDescriptor.h" -#include "lldb/Host/HostThread.h" +#include "lldb/Host/HostGetOpt.h" #include "lldb/Host/OptionParser.h" #include "lldb/Host/Pipe.h" #include "lldb/Host/Socket.h" #include "lldb/Host/StringConvert.h" -#include "lldb/Host/ThreadLauncher.h" #include "lldb/Target/Platform.h" +#include "Acceptor.h" #include "LLDBServerUtilities.h" #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h" @@ -54,15 +52,6 @@ using namespace lldb_private; using namespace lldb_private::lldb_server; using namespace lldb_private::process_gdb_remote; -// lldb-gdbserver state - -namespace -{ -HostThread s_listen_thread; - std::unique_ptr<ConnectionFileDescriptor> s_listen_connection_up; - std::string s_listen_url; -} - //---------------------------------------------------------------------- // option descriptors for getopt_long_only() //---------------------------------------------------------------------- @@ -263,64 +252,16 @@ handle_launch (GDBRemoteCommunicationServerLLGS &gdb_server, int argc, const cha } } -static lldb::thread_result_t -ListenThread (lldb::thread_arg_t /* arg */) -{ - Error error; - - if (s_listen_connection_up) - { - // Do the listen on another thread so we can continue on... - if (s_listen_connection_up->Connect(s_listen_url.c_str(), &error) != eConnectionStatusSuccess) - s_listen_connection_up.reset(); - } - return nullptr; -} - -static Error -StartListenThread (const char *hostname, uint16_t port) -{ - Error error; - if (s_listen_thread.IsJoinable()) - { - error.SetErrorString("listen thread already running"); - } - else - { - char listen_url[512]; - if (hostname && hostname[0]) - snprintf(listen_url, sizeof(listen_url), "listen://%s:%i", hostname, port); - else - snprintf(listen_url, sizeof(listen_url), "listen://%i", port); - - s_listen_url = listen_url; - s_listen_connection_up.reset (new ConnectionFileDescriptor ()); - s_listen_thread = ThreadLauncher::LaunchThread(listen_url, ListenThread, nullptr, &error); - } - return error; -} - -static bool -JoinListenThread () -{ - if (s_listen_thread.IsJoinable()) - s_listen_thread.Join(nullptr); - return true; -} - Error -WritePortToPipe(Pipe &port_pipe, const uint16_t port) +writeSocketIdToPipe(Pipe &port_pipe, const std::string &socket_id) { - char port_str[64]; - const auto port_str_len = ::snprintf(port_str, sizeof(port_str), "%u", port); - size_t bytes_written = 0; // Write the port number as a C string with the NULL terminator. - return port_pipe.Write(port_str, port_str_len + 1, bytes_written); + return port_pipe.Write(socket_id.c_str(), socket_id.size() + 1, bytes_written); } Error -writePortToPipe(const char *const named_pipe_path, const uint16_t port) +writeSocketIdToPipe(const char *const named_pipe_path, const std::string &socket_id) { Pipe port_name_pipe; // Wait for 10 seconds for pipe to be opened. @@ -328,17 +269,17 @@ writePortToPipe(const char *const named_pipe_path, const uint16_t port) std::chrono::seconds{10}); if (error.Fail()) return error; - return WritePortToPipe(port_name_pipe, port); + return writeSocketIdToPipe(port_name_pipe, socket_id); } Error -writePortToPipe(int unnamed_pipe_fd, const uint16_t port) +writeSocketIdToPipe(int unnamed_pipe_fd, const std::string &socket_id) { #if defined(_WIN32) return Error("Unnamed pipes are not supported on Windows."); #else Pipe port_pipe{Pipe::kInvalidDescriptor, unnamed_pipe_fd}; - return WritePortToPipe(port_pipe, port); + return writeSocketIdToPipe(port_pipe, socket_id); #endif } @@ -370,14 +311,8 @@ ConnectToRemote(MainLoop &mainloop, GDBRemoteCommunicationServerLLGS &gdb_server connection_port = final_host_and_port.substr (colon_pos + 1); connection_portno = StringConvert::ToUInt32 (connection_port.c_str (), 0); } - else - { - fprintf (stderr, "failed to parse host and port from connection string '%s'\n", final_host_and_port.c_str ()); - display_usage (progname, subcommand); - exit (1); - } - std::unique_ptr<ConnectionFileDescriptor> connection_up; + std::unique_ptr<Connection> connection_up; if (reverse_connect) { @@ -410,66 +345,51 @@ ConnectToRemote(MainLoop &mainloop, GDBRemoteCommunicationServerLLGS &gdb_server } else { - // llgs will listen for connections on the given port from the given address. - // Start the listener on a new thread. We need to do this so we can resolve the - // bound listener port. - StartListenThread(connection_host.c_str (), static_cast<uint16_t> (connection_portno)); - printf ("Listening to port %s for a connection from %s...\n", connection_port.c_str (), connection_host.c_str ()); - - // If we have a named pipe to write the port number back to, do that now. - if (named_pipe_path && named_pipe_path[0] && connection_portno == 0) + std::unique_ptr<Acceptor> acceptor_up(Acceptor::Create(final_host_and_port, false, error)); + if (error.Fail()) + { + fprintf(stderr, "failed to create acceptor: %s", error.AsCString()); + exit(1); + } + error = acceptor_up->Listen(1); + if (error.Fail()) { - const uint16_t bound_port = s_listen_connection_up->GetListeningPort (10); - if (bound_port > 0) + fprintf(stderr, "failed to listen: %s\n", error.AsCString()); + exit(1); + } + const std::string socket_id = acceptor_up->GetLocalSocketId(); + if (!socket_id.empty()) + { + // If we have a named pipe to write the socket id back to, do that now. + if (named_pipe_path && named_pipe_path[0]) { - error = writePortToPipe (named_pipe_path, bound_port); + error = writeSocketIdToPipe (named_pipe_path, socket_id); if (error.Fail ()) - { - fprintf (stderr, "failed to write to the named pipe \'%s\': %s", named_pipe_path, error.AsCString()); - } + fprintf (stderr, "failed to write to the named pipe \'%s\': %s", + named_pipe_path, error.AsCString()); } - else + // If we have an unnamed pipe to write the socket id back to, do that now. + else if (unnamed_pipe_fd >= 0) { - fprintf (stderr, "unable to get the bound port for the listening connection\n"); - } - } - - // If we have an unnamed pipe to write the port number back to, do that now. - if (unnamed_pipe_fd >= 0 && connection_portno == 0) - { - const uint16_t bound_port = s_listen_connection_up->GetListeningPort(10); - if (bound_port > 0) - { - error = writePortToPipe(unnamed_pipe_fd, bound_port); + error = writeSocketIdToPipe(unnamed_pipe_fd, socket_id); if (error.Fail()) - { fprintf(stderr, "failed to write to the unnamed pipe: %s", error.AsCString()); - } - } - else - { - fprintf(stderr, "unable to get the bound port for the listening connection\n"); } } - - // Join the listener thread. - if (!JoinListenThread ()) + else { - fprintf (stderr, "failed to join the listener thread\n"); - display_usage (progname, subcommand); - exit (1); + fprintf (stderr, "unable to get the socket id for the listening connection\n"); } - // Ensure we connected. - if (s_listen_connection_up) - connection_up = std::move(s_listen_connection_up); - else + Connection* conn = nullptr; + error = acceptor_up->Accept(false, conn); + if (error.Fail()) { - fprintf (stderr, "failed to connect to '%s': %s\n", final_host_and_port.c_str (), error.AsCString ()); - display_usage (progname, subcommand); - exit (1); + printf ("failed to accept new connection: %s\n", error.AsCString()); + exit(1); } + connection_up.reset(conn); } error = gdb_server.InitializeConnection (std::move(connection_up)); if (error.Fail()) diff --git a/tools/lldb-server/lldb-platform.cpp b/tools/lldb-server/lldb-platform.cpp index 4dfa7d23a4a8..3292080da63a 100644 --- a/tools/lldb-server/lldb-platform.cpp +++ b/tools/lldb-server/lldb-platform.cpp @@ -23,15 +23,17 @@ #include <fstream> // Other libraries and framework includes +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/FileUtilities.h" + #include "lldb/Core/Error.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostGetOpt.h" #include "lldb/Host/OptionParser.h" -#include "lldb/Host/Socket.h" -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/FileUtilities.h" +#include "lldb/Host/common/TCPSocket.h" +#include "Acceptor.h" #include "LLDBServerUtilities.h" #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h" @@ -61,7 +63,7 @@ static struct option g_long_options[] = { "gdbserver-port", required_argument, NULL, 'P' }, { "min-gdbserver-port", required_argument, NULL, 'm' }, { "max-gdbserver-port", required_argument, NULL, 'M' }, - { "port-file", required_argument, NULL, 'f' }, + { "socket-file", required_argument, NULL, 'f' }, { "server", no_argument, &g_server, 1 }, { NULL, 0, NULL, 0 } }; @@ -100,9 +102,9 @@ display_usage (const char *progname, const char *subcommand) } static Error -save_port_to_file(const uint16_t port, const FileSpec &port_file_spec) +save_socket_id_to_file(const std::string &socket_id, const FileSpec &file_spec) { - FileSpec temp_file_spec(port_file_spec.GetDirectory().AsCString(), false); + FileSpec temp_file_spec(file_spec.GetDirectory().AsCString(), false); auto error = FileSystem::MakeDirectory(temp_file_spec, eFilePermissionsDirectoryDefault); if (error.Fail()) return Error("Failed to create directory %s: %s", temp_file_spec.GetCString(), error.AsCString()); @@ -119,13 +121,13 @@ save_port_to_file(const uint16_t port, const FileSpec &port_file_spec) std::ofstream temp_file(temp_file_path.c_str(), std::ios::out); if (!temp_file.is_open()) return Error("Failed to open temp file %s", temp_file_path.c_str()); - temp_file << port; + temp_file << socket_id; } - err_code = llvm::sys::fs::rename(temp_file_path.c_str(), port_file_spec.GetPath().c_str()); + err_code = llvm::sys::fs::rename(temp_file_path.c_str(), file_spec.GetPath().c_str()); if (err_code) return Error("Failed to rename file %s to %s: %s", - temp_file_path.c_str(), port_file_spec.GetPath().c_str(), err_code.message().c_str()); + temp_file_path.c_str(), file_spec.GetPath().c_str(), err_code.message().c_str()); tmp_file_remover.releaseFile(); return Error(); @@ -156,7 +158,7 @@ main_platform (int argc, char *argv[]) int max_gdbserver_port = 0; uint16_t port_offset = 0; - FileSpec port_file; + FileSpec socket_file; bool show_usage = false; int option_error = 0; int socket_error = -1; @@ -191,9 +193,9 @@ main_platform (int argc, char *argv[]) log_channels = StringRef(optarg); break; - case 'f': // Port file + case 'f': // Socket file if (optarg && optarg[0]) - port_file.SetFile(optarg, false); + socket_file.SetFile(optarg, false); break; case 'p': @@ -282,36 +284,46 @@ main_platform (int argc, char *argv[]) display_usage(progname, subcommand); exit(option_error); } - - std::unique_ptr<Socket> listening_socket_up; - Socket *socket = nullptr; - const bool children_inherit_listen_socket = false; + // Skip any options we consumed with getopt_long_only. + argc -= optind; + argv += optind; + lldb_private::Args inferior_arguments; + inferior_arguments.SetArguments(argc, const_cast<const char**>(argv)); + + const bool children_inherit_listen_socket = false; // the test suite makes many connections in parallel, let's not miss any. - // The highest this should get reasonably is a function of the number - // of target CPUs. For now, let's just use 100 + // The highest this should get reasonably is a function of the number + // of target CPUs. For now, let's just use 100. const int backlog = 100; - error = Socket::TcpListen(listen_host_port.c_str(), children_inherit_listen_socket, socket, NULL, backlog); + + std::unique_ptr<Acceptor> acceptor_up(Acceptor::Create(listen_host_port, children_inherit_listen_socket, error)); if (error.Fail()) { - printf("error: %s\n", error.AsCString()); + fprintf(stderr, "failed to create acceptor: %s", error.AsCString()); exit(socket_error); } - listening_socket_up.reset(socket); - printf ("Listening for a connection from %u...\n", listening_socket_up->GetLocalPortNumber()); - if (port_file) + + error = acceptor_up->Listen(backlog); + if (error.Fail()) + { + printf("failed to listen: %s\n", error.AsCString()); + exit(socket_error); + } + if (socket_file) { - error = save_port_to_file(listening_socket_up->GetLocalPortNumber(), port_file); + error = save_socket_id_to_file(acceptor_up->GetLocalSocketId(), socket_file); if (error.Fail()) { - fprintf(stderr, "failed to write port to %s: %s", port_file.GetPath().c_str(), error.AsCString()); + fprintf(stderr, "failed to write socket id to %s: %s\n", socket_file.GetPath().c_str(), error.AsCString()); return 1; } } do { - GDBRemoteCommunicationServerPlatform platform; - + GDBRemoteCommunicationServerPlatform platform(acceptor_up->GetSocketProtocol(), + acceptor_up->GetSocketScheme()); + if (port_offset > 0) platform.SetPortOffset(port_offset); @@ -321,8 +333,8 @@ main_platform (int argc, char *argv[]) } const bool children_inherit_accept_socket = true; - socket = nullptr; - error = listening_socket_up->BlockingAccept(listen_host_port.c_str(), children_inherit_accept_socket, socket); + Connection* conn = nullptr; + error = acceptor_up->Accept(children_inherit_accept_socket, conn); if (error.Fail()) { printf ("error: %s\n", error.AsCString()); @@ -336,8 +348,7 @@ main_platform (int argc, char *argv[]) if (fork()) { // Parent doesn't need a connection to the lldb client - delete socket; - socket = nullptr; + delete conn; // Parent will continue to listen for new connections. continue; @@ -347,19 +358,35 @@ main_platform (int argc, char *argv[]) // Child process will handle the connection and exit. g_server = 0; // Listening socket is owned by parent process. - listening_socket_up.release(); + acceptor_up.release(); } } else { // If not running as a server, this process will not accept // connections while a connection is active. - listening_socket_up.reset(); + acceptor_up.reset(); } - platform.SetConnection (new ConnectionFileDescriptor(socket)); + platform.SetConnection (conn); if (platform.IsConnected()) { + if (inferior_arguments.GetArgumentCount() > 0) + { + lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; + uint16_t port = 0; + std::string socket_name; + Error error = platform.LaunchGDBServer(inferior_arguments, + "", // hostname + pid, + port, + socket_name); + if (error.Success()) + platform.SetPendingGdbServer(pid, port, socket_name); + else + fprintf(stderr, "failed to start gdbserver: %s\n", error.AsCString()); + } + // After we connected, we need to get an initial ack from... if (platform.HandshakeWithClient()) { diff --git a/tools/lldb-server/lldb-server.exports b/tools/lldb-server/lldb-server.exports new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/tools/lldb-server/lldb-server.exports |