From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OtpxH26aBmaz1hoAWB0awg (envelope-from ) for ; Fri, 29 Mar 2024 06:39:42 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=emyON+9v; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1FqHOHu+; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 6E8151E0C0; Fri, 29 Mar 2024 06:39:42 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 406BE1E030 for ; Fri, 29 Mar 2024 06:39:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA2823858407 for ; Fri, 29 Mar 2024 10:39:39 +0000 (GMT) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 4F2FC3858D20 for ; Fri, 29 Mar 2024 10:39:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F2FC3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4F2FC3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711708760; cv=none; b=duGy5j1S5UHmfpaQ0HOOXZUniMNYeofJLZzny0ARX+1bhf307KlaNOnqZ5d+FtXO75TLOzkVdUkqmxNtzIIUfh7NGhvcUHQal9uptHFdwGdd4g34YMYc3cm61utgVAnXBxKh3Ne4AeHDRM1NxH/8d8ctjYIpszJKX+ocOZoJ0vM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711708760; c=relaxed/simple; bh=GoyPSZnH+EVyRsKOpWIdwSttgd3fZp5jFIUTqmhEYwU=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version: Subject:To:From; b=XseS8OF+JZ6wnfU9OxPXMs8k2mmW985cOtesQEjDqqxuTII6QAMVumslihVokCGCfEZlRcz21pLE+7LhDynqvWQymErKXSp0UHNsxHqtN8TCDzrZskadrjRzWHReIre1y60xokFr2bT41MgmvrxJGB1V1t/GipvahKZLMNsT2ZQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 42C8034CAA; Fri, 29 Mar 2024 10:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1711708756; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2xTc1pVGs+/iSbMA1wD2zKvpTwh2Sb1asn3aozooT/s=; b=emyON+9vZ2OC6w6L8krKGEhedkmJAq1K68+qzz73l28d3hR8HBUdzSMf5zSJcM1V/6qUzu Ae2jfPZ6+j3Oe7249z9Clo3/TidSJL6hU6DnqeS08Mqrr1uDk3gBbzIoD2DFiYHxVX0m78 d4Zfg4vpWcMMwY8kv3kUu6g/kmfLrh4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1711708756; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2xTc1pVGs+/iSbMA1wD2zKvpTwh2Sb1asn3aozooT/s=; b=1FqHOHu+bkpOVFXprwUCWCHCi9U5tr+H77fZq9epfDcVrJrrQZloeNBthNtLC7Ms/pUfFO LJ9GTFQCKfYCMDCw== Authentication-Results: smtp-out1.suse.de; dkim=none Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 2C6E213A9F; Fri, 29 Mar 2024 10:39:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id JIZxCVSaBmZMJQAAn2gu4w (envelope-from ); Fri, 29 Mar 2024 10:39:16 +0000 Message-ID: <15b697d1-41ce-49ea-96e1-bad47a7796af@suse.de> Date: Fri, 29 Mar 2024 11:39:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] [gdb/tetsuite] Add missing include in gdb.base/ctf-ptype.c To: John Baldwin , gdb-patches@sourceware.org References: <20240327143038.20021-1-tdevries@suse.de> <364a5861-a4a2-47ba-9253-5c564c41ebe3@FreeBSD.org> Content-Language: en-US From: Tom de Vries In-Reply-To: <364a5861-a4a2-47ba-9253-5c564c41ebe3@FreeBSD.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -2.10 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [-2.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MX_GOOD(-0.01)[]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.20)[-0.999]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Level: X-Rspamd-Queue-Id: 42C8034CAA X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org On 3/28/24 18:21, John Baldwin wrote: > On 3/27/24 10:30 AM, Tom de Vries wrote: >> On fedora rawhide, when running test-case gdb.base/ctf-ptype.exp, I get: >> ... >> gdb compile failed, ctf-ptype.c: In function 'main': >> ctf-ptype.c:242:29: error: implicit declaration of function 'malloc' \ >>    [-Wimplicit-function-declaration] >>    242 |   v_char_pointer = (char *) malloc (1); >>        |                             ^~~~~~ >> ctf-ptype.c:1:1: note: include '' or provide a declaration >> of 'malloc' >>    +++ |+#include >>      1 | /* This test program is part of GDB, the GNU debugger. >> ... >> >> Fix this by adding the missing include. >> >> Tested on aarch64-linux. > > Patches 2 and 3 look obvious to me (so Approved-By on this is fine by me) > Hi John, thanks for the reviews. I've committed these two. >> --- >>   gdb/testsuite/gdb.base/ctf-ptype.c | 5 ++--- >>   1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/gdb/testsuite/gdb.base/ctf-ptype.c >> b/gdb/testsuite/gdb.base/ctf-ptype.c >> index 4d2df33c53c..ca347893349 100644 >> --- a/gdb/testsuite/gdb.base/ctf-ptype.c >> +++ b/gdb/testsuite/gdb.base/ctf-ptype.c >> @@ -24,6 +24,8 @@ >>    *    First the basic C types. >>    */ >> +#include >> + >>   #if !defined (__STDC__) && !defined (_AIX) >>   #define signed  /**/ >>   #endif >> @@ -234,9 +236,6 @@ func_type v_func_type; >>   int main () >>   { >> -  /* Ensure that malloc is a pointer type; avoid use of "void" and >> any include files. */ >> -/*  extern char *malloc();*/ >> - > > This certainly seems curious.  Nothing in the commit log for when this > was added > gives any clue to why this comment is here, nor why the prototype is > commented > out.  Other comments later in this function mention limitations of the > linker on > AIX, which makes me wonder how it was tested originally.  Did you > confirm that > the test program compiled contained CTF but not DWARF when the test passed? > I did not, but I've done so now, I tested this on fedora asahi 39, aarch64-linux, and there's no dwarf in the exec, only ctf. My guess of what happened during development of the test-case is: - copy ptype.c to ctf-ptype.c - run into some problem with including stdlib.h - remove the include - anticipate that compilation will fail due to malloc defaulting to int return type, and add comment and declaration - either: - accidentally comment out declaration, or - intentionally comment out declaration, see that compilation actually works because a compiler-builtin declaration is used, rely on it and forget to update the comment to point that out Avoiding void also doesn't make sense, given that the same commit that introduces the comment also introduces void. Anyway, since it was commented out we've been using the gcc builtin prototype which has a void * return type. So, I think reverting to using the include is the right thing to do. It's possible the include was removed in early stages of support in the compiler or gdb where pulling in a header file pulled in unsupported stuff. If there is indeed a problem, it'll pop up and we'll be able to fix it and add a proper comment explaining why we should avoid void or include files. Thanks, - Tom