[Lldb-commits] [lldb] r235195 - MI support for '-var-create $regname' command.
Ilia K
ki.stfu at gmail.com
Fri Apr 17 07:49:55 PDT 2015
Author: ki.stfu
Date: Fri Apr 17 09:49:54 2015
New Revision: 235195
URL: http://llvm.org/viewvc/llvm-project?rev=235195&view=rev
Log:
MI support for '-var-create $regname' command.
Summary:
This command is currently processed using expression evaluation, meaning the variable binds to the result of the expression not the register.
Therefore any subsequent calls to '-var-assign' will not update the register. Fixed by detecting '$' prefix for registers according to specification.
Thanks, Ewan
Patch from ewan at codeplay.com
Reviewers: EwanCrawford
Subscribers: lldb-commits, deepak2427
Differential Revision: http://reviews.llvm.org/D8965
Modified:
lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py
lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp
Modified: lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py?rev=235195&r1=235194&r2=235195&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py (original)
+++ lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py Fri Apr 17 09:49:54 2015
@@ -186,5 +186,41 @@ class MiVarTestCase(lldbmi_testcase.MiTe
self.runCmd("-var-update --all-values var_complx_array")
self.expect("\^done,changelist=\[\{name=\"var_complx_array\",value=\"\[2\]\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]")
+ @lldbmi_test
+ @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ def test_lldbmi_var_create_register(self):
+ """Test that 'lldb-mi --interpreter' works for -var-create $regname."""
+
+ 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\"")
+
+ # Find name of register 0
+ self.runCmd("-data-list-register-names 0")
+ self.expect("\^done,register-names=\[\".+?\"\]")
+ register_name = self.child.after.split("\"")[1]
+
+ # Create variable for register 0
+ self.runCmd("-var-create var_reg * $%s" % register_name)
+ self.expect("\^done,name=\"var_reg\",numchild=\"0\",value=\"0x[0-9a-f]+\",type=\"unsigned long\",thread-id=\"1\",has_more=\"0\"")
+
+ # Assign value to variable
+ self.runCmd("-var-assign var_reg \"6\"")
+ self.expect("\^done,value=\"0x0000000000000006\"")
+
+ # Assert register 0 updated
+ self.runCmd("-data-list-register-values d 0")
+ self.expect("\^done,register-values=\[{number=\"0\",value=\"6\"")
+
if __name__ == '__main__':
unittest2.main()
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp?rev=235195&r1=235194&r2=235195&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp Fri Apr 17 09:49:54 2015
@@ -177,13 +177,23 @@ CMICmdCmdVarCreate::Execute(void)
lldb::SBThread thread = (nThreadId != UINT64_MAX) ? sbProcess.GetThreadByIndexID(nThreadId) : sbProcess.GetSelectedThread();
m_nThreadId = thread.GetIndexID();
lldb::SBFrame frame = bCurrentFrame ? thread.GetSelectedFrame() : thread.GetFrameAtIndex(nFrame);
+ lldb::SBValue value;
+
+ if (rStrExpression[0] == '$')
+ {
+ const CMIUtilString rStrRegister(rStrExpression.substr(1).c_str());
+ value = frame.FindRegister(rStrRegister.c_str());
+ }
+ else
+ {
+ const bool bArgs = true;
+ const bool bLocals = true;
+ const bool bStatics = true;
+ const bool bInScopeOnly = false;
+ const lldb::SBValueList valueList = frame.GetVariables(bArgs, bLocals, bStatics, bInScopeOnly);
+ value = valueList.GetFirstValueByName(rStrExpression.c_str());
+ }
- const bool bArgs = true;
- const bool bLocals = true;
- const bool bStatics = true;
- const bool bInScopeOnly = false;
- const lldb::SBValueList valueList = frame.GetVariables(bArgs, bLocals, bStatics, bInScopeOnly);
- lldb::SBValue value = valueList.GetFirstValueByName(rStrExpression.c_str());
if (!value.IsValid())
value = frame.EvaluateExpression(rStrExpression.c_str());
More information about the lldb-commits
mailing list