From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 4A4CC3857373 for ; Sat, 7 May 2022 01:23:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4A4CC3857373 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mad-scientist.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mad-scientist.net Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id 8972A100483EA for ; Sat, 7 May 2022 01:23:34 +0000 (UTC) Received: from box5922.bluehost.com ([162.241.30.80]) by cmsmtp with ESMTP id n9AUnmJUokku4n9AUn1fhG; Sat, 07 May 2022 01:23:34 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=ANANYO9+ c=1 sm=1 tr=0 ts=6275ca16 a=u+82WREdhvUKZ7QTvcqjvQ==:117 a=u+82WREdhvUKZ7QTvcqjvQ==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=oZkIemNP1mAA:10:nop_rcvd_month_year a=3EOfIcITIxQA:10:endurance_base64_authed_username_1 a=j2E09x65xsY25WoxqakA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mad-scientist.us; s=default; h=MIME-Version:Content-Transfer-Encoding: Content-Type:Date:To:Reply-To:From:Subject:Message-ID:Sender:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=9xYEgiJd1GxMs8ywGRKVfwE3QPRR/jYJt/4DtbDbjYc=; b=mtLk9LZkOszyuOOSQVo2lE2sHR 9sMike/QB4GB0i65YrcSJ9yUpPf23zuZ5VtZUaIPYHKEDK6SZ1+jgkbasHfoMCAbWoZ69foCxpBxM pSyPqe4c4zKVYJtC/6dgRrnU8; Received: from static-11-191-147-69.axsne.net ([69.147.191.11]:10414 helo=[10.200.244.59]) by box5922.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nn9AT-001uMx-PH for gcc-help@gcc.gnu.org; Fri, 06 May 2022 19:23:33 -0600 Message-ID: <5568db74d0acb198a3e8121ee75e3cfa02ea0c6f.camel@mad-scientist.net> Subject: Help using the GDB C++ STL pretty-printers / xmethods From: Paul Smith Reply-To: paul@mad-scientist.net To: gcc-help@gcc.gnu.org Date: Fri, 06 May 2022 21:23:32 -0400 Organization: Please remain calm--I may be mad but I am a professional! Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.1 (by Flathub.org)) MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5922.bluehost.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mad-scientist.net X-BWhitelist: no X-Source-IP: 69.147.191.11 X-Source-L: No X-Exim-ID: 1nn9AT-001uMx-PH X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: static-11-191-147-69.axsne.net ([10.200.244.59]) [69.147.191.11]:10414 X-Source-Auth: paul@mad-scientist.us X-Email-Count: 1 X-Source-Cap: bWFkc2NpZTE7bWFkc2NpZTE7Ym94NTkyMi5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 May 2022 01:23:37 -0000 Are there any docs or other information about how to use the GDB pretty-printers for C++ STL that come with GCC? I have them installed and they work for displaying data, but they don't work for accessing data. Just as one very simple example, is there a way to dereference a unique_ptr? I see xmethods defined but nothing I've tried works.=20 Suppose I have: (gdb) p $mp->mgr $6 =3D std::unique_ptr =3D { get() =3D 0x7f519a24e000 } (so you can see the pretty-printers are installed). Now, how do I extract out this object pointer so I can see what's in it? These don't work: (gdb) p *$mp->mgr One of the arguments you tried to pass to operator* could not be converted to what the function wants. (gdb) p $mp->mgr->initialized One of the arguments you tried to pass to operator-> could not be converted to what the function wants. It used to work in GCC 10.2 / GDB 10.1 to access the pointer directly if you knew, or deciphered, the internal structor of unique_ptr: (gdb) p $mp->mgr._M_t._M_t._M_head_impl However, with GCC 11.3 / GDB 12.1 this no longer works: I get this error: Request for member '_M_head_impl' is ambiguous in type 'std::tuple >'. Candidates are: 'std::default_delete std::_Head_base<1ul, std::default_delete, true>::_M_head_impl' (std::tuple > -> std::_Tuple_impl<0ul, Mgr*, std::default_delete > -> std::_Tuple_impl<1ul, std::default_delete > -> std::_Head_base<1ul, std::default_delete, true>) ' std::_Head_base<0ul, Mgr*, false>::_M_head_impl' (std::tuple > -> std::_Tuple_impl<0ul, Mgr*, std::default_delete > -> std::_Head_base<0ul, Mgr*, false>) I have found no way to resolve this ambiguity to GDB's satisfaction. The only thing I've found that works is just to access the pointer value directly by cutting and pasting it with a cast: (gdb) p *((Mgr*)0x7f519a24e000) $8 =3D { ... initialized =3D true } (gdb) p ((Mgr*)0x7f519a24e000)->initialized $9 =3D true Is that really what we have to do? Secondly, is there some interface that is defined by the libstdcxx.v6 Python macros for GDB that people who are doing their own python scripting for their own C++ programs can take advantage of to avoid too much groveling through the depths of the C++ STL implementation?