diff options
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index 17498e0..a1bf9e4 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -80,6 +80,7 @@ #include "gdbsupport/buildargv.h" #include "pager.h" #include "run-on-main-thread.h" +#include "gdbsupport/gdb_tilde_expand.h" void (*deprecated_error_begin_hook) (void); @@ -192,7 +193,7 @@ verror (const char *string, va_list args) /* Emit a message and abort. */ -static void ATTRIBUTE_NORETURN +[[noreturn]] static void abort_with_message (const char *msg) { if (current_ui == NULL) @@ -818,7 +819,9 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args) } /* Format the question outside of the loop, to avoid reusing args. */ - std::string question = string_vprintf (ctlstr, args); + string_file tem (gdb_stdout->can_emit_style_escape ()); + gdb_vprintf (&tem, ctlstr, args); + std::string question = tem.release (); std::string prompt = string_printf (_("%s%s(%s or %s) %s"), annotation_level > 1 ? "\n\032\032pre-query\n" : "", @@ -1281,6 +1284,14 @@ set_screen_width_and_height (int width, int height) set_width (); } +/* Import termcap variable UP (instead of readline private variable + _rl_term_up, which we're trying to avoid, see PR build/10723). The UP + variable doesn't seem be part of the regular termcap interface, but rather + curses-specific. But if it's missing in the termcap library, then readline + provides a fallback version. Let's assume the fallback is not part of the + private readline interface. */ +extern "C" char *UP; + /* Implement "maint info screen". */ static void @@ -1339,6 +1350,46 @@ maintenance_info_screen (const char *args, int from_tty) _("Number of lines environment thinks " "are in a page is %s (LINES).\n"), getenv ("LINES")); + + bool have_up = UP != nullptr && *UP != '\0'; + + /* Fetch value of readline variable horizontal-scroll-mode. */ + const char *horizontal_scroll_mode_value + = rl_variable_value ("horizontal-scroll-mode"); + bool force_horizontal_scroll_mode + = (horizontal_scroll_mode_value != nullptr + && strcmp (horizontal_scroll_mode_value, "on") == 0); + + const char *mode = nullptr; + const char *reason = nullptr; + if (batch_flag) + { + mode = "unsupported"; + reason = "gdb batch mode"; + } + else if (!have_up) + { + mode = "unsupported"; + reason = "terminal is not Cursor Up capable"; + } + else if (force_horizontal_scroll_mode) + { + mode = "disabled"; + reason = "horizontal-scroll-mode"; + } + else if (readline_hidden_cols) + { + mode = "readline"; + reason = "terminal is not auto wrap capable, last column reserved"; + } + else + { + mode = "terminal"; + reason = "terminal is auto wrap capable"; + } + + gdb_printf (gdb_stdout, _("Readline wrapping mode: %s (%s).\n"), mode, + reason); } void @@ -3667,6 +3718,23 @@ copy_bitwise (gdb_byte *dest, ULONGEST dest_offset, } } +/* See utils.h. */ + +std::string +extract_single_filename_arg (const char *args) +{ + if (args == nullptr) + return {}; + + std::string filename = extract_string_maybe_quoted (&args); + args = skip_spaces (args); + if (*args != '\0') + error (_("Junk after filename \"%s\": %s"), filename.c_str (), args); + if (!filename.empty ()) + filename = gdb_tilde_expand (filename.c_str ()); + return filename; +} + #if GDB_SELF_TEST static void test_assign_set_return_if_changed () |