From 27e2c058c91c7be588db67b73473447a1fa4a4b9 Mon Sep 17 00:00:00 2001 From: Ilia K Date: Fri, 15 May 2015 09:46:28 +0000 Subject: [PATCH] Fix parsing of print-values arg (MI) # Add CMICmdArgValPrintValues argument # Rework -stack-list-arguments/-stack-list-locals/-stack-list-variables/-var-update/-var-list-children commands to use the CMICmdArgValPrintValues argument instead of usage of pair of non-mandatory arguments like: CMICmdArgValNumber(0) || CMICmdArgValLongOptions("no-values") llvm-svn: 237429 --- lldb/test/tools/lldb-mi/stack/TestMiStack.py | 6 +- lldb/test/tools/lldb-mi/variable/TestMiVar.py | 21 +-- lldb/tools/lldb-mi/CMakeLists.txt | 1 + lldb/tools/lldb-mi/MICmdArgValPrintValues.cpp | 129 ++++++++++++++++++ lldb/tools/lldb-mi/MICmdArgValPrintValues.h | 53 +++++++ lldb/tools/lldb-mi/MICmdCmdStack.cpp | 109 ++------------- lldb/tools/lldb-mi/MICmdCmdStack.h | 9 -- lldb/tools/lldb-mi/MICmdCmdVar.cpp | 69 ++-------- lldb/tools/lldb-mi/MICmdCmdVar.h | 6 - 9 files changed, 211 insertions(+), 192 deletions(-) create mode 100644 lldb/tools/lldb-mi/MICmdArgValPrintValues.cpp create mode 100644 lldb/tools/lldb-mi/MICmdArgValPrintValues.h diff --git a/lldb/test/tools/lldb-mi/stack/TestMiStack.py b/lldb/test/tools/lldb-mi/stack/TestMiStack.py index 1a830c347caa..10c7034d1d2e 100644 --- a/lldb/test/tools/lldb-mi/stack/TestMiStack.py +++ b/lldb/test/tools/lldb-mi/stack/TestMiStack.py @@ -43,16 +43,14 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase): # Test that -stack-list-arguments lists stack arguments with all values self.runCmd("-stack-list-arguments 1 0 0") self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}\]") - # FIXME: first 0 is treated as --no-values self.runCmd("-stack-list-arguments --all-values 0 0") - #self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}\]") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}\]") # Test that -stack-list-arguments lists stack arguments with simple values self.runCmd("-stack-list-arguments 2 0 1") self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}") - # FIXME: first 0 is treated as --no-values self.runCmd("-stack-list-arguments --simple-values 0 1") - #self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}") # Test that an invalid low-frame is handled # FIXME: -1 is treated as unsigned int diff --git a/lldb/test/tools/lldb-mi/variable/TestMiVar.py b/lldb/test/tools/lldb-mi/variable/TestMiVar.py index f1bb6e82e00f..ec8ae7bb678a 100644 --- a/lldb/test/tools/lldb-mi/variable/TestMiVar.py +++ b/lldb/test/tools/lldb-mi/variable/TestMiVar.py @@ -254,12 +254,12 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase): self.expect("\^done,name=\"var_complx_array\",numchild=\"2\",value=\"\[2\]\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"") # Test that -var-list-children lists empty children if range is empty - # FIXME (and that print-values is optional) - self.runCmd("-var-list-children 0 var_complx 0 0") + # (and that print-values is optional) + self.runCmd("-var-list-children var_complx 0 0") self.expect("\^done,numchild=\"0\",has_more=\"1\"") - self.runCmd("-var-list-children 0 var_complx 99 0") + self.runCmd("-var-list-children var_complx 99 0") self.expect("\^done,numchild=\"0\",has_more=\"1\"") - self.runCmd("-var-list-children 0 var_complx 99 3") + self.runCmd("-var-list-children var_complx 99 3") self.expect("\^done,numchild=\"0\",has_more=\"0\"") # Test that -var-list-children lists all children with their values @@ -272,39 +272,32 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase): # Test that -var-list-children lists children without values self.runCmd("-var-list-children 0 var_complx 0 1") self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"") - # FIXME: first 0 is treated as --no-values self.runCmd("-var-list-children --no-values var_complx 0 1") - # self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"") # Test that -var-list-children lists children with all values self.runCmd("-var-list-children 1 var_complx 1 2") self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"1\"") - # FIXME: first 1 is treated as --all-values self.runCmd("-var-list-children --all-values var_complx 1 2") - # self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"1\"") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"1\"") # Test that -var-list-children lists children with simple values self.runCmd("-var-list-children 2 var_complx 2 4") self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"") - # FIXME: first 2 is treated as --simple-values self.runCmd("-var-list-children --simple-values var_complx 2 4") - # self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"") # Test that an invalid from is handled - # FIXME: first 0 is treated as --no-values # FIXME: -1 is treated as unsigned int self.runCmd("-var-list-children 0 var_complx -1 0") #self.expect("\^error,msg=\"Command 'var-list-children'\. Variable children range invalid\"") # Test that an invalid to is handled - # FIXME: first 0 is treated as --no-values # FIXME: -1 is treated as unsigned int self.runCmd("-var-list-children 0 var_complx 0 -1") #self.expect("\^error,msg=\"Command 'var-list-children'\. Variable children range invalid\"") # Test that a missing low-frame or high-frame is handled - # FIXME: first 0 is treated as --no-values - # FIXME: -1 is treated as unsigned int self.runCmd("-var-list-children 0 var_complx 0") self.expect("\^error,msg=\"Command 'var-list-children'. Variable children range invalid\"") diff --git a/lldb/tools/lldb-mi/CMakeLists.txt b/lldb/tools/lldb-mi/CMakeLists.txt index 0f6c0d593b42..3075ed939948 100644 --- a/lldb/tools/lldb-mi/CMakeLists.txt +++ b/lldb/tools/lldb-mi/CMakeLists.txt @@ -11,6 +11,7 @@ set(LLDB_MI_SOURCES MICmdArgValNumber.cpp MICmdArgValOptionLong.cpp MICmdArgValOptionShort.cpp + MICmdArgValPrintValues.cpp MICmdArgValString.cpp MICmdArgValThreadGrp.cpp MICmdBase.cpp diff --git a/lldb/tools/lldb-mi/MICmdArgValPrintValues.cpp b/lldb/tools/lldb-mi/MICmdArgValPrintValues.cpp new file mode 100644 index 000000000000..d7b8c865d6b0 --- /dev/null +++ b/lldb/tools/lldb-mi/MICmdArgValPrintValues.cpp @@ -0,0 +1,129 @@ +//===-- MICmdArgValPrintValues.cpp ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// In-house headers: +#include "MICmdArgValPrintValues.h" +#include "MICmdArgContext.h" + +//++ ------------------------------------------------------------------------------------ +// Details: CMICmdArgValPrintValues constructor. +// Type: Method. +// Args: None. +// Return: None. +// Throws: None. +//-- +CMICmdArgValPrintValues::CMICmdArgValPrintValues(void) + : m_nPrintValues(0) +{ +} + +//++ ------------------------------------------------------------------------------------ +// Details: CMICmdArgValPrintValues constructor. +// Type: Method. +// Args: vrArgName - (R) Argument's name to search by. +// vbMandatory - (R) True = Yes must be present, false = optional argument. +// vbHandleByCmd - (R) True = Command processes *this option, false = not handled. +// Return: None. +// Throws: None. +//-- +CMICmdArgValPrintValues::CMICmdArgValPrintValues(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd) + : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd) + , m_nPrintValues(0) +{ +} + +//++ ------------------------------------------------------------------------------------ +// Details: CMICmdArgValPrintValues destructor. +// Type: Overridden. +// Args: None. +// Return: None. +// Throws: None. +//-- +CMICmdArgValPrintValues::~CMICmdArgValPrintValues(void) +{ +} + +//++ ------------------------------------------------------------------------------------ +// Details: Parse the command's argument options string and try to extract the value *this +// argument is looking for. +// Type: Overridden. +// Args: vwArgContext - (RW) The command's argument options string. +// Return: MIstatus::success - Functional succeeded. +// MIstatus::failure - Functional failed. +// Throws: None. +//-- +bool +CMICmdArgValPrintValues::Validate(CMICmdArgContext &vwArgContext) +{ + if (vwArgContext.IsEmpty()) + return MIstatus::success; + + const CMIUtilString &rArg(vwArgContext.GetArgs()[0]); + if (IsArgPrintValues(rArg) && ExtractPrintValues(rArg)) + { + m_bFound = true; + m_bValid = true; + m_argValue = GetPrintValues(); + vwArgContext.RemoveArg(rArg); + return MIstatus::success; + } + + return MIstatus::failure; +} + +//++ ------------------------------------------------------------------------------------ +// Details: Examine the string and determine if it is a valid string type argument. +// Type: Method. +// Args: vrTxt - (R) Some text. +// Return: bool - True = yes valid arg, false = no. +// Throws: None. +//-- +bool +CMICmdArgValPrintValues::IsArgPrintValues(const CMIUtilString &vrTxt) const +{ + return (CMIUtilString::Compare(vrTxt, "0") || CMIUtilString::Compare(vrTxt, "--no-values") || + CMIUtilString::Compare(vrTxt, "1") || CMIUtilString::Compare(vrTxt, "--all-values") || + CMIUtilString::Compare(vrTxt, "2") || CMIUtilString::Compare(vrTxt, "--simple-values")); +} + +//++ ------------------------------------------------------------------------------------ +// Details: Extract the print-values from the print-values argument. +// Type: Method. +// Args: vrTxt - (R) Some text. +// Return: MIstatus::success - Functional succeeded. +// MIstatus::failure - Functional failed. +// Throws: None. +//-- +bool +CMICmdArgValPrintValues::ExtractPrintValues(const CMIUtilString &vrTxt) +{ + if (CMIUtilString::Compare(vrTxt, "0") || CMIUtilString::Compare(vrTxt, "--no-values")) + m_nPrintValues = 0; + else if (CMIUtilString::Compare(vrTxt, "1") || CMIUtilString::Compare(vrTxt, "--all-values")) + m_nPrintValues = 1; + else if (CMIUtilString::Compare(vrTxt, "2") || CMIUtilString::Compare(vrTxt, "--simple-values")) + m_nPrintValues = 2; + else + return MIstatus::failure; + + return MIstatus::success; +} + +//++ ------------------------------------------------------------------------------------ +// Details: Retrieve the print-values found in the argument. +// Type: Method. +// Args: None. +// Return: MIuint - The print-values. +// Throws: None. +//-- +MIuint +CMICmdArgValPrintValues::GetPrintValues(void) const +{ + return m_nPrintValues; +} diff --git a/lldb/tools/lldb-mi/MICmdArgValPrintValues.h b/lldb/tools/lldb-mi/MICmdArgValPrintValues.h new file mode 100644 index 000000000000..37de923e9e52 --- /dev/null +++ b/lldb/tools/lldb-mi/MICmdArgValPrintValues.h @@ -0,0 +1,53 @@ +//===-- MICmdArgValPrintValues.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 + +// In-house headers: +#include "MICmdArgValBase.h" + +// Declarations: +class CMICmdArgContext; + +//++ ============================================================================ +// Details: MI common code class. Command argument class. Arguments object +// needing specialization derived from the CMICmdArgValBase class. +// An argument knows what type of argument it is and how it is to +// interpret the options (context) string to find and validate a matching +// argument and so extract a value from it. The print-values looks like: +// 0 or --no-values +// 1 or --all-values +// 2 or --simple-values +// Based on the Interpreter pattern. +//-- +class CMICmdArgValPrintValues : public CMICmdArgValBaseTemplate +{ + // Methods: + public: + /* ctor */ CMICmdArgValPrintValues(void); + /* ctor */ CMICmdArgValPrintValues(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd); + // + bool IsArgPrintValues(const CMIUtilString &vrTxt) const; + + // Overridden: + public: + // From CMICmdArgValBase + /* dtor */ virtual ~CMICmdArgValPrintValues(void); + // From CMICmdArgSet::IArg + virtual bool Validate(CMICmdArgContext &vArgContext); + + // Methods: + private: + bool ExtractPrintValues(const CMIUtilString &vrTxt); + MIuint GetPrintValues(void) const; + + // Attributes: + private: + MIuint m_nPrintValues; +}; diff --git a/lldb/tools/lldb-mi/MICmdCmdStack.cpp b/lldb/tools/lldb-mi/MICmdCmdStack.cpp index d608ad49fac3..7f767e727f97 100644 --- a/lldb/tools/lldb-mi/MICmdCmdStack.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdStack.cpp @@ -29,6 +29,7 @@ #include "MICmdArgValThreadGrp.h" #include "MICmdArgValOptionLong.h" #include "MICmdArgValOptionShort.h" +#include "MICmdArgValPrintValues.h" #include "MICmdArgValListOfN.h" //++ ------------------------------------------------------------------------------------ @@ -449,9 +450,6 @@ CMICmdCmdStackListArguments::CMICmdCmdStackListArguments(void) , m_miValueList(true) , m_constStrArgThread("thread") , m_constStrArgPrintValues("print-values") - , m_constStrArgNoValues("no-values") - , m_constStrArgAllValues("all-values") - , m_constStrArgSimpleValues("simple-values") , m_constStrArgFrameLow("low-frame") , m_constStrArgFrameHigh("high-frame") { @@ -487,10 +485,7 @@ CMICmdCmdStackListArguments::ParseArgs(void) { bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgPrintValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgNoValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgAllValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSimpleValues, false, true))); + 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()); @@ -509,10 +504,7 @@ bool CMICmdCmdStackListArguments::Execute(void) { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); - CMICMDBASE_GETOPTION(pArgPrintValues, Number, m_constStrArgPrintValues); - CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues); - CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues); - CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues); + CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues); CMICMDBASE_GETOPTION(pArgFrameLow, Number, m_constStrArgFrameLow); CMICMDBASE_GETOPTION(pArgFrameHigh, Number, m_constStrArgFrameHigh); @@ -527,28 +519,7 @@ CMICmdCmdStackListArguments::Execute(void) } } - CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat; - if (pArgPrintValues->GetFound()) - { - const MIuint nPrintValues = pArgPrintValues->GetValue(); - if (nPrintValues >= CMICmnLLDBDebugSessionInfo::kNumVariableInfoFormats) - { - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); - return MIstatus::failure; - } - eVarInfoFormat = static_cast(nPrintValues); - } - else if (pArgNoValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues; - else if (pArgAllValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues; - else if (pArgSimpleValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues; - else - { - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); - return MIstatus::failure; - } + const CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat = static_cast(pArgPrintValues->GetValue()); MIuint nFrameLow = 0; MIuint nFrameHigh = UINT32_MAX; @@ -667,9 +638,6 @@ CMICmdCmdStackListLocals::CMICmdCmdStackListLocals(void) , m_constStrArgThread("thread") , m_constStrArgFrame("frame") , m_constStrArgPrintValues("print-values") - , m_constStrArgNoValues("no-values") - , m_constStrArgAllValues("all-values") - , m_constStrArgSimpleValues("simple-values") { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "stack-list-locals"; @@ -705,10 +673,7 @@ CMICmdCmdStackListLocals::ParseArgs(void) 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 CMICmdArgValNumber(m_constStrArgPrintValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgNoValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgAllValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSimpleValues, false, true))); + bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true))); return (bOk && ParseValidateCmdOptions()); } @@ -726,10 +691,7 @@ CMICmdCmdStackListLocals::Execute(void) { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame); - CMICMDBASE_GETOPTION(pArgPrintValues, Number, m_constStrArgPrintValues); - CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues); - CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues); - CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues); + CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues); // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; @@ -752,28 +714,7 @@ CMICmdCmdStackListLocals::Execute(void) } } - CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat; - if (pArgPrintValues->GetFound()) - { - const MIuint nPrintValues = pArgPrintValues->GetValue(); - if (nPrintValues >= CMICmnLLDBDebugSessionInfo::kNumVariableInfoFormats) - { - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); - return MIstatus::failure; - } - eVarInfoFormat = static_cast(nPrintValues); - } - else if (pArgNoValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues; - else if (pArgAllValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues; - else if (pArgSimpleValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues; - else - { - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); - return MIstatus::failure; - } + const CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat = static_cast(pArgPrintValues->GetValue()); CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); lldb::SBProcess sbProcess = rSessionInfo.GetProcess(); @@ -862,9 +803,6 @@ CMICmdCmdStackListVariables::CMICmdCmdStackListVariables(void) , m_constStrArgThread("thread") , m_constStrArgFrame("frame") , m_constStrArgPrintValues("print-values") - , m_constStrArgNoValues("no-values") - , m_constStrArgAllValues("all-values") - , m_constStrArgSimpleValues("simple-values") { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "stack-list-variables"; @@ -900,10 +838,7 @@ CMICmdCmdStackListVariables::ParseArgs(void) 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 CMICmdArgValNumber(m_constStrArgPrintValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgNoValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgAllValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSimpleValues, false, true))); + bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValPrintValues(m_constStrArgPrintValues, true, true))); return (bOk && ParseValidateCmdOptions()); } @@ -921,10 +856,7 @@ CMICmdCmdStackListVariables::Execute(void) { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame); - CMICMDBASE_GETOPTION(pArgPrintValues, Number, m_constStrArgPrintValues); - CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues); - CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues); - CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues); + CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues); // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; @@ -947,28 +879,7 @@ CMICmdCmdStackListVariables::Execute(void) } } - CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat; - if (pArgPrintValues->GetFound()) - { - const MIuint nPrintValues = pArgPrintValues->GetValue(); - if (nPrintValues >= CMICmnLLDBDebugSessionInfo::kNumVariableInfoFormats) - { - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); - return MIstatus::failure; - } - eVarInfoFormat = static_cast(nPrintValues); - } - else if (pArgNoValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues; - else if (pArgAllValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues; - else if (pArgSimpleValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues; - else - { - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); - return MIstatus::failure; - } + const CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat = static_cast(pArgPrintValues->GetValue()); CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); lldb::SBProcess sbProcess = rSessionInfo.GetProcess(); diff --git a/lldb/tools/lldb-mi/MICmdCmdStack.h b/lldb/tools/lldb-mi/MICmdCmdStack.h index f5b02976f3e9..ed141fcf942f 100644 --- a/lldb/tools/lldb-mi/MICmdCmdStack.h +++ b/lldb/tools/lldb-mi/MICmdCmdStack.h @@ -166,9 +166,6 @@ class CMICmdCmdStackListArguments : public CMICmdBase CMICmnMIValueList m_miValueList; const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgPrintValues; - const CMIUtilString m_constStrArgNoValues; - const CMIUtilString m_constStrArgAllValues; - const CMIUtilString m_constStrArgSimpleValues; const CMIUtilString m_constStrArgFrameLow; const CMIUtilString m_constStrArgFrameHigh; }; @@ -207,9 +204,6 @@ class CMICmdCmdStackListLocals : public CMICmdBase 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; - const CMIUtilString m_constStrArgNoValues; - const CMIUtilString m_constStrArgAllValues; - const CMIUtilString m_constStrArgSimpleValues; }; //++ ============================================================================ @@ -243,9 +237,6 @@ private: const CMIUtilString m_constStrArgThread; const CMIUtilString m_constStrArgFrame; const CMIUtilString m_constStrArgPrintValues; - const CMIUtilString m_constStrArgNoValues; - const CMIUtilString m_constStrArgAllValues; - const CMIUtilString m_constStrArgSimpleValues; }; //++ ============================================================================ diff --git a/lldb/tools/lldb-mi/MICmdCmdVar.cpp b/lldb/tools/lldb-mi/MICmdCmdVar.cpp index 37e5eb060d81..f7e49beb68cb 100644 --- a/lldb/tools/lldb-mi/MICmdCmdVar.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdVar.cpp @@ -33,6 +33,7 @@ #include "MICmdArgValThreadGrp.h" #include "MICmdArgValOptionLong.h" #include "MICmdArgValOptionShort.h" +#include "MICmdArgValPrintValues.h" #include "MICmdArgValListOfN.h" #include "MICmnLLDBProxySBValue.h" #include "MICmnLLDBUtilSBValue.h" @@ -322,9 +323,6 @@ CMICmdCmdVarCreate::CompleteSBValue(lldb::SBValue &vrwValue) CMICmdCmdVarUpdate::CMICmdCmdVarUpdate(void) : m_constStrArgPrintValues("print-values") , m_constStrArgName("name") - , m_constStrArgNoValues("no-values") - , m_constStrArgAllValues("all-values") - , m_constStrArgSimpleValues("simple-values") , m_bValueChanged(false) , m_miValueList(true) { @@ -358,10 +356,7 @@ CMICmdCmdVarUpdate::~CMICmdCmdVarUpdate(void) bool CMICmdCmdVarUpdate::ParseArgs(void) { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgPrintValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgNoValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgAllValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSimpleValues, false, true))); + 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()); } @@ -378,32 +373,12 @@ CMICmdCmdVarUpdate::ParseArgs(void) bool CMICmdCmdVarUpdate::Execute(void) { - CMICMDBASE_GETOPTION(pArgPrintValues, Number, m_constStrArgPrintValues); - CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues); - CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues); - CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues); + CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues); CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName); - CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat; + CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues; if (pArgPrintValues->GetFound()) - { - const MIuint nPrintValues = pArgPrintValues->GetValue(); - if (nPrintValues >= CMICmnLLDBDebugSessionInfo::kNumVariableInfoFormats) - { - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); - return MIstatus::failure; - } - eVarInfoFormat = static_cast(nPrintValues); - } - else if (pArgNoValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues; - else if (pArgAllValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues; - else if (pArgSimpleValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues; - else - // If no print-values, default is "no-values" - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues; + eVarInfoFormat = static_cast(pArgPrintValues->GetValue()); const CMIUtilString &rVarObjName(pArgName->GetValue()); CMICmnLLDBDebugSessionInfoVarObj varObj; @@ -945,9 +920,6 @@ CMICmdCmdVarSetFormat::CreateSelf(void) //-- CMICmdCmdVarListChildren::CMICmdCmdVarListChildren(void) : m_constStrArgPrintValues("print-values") - , m_constStrArgNoValues("no-values") - , m_constStrArgAllValues("all-values") - , m_constStrArgSimpleValues("simple-values") , m_constStrArgName("name") , m_constStrArgFrom("from") , m_constStrArgTo("to") @@ -986,10 +958,7 @@ CMICmdCmdVarListChildren::~CMICmdCmdVarListChildren(void) bool CMICmdCmdVarListChildren::ParseArgs(void) { - bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgPrintValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgNoValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgAllValues, false, true))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSimpleValues, false, true))); + 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))); @@ -1008,34 +977,14 @@ CMICmdCmdVarListChildren::ParseArgs(void) bool CMICmdCmdVarListChildren::Execute(void) { - CMICMDBASE_GETOPTION(pArgPrintValues, Number, m_constStrArgPrintValues); - CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues); - CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues); - CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues); + CMICMDBASE_GETOPTION(pArgPrintValues, PrintValues, m_constStrArgPrintValues); CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName); CMICMDBASE_GETOPTION(pArgFrom, Number, m_constStrArgFrom); CMICMDBASE_GETOPTION(pArgTo, Number, m_constStrArgTo); - CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat; + CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues; if (pArgPrintValues->GetFound()) - { - const MIuint nPrintValues = pArgPrintValues->GetValue(); - if (nPrintValues >= CMICmnLLDBDebugSessionInfo::kNumVariableInfoFormats) - { - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); - return MIstatus::failure; - } - eVarInfoFormat = static_cast(nPrintValues); - } - else if (pArgNoValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues; - else if (pArgAllValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues; - else if (pArgSimpleValues->GetFound()) - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues; - else - // If no print-values, default is "no-values" - eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues; + eVarInfoFormat = static_cast(pArgPrintValues->GetValue()); const CMIUtilString &rVarObjName(pArgName->GetValue()); CMICmnLLDBDebugSessionInfoVarObj varObj; diff --git a/lldb/tools/lldb-mi/MICmdCmdVar.h b/lldb/tools/lldb-mi/MICmdCmdVar.h index 88d72ec7db88..4c294018a646 100644 --- a/lldb/tools/lldb-mi/MICmdCmdVar.h +++ b/lldb/tools/lldb-mi/MICmdCmdVar.h @@ -128,9 +128,6 @@ class CMICmdCmdVarUpdate : public CMICmdBase private: const CMIUtilString m_constStrArgPrintValues; const CMIUtilString m_constStrArgName; - const CMIUtilString m_constStrArgNoValues; - const CMIUtilString m_constStrArgAllValues; - const CMIUtilString m_constStrArgSimpleValues; bool m_bValueChanged; // True = yes value changed, false = no change CMICmnMIValueList m_miValueList; }; @@ -266,9 +263,6 @@ class CMICmdCmdVarListChildren : public CMICmdBase // Attributes: private: const CMIUtilString m_constStrArgPrintValues; - const CMIUtilString m_constStrArgNoValues; - const CMIUtilString m_constStrArgAllValues; - const CMIUtilString m_constStrArgSimpleValues; const CMIUtilString m_constStrArgName; const CMIUtilString m_constStrArgFrom; const CMIUtilString m_constStrArgTo;