Re: [Lldb-commits] [PATCH] D12634: Fix -data-evaluate-expression for array.

2015-09-07 Thread Ilia K via lldb-commits
ki.stfu added a comment.

lgtm


http://reviews.llvm.org/D12634



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12634: Fix -data-evaluate-expression for array.

2015-09-07 Thread Hafiz Abid Qadeer via lldb-commits
abidh updated this revision to Diff 34136.
abidh added a comment.

Handle review comments.
Moved the test to data directory and put it in a separate function.


http://reviews.llvm.org/D12634

Files:
  test/tools/lldb-mi/data/TestMiData.py
  test/tools/lldb-mi/data/main.cpp
  tools/lldb-mi/MICmdCmdData.cpp
  tools/lldb-mi/MICmdCmdData.h

Index: tools/lldb-mi/MICmdCmdData.h
===
--- tools/lldb-mi/MICmdCmdData.h
+++ tools/lldb-mi/MICmdCmdData.h
@@ -73,7 +73,6 @@
 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.
Index: tools/lldb-mi/MICmdCmdData.cpp
===
--- tools/lldb-mi/MICmdCmdData.cpp
+++ tools/lldb-mi/MICmdCmdData.cpp
@@ -54,7 +54,6 @@
 : m_bExpressionValid(true)
 , m_bEvaluatedExpression(true)
 , m_strValue("??")
-, m_bCompositeVarType(false)
 , m_bFoundInvalidChar(false)
 , m_cExpressionInvalidChar(0x00)
 , m_constStrArgThread("thread")
@@ -145,41 +144,7 @@
 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;
 }
 
@@ -199,15 +164,6 @@
 {
 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(
Index: test/tools/lldb-mi/data/main.cpp
===
--- test/tools/lldb-mi/data/main.cpp
+++ test/tools/lldb-mi/data/main.cpp
@@ -31,6 +31,19 @@
 }
 
 void
+local_2d_array_test()
+{
+int array2d[2][3];
+array2d[0][0] = 1;
+array2d[0][1] = 2;
+array2d[0][2] = 3;
+array2d[1][0] = 4;
+array2d[1][1] = 5;
+array2d[1][2] = 6;
+return; // BP_local_2d_array_test
+}
+
+void
 hello_world()
 {
 printf("Hello, World!\n"); // BP_hello_world
@@ -41,5 +54,6 @@
 { // FUNC_main
 local_array_test();
 hello_world();
+local_2d_array_test();
 return 0;
 }
Index: test/tools/lldb-mi/data/TestMiData.py
===
--- test/tools/lldb-mi/data/TestMiData.py
+++ test/tools/lldb-mi/data/TestMiData.py
@@ -312,5 +312,28 @@
 self.runCmd("-data-info-line main.cpp:0")
 self.expect("\^error,msg=\"error: zero is an invalid line number")
 
+@lldbmi_test
+@skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
+@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+def test_lldbmi_data_evaluate_expression(self):
+"""Te

Re: [Lldb-commits] [PATCH] D12634: Fix -data-evaluate-expression for array.

2015-09-04 Thread Ilia K via lldb-commits
ki.stfu requested changes to this revision.
ki.stfu added a comment.
This revision now requires changes to proceed.

Source code looks good but please move the test to TestMiData.py.



Comment at: test/tools/lldb-mi/variable/TestMiVar.py:39-42
@@ -38,2 +38,6 @@
 self.expect("\^error,msg=\"Could not evaluate expression\"")
+
+# Check 2d array 
+self.runCmd("-data-evaluate-expression g_blk")
+self.expect("\^done,value=\"\{\[0\] = \{\[0\] = 1, \[1\] = 2, \[2\] = 
3\}, \[1\] = \{\[0\] = 4, \[1\] = 5, \[2\] = 6\}\}\"")
 

Please move it to a separate @lldmi_test test in data/TestMiData.py


Comment at: test/tools/lldb-mi/variable/main.cpp:105-110
@@ -103,2 +104,8 @@
 int a = 10, b = 20;
+g_blk[0][0] = 1;
+g_blk[0][1] = 2;
+g_blk[0][2] = 3;
+g_blk[1][0] = 4;
+g_blk[1][1] = 5;
+g_blk[1][2] = 6;
 s_MyVar = a + b;

Move it to data/main.cpp and create a separate function for that 
(data_evaluate_expression_test, for example)


http://reviews.llvm.org/D12634



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D12634: Fix -data-evaluate-expression for array.

2015-09-04 Thread Hafiz Abid Qadeer via lldb-commits
abidh created this revision.
abidh added a reviewer: ki.stfu.
abidh added a subscriber: lldb-commits.

For an array declared like "blk[2][3]", this command was showing:
-data-evaluate-expression blk
^done,value="{[0] = [3], [1] = [3]}"

After this fix, it shows:
-data-evaluate-expression blk
^done,value="{[0] = {[0] = 1, [1] = 2, [2] = 3}, [1] = {[0] = 4, [1] = 5, [2] = 
6}}"

The code to do the right thing was already available and used by other commands.
So I have just used that and removed the half-baked previous implementation.

http://reviews.llvm.org/D12634

Files:
  test/tools/lldb-mi/variable/TestMiVar.py
  test/tools/lldb-mi/variable/main.cpp
  tools/lldb-mi/MICmdCmdData.cpp
  tools/lldb-mi/MICmdCmdData.h

Index: tools/lldb-mi/MICmdCmdData.h
===
--- tools/lldb-mi/MICmdCmdData.h
+++ tools/lldb-mi/MICmdCmdData.h
@@ -73,7 +73,6 @@
 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.
Index: tools/lldb-mi/MICmdCmdData.cpp
===
--- tools/lldb-mi/MICmdCmdData.cpp
+++ tools/lldb-mi/MICmdCmdData.cpp
@@ -54,7 +54,6 @@
 : m_bExpressionValid(true)
 , m_bEvaluatedExpression(true)
 , m_strValue("??")
-, m_bCompositeVarType(false)
 , m_bFoundInvalidChar(false)
 , m_cExpressionInvalidChar(0x00)
 , m_constStrArgThread("thread")
@@ -145,41 +144,7 @@
 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;
 }
 
@@ -199,15 +164,6 @@
 {
 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(
Index: test/tools/lldb-mi/variable/main.cpp
===
--- test/tools/lldb-mi/variable/main.cpp
+++ test/tools/lldb-mi/variable/main.cpp
@@ -96,11 +96,18 @@
 
 int g_MyVar = 3;
 static int s_MyVar = 4;
+int g_blk[2][3];
 
 int
 main(int argc, char const *argv[])
 {
 int a = 10, b = 20;
+g_blk[0][0] = 1;
+g_blk[0][1] = 2;
+g_blk[0][2] = 3;
+g_blk[1][0] = 4;
+g_blk[1][1] = 5;
+g_blk[1][2] = 6;
 s_MyVar = a + b;
 var_update_test();
 var_list_children_test();
Index: test/tools/lldb-mi/variable/TestMiVar.py
===
--- test/tools/lldb-mi/variable/TestMiVar.py
+++ test/tools/lldb-mi/variable/TestMiVar.py
@@ -36,6 +36,10 @@
 self.expect("\^error,msg=\"error: error: use of undeclared identif