| 673 | |
| 674 | template <typename T> |
| 675 | std::string |
| 676 | viewFormat(T const &t, uintptr_t _base_addr = 0, int _full_size = ext::sizeOf<T>()) |
| 677 | { |
| 678 | using namespace std; |
| 679 | stringstream ss; |
| 680 | if (_base_addr == 0) { |
| 681 | _base_addr = uintptr_t(&t); |
| 682 | } |
| 683 | int super_size = 0; |
| 684 | if constexpr (has_super_type<T>::value) { |
| 685 | ss << viewFormat<typename T::super_type>(t, _base_addr, _full_size); |
| 686 | super_size += sizeof(typename T::super_type); |
| 687 | } |
| 688 | |
| 689 | if constexpr (is_base_of<Extendible<T>, T>::value) { |
| 690 | Extendible<T> const *e = &t; |
| 691 | int ptr_start = uintptr_t(e) + Extendible<T>::getLocOffset() - _base_addr; |
| 692 | int ptr_end = ptr_start + sizeof(typename Extendible<T>::short_ptr_t); |
| 693 | int ext_start = e->getBegin() - _base_addr; |
| 694 | int ext_end = Extendible<T>::schema.fullSize(ext_start); |
| 695 | |
| 696 | ink_assert(ptr_end <= ext_start); |
| 697 | ink_assert(ext_end <= _full_size); |
| 698 | |
| 699 | ss << endl << setw(30) << typeid(T).name() << " | EXT | " << setw(5) << ext_end - ext_start << "b |"; |
| 700 | ss << string(ptr_start, '_').c_str(); |
| 701 | ss << string(ptr_end - ptr_start, '#').c_str(); |
| 702 | ss << string(ext_start - ptr_end, '_').c_str(); |
| 703 | ss << string(ext_end - ext_start, '#').c_str(); |
| 704 | ss << string(_full_size - ext_end, '_').c_str(); |
| 705 | |
| 706 | super_size += sizeof(Extendible<T>); |
| 707 | } |
| 708 | |
| 709 | int super_start = uintptr_t(&t) - _base_addr; |
| 710 | int member_start = super_start + super_size; |
| 711 | int member_end = super_start + sizeof(T); |
| 712 | |
| 713 | ink_assert(member_start <= member_end); |
| 714 | ink_assert(member_end <= _full_size); |
| 715 | |
| 716 | ss << endl << setw(30) << typeid(T).name() << " | BASE | " << setw(5) << sizeof(T) - super_size << "b |"; |
| 717 | ss << string(super_start, '_').c_str(); |
| 718 | ss << string(member_start - super_start, '_').c_str(); |
| 719 | ss << string(member_end - member_start, '#').c_str(); |
| 720 | ss << string(_full_size - member_end, '_').c_str(); |
| 721 | |
| 722 | return ss.str(); |
| 723 | } |
| 724 | |
| 725 | namespace details |
| 726 | { |