From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Y6UdIi6tomrRxTwAWB0awg (envelope-from ) for ; Thu, 10 Sep 2026 09:14:22 -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=JchvnlnE; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 73C521E09E; Thu, 10 Sep 2026 09:14:22 -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 103B21E091 for ; Thu, 10 Sep 2026 09:14:21 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8311D48F60F1 for ; Thu, 10 Sep 2026 13:14:20 +0000 (GMT) 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 4B45448F8A7C for ; Thu, 10 Sep 2026 13:14:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B45448F8A7C 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 4B45448F8A7C 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=1789046048; cv=none; b=fiyEl8gZvKWixHANnQrtjUHJQ8WzrLIb/fGzYruXM4kLkCcTEt4CMe/+IgBh8yAyuX1CyhW5IlsllzdukZXSMwgJKUtWeOjyWZxjHddP+pgahN06q2XfhqNIN4TaT5asW9zmnh6pSC6kGqLZm4qLsg1xfmHk+ZZ36WisKxSJMx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789046048; c=relaxed/simple; bh=J4Vmwjhxz4Vk8SZFkgRmbH7liDjuCsQeXGSPunS68/s=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=fHo5jHlCSCJEGT5KAH/oJ40QP+7Z6F3H+F8gBRY3OQgTJ11NkbaYFlHvvTqZwyqybWMJkKitx4q3JFOgdUo4CPGBh1TPJPJSpXuBl4U2bAEoUgzAXCrS4DtsrtOkeci0XIvoMgz9W4YETTsZh9l97qjVLM1EE5TZKO2/Z3+lL2Y= 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=JchvnlnE DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B45448F8A7C 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=JchvnlnE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789046047; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XZyj7Ht1sw4jiFuVHmfIGk+dmYcEc/rwMUoaBy3ubio=; b=JchvnlnEZwIK4jlXUqUMxSn0Cupqftbh4Pcl/z2M1RJAhwHUuXvJSArS4zzKKPYrBqlb1N j97L+NQolitO43U0VAeHgSi7VWFpOyECvhduXLWT07Kr3O/988SZHIgxZAsXVpJkUbnwdZ 462qibPD4JS7fQEEb5cpUkWuXXV60tE= 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-532-3RYJI_JnO_K3wGZQdYfKaA-1; Thu, 10 Sep 2026 09:14:06 -0400 X-MC-Unique: 3RYJI_JnO_K3wGZQdYfKaA-1 X-Mimecast-MFC-AGG-ID: 3RYJI_JnO_K3wGZQdYfKaA_1789046045 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4858f06e142so4228085f8f.0 for ; Thu, 10 Sep 2026 06:14:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789046045; x=1789650845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=XZyj7Ht1sw4jiFuVHmfIGk+dmYcEc/rwMUoaBy3ubio=; b=gqQr7d43eKq2MjWq2AuOjWFVR6OfKCTioCbkUuTbcYayMebTIAJ9Fu33MyhXjh6tiN DzUxpWDDwmJO1X3X8la/iRjbaneTeOmPNpPSW6vMYTPZTu1Tc7adf4hlLZE+3FDBrd0+ UeeugSYRzqpKQu+XB8UnzsAlno0CXPJJFUfCaE0orQRUqAAwLvVzA4eVHivbpNze/WJN YU10T6s2fEXzKkPr7GJ/nn4gpCjhG/V1VQf1pU5vE2ca6JmRXJaJpacgL00Dkd3T94BT Q1LVDuKeTmIUDx7dP6WAD1zpdgg1fjwpBVfGfhIT5Xpxq8DoAPeHgXHogsWCkvilJ69S u9GQ== X-Gm-Message-State: AFuF++kkBLpRyuvRSYSDFb1BqvNCZBhRJlhXVI6G42rWaO+D9xI9xEVv m6WRml/i3IAnrsidoPcBG/FRR8S+78DUpL+ibNorwF0U7v1VlQ3DQ9+yQhSkMq9YRWudX87kBQg oxdp4Dzu1U8fbRiQAEQDOZYopYAfQfBgpWxh15n3E7b4Z/doIH791zmfk+AsCxsrdh4CsDwCnUR nZO535lTTYrlYpzeThPvhlXn+jGGY7U1r/ia8BtOxF2s4zAA4= X-Gm-Gg: AYBFou24LrzHxa684CEm2/L4FdXVRjy1rJ55FZeUzhRZOwfAeYlbtGG1j3nstjwSm1Q NtKKw9QwxTANmWGFtOY3rBkchkMMTxv2408TqyOmKWgrnqSxJA9ZdWkK9XfVXBGvVYO+kNxeSDz ejhlz6QS+cGBL06wZzCxT4XoJp/7TmENxq7lAnfZFMwbgPjv5LEtgWi54YGfg4KONJ6Lqz8W7FZ c93MbVKfjrDlspFo2fSeRwo1WqywF6VrBjbyrR6bks1yMuVOzUWE4SNnwSgHurSUx2ilA+AUTzV biiXnxOiZ6Z5pTohTHu/fOuhr51ENkhkmQuWb4N6WKZar2UudbBWoPXt/pghwZ5j/unHS4UIEEW cBtVTFtTbJiCoe9z9 X-Received: by 2002:a7b:cb42:0:b0:49c:fa21:e74a with SMTP id 5b1f17b1804b1-49d25925184mr55269115e9.32.1789046044780; Thu, 10 Sep 2026 06:14:04 -0700 (PDT) X-Received: by 2002:a7b:cb42:0:b0:49c:fa21:e74a with SMTP id 5b1f17b1804b1-49d25925184mr55268585e9.32.1789046044262; Thu, 10 Sep 2026 06:14:04 -0700 (PDT) Received: from localhost (59.6.93.209.dyn.plus.net. [209.93.6.59]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-485885b1320sm49682393f8f.27.2026.09.10.06.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 06:14:03 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Tom de Vries , Abhay Kandpal , Andrew Burgess Subject: [PATCH 1/2] gdb: fill in default return types for some inferior function calls Date: Thu, 10 Sep 2026 14:13:52 +0100 Message-Id: <3b7851c296c932da6ddc366810ea6ee9f2f3db6a.1789034019.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: dB8cQHLqOtMysSxzWSLfwoT0yynzPHNarhoe03R5T5A_1789046045 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 After commit: commit 32090b27e92cb8fd4998e8e8e65d43f445545bc7 Date: Wed Sep 2 10:43:34 2026 +0100 gdb: fix incorrect search domain in find_function_in_inferior Bug PR gdb/34602 was created which details some new regressions that were introduced for the tests: gdb.ada/funcall_ref.exp gdb.ada/arrayparam.exp gdb.compile/compile.exp gdb.compile/compile-cplus.exp It appears that there are two different issues here, both caused by the changes in 32090b27e92cb8fd. This commit addresses the issues in the gdb.compile/ tests, the gdb.ada/ tests will be addressed in the next commit in this series. For the gdb.compile/ tests, what's happening is that when GDB calls lookup_symbol, after 32090b27e92cb8fd, a full symbol is now found, however, that symbol lacks full type information. Crucially, the symbol that is found lacks a return type. Prior to commit 32090b27e92cb8fd, lookup_symbol would always fail, so GDB would fall through to the minimal symbol lookup path. On this path GDB supplies some fake type information for any symbol found, specifically, the function is claimed to return 'char'. For the gdb.compile/ tests the problem is caused when munmap_list::~munmap_list calls gdbarch_infcall_munmap, which on Linux, calls linux_infcall_munmap. In linux_infcall_munmap, find_function_in_inferior is called, which now finds a symbol with an unknown return type, then call_function_by_hand is called to invoke the function. Interestingly, call_function_by_hand allows for a default return type to be passed in, but this is not used in this case. Instead we pass NULL, which means that call_function_by_hand will fail if the return type is unknown, which is what happens in this case, and this causes the test failures. Given that the return type for munmap is well defined, I think the fix here is to update the call_function_by_hand call to pass in the known default return type. With this done the gdb.compile/ tests now start passing again. I could have stopped at that point, but I wondered if there were any other places that might benefit from the same fix. I looked for all the call_function_by_hand calls, and updated those places where a trivial libc function was being called, where a default return type was reasonably straight forward. This covered calls to: sbrk, waitpid, fork, mmap, munmap, and malloc. No tests here as this relies on running in an environment where there is insufficient debug information to find the return type for munmap. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34602 --- gdb/gcore.c | 4 +++- gdb/linux-fork.c | 13 +++++++++++-- gdb/linux-tdep.c | 8 ++++++-- gdb/valops.c | 4 +++- 4 files changed, 23 insertions(+), 6 deletions(-) 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 ()) -- 2.25.4