From 0a909fdd47b94e2d2fd9c0387fb644a98cb35d3b Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 12 Dec 2023 19:22:07 -0700 Subject: Remove tui-out.[ch] The other day on irc, we were discussing the "m_line" hack in tui-out.c, and I mentioned that it would be nice to replace this with a new ui_out_flag. Later, I looked at ui_out_flag and found: ui_source_list = (1 << 0), ... and sure enough, this is tested already. This patch removes tui-out.[ch] and changes the TUI to use an ordinary cli-out object without this flag set. As far as I can tell, this doesn't affect behavior at all -- the TUI tests all pass, and interactively I tried switching stack frames, "list", etc, and it all seems to work. New in v2: fixed the problem pointed out by Keith, and added a test case for that scenario. Reviewed-By: Andrew Burgess --- gdb/source.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'gdb/source.c') diff --git a/gdb/source.c b/gdb/source.c index 2c465a1..bbeb415 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1341,30 +1341,21 @@ print_source_lines_base (struct symtab *s, int line, int stopline, styled_string (file_name_style.style (), filename), safe_strerror (errcode)); } - else + else if (uiout->is_mi_like_p () || uiout->test_flags (ui_source_list)) { + /* CLI expects only the "file" field. MI expects both + fields. ui_source_list is set only for CLI, not for + TUI. */ + uiout->field_signed ("line", line); uiout->text ("\tin "); - /* CLI expects only the "file" field. TUI expects only the - "fullname" field (and TUI does break if "file" is printed). - MI expects both fields. ui_source_list is set only for CLI, - not for TUI. */ - if (uiout->is_mi_like_p () || uiout->test_flags (ui_source_list)) - uiout->field_string ("file", symtab_to_filename_for_display (s), - file_name_style.style ()); - if (uiout->is_mi_like_p () || !uiout->test_flags (ui_source_list)) + uiout->field_string ("file", symtab_to_filename_for_display (s), + file_name_style.style ()); + if (uiout->is_mi_like_p ()) { const char *s_fullname = symtab_to_fullname (s); - char *local_fullname; - - /* ui_out_field_string may free S_FULLNAME by calling - open_source_file for it again. See e.g., - tui_field_string->tui_show_source. */ - local_fullname = (char *) alloca (strlen (s_fullname) + 1); - strcpy (local_fullname, s_fullname); - - uiout->field_string ("fullname", local_fullname); + uiout->field_string ("fullname", s_fullname); } uiout->text ("\n"); -- cgit v1.1