+2019-06-25 Tom Tromey <tom@tromey.com>
+
+ * tui/tui-winsource.c (tui_update_source_window)
+ (tui_refill_source_window)
+ (tui_source_window_base::do_scroll_horizontal)
+ (tui_update_breakpoint_info, tui_set_exec_info_content)
+ (tui_show_exec_info_content, tui_erase_exec_info_content)
+ (tui_clear_exec_info_content): Update.
+ * tui/tui-wingeneral.c (make_all_visible, tui_refresh_all):
+ Update.
+ * tui/tui-win.c (make_invisible_and_set_new_height)
+ (make_visible_with_new_height): Update.
+ * tui/tui-source.c (tui_set_source_content)
+ (tui_show_symtab_source): Update.
+ * tui/tui-layout.c (extract_display_start_addr)
+ (show_source_disasm_command, show_data)
+ (make_source_or_disasm_window)
+ (show_source_or_disasm_and_command): Update.
+ * tui/tui-disasm.c (tui_set_disassem_content): Simplify.
+ (tui_disasm_window::do_scroll_vertical): Remove shadowing
+ "gdbarch".
+ * tui/tui-data.h (struct tui_source_info): Remove. Move contents
+ to tui_source_window_base.
+ (struct tui_win_info) <detail>: Remove source_info member.
+ (struct tui_source_window_base) <has_locator>: Inline.
+ Move contents from tui_source_info; rename has_locator member to
+ m_has_locator.
+ (TUI_SRC_WIN, TUI_DISASM_WIN): Add casts.
+ * tui/tui-data.c (tui_source_window_base::has_locator): Move to
+ header file.
+ (tui_source_window_base::clear_detail, ~tui_source_window_base):
+ Simplify.
+ (tui_free_all_source_wins_content): Cast to
+ tui_source_window_base.
+
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (make_invisible_and_set_new_height)
return (win_type > MAX_MAJOR_WINDOWS);
}
-/* See tui-data.h. */
-
-bool
-tui_source_window_base::has_locator () const
-{
- return detail.source_info.has_locator;
-}
-
void
tui_set_win_highlight (struct tui_win_info *win_info,
int highlight)
void
tui_source_window_base::clear_detail ()
{
- detail.source_info.gdbarch = NULL;
- detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
- detail.source_info.start_line_or_addr.u.addr = 0;
- detail.source_info.horizontal_offset = 0;
+ gdbarch = NULL;
+ start_line_or_addr.loa = LOA_ADDRESS;
+ start_line_or_addr.u.addr = 0;
+ horizontal_offset = 0;
}
/* See tui-data.h. */
: tui_win_info (type)
{
gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
- detail.source_info.execution_info = NULL;
- detail.source_info.has_locator = false;
- detail.source_info.horizontal_offset = 0;
- detail.source_info.gdbarch = NULL;
- detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
- detail.source_info.start_line_or_addr.u.addr = 0;
- detail.source_info.fullname = NULL;
+ start_line_or_addr.loa = LOA_ADDRESS;
+ start_line_or_addr.u.addr = 0;
}
tui_data_window::tui_data_window ()
tui_source_window_base::~tui_source_window_base ()
{
- if (detail.source_info.fullname)
- {
- xfree (detail.source_info.fullname);
- detail.source_info.fullname = NULL;
- }
- struct tui_gen_win_info *generic_win = detail.source_info.execution_info;
+ xfree (fullname);
+ struct tui_gen_win_info *generic_win = execution_info;
if (generic_win != NULL)
{
tui_delete_win (generic_win->handle);
for (tui_win_info *win_info : tui_source_windows ())
{
tui_free_win_content (&(win_info->generic));
- tui_free_win_content (win_info->detail.source_info.execution_info);
+ tui_source_window_base *base = (tui_source_window_base *) win_info;
+ tui_free_win_content (base->execution_info);
}
}
};
-struct tui_source_info
-{
- /* Does the locator belong to this window? */
- bool has_locator;
- /* Execution information window. */
- struct tui_gen_win_info *execution_info;
- int horizontal_offset; /* Used for horizontal scroll. */
- struct tui_line_or_address start_line_or_addr;
-
- /* It is the resolved form as returned by symtab_to_fullname. */
- char *fullname;
-
- /* Architecture associated with code at this location. */
- struct gdbarch *gdbarch;
-};
-
-
struct tui_command_info
{
int start_line;
struct tui_gen_win_info generic; /* General window information. */
union
{
- struct tui_source_info source_info;
struct tui_data_info data_display_info;
struct tui_command_info command_info;
}
void clear_detail () override;
/* Return true if this window has the locator. */
- bool has_locator () const override;
+ bool has_locator () const override
+ {
+ return m_has_locator;
+ }
+
+ /* Does the locator belong to this window? */
+ bool m_has_locator = false;
+ /* Execution information window. */
+ struct tui_gen_win_info *execution_info = nullptr;
+ /* Used for horizontal scroll. */
+ int horizontal_offset = 0;
+ struct tui_line_or_address start_line_or_addr;
+
+ /* It is the resolved form as returned by symtab_to_fullname. */
+ char *fullname = nullptr;
+
+ /* Architecture associated with code at this location. */
+ struct gdbarch *gdbarch = nullptr;
};
/* A TUI source window. */
/* Global Data. */
extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
-#define TUI_SRC_WIN tui_win_list[SRC_WIN]
-#define TUI_DISASM_WIN tui_win_list[DISASSEM_WIN]
+#define TUI_SRC_WIN ((tui_source_window_base *) tui_win_list[SRC_WIN])
+#define TUI_DISASM_WIN ((tui_source_window_base *) tui_win_list[DISASSEM_WIN])
#define TUI_DATA_WIN tui_win_list[DATA_WIN]
#define TUI_CMD_WIN tui_win_list[CMD_WIN]
{
enum tui_status ret = TUI_FAILURE;
int i;
- int offset = TUI_DISASM_WIN->detail.source_info.horizontal_offset;
+ int offset = TUI_DISASM_WIN->horizontal_offset;
int max_lines, line_width;
CORE_ADDR cur_pc;
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
if (ret != TUI_SUCCESS)
return ret;
- TUI_DISASM_WIN->detail.source_info.gdbarch = gdbarch;
- TUI_DISASM_WIN->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
- TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr = pc;
+ tui_source_window_base *base = TUI_DISASM_WIN;
+ base->gdbarch = gdbarch;
+ base->start_line_or_addr.loa = LOA_ADDRESS;
+ base->start_line_or_addr.u.addr = pc;
cur_pc = locator->content[0]->which_element.locator.addr;
/* Window size, excluding highlight box. */
{
if (generic.content != NULL)
{
- struct gdbarch *gdbarch = detail.source_info.gdbarch;
CORE_ADDR pc;
tui_win_content content;
struct tui_line_or_address val;
{
case SRC_COMMAND:
case SRC_DATA_COMMAND:
- gdbarch = TUI_SRC_WIN->detail.source_info.gdbarch;
+ gdbarch = TUI_SRC_WIN->gdbarch;
find_line_pc (cursal.symtab,
- TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
+ TUI_SRC_WIN->start_line_or_addr.u.line_no,
&pc);
addr = pc;
break;
case DISASSEM_COMMAND:
case SRC_DISASSEM_COMMAND:
case DISASSEM_DATA_COMMAND:
- gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
- addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
+ gdbarch = TUI_DISASM_WIN->gdbarch;
+ addr = TUI_DISASM_WIN->start_line_or_addr.u.addr;
break;
default:
addr = 0;
asm_height = tui_term_height () - (src_height + cmd_height);
if (TUI_SRC_WIN == NULL)
- TUI_SRC_WIN = make_source_window (src_height, 0);
+ tui_win_list[SRC_WIN] = make_source_window (src_height, 0);
else
{
init_gen_win_info (&TUI_SRC_WIN->generic,
TUI_SRC_WIN->generic.type,
src_height,
TUI_SRC_WIN->generic.width,
- TUI_SRC_WIN->detail.source_info.execution_info->width,
+ TUI_SRC_WIN->execution_info->width,
0);
TUI_SRC_WIN->can_highlight = TRUE;
- init_gen_win_info (TUI_SRC_WIN->detail.source_info.execution_info,
+ init_gen_win_info (TUI_SRC_WIN->execution_info,
EXEC_INFO_WIN,
src_height,
3,
0,
0);
tui_make_visible (&TUI_SRC_WIN->generic);
- tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
- TUI_SRC_WIN->detail.source_info.has_locator = false;
+ tui_make_visible (TUI_SRC_WIN->execution_info);
+ TUI_SRC_WIN->m_has_locator = false;
}
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
tui_show_source_content (TUI_SRC_WIN);
if (TUI_DISASM_WIN == NULL)
{
- TUI_DISASM_WIN = make_disasm_window (asm_height, src_height - 1);
+ tui_win_list[DISASSEM_WIN]
+ = make_disasm_window (asm_height, src_height - 1);
locator
= ((struct tui_gen_win_info *)
init_and_make_win (locator,
tui_term_width (),
0,
(src_height + asm_height) - 1);
- TUI_DISASM_WIN->detail.source_info.has_locator = true;
+ TUI_DISASM_WIN->m_has_locator = true;
init_gen_win_info (&TUI_DISASM_WIN->generic,
TUI_DISASM_WIN->generic.type,
asm_height,
TUI_DISASM_WIN->generic.width,
- TUI_DISASM_WIN->detail.source_info.execution_info->width,
+ TUI_DISASM_WIN->execution_info->width,
src_height - 1);
- init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info,
+ init_gen_win_info (TUI_DISASM_WIN->execution_info,
EXEC_INFO_WIN,
asm_height,
3,
src_height - 1);
TUI_DISASM_WIN->can_highlight = TRUE;
tui_make_visible (&TUI_DISASM_WIN->generic);
- tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
+ tui_make_visible (TUI_DISASM_WIN->execution_info);
}
- TUI_SRC_WIN->detail.source_info.has_locator = false;
- TUI_DISASM_WIN->detail.source_info.has_locator = true;
+ TUI_SRC_WIN->m_has_locator = false;
+ TUI_DISASM_WIN->m_has_locator = true;
tui_make_visible (locator);
tui_show_locator_content ();
tui_show_source_content (TUI_DISASM_WIN);
win_type = SRC_WIN;
else
win_type = DISASSEM_WIN;
+
+ tui_source_window_base *base;
if (tui_win_list[win_type] == NULL)
{
if (win_type == SRC_WIN)
0,
total_height - 1,
DONT_BOX_WINDOW));
+ base = (tui_source_window_base *) tui_win_list[win_type];
}
else
{
+ base = (tui_source_window_base *) tui_win_list[win_type];
init_gen_win_info (&tui_win_list[win_type]->generic,
tui_win_list[win_type]->generic.type,
src_height,
tui_win_list[win_type]->generic.width,
- tui_win_list[win_type]->detail.source_info.execution_info->width,
+ base->execution_info->width,
data_height - 1);
- init_gen_win_info (tui_win_list[win_type]->detail.source_info.execution_info,
+ init_gen_win_info (base->execution_info,
EXEC_INFO_WIN,
src_height,
3,
0,
data_height - 1);
tui_make_visible (&tui_win_list[win_type]->generic);
- tui_make_visible (tui_win_list[win_type]->detail.source_info.execution_info);
+ tui_make_visible (base->execution_info);
init_gen_win_info (locator,
LOCATOR_WIN,
2 /* 1 */ ,
0,
total_height - 1);
}
- tui_win_list[win_type]->detail.source_info.has_locator = true;
+ base->m_has_locator = true;
tui_make_visible (locator);
tui_show_locator_content ();
tui_add_to_source_windows (tui_win_list[win_type]);
DONT_BOX_WINDOW));
/* Now create the source window. */
- struct tui_win_info *result
- = ((struct tui_win_info *)
+ struct tui_source_window_base *result
+ = ((struct tui_source_window_base *)
init_and_make_win (NULL,
type,
height,
execution_info->width,
origin_y,
BOX_WINDOW));
- result->detail.source_info.execution_info = execution_info;
+ result->execution_info = execution_info;
return result;
}
src_height = tui_term_height () - cmd_height;
if (layout_type == SRC_COMMAND)
- win_info_ptr = &TUI_SRC_WIN;
+ win_info_ptr = &tui_win_list[SRC_WIN];
else
- win_info_ptr = &TUI_DISASM_WIN;
+ win_info_ptr = &tui_win_list[DISASSEM_WIN];
+ tui_source_window_base *base;
if ((*win_info_ptr) == NULL)
{
if (layout_type == SRC_COMMAND)
0,
src_height - 1,
DONT_BOX_WINDOW));
+ base = (tui_source_window_base *) *win_info_ptr;
}
else
{
+ base = (tui_source_window_base *) *win_info_ptr;
init_gen_win_info (locator,
LOCATOR_WIN,
2 /* 1 */ ,
tui_term_width (),
0,
src_height - 1);
- (*win_info_ptr)->detail.source_info.has_locator = true;
+ base->m_has_locator = true;
init_gen_win_info (&(*win_info_ptr)->generic,
(*win_info_ptr)->generic.type,
src_height - 1,
(*win_info_ptr)->generic.width,
- (*win_info_ptr)->detail.source_info.execution_info->width,
+ base->execution_info->width,
0);
- init_gen_win_info ((*win_info_ptr)->detail.source_info.execution_info,
+ init_gen_win_info (base->execution_info,
EXEC_INFO_WIN,
src_height - 1,
3,
0,
0);
- (*win_info_ptr)->can_highlight = TRUE;
+ base->can_highlight = TRUE;
tui_make_visible (&(*win_info_ptr)->generic);
- tui_make_visible ((*win_info_ptr)->detail.source_info.execution_info);
+ tui_make_visible (base->execution_info);
}
if ((*win_info_ptr) != NULL)
{
- (*win_info_ptr)->detail.source_info.has_locator = true;
+ base->m_has_locator = true;
tui_make_visible (locator);
tui_show_locator_content ();
tui_show_source_content (*win_info_ptr);
int cur_line_no, cur_line;
struct tui_gen_win_info *locator
= tui_locator_win_info_ptr ();
- struct tui_source_info *src
- = &TUI_SRC_WIN->detail.source_info;
+ struct tui_source_window_base *src
+ = (struct tui_source_window_base *) TUI_SRC_WIN;
const char *s_filename = symtab_to_filename_for_display (s);
if (TUI_SRC_WIN->generic.title)
struct tui_line_or_address line,
int noerror)
{
- TUI_SRC_WIN->detail.source_info.horizontal_offset = 0;
+ TUI_SRC_WIN->horizontal_offset = 0;
tui_update_source_window_as_is (TUI_SRC_WIN, gdbarch, s, line, noerror);
}
win_info->generic.viewport_height--;
/* Now deal with the auxillary windows associated with win_info. */
+ tui_source_window_base *base;
switch (win_info->generic.type)
{
case SRC_WIN:
case DISASSEM_WIN:
- gen_win_info = win_info->detail.source_info.execution_info;
+ base = (tui_source_window_base *) win_info;
+ gen_win_info = base->execution_info;
tui_make_invisible (gen_win_info);
gen_win_info->height = height;
gen_win_info->origin.y = win_info->generic.origin.y;
tui_make_visible (&win_info->generic);
tui_check_and_display_highlight_if_needed (win_info);
+ tui_source_window_base *base;
switch (win_info->generic.type)
{
case SRC_WIN:
case DISASSEM_WIN:
- tui_free_win_content (win_info->detail.source_info.execution_info);
- tui_make_visible (win_info->detail.source_info.execution_info);
+ base = (tui_source_window_base *) win_info;
+ tui_free_win_content (base->execution_info);
+ tui_make_visible (base->execution_info);
if (win_info->generic.content != NULL)
{
- struct gdbarch *gdbarch = win_info->detail.source_info.gdbarch;
+ struct gdbarch *gdbarch = base->gdbarch;
struct tui_line_or_address line_or_addr;
struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
- line_or_addr = win_info->detail.source_info.start_line_or_addr;
+ line_or_addr = base->start_line_or_addr;
tui_free_win_content (&win_info->generic);
tui_update_source_window (win_info, gdbarch,
cursal.symtab, line_or_addr, TRUE);
&& ((tui_win_list[i])->generic.type) != CMD_WIN)
{
if (tui_win_is_source_type ((tui_win_list[i])->generic.type))
- make_visible ((tui_win_list[i])->detail.source_info.execution_info,
- visible);
+ {
+ tui_source_window_base *base
+ = (tui_source_window_base *) tui_win_list[i];
+ make_visible (base->execution_info, visible);
+ }
make_visible (&tui_win_list[i]->generic, visible);
}
}
{
if (type == SRC_WIN || type == DISASSEM_WIN)
{
- touchwin (list[type]->detail.source_info.execution_info->handle);
- tui_refresh_win (list[type]->detail.source_info.execution_info);
+ tui_source_window_base *base
+ = (tui_source_window_base *) list[type];
+ touchwin (base->execution_info->handle);
+ tui_refresh_win (base->execution_info);
}
touchwin (list[type]->generic.handle);
tui_refresh_win (&list[type]->generic);
struct tui_line_or_address line_or_addr,
int noerror)
{
- win_info->detail.source_info.horizontal_offset = 0;
+ tui_source_window_base *base = (tui_source_window_base *) win_info;
+ base->horizontal_offset = 0;
tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr, noerror);
return;
: cursal.symtab);
}
+ tui_source_window_base *base = (tui_source_window_base *) win_info;
tui_update_source_window_as_is (win_info,
- win_info->detail.source_info.gdbarch,
+ base->gdbarch,
s,
win_info->generic.content[0]
->which_element.source.line_or_addr,
int offset;
if (direction == LEFT_SCROLL)
- offset = detail.source_info.horizontal_offset
- + num_to_scroll;
+ offset = horizontal_offset + num_to_scroll;
else
{
- offset = detail.source_info.horizontal_offset
- - num_to_scroll;
+ offset = horizontal_offset - num_to_scroll;
if (offset < 0)
offset = 0;
}
- detail.source_info.horizontal_offset = offset;
+ horizontal_offset = offset;
tui_refill_source_window (this);
}
}
{
int i;
int need_refresh = 0;
- struct tui_source_info *src = &win->detail.source_info;
+ tui_source_window_base *src = (tui_source_window_base *) win;
for (i = 0; i < win->generic.content_size; i++)
{
{
enum tui_status ret = TUI_SUCCESS;
- if (win_info->detail.source_info.execution_info != NULL)
+ tui_source_window_base *base = (tui_source_window_base *) win_info;
+ if (base->execution_info != NULL)
{
- struct tui_gen_win_info *exec_info_ptr
- = win_info->detail.source_info.execution_info;
+ struct tui_gen_win_info *exec_info_ptr = base->execution_info;
if (exec_info_ptr->content == NULL)
exec_info_ptr->content =
void
tui_show_exec_info_content (struct tui_win_info *win_info)
{
- struct tui_gen_win_info *exec_info
- = win_info->detail.source_info.execution_info;
+ tui_source_window_base *base = (tui_source_window_base *) win_info;
+ struct tui_gen_win_info *exec_info = base->execution_info;
int cur_line;
werase (exec_info->handle);
void
tui_erase_exec_info_content (struct tui_win_info *win_info)
{
- struct tui_gen_win_info *exec_info
- = win_info->detail.source_info.execution_info;
+ tui_source_window_base *base = (tui_source_window_base *) win_info;
+ struct tui_gen_win_info *exec_info = base->execution_info;
werase (exec_info->handle);
tui_refresh_win (exec_info);
void
tui_clear_exec_info_content (struct tui_win_info *win_info)
{
- win_info->detail.source_info.execution_info->content_in_use = FALSE;
+ tui_source_window_base *base = (tui_source_window_base *) win_info;
+ base->execution_info->content_in_use = FALSE;
tui_erase_exec_info_content (win_info);
return;