diff mbox

Fetch all registers before writing the core register notes.

Message ID 2653052.Cuv9hkMi4i@ralph.baldwin.cx
State New
Headers show

Commit Message

John Baldwin March 14, 2015, 10:02 p.m. UTC
Without this, not all registers were present in the core generated by gcore.
For example, running 'gcore' on a program without examining the vector 
registers (SSE or AVX) would store all the vector registers as zeros because
they were not pulled into the regcache.  Running 'info vector' before 'gcore'
would store the correct values in the core since it populated the regcache.
For Linux processes, a similar operation is achieved somewhat by having the
thread iterator callback invoke target_fetch_registers on each thread before
its corresponding register notes are dumped.

(I don't plan on including that level of detail in the commit log, just as
a way to explain the bug this change fixes.)

gdb/ChangeLog:

	* fbsd-tdep.c (fbsd_make_corefile_notes): Fetch all target registers
	before writing core register notes.
---

Comments

Pedro Alves March 16, 2015, 12:09 p.m. UTC | #1
On 03/14/2015 10:02 PM, John Baldwin wrote:
> Without this, not all registers were present in the core generated by gcore.
> For example, running 'gcore' on a program without examining the vector 
> registers (SSE or AVX) would store all the vector registers as zeros because
> they were not pulled into the regcache.  Running 'info vector' before 'gcore'
> would store the correct values in the core since it populated the regcache.
> For Linux processes, a similar operation is achieved somewhat by having the
> thread iterator callback invoke target_fetch_registers on each thread before
> its corresponding register notes are dumped.
> 
> (I don't plan on including that level of detail in the commit log, just as
> a way to explain the bug this change fixes.)

I think it's good to have the detail in the log.  If you felt the need to
explain it for review, then a future archaeologist looking at git log/blame
would likely appreciate the same info.

> gdb/ChangeLog:
> 
> 	* fbsd-tdep.c (fbsd_make_corefile_notes): Fetch all target registers
> 	before writing core register notes.

Looks fine to me.

Thanks,
Pedro Alves
John Baldwin March 16, 2015, 2:55 p.m. UTC | #2
On Monday, March 16, 2015 12:09:22 PM Pedro Alves wrote:
> On 03/14/2015 10:02 PM, John Baldwin wrote:
> > Without this, not all registers were present in the core generated by gcore.
> > For example, running 'gcore' on a program without examining the vector 
> > registers (SSE or AVX) would store all the vector registers as zeros because
> > they were not pulled into the regcache.  Running 'info vector' before 'gcore'
> > would store the correct values in the core since it populated the regcache.
> > For Linux processes, a similar operation is achieved somewhat by having the
> > thread iterator callback invoke target_fetch_registers on each thread before
> > its corresponding register notes are dumped.
> > 
> > (I don't plan on including that level of detail in the commit log, just as
> > a way to explain the bug this change fixes.)
> 
> I think it's good to have the detail in the log.  If you felt the need to
> explain it for review, then a future archaeologist looking at git log/blame
> would likely appreciate the same info.

Fair enough, I will include it.

> > gdb/ChangeLog:
> > 
> > 	* fbsd-tdep.c (fbsd_make_corefile_notes): Fetch all target registers
> > 	before writing core register notes.
> 
> Looks fine to me.
> 
> Thanks,
> Pedro Alves
>
diff mbox

Patch

diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 5d17f03..9609cd8 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -89,7 +89,7 @@  fbsd_collect_regset_section_cb (const char *sect_name, int size,
 static char *
 fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
 {
-  const struct regcache *regcache = get_current_regcache ();
+  struct regcache *regcache = get_current_regcache ();
   char *note_data;
   Elf_Internal_Ehdr *i_ehdrp;
   struct fbsd_collect_regset_section_cb_data data;
@@ -104,6 +104,7 @@  fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
   data.obfd = obfd;
   data.note_data = NULL;
   data.note_size = note_size;
+  target_fetch_registers (regcache, -1);
   gdbarch_iterate_over_regset_sections (gdbarch,
 					fbsd_collect_regset_section_cb,
 					&data, regcache);