Currently if the "first child" of the pointer is a char type then the pointer is displayed as a string. This test succeeds incorrectly when the pointer is to a structured type with a char type as its first field. Fix this by switching the test to retrieve the pointee type and checking that it is a char type.
Details
- Reviewers
ChuckR abidh ki.stfu - Commits
- rG6940581e456b: Fix bug in expression display when determining if a pointer should be treated…
rLLDB243619: Fix bug in expression display when determining if a pointer should be treated…
rL243619: Fix bug in expression display when determining if a pointer should be treated…
Diff Detail
Event Timeline
It looks strangely for me. If structure has the first element of type char then GetChildAtIndex(0) will refer to this element and GetType().GetBasicType() will be char. But if we have a pointer to that structure then I suppose GetChildAtIndex(0) will not be equal to the first element of structure. From my point of view, it should relate to this structure entirely, but not to its first element.
See my inline comments.
test/tools/lldb-mi/variable/main.cpp | ||
---|---|---|
70–76 | Use clang-format for formatting please. | |
86 | a memory leak. just allocate it on the stack and then use "&nstr" | |
tools/lldb-mi/MICmnLLDBUtilSBValue.cpp | ||
139–141 | Please wrap it into IsPointeeCharType(): if (m_bHandleCharType && IsPointeeCharType()) | |
364 | Change to "Static": // Type: Static. | |
404 | Add IsPointeeCharType() function after IsFirstChildCharType(): //++ ------------------------------------------------------------------------------------ // Details: Retrieve the flag stating whether pointee 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. // Type: Method. // Args: None. // Return: bool - True = Yes is a char type, false = some other type. // Throws: None. //-- bool CMICmnLLDBUtilSBValue::IsPointeeCharType(void) const { const MIuint nChildren = m_rValue.GetNumChildren(); // Is it a basic type if (nChildren == 0) return false; const lldb::BasicType eType = m_rValue.GetType().GetPointeeType().GetBasicType(); return IsCharBasicType(eType); } | |
tools/lldb-mi/MICmnLLDBUtilSBValue.h | ||
57 | Add bool IsPointeeCharType(void) const; after these lines: CMIUtilString GetTypeName(void) const; CMIUtilString GetTypeNameDisplay(void) const; bool IsCharType(void) const; bool IsFirstChildCharType(void) const; | |
60 | Move to separate section: // Statics: private: static bool IsCharBasicType(lldb::BasicType eType); |
Add a section title and go ahead.
tools/lldb-mi/MICmnLLDBUtilSBValue.h | ||
---|---|---|
61–65 | Forgot a section title: // Statics: private: static bool IsCharBasicType(lldb::BasicType eType); |
Added the section title.
If you are ok with this now then can you please check it in?
Thanks.
Use clang-format for formatting please.