From patchwork Fri May 17 10:47:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 90366 Return-Path: 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 71A823849AE6 for ; Fri, 17 May 2024 10:46:33 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 688D13858435 for ; Fri, 17 May 2024 10:46:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 688D13858435 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 688D13858435 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715942766; cv=none; b=CBZ80piC33NrX8EB7yoLPO0t1JL14FilW0SPu/o686598Z+KTvhNWYyMsnTPtnX5CvDPUYw5kBvwy1mZW9mnaE/zksgwUGVyeMGR6Td+tGqioijOVA3x4lA0vIQYcCJu80ECg/PZ6c3I8nsPnGMfxxjQYX7UwqxUCb8OpXoaFE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715942766; c=relaxed/simple; bh=lOnEc6aUAGiNchzxuYCMdxG7gMQiPs1oTktDPYeghno=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=A2xFQNaKEUIaRCnMaEgJcoZy2nJAvlQEAowiZ02kOb9g9ttqNMooKhINvhUNXDqIZQNO/Ndt4lSLuX+Va4Yc4S5iZQAQMLELN9OHZbgK79xoYBANfZrn4dpPskxWGUT3LmBidspNUh04X3rJudyS3O4yiegj5IEBEp3YuRrTyaY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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-out2.suse.de (Postfix) with ESMTPS id 33AA95D265 for ; Fri, 17 May 2024 10:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715942762; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qNDOkzAVEbJwbD8ZBu3x7XQbj2ts6hb139vlkZ37XSY=; b=FhJlttdlf+Dxeqt4h3a47aw5BPZgLDDtPOLdtAmsWDsXDOhltuSJb4b1ZtwOzvK0ul62NP fogNG8URxkFszV9Liw3DM35QDX61nlJmYYALdOm+VJgTIsDmnsKNVbG3miaMp2DZwL+Ygr T8OBuxgjRj9p5vxj8bAMhzYMJtsEI28= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715942762; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qNDOkzAVEbJwbD8ZBu3x7XQbj2ts6hb139vlkZ37XSY=; b=AesG3xXUsJPw5asPRdzL6o+BjSEpu6GDt6iK1wWioQ4nVDW2uEEe/AWzzk+24ZjJ9GnPPS hlmdeWZG4/PrBTCA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=FhJlttdl; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=AesG3xXU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715942762; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qNDOkzAVEbJwbD8ZBu3x7XQbj2ts6hb139vlkZ37XSY=; b=FhJlttdlf+Dxeqt4h3a47aw5BPZgLDDtPOLdtAmsWDsXDOhltuSJb4b1ZtwOzvK0ul62NP fogNG8URxkFszV9Liw3DM35QDX61nlJmYYALdOm+VJgTIsDmnsKNVbG3miaMp2DZwL+Ygr T8OBuxgjRj9p5vxj8bAMhzYMJtsEI28= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715942762; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qNDOkzAVEbJwbD8ZBu3x7XQbj2ts6hb139vlkZ37XSY=; b=AesG3xXUsJPw5asPRdzL6o+BjSEpu6GDt6iK1wWioQ4nVDW2uEEe/AWzzk+24ZjJ9GnPPS hlmdeWZG4/PrBTCA== Received: from imap1.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1DC8013942 for ; Fri, 17 May 2024 10:46:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id NM/vBWo1R2aUJwAAD6G6ig (envelope-from ) for ; Fri, 17 May 2024 10:46:02 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 1/2] [gdb/macro] Ignore in-file macro definition with 0 line complaint for clang Date: Fri, 17 May 2024 12:47:03 +0200 Message-Id: <20240517104704.3477-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 33AA95D265 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_NONE(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, 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+patchwork=sourceware.org@sourceware.org When showing complaints for the exec of test-case gdb.dwarf2/clang-cli-macro.exp, we get: ... $ gdb -q -batch -iex "set complaints 5" clang-cli-macro -ex "p main" During symbol reading: \ debug info gives in-file macro definition with zero line 0: ONE 1 $1 = {int ()} 0x4004b7
... The readelf output for the .debug_macro section looks like: ... Contents of the .debug_macro section: Offset: 0 Version: 5 Offset size: 4 Offset into .debug_line: 0xe3 DW_MACRO_start_file - lineno: 0 filenum: 1 DW_MACRO_define - lineno : 1 macro : TWO 2 DW_MACRO_end_file DW_MACRO_define - lineno : 0 macro : ONE 1 ... The complaint is that the DW_MACRO_define for ONE both: - has lineno 0, so it's predefined or specified on the command line, and - occurs after the first DW_MACRO_start_file. In commit e7e7469e7a3 ("gdb: Fix issue with Clang CLI macros") we've added a workaround to accept this style of .debug_macro section, and gdb.dwarf2/clang-cli-macro.exp is the test-case for the workaround. Given that we've added the workaround, it doesn't make sense to complain. The warning is produced using the following condition in dwarf_decode_macro_bytes: ... if ((line == 0 && !at_commandline) || (line != 0 && at_commandline)) ... using the variable at_commandline which is initially 1, and set to 0 when encountering the first DW_MACRO_start_file. The value of this variable doesn't make sense in the context of a clang-style .debug_macro section. We could try to fix this by changing the value of the variable to fit with the clang-style .debug_macro section, but I don't think it's worth the effort. Simply fix this by for a clang producer opting out of all complaints in the function that use the at_commandline variable in the condition. Tested on x86_64-linux. --- gdb/dwarf2/macro.c | 10 ++++++---- gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) base-commit: 44fc9616c2e74396395f60c9a601317e4c4c4733 diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c index a511d0a3b44..66a40e88d3a 100644 --- a/gdb/dwarf2/macro.c +++ b/gdb/dwarf2/macro.c @@ -546,8 +546,9 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, line, body); break; } - if ((line == 0 && !at_commandline) - || (line != 0 && at_commandline)) + if (((line == 0 && !at_commandline) + || (line != 0 && at_commandline)) + && !producer_is_clang (cu)) complaint (_("debug info gives %s macro %s with %s line %d: %s"), at_commandline ? _("command-line") : _("in-file"), is_define ? _("definition") : _("undefinition"), @@ -648,8 +649,9 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); mac_ptr += bytes_read; - if ((line == 0 && !at_commandline) - || (line != 0 && at_commandline)) + if (((line == 0 && !at_commandline) + || (line != 0 && at_commandline)) + && !producer_is_clang (cu)) complaint (_("debug info gives source %d included " "from %s at %s line %d"), file, at_commandline ? _("command-line") : _("file"), diff --git a/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp b/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp index eafb75ad8d9..fdeaaff5afd 100644 --- a/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp +++ b/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp @@ -85,6 +85,12 @@ if {[prepare_for_testing "failed to prepare" $testfile [list $srcfile $asm_file] return } +set re_result "[string_to_regexp $]$decimal = \[^\r\n\]+" + +with_complaints 5 { + gdb_test "print main" ^$re_result "no complaints" +} + if {![runto_main]} { return } From patchwork Fri May 17 10:47:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 90365 Return-Path: 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 AF46C3849ADE for ; Fri, 17 May 2024 10:46:32 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 657543858415 for ; Fri, 17 May 2024 10:46:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 657543858415 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 657543858415 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715942765; cv=none; b=QseynR8Z700oNKrUDzYjIW6L86PFMGKqTb1b7t3wpHzUH/jUsiMq4jh8gDlCy/JB8MgHJtGE1YqIDd0nt7UT53owZV/PO8GertGzHu9v2BFJOlRaq9yVNa0QeRjxc/9fL5ueRe0zoep+gl3mDaSZsuQQT+hyLTT6ZPeCHaaYlPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715942765; c=relaxed/simple; bh=UYADsNSbGdlDS7iMa41W970IguXM+Nv4FyB9XT7+Te4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=FykB0GGMODmDfG6j03tJVAX1Eg/v/FP/XZgKu6sJVkTsSfwv2ID8jBjbp+NuNdPOyI+ZQRcoJThg8Zw8jHihgTES8Ow+EDnz8/hiklU3cd4aMgyS0OKpAND5zE4kqiceb4WFezn6VTG+gGpVpVr0yGK0nfcHLverortdiBEVNpc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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-out2.suse.de (Postfix) with ESMTPS id 5328A5D266 for ; Fri, 17 May 2024 10:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715942762; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gB47vbdA1/GKKl4ItAeyd6+DcKF2PoFJYzXJ6siow4w=; b=CRJ2L5ftQa0DdMVTkCeAwUq2Waoy6aZQl/UWpdONwUpL7gIYbRbYw9eBSHmMSfb98LO2Zk 33f+jVraK8z/8n7G2QTEMKB/GoMj6BMzAV2Uup4s59l09ZA3GwsFAEpDz+ulpJn9W15wOj X+tsF8S+z9oRQfe7xCybfSOpIfQRKLE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715942762; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gB47vbdA1/GKKl4ItAeyd6+DcKF2PoFJYzXJ6siow4w=; b=aUltqRzKO5KArXtyqBmSW7w+lOXpQh7HCfcDGxGUGRuALbxpHxrkhgxx5QiDPdjEuAetbN glu0IrSxu1dtjIAw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=CRJ2L5ft; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=aUltqRzK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715942762; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gB47vbdA1/GKKl4ItAeyd6+DcKF2PoFJYzXJ6siow4w=; b=CRJ2L5ftQa0DdMVTkCeAwUq2Waoy6aZQl/UWpdONwUpL7gIYbRbYw9eBSHmMSfb98LO2Zk 33f+jVraK8z/8n7G2QTEMKB/GoMj6BMzAV2Uup4s59l09ZA3GwsFAEpDz+ulpJn9W15wOj X+tsF8S+z9oRQfe7xCybfSOpIfQRKLE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715942762; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gB47vbdA1/GKKl4ItAeyd6+DcKF2PoFJYzXJ6siow4w=; b=aUltqRzKO5KArXtyqBmSW7w+lOXpQh7HCfcDGxGUGRuALbxpHxrkhgxx5QiDPdjEuAetbN glu0IrSxu1dtjIAw== Received: from imap1.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3BF8913A69 for ; Fri, 17 May 2024 10:46:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mHU6DWo1R2aUJwAAD6G6ig (envelope-from ) for ; Fri, 17 May 2024 10:46:02 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 2/2] [gdb/macro] Ignore malformed macro definition complaint for clang Date: Fri, 17 May 2024 12:47:04 +0200 Message-Id: <20240517104704.3477-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240517104704.3477-1-tdevries@suse.de> References: <20240517104704.3477-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Action: no action X-Rspamd-Queue-Id: 5328A5D266 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -5.01 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, 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+patchwork=sourceware.org@sourceware.org With test-case test.c: ... #define NOARG int main (void) { return 0; } ... compiled with clang: ... $ clang test.c -g3 -fdebug-macro ... we get a complaint: ... $ gdb -q -batch -iex "set complaints 5" a.out -ex "p main" During symbol reading: macro debug info contains a malformed macro definition: `NOARG' ... and four others from pre-defined defs. This is because the macro body is defined as "NOARG" instead of "NOARG ". There's a comment in parse_macro_definition that describes why the space should be there, quoting the standard. My guess is that this is just a matter of interpretation. Either we have - a name and empty definition, separated by a space, or - a name and no definition, and therefore no space. Anyway, this is long-standing and AFAICT intentional behaviour from clang, and I think it's entirely reasonable, so drop the complaint for clang. Likewise for '#define ARG(V)'. Tested on x86_64-linux. --- gdb/dwarf2/macro.c | 12 +++++++----- gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c index 66a40e88d3a..deaad155bef 100644 --- a/gdb/dwarf2/macro.c +++ b/gdb/dwarf2/macro.c @@ -103,7 +103,7 @@ consume_improper_spaces (const char *p, const char *body) static void parse_macro_definition (struct macro_source_file *file, int line, - const char *body) + const char *body, struct dwarf2_cu *cu) { const char *p; @@ -149,7 +149,8 @@ parse_macro_definition (struct macro_source_file *file, int line, replacement = body + name_len + 1; else { - dwarf2_macro_malformed_definition_complaint (body); + if (!producer_is_clang (cu)) + dwarf2_macro_malformed_definition_complaint (body); replacement = body + name_len; } @@ -213,7 +214,8 @@ parse_macro_definition (struct macro_source_file *file, int line, else if (*p == '\0') { /* Complain, but do define it. */ - dwarf2_macro_malformed_definition_complaint (body); + if (!producer_is_clang (cu)) + dwarf2_macro_malformed_definition_complaint (body); macro_define_function (file, line, name.c_str (), argc, (const char **) argv, p); @@ -569,7 +571,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, line, current_file->filename); } else if (is_define) - parse_macro_definition (current_file, line, body); + parse_macro_definition (current_file, line, body, cu); else { gdb_assert (macinfo_type == DW_MACRO_undef @@ -633,7 +635,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, } if (macinfo_type == DW_MACRO_define_strx) - parse_macro_definition (current_file, line, body); + parse_macro_definition (current_file, line, body, cu); else macro_undef (current_file, line, body); } diff --git a/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp b/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp index fdeaaff5afd..536132f6aa2 100644 --- a/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp +++ b/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp @@ -75,6 +75,8 @@ Dwarf::assemble $asm_file { start_file 0 1 # A macro defined at line 1 of the main file. define 1 "TWO 2" + define 2 "THREE" + define 3 "FOUR(ARG)" end_file define 0 "ONE 1" } @@ -97,3 +99,5 @@ if {![runto_main]} { gdb_test "print TWO" "= 2" "print simple macro" gdb_test "print ONE" "= 1" "print defined from CLI" +gdb_test "info macro THREE" "\r\n#define THREE " +gdb_test "info macro FOUR" "\r\n[string_to_regexp {#define FOUR(ARG) }]"