From patchwork Mon Jan 13 20:46:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 37360 Received: (qmail 45404 invoked by alias); 13 Jan 2020 20:46:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 45319 invoked by uid 89); 13 Jan 2020 20:46:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1896, WINDOW, yyyymmdd, HX-Received:sk:q10mr21 X-HELO: mail-wm1-f46.google.com Received: from mail-wm1-f46.google.com (HELO mail-wm1-f46.google.com) (209.85.128.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 Jan 2020 20:46:35 +0000 Received: by mail-wm1-f46.google.com with SMTP id p17so11294948wma.1 for ; Mon, 13 Jan 2020 12:46:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=uepDBFudLL5YsWGUZmIJYc1Gf15zfGkWgjVRQp1I6Xs=; b=JupDSvl7jON//j+hYBt7lII5RMFyLdSEGZXWqKmz9TaEfrGsrsczmdAyKM5sN5ZPtI xLySS1Vn7qpyr23uXoBFpdsR/sueA70f9bvJfoTeHxRev+7wpHuRGHeBnpXYPuXQmAAS 7MYxtitT66f5Yplurkzn5V0fTIgY7IT/ZbmxY/UpoHrF3AoMm/S3ogj5d+/IUIBbHtTB eGdMss30CzZAGmNtkEAWYYyIalfli+LvsMR6K+DKVcKfwgCbONQddEvR6ujyGp6pOBET EZ4QLSzfhJbT2tFgxo0CIXrykhh9JyY+G0aIUA9zrxaA/tXqHzRuasbFf5ASIKgEAm0e qqcg== Return-Path: Received: from localhost (cust242-dsl59.idnet.net. [212.69.59.242]) by smtp.gmail.com with ESMTPSA id n189sm16224231wme.33.2020.01.13.12.46.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Jan 2020 12:46:32 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Shahab Vahedi , Pedro Alves , Tom Tromey Subject: [PATCH 1/2] gdb/tui: Prevent exceptions from trying to cross readline Date: Mon, 13 Jan 2020 20:46:26 +0000 Message-Id: <7b66ec5655ca7eee42b5b210f29aff335406fb0d.1578948166.git.andrew.burgess@embecosm.com> In-Reply-To: References: In-Reply-To: References: <20200110143056.GD3815@gmail.com> X-IsSubscribed: yes From: Pedro Alves This is triggered by simply scrolling off the end of the dissasembly window. This commit doesn't fix the actual exception that is being thrown, which will still need to be fixed, but makes sure that we don't ever throw an exception out to readline. gdb/ChangeLog: yyyy-mm-dd Pedro Alves PR tui/9765 * tui/tui-io.c (tui_getc): Rename to ... (tui_getc_1): ... this. (tui_get): New, reimplent as try/catch wrapper around tui_getc_1. Change-Id: I2e32a401ab34404b2132ec82a3e1c17b9b723e41 --- gdb/tui/tui-io.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 9cb41104fe9..d9f23334f57 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -950,10 +950,12 @@ tui_dispatch_ctrl_char (unsigned int ch) return 0; } -/* Get a character from the command window. This is called from the - readline package. */ +/* Main worker for tui_getc. Get a character from the command window. + This is called from the readline package, but wrapped in a + try/catch by tui_getc. */ + static int -tui_getc (FILE *fp) +tui_getc_1 (FILE *fp) { int ch; WINDOW *w; @@ -1036,6 +1038,29 @@ tui_getc (FILE *fp) return ch; } +/* Get a character from the command window. This is called from the + readline package. */ + +static int +tui_getc (FILE *fp) +{ + try + { + return tui_getc_1 (fp); + } + catch (const gdb_exception &ex) + { + /* Just in case, don't ever let an exception escape to readline. + This shouldn't ever happen, but if it does, print the + exception instead of just crashing GDB. */ + exception_print (gdb_stderr, ex); + + /* If we threw an exception, it's because we recognized the + character. */ + return 0; + } +} + /* See tui-io.h. */ gdb::unique_xmalloc_ptr