Turn two locator functions into methods

This changes tui_set_locator_fullname and tui_set_locator_info to be
methods on tui_locator_window.  This enables some subsequent
cleannups.

gdb/ChangeLog
2019-08-30  Tom Tromey  <tom@tromey.com>

	* tui/tui-stack.h (struct tui_locator_window) <set_locator_info,
	set_locator_fullname>: New methods.
	* tui/tui-stack.c (tui_locator_window::set_locator_fullname):
	Rename from tui_set_locator_fullname.
	(tui_locator_window::set_locator_info): Rename from
	tui_set_locator_info.  Return bool.
	(tui_update_locator_fullname, tui_show_frame_info): Update.
This commit is contained in:
Tom Tromey 2019-07-18 14:01:56 -06:00
parent 715bb467fe
commit e594a5d19e
3 changed files with 59 additions and 47 deletions

View file

@ -1,3 +1,13 @@
2019-08-30 Tom Tromey <tom@tromey.com>
* tui/tui-stack.h (struct tui_locator_window) <set_locator_info,
set_locator_fullname>: New methods.
* tui/tui-stack.c (tui_locator_window::set_locator_fullname):
Rename from tui_set_locator_fullname.
(tui_locator_window::set_locator_info): Rename from
tui_set_locator_info. Return bool.
(tui_update_locator_fullname, tui_show_frame_info): Update.
2019-08-30 Tom Tromey <tom@tromey.com> 2019-08-30 Tom Tromey <tom@tromey.com>
* tui/tui-layout.c (show_layout): Don't call tui_refresh_all. * tui/tui-layout.c (show_layout): Don't call tui_refresh_all.

View file

@ -58,15 +58,6 @@ static struct tui_locator_window _locator;
Returns a pointer to a static area holding the result. */ Returns a pointer to a static area holding the result. */
static char *tui_get_function_from_frame (struct frame_info *fi); static char *tui_get_function_from_frame (struct frame_info *fi);
/* Set the full_name portion of the locator. */
static void tui_set_locator_fullname (const char *fullname);
/* Update the locator, with the provided arguments. */
static int tui_set_locator_info (struct gdbarch *gdbarch,
const char *fullname,
const char *procname,
int lineno, CORE_ADDR addr);
static void tui_update_command (const char *, int); static void tui_update_command (const char *, int);
@ -295,9 +286,10 @@ tui_locator_window::rerender ()
tui_show_locator_content (); tui_show_locator_content ();
} }
/* Set the filename portion of the locator. */ /* See tui-stack.h. */
static void
tui_set_locator_fullname (const char *fullname) void
tui_locator_window::set_locator_fullname (const char *fullname)
{ {
struct tui_locator_window *locator = tui_locator_win_info_ptr (); struct tui_locator_window *locator = tui_locator_win_info_ptr ();
@ -305,20 +297,16 @@ tui_set_locator_fullname (const char *fullname)
strcat_to_buf (locator->full_name, MAX_LOCATOR_ELEMENT_LEN, fullname); strcat_to_buf (locator->full_name, MAX_LOCATOR_ELEMENT_LEN, fullname);
} }
/* Update the locator, with the provided arguments. /* See tui-stack.h. */
Returns 1 if any of the locator's fields were actually changed, bool
and 0 otherwise. */ tui_locator_window::set_locator_info (struct gdbarch *gdbarch_in,
const char *fullname,
static int const char *procname,
tui_set_locator_info (struct gdbarch *gdbarch, int lineno,
const char *fullname, CORE_ADDR addr_in)
const char *procname,
int lineno,
CORE_ADDR addr)
{ {
struct tui_locator_window *locator = tui_locator_win_info_ptr (); bool locator_changed_p = false;
int locator_changed_p = 0;
if (procname == NULL) if (procname == NULL)
procname = ""; procname = "";
@ -326,20 +314,20 @@ tui_set_locator_info (struct gdbarch *gdbarch,
if (fullname == NULL) if (fullname == NULL)
fullname = ""; fullname = "";
locator_changed_p |= strncmp (locator->proc_name, procname, locator_changed_p |= strncmp (proc_name, procname,
MAX_LOCATOR_ELEMENT_LEN) != 0; MAX_LOCATOR_ELEMENT_LEN) != 0;
locator_changed_p |= lineno != locator->line_no; locator_changed_p |= lineno != line_no;
locator_changed_p |= addr != locator->addr; locator_changed_p |= addr_in != addr;
locator_changed_p |= gdbarch != locator->gdbarch; locator_changed_p |= gdbarch_in != gdbarch;
locator_changed_p |= strncmp (locator->full_name, fullname, locator_changed_p |= strncmp (full_name, fullname,
MAX_LOCATOR_ELEMENT_LEN) != 0; MAX_LOCATOR_ELEMENT_LEN) != 0;
locator->proc_name[0] = (char) 0; proc_name[0] = (char) 0;
strcat_to_buf (locator->proc_name, MAX_LOCATOR_ELEMENT_LEN, procname); strcat_to_buf (proc_name, MAX_LOCATOR_ELEMENT_LEN, procname);
locator->line_no = lineno; line_no = lineno;
locator->addr = addr; addr = addr_in;
locator->gdbarch = gdbarch; gdbarch = gdbarch_in;
tui_set_locator_fullname (fullname); set_locator_fullname (fullname);
return locator_changed_p; return locator_changed_p;
} }
@ -348,7 +336,9 @@ tui_set_locator_info (struct gdbarch *gdbarch,
void void
tui_update_locator_fullname (const char *fullname) tui_update_locator_fullname (const char *fullname)
{ {
tui_set_locator_fullname (fullname); struct tui_locator_window *locator = tui_locator_win_info_ptr ();
locator->set_locator_fullname (fullname);
tui_show_locator_content (); tui_show_locator_content ();
} }
@ -361,11 +351,11 @@ tui_update_locator_fullname (const char *fullname)
int int
tui_show_frame_info (struct frame_info *fi) tui_show_frame_info (struct frame_info *fi)
{ {
int locator_changed_p; bool locator_changed_p;
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
if (fi) if (fi)
{ {
struct tui_locator_window *locator = tui_locator_win_info_ptr ();
CORE_ADDR pc; CORE_ADDR pc;
symtab_and_line sal = find_frame_sal (fi); symtab_and_line sal = find_frame_sal (fi);
@ -376,16 +366,16 @@ tui_show_frame_info (struct frame_info *fi)
if (get_frame_pc_if_available (fi, &pc)) if (get_frame_pc_if_available (fi, &pc))
locator_changed_p locator_changed_p
= tui_set_locator_info (get_frame_arch (fi), = locator->set_locator_info (get_frame_arch (fi),
(sal.symtab == 0 (sal.symtab == 0
? "??" : fullname), ? "??" : fullname),
tui_get_function_from_frame (fi), tui_get_function_from_frame (fi),
sal.line, sal.line,
pc); pc);
else else
locator_changed_p locator_changed_p
= tui_set_locator_info (get_frame_arch (fi), = locator->set_locator_info (get_frame_arch (fi),
"??", _("<unavailable>"), sal.line, 0); "??", _("<unavailable>"), sal.line, 0);
/* If the locator information has not changed, then frame information has /* If the locator information has not changed, then frame information has
not changed. If frame information has not changed, then the windows' not changed. If frame information has not changed, then the windows'
@ -405,7 +395,7 @@ tui_show_frame_info (struct frame_info *fi)
else else
{ {
locator_changed_p locator_changed_p
= tui_set_locator_info (NULL, NULL, NULL, 0, (CORE_ADDR) 0); = locator->set_locator_info (NULL, NULL, NULL, 0, (CORE_ADDR) 0);
if (!locator_changed_p) if (!locator_changed_p)
return 0; return 0;

View file

@ -45,6 +45,18 @@ struct tui_locator_window : public tui_gen_win_info
void rerender () override; void rerender () override;
/* Update the locator, with the provided arguments.
Returns true if any of the locator's fields were actually
changed, and false otherwise. */
bool set_locator_info (struct gdbarch *gdbarch,
const char *fullname,
const char *procname,
int lineno, CORE_ADDR addr);
/* Set the full_name portion of the locator. */
void set_locator_fullname (const char *fullname);
char full_name[MAX_LOCATOR_ELEMENT_LEN]; char full_name[MAX_LOCATOR_ELEMENT_LEN];
char proc_name[MAX_LOCATOR_ELEMENT_LEN]; char proc_name[MAX_LOCATOR_ELEMENT_LEN];
int line_no = 0; int line_no = 0;