1 //===-- CXXFormatterFunctions.h------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_CXXFormatterFunctions_h_
11 #define liblldb_CXXFormatterFunctions_h_
16 #include "lldb/lldb-forward.h"
18 #include "lldb/Core/ConstString.h"
19 #include "lldb/DataFormatters/FormatClasses.h"
20 #include "lldb/DataFormatters/TypeSynthetic.h"
21 #include "lldb/Target/ExecutionContext.h"
22 #include "lldb/Target/ObjCLanguageRuntime.h"
23 #include "lldb/Target/Target.h"
25 #include "clang/AST/ASTContext.h"
27 namespace lldb_private {
31 GetViableFrame (ExecutionContext exe_ctx);
34 ExtractValueFromObjCExpression (ValueObject &valobj,
35 const char* target_type,
40 ExtractSummaryFromObjCExpression (ValueObject &valobj,
41 const char* target_type,
46 CallSelectorOnObject (ValueObject &valobj,
47 const char* return_type,
52 CallSelectorOnObject (ValueObject &valobj,
53 const char* return_type,
58 ExtractIndexFromString (const char* item_name);
64 Char16StringSummaryProvider (ValueObject& valobj, Stream& stream); // char16_t* and unichar*
67 Char32StringSummaryProvider (ValueObject& valobj, Stream& stream); // char32_t*
70 WCharStringSummaryProvider (ValueObject& valobj, Stream& stream); // wchar_t*
73 Char16SummaryProvider (ValueObject& valobj, Stream& stream); // char16_t and unichar
76 Char32SummaryProvider (ValueObject& valobj, Stream& stream); // char32_t
79 WCharSummaryProvider (ValueObject& valobj, Stream& stream); // wchar_t
82 LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::string
85 LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::wstring
88 LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::shared_ptr<> and std::weak_ptr<>
91 ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream);
93 SyntheticChildrenFrontEnd* ObjCClassSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
95 template<bool name_entries>
97 NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream);
100 NSIndexSetSummaryProvider (ValueObject& valobj, Stream& stream);
103 NSArraySummaryProvider (ValueObject& valobj, Stream& stream);
105 template<bool cf_style>
107 NSSetSummaryProvider (ValueObject& valobj, Stream& stream);
109 template<bool needs_at>
111 NSDataSummaryProvider (ValueObject& valobj, Stream& stream);
114 NSNumberSummaryProvider (ValueObject& valobj, Stream& stream);
117 NSNotificationSummaryProvider (ValueObject& valobj, Stream& stream);
120 NSTimeZoneSummaryProvider (ValueObject& valobj, Stream& stream);
123 NSMachPortSummaryProvider (ValueObject& valobj, Stream& stream);
126 CFBagSummaryProvider (ValueObject& valobj, Stream& stream);
129 CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream);
132 CFBitVectorSummaryProvider (ValueObject& valobj, Stream& stream);
135 NSDateSummaryProvider (ValueObject& valobj, Stream& stream);
138 CFAbsoluteTimeSummaryProvider (ValueObject& valobj, Stream& stream);
141 NSBundleSummaryProvider (ValueObject& valobj, Stream& stream);
144 NSStringSummaryProvider (ValueObject& valobj, Stream& stream);
147 NSTaggedString_SummaryProvider (ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream& stream);
150 NSAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream);
153 NSMutableAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream);
156 NSURLSummaryProvider (ValueObject& valobj, Stream& stream);
159 ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream);
161 template <bool is_sel_ptr>
163 ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream);
166 RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream);
169 NSDictionarySummaryProvider<true> (ValueObject&, Stream&) ;
172 NSDictionarySummaryProvider<false> (ValueObject&, Stream&) ;
175 NSDataSummaryProvider<true> (ValueObject&, Stream&) ;
178 NSDataSummaryProvider<false> (ValueObject&, Stream&) ;
181 ObjCSELSummaryProvider<true> (ValueObject&, Stream&);
184 ObjCSELSummaryProvider<false> (ValueObject&, Stream&);
186 SyntheticChildrenFrontEnd* NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
188 class NSDictionaryISyntheticFrontEnd : public SyntheticChildrenFrontEnd
191 struct DataDescriptor_32
196 struct DataDescriptor_64
202 struct DictionaryItemDescriptor
204 lldb::addr_t key_ptr;
205 lldb::addr_t val_ptr;
206 lldb::ValueObjectSP valobj_sp;
210 NSDictionaryISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
213 CalculateNumChildren ();
215 virtual lldb::ValueObjectSP
216 GetChildAtIndex (size_t idx);
222 MightHaveChildren ();
225 GetIndexOfChildWithName (const ConstString &name);
228 ~NSDictionaryISyntheticFrontEnd ();
230 ExecutionContextRef m_exe_ctx_ref;
232 lldb::ByteOrder m_order;
233 DataDescriptor_32 *m_data_32;
234 DataDescriptor_64 *m_data_64;
235 lldb::addr_t m_data_ptr;
236 ClangASTType m_pair_type;
237 std::vector<DictionaryItemDescriptor> m_children;
240 class NSDictionaryMSyntheticFrontEnd : public SyntheticChildrenFrontEnd
243 struct DataDescriptor_32
252 struct DataDescriptor_64
261 struct DictionaryItemDescriptor
263 lldb::addr_t key_ptr;
264 lldb::addr_t val_ptr;
265 lldb::ValueObjectSP valobj_sp;
268 NSDictionaryMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
271 CalculateNumChildren ();
273 virtual lldb::ValueObjectSP
274 GetChildAtIndex (size_t idx);
280 MightHaveChildren ();
283 GetIndexOfChildWithName (const ConstString &name);
286 ~NSDictionaryMSyntheticFrontEnd ();
288 ExecutionContextRef m_exe_ctx_ref;
290 lldb::ByteOrder m_order;
291 DataDescriptor_32 *m_data_32;
292 DataDescriptor_64 *m_data_64;
293 ClangASTType m_pair_type;
294 std::vector<DictionaryItemDescriptor> m_children;
297 class NSDictionaryCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd
300 NSDictionaryCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
303 CalculateNumChildren ();
305 virtual lldb::ValueObjectSP
306 GetChildAtIndex (size_t idx);
312 MightHaveChildren ();
315 GetIndexOfChildWithName (const ConstString &name);
318 ~NSDictionaryCodeRunningSyntheticFrontEnd ();
321 SyntheticChildrenFrontEnd* NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
323 class NSSetISyntheticFrontEnd : public SyntheticChildrenFrontEnd
326 struct DataDescriptor_32
331 struct DataDescriptor_64
337 struct SetItemDescriptor
339 lldb::addr_t item_ptr;
340 lldb::ValueObjectSP valobj_sp;
344 NSSetISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
347 CalculateNumChildren ();
349 virtual lldb::ValueObjectSP
350 GetChildAtIndex (size_t idx);
356 MightHaveChildren ();
359 GetIndexOfChildWithName (const ConstString &name);
362 ~NSSetISyntheticFrontEnd ();
364 ExecutionContextRef m_exe_ctx_ref;
366 DataDescriptor_32 *m_data_32;
367 DataDescriptor_64 *m_data_64;
368 lldb::addr_t m_data_ptr;
369 std::vector<SetItemDescriptor> m_children;
372 class NSOrderedSetSyntheticFrontEnd : public SyntheticChildrenFrontEnd
377 NSOrderedSetSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
380 CalculateNumChildren ();
382 virtual lldb::ValueObjectSP
383 GetChildAtIndex (size_t idx);
389 MightHaveChildren ();
392 GetIndexOfChildWithName (const ConstString &name);
395 ~NSOrderedSetSyntheticFrontEnd ();
398 std::map<uint32_t,lldb::ValueObjectSP> m_children;
401 class NSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd
404 struct DataDescriptor_32
411 struct DataDescriptor_64
418 struct SetItemDescriptor
420 lldb::addr_t item_ptr;
421 lldb::ValueObjectSP valobj_sp;
424 NSSetMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
427 CalculateNumChildren ();
429 virtual lldb::ValueObjectSP
430 GetChildAtIndex (size_t idx);
436 MightHaveChildren ();
439 GetIndexOfChildWithName (const ConstString &name);
442 ~NSSetMSyntheticFrontEnd ();
444 ExecutionContextRef m_exe_ctx_ref;
446 DataDescriptor_32 *m_data_32;
447 DataDescriptor_64 *m_data_64;
448 std::vector<SetItemDescriptor> m_children;
451 class NSSetCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd
454 NSSetCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
457 CalculateNumChildren ();
459 virtual lldb::ValueObjectSP
460 GetChildAtIndex (size_t idx);
466 MightHaveChildren ();
469 GetIndexOfChildWithName (const ConstString &name);
472 ~NSSetCodeRunningSyntheticFrontEnd ();
475 SyntheticChildrenFrontEnd* NSSetSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
477 class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd
480 LibcxxVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
483 CalculateNumChildren ();
485 virtual lldb::ValueObjectSP
486 GetChildAtIndex (size_t idx);
492 MightHaveChildren ();
495 GetIndexOfChildWithName (const ConstString &name);
498 ~LibcxxVectorBoolSyntheticFrontEnd ();
500 ClangASTType m_bool_type;
501 ExecutionContextRef m_exe_ctx_ref;
503 lldb::addr_t m_base_data_address;
504 std::map<size_t,lldb::ValueObjectSP> m_children;
507 SyntheticChildrenFrontEnd* LibcxxVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
510 LibcxxContainerSummaryProvider (ValueObject& valobj, Stream& stream);
512 class LibstdcppVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd
515 LibstdcppVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
518 CalculateNumChildren ();
520 virtual lldb::ValueObjectSP
521 GetChildAtIndex (size_t idx);
527 MightHaveChildren ();
530 GetIndexOfChildWithName (const ConstString &name);
533 ~LibstdcppVectorBoolSyntheticFrontEnd ();
535 ExecutionContextRef m_exe_ctx_ref;
537 lldb::addr_t m_base_data_address;
538 EvaluateExpressionOptions m_options;
541 SyntheticChildrenFrontEnd* LibstdcppVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
543 class LibstdcppMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
546 LibstdcppMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
549 CalculateNumChildren ();
551 virtual lldb::ValueObjectSP
552 GetChildAtIndex (size_t idx);
558 MightHaveChildren ();
561 GetIndexOfChildWithName (const ConstString &name);
564 ~LibstdcppMapIteratorSyntheticFrontEnd ();
566 ExecutionContextRef m_exe_ctx_ref;
567 lldb::addr_t m_pair_address;
568 ClangASTType m_pair_type;
569 EvaluateExpressionOptions m_options;
570 lldb::ValueObjectSP m_pair_sp;
573 SyntheticChildrenFrontEnd* LibstdcppMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
575 class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
578 LibCxxMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
581 CalculateNumChildren ();
583 virtual lldb::ValueObjectSP
584 GetChildAtIndex (size_t idx);
590 MightHaveChildren ();
593 GetIndexOfChildWithName (const ConstString &name);
596 ~LibCxxMapIteratorSyntheticFrontEnd ();
598 ValueObject *m_pair_ptr;
601 SyntheticChildrenFrontEnd* LibCxxMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
603 class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
606 VectorIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp,
607 ConstString item_name);
610 CalculateNumChildren ();
612 virtual lldb::ValueObjectSP
613 GetChildAtIndex (size_t idx);
619 MightHaveChildren ();
622 GetIndexOfChildWithName (const ConstString &name);
625 ~VectorIteratorSyntheticFrontEnd ();
627 ExecutionContextRef m_exe_ctx_ref;
628 ConstString m_item_name;
629 lldb::ValueObjectSP m_item_sp;
632 SyntheticChildrenFrontEnd* LibCxxVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
634 SyntheticChildrenFrontEnd* LibStdcppVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
636 class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd
639 LibcxxSharedPtrSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
642 CalculateNumChildren ();
644 virtual lldb::ValueObjectSP
645 GetChildAtIndex (size_t idx);
651 MightHaveChildren ();
654 GetIndexOfChildWithName (const ConstString &name);
657 ~LibcxxSharedPtrSyntheticFrontEnd ();
659 ValueObject* m_cntrl;
660 lldb::ValueObjectSP m_count_sp;
661 lldb::ValueObjectSP m_weak_count_sp;
663 lldb::ByteOrder m_byte_order;
666 SyntheticChildrenFrontEnd* LibcxxSharedPtrSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
668 class LibcxxStdVectorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
671 LibcxxStdVectorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
674 CalculateNumChildren ();
676 virtual lldb::ValueObjectSP
677 GetChildAtIndex (size_t idx);
683 MightHaveChildren ();
686 GetIndexOfChildWithName (const ConstString &name);
689 ~LibcxxStdVectorSyntheticFrontEnd ();
691 ValueObject* m_start;
692 ValueObject* m_finish;
693 ClangASTType m_element_type;
694 uint32_t m_element_size;
695 std::map<size_t,lldb::ValueObjectSP> m_children;
698 SyntheticChildrenFrontEnd* LibcxxStdVectorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
700 class LibcxxStdListSyntheticFrontEnd : public SyntheticChildrenFrontEnd
703 LibcxxStdListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
706 CalculateNumChildren ();
708 virtual lldb::ValueObjectSP
709 GetChildAtIndex (size_t idx);
715 MightHaveChildren ();
718 GetIndexOfChildWithName (const ConstString &name);
721 ~LibcxxStdListSyntheticFrontEnd ();
726 size_t m_list_capping_size;
727 static const bool g_use_loop_detect = true;
728 lldb::addr_t m_node_address;
731 ClangASTType m_element_type;
733 std::map<size_t,lldb::ValueObjectSP> m_children;
736 SyntheticChildrenFrontEnd* LibcxxStdListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
738 class LibcxxStdMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd
741 LibcxxStdMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
744 CalculateNumChildren ();
746 virtual lldb::ValueObjectSP
747 GetChildAtIndex (size_t idx);
753 MightHaveChildren ();
756 GetIndexOfChildWithName (const ConstString &name);
759 ~LibcxxStdMapSyntheticFrontEnd ();
765 GetValueOffset (const lldb::ValueObjectSP& node);
768 ValueObject* m_root_node;
769 ClangASTType m_element_type;
770 uint32_t m_skip_size;
772 std::map<size_t,lldb::ValueObjectSP> m_children;
775 SyntheticChildrenFrontEnd* LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
777 class LibcxxStdUnorderedMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd
780 LibcxxStdUnorderedMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
783 CalculateNumChildren ();
785 virtual lldb::ValueObjectSP
786 GetChildAtIndex (size_t idx);
792 MightHaveChildren ();
795 GetIndexOfChildWithName (const ConstString &name);
798 ~LibcxxStdUnorderedMapSyntheticFrontEnd ();
802 size_t m_num_elements;
803 ValueObject* m_next_element;
804 std::map<size_t,lldb::ValueObjectSP> m_children;
805 std::vector<std::pair<ValueObject*, uint64_t> > m_elements_cache;
808 SyntheticChildrenFrontEnd* LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
810 } // namespace formatters
811 } // namespace lldb_private
813 #endif // liblldb_CXXFormatterFunctions_h_