+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.
+
2019-07-17 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_resize_all)
#include "tui/tui.h"
#include "tui/tui-data.h"
#include "tui/tui-wingeneral.h"
+#include "tui/tui-winsource.h"
#include "gdb_curses.h"
/****************************
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 *
{
}
-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;
-}
#include "observable.h"
struct tui_cmd_window;
+struct tui_source_window_base;
struct tui_source_window;
/* This is a point definition. */
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
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);
#include "tui/tui.h"
#include "tui/tui-data.h"
+#include "tui-winsource.h"
/* A TUI disassembly window. */
&& 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);
-}
#define TUI_TUI_SOURCE_H
#include "tui/tui-data.h"
+#include "tui-winsource.h"
struct symtab;
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;
}
-/* 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)
{
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. */
}
-/* 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
/* 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
{
}
}
-/* 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
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
/* 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 ()
{
return is_displayed;
}
-
-
-/*****************************************
-** STATIC LOCAL FUNCTIONS **
-******************************************/
#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