Separate out locator window

This introduces a new subclass of tui_gen_win_info for the locator,
letting us remove another element from union tui_which_element.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_refresh_all): Update.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights)
	(tui_source_window_base::set_new_height): Update.
	* tui/tui-stack.c (tui_make_status_line): Change parameter type.
	Update.
	(tui_set_locator_fullname, tui_set_locator_info)
	(tui_show_frame_info): Update.
	* tui/tui-source.c (tui_set_source_content)
	(tui_source_is_displayed): Update.
	* tui/tui-layout.c (show_source_disasm_command, show_data)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-disasm.c (tui_set_disassem_content)
	(tui_get_begin_asm_address): Update.
	* tui/tui-data.h (struct tui_locator_element): Remove.
	(union tui_which_element) <locator>: Remove.
	(struct tui_locator_window): New.
	(tui_locator_win_info_ptr): Change return type.
	* tui/tui-data.c (_locator): Change type.
	(tui_locator_win_info_ptr): Change return type.
	(init_content_element): Remove LOCATOR_WIN case.  Add assert.
	(tui_alloc_content): Add assert.
This commit is contained in:
Tom Tromey 2019-06-20 20:16:07 -06:00
parent 489e9d8b7b
commit 3add462fff
9 changed files with 107 additions and 113 deletions

View File

@ -1,3 +1,27 @@
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-wingeneral.c (tui_refresh_all): Update.
* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights)
(tui_source_window_base::set_new_height): Update.
* tui/tui-stack.c (tui_make_status_line): Change parameter type.
Update.
(tui_set_locator_fullname, tui_set_locator_info)
(tui_show_frame_info): Update.
* tui/tui-source.c (tui_set_source_content)
(tui_source_is_displayed): Update.
* tui/tui-layout.c (show_source_disasm_command, show_data)
(show_source_or_disasm_and_command): Update.
* tui/tui-disasm.c (tui_set_disassem_content)
(tui_get_begin_asm_address): Update.
* tui/tui-data.h (struct tui_locator_element): Remove.
(union tui_which_element) <locator>: Remove.
(struct tui_locator_window): New.
(tui_locator_win_info_ptr): Change return type.
* tui/tui-data.c (_locator): Change type.
(tui_locator_win_info_ptr): Change return type.
(init_content_element): Remove LOCATOR_WIN case. Add assert.
(tui_alloc_content): Add assert.
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.c

View File

@ -36,7 +36,7 @@ struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
****************************/
static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
static int term_height, term_width;
static struct tui_gen_win_info _locator (LOCATOR_WIN);
static struct tui_locator_window _locator;
static std::vector<tui_source_window_base *> source_windows;
static struct tui_win_info *win_with_focus = NULL;
static struct tui_layout_def layout_def = {
@ -185,7 +185,7 @@ tui_data_window::clear_detail ()
/* Accessor for the locator win info. Answers a pointer to the static
locator win info struct. */
struct tui_gen_win_info *
struct tui_locator_window *
tui_locator_win_info_ptr (void)
{
return &_locator;
@ -365,6 +365,7 @@ init_content_element (struct tui_win_element *element,
enum tui_win_type type)
{
gdb_assert (type != EXEC_INFO_WIN);
gdb_assert (type != LOCATOR_WIN);
switch (type)
{
@ -393,12 +394,6 @@ init_content_element (struct tui_win_element *element,
element->which_element.data.highlight = FALSE;
element->which_element.data.content = NULL;
break;
case LOCATOR_WIN:
element->which_element.locator.full_name[0] =
element->which_element.locator.proc_name[0] = (char) 0;
element->which_element.locator.line_no = 0;
element->which_element.locator.addr = 0;
break;
default:
break;
}
@ -426,6 +421,7 @@ tui_alloc_content (int num_elements, enum tui_win_type type)
int i;
gdb_assert (type != EXEC_INFO_WIN);
gdb_assert (type != LOCATOR_WIN);
content = XNEWVEC (struct tui_win_element *, num_elements);

View File

@ -214,18 +214,6 @@ struct tui_command_element
# define MAX_LOCATOR_ELEMENT_LEN 1024
#endif
/* Elements in the locator window content. */
struct tui_locator_element
{
/* Resolved absolute filename as returned by symtab_to_fullname. */
char full_name[MAX_LOCATOR_ELEMENT_LEN];
char proc_name[MAX_LOCATOR_ELEMENT_LEN];
int line_no;
CORE_ADDR addr;
/* Architecture associated with code at this location. */
struct gdbarch *gdbarch;
};
/* Flags to tell what kind of breakpoint is at current line. */
#define TUI_BP_ENABLED 0x01
#define TUI_BP_DISABLED 0x02
@ -248,7 +236,6 @@ union tui_which_element
struct tui_gen_win_info *data_window; /* Data display elements. */
struct tui_data_element data; /* Elements of data_window. */
struct tui_command_element command; /* Command elements. */
struct tui_locator_element locator; /* Locator elements. */
};
struct tui_win_element
@ -284,6 +271,25 @@ private:
tui_exec_info_content *m_content = nullptr;
};
/* Locator window class. */
struct tui_locator_window : public tui_gen_win_info
{
tui_locator_window ()
: tui_gen_win_info (LOCATOR_WIN)
{
full_name[0] = 0;
proc_name[0] = 0;
}
char full_name[MAX_LOCATOR_ELEMENT_LEN];
char proc_name[MAX_LOCATOR_ELEMENT_LEN];
int line_no = 0;
CORE_ADDR addr = 0;
/* Architecture associated with code at this location. */
struct gdbarch *gdbarch = nullptr;
};
/* This defines information about each logical window. */
struct tui_win_info : public tui_gen_win_info
{
@ -572,7 +578,7 @@ extern int tui_term_height (void);
extern void tui_set_term_height_to (int);
extern int tui_term_width (void);
extern void tui_set_term_width_to (int);
extern struct tui_gen_win_info *tui_locator_win_info_ptr (void);
extern struct tui_locator_window *tui_locator_win_info_ptr (void);
extern std::vector<tui_source_window_base *> &tui_source_windows ();
extern void tui_clear_source_windows (void);
extern void tui_clear_source_windows_detail (void);

View File

@ -169,7 +169,7 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
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 ();
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
int tab_len = tui_tab_width;
struct tui_asm_line *asm_lines;
int insn_pos;
@ -185,7 +185,7 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
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;
cur_pc = locator->addr;
/* Window size, excluding highlight box. */
max_lines = TUI_DISASM_WIN->height - 2;
@ -316,15 +316,13 @@ tui_show_disassem_and_update_source (struct gdbarch *gdbarch,
void
tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
{
struct tui_gen_win_info *locator;
struct tui_locator_element *element;
struct tui_locator_window *locator;
struct gdbarch *gdbarch = get_current_arch ();
CORE_ADDR addr;
locator = tui_locator_win_info_ptr ();
element = &locator->content[0]->which_element.locator;
if (element->addr == 0)
if (locator->addr == 0)
{
struct bound_minimal_symbol main_symbol;
@ -342,8 +340,8 @@ tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
}
else /* The target is executing. */
{
gdbarch = element->gdbarch;
addr = element->addr;
gdbarch = locator->gdbarch;
addr = locator->addr;
}
*gdbarch_p = gdbarch;

View File

@ -634,21 +634,21 @@ show_source_disasm_command (void)
TUI_SRC_WIN->m_has_locator = false;
}
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
gdb_assert (locator != nullptr);
tui_show_source_content (TUI_SRC_WIN);
if (TUI_DISASM_WIN == NULL)
{
tui_win_list[DISASSEM_WIN]
= make_disasm_window (asm_height, src_height - 1);
locator
= init_and_make_win (locator,
LOCATOR_WIN,
2 /* 1 */ ,
tui_term_width (),
0,
(src_height + asm_height) - 1,
DONT_BOX_WINDOW);
init_and_make_win (locator,
LOCATOR_WIN,
2 /* 1 */ ,
tui_term_width (),
0,
(src_height + asm_height) - 1,
DONT_BOX_WINDOW);
}
else
{
@ -703,8 +703,9 @@ show_data (enum tui_layout_type new_layout)
int total_height = (tui_term_height () - TUI_CMD_WIN->height);
int src_height, data_height;
enum tui_win_type win_type;
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
gdb_assert (locator != nullptr);
data_height = total_height / 2;
src_height = total_height - data_height;
@ -725,8 +726,7 @@ show_data (enum tui_layout_type new_layout)
else
tui_win_list[win_type]
= make_disasm_window (src_height, data_height - 1);
locator
= init_and_make_win (locator,
init_and_make_win (locator,
LOCATOR_WIN,
2 /* 1 */ ,
tui_term_width (),
@ -870,7 +870,8 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
{
struct tui_win_info **win_info_ptr;
int src_height, cmd_height;
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
gdb_assert (locator != nullptr);
if (TUI_CMD_WIN != NULL)
cmd_height = TUI_CMD_WIN->height;
@ -890,14 +891,13 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
*win_info_ptr = make_source_window (src_height - 1, 0);
else
*win_info_ptr = make_disasm_window (src_height - 1, 0);
locator
= init_and_make_win (locator,
LOCATOR_WIN,
2 /* 1 */ ,
tui_term_width (),
0,
src_height - 1,
DONT_BOX_WINDOW);
init_and_make_win (locator,
LOCATOR_WIN,
2 /* 1 */ ,
tui_term_width (),
0,
src_height - 1,
DONT_BOX_WINDOW);
base = (tui_source_window_base *) *win_info_ptr;
}
else

View File

@ -157,7 +157,7 @@ tui_set_source_content (struct symtab *s,
else
{
int cur_line_no, cur_line;
struct tui_gen_win_info *locator
struct tui_locator_window *locator
= tui_locator_win_info_ptr ();
struct tui_source_window_base *src
= (struct tui_source_window_base *) TUI_SRC_WIN;
@ -194,12 +194,9 @@ tui_set_source_content (struct symtab *s,
element->which_element.source.line_or_addr.u.line_no =
cur_line_no;
element->which_element.source.is_exec_point =
(filename_cmp (locator->content[0]
->which_element.locator.full_name,
(filename_cmp (locator->full_name,
symtab_to_fullname (s)) == 0
&& cur_line_no
== locator->content[0]
->which_element.locator.line_no);
&& cur_line_no == locator->line_no);
xfree (TUI_SRC_WIN->content[cur_line]
->which_element.source.line);
@ -300,8 +297,7 @@ tui_source_is_displayed (const char *fullname)
{
return (TUI_SRC_WIN != NULL
&& TUI_SRC_WIN->content_in_use
&& (filename_cmp (tui_locator_win_info_ptr ()->content[0]
->which_element.locator.full_name,
&& (filename_cmp (tui_locator_win_info_ptr ()->full_name,
fullname) == 0));
}

View File

@ -59,8 +59,8 @@ static void tui_update_command (const char *, int);
/* Create the status line to display as much information as we can on
this single line: target name, process number, current function,
current line, current PC, SingleKey mode. */
static char*
tui_make_status_line (struct tui_locator_element *loc)
static char *
tui_make_status_line (struct tui_locator_window *loc)
{
char *string;
char line_buf[50], *pname;
@ -246,17 +246,13 @@ void
tui_show_locator_content (void)
{
char *string;
struct tui_gen_win_info *locator;
struct tui_locator_window *locator;
locator = tui_locator_win_info_ptr ();
if (locator != NULL && locator->handle != NULL)
{
struct tui_win_element *element;
element = locator->content[0];
string = tui_make_status_line (&element->which_element.locator);
string = tui_make_status_line (locator);
wmove (locator->handle, 0, 0);
/* We ignore the return value from wstandout and wstandend, casting
them to void in order to avoid a compiler warning. The warning
@ -279,18 +275,10 @@ tui_show_locator_content (void)
static void
tui_set_locator_fullname (const char *fullname)
{
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
struct tui_locator_element *element;
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
if (locator->content[0] == NULL)
{
tui_set_locator_info (NULL, fullname, NULL, 0, 0);
return;
}
element = &locator->content[0]->which_element.locator;
element->full_name[0] = 0;
strcat_to_buf (element->full_name, MAX_LOCATOR_ELEMENT_LEN, fullname);
locator->full_name[0] = 0;
strcat_to_buf (locator->full_name, MAX_LOCATOR_ELEMENT_LEN, fullname);
}
/* Update the locator, with the provided arguments.
@ -305,39 +293,28 @@ tui_set_locator_info (struct gdbarch *gdbarch,
int lineno,
CORE_ADDR addr)
{
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
struct tui_locator_element *element;
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
int locator_changed_p = 0;
/* Allocate the locator content if necessary. */
if (locator->content_size <= 0)
{
locator->content = tui_alloc_content (1, LOCATOR_WIN);
locator->content_size = 1;
locator_changed_p = 1;
}
if (procname == NULL)
procname = "";
if (fullname == NULL)
fullname = "";
element = &locator->content[0]->which_element.locator;
locator_changed_p |= strncmp (element->proc_name, procname,
locator_changed_p |= strncmp (locator->proc_name, procname,
MAX_LOCATOR_ELEMENT_LEN) != 0;
locator_changed_p |= lineno != element->line_no;
locator_changed_p |= addr != element->addr;
locator_changed_p |= gdbarch != element->gdbarch;
locator_changed_p |= strncmp (element->full_name, fullname,
locator_changed_p |= lineno != locator->line_no;
locator_changed_p |= addr != locator->addr;
locator_changed_p |= gdbarch != locator->gdbarch;
locator_changed_p |= strncmp (locator->full_name, fullname,
MAX_LOCATOR_ELEMENT_LEN) != 0;
element->proc_name[0] = (char) 0;
strcat_to_buf (element->proc_name, MAX_LOCATOR_ELEMENT_LEN, procname);
element->line_no = lineno;
element->addr = addr;
element->gdbarch = gdbarch;
locator->proc_name[0] = (char) 0;
strcat_to_buf (locator->proc_name, MAX_LOCATOR_ELEMENT_LEN, procname);
locator->line_no = lineno;
locator->addr = addr;
locator->gdbarch = gdbarch;
tui_set_locator_fullname (fullname);
return locator_changed_p;
@ -366,7 +343,7 @@ tui_show_frame_info (struct frame_info *fi)
{
int start_line;
CORE_ADDR low;
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
int source_already_displayed;
CORE_ADDR pc;
@ -398,12 +375,9 @@ tui_show_frame_info (struct frame_info *fi)
start_line = 0;
for (struct tui_source_window_base *win_info : tui_source_windows ())
{
union tui_which_element *item;
item = &locator->content[0]->which_element;
if (win_info == TUI_SRC_WIN)
{
start_line = (item->locator.line_no -
start_line = (locator->line_no -
(win_info->viewport_height / 2)) + 1;
if (start_line <= 0)
start_line = 1;
@ -429,13 +403,13 @@ tui_show_frame_info (struct frame_info *fi)
l.loa = LOA_LINE;
l.u.line_no = start_line;
if (!(source_already_displayed
&& tui_line_is_displayed (item->locator.line_no,
&& tui_line_is_displayed (locator->line_no,
win_info, TRUE)))
tui_update_source_window (win_info, get_frame_arch (fi),
sal.symtab, l, TRUE);
else
{
l.u.line_no = item->locator.line_no;
l.u.line_no = locator->line_no;
win_info->set_is_exec_point_at (l);
}
}
@ -447,13 +421,13 @@ tui_show_frame_info (struct frame_info *fi)
a.loa = LOA_ADDRESS;
a.u.addr = low;
if (!tui_addr_is_displayed (item->locator.addr,
if (!tui_addr_is_displayed (locator->addr,
win_info, TRUE))
tui_update_source_window (win_info, get_frame_arch (fi),
sal.symtab, a, TRUE);
else
{
a.u.addr = item->locator.addr;
a.u.addr = locator->addr;
win_info->set_is_exec_point_at (a);
}
}

View File

@ -556,7 +556,7 @@ tui_resize_all (void)
struct tui_win_info *win_with_focus = tui_win_with_focus ();
struct tui_win_info *first_win;
struct tui_win_info *second_win;
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
int win_type;
int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2;
@ -1099,7 +1099,7 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
{
int diff;
struct tui_win_info *win_info;
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
enum tui_layout_type cur_layout = tui_current_layout ();
diff = (new_height - primary_win_info->height) * (-1);
@ -1255,7 +1255,7 @@ tui_source_window_base::set_new_height (int height)
if (has_locator ())
{
tui_gen_win_info *gen_win_info = tui_locator_win_info_ptr ();
tui_locator_window *gen_win_info = tui_locator_win_info_ptr ();
tui_make_invisible (gen_win_info);
gen_win_info->origin.y = origin.y + height;
}

View File

@ -266,7 +266,7 @@ void
tui_refresh_all (struct tui_win_info **list)
{
int type;
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
{