Index: lldb/trunk/test/tools/lldb-mi/data/TestMiData.py =================================================================== --- lldb/trunk/test/tools/lldb-mi/data/TestMiData.py +++ lldb/trunk/test/tools/lldb-mi/data/TestMiData.py @@ -200,10 +200,13 @@ self.runCmd('-data-read-memory-bytes &array') self.expect(r'\^error') - # Test that the address argument is required when other options are present + # Test that the address and count arguments are required when other options are present self.runCmd('-data-read-memory-bytes --thread 1') self.expect(r'\^error') + self.runCmd('-data-read-memory-bytes --thread 1 --frame 0') + self.expect(r'\^error') + # Test that the count argument is required when other options are present self.runCmd('-data-read-memory-bytes --thread 1 &array') self.expect(r'\^error') Index: lldb/trunk/test/tools/lldb-mi/stack/TestMiStack.py =================================================================== --- lldb/trunk/test/tools/lldb-mi/stack/TestMiStack.py +++ lldb/trunk/test/tools/lldb-mi/stack/TestMiStack.py @@ -445,7 +445,7 @@ # Test that -stack-select-frame requires 1 mandatory argument self.runCmd("-stack-select-frame") - self.expect("\^error,msg=\"Command 'stack-select-frame'\. Command Args\. Missing options, 1 or more required\"") + self.expect("\^error,msg=\"Command 'stack-select-frame'\. Command Args\. Validation failed. Mandatory args not found: frame\"") # Test that -stack-select-frame fails on invalid frame number self.runCmd("-stack-select-frame 99") Index: lldb/trunk/tools/lldb-mi/MICmdArgSet.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdArgSet.cpp +++ lldb/trunk/tools/lldb-mi/MICmdArgSet.cpp @@ -169,28 +169,24 @@ m_cmdArgContext = vwCmdArgsText; // Iterate all the arguments or options required by a command - const MIuint nArgs = vwCmdArgsText.GetNumberArgsPresent(); - MIuint nArgsMandatoryCnt = 0; SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin(); while (it != m_setCmdArgs.end()) { const CMICmdArgValBase *pArg(*it); - const CMIUtilString &rArgName(pArg->GetName()); - MIunused(rArgName); - if (pArg->GetIsMandatory()) - nArgsMandatoryCnt++; + if (!const_cast(pArg)->Validate(vwCmdArgsText)) { - if (pArg->GetIsMandatory() && !pArg->GetFound()) - m_setCmdArgsThatAreMissing.push_back(const_cast(pArg)); - else if (pArg->GetFound()) + if (pArg->GetFound()) { if (pArg->GetIsMissingOptions()) m_setCmdArgsMissingInfo.push_back(const_cast(pArg)); else if (!pArg->GetValid()) m_setCmdArgsThatNotValid.push_back(const_cast(pArg)); } + else if (pArg->GetIsMandatory()) + m_setCmdArgsThatAreMissing.push_back(const_cast(pArg)); } + if (pArg->GetFound() && !pArg->GetIsHandledByCmd()) { m_bIsArgsPresentButNotHandledByCmd = true; @@ -201,14 +197,7 @@ ++it; } - // Check that one or more argument objects have any issues to report... - - if (nArgs < nArgsMandatoryCnt) - { - SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_N_OPTIONS_REQUIRED), nArgsMandatoryCnt)); - return MIstatus::failure; - } - + // report any issues with arguments/options if (IsArgsPresentButNotHandledByCmd()) WarningArgsNotHandledbyCmdLogFile(vStrMiCmd); Index: lldb/trunk/tools/lldb-mi/MICmdArgValConsume.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdArgValConsume.cpp +++ lldb/trunk/tools/lldb-mi/MICmdArgValConsume.cpp @@ -59,7 +59,7 @@ CMICmdArgValConsume::Validate(CMICmdArgContext &vwArgContext) { if (vwArgContext.IsEmpty()) - return MIstatus::success; + return m_bMandatory ? MIstatus::failure : MIstatus::success; // Consume the optional file, line, linenum arguments till the mode '--' argument const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs()); @@ -68,15 +68,15 @@ { const CMIUtilString & rTxt( *it ); - if ( rTxt.compare( "--" ) == 0 ) + if ( rTxt.compare( "--" ) == 0 ) { m_bFound = true; m_bValid = true; - return MIstatus::success; - } + return MIstatus::success; + } - if ( !vwArgContext.RemoveArg( rTxt ) ) - return MIstatus::failure; + if ( !vwArgContext.RemoveArg( rTxt ) ) + return MIstatus::failure; // Next ++it; Index: lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp +++ lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp @@ -60,7 +60,7 @@ CMICmdArgValFile::Validate(CMICmdArgContext &vwArgContext) { if (vwArgContext.IsEmpty()) - return MIstatus::success; + return m_bMandatory ? MIstatus::failure : MIstatus::success; // The GDB/MI spec suggests there is only parameter Index: lldb/trunk/tools/lldb-mi/MICmdArgValListOfN.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdArgValListOfN.cpp +++ lldb/trunk/tools/lldb-mi/MICmdArgValListOfN.cpp @@ -74,7 +74,7 @@ } if (vwArgContext.IsEmpty()) - return MIstatus::success; + return m_bMandatory ? MIstatus::failure : MIstatus::success; const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse()); if (IsListOfN(rArg) && CreateList(rArg)) Index: lldb/trunk/tools/lldb-mi/MICmdArgValNumber.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdArgValNumber.cpp +++ lldb/trunk/tools/lldb-mi/MICmdArgValNumber.cpp @@ -66,7 +66,7 @@ CMICmdArgValNumber::Validate(CMICmdArgContext &vwArgContext) { if (vwArgContext.IsEmpty()) - return MIstatus::success; + return m_bMandatory ? MIstatus::failure : MIstatus::success; if (vwArgContext.GetNumberArgsPresent() == 1) { Index: lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp +++ lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp @@ -108,7 +108,7 @@ CMICmdArgValOptionLong::Validate(CMICmdArgContext &vwArgContext) { if (vwArgContext.IsEmpty()) - return MIstatus::success; + return m_bMandatory ? MIstatus::failure : MIstatus::success; if (vwArgContext.GetNumberArgsPresent() == 1) { Index: lldb/trunk/tools/lldb-mi/MICmdArgValPrintValues.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdArgValPrintValues.cpp +++ lldb/trunk/tools/lldb-mi/MICmdArgValPrintValues.cpp @@ -62,7 +62,7 @@ CMICmdArgValPrintValues::Validate(CMICmdArgContext &vwArgContext) { if (vwArgContext.IsEmpty()) - return MIstatus::success; + return m_bMandatory ? MIstatus::failure : MIstatus::success; const CMIUtilString strArg(vwArgContext.GetArgs()[0]); if (IsArgPrintValues(strArg) && ExtractPrintValues(strArg)) Index: lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp +++ lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp @@ -108,7 +108,7 @@ CMICmdArgValString::Validate(CMICmdArgContext &vrwArgContext) { if (vrwArgContext.IsEmpty()) - return MIstatus::success; + return m_bMandatory ? MIstatus::failure : MIstatus::success; if (m_bHandleQuotedString) return ValidateQuotedText(vrwArgContext); Index: lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.cpp +++ lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.cpp @@ -62,7 +62,7 @@ CMICmdArgValThreadGrp::Validate(CMICmdArgContext &vwArgContext) { if (vwArgContext.IsEmpty()) - return MIstatus::success; + return m_bMandatory ? MIstatus::failure : MIstatus::success; if (vwArgContext.GetNumberArgsPresent() == 1) { Index: lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp +++ lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp @@ -617,21 +617,6 @@ return MIstatus::failure; } - // FIXME: shouldn't have to ensure mandatory arguments are present, that should've been handled - // in ParseArgs(), unfortunately that seems kinda sorta broken right now if options are provided - // but mandatory arguments are missing, so here we go... - if (!pArgAddrExpr->GetFound()) - { - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY), m_constStrArgAddrExpr.c_str())); - return MIstatus::failure; - } - - if (!pArgNumBytes->GetFound()) - { - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY), m_constStrArgNumBytes.c_str())); - return MIstatus::failure; - } - CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); lldb::SBProcess sbProcess = rSessionInfo.GetProcess(); if (!sbProcess.IsValid()) Index: lldb/trunk/tools/lldb-mi/MICmnResources.h =================================================================== --- lldb/trunk/tools/lldb-mi/MICmnResources.h +++ lldb/trunk/tools/lldb-mi/MICmnResources.h @@ -193,7 +193,6 @@ IDS_STDERR_ERR_NOT_ALL_DATA_WRITTEN, - IDS_CMD_ARGS_ERR_N_OPTIONS_REQUIRED, IDS_CMD_ARGS_ERR_OPTION_NOT_FOUND, IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY, IDS_CMD_ARGS_ERR_VALIDATION_INVALID, Index: lldb/trunk/tools/lldb-mi/MICmnResources.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmnResources.cpp +++ lldb/trunk/tools/lldb-mi/MICmnResources.cpp @@ -178,7 +178,6 @@ {IDS_DRIVER_ERR_LOCAL_DEBUG_NOT_IMPL, "Driver. --executable argument given. Local debugging is not implemented."}, {IDS_DRIVER_ERR_LOCAL_DEBUG_INIT, "Driver. --executable argument given. Initialising local debugging failed."}, {IDS_STDERR_ERR_NOT_ALL_DATA_WRITTEN, "Stderr. Not all data was written to stream. The data '%s'"}, - {IDS_CMD_ARGS_ERR_N_OPTIONS_REQUIRED, "Command Args. Missing options, %d or more required"}, {IDS_CMD_ARGS_ERR_OPTION_NOT_FOUND, "Command Args. Option '%s' not found"}, {IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY, "Mandatory args not found: %s"}, {IDS_CMD_ARGS_ERR_VALIDATION_INVALID, "Invalid args: %s"},