Message ID | 20231020-arm-params-v1-1-19d4c89c11b6@adacore.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 481E7385C6F3 for <patchwork@sourceware.org>; Fri, 20 Oct 2023 19:16:16 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 3A3AA3858C54 for <gdb-patches@sourceware.org>; Fri, 20 Oct 2023 19:16:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A3AA3858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3A3AA3858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697829361; cv=none; b=pnya/MEBmoVKZxwfXkXW25Rhec2mwIVrlwh26RiK/Jh8LSmBZvyuCUn7BKQAOjjAYyD4TixA4bCPja8ao8qdlWRNZte6IViRpEeLDQLBOimNw5NtNXj8kSGy+sSspVcAnOcmZCm6TnW3/wGl7/jXPQcyilJCWa+sFIam5hBI7nw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697829361; c=relaxed/simple; bh=y61SYO00SBeBe4ztV9jVF8KGNBUOpmzLKJTY2QHpEmQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=wFl406UhfgJFTUEYjBvIQmkXSRvtqpPJ9VfkKdkY8Am5vzeeOW0aeTxJAwImVfk8h87u8N5FT7Z8HcfQ3EFt5y4NEtspgtq4bVf8EuGZlvsPip//GA+uE7/zVZE89eH59uqtAtMgBY3kiPU/QrHC+CfL13sTf5ojIcpZpDjG/pI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-35754465cb3so4260495ab.0 for <gdb-patches@sourceware.org>; Fri, 20 Oct 2023 12:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1697829359; x=1698434159; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=uWZM4DVX4kIvbi4O9EnDHwieyiC5vjj1c7sElWpxgLI=; b=TcSFth/ksh1RBrJjYMVhI82OcGZSbJFs8CUfqOg1nP66Bf6ZDwc/fu13VPRDeir/d7 2FqmlhxNKBplGfelU711f99jczCKdve+4FkPQBuLmAoyQ9aj9FGpxbAx2sR2kY681X0A EtDiowCRq4oxd8epp71I/FT/AX437y3Dk9Lhrdh22a0Vi8TU95AUhm0Y8Gr0LLQLbMGL fcQJMUA/EroVtfFzzAo9MfMqlBcybzcZLhaLzo5AhwsJYt9/vpjivZ5WgS7IKlWUh0A+ Xff1T83Ju0vJW5DGqdw3thIodsbY/v3A5HDs0rAHvCoJkuk9EWDIwH6+kkgAom3EfduL o7Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697829359; x=1698434159; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uWZM4DVX4kIvbi4O9EnDHwieyiC5vjj1c7sElWpxgLI=; b=R4ygs6I5qMUw5jZ5x43Uep9DL/5lq19zxoJ4Jq8QJlzSvXKtNShtz/98EppUanD8F8 3eq3QGyR8tvCeP/tw4jmpJbHA1QbeAc8V4Zgu0Ccl6fEXulrhubL49j4kij1AF9Qw8A7 cgBnsDG7zzu34twKEmW512u81J89RCmSh3IkJpEmzSNnUkvYy9nIvT4dcoSpy304wOuZ fzPGbN8YRnNRUpTEyobrDtiqEJYsnpDe4ea8eutnVYP1ps2/KdaeVDLbK7Jx89NnPZeD vA1xp+P3112PG4SQeQXmVfSW+0s/Lo81wq7KdcImilgdlcqlCByRdIlxN59Esa2HTH0/ BwWQ== X-Gm-Message-State: AOJu0Ywbg1yjs5LZclPFbWr/6pFmOdTBoP+ZLiK3ILq1XBZBQ+Y2ztuA nWpUBIM/StfWn+GokE5t36vwcYbiXRk0UwZZao8+8Q== X-Google-Smtp-Source: AGHT+IHfU6JmulqE04i/QOwsnjUUzsX//22k10urAzY/uoV/t9gf5Rj9kcssCF4XNkEpmVH7bSm8mg== X-Received: by 2002:a05:6e02:1ba8:b0:351:4f0c:b95d with SMTP id n8-20020a056e021ba800b003514f0cb95dmr3807084ili.22.1697829359475; Fri, 20 Oct 2023 12:15:59 -0700 (PDT) Received: from localhost.localdomain (97-122-77-73.hlrn.qwest.net. [97.122.77.73]) by smtp.gmail.com with ESMTPSA id q15-20020a0566380ecf00b00430bb70004dsm701765jas.103.2023.10.20.12.15.59 for <gdb-patches@sourceware.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 12:15:59 -0700 (PDT) From: Tom Tromey <tromey@adacore.com> Date: Fri, 20 Oct 2023 13:15:52 -0600 Subject: [PATCH 1/5] Fix calls with small integers on ARM MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231020-arm-params-v1-1-19d4c89c11b6@adacore.com> References: <20231020-arm-params-v1-0-19d4c89c11b6@adacore.com> In-Reply-To: <20231020-arm-params-v1-0-19d4c89c11b6@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org |
Series | ARM function-calling / return fixes | |
Checks
Context | Check | Description |
---|---|---|
linaro-tcwg-bot/tcwg_gdb_build--master-arm | success | Testing passed |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 | success | Testing passed |
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 | success | Testing passed |
linaro-tcwg-bot/tcwg_gdb_check--master-arm | success | Testing passed |
Commit Message
Tom Tromey
Oct. 20, 2023, 7:15 p.m. UTC
On big-endian ARM, an inferior call with a small integer will pass the wrong value. This patch fixes the problem. Because the code here works using scalar values, and not just bytes, left-shifting is unnecessary. --- gdb/arm-tdep.c | 3 --- 1 file changed, 3 deletions(-)
Comments
On 10/20/23 20:15, Tom Tromey wrote: > On big-endian ARM, an inferior call with a small integer will pass the > wrong value. This patch fixes the problem. Because the code here > works using scalar values, and not just bytes, left-shifting is > unnecessary. > --- > gdb/arm-tdep.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c > index a0ad1fb7a82..97d7c5140d2 100644 > --- a/gdb/arm-tdep.c > +++ b/gdb/arm-tdep.c > @@ -4824,9 +4824,6 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, > { > /* The argument is being passed in a general purpose > register. */ > - if (byte_order == BFD_ENDIAN_BIG) > - regval <<= (ARM_INT_REGISTER_SIZE - partial_len) * 8; > - > arm_debug_printf ("arg %d in %s = 0x%s", argnum, > gdbarch_register_name (gdbarch, argreg), > phex (regval, ARM_INT_REGISTER_SIZE)); > Do you have an example failure for the above? Is it a positve or negative integer? The code is meant to adjust padding, as small integers need to be padded/sign-extended when being put in the GPR's. This code has seen many changes over the years, and the padding/extension could've worked then. But looking at it now, it isn't really clear what the left-shifting is supposed to accomplish, as regval should be padded/sign-extended from extract_unsigned_integer.
>>>>> "Luis" == Luis Machado <luis.machado@arm.com> writes: >> @@ -4824,9 +4824,6 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, >> { >> /* The argument is being passed in a general purpose >> register. */ >> - if (byte_order == BFD_ENDIAN_BIG) >> - regval <<= (ARM_INT_REGISTER_SIZE - partial_len) * 8; >> - >> arm_debug_printf ("arg %d in %s = 0x%s", argnum, >> gdbarch_register_name (gdbarch, argreg), >> phex (regval, ARM_INT_REGISTER_SIZE)); >> Luis> Do you have an example failure for the above? Is it a positve or Luis> negative integer? I backed this out and ran the internal tests, and it fails on one Ada-specific test involving fixed-point types -- but also on the internal equivalent of this test from gnu_vector.exp: gdb_test "print add_singlevecs((char1) \{6\}, (int1) \{12\}, (double1) \{24\})" "= \\{42\\}" \ "call add_singlevecs" Luis> But looking at it now, it isn't really clear what the Luis> left-shifting is supposed to accomplish, as regval should be Luis> padded/sign-extended from extract_unsigned_integer. Yeah. Tom
On 10/27/23 19:08, Tom Tromey wrote: >>>>>> "Luis" == Luis Machado <luis.machado@arm.com> writes: > >>> @@ -4824,9 +4824,6 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, >>> { >>> /* The argument is being passed in a general purpose >>> register. */ >>> - if (byte_order == BFD_ENDIAN_BIG) >>> - regval <<= (ARM_INT_REGISTER_SIZE - partial_len) * 8; >>> - >>> arm_debug_printf ("arg %d in %s = 0x%s", argnum, >>> gdbarch_register_name (gdbarch, argreg), >>> phex (regval, ARM_INT_REGISTER_SIZE)); >>> > > Luis> Do you have an example failure for the above? Is it a positve or > Luis> negative integer? > > I backed this out and ran the internal tests, and it fails on one > Ada-specific test involving fixed-point types -- but also on the > internal equivalent of this test from gnu_vector.exp: > > gdb_test "print add_singlevecs((char1) \{6\}, (int1) \{12\}, (double1) \{24\})" "= \\{42\\}" \ > "call add_singlevecs" > > Luis> But looking at it now, it isn't really clear what the > Luis> left-shifting is supposed to accomplish, as regval should be > Luis> padded/sign-extended from extract_unsigned_integer. > > Yeah. > Probably untested BE breakage. This code is really old, and gdb has seen a lot of changes to regcache functions. > Tom Thanks. Approved-By: Luis Machado <luis.machado@arm.com>
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index a0ad1fb7a82..97d7c5140d2 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -4824,9 +4824,6 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { /* The argument is being passed in a general purpose register. */ - if (byte_order == BFD_ENDIAN_BIG) - regval <<= (ARM_INT_REGISTER_SIZE - partial_len) * 8; - arm_debug_printf ("arg %d in %s = 0x%s", argnum, gdbarch_register_name (gdbarch, argreg), phex (regval, ARM_INT_REGISTER_SIZE));