From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Y46ECCtjYGDdIwAAWB0awg (envelope-from ) for ; Sun, 28 Mar 2021 07:06:19 -0400 Received: by simark.ca (Postfix, from userid 112) id 0F50F1E813; Sun, 28 Mar 2021 07:06:19 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_SIGNED, MAILING_LIST_MULTI,RDNS_DYNAMIC,T_DKIM_INVALID,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DEE911E01F for ; Sun, 28 Mar 2021 07:06:16 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 12AEF3857023; Sun, 28 Mar 2021 11:06:16 +0000 (GMT) Received: from ned.t-8ch.de (ned.t-8ch.de [212.47.237.191]) by sourceware.org (Postfix) with ESMTPS id BF7C33857023 for ; Sun, 28 Mar 2021 11:06:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BF7C33857023 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=t-8ch.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=thomas@t-8ch.de Date: Sun, 28 Mar 2021 13:06:01 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=t-8ch.de; s=mail; t=1616929563; bh=3qPUceiV41GuyvKfIe9F/yhys+yD0Zf8ML6R9X50KIY=; h=Date:From:To:Subject:From; b=ShXkDLGDwFwi0OTgVCi5icIoSK+bBePStXZqAL2S408rQmWEfxXagPzcaaL0KwKfS CApYxPqmwSS/QIyFZ8eMIu8svdml5pnpGvOmfpJTMk1y7KQNc8SSY9eJ7odejv6mmy 6HfmrjUNnnHxSp/2iz7Y6fxdMY1Na6wB5uTkKi5E= From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: gdb@sourceware.org Subject: Remote query for structure layout Message-ID: <0e328e95-5035-4de6-9b44-b83ffab38662@t-8ch.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Jabber-ID: thomas@t-8ch.de X-Accept: text/plain, text/html;q=0.2, text/*;q=0.1 X-Accept-Language: en-us, en;q=0.8, de-de;q=0.7, de;q=0.6 X-PGP-Key: https://t-8ch.de/pubkey.asc X-PGP-Key-Fingerprint: 187EF7CE 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: , Errors-To: gdb-bounces@sourceware.org Sender: "Gdb" Hi everybody, I would like to propose a new command for the remote protocol that can be used to query structure layouts. Essentially a `qSymbol` equivalent for the output of `ptype`. Background: The RTOS-support in OpenOCD has to read in-memory datastructures of the debug target to reconstruct the threading information for GDB. For example for FreeRTOS this is done by first looking up the scheduler datastructure via `qSymbol` and then doing hardcoded pointer arithmetic based on the retrieved symbol addresses. (https://repo.or.cz/openocd.git/blob/HEAD:/src/rtos/FreeRTOS.c#l60) Unfortunately the specific offsets inside the structures can change based on compilation options of FreeRTOS. If GDB could report the information it already has from the debug information (as shown in `ptype /o`) via its remote protocol then the logic in OpenOCD could be more robust. Ideas: While a simple mapping of (structure name, member name) -> (offset) mapping would be enough for my usecase it would probably be better to report more data. * type of a typename (struct, union) * total size of the type * all members of the type including their own type and offsets Example: # request info for type "foo_t" IN qType:666f6f5f74 # "foo_t" is a struct of size 32 and members: # * bar_t bar at offset 0 # * baz_t baz at offset 16 OUT qType:666f6f5f74:struct:32:0;6261725f74;626172,16;62617a5f74;62617a (Or some XML equivalent) Is this something that would fit into gdb? Regards, Thomas