From patchwork Wed Nov 28 00:14:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 30349 Received: (qmail 28300 invoked by alias); 28 Nov 2018 00:14:51 -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 28142 invoked by uid 89); 28 Nov 2018 00:14:50 -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=H*RU:100.42.49.4, Hx-spam-relays-external:100.42.49.4, Hx-spam-relays-external:sk:cm10.we, H*RU:sk:cm10.we X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.148.164) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Nov 2018 00:14:42 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway34.websitewelcome.com (Postfix) with ESMTP id 1B9F81AC036 for ; Tue, 27 Nov 2018 18:14:41 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id RnV3gKSlxBcCXRnV3gPlPk; Tue, 27 Nov 2018 18:14:41 -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=FMhqWJVPH2rlHZ9RQMZC6eZOau3/vUNDqqiwgZyz6CY=; b=vwUGEgLxqeAOts1R9Eu//Y79bR h/8e8psSYNAp9FDmOnj91IRdnjbGVTUJkz+gYFXJDm+a7KGHCJykamZ0PtqdGGMCFBOe7Hakxvhav FmJBkU6v5+vmbQa7sMcy/m3Pw; 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 1gRnV2-004MMp-T2; Tue, 27 Nov 2018 18:14:40 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 12/16] Style addresses Date: Tue, 27 Nov 2018 17:14:31 -0700 Message-Id: <20181128001435.12703-13-tom@tromey.com> In-Reply-To: <20181128001435.12703-1-tom@tromey.com> References: <20181128001435.12703-1-tom@tromey.com> This changes gdb to style addresses. gdb/ChangeLog 2018-11-27 Tom Tromey * ui-out.h (enum class ui_out_style_kind)
: New constant. * ui-out.c (ui_out::field_core_addr): Add styling. * stack.c (print_frame): Add styling. * printcmd.c (print_address): Add styling. (print_address_demangle, info_address_command): Likewise. * cli/cli-style.h (address_style): Declare. * cli/cli-style.c (address_style): New global. (_initialize_cli_style): Register new commands. * cli-out.c (cli_ui_out::do_field_string): Update. gdb/testsuite/ChangeLog 2018-11-27 Tom Tromey * gdb.base/style.exp: Update test to check for address styling. --- gdb/ChangeLog | 13 ++++++++++++ gdb/cli-out.c | 3 +++ gdb/cli/cli-style.c | 11 ++++++++++ gdb/cli/cli-style.h | 3 +++ gdb/printcmd.c | 36 +++++++++++++++++++++----------- gdb/stack.c | 3 ++- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.base/style.exp | 2 +- gdb/ui-out.c | 3 ++- gdb/ui-out.h | 4 +++- 10 files changed, 66 insertions(+), 16 deletions(-) diff --git a/gdb/cli-out.c b/gdb/cli-out.c index e1005e1b35..691f993bad 100644 --- a/gdb/cli-out.c +++ b/gdb/cli-out.c @@ -176,6 +176,9 @@ cli_ui_out::do_field_string (int fldno, int width, ui_align align, case ui_out_style_kind::VARIABLE: fstyle = variable_name_style.style (); break; + case ui_out_style_kind::ADDRESS: + fstyle = address_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 fd4a4fc477..74e3958eb8 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -66,6 +66,10 @@ cli_style_option variable_name_style (ui_file_style::CYAN); /* See cli-style.h. */ +cli_style_option address_style (ui_file_style::BLUE); + +/* 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]), @@ -265,4 +269,11 @@ Variable name display styling\n\ Configure variable name colors and display intensity"), &style_set_list, &style_show_list); + address_style.add_setshow_commands ("address", no_class, + "style address", + _("\ +Address display styling\n\ +Configure address 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 3d5142e3de..b1e9e09d45 100644 --- a/gdb/cli/cli-style.h +++ b/gdb/cli/cli-style.h @@ -86,6 +86,9 @@ extern cli_style_option function_name_style; /* The variable name style. */ extern cli_style_option variable_name_style; +/* The address style. */ +extern cli_style_option address_style; + /* True if styling is enabled. */ extern int cli_styling; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index c5b6b1a75b..98f5b23ce5 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -693,7 +693,7 @@ void print_address (struct gdbarch *gdbarch, CORE_ADDR addr, struct ui_file *stream) { - fputs_filtered (paddress (gdbarch, addr), stream); + fputs_styled (paddress (gdbarch, addr), address_style.style (), stream); print_address_symbolic (gdbarch, addr, stream, asm_demangle, " "); } @@ -726,7 +726,7 @@ print_address_demangle (const struct value_print_options *opts, { if (opts->addressprint) { - fputs_filtered (paddress (gdbarch, addr), stream); + fputs_styled (paddress (gdbarch, addr), address_style.style (), stream); print_address_symbolic (gdbarch, addr, stream, do_demangle, " "); } else @@ -1404,14 +1404,17 @@ info_address_command (const char *exp, int from_tty) fprintf_symbol_filtered (gdb_stdout, exp, current_language->la_language, DMGL_ANSI); printf_filtered ("\" is at "); - fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); + fputs_styled (paddress (gdbarch, load_addr), address_style.style (), + gdb_stdout); printf_filtered (" in a file compiled without debugging"); section = MSYMBOL_OBJ_SECTION (objfile, msymbol.minsym); if (section_is_overlay (section)) { load_addr = overlay_unmapped_address (load_addr, section); printf_filtered (",\n -- loaded at "); - fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); + fputs_styled (paddress (gdbarch, load_addr), + address_style.style (), + gdb_stdout); printf_filtered (" in overlay section %s", section->the_bfd_section->name); } @@ -1451,12 +1454,14 @@ info_address_command (const char *exp, int from_tty) case LOC_LABEL: printf_filtered ("a label at address "); load_addr = SYMBOL_VALUE_ADDRESS (sym); - fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); + fputs_styled (paddress (gdbarch, load_addr), address_style.style (), + gdb_stdout); if (section_is_overlay (section)) { load_addr = overlay_unmapped_address (load_addr, section); printf_filtered (",\n -- loaded at "); - fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); + fputs_styled (paddress (gdbarch, load_addr), address_style.style (), + gdb_stdout); printf_filtered (" in overlay section %s", section->the_bfd_section->name); } @@ -1485,12 +1490,14 @@ info_address_command (const char *exp, int from_tty) case LOC_STATIC: printf_filtered (_("static storage at address ")); load_addr = SYMBOL_VALUE_ADDRESS (sym); - fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); + fputs_styled (paddress (gdbarch, load_addr), address_style.style (), + gdb_stdout); if (section_is_overlay (section)) { load_addr = overlay_unmapped_address (load_addr, section); printf_filtered (_(",\n -- loaded at ")); - fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); + fputs_styled (paddress (gdbarch, load_addr), address_style.style (), + gdb_stdout); printf_filtered (_(" in overlay section %s"), section->the_bfd_section->name); } @@ -1522,12 +1529,14 @@ info_address_command (const char *exp, int from_tty) case LOC_BLOCK: printf_filtered (_("a function at address ")); load_addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)); - fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); + fputs_styled (paddress (gdbarch, load_addr), address_style.style (), + gdb_stdout); if (section_is_overlay (section)) { load_addr = overlay_unmapped_address (load_addr, section); printf_filtered (_(",\n -- loaded at ")); - fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); + fputs_styled (paddress (gdbarch, load_addr), address_style.style (), + gdb_stdout); printf_filtered (_(" in overlay section %s"), section->the_bfd_section->name); } @@ -1557,12 +1566,15 @@ info_address_command (const char *exp, int from_tty) { load_addr = BMSYMBOL_VALUE_ADDRESS (msym); printf_filtered (_("static storage at address ")); - fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); + fputs_styled (paddress (gdbarch, load_addr), + address_style.style (), gdb_stdout); if (section_is_overlay (section)) { load_addr = overlay_unmapped_address (load_addr, section); printf_filtered (_(",\n -- loaded at ")); - fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); + fputs_styled (paddress (gdbarch, load_addr), + address_style.style (), + gdb_stdout); printf_filtered (_(" in overlay section %s"), section->the_bfd_section->name); } diff --git a/gdb/stack.c b/gdb/stack.c index 930d7d0b1e..819bb616f0 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1176,7 +1176,8 @@ print_frame (struct frame_info *frame, int print_level, if (pc_p) uiout->field_core_addr ("addr", gdbarch, pc); else - uiout->field_string ("addr", ""); + uiout->field_string ("addr", "", + ui_out_style_kind::ADDRESS); annotate_frame_address_end (); uiout->text (" in "); } diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index a44d78f236..b633340afe 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -43,7 +43,7 @@ save_vars { env(TERM) } { gdb_test "break main" "file $base_file_expr.*" - gdb_test "print &main" " = .* <$main_expr>" + gdb_test "print &main" " = .* \033\\\[34m$hex\033\\\[m <$main_expr>" gdb_exit gdb_spawn diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 761d6c0745..49f04dd936 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -469,7 +469,8 @@ void ui_out::field_core_addr (const char *fldname, struct gdbarch *gdbarch, CORE_ADDR address) { - field_string (fldname, print_core_address (gdbarch, address)); + field_string (fldname, print_core_address (gdbarch, address), + ui_out_style_kind::ADDRESS); } void diff --git a/gdb/ui-out.h b/gdb/ui-out.h index 93be9a91b2..96466d8023 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -77,7 +77,9 @@ enum class ui_out_style_kind /* Function name. */ FUNCTION, /* Variable name. */ - VARIABLE + VARIABLE, + /* Address. */ + ADDRESS }; class ui_out