LLDB mainline
DILEval.cpp
Go to the documentation of this file.
1//===-- DILEval.cpp -------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "lldb/Core/Module.h"
19#include "llvm/Support/FormatAdapters.h"
20#include <memory>
21
22namespace lldb_private::dil {
23
25 VariableList &variable_list) {
26 lldb::VariableSP exact_match;
27 std::vector<lldb::VariableSP> possible_matches;
28
29 for (lldb::VariableSP var_sp : variable_list) {
30 llvm::StringRef str_ref_name = var_sp->GetName().GetStringRef();
31
32 str_ref_name.consume_front("::");
33 // Check for the exact same match
34 if (str_ref_name == name.GetStringRef())
35 return var_sp;
36
37 // Check for possible matches by base name
38 if (var_sp->NameMatches(name))
39 possible_matches.push_back(var_sp);
40 }
41
42 // If there's a non-exact match, take it.
43 if (possible_matches.size() > 0)
44 return possible_matches[0];
45
46 return nullptr;
47}
48
50 llvm::StringRef name_ref, std::shared_ptr<StackFrame> stack_frame,
51 lldb::TargetSP target_sp, lldb::DynamicValueType use_dynamic) {
52 // Get a global variables list without the locals from the current frame
53 SymbolContext symbol_context =
54 stack_frame->GetSymbolContext(lldb::eSymbolContextCompUnit);
55 lldb::VariableListSP variable_list;
56 if (symbol_context.comp_unit)
57 variable_list = symbol_context.comp_unit->GetVariableList(true);
58
59 name_ref.consume_front("::");
60 lldb::ValueObjectSP value_sp;
61 if (variable_list) {
62 lldb::VariableSP var_sp =
63 DILFindVariable(ConstString(name_ref), *variable_list);
64 if (var_sp)
65 value_sp =
66 stack_frame->GetValueObjectForFrameVariable(var_sp, use_dynamic);
67 }
68
69 if (value_sp)
70 return value_sp;
71
72 // Check for match in modules global variables.
73 VariableList modules_var_list;
74 target_sp->GetImages().FindGlobalVariables(
75 ConstString(name_ref), std::numeric_limits<uint32_t>::max(),
76 modules_var_list);
77
78 if (!modules_var_list.Empty()) {
79 lldb::VariableSP var_sp =
80 DILFindVariable(ConstString(name_ref), modules_var_list);
81 if (var_sp)
82 value_sp = ValueObjectVariable::Create(stack_frame.get(), var_sp);
83
84 if (value_sp)
85 return value_sp;
86 }
87 return nullptr;
88}
89
90lldb::ValueObjectSP LookupIdentifier(llvm::StringRef name_ref,
91 std::shared_ptr<StackFrame> stack_frame,
92 lldb::DynamicValueType use_dynamic) {
93 // Support $rax as a special syntax for accessing registers.
94 // Will return an invalid value in case the requested register doesn't exist.
95 if (name_ref.consume_front("$")) {
96 lldb::RegisterContextSP reg_ctx(stack_frame->GetRegisterContext());
97 if (!reg_ctx)
98 return nullptr;
99
100 if (const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name_ref))
101 return ValueObjectRegister::Create(stack_frame.get(), reg_ctx, reg_info);
102
103 return nullptr;
104 }
105
106 if (!name_ref.contains("::")) {
107 // Lookup in the current frame.
108 // Try looking for a local variable in current scope.
109 lldb::VariableListSP variable_list(
110 stack_frame->GetInScopeVariableList(false));
111
112 lldb::ValueObjectSP value_sp;
113 if (variable_list) {
114 lldb::VariableSP var_sp =
115 variable_list->FindVariable(ConstString(name_ref));
116 if (var_sp)
117 value_sp =
118 stack_frame->GetValueObjectForFrameVariable(var_sp, use_dynamic);
119 }
120
121 if (value_sp)
122 return value_sp;
123
124 // Try looking for an instance variable (class member).
125 SymbolContext sc = stack_frame->GetSymbolContext(
126 lldb::eSymbolContextFunction | lldb::eSymbolContextBlock);
127 llvm::StringRef ivar_name = sc.GetInstanceVariableName();
128 value_sp = stack_frame->FindVariable(ConstString(ivar_name));
129 if (value_sp)
130 value_sp = value_sp->GetChildMemberWithName(name_ref);
131
132 if (value_sp)
133 return value_sp;
134 }
135 return nullptr;
136}
137
138Interpreter::Interpreter(lldb::TargetSP target, llvm::StringRef expr,
139 std::shared_ptr<StackFrame> frame_sp,
140 lldb::DynamicValueType use_dynamic, bool use_synthetic,
141 bool fragile_ivar, bool check_ptr_vs_member)
142 : m_target(std::move(target)), m_expr(expr), m_exe_ctx_scope(frame_sp),
143 m_use_dynamic(use_dynamic), m_use_synthetic(use_synthetic),
144 m_fragile_ivar(fragile_ivar), m_check_ptr_vs_member(check_ptr_vs_member) {
145}
146
147llvm::Expected<lldb::ValueObjectSP> Interpreter::Evaluate(const ASTNode *node) {
148 // Evaluate an AST.
149 auto value_or_error = node->Accept(this);
150 // Return the computed value-or-error. The caller is responsible for
151 // checking if an error occured during the evaluation.
152 return value_or_error;
153}
154
155llvm::Expected<lldb::ValueObjectSP>
158
159 lldb::ValueObjectSP identifier =
160 LookupIdentifier(node->GetName(), m_exe_ctx_scope, use_dynamic);
161
162 if (!identifier)
163 identifier = LookupGlobalIdentifier(node->GetName(), m_exe_ctx_scope,
164 m_target, use_dynamic);
165 if (!identifier) {
166 std::string errMsg =
167 llvm::formatv("use of undeclared identifier '{0}'", node->GetName());
168 return llvm::make_error<DILDiagnosticError>(
169 m_expr, errMsg, node->GetLocation(), node->GetName().size());
170 }
171
172 return identifier;
173}
174
175llvm::Expected<lldb::ValueObjectSP>
178 auto rhs_or_err = Evaluate(node->GetOperand());
179 if (!rhs_or_err)
180 return rhs_or_err;
181
182 lldb::ValueObjectSP rhs = *rhs_or_err;
183
184 switch (node->GetKind()) {
185 case UnaryOpKind::Deref: {
186 lldb::ValueObjectSP dynamic_rhs = rhs->GetDynamicValue(m_use_dynamic);
187 if (dynamic_rhs)
188 rhs = dynamic_rhs;
189
190 lldb::ValueObjectSP child_sp = rhs->Dereference(error);
191 if (!child_sp && m_use_synthetic) {
192 if (lldb::ValueObjectSP synth_obj_sp = rhs->GetSyntheticValue()) {
193 error.Clear();
194 child_sp = synth_obj_sp->Dereference(error);
195 }
196 }
197 if (error.Fail())
198 return llvm::make_error<DILDiagnosticError>(m_expr, error.AsCString(),
199 node->GetLocation());
200
201 return child_sp;
202 }
203 case UnaryOpKind::AddrOf: {
205 lldb::ValueObjectSP value = rhs->AddressOf(error);
206 if (error.Fail())
207 return llvm::make_error<DILDiagnosticError>(m_expr, error.AsCString(),
208 node->GetLocation());
209
210 return value;
211 }
212 }
213
214 // Unsupported/invalid operation.
215 return llvm::make_error<DILDiagnosticError>(
216 m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
217}
218
219llvm::Expected<lldb::ValueObjectSP>
221 auto base_or_err = Evaluate(node->GetBase());
222 if (!base_or_err)
223 return base_or_err;
224 bool expr_is_ptr = node->GetIsArrow();
225 lldb::ValueObjectSP base = *base_or_err;
226
227 // Perform some basic type & correctness checking.
228 if (node->GetIsArrow()) {
229 if (!m_fragile_ivar) {
230 // Make sure we aren't trying to deref an objective
231 // C ivar if this is not allowed
232 const uint32_t pointer_type_flags =
233 base->GetCompilerType().GetTypeInfo(nullptr);
234 if ((pointer_type_flags & lldb::eTypeIsObjC) &&
235 (pointer_type_flags & lldb::eTypeIsPointer)) {
236 // This was an objective C object pointer and it was requested we
237 // skip any fragile ivars so return nothing here
238 return lldb::ValueObjectSP();
239 }
240 }
241
242 // If we have a non-pointer type with a synthetic value then lets check
243 // if we have a synthetic dereference specified.
244 if (!base->IsPointerType() && base->HasSyntheticValue()) {
245 Status deref_error;
246 if (lldb::ValueObjectSP synth_deref_sp =
247 base->GetSyntheticValue()->Dereference(deref_error);
248 synth_deref_sp && deref_error.Success()) {
249 base = std::move(synth_deref_sp);
250 }
251 if (!base || deref_error.Fail()) {
252 std::string errMsg = llvm::formatv(
253 "Failed to dereference synthetic value: {0}", deref_error);
254 return llvm::make_error<DILDiagnosticError>(
255 m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
256 }
257
258 // Some synthetic plug-ins fail to set the error in Dereference
259 if (!base) {
260 std::string errMsg = "Failed to dereference synthetic value";
261 return llvm::make_error<DILDiagnosticError>(
262 m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
263 }
264 expr_is_ptr = false;
265 }
266 }
267
269 bool base_is_ptr = base->IsPointerType();
270
271 if (expr_is_ptr != base_is_ptr) {
272 if (base_is_ptr) {
273 std::string errMsg =
274 llvm::formatv("member reference type {0} is a pointer; "
275 "did you mean to use '->'?",
276 base->GetCompilerType().TypeDescription());
277 return llvm::make_error<DILDiagnosticError>(
278 m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
279 } else {
280 std::string errMsg =
281 llvm::formatv("member reference type {0} is not a pointer; "
282 "did you mean to use '.'?",
283 base->GetCompilerType().TypeDescription());
284 return llvm::make_error<DILDiagnosticError>(
285 m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
286 }
287 }
288 }
289
290 lldb::ValueObjectSP field_obj =
291 base->GetChildMemberWithName(node->GetFieldName());
292 if (!field_obj) {
293 if (m_use_synthetic) {
294 field_obj = base->GetSyntheticValue();
295 if (field_obj)
296 field_obj = field_obj->GetChildMemberWithName(node->GetFieldName());
297 }
298
299 if (!m_use_synthetic || !field_obj) {
300 std::string errMsg = llvm::formatv(
301 "\"{0}\" is not a member of \"({1}) {2}\"", node->GetFieldName(),
302 base->GetTypeName().AsCString("<invalid type>"), base->GetName());
303 return llvm::make_error<DILDiagnosticError>(
304 m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
305 }
306 }
307
308 if (field_obj) {
310 lldb::ValueObjectSP dynamic_val_sp =
311 field_obj->GetDynamicValue(m_use_dynamic);
312 if (dynamic_val_sp)
313 field_obj = dynamic_val_sp;
314 }
315 return field_obj;
316 }
317
318 CompilerType base_type = base->GetCompilerType();
319 if (node->GetIsArrow() && base->IsPointerType())
320 base_type = base_type.GetPointeeType();
321 std::string errMsg = llvm::formatv(
322 "\"{0}\" is not a member of \"({1}) {2}\"", node->GetFieldName(),
323 base->GetTypeName().AsCString("<invalid type>"), base->GetName());
324 return llvm::make_error<DILDiagnosticError>(
325 m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
326}
327
328llvm::Expected<lldb::ValueObjectSP>
330 auto lhs_or_err = Evaluate(node->GetBase());
331 if (!lhs_or_err)
332 return lhs_or_err;
333 lldb::ValueObjectSP base = *lhs_or_err;
334
335 StreamString var_expr_path_strm;
336 uint64_t child_idx = node->GetIndex();
337 lldb::ValueObjectSP child_valobj_sp;
338
339 bool is_incomplete_array = false;
340 CompilerType base_type = base->GetCompilerType().GetNonReferenceType();
341 base->GetExpressionPath(var_expr_path_strm);
342
343 if (base_type.IsPointerType()) {
344 bool is_objc_pointer = true;
345
346 if (base->GetCompilerType().GetMinimumLanguage() != lldb::eLanguageTypeObjC)
347 is_objc_pointer = false;
348 else if (!base->GetCompilerType().IsPointerType())
349 is_objc_pointer = false;
350
351 if (!m_use_synthetic && is_objc_pointer) {
352 std::string err_msg = llvm::formatv(
353 "\"({0}) {1}\" is an Objective-C pointer, and cannot be subscripted",
354 base->GetTypeName().AsCString("<invalid type>"),
355 var_expr_path_strm.GetData());
356 return llvm::make_error<DILDiagnosticError>(m_expr, std::move(err_msg),
357 node->GetLocation());
358 }
359 if (is_objc_pointer) {
360 lldb::ValueObjectSP synthetic = base->GetSyntheticValue();
361 if (!synthetic || synthetic == base) {
362 std::string err_msg =
363 llvm::formatv("\"({0}) {1}\" is not an array type",
364 base->GetTypeName().AsCString("<invalid type>"),
365 var_expr_path_strm.GetData());
366 return llvm::make_error<DILDiagnosticError>(m_expr, std::move(err_msg),
367 node->GetLocation());
368 }
369 if (static_cast<uint32_t>(child_idx) >=
370 synthetic->GetNumChildrenIgnoringErrors()) {
371 std::string err_msg = llvm::formatv(
372 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
373 base->GetTypeName().AsCString("<invalid type>"),
374 var_expr_path_strm.GetData());
375 return llvm::make_error<DILDiagnosticError>(m_expr, std::move(err_msg),
376 node->GetLocation());
377 }
378 child_valobj_sp = synthetic->GetChildAtIndex(child_idx);
379 if (!child_valobj_sp) {
380 std::string err_msg = llvm::formatv(
381 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
382 base->GetTypeName().AsCString("<invalid type>"),
383 var_expr_path_strm.GetData());
384 return llvm::make_error<DILDiagnosticError>(m_expr, std::move(err_msg),
385 node->GetLocation());
386 }
388 if (auto dynamic_sp = child_valobj_sp->GetDynamicValue(m_use_dynamic))
389 child_valobj_sp = std::move(dynamic_sp);
390 }
391 return child_valobj_sp;
392 }
393
394 child_valobj_sp = base->GetSyntheticArrayMember(child_idx, true);
395 if (!child_valobj_sp) {
396 std::string err_msg = llvm::formatv(
397 "failed to use pointer as array for index {0} for "
398 "\"({1}) {2}\"",
399 child_idx, base->GetTypeName().AsCString("<invalid type>"),
400 var_expr_path_strm.GetData());
401 if (base_type.IsPointerToVoid())
402 err_msg = "subscript of pointer to incomplete type 'void'";
403 return llvm::make_error<DILDiagnosticError>(m_expr, std::move(err_msg),
404 node->GetLocation());
405 }
406 } else if (base_type.IsArrayType(nullptr, nullptr, &is_incomplete_array)) {
407 child_valobj_sp = base->GetChildAtIndex(child_idx);
408 if (!child_valobj_sp && (is_incomplete_array || m_use_synthetic))
409 child_valobj_sp = base->GetSyntheticArrayMember(child_idx, true);
410 if (!child_valobj_sp) {
411 std::string err_msg = llvm::formatv(
412 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
413 base->GetTypeName().AsCString("<invalid type>"),
414 var_expr_path_strm.GetData());
415 return llvm::make_error<DILDiagnosticError>(m_expr, std::move(err_msg),
416 node->GetLocation());
417 }
418 } else if (base_type.IsScalarType()) {
419 child_valobj_sp =
420 base->GetSyntheticBitFieldChild(child_idx, child_idx, true);
421 if (!child_valobj_sp) {
422 std::string err_msg = llvm::formatv(
423 "bitfield range {0}-{1} is not valid for \"({2}) {3}\"", child_idx,
424 child_idx, base->GetTypeName().AsCString("<invalid type>"),
425 var_expr_path_strm.GetData());
426 return llvm::make_error<DILDiagnosticError>(m_expr, std::move(err_msg),
427 node->GetLocation(), 1);
428 }
429 } else {
430 lldb::ValueObjectSP synthetic = base->GetSyntheticValue();
431 if (!m_use_synthetic || !synthetic || synthetic == base) {
432 std::string err_msg =
433 llvm::formatv("\"{0}\" is not an array type",
434 base->GetTypeName().AsCString("<invalid type>"));
435 return llvm::make_error<DILDiagnosticError>(m_expr, std::move(err_msg),
436 node->GetLocation(), 1);
437 }
438 if (static_cast<uint32_t>(child_idx) >=
439 synthetic->GetNumChildrenIgnoringErrors(child_idx + 1)) {
440 std::string err_msg = llvm::formatv(
441 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
442 base->GetTypeName().AsCString("<invalid type>"),
443 var_expr_path_strm.GetData());
444 return llvm::make_error<DILDiagnosticError>(m_expr, std::move(err_msg),
445 node->GetLocation(), 1);
446 }
447 child_valobj_sp = synthetic->GetChildAtIndex(child_idx);
448 if (!child_valobj_sp) {
449 std::string err_msg = llvm::formatv(
450 "array index {0} is not valid for \"({1}) {2}\"", child_idx,
451 base->GetTypeName().AsCString("<invalid type>"),
452 var_expr_path_strm.GetData());
453 return llvm::make_error<DILDiagnosticError>(m_expr, std::move(err_msg),
454 node->GetLocation(), 1);
455 }
456 }
457
458 if (child_valobj_sp) {
460 if (auto dynamic_sp = child_valobj_sp->GetDynamicValue(m_use_dynamic))
461 child_valobj_sp = std::move(dynamic_sp);
462 }
463 return child_valobj_sp;
464 }
465
466 int64_t signed_child_idx = node->GetIndex();
467 return base->GetSyntheticArrayMember(signed_child_idx, true);
468}
469
470llvm::Expected<lldb::ValueObjectSP>
472 auto lhs_or_err = Evaluate(node->GetBase());
473 if (!lhs_or_err)
474 return lhs_or_err;
475 lldb::ValueObjectSP base = *lhs_or_err;
476 int64_t first_index = node->GetFirstIndex();
477 int64_t last_index = node->GetLastIndex();
478
479 // if the format given is [high-low], swap range
480 if (first_index > last_index)
481 std::swap(first_index, last_index);
482
484 if (base->GetCompilerType().IsReferenceType()) {
485 base = base->Dereference(error);
486 if (error.Fail())
487 return error.ToError();
488 }
489 lldb::ValueObjectSP child_valobj_sp =
490 base->GetSyntheticBitFieldChild(first_index, last_index, true);
491 if (!child_valobj_sp) {
492 std::string message = llvm::formatv(
493 "bitfield range {0}-{1} is not valid for \"({2}) {3}\"", first_index,
494 last_index, base->GetTypeName().AsCString("<invalid type>"),
495 base->GetName().AsCString());
496 return llvm::make_error<DILDiagnosticError>(m_expr, message,
497 node->GetLocation());
498 }
499 return child_valobj_sp;
500}
501
502static llvm::Expected<lldb::TypeSystemSP>
503GetTypeSystemFromCU(std::shared_ptr<StackFrame> ctx) {
504 SymbolContext symbol_context =
505 ctx->GetSymbolContext(lldb::eSymbolContextCompUnit);
506 lldb::LanguageType language = symbol_context.comp_unit->GetLanguage();
507
508 symbol_context = ctx->GetSymbolContext(lldb::eSymbolContextModule);
509 return symbol_context.module_sp->GetTypeSystemForLanguage(language);
510}
511
513 lldb::BasicType basic_type) {
514 if (type_system)
515 return type_system.get()->GetBasicTypeFromAST(basic_type);
516
517 return CompilerType();
518}
519
520llvm::Expected<CompilerType>
522 std::shared_ptr<ExecutionContextScope> ctx,
523 const IntegerLiteralNode *literal) {
524 // Binary, Octal, Hexadecimal and literals with a U suffix are allowed to be
525 // an unsigned integer.
526 bool unsigned_is_allowed = literal->IsUnsigned() || literal->GetRadix() != 10;
527 llvm::APInt apint = literal->GetValue();
528
529 llvm::SmallVector<std::pair<lldb::BasicType, lldb::BasicType>, 3> candidates;
530 if (literal->GetTypeSuffix() <= IntegerTypeSuffix::None)
531 candidates.emplace_back(lldb::eBasicTypeInt,
532 unsigned_is_allowed ? lldb::eBasicTypeUnsignedInt
534 if (literal->GetTypeSuffix() <= IntegerTypeSuffix::Long)
535 candidates.emplace_back(lldb::eBasicTypeLong,
536 unsigned_is_allowed ? lldb::eBasicTypeUnsignedLong
538 candidates.emplace_back(lldb::eBasicTypeLongLong,
540 for (auto [signed_, unsigned_] : candidates) {
541 CompilerType signed_type = type_system->GetBasicTypeFromAST(signed_);
542 if (!signed_type)
543 continue;
544 llvm::Expected<uint64_t> size = signed_type.GetBitSize(ctx.get());
545 if (!size)
546 return size.takeError();
547 if (!literal->IsUnsigned() && apint.isIntN(*size - 1))
548 return signed_type;
549 if (unsigned_ != lldb::eBasicTypeInvalid && apint.isIntN(*size))
550 return type_system->GetBasicTypeFromAST(unsigned_);
551 }
552
553 return llvm::make_error<DILDiagnosticError>(
554 m_expr,
555 "integer literal is too large to be represented in any integer type",
556 literal->GetLocation());
557}
558
559llvm::Expected<lldb::ValueObjectSP>
561 llvm::Expected<lldb::TypeSystemSP> type_system =
563 if (!type_system)
564 return type_system.takeError();
565
566 llvm::Expected<CompilerType> type =
567 PickIntegerType(*type_system, m_exe_ctx_scope, node);
568 if (!type)
569 return type.takeError();
570
571 Scalar scalar = node->GetValue();
572 // APInt from StringRef::getAsInteger comes with just enough bitwidth to
573 // hold the value. This adjusts APInt bitwidth to match the compiler type.
574 llvm::Expected<uint64_t> type_bitsize =
575 type->GetBitSize(m_exe_ctx_scope.get());
576 if (!type_bitsize)
577 return type_bitsize.takeError();
578 scalar.TruncOrExtendTo(*type_bitsize, false);
580 "result");
581}
582
583llvm::Expected<lldb::ValueObjectSP>
585 llvm::Expected<lldb::TypeSystemSP> type_system =
587 if (!type_system)
588 return type_system.takeError();
589
590 bool isFloat =
591 &node->GetValue().getSemantics() == &llvm::APFloat::IEEEsingle();
592 lldb::BasicType basic_type =
594 CompilerType type = GetBasicType(*type_system, basic_type);
595
596 if (!type)
597 return llvm::make_error<DILDiagnosticError>(
598 m_expr, "unable to create a const literal", node->GetLocation());
599
600 Scalar scalar = node->GetValue();
602 "result");
603}
604
605llvm::Expected<lldb::ValueObjectSP>
607 bool value = node->GetValue();
608 return ValueObject::CreateValueObjectFromBool(m_target, value, "result");
609}
610
611} // namespace lldb_private::dil
static llvm::raw_ostream & error(Stream &strm)
lldb::VariableListSP GetVariableList(bool can_create)
Get the variable list for a compile unit.
lldb::LanguageType GetLanguage()
Generic representation of a type in a programming language.
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const
Create related types using the current type's AST.
bool IsArrayType(CompilerType *element_type=nullptr, uint64_t *size=nullptr, bool *is_incomplete=nullptr) const
CompilerType GetNonReferenceType() const
If this type is a reference to a type (L value or R value reference), return a new type with the refe...
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
bool IsPointerType(CompilerType *pointee_type=nullptr) const
A uniqued constant string class.
Definition ConstString.h:40
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
void TruncOrExtendTo(uint16_t bits, bool sign)
Convert to an integer with bits and the given signedness.
Definition Scalar.cpp:204
An error handling class.
Definition Status.h:118
bool Fail() const
Test for error condition.
Definition Status.cpp:294
bool Success() const
Test for success condition.
Definition Status.cpp:304
const char * GetData() const
Defines a symbol context baton that can be handed other debug core functions.
llvm::StringRef GetInstanceVariableName()
Determines the name of the instance variable for the this decl context.
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, const RegisterInfo *reg_info)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target, bool value, llvm::StringRef name)
Create a value object containing the given boolean value.
static lldb::ValueObjectSP CreateValueObjectFromScalar(lldb::TargetSP target, Scalar &s, CompilerType type, llvm::StringRef name)
Create a value object containing the given Scalar value.
The rest of the classes in this file, except for the Visitor class at the very end,...
Definition DILAST.h:52
uint32_t GetLocation() const
Definition DILAST.h:60
virtual llvm::Expected< lldb::ValueObjectSP > Accept(Visitor *v) const =0
const llvm::APFloat & GetValue() const
Definition DILAST.h:220
std::string GetName() const
Definition DILAST.h:87
IntegerTypeSuffix GetTypeSuffix() const
Definition DILAST.h:199
const llvm::APInt & GetValue() const
Definition DILAST.h:196
std::shared_ptr< StackFrame > m_exe_ctx_scope
Definition DILEval.h:73
llvm::Expected< lldb::ValueObjectSP > Visit(const IdentifierNode *node) override
Definition DILEval.cpp:156
llvm::Expected< lldb::ValueObjectSP > Evaluate(const ASTNode *node)
Definition DILEval.cpp:147
Interpreter(lldb::TargetSP target, llvm::StringRef expr, std::shared_ptr< StackFrame > frame_sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, bool fragile_ivar, bool check_ptr_vs_member)
Definition DILEval.cpp:138
lldb::DynamicValueType m_use_dynamic
Definition DILEval.h:74
llvm::Expected< CompilerType > PickIntegerType(lldb::TypeSystemSP type_system, std::shared_ptr< ExecutionContextScope > ctx, const IntegerLiteralNode *literal)
Definition DILEval.cpp:521
llvm::StringRef GetFieldName() const
Definition DILAST.h:108
ASTNode * GetBase() const
Definition DILAST.h:106
ASTNode * GetOperand() const
Definition DILAST.h:129
UnaryOpKind GetKind() const
Definition DILAST.h:128
static llvm::Expected< lldb::TypeSystemSP > GetTypeSystemFromCU(std::shared_ptr< StackFrame > ctx)
Definition DILEval.cpp:503
static CompilerType GetBasicType(lldb::TypeSystemSP type_system, lldb::BasicType basic_type)
Definition DILEval.cpp:512
static lldb::VariableSP DILFindVariable(ConstString name, VariableList &variable_list)
Definition DILEval.cpp:24
lldb::ValueObjectSP LookupGlobalIdentifier(llvm::StringRef name_ref, std::shared_ptr< StackFrame > frame_sp, lldb::TargetSP target_sp, lldb::DynamicValueType use_dynamic)
Given the name of an identifier, check to see if it matches the name of a global variable.
Definition DILEval.cpp:49
lldb::ValueObjectSP LookupIdentifier(llvm::StringRef name_ref, std::shared_ptr< StackFrame > frame_sp, lldb::DynamicValueType use_dynamic)
Given the name of an identifier (variable name, member name, type name, etc.), find the ValueObject f...
Definition DILEval.cpp:90
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eBasicTypeUnsignedLong
@ eBasicTypeUnsignedLongLong
@ eBasicTypeUnsignedInt
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
LanguageType
Programming language type.
@ eLanguageTypeObjC
Objective-C.
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::Variable > VariableSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
Every register is described in detail including its name, alternate name (optional),...