public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Jameson Nash <vtjnash@gmail.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: define COFF file offsets with file_ptr
Date: Thu, 26 Nov 2020 13:51:01 -0500	[thread overview]
Message-ID: <2bb948a7-e909-8949-7486-2aec0c4a9ecf@simark.ca> (raw)
In-Reply-To: <20201126181121.31219-1-vtjnash@gmail.com>

On 2020-11-26 1:11 p.m., Jameson Nash via Gdb-patches wrote:
> The arguments to these functions are file_ptr, so these declarations
> were accidentally implicitly down-casting them to signed int. This
> allows for reading files between 2 and 4 GB in size in my testing (I
> don't have a larger dll currently to test). These may not be natively
> supported by Windows, but can appear when using split-dwarf information.
>
> This solves a "can't get string table" error resulting from attempting
> to pass a negative offset to bfd_seek. I encountered this occuring while
> trying to use a debug file for libLLVM.dll, but searching online reveals
> at least one other person may have run into a similar problem with
> Firefox?
> https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/CA+cU71k2bU0azQxjy4-77ynQj1O+TKmgtaTKe59n7Bjub1y7Tg@mail.gmail.com/
> With this patch, the debug file appears to load successfully and I can
> see debug information in gdb for the library.
>
> gdb/ChangeLog:
> 	*coffread.c: Define COFF file offsets with file_ptr to support
> files over 2GB.

I forgot to mention that you need to list the changed entities as well
(it's described somewhere in the contribution checklist).  A quick way
to get started is to use the mklog.py script:

$ git show | ../contrib/mklog.py
gdb/ChangeLog:

        * coffread.c (enter_linenos):
        (init_lineno):
        (init_stringtab):
        (coff_symtab_read):
        (coff_symfile_read):
        (coff_symfile_finish):

As you can see, it doesn't get everything right.  I would fix it up and
fill it up like this:

gdb/ChangeLog:

	* coffread.c (linetab_offset): Change type to file_ptr.
	(linetab_size): Likewise.
	(enter_linenos): Change parameter type to file_ptr.
	(init_lineno): Likewise.
	(init_stringtab): Likewise.
	(coff_symtab_read): Likewise.
	(coff_symfile_read): Change variable types to file_ptr.

I don't see anything wrong with the patch, except maybe one nit below.
I would like if we could wait a week or so, maybe others who know more
about this will have something to say.

> diff --git a/gdb/coffread.c b/gdb/coffread.c
> index c61c9a7ca1..8e0e9543ae 100644
> --- a/gdb/coffread.c
> +++ b/gdb/coffread.c
> @@ -155,8 +155,8 @@ static int type_vector_length;
>  #define INITIAL_TYPE_VECTOR_LENGTH 160
>
>  static char *linetab = NULL;
> -static long linetab_offset;
> -static unsigned long linetab_size;
> +static file_ptr linetab_offset;
> +static file_ptr linetab_size;

linetab_size was unsigned, so maybe use ufile_ptr to keep it that way?

I don't know what linetab_offset is, presumably it's the offset of the
line table in the file, so it can't really be negative.  So I'd try to
see if it would make sense to make that unsigned too.  But if the goal
is to minimize the changes, it can stay signed.

Simon

  reply	other threads:[~2020-11-26 18:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-26 18:11 Jameson Nash
2020-11-26 18:51 ` Simon Marchi [this message]
2020-11-26 21:49   ` Simon Marchi
2020-11-27 20:49   ` Jameson Nash
2020-11-27 20:55     ` Simon Marchi
2020-12-18 19:12       ` Simon Marchi
  -- strict thread matches above, loose matches on Subject: below --
2020-11-27  2:46 Jameson Nash
2020-11-25 19:14 Jameson Nash
2020-11-26 15:30 ` Simon Marchi

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=2bb948a7-e909-8949-7486-2aec0c4a9ecf@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=vtjnash@gmail.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).