From patchwork Thu Jul 4 17:03:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33592 Received: (qmail 114010 invoked by alias); 4 Jul 2019 17:04:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 108378 invoked by uid 89); 4 Jul 2019 17:03:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.46.113) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 17:03:38 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway21.websitewelcome.com (Postfix) with ESMTP id B9E5540112A63 for ; Thu, 4 Jul 2019 12:03:36 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58yhuwhM2PzOj58yh7dYT; Thu, 04 Jul 2019 12:03:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=16d/oKdAqCCHZ45MdtMfzu58bRDINMzN072s6MOzLNc=; b=BdC1NHfkIveUTRZQ3WGo40yrGG 2lNZtomKTiuLhCGWomdc5zN1WANDiTIz0RHxwlDfjxFdUoLR9KnLp4L9WconG37BIsOVRt+Y+ZVEh 2KGHmv2xJZef9z3gNIpgqs2RF; Received: from 174-29-58-150.hlrn.qwest.net ([174.29.58.150]:34704 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1hj58y-002sNV-Fr; Thu, 04 Jul 2019 12:03:36 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 59/61] Move source window common to code to tui-winsource.[ch] Date: Thu, 4 Jul 2019 11:03:09 -0600 Message-Id: <20190704170311.15982-60-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> 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. 2019-07-04 Tom Tromey * 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. --- gdb/ChangeLog | 25 +++++++ gdb/tui/tui-data.c | 27 +------ gdb/tui/tui-data.h | 83 +--------------------- gdb/tui/tui-disasm.h | 1 + gdb/tui/tui-source.c | 9 --- gdb/tui/tui-source.h | 1 + gdb/tui/tui-win.c | 90 ----------------------- gdb/tui/tui-wingeneral.c | 18 ----- gdb/tui/tui-winsource.c | 149 +++++++++++++++++++++++++++++++++++++-- gdb/tui/tui-winsource.h | 82 ++++++++++++++++++++- 10 files changed, 254 insertions(+), 231 deletions(-) diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 8977e8fd592..2748230700c 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 84a8117c754..214f728befe 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,60 +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; - - 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 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 cc00d0018fa..19672a74df1 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 e171101e7fb..f0bac24bfea 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 6faaa2e9e0f..063f3e6860e 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; diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 227ab94bdc7..1e02c42dbd1 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. */ @@ -1215,28 +1191,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 @@ -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 5d632b6f97e..a2e48865761 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 d9f64251090..71147da2f91 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -300,6 +300,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 () { @@ -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 a4907e6cc4e..ec44d1d2c02 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 content; +}; /* Update the execution windows to show the active breakpoints. This is called whenever a breakpoint is inserted, removed or has its