From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Shahab Vahedi <shahab@synopsys.com>,
Pedro Alves <palves@redhat.com>, Tom Tromey <tom@tromey.com>
Subject: [PATCHv2 1/2] gdb/tui: Prevent exceptions from trying to cross readline
Date: Thu, 16 Jan 2020 02:55:00 -0000 [thread overview]
Message-ID: <7b66ec5655ca7eee42b5b210f29aff335406fb0d.1579135219.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1579135219.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1579135219.git.andrew.burgess@embecosm.com>
From: Pedro Alves <palves@redhat.com>
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 <palves@redhat.com>
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<char>
--
2.14.5
next prev parent reply other threads:[~2020-01-16 0:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200110115728.13940-1-shahab.vahedi@gmail.com>
2020-01-10 12:53 ` [PATCH v2][PR tui/9765] Fix segfault in asm TUI when reaching end of file Pedro Alves
2020-01-10 13:37 ` [PATCH] Don't let TUI exceptions escape to readline (PR tui/9765) Pedro Alves
2020-01-10 14:31 ` Shahab Vahedi
2020-01-13 20:46 ` [PATCH 2/2] gdb/tui: asm window handles invalid memory and scrolls better Andrew Burgess
2020-01-15 0:57 ` Tom Tromey
2020-01-13 22:04 ` [PATCH 1/2] gdb/tui: Prevent exceptions from trying to cross readline Andrew Burgess
2020-01-15 0:56 ` Tom Tromey
[not found] ` <cover.1578948166.git.andrew.burgess@embecosm.com>
2020-01-14 14:19 ` [PATCH 0/2] gdb/tui: Assembler window scrolling fixes Shahab Vahedi
2020-01-16 0:48 ` [PATCHv2 2/2] gdb/tui: asm window handles invalid memory and scrolls better Andrew Burgess
2020-01-21 16:27 ` Shahab Vahedi
2020-01-22 13:30 ` Shahab Vahedi
2020-01-22 16:32 ` Andrew Burgess
2020-01-22 19:26 ` Pedro Alves
2020-01-16 0:48 ` [PATCHv2 0/2] gdb/tui: Assembler window scrolling fixes Andrew Burgess
2020-01-24 11:22 ` Shahab Vahedi
2020-01-24 21:22 ` [PATCH 0/2] Further Assembler Scrolling Fixes Andrew Burgess
2020-01-24 21:22 ` [PATCH 1/2] gdb/tui: Update help text for scroll commands Andrew Burgess
2020-01-26 16:07 ` Tom Tromey
2020-01-24 21:29 ` [PATCH 2/2] gdb/tui: Disassembler scrolling of very small programs Andrew Burgess
2020-01-26 16:10 ` Tom Tromey
2020-01-31 10:10 ` Shahab Vahedi
2020-01-16 2:55 ` Andrew Burgess [this message]
2020-01-10 14:42 ` [PATCH] Don't let TUI exceptions escape to readline (PR tui/9765) Tom Tromey
2020-01-10 13:47 ` [PATCH v2][PR tui/9765] Fix segfault in asm TUI when reaching end of file Shahab Vahedi
2020-01-11 2:00 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b66ec5655ca7eee42b5b210f29aff335406fb0d.1579135219.git.andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=shahab@synopsys.com \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox