From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id D2D033858402 for ; Wed, 21 Feb 2024 13:27:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D2D033858402 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 D2D033858402 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=1708522078; cv=none; b=hSneL6oWt4p0YvgpYcTeSSnlKU9F1eJ1x+7lJQVD3STJCrdDZGPhexp/Gg2ZeUPMNpyMoX34yEyLd9+7/732c5iiDCCouZkHJn1pOEArp2aAkY7DZyE4rVZaWSzJ72Hxr3g345tLgLkiUIvwnWJ2E8woih5yrQcU3RPWlMoKM6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708522078; c=relaxed/simple; bh=Y43lW6vgUx5SOi0+0Dv5eimoMZ6kWX/B3bYfr45SlmE=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=IyxpPCZHhAFW4Pa99qD6jHSg9FfOrDzFwbmqqM/nspPIvipVIjU1D+YqOK3uUjWivkXMjC0hTAknosUMiU+qnR14er4a1wGzdj8MfEXvlcOqZFTrwQxXjGDiWDQ73YHTQwqzkKq0T3t89JSQyQzudEA17wNgq22iml70Z0VPoZg= 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 CF37D1FB5A for ; Wed, 21 Feb 2024 13:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708522074; 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=1NHGZjHYA0jFIAnivbiJ2eoD4dqbMdHp8mY3Ip/b1d8=; b=ZNsC7pAnO6eOTdsYlotuKeQi0c3tDI0/Xc/7tQCyyut3/gnAXGDTOUd0EL6EudijVbat8A kzNh4I0qarrCAI4gwvRrSErD3KYfLtett2cPbFkwGocPw6hmTUWAxvmaMFyFvobpPJDLeb R1sbVCsLuX/hN/YXoufZZ4+oNT29CO0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708522074; 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=1NHGZjHYA0jFIAnivbiJ2eoD4dqbMdHp8mY3Ip/b1d8=; b=7A/nCcjpY82T3QpZzZCLlImZP+c1AN4qQeeSpmmJ7vBExfEvQS4tF6Woy9RfXM9bg93nIM PNcCyt5g23R8qTCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708522074; 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=1NHGZjHYA0jFIAnivbiJ2eoD4dqbMdHp8mY3Ip/b1d8=; b=ZNsC7pAnO6eOTdsYlotuKeQi0c3tDI0/Xc/7tQCyyut3/gnAXGDTOUd0EL6EudijVbat8A kzNh4I0qarrCAI4gwvRrSErD3KYfLtett2cPbFkwGocPw6hmTUWAxvmaMFyFvobpPJDLeb R1sbVCsLuX/hN/YXoufZZ4+oNT29CO0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708522074; 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=1NHGZjHYA0jFIAnivbiJ2eoD4dqbMdHp8mY3Ip/b1d8=; b=7A/nCcjpY82T3QpZzZCLlImZP+c1AN4qQeeSpmmJ7vBExfEvQS4tF6Woy9RfXM9bg93nIM PNcCyt5g23R8qTCw== 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 BCF16139D0 for ; Wed, 21 Feb 2024 13:27:54 +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 iWOqLFr61WWqcwAAD6G6ig (envelope-from ) for ; Wed, 21 Feb 2024 13:27:54 +0000 Message-ID: Date: Wed, 21 Feb 2024 14:27:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/testsuite] Fix error handling in _dap_read_json Content-Language: en-US From: Tom de Vries To: gdb-patches@sourceware.org References: <20240214162231.26969-1-tdevries@suse.de> In-Reply-To: <20240214162231.26969-1-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Level: Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ZNsC7pAn; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="7A/nCcjp" X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.50 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; 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]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Score: -4.50 X-Rspamd-Queue-Id: CF37D1FB5A 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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2/14/24 17:22, Tom de Vries wrote: > In _dap_read_json we have a gdb_expect with clauses that generate errors: > ... > timeout { > error "timeout reading json header" > } > eof { > error "eof reading json header" > } > ... > > Proc gdb_expect uses dejagnu's remote_expect, which has some peculiar > semantics related to errors: > ... > # remote_expect works basically the same as standard expect, but it > # also takes care of getting the file descriptor from the specified > # host and also calling the timeout/eof/default section if there is an > # error on the expect call. > ..... > > When a timeout triggers, it generates a timeout error, which is reported by > gdb_expect, after which it runs the timeout/eof/default clauses, which > generates an eof error, which is reported by runtest. > > I think the intention here is to generate just a one error, a timeout error. > > Fix this by postponing generating the error until after gdb_expect. > Committed. Thanks, - Tom > Tested on x86_64-linux, by: > - running all the DAP test-cases and observing no regressions, and > - modifying the gdb.dap/eof.exp test-case to trigger a timeout error, and > observing only a timeout error. > > PR testsuite/31382 > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31382 > --- > gdb/testsuite/lib/dap-support.exp | 27 +++++++++++++++++++++++---- > 1 file changed, 23 insertions(+), 4 deletions(-) > > diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp > index 979dfa2cd73..42c1491e507 100644 > --- a/gdb/testsuite/lib/dap-support.exp > +++ b/gdb/testsuite/lib/dap-support.exp > @@ -137,6 +137,8 @@ proc dap_send_request {command {obj {}}} { > # "last_ton" will be set to the TON form of the result. > proc _dap_read_json {} { > set length "" > + set seen_timeout 0 > + set seen_eof 0 > gdb_expect { > -re "^Content-Length: (\[0-9\]+)\r\n" { > set length $expect_out(1,string) > @@ -150,13 +152,20 @@ proc _dap_read_json {} { > # Done. > } > timeout { > - error "timeout reading json header" > + set seen_timeout 1 > } > eof { > - error "eof reading json header" > + set seen_eof 1 > } > } > > + if {$seen_timeout} { > + error "timeout reading json header" > + } > + if {$seen_eof} { > + error "eof reading json header" > + } > + > if {$length == ""} { > error "didn't find content-length" > } > @@ -166,17 +175,27 @@ proc _dap_read_json {} { > # Tcl only allows up to 255 characters in a {} expression in a > # regexp, so we may need to read in chunks. > set this_len [expr {min ($length, 255)}] > + set seen_timeout 0 > + set seen_eof 0 > gdb_expect { > -re "^.{$this_len}" { > append json $expect_out(0,string) > } > timeout { > - error "timeout reading json body" > + set seen_timeout 1 > } > eof { > - error "eof reading json body" > + set seen_eof 1 > } > } > + > + if {$seen_timeout} { > + error "timeout reading json header" > + } > + if {$seen_eof} { > + error "eof reading json header" > + } > + > incr length -$this_len > } > > > base-commit: b235e90e740aa486e6bbe8243eedf109fed41a5c