diff options
-rw-r--r-- | gdb/ChangeLog | 8 | ||||
-rwxr-xr-x | gdb/configure | 6 | ||||
-rw-r--r-- | gdb/configure.ac | 8 | ||||
-rw-r--r-- | gdb/source-cache.c | 24 |
4 files changed, 39 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c43ee64..c654872 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2019-08-19 Tom Tromey <tom@tromey.com> + + * configure: Rebuild. + * configure.ac: Disallow the combination of -static-libstdc++ and + source highlight. + * source-cache.c (get_language_name): Handle rust. + (source_cache::get_source_lines): Ignore highlighting exceptions. + 2019-08-16 Tom Tromey <tom@tromey.com> * tui/tui.h (enum tui_win_type) <EXEC_INFO_WIN>: Remove. diff --git a/gdb/configure b/gdb/configure index 2832c83..cb71bbf 100755 --- a/gdb/configure +++ b/gdb/configure @@ -11326,6 +11326,12 @@ $as_echo "no - pkg-config not found" >&6; } as_fn_error $? "pkg-config was not found in your system" "$LINENO" 5 fi else + case "$LDFLAGS" in + *static-libstdc*) + as_fn_error $? "source highlight is incompatible with -static-libstdc++; either use --disable-source-highlight or --without-static-standard-libraries" "$LINENO" 5 + ;; + esac + if ${pkg_config_prog_path} --exists source-highlight; then SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight` SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight` diff --git a/gdb/configure.ac b/gdb/configure.ac index 0979109..5a18c16 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1231,6 +1231,14 @@ if test "${enable_source_highlight}" != "no"; then AC_MSG_ERROR([pkg-config was not found in your system]) fi else + case "$LDFLAGS" in + *static-libstdc*) + AC_MSG_ERROR([source highlight is incompatible with -static-libstdc++; dnl +either use --disable-source-highlight or dnl +--without-static-standard-libraries]) + ;; + esac + if ${pkg_config_prog_path} --exists source-highlight; then SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight` SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight` diff --git a/gdb/source-cache.c b/gdb/source-cache.c index 9039f8f..18e2be9 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -135,8 +135,7 @@ get_language_name (enum language lang) break; case language_rust: - /* Not handled by Source Highlight. */ - break; + return "rust.lang"; case language_ada: return "ada.lang"; @@ -197,11 +196,22 @@ source_cache::ensure (struct symtab *s) highlighter->setStyleFile ("esc.style"); } - std::istringstream input (contents); - std::ostringstream output; - highlighter->highlight (input, output, lang_name, fullname); - - contents = output.str (); + try + { + std::istringstream input (contents); + std::ostringstream output; + highlighter->highlight (input, output, lang_name, fullname); + contents = output.str (); + } + catch (...) + { + /* Source Highlight will throw an exception if + highlighting fails. One possible reason it can fail + is if the language is unknown -- which matters to gdb + because Rust support wasn't added until after 3.1.8. + Ignore exceptions here and fall back to + un-highlighted text. */ + } } } #endif /* HAVE_SOURCE_HIGHLIGHT */ |