Index: test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py =================================================================== --- test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py +++ test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py @@ -132,6 +132,10 @@ self.runCmd("-var-create var2 * complx_array") self.expect("\^done,name=\"var2\",numchild=\"2\",value=\"\[2\]\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"") + # Test that a struct with a char first element is not formatted as a string + self.runCmd("-var-create - * ps") + self.expect("\^done,name=\"var\d+\",numchild=\"2\",value=\"0x[0-9a-f]+\",type=\"not_str \*\",thread-id=\"1\",has_more=\"0\"") + # Test that -gdb-set can set print expand-aggregates flag self.runCmd("-gdb-set print expand-aggregates on") self.expect("\^done") Index: test/tools/lldb-mi/variable/main.cpp =================================================================== --- test/tools/lldb-mi/variable/main.cpp +++ test/tools/lldb-mi/variable/main.cpp @@ -67,11 +67,20 @@ // BP_gdb_set_show_print_char_array_as_string_test } +struct not_str +{ + char c; + int f; + not_str(char _c, int _f) : c(_c), f(_f) + {} +}; + void gdb_set_show_print_expand_aggregates(void) { complex_type complx = { 3, { 3L }, &complx }; complex_type complx_array[2] = { { 4, { 4L }, &complx_array[1] }, { 5, { 5 }, &complx_array[0] } }; + not_str* ps = new not_str('a', 0); // BP_gdb_set_show_print_expand_aggregates } Index: tools/lldb-mi/MICmnLLDBUtilSBValue.h =================================================================== --- tools/lldb-mi/MICmnLLDBUtilSBValue.h +++ tools/lldb-mi/MICmnLLDBUtilSBValue.h @@ -57,7 +57,8 @@ CMIUtilString GetSimpleValueCStringPointer(void) const; CMIUtilString GetSimpleValueCStringArray(void) const; bool GetCompositeValue(const bool vbPrintFieldNames, CMICmnMIValueTuple &vwrMiValueTuple, const MIuint vnDepth = 1) const; - + static bool IsCharBasicType(lldb::BasicType eType); + // Attributes: private: lldb::SBValue &m_rValue; Index: tools/lldb-mi/MICmnLLDBUtilSBValue.cpp =================================================================== --- tools/lldb-mi/MICmnLLDBUtilSBValue.cpp +++ tools/lldb-mi/MICmnLLDBUtilSBValue.cpp @@ -136,7 +136,9 @@ } else if (IsPointerType()) { - if (m_bHandleCharType && IsFirstChildCharType()) + const lldb::BasicType eType = m_rValue.GetType().GetPointeeType().GetBasicType(); + + if (m_bHandleCharType && IsCharBasicType(eType)) { vwrValue = GetSimpleValueCStringPointer(); return MIstatus::success; @@ -358,17 +360,15 @@ } //++ ------------------------------------------------------------------------------------ -// Details: Retrieve the flag stating whether this value object is a char type or some -// other type. Char type can be signed or unsigned. +// Details: Check that basic type is a char type. Char type can be signed or unsigned. // Type: Method. -// Args: None. +// Args: eType - type to check // Return: bool - True = Yes is a char type, false = some other type. // Throws: None. //-- bool -CMICmnLLDBUtilSBValue::IsCharType(void) const +CMICmnLLDBUtilSBValue::IsCharBasicType(lldb::BasicType eType) { - const lldb::BasicType eType = m_rValue.GetType().GetBasicType(); switch (eType) { case lldb::eBasicTypeChar: @@ -383,6 +383,22 @@ } //++ ------------------------------------------------------------------------------------ +// Details: Retrieve the flag stating whether this value object is a char type or some +// other type. Char type can be signed or unsigned. +// Type: Method. +// Args: None. +// Return: bool - True = Yes is a char type, false = some other type. +// Throws: None. +//-- +bool +CMICmnLLDBUtilSBValue::IsCharType(void) const +{ + const lldb::BasicType eType = m_rValue.GetType().GetBasicType(); + return IsCharBasicType(eType); +} + + +//++ ------------------------------------------------------------------------------------ // Details: Retrieve the flag stating whether first child value object of *this object is // a char type or some other type. Returns false if there are not children. Char // type can be signed or unsigned.