From: Pedro Alves <pedro@palves.net>
To: Andrew Burgess <andrew.burgess@embecosm.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] gdb: add setting to disable reading source code files
Date: Fri, 24 Sep 2021 17:14:54 +0100 [thread overview]
Message-ID: <6e8fb450-3304-dee2-73ae-2a4e142d4ef2@palves.net> (raw)
In-Reply-To: <9b4e2c9c4e0c4153cda06ccb075e49b529253413.1631136815.git.andrew.burgess@embecosm.com>
Hi Andrew,
Just some typos/nits.
On 2021-09-08 10:34 p.m., Andrew Burgess wrote:
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index f9485520438..cb4c9ccf902 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -3,6 +3,8 @@
>
> *** Changes since GDB 11
>
> +* New commands
> +
> maint set backtrace-on-fatal-signal on|off
> maint show backtrace-on-fatal-signal
> This setting is 'on' by default. When 'on' GDB will print a limited
> @@ -10,6 +12,13 @@ maint show backtrace-on-fatal-signal
> fatal signal. This only supported on some platforms where the
> backtrace and backtrace_symbols_fd functions are available.
>
> +set source open on|off
> +show source open
> + This command, which is on by default, controls whether GDB will try
> + to open source code files. Switching this off will stop GDB trying
> + to open and read soure code files, which can be useful if the files
Typo: "soure"
> + are located over a slow network connection.
> +
> * Python API
>
> +When this option is @code{off}, @value{GDBN} will not access source
> +code files.
> +@end table
>
> @node Data
> @chapter Examining Data
> diff --git a/gdb/source.c b/gdb/source.c
> index 7d1934bd6c9..e5a1524cedf 100644
> --- a/gdb/source.c
> +++ b/gdb/source.c
> @@ -148,7 +148,21 @@ show_filename_display_string (struct ui_file *file, int from_tty,
> {
> fprintf_filtered (file, _("Filenames are displayed as \"%s\".\n"), value);
> }
> -
> +
> +/* When true GDB will stat and open source files at as required, but when
The "at" in "open source files at as" seems spurious.
> + false, GDB will avoid accessing source files as much as possible. */
> +
> +static bool source_open = true;
> +
> +/* Implement 'show source open'. */
> +
> +static void
> +show_source_open (struct ui_file *file, int from_tty,
> + struct cmd_list_element *c, const char *value)
> +{
> + fprintf_filtered (file, _("Source opening is \"%s\".\n"), value);
> +}
> +
> /* Line number of last line printed. Default for various commands.
> current_source_line is usually, but not always, the same as this. */
>
> @@ -1048,8 +1062,13 @@ find_and_open_source (const char *filename,
> const char *p;
> int result;
>
> - /* Quick way out if we already know its full name. */
> + /* If reading of source files is disabled then return a result indicating
> + the attempt to read this source file failed, GDB will then display
I think there should be a period between "failed, GDB".
> + filename and line number instead. */
> + if (!source_open)
> + return scoped_fd(-1);
Missing space before parens.
> +}
> diff --git a/gdb/testsuite/gdb.base/source-open.exp b/gdb/testsuite/gdb.base/source-open.exp
> new file mode 100644
> index 00000000000..bae179bb47d
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/source-open.exp
> @@ -0,0 +1,45 @@
> +# Copyright 2021 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +
> +# Test the 'set source open on|off' command.
> +
> +standard_testfile
> +
> +if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
> + return -1
> +}
> +
> +gdb_start
Either gdb_start is not needed, or use build_executable instead of prepare_for_testing.
next prev parent reply other threads:[~2021-09-24 16:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-08 21:34 [PATCH 0/2] New option to switch off source code display Andrew Burgess
2021-09-08 21:34 ` [PATCH 1/2] gdb: remove duplicate cmd_list_element declarations Andrew Burgess
2021-09-23 20:21 ` Tom Tromey
2021-09-08 21:34 ` [PATCH 2/2] gdb: add setting to disable reading source code files Andrew Burgess
2021-09-09 18:51 ` Philippe Waroquiers
2021-09-23 20:27 ` Tom Tromey
2021-09-24 16:14 ` Pedro Alves [this message]
2021-09-27 10:33 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e8fb450-3304-dee2-73ae-2a4e142d4ef2@palves.net \
--to=pedro@palves.net \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).