From patchwork Wed Jan 24 15:48:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84682 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 7B5EC385DC04 for ; Wed, 24 Jan 2024 15:49:32 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by sourceware.org (Postfix) with ESMTPS id C06633858D3C for ; Wed, 24 Jan 2024 15:48:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C06633858D3C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C06633858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706111337; cv=none; b=CoB2cD5BqbeG/mt+/5eDLWqkAr2vIova4nbn23L1GdR6E9FzDYPgzlRVqTI5wK6njcLIFjNEygiqCVHHv1iEZLQEMtMznYsPewAOCn6IXTUFNC/KvafL7nLEEGBb7j/jg+ioxpffQFTR9h/X5hSPQK30MU9KqO+u5vdZH5h3LoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706111337; c=relaxed/simple; bh=yi/VJsNLEv0/SOTUMwbT2PSVby1UYeSJT0JHLGexiPo=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=dtoM8FMqVk0MlNtQbiGzAR3+BihLIfySwrK4IVyiRZBn3ixLx6uHTQi7cCnfmEewL0/lngbAL671JlWZHo/rPm2nXT1aOCKdYPQBeW4nAExr4i09UZnZzYzRL1KvZoJ8aA4em5Yi8NJnffw0EI9VwDjM5h+ohGNFUX5URWkscC8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-7bef44df5c6so153398939f.0 for ; Wed, 24 Jan 2024 07:48:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1706111335; x=1706716135; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=zEeyXsksjMEvNzBMcQ9Hjn6bHz1lp5XA8gHhhsOT9mw=; b=BOYgrEyqutv6TxuLCeVLFE/d8dApq/zkqMZa3E64IiDoVmqf2++rocph11D+7hD8LC tGjJujJmt+QuBy4teu4WLM9+C/AqNim2dthI4ykoRLpSUWXA++kMEUOBcEEt7fM2AS32 MADjI7FXIqciqYJq1wM14JNn+qcvYxA9ttgCcO3g/U7MHpDK8Q59iw+2ytaIV03+ko76 gDivjG4+zcxqEPIaayl0rUQcuF8F6MCXSdoW7Ri4KnV8NoZmGS1QyK0vGVaYejE47zBy 6IRXJANsgJ/iVF60cG/eouE4qt8RRpTTbsiot96kgL4/9rGeZr8WNdIsyRopR6r4ZiGq Pe5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706111335; x=1706716135; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zEeyXsksjMEvNzBMcQ9Hjn6bHz1lp5XA8gHhhsOT9mw=; b=G8Kii+pjmPlljBA/awDAfOpqJ59bqtq25dkXspui+lNZK696P/UkiRNdEHEisXssKF EjNbaUvXn58i6h0q5rtmD3lM9wNvVUu0EqbS1QpdQ+7gZnMbRP/R2Otu9ROMcU9TztsT 8Xn7CRkyflfYU0/hlcus0Y75qKUFRNTTXeo0WFUdxDiGLSY0jxMuBRR7FMWD+bfZtPP/ evs8ngzlGC+yXiitGw41II6TgVGfecncrLmtBEiv7q/hkHh2wCpO72GUa2gayrGCrCtF /MZDWfGGb5REgg4ntE/TVzHk/8rFPs+QKhbmSb/IJthZpFc/2EZlZ6+vMGYJIdiygFd1 UEyw== X-Gm-Message-State: AOJu0Yxk/nQwVCgSkGost+PlGXDf2zY+vtNrRzf6tjCXtQOXHFaOHoK3 OL/qMf3oh2WwJ4FuMRmnLFmS2RNIWoINEv1mloT9ic4mp9jhXJOPtFZ9yKRKMgTfH7CDLxcTA2c = X-Google-Smtp-Source: AGHT+IH7qLtAONfIrRnNX9haq6y7+8bDoK95EJSAOpCW+0XEFsb+mPuZqZOzb3dygIsYJUFNWYZUDQ== X-Received: by 2002:a6b:7f4a:0:b0:7bf:47a9:4430 with SMTP id m10-20020a6b7f4a000000b007bf47a94430mr947971ioq.17.1706111334983; Wed, 24 Jan 2024 07:48:54 -0800 (PST) Received: from localhost.localdomain (97-122-68-157.hlrn.qwest.net. [97.122.68.157]) by smtp.gmail.com with ESMTPSA id h5-20020a6b7845000000b007ba783a27c3sm6972526iop.11.2024.01.24.07.48.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 07:48:54 -0800 (PST) From: Tom Tromey Date: Wed, 24 Jan 2024 08:48:53 -0700 Subject: [PATCH 1/3] Export dap_initialize MIME-Version: 1.0 Message-Id: <20240124-dap-launch-fix-v1-1-0d47f87fa9f0@adacore.com> References: <20240124-dap-launch-fix-v1-0-0d47f87fa9f0@adacore.com> In-Reply-To: <20240124-dap-launch-fix-v1-0-0d47f87fa9f0@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This changes the test suite to export dap_initialize. --- gdb/testsuite/lib/dap-support.exp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index 0bb413e4037..07259862b18 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -238,7 +238,7 @@ proc dap_check_request_and_response {name command {obj {}}} { # desired. Callers not caring about this should probably use # dap_launch. Returns the empty string on failure. NAME is used as # the test name. -proc _dap_initialize {name} { +proc dap_initialize {name} { if {[dap_gdb_start]} { return "" } @@ -266,7 +266,7 @@ proc _dap_initialize {name} { # After this proc is called, gdb will be ready to accept breakpoint # requests. proc dap_launch {file {args {}}} { - if {[_dap_initialize "startup - initialize"] == ""} { + if {[dap_initialize "startup - initialize"] == ""} { return "" } set params "o program" @@ -315,7 +315,7 @@ proc dap_launch {file {args {}}} { # specifying PID as the inferior process ID. Returns the empty string # on failure, or the response object from the attach request. proc dap_attach {pid {prog ""}} { - if {[_dap_initialize "startup - initialize"] == ""} { + if {[dap_initialize "startup - initialize"] == ""} { return "" } @@ -331,7 +331,7 @@ proc dap_attach {pid {prog ""}} { # specifying TARGET as the remote target. Returns the empty string on # failure, or the response object from the attach request. proc dap_target_remote {target} { - if {[_dap_initialize "startup - initialize"] == ""} { + if {[dap_initialize "startup - initialize"] == ""} { return "" } return [dap_check_request_and_response "startup - target" attach \ From patchwork Wed Jan 24 15:48:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84684 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 838C03858289 for ; Wed, 24 Jan 2024 15:50:11 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id 5102F3858C41 for ; Wed, 24 Jan 2024 15:48:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5102F3858C41 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5102F3858C41 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706111337; cv=none; b=pUkPcfom66yA89T3/IfiLpruz2MN969EEGjnheJt2e2nnB+4Ju2cJ3s00BqSZoizrQpRCSivv2r8RBZBGMMwNBH6lA+LWo1zzTHsFCkc6epOSXipHLAQGb1UXuGoogiWH9WPfPMBR4e1aMUu0ivVwjdLVihumbGenjS22pOpOWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706111337; c=relaxed/simple; bh=S8mAhoqLO9S0sElRSI5tiHMkhwKb6zi1/do0M1lXTwI=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=K3swBQISs9MgZEDwN8DBA7yWV46/p/i1xA5hnwCOQYae5OqOuM3xgsEz269tKPff/IyK8UVcKBfRbIOHDNzdF7MyrfeL+qJ9Xp3aCE7m5KZF7d0kmaTa8VSYrgRYNJJuiZ7t2xojW8tT/7UBPZavvLgf8QgXtvtB16idWml92F0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7beda2e6794so138766439f.1 for ; Wed, 24 Jan 2024 07:48:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1706111335; x=1706716135; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=doqBiIoTjC7bzUEBa95sIaUsVxWKfObzHRhcrl3vxSw=; b=lBKdTe8YUesAne7OIKp1q+pgTWfzMZN712446QVmK9szMw3TW8wqmTYXnzXejR8xDj Xz6ZvxfdPBFcvHYYf1P7y/ZL06O0XkisbxrQxqigMx3Bt3GXQ4A4g1AZXvsdVESz1MFN 1MKCUZxVDXJD17LhggTnlD/ub3KOAo+GRXNgFATrfhFDTM26mmijzI0H6TX9v9J/wpjM bRIuH0h4a6wuQm90Tq9FopYayd8YGgiWaDgEWJpTQPyHEY5MwAxurnoOjsyi/qE10Qfg KWIE5oOqaX7DBobwpZoBzsRyuFfu821/WJxUGyJwrQBTjN+tG43cUwWrJOotM2eRFuUK 7Uvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706111335; x=1706716135; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=doqBiIoTjC7bzUEBa95sIaUsVxWKfObzHRhcrl3vxSw=; b=ZizJo4KSiIdC2n+6jKArPjkxNWsLK26zjBO3sWbdhed9uJTvomp2EKsItboW9hZieZ YWG/ZLNid2A51NTqoFIW1nEwLAsMmP3nYEYkvYs6oMjkSCBXMvbt2ltThubq2ZAEfUrI W9G/J1spdFT+A2Dx9q4nCQYAuVBaYJu/PQZkAnonN+qrrv6HOdqPIywlNfsJrviVJcX/ jLL5JzhlAwFwQqRg9YOTeWWcgpOlEonAZvlGiNYisEbMyoZlM/IL7ZFUSyknzUVTUjLO w1kPW5dZXZez7hFWxZIGFVNzQp9PGax42F7Zbdko/4Dp9z9M1mWTFSZNCuARHb94o/rP kGLQ== X-Gm-Message-State: AOJu0Yxxl4hbdcajtXVAfkgZtd2tm6Xn3X9B8v5dRYdhDH3oXUYacrMc VQr5TmOG77Pn38TMsSJZ5MHGgUCt1/kBQeqB92MPEa1yqcOI+HfvPmFNcovURytc4QPxbBgRp8k = X-Google-Smtp-Source: AGHT+IEp/VktX6QlhYOnD+TmUHYNnY29Ot2LT7eRFFRV022ijaER7SG6+3q1KdzKqeWi56IDjRhkSA== X-Received: by 2002:a6b:3c0e:0:b0:7bf:6f65:2bab with SMTP id k14-20020a6b3c0e000000b007bf6f652babmr1023363iob.7.1706111335593; Wed, 24 Jan 2024 07:48:55 -0800 (PST) Received: from localhost.localdomain (97-122-68-157.hlrn.qwest.net. [97.122.68.157]) by smtp.gmail.com with ESMTPSA id h5-20020a6b7845000000b007ba783a27c3sm6972526iop.11.2024.01.24.07.48.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 07:48:55 -0800 (PST) From: Tom Tromey Date: Wed, 24 Jan 2024 08:48:54 -0700 Subject: [PATCH 2/3] Clean up suppress_new_breakpoint_event MIME-Version: 1.0 Message-Id: <20240124-dap-launch-fix-v1-2-0d47f87fa9f0@adacore.com> References: <20240124-dap-launch-fix-v1-0-0d47f87fa9f0@adacore.com> In-Reply-To: <20240124-dap-launch-fix-v1-0-0d47f87fa9f0@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Kévin pointed out that suppress_new_breakpoint_event would do the wrong thing if it happened to be used reentrantly. While I don't think this can happen, it's also easy and clearly better to make it robust. --- gdb/python/lib/gdb/dap/breakpoint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py index 9cbd7ae0c47..87e746472fb 100644 --- a/gdb/python/lib/gdb/dap/breakpoint.py +++ b/gdb/python/lib/gdb/dap/breakpoint.py @@ -47,11 +47,12 @@ _suppress_bp = False def suppress_new_breakpoint_event(): """Return a new context manager that suppresses new breakpoint events.""" global _suppress_bp + saved = _suppress_bp _suppress_bp = True try: yield None finally: - _suppress_bp = False + _suppress_bp = saved @in_gdb_thread From patchwork Wed Jan 24 15:48:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84683 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 D09AA385DC04 for ; Wed, 24 Jan 2024 15:49:50 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by sourceware.org (Postfix) with ESMTPS id 786B03858C53 for ; Wed, 24 Jan 2024 15:48:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 786B03858C53 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 786B03858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706111342; cv=none; b=cRovfMNicBj4MQqgeNfsltjfuLAtS3MAwslKOAtn0UvIHlLEEAXV4+iUtwYkBj1suihc/02txCC2jBF/C60vzP3o9Afz/FR6IkNJJCmFZp1CfJ0Sge6EIOQUMzFFJNvW4Q6yteOKQwIcDZUoqru1QbJfj6DeRHhLiStUp1lWOcU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706111342; c=relaxed/simple; bh=bL4DWgcpN6Vh1bAdYlduxainP9pWxCf0x4W7VsZENNI=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=VBZdJGoN0/aEM8Y57YB7ecxdB0nweRHi5z5fjhDi/B4W/pIYbHgPSWlUYAd9vQowgqKw96pr7/lM0N2jqqKcHEeH1gEjK9HE+PEPo/Kd0SbhKEh8ilq+zkDXg+tF1QGseW91uH4KEcaPgwA4YF8dHnJU9OGXnRf7jUB+rs7KF2w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-7bee8858a8aso241829539f.0 for ; Wed, 24 Jan 2024 07:48:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1706111336; x=1706716136; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=o0j0RFTIVfoW7/Z2nj4tJKlYBW5FmcZ1lRhu9qAg9iA=; b=AVLtzfeU3sJ/sJxOanZ1TW6wsiPG0hlTdK940seIItS1SXF3BUqa21zpofhrdA3f5O b2c641cvdKGL1hSumkkg3DvdP45iGFT7QnqCF+1EhrFX7jzPfi15vhsk57V4XuIb367N O4mNoRYndHuGWw9ugPm/Ks0Gj9yzUM3dQKkZE7lqNfWSLegv4++OA+Lw2MzwO8ew+n97 z2+I56sUDuQT+Sc379y81SIVCP5enWsgbDTtbHSTVLzKcfRpUd20wsJLj9Gf9cdzX0Jy uHsxZljN4y9GZc2JQAsqi1B+uywZJnMsrP+Ji3e1XDc9f2RqUMEeo9Q5067y9Nr6V5ef UdUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706111336; x=1706716136; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o0j0RFTIVfoW7/Z2nj4tJKlYBW5FmcZ1lRhu9qAg9iA=; b=L3KXHmF5jfVSbUOKZ+acIt1kRwH6L0915SmLymN8fQuiWDwsKurtwPMfYcCZJM9om+ Ts7AvqR7uaWW12GC3roiaWIG+NzAK063GH3fHzdQJJpSga+OKHflSO/vzmFs9/K+bXSf YeBYk7LV9kb27f0xE43r1tysTE3trIEwj7bWi4gsG7IZ4D7JP1GBRS4RARQAWAAxDW+T Zh8Raemg0Uw9qIjPY6yNH3UNxKW57WXJ9DKviEQ5oQILlWWnxFjoDT2CrcTuAMPZyPSZ 7KSq9pwVN9DvCop55e0qlriJNYKpOpBWn7APmChpTvVU2woViW1bITLGBqBb6FNTpLkk JY4Q== X-Gm-Message-State: AOJu0YwVGlU3pIC7ad4NVhxtK1uayk2YO4qHpciLv7WNO4M673XKx1fa AF+UremJqRkpAWcbnFDCbALu21B9TbhkoktHcAiQoZxEig5nFlt/1dT2JjXkItUDOHvwGC0lOSg = X-Google-Smtp-Source: AGHT+IEtD90tyEdvqwXIka6mf2U81uFbxr5aVXZJoom3GxueubGjMnHkUPEoIci8O5NkDIiPgndmpQ== X-Received: by 2002:a5e:8c16:0:b0:7bf:a045:3c7e with SMTP id n22-20020a5e8c16000000b007bfa0453c7emr1986873ioj.40.1706111336307; Wed, 24 Jan 2024 07:48:56 -0800 (PST) Received: from localhost.localdomain (97-122-68-157.hlrn.qwest.net. [97.122.68.157]) by smtp.gmail.com with ESMTPSA id h5-20020a6b7845000000b007ba783a27c3sm6972526iop.11.2024.01.24.07.48.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 07:48:55 -0800 (PST) From: Tom Tromey Date: Wed, 24 Jan 2024 08:48:55 -0700 Subject: [PATCH 3/3] Fix DAP launch and configurationDone requests MIME-Version: 1.0 Message-Id: <20240124-dap-launch-fix-v1-3-0d47f87fa9f0@adacore.com> References: <20240124-dap-launch-fix-v1-0-0d47f87fa9f0@adacore.com> In-Reply-To: <20240124-dap-launch-fix-v1-0-0d47f87fa9f0@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Co-workers at AdaCore pointed out that gdb incorrectly implements the DAP launch and configurationDone requests. It's somewhat strange to me, but the spec does in fact say that configuration requests should occur before the executable is known to gdb. This was clarified in this bug report against the spec: https://github.com/microsoft/debug-adapter-protocol/issues/452 Fixing 'launch' to start the inferior was straightforward, but this then required some changes to how breakpoints are handled. In particular, now gdb will emit the "pending" reason on a breakpoint, and will suppress breakpoint events during breakpoint setting. --- gdb/python/lib/gdb/dap/breakpoint.py | 132 +++++++++++++++--------------- gdb/python/lib/gdb/dap/launch.py | 29 ++----- gdb/testsuite/gdb.dap/ada-arrays.exp | 8 +- gdb/testsuite/gdb.dap/ada-nested.exp | 7 +- gdb/testsuite/gdb.dap/ada-scopes.exp | 7 +- gdb/testsuite/gdb.dap/args-env.exp | 8 +- gdb/testsuite/gdb.dap/assign.exp | 7 +- gdb/testsuite/gdb.dap/basic-dap.exp | 63 +++++++------- gdb/testsuite/gdb.dap/bt-nodebug.exp | 8 +- gdb/testsuite/gdb.dap/catch-exception.exp | 7 +- gdb/testsuite/gdb.dap/children.exp | 7 +- gdb/testsuite/gdb.dap/cond-bp.exp | 16 +++- gdb/testsuite/gdb.dap/cwd.exp | 7 +- gdb/testsuite/gdb.dap/cxx-exception.exp | 7 +- gdb/testsuite/gdb.dap/eof.exp | 2 +- gdb/testsuite/gdb.dap/frameless.exp | 9 +- gdb/testsuite/gdb.dap/hover.exp | 8 +- gdb/testsuite/gdb.dap/lazy-string.exp | 7 +- gdb/testsuite/gdb.dap/log-message.exp | 8 +- gdb/testsuite/gdb.dap/memory.exp | 8 +- gdb/testsuite/gdb.dap/modules.exp | 7 +- gdb/testsuite/gdb.dap/pause.exp | 8 +- gdb/testsuite/gdb.dap/ptrref.exp | 8 +- gdb/testsuite/gdb.dap/rust-slices.exp | 8 +- gdb/testsuite/gdb.dap/scopes.exp | 8 +- gdb/testsuite/gdb.dap/sources.exp | 4 + gdb/testsuite/gdb.dap/stack-format.exp | 7 +- gdb/testsuite/gdb.dap/stop-at-main.exp | 6 +- gdb/testsuite/gdb.dap/terminate.exp | 6 +- gdb/testsuite/lib/dap-support.exp | 21 ++--- 30 files changed, 256 insertions(+), 182 deletions(-) diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py index 87e746472fb..dd6f6fb1827 100644 --- a/gdb/python/lib/gdb/dap/breakpoint.py +++ b/gdb/python/lib/gdb/dap/breakpoint.py @@ -28,17 +28,6 @@ from .startup import in_gdb_thread, log_stack, parse_and_eval, LogLevel, DAPExce from .typecheck import type_check -@in_gdb_thread -def _bp_modified(event): - send_event( - "breakpoint", - { - "reason": "changed", - "breakpoint": _breakpoint_descriptor(event), - }, - ) - - # True when suppressing new breakpoint events. _suppress_bp = False @@ -55,6 +44,19 @@ def suppress_new_breakpoint_event(): _suppress_bp = saved +@in_gdb_thread +def _bp_modified(event): + global _suppress_bp + if not _suppress_bp: + send_event( + "breakpoint", + { + "reason": "changed", + "breakpoint": _breakpoint_descriptor(event), + }, + ) + + @in_gdb_thread def _bp_created(event): global _suppress_bp @@ -70,13 +72,15 @@ def _bp_created(event): @in_gdb_thread def _bp_deleted(event): - send_event( - "breakpoint", - { - "reason": "removed", - "breakpoint": _breakpoint_descriptor(event), - }, - ) + global _suppress_bp + if not _suppress_bp: + send_event( + "breakpoint", + { + "reason": "removed", + "breakpoint": _breakpoint_descriptor(event), + }, + ) gdb.events.breakpoint_created.connect(_bp_created) @@ -97,11 +101,10 @@ def _breakpoint_descriptor(bp): "Return the Breakpoint object descriptor given a gdb Breakpoint." result = { "id": bp.number, - # We always use True here, because this field just indicates - # that breakpoint creation was successful -- and if we have a - # breakpoint, the creation succeeded. - "verified": True, + "verified": not bp.pending, } + if bp.pending: + result["reason"] = "pending" if bp.locations: # Just choose the first location, because DAP doesn't allow # multiple locations. See @@ -146,52 +149,53 @@ def _set_breakpoints_callback(kind, specs, creator): saved_map = {} breakpoint_map[kind] = {} result = [] - for spec in specs: - # It makes sense to reuse a breakpoint even if the condition - # or ignore count differs, so remove these entries from the - # spec first. - (condition, hit_condition) = _remove_entries(spec, "condition", "hitCondition") - keyspec = frozenset(spec.items()) - - # Create or reuse a breakpoint. If asked, set the condition - # or the ignore count. Catch errors coming from gdb and - # report these as an "unverified" breakpoint. - bp = None - try: - if keyspec in saved_map: - bp = saved_map.pop(keyspec) - else: - with suppress_new_breakpoint_event(): + with suppress_new_breakpoint_event(): + for spec in specs: + # It makes sense to reuse a breakpoint even if the condition + # or ignore count differs, so remove these entries from the + # spec first. + (condition, hit_condition) = _remove_entries(spec, "condition", "hitCondition") + keyspec = frozenset(spec.items()) + + # Create or reuse a breakpoint. If asked, set the condition + # or the ignore count. Catch errors coming from gdb and + # report these as an "unverified" breakpoint. + bp = None + try: + if keyspec in saved_map: + bp = saved_map.pop(keyspec) + else: bp = creator(**spec) - bp.condition = condition - if hit_condition is None: - bp.ignore_count = 0 - else: - bp.ignore_count = int( - parse_and_eval(hit_condition, global_context=True) + bp.condition = condition + if hit_condition is None: + bp.ignore_count = 0 + else: + bp.ignore_count = int( + parse_and_eval(hit_condition, global_context=True) + ) + + # Reaching this spot means success. + breakpoint_map[kind][keyspec] = bp + result.append(_breakpoint_descriptor(bp)) + # Exceptions other than gdb.error are possible here. + except Exception as e: + # Don't normally want to see this, as it interferes with + # the test suite. + log_stack(LogLevel.FULL) + # Maybe the breakpoint was made but setting an attribute + # failed. We still want this to fail. + if bp is not None: + bp.delete() + # Breakpoint creation failed. + result.append( + { + "verified": False, + "reason": "failed", + "message": str(e), + } ) - # Reaching this spot means success. - breakpoint_map[kind][keyspec] = bp - result.append(_breakpoint_descriptor(bp)) - # Exceptions other than gdb.error are possible here. - except Exception as e: - # Don't normally want to see this, as it interferes with - # the test suite. - log_stack(LogLevel.FULL) - # Maybe the breakpoint was made but setting an attribute - # failed. We still want this to fail. - if bp is not None: - bp.delete() - # Breakpoint creation failed. - result.append( - { - "verified": False, - "message": str(e), - } - ) - # Delete any breakpoints that were not reused. for entry in saved_map.values(): entry.delete() diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/launch.py index bf9640a4d92..19e8faa6704 100644 --- a/gdb/python/lib/gdb/dap/launch.py +++ b/gdb/python/lib/gdb/dap/launch.py @@ -23,16 +23,6 @@ from .server import request, capability from .startup import exec_and_log, DAPException -# The program being launched, or None. This should only be accessed -# from the gdb thread. -_program = None - - -# True if the program was attached, False otherwise. This should only -# be accessed from the gdb thread. -_attach = False - - # Any parameters here are necessarily extensions -- DAP requires this # from implementations. Any additions or changes here should be # documented in the gdb manual. @@ -46,10 +36,6 @@ def launch( stopAtBeginningOfMainSubprogram: bool = False, **extra, ): - global _program - _program = program - global _attach - _attach = False if cwd is not None: exec_and_log("cd " + cwd) if program is not None: @@ -64,6 +50,8 @@ def launch( inf.clear_env() for name, value in env.items(): inf.set_env(name, value) + expect_process("process") + exec_and_expect_stop("run") @request("attach") @@ -74,11 +62,6 @@ def attach( target: Optional[str] = None, **args, ): - # Ensure configurationDone does not try to run. - global _attach - _attach = True - global _program - _program = program if program is not None: exec_and_log("file " + program) if pid is not None: @@ -93,9 +76,7 @@ def attach( @capability("supportsConfigurationDoneRequest") -@request("configurationDone", response=False) +@request("configurationDone") def config_done(**args): - global _attach - if not _attach: - expect_process("process") - exec_and_expect_stop("run") + # Nothing to do. + return None diff --git a/gdb/testsuite/gdb.dap/ada-arrays.exp b/gdb/testsuite/gdb.dap/ada-arrays.exp index 7928aa19424..0de361f96bd 100644 --- a/gdb/testsuite/gdb.dap/ada-arrays.exp +++ b/gdb/testsuite/gdb.dap/ada-arrays.exp @@ -29,7 +29,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != ""} { return -1 } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -42,7 +42,11 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s cstuff.c] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone + +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "inferior started" thread "body reason" started dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ diff --git a/gdb/testsuite/gdb.dap/ada-nested.exp b/gdb/testsuite/gdb.dap/ada-nested.exp index f543fef47ef..3415da3e9cb 100644 --- a/gdb/testsuite/gdb.dap/ada-nested.exp +++ b/gdb/testsuite/gdb.dap/ada-nested.exp @@ -27,7 +27,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \ return -1 } -if {[dap_launch $binfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -39,8 +39,11 @@ set obj [dap_check_request_and_response "set breakpoint" \ [list s $srcfile] $line]] set fn_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone +if {[dap_launch $binfile] == ""} { + return +} dap_wait_for_event_and_check "stopped at breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $fn_bpno diff --git a/gdb/testsuite/gdb.dap/ada-scopes.exp b/gdb/testsuite/gdb.dap/ada-scopes.exp index 070deadb3a1..12004f8fc32 100644 --- a/gdb/testsuite/gdb.dap/ada-scopes.exp +++ b/gdb/testsuite/gdb.dap/ada-scopes.exp @@ -25,7 +25,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \ return -1 } -if {[dap_launch $binfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -37,8 +37,11 @@ set obj [dap_check_request_and_response "set breakpoint" \ [list s $srcfile] $line]] set fn_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone +if {[dap_launch $binfile] == ""} { + return +} dap_wait_for_event_and_check "stopped at breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $fn_bpno diff --git a/gdb/testsuite/gdb.dap/args-env.exp b/gdb/testsuite/gdb.dap/args-env.exp index 0f07fd25aae..d6511733348 100644 --- a/gdb/testsuite/gdb.dap/args-env.exp +++ b/gdb/testsuite/gdb.dap/args-env.exp @@ -25,7 +25,7 @@ if {[build_executable ${testfile}.exp $testfile] == -1} { return } -if {[dap_launch $testfile arguments {a "b c"} env {{DEI something}}] == ""} { +if {[dap_initialize] == ""} { return } @@ -36,7 +36,11 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s $srcfile] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone + +if {[dap_launch $testfile arguments {a "b c"} env {{DEI something}}] == ""} { + return +} dap_wait_for_event_and_check "inferior started" thread "body reason" started dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ diff --git a/gdb/testsuite/gdb.dap/assign.exp b/gdb/testsuite/gdb.dap/assign.exp index 386bf033f34..6703a97bb7a 100644 --- a/gdb/testsuite/gdb.dap/assign.exp +++ b/gdb/testsuite/gdb.dap/assign.exp @@ -31,7 +31,7 @@ set remote_python_file [gdb_remote_download host \ save_vars GDBFLAGS { append GDBFLAGS " -iex \"source $remote_python_file\"" - if {[dap_launch $testfile] == ""} { + if {[dap_initialize] == ""} { return } } @@ -43,8 +43,11 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s $srcfile] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $line_bpno diff --git a/gdb/testsuite/gdb.dap/basic-dap.exp b/gdb/testsuite/gdb.dap/basic-dap.exp index 431ea3d213d..6ef9a5b0f6e 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp @@ -25,7 +25,7 @@ if {[build_executable ${testfile}.exp $testfile] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -72,21 +72,6 @@ if {$ok} { fail "check lack of new breakpoint event" } -# Check that there are breakpoint locations on each line between FIRST -# and BREAK. -set first_line [gdb_get_line_number "FIRST"] -set last_line [expr {$line - 1}] -set obj [dap_check_request_and_response "breakpoint locations" \ - breakpointLocations \ - [format {o source [o path [%s]] line [i %d] endLine [i %d]} \ - [list s $srcfile] $first_line $last_line]] -# We know gdb returns the lines in sorted order. -foreach entry [dict get [lindex $obj 0] body breakpoints] { - gdb_assert {[dict get $entry line] == $first_line} \ - "line $first_line in result" - incr first_line -} - # Note that in this request, we add a 'source' field to the # SourceBreakpoint object. This isn't in the spec but it once caused # an incorrect exception in the Python code. See PR dap/30820. @@ -99,23 +84,15 @@ set obj [dap_check_request_and_response "reset breakpoint by line number" \ set new_line_bpno [dap_get_breakpoint_number $obj] gdb_assert {$new_line_bpno == $line_bpno} "re-setting kept same breakpoint number" -# This uses "&address_breakpoint_here" as the address -- this is a -# hack because we know how this is implemented under the hood. -set obj [dap_check_request_and_response "set breakpoint by address" \ - setInstructionBreakpoints \ - {o breakpoints [a [o instructionReference [s &address_breakpoint_here]]]}] -set insn_bpno [dap_get_breakpoint_number $obj] - -set response [lindex $obj 0] -set bplist [dict get $response body breakpoints] -set insn_pc [dict get [lindex $bplist 0] instructionReference] +dap_check_request_and_response "configurationDone" configurationDone -dap_check_request_and_response "start inferior" configurationDone +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "inferior started" thread "body reason" started # While waiting for the stopped event, we might receive breakpoint changed -# events indicating some breakpoint addresses were relocated. Update INSN_PC -# if necessary. +# events indicating some breakpoint addresses were relocated. lassign [dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $fn_bpno] unused objs @@ -136,12 +113,32 @@ foreach obj $objs { set breakpoint [dict get $body "breakpoint"] set breakpoint_id [dict get $breakpoint "id"] +} - if { $breakpoint_id != $insn_bpno } { - continue - } +# This uses "&address_breakpoint_here" as the address -- this is a +# hack because we know how this is implemented under the hood. +set obj [dap_check_request_and_response "set breakpoint by address" \ + setInstructionBreakpoints \ + {o breakpoints [a [o instructionReference [s &address_breakpoint_here]]]}] +set insn_bpno [dap_get_breakpoint_number $obj] + +set response [lindex $obj 0] +set bplist [dict get $response body breakpoints] +set insn_pc [dict get [lindex $bplist 0] instructionReference] - set insn_pc [dict get $breakpoint "instructionReference"] +# Check that there are breakpoint locations on each line between FIRST +# and BREAK. +set first_line [gdb_get_line_number "FIRST"] +set last_line [expr {$line - 1}] +set obj [dap_check_request_and_response "breakpoint locations" \ + breakpointLocations \ + [format {o source [o path [%s]] line [i %d] endLine [i %d]} \ + [list s $srcfile] $first_line $last_line]] +# We know gdb returns the lines in sorted order. +foreach entry [dict get [lindex $obj 0] body breakpoints] { + gdb_assert {[dict get $entry line] == $first_line} \ + "line $first_line in result" + incr first_line } set obj [dap_check_request_and_response "evaluate global in function" \ diff --git a/gdb/testsuite/gdb.dap/bt-nodebug.exp b/gdb/testsuite/gdb.dap/bt-nodebug.exp index 57d4dacaedc..550b9c5c5ac 100644 --- a/gdb/testsuite/gdb.dap/bt-nodebug.exp +++ b/gdb/testsuite/gdb.dap/bt-nodebug.exp @@ -27,7 +27,7 @@ if {[build_executable_from_specs $testfile.exp $testfile {} \ return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -36,7 +36,11 @@ set obj [dap_check_request_and_response "set breakpoint on inner" \ {o breakpoints [a [o name [s function_breakpoint_here]]]}] set fn_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone + +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "inferior started" thread "body reason" started lassign [dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ diff --git a/gdb/testsuite/gdb.dap/catch-exception.exp b/gdb/testsuite/gdb.dap/catch-exception.exp index 8ca0a83ec71..166b862f9a7 100644 --- a/gdb/testsuite/gdb.dap/catch-exception.exp +++ b/gdb/testsuite/gdb.dap/catch-exception.exp @@ -25,7 +25,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \ return -1 } -if {[dap_launch $binfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -61,8 +61,11 @@ foreach spec $bps { incr i } -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone +if {[dap_launch $binfile] == ""} { + return +} dap_wait_for_event_and_check "stopped at first raise" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" 2 diff --git a/gdb/testsuite/gdb.dap/children.exp b/gdb/testsuite/gdb.dap/children.exp index b2444e06fb6..f5dfe2cbb91 100644 --- a/gdb/testsuite/gdb.dap/children.exp +++ b/gdb/testsuite/gdb.dap/children.exp @@ -31,7 +31,7 @@ set remote_python_file [gdb_remote_download host \ save_vars GDBFLAGS { append GDBFLAGS " -iex \"source $remote_python_file\"" - if {[dap_launch $testfile] == ""} { + if {[dap_initialize] == ""} { return } } @@ -43,8 +43,11 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s $srcfile] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $line_bpno diff --git a/gdb/testsuite/gdb.dap/cond-bp.exp b/gdb/testsuite/gdb.dap/cond-bp.exp index 427776a5cbb..2bd52ba83a0 100644 --- a/gdb/testsuite/gdb.dap/cond-bp.exp +++ b/gdb/testsuite/gdb.dap/cond-bp.exp @@ -25,7 +25,7 @@ if {[build_executable ${testfile}.exp $testfile] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -44,8 +44,13 @@ set i 1 foreach bp [dict get [lindex $obj 0] body breakpoints] { gdb_assert {[dict get $bp verified] == "false"} \ "breakpoint $i invalid" - gdb_assert {[dict get $bp message] != ""} \ - "breakpoint $i has message" + if {$i == 1} { + gdb_assert {[dict get $bp reason] == "pending"} \ + "breakpoint $i pending" + } else { + gdb_assert {[dict get $bp message] != ""} \ + "breakpoint $i has message" + } incr i } @@ -58,8 +63,11 @@ set obj [dap_check_request_and_response "set conditional breakpoint" \ [list s $srcfile] $line]] set fn_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $fn_bpno diff --git a/gdb/testsuite/gdb.dap/cwd.exp b/gdb/testsuite/gdb.dap/cwd.exp index 9e1d070435b..6b8829965c5 100644 --- a/gdb/testsuite/gdb.dap/cwd.exp +++ b/gdb/testsuite/gdb.dap/cwd.exp @@ -25,6 +25,12 @@ if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} { return } +if {[dap_initialize] == ""} { + return +} + +dap_check_request_and_response "configurationDone" configurationDone + # Starting the inferior will fail if the change of cwd does not work. set the_dir [file dirname $testfile] set the_file [file tail $testfile] @@ -32,7 +38,6 @@ if {[dap_launch $the_file cwd $the_dir stop_at_main 1] == ""} { return } -dap_check_request_and_response "start inferior" configurationDone # We didn't explicitly set a breakpoint, so if we hit one, it worked. dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ "body reason" breakpoint diff --git a/gdb/testsuite/gdb.dap/cxx-exception.exp b/gdb/testsuite/gdb.dap/cxx-exception.exp index 284aef40009..b54b11a2c9a 100644 --- a/gdb/testsuite/gdb.dap/cxx-exception.exp +++ b/gdb/testsuite/gdb.dap/cxx-exception.exp @@ -24,7 +24,7 @@ if {[build_executable ${testfile}.exp $testfile $srcfile {debug c++}] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -37,8 +37,11 @@ set bps [dict get [lindex $obj 0] body breakpoints] # breakpoints. gdb_assert {[llength $bps] == 3} "three breakpoints" -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "stopped at throw" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" 1 diff --git a/gdb/testsuite/gdb.dap/eof.exp b/gdb/testsuite/gdb.dap/eof.exp index 139c17ad335..9c17725c0d0 100644 --- a/gdb/testsuite/gdb.dap/eof.exp +++ b/gdb/testsuite/gdb.dap/eof.exp @@ -26,7 +26,7 @@ if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } diff --git a/gdb/testsuite/gdb.dap/frameless.exp b/gdb/testsuite/gdb.dap/frameless.exp index 9d25fc5902d..63ee521af65 100644 --- a/gdb/testsuite/gdb.dap/frameless.exp +++ b/gdb/testsuite/gdb.dap/frameless.exp @@ -25,7 +25,7 @@ if {[build_executable ${testfile}.exp $testfile] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -36,9 +36,12 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s $srcfile] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone -dap_wait_for_event_and_check "inferior started" thread "body reason" started +dap_check_request_and_response "configurationDone" configurationDone +if {[dap_launch $testfile] == ""} { + return +} +dap_wait_for_event_and_check "inferior started" thread "body reason" started dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $line_bpno diff --git a/gdb/testsuite/gdb.dap/hover.exp b/gdb/testsuite/gdb.dap/hover.exp index f7b9fd702ad..0c80650b152 100644 --- a/gdb/testsuite/gdb.dap/hover.exp +++ b/gdb/testsuite/gdb.dap/hover.exp @@ -25,7 +25,7 @@ if {[build_executable ${testfile}.exp $testfile] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -36,7 +36,11 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s $srcfile] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone + +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "inferior started" thread "body reason" started dap_wait_for_event_and_check "stopped at breakpoint" stopped \ diff --git a/gdb/testsuite/gdb.dap/lazy-string.exp b/gdb/testsuite/gdb.dap/lazy-string.exp index 0249f142a6e..54422209fda 100644 --- a/gdb/testsuite/gdb.dap/lazy-string.exp +++ b/gdb/testsuite/gdb.dap/lazy-string.exp @@ -31,7 +31,7 @@ set remote_python_file [gdb_remote_download host \ save_vars GDBFLAGS { append GDBFLAGS " -iex \"source $remote_python_file\"" - if {[dap_launch $testfile] == ""} { + if {[dap_initialize] == ""} { return } } @@ -43,8 +43,11 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s $srcfile] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $line_bpno diff --git a/gdb/testsuite/gdb.dap/log-message.exp b/gdb/testsuite/gdb.dap/log-message.exp index 4e3ecb7807b..e966b962a71 100644 --- a/gdb/testsuite/gdb.dap/log-message.exp +++ b/gdb/testsuite/gdb.dap/log-message.exp @@ -25,7 +25,7 @@ if {[build_executable ${testfile}.exp $testfile] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -38,7 +38,11 @@ set obj [dap_check_request_and_response "set breakpoint" \ [list s $srcfile] $line]] set fn_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone + +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "inferior started" thread "body reason" started dap_wait_for_event_and_check "logging output" output \ diff --git a/gdb/testsuite/gdb.dap/memory.exp b/gdb/testsuite/gdb.dap/memory.exp index 481ab628be9..2e911f4dc77 100644 --- a/gdb/testsuite/gdb.dap/memory.exp +++ b/gdb/testsuite/gdb.dap/memory.exp @@ -25,7 +25,7 @@ if {[build_executable ${testfile}.exp $testfile] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -36,7 +36,11 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s $srcfile] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone + +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "inferior started" thread "body reason" started dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ diff --git a/gdb/testsuite/gdb.dap/modules.exp b/gdb/testsuite/gdb.dap/modules.exp index 4d53b90fa96..87cebda7131 100644 --- a/gdb/testsuite/gdb.dap/modules.exp +++ b/gdb/testsuite/gdb.dap/modules.exp @@ -38,7 +38,7 @@ if {[build_executable ${testfile}.exp $testfile $srcfile \ return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -47,8 +47,11 @@ set obj [dap_check_request_and_response "set breakpoint on stop function" \ {o breakpoints [a [o name [s stop]]]}] set fn_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $fn_bpno diff --git a/gdb/testsuite/gdb.dap/pause.exp b/gdb/testsuite/gdb.dap/pause.exp index e1e0d957fc6..4d13dadd3ad 100644 --- a/gdb/testsuite/gdb.dap/pause.exp +++ b/gdb/testsuite/gdb.dap/pause.exp @@ -25,7 +25,7 @@ if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -41,7 +41,11 @@ dap_check_request_and_response "set conditional breakpoint" \ condition [s "return_false()"]]]} \ [list s $srcfile] $line] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone + +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "process event generated" process \ "body startMethod" process dap_wait_for_event_and_check "inferior started" thread "body reason" started diff --git a/gdb/testsuite/gdb.dap/ptrref.exp b/gdb/testsuite/gdb.dap/ptrref.exp index bcdbc5bb56c..0552c3b9815 100644 --- a/gdb/testsuite/gdb.dap/ptrref.exp +++ b/gdb/testsuite/gdb.dap/ptrref.exp @@ -23,7 +23,7 @@ if {[build_executable ${testfile}.exp $testfile $srcfile {debug c++}] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -34,7 +34,11 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s $srcfile] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone + +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "inferior started" thread "body reason" started dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ diff --git a/gdb/testsuite/gdb.dap/rust-slices.exp b/gdb/testsuite/gdb.dap/rust-slices.exp index 8a8c79c7088..c85568d69ea 100644 --- a/gdb/testsuite/gdb.dap/rust-slices.exp +++ b/gdb/testsuite/gdb.dap/rust-slices.exp @@ -28,7 +28,7 @@ if {[build_executable ${testfile}.exp $testfile $srcfile {debug rust}] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -39,7 +39,11 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s $srcfile] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone + +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "inferior started" thread "body reason" started dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ diff --git a/gdb/testsuite/gdb.dap/scopes.exp b/gdb/testsuite/gdb.dap/scopes.exp index 0b0727cd875..aa3bb688c0e 100644 --- a/gdb/testsuite/gdb.dap/scopes.exp +++ b/gdb/testsuite/gdb.dap/scopes.exp @@ -25,7 +25,7 @@ if {[build_executable ${testfile}.exp $testfile] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } @@ -36,7 +36,11 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s $srcfile] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone + +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "inferior started" thread "body reason" started dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ diff --git a/gdb/testsuite/gdb.dap/sources.exp b/gdb/testsuite/gdb.dap/sources.exp index 670084e56cf..b60681160af 100644 --- a/gdb/testsuite/gdb.dap/sources.exp +++ b/gdb/testsuite/gdb.dap/sources.exp @@ -25,6 +25,10 @@ if {[build_executable ${testfile}.exp $testfile] == -1} { return } +if {[dap_initialize] == ""} { + return +} + if {[dap_launch $testfile stop_at_main 1] == ""} { return } diff --git a/gdb/testsuite/gdb.dap/stack-format.exp b/gdb/testsuite/gdb.dap/stack-format.exp index af9d6d02efa..b81183a016e 100644 --- a/gdb/testsuite/gdb.dap/stack-format.exp +++ b/gdb/testsuite/gdb.dap/stack-format.exp @@ -31,7 +31,7 @@ set remote_python_file [gdb_remote_download host \ save_vars GDBFLAGS { append GDBFLAGS " -iex \"source $remote_python_file\"" - if {[dap_launch $testfile] == ""} { + if {[dap_initialize] == ""} { return } } @@ -43,8 +43,11 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ [list s $srcfile] $line]] set line_bpno [dap_get_breakpoint_number $obj] -dap_check_request_and_response "start inferior" configurationDone +dap_check_request_and_response "configurationDone" configurationDone +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $line_bpno diff --git a/gdb/testsuite/gdb.dap/stop-at-main.exp b/gdb/testsuite/gdb.dap/stop-at-main.exp index f7eb9ac7a0d..4c3e57a23e4 100644 --- a/gdb/testsuite/gdb.dap/stop-at-main.exp +++ b/gdb/testsuite/gdb.dap/stop-at-main.exp @@ -25,11 +25,15 @@ if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} { return } -if {[dap_launch $testfile stop_at_main 1] == ""} { +if {[dap_initialize] == ""} { return } dap_check_request_and_response "start inferior" configurationDone + +if {[dap_launch $testfile stop_at_main 1] == ""} { + return +} # We didn't explicitly set a breakpoint, so if we hit one, it worked. dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ "body reason" breakpoint diff --git a/gdb/testsuite/gdb.dap/terminate.exp b/gdb/testsuite/gdb.dap/terminate.exp index 9c3706447dc..90d01945a64 100644 --- a/gdb/testsuite/gdb.dap/terminate.exp +++ b/gdb/testsuite/gdb.dap/terminate.exp @@ -27,11 +27,15 @@ if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} { return } -if {[dap_launch $testfile] == ""} { +if {[dap_initialize] == ""} { return } dap_check_request_and_response "start inferior" configurationDone + +if {[dap_launch $testfile] == ""} { + return +} dap_wait_for_event_and_check "inferior started" thread "body reason" started dap_wait_for_event_and_check "terminated event" terminated diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index 07259862b18..979dfa2cd73 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -235,10 +235,9 @@ proc dap_check_request_and_response {name command {obj {}}} { # Start gdb, send a DAP initialization request and return the # response. This approach lets the caller check the feature list, if -# desired. Callers not caring about this should probably use -# dap_launch. Returns the empty string on failure. NAME is used as -# the test name. -proc dap_initialize {name} { +# desired. Returns the empty string on failure. NAME is used as the +# test name. +proc dap_initialize {{name "initialize"}} { if {[dap_gdb_start]} { return "" } @@ -249,11 +248,12 @@ proc dap_initialize {name} { supportsMemoryReferences [l true]}] } -# Start gdb, send a DAP initialize request, and then a launch request -# specifying FILE as the program to use for the inferior. Returns the -# empty string on failure, or the response object from the launch -# request. If specified, ARGS is a dictionary of key-value pairs, -# each passed to the launch request. Valid keys are: +# Send a launch request specifying FILE as the program to use for the +# inferior. Returns the empty string on failure, or the response +# object from the launch request. If specified, ARGS is a dictionary +# of key-value pairs, each passed to the launch request. Valid keys +# are: +# # * arguments - value is a list of strings passed as command-line # arguments to the inferior # * env - value is a list of pairs of the form {VAR VALUE} that is @@ -266,9 +266,6 @@ proc dap_initialize {name} { # After this proc is called, gdb will be ready to accept breakpoint # requests. proc dap_launch {file {args {}}} { - if {[dap_initialize "startup - initialize"] == ""} { - return "" - } set params "o program" append params " [format {[%s]} [list s [standard_output_file $file]]]"