LLDB mainline
SBFrame.cpp
Go to the documentation of this file.
1//===-- SBFrame.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
9#include <algorithm>
10#include <set>
11#include <string>
12
13#include "lldb/API/SBFrame.h"
14
15#include "lldb/lldb-types.h"
16
17#include "Utils.h"
18#include "lldb/Core/Address.h"
19#include "lldb/Core/Debugger.h"
22#include "lldb/Host/Host.h"
23#include "lldb/Symbol/Block.h"
25#include "lldb/Symbol/Symbol.h"
30#include "lldb/Target/Process.h"
34#include "lldb/Target/StackID.h"
35#include "lldb/Target/Target.h"
36#include "lldb/Target/Thread.h"
40#include "lldb/Utility/Stream.h"
44
45#include "lldb/API/SBAddress.h"
46#include "lldb/API/SBDebugger.h"
48#include "lldb/API/SBFormat.h"
49#include "lldb/API/SBStream.h"
52#include "lldb/API/SBThread.h"
53#include "lldb/API/SBValue.h"
55
56#include "llvm/Support/PrettyStackTrace.h"
57
58using namespace lldb;
59using namespace lldb_private;
60
61SBFrame::SBFrame() : m_opaque_sp(new ExecutionContextRef()) {
63}
64
65SBFrame::SBFrame(const StackFrameSP &lldb_object_sp)
66 : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
67 LLDB_INSTRUMENT_VA(this, lldb_object_sp);
68}
69
71 LLDB_INSTRUMENT_VA(this, rhs);
72
74}
75
76SBFrame::~SBFrame() = default;
77
79 LLDB_INSTRUMENT_VA(this, rhs);
80
81 if (this != &rhs)
83 return *this;
84}
85
87 return (m_opaque_sp ? m_opaque_sp->GetFrameSP() : StackFrameSP());
88}
89
90void SBFrame::SetFrameSP(const StackFrameSP &lldb_object_sp) {
91 return m_opaque_sp->SetFrameSP(lldb_object_sp);
92}
93
94bool SBFrame::IsValid() const {
96 return this->operator bool();
97}
98SBFrame::operator bool() const {
100
101 std::unique_lock<std::recursive_mutex> lock;
102 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
103
104 Target *target = exe_ctx.GetTargetPtr();
105 Process *process = exe_ctx.GetProcessPtr();
106 if (target && process) {
107 Process::StopLocker stop_locker;
108 if (stop_locker.TryLock(&process->GetRunLock()))
109 return GetFrameSP().get() != nullptr;
110 }
111
112 // Without a target & process we can't have a valid stack frame.
113 return false;
114}
115
116SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const {
117 LLDB_INSTRUMENT_VA(this, resolve_scope);
118
119 SBSymbolContext sb_sym_ctx;
120 std::unique_lock<std::recursive_mutex> lock;
121 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
122 SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
123 Target *target = exe_ctx.GetTargetPtr();
124 Process *process = exe_ctx.GetProcessPtr();
125 if (target && process) {
126 Process::StopLocker stop_locker;
127 if (stop_locker.TryLock(&process->GetRunLock())) {
128 if (StackFrame *frame = exe_ctx.GetFramePtr())
129 sb_sym_ctx = frame->GetSymbolContext(scope);
130 }
131 }
132
133 return sb_sym_ctx;
134}
135
137 LLDB_INSTRUMENT_VA(this);
138
139 SBModule sb_module;
140 ModuleSP module_sp;
141 std::unique_lock<std::recursive_mutex> lock;
142 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
143
144 StackFrame *frame = nullptr;
145 Target *target = exe_ctx.GetTargetPtr();
146 Process *process = exe_ctx.GetProcessPtr();
147 if (target && process) {
148 Process::StopLocker stop_locker;
149 if (stop_locker.TryLock(&process->GetRunLock())) {
150 frame = exe_ctx.GetFramePtr();
151 if (frame) {
152 module_sp = frame->GetSymbolContext(eSymbolContextModule).module_sp;
153 sb_module.SetSP(module_sp);
154 }
155 }
156 }
157
158 return sb_module;
159}
160
162 LLDB_INSTRUMENT_VA(this);
163
164 SBCompileUnit sb_comp_unit;
165 std::unique_lock<std::recursive_mutex> lock;
166 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
167
168 StackFrame *frame = nullptr;
169 Target *target = exe_ctx.GetTargetPtr();
170 Process *process = exe_ctx.GetProcessPtr();
171 if (target && process) {
172 Process::StopLocker stop_locker;
173 if (stop_locker.TryLock(&process->GetRunLock())) {
174 frame = exe_ctx.GetFramePtr();
175 if (frame) {
176 sb_comp_unit.reset(
177 frame->GetSymbolContext(eSymbolContextCompUnit).comp_unit);
178 }
179 }
180 }
181
182 return sb_comp_unit;
183}
184
186 LLDB_INSTRUMENT_VA(this);
187
188 SBFunction sb_function;
189 std::unique_lock<std::recursive_mutex> lock;
190 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
191
192 StackFrame *frame = nullptr;
193 Target *target = exe_ctx.GetTargetPtr();
194 Process *process = exe_ctx.GetProcessPtr();
195 if (target && process) {
196 Process::StopLocker stop_locker;
197 if (stop_locker.TryLock(&process->GetRunLock())) {
198 frame = exe_ctx.GetFramePtr();
199 if (frame) {
200 sb_function.reset(
201 frame->GetSymbolContext(eSymbolContextFunction).function);
202 }
203 }
204 }
205
206 return sb_function;
207}
208
210 LLDB_INSTRUMENT_VA(this);
211
212 SBSymbol sb_symbol;
213 std::unique_lock<std::recursive_mutex> lock;
214 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
215
216 StackFrame *frame = nullptr;
217 Target *target = exe_ctx.GetTargetPtr();
218 Process *process = exe_ctx.GetProcessPtr();
219 if (target && process) {
220 Process::StopLocker stop_locker;
221 if (stop_locker.TryLock(&process->GetRunLock())) {
222 frame = exe_ctx.GetFramePtr();
223 if (frame) {
224 sb_symbol.reset(frame->GetSymbolContext(eSymbolContextSymbol).symbol);
225 }
226 }
227 }
228
229 return sb_symbol;
230}
231
233 LLDB_INSTRUMENT_VA(this);
234
235 SBBlock sb_block;
236 std::unique_lock<std::recursive_mutex> lock;
237 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
238
239 StackFrame *frame = nullptr;
240 Target *target = exe_ctx.GetTargetPtr();
241 Process *process = exe_ctx.GetProcessPtr();
242 if (target && process) {
243 Process::StopLocker stop_locker;
244 if (stop_locker.TryLock(&process->GetRunLock())) {
245 frame = exe_ctx.GetFramePtr();
246 if (frame)
247 sb_block.SetPtr(frame->GetSymbolContext(eSymbolContextBlock).block);
248 }
249 }
250 return sb_block;
251}
252
254 LLDB_INSTRUMENT_VA(this);
255
256 SBBlock sb_block;
257 std::unique_lock<std::recursive_mutex> lock;
258 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
259
260 StackFrame *frame = nullptr;
261 Target *target = exe_ctx.GetTargetPtr();
262 Process *process = exe_ctx.GetProcessPtr();
263 if (target && process) {
264 Process::StopLocker stop_locker;
265 if (stop_locker.TryLock(&process->GetRunLock())) {
266 frame = exe_ctx.GetFramePtr();
267 if (frame)
268 sb_block.SetPtr(frame->GetFrameBlock());
269 }
270 }
271 return sb_block;
272}
273
275 LLDB_INSTRUMENT_VA(this);
276
277 SBLineEntry sb_line_entry;
278 std::unique_lock<std::recursive_mutex> lock;
279 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
280
281 StackFrame *frame = nullptr;
282 Target *target = exe_ctx.GetTargetPtr();
283 Process *process = exe_ctx.GetProcessPtr();
284 if (target && process) {
285 Process::StopLocker stop_locker;
286 if (stop_locker.TryLock(&process->GetRunLock())) {
287 frame = exe_ctx.GetFramePtr();
288 if (frame) {
289 sb_line_entry.SetLineEntry(
290 frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
291 }
292 }
293 }
294 return sb_line_entry;
295}
296
297uint32_t SBFrame::GetFrameID() const {
298 LLDB_INSTRUMENT_VA(this);
299
300 uint32_t frame_idx = UINT32_MAX;
301
302 std::unique_lock<std::recursive_mutex> lock;
303 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
304
305 StackFrame *frame = exe_ctx.GetFramePtr();
306 if (frame)
307 frame_idx = frame->GetFrameIndex();
308
309 return frame_idx;
310}
311
313 LLDB_INSTRUMENT_VA(this);
314
315 std::unique_lock<std::recursive_mutex> lock;
316 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
317
318 StackFrame *frame = exe_ctx.GetFramePtr();
319 if (frame)
320 return frame->GetStackID().GetCallFrameAddress();
322}
323
325 LLDB_INSTRUMENT_VA(this);
326
328 std::unique_lock<std::recursive_mutex> lock;
329 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
330
331 StackFrame *frame = nullptr;
332 Target *target = exe_ctx.GetTargetPtr();
333 Process *process = exe_ctx.GetProcessPtr();
334 if (target && process) {
335 Process::StopLocker stop_locker;
336 if (stop_locker.TryLock(&process->GetRunLock())) {
337 frame = exe_ctx.GetFramePtr();
338 if (frame) {
340 target, AddressClass::eCode);
341 }
342 }
343 }
344
345 return addr;
346}
347
348bool SBFrame::SetPC(addr_t new_pc) {
349 LLDB_INSTRUMENT_VA(this, new_pc);
350
351 bool ret_val = false;
352 std::unique_lock<std::recursive_mutex> lock;
353 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
354
355 Target *target = exe_ctx.GetTargetPtr();
356 Process *process = exe_ctx.GetProcessPtr();
357 if (target && process) {
358 Process::StopLocker stop_locker;
359 if (stop_locker.TryLock(&process->GetRunLock())) {
360 if (StackFrame *frame = exe_ctx.GetFramePtr()) {
361 if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
362 ret_val = reg_ctx_sp->SetPC(new_pc);
363 }
364 }
365 }
366 }
367
368 return ret_val;
369}
370
372 LLDB_INSTRUMENT_VA(this);
373
375 std::unique_lock<std::recursive_mutex> lock;
376 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
377
378 Target *target = exe_ctx.GetTargetPtr();
379 Process *process = exe_ctx.GetProcessPtr();
380 if (target && process) {
381 Process::StopLocker stop_locker;
382 if (stop_locker.TryLock(&process->GetRunLock())) {
383 if (StackFrame *frame = exe_ctx.GetFramePtr()) {
384 if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
385 addr = reg_ctx_sp->GetSP();
386 }
387 }
388 }
389 }
390
391 return addr;
392}
393
395 LLDB_INSTRUMENT_VA(this);
396
398 std::unique_lock<std::recursive_mutex> lock;
399 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
400
401 Target *target = exe_ctx.GetTargetPtr();
402 Process *process = exe_ctx.GetProcessPtr();
403 if (target && process) {
404 Process::StopLocker stop_locker;
405 if (stop_locker.TryLock(&process->GetRunLock())) {
406 if (StackFrame *frame = exe_ctx.GetFramePtr()) {
407 if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
408 addr = reg_ctx_sp->GetFP();
409 }
410 }
411 }
412 }
413
414 return addr;
415}
416
418 LLDB_INSTRUMENT_VA(this);
419
420 SBAddress sb_addr;
421 std::unique_lock<std::recursive_mutex> lock;
422 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
423
424 StackFrame *frame = exe_ctx.GetFramePtr();
425 Target *target = exe_ctx.GetTargetPtr();
426 Process *process = exe_ctx.GetProcessPtr();
427 if (target && process) {
428 Process::StopLocker stop_locker;
429 if (stop_locker.TryLock(&process->GetRunLock())) {
430 frame = exe_ctx.GetFramePtr();
431 if (frame)
432 sb_addr.SetAddress(frame->GetFrameCodeAddress());
433 }
434 }
435 return sb_addr;
436}
437
439 LLDB_INSTRUMENT_VA(this);
440
441 m_opaque_sp->Clear();
442}
443
445 LLDB_INSTRUMENT_VA(this, var_path);
446
447 SBValue sb_value;
448 std::unique_lock<std::recursive_mutex> lock;
449 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
450
451 StackFrame *frame = exe_ctx.GetFramePtr();
452 Target *target = exe_ctx.GetTargetPtr();
453 if (frame && target) {
454 lldb::DynamicValueType use_dynamic =
455 frame->CalculateTarget()->GetPreferDynamicValue();
456 sb_value = GetValueForVariablePath(var_path, use_dynamic);
457 }
458 return sb_value;
459}
460
462 DynamicValueType use_dynamic) {
463 LLDB_INSTRUMENT_VA(this, var_path, use_dynamic);
464
465 SBValue sb_value;
466 if (var_path == nullptr || var_path[0] == '\0') {
467 return sb_value;
468 }
469
470 std::unique_lock<std::recursive_mutex> lock;
471 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
472
473 StackFrame *frame = nullptr;
474 Target *target = exe_ctx.GetTargetPtr();
475 Process *process = exe_ctx.GetProcessPtr();
476 if (target && process) {
477 Process::StopLocker stop_locker;
478 if (stop_locker.TryLock(&process->GetRunLock())) {
479 frame = exe_ctx.GetFramePtr();
480 if (frame) {
481 VariableSP var_sp;
484 var_path, eNoDynamicValues,
487 var_sp, error));
488 sb_value.SetSP(value_sp, use_dynamic);
489 }
490 }
491 }
492 return sb_value;
493}
494
496 LLDB_INSTRUMENT_VA(this, name);
497
498 SBValue value;
499 std::unique_lock<std::recursive_mutex> lock;
500 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
501
502 StackFrame *frame = exe_ctx.GetFramePtr();
503 Target *target = exe_ctx.GetTargetPtr();
504 if (frame && target) {
505 lldb::DynamicValueType use_dynamic =
506 frame->CalculateTarget()->GetPreferDynamicValue();
507 value = FindVariable(name, use_dynamic);
508 }
509 return value;
510}
511
513 lldb::DynamicValueType use_dynamic) {
514 LLDB_INSTRUMENT_VA(this, name, use_dynamic);
515
516 VariableSP var_sp;
517 SBValue sb_value;
518
519 if (name == nullptr || name[0] == '\0') {
520 return sb_value;
521 }
522
523 ValueObjectSP value_sp;
524 std::unique_lock<std::recursive_mutex> lock;
525 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
526
527 StackFrame *frame = nullptr;
528 Target *target = exe_ctx.GetTargetPtr();
529 Process *process = exe_ctx.GetProcessPtr();
530 if (target && process) {
531 Process::StopLocker stop_locker;
532 if (stop_locker.TryLock(&process->GetRunLock())) {
533 frame = exe_ctx.GetFramePtr();
534 if (frame) {
535 value_sp = frame->FindVariable(ConstString(name));
536
537 if (value_sp)
538 sb_value.SetSP(value_sp, use_dynamic);
539 }
540 }
541 }
542
543 return sb_value;
544}
545
546SBValue SBFrame::FindValue(const char *name, ValueType value_type) {
547 LLDB_INSTRUMENT_VA(this, name, value_type);
548
549 SBValue value;
550 std::unique_lock<std::recursive_mutex> lock;
551 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
552
553 StackFrame *frame = exe_ctx.GetFramePtr();
554 Target *target = exe_ctx.GetTargetPtr();
555 if (frame && target) {
556 lldb::DynamicValueType use_dynamic =
557 frame->CalculateTarget()->GetPreferDynamicValue();
558 value = FindValue(name, value_type, use_dynamic);
559 }
560 return value;
561}
562
563SBValue SBFrame::FindValue(const char *name, ValueType value_type,
564 lldb::DynamicValueType use_dynamic) {
565 LLDB_INSTRUMENT_VA(this, name, value_type, use_dynamic);
566
567 SBValue sb_value;
568
569 if (name == nullptr || name[0] == '\0') {
570 return sb_value;
571 }
572
573 ValueObjectSP value_sp;
574 std::unique_lock<std::recursive_mutex> lock;
575 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
576
577 StackFrame *frame = nullptr;
578 Target *target = exe_ctx.GetTargetPtr();
579 Process *process = exe_ctx.GetProcessPtr();
580 if (target && process) {
581 Process::StopLocker stop_locker;
582 if (stop_locker.TryLock(&process->GetRunLock())) {
583 frame = exe_ctx.GetFramePtr();
584 if (frame) {
585 VariableList variable_list;
586
587 switch (value_type) {
588 case eValueTypeVariableGlobal: // global variable
589 case eValueTypeVariableStatic: // static variable
590 case eValueTypeVariableArgument: // function argument variables
591 case eValueTypeVariableLocal: // function local variables
592 case eValueTypeVariableThreadLocal: // thread local variables
593 {
594 SymbolContext sc(frame->GetSymbolContext(eSymbolContextBlock));
595
596 const bool can_create = true;
597 const bool get_parent_variables = true;
598 const bool stop_if_block_is_inlined_function = true;
599
600 if (sc.block)
602 can_create, get_parent_variables,
603 stop_if_block_is_inlined_function,
604 [frame](Variable *v) { return v->IsInScope(frame); },
605 &variable_list);
606 if (value_type == eValueTypeVariableGlobal
607 || value_type == eValueTypeVariableStatic) {
608 const bool get_file_globals = true;
609 VariableList *frame_vars = frame->GetVariableList(get_file_globals,
610 nullptr);
611 if (frame_vars)
612 frame_vars->AppendVariablesIfUnique(variable_list);
613 }
614 ConstString const_name(name);
615 VariableSP variable_sp(
616 variable_list.FindVariable(const_name, value_type));
617 if (variable_sp) {
618 value_sp = frame->GetValueObjectForFrameVariable(variable_sp,
620 sb_value.SetSP(value_sp, use_dynamic);
621 }
622 } break;
623
624 case eValueTypeRegister: // stack frame register value
625 {
626 RegisterContextSP reg_ctx(frame->GetRegisterContext());
627 if (reg_ctx) {
628 if (const RegisterInfo *reg_info =
629 reg_ctx->GetRegisterInfoByName(name)) {
630 value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
631 sb_value.SetSP(value_sp);
632 }
633 }
634 } break;
635
636 case eValueTypeRegisterSet: // A collection of stack frame register
637 // values
638 {
639 RegisterContextSP reg_ctx(frame->GetRegisterContext());
640 if (reg_ctx) {
641 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
642 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
643 const RegisterSet *reg_set = reg_ctx->GetRegisterSet(set_idx);
644 if (reg_set &&
645 (llvm::StringRef(reg_set->name).equals_insensitive(name) ||
646 llvm::StringRef(reg_set->short_name)
647 .equals_insensitive(name))) {
648 value_sp =
649 ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx);
650 sb_value.SetSP(value_sp);
651 break;
652 }
653 }
654 }
655 } break;
656
657 case eValueTypeConstResult: // constant result variables
658 {
659 ConstString const_name(name);
660 ExpressionVariableSP expr_var_sp(
661 target->GetPersistentVariable(const_name));
662 if (expr_var_sp) {
663 value_sp = expr_var_sp->GetValueObject();
664 sb_value.SetSP(value_sp, use_dynamic);
665 }
666 } break;
667
668 default:
669 break;
670 }
671 }
672 }
673 }
674
675 return sb_value;
676}
677
678bool SBFrame::IsEqual(const SBFrame &that) const {
679 LLDB_INSTRUMENT_VA(this, that);
680
681 lldb::StackFrameSP this_sp = GetFrameSP();
682 lldb::StackFrameSP that_sp = that.GetFrameSP();
683 return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
684}
685
686bool SBFrame::operator==(const SBFrame &rhs) const {
687 LLDB_INSTRUMENT_VA(this, rhs);
688
689 return IsEqual(rhs);
690}
691
692bool SBFrame::operator!=(const SBFrame &rhs) const {
693 LLDB_INSTRUMENT_VA(this, rhs);
694
695 return !IsEqual(rhs);
696}
697
699 LLDB_INSTRUMENT_VA(this);
700
701 std::unique_lock<std::recursive_mutex> lock;
702 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
703
704 ThreadSP thread_sp(exe_ctx.GetThreadSP());
705 SBThread sb_thread(thread_sp);
706
707 return sb_thread;
708}
709
710const char *SBFrame::Disassemble() const {
711 LLDB_INSTRUMENT_VA(this);
712
713 std::unique_lock<std::recursive_mutex> lock;
714 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
715 Target *target = exe_ctx.GetTargetPtr();
716 Process *process = exe_ctx.GetProcessPtr();
717 if (!target || !process)
718 return nullptr;
719
720 Process::StopLocker stop_locker;
721 if (stop_locker.TryLock(&process->GetRunLock())) {
722 if (auto *frame = exe_ctx.GetFramePtr())
723 return ConstString(frame->Disassemble()).GetCString();
724 }
725
726 return nullptr;
727}
728
729SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics,
730 bool in_scope_only) {
731 LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only);
732
733 SBValueList value_list;
734 std::unique_lock<std::recursive_mutex> lock;
735 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
736
737 StackFrame *frame = exe_ctx.GetFramePtr();
738 Target *target = exe_ctx.GetTargetPtr();
739 if (frame && target) {
740 lldb::DynamicValueType use_dynamic =
741 frame->CalculateTarget()->GetPreferDynamicValue();
742 const bool include_runtime_support_values =
744
745 SBVariablesOptions options;
746 options.SetIncludeArguments(arguments);
747 options.SetIncludeLocals(locals);
748 options.SetIncludeStatics(statics);
749 options.SetInScopeOnly(in_scope_only);
750 options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
751 options.SetUseDynamic(use_dynamic);
752
753 value_list = GetVariables(options);
754 }
755 return value_list;
756}
757
758lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals,
759 bool statics, bool in_scope_only,
760 lldb::DynamicValueType use_dynamic) {
761 LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only,
762 use_dynamic);
763
764 std::unique_lock<std::recursive_mutex> lock;
765 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
766
767 Target *target = exe_ctx.GetTargetPtr();
768 const bool include_runtime_support_values =
769 target ? target->GetDisplayRuntimeSupportValues() : false;
770 SBVariablesOptions options;
771 options.SetIncludeArguments(arguments);
772 options.SetIncludeLocals(locals);
773 options.SetIncludeStatics(statics);
774 options.SetInScopeOnly(in_scope_only);
775 options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
776 options.SetUseDynamic(use_dynamic);
777 return GetVariables(options);
778}
779
781 LLDB_INSTRUMENT_VA(this, options);
782
783 SBValueList value_list;
784 std::unique_lock<std::recursive_mutex> lock;
785 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
786
787 StackFrame *frame = nullptr;
788 Target *target = exe_ctx.GetTargetPtr();
789
790 const bool statics = options.GetIncludeStatics();
791 const bool arguments = options.GetIncludeArguments();
792 const bool recognized_arguments =
794 const bool locals = options.GetIncludeLocals();
795 const bool in_scope_only = options.GetInScopeOnly();
796 const bool include_runtime_support_values =
798 const lldb::DynamicValueType use_dynamic = options.GetUseDynamic();
799
800
801 std::set<VariableSP> variable_set;
802 Process *process = exe_ctx.GetProcessPtr();
803 if (target && process) {
804 Process::StopLocker stop_locker;
805 if (stop_locker.TryLock(&process->GetRunLock())) {
806 frame = exe_ctx.GetFramePtr();
807 if (frame) {
808 Debugger &dbg = process->GetTarget().GetDebugger();
809 VariableList *variable_list = nullptr;
810 Status var_error;
811 variable_list = frame->GetVariableList(true, &var_error);
812 if (var_error.Fail())
813 value_list.SetError(std::move(var_error));
814 if (variable_list) {
815 const size_t num_variables = variable_list->GetSize();
816 if (num_variables) {
817 size_t num_produced = 0;
818 for (const VariableSP &variable_sp : *variable_list) {
819 if (INTERRUPT_REQUESTED(dbg,
820 "Interrupted getting frame variables with {0} of {1} "
821 "produced.", num_produced, num_variables))
822 return {};
823
824 if (variable_sp) {
825 bool add_variable = false;
826 switch (variable_sp->GetScope()) {
830 add_variable = statics;
831 break;
832
834 add_variable = arguments;
835 break;
836
838 add_variable = locals;
839 break;
840
841 default:
842 break;
843 }
844 if (add_variable) {
845 // Only add variables once so we don't end up with duplicates
846 if (variable_set.find(variable_sp) == variable_set.end())
847 variable_set.insert(variable_sp);
848 else
849 continue;
850
851 if (in_scope_only && !variable_sp->IsInScope(frame))
852 continue;
853
855 variable_sp, eNoDynamicValues));
856
857 if (!include_runtime_support_values && valobj_sp != nullptr &&
858 valobj_sp->IsRuntimeSupportValue())
859 continue;
860
861 SBValue value_sb;
862 value_sb.SetSP(valobj_sp, use_dynamic);
863 value_list.Append(value_sb);
864 }
865 }
866 }
867 num_produced++;
868 }
869 }
870 if (recognized_arguments) {
871 auto recognized_frame = frame->GetRecognizedFrame();
872 if (recognized_frame) {
873 ValueObjectListSP recognized_arg_list =
874 recognized_frame->GetRecognizedArguments();
875 if (recognized_arg_list) {
876 for (auto &rec_value_sp : recognized_arg_list->GetObjects()) {
877 SBValue value_sb;
878 value_sb.SetSP(rec_value_sp, use_dynamic);
879 value_list.Append(value_sb);
880 }
881 }
882 }
883 }
884 }
885 }
886 }
887
888 return value_list;
889}
890
892 LLDB_INSTRUMENT_VA(this);
893
894 SBValueList value_list;
895 std::unique_lock<std::recursive_mutex> lock;
896 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
897
898 StackFrame *frame = nullptr;
899 Target *target = exe_ctx.GetTargetPtr();
900 Process *process = exe_ctx.GetProcessPtr();
901 if (target && process) {
902 Process::StopLocker stop_locker;
903 if (stop_locker.TryLock(&process->GetRunLock())) {
904 frame = exe_ctx.GetFramePtr();
905 if (frame) {
906 RegisterContextSP reg_ctx(frame->GetRegisterContext());
907 if (reg_ctx) {
908 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
909 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
910 value_list.Append(
911 ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx));
912 }
913 }
914 }
915 }
916 }
917
918 return value_list;
919}
920
922 LLDB_INSTRUMENT_VA(this, name);
923
924 SBValue result;
925 ValueObjectSP value_sp;
926 std::unique_lock<std::recursive_mutex> lock;
927 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
928
929 StackFrame *frame = nullptr;
930 Target *target = exe_ctx.GetTargetPtr();
931 Process *process = exe_ctx.GetProcessPtr();
932 if (target && process) {
933 Process::StopLocker stop_locker;
934 if (stop_locker.TryLock(&process->GetRunLock())) {
935 frame = exe_ctx.GetFramePtr();
936 if (frame) {
937 RegisterContextSP reg_ctx(frame->GetRegisterContext());
938 if (reg_ctx) {
939 if (const RegisterInfo *reg_info =
940 reg_ctx->GetRegisterInfoByName(name)) {
941 value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
942 result.SetSP(value_sp);
943 }
944 }
945 }
946 }
947 }
948
949 return result;
950}
951
953 SBStream &output) {
954 Stream &strm = output.ref();
955
956 std::unique_lock<std::recursive_mutex> lock;
957 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
958
959 StackFrame *frame = nullptr;
960 Target *target = exe_ctx.GetTargetPtr();
961 Process *process = exe_ctx.GetProcessPtr();
963
964 if (!format) {
965 error.SetErrorString("The provided SBFormat object is invalid");
966 return error;
967 }
968
969 if (target && process) {
970 Process::StopLocker stop_locker;
971 if (stop_locker.TryLock(&process->GetRunLock())) {
972 frame = exe_ctx.GetFramePtr();
973 if (frame &&
974 frame->DumpUsingFormat(strm, format.GetFormatEntrySP().get())) {
975 return error;
976 }
977 }
978 }
979 error.SetErrorStringWithFormat(
980 "It was not possible to generate a frame "
981 "description with the given format string '%s'",
982 format.GetFormatEntrySP()->string.c_str());
983 return error;
984}
985
987 LLDB_INSTRUMENT_VA(this, description);
988
989 Stream &strm = description.ref();
990
991 std::unique_lock<std::recursive_mutex> lock;
992 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
993
994 StackFrame *frame;
995 Target *target = exe_ctx.GetTargetPtr();
996 Process *process = exe_ctx.GetProcessPtr();
997 if (target && process) {
998 Process::StopLocker stop_locker;
999 if (stop_locker.TryLock(&process->GetRunLock())) {
1000 frame = exe_ctx.GetFramePtr();
1001 if (frame) {
1002 frame->DumpUsingSettingsFormat(&strm);
1003 }
1004 }
1005
1006 } else
1007 strm.PutCString("No value");
1008
1009 return true;
1010}
1011
1013 LLDB_INSTRUMENT_VA(this, expr);
1014
1015 SBValue result;
1016 std::unique_lock<std::recursive_mutex> lock;
1017 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1018
1019 StackFrame *frame = exe_ctx.GetFramePtr();
1020 Target *target = exe_ctx.GetTargetPtr();
1021 if (frame && target) {
1022 SBExpressionOptions options;
1023 lldb::DynamicValueType fetch_dynamic_value =
1024 frame->CalculateTarget()->GetPreferDynamicValue();
1025 options.SetFetchDynamicValue(fetch_dynamic_value);
1026 options.SetUnwindOnError(true);
1027 options.SetIgnoreBreakpoints(true);
1028 SourceLanguage language = target->GetLanguage();
1029 if (!language)
1030 language = frame->GetLanguage();
1031 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1032 return EvaluateExpression(expr, options);
1033 } else {
1034 Status error;
1035 error = Status::FromErrorString("can't evaluate expressions when the "
1036 "process is running.");
1037 ValueObjectSP error_val_sp =
1038 ValueObjectConstResult::Create(nullptr, std::move(error));
1039 result.SetSP(error_val_sp, false);
1040 }
1041 return result;
1042}
1043
1044SBValue
1046 lldb::DynamicValueType fetch_dynamic_value) {
1047 LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value);
1048
1049 SBExpressionOptions options;
1050 options.SetFetchDynamicValue(fetch_dynamic_value);
1051 options.SetUnwindOnError(true);
1052 options.SetIgnoreBreakpoints(true);
1053 std::unique_lock<std::recursive_mutex> lock;
1054 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1055
1056 StackFrame *frame = exe_ctx.GetFramePtr();
1057 Target *target = exe_ctx.GetTargetPtr();
1058 SourceLanguage language;
1059 if (target)
1060 language = target->GetLanguage();
1061 if (!language && frame)
1062 language = frame->GetLanguage();
1063 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1064 return EvaluateExpression(expr, options);
1065}
1066
1068 lldb::DynamicValueType fetch_dynamic_value,
1069 bool unwind_on_error) {
1070 LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value, unwind_on_error);
1071
1072 SBExpressionOptions options;
1073 std::unique_lock<std::recursive_mutex> lock;
1074 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1075
1076 options.SetFetchDynamicValue(fetch_dynamic_value);
1077 options.SetUnwindOnError(unwind_on_error);
1078 options.SetIgnoreBreakpoints(true);
1079 StackFrame *frame = exe_ctx.GetFramePtr();
1080 Target *target = exe_ctx.GetTargetPtr();
1081 SourceLanguage language;
1082 if (target)
1083 language = target->GetLanguage();
1084 if (!language && frame)
1085 language = frame->GetLanguage();
1086 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1087 return EvaluateExpression(expr, options);
1088}
1089
1091 const SBExpressionOptions &options) {
1092 LLDB_INSTRUMENT_VA(this, expr, options);
1093
1094 Log *expr_log = GetLog(LLDBLog::Expressions);
1095
1096 SBValue expr_result;
1097
1098 if (expr == nullptr || expr[0] == '\0') {
1099 return expr_result;
1100 }
1101
1102 ValueObjectSP expr_value_sp;
1103
1104 std::unique_lock<std::recursive_mutex> lock;
1105 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1106
1107 StackFrame *frame = nullptr;
1108 Target *target = exe_ctx.GetTargetPtr();
1109 Process *process = exe_ctx.GetProcessPtr();
1110
1111 if (target && process) {
1112 Process::StopLocker stop_locker;
1113 if (stop_locker.TryLock(&process->GetRunLock())) {
1114 frame = exe_ctx.GetFramePtr();
1115 if (frame) {
1116 std::unique_ptr<llvm::PrettyStackTraceFormat> stack_trace;
1117 if (target->GetDisplayExpressionsInCrashlogs()) {
1118 StreamString frame_description;
1119 frame->DumpUsingSettingsFormat(&frame_description);
1120 stack_trace = std::make_unique<llvm::PrettyStackTraceFormat>(
1121 "SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value "
1122 "= %u) %s",
1123 expr, options.GetFetchDynamicValue(),
1124 frame_description.GetData());
1125 }
1126
1127 target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
1128 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
1129 }
1130 } else {
1131 Status error;
1132 error = Status::FromErrorString("can't evaluate expressions when the "
1133 "process is running.");
1134 expr_value_sp = ValueObjectConstResult::Create(nullptr, std::move(error));
1135 expr_result.SetSP(expr_value_sp, false);
1136 }
1137 } else {
1138 Status error;
1139 error = Status::FromErrorString("sbframe object is not valid.");
1140 expr_value_sp = ValueObjectConstResult::Create(nullptr, std::move(error));
1141 expr_result.SetSP(expr_value_sp, false);
1142 }
1143
1144 if (expr_result.GetError().Success())
1145 LLDB_LOGF(expr_log,
1146 "** [SBFrame::EvaluateExpression] Expression result is "
1147 "%s, summary %s **",
1148 expr_result.GetValue(), expr_result.GetSummary());
1149 else
1150 LLDB_LOGF(expr_log,
1151 "** [SBFrame::EvaluateExpression] Expression evaluation failed: "
1152 "%s **",
1153 expr_result.GetError().GetCString());
1154
1155 return expr_result;
1156}
1157
1159 LLDB_INSTRUMENT_VA(this);
1160
1161 SBStructuredData sb_data;
1162 std::unique_lock<std::recursive_mutex> lock;
1163 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1164 StackFrame *frame = exe_ctx.GetFramePtr();
1165 if (!frame)
1166 return sb_data;
1167
1169 sb_data.m_impl_up->SetObjectSP(data);
1170 return sb_data;
1171}
1172
1174 LLDB_INSTRUMENT_VA(this);
1175
1176 return static_cast<const SBFrame *>(this)->IsInlined();
1177}
1178
1180 LLDB_INSTRUMENT_VA(this);
1181
1182 std::unique_lock<std::recursive_mutex> lock;
1183 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1184
1185 StackFrame *frame = nullptr;
1186 Target *target = exe_ctx.GetTargetPtr();
1187 Process *process = exe_ctx.GetProcessPtr();
1188 if (target && process) {
1189 Process::StopLocker stop_locker;
1190 if (stop_locker.TryLock(&process->GetRunLock())) {
1191 frame = exe_ctx.GetFramePtr();
1192 if (frame)
1193 return frame->IsInlined();
1194 }
1195 }
1196 return false;
1197}
1198
1200 LLDB_INSTRUMENT_VA(this);
1201
1202 return static_cast<const SBFrame *>(this)->IsArtificial();
1203}
1204
1206 LLDB_INSTRUMENT_VA(this);
1207
1208 std::unique_lock<std::recursive_mutex> lock;
1209 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1210
1211 if (StackFrame *frame = exe_ctx.GetFramePtr())
1212 return frame->IsArtificial();
1213
1214 return false;
1215}
1216
1217bool SBFrame::IsHidden() const {
1218 LLDB_INSTRUMENT_VA(this);
1219
1220 std::unique_lock<std::recursive_mutex> lock;
1221 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1222
1223 if (StackFrame *frame = exe_ctx.GetFramePtr())
1224 return frame->IsHidden();
1225
1226 return false;
1227}
1228
1230 LLDB_INSTRUMENT_VA(this);
1231
1232 return static_cast<const SBFrame *>(this)->GetFunctionName();
1233}
1234
1236 LLDB_INSTRUMENT_VA(this);
1237
1238 std::unique_lock<std::recursive_mutex> lock;
1239 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1240
1241 StackFrame *frame = nullptr;
1242 Target *target = exe_ctx.GetTargetPtr();
1243 Process *process = exe_ctx.GetProcessPtr();
1244 if (target && process) {
1245 Process::StopLocker stop_locker;
1246 if (stop_locker.TryLock(&process->GetRunLock())) {
1247 frame = exe_ctx.GetFramePtr();
1248 if (frame) {
1249 return frame->GuessLanguage().AsLanguageType();
1250 }
1251 }
1252 }
1253 return eLanguageTypeUnknown;
1254}
1255
1256const char *SBFrame::GetFunctionName() const {
1257 LLDB_INSTRUMENT_VA(this);
1258
1259 const char *name = nullptr;
1260 std::unique_lock<std::recursive_mutex> lock;
1261 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1262
1263 StackFrame *frame = nullptr;
1264 Target *target = exe_ctx.GetTargetPtr();
1265 Process *process = exe_ctx.GetProcessPtr();
1266 if (target && process) {
1267 Process::StopLocker stop_locker;
1268 if (stop_locker.TryLock(&process->GetRunLock())) {
1269 frame = exe_ctx.GetFramePtr();
1270 if (frame)
1271 return frame->GetFunctionName();
1272 }
1273 }
1274 return name;
1275}
1276
1278 LLDB_INSTRUMENT_VA(this);
1279
1280 const char *name = nullptr;
1281
1282 std::unique_lock<std::recursive_mutex> lock;
1283 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1284
1285 StackFrame *frame = nullptr;
1286 Target *target = exe_ctx.GetTargetPtr();
1287 Process *process = exe_ctx.GetProcessPtr();
1288 if (target && process) {
1289 Process::StopLocker stop_locker;
1290 if (stop_locker.TryLock(&process->GetRunLock())) {
1291 frame = exe_ctx.GetFramePtr();
1292 if (frame)
1293 return frame->GetDisplayFunctionName();
1294 }
1295 }
1296 return name;
1297}
static llvm::raw_ostream & error(Stream &strm)
#define INTERRUPT_REQUESTED(debugger,...)
This handy define will keep you from having to generate a report for the interruption by hand.
Definition: Debugger.h:454
#define LLDB_INSTRUMENT_VA(...)
#define LLDB_LOGF(log,...)
Definition: Log.h:376
void SetAddress(lldb::SBSection section, lldb::addr_t offset)
Definition: SBAddress.cpp:88
void SetPtr(lldb_private::Block *lldb_object_ptr)
Definition: SBBlock.cpp:162
void reset(lldb_private::CompileUnit *lldb_object_ptr)
bool Success() const
Definition: SBError.cpp:79
const char * GetCString() const
Get the error string as a NULL terminated UTF8 c-string.
Definition: SBError.cpp:53
void SetFetchDynamicValue(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
void SetLanguage(lldb::LanguageType language)
lldb_private::EvaluateExpressionOptions & ref() const
void SetIgnoreBreakpoints(bool ignore=true)
void SetUnwindOnError(bool unwind=true)
lldb::DynamicValueType GetFetchDynamicValue() const
Class that represents a format string that can be used to generate descriptions of objects like frame...
Definition: SBFormat.h:28
lldb::FormatEntrySP GetFormatEntrySP() const
Definition: SBFormat.cpp:44
lldb::ExecutionContextRefSP m_opaque_sp
Definition: SBFrame.h:236
lldb::addr_t GetPC() const
Definition: SBFrame.cpp:324
const char * GetFunctionName()
Get the appropriate function name for this frame.
Definition: SBFrame.cpp:1229
lldb::SBValue FindValue(const char *name, ValueType value_type)
Find variables, register sets, registers, or persistent variables using the frame as the scope.
Definition: SBFrame.cpp:546
lldb::SBValue GetValueForVariablePath(const char *var_expr_cstr, DynamicValueType use_dynamic)
Definition: SBFrame.cpp:461
lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope) const
Definition: SBFrame.cpp:116
SBError GetDescriptionWithFormat(const SBFormat &format, SBStream &output)
Similar to GetDescription() but the format of the description can be configured via the format parame...
Definition: SBFrame.cpp:952
bool IsValid() const
Definition: SBFrame.cpp:94
lldb::SBValue FindRegister(const char *name)
Definition: SBFrame.cpp:921
bool SetPC(lldb::addr_t new_pc)
Definition: SBFrame.cpp:348
lldb::SBValue FindVariable(const char *var_name)
The version that doesn't supply a 'use_dynamic' value will use the target's default.
Definition: SBFrame.cpp:495
const char * GetDisplayFunctionName()
Definition: SBFrame.cpp:1277
bool IsInlined()
Return true if this frame represents an inlined function.
Definition: SBFrame.cpp:1173
bool operator==(const lldb::SBFrame &rhs) const
Definition: SBFrame.cpp:686
lldb::addr_t GetCFA() const
Definition: SBFrame.cpp:312
lldb::addr_t GetFP() const
Definition: SBFrame.cpp:394
const lldb::SBFrame & operator=(const lldb::SBFrame &rhs)
Definition: SBFrame.cpp:78
lldb::SBLineEntry GetLineEntry() const
Definition: SBFrame.cpp:274
lldb::SBValue EvaluateExpression(const char *expr)
The version that doesn't supply a 'use_dynamic' value will use the target's default.
Definition: SBFrame.cpp:1012
lldb::SBCompileUnit GetCompileUnit() const
Definition: SBFrame.cpp:161
uint32_t GetFrameID() const
Definition: SBFrame.cpp:297
lldb::SBAddress GetPCAddress() const
Definition: SBFrame.cpp:417
lldb::SBFunction GetFunction() const
Definition: SBFrame.cpp:185
lldb::SBBlock GetBlock() const
Gets the deepest block that contains the frame PC.
Definition: SBFrame.cpp:232
lldb::SBValueList GetVariables(bool arguments, bool locals, bool statics, bool in_scope_only)
The version that doesn't supply a 'use_dynamic' value will use the target's default.
Definition: SBFrame.cpp:729
bool IsEqual(const lldb::SBFrame &that) const
Definition: SBFrame.cpp:678
const char * Disassemble() const
Definition: SBFrame.cpp:710
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
Definition: SBFrame.cpp:90
lldb::SBThread GetThread() const
Definition: SBFrame.cpp:698
lldb::SBValueList GetRegisters()
Definition: SBFrame.cpp:891
bool IsArtificial()
Definition: SBFrame.cpp:1199
void Clear()
Definition: SBFrame.cpp:438
lldb::LanguageType GuessLanguage() const
Definition: SBFrame.cpp:1235
lldb::SBBlock GetFrameBlock() const
Gets the lexical block that defines the stack frame.
Definition: SBFrame.cpp:253
lldb::addr_t GetSP() const
Definition: SBFrame.cpp:371
lldb::StackFrameSP GetFrameSP() const
Definition: SBFrame.cpp:86
bool IsHidden() const
Return whether a frame recognizer decided this frame should not be displayes in backtraces etc.
Definition: SBFrame.cpp:1217
SBStructuredData GetLanguageSpecificData() const
Language plugins can use this API to report language-specific runtime information about this compile ...
Definition: SBFrame.cpp:1158
lldb::SBSymbol GetSymbol() const
Definition: SBFrame.cpp:209
lldb::SBModule GetModule() const
Definition: SBFrame.cpp:136
bool GetDescription(lldb::SBStream &description)
Definition: SBFrame.cpp:986
bool operator!=(const lldb::SBFrame &rhs) const
Definition: SBFrame.cpp:692
void reset(lldb_private::Function *lldb_object_ptr)
Definition: SBFunction.cpp:139
void SetLineEntry(const lldb_private::LineEntry &lldb_object_ref)
Definition: SBLineEntry.cpp:43
void SetSP(const ModuleSP &module_sp)
Definition: SBModule.cpp:211
lldb_private::Stream & ref()
Definition: SBStream.cpp:177
StructuredDataImplUP m_impl_up
void reset(lldb_private::Symbol *)
Definition: SBSymbol.cpp:140
void Append(const lldb::SBValue &val_obj)
void SetError(lldb_private::Status &&status)
SBError GetError()
Definition: SBValue.cpp:265
void SetSP(const lldb::ValueObjectSP &sp)
Definition: SBValue.cpp:1115
const char * GetValue()
Definition: SBValue.cpp:352
const char * GetSummary()
Definition: SBValue.cpp:419
bool GetIncludeRuntimeSupportValues() const
lldb::DynamicValueType GetUseDynamic() const
void SetUseDynamic(lldb::DynamicValueType)
bool GetIncludeRecognizedArguments(const lldb::SBTarget &) const
lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass addr_class=AddressClass::eInvalid) const
Get the load address as an opcode load address.
Definition: Address.cpp:370
uint32_t AppendVariables(bool can_create, bool get_parent_variables, bool stop_if_block_is_inlined_function, const std::function< bool(Variable *)> &filter, VariableList *variable_list)
Appends the variables from this block, and optionally from all parent blocks, to variable_list.
Definition: Block.cpp:451
A uniqued constant string class.
Definition: ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
A class to manage flag bits.
Definition: Debugger.h:80
Execution context objects refer to objects in the execution of the program that is being debugged.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
Target * GetTargetPtr() const
Returns a pointer to the target object.
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
Process * GetProcessPtr() const
Returns a pointer to the process object.
A plug-in interface definition class for debugging a process.
Definition: Process.h:343
ProcessRunLock & GetRunLock()
Definition: Process.cpp:5851
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1246
This base class provides an interface to stack frames.
Definition: StackFrame.h:44
@ eExpressionPathOptionsAllowDirectIVarAccess
Definition: StackFrame.h:51
const char * GetFunctionName()
Get the frame's demangled name.
VariableList * GetVariableList(bool get_file_globals, Status *error_ptr)
Retrieve the list of variables that are in scope at this StackFrame's pc.
Definition: StackFrame.cpp:425
void DumpUsingSettingsFormat(Stream *strm, bool show_unique=false, const char *frame_marker=nullptr)
Print a description for this frame using the frame-format formatter settings.
bool IsInlined()
Query whether this frame is a concrete frame on the call stack, or if it is an inlined frame derived ...
lldb::ValueObjectSP GetValueForVariableExpressionPath(llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic, uint32_t options, lldb::VariableSP &var_sp, Status &error)
Create a ValueObject for a variable name / pathname, possibly including simple dereference/child sele...
Definition: StackFrame.cpp:509
SourceLanguage GuessLanguage()
Similar to GetLanguage(), but is allowed to take a potentially incorrect guess if exact information i...
lldb::RegisterContextSP GetRegisterContext()
Get the RegisterContext for this frame, if possible.
StructuredData::ObjectSP GetLanguageSpecificData()
Language plugins can use this API to report language-specific runtime information about this compile ...
SourceLanguage GetLanguage()
Query this frame to determine what the default language should be when parsing expressions given the ...
lldb::ValueObjectSP GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic)
Create a ValueObject for a given Variable in this StackFrame.
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:301
const char * GetDisplayFunctionName()
Get the frame's demangled display name.
uint32_t GetFrameIndex() const
Query this frame to find what frame it is in this Thread's StackFrameList.
Definition: StackFrame.cpp:176
Block * GetFrameBlock()
Get the current lexical scope block for this StackFrame, if possible.
Definition: StackFrame.cpp:276
bool DumpUsingFormat(Stream &strm, const lldb_private::FormatEntity::Entry *format, llvm::StringRef frame_marker={})
Print a description of this frame using the provided frame format.
lldb::RecognizedStackFrameSP GetRecognizedFrame()
lldb::ValueObjectSP FindVariable(ConstString name)
Attempt to reconstruct the ValueObject for a variable with a given name from within the current Stack...
const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
Definition: StackFrame.cpp:191
lldb::TargetSP CalculateTarget() override
lldb::addr_t GetCallFrameAddress() const
Definition: StackID.h:33
An error handling class.
Definition: Status.h:115
static Status FromErrorString(const char *str)
Definition: Status.h:138
bool Fail() const
Test for error condition.
Definition: Status.cpp:270
const char * GetData() const
Definition: StreamString.h:45
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:65
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:34
Function * function
The Function for a given query.
Block * block
The Block for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
Symbol * symbol
The Symbol for a given query.
LineEntry line_entry
The LineEntry for a given query.
bool GetDisplayRuntimeSupportValues() const
Definition: Target.cpp:4945
SourceLanguage GetLanguage() const
Definition: Target.cpp:4840
bool GetDisplayExpressionsInCrashlogs() const
Definition: Target.cpp:4901
Debugger & GetDebugger()
Definition: Target.h:1080
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name)
Definition: Target.cpp:2858
lldb::ExpressionResults EvaluateExpression(llvm::StringRef expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, const EvaluateExpressionOptions &options=EvaluateExpressionOptions(), std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
Definition: Target.cpp:2790
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t set_idx)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, const RegisterInfo *reg_info)
lldb::VariableSP FindVariable(ConstString name, bool include_static_members=true)
size_t AppendVariablesIfUnique(VariableList &var_list)
bool IsInScope(StackFrame *frame)
Definition: Variable.cpp:275
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:332
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:424
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:450
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:484
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
Definition: lldb-forward.h:351
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::ValueObjectList > ValueObjectListSP
Definition: lldb-forward.h:488
std::shared_ptr< lldb_private::Variable > VariableSP
Definition: lldb-forward.h:486
uint64_t addr_t
Definition: lldb-types.h:80
@ eNoDynamicValues
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
Definition: lldb-forward.h:394
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:373
@ eValueTypeVariableGlobal
globals variable
@ eValueTypeConstResult
constant result variables
@ eValueTypeVariableLocal
function local variables
@ eValueTypeVariableArgument
function argument variables
@ eValueTypeRegister
stack frame register value
@ eValueTypeVariableStatic
static variable
@ eValueTypeRegisterSet
A collection of stack frame register values.
@ eValueTypeVariableThreadLocal
thread local storage variable
Every register is described in detail including its name, alternate name (optional),...
Registers are grouped into register sets.
const char * name
Name of this register set.
const char * short_name
A short name for this register set.
A type-erased pair of llvm::dwarf::SourceLanguageName and version.
lldb::LanguageType AsLanguageType() const
Definition: Language.cpp:554