From patchwork Sat Mar 14 22:02:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 5616 Received: (qmail 105170 invoked by alias); 14 Mar 2015 22:02:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 105161 invoked by uid 89); 14 Mar 2015 22:02:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: bigwig.baldwin.cx Received: from bigwig.baldwin.cx (HELO bigwig.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Sat, 14 Mar 2015 22:02:44 +0000 Received: from ralph.baldwin.cx (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id B8075B939 for ; Sat, 14 Mar 2015 18:02:41 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH] Fetch all registers before writing the core register notes. Date: Sat, 14 Mar 2015 18:02:21 -0400 Message-ID: <2653052.Cuv9hkMi4i@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-STABLE; KDE/4.14.2; amd64; ; ) MIME-Version: 1.0 X-IsSubscribed: yes 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. 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);