From patchwork Mon Apr 8 12:04:45 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: 88167 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 DEB5B384640D for ; Mon, 8 Apr 2024 12:05:11 +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 383083858D32 for ; Mon, 8 Apr 2024 12:04:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 383083858D32 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 383083858D32 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=1712577875; cv=none; b=gdWPa7UB21wk7NdPLP/ElZS4vMgQkoyBoV5ftM3LbpBwKAX1YivEJ2XAdhOO6jNyDiNkwGOR5iu+0w/r34kFEP/HKPL7KzSdfwKTcd+fJHOkEFJw9VcYGf3uH8hdICn/u3VuY1DrTgiXdYASLAgbCKTw+HY1W275luaJjinbik8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712577875; c=relaxed/simple; bh=lgZr1tQzqD/r7PtA/Xlfdz0Ytqx/+lLiKB+aXKJp5j4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=SpfF/NsRBaebvT/ixbVg8m2cJl9bXf2mab/IjqiYMd2vFYQ84CaLV5EuSwckhcDtPt4yv8dNkLTJeJKFKUnd9RzHS2epJ9mE3E+FqE1hMq4T1YVsrz51SGECyLQti0giM3YUqPbkdYWFKWcOb5NC6IA93gw0bTWdanQ01Gi+uYQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 4211B20318 for ; Mon, 8 Apr 2024 12:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712577872; 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=8N5yqEK0xproqTteANMkZcfSdoYwkMf5PLIz+2+0HwI=; b=nj4/8B1XJuJ5ikUC7iGk2nmNFdEJaMAXKtMREj8RVsXgxGJzWltHqxBcBzqtABJRveX3xS selGCzyZHppN2csv58+6kJR2ilUnCKd8275S3guxUzT6yTc5Up7IAwTFPDsFhlZT+Vm7AN Tevzrf1c4E+3yknri27CJENzHkRLvAE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712577872; 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=8N5yqEK0xproqTteANMkZcfSdoYwkMf5PLIz+2+0HwI=; b=qwt3byvm0kFtOlR1lDEqYBl1YKJL9jOIS4nVYECCKO3fBdro1tbamZJPZctRGru60400I8 TBaUjN7X8RIf79DA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712577872; 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=8N5yqEK0xproqTteANMkZcfSdoYwkMf5PLIz+2+0HwI=; b=nj4/8B1XJuJ5ikUC7iGk2nmNFdEJaMAXKtMREj8RVsXgxGJzWltHqxBcBzqtABJRveX3xS selGCzyZHppN2csv58+6kJR2ilUnCKd8275S3guxUzT6yTc5Up7IAwTFPDsFhlZT+Vm7AN Tevzrf1c4E+3yknri27CJENzHkRLvAE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712577872; 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=8N5yqEK0xproqTteANMkZcfSdoYwkMf5PLIz+2+0HwI=; b=qwt3byvm0kFtOlR1lDEqYBl1YKJL9jOIS4nVYECCKO3fBdro1tbamZJPZctRGru60400I8 TBaUjN7X8RIf79DA== 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 2B4A81386D for ; Mon, 8 Apr 2024 12:04:32 +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 8DkiCVDdE2a6IQAAD6G6ig (envelope-from ) for ; Mon, 08 Apr 2024 12:04:32 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v2 4/4] [gdb/testsuite] Require DW_LNE_end_sequence Date: Mon, 8 Apr 2024 14:04:45 +0200 Message-Id: <20240408120445.12544-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240408120445.12544-1-tdevries@suse.de> References: <20240408120445.12544-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 X-Spam-Status: No, score=-12.2 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 The dwarf standard requires that every line number program sequence ends with a DW_LNE_end_sequence instruction. Enforce this in the dwarf assembler for the last sequence in a line number program (we have no means to enforce this for earlier sequences), and fix a few test-case that don't have it. Tested on aarch64-linux. PR testsuite/31618 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31618 --- gdb/testsuite/gdb.dwarf2/dw2-noloc.exp | 3 +++ .../gdb.dwarf2/dw2-symtab-includes-lookup.exp | 7 +++++ .../gdb.dwarf2/dw2-symtab-includes.exp | 7 +++++ gdb/testsuite/lib/dwarf.exp | 26 +++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp b/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp index 8c96ab8b0c5..bd74760e29c 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp @@ -203,6 +203,9 @@ Dwarf::assemble $asm_file { line [gdb_get_line_number "main start"] DW_LNS_set_prologue_end DW_LNS_copy + + DW_LNE_set_address $main_end + DW_LNE_end_sequence } } } diff --git a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp index 14bc84882be..96a528498da 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp @@ -50,6 +50,8 @@ Dwarf::assemble $asm_file { declare_labels partial_label lines_label global srcdir subdir srcfile + get_func_info main + cu {} { partial_label: partial_unit { {stmt_list ${lines_label} DW_FORM_sec_offset} @@ -77,7 +79,12 @@ Dwarf::assemble $asm_file { include_dir "${srcdir}/${subdir}" file_name "dw2-symtab-includes.h" 1 program { + DW_LNE_set_address $main_start DW_LNS_advance_line 1 + DW_LNS_copy + + DW_LNE_set_address $main_end + DW_LNE_end_sequence } } } diff --git a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp index 09007f22200..dc4a788bd70 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp @@ -29,6 +29,8 @@ Dwarf::assemble $asm_file { declare_labels partial_label lines_label global srcdir subdir srcfile + get_func_info main + cu {} { partial_label: partial_unit {} { } @@ -49,7 +51,12 @@ Dwarf::assemble $asm_file { include_dir "${srcdir}/${subdir}" file_name "dw2-symtab-includes.h" 1 program { + DW_LNE_set_address $main_start DW_LNS_advance_line 1 + DW_LNS_copy + + DW_LNE_set_address $main_end + DW_LNE_end_sequence } } } diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index 254f88f1055..c694375b534 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -2546,16 +2546,20 @@ namespace eval Dwarf { variable _line_header_end_label variable _line variable _line_address_update + variable _line_program_terminated set _line 1 set _line_address_update 0 + set _line_program_terminated 0 _line_finalize_header proc DW_LNE_set_address {addr} { variable _line_address_update set _line_address_update 1 + variable _line_program_terminated + set _line_program_terminated 0 _op .byte 0 set start [new_label "set_address_start"] set end [new_label "set_address_end"] @@ -2576,6 +2580,8 @@ namespace eval Dwarf { error "Missing address update for end_sequence" } set _line_address_update 0 + variable _line_program_terminated + set _line_program_terminated 1 variable _line _op .byte 0 _op .uleb128 1 @@ -2584,6 +2590,8 @@ namespace eval Dwarf { } proc DW_LNE_user { len opcode } { + variable _line_program_terminated + set _line_program_terminated 0 set DW_LNE_lo_usr 0x80 set DW_LNE_hi_usr 0xff if { $DW_LNE_lo_usr <= $opcode @@ -2605,22 +2613,32 @@ namespace eval Dwarf { error "Missing address update for copy" } set _line_address_update 0 + variable _line_program_terminated + set _line_program_terminated 0 _op .byte 1 } proc DW_LNS_negate_stmt {} { + variable _line_program_terminated + set _line_program_terminated 0 _op .byte 6 } proc DW_LNS_set_prologue_end {} { + variable _line_program_terminated + set _line_program_terminated 0 _op .byte 0x0a } proc DW_LNS_set_epilogue_begin {} { + variable _line_program_terminated + set _line_program_terminated 0 _op .byte 0x0b } proc DW_LNS_advance_pc {offset} { + variable _line_program_terminated + set _line_program_terminated 0 variable _line_address_update set _line_address_update 1 _op .byte 2 @@ -2628,6 +2646,8 @@ namespace eval Dwarf { } proc DW_LNS_advance_line {offset} { + variable _line_program_terminated + set _line_program_terminated 0 variable _line _op .byte 3 _op .sleb128 ${offset} @@ -2650,11 +2670,17 @@ namespace eval Dwarf { } proc DW_LNS_set_file {num} { + variable _line_program_terminated + set _line_program_terminated 0 _op .byte 4 _op .sleb128 ${num} } uplevel $body + + if { $_line_program_terminated == 0 } { + error "Missing end_seq" + } } uplevel $body