From patchwork Wed Aug 14 16:21:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34095 Received: (qmail 71590 invoked by alias); 14 Aug 2019 16:21:41 -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 71494 invoked by uid 89); 14 Aug 2019 16:21:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.2 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=3947 X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.147.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Aug 2019 16:21:38 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway34.websitewelcome.com (Postfix) with ESMTP id BCAFE254E679 for ; Wed, 14 Aug 2019 11:21:36 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id xw1ohlm8tiQerxw1oh7rLy; Wed, 14 Aug 2019 11:21: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=r7lcyWudHut/EGJdU0Z/bbDQ6gzIXePSuRdFKfnNFv0=; b=QpJapE7oKYR8LUA++iPe281ZY3 E3v27BxxMZLGQChwJlPRgkJefUiT2UTA1GeK+o33yAGqSEuddV22KfFp4IRVkFHtwQoegJSP0SRv/ SdVbx0bCIzqdjwbn63nrHQLcm; Received: from 97-122-178-82.hlrn.qwest.net ([97.122.178.82]:38600 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hxw1o-002Cwq-Gf; Wed, 14 Aug 2019 11:21:36 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 05/15] Move contents of tui_show_frame_info to new method Date: Wed, 14 Aug 2019 10:21:22 -0600 Message-Id: <20190814162132.31424-6-tom@tromey.com> In-Reply-To: <20190814162132.31424-1-tom@tromey.com> References: <20190814162132.31424-1-tom@tromey.com> This moves much of the body of tui_show_frame_info to a new method on tui_source_window_base. This removes a check for the type of a window. gdb/ChangeLog 2019-08-14 Tom Tromey * tui/tui-winsource.h (struct tui_source_window_base) : Declare. * tui/tui-stack.c (tui_show_frame_info): Call maybe_update method. * tui/tui-source.h (struct tui_source_window) : Declare. * tui/tui-source.c (tui_source_window::maybe_update): New method. * tui/tui-disasm.h (struct tui_disasm_window) : Declare. * tui/tui-disasm.c (tui_disasm_window::maybe_update): New method. --- gdb/ChangeLog | 13 +++++++++ gdb/tui/tui-disasm.c | 31 ++++++++++++++++++++++ gdb/tui/tui-disasm.h | 4 +++ gdb/tui/tui-source.c | 26 ++++++++++++++++++ gdb/tui/tui-source.h | 4 +++ gdb/tui/tui-stack.c | 58 +---------------------------------------- gdb/tui/tui-winsource.h | 4 +++ 7 files changed, 83 insertions(+), 57 deletions(-) diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index a442a00019e..fcb33bccfd7 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -380,3 +380,34 @@ tui_disasm_window::location_matches_p (struct bp_location *loc, int line_no) return (content[line_no].line_or_addr.loa == LOA_ADDRESS && content[line_no].line_or_addr.u.addr == loc->address); } + +void +tui_disasm_window::maybe_update (struct frame_info *fi, symtab_and_line sal, + int line_no, CORE_ADDR addr) +{ + CORE_ADDR low; + + if (find_pc_partial_function (get_frame_pc (fi), + NULL, &low, NULL) == 0) + { + /* There is no symbol available for current PC. There is no + safe way how to "disassemble backwards". */ + low = get_frame_pc (fi); + } + else + low = tui_get_low_disassembly_address (get_frame_arch (fi), + low, get_frame_pc (fi)); + + struct tui_line_or_address a; + + a.loa = LOA_ADDRESS; + a.u.addr = low; + if (!tui_addr_is_displayed (addr, this, TRUE)) + tui_update_source_window (this, get_frame_arch (fi), + sal.symtab, a, TRUE); + else + { + a.u.addr = addr; + set_is_exec_point_at (a); + } +} diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h index 19672a74df1..20bc4290ffc 100644 --- a/gdb/tui/tui-disasm.h +++ b/gdb/tui/tui-disasm.h @@ -44,6 +44,10 @@ struct tui_disasm_window : public tui_source_window_base bool location_matches_p (struct bp_location *loc, int line_no) override; + void maybe_update (struct frame_info *fi, symtab_and_line sal, + int line_no, CORE_ADDR addr) + override; + protected: void do_scroll_vertical (int num_to_scroll) override; diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 619d9374500..34b8f54557d 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -293,3 +293,29 @@ 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::maybe_update (struct frame_info *fi, symtab_and_line sal, + int line_no, CORE_ADDR addr) +{ + int start_line = (line_no - (viewport_height / 2)) + 1; + if (start_line <= 0) + start_line = 1; + + bool source_already_displayed = (sal.symtab != 0 + && showing_source_p (fullname)); + + struct tui_line_or_address l; + + l.loa = LOA_LINE; + l.u.line_no = start_line; + if (!(source_already_displayed + && tui_line_is_displayed (line_no, this, TRUE))) + tui_update_source_window (this, get_frame_arch (fi), + sal.symtab, l, TRUE); + else + { + l.u.line_no = line_no; + set_is_exec_point_at (l); + } +} diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h index 49d79aba629..dc4470e9e5a 100644 --- a/gdb/tui/tui-source.h +++ b/gdb/tui/tui-source.h @@ -47,6 +47,10 @@ struct tui_source_window : public tui_source_window_base bool showing_source_p (const char *filename) const; + void maybe_update (struct frame_info *fi, symtab_and_line sal, + int line_no, CORE_ADDR addr) + override; + protected: void do_scroll_vertical (int num_to_scroll) override; diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index 1d7491dff93..09ee87f4027 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -364,7 +364,6 @@ tui_show_frame_info (struct frame_info *fi) if (fi) { struct tui_locator_window *locator = tui_locator_win_info_ptr (); - int source_already_displayed; CORE_ADDR pc; symtab_and_line sal = find_frame_sal (fi); @@ -373,10 +372,6 @@ tui_show_frame_info (struct frame_info *fi) if (sal.symtab != nullptr) fullname = symtab_to_fullname (sal.symtab); - source_already_displayed = (sal.symtab != 0 - && TUI_SRC_WIN != nullptr - && TUI_SRC_WIN->showing_source_p (fullname)); - if (get_frame_pc_if_available (fi, &pc)) locator_changed_p = tui_set_locator_info (get_frame_arch (fi), @@ -399,58 +394,7 @@ tui_show_frame_info (struct frame_info *fi) tui_show_locator_content (); for (struct tui_source_window_base *win_info : tui_source_windows ()) { - if (win_info == TUI_SRC_WIN) - { - int start_line = (locator->line_no - - (win_info->viewport_height / 2)) + 1; - if (start_line <= 0) - start_line = 1; - - struct tui_line_or_address l; - - l.loa = LOA_LINE; - l.u.line_no = start_line; - if (!(source_already_displayed - && tui_line_is_displayed (locator->line_no, - win_info, TRUE))) - tui_update_source_window (win_info, get_frame_arch (fi), - sal.symtab, l, TRUE); - else - { - l.u.line_no = locator->line_no; - win_info->set_is_exec_point_at (l); - } - } - else - { - CORE_ADDR low; - - if (find_pc_partial_function (get_frame_pc (fi), - NULL, &low, NULL) == 0) - { - /* There is no symbol available for current PC. There is no - safe way how to "disassemble backwards". */ - low = get_frame_pc (fi); - } - else - low = tui_get_low_disassembly_address (get_frame_arch (fi), - low, get_frame_pc (fi)); - - struct tui_line_or_address a; - - a.loa = LOA_ADDRESS; - a.u.addr = low; - if (!tui_addr_is_displayed (locator->addr, - win_info, TRUE)) - tui_update_source_window (win_info, get_frame_arch (fi), - sal.symtab, a, TRUE); - else - { - a.u.addr = locator->addr; - win_info->set_is_exec_point_at (a); - } - } - + win_info->maybe_update (fi, sal, locator->line_no, locator->addr); win_info->update_exec_info (); } diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index abb7ea34816..ed6cbec7626 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -23,6 +23,7 @@ #define TUI_TUI_WINSOURCE_H #include "tui/tui-data.h" +#include "symtab.h" /* Flags to tell what kind of breakpoint is at current line. */ enum tui_bp_flag @@ -116,6 +117,9 @@ public: void update_exec_info (); + virtual void maybe_update (struct frame_info *fi, symtab_and_line sal, + int line_no, CORE_ADDR addr) = 0; + /* Does the locator belong to this window? */ bool m_has_locator = false; /* Execution information window. */