I have a debug build of the program (V8 JavaScript VM), and I want to understand how instances of some classes are laid out in memory. I can beautifully print such structures:
(gdb) print thread_local
$6 = {
blocks_ = {
data_ = 0x868ceb0,
capacity_ = 7,
length_ = 1
},
entered_contexts_ = {
data_ = 0x868d828,
capacity_ = 1,
length_ = 1
},
saved_contexts_ = {
data_ = 0x868d838,
capacity_ = 1,
length_ = 1
},
spare_ = 0x0,
ignore_out_of_memory_ = false,
call_depth_ = 1,
handle_scope_data_ = {
next = 0x0,
limit = 0x0,
level = 0
}
}
but I want to know where these various members (blocks, entered_contexts, etc.) physically refer to the beginning of the object. On Solaris-based systems, mdb can do this for C structures as follows:
> ::print -at port_event_t
0 port_event_t {
0 int portev_events
4 ushort_t portev_source
6 ushort_t portev_pad
8 uintptr_t portev_object
10 void *portev_user
}
In this example, each field has a prefix with its offset from the beginning of the structure. I want to do the same for C ++ classes. gdb must have this information to print out the elements of the structure, but is there any way to view it?
Alternatively, is there another way to do this for the current program?