From patchwork Mon May 13 16:26:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32660 Received: (qmail 38717 invoked by alias); 13 May 2019 16:26:58 -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 38709 invoked by uid 89); 13 May 2019 16:26:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=ansi, HContent-Transfer-Encoding:8bit X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 May 2019 16:26:55 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CD0FE11644E; Mon, 13 May 2019 12:26:53 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7AAJfZiheUPL; Mon, 13 May 2019 12:26:53 -0400 (EDT) Received: from murgatroyd.Home (97-122-168-123.hlrn.qwest.net [97.122.168.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 7812211644D; Mon, 13 May 2019 12:26:53 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Add file name styling to "info sharedlibrary" Date: Mon, 13 May 2019 10:26:51 -0600 Message-Id: <20190513162651.18605-1-tromey@adacore.com> MIME-Version: 1.0 This changes "info sharedlibrary" to add styling to the file name. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-05-13 Tom Tromey * solib.c (info_sharedlibrary_command): Style the file name. gdb/testsuite/ChangeLog 2019-05-13 Tom Tromey * gdb.base/info-shared.exp (check_info_shared): Add "info shared" styling test. --- gdb/ChangeLog | 4 ++++ gdb/solib.c | 2 +- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/info-shared.exp | 24 ++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/gdb/solib.c b/gdb/solib.c index 25555af2939..e0b1a921f82 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1104,7 +1104,7 @@ info_sharedlibrary_command (const char *pattern, int from_tty) else uiout->field_string ("syms-read", so->symbols_loaded ? "Yes" : "No"); - uiout->field_string ("name", so->so_name); + uiout->field_string ("name", so->so_name, ui_out_style_kind::FILE); uiout->text ("\n"); } diff --git a/gdb/testsuite/gdb.base/info-shared.exp b/gdb/testsuite/gdb.base/info-shared.exp index eb5ee9562ef..e1314bf5dd7 100644 --- a/gdb/testsuite/gdb.base/info-shared.exp +++ b/gdb/testsuite/gdb.base/info-shared.exp @@ -144,3 +144,27 @@ check_info_shared "info sharedlibrary #7" 0 1 # Run to the last stop and check that both libraries are gone. gdb_continue_to_breakpoint "library unload #2" "\\.?stop .*" check_info_shared "info sharedlibrary #8" 0 0 + +with_test_prefix styled { + save_vars { env(TERM) } { + # We need an ANSI-capable terminal to get the output. + setenv TERM ansi + + clean_restart $testfile + + gdb_test_no_output "set style enabled off" + if {![runto_main]} { + return 0 + } + gdb_breakpoint "stop" + gdb_continue_to_breakpoint "library load #1" "\\.?stop .*" + + # Simple test for "info sharedlibrary" styling. Look for styled + # addresses and file name. + set addr "\033\\\[34m${hex}\033\\\[m" + set sofile "\033\\\[32m\[^\033\]+\033\\\[m" + gdb_test_no_output "set style enabled on" + gdb_test "info sharedlibrary" \ + "$addr\[ \t\]+$addr.*$sofile\r\n.*" + } +}