From patchwork Tue Sep 10 19:08:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34477 Received: (qmail 25991 invoked by alias); 10 Sep 2019 19:09:10 -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 25697 invoked by uid 89); 10 Sep 2019 19:09:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.7 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: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.45.159) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Sep 2019 19:09:05 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway21.websitewelcome.com (Postfix) with ESMTP id B5164400C9D14 for ; Tue, 10 Sep 2019 14:09:01 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 7lVdi5wWjdnCe7lVdiR97q; Tue, 10 Sep 2019 14:09:01 -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=HMO0RTn1LZRw7zwJFFwdl4YShr9viBRcQ7Sf6Z2416w=; b=OHxgtp2W/VLSno/2jifcAsPc7O WJDbKzK389S0XfVbFvemwDh7CLPR3P69gMObEm121FJanjmQ43y1dIssQUlcp2SJLETu3psJLd0IV gi9ftzSMxtqwAgAN+HFHS/1hP; Received: from 71-218-73-27.hlrn.qwest.net ([71.218.73.27]:51786 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1i7lVd-000EYF-6m; Tue, 10 Sep 2019 14:09:01 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 05/20] Change tui_make_status_line to be a method Date: Tue, 10 Sep 2019 13:08:42 -0600 Message-Id: <20190910190857.6562-6-tom@tromey.com> In-Reply-To: <20190910190857.6562-1-tom@tromey.com> References: <20190910190857.6562-1-tom@tromey.com> This changes tui_make_status_line to be a method on tui_locator_window. This is a minor cleanup. This also changes the new method to use the locator's width, rather than the terminal width. This is important if we ever want to allow windows to be made more narrow. gdb/ChangeLog 2019-09-10 Tom Tromey * tui/tui-stack.h (struct tui_locator_window) : Declare. * tui/tui-stack.c (tui_locator_window::make_status_line): Rename from tui_make_status_line. (tui_locator_window::rerender): Update. --- gdb/ChangeLog | 8 ++++++++ gdb/tui/tui-stack.c | 30 ++++++++++++------------------ gdb/tui/tui-stack.h | 8 ++++++++ 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index a2e4a161bb7..163a5ad7255 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -63,13 +63,10 @@ tui_locator_win_info_ptr (void) return &_locator; } -/* Create the status line to display as much information as we can on - this single line: target name, process number, current function, - current line, current PC, SingleKey mode. */ -static std::string -tui_make_status_line (struct tui_locator_window *loc) +std::string +tui_locator_window::make_status_line () const { - char line_buf[50], *pname; + char line_buf[50]; int status_size; int proc_width; const char *pid_name; @@ -94,11 +91,11 @@ tui_make_status_line (struct tui_locator_window *loc) if (pid_width > MAX_PID_WIDTH) pid_width = MAX_PID_WIDTH; - status_size = tui_term_width (); + status_size = width; /* Translate line number and obtain its size. */ - if (loc->line_no > 0) - xsnprintf (line_buf, sizeof (line_buf), "%d", loc->line_no); + if (line_no > 0) + xsnprintf (line_buf, sizeof (line_buf), "%d", line_no); else strcpy (line_buf, "??"); line_width = strlen (line_buf); @@ -106,8 +103,8 @@ tui_make_status_line (struct tui_locator_window *loc) line_width = MIN_LINE_WIDTH; /* Translate PC address. */ - std::string pc_out (loc->gdbarch - ? paddress (loc->gdbarch, loc->addr) + std::string pc_out (gdbarch + ? paddress (gdbarch, addr) : "??"); const char *pc_buf = pc_out.c_str (); int pc_width = pc_out.size (); @@ -150,9 +147,6 @@ tui_make_status_line (struct tui_locator_window *loc) } } - /* Now convert elements to string form. */ - pname = loc->proc_name; - /* Now create the locator line from the string version of the elements. */ string_file string; @@ -172,12 +166,12 @@ tui_make_status_line (struct tui_locator_window *loc) /* Procedure/class name. */ if (proc_width > 0) { - if (strlen (pname) > proc_width) + if (strlen (proc_name) > proc_width) string.printf ("%s%*.*s* ", PROC_PREFIX, - 1 - proc_width, proc_width - 1, pname); + 1 - proc_width, proc_width - 1, proc_name); else string.printf ("%s%*.*s ", PROC_PREFIX, - -proc_width, proc_width, pname); + -proc_width, proc_width, proc_name); } if (line_width > 0) @@ -234,7 +228,7 @@ tui_locator_window::rerender () { if (handle != NULL) { - std::string string = tui_make_status_line (this); + std::string string = make_status_line (); wmove (handle, 0, 0); /* We ignore the return value from wstandout and wstandend, casting them to void in order to avoid a compiler warning. The warning diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h index 86239b0d284..b6ffa986a6f 100644 --- a/gdb/tui/tui-stack.h +++ b/gdb/tui/tui-stack.h @@ -63,6 +63,14 @@ struct tui_locator_window : public tui_gen_win_info CORE_ADDR addr = 0; /* Architecture associated with code at this location. */ struct gdbarch *gdbarch = nullptr; + +private: + + /* Create the status line to display as much information as we can + on this single line: target name, process number, current + function, current line, current PC, SingleKey mode. */ + + std::string make_status_line () const; }; extern void tui_update_locator_fullname (const char *);