public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch] cygwin cross core support
@ 2007-08-19 20:16 Pedro Alves
  2007-08-24 13:58 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2007-08-19 20:16 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 297 bytes --]

Hi guys,

This patch paves the way to add Cygwin cross core support into gdb.

Tested by checking that a patched i686-pc-linux x i686-pc-cygwin gdb can
read cygwin cores successfully, that a native i686-pc-linux gdb still
builds and has no gdb testsuite regressions.

OK?

Cheers,
Pedro Alves





[-- Attachment #2: bfd_win32_cross_core.diff --]
[-- Type: text/x-diff, Size: 3951 bytes --]

2007-08-19  Pedro Alves  <pedro_alves@portugalmail.pt>

	* elf.c (elfcore_grok_win32pstatus): Remove HAVE_WIN32_PSTATUS_T
	guard.  Make it host independent.
	(elfcore_grok_note): Remove HAVE_WIN32_PSTATUS_T guard around
	NT_WIN32PSTATUS.

---
 bfd/elf.c |   50 +++++++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 21 deletions(-)

Index: src/bfd/elf.c
===================================================================
--- src.orig/bfd/elf.c	2007-08-19 15:25:42.000000000 +0100
+++ src/bfd/elf.c	2007-08-19 16:55:12.000000000 +0100
@@ -7561,7 +7561,6 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_I
 }
 #endif /* defined (HAVE_LWPSTATUS_T) */
 
-#if defined (HAVE_WIN32_PSTATUS_T)
 static bfd_boolean
 elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
 {
@@ -7569,24 +7568,32 @@ elfcore_grok_win32pstatus (bfd *abfd, El
   char *name;
   size_t len;
   asection *sect;
-  win32_pstatus_t pstatus;
+  int type;
+  int is_active_thread;
+  bfd_vma base_addr;
 
-  if (note->descsz < sizeof (pstatus))
+  if (note->descsz < 728)
     return TRUE;
 
-  memcpy (&pstatus, note->descdata, sizeof (pstatus));
+  if (! CONST_STRNEQ (note->namedata, "win32"))
+    return TRUE;
+
+  type = bfd_get_32 (abfd, note->descdata);
 
-  switch (pstatus.data_type)
+  switch (type)
     {
-    case NOTE_INFO_PROCESS:
+    case 1 /* NOTE_INFO_PROCESS */:
       /* FIXME: need to add ->core_command.  */
-      elf_tdata (abfd)->core_signal = pstatus.data.process_info.signal;
-      elf_tdata (abfd)->core_pid = pstatus.data.process_info.pid;
+      /* process_info.pid */
+      elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 8);
+      /* process_info.signal */
+      elf_tdata (abfd)->core_signal = bfd_get_32 (abfd, note->descdata + 12);
       break;
 
-    case NOTE_INFO_THREAD:
+    case 2 /* NOTE_INFO_THREAD */:
       /* Make a ".reg/999" section.  */
-      sprintf (buf, ".reg/%ld", (long) pstatus.data.thread_info.tid);
+      /* thread_info.tid */
+      sprintf (buf, ".reg/%ld", (long) bfd_get_32 (abfd, note->descdata + 8));
 
       len = strlen (buf) + 1;
       name = bfd_alloc (abfd, len);
@@ -7599,21 +7606,25 @@ elfcore_grok_win32pstatus (bfd *abfd, El
       if (sect == NULL)
 	return FALSE;
 
-      sect->size = sizeof (pstatus.data.thread_info.thread_context);
-      sect->filepos = (note->descpos
-		       + offsetof (struct win32_pstatus,
-				   data.thread_info.thread_context));
+      /* sizeof (thread_info.thread_context) */
+      sect->size = 716;
+      /* offsetof (thread_info.thread_context) */
+      sect->filepos = note->descpos + 12;
       sect->alignment_power = 2;
 
-      if (pstatus.data.thread_info.is_active_thread)
+      /* thread_info.is_active_thread */
+      is_active_thread = bfd_get_32 (abfd, note->descdata + 8);
+
+      if (is_active_thread)
 	if (! elfcore_maybe_make_sect (abfd, ".reg", sect))
 	  return FALSE;
       break;
 
-    case NOTE_INFO_MODULE:
+    case 3 /* NOTE_INFO_MODULE */:
       /* Make a ".module/xxxxxxxx" section.  */
-      sprintf (buf, ".module/%08lx",
-	       (long) pstatus.data.module_info.base_address);
+      /* module_info.base_address */
+      base_addr = bfd_get_32 (abfd, note->descdata + 4);
+      sprintf (buf, ".module/%08lx", (long) base_addr);
 
       len = strlen (buf) + 1;
       name = bfd_alloc (abfd, len);
@@ -7638,7 +7649,6 @@ elfcore_grok_win32pstatus (bfd *abfd, El
 
   return TRUE;
 }
-#endif /* HAVE_WIN32_PSTATUS_T */
 
 static bfd_boolean
 elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
@@ -7673,10 +7683,8 @@ elfcore_grok_note (bfd *abfd, Elf_Intern
     case NT_FPREGSET:		/* FIXME: rename to NT_PRFPREG */
       return elfcore_grok_prfpreg (abfd, note);
 
-#if defined (HAVE_WIN32_PSTATUS_T)
     case NT_WIN32PSTATUS:
       return elfcore_grok_win32pstatus (abfd, note);
-#endif
 
     case NT_PRXFPREG:		/* Linux SSE extension */
       if (note->namesz == 6

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] cygwin cross core support
  2007-08-19 20:16 [patch] cygwin cross core support Pedro Alves
@ 2007-08-24 13:58 ` Daniel Jacobowitz
  2007-08-25 13:19   ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2007-08-24 13:58 UTC (permalink / raw)
  To: Pedro Alves; +Cc: binutils

On Sun, Aug 19, 2007 at 06:01:58PM +0100, Pedro Alves wrote:
> 2007-08-19  Pedro Alves  <pedro_alves@portugalmail.pt>
> 
> 	* elf.c (elfcore_grok_win32pstatus): Remove HAVE_WIN32_PSTATUS_T
> 	guard.  Make it host independent.
> 	(elfcore_grok_note): Remove HAVE_WIN32_PSTATUS_T guard around
> 	NT_WIN32PSTATUS.

OK.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] cygwin cross core support
  2007-08-24 13:58 ` Daniel Jacobowitz
@ 2007-08-25 13:19   ` Pedro Alves
  0 siblings, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2007-08-25 13:19 UTC (permalink / raw)
  To: binutils

Daniel Jacobowitz wrote:
> On Sun, Aug 19, 2007 at 06:01:58PM +0100, Pedro Alves wrote:
>> 2007-08-19  Pedro Alves  <pedro_alves@portugalmail.pt>
>>
>> 	* elf.c (elfcore_grok_win32pstatus): Remove HAVE_WIN32_PSTATUS_T
>> 	guard.  Make it host independent.
>> 	(elfcore_grok_note): Remove HAVE_WIN32_PSTATUS_T guard around
>> 	NT_WIN32PSTATUS.
> 
> OK.
> 

Thanks.  Checked in.

Cheers,
Pedro Alves

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-24 21:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-19 20:16 [patch] cygwin cross core support Pedro Alves
2007-08-24 13:58 ` Daniel Jacobowitz
2007-08-25 13:19   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).