[gdb] Catch exception when constructing the highlighter
authorTom de Vries <tdevries@suse.de>
Thu, 19 Sep 2019 17:49:39 +0000 (19:49 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 19 Sep 2019 17:49:39 +0000 (19:49 +0200)
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/ChangeLog
gdb/source-cache.c

index 7057e37e8da8e7dae9f744d0a7ffba5388a24017..39f917b1867ce73e443e3c0c11d806907e2a8fc8 100644 (file)
@@ -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,
index 7a52ce9458e538153412e89d576a2af4b43afa41..1fe6da81326a5773642acaba2ef250d6f4c0fc2d 100644 (file)
@@ -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);
This page took 0.033605 seconds and 4 git commands to generate.