1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
|
//===-- SBValue.cpp ---------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBValue.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBTarget.h"
#include "lldb/API/SBThread.h"
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBDebugger.h"
using namespace lldb;
using namespace lldb_private;
SBValue::SBValue () :
m_opaque_sp ()
{
}
SBValue::SBValue (const lldb::ValueObjectSP &value_sp) :
m_opaque_sp (value_sp)
{
}
SBValue::SBValue(const SBValue &rhs) :
m_opaque_sp (rhs.m_opaque_sp)
{
}
const SBValue &
SBValue::operator = (const SBValue &rhs)
{
if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp;
return *this;
}
SBValue::~SBValue()
{
}
bool
SBValue::IsValid () const
{
// If this function ever changes to anything that does more than just
// check if the opaque shared pointer is non NULL, then we need to update
// all "if (m_opaque_sp)" code in this file.
return m_opaque_sp.get() != NULL;
}
SBError
SBValue::GetError()
{
SBError sb_error;
if (m_opaque_sp.get())
sb_error.SetError(m_opaque_sp->GetError());
return sb_error;
}
user_id_t
SBValue::GetID()
{
if (m_opaque_sp)
return m_opaque_sp->GetID();
return LLDB_INVALID_UID;
}
const char *
SBValue::GetName()
{
const char *name = NULL;
if (m_opaque_sp)
name = m_opaque_sp->GetName().GetCString();
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (name)
log->Printf ("SBValue(%p)::GetName () => \"%s\"", m_opaque_sp.get(), name);
else
log->Printf ("SBValue(%p)::GetName () => NULL", m_opaque_sp.get(), name);
}
return name;
}
const char *
SBValue::GetTypeName ()
{
const char *name = NULL;
if (m_opaque_sp)
name = m_opaque_sp->GetTypeName().GetCString();
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (name)
log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"", m_opaque_sp.get(), name);
else
log->Printf ("SBValue(%p)::GetTypeName () => NULL", m_opaque_sp.get());
}
return name;
}
size_t
SBValue::GetByteSize ()
{
size_t result = 0;
if (m_opaque_sp)
result = m_opaque_sp->GetByteSize();
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetByteSize () => %zu", m_opaque_sp.get(), result);
return result;
}
bool
SBValue::IsInScope (const SBFrame &sb_frame)
{
return IsInScope();
}
bool
SBValue::IsInScope ()
{
bool result = false;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
result = m_opaque_sp->IsInScope ();
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::IsInScope () => %i", m_opaque_sp.get(), result);
return result;
}
const char *
SBValue::GetValue (const SBFrame &sb_frame)
{
return GetValue();
}
const char *
SBValue::GetValue ()
{
const char *cstr = NULL;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
cstr = m_opaque_sp->GetValueAsCString ();
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
log->Printf ("SBValue(%p)::GetValue => \"%s\"", m_opaque_sp.get(), cstr);
else
log->Printf ("SBValue(%p)::GetValue => NULL", m_opaque_sp.get());
}
return cstr;
}
ValueType
SBValue::GetValueType ()
{
ValueType result = eValueTypeInvalid;
if (m_opaque_sp)
result = m_opaque_sp->GetValueType();
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
switch (result)
{
case eValueTypeInvalid: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid", m_opaque_sp.get()); break;
case eValueTypeVariableGlobal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal", m_opaque_sp.get()); break;
case eValueTypeVariableStatic: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic", m_opaque_sp.get()); break;
case eValueTypeVariableArgument:log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument", m_opaque_sp.get()); break;
case eValueTypeVariableLocal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal", m_opaque_sp.get()); break;
case eValueTypeRegister: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister", m_opaque_sp.get()); break;
case eValueTypeRegisterSet: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet", m_opaque_sp.get()); break;
case eValueTypeConstResult: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult", m_opaque_sp.get()); break;
default: log->Printf ("SBValue(%p)::GetValueType () => %i ???", m_opaque_sp.get(), result); break;
}
}
return result;
}
const char *
SBValue::GetObjectDescription (const SBFrame &sb_frame)
{
return GetObjectDescription ();
}
const char *
SBValue::GetObjectDescription ()
{
const char *cstr = NULL;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
cstr = m_opaque_sp->GetObjectDescription ();
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
log->Printf ("SBValue(%p)::GetObjectDescription => \"%s\"", m_opaque_sp.get(), cstr);
else
log->Printf ("SBValue(%p)::GetObjectDescription => NULL", m_opaque_sp.get());
}
return cstr;
}
bool
SBValue::GetValueDidChange (const SBFrame &sb_frame)
{
return GetValueDidChange ();
}
SBType
SBValue::GetType()
{
SBType result;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
result = SBType(m_opaque_sp->GetClangAST(),
m_opaque_sp->GetClangType());
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (result.IsValid())
log->Printf ("SBValue(%p)::GetType => %p", m_opaque_sp.get(), &result);
else
log->Printf ("SBValue(%p)::GetType => NULL", m_opaque_sp.get());
}
return result;
}
bool
SBValue::GetValueDidChange ()
{
bool result = false;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
result = m_opaque_sp->GetValueDidChange ();
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetValueDidChange => %i", m_opaque_sp.get(), result);
return result;
}
const char *
SBValue::GetSummary (const SBFrame &sb_frame)
{
return GetSummary ();
}
const char *
SBValue::GetSummary ()
{
const char *cstr = NULL;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
cstr = m_opaque_sp->GetSummaryAsCString();
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
log->Printf ("SBValue(%p)::GetSummary => \"%s\"", m_opaque_sp.get(), cstr);
else
log->Printf ("SBValue(%p)::GetSummary => NULL", m_opaque_sp.get());
}
return cstr;
}
const char *
SBValue::GetLocation (const SBFrame &sb_frame)
{
return GetLocation ();
}
const char *
SBValue::GetLocation ()
{
const char *cstr = NULL;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
cstr = m_opaque_sp->GetLocationAsCString();
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (cstr)
log->Printf ("SBValue(%p)::GetSummary => \"%s\"", m_opaque_sp.get(), cstr);
else
log->Printf ("SBValue(%p)::GetSummary => NULL", m_opaque_sp.get());
}
return cstr;
}
bool
SBValue::SetValueFromCString (const SBFrame &sb_frame, const char *value_str)
{
return SetValueFromCString (value_str);
}
bool
SBValue::SetValueFromCString (const char *value_str)
{
bool success = false;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
success = m_opaque_sp->SetValueFromCString (value_str);
}
}
return success;
}
lldb::SBValue
SBValue::CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type)
{
lldb::SBValue result;
if (m_opaque_sp)
{
if (type.IsValid())
{
result = SBValue(m_opaque_sp->GetSyntheticChildAtOffset(offset, *type.m_opaque_ap->GetClangASTType(), true));
result.m_opaque_sp->SetName(ConstString(name));
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (result.IsValid())
log->Printf ("SBValue(%p)::GetChildAtOffset => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get());
else
log->Printf ("SBValue(%p)::GetChildAtOffset => NULL", m_opaque_sp.get());
}
return result;
}
lldb::SBValue
SBValue::Cast(const SBType& type)
{
return CreateChildAtOffset(m_opaque_sp->GetName().GetCString(), 0, type);
}
lldb::SBValue
SBValue::CreateValueFromExpression (const char *name, const char* expression)
{
lldb::SBValue result;
if (m_opaque_sp)
{
ValueObjectSP result_valobj_sp;
m_opaque_sp->GetUpdatePoint().GetTargetSP()->EvaluateExpression(expression,
m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame(),
true, true, eNoDynamicValues,
result_valobj_sp);
result_valobj_sp->SetName(ConstString(name));
result = SBValue(result_valobj_sp);
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (result.IsValid())
log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get());
else
log->Printf ("SBValue(%p)::GetChildFromExpression => NULL", m_opaque_sp.get());
}
return result;
}
lldb::SBValue
SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type)
{
lldb::SBValue result;
if (m_opaque_sp)
{
SBType real_type(type.GetPointerType());
lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
ValueObjectSP result_valobj_sp(ValueObjectConstResult::Create(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope(),
real_type.m_opaque_ap->GetASTContext(),
real_type.m_opaque_ap->GetOpaqueQualType(),
ConstString(name),
buffer,
lldb::endian::InlHostByteOrder(),
GetTarget().GetProcess().GetAddressByteSize()));
result_valobj_sp->SetName(ConstString(name));
result = SBValue(result_valobj_sp);
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (result.IsValid())
log->Printf ("SBValue(%p)::GetChildFromAddress => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get());
else
log->Printf ("SBValue(%p)::GetChildFromAddress => NULL", m_opaque_sp.get());
}
return result;
}
SBValue
SBValue::GetChildAtIndex (uint32_t idx)
{
const bool can_create_synthetic = false;
lldb::DynamicValueType use_dynamic = eNoDynamicValues;
if (m_opaque_sp)
use_dynamic = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue();
return GetChildAtIndex (idx, use_dynamic, can_create_synthetic);
}
SBValue
SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic)
{
lldb::ValueObjectSP child_sp;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
const bool can_create = true;
child_sp = m_opaque_sp->GetChildAtIndex (idx, can_create);
if (can_create_synthetic && !child_sp)
{
if (m_opaque_sp->IsPointerType())
{
child_sp = m_opaque_sp->GetSyntheticArrayMemberFromPointer(idx, can_create);
}
else if (m_opaque_sp->IsArrayType())
{
child_sp = m_opaque_sp->GetSyntheticArrayMemberFromArray(idx, can_create);
}
}
if (child_sp)
{
if (use_dynamic != lldb::eNoDynamicValues)
{
lldb::ValueObjectSP dynamic_sp(child_sp->GetDynamicValue (use_dynamic));
if (dynamic_sp)
child_sp = dynamic_sp;
}
}
}
}
SBValue sb_value (child_sp);
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", m_opaque_sp.get(), idx, sb_value.get());
return sb_value;
}
uint32_t
SBValue::GetIndexOfChildWithName (const char *name)
{
uint32_t idx = UINT32_MAX;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name));
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (idx == UINT32_MAX)
log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", m_opaque_sp.get(), name, idx);
else
log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u", m_opaque_sp.get(), name, idx);
}
return idx;
}
SBValue
SBValue::GetChildMemberWithName (const char *name)
{
if (m_opaque_sp)
{
lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue();
return GetChildMemberWithName (name, use_dynamic_value);
}
else
return GetChildMemberWithName (name, eNoDynamicValues);
}
SBValue
SBValue::GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic_value)
{
lldb::ValueObjectSP child_sp;
const ConstString str_name (name);
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true);
if (use_dynamic_value != lldb::eNoDynamicValues)
{
if (child_sp)
{
lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic_value);
if (dynamic_sp)
child_sp = dynamic_sp;
}
}
}
}
SBValue sb_value (child_sp);
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", m_opaque_sp.get(), name, sb_value.get());
return sb_value;
}
lldb::SBValue
SBValue::GetValueForExpressionPath(const char* expr_path)
{
lldb::ValueObjectSP child_sp;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
// using default values for all the fancy options, just do it if you can
child_sp = m_opaque_sp->GetValueForExpressionPath(expr_path);
}
}
SBValue sb_value (child_sp);
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => SBValue(%p)", m_opaque_sp.get(), expr_path, sb_value.get());
return sb_value;
}
uint32_t
SBValue::GetNumChildren ()
{
uint32_t num_children = 0;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
num_children = m_opaque_sp->GetNumChildren();
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetNumChildren () => %u", m_opaque_sp.get(), num_children);
return num_children;
}
SBValue
SBValue::Dereference ()
{
SBValue sb_value;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Error error;
sb_value = m_opaque_sp->Dereference (error);
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", m_opaque_sp.get(), sb_value.get());
return sb_value;
}
bool
SBValue::TypeIsPointerType ()
{
bool is_ptr_type = false;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
is_ptr_type = m_opaque_sp->IsPointerType();
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", m_opaque_sp.get(), is_ptr_type);
return is_ptr_type;
}
void *
SBValue::GetOpaqueType()
{
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
return m_opaque_sp->GetClangType();
}
}
return NULL;
}
lldb::SBTarget
SBValue::GetTarget()
{
SBTarget result;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
result = SBTarget(lldb::TargetSP(m_opaque_sp->GetUpdatePoint().GetTargetSP()));
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (result.get() == NULL)
log->Printf ("SBValue(%p)::GetTarget () => NULL", m_opaque_sp.get());
else
log->Printf ("SBValue(%p)::GetTarget () => %p", m_opaque_sp.get(), result.get());
}
return result;
}
lldb::SBProcess
SBValue::GetProcess()
{
SBProcess result;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
result = SBProcess(lldb::ProcessSP(m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetProcessSP()));
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (result.get() == NULL)
log->Printf ("SBValue(%p)::GetProcess () => NULL", m_opaque_sp.get());
else
log->Printf ("SBValue(%p)::GetProcess () => %p", m_opaque_sp.get(), result.get());
}
return result;
}
lldb::SBThread
SBValue::GetThread()
{
SBThread result;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope())
{
result = SBThread(lldb::ThreadSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateThread()));
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (result.get() == NULL)
log->Printf ("SBValue(%p)::GetThread () => NULL", m_opaque_sp.get());
else
log->Printf ("SBValue(%p)::GetThread () => %p", m_opaque_sp.get(), result.get());
}
return result;
}
lldb::SBFrame
SBValue::GetFrame()
{
SBFrame result;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope())
{
result = SBFrame(lldb::StackFrameSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame()));
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (result.get() == NULL)
log->Printf ("SBValue(%p)::GetFrame () => NULL", m_opaque_sp.get());
else
log->Printf ("SBValue(%p)::GetFrame () => %p", m_opaque_sp.get(), result.get());
}
return result;
}
// Mimic shared pointer...
lldb_private::ValueObject *
SBValue::get() const
{
return m_opaque_sp.get();
}
lldb_private::ValueObject *
SBValue::operator->() const
{
return m_opaque_sp.get();
}
lldb::ValueObjectSP &
SBValue::operator*()
{
return m_opaque_sp;
}
const lldb::ValueObjectSP &
SBValue::operator*() const
{
return m_opaque_sp;
}
bool
SBValue::GetExpressionPath (SBStream &description)
{
if (m_opaque_sp)
{
m_opaque_sp->GetExpressionPath (description.ref(), false);
return true;
}
return false;
}
bool
SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes)
{
if (m_opaque_sp)
{
m_opaque_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes);
return true;
}
return false;
}
bool
SBValue::GetDescription (SBStream &description)
{
if (m_opaque_sp)
{
uint32_t ptr_depth = 0;
uint32_t curr_depth = 0;
uint32_t max_depth = UINT32_MAX;
bool show_types = false;
bool show_location = false;
bool use_objc = false;
lldb::DynamicValueType use_dynamic = eNoDynamicValues;
bool scope_already_checked = false;
bool flat_output = false;
bool use_synthetic = true;
uint32_t no_summary_depth = 0;
ValueObject::DumpValueObject (description.ref(),
m_opaque_sp.get(),
m_opaque_sp->GetName().GetCString(),
ptr_depth,
curr_depth,
max_depth,
show_types, show_location,
use_objc,
use_dynamic,
use_synthetic,
scope_already_checked,
flat_output,
no_summary_depth);
}
else
description.Printf ("No value");
return true;
}
lldb::Format
SBValue::GetFormat () const
{
if (m_opaque_sp)
return m_opaque_sp->GetFormat();
return eFormatDefault;
}
void
SBValue::SetFormat (lldb::Format format)
{
if (m_opaque_sp)
m_opaque_sp->SetFormat(format);
}
lldb::SBValue
SBValue::AddressOf()
{
SBValue sb_value;
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Error error;
sb_value = m_opaque_sp->AddressOf (error);
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetPointerToObject () => SBValue(%p)", m_opaque_sp.get(), sb_value.get());
return sb_value;
}
|