From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 5FDCF385781D for ; Tue, 25 May 2021 14:04:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5FDCF385781D Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 14PE3vAA021869 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 May 2021 10:04:01 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 14PE3vAA021869 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id DA1F51E54D; Tue, 25 May 2021 10:03:56 -0400 (EDT) Subject: Re: MI to access value of $ prefixed variable name To: Jonah Graham , GDB Development References: From: Simon Marchi Message-ID: Date: Tue, 25 May 2021 10:03:56 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 25 May 2021 14:03:57 +0000 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2021 14:04:05 -0000 On 2021-05-25 12:35 a.m., Jonah Graham wrote: > Hello, > > I have a user of Eclipse CDT who is having problems displaying a C variable > called $j (dollar sign prefixed variable) - > https://bugs.eclipse.org/bugs/show_bug.cgi?id=573703 > > I understand this is because $ prefixed variables are treated specially by > GDB. > > 47-stack-list-locals --thread 1 --frame 0 1 > 47^done,locals=[{name="$f",value="0"}] > > 52-var-create --thread 1 --frame 0 - * $f > 52^done,name="var3",numchild="0",value="void",type="void",has_more="0" > > Note type "void" above, $f is an int in the C code, but is indeed void (as > expected) in GDB. -stack-list-locals shows the correct value, but I can't > use the returned name back to -var-create because of the naming conflict. > > There wasn't anything I saw in the help ( > https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html) > on this topic. Huh, I didn't know this was possible: https://gcc.gnu.org/onlinedocs/gcc/Dollar-Signs.html#Dollar-Signs I didn't look in depth, but I don't think there's a way to make it work. I don't remember seeing a way to escape that dollar sign. I'd say that the simplest solution would be: don't use dollar sign in identifiers. But if somebody really wants GDB to support it, then they can always send a patch for it (I don't think this is a priority for anyone). Simon