From patchwork Wed Aug 14 16:21:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34096 Received: (qmail 71888 invoked by alias); 14 Aug 2019 16:21:43 -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 71626 invoked by uid 89); 14 Aug 2019 16:21:41 -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=dimensions X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.143.31) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Aug 2019 16:21:39 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway31.websitewelcome.com (Postfix) with ESMTP id E98FC108A4 for ; Wed, 14 Aug 2019 11:21:37 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id xw1phG3ri90onxw1ph4e3m; Wed, 14 Aug 2019 11:21:37 -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=J/Z/zyFDxYWd+X9VJfv7u3oF1RYVoyF7amV2V/UCY6Y=; b=sfmxUCuhCnRu+FWkTQZORS01Sc hRsYCpCxllaU03IsaDRvmZrjoHQPO3HaKiIcAKvM+R8bTD5YrgPec+xs/PyIKkj8u3hLRQzQfLTsG 8+QxUhgzwTvYArvCALAQAEZqR; 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 1hxw1p-002Cwq-Mz; Wed, 14 Aug 2019 11:21:37 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 08/15] Remove tui_alloc_source_buffer Date: Wed, 14 Aug 2019 10:21:25 -0600 Message-Id: <20190814162132.31424-9-tom@tromey.com> In-Reply-To: <20190814162132.31424-1-tom@tromey.com> References: <20190814162132.31424-1-tom@tromey.com> There is no longer any need for tui_alloc_source_buffer. The two callers of this function immediately change the contents of the window, undoing the work done by this function. This required adding a move constructor to tui_source_element -- a mildly surprising find, but without this, resizing the vector will cause crashes. This issue was masked earlier because tui_alloc_source_buffer handled this. Note that a patch for this bug was submitted here: https://sourceware.org/ml/gdb-patches/2019-08/msg00094.html That patch is better, IMO, but the author as yet hasn't responded to a request for a ChangeLog entry. gdb/ChangeLog 2019-08-14 Tom Tromey * tui/tui-winsource.h (tui_alloc_source_buffer): Don't declare. (struct tui_source_element): Add DISABLE_COPY_AND_ASSIGN, and move constructor. * tui/tui-winsource.c (tui_alloc_source_buffer): Remove. * tui/tui-source.c (tui_set_source_content): Update. * tui/tui-disasm.c (tui_set_disassem_content): Update. --- gdb/ChangeLog | 9 +++++++++ gdb/tui/tui-disasm.c | 2 -- gdb/tui/tui-source.c | 1 - gdb/tui/tui-winsource.c | 20 -------------------- gdb/tui/tui-winsource.h | 14 +++++++++++--- 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index e55f35da214..23943947085 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -179,8 +179,6 @@ tui_set_disassem_content (tui_source_window_base *win_info, if (pc == 0) return TUI_FAILURE; - tui_alloc_source_buffer (win_info); - win_info->gdbarch = gdbarch; win_info->start_line_or_addr.loa = LOA_ADDRESS; win_info->start_line_or_addr.u.addr = pc; diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 7c173f8a6f9..3d88f66d549 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -135,7 +135,6 @@ tui_set_source_content (tui_source_window_base *win_info, int line_width, nlines; ret = TUI_SUCCESS; - tui_alloc_source_buffer (win_info); line_width = win_info->width - 1; /* Take hilite (window border) into account, when calculating the number of lines. */ diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index a85269657cf..121f19abd8b 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -620,23 +620,3 @@ tui_source_window_base::update_exec_info () } execution_info->refresh_window (); } - - -void -tui_alloc_source_buffer (struct tui_source_window_base *win_info) -{ - int i, line_width, max_lines; - - /* The window width/height includes the highlight box. Determine actual - content dimensions, including string null-terminators. */ - max_lines = win_info->height - 2; - line_width = win_info->width - 2 + 1; - - /* Allocate the buffer for the source lines. */ - win_info->content.resize (max_lines); - for (i = 0; i < max_lines; i++) - { - if (win_info->content[i].line == nullptr) - win_info->content[i].line = (char *) xmalloc (line_width); - } -} diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index f88f6b7de45..320c8370166 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -69,6 +69,17 @@ struct tui_source_element xfree (line); } + DISABLE_COPY_AND_ASSIGN (tui_source_element); + + tui_source_element (tui_source_element &&other) + : line (other.line), + line_or_addr (other.line_or_addr), + is_exec_point (other.is_exec_point), + break_mode (other.break_mode) + { + other.line = nullptr; + } + char *line = nullptr; struct tui_line_or_address line_or_addr; bool is_exec_point = false; @@ -171,9 +182,6 @@ extern void tui_update_source_windows_with_line (struct symtab *, extern void tui_clear_source_content (struct tui_source_window_base *); extern void tui_erase_source_content (struct tui_source_window_base *); -extern void tui_alloc_source_buffer (struct tui_source_window_base *); - - /* Constant definitions. */ #define SCROLL_THRESHOLD 2 /* Threshold for lazy scroll. */