From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B8C8C3858D35; Thu, 25 Nov 2021 18:28:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8C8C3858D35 From: "blarsen at redhat dot com" To: gdb-prs@sourceware.org Subject: [Bug c++/26550] Object of class with virtual base classes printed incorrectly (gdb.cp/ambiguous.exp) Date: Thu, 25 Nov 2021 18:28:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: blarsen at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Nov 2021 18:28:04 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26550 --- Comment #3 from B. Larsen --- After 2 weeks looking at this I know why this is happening, but I haven't figured out how to fix it, so I'm gonna document what I found in case someo= ne can help me out. When GDB is processing the expression "jva1.KV::x", the processing ends up = at structop_member_operation::evaluate, where it gets broken into: * get address of jva1 (addr) * cast JVA1 into KV, and get the offset of x within that class (offset) * get the value of `addr + offset` And the problem lies on that middle part. it happens by calling: 1. expr::unop_addr_operation::evaluate 2. expr::scope_operation::evaluate_for_address 3. value_aggregate_elt 4. value_struct_elt_for_reference and 4. is where the problem happens. When we get there, our "domain type" is already KV, we don't have any idea what the original memory address is, and because KV was contructed through virtual inheritances, the offset for the virtual baseclass A1 needs stuff in the inferior's memory. I brought the stack trace up because my best guess on how to solve the prob= lem would involve changing `class expr::operation` to have a base_addr field, a= nd a method for setting it, so that scope_operation::evaluate_for_address may ac= cess that info, but this does sound like wasted space for every other use case of operations, so I'm reluctant to doing it --=20 You are receiving this mail because: You are on the CC list for the bug.=