1 //===-- MICmnLLDBUtilSBValue.h ----------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #pragma once
11 
12 // Third Party Headers:
13 #include "lldb/API/SBValue.h"
14 
15 // In-house headers:
16 #include "MICmnMIValueTuple.h"
17 #include "MIDataTypes.h"
18 
19 // Declarations:
20 class CMIUtilString;
21 
22 //++
23 //============================================================================
24 // Details: Utility helper class to lldb::SBValue. Using a lldb::SBValue extract
25 //          value object information to help form verbose debug information.
26 //--
27 class CMICmnLLDBUtilSBValue {
28   // Methods:
29 public:
30   /* ctor */ CMICmnLLDBUtilSBValue(const lldb::SBValue &vrValue,
31                                    const bool vbHandleCharType = false,
32                                    const bool vbHandleArrayType = true);
33   /* dtor */ ~CMICmnLLDBUtilSBValue();
34   //
35   CMIUtilString GetName() const;
36   CMIUtilString GetValue(const bool vbExpandAggregates = false) const;
37   CMIUtilString GetTypeName() const;
38   CMIUtilString GetTypeNameDisplay() const;
39   bool IsCharType() const;
40   bool IsFirstChildCharType() const;
41   bool IsPointeeCharType() const;
42   bool IsIntegerType() const;
43   bool IsPointerType() const;
44   bool IsArrayType() const;
45   bool IsLLDBVariable() const;
46   bool IsNameUnknown() const;
47   bool IsValueUnknown() const;
48   bool IsValid() const;
49   bool HasName() const;
50 
51   // Methods:
52 private:
53   template <typename charT>
54   CMIUtilString
55   ReadCStringFromHostMemory(lldb::SBValue &vrValue,
56                             const MIuint vnMaxLen = UINT32_MAX) const;
57   bool GetSimpleValue(const bool vbHandleArrayType,
58                       CMIUtilString &vrValue) const;
59   bool GetCompositeValue(const bool vbPrintFieldNames,
60                          CMICmnMIValueTuple &vwrMiValueTuple,
61                          const MIuint vnDepth = 1) const;
62   CMIUtilString
63   GetValueSummary(bool valueOnly,
64                   const CMIUtilString &failVal = CMIUtilString()) const;
65 
66   // Statics:
67 private:
68   static bool IsCharBasicType(lldb::BasicType eType);
69 
70   // Attributes:
71 private:
72   lldb::SBValue &m_rValue;
73   bool m_bValidSBValue; // True = SBValue is a valid object, false = not valid.
74   bool m_bHandleCharType;  // True = Yes return text molding to char type, false
75                            // = just return data.
76   bool m_bHandleArrayType; // True = Yes return special stub for array type,
77                            // false = just return data.
78 };
79