aboutsummaryrefslogtreecommitdiff
path: root/readline/histlib.h
diff options
context:
space:
mode:
authorWeimin Pan <weimin.pan@oracle.com>2018-10-08 21:16:59 +0000
committerWeimin Pan <weimin.pan@oracle.com>2018-10-08 21:23:50 +0000
commit9f6b697b0efd4ba4e2cb21ac17d2b18a23f81abd (patch)
treec9b6950d1f7a4e1618079b5f27b652523c795e19 /readline/histlib.h
parent780f601cf3bfd2eb141c2ea32b673b5bd0956a33 (diff)
downloadgdb-9f6b697b0efd4ba4e2cb21ac17d2b18a23f81abd.zip
gdb-9f6b697b0efd4ba4e2cb21ac17d2b18a23f81abd.tar.gz
gdb-9f6b697b0efd4ba4e2cb21ac17d2b18a23f81abd.tar.bz2
Finding data member in virtual base class
This patch fixes the original problem - printing member in a virtual base, using various expressions, do not yield the same value. Simple test case below demonstrates the problem: % cat t.cc struct base { int i; }; typedef base tbase; struct derived: virtual tbase { void func() { } }; int main() { derived().func(); } % g++ -g t.cc % gdb a.out (gdb) break derived::func (gdb) run (gdb) p i $1 = 0 (gdb) p base::i $3 = 0 (gdb) p derived::i $4 = 4196392 To fix the problem, add function get_baseclass_offset() which searches recursively for the base class along the class hierarchy. If the base is virtual, it uses "vptr" in virtual class object, which indexes to its derived class's vtable, to get and returns the baseclass offset. If the base is non-virtual, it returns the accumulated offset of its parent classes. The offset is then added to the address of the class object to access its member in value_struct_elt_for_reference().
Diffstat (limited to 'readline/histlib.h')
0 files changed, 0 insertions, 0 deletions