Apply patch from Egor Duda to process win32_pstatus notes in core dumps.
authorNick Clifton <nickc@redhat.com>
Mon, 10 Jan 2000 18:50:16 +0000 (18:50 +0000)
committerNick Clifton <nickc@redhat.com>
Mon, 10 Jan 2000 18:50:16 +0000 (18:50 +0000)
bfd/ChangeLog
bfd/config.bfd
bfd/config.in
bfd/configure
bfd/configure.in
bfd/elf.c

index 063dbce4b9dc877d287a3e14314eee07ce4ff2b7..ddec5930c50f911f23a686acb45bc0b790c9b01e 100644 (file)
@@ -1,3 +1,17 @@
+2000-01-10  Egor Duda  <deo@logos-m.ru>
+
+       * config.bfd: Include elf32_i386 vector to target list for cygwin 
+       and mingw.
+       
+       * config.in: Undefine HAVE_WIN32_PSTATUS_T.
+       * configure.in: Test for structure win32_pstatus_t in
+       <sys/procfs.h>
+       * configure: Regenerate.
+       
+       * elf.c (elfcore_grok_win32pstatus): New function: process
+       win32_pstatus_t notes in elf core file.
+       (elfcore_grok_note): Detect win32_pstatus notes.
+
 2000-01-03  Martin v. Loewis  <loewis@informatik.hu-berlin.de>
 
        * elflink.c (_bfd_elf_link_record_dynamic_symbol): Process symbol
index b5f08a3c505c9dae5e851d90aaee2eb1d3016fbe..e844bf1d680ff8e879f4cbe5d566b9c55aa30c36 100644 (file)
@@ -316,7 +316,7 @@ case "${targ}" in
     ;;
   i[3456]86-*-mingw32* | i[3456]86-*-cygwin* | i[3456]86-*-winnt | i[3456]86-*-pe)
     targ_defvec=i386pe_vec
-    targ_selvecs="i386pe_vec i386pei_vec"
+    targ_selvecs="i386pe_vec i386pei_vec bfd_elf32_i386_vec"
     ;;
   i[3456]86-none-*)
     targ_defvec=i386coff_vec
index abb2c7872ccd3db72d2f07ea20f34ae70f452294..7383656618bca3b02f8d0ca0262760700689e0f5 100644 (file)
 /* Define if <sys/procfs.h> has lwpstatus_t.pr_reg. */
 #undef HAVE_LWPSTATUS_T_PR_REG
 
+/* Define if <sys/procfs.h> has win32_pstatus_t. */
+#undef HAVE_WIN32_PSTATUS_T
+
 /* Name of host specific header file to include in trad-core.c. */
 #undef TRAD_HEADER
 
index adc316db9c7e278a2f7a79316c9e99f1d7c0adeb..53c7b3f83f5756c6dab082671345930f8589d68a 100755 (executable)
@@ -5267,6 +5267,14 @@ EOF
   fi
 fi
 
+ if test $bfd_cv_have_sys_procfs_type_lwpstatus_t = yes; then
+   cat >> confdefs.h <<\EOF
+#define HAVE_LWPSTATUS_T 1
+EOF
+
+ fi
+ echo "$ac_t""$bfd_cv_have_sys_procfs_type_lwpstatus_t" 1>&6
+
 
 cat >> confdefs.h <<EOF
 #define TRAD_HEADER $TRAD_HEADER
index 4976c3abcc19abfd904b5c4ca11b2e580f488d01..88d3731926291bd48e29e0804ff5a31a0fe426ce 100644 (file)
@@ -314,6 +314,7 @@ changequote([,])dnl
     BFD_HAVE_SYS_PROCFS_TYPE(lwpstatus_t)
     BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(lwpstatus_t, pr_context)
     BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(lwpstatus_t, pr_reg)
+    BFD_HAVE_SYS_PROCFS_TYPE(win32_pstatus_t)
   fi
 fi
 AC_SUBST(COREFILE)
index f97a9a98cc8ef9204b1b7685c0209f5c1faaa53c..436f8db9337d32d373864fc80ebfa29ff7e0777b 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5292,7 +5292,83 @@ elfcore_grok_lwpstatus (abfd, note)
 }
 #endif /* defined (HAVE_LWPSTATUS_T) */
 
+#if defined (HAVE_WIN32_PSTATUS_T)
+static boolean
+elfcore_grok_win32pstatus (abfd, note)
+     bfd * abfd;
+     Elf_Internal_Note * note;
+{
+  char buf[30];
+  char * name;
+  asection * sect;
+  win32_pstatus_t pstatus;
+
+  if (note->descsz < sizeof (pstatus))
+    return true;
+
+  memcpy (& pstatus, note->descdata, note->descsz);
+  
+  switch (pstatus.data_type) 
+    {
+    case 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;
+      break ;
+
+    case NOTE_INFO_THREAD:
+      /* Make a ".reg/999" section.  */
+      sprintf (buf, ".reg/%d", pstatus.data.thread_info.tid);
+      
+      name = bfd_alloc (abfd, strlen (buf) + 1);
+      if (name == NULL)
+        return false;
+      
+      strcpy (name, buf);
+
+      sect = bfd_make_section (abfd, name);
+      if (sect == NULL)
+        return false;
+      
+      sect->_raw_size = sizeof (pstatus.data.thread_info.thread_context);
+      sect->filepos = note->descpos + offsetof (struct win32_pstatus,
+                                               data.thread_info.thread_context);
+      sect->flags = SEC_HAS_CONTENTS;
+      sect->alignment_power = 2;
+
+      if (pstatus.data.thread_info.is_active_thread)
+       if (! elfcore_maybe_make_sect (abfd, ".reg", sect))
+         return false;
+      break;
+
+    case NOTE_INFO_MODULE:
+      /* Make a ".module/xxxxxxxx" section.  */
+      sprintf (buf, ".module/%08x" , pstatus.data.module_info.base_address);
+      
+      name = bfd_alloc (abfd, strlen (buf) + 1);
+      if (name == NULL)
+       return false;
+      
+      strcpy (name, buf);
 
+      sect = bfd_make_section (abfd, name);
+      
+      if (sect == NULL)
+       return false;
+      
+      sect->_raw_size = note->descsz;
+      sect->filepos = note->descpos;
+      sect->flags = SEC_HAS_CONTENTS;
+      sect->alignment_power = 2;
+      break;
+
+    default:
+      return true;
+    }
+
+  return true;
+}
+#endif /* HAVE_WIN32_PSTATUS_T */
 
 static boolean
 elfcore_grok_note (abfd, note)
@@ -5322,7 +5398,12 @@ elfcore_grok_note (abfd, note)
     case NT_FPREGSET:          /* FIXME: rename to NT_PRFPREG */
       return elfcore_grok_prfpreg (abfd, note);
 
-    case NT_PRXFPREG:          /* Linux SSE extension */
+#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 == 5
          && ! strcmp (note->namedata, "LINUX"))
        return elfcore_grok_prxfpreg (abfd, note);