Index: test/tools/lldb-mi/TestMiBreakpoint.py =================================================================== --- test/tools/lldb-mi/TestMiBreakpoint.py +++ test/tools/lldb-mi/TestMiBreakpoint.py @@ -18,7 +18,7 @@ self.runCmd("-file-exec-and-symbols %s" % self.myexe) self.expect("\^done") - self.runCmd("-break-insert -f a_MyFunction") + self.runCmd("-break-insert -f b_MyFunction") self.expect("\^done,bkpt={number=\"1\"") self.runCmd("-exec-run") @@ -71,7 +71,7 @@ self.expect("\*stopped,reason=\"breakpoint-hit\"") #break on symbol - self.runCmd("-break-insert a_MyFunction") + self.runCmd("-break-insert b_MyFunction") self.expect("\^done,bkpt={number=\"2\"") self.runCmd("-exec-continue") Index: test/tools/lldb-mi/TestMiData.py =================================================================== --- test/tools/lldb-mi/TestMiData.py +++ test/tools/lldb-mi/TestMiData.py @@ -0,0 +1,34 @@ +""" +Test that the lldb-mi driver works with -data-xxx commands +""" + +import lldbmi_testcase +from lldbtest import * +import unittest2 + +class MiDataTestCase(lldbmi_testcase.MiTestCaseBase): + + @lldbmi_test + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + def test_lldbmi_datadisassemble(self): + """Test that 'lldb-mi --interpreter' works for -data-disassemble.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -data-disassemble: try to disassemble some address + self.runCmd("-data-disassemble -s 0x0 -e 0x0 -- 0") + self.expect("\^done,asm_insns=\[") + +if __name__ == '__main__': + unittest2.main() Index: test/tools/lldb-mi/TestMiEvaluate.py =================================================================== --- test/tools/lldb-mi/TestMiEvaluate.py +++ test/tools/lldb-mi/TestMiEvaluate.py @@ -36,26 +36,26 @@ self.expect("\*stopped,reason=\"breakpoint-hit\"") #print non-existant variable - #self.runCmd("-var-create var1 --thread 1 --frame 0 * undef") #FIXME: shows undef as {...} + #self.runCmd("-var-create var1 --frame 0 * undef") #FIXME: shows undef as {...} #self.expect("error") #self.runCmd("-data-evaluate-expression undef") #FIXME: gets value="undef" #self.expect("error") #print global "g_MyVar" - self.runCmd("-var-create var1 --thread 1 --frame 0 * g_MyVar") #FIXME: shows name=" + self.runCmd("-var-create var1 --frame 0 * g_MyVar") #FIXME: shows name=" self.expect("value=\"3\",type=\"int\"") #self.runCmd("-var-evaluate-expression var1") #FIXME: gets var1 does not exist self.runCmd("-var-show-attributes var1") self.expect("status=\"editable\"") self.runCmd("-var-delete var1") self.expect("\^done") - self.runCmd("-var-create var1 --thread 1 --frame 0 * g_MyVar") + self.runCmd("-var-create var1 --frame 0 * g_MyVar") self.expect("value=\"3\",type=\"int\"") #print static "s_MyVar" and modify self.runCmd("-data-evaluate-expression s_MyVar") self.expect("value=\"30\"") - self.runCmd("-var-create var3 --thread 1 --frame 0 * \"s_MyVar=3\"") + self.runCmd("-var-create var3 --frame 0 * \"s_MyVar=3\"") self.expect("value=\"3\",type=\"int\"") self.runCmd("-data-evaluate-expression \"s_MyVar=30\"") self.expect("value=\"30\"") @@ -63,12 +63,12 @@ #print local "b" and modify self.runCmd("-data-evaluate-expression b") self.expect("value=\"20\"") - self.runCmd("-var-create var3 --thread 1 --frame 0 * \"b=3\"") + self.runCmd("-var-create var3 --frame 0 * \"b=3\"") self.expect("value=\"3\",type=\"int\"") self.runCmd("-data-evaluate-expression \"b=20\"") self.expect("value=\"20\"") - #print "a + b" + #print "a + b" in certain thread self.runCmd("-data-evaluate-expression \"a + b\"") self.expect("value=\"30\"") self.runCmd("-var-create var3 --thread 1 --frame 0 * \"a + b\"") @@ -77,7 +77,7 @@ #print "argv[0]" self.runCmd("-data-evaluate-expression \"argv[0]\"") self.expect("value=\"0x") - self.runCmd("-var-create var3 --thread 1 --frame 0 * \"argv[0]\"") + self.runCmd("-var-create var3 --frame 0 * \"argv[0]\"") self.expect("numchild=\"1\",value=\"0x.*\",type=\"const char \*\"") #run to exit Index: test/tools/lldb-mi/TestMiExec.py =================================================================== --- test/tools/lldb-mi/TestMiExec.py +++ test/tools/lldb-mi/TestMiExec.py @@ -0,0 +1,315 @@ +""" +Test that the lldb-mi driver works with -exec-xxx commands +""" + +import lldbmi_testcase +from lldbtest import * +import unittest2 + +class MiExecTestCase(lldbmi_testcase.MiTestCaseBase): + + @lldbmi_test + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + def test_lldbmi_exec_next(self): + """Test that 'lldb-mi --interpreter' works for stepping.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Warning: the following is sensative to the lines in the source. + + # Test -exec-next + self.runCmd("-exec-next --thread 1 --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"22\"") + + # Test that --thread is optional + self.runCmd("-exec-next --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"23\"") + + # Test that --frame is optional + self.runCmd("-exec-next --thread 1") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"25\"") + + # Test that both --thread and --frame are optional + self.runCmd("-exec-next --thread 1") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"27\"") + + # Test that an invalid --thread is handled + self.runCmd("-exec-next --thread 0") + self.expect("\^error,message=\"error: Thread index 0 is out of range") + self.runCmd("-exec-next --thread 10") + self.expect("\^error,message=\"error: Thread index 10 is out of range") + + # Test that an invalid --frame is handled + # FIXME: no error is returned. + self.runCmd("-exec-next --frame 10") + #self.expect("\^error: Frame index 10 is out of range") + + @lldbmi_test + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + def test_lldbmi_exec_next_instruction(self): + """Test that 'lldb-mi --interpreter' works for instruction stepping.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Warning: the following is sensative to the lines in the + # source and optimizations. + + # Test -exec-next-instruction + self.runCmd("-exec-next-instruction --thread 1 --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"20\"") + + # Test that --thread is optional + self.runCmd("-exec-next-instruction --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"20\"") + + # Test that --frame is optional + self.runCmd("-exec-next-instruction --thread 1") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"20\"") + + # Test that both --thread and --frame are optional + self.runCmd("-exec-next-instruction --thread 1") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"22\"") + + # Test that an invalid --thread is handled + self.runCmd("-exec-next-instruction --thread 0") + self.expect("\^error,message=\"error: Thread index 0 is out of range") + self.runCmd("-exec-next-instruction --thread 10") + self.expect("\^error,message=\"error: Thread index 10 is out of range") + + # Test that an invalid --frame is handled + # FIXME: no error is returned + self.runCmd("-exec-next-instruction --frame 10") + #self.expect("\^error: Frame index 10 is out of range") + + @lldbmi_test + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + def test_lldbmi_exec_step(self): + """Test that 'lldb-mi --interpreter' works for stepping into.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Warning: the following is sensative to the lines in the source. + + # Test that -exec-step does not step into printf (which + # has no debug info) + self.runCmd("-exec-step --thread 1 --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"22\"") + + # Test that -exec-step steps into a_MyFunction and back out + # (and that --thread is optional) + self.runCmd("-exec-step --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"a_MyFunction\"") + self.runCmd("-exec-step --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"a_MyFunction\"") + self.runCmd("-exec-step --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"22\"") + self.runCmd("-exec-step --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"23\"") + + # Test that -exec-step steps into b_MyFunction + # (and that --frame is optional) + self.runCmd("-exec-step --thread 1") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"b_MyFunction\"") + + # Test that -exec-step steps into a_MyFunction from inside + # b_MyFunction (and that both --thread and --frame are optional) + self.runCmd("-exec-step") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"a_MyFunction\"") + + # Test that an invalid --thread is handled + self.runCmd("-exec-step --thread 0") + self.expect("\^error,message=\"error: Thread index 0 is out of range") + self.runCmd("-exec-step --thread 10") + self.expect("\^error,message=\"error: Thread index 10 is out of range") + + # Test that an invalid --frame is handled. + # FIXME: no error is returned + self.runCmd("-exec-step --frame 10") + #self.expect("\^error: Frame index 10 is out of range") + + @lldbmi_test + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin due to calling convention assumptions") + def test_lldbmi_exec_step_instruction(self): + """Test that 'lldb-mi --interpreter' works for instruction stepping into.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Warning: the following is sensative to the lines in the + # source and optimizations. + + # Run to a_MyFunction call + line = line_number('main.c', '//BP_a_MyFunction_call') + self.runCmd("-break-insert -f main.c:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -exec-step-instruction steps over non branching + # instruction + self.runCmd("-exec-step-instruction --thread 1 --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"22\"") + + # Test that -exec-step-instruction steps over non branching + # instruction (and that --thread is optional) + self.runCmd("-exec-step-instruction --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*main.c\",line=\"22\"") + + # Test that -exec-step-instruction steps into a_MyFunction + # (and that --frame is optional) + self.runCmd("-exec-step-instruction --thread 1") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"a_MyFunction\"") + + # Test that -exec-step-instruction steps into a_MyFunction + # (and that both --thread and --frame are optional) + self.runCmd("-exec-step-instruction --thread 1") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"a_MyFunction\"") + + # Test that an invalid --thread is handled + self.runCmd("-exec-step-instruction --thread 0") + self.expect("\^error,message=\"error: Thread index 0 is out of range") + self.runCmd("-exec-step-instruction --thread 10") + self.expect("\^error,message=\"error: Thread index 10 is out of range") + + # Test that an invalid --frame is handled + # FIXME: no error is returned. + self.runCmd("-exec-step-instruction --frame 10") + #self.expect("\^error: Frame index 10 is out of range") + + @lldbmi_test + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @unittest2.expectedFailure("requires '-exec-arguments' patch") + def test_lldbmi_exec_finish(self): + """Test that 'lldb-mi --interpreter' works for -exec-finish.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Set argument 'l' + self.runCmd("-exec-arguments l") + self.expect("\^done") + + # Set BP at a_MyFunction_call and run to BP + self.runCmd("-break-insert -f a_MyFunction") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -exec-finish returns from a_MyFunction + self.runCmd("-exec-finish --thread 1 --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"main\"") + + # Run to BP inside b_MyFunction call + line = line_number('b.c', '//BP_b_MyFunction') + self.runCmd("-break-insert -f b.c:%d" % line) + self.expect("\^done,bkpt={number=\"2\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -exec-finish hits BP at a_MyFunction call inside + # b_MyFunction (and that --thread is optional) + self.runCmd("-exec-finish --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -exec-finish returns from a_MyFunction call inside + # b_MyFunction (and that --frame is optional) + self.runCmd("-exec-finish --thread 1") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"b_MyFunction\"") + + # Test that -exec-finish returns from b_MyFunction + # (and that both --thread and --frame are optional) + self.runCmd("-exec-finish") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"main\"") + + # Test that an invalid --thread is handled + self.runCmd("-exec-finish --thread 0") + self.expect("\^error,message=\"error: Thread index 0 is out of range") + self.runCmd("-exec-finish --thread 10") + self.expect("\^error,message=\"error: Thread index 10 is out of range") + + # Test that an invalid --frame is handled. + # FIXME: no error is returned. + #self.runCmd("-exec-finish --frame 10") + #self.expect("\^error: Frame index 10 is out of range") + + # Set BP at printf and run to BP. + # FIXME: BP at printf not resolved and never hit! + self.runCmd("-interpreter-exec command \"b printf\"") #FIXME: self.runCmd("-break-insert -f printf") + self.expect("\^done") #FIXME: self.expect("\^done,bkpt={number=\"3\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + ## Test that -exec-finish returns from printf. + self.runCmd("-exec-finish --thread 1 --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"main\"") + +if __name__ == '__main__': + unittest2.main() Index: test/tools/lldb-mi/TestMiStack.py =================================================================== --- test/tools/lldb-mi/TestMiStack.py +++ test/tools/lldb-mi/TestMiStack.py @@ -40,7 +40,7 @@ self.spawnLldbMi(args = None) # Load executable - self.runCmd("-file-exec-and-symbols %s" % (self.myexe)) + self.runCmd("-file-exec-and-symbols %s" % self.myexe) self.expect("\^done") # Run to main @@ -57,5 +57,49 @@ self.runCmd("-stack-list-locals 1") self.expect("\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]") + @lldbmi_test + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + def test_lldbmi_stackdepth(self): + """Test that 'lldb-mi --interpreter' can shows depth of the stack.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test stack depth + self.runCmd("-stack-info-depth") + self.expect("\^done,depth=\"[1-9]\"") + + @lldbmi_test + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + def test_lldbmi_stackframes(self): + """Test that 'lldb-mi --interpreter' can lists the frames on the stack.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test stack frame: get frame #0 info + self.runCmd("-stack-list-frames 0 0") + self.expect("\^done,stack=\[frame=\{level=\"0\",addr=\".+\",func=\"main\",file=\"main\.c\",fullname=\".*main\.c\",line=\"[0-9]+\"\}\]") + if __name__ == '__main__': unittest2.main() Index: test/tools/lldb-mi/TestMiSyntax.py =================================================================== --- test/tools/lldb-mi/TestMiSyntax.py +++ test/tools/lldb-mi/TestMiSyntax.py @@ -20,7 +20,7 @@ self.expect("000\^done") # Run to main - self.runCmd("100000001-break-insert -f a_MyFunction") + self.runCmd("100000001-break-insert -f b_MyFunction") self.expect("100000001\^done,bkpt={number=\"1\"") self.runCmd("2-exec-run") self.expect("2\^running") Index: test/tools/lldb-mi/a.c =================================================================== --- test/tools/lldb-mi/a.c +++ test/tools/lldb-mi/a.c @@ -3,7 +3,6 @@ int a_MyFunction () { - // Set a breakpoint here. - printf ("a is about to return 10.\n"); + printf ("a is about to return 10.\n"); //BP_a_MyFunction return 10; } Index: test/tools/lldb-mi/b.c =================================================================== --- test/tools/lldb-mi/b.c +++ test/tools/lldb-mi/b.c @@ -1,9 +1,10 @@ #include +extern int a_MyFunction(); int b_MyFunction () { - // Set a breakpoint here. + (void)a_MyFunction(); //BP_b_MyFunction printf ("b is about to return 20.\n"); return 20; } Index: test/tools/lldb-mi/main.c =================================================================== --- test/tools/lldb-mi/main.c +++ test/tools/lldb-mi/main.c @@ -17,9 +17,10 @@ int main (int argc, char const *argv[]) { int a, b; - printf("argc=%d\n", argc); - a = a_MyFunction(); - b = b_MyFunction(); + printf("argc=%d\n", argc); //BP_printf_call + //BP_argctest + a = a_MyFunction(); //BP_a_MyFunction_call + b = b_MyFunction(); //BP_b_MyFunction_call //BP_localstest if (doloop) infloop(); Index: tools/lldb-mi/MICmdCmdData.cpp =================================================================== --- tools/lldb-mi/MICmdCmdData.cpp +++ tools/lldb-mi/MICmdCmdData.cpp @@ -342,7 +342,7 @@ CMICmdCmdDataDisassemble::ParseArgs(void) { bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1))); + 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))); @@ -373,7 +373,7 @@ // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; - if (!pArgThread->GetExpectedOption(nThreadId)) + if (pArgThread->GetFound() && !pArgThread->GetExpectedOption(nThreadId)) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str())); return MIstatus::failure; Index: tools/lldb-mi/MICmdCmdExec.cpp =================================================================== --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -328,7 +328,7 @@ CMICmdCmdExecNext::ParseArgs(void) { bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1))); + 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()); } @@ -349,7 +349,7 @@ // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; - if (!pArgThread->GetExpectedOption(nThreadId)) + if (pArgThread->GetFound() && !pArgThread->GetExpectedOption(nThreadId)) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str())); return MIstatus::failure; @@ -455,7 +455,7 @@ CMICmdCmdExecStep::ParseArgs(void) { bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1))); + 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()); } @@ -476,7 +476,7 @@ // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; - if (!pArgThread->GetExpectedOption(nThreadId)) + if (pArgThread->GetFound() && !pArgThread->GetExpectedOption(nThreadId)) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str())); return MIstatus::failure; @@ -582,7 +582,7 @@ CMICmdCmdExecNextInstruction::ParseArgs(void) { bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1))); + 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()); } @@ -603,7 +603,7 @@ // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; - if (!pArgThread->GetExpectedOption(nThreadId)) + if (pArgThread->GetFound() && !pArgThread->GetExpectedOption(nThreadId)) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str())); return MIstatus::failure; @@ -709,7 +709,7 @@ CMICmdCmdExecStepInstruction::ParseArgs(void) { bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1))); + 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()); } @@ -730,7 +730,7 @@ // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; - if (!pArgThread->GetExpectedOption(nThreadId)) + if (pArgThread->GetFound() && !pArgThread->GetExpectedOption(nThreadId)) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str())); return MIstatus::failure; @@ -836,7 +836,7 @@ CMICmdCmdExecFinish::ParseArgs(void) { bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1))); + 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()); @@ -858,7 +858,7 @@ // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; - if (!pArgThread->GetExpectedOption(nThreadId)) + if (pArgThread->GetFound() && !pArgThread->GetExpectedOption(nThreadId)) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str())); return MIstatus::failure; Index: tools/lldb-mi/MICmdCmdStack.cpp =================================================================== --- tools/lldb-mi/MICmdCmdStack.cpp +++ tools/lldb-mi/MICmdCmdStack.cpp @@ -82,7 +82,7 @@ CMICmdCmdStackInfoDepth::ParseArgs(void) { bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1))); + 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()); } @@ -104,7 +104,7 @@ // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; - if (!pArgThread->GetExpectedOption(nThreadId)) + if (pArgThread->GetFound() && !pArgThread->GetExpectedOption(nThreadId)) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str())); return MIstatus::failure; @@ -202,7 +202,7 @@ CMICmdCmdStackListFrames::ParseArgs(void) { bool bOk = - m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1))); + 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()); @@ -226,7 +226,7 @@ // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; - if (!pArgThread->GetExpectedOption(nThreadId)) + if (pArgThread->GetFound() && !pArgThread->GetExpectedOption(nThreadId)) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str())); return MIstatus::failure; Index: tools/lldb-mi/MICmdCmdVar.cpp =================================================================== --- tools/lldb-mi/MICmdCmdVar.cpp +++ tools/lldb-mi/MICmdCmdVar.cpp @@ -129,12 +129,11 @@ // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; - if (!pArgThread->GetExpectedOption(nThreadId)) + if (pArgThread->GetFound() && !pArgThread->GetExpectedOption(nThreadId)) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str())); return MIstatus::failure; } - m_nThreadId = nThreadId; // Retrieve the --frame option's number MIuint64 nFrame = UINT64_MAX; @@ -171,7 +170,8 @@ CMICmnLLDBDebugSessionInfoVarObj::VarObjIdInc(); } lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess; - lldb::SBThread thread = rProcess.GetThreadByIndexID(nThreadId); + lldb::SBThread thread = (nThreadId != UINT64_MAX) ? rProcess.GetThreadByIndexID(nThreadId) : rProcess.GetSelectedThread(); + m_nThreadId = thread.GetIndexID(); lldb::SBFrame frame = thread.GetFrameAtIndex(nFrame); lldb::SBValue value = frame.FindVariable(rStrExpression.c_str()); if (!value.IsValid())