From patchwork Thu Jul 4 17:02:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33571 Received: (qmail 109414 invoked by alias); 4 Jul 2019 17:03:54 -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 106792 invoked by uid 89); 4 Jul 2019 17:03:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.145.216) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 17:03:28 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 66254C88500 for ; Thu, 4 Jul 2019 12:03:27 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58phxLxU4FKpj58phBuY9; Thu, 04 Jul 2019 12:03:27 -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=BLlcmI9cEe6Rr1xu/heg5O15X1VmVMbN0+qrSM4nIQU=; b=E7FbQ1QLLecvupfJxuSzMh/mPJ d9zvWtJV0MAzQPdyOmP5sC6bOiVBSaadioiBTYjIkqccNRDIivBNxHIDtvQKz/LVigrIcWxLHkbKc 4HujR91lXu44oWJTczrkminS0; Received: from 174-29-58-150.hlrn.qwest.net ([174.29.58.150]:34696 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1hj58p-002sIW-6Q; Thu, 04 Jul 2019 12:03:27 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 36/61] Always create an execution info window for a source window Date: Thu, 4 Jul 2019 11:02:46 -0600 Message-Id: <20190704170311.15982-37-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> A source or disassembly window will always have an "execution info" window (the window along the side that displays breakpoint info), but this isn't immediately clear from the source. As a result, some code has checks to see whether the execution_info is NULL. This changes the source window base class to always instantiate an execution_info window, then updates the rest of the code. It also simplifies window creation in tui-layout.c. 2019-07-04 Tom Tromey * tui/tui-winsource.c (tui_set_exec_info_content): Remove condition. * tui/tui-wingeneral.c (tui_source_window_base::make_visible): Remove condition. * tui/tui-source.c (tui_source_window_base::reset): New method. * tui/tui-layout.c (make_command_window): Don't call init_and_make_win. (make_source_window, make_disasm_window): Don't call make_source_or_disasm_window. (make_data_window): Don't call init_and_make_win. Change calling convention. (show_source_disasm_command, show_data): Simplify. (make_source_or_disasm_window): Remove. (show_source_or_disasm_and_command): Simplify. * tui/tui-data.h (struct tui_gen_win_info) : Now virtual. (struct tui_source_window_base) : Likewise. : Remove initializer. * tui/tui-data.c (tui_source_window_base): Initialize execution_info. --- gdb/ChangeLog | 22 +++++++ gdb/tui/tui-data.c | 3 +- gdb/tui/tui-data.h | 12 ++-- gdb/tui/tui-layout.c | 120 +++++++++++---------------------------- gdb/tui/tui-source.c | 10 ++++ gdb/tui/tui-wingeneral.c | 3 +- gdb/tui/tui-winsource.c | 61 ++++++++++---------- 7 files changed, 105 insertions(+), 126 deletions(-) diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 396635b779c..ee5b3aa3a7a 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -332,7 +332,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) + : 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; diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 9d1d0dd5753..39c7f0c9d2f 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -61,9 +61,9 @@ public: /* Reset this window. WIN_TYPE must match the existing type of this window (it is only passed for self-test purposes). The other parameters are used to set the window's size and position. */ - void reset (enum tui_win_type win_type, - int height, int width, - int origin_x, int origin_y); + virtual void reset (enum tui_win_type win_type, + int height, int width, + int origin_x, int origin_y); /* Window handle. */ WINDOW *handle = nullptr; @@ -393,10 +393,14 @@ public: virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0; + void reset (enum tui_win_type win_type, + 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 = nullptr; + struct tui_exec_info_window *execution_info; /* Used for horizontal scroll. */ int horizontal_offset = 0; struct tui_line_or_address start_line_or_addr; diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index ac0d01c990a..23537b7f496 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -48,12 +48,9 @@ static tui_gen_win_info *init_and_make_win (tui_gen_win_info *, int, int, int, int, enum tui_box); static void show_source_or_disasm_and_command (enum tui_layout_type); -static struct tui_win_info *make_source_or_disasm_window (enum tui_win_type, - int, int); static struct tui_win_info *make_command_window (int, int); static struct tui_win_info *make_source_window (int, int); static struct tui_win_info *make_disasm_window (int, int); -static void make_data_window (struct tui_win_info **, int, int); static void show_source_command (void); static void show_disasm_command (void); static void show_source_disasm_command (void); @@ -522,14 +519,9 @@ prev_layout (void) static struct tui_win_info * make_command_window (int height, int origin_y) { - struct tui_win_info *result - = (struct tui_win_info *) init_and_make_win (NULL, - CMD_WIN, - height, - tui_term_width (), - 0, - origin_y, - DONT_BOX_WINDOW); + struct tui_win_info *result = new tui_cmd_window (); + result->reset (CMD_WIN, height, tui_term_width (), 0, origin_y); + tui_make_window (result, DONT_BOX_WINDOW); return result; } @@ -539,8 +531,11 @@ make_command_window (int height, int origin_y) static struct tui_win_info * make_source_window (int height, int origin_y) { - return make_source_or_disasm_window (SRC_WIN, height, origin_y); -} /* make_source_window */ + tui_win_info *result = new tui_source_window (); + result->reset (SRC_WIN, height, tui_term_width (), 0, origin_y); + result->make_visible (true); + return result; +} /* make_disasm_window(). @@ -548,22 +543,20 @@ make_source_window (int height, int origin_y) static struct tui_win_info * make_disasm_window (int height, int origin_y) { - return make_source_or_disasm_window (DISASSEM_WIN, height, origin_y); -} /* make_disasm_window */ + tui_win_info *result = new tui_disasm_window (); + result->reset (SRC_WIN, height, tui_term_width (), 0, origin_y); + result->make_visible (true); + return result; +} -static void -make_data_window (struct tui_win_info **win_info_ptr, - int height, int origin_y) +static tui_win_info * +make_data_window (int height, int origin_y) { - *win_info_ptr - = (struct tui_win_info *) init_and_make_win (*win_info_ptr, - DATA_WIN, - height, - tui_term_width (), - 0, - origin_y, - BOX_WINDOW); + tui_win_info *result = new tui_data_window (); + result->reset (DATA_WIN, height, tui_term_width (), 0, origin_y); + result->make_visible (true); + return result; } @@ -606,16 +599,10 @@ show_source_disasm_command (void) { TUI_SRC_WIN->reset (TUI_SRC_WIN->type, src_height, - TUI_SRC_WIN->width, - TUI_SRC_WIN->execution_info->width, + tui_term_width (), + 0, 0); - TUI_SRC_WIN->execution_info->reset (EXEC_INFO_WIN, - src_height, - 3, - 0, - 0); tui_make_visible (TUI_SRC_WIN); - tui_make_visible (TUI_SRC_WIN->execution_info); TUI_SRC_WIN->m_has_locator = false; } @@ -645,16 +632,10 @@ show_source_disasm_command (void) TUI_DISASM_WIN->m_has_locator = true; TUI_DISASM_WIN->reset (TUI_DISASM_WIN->type, asm_height, - TUI_DISASM_WIN->width, - TUI_DISASM_WIN->execution_info->width, + tui_term_width (), + 0, src_height - 1); - TUI_DISASM_WIN->execution_info->reset (EXEC_INFO_WIN, - asm_height, - 3, - 0, - src_height - 1); tui_make_visible (TUI_DISASM_WIN); - tui_make_visible (TUI_DISASM_WIN->execution_info); } TUI_SRC_WIN->m_has_locator = false; TUI_DISASM_WIN->m_has_locator = true; @@ -695,7 +676,12 @@ show_data (enum tui_layout_type new_layout) src_height = total_height - data_height; tui_make_all_invisible (); tui_make_invisible (locator); - make_data_window (&tui_win_list[DATA_WIN], data_height, 0); + if (tui_win_list[DATA_WIN] == nullptr) + tui_win_list[DATA_WIN] = make_data_window (data_height, 0); + else + tui_win_list[DATA_WIN]->reset (data_height, tui_term_width (), 0, 0); + tui_win_list[DATA_WIN]->make_visible (true); + if (new_layout == SRC_DATA_COMMAND) win_type = SRC_WIN; else @@ -724,16 +710,10 @@ show_data (enum tui_layout_type new_layout) base = (tui_source_window_base *) tui_win_list[win_type]; tui_win_list[win_type]->reset (tui_win_list[win_type]->type, src_height, - tui_win_list[win_type]->width, - base->execution_info->width, + tui_term_width (), + 0, data_height - 1); - base->execution_info->reset (EXEC_INFO_WIN, - src_height, - 3, - 0, - data_height - 1); tui_make_visible (tui_win_list[win_type]); - tui_make_visible (base->execution_info); locator->reset (LOCATOR_WIN, 2 /* 1 */ , tui_term_width (), @@ -816,34 +796,6 @@ init_and_make_win (tui_gen_win_info *win_info, } -static struct tui_win_info * -make_source_or_disasm_window (enum tui_win_type type, - int height, int origin_y) -{ - struct tui_exec_info_window *execution_info - = (tui_exec_info_window *) init_and_make_win (nullptr, - EXEC_INFO_WIN, - height, - 3, - 0, - origin_y, - DONT_BOX_WINDOW); - - /* Now create the source window. */ - struct tui_source_window_base *result - = ((struct tui_source_window_base *) - init_and_make_win (NULL, - type, - height, - tui_term_width () - execution_info->width, - execution_info->width, - origin_y, - BOX_WINDOW)); - result->execution_info = execution_info; - return result; -} - - /* Show the Source/Command or the Disassem layout. */ static void show_source_or_disasm_and_command (enum tui_layout_type layout_type) @@ -893,16 +845,10 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type) base->m_has_locator = true; (*win_info_ptr)->reset ((*win_info_ptr)->type, src_height - 1, - (*win_info_ptr)->width, - base->execution_info->width, + tui_term_width (), + 0, 0); - base->execution_info->reset (EXEC_INFO_WIN, - src_height - 1, - 3, - 0, - 0); tui_make_visible (*win_info_ptr); - tui_make_visible (base->execution_info); } base->m_has_locator = true; diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index f0bac24bfea..873612fecce 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -291,3 +291,13 @@ 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 (enum tui_win_type win_type, + int height, int width, + int origin_x, int origin_y) +{ + tui_gen_win_info::reset (win_type, height, width - 3, + origin_x + 3, origin_y); + execution_info->reset (EXEC_INFO_WIN, height, 3, origin_x, origin_y); +} diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c index dc008cd7198..3dca621b887 100644 --- a/gdb/tui/tui-wingeneral.c +++ b/gdb/tui/tui-wingeneral.c @@ -201,8 +201,7 @@ tui_make_invisible (struct tui_gen_win_info *win_info) void tui_source_window_base::make_visible (bool visible) { - if (execution_info != nullptr) - execution_info->make_visible (visible); + execution_info->make_visible (visible); tui_win_info::make_visible (visible); } diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 38d5532912d..d9f64251090 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -469,39 +469,36 @@ tui_exec_info_window::maybe_allocate_content (int n_elements) void tui_set_exec_info_content (struct tui_source_window_base *win_info) { - if (win_info->execution_info != NULL) - { - tui_exec_info_content *content - = win_info->execution_info->maybe_allocate_content (win_info->height); + tui_exec_info_content *content + = win_info->execution_info->maybe_allocate_content (win_info->height); - tui_update_breakpoint_info (win_info, nullptr, true); - for (int i = 0; i < win_info->content.size (); i++) - { - tui_exec_info_content &element = content[i]; - struct tui_source_element *src_element; - tui_bp_flags mode; - - src_element = &win_info->content[i]; - - memset (element, ' ', sizeof (tui_exec_info_content)); - element[TUI_EXECINFO_SIZE - 1] = 0; - - /* Now update the exec info content based upon the state - of each line as indicated by the source content. */ - mode = src_element->break_mode; - if (mode & TUI_BP_HIT) - element[TUI_BP_HIT_POS] = (mode & TUI_BP_HARDWARE) ? 'H' : 'B'; - else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED)) - element[TUI_BP_HIT_POS] = (mode & TUI_BP_HARDWARE) ? 'h' : 'b'; - - if (mode & TUI_BP_ENABLED) - element[TUI_BP_BREAK_POS] = '+'; - else if (mode & TUI_BP_DISABLED) - element[TUI_BP_BREAK_POS] = '-'; - - if (src_element->is_exec_point) - element[TUI_EXEC_POS] = '>'; - } + tui_update_breakpoint_info (win_info, nullptr, true); + for (int i = 0; i < win_info->content.size (); i++) + { + tui_exec_info_content &element = content[i]; + struct tui_source_element *src_element; + tui_bp_flags mode; + + src_element = &win_info->content[i]; + + memset (element, ' ', sizeof (tui_exec_info_content)); + element[TUI_EXECINFO_SIZE - 1] = 0; + + /* Now update the exec info content based upon the state + of each line as indicated by the source content. */ + mode = src_element->break_mode; + if (mode & TUI_BP_HIT) + element[TUI_BP_HIT_POS] = (mode & TUI_BP_HARDWARE) ? 'H' : 'B'; + else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED)) + element[TUI_BP_HIT_POS] = (mode & TUI_BP_HARDWARE) ? 'h' : 'b'; + + if (mode & TUI_BP_ENABLED) + element[TUI_BP_BREAK_POS] = '+'; + else if (mode & TUI_BP_DISABLED) + element[TUI_BP_BREAK_POS] = '-'; + + if (src_element->is_exec_point) + element[TUI_EXEC_POS] = '>'; } }