From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org, Pedro Alves <palves@redhat.com>
Subject: [PATCH][gdb] Catch exception when constructing the highlighter
Date: Thu, 19 Sep 2019 16:18:00 -0000 [thread overview]
Message-ID: <2e0b9a76-a897-167e-6d4b-46174bfc6da7@suse.de> (raw)
In-Reply-To: <87woe4saz0.fsf@tromey.com>
[-- Attachment #1: Type: text/plain, Size: 799 bytes --]
[ was: Re: [PATCH v2 2/2] Add Rust support to source highlighting ]
On 19-09-19 14:54, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> Well, it does work, but your question makes me realize that that's an
> Tom> implementation artefact of the library, which could change for newer
> Tom> version (or perhaps there are older versions where that differs). So it
> Tom> should be safer to wrap highlighter construction as well.
>
> Tom> Updated the patch accordingly, and also added a PR number to both patches.
>
> Looks good to me -- but the bad news is you'll probably now want a
> similar patch on master.
Ok, committed to 8.3 branch.
Here's the proposed commit for master.
Ok for trunk if testing on x86_64-linux finishes without problems?
Thanks,
- Tom
[-- Attachment #2: 0001-gdb-Catch-exception-when-constructing-the-highlighter.patch --]
[-- Type: text/x-patch, Size: 2015 bytes --]
[gdb] Catch exception when constructing the highlighter
Currently in source_cache::ensure we catch the exception that triggers when
highlighter->highlight is called:
...
try
{
std::istringstream input (contents);
std::ostringstream output;
highlighter->highlight (input, output, lang_name, fullname);
...
and the file used earlier in the construction of the highlighter:
...
highlighter = new srchilite::SourceHighlight ("esc.outlang");
...
is missing.
The fact that this exception triggers when highlighter->highlight is called is
an implementation artefact of libsource-highlight.so though, and this could be
different for older or newer versions.
Make things more robust by also catching exceptions thrown during construction
of the highlighter. This makes the handling on master equivalent with what
has been committed for 8.3.1.
Tested on x86_64-linux.
gdb/ChangeLog:
2019-09-19 Tom de Vries <tdevries@suse.de>
PR gdb/25009
* source-cache.c (source_cache::ensure): Catch exception thrown during
construction of the highlighter.
---
gdb/source-cache.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gdb/source-cache.c b/gdb/source-cache.c
index 7a52ce9458..1fe6da8132 100644
--- a/gdb/source-cache.c
+++ b/gdb/source-cache.c
@@ -190,14 +190,14 @@ source_cache::ensure (struct symtab *s)
conditional compilation in source-cache.h. */
static srchilite::SourceHighlight *highlighter;
- if (highlighter == nullptr)
- {
- highlighter = new srchilite::SourceHighlight ("esc.outlang");
- highlighter->setStyleFile ("esc.style");
- }
-
try
{
+ if (highlighter == nullptr)
+ {
+ highlighter = new srchilite::SourceHighlight ("esc.outlang");
+ highlighter->setStyleFile ("esc.style");
+ }
+
std::istringstream input (contents);
std::ostringstream output;
highlighter->highlight (input, output, lang_name, fullname);
next prev parent reply other threads:[~2019-09-19 16:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-27 15:52 [PATCH v2 0/2] Add Rust support to source highlighting Tom Tromey
2019-07-27 15:52 ` [PATCH v2 1/2] Add --with-static-standard-libraries to the top level Tom Tromey
2019-07-27 15:52 ` [PATCH v2 2/2] Add Rust support to source highlighting Tom Tromey
2019-09-04 17:22 ` Tom de Vries
2019-09-10 15:56 ` Tom Tromey
2019-09-12 19:20 ` Tom de Vries
2019-09-17 18:24 ` Tom Tromey
2019-09-18 22:16 ` Tom de Vries
2019-09-19 12:54 ` Tom Tromey
2019-09-19 16:18 ` Tom de Vries [this message]
2019-08-19 16:19 ` [PATCH v2 0/2] " Tom Tromey
2019-08-19 18:29 ` Pedro Alves
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=2e0b9a76-a897-167e-6d4b-46174bfc6da7@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).