From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 23AAE3858C52; Fri, 1 Apr 2022 00:05:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23AAE3858C52 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Style URLs in GDB output X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: d7abb2c4bd748e5fc54f3e2585fe295fb60300f0 X-Git-Newrev: 8839e3f3b0d1af5d93ba1d4f667ce33936bb7db2 Message-Id: <20220401000550.23AAE3858C52@sourceware.org> Date: Fri, 1 Apr 2022 00:05:50 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2022 00:05:50 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D8839e3f3b0d1= af5d93ba1d4f667ce33936bb7db2 commit 8839e3f3b0d1af5d93ba1d4f667ce33936bb7db2 Author: Tom Tromey Date: Wed Mar 9 17:26:37 2022 -0700 Style URLs in GDB output =20 I noticed that GDB will display URLs in a few spots. This changes them to be styled. Originally I thought I'd introduce a new "url" style, but there aren't many places to use this, so I just reused filename styling instead. This patch also changes the debuginfod URL list to be printed one URL per line. I think this is probably a bit easier to read. Diff: --- gdb/debuginfod-support.c | 25 +++++++++++++++++++++---- gdb/doc/gdb.texinfo | 2 +- gdb/main.c | 4 ++-- gdb/testsuite/gdb.base/style.exp | 5 +++-- gdb/top.c | 14 ++++++++++---- gdb/utils.c | 5 +++-- 6 files changed, 40 insertions(+), 15 deletions(-) diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index b3a49bfeccf..22944ce50bb 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -181,10 +181,27 @@ debuginfod_is_enabled () =20 if (debuginfod_enabled =3D=3D debuginfod_ask) { - int resp =3D nquery (_("\nThis GDB supports auto-downloading debugin= fo " \ - "from the following URLs:\n%s\nEnable debuginfod " \ - "for this session? "), - urls); + gdb_printf (_("\nThis GDB supports auto-downloading debuginfo " \ + "from the following URLs:\n")); + + gdb::string_view url_view (urls); + while (true) + { + url_view =3D url_view.substr (url_view.find_first_not_of (' ')); + if (url_view.empty ()) + break; + size_t off =3D url_view.find_first_of (' '); + gdb_printf + (_(" <%ps>\n"), + styled_string (file_name_style.style (), + gdb::to_string (url_view.substr (0, + off)).c_str ())); + if (off =3D=3D gdb::string_view::npos) + break; + url_view =3D url_view.substr (off); + } + + int resp =3D nquery (_("Enable debuginfod for this session? ")); if (!resp) { gdb_printf (_("Debuginfod has been disabled.\nTo make this " \ diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index a4afa75d967..d21fd0d3f0a 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26238,7 +26238,7 @@ their characteristics and the visual aspect of each= style. The style-able objects are: @table @code @item filename -Control the styling of file names. By default, this style's +Control the styling of file names and URLs. By default, this style's foreground color is green. =20 @item function diff --git a/gdb/main.c b/gdb/main.c index f53131da567..8c0807ff83b 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -1495,8 +1495,8 @@ GDB manual (available as on-line info or a printed ma= nual).\n\ "), stream); if (REPORT_BUGS_TO[0] && stream =3D=3D gdb_stdout) gdb_printf (stream, _("\n\ -Report bugs to %s.\n\ -"), REPORT_BUGS_TO); +Report bugs to %ps.\n\ +"), styled_string (file_name_style.style (), REPORT_BUGS_TO)); if (stream =3D=3D gdb_stdout) gdb_printf (stream, _("\n\ You can ask GDB-related questions on the GDB users mailing list\n\ diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/styl= e.exp index 68196d6e3e2..611b8ae52ba 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -309,8 +309,9 @@ proc run_style_tests { } { # Check that the version string is styled in the output of 'show # version', and that this styling can be disabled. set vers [style "GNU gdb.*" version] - gdb_test "show version" "${vers}.*" \ - "version is styled in 'show version'" + set url [limited_style "http:.*html" file] + gdb_test "show version" "${vers}.*<$url>.*" \ + "'show version' is styled" } } =20 diff --git a/gdb/top.c b/gdb/top.c index ecd31456f03..c7ff6744694 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1428,9 +1428,11 @@ print_gdb_version (struct ui_file *stream, bool inte= ractive) there is no warranty. */ =20 gdb_printf (stream, "\ -License GPLv3+: GNU GPL version 3 or later \ +License GPLv3+: GNU GPL version 3 or later <%ps>\ \nThis is free software: you are free to change and redistribute it.\n\ -There is NO WARRANTY, to the extent permitted by law."); +There is NO WARRANTY, to the extent permitted by law.", + styled_string (file_name_style.style (), + "http://gnu.org/licenses/gpl.html")); =20 if (!interactive) return; @@ -1459,11 +1461,15 @@ There is NO WARRANTY, to the extent permitted by la= w."); { gdb_printf (stream, _("For bug reporting instructions, please see:\n")); - gdb_printf (stream, "%s.\n", REPORT_BUGS_TO); + gdb_printf (stream, "%ps.\n", + styled_string (file_name_style.style (), + REPORT_BUGS_TO)); } gdb_printf (stream, _("Find the GDB manual and other documentation \ -resources online at:\n = .")); +resources online at:\n <%ps>."), + styled_string (file_name_style.style (), + "http://www.gnu.org/software/gdb/documentation/")); gdb_printf (stream, "\n\n"); gdb_printf (stream, _("For help, type \"help\".\n")); gdb_printf (stream, diff --git a/gdb/utils.c b/gdb/utils.c index 9ca268ad07f..68bf3a67340 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -404,8 +404,9 @@ internal_vproblem (struct internal_problem *problem, =20 gdb_puts (_("\nThis is a bug, please report it."), gdb_stderr); if (REPORT_BUGS_TO[0]) - gdb_printf (gdb_stderr, _(" For instructions, see:\n%s."), - REPORT_BUGS_TO); + gdb_printf (gdb_stderr, _(" For instructions, see:\n%ps."), + styled_string (file_name_style.style (), + REPORT_BUGS_TO)); gdb_puts ("\n\n", gdb_stderr); =20 if (problem->should_dump_core =3D=3D internal_problem_ask)