[1/7] Read tid from correct offset in win32pstatus NOTE_INFO_THREAD

Message ID 20200701213225.14144-2-jon.turney@dronecode.org.uk
State New
Headers show
Series
  • Add gdb support for Cygwin x86_64 core dumps
Related show

Commit Message

Jon Turney July 1, 2020, 9:32 p.m.
Fix the offset used to read the tid from a win32pstatus ELF note.

This probably meant that registers were only being correctly recovered
from the core dump for the current thread.

Also improve comment.

bfd/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

	* elf.c (elfcore_grok_win32pstatus): Fix the offset used to read
	the tid from a win32pstatus ELF note.
---
 bfd/ChangeLog | 5 +++++
 bfd/elf.c     | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

-- 
2.27.0

Patch

diff --git a/bfd/elf.c b/bfd/elf.c
index 9ca42e10d8e..5a184d14c66 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -10157,9 +10157,10 @@  elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
       break;
 
     case 2 /* NOTE_INFO_THREAD */:
-      /* Make a ".reg/999" section.  */
+      /* Make a ".reg/<tid>" section containing the Win32 API thread CONTEXT
+         structure. */
       /* thread_info.tid */
-      sprintf (buf, ".reg/%ld", (long) bfd_get_32 (abfd, note->descdata + 8));
+      sprintf (buf, ".reg/%ld", (long) bfd_get_32 (abfd, note->descdata + 4));
 
       len = strlen (buf) + 1;
       name = (char *) bfd_alloc (abfd, len);