Re: [patch] Support gcore for i386 inferiors on amd64

Mark Kettenis
2006-09-26T22:55:16Z

> Date: Sat, 23 Sep 2006 15:11:43 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Hi,
>
> currently "gcore" command creates invalid core file for i386
> (32-bit) inferiors running on amd64 gdb/machine.
>
> bfd interface lacks the proper support so it is supplying its own
> implementation of 32-bit target while running on 64-bit built bfd.
>
> Patch mostly created by Fujitsu.

What's the copyright status of this diff?

> Attached glibc patch for review for a possible push there.
> Still the gdb patch fallbacks on its copy in the case of
> legacy/current glibc.

> 2006-09-23 Jan Kratochvil <jan.kratochvil@redhat.com>
> Fujitsu
>
> * amd64-linux-nat.c: Support new to_elfcore_write_prpsinfo,
> to_elfcore_write_prstatus, to_elfcore_write_prfpreg.
> (i386_linux_gregset32_reg_offset): New mapping for i386 on amd64.
> (amd64_linux_gcore_create_hook): New hook for modifying segment attrs.
> * gcore.c (gcore_create_hook): Hook function variable.
> (gcore_create_callback): Call (*gcore_create_hook).
> * configure.ac: Check for sys/user32.h, sys/procfs32.h.
> * configure, config.in: Regenerated.
> * corelow.c (init_core_ops): Support new to_elfcore_write_prpsinfo,
> to_elfcore_write_prstatus, to_elfcore_write_prfpreg.
> * fbsd-nat.c (fbsd_make_corefile_notes): Virtualize elfcore_*.
> * linux-nat.c (linux_nat_do_thread_registers): Likewise.
> (linux_nat_make_corefile_notes): Likewise.
> * procfs.c (procfs_do_thread_registers): Likewise.
> (procfs_make_note_section): Likewise.
> * target.c (update_current_target): Likewise.
> * target.h (struct target_ops): Likewise.
> * Makefile.in: Dependencies updated.

I don't think the elfcore_write_xxx functions belong in the target
vector. They're specific to one type of core file format that's
shared by only three or four operating systems. And even then there's
quite a bit of variation between systems. I think it is simpler to
keep this Linux-specific (although Solaris probably needs something
similar).

There are a few other problems with the code too, but I will nag about
that later.

Mark