From patchwork Sat Dec 23 19:56:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 82796 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 03EFD3858284 for ; Sat, 23 Dec 2023 19:56:33 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D36EE3858D3C for ; Sat, 23 Dec 2023 19:56:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D36EE3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D36EE3858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703361375; cv=none; b=sKSUaJceaWPKO3I/Sky17V8x5dYH7ED93JrJ3+SZBnGbD7vEAFXyhJTZYRfOTTC9I75Qj1rjpFvSPd+wp/yANrKYazmFMq8CPvtOmcjDr2A+rz0BZokwhkHC4XQDB9BAnud5z0iZ3SZfnA66JBrplU4G5FaCiVnfrsO/eQnmQK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703361375; c=relaxed/simple; bh=8U2/W8I6svqwDJdX2zybz0nfN6yo8XlSABp2qau46D0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=wrNjBeJ+K+NwE0B7l+laWRMUfEPDOkGFZJnQ2bkQB19FrlpOkBbbRGv29o7OATjNFwzM0M+rl8CnNjvZD9tz4SFJPSbq2ov81wPbESQRtvxmqxlHkn4czs05Ta+XCL86VDPnDywRnirNFuQk0ZIuUVvkwxHyd/MLba24ZTOdoJM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703361372; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EsK4w5a4Lm38yniwOyJzlpUgrVDTLODBh36EZ9OPVbs=; b=A2UcsYxqT26JC6U1GB+UFCtwB3+JCetogkb6IjVHgVVy6+IhsY8Hl900nIvq6JhYpKGzPc vr/OoLXY8CxaFBEMao6QsMnZ0r+tiwYoZI0Y1fm4pnILIUNhP4KaaYWNE5OEkJeifJmhAQ /ZGgzF97ecu3GfNA8qi1IrRWLz9o+HA= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-262-9j020EHkNYq8_zpjVu4Wdw-1; Sat, 23 Dec 2023 14:56:11 -0500 X-MC-Unique: 9j020EHkNYq8_zpjVu4Wdw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40d17446f11so29680875e9.0 for ; Sat, 23 Dec 2023 11:56:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703361369; x=1703966169; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qu8l2Gg0ZOx/Zu4nXwRAZ4jtuESL4RWR81DZjXEh1bQ=; b=q95ut9UMS5ob/5ovRg8JB1FQ47TpKCQbSz8Fxq7kdUbXCfyO5bfB+KThTf6p/ozgkg f2C2nbdJdAeyxAc8URpMSDiTS0pLJC95smDFvls7JEeeV4WoLvH1U34q+b3nBcWvKL1B 7fG57ENR+Qwsa5tOXEG6VnDkeITdkPLZUoQokr1F6z2u/ZxYz7sz7ZRr/z9jCVahpstU BSfKQQ1RavKQ3GTXYp0m770aWLZSDpehpS0zQfkk3gpARRKwEhzsvndzsN1kyEiRTrb5 VT9Z3tx/FGHfTBZISft3w3ZYY7JBT0Wtsoz/ZAJtKisfr9fnkuzCmp8m3X40EyROhbqh l6MA== X-Gm-Message-State: AOJu0YyHaPhEXcFkmiSza+EPPHTLhQNOuOhbidtiz/cHwMiHMofaaR5y 7sm0gHZCA+lScMY7G8PFvBSdyTXpQktnJgYjxkf+517EdbBpnBqGLEzeiN2z2BPP6L/0hv9LgnV 51yBJhHsKHlEy7u3TBuJqDCrR5wUXovNSsjEgftbR8Mj1KWzTDXmNE7eNcDGF2HGGad70I1LqCs Q3jXFs2k8Xetb4Vg== X-Received: by 2002:a05:600c:234a:b0:40d:190d:f36e with SMTP id 10-20020a05600c234a00b0040d190df36emr1803522wmq.161.1703361368896; Sat, 23 Dec 2023 11:56:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMG+pVgJ9kVMtB8/R0RN7hkcg51s9YZAE2i16LUDqHVbwMrRwD1vmpNKR5LJCfY/vaRy3BQg== X-Received: by 2002:a05:600c:234a:b0:40d:190d:f36e with SMTP id 10-20020a05600c234a00b0040d190df36emr1803514wmq.161.1703361368422; Sat, 23 Dec 2023 11:56:08 -0800 (PST) Received: from localhost ([2a00:23c7:c696:e701:85a5:8a0c:1403:2dc]) by smtp.gmail.com with ESMTPSA id r12-20020a05600c35cc00b0040d2dfb10e0sm17227823wmq.11.2023.12.23.11.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 11:56:07 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 1/2] gdb: improve error reporting from expression parser Date: Sat, 23 Dec 2023 19:56:03 +0000 Message-Id: <1dc7fb98343743fe010687ab3d5ccf2474181e64.1703361278.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 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 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. --- gdb/ada-exp.y | 2 +- gdb/c-exp.y | 5 +---- gdb/d-exp.y | 5 +---- gdb/f-exp.y | 5 +---- gdb/go-exp.y | 5 +---- gdb/m2-exp.y | 5 +---- gdb/p-exp.y | 5 +---- gdb/parse.c | 16 ++++++++++++++++ gdb/parser-defs.h | 9 +++++++++ gdb/testsuite/gdb.ada/bp_c_mixed_case.exp | 4 ++-- gdb/testsuite/gdb.base/exprs.exp | 7 +++++++ gdb/testsuite/gdb.base/quit.exp | 2 +- gdb/testsuite/gdb.base/settings.exp | 4 ++-- gdb/testsuite/gdb.base/watch_thread_num.exp | 2 +- gdb/testsuite/gdb.cp/local-static.exp | 2 +- gdb/testsuite/gdb.dlang/expression.exp | 2 +- 16 files changed, 47 insertions(+), 33 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index fcb5aa4379b..2a1cff50887 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1212,7 +1212,7 @@ ada_parse (struct parser_state *par_state) static void yyerror (const char *msg) { - error (_("Error in expression, near `%s'."), pstate->lexptr); + pstate->parse_error (msg); } /* Emit expression to access an instance of SYM, in block BLOCK (if diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 2b4c21850d3..6697b3b2278 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -3482,8 +3482,5 @@ c_print_token (FILE *file, int type, YYSTYPE value) static void yyerror (const char *msg) { - if (pstate->prev_lexptr) - pstate->lexptr = pstate->prev_lexptr; - - error (_("A %s in expression, near `%s'."), msg, pstate->lexptr); + pstate->parse_error (msg); } diff --git a/gdb/d-exp.y b/gdb/d-exp.y index e2507982d50..627c681d895 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -1631,9 +1631,6 @@ d_parse (struct parser_state *par_state) static void yyerror (const char *msg) { - if (pstate->prev_lexptr) - pstate->lexptr = pstate->prev_lexptr; - - error (_("A %s in expression, near `%s'."), msg, pstate->lexptr); + pstate->parse_error (msg); } diff --git a/gdb/f-exp.y b/gdb/f-exp.y index e4e2171d641..88a95bccb11 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -1736,8 +1736,5 @@ f_language::parser (struct parser_state *par_state) const static void yyerror (const char *msg) { - if (pstate->prev_lexptr) - pstate->lexptr = pstate->prev_lexptr; - - error (_("A %s in expression, near `%s'."), msg, pstate->lexptr); + pstate->parse_error (msg); } diff --git a/gdb/go-exp.y b/gdb/go-exp.y index c9b9c0b1ab7..561a3bef1b0 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -1545,8 +1545,5 @@ go_language::parser (struct parser_state *par_state) const static void yyerror (const char *msg) { - if (pstate->prev_lexptr) - pstate->lexptr = pstate->prev_lexptr; - - error (_("A %s in expression, near `%s'."), msg, pstate->lexptr); + pstate->parse_error (msg); } diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index 092a8be248d..9a8767f5ac7 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -1006,8 +1006,5 @@ m2_language::parser (struct parser_state *par_state) const static void yyerror (const char *msg) { - if (pstate->prev_lexptr) - pstate->lexptr = pstate->prev_lexptr; - - error (_("A %s in expression, near `%s'."), msg, pstate->lexptr); + pstate->parse_error (msg); } diff --git a/gdb/p-exp.y b/gdb/p-exp.y index b0f334897ad..9dfa8c5fd4f 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -1660,8 +1660,5 @@ pascal_language::parser (struct parser_state *par_state) const static void yyerror (const char *msg) { - if (pstate->prev_lexptr) - pstate->lexptr = pstate->prev_lexptr; - - error (_("A %s in expression, near `%s'."), msg, pstate->lexptr); + pstate->parse_error (msg); } diff --git a/gdb/parse.c b/gdb/parse.c index b57d112fafd..53f8a761c40 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -51,6 +51,7 @@ #include #include #include "c-exp.h" +#include "cli/cli-style.h" static unsigned int expressiondebug = 0; static void @@ -244,6 +245,21 @@ parser_state::push_dollar (struct stoken str) (create_internalvar (copy.c_str () + 1)); } +/* See parser-defs.h. */ + +void +parser_state::parse_error (const char *msg) +{ + if (this->prev_lexptr) + this->lexptr = this->prev_lexptr; + + error (_("A %s in expression near '' marker in: `%.*s%s'."), + msg, + ((int) (this->lexptr - this->start_of_input)), + this->start_of_input, + this->lexptr); +} + const char * diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index 93ebdf5c061..34673787ef0 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -152,6 +152,7 @@ struct parser_state : public expr_builder expression_context_block (context_block), expression_context_pc (context_pc), lexptr (input), + start_of_input (input), block_tracker (tracker), comma_terminates ((flags & PARSER_COMMA_TERMINATES) != 0), parse_completion (completion), @@ -262,6 +263,11 @@ struct parser_state : public expr_builder push (expr::make_operation (std::move (lhs), std::move (rhs))); } + /* Function called from various the various parsers yyerror functions to + throw an error. The error will include a message identifying the + location of the error within the current expression. */ + void parse_error (const char *msg); + /* If this is nonzero, this block is used as the lexical context for symbol names. */ @@ -283,6 +289,9 @@ struct parser_state : public expr_builder Currently used only for error reporting. */ const char *prev_lexptr = nullptr; + /* A pointer to the start of the full input, used for error reporting. */ + const char *start_of_input = nullptr; + /* Number of arguments seen so far in innermost function call. */ int arglist_len = 0; diff --git a/gdb/testsuite/gdb.ada/bp_c_mixed_case.exp b/gdb/testsuite/gdb.ada/bp_c_mixed_case.exp index d87b185c0c3..90a6dc867ee 100644 --- a/gdb/testsuite/gdb.ada/bp_c_mixed_case.exp +++ b/gdb/testsuite/gdb.ada/bp_c_mixed_case.exp @@ -83,11 +83,11 @@ gdb_test "continue" \ # Try printing again using the "<...>" notation. This shouldn't work # now, since the current frame is a C function. gdb_test "p " \ - "A syntax error in expression, near `'\\." \ + "A syntax error in expression near '' marker in: `'\\." \ "p , in C" gdb_test "p " \ - "A syntax error in expression, near `'\\." \ + "A syntax error in expression near '' marker in: `'\\." \ "p , in C" set test "break , in C" diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp index 79ae905fccf..d6773f8dfd9 100644 --- a/gdb/testsuite/gdb.base/exprs.exp +++ b/gdb/testsuite/gdb.base/exprs.exp @@ -275,3 +275,10 @@ gdb_test "print null_t_struct && null_t_struct->v_int_member == 0" \ # Regression test for unusual function-call parse that caused a crash. gdb_test "print v_short++(97)" \ "cast the call to its declared return type" + +# Some simple syntax errors in expressions. +gdb_test "print v_short ==" \ + "A syntax error in expression near '' marker in: `v_short =='\\." + +gdb_test "print v_short =}{= 3" \ + "A syntax error in expression near '' marker in: `v_short =}{= 3'\\." diff --git a/gdb/testsuite/gdb.base/quit.exp b/gdb/testsuite/gdb.base/quit.exp index 23418074c39..9cc4c91880d 100644 --- a/gdb/testsuite/gdb.base/quit.exp +++ b/gdb/testsuite/gdb.base/quit.exp @@ -19,7 +19,7 @@ clean_restart # Test that a syntax error causes quit to abort. # Regression test for PR gdb/20604. -gdb_test "quit()" "A syntax error in expression, near .*" \ +gdb_test "quit()" "A syntax error in expression near '' marker in: .*" \ "quit with syntax error" # Test that an expression can be used to set the error code. diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp index dc96f85c1bb..6943501a180 100644 --- a/gdb/testsuite/gdb.base/settings.exp +++ b/gdb/testsuite/gdb.base/settings.exp @@ -134,11 +134,11 @@ proc test-integer {variant} { # Valid value followed by garbage. gdb_test "$set_cmd 1 1" \ - "A syntax error in expression, near `1'\\." + "A syntax error in expression near '' marker in: `1 1'\\." # Valid value followed by garbage. gdb_test "$set_cmd 1 x" \ - "A syntax error in expression, near `x'\\." + "A syntax error in expression near '' marker in: `1 x'\\." if {$variant == "zuinteger-unlimited"} { # -1 means unlimited. Other negative values are rejected. -1 diff --git a/gdb/testsuite/gdb.base/watch_thread_num.exp b/gdb/testsuite/gdb.base/watch_thread_num.exp index 28b8581ba5a..b745f64fc14 100644 --- a/gdb/testsuite/gdb.base/watch_thread_num.exp +++ b/gdb/testsuite/gdb.base/watch_thread_num.exp @@ -38,7 +38,7 @@ if {![runto_main]} { } gdb_test "watch shared_var thread 0" "Invalid thread ID: 0" "watchpoint on invalid thread" -gdb_test "watch shared_var thread" "A syntax error in expression, near `thread'\." "invalid watch syntax" +gdb_test "watch shared_var thread" "A syntax error in expression near '' marker in: `shared_var thread'\." "invalid watch syntax" set bpexitline [gdb_get_line_number "all threads started"] gdb_breakpoint "$bpexitline" diff --git a/gdb/testsuite/gdb.cp/local-static.exp b/gdb/testsuite/gdb.cp/local-static.exp index 8d967c4b293..5ccf72081a0 100644 --- a/gdb/testsuite/gdb.cp/local-static.exp +++ b/gdb/testsuite/gdb.cp/local-static.exp @@ -20,7 +20,7 @@ standard_testfile .c # A few expected errors. -set syntax_re "A syntax error in expression, near.*" +set syntax_re "A syntax error in expression near '' marker in: .*" set cannot_resolve_re "Cannot resolve method S::method to any overloaded instance" # Build an "Cannot resolve method ..." expected error string for diff --git a/gdb/testsuite/gdb.dlang/expression.exp b/gdb/testsuite/gdb.dlang/expression.exp index c7aeec52d25..3a4af396041 100644 --- a/gdb/testsuite/gdb.dlang/expression.exp +++ b/gdb/testsuite/gdb.dlang/expression.exp @@ -110,7 +110,7 @@ proc test_d_expressions {} { # Test expression behaviour specific to D. # Comparison and order expressions have same precedence. - gdb_test "print 1 == 2 > 0" "A syntax error in expression, near `> 0'\." + gdb_test "print 1 == 2 > 0" "A syntax error in expression near '' marker in: `1 == 2 > 0'\." gdb_test "print (1 == 2) > 0" " = false" # Exponent expressions From patchwork Sat Dec 23 19:56:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 82797 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 ED55038582AC for ; Sat, 23 Dec 2023 19:56:33 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C319E3858432 for ; Sat, 23 Dec 2023 19:56:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C319E3858432 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C319E3858432 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703361376; cv=none; b=emwX0epm1tOzVaAz1mjWg5mDeZal8GYbn+AeKWH6T/UwIlhrOEEKg73ljlhdKsozZmzmUBkeEyGUx3K3p127lyguXITe6BNjv2nGy4zeVv8J2TU7t2xRFg4DH91rjpPrmqQp5+tSh/o5ESx0JbJgfCG1cNx99BXEXv3xG+AwWME= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703361376; c=relaxed/simple; bh=/iIqd2SVYnMrNbnxcqTciMjjI4gQFXvPDw/u6bbo+lc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=C/Sm734xWDnw75aGGfdkfwAMMa7fjqF9kI/lmGFCdhNwKZM2xuUUGR0/Y9Hgz03v1dy1xespyeqkjNFPi8Ej1FFol9Z6KD9DarX+zAJRdes3qXObd+GQZl9qj+Gp0N82/lUlUAqg/7SqMZ/5g8EFeuvTqNVyRvTaP4vnqNgF4yA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703361374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wIsfh9S+avzcbZR/B496BOq1derhgOOb16Sw6N69FPQ=; b=cI0qyrwQyXo8y2cF6xwPrUscCir5hF6Mu4p/tovFoLsIsgeymWfrIdGNEtlHmSvhukPCaN Mp8N5X7DcwmD9ozEMbiLXiHu6oHLRRvnwmkd+vSN/lk4PBiS9g+NGnqrO50J9OcnneIkLW zNLarpjCB7eN68q4u1TIx6+33Z34EYg= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-YnvyDl4zO3ics8ofz-uw_g-1; Sat, 23 Dec 2023 14:56:13 -0500 X-MC-Unique: YnvyDl4zO3ics8ofz-uw_g-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-40d17446f11so29681025e9.0 for ; Sat, 23 Dec 2023 11:56:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703361369; x=1703966169; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wIsfh9S+avzcbZR/B496BOq1derhgOOb16Sw6N69FPQ=; b=r50t9epsiZXGYq+9RM36tIj+1jqVTQFhOV2s3IKwJgQn+oilMlLSzVqdlRpYVKgVZk 6M/mBXj0gzKcsGCJQNwt6X1OG6YaNZFyGq497Sw2PQXC3ZOO1l1718jghF6fUmjQD0ct kSvrVFVD9TuhUM+sHLj/0f0Wx3iCR7nRK+pQpeGBpJoxnjzU6NRoCUR/Lk7NgYsT6kXD gAh2goZz3Y58+pslrTQPUW4Nw5m91twfmCO7skuQT9tZ3VoL2+ox1seG1kQsD8eyB5GP QcdWqXljjkwnfuEVWhX/f7omxS52/NebQoKjrKL+DYJP8lhTO8WwRZUcpvXWA/BF3+Xd 6XqA== X-Gm-Message-State: AOJu0Yw4XijODvmXBWzd+Ovfcee0OwqL70yTyH/aJ0UFGQcm/H3cCv6A CBOZxKUlzCc8WVhp90ac8NhFxaDFPompgEJjUQ+MOAcOvsF0a6vqy/LnIKjukbH5ca9/VWTUEp8 zrqrx7rtpj+Hdy7fwhFETQC+RTdJPGjNOz0/YStRyySjZM66e9tq9ZKfSglisWQwkeTorOHPVST Qdep+UjNYHexXlmQ== X-Received: by 2002:a05:600c:511d:b0:40b:36e9:bf4b with SMTP id o29-20020a05600c511d00b0040b36e9bf4bmr1560658wms.41.1703361369662; Sat, 23 Dec 2023 11:56:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IEynRiG30AGluI0gaK3nlDvU30BJ+CSt2PssLyzzDr7cENaac/NXd5/uQyK6yc3a/sfhBC83A== X-Received: by 2002:a05:600c:511d:b0:40b:36e9:bf4b with SMTP id o29-20020a05600c511d00b0040b36e9bf4bmr1560654wms.41.1703361369303; Sat, 23 Dec 2023 11:56:09 -0800 (PST) Received: from localhost ([2a00:23c7:c696:e701:85a5:8a0c:1403:2dc]) by smtp.gmail.com with ESMTPSA id fl25-20020a05600c0b9900b0040b3e26872dsm19536757wmb.8.2023.12.23.11.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 11:56:09 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/2] gdb: don't try to style content in error calls Date: Sat, 23 Dec 2023 19:56:04 +0000 Message-Id: <7e6ee472a9d550bfdcb41da6962efdda0fbcda83.1703361278.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 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 Working on the previous commit I realised that we can't style output in error calls. I took a look and found one place where we do currently try to style something within an error call, if this ever triggers then it's just going to print a pointer rather than the styled string. Fixed by removing the styling. --- gdb/procfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gdb/procfs.c b/gdb/procfs.c index 1410bbc0d7d..0eafc2eddcc 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -605,10 +605,8 @@ static void proc_error (procinfo *pi, const char *func, int line) { int saved_errno = errno; - error ("procfs: %s line %d, %ps: %s", - func, line, styled_string (file_name_style.style (), - pi->pathname), - safe_strerror (saved_errno)); + error ("procfs: %s line %d, %s: %s", + func, line, pi->pathname, safe_strerror (saved_errno)); } /* Updates the status struct in the procinfo. There is a 'valid'