diff options
author | Tom Tromey <tom@tromey.com> | 2019-07-18 14:01:56 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-08-30 12:57:07 -0600 |
commit | e594a5d19e855cf19a89dab29196d13f53ced7da (patch) | |
tree | 6079bc2a7ca0f9fcb3da9c8e061cfe1c0d76b931 /gdb/tui | |
parent | 715bb467feab6e94e01bdf4f5aced092df7398c0 (diff) | |
download | gdb-e594a5d19e855cf19a89dab29196d13f53ced7da.zip gdb-e594a5d19e855cf19a89dab29196d13f53ced7da.tar.gz gdb-e594a5d19e855cf19a89dab29196d13f53ced7da.tar.bz2 |
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.
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-stack.c | 84 | ||||
-rw-r--r-- | gdb/tui/tui-stack.h | 12 |
2 files changed, 49 insertions, 47 deletions
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index 0d41133..a4adf36 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -58,15 +58,6 @@ static struct tui_locator_window _locator; Returns a pointer to a static area holding the result. */ 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); @@ -295,9 +286,10 @@ tui_locator_window::rerender () tui_show_locator_content (); } -/* Set the filename portion of the locator. */ -static void -tui_set_locator_fullname (const char *fullname) +/* See tui-stack.h. */ + +void +tui_locator_window::set_locator_fullname (const char *fullname) { 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); } -/* Update the locator, with the provided arguments. +/* See tui-stack.h. */ - Returns 1 if any of the locator's fields were actually changed, - and 0 otherwise. */ - -static int -tui_set_locator_info (struct gdbarch *gdbarch, - const char *fullname, - const char *procname, - int lineno, - CORE_ADDR addr) +bool +tui_locator_window::set_locator_info (struct gdbarch *gdbarch_in, + const char *fullname, + const char *procname, + int lineno, + CORE_ADDR addr_in) { - struct tui_locator_window *locator = tui_locator_win_info_ptr (); - int locator_changed_p = 0; + bool locator_changed_p = false; if (procname == NULL) procname = ""; @@ -326,20 +314,20 @@ tui_set_locator_info (struct gdbarch *gdbarch, if (fullname == NULL) fullname = ""; - locator_changed_p |= strncmp (locator->proc_name, procname, + locator_changed_p |= strncmp (proc_name, procname, MAX_LOCATOR_ELEMENT_LEN) != 0; - 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, + locator_changed_p |= lineno != line_no; + locator_changed_p |= addr_in != addr; + locator_changed_p |= gdbarch_in != gdbarch; + locator_changed_p |= strncmp (full_name, fullname, MAX_LOCATOR_ELEMENT_LEN) != 0; - 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); + proc_name[0] = (char) 0; + strcat_to_buf (proc_name, MAX_LOCATOR_ELEMENT_LEN, procname); + line_no = lineno; + addr = addr_in; + gdbarch = gdbarch_in; + set_locator_fullname (fullname); return locator_changed_p; } @@ -348,7 +336,9 @@ tui_set_locator_info (struct gdbarch *gdbarch, void 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 (); } @@ -361,11 +351,11 @@ tui_update_locator_fullname (const char *fullname) int 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) { - struct tui_locator_window *locator = tui_locator_win_info_ptr (); CORE_ADDR pc; 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)) locator_changed_p - = tui_set_locator_info (get_frame_arch (fi), - (sal.symtab == 0 - ? "??" : fullname), - tui_get_function_from_frame (fi), - sal.line, - pc); + = locator->set_locator_info (get_frame_arch (fi), + (sal.symtab == 0 + ? "??" : fullname), + tui_get_function_from_frame (fi), + sal.line, + pc); else locator_changed_p - = tui_set_locator_info (get_frame_arch (fi), - "??", _("<unavailable>"), sal.line, 0); + = locator->set_locator_info (get_frame_arch (fi), + "??", _("<unavailable>"), sal.line, 0); /* If the locator information has not changed, then frame information has not changed. If frame information has not changed, then the windows' @@ -405,7 +395,7 @@ tui_show_frame_info (struct frame_info *fi) else { 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) return 0; diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h index 951cf2c..86239b0 100644 --- a/gdb/tui/tui-stack.h +++ b/gdb/tui/tui-stack.h @@ -45,6 +45,18 @@ struct tui_locator_window : public tui_gen_win_info 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 proc_name[MAX_LOCATOR_ELEMENT_LEN]; int line_no = 0; |