aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-07-02 17:07:02 -0600
committerTom Tromey <tom@tromey.com>2019-07-17 12:19:25 -0600
commit5104fe361d818a46b262b5d504f3d293c9a2b44a (patch)
tree2e6677c74b037797ea5da459cc3f1a0d0099305b /gdb/tui
parentdaa15dde7202d948da694bdfe0df9e5294c7ee9a (diff)
downloadgdb-5104fe361d818a46b262b5d504f3d293c9a2b44a.zip
gdb-5104fe361d818a46b262b5d504f3d293c9a2b44a.tar.gz
gdb-5104fe361d818a46b262b5d504f3d293c9a2b44a.tar.bz2
Move source window common to code to tui-winsource.[ch]
Like the previous rearranging patches, this moves the source and disassembly window base class code to tui-winsource.[ch]. The execution info window is also moved, because it is associated with this base class. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_exec_info_window) (struct tui_source_window_base): Move from tui-data.h. * tui/tui-winsource.c: Move many method definitions from elsewhere. Remove "structuring" comments. * tui/tui-wingeneral.c (tui_source_window_base::make_visible) (tui_source_window_base::refresh_window): Move to tui-winsource.c. * tui/tui-win.c (tui_source_window_base::refresh_all) (tui_source_window_base::update_tab_width) (tui_source_window_base::set_new_height) (tui_source_window_base::do_make_visible_with_new_height): Move to tui-winsource.c. * tui/tui-source.h: Update. * tui/tui-source.c (tui_source_window_base::reset): Move to tui-winsource.c. * tui/tui-disasm.h: Update. * tui/tui-data.h (struct tui_exec_info_window): Move to tui-winsource.h. (struct tui_source_window_base): Likewise. * tui/tui-data.c (tui_source_window_base::clear_detail) (tui_source_window_base, ~tui_source_window_base): Move to tui-winsource.c.
Diffstat (limited to 'gdb/tui')
-rw-r--r--gdb/tui/tui-data.c27
-rw-r--r--gdb/tui/tui-data.h85
-rw-r--r--gdb/tui/tui-disasm.h1
-rw-r--r--gdb/tui/tui-source.c9
-rw-r--r--gdb/tui/tui-source.h3
-rw-r--r--gdb/tui/tui-win.c90
-rw-r--r--gdb/tui/tui-wingeneral.c18
-rw-r--r--gdb/tui/tui-winsource.c149
-rw-r--r--gdb/tui/tui-winsource.h82
9 files changed, 231 insertions, 233 deletions
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 8977e8f..2748230 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -24,6 +24,7 @@
#include "tui/tui.h"
#include "tui/tui-data.h"
#include "tui/tui-wingeneral.h"
+#include "tui/tui-winsource.h"
#include "gdb_curses.h"
/****************************
@@ -139,17 +140,6 @@ tui_add_to_source_windows (struct tui_source_window_base *win_info)
source_windows.push_back (win_info);
}
-/* See tui-data.h. */
-
-void
-tui_source_window_base::clear_detail ()
-{
- gdbarch = NULL;
- start_line_or_addr.loa = LOA_ADDRESS;
- start_line_or_addr.u.addr = 0;
- horizontal_offset = 0;
-}
-
/* Accessor for the locator win info. Answers a pointer to the static
locator win info struct. */
struct tui_locator_window *
@@ -313,23 +303,8 @@ tui_win_info::tui_win_info (enum tui_win_type type)
{
}
-tui_source_window_base::tui_source_window_base (enum tui_win_type type)
- : tui_win_info (type),
- execution_info (new tui_exec_info_window ())
-{
- gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
- start_line_or_addr.loa = LOA_ADDRESS;
- start_line_or_addr.u.addr = 0;
-}
-
tui_gen_win_info::~tui_gen_win_info ()
{
tui_delete_win (handle);
xfree (title);
}
-
-tui_source_window_base::~tui_source_window_base ()
-{
- xfree (fullname);
- delete execution_info;
-}
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 5b436a1..214f728 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -27,6 +27,7 @@
#include "observable.h"
struct tui_cmd_window;
+struct tui_source_window_base;
struct tui_source_window;
/* This is a point definition. */
@@ -203,34 +204,6 @@ struct tui_source_element
typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
-/* Execution info window class. */
-
-struct tui_exec_info_window : public tui_gen_win_info
-{
- tui_exec_info_window ()
- : tui_gen_win_info (EXEC_INFO_WIN)
- {
- }
-
- ~tui_exec_info_window () override
- {
- xfree (m_content);
- }
-
- /* Get or allocate contents. */
- tui_exec_info_content *maybe_allocate_content (int n_elements);
-
- /* Return the contents. */
- const tui_exec_info_content *get_content () const
- {
- return m_content;
- }
-
-private:
-
- tui_exec_info_content *m_content = nullptr;
-};
-
/* Locator window class. */
struct tui_locator_window : public tui_gen_win_info
@@ -334,62 +307,6 @@ public:
bool is_highlighted = false;
};
-/* The base class for all source-like windows, namely the source and
- disassembly windows. */
-
-struct tui_source_window_base : public tui_win_info
-{
-protected:
- explicit tui_source_window_base (enum tui_win_type type);
- ~tui_source_window_base () override;
- DISABLE_COPY_AND_ASSIGN (tui_source_window_base);
-
- void do_scroll_horizontal (int num_to_scroll) override;
- void do_make_visible_with_new_height () override;
-
-public:
-
- void clear_detail () override;
-
- void make_visible (bool visible) override;
- void refresh_window () override;
- void refresh_all () override;
-
- /* Refill the source window's source cache and update it. If this
- is a disassembly window, then just update it. */
- void refill ();
-
- /* Set the location of the execution point. */
- void set_is_exec_point_at (struct tui_line_or_address l);
-
- void set_new_height (int height) override;
-
- void update_tab_width () override;
-
- /* Return true if the location LOC corresponds to the line number
- LINE_NO in this source window; false otherwise. */
- virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
-
- void reset (int height, int width,
- int origin_x, int origin_y) override;
-
- /* Does the locator belong to this window? */
- bool m_has_locator = false;
- /* Execution information window. */
- struct tui_exec_info_window *execution_info;
- /* 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;
-
- std::vector<tui_source_element> content;
-};
-
extern int tui_win_is_auxiliary (enum tui_win_type win_type);
diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h
index cc00d00..19672a7 100644
--- a/gdb/tui/tui-disasm.h
+++ b/gdb/tui/tui-disasm.h
@@ -24,6 +24,7 @@
#include "tui/tui.h"
#include "tui/tui-data.h"
+#include "tui-winsource.h"
/* A TUI disassembly window. */
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index e171101..f0bac24 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -291,12 +291,3 @@ tui_source_window::location_matches_p (struct bp_location *loc, int line_no)
&& filename_cmp (fullname,
symtab_to_fullname (loc->symtab)) == 0);
}
-
-void
-tui_source_window_base::reset (int height, int width,
- int origin_x, int origin_y)
-{
- tui_gen_win_info::reset (height, width - 3,
- origin_x + 3, origin_y);
- execution_info->reset (height, 3, origin_x, origin_y);
-}
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index 6faaa2e..49d79ab 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -23,6 +23,7 @@
#define TUI_TUI_SOURCE_H
#include "tui/tui-data.h"
+#include "tui-winsource.h"
struct symtab;
@@ -40,6 +41,8 @@ struct tui_source_window : public tui_source_window_base
return SRC_NAME;
}
+ /* Return true if the location LOC corresponds to the line number
+ LINE_NO in this source window; false otherwise. */
bool location_matches_p (struct bp_location *loc, int line_no) override;
bool showing_source_p (const char *filename) const;
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 227ab94..1e02c42 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -498,17 +498,6 @@ tui_win_info::right_scroll (int num_to_scroll)
}
-/* See tui-data.h. */
-
-void
-tui_source_window_base::refresh_all ()
-{
- tui_show_source_content (this);
- tui_check_and_display_highlight_if_needed (this);
- tui_erase_exec_info_content (this);
- tui_update_exec_info (this);
-}
-
void
tui_refresh_all_win (void)
{
@@ -899,19 +888,6 @@ unsigned int tui_tab_width = DEFAULT_TAB_LEN;
static unsigned int internal_tab_width = DEFAULT_TAB_LEN;
-/* See tui-data.h. */
-
-void
-tui_source_window_base::update_tab_width ()
-{
- /* We don't really change the height of any windows, but
- calling these 2 functions causes a complete regeneration
- and redisplay of the window's contents, which will take
- the new tab width into account. */
- make_invisible_and_set_new_height (height);
- make_visible_with_new_height ();
-}
-
/* After the tab width is set, call this to update the relevant
windows. */
@@ -1218,28 +1194,6 @@ tui_adjust_win_heights (struct tui_win_info *primary_win_info,
/* See tui-data.h. */
void
-tui_source_window_base::set_new_height (int height)
-{
- execution_info->make_visible (false);
- execution_info->height = height;
- execution_info->origin.y = origin.y;
- if (height > 1)
- execution_info->viewport_height = height - 1;
- else
- execution_info->viewport_height = height;
- execution_info->viewport_height--;
-
- if (m_has_locator)
- {
- tui_locator_window *gen_win_info = tui_locator_win_info_ptr ();
- gen_win_info->make_visible (false);
- gen_win_info->origin.y = origin.y + height;
- }
-}
-
-/* See tui-data.h. */
-
-void
tui_win_info::make_invisible_and_set_new_height (int height)
{
make_visible (false);
@@ -1268,50 +1222,6 @@ tui_win_info::make_visible_with_new_height ()
/* See tui-data.h. */
-void
-tui_source_window_base::do_make_visible_with_new_height ()
-{
- execution_info->make_visible (true);
- if (!content.empty ())
- {
- struct tui_line_or_address line_or_addr;
- struct symtab_and_line cursal
- = get_current_source_symtab_and_line ();
-
- line_or_addr = start_line_or_addr;
- tui_update_source_window (this, gdbarch,
- cursal.symtab, line_or_addr, TRUE);
- }
- else if (deprecated_safe_get_selected_frame () != NULL)
- {
- struct tui_line_or_address line;
- struct symtab_and_line cursal
- = get_current_source_symtab_and_line ();
- struct frame_info *frame = deprecated_safe_get_selected_frame ();
- struct gdbarch *gdbarch = get_frame_arch (frame);
-
- struct symtab *s = find_pc_line_symtab (get_frame_pc (frame));
- if (type == SRC_WIN)
- {
- line.loa = LOA_LINE;
- line.u.line_no = cursal.line;
- }
- else
- {
- line.loa = LOA_ADDRESS;
- find_line_pc (s, cursal.line, &line.u.addr);
- }
- tui_update_source_window (this, gdbarch, s, line, TRUE);
- }
- if (m_has_locator)
- {
- tui_locator_win_info_ptr ()->make_visible (true);
- tui_show_locator_content ();
- }
-}
-
-/* See tui-data.h. */
-
int
tui_win_info::max_height () const
{
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 5d632b6..a2e4886 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -166,15 +166,6 @@ tui_gen_win_info::make_visible (bool visible)
}
}
-/* See tui-data.h. */
-
-void
-tui_source_window_base::make_visible (bool visible)
-{
- execution_info->make_visible (visible);
- tui_win_info::make_visible (visible);
-}
-
/* Makes all windows invisible (except the command and locator
windows). */
static void
@@ -196,15 +187,6 @@ tui_make_all_invisible (void)
make_all_visible (false);
}
-/* See tui-data.h. */
-
-void
-tui_source_window_base::refresh_window ()
-{
- execution_info->refresh_window ();
- tui_win_info::refresh_window ();
-}
-
/* Function to refresh all the windows currently displayed. */
void
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index d9f6425..71147da 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -301,6 +301,150 @@ tui_show_source_content (struct tui_source_window_base *win_info)
/* See tui-data.h. */
void
+tui_source_window_base::clear_detail ()
+{
+ gdbarch = NULL;
+ start_line_or_addr.loa = LOA_ADDRESS;
+ start_line_or_addr.u.addr = 0;
+ horizontal_offset = 0;
+}
+
+tui_source_window_base::tui_source_window_base (enum tui_win_type type)
+ : tui_win_info (type),
+ execution_info (new tui_exec_info_window ())
+{
+ gdb_assert (type == SRC_WIN || type == DISASSEM_WIN);
+ start_line_or_addr.loa = LOA_ADDRESS;
+ start_line_or_addr.u.addr = 0;
+}
+
+
+tui_source_window_base::~tui_source_window_base ()
+{
+ xfree (fullname);
+ delete execution_info;
+}
+
+void
+tui_source_window_base::reset (int height, int width,
+ int origin_x, int origin_y)
+{
+ tui_gen_win_info::reset (height, width - 3,
+ origin_x + 3, origin_y);
+ execution_info->reset (height, 3, origin_x, origin_y);
+}
+
+/* See tui-data.h. */
+
+void
+tui_source_window_base::refresh_all ()
+{
+ tui_show_source_content (this);
+ tui_check_and_display_highlight_if_needed (this);
+ tui_erase_exec_info_content (this);
+ tui_update_exec_info (this);
+}
+
+/* See tui-data.h. */
+
+void
+tui_source_window_base::update_tab_width ()
+{
+ /* We don't really change the height of any windows, but
+ calling these 2 functions causes a complete regeneration
+ and redisplay of the window's contents, which will take
+ the new tab width into account. */
+ make_invisible_and_set_new_height (height);
+ make_visible_with_new_height ();
+}
+
+/* See tui-data.h. */
+
+void
+tui_source_window_base::set_new_height (int height)
+{
+ execution_info->make_visible (false);
+ execution_info->height = height;
+ execution_info->origin.y = origin.y;
+ if (height > 1)
+ execution_info->viewport_height = height - 1;
+ else
+ execution_info->viewport_height = height;
+ execution_info->viewport_height--;
+
+ if (m_has_locator)
+ {
+ tui_locator_window *gen_win_info = tui_locator_win_info_ptr ();
+ gen_win_info->make_visible (false);
+ gen_win_info->origin.y = origin.y + height;
+ }
+}
+
+/* See tui-data.h. */
+
+void
+tui_source_window_base::do_make_visible_with_new_height ()
+{
+ execution_info->make_visible (true);
+ if (!content.empty ())
+ {
+ struct tui_line_or_address line_or_addr;
+ struct symtab_and_line cursal
+ = get_current_source_symtab_and_line ();
+
+ line_or_addr = start_line_or_addr;
+ tui_update_source_window (this, gdbarch,
+ cursal.symtab, line_or_addr, TRUE);
+ }
+ else if (deprecated_safe_get_selected_frame () != NULL)
+ {
+ struct tui_line_or_address line;
+ struct symtab_and_line cursal
+ = get_current_source_symtab_and_line ();
+ struct frame_info *frame = deprecated_safe_get_selected_frame ();
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+
+ struct symtab *s = find_pc_line_symtab (get_frame_pc (frame));
+ if (type == SRC_WIN)
+ {
+ line.loa = LOA_LINE;
+ line.u.line_no = cursal.line;
+ }
+ else
+ {
+ line.loa = LOA_ADDRESS;
+ find_line_pc (s, cursal.line, &line.u.addr);
+ }
+ tui_update_source_window (this, gdbarch, s, line, TRUE);
+ }
+ if (m_has_locator)
+ {
+ tui_locator_win_info_ptr ()->make_visible (true);
+ tui_show_locator_content ();
+ }
+}
+
+/* See tui-data.h. */
+
+void
+tui_source_window_base::make_visible (bool visible)
+{
+ execution_info->make_visible (visible);
+ tui_win_info::make_visible (visible);
+}
+
+/* See tui-data.h. */
+
+void
+tui_source_window_base::refresh_window ()
+{
+ execution_info->refresh_window ();
+ tui_win_info::refresh_window ();
+}
+
+/* See tui-data.h. */
+
+void
tui_source_window_base::refill ()
{
symtab *s = nullptr;
@@ -616,8 +760,3 @@ tui_addr_is_displayed (CORE_ADDR addr,
return is_displayed;
}
-
-
-/*****************************************
-** STATIC LOCAL FUNCTIONS **
-******************************************/
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index a4907e6..ec44d1d 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -24,7 +24,87 @@
#include "tui/tui-data.h"
-struct tui_win_info;
+/* Execution info window class. */
+
+struct tui_exec_info_window : public tui_gen_win_info
+{
+ tui_exec_info_window ()
+ : tui_gen_win_info (EXEC_INFO_WIN)
+ {
+ }
+
+ ~tui_exec_info_window () override
+ {
+ xfree (m_content);
+ }
+
+ /* Get or allocate contents. */
+ tui_exec_info_content *maybe_allocate_content (int n_elements);
+
+ /* Return the contents. */
+ const tui_exec_info_content *get_content () const
+ {
+ return m_content;
+ }
+
+private:
+
+ tui_exec_info_content *m_content = nullptr;
+};
+
+/* The base class for all source-like windows, namely the source and
+ disassembly windows. */
+
+struct tui_source_window_base : public tui_win_info
+{
+protected:
+ explicit tui_source_window_base (enum tui_win_type type);
+ ~tui_source_window_base () override;
+ DISABLE_COPY_AND_ASSIGN (tui_source_window_base);
+
+ void do_scroll_horizontal (int num_to_scroll) override;
+ void do_make_visible_with_new_height () override;
+
+public:
+
+ void clear_detail () override;
+
+ void make_visible (bool visible) override;
+ void refresh_window () override;
+ void refresh_all () override;
+
+ /* Refill the source window's source cache and update it. If this
+ is a disassembly window, then just update it. */
+ void refill ();
+
+ /* Set the location of the execution point. */
+ void set_is_exec_point_at (struct tui_line_or_address l);
+
+ void set_new_height (int height) override;
+
+ void update_tab_width () override;
+
+ virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
+
+ void reset (int height, int width,
+ int origin_x, int origin_y) override;
+
+ /* Does the locator belong to this window? */
+ bool m_has_locator = false;
+ /* Execution information window. */
+ struct tui_exec_info_window *execution_info;
+ /* 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;
+
+ std::vector<tui_source_element> content;
+};
/* Update the execution windows to show the active breakpoints. This
is called whenever a breakpoint is inserted, removed or has its