From patchwork Fri Apr 19 15:13:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88740 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 8C740384772B for ; Fri, 19 Apr 2024 15:14:25 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by sourceware.org (Postfix) with ESMTPS id 46B4E3849AC0 for ; Fri, 19 Apr 2024 15:13:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 46B4E3849AC0 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 46B4E3849AC0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539631; cv=none; b=SqUn7/igjeRZFYbwYy/cwHKQ1JjKs6P8w0/xkfLfL+g8UeljlxlCU36BFukTJ8imBYtz8/JF/lMzWt/a+qVsv3LM0ahdnLSxngGwn7HkACGrMoPGQuGySN5usoK8mwA/0CrOeuJhj2r0sFT0+buQp/iTF25YQgRIO7B4f280UW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539631; c=relaxed/simple; bh=p81EPXfYlp3UA8W+ilitCOJU3fDrBQiJQY/XmqZUM34=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Ssdc2WSI2GlXdsta489O3ALQk6HS4H4cwXL97MirH2QOX770pJgzexwW93MHLACVp4Zq+ZsGp9+ODW/D3YYcvLT7Q4IjghzjZtQefFrBlIApQykHWE4/KSHwLOGs64+nC1Hc3WEO6WibsIEOPAJf2Uglvtfdm9oDSArB+CQbtvE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-343f1957ffcso1251604f8f.0 for ; Fri, 19 Apr 2024 08:13:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539629; x=1714144429; 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=/8XDkIhgO0WGJosnOuALCLnspOgpLnsDDSI9fDiJAzY=; b=ffgspagc/8bHQAOi7JtczP6hTHUs3aEWNojyPL6zxXgbKiWlpAXrRxnzoDI1xnZ6BZ ueqjcduWEuQi7fyp+NMmL4QWc9reTQK0uC877WJkmL0WkuVx4mt0DpLnQPUQFBm+WCmS 4tYQP14x9pyfPLFQYA/wdHLu0+Mj5KQYwKMzrxBujAfqt2MnYmUEQ+rUlW2w+Ma0AaDq 3aV3a5l02cwyh2luXuPcYYE+CH7i8TPKhLSBc/ZHU58ZqprWXCI638IJZINK4HUV/hyO fLMYAz+m8eB1Md1Eqrj7SrMxcLNtV5hIrxF/QdX6XcVnM4jbqGWbHvzxxw+biKgEfrrj 0ESA== X-Gm-Message-State: AOJu0YxypKPhmpQdOI7Tw9O/gry+vOV+Y93j+cRBM0p57INTGlVCMWfn Uumf/fEOwX25Jx/+tYlvl3nNrD8m63BDbw1sWK6I5V9pplnk5fa1IHpgHyau X-Google-Smtp-Source: AGHT+IE3+66EGquDbj90rv365eIZ+QB2UoNHgS43Bqy+waTU/KaSPV8d0kHqh1aEmK3+ObYwEXEvPA== X-Received: by 2002:a5d:6a83:0:b0:348:b458:56b8 with SMTP id s3-20020a5d6a83000000b00348b45856b8mr4568787wru.17.1713539628726; Fri, 19 Apr 2024 08:13:48 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id s9-20020a05600c45c900b004170e0aff7asm10489639wmo.35.2024.04.19.08.13.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:13:48 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Jim Blandy , Mike Wrighton , Nathan Sidwell , Hafiz Abid Qadeer Subject: [PATCH 01/12] Document conventions for describing packet syntax Date: Fri, 19 Apr 2024 16:13:31 +0100 Message-ID: <20240419151342.1592474-2-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 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 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 comment documents conventions for describing packet syntax in the Overview section. Change-Id: I96198592601b24c983da563d143666137e4d0a4e Co-Authored-By: Jim Blandy Co-Authored-By: Mike Wrighton Co-Authored-By: Nathan Sidwell Co-Authored-By: Hafiz Abid Qadeer --- gdb/doc/gdb.texinfo | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 31a531ee992..e9d54527c90 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -42517,6 +42517,22 @@ For any @var{command} not supported by the stub, an empty response protocol. A newer @value{GDBN} can tell if a packet is supported based on that response. +In describing packets (and responses), each description has a template +showing the overall syntax, followed by an explanation of the packet's +meaning. We include spaces in some of the templates for clarity; +these are not part of the packet's syntax. No @value{GDBN} packet +uses spaces to separate its components. For example, a template like +@samp{foo @var{bar} @var{baz}} describes a packet beginning with the +three ASCII bytes @samp{foo}, followed by a @var{bar}, followed +directly by a @var{baz}. @value{GDBN} does not transmit a space +character between the @samp{foo} and the @var{bar}, or between the +@var{bar} and the @var{baz}. + +We place optional portions of a packet in @r{[}square brackets@r{]}; +for example, a template like @samp{c @r{[}@var{addr}@r{]}} describes a +packet beginning with the single ASCII character @samp{c}, possibly +followed by an @var{addr}. + At a minimum, a stub is required to support the @samp{?} command to tell @value{GDBN} the reason for halting, @samp{g} and @samp{G} commands for register access, and the @samp{m} and @samp{M} commands From patchwork Fri Apr 19 15:13:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88741 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 2130C3849AF0 for ; Fri, 19 Apr 2024 15:14:36 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by sourceware.org (Postfix) with ESMTPS id 25FBD3849ACC for ; Fri, 19 Apr 2024 15:13:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 25FBD3849ACC 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 25FBD3849ACC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539638; cv=none; b=C9lH6KUc+cwpeXkO12yPzpz3IKwmSap2j1OrBzNMSfaKOJFPXbfPQPqDeqqPnWMQkrf5q2elYYyPlkdyxUt4XjYaXBGbFdKS1Zwf8LzGcRLTaHsWJKwZc2SBpso1j4MD/ckCNs83uHXYkWsSLu1OivhN9ldDEAMFP7glmXcc3Vg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539638; c=relaxed/simple; bh=B6IqXihE2g+iWHFa0soxhah/j/0QO11E+9PuN8Eb//s=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=UkClkltnedDX9BrC63SwpOadljUizbSGkcQB7Kmiw571SOEQHMNxoDPGcM6Ky1ucLTFQ5Pv2KlBIgrW1OHeJV+y7W5YwNskirEfcbEqBJ56Jr5uNeW22GGK4XR561wuUIMRt6YWTVwvaZYRq0h7IAXuGeuyW//ZzywLTC75j7ug= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d9fe2b37acso28810241fa.2 for ; Fri, 19 Apr 2024 08:13:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539631; x=1714144431; 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=uOheCFjcSjFkiA9M4GQ40PF3mK1k0NPOHIRl/keocrc=; b=T8G9570ndAQSLAtCVUvM4IbK0sNbjUjndn8+7WKEFM1HC5VBS8F4SNHeXXUayB+Ez9 9IqaawQnkYtY4y5Fu2dey+ouLGxSXMipPgvEMz43OR2T4vyhKUpYWxru44jCupacXkGG qKFCiO7asWs7y9q3uWNivfyXzHojxdXdcSvfltnIzGmEoh48cpHAOUEmmil1Q84gZjlY e4nQ8+pqA9vqKCJe3vyf6cgxFxBk/t4uGwIW6EqnEKMfd4GniMXJa4oY1ysS/aKEPuZn qZUdLi1oeCau6ze9GWVZCPi+uLqabICnk/QrFr+D/i0bcIVlZVnPks0L16SAzMD6X8X7 R2kQ== X-Gm-Message-State: AOJu0Yx25bpPlRA0NfHZRzRtuuFNndVqfQagua7RCIlU8BA2R+I3lEGm Fp5R2RyAX02dvDXct+sqgSrvrUVYXGJ58TxPFheIhqJMNjcqOhot1xD09mAy X-Google-Smtp-Source: AGHT+IHoRTbdeZ/0H8YPRTroh1fayuZzfVSrza97cwY+lwDCMfwlswCEDEvT+DCkH7wZHtlNBcDC4Q== X-Received: by 2002:a2e:a682:0:b0:2db:7b:1a7b with SMTP id q2-20020a2ea682000000b002db007b1a7bmr1372595lje.46.1713539630665; Fri, 19 Apr 2024 08:13:50 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id a12-20020a056000100c00b00349ceadededsm4678316wrx.16.2024.04.19.08.13.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:13:50 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Jim Blandy , Mike Wrighton , Nathan Sidwell , Hafiz Abid Qadeer Subject: [PATCH 02/12] Centralize documentation of error and empty RSP responses Date: Fri, 19 Apr 2024 16:13:32 +0100 Message-ID: <20240419151342.1592474-3-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 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 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 Currently, for each packet, we document the "E NN" response (error), and the empty response (unsupported). This patch centralizes that in a new "Standard Replies" section. In the "Packets", "General Query Packets", "Tracepoint Packets" sections, Remove explicit mention of empty and error replies, except when they provide detail not covered in Standard Replies. Note this hunk: -@item E @var{NN} -@var{NN} is errno and this one: -@item E00 -The request was malformed, or @var{annex} was invalid. - -@item E @var{nn} -The offset was invalid, or there was an error encountered reading the data. -The @var{nn} part is a hex-encoded @code{errno} value. were really documenting things that don't really work that way. The first is the documentation of the "m" packet. GDB does _not_ interpret the NN as an errno. It can't, in fact, because the remote/target errno numbers have nothing to do with GDB/host errno numbers in a cross debugging scenario. The second hunk above is from the documentation of qXfer. Again, GDB does not give any interpretation to the NN error code at all. Nor does GDBserver. And again, an errno number can't be interpreted in a cross debugging scenario. Change-Id: I973695c80809cdb5a5e8d5be8b78ba4d1ecdb513 Co-Authored-By: Jim Blandy Co-Authored-By: Mike Wrighton Co-Authored-By: Nathan Sidwell Co-Authored-By: Hafiz Abid Qadeer Reviewed-By: Eli Zaretskii --- gdb/doc/gdb.texinfo | 244 +++++++------------------------------------- 1 file changed, 36 insertions(+), 208 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index e9d54527c90..57260a5b2fa 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -40242,8 +40242,6 @@ The @var{gdb_jump_pad_head} is updated head of jumppad. Both of @var{target_address} and @var{gdb_jump_pad_head} are 8-byte long. The @var{fjump} contains a sequence of instructions jump to jumppad entry. The @var{fjump_size}, 4-byte long, is the size of @var{fjump}. -@item E @var{NN} -for an error @end table @@ -40262,8 +40260,6 @@ Asks in-process agent to probe the marker at @var{address}. Replies: @table @samp -@item E @var{NN} -for an error @end table @item unprobe_marker_at:@var{address} Asks in-process agent to unprobe the marker at @var{address}. @@ -42368,6 +42364,7 @@ Show the current setting of the target wait timeout. @menu * Overview:: +* Standard Replies:: * Packets:: * Stop Reply Packets:: * General Query Packets:: @@ -42508,14 +42505,8 @@ seven repeats (@samp{$}) can be expanded using a repeat count of only five (@samp{"}). For example, @samp{00000000} can be encoded as @samp{0*"00}. -The error response returned for some packets includes a two character -error number. That number is not well defined. - -@cindex empty response, for unsupported packets -For any @var{command} not supported by the stub, an empty response -(@samp{$#00}) should be returned. That way it is possible to extend the -protocol. A newer @value{GDBN} can tell if a packet is supported based -on that response. +See @ref{Standard Replies} for standard error responses, and how to +respond indicating a packet is not supported. In describing packets (and responses), each description has a template showing the overall syntax, followed by an explanation of the packet's @@ -42543,6 +42534,31 @@ the @samp{s} (step) command. Stubs that support multi-threading targets should support the @samp{vCont} command. All other commands are optional. +@node Standard Replies +@section Standard Replies + +The remote protocol specifies a few standard replies. All commands +support these, except as noted in the individual command descriptions. + +@table @asis + +@item empty response + +@cindex empty response, for unsupported packets +@cindex unsupported packets, empty response for +For any @var{command} not supported by the stub, an empty response +(@samp{$#00}) should be returned. That way it is possible to extend the +protocol. A newer @value{GDBN} can tell if a packet is supported based +on that response (but see also @ref{qSupported}). + +@item @samp{E @var{xx}} +An error has occurred; @var{xx} is a two-digit hexadecimal error +number. In almost all cases, the protocol does not specify the +meaning of the error numbers; @value{GDBN} usually ignores the +numbers, or displays them to the user without further interpretation. + +@end table + @node Packets @section Packets @@ -42630,8 +42646,6 @@ Reply: @table @samp @item OK The arguments were set. -@item E @var{NN} -An error occurred. @end table @item b @var{baud} @@ -42720,8 +42734,6 @@ Reply: @table @samp @item OK for success -@item E @var{NN} -for an error @end table @item F @var{RC},@var{EE},@var{CF};@var{XX} @@ -42768,8 +42780,6 @@ are available, and both have zero value: <- @code{xxxxxxxx00000000xxxxxxxx00000000} @end smallexample -@item E @var{NN} -for an error. @end table @item G @var{XX@dots{}} @@ -42781,8 +42791,6 @@ Reply: @table @samp @item OK for success -@item E @var{NN} -for an error @end table @item H @var{op} @var{thread-id} @@ -42799,8 +42807,6 @@ Reply: @table @samp @item OK for success -@item E @var{NN} -for an error @end table @c FIXME: JTC: @@ -42875,8 +42881,6 @@ Reply: Memory contents; each byte is transmitted as a two-digit hexadecimal number. The reply may contain fewer addressable memory units than requested if the server was able to read only part of the region of memory. -@item E @var{NN} -@var{NN} is errno @end table @item M @var{addr},@var{length}:@var{XX@dots{}} @@ -42888,10 +42892,8 @@ byte is transmitted as a two-digit hexadecimal number. Reply: @table @samp @item OK -for success -@item E @var{NN} -for an error (this includes the case where only part of the data was -written). +All the data was written successfully. (If only part of the data was +written, this command returns an error.) @end table @item p @var{n} @@ -42904,10 +42906,6 @@ Reply: @table @samp @item @var{XX@dots{}} the register's value -@item E @var{NN} -for an error -@item @w{} -Indicating an unrecognized @var{query}. @end table @item P @var{n@dots{}}=@var{r@dots{}} @@ -42921,8 +42919,6 @@ Reply: @table @samp @item OK for success -@item E @var{NN} -for an error @end table @item q @var{name} @var{params}@dots{} @@ -42982,8 +42978,6 @@ Reply: @table @samp @item OK thread is still alive -@item E @var{NN} -thread is dead @end table @item v @@ -43011,8 +43005,6 @@ This packet is only available in extended mode (@pxref{extended mode}). Reply: @table @samp -@item E @var{nn} -for an error @item @r{Any stop packet} for success in all-stop mode (@pxref{Stop Reply Packets}) @item OK @@ -43101,8 +43093,6 @@ Reply: @item vCont@r{[};@var{action}@dots{}@r{]} The @samp{vCont} packet is supported. Each @var{action} is a supported command in the @samp{vCont} packet. -@item @w{} -The @samp{vCont} packet is not supported. @end table @anchor{vCtrlC packet} @@ -43117,8 +43107,6 @@ variant. Reply: @table @samp -@item E @var{nn} -for an error @item OK for success @end table @@ -43143,8 +43131,6 @@ Reply: @table @samp @item OK for success -@item E @var{NN} -for an error @end table @item vFlashWrite:@var{addr}:@var{XX@dots{}} @@ -43167,8 +43153,6 @@ Reply: for success @item E.memtype for vFlashWrite addressing non-flash memory -@item E @var{NN} -for an error @end table @item vFlashDone @@ -43190,8 +43174,6 @@ supported; see @ref{multiprocess extensions}. Reply: @table @samp -@item E @var{nn} -for an error @item OK for success @end table @@ -43223,8 +43205,6 @@ This packet is only available in extended mode (@pxref{extended mode}). Reply: @table @samp -@item E @var{nn} -for an error @item @r{Any stop packet} for success (@pxref{Stop Reply Packets}) @end table @@ -43245,8 +43225,6 @@ Reply: @table @samp @item OK for success -@item E @var{NN} -for an error @end table @item z @var{type},@var{addr},@var{kind} @@ -43327,10 +43305,6 @@ Reply: @table @samp @item OK success -@item @w{} -not supported -@item E @var{NN} -for an error @end table @item z1,@var{addr},@var{kind} @@ -43352,10 +43326,6 @@ Reply: @table @samp @item OK success -@item @w{} -not supported -@item E @var{NN} -for an error @end table @item z2,@var{addr},@var{kind} @@ -43369,10 +43339,6 @@ Reply: @table @samp @item OK success -@item @w{} -not supported -@item E @var{NN} -for an error @end table @item z3,@var{addr},@var{kind} @@ -43386,10 +43352,6 @@ Reply: @table @samp @item OK success -@item @w{} -not supported -@item E @var{NN} -for an error @end table @item z4,@var{addr},@var{kind} @@ -43403,10 +43365,6 @@ Reply: @table @samp @item OK success -@item @w{} -not supported -@item E @var{NN} -for an error @end table @end table @@ -43776,8 +43734,6 @@ detect trailing zeros. Reply: @table @samp -@item E @var{NN} -An error (such as memory fault) @item C @var{crc32} The specified memory region's checksum is @var{crc32}. @end table @@ -43800,13 +43756,6 @@ Reply: @table @samp @item OK The request succeeded. - -@item E @var{nn} -An error occurred. The error number @var{nn} is given as hex digits. - -@item @w{} -An empty reply indicates that @samp{QDisableRandomization} is not supported -by the stub. @end table This packet is not probed by default; the remote stub must request it, @@ -43835,9 +43784,6 @@ Reply: @table @samp @item OK The request succeeded. - -@item E @var{nn} -An error occurred. The error number @var{nn} is given as hex digits. @end table This packet is not probed by default; the remote stub must request it, @@ -44027,12 +43973,6 @@ Reply: @item @var{XX}@dots{} Hex encoded (big endian) bytes representing the address of the thread local storage requested. - -@item E @var{nn} -An error occurred. The error number @var{nn} is given as hex digits. - -@item @w{} -An empty reply indicates that @samp{qGetTLSAddr} is not supported by the stub. @end table @item qGetTIBAddr:@var{thread-id} @@ -44047,13 +43987,6 @@ Reply: @item @var{XX}@dots{} Hex encoded (big endian) bytes representing the linear address of the thread information block. - -@item E @var{nn} -An error occurred. This means that either the thread was not found, or the -address could not be retrieved. - -@item @w{} -An empty reply indicates that @samp{qGetTIBAddr} is not supported by the stub. @end table @item qL @var{startflag} @var{threadcount} @var{nextthread} @@ -44093,20 +44026,15 @@ is architecture-specific. @var{type} is the type of tag the request wants to fetch. The type is a signed integer. +@value{GDBN} will only send this packet if the stub has advertised +support for memory tagging via @samp{qSupported}. + Reply: @table @samp @item @var{mxx}@dots{} Hex encoded sequence of uninterpreted bytes, @var{xx}@dots{}, representing the tags found in the requested memory range. -@item E @var{nn} -An error occurred. This means that fetching of memory tags failed for some -reason. - -@item @w{} -An empty reply indicates that @samp{qMemTags} is not supported by the stub, -although this should not happen given @value{GDBN} will only send this packet -if the stub has advertised support for memory tagging via @samp{qSupported}. @end table @cindex check if a given address is in a memory tagged region @@ -44171,20 +44099,14 @@ integer. interpreted by the target. Each pair of hex digits is interpreted as a single byte. +@value{GDBN} will only send this packet if the stub has advertised +support for memory tagging via @samp{qSupported}. + Reply: @table @samp @item OK The request was successful and the memory tag granules were modified accordingly. - -@item E @var{nn} -An error occurred. This means that modifying the memory tag granules failed -for some reason. - -@item @w{} -An empty reply indicates that @samp{QMemTags} is not supported by the stub, -although this should not happen given @value{GDBN} will only send this packet -if the stub has advertised support for memory tagging via @samp{qSupported}. @end table @item qOffsets @@ -44241,13 +44163,6 @@ Reply: @table @samp @item OK The request succeeded. - -@item E @var{nn} -An error occurred. The error number @var{nn} is given as hex digits. - -@item @w{} -An empty reply indicates that @samp{QNonStop} is not supported by -the stub. @end table This packet is not probed by default; the remote stub must request it, @@ -44284,13 +44199,6 @@ Reply: @table @samp @item OK The request succeeded. - -@item E @var{nn} -An error occurred. @var{nn} are hex digits. - -@item @w{} -An empty reply indicates that @samp{QCatchSyscalls} is not supported by -the stub. @end table Use of this packet is controlled by the @code{set remote catch-syscalls} @@ -44316,13 +44224,6 @@ Reply: @table @samp @item OK The request succeeded. - -@item E @var{nn} -An error occurred. The error number @var{nn} is given as hex digits. - -@item @w{} -An empty reply indicates that @samp{QPassSignals} is not supported by -the stub. @end table Use of this packet is controlled by the @code{set remote pass-signals} @@ -44358,13 +44259,6 @@ Reply: @table @samp @item OK The request succeeded. - -@item E @var{nn} -An error occurred. The error number @var{nn} is given as hex digits. - -@item @w{} -An empty reply indicates that @samp{QProgramSignals} is not supported -by the stub. @end table Use of this packet is controlled by the @code{set remote program-signals} @@ -44398,13 +44292,6 @@ Reply: @table @samp @item OK The request succeeded. - -@item E @var{nn} -An error occurred. The error number @var{nn} is given as hex digits. - -@item @w{} -An empty reply indicates that @samp{QThreadEvents} is not supported by -the stub. @end table Use of this packet is controlled by the @code{set remote thread-events} @@ -44487,13 +44374,6 @@ Reply: @table @samp @item OK The request succeeded. - -@item E @var{nn} -An error occurred. The error number @var{nn} is given as hex digits. - -@item @w{} -An empty reply indicates that @samp{QThreadOptions} is not supported by -the stub. @end table Use of this packet is controlled by the @code{set remote thread-options} @@ -44515,11 +44395,6 @@ Reply: A command response with no output. @item @var{OUTPUT} A command response with the hex encoded output string @var{OUTPUT}. -@item E @var{NN} -Indicate a badly formed request. The error number @var{NN} is given as -hex digits. -@item @w{} -An empty reply indicates that @samp{qRcmd} is not recognized. @end table (Note that the @code{qRcmd} packet's name is separated from the @@ -44544,10 +44419,6 @@ Reply: The pattern was not found. @item 1,address The pattern was found at @var{address}. -@item E @var{NN} -A badly formed request or an error was encountered while searching memory. -@item @w{} -An empty reply indicates that @samp{qSearch:memory} is not recognized. @end table @item QStartNoAckMode @@ -44563,8 +44434,6 @@ The stub has switched to no-acknowledgment mode. @value{GDBN} acknowledges this response, but neither the stub nor @value{GDBN} shall send or expect further @samp{+}/@samp{-} acknowledgments in the current connection. -@item @w{} -An empty reply indicates that the stub does not support no-acknowledgment mode. @end table @item qSupported @r{[}:@var{gdbfeature} @r{[};@var{gdbfeature}@r{]}@dots{} @r{]} @@ -44593,9 +44462,6 @@ Reply: The stub supports or does not support each returned @var{stubfeature}, depending on the form of each @var{stubfeature} (see below for the possible forms). -@item @w{} -An empty reply indicates that @samp{qSupported} is not recognized, -or that no features needed to be reported to @value{GDBN}. @end table The allowed forms for each feature (either a @var{gdbfeature} in the @@ -45316,17 +45182,6 @@ have fewer bytes than the @var{length} in the request. @item l The @var{offset} in the request is at the end of the data. There is no more data to be read. - -@item E00 -The request was malformed, or @var{annex} was invalid. - -@item E @var{nn} -The offset was invalid, or there was an error encountered reading the data. -The @var{nn} part is a hex-encoded @code{errno} value. - -@item @w{} -An empty reply indicates the @var{object} string was not recognized by -the stub, or that the object does not support reading. @end table Here are the specific requests of this form defined so far. All the @@ -45545,17 +45400,6 @@ Reply: @item @var{nn} @var{nn} (hex encoded) is the number of bytes written. This may be fewer bytes than supplied in the request. - -@item E00 -The request was malformed, or @var{annex} was invalid. - -@item E @var{nn} -The offset was invalid, or there was an error encountered writing the data. -The @var{nn} part is a hex-encoded @code{errno} value. - -@item @w{} -An empty reply indicates the @var{object} string was not -recognized by the stub, or that the object does not support writing. @end table Here are the specific requests of this form defined so far. All the @@ -45600,8 +45444,6 @@ Reply: The remote server attached to an existing process. @item 0 The remote server created a new process. -@item E @var{NN} -A badly formed request or an error was encountered. @end table @item Qbtrace:bts @@ -45805,8 +45647,6 @@ Replies: The packet was understood and carried out. @item qRelocInsn @xref{Tracepoint Packets,,Relocate instruction reply packet}. -@item @w{} -The packet was not recognized. @end table @item QTDP:-@var{n}:@var{addr}:@r{[}S@r{]}@var{action}@dots{}@r{[}-@r{]} @@ -45871,8 +45711,6 @@ Replies: The packet was understood and carried out. @item qRelocInsn @xref{Tracepoint Packets,,Relocate instruction reply packet}. -@item @w{} -The packet was not recognized. @end table @item QTDPsrc:@var{n}:@var{addr}:@var{type}:@var{start}:@var{slen}:@var{bytes} @@ -45989,8 +45827,6 @@ of 1 means that a fast tracepoint may be placed on any instruction regardless of size. @item E An error has occurred. -@item @w{} -An empty reply indicates that the request is not supported by the stub. @end table @item QTStart @@ -46199,11 +46035,6 @@ A single marker a comma-separated list of markers @item l (lower case letter @samp{L}) denotes end of list. -@item E @var{nn} -An error occurred. The error number @var{nn} is given as hex digits. -@item @w{} -An empty reply indicates that the request is not supported by the -stub. @end table The @var{address} is encoded in hex; @@ -46292,9 +46123,6 @@ Replies: @item qRelocInsn:@var{adjusted_size} Informs the stub the relocation is complete. The @var{adjusted_size} is the length in bytes of resulting relocated instruction sequence. -@item E @var{NN} -A badly formed request was detected, or an error was encountered while -relocating the instruction. @end table @node Host I/O Packets From patchwork Fri Apr 19 15:13:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88743 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 ED48C3846047 for ; Fri, 19 Apr 2024 15:15:10 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by sourceware.org (Postfix) with ESMTPS id E91D8384770C for ; Fri, 19 Apr 2024 15:13:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E91D8384770C 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 E91D8384770C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539638; cv=none; b=XadMBryJWNjGZYjD07CKVfX7N4wFoLVjkl/Q6zxE179sugdMQDHBhspX90KJbFvbcYCfyiu2GXn+2hQyzDSq6YWY076ii8D9AVembG2SsX9/TGt3UNjtvq/rSHlYEONhL3TQbLNXNTQXZoa8yKQe0IIlQw3M5+qJRS7/Pb8uhvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539638; c=relaxed/simple; bh=+dkL37xZgHBzL6HR+5CW/a3vc1EbSXGOisyS5QAsSgg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=ayWbyk//GduOWNI2Vwz0UU77IiSnS0MyFTOXCNF6dATWf2dfIwJuZoMIYcVLsQhMTCZCakRa9m3wcG+d0T21+52Vzd7eiIGMtFtZRc51DmHhcYuUbRghYCibou2e+LI4Pu9D6pCvB2YOLW6GjrxmHWNgV7oZBUe5SvgC3H3OezE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-34a4772d5easo1126521f8f.0 for ; Fri, 19 Apr 2024 08:13:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539633; x=1714144433; 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=qCTT64AE7sBnHcx2g78LO92xgnuMazuTpwsopG6b9BQ=; b=mx7WljH/vfLLRrxyn460FvLFs16TWAzaa0kwxqi8/mqnwzYeBhNwM1i9532RtV4sWR /hMNoQf8PwMX3NgWHH/Q8WUQYknJs+3vJr3y3S4TL3i5vgnpkn3SCTAHD0ycek5wbA8o kO3Y7DaOf8S+xrS0m9VG6jqpVMZWziH2tzx/tYfawGaKiL8uRLvkv181yIGNA5szQ8E0 SOsiyOIWNAKjDWfFXrw/7/wUNe31t4v+t4wd+g3EcksXVJrobnvqJ+0JHNYgHwiZiWof M9A10vM6JqR8pS1NqsE/23jq8sVUGcDdMrHbAmM1GsKz0gafweb0NKDDj/VAaGTa96+t zE3g== X-Gm-Message-State: AOJu0YwhtrD4l3NMPx7a0kC9HododIktbd/OPfkd5G4CZjifwnHkGJsQ 15tjYPxKBCy/NKklVCORnZaPjB+G6A2pXTdFCryEcthILSnDcW39xOC+g8ye X-Google-Smtp-Source: AGHT+IFVcP9AdDmhrLTU+UM25ho+5onegkJQN4krzj2gamTjDPxmJrwbnD3uDiBP75BEOP8yoTbuuw== X-Received: by 2002:adf:a418:0:b0:347:48f8:9a8 with SMTP id d24-20020adfa418000000b0034748f809a8mr1619605wra.19.1713539633382; Fri, 19 Apr 2024 08:13:53 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id d9-20020a056000114900b003469e7f5c52sm4675097wrx.80.2024.04.19.08.13.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:13:52 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Jim Blandy , Mike Wrighton , Nathan Sidwell , Hafiz Abid Qadeer Subject: [PATCH 03/12] Document "E.MESSAGE" RSP errors Date: Fri, 19 Apr 2024 16:13:33 +0100 Message-ID: <20240419151342.1592474-4-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.4 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 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 For many years, GDB has accepted a "E.MESSAGE" error reponse, in addition to "E NN". For many packets, GDB strips the "E." before giving the error message to the user. For others, GDB does not strip the "E.", but still understands that it is an error, as it starts with "E", and either prints the whole string, or ignores it and just mentions an error occured (same as for "E NN"). This has been the case for as long as I remember. Now that I check, I see that it's been there since 2006 (commit a76d924dffcb, also here: https://sourceware.org/pipermail/gdb-patches/2006-September/047286.html). All along, I actually thought it was documented. Turns out it wasn't. This commit documents it, in the new "Standard Replies" section, near where we document "E NN". The original version of this 3-patch documentation series was a single CodeSourcery patch that documented the textual error as "E.NAME.MESSAGE", with MESSAGE being 8-bit binary encoded. But I think the ship has sailed for that. GDBserver has been sending error messages with more than one "." for a long while, and with no binary encoding. Still, I've preserved the "Co-Authored-By" list of the original larger patch. Change-Id: Ie4fee3d00d82ede39e439bf162e8cb7485532fd8 Co-Authored-By: Jim Blandy Co-Authored-By: Mike Wrighton Co-Authored-By: Nathan Sidwell Co-Authored-By: Hafiz Abid Qadeer Reviewed-By: Andrew Burgess --- gdb/doc/gdb.texinfo | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 57260a5b2fa..d6184d52841 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -42557,6 +42557,10 @@ number. In almost all cases, the protocol does not specify the meaning of the error numbers; @value{GDBN} usually ignores the numbers, or displays them to the user without further interpretation. +@item @samp{E.@var{message}} +An error has occurred; @var{message} is the textual error message, +encoded in @sc{ascii}. + @end table @node Packets From patchwork Fri Apr 19 15:13:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88742 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 4FA763846420 for ; Fri, 19 Apr 2024 15:14:59 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by sourceware.org (Postfix) with ESMTPS id E3D543849AE1 for ; Fri, 19 Apr 2024 15:13:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E3D543849AE1 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 E3D543849AE1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539642; cv=none; b=Y/WmmhUHF6WADvDqvMgBFj6083AwNKfPvV4SdHd8imoPvbLB7MkvlYe4tgFzZuulIMYi90c81mAP97t8pkj0crnJx+r2tlLyy7F09QTxP8lN5WfZ7cdWHfbjFsVnb6FMvAOj2ay+Fb931PfMgFBDaz0zcTQoPAatSKfTRZQvn+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539642; c=relaxed/simple; bh=CqrsICX3sAsU9wy7N37YAmMKHejumn8iEoQCjPe78DE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Vy4+oCfZ3rtk7rRvKziETAZRwaDOqgVOHLqqXM6MmDHxHAWJnGNMe2DXgtklXfp61eXb9XH1oAji5ZO32QzAU6Gh2YCyKev/OXl43Lnq3YXenME4S/6xX3N7jN9UQwMKh0FbrfSEo/g/rGQnz0S/mih0rTmVIJ33elpu2B24nGE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2d8b4778f5fso21071691fa.3 for ; Fri, 19 Apr 2024 08:13:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539636; x=1714144436; 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=9pLeGk4n+kUdJvnn3ymntfohQ2apkb9XfUbfn2Zf0o4=; b=YuzotUWoBmcsxDJBCQXSpJWbDdlfndo34HxvlfBm7nYy8Qaw4SoHe2vXTOVlKWmiHh KbKPaB2O1YfQNZwS23V19hMGh4yh4EULczJEu2RM6UghPFlyVZsCATStYf9DIA9C2LrR dY+QEOBKNJjbyifc/8l0edROzX8YU4zm0UQDubzTsObOMMGFCkO1gR2uO8TWjd/uqcWx yuBHwkFVWB3LUZzjRL1Dk+uPSk7fch14yxXF41ypXdyTGW3T6Xw64Xkn5+8WhuOiNmeC ErL0YeUkY3kOyzx2DUxT0R0X/JKX9UlbFXSOloCX8G1kqLg1BovxNbc1jBcsBvqVNxDc SM0g== X-Gm-Message-State: AOJu0YykwrU8H2tviOZlYeNybZ/2DANThn0gL5Ui0tsNnVivMyiXtmK6 QbH0zVIJ4AYoFdJCKhJGBWKw072TJj7mIgYJtMGX7ZVdNxVVIujMAbTSIf8T X-Google-Smtp-Source: AGHT+IEWi9Cly9kUFglYiZahkxAcDUZgIw73e7w1h1/JJLSAAK5smcLrYUzNlVCD9w2C6sqGk+zg1g== X-Received: by 2002:a05:651c:794:b0:2da:7944:9525 with SMTP id g20-20020a05651c079400b002da79449525mr1362378lje.49.1713539636022; Fri, 19 Apr 2024 08:13:56 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id a12-20020a056000188c00b00347eb354b30sm4775053wri.84.2024.04.19.08.13.55 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:13:55 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 04/12] Windows: Fix run/attach hang after bad run/attach Date: Fri, 19 Apr 2024 16:13:34 +0100 Message-ID: <20240419151342.1592474-5-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 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 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 On Cygwin, gdb.base/attach.exp exposes that an "attach" after a previously failed "attach" hangs: (gdb) PASS: gdb.base/attach.exp: do_attach_failure_tests: attach to digits-starting nonsense is prohibited attach 0 Can't attach to process 0 (error 2: The system cannot find the file specified.) (gdb) PASS: gdb.base/attach.exp: do_attach_failure_tests: attach to nonexistent process is prohibited attach 10644 FAIL: gdb.base/attach.exp: do_attach_failure_tests: first attach (timeout) The problem is that windows_nat_target::attach always returns success even if the attach fails. When we return success, the helper thread begins waiting for events (which will never come), and thus the next attach deadlocks on the do_synchronously call within windows_nat_target::attach. "run" has the same problem, which is exposed by the new gdb.base/run-fail-twice.exp testcase added in a following patch: (gdb) run Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox Error creating process .../gdb.base/run-fail-twice/run-fail-twice.nox, (error 6: The handle is invalid.) (gdb) PASS: gdb.base/run-fail-twice.exp: test: bad run 1 run Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox FAIL: gdb.base/run-fail-twice.exp: test: bad run 2 (timeout) The problem here is the same, except that this time it is windows_nat_target::create_inferior that returns the incorrect result. This commit fixes both the "attach" and "run" paths, and the latter both the Cygwin and MinGW paths. The tests mentioned above now pass on Cygwin. Confirmed the fixes manually for MinGW GDB. Change-Id: I15ec9fa279aff269d4982b00f4ea7c25ae917239 --- gdb/windows-nat.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index a53b6a6e053..d61ed95a7fb 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2059,7 +2059,7 @@ windows_nat_target::attach (const char *args, int from_tty) if (!ok) err = (unsigned) GetLastError (); - return true; + return ok; }); if (err.has_value ()) @@ -2784,12 +2784,15 @@ windows_nat_target::create_inferior (const char *exec_file, windows_init_thread_list (); do_synchronously ([&] () { - if (!create_process (nullptr, args, flags, w32_env, - inferior_cwd != nullptr ? infcwd : nullptr, - disable_randomization, - &si, &pi)) + BOOL ok = create_process (nullptr, args, flags, w32_env, + inferior_cwd != nullptr ? infcwd : nullptr, + disable_randomization, + &si, &pi); + + if (!ok) ret = (unsigned) GetLastError (); - return true; + + return ok; }); if (w32_env) @@ -2910,16 +2913,18 @@ windows_nat_target::create_inferior (const char *exec_file, windows_init_thread_list (); do_synchronously ([&] () { - if (!create_process (nullptr, /* image */ - args, /* command line */ - flags, /* start flags */ - w32env, /* environment */ - inferior_cwd, /* current directory */ - disable_randomization, - &si, - &pi)) + BOOL ok = create_process (nullptr, /* image */ + args, /* command line */ + flags, /* start flags */ + w32env, /* environment */ + inferior_cwd, /* current directory */ + disable_randomization, + &si, + &pi); + if (!ok) ret = (unsigned) GetLastError (); - return true; + + return ok; }); if (tty != INVALID_HANDLE_VALUE) CloseHandle (tty); From patchwork Fri Apr 19 15:13:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88747 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 9B1E03844744 for ; Fri, 19 Apr 2024 15:15:45 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by sourceware.org (Postfix) with ESMTPS id 9BBC03849AE8 for ; Fri, 19 Apr 2024 15:14:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9BBC03849AE8 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 9BBC03849AE8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539644; cv=none; b=TG/LELcQoOz2KClllh6ttoZGqGZ6EkBMnZhIsYHh45JWx3yB+u3WBQBfyqg1/1S9CMh8xI88s7mQY5yhMrTqi4pWkWH0RgXToQG0F/Tg/LzmB0MZX+ttHCA8dGDmwAoiKvCm1E/1EiYVhJviWnEBLMhmu8P40j3i7kdRf7+5Dhg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539644; c=relaxed/simple; bh=NYHaXGe685prUsveuwIrTm7tU1PFws8zQdEdsukwfgM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=FCfR2UPnNV2QgmfRVvuHqG2GfNEQfCmmiGf5DEH0W8wP71klDK1DQzJQ/bgQNKSSPuFFxOfuwFK/rabKQOXl9iC/HYZVyHOiSYpHx3mi5lW8/pviQ0rOMAUypwteKSFFOytA4o7tFTvlCZsgwy6PwjzkF4TYuEg9huVXOaJSLk4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-419c8c314d4so2560495e9.0 for ; Fri, 19 Apr 2024 08:14:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539640; x=1714144440; 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=z+6mVsoR+YRDsQk5fTTG99oznTAZPszt3Rwfx9KY+vU=; b=hMFlaV7Tv5mdoy0glCC18AN2zBQ4VkowMUXI6NIntYq9oiNho3+z/86+eh70CCPQzb EBB+uyKosDKeNfyrwqfjySZ/IuWfCVuxUpjH0h5qXOJGi5WFVomTwCBCH8p717gunrdX aZeW4mzE/6LQ9Kc2SW2BeAai03acurgHupPypJK1UkVsT3cSbr0Q4H0/fe2r4IL+URyA AnZ9zYJObCL9Z9kZmhwTzOsGn1G1iKyDPTLz4zXatxOXRJjvp/flnqlQu3WDHGg5y/dD wozGoj/DVbipum+bbbF9C5mn3HlNO8zav2uhYKreXFYOs44JmU6uW3vXyAmUkA6vZ/+e nhdw== X-Gm-Message-State: AOJu0YyU0JUbX+hSYq1XzfFuw7eijo8T1lTbggpAZksw4CFtneTF7Rk5 WEB0p3ox1/x1uMSlFjDWY92CLZagygMKzWhU4r8N+xMxJs7ZxL5iqa+m4SLS X-Google-Smtp-Source: AGHT+IHIE7Yrv6ZwRcyEI0e5lr+WSrq7x+FS1Ydgni0J+SHNnFJYXuOuGT43zFn3BsxLEv4GGJDj+g== X-Received: by 2002:a05:600c:3acd:b0:419:b36:7e43 with SMTP id d13-20020a05600c3acd00b004190b367e43mr1494331wms.7.1713539639536; Fri, 19 Apr 2024 08:13:59 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id r18-20020a05600c35d200b00418d434ae4esm6795860wmq.10.2024.04.19.08.13.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:13:59 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 05/12] Fix "run" failure handling with GDBserver Date: Fri, 19 Apr 2024 16:13:35 +0100 Message-ID: <20240419151342.1592474-6-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 If starting the inferior process with "run" (vRun packet) fails, GDBserver throws an error that escapes all the way to the top level. When an error escapes all the way like that, GDBserver interprets it as a disconnection, and either goes back to waiting for a new GDB connection, or exits, if --once was specified. E.g., with the testcase program added by this commit, we see: On GDB side: ... (gdb) tar extended-remote :999 ... Remote debugging using :9999 (gdb) r Starting program: Running ".../gdb.base/run-fail-twice/run-fail-twice.nox" on the remote target failed (gdb) On GDBserver side: $ gdbserver --once --multi :9999 Remote debugging from host 127.0.0.1, port 34344 bash: line 1: .../gdb.base/run-fail-twice/run-fail-twice.nox: Permission denied bash: line 1: exec: .../gdb.base/run-fail-twice/run-fail-twice.nox: cannot execute: Permission denied gdbserver: During startup program exited with code 126. $ # gdbserver exited This is wrong, as we've connected with extended-remote/--multi. GDBserver should just report an error to vCont, and continue connected to GDB, waiting for other commands. This commit fixes GDBserver by catching the error locally in handle_v_run. Change-Id: Ib386f267522603f554b52a885b15229c9639e870 --- gdb/testsuite/gdb.base/run-fail-twice.c | 20 +++++++ gdb/testsuite/gdb.base/run-fail-twice.exp | 63 +++++++++++++++++++++++ gdbserver/server.cc | 10 +++- 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.base/run-fail-twice.c create mode 100644 gdb/testsuite/gdb.base/run-fail-twice.exp diff --git a/gdb/testsuite/gdb.base/run-fail-twice.c b/gdb/testsuite/gdb.base/run-fail-twice.c new file mode 100644 index 00000000000..fddf841eb3e --- /dev/null +++ b/gdb/testsuite/gdb.base/run-fail-twice.c @@ -0,0 +1,20 @@ +/* Copyright 2024 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +int +main (int argc, char **argv) +{ + return 0; +} diff --git a/gdb/testsuite/gdb.base/run-fail-twice.exp b/gdb/testsuite/gdb.base/run-fail-twice.exp new file mode 100644 index 00000000000..676fc486fbf --- /dev/null +++ b/gdb/testsuite/gdb.base/run-fail-twice.exp @@ -0,0 +1,63 @@ +# Copyright 2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test doing a "run" that fails, and then another "run". + +require target_can_use_run_cmd + +standard_testfile + +if {[build_executable "failed to build" $testfile $srcfile {debug}]} { + return -1 +} + +proc test_run {testname} { + gdb_test_multiple "run" $testname { + -re -wrap "During startup program exited with code 126\\." { + # What we get on GNU/Linux. + pass $gdb_test_name + } + -re -wrap "Error creating process.*" { + # What we get on Windows. + pass $gdb_test_name + } + -re -wrap "Running .* on the remote target failed" { + # What we get with remote targets. + pass $gdb_test_name + } + } +} + +proc_with_prefix test {} { + global gdb_prompt binfile + + clean_restart $binfile + + gdb_test_no_output "set confirm off" + + gdb_remote_download host $binfile $binfile.nox + remote_exec target "chmod \"a-x\" $binfile.nox" + gdb_test_no_output \ + "exec-file $binfile.nox" \ + "exec-file \$binfile.nox" + gdb_test_no_output \ + "set remote exec-file $binfile.nox" \ + "set remote exec-file \$binfile.nox" + + test_run "bad run 1" + test_run "bad run 2" +} + +test diff --git a/gdbserver/server.cc b/gdbserver/server.cc index c7d5cc1c1b0..b170da44f6a 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -3427,7 +3427,15 @@ handle_v_run (char *own_buf) free_vector_argv (program_args); program_args = new_argv; - target_create_inferior (program_path.get (), program_args); + try + { + target_create_inferior (program_path.get (), program_args); + } + catch (const gdb_exception_error &exception) + { + sprintf (own_buf, "E.%s", exception.what ()); + return; + } if (cs.last_status.kind () == TARGET_WAITKIND_STOPPED) { From patchwork Fri Apr 19 15:13:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88744 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 A5D6A3849AFC for ; Fri, 19 Apr 2024 15:15:24 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by sourceware.org (Postfix) with ESMTPS id 106683849AF4 for ; Fri, 19 Apr 2024 15:14:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 106683849AF4 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 106683849AF4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539648; cv=none; b=VsRuQ9oxzSbkJ9deDhOyc2fo52nGfHu5FqqL9Ge5VDPoWRKE884CFwkJ2ogmyPM9aBtjRFmx0lOTwcRk0uzFjVh3v8IaU3y41oZevbFE1LEW4smfmrKkAnC6kvVpr5YPwUSlxQBhBpRuRSh1QVMlKBLFGzWba1LFce7eoJg/Kg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539648; c=relaxed/simple; bh=hESiXq+5hsUbL0lTAJ51Uu3X3YolUfvAAOO1O47G4LU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=ROdy0HO5X1Fu+vdSmKCvEMdTHFv/Eq69ewmsZhcOHq8m1Ko6F24flS11ltAW30b/XBnGUmAPBa/a1+VGbjV1LeDo2HRc3n4tFZhbxn8oBNgrHOxu7mRYwwT6lj88PxXFUY+5p6ICm08H9YkRUX1fxxzcPYOW297SoM9ip5bvamc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-344047ac7e4so2015475f8f.0 for ; Fri, 19 Apr 2024 08:14:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539644; x=1714144444; 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=7eJ0kYMA6qSjpPVsAuN6fj2FvMIon1uApzvpR6KW0ro=; b=FXBmjjhH13mCoJusEhXGTuRVrRMqoyZprZCpN0khmPEYdXe2tCqaT6dT5X3m2oI7aK P4m3snNTSd4NA2nL2KKF+bvrwR+uYjqNfAAVdgA2htgA0IZgcDgRub6BeZZx8S2Ke8Zv rn0Uf2mGf5QHBmPA/763QTP86mF8ZTteUA5IYXo2CCaCejf2LsrU9KtkBUSqR3cA5h7e tZTEwfMF4HmwTXqFuF4F94SzgvYm8owObabT6gmZwJrSrVucAlK211uuwB6zAXGPo1cB dDOcvevLTEpauIThTxYc9NXnaqXvWK2YfR5jAv04oCS5Y/El8OHnsRzr0epG4ga7xuFr Himw== X-Gm-Message-State: AOJu0YzYKgvT/z8M3Y+JaZDbKh86n73F1SC1+oDM8bxfLNCKi65WZqUG z5bZ9/2dBFqVCQTI+Q5gT11oVHbU8yXN3TbNwIKzwqOzPnAYuHpH8AbhQC40 X-Google-Smtp-Source: AGHT+IFYZvsdu99G73hvTvrQHQoB9OVe8ndXI9XDaV7d8oySlAF7HMC//muidD0C5X0TB2hO8d1rxw== X-Received: by 2002:a5d:5906:0:b0:346:f091:fb75 with SMTP id v6-20020a5d5906000000b00346f091fb75mr1974018wrd.33.1713539643520; Fri, 19 Apr 2024 08:14:03 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id h15-20020a056000000f00b003434c764f01sm4636427wrx.107.2024.04.19.08.14.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:14:03 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 06/12] Improve vRun error reporting Date: Fri, 19 Apr 2024 16:13:36 +0100 Message-ID: <20240419151342.1592474-7-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 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 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 After the previous commit, if starting the inferior process with "run" (vRun packet) fails, GDBserver reports an error using the "E." textual error packet. On the GDB side, however, GDB doesn't yet do anything with the textual error string. This commit improves 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. To know whether we have a textual error message, extend packet_result to carry that information. While at it, convert packet_result to use factory methods, and change its std::string parameter to a plain const char *, as that it always what we have handy to pass to it. Change-Id: Ib386f267522603f554b52a885b15229c9639e870 --- gdb/remote.c | 67 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index cfb54de157d..8ef808c5ad6 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -158,20 +158,27 @@ enum packet_status /* Keeps packet's return value. If packet's return value is PACKET_ERROR, err_msg contains an error message string from E.string or the number stored as a string from E.num. */ -struct packet_result +class packet_result { - packet_result (enum packet_status status, std::string err_msg) - : m_status (status), m_err_msg (std::move (err_msg)) - { - gdb_assert (status == PACKET_ERROR); - } +private: + /* Private ctors for internal use. Clients should use the public + factory static methods instead. */ + + /* Construct a PACKET_ERROR packet_result. */ + packet_result (const char *err_msg, bool textual_err_msg) + : m_status (PACKET_ERROR), + m_err_msg (err_msg), + m_textual_err_msg (textual_err_msg) + {} + /* Construct an PACKET_OK/PACKET_UNKNOWN packet_result. */ explicit packet_result (enum packet_status status) : m_status (status) { gdb_assert (status != PACKET_ERROR); } +public: enum packet_status status () const { return this->m_status; @@ -183,9 +190,39 @@ struct packet_result return this->m_err_msg.c_str (); } + bool textual_err_msg () const + { + gdb_assert (this->m_status == PACKET_ERROR); + return this->m_textual_err_msg; + } + + static packet_result make_numeric_error (const char *err_msg) + { + return packet_result (err_msg, false); + } + + static packet_result make_textual_error (const char *err_msg) + { + return packet_result (err_msg, true); + } + + static packet_result make_ok () + { + return packet_result (PACKET_OK); + } + + static packet_result make_unknown () + { + return packet_result (PACKET_UNKNOWN); + } + private: enum packet_status m_status; std::string m_err_msg; + + /* True if we have a textual error message, from an "E.MESSAGE" + response. */ + bool m_textual_err_msg; }; /* Enumeration of packets for a remote target. */ @@ -2473,7 +2510,7 @@ packet_check_result (const char *buf, bool accept_msg) && isxdigit (buf[1]) && isxdigit (buf[2]) && buf[3] == '\0') /* "Enn" - definitely an error. */ - return { PACKET_ERROR, buf + 1 }; + return packet_result::make_numeric_error (buf + 1); /* Not every request accepts an error in a E.msg form. Some packets accepts only Enn, in this case E. is not @@ -2485,19 +2522,19 @@ packet_check_result (const char *buf, bool accept_msg) if (buf[0] == 'E' && buf[1] == '.') { if (buf[2] != '\0') - return { PACKET_ERROR, buf + 2 }; + return packet_result::make_textual_error (buf + 2); else - return { PACKET_ERROR, "no error provided" }; + return packet_result::make_textual_error ("no error provided"); } } /* The packet may or may not be OK. Just assume it is. */ - return packet_result (PACKET_OK); + return packet_result::make_ok (); } else { /* The stub does not support the packet. */ - return packet_result (PACKET_UNKNOWN); + return packet_result::make_unknown (); } } @@ -10704,7 +10741,8 @@ remote_target::extended_remote_run (const std::string &args) putpkt (rs->buf); getpkt (&rs->buf); - switch ((m_features.packet_ok (rs->buf, PACKET_vRun)).status ()) + packet_result result = m_features.packet_ok (rs->buf, PACKET_vRun); + switch (result.status ()) { case PACKET_OK: /* We have a wait response. All is well. */ @@ -10712,6 +10750,11 @@ remote_target::extended_remote_run (const std::string &args) case PACKET_UNKNOWN: return -1; case PACKET_ERROR: + /* If we have a textual error message, print just that. This + makes remote debugging output the same as native output, when + possible. */ + if (result.textual_err_msg ()) + error (("%s"), result.err_msg ()); if (remote_exec_file[0] == '\0') error (_("Running the default executable on the remote target failed; " "try \"set remote exec-file\"?")); From patchwork Fri Apr 19 15:13:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88749 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 8890D3846422 for ; Fri, 19 Apr 2024 15:16:05 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by sourceware.org (Postfix) with ESMTPS id 544B3384641E for ; Fri, 19 Apr 2024 15:14:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 544B3384641E 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 544B3384641E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539651; cv=none; b=wIkKwQHOHp7B5NxeGN5T8Z3SAh73VOXzlaBi6jynnJz4j+ruTIk3XEifomS77FTI7AozdCkJieS/LtDgfSTgvRil3o8WRjTik2969MTq1oPxcugTJD8p9YNhhq7v2rZZ5mFGkm0R4vh2XGCqsyyq8WOS0hh+iVvdXKCFYuUNI8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539651; c=relaxed/simple; bh=f5eEgqJ0JawEHmmgRdxWbXfbhQFzpF+hssXQ1H3nfQ4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=RUT0uwCW6hWT+CrE9zN2lmImBj91RpVibtw8KoDcE+I6MhxpMyeKA8JEXMYIChrWmHjuZMmip4Pc5Mtj9PUQvGH1LSXZqGWaeDZtHtvYnA+e8FOowYy27tidJ3pjQe2IBDTTuPgFZgWE5V0d3/WVHXfirfFUF36h3EvwbgR9MKw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-416a8ec0239so12611615e9.0 for ; Fri, 19 Apr 2024 08:14:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539647; x=1714144447; 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=GghbwyqU55ZVvD65hzISzUbz/amvNOJsjRf8qyg9lPc=; b=DNOqadw9Yh2oVPE3j3UN369fixI2gWVn6c+Hi5osyNyMV55780a9FiKF0qDGwEiQzq NYAfpJ1JKGNHV4ycHZTTqAGYUDczwDWJGDGQmBcyev2tpFfvLf7r4td6tVL07xbyqEvv EFSRbHDfzmw/CYKv5JOiivzuv2oA4N+k4iOvEBfTbefnrWI2XqqLD/kN7of73MkPiYt/ 1aVfTV1JyMbzpRG/+q8nut+RP121b55c9oe/ndaNNvGEZ+E4xIqGWkQ5yazyGAALluEJ G8PZ3l7xn1ry32EX01zkZTvudI3bzVGwt3LsufzphEJtYgWxDaQex88D3cOAyDUhZ2d8 MKnA== X-Gm-Message-State: AOJu0Yzd9m7MJMJBn1xoX7OXgbFBdthhvZ0NJ/y9FvTuNKtHBTKcke8N 3M6FweEb2/4PABkXcB1yLTIwNWRRE2HhsW68GCuVx9hPS/Nd0gB7sZE/I6gv X-Google-Smtp-Source: AGHT+IGk7rrxDwEBnHisAxzXEYhzFZtrRCvXU+DadrPfc07Je4Sv+m7neL+/J5UwaDSUNm4PF2RwJw== X-Received: by 2002:a05:600c:4708:b0:416:6a57:c52 with SMTP id v8-20020a05600c470800b004166a570c52mr2055407wmo.8.1713539647307; Fri, 19 Apr 2024 08:14:07 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id z9-20020a05600c0a0900b00418916f5848sm6621216wmp.43.2024.04.19.08.14.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:14:06 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 07/12] Fix "attach" failure handling with GDBserver Date: Fri, 19 Apr 2024 16:13:37 +0100 Message-ID: <20240419151342.1592474-8-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 This fixes the same issue as the previous patch, but for "attach" instead of "run". If attaching to a process with "attach" (vAttach packet) fails, GDBserver throws an error that escapes all the way to the top level. When an error escapes all the way like that, GDBserver interprets it as a disconnection, and either goes back to waiting for a new GDB connection, or exits, if --once was specified. Here's an example: On the GDB side: ... (gdb) tar extended-remote :9999 ... Remote debugging using :9999 (gdb) attach 1 Attaching to process 1 Attaching to process 1 failed (gdb) On the GDBserver side: $ gdbserver --once --multi :9999 Listening on port 9999 Remote debugging from host 127.0.0.1, port 37464 gdbserver: Cannot attach to process 1: Operation not permitted (1) $ # gdbserver exited This is wrong, as we've connected with extended-remote/--multi. GDBserver should just report an error to vAttach, and continue connected to GDB, waiting for other commands. This commit fixes GDBserver by catching the error locally in handle_v_attach. Note we now let pid == 0 pass down to attach_inferior. That is so we get a useful textual error message to report to GDB. This fixes a couple KFAILs in gdb.base/attach.exp. Still, I thought it would be useful to add a new testcase specifically for this scenario, in case gdb.base/attach.exp is ever split and stops trying to attach again after a failed attach, with the same GDB session. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19558 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31554 Change-Id: I25314c7e5f1435eff69cb84d57ecac13d8de3393 --- gdb/testsuite/gdb.base/attach-fail-twice.c | 27 ++++++ gdb/testsuite/gdb.base/attach-fail-twice.exp | 94 ++++++++++++++++++++ gdb/testsuite/gdb.base/attach.exp | 6 -- gdbserver/server.cc | 41 +++++---- 4 files changed, 145 insertions(+), 23 deletions(-) create mode 100644 gdb/testsuite/gdb.base/attach-fail-twice.c create mode 100644 gdb/testsuite/gdb.base/attach-fail-twice.exp diff --git a/gdb/testsuite/gdb.base/attach-fail-twice.c b/gdb/testsuite/gdb.base/attach-fail-twice.c new file mode 100644 index 00000000000..d045e35e4b4 --- /dev/null +++ b/gdb/testsuite/gdb.base/attach-fail-twice.c @@ -0,0 +1,27 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2024 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +int +main () +{ + for (int i = 0; i < 60; i++) + sleep (1); + + return 0; +} diff --git a/gdb/testsuite/gdb.base/attach-fail-twice.exp b/gdb/testsuite/gdb.base/attach-fail-twice.exp new file mode 100644 index 00000000000..59020463c67 --- /dev/null +++ b/gdb/testsuite/gdb.base/attach-fail-twice.exp @@ -0,0 +1,94 @@ +# Copyright 2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test doing a "attach" that fails, and then another "attach". + +require can_spawn_for_attach + +standard_testfile + +if {[build_executable "failed to build" $testfile $srcfile {debug}]} { + return -1 +} + +set test_spawn_id [spawn_wait_for_attach $binfile] +set testpid [spawn_id_get_pid $test_spawn_id] + +# Test an attach that fails. + +proc test_bad_attach {test} { + global testpid gdb_prompt + + set boguspid 0 + if { [istarget "*-*-*bsd*"] } { + # In FreeBSD 5.0, PID 0 is used for "swapper". Use -1 instead + # (which should have the desired effect on any version of + # FreeBSD, and probably other *BSD's too). + set boguspid -1 + } + gdb_test_multiple "attach $boguspid" $test { + -re "Attaching to.*, process $boguspid.*No such process.*$gdb_prompt $" { + # Response expected on ptrace-based systems (i.e. GNU/Linux). + pass "$test" + } + -re "Attaching to.*, process $boguspid.*denied.*$gdb_prompt $" { + pass "$gdb_test_name" + } + -re "Attaching to.*, process $boguspid.*not permitted.*$gdb_prompt $" { + pass "$gdb_test_name" + } + -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $" { + # Response expected from /proc-based systems. + pass "$gdb_test_name" + } + -re "Can't attach to process..*$gdb_prompt $" { + # Response expected on Windows. + pass "$gdb_test_name" + } + -re "Attaching to.*, process $boguspid.*failed.*$gdb_prompt $" { + # Response expected on the extended-remote target. + pass "$gdb_test_name" + } + } +} + +# Test an attach that succeeds. + +proc test_good_attach {test} { + gdb_test "attach $::testpid" \ + "Attaching to program.*, process $::testpid.*" \ + "$test" + + set thread_count [get_valueof "" "\$_inferior_thread_count" -1] + gdb_assert {$thread_count > 0} \ + "attached" +} + +proc_with_prefix test {} { + clean_restart $::binfile + + # GDB used to have a bug on Windows where failing to attach once + # made a subsequent "attach" or "run" hang. So it's important for + # this regression test that we try to attach more than once. + + test_bad_attach "bad attach 1" + test_bad_attach "bad attach 2" + + # For good measure, test that we can attach to something after + # failing to attach previously. + test_good_attach "good attach" +} + +test diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp index 7907441054b..84b2d27f3eb 100644 --- a/gdb/testsuite/gdb.base/attach.exp +++ b/gdb/testsuite/gdb.base/attach.exp @@ -173,10 +173,6 @@ proc_with_prefix do_attach_failure_tests {} { gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2" gdb_test "inferior 2" "Switching to inferior 2.*" "switch to inferior 2" - # Probe this before the failing attach: the failed attach against GDBserver - # currently leaves the extended-remote target in a bad state. - set do_kfail [target_is_gdbserver] - set test "fail to attach again" gdb_test_multiple "attach $testpid" "$test" { -re "Attaching to process $testpid.*warning: process .* is already traced by process .*$gdb_prompt $" { @@ -193,14 +189,12 @@ proc_with_prefix do_attach_failure_tests {} { gdb_test_no_output "set confirm off" gdb_test "inferior 1" "Switching to inferior 1.*" "switch to inferior 1" - if { $do_kfail } { setup_kfail "gdb/19558" "*-*-*" } gdb_test "kill" "killed.*" "exit after attach failures" # This can probably be replaced with a call to runto or runto_main once # the kfail is removed. gdb_breakpoint "main" gdb_run_cmd - if { $do_kfail } { setup_kfail "gdb/19558" "*-*-*" } gdb_test_multiple "" "stop at main" { -wrap -re "Breakpoint $::decimal, main .*" { pass $gdb_test_name diff --git a/gdbserver/server.cc b/gdbserver/server.cc index b170da44f6a..2633df08ddb 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -3294,29 +3294,36 @@ static void handle_v_attach (char *own_buf) { client_state &cs = get_client_state (); - int pid; - pid = strtol (own_buf + 8, NULL, 16); - if (pid != 0 && attach_inferior (pid) == 0) - { - /* Don't report shared library events after attaching, even if - some libraries are preloaded. GDB will always poll the - library list. Avoids the "stopped by shared library event" - notice on the GDB side. */ - current_process ()->dlls_changed = false; + int pid = strtol (own_buf + 8, NULL, 16); - if (non_stop) + try + { + if (attach_inferior (pid) == 0) { - /* In non-stop, we don't send a resume reply. Stop events - will follow up using the normal notification - mechanism. */ - write_ok (own_buf); + /* Don't report shared library events after attaching, even if + some libraries are preloaded. GDB will always poll the + library list. Avoids the "stopped by shared library event" + notice on the GDB side. */ + current_process ()->dlls_changed = false; + + if (non_stop) + { + /* In non-stop, we don't send a resume reply. Stop events + will follow up using the normal notification + mechanism. */ + write_ok (own_buf); + } + else + prepare_resume_reply (own_buf, cs.last_ptid, cs.last_status); } else - prepare_resume_reply (own_buf, cs.last_ptid, cs.last_status); + write_enn (own_buf); + } + catch (const gdb_exception_error &exception) + { + sprintf (own_buf, "E.%s", exception.what ()); } - else - write_enn (own_buf); } /* Decode an argument from the vRun packet buffer. PTR points to the From patchwork Fri Apr 19 15:13:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88745 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 A8841384640E for ; Fri, 19 Apr 2024 15:15:29 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by sourceware.org (Postfix) with ESMTPS id E50673849ACF for ; Fri, 19 Apr 2024 15:14:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E50673849ACF 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 E50673849ACF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539652; cv=none; b=ENKuAhlwpzUREUNVzqvgttnthDF/ouG37K1Midstt5ZBkuYhDOIBVglJLfqsqOvXoqQhVCdv2FjZOoAYLH/Ow5jWTxPE0GrDiwwjllkEf4J9UmtOSku2W/ioOl1oKs3LdfNpkRt+eECHQQOOgUpILW84GtTfovkgBD5xiUiwUlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539652; c=relaxed/simple; bh=rb3T+8lA4Lo03H7fHJlSz4/7FEUA6zZHwD1fIfYQcoM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=cp6WDgc7OPZoiPVCGNBm6wN60K+qYy8QCZb8m0dVoFb2b9V9bAQDZSpnydJNSL8FN7epH7Vq5t7INUgDtwVybDG3iCeYAEmlwg4NTxz3RECdmTXnPXUGsU3lyJEmApp6VnNVX55CN+Z8F30j5NiUZDZMZPHLbHvX0Gm4jdZDhls= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-343c7fae6e4so1889029f8f.1 for ; Fri, 19 Apr 2024 08:14:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539649; x=1714144449; 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=0ijeoMI+Au2qgpmyNkpFAwByGxfLk9QFs7kLUn1eLVg=; b=tWirvHIJ6O9feuYypbuv1bZTaL93PC/8vUbgDi4kGjuyN/u+EVqcGt2WJh43sDyueX AfidW3rqlW4HjqEf1PVTj7PiZrHKuso3ApliQjUNxY9JdfyiBHnjydjcUUGx/q65tMnq HyHSXOAUtC5iPmOInyrSeDIYUE5PSAJOkkmasOt0wApgppv04ap2SScO6xB18EFbYZsd tG8ZfDEk5lnk/GaGj9vpYrr3dPTJl/grj6Zu3oRyjqKD1zxwo5UVgiA9MMrk24GwG618 mu+RHwsUZE5B3GlajgkadMadgO9KySBEeenAC0sAZHKpa8yTp545dxFiEwZnBt7q3nZU VuBg== X-Gm-Message-State: AOJu0Yyp+GZk67jX0z7CJHwPMubsE1p20A1iJ6j015VJaLKMxAraUJnx ey86ofHiDB3O/nEKWI3/edLVVuS31FccraonV8r5BzpdesaXMsmK7umcWkCw X-Google-Smtp-Source: AGHT+IGWzfLnyYXCvTUB6HZcTDZWXtiUASy6lOYS/WoLJ2Rrs0D0wOcNSMaAmaWcm3asEtZwvCXnkw== X-Received: by 2002:a5d:4586:0:b0:34a:587:9344 with SMTP id p6-20020a5d4586000000b0034a05879344mr1392018wrq.25.1713539649423; Fri, 19 Apr 2024 08:14:09 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id p8-20020a05600c358800b00418f72d9027sm4649114wmq.18.2024.04.19.08.14.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:14:08 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 08/12] gdbserver: Fix vAttach response when attaching is not supported Date: Fri, 19 Apr 2024 16:13:38 +0100 Message-ID: <20240419151342.1592474-9-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 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 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 handle_v_attach calls attach_inferior, which says: "return -1 if attaching is unsupported, 0 if it succeeded, and call error() otherwise." So if attach_inferior return != 0, we have the unsupported case, meaning we should return the empty packet instead of an error. In practice, this shouldn't trigger, as vAttach support is supposed to be reported via qSupported. But it doesn't hurt to be pedantic here. Change-Id: I99cce6fa678f2370571e6bca0657451300956127 --- gdbserver/server.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdbserver/server.cc b/gdbserver/server.cc index 2633df08ddb..789af36d9a4 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -3318,7 +3318,10 @@ handle_v_attach (char *own_buf) prepare_resume_reply (own_buf, cs.last_ptid, cs.last_status); } else - write_enn (own_buf); + { + /* Not supported. */ + own_buf[0] = 0; + } } catch (const gdb_exception_error &exception) { From patchwork Fri Apr 19 15:13:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88746 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 77720384772F for ; Fri, 19 Apr 2024 15:15:42 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by sourceware.org (Postfix) with ESMTPS id 0FEBB3846426 for ; Fri, 19 Apr 2024 15:14:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0FEBB3846426 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 0FEBB3846426 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539655; cv=none; b=I2I33F1taTw9RkMrC/JB3/6LUT0feUIwGLt7Lv66LD8vOVI/q9KgA8xYINsev05CtuiOBmQDgoyGMjSEmWufXb65G1J13oYqPSklnxPXtvMg1WdS+f3uVZ3n0G3xC0Z8tyqAhJTjehctkt8BgXZMfQg5a+1Tjpg2s1rWjwx4Ork= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539655; c=relaxed/simple; bh=+78xNMR8xEVw7PVaFg7eMjkX9nvVguIMAoqxEStALbY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=UdInYX9WjIZ2Q65YRkY6vy5OC+0Y+MEwG+eZK5ljT+fVXxL3j6WmUvpn2XpYNE/1bbf0KsU2zZ8zaApz3DRclXGRAvWxtkhLiFRLLd2J47rhz3dFQ1c0tiD48hUecz6ODWUbHjmY0tv9SMVSAnz6a5/1S1k1DToVEuq7F8xady0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-418dde387a3so16673245e9.0 for ; Fri, 19 Apr 2024 08:14:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539652; x=1714144452; 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=rUJ3tWZez6jS4Uc+wh5CnEeduAqeLLJHb+zOVrD5bow=; b=KzEyycuL5mEK77UJRtZ6Qp6xLfUylAP3pOPbOCMmRX6rOoXkNGWul4eehQ7OgjgpWS NhGrPdafvGo7XJE16W7XW4qANVuTmTq1SLaywKLb02PBqso9bztzW9QpR6qK/b3NdBYl Xqt9QCH8VZKBNVVHciRz8qFGuqNHEutBFAhmlskyBU0IaQVKOGV4AMpC9wHDT5vBBGFA DgjfqG4qzmV0/fYH+iCr7YeW60IMrTgfAJ9EbybYzi37I/cS10EggQ93tXuF92C+ux4w VjpHhYDwm6aZ4FoXw4Az8MzcnU2PNLcgyovAMZLOvo+gKsZlMjFOiIwC6Obiobnv1sdA D7mQ== X-Gm-Message-State: AOJu0YyNC3/foJuuBn0bCRCTZdI0VRft7TPZawIjH834czxL2+g9MT4J 5QscEjhsfCaOBr34I/+Aen2ExiHwY7+9zTny7LTwcVSCj5G5icPmRFrl9kek X-Google-Smtp-Source: AGHT+IEAIkyjEALM8WR5rUOXbw+Tc5H1BxrYuKHVND8tZp0YG1fm3Ke0KztoZFLCIhoHaT8P7wfpwg== X-Received: by 2002:a05:600c:3c9f:b0:418:41b8:4d5c with SMTP id bg31-20020a05600c3c9f00b0041841b84d5cmr1984246wmb.30.1713539651450; Fri, 19 Apr 2024 08:14:11 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id c22-20020a05600c0a5600b00419cff40a01sm417766wmq.8.2024.04.19.08.14.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:14:10 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 09/12] gdb_target_is_native -> gdb_protocol_is_native Date: Fri, 19 Apr 2024 16:13:39 +0100 Message-ID: <20240419151342.1592474-10-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 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 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 gdb_is_target_native uses "maint print target-stack", which is unnecessary when checking whether gdb_protocol is empty would do. Checking gdb_protocol is more efficient, and can be done before starting GDB and running to main, unlike gdb_is_target_native. This adds a new gdb_protocol_is_native procedure, and uses it in place of gdb_is_target_native. At first, I thought that we'd end up with a few testcases needing to use gdb_is_target_native still, especially multi-target tests that connect to targets different from the default board target, but no, actually all uses of gdb_is_target_native could be converted. gdb_is_target_native will be eliminated in a following patch. In some spots, we no longer need to defer the check until after starting GDB, so the patch adjusts accordingly. Change-Id: Ia706232dbffac70f9d9740bcb89c609dbee5cee3 --- gdb/testsuite/gdb.base/attach.exp | 13 +++---------- gdb/testsuite/gdb.base/foll-exec-mode.exp | 4 +--- gdb/testsuite/gdb.base/load-command.exp | 11 +++++------ gdb/testsuite/gdb.multi/stop-all-on-exit.exp | 16 ++++++++-------- gdb/testsuite/gdb.python/py-inferior.exp | 2 +- gdb/testsuite/gdb.threads/threads-after-exec.exp | 2 +- gdb/testsuite/lib/gdb.exp | 15 +++++++++++++++ 7 files changed, 34 insertions(+), 29 deletions(-) diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp index 84b2d27f3eb..637f287f59e 100644 --- a/gdb/testsuite/gdb.base/attach.exp +++ b/gdb/testsuite/gdb.base/attach.exp @@ -470,16 +470,9 @@ proc_with_prefix test_command_line_attach_run {} { global gdb_prompt global binfile - # The --pid option is used to attach to a process using the native target. - # Start GDB and run to main just to see what the execution target is, skip - # if it's not the native target. - clean_restart $binfile - - if { ![runto_main] } { - return - } - - if { ![gdb_is_target_native] } { + # The --pid option is used to attach to a process using the native + # target. + if { ![gdb_protocol_is_native] } { unsupported "commandline attach run test" return } diff --git a/gdb/testsuite/gdb.base/foll-exec-mode.exp b/gdb/testsuite/gdb.base/foll-exec-mode.exp index ff92c551bba..65054b530b3 100644 --- a/gdb/testsuite/gdb.base/foll-exec-mode.exp +++ b/gdb/testsuite/gdb.base/foll-exec-mode.exp @@ -109,8 +109,6 @@ proc do_follow_exec_mode_tests { mode cmd infswitch } { return } - set target_is_native [gdb_is_target_native] - # Set the follow-exec mode. # gdb_test_no_output "set follow-exec-mode $mode" @@ -150,7 +148,7 @@ proc do_follow_exec_mode_tests { mode cmd infswitch } { # process target, which was automatically pushed when running, was # automatically unpushed from inferior 1 on exec. Use a # different regexp that verifies the Connection field is empty. - if { $target_is_native } { + if { [gdb_protocol_is_native] } { set expected_re " 1.* +[string_to_regexp $binfile].*\r\n\\* 2.*process.*$testfile2 .*" } else { set expected_re " 1.*null.*$testfile.*\r\n\\* 2.*process.*$testfile2 .*" diff --git a/gdb/testsuite/gdb.base/load-command.exp b/gdb/testsuite/gdb.base/load-command.exp index ce6f9bcb730..2d3656e711a 100644 --- a/gdb/testsuite/gdb.base/load-command.exp +++ b/gdb/testsuite/gdb.base/load-command.exp @@ -17,6 +17,11 @@ standard_testfile +if [gdb_protocol_is_native] { + unsupported "the native target does not support the load command" + return +} + # Disable generation of position independent executable (PIE). Otherwise, we # would have to manually specify an offset to load. @@ -30,12 +35,6 @@ if ![runto_main] { return -1 } -# The native target does not support the load command. -if [gdb_is_target_native] { - unsupported "the native target does not support the load command" - return -} - # Manually change the value of the_variable. gdb_test "print/x the_variable" " = 0x1234" "check initial value of the_variable" gdb_test_no_output "set the_variable = 0x5555" "manually change the_variable" diff --git a/gdb/testsuite/gdb.multi/stop-all-on-exit.exp b/gdb/testsuite/gdb.multi/stop-all-on-exit.exp index f014037106d..1ac5388c0a4 100644 --- a/gdb/testsuite/gdb.multi/stop-all-on-exit.exp +++ b/gdb/testsuite/gdb.multi/stop-all-on-exit.exp @@ -18,6 +18,14 @@ # Test that in all-stop mode with multiple inferiors, GDB stops all # threads upon receiving an exit event from one of the inferiors. +# This is a test specific for a native target, where we use the +# "-exec" argument to "add-inferior" and we explicitly don't do +# "maint set target-non-stop on". +if {![gdb_protocol_is_native]} { + untested "the test is aimed at a native target" + return 0 +} + standard_testfile if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { @@ -28,14 +36,6 @@ if {![runto_main]} { return -1 } -# This is a test specific for a native target, where we use the -# "-exec" argument to "add-inferior" and we explicitly don't do -# "maint set target-non-stop on". -if {![gdb_is_target_native]} { - untested "the test is aimed at a native target" - return 0 -} - # Add a second inferior that will sleep longer. gdb_test "add-inferior -exec $binfile" "Added inferior 2.*" \ "add the second inferior" diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp index e74fbfd050d..ee30390e29f 100644 --- a/gdb/testsuite/gdb.python/py-inferior.exp +++ b/gdb/testsuite/gdb.python/py-inferior.exp @@ -406,7 +406,7 @@ with_test_prefix "selected_inferior" { gdb_test "py print (gdb.selected_inferior().connection.num)" "1" \ "first inferior's connection number, though connection object" # Figure out if inf 1 has a native target. - set inf_1_is_native [gdb_is_target_native] + set inf_1_is_native [gdb_protocol_is_native] set num [add_inferior "-no-connection"] gdb_test "inferior $num" ".*" "switch to inferior $num" diff --git a/gdb/testsuite/gdb.threads/threads-after-exec.exp b/gdb/testsuite/gdb.threads/threads-after-exec.exp index 4dc71dd76fd..32aec6b39db 100644 --- a/gdb/testsuite/gdb.threads/threads-after-exec.exp +++ b/gdb/testsuite/gdb.threads/threads-after-exec.exp @@ -38,7 +38,7 @@ proc do_test { } { # leader detection racy") this isn't always thread 1.1. set cur_thr [get_integer_valueof "\$_thread" 0] - if {[istarget *-*-linux*] && [gdb_is_target_native]} { + if {[istarget *-*-linux*] && [gdb_protocol_is_native]} { # Confirm there's only one LWP in the list as well, and that # it is bound to the existing GDB thread. set inf_pid [get_inferior_pid] diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index ddee928d510..c072a4502b4 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4698,6 +4698,10 @@ proc gdb_is_target_remote_prompt { prompt_regexp } { # Check whether we're testing with the remote or extended-remote # targets. # +# This is meant to be used on testcases that connect to targets +# different from the default board protocol. For most tests, you can +# check whether gdb_protocol is "remote" or "extended-remote" instead. +# # NOTE: GDB must be running BEFORE this procedure is called! proc gdb_is_target_remote { } { @@ -4708,6 +4712,10 @@ proc gdb_is_target_remote { } { # Check whether we're testing with the native target. # +# This is meant to be used on testcases that connect to targets +# different from the default board protocol. For most tests, you can +# check whether gdb_protocol is the empty string instead. +# # NOTE: GDB must be running BEFORE this procedure is called! proc gdb_is_target_native { } { @@ -4716,6 +4724,13 @@ proc gdb_is_target_native { } { return [gdb_is_target_1 "native" ".*native \\(Native process\\).*" "$gdb_prompt $"] } +# Returns true if gdb_protocol is empty, indicating use of the native +# target. + +proc gdb_protocol_is_native { } { + return [expr {[target_info gdb_protocol] == ""}] +} + # Like istarget, but checks a list of targets. proc is_any_target {args} { foreach targ $args { From patchwork Fri Apr 19 15:13:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88751 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 8E36E3849AC0 for ; Fri, 19 Apr 2024 15:16:34 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by sourceware.org (Postfix) with ESMTPS id A254D3849AC5 for ; Fri, 19 Apr 2024 15:14:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A254D3849AC5 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 A254D3849AC5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539665; cv=none; b=ld7Yj1iXFbb6X95+63D4Lu5+H97ixfF3vrBE2HEJ5o++FC5mu3MfgI2ZQbYDBxlt4oRfz6yWJarwxiBA8TzXTwzkHPjnds2mweaQDb1AY7lZE3ucLhPNVGXfmDNBcpaT0EMV1RS5GkvAgGi7hKinW9Q9Y5pktvTWwWCAELR/76U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539665; c=relaxed/simple; bh=yVIXwZ9iCSl6Z3RP4ZQW7FTQx0mZRHtrT2g5eKu1vCs=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=bzvmuGuKGLI4yhY9Mzx0TX1IZrGDRFMZbmmrD+yVXUl6IKYMqP4+XGX0TaikGhScO8cFQQ58UssV1ZPRbegelZVLcLGaT+KufkxyolNpszDOZ8QZmapguftYc1CJ0iqZsFmIgW1OV7r7objb83d9wIg4vvxmCmTxRHrEU333H20= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-34a4772d5easo1126995f8f.0 for ; Fri, 19 Apr 2024 08:14:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539657; x=1714144457; 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=9qEU7QmkZdIbijaLDn3K1qkrkGK746+SY6Y+in7TdZU=; b=S83B87puShY0X1nrwoKxh1PSwxBkbo+ll74agnSZq6gTny/3P9AElYdhrCuMompWME r6oCs0VBTdOm7OdUYTFO4nD0hYlCJwsAYdHeQ4324Mr6qW1u8SysENVNgzUEYuXtw7+f FFuj1261795MVHIM2A9xDXzvannFbnoSXsiOrs8IeOxKh9jBqQnKIsNkF7ZnNO/SYDMm 197oUwxdNr0OdNgeAOjmYpLNH67qGO5dkfYmI3ZRLgXhbV7j8xYhoqJdWy+SWRwPEhHQ DNmYNSJ7J5hADxKo/xLQfXxTRscUNS0TJtsXyThV1dM/jFN1Q1KmXlU6lBIb8IPBZMQi FGhQ== X-Gm-Message-State: AOJu0YwDXqFgG8no0TcmRR/DzFqYPJVIcMsHp545muc6eDGwdNzqLslZ aRbLjILKAM6xm3EK9HI83hQGKiuo8RWG68RoXDNGgtxqUph5l6RUVR3bnpEH X-Google-Smtp-Source: AGHT+IHfmLxiBUa6uEqemcYQ00QeORFJ/Gs+TYIl2FcbJohM7ejG8by252dQlNEHDUV0L2mGIX+NGQ== X-Received: by 2002:a5d:5608:0:b0:343:93dc:6255 with SMTP id l8-20020a5d5608000000b0034393dc6255mr1692533wrv.27.1713539656209; Fri, 19 Apr 2024 08:14:16 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id g18-20020adfa492000000b0033e9d9f891csm4709459wrb.58.2024.04.19.08.14.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:14:15 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 10/12] gdb_target_is_remote -> gdb_protocol_is_remote Date: Fri, 19 Apr 2024 16:13:40 +0100 Message-ID: <20240419151342.1592474-11-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 This is similar to the previous patch, but for gdb_protocol_is_remote. gdb_is_target_remote and its MI cousin mi_is_target_remote, use "maint print target-stack", which is unnecessary when checking whether gdb_protocol is "remote" or "extended-remote" would do. Checking gdb_protocol is more efficient, and can be done before starting GDB and running to main, unlike gdb_is_target_remote/mi_is_target_remote. This adds a new gdb_protocol_is_remote procedure, and uses it in place of gdb_is_target_remote/mi_is_target_remote throughout. There are no uses of gdb_is_target_remote/mi_is_target_remote left after this. Those will be eliminated in a following patch. In some spots, we no longer need to defer the check until after starting GDB, so the patch adjusts accordingly. Change-Id: I90267c132f942f63426f46dbca0b77dbfdf9d2ef --- .../gdb.arch/aarch64-sme-core.exp.tcl | 12 ++++----- .../aarch64-sme-regs-available.exp.tcl | 25 ++++++++++--------- .../aarch64-sme-regs-sigframe.exp.tcl | 25 ++++++++++--------- .../aarch64-sme-regs-unavailable.exp.tcl | 12 ++++----- gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp | 16 ++++++------ gdb/testsuite/gdb.base/cond-eval-mode.exp | 2 +- gdb/testsuite/gdb.base/dprintf.exp | 2 +- .../gdb.base/hbreak-in-shr-unsupported.exp | 6 ++--- gdb/testsuite/gdb.mi/mi-nonstop.exp | 2 +- gdb/testsuite/gdb.python/py-evsignal.exp | 3 +-- .../gdb.reverse/finish-reverse-next.exp | 1 - .../gdb.threads/break-while-running.exp | 2 +- .../main-thread-exit-during-detach.exp | 2 +- .../process-dies-while-handling-bp.exp | 2 +- gdb/testsuite/gdb.trace/change-loc.exp | 10 ++++---- gdb/testsuite/gdb.trace/ftrace.exp | 2 +- gdb/testsuite/gdb.trace/qtro.exp | 11 ++++---- gdb/testsuite/lib/gdb.exp | 11 +++++++- 18 files changed, 76 insertions(+), 70 deletions(-) diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl index b4868d389b1..b9b83b93772 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl @@ -158,20 +158,20 @@ proc test_sme_core_file { id_start id_end } { continue } - if ![runto_main] { - untested "could not run to main" - return -1 - } - # Check if we are talking to a remote target. If so, bail out, # as right now remote targets can't communicate vector length (vl # or svl) changes to gdb via the RSP. When this restriction is # lifted, we can remove this guard. - if {[gdb_is_target_remote]} { + if {[gdb_protocol_is_remote]} { unsupported "aarch64 sve/sme tests not supported for remote targets" return -1 } + if ![runto_main] { + untested "could not run to main" + return -1 + } + generate_sme_core_files ${executable} ${binfile} $id $state $vl $svl } } diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl index 450cb87021e..569d0b71340 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl @@ -18,6 +18,19 @@ load_lib aarch64-scalable.exp +require is_aarch64_target +require allow_aarch64_sve_tests +require allow_aarch64_sme_tests + +# Check if we are talking to a remote target. If so, bail out, as +# right now remote targets can't communicate vector length (vl or svl) +# changes to gdb via the RSP. When this restriction is lifted, we can +# remove this guard. +if {[gdb_protocol_is_remote]} { + unsupported "aarch64 sve/sme tests not supported for remote targets" + return -1 +} + # # Cycle through all ZA registers and pseudo-registers and validate that their # contents are available for vector length SVL. @@ -160,14 +173,6 @@ proc test_sme_registers_available { id_start id_end } { return -1 } - # Check if we are talking to a remote target. If so, bail out, as right now - # remote targets can't communicate vector length (vl or svl) changes to gdb - # via the RSP. When this restriction is lifted, we can remove this guard. - if {[gdb_is_target_remote]} { - unsupported "aarch64 sve/sme tests not supported for remote targets" - return -1 - } - gdb_test_no_output "set print repeats 1" set prctl_breakpoint "stop 1" @@ -255,8 +260,4 @@ proc test_sme_registers_available { id_start id_end } { } } -require is_aarch64_target -require allow_aarch64_sve_tests -require allow_aarch64_sme_tests - test_sme_registers_available $id_start $id_end diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl index d79bd3969c9..8b61ddaafd6 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl @@ -17,6 +17,19 @@ load_lib aarch64-scalable.exp +require is_aarch64_target +require allow_aarch64_sve_tests +require allow_aarch64_sme_tests + +# Check if we are talking to a remote target. If so, bail out, as +# right now remote targets can't communicate vector length (vl or svl) +# changes to gdb via the RSP. When this restriction is lifted, we can +# remove this guard. +if {[gdb_protocol_is_remote]} { + unsupported "aarch64 sve/sme tests not supported for remote targets" + return -1 +} + # # Validate the state of registers in the signal frame for various states. # @@ -39,14 +52,6 @@ proc test_sme_registers_sigframe { id_start id_end } { return -1 } - # Check if we are talking to a remote target. If so, bail out, as right now - # remote targets can't communicate vector length (vl or svl) changes to gdb - # via the RSP. When this restriction is lifted, we can remove this guard. - if {[gdb_is_target_remote]} { - unsupported "aarch64 sve/sme tests not supported for remote targets" - return -1 - } - set sigill_breakpoint "stop before SIGILL" set handler_breakpoint "handler" gdb_breakpoint [gdb_get_line_number $sigill_breakpoint] @@ -183,8 +188,4 @@ proc test_sme_registers_sigframe { id_start id_end } { } } -require is_aarch64_target -require allow_aarch64_sve_tests -require allow_aarch64_sme_tests - test_sme_registers_sigframe $id_start $id_end diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl index 51488527ca8..77ff66c49c4 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl @@ -120,19 +120,19 @@ proc test_sme_registers_unavailable { id_start id_end } { } set binfile [standard_output_file ${executable}] - if ![runto_main] { - untested "could not run to main" - return -1 - } - # Check if we are talking to a remote target. If so, bail out, as right now # remote targets can't communicate vector length (vl or svl) changes to gdb # via the RSP. When this restriction is lifted, we can remove this guard. - if {[gdb_is_target_remote]} { + if {[gdb_protocol_is_remote]} { unsupported "aarch64 sve/sme tests not supported for remote targets" return -1 } + if ![runto_main] { + untested "could not run to main" + return -1 + } + gdb_test_no_output "set print repeats 1" set prctl_breakpoint "stop 1" diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp index 51b3d225cdd..9643b110c3d 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp +++ b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp @@ -40,6 +40,14 @@ require is_aarch64_target require allow_aarch64_sve_tests require allow_aarch64_sme_tests +# Check if we are talking to a remote target. If so, bail out, as right now +# remote targets can't communicate vector length (vl or svl) changes to gdb +# via the RSP. When this restriction is lifted, we can remove this guard. +if {[gdb_protocol_is_remote]} { + unsupported "aarch64 sve/sme tests not supported for remote targets" + return -1 +} + set compile_flags {"debug" "macros" "additional_flags=-march=armv8.5-a+sve"} standard_testfile if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} ${compile_flags}]} { @@ -50,14 +58,6 @@ if {![runto_main]} { return -1 } -# Check if we are talking to a remote target. If so, bail out, as right now -# remote targets can't communicate vector length (vl or svl) changes to gdb -# via the RSP. When this restriction is lifted, we can remove this guard. -if {[gdb_is_target_remote]} { - unsupported "aarch64 sve/sme tests not supported for remote targets" - return -1 -} - # Adjust the repeat count for the test. gdb_test_no_output "set print repeats 1" "adjust repeat count" diff --git a/gdb/testsuite/gdb.base/cond-eval-mode.exp b/gdb/testsuite/gdb.base/cond-eval-mode.exp index cd1b78bf2ab..0e98b8307ca 100644 --- a/gdb/testsuite/gdb.base/cond-eval-mode.exp +++ b/gdb/testsuite/gdb.base/cond-eval-mode.exp @@ -58,7 +58,7 @@ gdb_test_multiple $test_target $test_target { # We now know that the target supports target-side conditional # evaluation. Now make sure we can force-disable the # ConditionalBreakpoints RSP feature. -if [gdb_is_target_remote] { +if [gdb_protocol_is_remote] { gdb_test \ "set remote conditional-breakpoints-packet off" \ "Support for the 'ConditionalBreakpoints' packet on the current remote target is set to \"off\"." diff --git a/gdb/testsuite/gdb.base/dprintf.exp b/gdb/testsuite/gdb.base/dprintf.exp index 8b284a8d93d..649126f141b 100644 --- a/gdb/testsuite/gdb.base/dprintf.exp +++ b/gdb/testsuite/gdb.base/dprintf.exp @@ -217,7 +217,7 @@ gdb_test "set dprintf-style foobar" "Undefined item: \"foobar\"." \ # Test that force-disabling the BreakpointCommands RSP feature works # as expected. dprintf relies on support for target-side breakpoint # commands --- use it as proxy. -if [gdb_is_target_remote] { +if [gdb_protocol_is_remote] { gdb_test \ "set remote breakpoint-commands-packet off" \ "Support for the 'BreakpointCommands' packet on the current remote target is set to \"off\"." diff --git a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp index 8b078a69d10..e90f352b272 100644 --- a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp +++ b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp @@ -41,8 +41,6 @@ if {![runto_main]} { return -1 } -set is_target_remote [gdb_is_target_remote] - # Get main breakpoint out of the way. delete_breakpoints @@ -51,7 +49,7 @@ gdb_test_no_output "set breakpoint always-inserted on" # Force-disable Z1 packets, in case the target actually supports # these. -if {$is_target_remote} { +if {[gdb_protocol_is_remote]} { gdb_test \ "set remote Z-packet off" \ "Use of Z packets on the current remote target is set to \"off\"." @@ -79,7 +77,7 @@ gdb_test_multiple "hbreak -q main" $test { } -re "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*$gdb_prompt $" { set supports_hbreak 1 - if {$is_target_remote} { + if {[gdb_protocol_is_remote]} { # Z-packets have been force-disabled, so this shouldn't # happen. fail $test diff --git a/gdb/testsuite/gdb.mi/mi-nonstop.exp b/gdb/testsuite/gdb.mi/mi-nonstop.exp index 922f5ea0a76..609fbec0e9f 100644 --- a/gdb/testsuite/gdb.mi/mi-nonstop.exp +++ b/gdb/testsuite/gdb.mi/mi-nonstop.exp @@ -126,7 +126,7 @@ mi_gdb_test "-thread-select 2" "\\^done.*" "select first worker thread" mi_gdb_test "-gdb-set --thread 3 variable exit_first_thread=1" ".*\\^done" "ask the second thread to exit" set test "wait for thread exit" -if { [mi_is_target_remote] } { +if { [gdb_protocol_is_remote] } { # The remote protocol doesn't have support for thread exit # notifications. unsupported $test diff --git a/gdb/testsuite/gdb.python/py-evsignal.exp b/gdb/testsuite/gdb.python/py-evsignal.exp index aa87cb42fbd..83b351f8f39 100644 --- a/gdb/testsuite/gdb.python/py-evsignal.exp +++ b/gdb/testsuite/gdb.python/py-evsignal.exp @@ -13,8 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if {[target_info gdb_protocol] == "remote" - || [target_info gdb_protocol] == "extended-remote"} { +if {[gdb_protocol_is_remote]} { # RuntimeError: Could not find event thread kfail "python/12966" "Signal Thread 3" return -1 diff --git a/gdb/testsuite/gdb.reverse/finish-reverse-next.exp b/gdb/testsuite/gdb.reverse/finish-reverse-next.exp index 4ca670e270f..73a4124fab4 100644 --- a/gdb/testsuite/gdb.reverse/finish-reverse-next.exp +++ b/gdb/testsuite/gdb.reverse/finish-reverse-next.exp @@ -52,7 +52,6 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { } runto_main -set target_remote [gdb_is_target_remote] if [supports_process_record] { # Activate process record/replay. diff --git a/gdb/testsuite/gdb.threads/break-while-running.exp b/gdb/testsuite/gdb.threads/break-while-running.exp index aa56af9ac62..4bec753c235 100644 --- a/gdb/testsuite/gdb.threads/break-while-running.exp +++ b/gdb/testsuite/gdb.threads/break-while-running.exp @@ -53,7 +53,7 @@ proc test { update_thread_list always_inserted non_stop } { # RSP, we can't issue commands until the target replies to vCont. # Not an issue with the non-stop RSP variant, which has a # non-blocking vCont. - if {$non_stop=="off" && [gdb_is_target_remote]} { + if {$non_stop=="off" && [gdb_protocol_is_remote]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp b/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp index 15780adc118..2a9320a6914 100644 --- a/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp +++ b/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp @@ -120,7 +120,7 @@ proc run_test { spawn_inferior } { # In both cases the stop arrives while GDB is processing the # detach, however, for remote targets GDB doesn't report the stop, # while for local targets GDB does report the stop. - if {![gdb_is_target_remote]} { + if {![gdb_protocol_is_remote]} { set stop_re "\\\[Thread.*exited\\\]\r\n" } else { set stop_re "" diff --git a/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp b/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp index a4c50d1c1f1..e1bc6feea46 100644 --- a/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp +++ b/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp @@ -52,7 +52,7 @@ proc do_test { non_stop cond_bp_target } { # Whether it's known that the test fails. set should_kfail 0 - if {![gdb_is_target_remote]} { + if {![gdb_protocol_is_remote]} { set should_kfail 1 } else { if {!$cond_bp_target} { diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp index cc9f77f2514..fb55153bfcb 100644 --- a/gdb/testsuite/gdb.trace/change-loc.exp +++ b/gdb/testsuite/gdb.trace/change-loc.exp @@ -288,16 +288,16 @@ proc tracepoint_install_in_trace_disabled { trace_type } { global pcreg global gdb_prompt + # This test only makes sense with remote targets. + if ![gdb_protocol_is_remote] { + return + } + clean_restart ${testfile} if ![runto_main] { return -1 } - # This test only makes sense with the remote target. - if ![gdb_is_target_remote] { - return - } - gdb_test_no_output "delete break 1" # Set a tracepoint we'll never meet. Just to avoid the diff --git a/gdb/testsuite/gdb.trace/ftrace.exp b/gdb/testsuite/gdb.trace/ftrace.exp index 7f74a5a45cb..9b100ced8f5 100644 --- a/gdb/testsuite/gdb.trace/ftrace.exp +++ b/gdb/testsuite/gdb.trace/ftrace.exp @@ -189,7 +189,7 @@ proc test_fast_tracepoints {} { # fast tracepoints RSP feature, and confirm fast tracepoints # can no longer be downloaded. set test "fast tracepoint could not be downloaded with the feature disabled" - if [gdb_is_target_remote] { + if [gdb_protocol_is_remote] { gdb_test "set remote fast-tracepoints-packet off" gdb_test_multiple "tstart" $test { diff --git a/gdb/testsuite/gdb.trace/qtro.exp b/gdb/testsuite/gdb.trace/qtro.exp index 3693f249e26..60f73d7e5ef 100644 --- a/gdb/testsuite/gdb.trace/qtro.exp +++ b/gdb/testsuite/gdb.trace/qtro.exp @@ -20,6 +20,10 @@ load_lib trace-support.exp +# Check whether we're testing with the remote or extended-remote +# targets. +require gdb_protocol_is_remote + standard_testfile if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug nopie}]} { @@ -30,12 +34,7 @@ if ![runto_main] { return -1 } -# Check whether we're testing with the remote or extended-remote -# targets, and whether the target supports tracepoints. - -if ![gdb_is_target_remote] { - return -1 -} +# Check whether the target supports tracepoints. if ![gdb_target_supports_trace] { unsupported "current target does not support trace" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index c072a4502b4..f37d54b16be 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4700,7 +4700,8 @@ proc gdb_is_target_remote_prompt { prompt_regexp } { # # This is meant to be used on testcases that connect to targets # different from the default board protocol. For most tests, you can -# check whether gdb_protocol is "remote" or "extended-remote" instead. +# check whether gdb_protocol is "remote" or "extended-remote" instead +# (or call gdb_protocol_is_remote for either). # # NOTE: GDB must be running BEFORE this procedure is called! @@ -4731,6 +4732,14 @@ proc gdb_protocol_is_native { } { return [expr {[target_info gdb_protocol] == ""}] } +# Returns true if gdb_protocol is either "remote" or +# "extended-remote". + +proc gdb_protocol_is_remote { } { + return [expr {[target_info gdb_protocol] == "remote" + || [target_info gdb_protocol] == "extended-remote"}] +} + # Like istarget, but checks a list of targets. proc is_any_target {args} { foreach targ $args { From patchwork Fri Apr 19 15:13:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88750 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 2A3763846403 for ; Fri, 19 Apr 2024 15:16:06 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by sourceware.org (Postfix) with ESMTPS id 0BF7F3849AD9 for ; Fri, 19 Apr 2024 15:14:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0BF7F3849AD9 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 0BF7F3849AD9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539662; cv=none; b=jSkQpukN6WGuRC+HeL8xjywmoZ5eMCMWYj3Ha+u58mGUtZDcZUSKcG1GZ18lOOfRl3gcaD8o9BCIWofAYtjEQ14W9jYB5rORE5mE6PQCO81kKN4FCJpn9AJ/NcBgifzHavLce7LS1Qe5TZvwsggM2k74H1OPpdLJ8N+BrHs5KIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539662; c=relaxed/simple; bh=kcE8VEFEGnAkSyys0V4G4q2CQEf1NSkS0W1fhZAdjew=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=AggpoXslKwoMVppmaX+k67MAL9xqHMVQe49Tx+3YDU2ftMXawzGp5/ANpzcCvXdiFd35fcO/CWwDfN6EzY3ubMhZsidKR8/W4FCTIM7xnpnd1Wh9xo1smCyxUarB1yZA7NMojM+mdV9Wdfri5y1SF/YRL+v5ZLopWMUbAuCSD1Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-418dcaa77d5so15082935e9.2 for ; Fri, 19 Apr 2024 08:14:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539658; x=1714144458; 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=Lvpwqh8A67BBLnXrK5GTeaAJV6DgulgB3bEQL0NAuIE=; b=EC7SmS264FWcglQ/r+pqoqEOlSy2Y8MAE48CKo3aqCQPhVSefRFphuJ3BLkLRoc93p xqIyVpvzU/uERt+2gaJlDowjSqVMbs6P7j2WMPj6rI9rX+8ADrRl3Xgy9cT4Qj+1DeLE YltljgYqm3s50DIEJkfZef3rnzvv+QR+9s7LudodYV2R89rowwfDv4OKX8FT6vhZ1iiG oxlJCeJf4+TuSGC35Mjrl6G0PtUsazBBMGhVwqDHCONKsJ6ew/vwZXmj3JlFY6jNyu5o 57TYkBHkZBE4KSFGPPTgZP2kA1YLgPTPvj5qgoAKICzxS3tm7MTYgez+1/7oy3ihoL7C /kwg== X-Gm-Message-State: AOJu0YwUVBIzQvyuEbt6Lg7FihB62B8uC8W+hi70NjRvw/gkIgLCtJSJ 1itdeviPMZmSL4WBr3GFUsTuIQFfii72sWjKtzj51Jq+dkBHFxwW5M59Qt1l X-Google-Smtp-Source: AGHT+IHaJ+rVuyZScr8qhIbQVMCE5HokSEhDXSjR5GuxdMMRAdz4Owkdr5WA5LE/PMPdzbUr8XUjyw== X-Received: by 2002:a05:600c:3554:b0:418:d54c:f57d with SMTP id i20-20020a05600c355400b00418d54cf57dmr1840168wmq.4.1713539658516; Fri, 19 Apr 2024 08:14:18 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id ay15-20020a05600c1e0f00b004189a5ada3asm10689552wmb.19.2024.04.19.08.14.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:14:18 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 11/12] Eliminate gdb_is_target_remote / gdb_is_target_native & friends Date: Fri, 19 Apr 2024 16:13:41 +0100 Message-ID: <20240419151342.1592474-12-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 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 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 After the previous patches, gdb_is_target_remote, gdb_is_target_native, and mi_is_target_remote aren't used anywhere. This commit eliminates them, along with now unnecessary helpers. Change-Id: I54f9ae1f5aed3f640e5758731cf4954e6dbb1bee --- gdb/testsuite/lib/gdb.exp | 68 -------------------------------- gdb/testsuite/lib/mi-support.exp | 9 ----- 2 files changed, 77 deletions(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index f37d54b16be..03ca8f9a63a 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4657,74 +4657,6 @@ proc have_longjmp_probe {} { return $have_probe } -# Helper for gdb_is_target_* procs. TARGET_NAME is the name of the target -# we're looking for (used to build the test name). TARGET_STACK_REGEXP -# is a regexp that will match the output of "maint print target-stack" if -# the target in question is currently pushed. PROMPT_REGEXP is a regexp -# matching the expected prompt after the command output. -# -# NOTE: GDB must be running BEFORE this procedure is called! - -proc gdb_is_target_1 { target_name target_stack_regexp prompt_regexp } { - global gdb_spawn_id - - # Throw a Tcl error if gdb isn't already started. - if {![info exists gdb_spawn_id]} { - error "gdb_is_target_1 called with no running gdb instance" - } - - set test "probe for target ${target_name}" - gdb_test_multiple "maint print target-stack" $test \ - -prompt "$prompt_regexp" { - -re "${target_stack_regexp}${prompt_regexp}" { - pass $test - return 1 - } - -re "$prompt_regexp" { - pass $test - } - } - return 0 -} - -# Helper for gdb_is_target_remote where the expected prompt is variable. -# -# NOTE: GDB must be running BEFORE this procedure is called! - -proc gdb_is_target_remote_prompt { prompt_regexp } { - return [gdb_is_target_1 "remote" ".*emote target using gdb-specific protocol.*" $prompt_regexp] -} - -# Check whether we're testing with the remote or extended-remote -# targets. -# -# This is meant to be used on testcases that connect to targets -# different from the default board protocol. For most tests, you can -# check whether gdb_protocol is "remote" or "extended-remote" instead -# (or call gdb_protocol_is_remote for either). -# -# NOTE: GDB must be running BEFORE this procedure is called! - -proc gdb_is_target_remote { } { - global gdb_prompt - - return [gdb_is_target_remote_prompt "$gdb_prompt $"] -} - -# Check whether we're testing with the native target. -# -# This is meant to be used on testcases that connect to targets -# different from the default board protocol. For most tests, you can -# check whether gdb_protocol is the empty string instead. -# -# NOTE: GDB must be running BEFORE this procedure is called! - -proc gdb_is_target_native { } { - global gdb_prompt - - return [gdb_is_target_1 "native" ".*native \\(Native process\\).*" "$gdb_prompt $"] -} - # Returns true if gdb_protocol is empty, indicating use of the native # target. diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index b3a27efb155..aa0f9df6c3a 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -2863,15 +2863,6 @@ proc mi_skip_libstdcxx_probe_tests {} { return [skip_libstdcxx_probe_tests_prompt "$mi_gdb_prompt$"] } -# Check whether we're testing with the remote or extended-remote -# targets. - -proc mi_is_target_remote {} { - global mi_gdb_prompt - - return [gdb_is_target_remote_prompt "$mi_gdb_prompt"] -} - # Retrieve the value of EXP in the inferior, represented in format # specified in FMT (using "printFMT"). DEFAULT is used as fallback if # print fails. TEST is the test message to use. It can be omitted, From patchwork Fri Apr 19 15:13:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 88748 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 B8540384772B for ; Fri, 19 Apr 2024 15:15:57 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by sourceware.org (Postfix) with ESMTPS id D77E03849ACB for ; Fri, 19 Apr 2024 15:14:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D77E03849ACB 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 D77E03849ACB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539666; cv=none; b=kGWYEXBGwMLIsusXre+X4kPCPDBUxynC56erHyNsrPXCR4l9FG9JEOQcAKIWgsG4qPQsf/QN06rQbBIraHIT9/2zvaDq5UCyrfsoHcCnEVFgEfVvhT2QtXMQFotZbZmc5b+QbklbFTNHX2MRM2lt/zyermKChMRAnHV1iGDQGmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713539666; c=relaxed/simple; bh=pQz8DnqMq3IUP9nlbf+ymlv2scpIJdVBIqXgh6VS7jA=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=KKiT7p/67BeIs2eUsqc9yJATfMZWOL47TWyzw7KjhDpJ00rUVEZ6ZeGucwkWxVshaivx3dpat4uLOPxFUbB+qydmKFt+YB4T9qKo7LAYLnzm5/EuAZQkkNRyBuCnCJCbbuKcHwEj8XdQx0lYFTHBbCf5y3vsyUe8A/Qsi2tlI9M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-418c979ddd2so15534355e9.3 for ; Fri, 19 Apr 2024 08:14:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713539662; x=1714144462; 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=W9+40qIofqkpwlzQKw/1hgQ6dBROZae/3ZwzHwXk7lw=; b=gguDeVB44G8UkVsvbtRS9LWMFqWaC7eu4dGmuYAH9wqj/DrBxlNft1y/4bMZVD6CaK JqPHq9CPDX+wYafqf+ICTtpNqz3mSodXHB7B4cggBs/rIOAWfz2u12ywLHuY6P/IOAQY elUQv1sJNrJlB+WP6lxm5aVZpSnN9uYQIZRoUf0NP0lo0a+JOaBkjfxW0eIrVBO1GIqb f7utvAKKo1aa5s1P1eqC328it54hKkHDDaKuIMM/gbeo1aZpcEiw6Vo+bcs6bjUlS/Jv 6TGweYaILys5hRLYca99SQ1XT3+wF/pwNdQ1yqdnjscnXYFchKAjOcvr9nI6uXn8Tttt HZ6A== X-Gm-Message-State: AOJu0Yw9cePpAzwRJ3va68TOCpnkqdHYyalD7wnrQ2NN/PtkiRi5jlbK 3h8+US8E5UxpvqOFkjaaMs7QR1t5ayGtfLLDinKyyMvyqoo8RcdkfWDzWJUK X-Google-Smtp-Source: AGHT+IGRYx1IxAWXswhgssBGH/JgQ6fhXhx7ilxtqgQQx+xk97S5jdiOgWXjrdEdq7sSJVQs+6/Ibw== X-Received: by 2002:a05:600c:1e25:b0:419:cf15:f3b9 with SMTP id ay37-20020a05600c1e2500b00419cf15f3b9mr344479wmb.36.1713539662189; Fri, 19 Apr 2024 08:14:22 -0700 (PDT) Received: from localhost ([2001:8a0:f93d:b900:2438:d637:5572:c30a]) by smtp.gmail.com with UTF8SMTPSA id o19-20020a05600c511300b00417e36953a0sm6820024wms.20.2024.04.19.08.14.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 08:14:21 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 12/12] Fix gdb.base/attach.exp --pid test skipping on native-extended-gdbserver Date: Fri, 19 Apr 2024 16:13:42 +0100 Message-ID: <20240419151342.1592474-13-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240419151342.1592474-1-pedro@palves.net> References: <20240419151342.1592474-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 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 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 When testing with the native-extended-gdbserver board, gdb.base/attach.exp shows a couple failures, like so: Running /home/pedro/gdb/src/gdb/testsuite/gdb.base/attach.exp ... FAIL: gdb.base/attach.exp: do_command_attach_tests: gdb_spawn_attach_cmdline: start gdb with --pid FAIL: gdb.base/attach.exp: do_command_attach_tests: gdb_spawn_attach_cmdline: info thread (no thread) From gdb.log: builtin_spawn /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -q -iex set height 0 -iex set width 0 -data-directory /home/pedro/gdb/build /gdb/data-directory -iex set auto-connect-native-target off -iex set sysroot -quiet --pid=2115260 Don't know how to attach. Try "help target". (gdb) FAIL: gdb.base/attach.exp: do_command_attach_tests: gdb_spawn_attach_cmdline: start gdb with --pid There is a check for [isnative] to skip the test on anything but target native, but that is the wrong check. native-extended-gdbserver is "isnative". Fix it by using a gdb_protocol check instead. Change-Id: I37ee730b8d6f1913b12c118838f511bd1c0b3768 --- gdb/testsuite/gdb.base/attach.exp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp index 637f287f59e..831e11f96a6 100644 --- a/gdb/testsuite/gdb.base/attach.exp +++ b/gdb/testsuite/gdb.base/attach.exp @@ -445,7 +445,9 @@ proc_with_prefix do_command_attach_tests {} { global gdb_prompt global binfile - if {![isnative]} { + # The --pid option is used to attach to a process using the native + # target. + if { ![gdb_protocol_is_native] } { unsupported "command attach test" return 0 }