Message ID | 20240212200153.882582-3-pedro@palves.net |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> 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 25399385841B for <patchwork@sourceware.org>; Mon, 12 Feb 2024 20:02:38 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by sourceware.org (Postfix) with ESMTPS id 89C6B3858408 for <gdb-patches@sourceware.org>; Mon, 12 Feb 2024 20:02:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 89C6B3858408 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 89C6B3858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707768126; cv=none; b=l7lhY99oymua6Cz//u1cikETLPIkNWwdLTBGrv6jcIJOAYUgTh5eAyZrEp0Zeb4aNRPgq4EDUdJ7V1d/Y4JwagPwddUUdOOJyYZ/WZM0iC9oqowggPaA2YS+tIp2zgjAkXU8JSbNz0jDg6OmkXfU8ZfFIsa4ilEkJjsehic/hbg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707768126; c=relaxed/simple; bh=npKzAsmaw3x6tTGTgMR75Y5cKY+DZE7n4pDmo5uQxpM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Rrj3wdb4adoyNej2u/JYcP9JJWPHxfc/bBCka35bFLje5AaPEyAOZDRYgPrMgZ3ctSFuKd4R4FOtckop8hkheFW+izUL6rAG5lDyF9MjOY2PVGJmXI0PJdePC4jQ+XcgcqK0XwqbBlgBujH7KFRS4azPdcfPrGQ/xfWo7lHksmE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-33b65b2e43eso2591589f8f.1 for <gdb-patches@sourceware.org>; Mon, 12 Feb 2024 12:02:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707768122; x=1708372922; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MTunuHjteKGK+MDkUrXHDgFED6l2f8cD60d695yhjEc=; b=SvsjPW589SGjopBHrNYi5JN8ZNU93jCIGoWR25DBvGMbw/sQEBFIx2/ZO60Ov9ogRP 6qQJqairFEmdspPK9oh1I8+DWYRhVk0q6VBxR0Xgu7F6DF2xoMQZpda0e7YCWbIsbZUY tP+iShUiA8l5Njh7h6ixFpChVUriSW0Qon0pPj8Jfogb3/q1PhFdtPpHAKB2WMmmwTC9 e/1QtBZ61f9y4dsDGf2WcN/g0URHI1+iOTH3kr5Q1fc6BB+a3ulzUNUH7pn37mLKVygV ekxd7O7+tDLaGobSxXcJefhAl6R7FFmHLnoRGemsi8yHcP3L/6r2rOP1sLa0Kxp1zjQI nE9g== X-Gm-Message-State: AOJu0YxORYJxuHTZFfOop+B9Tt79zVryfCoE9OKVIcKMwR2UDwOYeKik +4ALKa4vGIKSa3T+S8Cnkb/r7S+6ACsxewzIOcu+P12g82ntJqBt7oRMwffeayc= X-Google-Smtp-Source: AGHT+IFn2i/MQE3wY//X7SoBAkBIJnI//NJBZEPKzxfUsq3Zb7/APDWHQUom+FVTq93BafE2unuKNA== X-Received: by 2002:adf:f9cd:0:b0:33b:8782:b526 with SMTP id w13-20020adff9cd000000b0033b8782b526mr1490643wrr.59.1707768121957; Mon, 12 Feb 2024 12:02:01 -0800 (PST) Received: from localhost ([2001:8a0:f923:4f00:6d21:130f:e0dc:ea4b]) by smtp.gmail.com with UTF8SMTPSA id y8-20020a5d4708000000b0033b507b0abdsm7590001wrq.32.2024.02.12.12.02.01 for <gdb-patches@sourceware.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Feb 2024 12:02:01 -0800 (PST) From: Pedro Alves <pedro@palves.net> To: gdb-patches@sourceware.org Subject: [PATCH 2/3] Improve vRun error reporting Date: Mon, 12 Feb 2024 20:01:52 +0000 Message-ID: <20240212200153.882582-3-pedro@palves.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212200153.882582-1-pedro@palves.net> References: <20240212200153.882582-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org |
Series |
"run" and "attach" failure handling problems
|
|
Commit Message
Pedro Alves
Feb. 12, 2024, 8:01 p.m. UTC
After the previous commit, if starting the inferior process with "run" (vRun packet) fails, GDBserver reports an error using the "E." verbose error packet. On the GDB side, however, GDB doesn't yet do anything with verbose error strings when handling vRun errors. This commit fixes that. This makes remote debugging output the same as native output, when possible, another small step in the "local/remote parity" project. E.g., before, against GNU/Linux GDBserver: (gdb) run Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox Running ".../gdb.base/run-fail-twice/run-fail-twice.nox" on the remote target failed After, against GNU/Linux GDBserver (same as native): (gdb) run Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox During startup program exited with code 126. Change-Id: Ib386f267522603f554b52a885b15229c9639e870 --- gdb/remote.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
Comments
Hi! This conflicts with Alexandra's just-merged packet_check_result changes. I see she has some follow up patches that would help me here. I will take a look at those. For the meantime, disregard this patch. Pedro Alves On 2024-02-12 20:01, Pedro Alves wrote: > After the previous commit, if starting the inferior process with "run" > (vRun packet) fails, GDBserver reports an error using the "E." verbose > error packet. On the GDB side, however, GDB doesn't yet do anything > with verbose error strings when handling vRun errors. This commit > fixes that. > > This makes remote debugging output the same as native output, when > possible, another small step in the "local/remote parity" project. > > E.g., before, against GNU/Linux GDBserver: > > (gdb) run > Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox > Running ".../gdb.base/run-fail-twice/run-fail-twice.nox" on the remote target failed > > After, against GNU/Linux GDBserver (same as native): > > (gdb) run > Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox > During startup program exited with code 126. > > Change-Id: Ib386f267522603f554b52a885b15229c9639e870 > --- > gdb/remote.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > > diff --git a/gdb/remote.c b/gdb/remote.c > index b58dbd4cb66..dca5add260a 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -2400,6 +2400,19 @@ add_packet_config_cmd (const unsigned int which_packet, const char *name, > } > } > > +/* Strings that starts with "E.", are verbose error messages, like > + "E.ERROR_MESSAGE". If BUF is such an error message, return a > + pointer to message after the period. Otherwise return NULL. */ > + > +static const char * > +verbose_error_message (const char *buf) > +{ > + if (buf[0] == 'E' && buf[1] == '.') > + return buf + 2; > + else > + return nullptr; > +} > + > static enum packet_result > packet_check_result (const char *buf) > { > @@ -2415,7 +2428,7 @@ packet_check_result (const char *buf) > > /* Always treat "E." as an error. This will be used for > more verbose error messages, such as E.memtypes. */ > - if (buf[0] == 'E' && buf[1] == '.') > + if (verbose_error_message (buf) != nullptr) > return PACKET_ERROR; > > /* The packet may or may not be OK. Just assume it is. */ > @@ -10502,7 +10515,13 @@ remote_target::extended_remote_run (const std::string &args) > case PACKET_UNKNOWN: > return -1; > case PACKET_ERROR: > - if (remote_exec_file[0] == '\0') > + /* If we have a verbose error message, print just that. This > + makes remote debugging output the same as native output, when > + possible. */ > + if (const char *msg = verbose_error_message (rs->buf.data ()); > + msg != nullptr) > + error (("%s"), msg); > + else if (remote_exec_file[0] == '\0') > error (_("Running the default executable on the remote target failed; " > "try \"set remote exec-file\"?")); > else
Hi, I only glanced at this patch, but it seems to me that is would conflict with this patch: commit 7e9d8a3627c8a80b76c250b6881b7eb6fc2f4443 Date: Fri Nov 24 14:33:42 2023 +0100 remote.c: Make packet_check_result return a structure https://sourceware.org/pipermail/gdb-patches/2024-February/206483.html I expect that this patch would remove the need for verbose_error_message, you just need to have some changes in remote_target::extended_remote_run. Best, Lancelot. On Mon, Feb 12, 2024 at 08:01:52PM +0000, Pedro Alves wrote: > After the previous commit, if starting the inferior process with "run" > (vRun packet) fails, GDBserver reports an error using the "E." verbose > error packet. On the GDB side, however, GDB doesn't yet do anything > with verbose error strings when handling vRun errors. This commit > fixes that. > > This makes remote debugging output the same as native output, when > possible, another small step in the "local/remote parity" project. > > E.g., before, against GNU/Linux GDBserver: > > (gdb) run > Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox > Running ".../gdb.base/run-fail-twice/run-fail-twice.nox" on the remote target failed > > After, against GNU/Linux GDBserver (same as native): > > (gdb) run > Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox > During startup program exited with code 126. > > Change-Id: Ib386f267522603f554b52a885b15229c9639e870 > --- > gdb/remote.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > > diff --git a/gdb/remote.c b/gdb/remote.c > index b58dbd4cb66..dca5add260a 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -2400,6 +2400,19 @@ add_packet_config_cmd (const unsigned int which_packet, const char *name, > } > } > > +/* Strings that starts with "E.", are verbose error messages, like > + "E.ERROR_MESSAGE". If BUF is such an error message, return a > + pointer to message after the period. Otherwise return NULL. */ > + > +static const char * > +verbose_error_message (const char *buf) > +{ > + if (buf[0] == 'E' && buf[1] == '.') > + return buf + 2; > + else > + return nullptr; > +} > + > static enum packet_result > packet_check_result (const char *buf) > { > @@ -2415,7 +2428,7 @@ packet_check_result (const char *buf) ss> > /* Always treat "E." as an error. This will be used for > more verbose error messages, such as E.memtypes. */ > - if (buf[0] == 'E' && buf[1] == '.') > + if (verbose_error_message (buf) != nullptr) > return PACKET_ERROR; > > /* The packet may or may not be OK. Just assume it is. */ > @@ -10502,7 +10515,13 @@ remote_target::extended_remote_run (const std::string &args) > case PACKET_UNKNOWN: > return -1; > case PACKET_ERROR: > - if (remote_exec_file[0] == '\0') > + /* If we have a verbose error message, print just that. This > + makes remote debugging output the same as native output, when > + possible. */ > + if (const char *msg = verbose_error_message (rs->buf.data ()); > + msg != nullptr) > + error (("%s"), msg); > + else if (remote_exec_file[0] == '\0') > error (_("Running the default executable on the remote target failed; " > "try \"set remote exec-file\"?")); > else > > -- > 2.43.0 >
diff --git a/gdb/remote.c b/gdb/remote.c index b58dbd4cb66..dca5add260a 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -2400,6 +2400,19 @@ add_packet_config_cmd (const unsigned int which_packet, const char *name, } } +/* Strings that starts with "E.", are verbose error messages, like + "E.ERROR_MESSAGE". If BUF is such an error message, return a + pointer to message after the period. Otherwise return NULL. */ + +static const char * +verbose_error_message (const char *buf) +{ + if (buf[0] == 'E' && buf[1] == '.') + return buf + 2; + else + return nullptr; +} + static enum packet_result packet_check_result (const char *buf) { @@ -2415,7 +2428,7 @@ packet_check_result (const char *buf) /* Always treat "E." as an error. This will be used for more verbose error messages, such as E.memtypes. */ - if (buf[0] == 'E' && buf[1] == '.') + if (verbose_error_message (buf) != nullptr) return PACKET_ERROR; /* The packet may or may not be OK. Just assume it is. */ @@ -10502,7 +10515,13 @@ remote_target::extended_remote_run (const std::string &args) case PACKET_UNKNOWN: return -1; case PACKET_ERROR: - if (remote_exec_file[0] == '\0') + /* If we have a verbose error message, print just that. This + makes remote debugging output the same as native output, when + possible. */ + if (const char *msg = verbose_error_message (rs->buf.data ()); + msg != nullptr) + error (("%s"), msg); + else if (remote_exec_file[0] == '\0') error (_("Running the default executable on the remote target failed; " "try \"set remote exec-file\"?")); else