This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH bfd/elf.c for UnixWare 2.1,7.1 (v2)
- From: Michael Snyder <msnyder at redhat dot com>
- To: rbrown64 at csc dot com dot au
- Cc: binutils at sources dot redhat dot com
- Date: Thu, 17 Jan 2002 17:41:01 -0800
- Subject: Re: PATCH bfd/elf.c for UnixWare 2.1,7.1 (v2)
- Organization: Red Hat, Inc.
- References: <OFCDF1C0FC.8B32FA04-ONCA256B45.0006970B@int.csc.com.au>
rbrown64@csc.com.au wrote:
>
> elfcore_write_prstatus and elfcore_write_pstatus were called from
> gdb/procfs.c which had hidden which process status structure type was
> being used in a gdb_prstatus_t typedef. Keep that information hiding
> inside the elf.c(elfcore_write_gdb_prstatus) interface - which assumes
> that HAVE_PRSTATUS_T and HAVE_PSTATUS_T are disjoint.
> No gdb regressions on Solaris 2.7 and UnixWare 7.1.0.
Rodney, I'd really prefer that we did not do this.
We're exporting the ugliness from gdb/procfs.c into bfd/elf.c,
when we could (and I think ought to) keep that ugliness in one place.
I already suggested how this could be done, by just using one
ifdef in procfs.c (similar to your original patch, only substituting
the macro name which already controls all of these differences).
Is there a reason for not doing it the way that I suggested?
Michael
>
> 2002-01-18 Rodney Brown <rbrown64@csc.com.au>
>
> * elf.c: Merge elfcore_write_prstatus and elfcore_write_pstatus
> into elfcore_write_gdb_prstatus. Assign cursig to pr_lwp.pr_cursig.
>
> *** elf.c.bu Fri Jan 11 10:05:21 2002
> --- elf.c Thu Jan 17 17:01:55 2002
> *************** elfcore_write_prpsinfo (abfd, buf, bufsi
> *** 6556,6564 ****
> }
> #endif /* PSINFO_T or PRPSINFO_T */
>
> ! #if defined (HAVE_PRSTATUS_T)
> char *
> ! elfcore_write_prstatus (abfd, buf, bufsiz, pid, cursig, gregs)
> bfd *abfd;
> char *buf;
> int *bufsiz;
> --- 6556,6564 ----
> }
> #endif /* PSINFO_T or PRPSINFO_T */
>
> ! #if defined (HAVE_PRSTATUS_T) || defined (HAVE_PSTATUS_T)
> char *
> ! elfcore_write_gdb_prstatus (abfd, buf, bufsiz, pid, cursig, gregs)
> bfd *abfd;
> char *buf;
> int *bufsiz;
> *************** elfcore_write_prstatus (abfd, buf, bufsi
> *** 6566,6603 ****
> int cursig;
> void *gregs;
> {
> - prstatus_t prstat;
> char *note_name = "CORE";
>
> memset (&prstat, 0, sizeof (prstat));
> prstat.pr_pid = pid;
> prstat.pr_cursig = cursig;
> memcpy (prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
> ! return elfcore_write_note (abfd, buf, bufsiz,
> ! note_name, NT_PRSTATUS, &prstat, sizeof (prstat));
> ! }
> ! #endif /* HAVE_PRSTATUS_T */
> !
> ! #if defined (HAVE_PSTATUS_T)
> ! char *
> ! elfcore_write_pstatus (abfd, buf, bufsiz, pid, cursig, gregs)
> ! bfd *abfd;
> ! char *buf;
> ! int *bufsiz;
> ! long pid;
> ! int cursig;
> ! void *gregs;
> ! {
> ! pstatus_t pstat;
> ! char *note_name = "CORE";
> !
> ! memset (&pstat, 0, sizeof (prstat));
> ! pstat.pr_pid = pid;
> ! memcpy (pstat.pr_reg, gregs, sizeof (pstat.pr_reg));
> ! return elfcore_write_note (abfd, buf, bufsiz,
> ! note_name, NT_PSTATUS, &pstat, sizeof (pstat));
> }
> ! #endif /* HAVE_PSTATUS_T */
>
> char *
> elfcore_write_prfpreg (abfd, buf, bufsiz, fpregs, size)
> --- 6566,6604 ----
> int cursig;
> void *gregs;
> {
> char *note_name = "CORE";
> + #if defined (HAVE_PRSTATUS_T)
> + #define NT_GDB_PRSTATUS NT_PRSTATUS
> + prstatus_t prstat;
> + #elif defined (HAVE_PSTATUS_T)
> + #define NT_GDB_PRSTATUS NT_PSTATUS
> + pstatus_t prstat;
> + #endif
>
> memset (&prstat, 0, sizeof (prstat));
> prstat.pr_pid = pid;
> + #if defined(HAVE_PRSTATUS_T) || !defined (HAVE_LWPSTATUS_T)
> prstat.pr_cursig = cursig;
> memcpy (prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
> ! #elif defined (HAVE_LWPSTATUS_T_PR_REG)
> ! prstat.pr_lwp.pr_cursig = cursig;
> ! memcpy (prstat.pr_lwp.pr_reg, gregs, sizeof (prstat.pr_lwp.pr_reg));
> ! #elif defined (HAVE_LWPSTATUS_T_PR_CONTEXT)
> ! prstat.pr_lwp.pr_cursig = cursig;
> ! #if !defined(gregs)
> ! memcpy (prstat.pr_lwp.pr_context.uc_mcontext.gregs,
> ! gregs, sizeof (gregset_t));
> ! #else
> ! memcpy (prstat.pr_lwp.pr_context.uc_mcontext.__gregs,
> ! gregs, sizeof (gregset_t));
> ! #endif
> ! #else
> ! #error FixMe
> ! #endif
> ! return elfcore_write_note (abfd, buf, bufsiz, note_name, NT_GDB_PRSTATUS,
> ! &prstat, sizeof (prstat));
> }
> ! #endif /* HAVE_PRSTATUS_T || HAVE_PSTATUS_T */
>
> char *
> elfcore_write_prfpreg (abfd, buf, bufsiz, fpregs, size)