public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>,
	Christian Biesinger via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2 2/7] Add "help news"
Date: Mon, 6 Jul 2020 10:14:20 -0400	[thread overview]
Message-ID: <66512dc6-6498-520d-ae54-51de98db5f06@simark.ca> (raw)
In-Reply-To: <875zb2kl6j.fsf@tromey.com>

On 2020-07-05 11:59 a.m., Tom Tromey wrote:
>>>>>> "Christian" == Christian Biesinger via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Christian> On Tue, Jun 23, 2020 at 8:20 AM Tom Tromey <tom@tromey.com> wrote:
>>> +static void
>>> +help_news (struct ui_file *stream)
>>> +{
>>> +  std::string news_name = std::string (gdb_datadir) + SLASH_STRING + "NEWS";
>>> +  gdb_file_up news_file = gdb_fopen_cloexec (news_name.c_str (), "r");
>>> +  if (news_file == nullptr)
>>> +    perror_with_name (_("could not open the NEWS file"));
>>> +
>>> +  char buffer[1024];
>>> +  size_t offset = 0;
>>> +  while (true)
>>> +    {
>>> +      size_t nbytes = fread (&buffer[offset], 1, sizeof (buffer) - offset,
>>> +                            news_file.get ());
> 
> 
> Christian> Why not use read_entire_file from your other patch?
> 
> The NEWS file seems large-ish, and I figured the normal thing for users
> would be to use the pager to view the top, then stop reading.

The NEWS file is 281k and contains all NEWS since GDB 4.0 (pre year 2000).  So
I think it's safe to say that it grows much slower than the available memory
on the average computer grows.  That amount in memory is minimal compared to
what is typically used for reading DWARF information of large-ish programs,
and it's just transient use anyway.

So I think it's safe to read it all, and preferable if it makes the code
simpler.  I don't think reading 281k will cause any delay noticeable to the
user of "help news".

Simon

  reply	other threads:[~2020-07-06 14:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23 13:19 [PATCH v2 0/7] Some user-friendliness changes Tom Tromey
2020-06-23 13:20 ` [PATCH v2 1/7] Introduce read_entire_file Tom Tromey
2020-07-06 13:47   ` Simon Marchi
2020-10-02 10:24   ` Andrew Burgess
2020-06-23 13:20 ` [PATCH v2 2/7] Add "help news" Tom Tromey
2020-06-23 14:35   ` Eli Zaretskii
2020-06-23 18:18   ` Christian Biesinger
2020-07-05 15:59     ` Tom Tromey
2020-07-06 14:14       ` Simon Marchi [this message]
2020-07-11 15:30     ` Tom Tromey
2020-07-06 14:06   ` Simon Marchi
2020-07-06 14:18     ` Simon Marchi
2020-07-11 15:56       ` Tom Tromey
2020-07-06 14:22     ` Simon Marchi
2020-07-11 15:31     ` Tom Tromey
2020-06-23 13:20 ` [PATCH v2 3/7] Add "tips" file to gdb Tom Tromey
2020-06-23 14:36   ` Eli Zaretskii
2020-07-06 14:27   ` Simon Marchi
2020-06-23 13:20 ` [PATCH v2 4/7] Add get_standard_config_dir function Tom Tromey
2020-06-23 13:20 ` [PATCH v2 5/7] Add early startup command file Tom Tromey
2020-07-05 18:51   ` Tom Tromey
2020-08-26 15:47   ` Andrew Burgess
2020-08-27 16:32   ` Andrew Burgess
2020-06-23 13:20 ` [PATCH v2 6/7] Let the user control the startup style Tom Tromey
2020-06-23 14:41   ` Eli Zaretskii
2020-07-05 18:50     ` Tom Tromey
2020-07-05 19:02       ` Eli Zaretskii
2020-06-23 13:20 ` [PATCH v2 7/7] Add "set startup-quietly" Tom Tromey
2020-06-23 14:45   ` Eli Zaretskii

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=66512dc6-6498-520d-ae54-51de98db5f06@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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).