From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id El4+M4g3oGoOcjcAWB0awg (envelope-from ) for ; Tue, 08 Sep 2026 12:27:52 -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=TXv4mtzl; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A46661E033; Tue, 08 Sep 2026 12:27:52 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.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 autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 C3E2F1E033 for ; Tue, 08 Sep 2026 12:27:50 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EAE2248F90E9 for ; Tue, 8 Sep 2026 16:27:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAE2248F90E9 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=TXv4mtzl Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 7E6214C31896 for ; Tue, 8 Sep 2026 16:27:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E6214C31896 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 7E6214C31896 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788884844; cv=none; b=SUGXHWASUJOwW5At721D9TD7fTprv/7BxJ6fjY4Kz5WKD8CprXOTmL/JQX6u3ZuY5ryUEQgpbT5EWvyy23VrZre9mqDzTSr1tazOPtVtEgA5rAqdDJyq2YwSUqP9pLCT2nfHHCutEtdaYPMZZe4mk2S6fY4CZfyKGvIqYJsF7Mg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788884844; c=relaxed/simple; bh=DDdFHwx96/2o40yymmJSuiSK56FfeB4fBDGOK0VQbiI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=K3XRjJQF/BOcQhTVvHV/M5b873RvsLW6IFrPrwoFbJyfk7k282ZlEI8WHjA6Oxv7Na2TZNbzgWB+yU44Q1/bFkqauEBkaVDviNK1aGVWS0punQyvsp1RGOCGzHWjOj3zW7vTTvBcdmv9FvPWZoHnaE+rkX86OHxd2FHpQ5AwYFk= 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=TXv4mtzl DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E6214C31896 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788884844; 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=zEGh6cHxGbfUl2VwUTrxfVEG9I23MCFVb2yPSwmeQkY=; b=TXv4mtzlCOZ2unCyAw7ywzLxyvUqA0OTkt+Qqp+Z8ycoq6uNwcusEu3tPWXBGQjsob+RS+ PHlsubmxvBw4HZRbx9ppGOOqedQ5miMBrI4YfyWXy6U2HeIsjTsY1w6VfxEl3inGU+F03y 4s5X7ppe6hYxy8rOJp3YN5J0vPeMY0U= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-86-XMj8ayKNPquxx8WVlbOkDg-1; Tue, 08 Sep 2026 12:27:23 -0400 X-MC-Unique: XMj8ayKNPquxx8WVlbOkDg-1 X-Mimecast-MFC-AGG-ID: XMj8ayKNPquxx8WVlbOkDg_1788884842 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-485835753caso3843969f8f.3 for ; Tue, 08 Sep 2026 09:27:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788884842; x=1789489642; h=content-type: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:content-type; bh=zEGh6cHxGbfUl2VwUTrxfVEG9I23MCFVb2yPSwmeQkY=; b=mi/sirPBNSlkjdMU85km9ugwUhGYuSnQKyeyNy+wHAyJ8B7fdMr0BQgDtEi8S6iaNL sbO+c0/JDapA+21ojvJMJx+B0bWkPouMtjLqw6lKImiPn320ZlCS2pJ7pbXZ1d7wLP3N b1/D4vMkG/xH+nOjaWyJVjOglIa83cUjzlnXR6WRYsjHFCjqLELbxR7+40MBvSKwYgym kGU1d5zdh8w0SJI2IhknVDiGjIFNIkImcGoxqCrUgm237E063mL+AJIeUk0QAcOhDmbB ztMzX3xpz6XjInJD4SQdd+VOgiX9lYFpI/WUZRA1IzYPdy2NMlLw+sxGTnzFioxlSwJa Esdg== X-Gm-Message-State: AFuF++nx20iHW+qPSE3CGyqOOGaIrnU746ms48kt0ydzRqNknacy///K qGa2bUskRgi2PyAEmayZu0i3yOpQevs1KlvXF/S5GuUib7EN7OIjPGmvsSsgbyPCPSxohkPpWig sxuw3VT67zJXkAg7kFN55V4FuS8leJXNWPoLLjW78Ep/e3GlnM25YIgKVeRobSAEpDyyVUgw= X-Gm-Gg: AYBFou1I5FyKBwyGTWVU5fmPHFfKShoJiJ4P8z79swerK6bW7WGLHIs96x6FdnVALOu iVw398orxoqhAKg5dhfyc7TjcTFv45Ee9Y4GQ9VE3obo03odi82vF6QZ8y87X6JXVxFcgosr36/ K2xC7qceb1a/DiECjAjXV+jZPLxpS86EIib8FTd1PTJPdjBWP7zcUZMiMh2KURaQYbfOwMXfGs3 LaIAIq5KWTrMSX9tzke7Wkp5jj4sJZgT135uk/U34Mo1BOclt2Ct+w6mh8QvJOqy7N77V00AL0K ixWeKpKeuUE3bqbHeqN7jHM7u9BVO8H7zFROsyl4YViNc3LB9s9Qw4gvEDToqSld1Sp26QL+Gf6 M388fY2OQ90d8zJ5qg9uCEPvKUAU= X-Received: by 2002:a05:6000:2209:b0:485:8a46:7057 with SMTP id ffacd0b85a97d-4858a46719cmr30306096f8f.41.1788884841554; Tue, 08 Sep 2026 09:27:21 -0700 (PDT) X-Received: by 2002:a05:6000:2209:b0:485:8a46:7057 with SMTP id ffacd0b85a97d-4858a46719cmr30306041f8f.41.1788884841027; Tue, 08 Sep 2026 09:27:21 -0700 (PDT) Received: from localhost (246.223.159.143.dyn.plus.net. [143.159.223.246]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-485883c5bc5sm39654684f8f.24.2026.09.08.09.27.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2026 09:27:20 -0700 (PDT) From: Andrew Burgess To: Abhay Kandpal , Tom de Vries , Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb: fix incorrect search domain in find_function_in_inferior In-Reply-To: References: <87zexy13u7.fsf@tromey.com> <87h5k5s5nc.fsf@redhat.com> Date: Tue, 08 Sep 2026 17:27:19 +0100 Message-ID: <874ifzr9nc.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: g6pVUw4u-cZT-7P9AUiiMa0YWDsZRXjko9j1Avm1f84_1788884842 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 Abhay Kandpal writes: > Hi Tom, > > I see two more from the same commit on powerpc64le-linux: > > FAIL: gdb.compile/compile.exp: expect no 5 > FAIL: gdb.compile/compile-cplus.exp: expect 5 > > Bisected to 32090b27e92 as well. I sent the details to the > mailing list yesterday and have also added them to PR 34602. Hi, I've run out of time to continue looking at this today, so I wanted to share what I have currently. I can reproduce the gdb.compile/ failures, and the patch below fixes them. I have not yet reproduced the gdb.ada/ failures, but there are only a couple of malloc related calls from these tests, so I think this is likely a similar issue to the gdb.compile/, just from a different place in GDB. The patch below does (for me) fix gdb.copile/, and I suspect will fix gdb.ada/ too, though this is just a guess. I need to finish writing up the commit message (like I said: ENOTIME), but I'll finish this off tomorrow and post this as a new thread. Before then, if you wanted to test this patch, especially Tom de Vries for the gdb.ada/ regressions, do let me know how you get on. thanks, Andrew -- commit 7e023bcaf91d062ade1f0e34b3292d8a3e6be9a1 Author: Andrew Burgess Date: Tue Sep 8 12:06:26 2026 -0400 [wip] gdb: fill in default return types for some inferior function calls After commit: commit 32090b27e92cb8fd4998e8e8e65d43f445545bc7 Date: Wed Sep 2 10:43:34 2026 +0100 gdb: fix incorrect search domain in find_function_in_inferior Some regressions were reported against the tests: gdb.ada/funcall_ref.exp gdb.ada/arrayparam.exp gdb.compile/compile.exp gdb.compile/compile-cplus.exp I've not been able to reproduce the gdb.ada/* regressions, but I could reproduce the gdb.compile/* failures. In that case what's happening is that we are now finding a full symbol rather than a minimal symbol. However, the full symbol lacks full type information. When we previously took the minimal symbol path through find_function_in_inferior we would create a fake function type for the minimal symbol `char (*) (void)` and use this for calling the minimal symbol. However, the inferior function calls that are causing problems in the gdb.compile/ case are all passing through linux_infcall_munmap in linux-tdep.c. From linux_infcall_munmap we call find_function_in_inferior and then call_function_by_hand. When we call call_function_by_hand we pass NULL as the second argument, the second argument being the default return type. This means that because the full symbol we found lacks a return type call_function_by_hand will throw an error. If instead I updated linux_infcall_munmap to pass a suitable default return type into call_function_by_hand, then GDB can now make the inferior function call, and the gdb.compile/* errors are resolved. TODO: Explain the change the might fix the gdb.ada/* regressions. TODO: Explain the other changes. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34602 diff --git a/gdb/gcore.c b/gdb/gcore.c index e50115370c7..77d915505d1 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -292,7 +292,9 @@ call_target_sbrk (int sbrk_arg) target_sbrk_arg = value_from_longest (builtin_type (gdbarch)->builtin_int, sbrk_arg); gdb_assert (target_sbrk_arg); - ret = call_function_by_hand (sbrk_fn, NULL, target_sbrk_arg); + ret = call_function_by_hand (sbrk_fn, + builtin_type (gdbarch)->builtin_data_ptr, + target_sbrk_arg); if (ret == NULL) return (bfd_vma) 0; diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index a0ff625a41a..e11b29349fc 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -664,7 +664,12 @@ inferior_call_waitpid (ptid_t pptid, int pid) argv[1] = value_from_pointer (builtin_type (gdbarch)->builtin_data_ptr, 0); argv[2] = value_from_longest (builtin_type (gdbarch)->builtin_int, 0); - retv = call_function_by_hand (waitpid_fn, NULL, argv); + /* Use `int` default return type, even though waitpid actually + returns pid_t. This matches ARGV[0] above, which is + similarly of type pid_t, but we treat as `int`. */ + retv = call_function_by_hand (waitpid_fn, + builtin_type (gdbarch)->builtin_int, + argv); if (value_as_long (retv) >= 0) ret = 0; @@ -1007,7 +1012,11 @@ checkpoint_command (const char *args, int from_tty) scoped_restore save_pid = make_scoped_restore (&checkpointing_pid, inferior_ptid.pid ()); - ret = call_function_by_hand (fork_fn, NULL, {}); + /* Use `int` as the default return type even though fork actually + returns pid_t. */ + ret = call_function_by_hand (fork_fn, + builtin_type (gdbarch)->builtin_int, + {}); } if (!ret) /* Probably can't happen. */ diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index e37c400bed1..05ee71fc96f 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -2946,7 +2946,9 @@ linux_infcall_mmap (CORE_ADDR size, unsigned prot) arg[ARG_FD] = value_from_longest (builtin_type (gdbarch)->builtin_int, -1); arg[ARG_OFFSET] = value_from_longest (builtin_type (gdbarch)->builtin_int64, 0); - addr_val = call_function_by_hand (mmap_val, NULL, arg); + addr_val = call_function_by_hand (mmap_val, + builtin_type (gdbarch)->builtin_data_ptr, + arg); retval = value_as_address (addr_val); if (retval == (CORE_ADDR) -1) error (_("Failed inferior mmap call for %s bytes, errno is changed."), @@ -2975,7 +2977,9 @@ linux_infcall_munmap (CORE_ADDR addr, CORE_ADDR size) /* Assuming sizeof (unsigned long) == sizeof (size_t). */ arg[ARG_LENGTH] = value_from_ulongest (builtin_type (gdbarch)->builtin_unsigned_long, size); - retval_val = call_function_by_hand (munmap_val, NULL, arg); + retval_val = call_function_by_hand (munmap_val, + builtin_type (gdbarch)->builtin_int, + arg); retval = value_as_long (retval_val); if (retval != 0) warning (_("Failed inferior munmap call at %s for %s bytes, " diff --git a/gdb/valops.c b/gdb/valops.c index e214342c40d..2ff15de7c68 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -176,7 +176,9 @@ value_allocate_space_in_inferior (int len) struct value *blocklen; blocklen = value_from_longest (builtin_type (gdbarch)->builtin_int, len); - val = call_function_by_hand (val, NULL, blocklen); + val = call_function_by_hand (val, + builtin_type (gdbarch)->builtin_data_ptr, + blocklen); if (value_logical_not (val)) { if (!target_has_execution ())