1 //===-- FormatEntity.h ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_FormatEntity_h_
11 #define liblldb_FormatEntity_h_
18 // Other libraries and framework includes
20 #include "lldb/lldb-private.h"
21 #include "lldb/Core/Error.h"
28 namespace lldb_private
46 ScriptVariableSynthetic,
60 ThreadCompletedExpression,
77 FunctionInitialFunction,
82 FunctionAddrOffsetConcrete,
90 LineEntryStartAddress,
106 const char *string; // Insert this exact string into the output
108 FormatType format_type; // uint32_t, uint64_t, cstr, or anything that can be formatted by printf or lldb::Format
110 uint32_t num_children;
111 Definition *children; // An array of "num_children" Definition entries,
115 Entry(Type t = Type::Invalid,
116 const char *s = nullptr,
117 const char *f = nullptr) :
119 printf_format (f ? f : ""),
121 definition (nullptr),
123 fmt (lldb::eFormatDefault),
129 Entry (llvm::StringRef s);
133 AppendChar (char ch);
136 AppendText (const llvm::StringRef &s);
139 AppendText (const char *cstr);
142 AppendEntry (const Entry &&entry)
144 children.push_back(entry);
151 printf_format.clear();
153 definition = nullptr;
154 type = Type::Invalid;
155 fmt = lldb::eFormatDefault;
161 TypeToCString (Type t);
164 Dump (Stream &s, int depth = 0) const;
167 operator == (const Entry &rhs) const
169 if (string != rhs.string)
171 if (printf_format != rhs.printf_format)
173 const size_t n = children.size();
174 const size_t m = rhs.children.size();
175 for (size_t i=0; i < std::min<size_t>(n, m); ++i)
177 if (!(children[i] == rhs.children[i]))
180 if (children != rhs.children)
182 if (definition != rhs.definition)
184 if (type != rhs.type)
188 if (deref != rhs.deref)
194 std::string printf_format;
195 std::vector<Entry> children;
196 Definition *definition;
204 Format (const Entry &entry,
206 const SymbolContext *sc,
207 const ExecutionContext *exe_ctx,
210 bool function_changed,
211 bool initial_function);
214 FormatStringRef (const llvm::StringRef &format,
216 const SymbolContext *sc,
217 const ExecutionContext *exe_ctx,
220 bool function_changed,
221 bool initial_function);
224 FormatCString (const char *format,
226 const SymbolContext *sc,
227 const ExecutionContext *exe_ctx,
230 bool function_changed,
231 bool initial_function);
234 Parse (const llvm::StringRef &format, Entry &entry);
237 ExtractVariableInfo (llvm::StringRef &format_str,
238 llvm::StringRef &variable_name,
239 llvm::StringRef &variable_format);
242 AutoComplete (const char *s,
243 int match_start_point,
244 int max_return_elements,
246 StringList &matches);
248 //----------------------------------------------------------------------
249 // Format the current elements into the stream \a s.
251 // The root element will be stripped off and the format str passed in
252 // will be either an empty string (print a description of this object),
253 // or contain a . separated series like a domain name that identifies
254 // further sub elements to display.
255 //----------------------------------------------------------------------
257 FormatFileSpec (const FileSpec &file, Stream &s, llvm::StringRef elements, llvm::StringRef element_format);
260 ParseInternal (llvm::StringRef &format, Entry &parent_entry, uint32_t depth);
263 } // namespace lldb_private
265 #endif // liblldb_FormatEntity_h_