From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YTdaMR4LB2rAHz0AWB0awg (envelope-from ) for ; Fri, 15 May 2026 08:01:34 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VaxTEpGz; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BF6251E0B1; Fri, 15 May 2026 08:01:34 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 158FF1E093 for ; Fri, 15 May 2026 08:01:34 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6943240A1F8E for ; Fri, 15 May 2026 12:01:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6943240A1F8E Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VaxTEpGz Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 0DCD640A1FA1 for ; Fri, 15 May 2026 12:00:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0DCD640A1FA1 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0DCD640A1FA1 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778846418; cv=none; b=fl0gQBA4ndnGt4s5PEAQ6HBCVV2fgGqT49J6NfjkkzFlRD9E5V+G1epPfgSB0qlowUJ5NzpoIvE8QY2gRbPJmSUxhupD5GT40zInAGVsAA2QDUf+wmp9iFIQgkSoKZLyGRVODtHwYS5CWiX5bPzbdRdfme/zG8J9KGBE1YpNsPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778846418; c=relaxed/simple; bh=w3r6+FnB+p/aHUcJpw40F+JOP935syPF3Z4y7nfHi48=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=v9B9HfQZmnIQTn1azibHHKs/KhJTbDXv1x8Gx+7pPoDxe47Df99xiPBM4OWIDiMgQMLWJCqZAHortfrgs+nDax9DMfTIe6MDzkMeglcRYKpdnkX4ltmhT4J3AovxFlcnbt6KQLqJqccoflWoNerhU2oAgj7SLQdf/gn50NtR/Sk= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VaxTEpGz DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DCD640A1FA1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778846417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9+ENgP/AtYP2Yq5x2a/bepW1HP2qlo90dRFqtpSQ+o8=; b=VaxTEpGzqZvoKKXrXQ8nPfgYx/a6tqKd6/wmo/L+pXMGaD5auX5cA+60rh+N5sjF7aiVZY 3mpEvtULPQKqbKW9Zn9u7Ya1kmdLNEHnaGrvwLPv2lvQQJdSoDXVwAYRkneq5GIKWrro3y dsTdEAihxM1mZWnMRUjc6D1ZVglNDi0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-73-fs6RncJHOXyMsYWF2WL6uA-1; Fri, 15 May 2026 08:00:16 -0400 X-MC-Unique: fs6RncJHOXyMsYWF2WL6uA-1 X-Mimecast-MFC-AGG-ID: fs6RncJHOXyMsYWF2WL6uA_1778846415 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-43d789cebcfso590820f8f.1 for ; Fri, 15 May 2026 05:00:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778846415; x=1779451215; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9+ENgP/AtYP2Yq5x2a/bepW1HP2qlo90dRFqtpSQ+o8=; b=a2L6E404+bgExgtsrL80PbgPu/gpXXN7TrxpneGpVdDu3uhaobSwQQIkc57xJg03mp 7+PcFqXeVPpsF4T1M8aTYJ3OylLaxDzSLb/Ob80JtQ3fh/R24a2++ThtdwvMb7/3IOYa 1U7GKTP63/iSsHBupfKDdTHcALOlhyNjFtdVFVwH8AYjhQOI6qJ/jCPTWmbgZbrAJmxe LXvdqXIRP5jqvzGZBQK8LaDxJKjtM1fv9Z5QZh3HSkBEx49eXv/fFXGWLwXltJXhQZN5 PjMkTvs/1WNJpetKI757AyFG1MNXjqbuNZv463vHVanp3AqL2ULLHh/fdj42xB7LIovq tcBQ== X-Gm-Message-State: AOJu0Yy3s8ok9HX4qjzpGo0ohcRxT6zH1H3WIq/bClpchh5w2tKZm3Dm jFwUegFTBe3iQuulg3etV445Xz59cmsaSIryUwQ1vb02KSFaLqaEK16R8/sMKhJYvdVEgV2xH6n kozGS9o9sAX3tgUUz7Fd21TFVZfVOYi3n3OMEVEeftGeuhFUbcGaMhPisYAqP/pibI5XYNvI= X-Gm-Gg: Acq92OEHQRcaZJPeY1IU1FEZikC1kyp/DtwB7hG41lMGecqlz0GUbNSBgXuh2VAVgpF lMGvsWPJ2CEUYenY/XYMc/kItuQC4grycBrrYwU29ZhUhyPjUZ3YQNgkLykUctFjT+aLsVUhFLk Bh9hDG578osWC50tQtBmqs1M2w3z4kGjnhgM6sxZssv3rYvcaoeYjPz/NKqm8BUsmFCKb6EbBF2 2mdTJ/dwNOwS32GNAbFwBx5NYG98VYrD2SiH+E4/iiEpQx1RXpiU81wO7EvitGmKUA/o3eZ7w0w kA+UdzQC7kizGBnD0ZFs1tedtzfYx8kbAhSqR/Vk38V3C1Hmi+xkAT0LQTadiq9fBXScQgvLgDA Q7AWnSlHRqaUH60Wff3NsWIid5Odba5biuiHtG+pEA3o= X-Received: by 2002:a05:600c:a406:b0:489:32b:ac0b with SMTP id 5b1f17b1804b1-48fe4fa1902mr43775195e9.6.1778846414642; Fri, 15 May 2026 05:00:14 -0700 (PDT) X-Received: by 2002:a05:600c:a406:b0:489:32b:ac0b with SMTP id 5b1f17b1804b1-48fe4fa1902mr43774665e9.6.1778846414038; Fri, 15 May 2026 05:00:14 -0700 (PDT) Received: from localhost (92.40.184.80.threembb.co.uk. [92.40.184.80]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da15a562dsm14573220f8f.33.2026.05.15.05.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2026 05:00:13 -0700 (PDT) From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 2/6] gdb: use TARGET_CHAR_BIT more in dwarf2/expr.c In-Reply-To: <87tssbl58d.fsf@tromey.com> References: <7865aefc9044e187b325f71ed2443f1ccf43c30e.1778579473.git.aburgess@redhat.com> <87tssbl58d.fsf@tromey.com> Date: Fri, 15 May 2026 13:00:11 +0100 Message-ID: <87y0hkdgs4.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: SjPq_Hng3-ZJgSvTsjvinyY2sgkNetLhM7jyzEUzhZQ_1778846415 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Tom Tromey writes: >>>>>> "Andrew" == Andrew Burgess writes: > > Andrew> A later commit in this series touches some code in dwarf2/expr.c that > Andrew> used "8 * some_byte_count" to convert to a bit count. It seemed > Andrew> natural to change this to "TARGET_CHAR_BIT * some_byte_count", but > Andrew> when I started looking I realised there's a lot of places in > Andrew> dwarf2/expr.c that use "8" instead of "TARGET_CHAR_BIT". > > Andrew> So I split out this commit to change all of the uses of "8" to > Andrew> "TARGET_CHAR_BIT". I believe everywhere I've changed really is doing > Andrew> conversions between bits and bytes, so this change is appropriate. > > FWIW I think there's a lot more code around using '8' (not your problem > obviously); but more importantly that TARGET_CHAR_BIT can't really be > the correct approach to this problem. > > For TARGET_CHAR_BIT to work, I think we'd instead have to change all > these spots to reference some gdbarch (i.e. in addition to its other > problems, "TARGET" is a misnomer). > > Also, I think some places using TARGET_CHAR_BIT incorrectly mix host and > target side data. > > But, luckily, I also tend to think it's a problem that won't ever need > solving. > > Andrew> if (!check_optimized) > Andrew> copy_bitwise (v_contents, offset, > Andrew> - buffer.data (), bits_to_skip % 8, > Andrew> + buffer.data (), bits_to_skip % TARGET_CHAR_BIT, > Andrew> this_size_bits, bits_big_endian); > > In this situation it seems to me that gdb is manipulating host-side data. Aren't the value contents pulled from the inferior though? And bits_to_skip and this_size_bits are all from DWARF properties that describe the inferior's data, so I don't understand why TARGET_CHAR_BIT wouldn't be correct? I got really confused trying to reason this all through. Maybe the 8-bit byte assumption is just baked into GDB too much? In this case the BUFFER is filled by get_frame_register_bytes. Is this host bytes? Target bytes? Is the '%' here trying to adjust the inferior bits_to_skip so we can index into a host byte buffer? Or express a target bits_to_skip and copy_bitwise will figure out any conversion? Of course copy_bitwise actually just hard-codes '8' everywhere, so the question is mostly pointless. I eventually just decided to drop this patch from the series. There were just 3 lines in the final patch where I wanted to change from '8' to 'TARGET_CHAR_BIT', and in that case I think it's much clearer that TARGET_CHAR_BIT is the correct choice. This patch started as me factoring out those 3 lines, and then thinking: I wonder if there are other places that I could update. But it's now just a distraction from getting the actual fixes into GDB, so I'd rather just get those merged, and return to this another day. Thanks for looking at this series. I've now pushed all the other patches. Thanks, Andrew