This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH] Fix QNX Neutrino core file reading.
Okay. Better?
cheers,
Kris
Index: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.184
diff -u -r1.184 elf.c
--- elf.c 9 May 2003 10:58:12 -0000 1.184
+++ elf.c 16 May 2003 14:06:27 -0000
@@ -7001,18 +7001,32 @@
char buf[100];
char *name;
asection *sect;
+ short sig;
+ unsigned flags;
/* nto_procfs_status 'pid' field is at offset 0. */
elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, (bfd_byte *) ddata);
- /* nto_procfs_status 'tid' field is at offset 4. */
- elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, (bfd_byte *) ddata + 4);
+ /* nto_procfs_status 'tid' field is at offset 4. Pass it back. */
+ *tid = bfd_get_32 (abfd, (bfd_byte *) ddata + 4);
- /* nto_procfs_status 'what' field is at offset 14. */
- elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, (bfd_byte *) ddata +
14);
+ /* nto_procfs_status 'flags' field is at offset 8. */
+ flags = bfd_get_32 (abfd, (bfd_byte *) ddata + 8);
- /* Pass tid back. */
- *tid = elf_tdata (abfd)->core_lwpid;
+ /* nto_procfs_status 'what' field is at offset 14. */
+ if( (sig = bfd_get_16 (abfd, (bfd_byte *) ddata + 14)) > 0 )
+ {
+ elf_tdata (abfd)->core_signal = sig;
+ elf_tdata (abfd)->core_lwpid = *tid;
+ }
+
+ /* _DEBUG_FLAG_CURTID (current thread) is 0x80. Some cores
+ do not come from signals so we make sure we set the current
+ thread just in case. */
+ if (flags & 0x00000080)
+ {
+ elf_tdata (abfd)->core_lwpid = *tid;
+ }
/* Make a ".qnx_core_status/%d" section. */
sprintf (buf, ".qnx_core_status/%d", *tid);
@@ -7061,7 +7075,13 @@
sect->flags = SEC_HAS_CONTENTS;
sect->alignment_power = 2;
- return elfcore_maybe_make_sect (abfd, ".reg", sect);
+ /* This is the current thread. */
+ if (elf_tdata (abfd)->core_lwpid == tid)
+ {
+ return elfcore_maybe_make_sect (abfd, ".reg", sect);
+ }
+
+ return TRUE;
}
#define BFD_QNT_CORE_INFO 7
----- Original Message -----
From: "Alan Modra" <amodra@bigpond.net.au>
To: "Kris Warkentin" <kewarken@qnx.com>
Cc: <binutils@sources.redhat.com>
Sent: Friday, May 16, 2003 12:01 AM
Subject: Re: [PATCH] Fix QNX Neutrino core file reading.
> On Thu, May 15, 2003 at 04:04:24PM -0400, Kris Warkentin wrote:
> > * elf.c (elfcore_grok_nto_status): Only set lwpid for the active or
> > signalled thread.
> > (elfcore_grok_nto_gregs): Only make .reg section for the active
thread.
> >
> > Index: elf.c
> > ===================================================================
> > RCS file: /cvs/src/src/bfd/elf.c,v
> > retrieving revision 1.184
> > diff -u -r1.184 elf.c
> > --- elf.c 9 May 2003 10:58:12 -0000 1.184
> > +++ elf.c 15 May 2003 19:27:31 -0000
> > @@ -7001,18 +7001,30 @@
> > char buf[100];
> > char *name;
> > asection *sect;
> > + short sig;
> > + unsigned flags;
> >
> > /* nto_procfs_status 'pid' field is at offset 0. */
> > elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, (bfd_byte *) ddata);
> >
> > - /* nto_procfs_status 'tid' field is at offset 4. */
> > - elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, (bfd_byte *) ddata +
4);
> > + /* nto_procfs_status 'tid' field is at offset 4. Pass it back. */
>
> Two spaces between `.' and `*/'
>
> > + *tid = bfd_get_32 (abfd, (bfd_byte *) ddata + 4);
> >
> > - /* nto_procfs_status 'what' field is at offset 14. */
> > - elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, (bfd_byte *) ddata
+
> > 14);
> > + /* nto_procfs_status 'flags' field is at offset 8. */
>
> Ditto.
>
> > + flags = bfd_get_32 (abfd, (bfd_byte *) ddata + 8);
> >
> > - /* Pass tid back. */
> > - *tid = elf_tdata (abfd)->core_lwpid;
> > + /* nto_procfs_status 'what' field is at offset 14. */
> > + if( (sig = bfd_get_16 (abfd, (bfd_byte *) ddata + 14)) > 0 ){
>
> Open brace belongs on its own line.
>
> > + elf_tdata (abfd)->core_signal = sig;
> > + elf_tdata (abfd)->core_lwpid = *tid;
> > + }
> > +
> > + /* _DEBUG_FLAG_CURTID (current thread) is 0x80. Some cores
> > + do not come from signals so we make sure we set the current
> > + thread just in case. */
> > + if (flags & 0x00000080){
>
> Ditto.
>
> > + elf_tdata (abfd)->core_lwpid = *tid;
> > + }
> >
> > /* Make a ".qnx_core_status/%d" section. */
> > sprintf (buf, ".qnx_core_status/%d", *tid);
> > @@ -7022,8 +7034,7 @@
> > return FALSE;
> > strcpy (name, buf);
> >
> > - sect = bfd_make_section (abfd, name);
> > - if (sect == NULL)
> > + if ( (sect = bfd_make_section (abfd, name)) == NULL )
>
> This is a step backwards. Better to leave as is.
>
> > return FALSE;
> >
> > sect->_raw_size = note->descsz;
> > @@ -7061,7 +7072,12 @@
> > sect->flags = SEC_HAS_CONTENTS;
> > sect->alignment_power = 2;
> >
> > - return elfcore_maybe_make_sect (abfd, ".reg", sect);
> > + /* This is the current thread. */
> > + if (elf_tdata (abfd)->core_lwpid == tid){
>
> Brace again.
>
> > + return elfcore_maybe_make_sect (abfd, ".reg", sect);
> > + }
> > +
> > + return TRUE;
> > }
> >
> > #define BFD_QNT_CORE_INFO 7
> >
>
> OK with those changes.
>
> --
> Alan Modra
> IBM OzLabs - Linux Technology Centre
>