* [PATCH] Style URLs in GDB output @ 2022-03-10 0:31 Tom Tromey 2022-03-10 6:38 ` Eli Zaretskii 2022-03-10 7:15 ` Aktemur, Tankut Baris 0 siblings, 2 replies; 5+ messages in thread From: Tom Tromey @ 2022-03-10 0:31 UTC (permalink / raw) To: gdb-patches; +Cc: Tom Tromey 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. --- gdb/debuginfod-support.c | 25 +++++++++++++++++++++---- gdb/doc/gdb.texinfo | 2 +- gdb/testsuite/gdb.base/style.exp | 5 +++-- gdb/top.c | 10 +++++++--- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index b44ce67c340..d4255a5d2b3 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -164,10 +164,27 @@ debuginfod_is_enabled () if (debuginfod_enabled == debuginfod_ask) { - int resp = nquery (_("\nThis GDB supports auto-downloading debuginfo " \ - "from the following URLs:\n%s\nEnable debuginfod " \ - "for this session? "), - urls); + printf_filtered (_("\nThis GDB supports auto-downloading debuginfo " \ + "from the following URLs:\n")); + + gdb::string_view url_view (urls); + while (true) + { + url_view = url_view.substr (url_view.find_first_not_of (' ')); + if (url_view.empty ()) + break; + size_t off = url_view.find_first_of (' '); + printf_filtered + (_(" <%ps>\n"), + styled_string (file_name_style.style (), + gdb::to_string (url_view.substr (0, + off)).c_str ())); + if (off == gdb::string_view::npos) + break; + url_view = url_view.substr (off); + } + + int resp = nquery (_("Enable debuginfod for this session? ")); if (!resp) { printf_filtered (_("Debuginfod has been disabled.\nTo make this " \ diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index e61cef36a2d..6e0d0e1f26f 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26239,7 +26239,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. @item function diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.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" } } diff --git a/gdb/top.c b/gdb/top.c index a94ed5cebdb..3a3a697fd1c 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1443,9 +1443,11 @@ print_gdb_version (struct ui_file *stream, bool interactive) there is no warranty. */ fprintf_filtered (stream, "\ -License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\ +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")); if (!interactive) return; @@ -1478,7 +1480,9 @@ There is NO WARRANTY, to the extent permitted by law."); } fprintf_filtered (stream, _("Find the GDB manual and other documentation \ -resources online at:\n <http://www.gnu.org/software/gdb/documentation/>.")); +resources online at:\n <%ps>."), + styled_string (file_name_style.style (), + "http://www.gnu.org/software/gdb/documentation/")); fprintf_filtered (stream, "\n\n"); fprintf_filtered (stream, _("For help, type \"help\".\n")); fprintf_filtered (stream, -- 2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Style URLs in GDB output 2022-03-10 0:31 [PATCH] Style URLs in GDB output Tom Tromey @ 2022-03-10 6:38 ` Eli Zaretskii 2022-03-10 7:15 ` Aktemur, Tankut Baris 1 sibling, 0 replies; 5+ messages in thread From: Eli Zaretskii @ 2022-03-10 6:38 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches > From: Tom Tromey <tom@tromey.com> > Date: Wed, 9 Mar 2022 17:31:52 -0700 > Cc: Tom Tromey <tom@tromey.com> > > 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. File-name styling for URLs is fine, IMO. We don't need to invent a new style. > gdb/debuginfod-support.c | 25 +++++++++++++++++++++---- > gdb/doc/gdb.texinfo | 2 +- > gdb/testsuite/gdb.base/style.exp | 5 +++-- > gdb/top.c | 10 +++++++--- > 4 files changed, 32 insertions(+), 10 deletions(-) The documentation part of the patch is OK, thanks. ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] Style URLs in GDB output 2022-03-10 0:31 [PATCH] Style URLs in GDB output Tom Tromey 2022-03-10 6:38 ` Eli Zaretskii @ 2022-03-10 7:15 ` Aktemur, Tankut Baris 2022-03-15 21:19 ` Tom Tromey 1 sibling, 1 reply; 5+ messages in thread From: Aktemur, Tankut Baris @ 2022-03-10 7:15 UTC (permalink / raw) To: Tom Tromey, gdb-patches On Thursday, March 10, 2022 1:32 AM, Tom Tromey wrote: > 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. There is REPORT_BUGS_TO printed in a few places. I think it's a URL, too. Thanks -Baris Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Style URLs in GDB output 2022-03-10 7:15 ` Aktemur, Tankut Baris @ 2022-03-15 21:19 ` Tom Tromey 2022-03-31 23:56 ` Tom Tromey 0 siblings, 1 reply; 5+ messages in thread From: Tom Tromey @ 2022-03-15 21:19 UTC (permalink / raw) To: Aktemur, Tankut Baris; +Cc: Tom Tromey, gdb-patches > There is REPORT_BUGS_TO printed in a few places. I think it's a URL, > too. Thanks for noticing that. I've appended an updated patch. This touches the --help output, and looking at that, I see a few more things that probably should be styled. I can do that later though. Tom commit 2971cfbf60c5e727acdc7d70f0820dc043fde405 Author: Tom Tromey <tom@tromey.com> Date: Wed Mar 9 17:26:37 2022 -0700 Style URLs in GDB output 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 --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index e077e136614..1e76f380a61 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -164,10 +164,27 @@ debuginfod_is_enabled () if (debuginfod_enabled == debuginfod_ask) { - int resp = nquery (_("\nThis GDB supports auto-downloading debuginfo " \ - "from the following URLs:\n%s\nEnable debuginfod " \ - "for this session? "), - urls); + printf_filtered (_("\nThis GDB supports auto-downloading debuginfo " \ + "from the following URLs:\n")); + + gdb::string_view url_view (urls); + while (true) + { + url_view = url_view.substr (url_view.find_first_not_of (' ')); + if (url_view.empty ()) + break; + size_t off = url_view.find_first_of (' '); + printf_filtered + (_(" <%ps>\n"), + styled_string (file_name_style.style (), + gdb::to_string (url_view.substr (0, + off)).c_str ())); + if (off == gdb::string_view::npos) + break; + url_view = url_view.substr (off); + } + + int resp = nquery (_("Enable debuginfod for this session? ")); if (!resp) { printf_filtered (_("Debuginfod has been disabled.\nTo make this " \ diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index d216fa1d529..f5b1cc90fb1 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26241,7 +26241,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. @item function diff --git a/gdb/main.c b/gdb/main.c index 73fdff25018..4505e783d28 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -1507,8 +1507,8 @@ GDB manual (available as on-line info or a printed manual).\n\ "), stream); if (REPORT_BUGS_TO[0] && stream == gdb_stdout) fprintf_unfiltered (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 == gdb_stdout) fprintf_unfiltered (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/style.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" } } diff --git a/gdb/top.c b/gdb/top.c index a94ed5cebdb..25c56077835 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1443,9 +1443,11 @@ print_gdb_version (struct ui_file *stream, bool interactive) there is no warranty. */ fprintf_filtered (stream, "\ -License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\ +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")); if (!interactive) return; @@ -1474,11 +1476,15 @@ There is NO WARRANTY, to the extent permitted by law."); { fprintf_filtered (stream, _("For bug reporting instructions, please see:\n")); - fprintf_filtered (stream, "%s.\n", REPORT_BUGS_TO); + fprintf_filtered (stream, "%ps.\n", + styled_string (file_name_style.style (), + REPORT_BUGS_TO)); } fprintf_filtered (stream, _("Find the GDB manual and other documentation \ -resources online at:\n <http://www.gnu.org/software/gdb/documentation/>.")); +resources online at:\n <%ps>."), + styled_string (file_name_style.style (), + "http://www.gnu.org/software/gdb/documentation/")); fprintf_filtered (stream, "\n\n"); fprintf_filtered (stream, _("For help, type \"help\".\n")); fprintf_filtered (stream, diff --git a/gdb/utils.c b/gdb/utils.c index a8d6c96386d..54c4d1cd201 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -413,8 +413,9 @@ internal_vproblem (struct internal_problem *problem, fputs_unfiltered (_("\nThis is a bug, please report it."), gdb_stderr); if (REPORT_BUGS_TO[0]) - fprintf_unfiltered (gdb_stderr, _(" For instructions, see:\n%s."), - REPORT_BUGS_TO); + fprintf_unfiltered (gdb_stderr, _(" For instructions, see:\n%ps."), + styled_string (file_name_style.style (), + REPORT_BUGS_TO)); fputs_unfiltered ("\n\n", gdb_stderr); if (problem->should_dump_core == internal_problem_ask) ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Style URLs in GDB output 2022-03-15 21:19 ` Tom Tromey @ 2022-03-31 23:56 ` Tom Tromey 0 siblings, 0 replies; 5+ messages in thread From: Tom Tromey @ 2022-03-31 23:56 UTC (permalink / raw) To: Tom Tromey; +Cc: Aktemur, Tankut Baris, gdb-patches >> There is REPORT_BUGS_TO printed in a few places. I think it's a URL, >> too. Tom> Thanks for noticing that. Tom> I've appended an updated patch. Tom> This touches the --help output, and looking at that, I see a few more Tom> things that probably should be styled. I can do that later though. I've updated this patch and I'm going to check it in. Tom ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-31 23:56 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-03-10 0:31 [PATCH] Style URLs in GDB output Tom Tromey 2022-03-10 6:38 ` Eli Zaretskii 2022-03-10 7:15 ` Aktemur, Tankut Baris 2022-03-15 21:19 ` Tom Tromey 2022-03-31 23:56 ` Tom Tromey
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).