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 18BC33858004 for ; Sat, 3 Apr 2021 19:39:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 18BC33858004 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 133JdeHc008500 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 3 Apr 2021 15:39:44 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 133JdeHc008500 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) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 87C2A1E789; Sat, 3 Apr 2021 15:39:39 -0400 (EDT) Subject: Re: Remote query for structure layout To: David Blaikie Cc: Tim Newsome , gdb References: <6b00bbbe-1400-7f11-bdcf-811595bf8e31@polymtl.ca> <1c8fec3c-0d7e-d133-bf88-adaf764473f1@polymtl.ca> <4f5e4de2-035d-a1eb-69ef-bb4144ce82de@polymtl.ca> From: Simon Marchi Message-ID: Date: Sat, 3 Apr 2021 15:39:39 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.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 Sat, 3 Apr 2021 19:39:40 +0000 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: Sat, 03 Apr 2021 19:39:48 -0000 On 2021-04-02 6:05 p.m., David Blaikie wrote: > One possibly "cheap" way would be for FreeRTOS to use the structure in > C code to do the register stashing - rather than or in addition to/in > some kind of hybrid manner along with the assembly. If that's not > possible/would make the code harder to understand, then finding some > other way to pin the data structure into the DWARF would be needed. > > I'd be inclined to avoid adding a new attribute or other feature > (though I wouldn't be entirely opposed to it - I can certainly think > of other places where it may be useful to have a "whenever the > compiler sees this type, ensure it makes it into the resulting DWARF > no matter what" attribute) if reasonably possible - instead finding > some lowest-common-denominator/highly reliable signal that compilers > use to emit type information. > > The simplest such signal is a global variable of the type (not a > pointer to it, but of the type itself) - though probably has to be > annotated in some way that ensures the compiler won't optimize the > variable away even under LTO, etc. I'm not sure sure off-hand if I > have a great way to do that portably (non-portably I guess there's > various "exported" attributes that ensure the entity is visible even > beyond the shared library/executable scope, and thus can't be > optimized away - maybe such an attribute would be sufficiently > portable for FreeRTOS's needs (ie: no less portable than the rest of > the code already)). > If such a variable would be problematic (taking up space in the image, > etc) - maybe there's a way to ensure it through an extra nonce > parameter (if it's C++ code, a parameter with a default argument - so > the caller never has to think about it) to some core FreeRTOS function > that won't be optimized away/removed as unused/etc. Again, has a > runtime impact, though - maybe if it was zero-size (like a class > template specialization with no members) & with the type as a template > parameter /maybe/ that would suffice... > > Happy to play around with mechanisms like that if it's of interest. Ok, good to know that the intent is now clear. I have no real opinion on how this is achieved, since I am neither a FreeRTOS, OpenOCD or compiler developer :). Tim, Thomas: as for the GDB implementation part, feel free to send a patch on gdb-patches, even if it's just a prototype. Simon