From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24625 invoked by alias); 28 Sep 2013 16:23:25 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 24613 invoked by uid 89); 28 Sep 2013 16:23:24 -0000 Received: from mail-oa0-f42.google.com (HELO mail-oa0-f42.google.com) (209.85.219.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 28 Sep 2013 16:23:24 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,NO_RELAYS autolearn=no version=3.3.2 X-HELO: mail-oa0-f42.google.com Received: by mail-oa0-f42.google.com with SMTP id g12so2905415oah.15 for ; Sat, 28 Sep 2013 09:23:22 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.52.244 with SMTP id w20mr11315046oeo.30.1380385402263; Sat, 28 Sep 2013 09:23:22 -0700 (PDT) Received: by 10.60.45.207 with HTTP; Sat, 28 Sep 2013 09:23:22 -0700 (PDT) Date: Sat, 28 Sep 2013 16:23:00 -0000 Message-ID: Subject: Could GDB get offset of a field in virtual base class through NULL pointer From: hex To: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-SW-Source: 2013-09/txt/msg00030.txt.bz2 Hi All, I defined two classes as following: // test.cpp class A{ public: int a; }; class B: public virtual A{ public: int b; }; GDB could print &(((B *)0)->a), but it could not print &(((B *)0)->a). I debugged GDB, and found it try to visit the virtual table of (B *)0, then it failed. It is reasonable. But I think whether GDB could support this case, it could just regard the NULL pointer as a special case: it could get offset using TYPE_BASECLASS_BITPOS(). But the TYPE_BASECLASS_BITPOS() returns 0 now because we have not set a value for virtual base class. Then problem is whether we could store an offset for virtual base class to support above case. But I do not know how to get this offset from sections of its binary. Could you give some suggestions please? Thank you!