public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb] Catch exception when constructing the highlighter
@ 2019-09-19 17:49 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2019-09-19 17:49 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f64e2f4045485f99b4ce6649fdab874dacccd5a6

commit f64e2f4045485f99b4ce6649fdab874dacccd5a6
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Sep 19 19:49:39 2019 +0200

    [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.

Diff:
---
 gdb/ChangeLog      |  6 ++++++
 gdb/source-cache.c | 12 ++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7057e37..39f917b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
 2019-09-18  Alan Modra  <amodra@gmail.com>
 
 	* aarch64-linux-tdep.c, * arm-tdep.c, * auto-load.c,
diff --git a/gdb/source-cache.c b/gdb/source-cache.c
index 7a52ce9..1fe6da8 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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-19 17:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-19 17:49 [binutils-gdb] [gdb] Catch exception when constructing the highlighter Tom de Vries

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).