From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YM8XMQb39mK29CUAWB0awg (envelope-from ) for ; Fri, 12 Aug 2022 20:57:42 -0400 Received: by simark.ca (Postfix, from userid 112) id C69681E797; Fri, 12 Aug 2022 20:57:42 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=bIviTPYL; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id CEBF41E13B for ; Fri, 12 Aug 2022 20:57:41 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7F84F3857346 for ; Sat, 13 Aug 2022 00:57:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F84F3857346 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660352261; bh=ngR7fBy60u2j5SZIfoG+LKKa4Aw2e51e0lc+5+HdfM0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=bIviTPYLQ83q3BPpElLsJKoOoKjLFcWqaDBkVYYIuw2k+EXymzYR00+oKBbk2MUXe wZf/Oe/t0hk6iCUPgtn/XSoRgn3Cc1aiDUOrQm5q8fv4AzObQ+HWU7aEmWFuClgv6W fTjiX4SM55Yj2+t6Y5qe9zRQvjgaz7h40f0qALi0= 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 C90583858010 for ; Sat, 13 Aug 2022 00:54:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C90583858010 Received: by mail-io1-xd2b.google.com with SMTP id v185so2066659ioe.11 for ; Fri, 12 Aug 2022 17:54:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ngR7fBy60u2j5SZIfoG+LKKa4Aw2e51e0lc+5+HdfM0=; b=omgaIofE4DdPhEKgQDiozIFcqzwkcBxGI7Eomjh5ZsXZtiC7ACP9DQTboEwFeEOcU8 CFknKewVlpdNTR3q0X61pB3902m/GyaAgZmHeYdBR/06NcZQTlkBSqlX2eEj7+6hDdVf yoC1bgCi8oYH8WRwCmo6zgyajzGa5uL+f7VEfM0k6ENs8m4eTzDuOnNOz+9GXq6j4mme CcbkZAUeO6RIFZLykHLtdwm0mzJBhRQQZhrR6PBm/zyv3hxqfSUug9j7TZ2GrcnvA0Jm SRXqTixXvBAtCuefupK+dF1Omn80cLeQnugpIKhjF0rakklOP8oL9A/a6BjoDyXvRzYs 5dOw== X-Gm-Message-State: ACgBeo01R5w9chAJLc8z1l3i1grtYoZ+Cpsj5hHgFQBxiyi6yRKk5tdv njyjqRbW8Q4fzIGoG4bSM/w51I7OH9tAIw== X-Google-Smtp-Source: AA6agR7LmC44QyFAZ6Xpcp7cheDdhyKlgaDi4r2BrBwBuaf7jYJl+VCImxZqoMUwievMyXx8Jez9WQ== X-Received: by 2002:a05:6602:2b88:b0:67c:aca7:2f73 with SMTP id r8-20020a0566022b8800b0067caca72f73mr2752053iov.108.1660352093089; Fri, 12 Aug 2022 17:54:53 -0700 (PDT) Received: from murgatroyd.Home (71-211-185-228.hlrn.qwest.net. [71.211.185.228]) by smtp.gmail.com with ESMTPSA id p17-20020a056638217100b00343455007f7sm494366jak.110.2022.08.12.17.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 17:54:52 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 13/14] Fix "source" with interpreter-exec Date: Fri, 12 Aug 2022 18:54:41 -0600 Message-Id: <20220813005442.4163512-14-tromey@adacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220813005442.4163512-1-tromey@adacore.com> References: <20220813005442.4163512-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom Tromey via Gdb-patches Reply-To: Tom Tromey Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" PR mi/15811 points out that "source"ing a file that uses interpreter-exec will put gdb in a weird state, where the CLI stops working. The bug is that tui_interp::suspend does not unregister the event file descriptor. The test case is from Andrew Burgess. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=15811 --- gdb/testsuite/gdb.base/interpreter-exec.gdb | 20 ++++++++++++++++++++ gdb/testsuite/gdb.base/source.exp | 6 ++++++ gdb/tui/tui-interp.c | 1 + 3 files changed, 27 insertions(+) create mode 100644 gdb/testsuite/gdb.base/interpreter-exec.gdb diff --git a/gdb/testsuite/gdb.base/interpreter-exec.gdb b/gdb/testsuite/gdb.base/interpreter-exec.gdb new file mode 100644 index 00000000000..6afff23af0f --- /dev/null +++ b/gdb/testsuite/gdb.base/interpreter-exec.gdb @@ -0,0 +1,20 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2013 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 GDB's "source" command for scripts containing interpreter-exec. + +interpreter-exec mi "-gdb-show verbose" diff --git a/gdb/testsuite/gdb.base/source.exp b/gdb/testsuite/gdb.base/source.exp index 3d72b504832..9884a720420 100644 --- a/gdb/testsuite/gdb.base/source.exp +++ b/gdb/testsuite/gdb.base/source.exp @@ -73,3 +73,9 @@ gdb_test "source ${srcdir}/${subdir}/source-error.gdb" \ "source-error-1.gdb:21: Error in sourced command file:" \ "Cannot access memory at address 0x0" ] \ "script contains error" + +# There was a case where sourcing a script containing "interpreter-exec" +# commands would corrupt the interpreter mechanism and crash gdb. +gdb_test "source ${srcdir}/${subdir}/interpreter-exec.gdb" \ + "\\^done,value=\"off\"" \ + "source interpreter-exec" diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c index 1c4ffbbc3aa..e0846fe80c4 100644 --- a/gdb/tui/tui-interp.c +++ b/gdb/tui/tui-interp.c @@ -135,6 +135,7 @@ tui_interp::resume () void tui_interp::suspend () { + gdb_disable_readline (); tui_start_enabled = tui_active; tui_disable (); } -- 2.34.1