From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27565 invoked by alias); 28 Nov 2018 00:14:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 27427 invoked by uid 89); 28 Nov 2018 00:14:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_STOCKGEN,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=yellow, Style, Configure X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.48.104) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Nov 2018 00:14:40 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway23.websitewelcome.com (Postfix) with ESMTP id ADBA841E3 for ; Tue, 27 Nov 2018 18:14:39 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id RnV1gAfwOPvAdRnV1gqWF3; Tue, 27 Nov 2018 18:14:39 -0600 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=SUDih1pnmDtHQ+s7S0at1eLHjJLp2m8qUTqF/nq7WI0=; b=PAAzhVXw5Wgg6p3oFYyK1YmopT GCiG9pdkS7s0hqwUmwM8B6tGA9gO0pV72X/kArjmfST6/bcGrtLKm9shABZnU8/FFjnZHKo8HOCd9 LgLPVqfPQvQHe59L6wVUS9qzL; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:33804 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gRnV1-004MMp-Fl; Tue, 27 Nov 2018 18:14:39 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 07/16] Style variable names Date: Wed, 28 Nov 2018 00:16:00 -0000 Message-Id: <20181128001435.12703-8-tom@tromey.com> In-Reply-To: <20181128001435.12703-1-tom@tromey.com> References: <20181128001435.12703-1-tom@tromey.com> X-SW-Source: 2018-11/txt/msg00505.txt.bz2 This adds style support for variable names. For the time being, this is only done in backtraces, not in ptype or print; those places do not use ui-out and so would need ad hoc changes. This also adds styling to the names printed for local variables in "backtrace full". This code does not use ui-out, so the styling is done using the low-level API. gdb/ChangeLog 2018-11-27 Tom Tromey * ui-out.h (enum class ui_out_style_kind) : New global. * stack.c (print_frame_arg): Style name. * printcmd.c (print_variable_and_value): Style variable name. * cli/cli-style.h (variable_name_style): Declare. * cli/cli-style.c (variable_name_style): New global. (_initialize_cli_style): Update. * cli-out.c (cli_ui_out::do_field_string): Update. gdb/testsuite/ChangeLog 2018-11-27 Tom Tromey * gdb.base/style.exp: Add test for variable names. --- gdb/ChangeLog | 10 ++++++++++ gdb/cli-out.c | 3 +++ gdb/cli/cli-style.c | 11 +++++++++++ gdb/cli/cli-style.h | 3 +++ gdb/printcmd.c | 6 +++++- gdb/stack.c | 2 +- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.base/style.exp | 3 ++- gdb/ui-out.h | 4 +++- 9 files changed, 42 insertions(+), 4 deletions(-) diff --git a/gdb/cli-out.c b/gdb/cli-out.c index 4b5fc17390..e1005e1b35 100644 --- a/gdb/cli-out.c +++ b/gdb/cli-out.c @@ -173,6 +173,9 @@ cli_ui_out::do_field_string (int fldno, int width, ui_align align, case ui_out_style_kind::FUNCTION: fstyle = function_name_style.style (); break; + case ui_out_style_kind::VARIABLE: + fstyle = variable_name_style.style (); + break; default: gdb_assert_not_reached ("missing case"); } diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c index de2866ce75..fd4a4fc477 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -62,6 +62,10 @@ cli_style_option function_name_style (ui_file_style::YELLOW); /* See cli-style.h. */ +cli_style_option variable_name_style (ui_file_style::CYAN); + +/* See cli-style.h. */ + cli_style_option::cli_style_option (ui_file_style::simple_color fg) : m_foreground (cli_colors[fg - ui_file_style::NONE]), m_background (cli_colors[0]), @@ -254,4 +258,11 @@ Configure function name colors and display intensity"), "style function", &style_set_list, &style_show_list); + variable_name_style.add_setshow_commands ("variable", no_class, + "style variable", + _("\ +Variable name display styling\n\ +Configure variable name colors and display intensity"), + &style_set_list, + &style_show_list); } diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h index 36845b2581..3d5142e3de 100644 --- a/gdb/cli/cli-style.h +++ b/gdb/cli/cli-style.h @@ -83,6 +83,9 @@ extern cli_style_option file_name_style; /* The function name style. */ extern cli_style_option function_name_style; +/* The variable name style. */ +extern cli_style_option variable_name_style; + /* True if styling is enabled. */ extern int cli_styling; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 79c3d2d2ff..dd1626455b 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -46,6 +46,7 @@ #include "arch-utils.h" #include "cli/cli-utils.h" #include "cli/cli-script.h" +#include "cli/cli-style.h" #include "format.h" #include "source.h" #include "common/byte-vector.h" @@ -2156,7 +2157,10 @@ print_variable_and_value (const char *name, struct symbol *var, if (!name) name = SYMBOL_PRINT_NAME (var); - fprintf_filtered (stream, "%s%s = ", n_spaces (2 * indent), name); + fputs_filtered (n_spaces (2 * indent), stream); + fputs_styled (name, variable_name_style.style (), stream); + fputs_filtered (" = ", stream); + TRY { struct value *val; diff --git a/gdb/stack.c b/gdb/stack.c index a718bf8901..930d7d0b1e 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -256,7 +256,7 @@ print_frame_arg (const struct frame_arg *arg) if (arg->entry_kind == print_entry_values_only || arg->entry_kind == print_entry_values_compact) stb.puts ("@entry"); - uiout->field_stream ("name", stb); + uiout->field_stream ("name", stb, ui_out_style_kind::VARIABLE); annotate_arg_name_end (); uiout->text ("="); diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index 859e50352f..1ab9d68431 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -34,8 +34,9 @@ save_vars { env(TERM) } { set main_expr "\033\\\[33mmain\033\\\[m" set file_expr "\033\\\[32m.*style\\.c\033\\\[m:\[0-9\]" + set arg_expr "\033\\\[36marg.\033\\\[m" gdb_test "frame" \ - "$main_expr.*$file_expr.*" + "$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*" gdb_test "info breakpoints" "$main_expr at $file_expr.*" } diff --git a/gdb/ui-out.h b/gdb/ui-out.h index 8604105c09..93be9a91b2 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -75,7 +75,9 @@ enum class ui_out_style_kind /* File name. */ FILE, /* Function name. */ - FUNCTION + FUNCTION, + /* Variable name. */ + VARIABLE }; class ui_out -- 2.17.2