Commit 4aceaad1 authored by PotatoGim's avatar PotatoGim

C++: 가상 테이블 디버깅

parent 8938e170
/*!
* ===========================================================================
* @file test.cxx
* @brief
* @author Ji-Hyeon Gim <potatogim@potatogim.net>
* @date 2015년 09월 04일 14시 13분 03초
* @version 1.0
* @copyright Copyleft (c) 2015, Ji-Hyeon Gim
* @license GNU General Public License v3
* ===========================================================================
*/
#include <iostream>
#pragma pack(1)
struct base1 {
virtual void m1() {}
};
struct base2 {
virtual void m2() {}
};
struct base3 {
virtual void m3() {}
};
struct base4 {
virtual void m4() {}
};
struct base5 {
virtual void m5() {}
};
struct cls1 : base2,base1,base3 {
virtual void c1() {}
};
struct cls2 : base4, base5
{
virtual void c2() {}
};
struct cls : cls1, cls2
{
virtual void m7() {}
};
int
main (int argc, char** argv)
{
std::cout << sizeof(int) << std::endl; // 4
std::cout << sizeof(struct base1) << std::endl; // 8
std::cout << sizeof(struct base2) << std::endl; // 8
std::cout << sizeof(struct base3) << std::endl; // 8
std::cout << sizeof(struct base4) << std::endl; // 8
std::cout << sizeof(struct base5) << std::endl; // 8
std::cout << sizeof(struct cls1) << std::endl; // 16
std::cout << sizeof(struct cls2) << std::endl; // 16
std::cout << sizeof(struct cls) << std::endl; // 16
return 0;
}
Class <anonymous struct>::<anonymous union>
size=4 align=4
base size=4 base align=4
<anonymous struct>::<anonymous union> (0x0x7f5108d7cc00) 0
Class <anonymous struct>
size=8 align=4
base size=8 base align=4
<anonymous struct> (0x0x7f5108d7cba0) 0
Class __locale_struct
size=232 align=8
base size=232 base align=8
__locale_struct (0x0x7f5108d7cc60) 0
Vtable for std::exception
std::exception::_ZTVSt9exception: 5u entries
0 (int (*)(...))0
8 (int (*)(...))0
16 (int (*)(...))std::exception::~exception
24 (int (*)(...))std::exception::~exception
32 (int (*)(...))std::exception::what
Class std::exception
size=8 align=8
base size=8 base align=8
std::exception (0x0x7f5108d7cd20) 0 nearly-empty
vptr=((& std::exception::_ZTVSt9exception) + 16u)
Vtable for std::bad_exception
std::bad_exception::_ZTVSt13bad_exception: 5u entries
0 (int (*)(...))0
8 (int (*)(...))0
16 (int (*)(...))std::bad_exception::~bad_exception
24 (int (*)(...))std::bad_exception::~bad_exception
32 (int (*)(...))std::bad_exception::what
Class std::bad_exception
size=8 align=8
base size=8 base align=8
std::bad_exception (0x0x7f5108dee1a0) 0 nearly-empty
vptr=((& std::bad_exception::_ZTVSt13bad_exception) + 16u)
std::exception (0x0x7f5108d7cd80) 0 nearly-empty
primary-for std::bad_exception (0x0x7f5108dee1a0)
Class std::__true_type
size=1 align=1
base size=0 base align=1
std::__true_type (0x0x7f5108d7cde0) 0 empty
Class std::__false_type
size=1 align=1
base size=0 base align=1
std::__false_type (0x0x7f5108d7ce40) 0 empty
Class std::__truth_type<true>
size=1 align=1
base size=0 base align=1
std::__truth_type<true> (0x0x7f5108d7cf00) 0 empty
Class std::__is_void<void>
size=1 align=1
base size=0 base align=1
std::__is_void<void> (0x0x7f5108779120) 0 empty
Class std::__is_integer<bool>
size=1 align=1
base size=0 base align=1
std::__is_integer<bool> (0x0x7f51087791e0) 0 empty
Class std::__is_integer<char>
size=1 align=1
base size=0 base align=1
std::__is_integer<char> (0x0x7f5108779240) 0 empty
Class std::__is_integer<signed char>
size=1 align=1
base size=0 base align=1
std::__is_integer<signed char> (0x0x7f51087792a0) 0 empty
Class std::__is_integer<unsigned char>
size=1 align=1
base size=0 base align=1
std::__is_integer<unsigned char> (0x0x7f5108779300) 0 empty
Class std::__is_integer<wchar_t>
size=1 align=1
base size=0 base align=1
std::__is_integer<wchar_t> (0x0x7f5108779360) 0 empty
Class std::__is_integer<short int>
size=1 align=1
base size=0 base align=1
std::__is_integer<short int> (0x0x7f51087793c0) 0 empty
Class std::__is_integer<short unsigned int>
size=1 align=1
base size=0 base align=1
std::__is_integer<short unsigned int> (0x0x7f5108779420) 0 empty
Class std::__is_integer<int>
size=1 align=1
base size=0 base align=1
std::__is_integer<int> (0x0x7f5108779480) 0 empty
Class std::__is_integer<unsigned int>
size=1 align=1
base size=0 base align=1
std::__is_integer<unsigned int> (0x0x7f51087794e0) 0 empty
Class std::__is_integer<long int>
size=1 align=1
base size=0 base align=1
std::__is_integer<long int> (0x0x7f5108779540) 0 empty
Class std::__is_integer<long unsigned int>
size=1 align=1
base size=0 base align=1
std::__is_integer<long unsigned int> (0x0x7f51087795a0) 0 empty
Class std::__is_integer<long long int>
size=1 align=1
base size=0 base align=1
std::__is_integer<long long int> (0x0x7f5108779600) 0 empty
Class std::__is_integer<long long unsigned int>
size=1 align=1
base size=0 base align=1
std::__is_integer<long long unsigned int> (0x0x7f5108779660) 0 empty
Class std::__is_integer<__int128>
size=1 align=1
base size=0 base align=1
std::__is_integer<__int128> (0x0x7f51087796c0) 0 empty
Class std::__is_integer<__int128 unsigned>
size=1 align=1
base size=0 base align=1
std::__is_integer<__int128 unsigned> (0x0x7f5108779720) 0 empty
Class std::__is_floating<float>
size=1 align=1
base size=0 base align=1
std::__is_floating<float> (0x0x7f51087797e0) 0 empty
Class std::__is_floating<double>
size=1 align=1
base size=0 base align=1
std::__is_floating<double> (0x0x7f5108779840) 0 empty
Class std::__is_floating<long double>
size=1 align=1
base size=0 base align=1
std::__is_floating<long double> (0x0x7f51087798a0) 0 empty
Class std::__is_char<char>
size=1 align=1
base size=0 base align=1
std::__is_char<char> (0x0x7f5108779ba0) 0 empty
Class std::__is_char<wchar_t>
size=1 align=1
base size=0 base align=1
std::__is_char<wchar_t> (0x0x7f5108779c00) 0 empty
Class std::__is_byte<char>
size=1 align=1
base size=0 base align=1
std::__is_byte<char> (0x0x7f5108779cc0) 0 empty
Class std::__is_byte<signed char>
size=1 align=1
base size=0 base align=1
std::__is_byte<signed char> (0x0x7f5108779d20) 0 empty
Class std::__is_byte<unsigned char>
size=1 align=1
base size=0 base align=1
std::__is_byte<unsigned char> (0x0x7f5108779d80) 0 empty
Class __gnu_cxx::__add_unsigned<char>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__add_unsigned<char> (0x0x7f51087aa060) 0 empty
Class __gnu_cxx::__add_unsigned<signed char>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__add_unsigned<signed char> (0x0x7f51087aa0c0) 0 empty
Class __gnu_cxx::__add_unsigned<short int>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__add_unsigned<short int> (0x0x7f51087aa120) 0 empty
Class __gnu_cxx::__add_unsigned<int>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__add_unsigned<int> (0x0x7f51087aa180) 0 empty
Class __gnu_cxx::__add_unsigned<long int>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__add_unsigned<long int> (0x0x7f51087aa1e0) 0 empty
Class __gnu_cxx::__add_unsigned<long long int>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__add_unsigned<long long int> (0x0x7f51087aa240) 0 empty
Class __gnu_cxx::__remove_unsigned<char>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__remove_unsigned<char> (0x0x7f51087aa300) 0 empty
Class __gnu_cxx::__remove_unsigned<unsigned char>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__remove_unsigned<unsigned char> (0x0x7f51087aa360) 0 empty
Class __gnu_cxx::__remove_unsigned<short unsigned int>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__remove_unsigned<short unsigned int> (0x0x7f51087aa3c0) 0 empty
Class __gnu_cxx::__remove_unsigned<unsigned int>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__remove_unsigned<unsigned int> (0x0x7f51087aa420) 0 empty
Class __gnu_cxx::__remove_unsigned<long unsigned int>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__remove_unsigned<long unsigned int> (0x0x7f51087aa480) 0 empty
Class __gnu_cxx::__remove_unsigned<long long unsigned int>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__remove_unsigned<long long unsigned int> (0x0x7f51087aa4e0) 0 empty
Class std::__is_integer<long double>
size=1 align=1
base size=0 base align=1
std::__is_integer<long double> (0x0x7f51087aa600) 0 empty
Class __gnu_cxx::__promote<long double>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__promote<long double> (0x0x7f51087aa660) 0 empty
Class std::__is_integer<double>
size=1 align=1
base size=0 base align=1
std::__is_integer<double> (0x0x7f51087aa6c0) 0 empty
Class __gnu_cxx::__promote<double>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__promote<double> (0x0x7f51087aa720) 0 empty
Class std::__is_integer<float>
size=1 align=1
base size=0 base align=1
std::__is_integer<float> (0x0x7f51087aa780) 0 empty
Class __gnu_cxx::__promote<float>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__promote<float> (0x0x7f51087aa7e0) 0 empty
Class std::input_iterator_tag
size=1 align=1
base size=0 base align=1
std::input_iterator_tag (0x0x7f51087aaae0) 0 empty
Class std::output_iterator_tag
size=1 align=1
base size=0 base align=1
std::output_iterator_tag (0x0x7f51087aab40) 0 empty
Class std::forward_iterator_tag
size=1 align=1
base size=1 base align=1
std::forward_iterator_tag (0x0x7f5108dee340) 0 empty
std::input_iterator_tag (0x0x7f51087aaba0) 0 empty
Class std::bidirectional_iterator_tag
size=1 align=1
base size=1 base align=1
std::bidirectional_iterator_tag (0x0x7f5108dee3a8) 0 empty
std::forward_iterator_tag (0x0x7f5108dee410) 0 empty
std::input_iterator_tag (0x0x7f51087aac00) 0 empty
Class std::random_access_iterator_tag
size=1 align=1
base size=1 base align=1
std::random_access_iterator_tag (0x0x7f5108dee478) 0 empty
std::bidirectional_iterator_tag (0x0x7f5108dee4e0) 0 empty
std::forward_iterator_tag (0x0x7f5108dee548) 0 empty
std::input_iterator_tag (0x0x7f51087aac60) 0 empty
Class std::iterator<std::output_iterator_tag, void, void, void, void>
size=1 align=1
base size=0 base align=1
std::iterator<std::output_iterator_tag, void, void, void, void> (0x0x7f51087aaf60) 0 empty
Class __gnu_cxx::__ops::_Iter_less_iter
size=1 align=1
base size=0 base align=1
__gnu_cxx::__ops::_Iter_less_iter (0x0x7f5108811180) 0 empty
Class __gnu_cxx::__ops::_Iter_less_val
size=1 align=1
base size=0 base align=1
__gnu_cxx::__ops::_Iter_less_val (0x0x7f51088111e0) 0 empty
Class __gnu_cxx::__ops::_Val_less_iter
size=1 align=1
base size=0 base align=1
__gnu_cxx::__ops::_Val_less_iter (0x0x7f5108811240) 0 empty
Class __gnu_cxx::__ops::_Iter_equal_to_iter
size=1 align=1
base size=0 base align=1
__gnu_cxx::__ops::_Iter_equal_to_iter (0x0x7f51088112a0) 0 empty
Class __gnu_cxx::__ops::_Iter_equal_to_val
size=1 align=1
base size=0 base align=1
__gnu_cxx::__ops::_Iter_equal_to_val (0x0x7f5108811300) 0 empty
Class std::__iter_swap<true>
size=1 align=1
base size=0 base align=1
std::__iter_swap<true> (0x0x7f5108811720) 0 empty
Class std::__copy_move<false, false, std::random_access_iterator_tag>
size=1 align=1
base size=0 base align=1
std::__copy_move<false, false, std::random_access_iterator_tag> (0x0x7f51088118a0) 0 empty
Class std::__copy_move_backward<false, false, std::random_access_iterator_tag>
size=1 align=1
base size=0 base align=1
std::__copy_move_backward<false, false, std::random_access_iterator_tag> (0x0x7f51088119c0) 0 empty
Class std::__equal<true>
size=1 align=1
base size=0 base align=1
std::__equal<true> (0x0x7f5108811ae0) 0 empty
Class std::__lc_rai<std::random_access_iterator_tag, std::random_access_iterator_tag>
size=1 align=1
base size=0 base align=1
std::__lc_rai<std::random_access_iterator_tag, std::random_access_iterator_tag> (0x0x7f5108811ba0) 0 empty
Class std::__lexicographical_compare<true>
size=1 align=1
base size=0 base align=1
std::__lexicographical_compare<true> (0x0x7f5108811c60) 0 empty
Class std::char_traits<char>
size=1 align=1
base size=0 base align=1
std::char_traits<char> (0x0x7f5108811de0) 0 empty
Class std::char_traits<wchar_t>
size=1 align=1
base size=0 base align=1
std::char_traits<wchar_t> (0x0x7f5108811e40) 0 empty
Class lconv
size=96 align=8
base size=96 base align=8
lconv (0x0x7f5108811ea0) 0
Class <anonymous struct>
size=8 align=4
base size=8 base align=4
<anonymous struct> (0x0x7f5108811f00) 0
Class timespec
size=16 align=8
base size=16 base align=8
timespec (0x0x7f5108811f60) 0
Class sched_param
size=4 align=4
base size=4 base align=4
sched_param (0x0x7f5108539000) 0
Class __sched_param
size=4 align=4
base size=4 base align=4
__sched_param (0x0x7f5108539060) 0
Class <anonymous struct>
size=128 align=8
base size=128 base align=8
<anonymous struct> (0x0x7f51085390c0) 0
Class timeval
size=16 align=8
base size=16 base align=8
timeval (0x0x7f5108539120) 0
Class timex
size=208 align=8
base size=208 base align=8
timex (0x0x7f5108539180) 0
Class tm
size=56 align=8
base size=56 base align=8
tm (0x0x7f51085391e0) 0
Class itimerspec
size=32 align=8
base size=32 base align=8
itimerspec (0x0x7f5108539240) 0
Class pthread_attr_t
size=56 align=8
base size=56 base align=8
pthread_attr_t (0x0x7f51085392a0) 0
Class __pthread_internal_list
size=16 align=8
base size=16 base align=8
__pthread_internal_list (0x0x7f5108539300) 0
Class <anonymous union>::__pthread_mutex_s
size=40 align=8
base size=40 base align=8
<anonymous union>::__pthread_mutex_s (0x0x7f51085393c0) 0
Class <anonymous union>
size=40 align=8
base size=40 base align=8
<anonymous union> (0x0x7f5108539360) 0
Class <anonymous union>
size=4 align=4
base size=4 base align=4
<anonymous union> (0x0x7f5108539420) 0
Class <anonymous union>::<anonymous struct>
size=48 align=8
base size=48 base align=8
<anonymous union>::<anonymous struct> (0x0x7f51085394e0) 0
Class <anonymous union>
size=48 align=8
base size=48 base align=8
<anonymous union> (0x0x7f5108539480) 0
Class <anonymous union>
size=4 align=4
base size=4 base align=4
<anonymous union> (0x0x7f5108539540) 0
Class <anonymous union>::<anonymous struct>
size=56 align=8
base size=56 base align=8
<anonymous union>::<anonymous struct> (0x0x7f5108539600) 0
Class <anonymous union>
size=56 align=8
base size=56 base align=8
<anonymous union> (0x0x7f51085395a0) 0
Class <anonymous union>
size=8 align=8
base size=8 base align=8
<anonymous union> (0x0x7f5108539660) 0
Class <anonymous union>
size=32 align=8
base size=32 base align=8
<anonymous union> (0x0x7f51085396c0) 0
Class <anonymous union>
size=4 align=4
base size=4 base align=4
<anonymous union> (0x0x7f5108539720) 0
Class _pthread_cleanup_buffer
size=32 align=8
base size=32 base align=8
_pthread_cleanup_buffer (0x0x7f5108539780) 0
Class <anonymous struct>::<anonymous struct>
size=72 align=8
base size=72 base align=8
<anonymous struct>::<anonymous struct> (0x0x7f5108539840) 0
Class <anonymous struct>
size=104 align=8
base size=104 base align=8
<anonymous struct> (0x0x7f51085397e0) 0
Class __pthread_cleanup_frame
size=24 align=8
base size=24 base align=8
__pthread_cleanup_frame (0x0x7f51085398a0) 0
Class __pthread_cleanup_class
size=24 align=8
base size=24 base align=8
__pthread_cleanup_class (0x0x7f5108539900) 0
Vtable for std::bad_alloc
std::bad_alloc::_ZTVSt9bad_alloc: 5u entries
0 (int (*)(...))0
8 (int (*)(...))0
16 (int (*)(...))std::bad_alloc::~bad_alloc
24 (int (*)(...))std::bad_alloc::~bad_alloc
32 (int (*)(...))std::bad_alloc::what
Class std::bad_alloc
size=8 align=8
base size=8 base align=8
std::bad_alloc (0x0x7f5108dee888) 0 nearly-empty
vptr=((& std::bad_alloc::_ZTVSt9bad_alloc) + 16u)
std::exception (0x0x7f5108539960) 0 nearly-empty
primary-for std::bad_alloc (0x0x7f5108dee888)
Class std::nothrow_t
size=1 align=1
base size=0 base align=1
std::nothrow_t (0x0x7f51085399c0) 0 empty
Class std::allocator<void>
size=1 align=1
base size=0 base align=1
std::allocator<void> (0x0x7f5108539ae0) 0 empty
Class __gnu_cxx::new_allocator<char>
size=1 align=1
base size=0 base align=1
__gnu_cxx::new_allocator<char> (0x0x7f5108539c60) 0 empty
Class std::allocator<char>
size=1 align=1
base size=1 base align=1
std::allocator<char> (0x0x7f5108dee958) 0 empty
__gnu_cxx::new_allocator<char> (0x0x7f5108539cc0) 0 empty
Class __gnu_cxx::new_allocator<wchar_t>
size=1 align=1
base size=0 base align=1
__gnu_cxx::new_allocator<wchar_t> (0x0x7f5108539d20) 0 empty
Class std::allocator<wchar_t>
size=1 align=1
base size=1 base align=1
std::allocator<wchar_t> (0x0x7f5108dee9c0) 0 empty
__gnu_cxx::new_allocator<wchar_t> (0x0x7f5108539d80) 0 empty
Vtable for __cxxabiv1::__forced_unwind
__cxxabiv1::__forced_unwind::_ZTVN10__cxxabiv115__forced_unwindE: 5u entries
0 (int (*)(...))0
8 (int (*)(...))0
16 0u
24 0u
32 (int (*)(...))__cxa_pure_virtual
Class __cxxabiv1::__forced_unwind
size=8 align=8
base size=8 base align=8
__cxxabiv1::__forced_unwind (0x0x7f5108539f60) 0 nearly-empty
vptr=((& __cxxabiv1::__forced_unwind::_ZTVN10__cxxabiv115__forced_unwindE) + 16u)
Class __gnu_cxx::__conditional_type<true, __gnu_cxx::__numeric_traits_integer<int>, __gnu_cxx::__numeric_traits_floating<int> >
size=1 align=1
base size=0 base align=1
__gnu_cxx::__conditional_type<true, __gnu_cxx::__numeric_traits_integer<int>, __gnu_cxx::__numeric_traits_floating<int> > (0x0x7f510869e0c0) 0 empty
Class __gnu_cxx::__numeric_traits_integer<int>
size=1 align=1
base size=0 base align=1
__gnu_cxx::__numeric_traits_integer<int> (0x0x7f510869e120) 0 empty
Class __gnu_cxx::__numeric_traits<int>
size=1 align=1
base size=1 base align=1
__gnu_cxx::__numeric_traits<int> (0x0x7f5108634a28) 0 empty
__gnu_cxx::__numeric_traits_integer<int> (0x0x7f510869e180) 0 empty
Class std::allocator<char>::rebind<char>
size=1 align=1
base size=0 base align=1
std::allocator<char>::rebind<char> (0x0x7f510869e300) 0 empty
Class std::basic_string<char>::_Alloc_hider
size=8 align=8
base size=8 base align=8
std::basic_string<char>::_Alloc_hider (0x0x7f5108634bc8) 0
std::allocator<char> (0x0x7f5108634c30) 0 empty
__gnu_cxx::new_allocator<char> (0x0x7f510869e360) 0 empty
Class std::basic_string<char>
size=8 align=8
base size=8 base align=8
std::basic_string<char> (0x0x7f510869e2a0) 0
Class std::basic_string<char>::_Rep_base
size=24 align=8
base size=24 base align=8
std::basic_string<char>::_Rep_base (0x0x7f510869e3c0) 0
Class std::basic_string<char>::_Rep
size=24 align=8
base size=24 base align=8
std::basic_string<char>::_Rep (0x0x7f5108634c98) 0
std::basic_string<char>::_Rep_base (0x0x7f510869e420) 0
Class std::allocator<wchar_t>::rebind<wchar_t>
size=1 align=1
base size=0 base align=1
std::allocator<wchar_t>::rebind<wchar_t> (0x0x7f510869e4e0) 0 empty
Class std::basic_string<wchar_t>::_Alloc_hider
size=8 align=8
base size=8 base align=8
std::basic_string<wchar_t>::_Alloc_hider (0x0x7f5108634dd0) 0
std::allocator<wchar_t> (0x0x7f5108634e38) 0 empty
__gnu_cxx::new_allocator<wchar_t> (0x0x7f510869e540) 0 empty
Class std::basic_string<wchar_t>
size=8 align=8
base size=8 base align=8
std::basic_string<wchar_t> (0x0x7f510869e480) 0
Class std::basic_string<wchar_t>::_Rep_base
size=24 align=8
base size=24 base align=8
std::basic_string<wchar_t>::_Rep_base (0x0x7f510869e5a0) 0
Class std::allocator<wchar_t>::rebind<char>
size=1 align=1
base size=0 base align=1
std::allocator<wchar_t>::rebind<char> (0x0x7f510869e660) 0 empty
Class std::basic_string<wchar_t>::_Rep
size=24 align=8
base size=24 base align=8
std::basic_string<wchar_t>::_Rep (0x0x7f5108634ea0) 0
std::basic_string<wchar_t>::_Rep_base (0x0x7f510869e600) 0
Class std::locale
size=8 align=8
base size=8 base align=8
std::locale (0x0x7f510869e6c0) 0