From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id 07E2A3858D38 for ; Thu, 28 Dec 2023 19:12:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 07E2A3858D38 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 07E2A3858D38 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2610:1c1:1:606c::19:2 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1703790755; cv=pass; b=s44JYswhVoDQTmNHyYEn3H9tq1PhSu0F41yhVZqHb8qW4va05FI9exWEltKSo09Y/0alYxDrFifBPT0PhPgzvM+zfbq1rb9wka4gGmq9HyqHY31QOvcXUK1CA3NjK9ujbels8j+zzDJFlg/njhZeZa2FhOpvg0AQ8BuYEwWXSZQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1703790755; c=relaxed/simple; bh=Fs+Chza8S2rEQhLTJtqZDruUXmerFdF2oPMijkhqZJM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=P0IoC1QUT4ziIiMv0HunqzSq1ge+7iqKiOQnrUKTfQStFqk5rwHITwCTrJahcnPwbMtMy7hitcCJXbAEp66qULJHGzWoI6UUrj9aYTHiJzIeZfLq8dkvb1nVky9UZQ5T362dEt8EUgrjGhqdGR0SPQ0foOd0iuDe8Z/p/BLwQ3E= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4T1J6l6JRVz3NDT; Thu, 28 Dec 2023 19:12:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T1J6l5Xxbz4Nls; Thu, 28 Dec 2023 19:12:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703790751; h=from:from:reply-to:subject:subject: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=dW79/P6iqkiSdYeT9HZfGedQwVOWGFAIdN+jOxnp02o=; b=AagIS4GF9lsyONfOLMHckm8YlYUEzeO8B6uUBbyCI74vH6+MnFRJSA/PWIKYzwc1zu1k/h sE0ip1BCYUud5dau7tBloQvucwNmIlMg2OYNd2IBUEpV3l6TLlkqWmEi3ud46/p+elF7cj 0oeAQ2BdSITDWNGja8YYZ/ifn+4eqGRR0XAabGDfGuzkYbM125MdtyKk/fjfIijSeMWWma /p5dh4voH4cycovShbLZf+0tHCOcXKOoY+fruuGpW4/9sdz5zXXU/CoyigkyFojsb3Lz9L bAxsvi0xvEjCFMX8mnijmfvwH+G7SWVNQaCuaqEOCphDOXTBTRG8tc52U7qDWw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703790751; a=rsa-sha256; cv=none; b=UsZP0+sOfzSgcQHTnYIkvx6VBWsh1xIVqY9ARuhtP78sByED9xy+Q4xBPityl3UisoI1r0 GcLFBdv2Aq1BU4jZXeyeVTv2m1g9juXCIyLcIA6SEnXr5dUyskjXlN4rhp7zHM8A4S0ljX XyYcQ1t0MkzmpW+U3oBUC4C8RwTwCnxgJCCInODVFE7HAxafdNCrcs3WKWTSz1ianfvhCp rkU5rkK0L2B37sVNjzLqb1dK7faJS6djpWfxIIfGSvbkz/3tnX7Yf9MolTPEKhFItdiRTW PGApei7naNciypRowrtyxl5QHaWXs95waSFOFsmovWbI9vhhz3KNAHdqcbQVYg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703790751; h=from:from:reply-to:subject:subject: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=dW79/P6iqkiSdYeT9HZfGedQwVOWGFAIdN+jOxnp02o=; b=wsR1DuvK1K9aqYalj1Gu+CL8+DBmVQQgLbOOtSMe+A2/t0LxpZkmLJx8h884Vb74916ESI o8WMn+t1vqDZd+ZDcvowW/vUszpUFdQPN8TGgqvjaNuelvhazUII9Novl1kzr2ZXrAT60U lYxaK/53SlNK6TIbTylk9cK3W3AWc3T7qehgu267fdbf+cYJfDl4VUvyIwoonDYurNgnkj PNFE9UgBopou7jVZMepd4+nSx0feDX5bFJx6XGSq1giN3mmN9Kc/c1hXAKL/QBKet9QhNh VitNaUke+JsGKCM5hxlCyr57oai0d2y0AKTTE1ydArkgywmNqB4DsHcQex2LgA== Received: from [IPV6:2601:644:9381:f410:51b5:c0ad:43d:a2] (unknown [IPv6:2601:644:9381:f410:51b5:c0ad:43d:a2]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4T1J6l2j9Yz7Cd; Thu, 28 Dec 2023 19:12:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <44359512-5392-46ed-9e80-31052843ba68@FreeBSD.org> Date: Thu, 28 Dec 2023 11:12:30 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] gdb: improve error reporting from expression parser Content-Language: en-US To: Andrew Burgess , gdb-patches@sourceware.org References: <1dc7fb98343743fe010687ab3d5ccf2474181e64.1703361278.git.aburgess@redhat.com> From: John Baldwin In-Reply-To: <1dc7fb98343743fe010687ab3d5ccf2474181e64.1703361278.git.aburgess@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 12/23/23 11:56 AM, Andrew Burgess wrote: > This commits changes how errors are reported from the expression > parser. Previously, parser errors were reported like this: > > (gdb) p a1 +}= 432 > A syntax error in expression, near `}= 432'. > (gdb) p a1 + > A syntax error in expression, near `'. > > The first case is fine, a user can figure out what's going wrong, but > the second case is a little confusing; as the error occurred at the > end of the expression GDB just reports the empty string to the user. > > After this commit the errors are now reported like this: > > (gdb) p a1 +}= 432 > A syntax error in expression near '' marker in: `a1 +}= 432'. > (gdb) p a1 + > A syntax error in expression near '' marker in: `a1 +'. > > Now GDB reports the entire expression along with a marker to > indicate where the error occurred. > > I did consider trying to have multi-line errors here, in the style > that gcc produces, with some kind of '~~~~~^' marker on the second > line to indicate where the error occurred; but I rejected this due to > the places in GDB where we catch an error and repackage the message > within some longer string, I don't think multi-line error messages > would work well in that case. > > Adding the '' marker was actually a later extension I made. My > first implementation simply tried to address the empty string > case (where GDB reports "..., near `'"). Originally I just changed > this to be: > > (gdb) p a1 + > A syntax error in expression, at the end of `a1 +'. > > But then I thought adding the '' markers was pretty neat, so I > did that instead. However, if folk feel the '' marker is more > confusing than helpful I can always fall back to my original plan, and > just fix the empty string case. > > I originally wanted to try and style the '' marker, I thought > that would help make it clear that it wasn't part of the expression. > However, GDB's error function doesn't support styling right now. We > could possibly add this in the future, in which case the marker > could be given maybe the metadata style to help it stand out. > > I've updated the small number of tests that check for a syntax error, > and add a couple of extra tests in gdb.base/exprs.exp. Hmm, I do kind of find the approach somewhat verbose (or at least I feel like it's a bit shouty). I might prefer either your simple fix for end of string (which I think is a perfectly fine fix), or the more complicated multi-line error similar to what GCC/clang do for compile errors. It does sound like the multi-line case might be too complicated to implement. -- John Baldwin