From patchwork Sun Jun 23 22:42:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33311 Received: (qmail 56499 invoked by alias); 23 Jun 2019 23:25:50 -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 56411 invoked by uid 89); 23 Jun 2019 23:25:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.8 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=UD:line X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.144.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Jun 2019 23:25:48 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway30.websitewelcome.com (Postfix) with ESMTP id F353E29E66 for ; Sun, 23 Jun 2019 18:25:46 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id fBrmhMCNg4FKpfBrmhcnMW; Sun, 23 Jun 2019 18:25:46 -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=Tbe6B6vsK9Cj2p8xWqSu4Kd02e4wQSxT+JAsqdoW2aw=; b=Tqu/9NkEKzsnGdHHjnJnqcFIgA IkH8/0xtMCWWW4r1tc+r1A4o2Fns2U+crl6ezJvBlOqWkoLIdwRPAR/XzJ0zkUAYZI0TFT9U7h0ci HZqF6ou1oC8AaNuEZNW0+F3L4; Received: from 75-166-12-78.hlrn.qwest.net ([75.166.12.78]:54396 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hfBD9-000vDQ-W4; Sun, 23 Jun 2019 17:43:48 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 36/66] Change tui_alloc_source_buffer return type to void Date: Sun, 23 Jun 2019 16:42:59 -0600 Message-Id: <20190623224329.16060-37-tom@tromey.com> In-Reply-To: <20190623224329.16060-1-tom@tromey.com> References: <20190623224329.16060-1-tom@tromey.com> tui_alloc_source_buffer can't actually fail, so change its return type to void and update the callers. 2019-06-23 Tom Tromey * tui/tui-winsource.h (tui_alloc_source_buffer): Change return type to void. * tui/tui-winsource.c (tui_alloc_source_buffer): Change return type to void. * 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 | 5 +- gdb/tui/tui-source.c | 149 ++++++++++++++++++++-------------------- gdb/tui/tui-winsource.c | 4 +- gdb/tui/tui-winsource.h | 2 +- 5 files changed, 86 insertions(+), 83 deletions(-) diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index a9d827f5b78..0bc7c642bcd 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -165,7 +165,6 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) enum tui_status tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc) { - enum tui_status ret = TUI_FAILURE; int i; int offset = TUI_DISASM_WIN->horizontal_offset; int max_lines, line_width; @@ -180,9 +179,7 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc) if (pc == 0) return TUI_FAILURE; - ret = tui_alloc_source_buffer (TUI_DISASM_WIN); - if (ret != TUI_SUCCESS) - return ret; + tui_alloc_source_buffer (TUI_DISASM_WIN); tui_source_window_base *base = TUI_DISASM_WIN; base->gdbarch = gdbarch; diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index c6367765d67..39abe81a870 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -133,86 +133,85 @@ tui_set_source_content (struct symtab *s, { int line_width, nlines; - if ((ret = tui_alloc_source_buffer (TUI_SRC_WIN)) == TUI_SUCCESS) + ret = TUI_SUCCESS; + tui_alloc_source_buffer (TUI_SRC_WIN); + line_width = TUI_SRC_WIN->width - 1; + /* Take hilite (window border) into account, when + calculating the number of lines. */ + nlines = (line_no + (TUI_SRC_WIN->height - 2)) - line_no; + + std::string srclines; + if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines, + &srclines)) { - line_width = TUI_SRC_WIN->width - 1; - /* Take hilite (window border) into account, when - calculating the number of lines. */ - nlines = (line_no + (TUI_SRC_WIN->height - 2)) - line_no; - - std::string srclines; - if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines, - &srclines)) + if (!noerror) { - if (!noerror) - { - const char *filename = symtab_to_filename_for_display (s); - char *name = (char *) alloca (strlen (filename) + 100); - - sprintf (name, "%s:%d", filename, line_no); - print_sys_errmsg (name, errno); - } - ret = TUI_FAILURE; + const char *filename = symtab_to_filename_for_display (s); + char *name = (char *) alloca (strlen (filename) + 100); + + sprintf (name, "%s:%d", filename, line_no); + print_sys_errmsg (name, errno); } - else + ret = TUI_FAILURE; + } + else + { + int cur_line_no, cur_line; + struct tui_gen_win_info *locator + = tui_locator_win_info_ptr (); + struct tui_source_window_base *src + = (struct tui_source_window_base *) TUI_SRC_WIN; + const char *s_filename = symtab_to_filename_for_display (s); + + if (TUI_SRC_WIN->title) + xfree (TUI_SRC_WIN->title); + TUI_SRC_WIN->title = xstrdup (s_filename); + + xfree (src->fullname); + src->fullname = xstrdup (symtab_to_fullname (s)); + + cur_line = 0; + src->gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s)); + src->start_line_or_addr.loa = LOA_LINE; + cur_line_no = src->start_line_or_addr.u.line_no = line_no; + + const char *iter = srclines.c_str (); + while (cur_line < nlines) { - int cur_line_no, cur_line; - struct tui_gen_win_info *locator - = tui_locator_win_info_ptr (); - struct tui_source_window_base *src - = (struct tui_source_window_base *) TUI_SRC_WIN; - const char *s_filename = symtab_to_filename_for_display (s); - - if (TUI_SRC_WIN->title) - xfree (TUI_SRC_WIN->title); - TUI_SRC_WIN->title = xstrdup (s_filename); - - xfree (src->fullname); - src->fullname = xstrdup (symtab_to_fullname (s)); - - cur_line = 0; - src->gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s)); - src->start_line_or_addr.loa = LOA_LINE; - cur_line_no = src->start_line_or_addr.u.line_no = line_no; - - const char *iter = srclines.c_str (); - while (cur_line < nlines) - { - struct tui_win_element *element - = TUI_SRC_WIN->content[cur_line]; - - std::string text; - if (*iter != '\0') - text = copy_source_line (&iter, cur_line_no, - src->horizontal_offset, - line_width); - - /* Set whether element is the execution point - and whether there is a break point on it. */ - element->which_element.source.line_or_addr.loa = - LOA_LINE; - element->which_element.source.line_or_addr.u.line_no = - cur_line_no; - element->which_element.source.is_exec_point = - (filename_cmp (locator->content[0] - ->which_element.locator.full_name, - symtab_to_fullname (s)) == 0 - && cur_line_no - == locator->content[0] - ->which_element.locator.line_no); - - xfree (TUI_SRC_WIN->content[cur_line] - ->which_element.source.line); - TUI_SRC_WIN->content[cur_line] - ->which_element.source.line - = xstrdup (text.c_str ()); - - cur_line++; - cur_line_no++; - } - TUI_SRC_WIN->content_size = nlines; - ret = TUI_SUCCESS; + struct tui_win_element *element + = TUI_SRC_WIN->content[cur_line]; + + std::string text; + if (*iter != '\0') + text = copy_source_line (&iter, cur_line_no, + src->horizontal_offset, + line_width); + + /* Set whether element is the execution point + and whether there is a break point on it. */ + element->which_element.source.line_or_addr.loa = + LOA_LINE; + element->which_element.source.line_or_addr.u.line_no = + cur_line_no; + element->which_element.source.is_exec_point = + (filename_cmp (locator->content[0] + ->which_element.locator.full_name, + symtab_to_fullname (s)) == 0 + && cur_line_no + == locator->content[0] + ->which_element.locator.line_no); + + xfree (TUI_SRC_WIN->content[cur_line] + ->which_element.source.line); + TUI_SRC_WIN->content[cur_line] + ->which_element.source.line + = xstrdup (text.c_str ()); + + cur_line++; + cur_line_no++; } + TUI_SRC_WIN->content_size = nlines; + ret = TUI_SUCCESS; } } return ret; diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 1ec9cecdc9c..209d33d6c99 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -589,7 +589,7 @@ tui_update_exec_info (struct tui_win_info *win_info) tui_show_exec_info_content (win_info); } -enum tui_status +void tui_alloc_source_buffer (struct tui_win_info *win_info) { int i, line_width, max_lines; @@ -608,8 +608,6 @@ tui_alloc_source_buffer (struct tui_win_info *win_info) win_info->content[i]->which_element.source.line = (char *) xmalloc (line_width); } - - return TUI_SUCCESS; } diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index 6f2dc3533f7..ccc9ae5f68a 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -59,7 +59,7 @@ extern void tui_erase_exec_info_content (struct tui_win_info *); extern void tui_clear_exec_info_content (struct tui_win_info *); extern void tui_update_exec_info (struct tui_win_info *); -extern enum tui_status tui_alloc_source_buffer (struct tui_win_info *); +extern void tui_alloc_source_buffer (struct tui_win_info *); extern int tui_line_is_displayed (int, struct tui_win_info *, int);