Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Sergio Durigan Junior <sergiodj@redhat.com>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>,
	       Binutils Development <binutils@sourceware.org>,
	       GDB Patches <gdb-patches@sourceware.org>,
	       "H.J. Lu" <hjl.tools@gmail.com>
Subject: Re: [PATCH/RFC 01/02 v2] Refactor PRPSINFO handling on Binutils
Date: Fri, 11 Jan 2013 15:45:00 -0000	[thread overview]
Message-ID: <50F0339E.5070206@redhat.com> (raw)
In-Reply-To: <m36234252d.fsf@redhat.com>

On 01/10/2013 07:47 PM, Sergio Durigan Junior wrote:

>> On 01/04/2013 04:39 AM, Sergio Durigan Junior wrote:> +++ b/bfd/elf-psinfo.h
>>> @@ -0,0 +1,124 @@
>>> +/* Definitions for PRPSINFO structures under ELF on GNU/Linux.
>>
>> What about other OSs, like e.g., Solaris?
> 
> Since I took the definitions from the Linux kernel, I thought it'd be
> better to explicitly mention that.  I'm afraid I don't know how Solaris
> handle corefiles, do you think this comment should be expanded?

It's not that different on other Unixen, but the structures
may be different.  But I'm actually pondering about is whether we're
tying the whole new interface to Linux, causing problems for converting
other non-Linux ports.

E.g., a quick websearch for prpsinfo finds:

 http://bintree.net/freebsd/d0/ddc/sys_2procfs_8h_source.html

00075 typedef struct prpsinfo {
00076     int         pr_version;     /* Version number of struct (1) */
00077     size_t      pr_psinfosz;    /* sizeof(prpsinfo_t) (1) */
00078     char        pr_fname[PRFNAMESZ+1];  /* Command name, null terminated (1) */
00079     char        pr_psargs[PRARGSZ+1];   /* Arguments, null terminated (1) */
00080 } prpsinfo_t;

Other BSDs are probably similar, Solaris, IRIX, etc.,
will probably have a different structure in their own ways.

So indeed it looks like there's a problem here, and I think these
differences need to be contemplated.  How is the question.

One way would be for the hook to still take a "struct elf_internal_prpsinfo"
pointer, but make it so that "struct elf_internal_prpsinfo" itself is
opaque to the common code.  Both GDB's core generator code, and then
bfd's elf_backend_write_core_note hook would then have to agree on what
the type of "struct elf_internal_prpsinfo" really is, and either cast
appropriately (e.g., to/from struct elf_linux_internal_prpsinfo),
or including a file that has the proper definition of
"struct elf_internal_prpsinfo" for the target (I think that violates
C++'s ODR, so I tend to dislike it, although gdb/binutils do this
for other similar cases).

This is largely what the patch does already, except it takes
no consideration, either in naming or in comments that
"struct elf_internal_prpsinfo" is Linux specific, giving the
impression that it'd work for all ports.  But it doesn't
look like it would.  E.g., elf64-x86-64.c:elf_x86_64_write_core_note
with the patch is always using the Linux specific structure.
We need to instead have a Linux-specific version of that hook;
comments at the top of the file show it's used with FreeBSD and
Solaris too as well, and those will need their own versions
(could be the current pre-patch version).  Etc.

-- 
Pedro Alves


      reply	other threads:[~2013-01-11 15:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-17  3:10 Sergio Durigan Junior
2012-12-17 15:43 ` H.J. Lu
2012-12-17 17:41   ` Sergio Durigan Junior
2012-12-17 17:44     ` H.J. Lu
2012-12-17 17:51       ` Sergio Durigan Junior
2012-12-17 22:01         ` H.J. Lu
2012-12-18  5:47           ` Sergio Durigan Junior
2012-12-18 15:43             ` H.J. Lu
2012-12-18 17:38 ` Jan Kratochvil
2012-12-18 19:19   ` Sergio Durigan Junior
2012-12-18 19:43     ` Jan Kratochvil
2012-12-30  1:49       ` Sergio Durigan Junior
2013-01-01 14:30         ` Jan Kratochvil
2013-01-02 23:32           ` Sergio Durigan Junior
2013-01-03 13:44             ` Jan Kratochvil
2013-01-03 15:46               ` Sergio Durigan Junior
2013-01-04  4:40                 ` Sergio Durigan Junior
2013-01-09 20:49                   ` Sergio Durigan Junior
2013-01-10 18:26                   ` Pedro Alves
2013-01-10 19:47                     ` Sergio Durigan Junior
2013-01-11 15:45                       ` Pedro Alves [this message]

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=50F0339E.5070206@redhat.com \
    --to=palves@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=jan.kratochvil@redhat.com \
    --cc=sergiodj@redhat.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