Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 312566 Details for
Bug 254229
gcore produces incorrect elf_prpsinfo note data
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Updated patch against Fedora 9 source
4.patch (text/plain), 10.07 KB, created by
Denys Vlasenko
on 2008-07-24 14:36:53 UTC
(
hide
)
Description:
Updated patch against Fedora 9 source
Filename:
MIME Type:
Creator:
Denys Vlasenko
Created:
2008-07-24 14:36:53 UTC
Size:
10.07 KB
patch
obsolete
>diff -d -urpN gdb-6.8.3/bfd/elf-bfd.h gdb-6.8.4/bfd/elf-bfd.h >--- gdb-6.8.3/bfd/elf-bfd.h 2008-02-15 09:27:18.000000000 +0100 >+++ gdb-6.8.4/bfd/elf-bfd.h 2008-07-24 13:37:37.000000000 +0200 >@@ -2125,7 +2125,7 @@ extern Elf_Internal_Phdr * _bfd_elf_find > extern char *elfcore_write_note > (bfd *, char *, int *, const char *, int, const void *, int); > extern char *elfcore_write_prpsinfo >- (bfd *, char *, int *, const char *, const char *); >+ (bfd *, char *, int *, void *, const char *, const char *); > extern char *elfcore_write_prstatus > (bfd *, char *, int *, long, int, const void *); > extern char * elfcore_write_pstatus >diff -d -urpN gdb-6.8.3/bfd/elf.c gdb-6.8.4/bfd/elf.c >--- gdb-6.8.3/bfd/elf.c 2008-02-18 00:45:23.000000000 +0100 >+++ gdb-6.8.4/bfd/elf.c 2008-07-24 16:27:51.000000000 +0200 >@@ -8256,6 +8256,7 @@ char * > elfcore_write_prpsinfo (bfd *abfd, > char *buf, > int *bufsiz, >+ void *info, > const char *fname, > const char *psargs) > { >@@ -8282,7 +8283,10 @@ elfcore_write_prpsinfo (bfd *abfd, > int note_type = NT_PRPSINFO; > #endif > >- memset (&data, 0, sizeof (data)); >+ if (info) >+ memcpy (&data, info, sizeof (data)); >+ else >+ memset (&data, 0, sizeof (data)); > strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); > strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); > return elfcore_write_note (abfd, buf, bufsiz, >@@ -8299,7 +8303,10 @@ elfcore_write_prpsinfo (bfd *abfd, > int note_type = NT_PRPSINFO; > #endif > >- memset (&data, 0, sizeof (data)); >+ if (info) >+ memcpy (&data, info, sizeof (data)); >+ else >+ memset (&data, 0, sizeof (data)); > strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); > strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); > return elfcore_write_note (abfd, buf, bufsiz, >diff -d -urpN gdb-6.8.3/gdb/amd64-linux-nat.c gdb-6.8.4/gdb/amd64-linux-nat.c >--- gdb-6.8.3/gdb/amd64-linux-nat.c 2008-07-24 11:14:22.000000000 +0200 >+++ gdb-6.8.4/gdb/amd64-linux-nat.c 2008-07-24 13:43:18.000000000 +0200 >@@ -139,6 +139,7 @@ static int amd64_linux_gregset32_reg_off > > static char * > amd64_linux_elfcore_write_prpsinfo (bfd *abfd, char *buf, int *bufsiz, >+ void *info, > const char *fname, const char *psargs) > { > if (gdbarch_ptr_bit(current_gdbarch) == 32) >@@ -148,14 +149,17 @@ amd64_linux_elfcore_write_prpsinfo (bfd > struct elf_prpsinfo32 data; > note_type = NT_PRPSINFO; > >- memset (&data, 0, sizeof (data)); >+ if (info) >+ memcpy (&data, info, sizeof (data)); >+ else >+ memset (&data, 0, sizeof (data)); > strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); > strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); > return elfcore_write_note (abfd, buf, bufsiz, > note_name, note_type, &data, sizeof (data)); > } > else >- return elfcore_write_prpsinfo (abfd, buf, bufsiz, fname, psargs); >+ return elfcore_write_prpsinfo (abfd, buf, bufsiz, info, fname, psargs); > } > > static void >diff -d -urpN gdb-6.8.3/gdb/dbxread.c gdb-6.8.4/gdb/dbxread.c >--- gdb-6.8.3/gdb/dbxread.c 2008-01-29 00:43:57.000000000 +0100 >+++ gdb-6.8.4/gdb/dbxread.c 2008-07-24 15:40:03.000000000 +0200 >@@ -1182,7 +1182,7 @@ static void > read_dbx_symtab (struct objfile *objfile) > { > struct external_nlist *bufp = 0; /* =0 avoids gcc -Wall glitch */ >- struct internal_nlist nlist; >+ struct internal_nlist nlist = {}; /* same */ > CORE_ADDR text_addr; > int text_size; > >diff -d -urpN gdb-6.8.3/gdb/fbsd-nat.c gdb-6.8.4/gdb/fbsd-nat.c >--- gdb-6.8.3/gdb/fbsd-nat.c 2008-01-01 23:53:09.000000000 +0100 >+++ gdb-6.8.4/gdb/fbsd-nat.c 2008-07-24 13:37:37.000000000 +0200 >@@ -184,6 +184,7 @@ fbsd_make_corefile_notes (bfd *obfd, int > psargs = reconcat (psargs, psargs, " ", get_inferior_args (), NULL); > > note_data = elfcore_write_prpsinfo (obfd, note_data, note_size, >+ NULL, > fname, psargs); > } > >diff -d -urpN gdb-6.8.3/gdb/linux-nat.c gdb-6.8.4/gdb/linux-nat.c >--- gdb-6.8.3/gdb/linux-nat.c 2008-07-24 11:14:22.000000000 +0200 >+++ gdb-6.8.4/gdb/linux-nat.c 2008-07-24 16:26:33.000000000 +0200 >@@ -47,6 +47,7 @@ > #include "gdbthread.h" /* for struct thread_info etc. */ > #include "gdb_stat.h" /* for struct stat */ > #include <fcntl.h> /* for O_RDONLY */ >+#include "gdb_procfs32.h" /* for struct elf_prpsinfo32 */ > > #ifndef O_LARGEFILE > #define O_LARGEFILE 0 >@@ -108,7 +109,7 @@ static LONGEST (*super_xfer_partial) (st > /* This functions make elfcore note sections. > They may get overriden by code adjusting data for multi-target builds. */ > char *(*linux_elfcore_write_prpsinfo) >- (bfd *, char *, int *, const char *, const char *) = elfcore_write_prpsinfo; >+ (bfd *, char *, int *, void *, const char *, const char *) = elfcore_write_prpsinfo; > char *(*linux_elfcore_write_prstatus) > (bfd *, char *, int *, long, int, const void *) = elfcore_write_prstatus; > static char * >@@ -2812,6 +2813,108 @@ linux_nat_do_registers (bfd *obfd, ptid_ > note_data, note_size); > } > >+/* Should be always true for Linux */ >+#define HAVE_PRPSINFO_T 1 >+ >+#if defined (HAVE_PRPSINFO_T) >+ >+/* Fills struct elf_prpsinfo{32,64} as much as possible. Unknown values >+ are filled with zeroes. The structure is malloced. */ >+ >+static void* >+fill_prpsinfo (void) >+{ >+ struct stat sb; >+ char filename[sizeof ("/proc//stat") + sizeof (int) * 3 + 2]; >+ char buf[1024]; >+ char proc_state[5]; >+ long proc_nice; >+ unsigned proc_ppid; >+ unsigned proc_pgid; >+ unsigned proc_sid; >+ pid_t pid; >+ int fd, n; >+ char *cp; >+ >+ pid = ptid_get_pid (inferior_ptid); >+ sprintf (filename, "/proc/%u/stat", (unsigned)pid); >+ fd = open (filename, O_RDONLY); >+ if (fd < 0) >+ return NULL; >+ fstat (fd, &sb); /* ignore (im)possible error */ >+ n = read (fd, buf, sizeof(buf) - 1); >+ close (fd); >+ if (n < 0) >+ return NULL; >+ buf[n] = 0; >+ cp = strrchr (buf, ')'); /* split into "PID (cmd" and "<rest>" */ >+ if (!cp) >+ return NULL; >+ >+ /* see proc(5) for some details on this */ >+ n = sscanf (cp + 2, /* skip ") " */ >+ "%4s %u " /* state, ppid */ >+ "%u %u %*s %*s " /* pgid, sid, tty, tpgid */ >+ "%*s %*s %*s %*s %*s " /* flags, min_flt, cmin_flt, maj_flt, cmaj_flt */ >+ "%*s %*s " /* utime, stime */ >+ "%*s %*s %*s " /* cutime, cstime, priority */ >+ "%ld " /* nice */ >+ /*"%*s %*s " timeout, it_real_value */ >+ /*"%lu " start_time */ >+ /*"%lu " vsize */ >+ /*"%lu " rss */ >+ /*"%lu %lu %lu %lu %lu %lu " rss_rlim, start_code, end_code, start_stack, kstk_esp, kstk_eip */ >+ /*"%u %u %u %u " signal, blocked, sigignore, sigcatch */ >+ /*"%lu %lu %lu" wchan, nswap, cnswap */ >+ , proc_state, &proc_ppid, >+ &proc_pgid, &proc_sid, >+ &proc_nice); >+ if (n != 5) >+ return NULL; >+ >+#if ULONG_MAX > 0xffffffffU >+ /* we skip this code on 32-bit gdb */ >+ if (gdbarch_ptr_bit(current_gdbarch) == 64) >+ { >+ struct elf_prpsinfo *info = calloc(1, sizeof (*info)); >+ if (!info) >+ return info; >+ /*info->pr_state is "numeric process state" - ?! */ >+ info->pr_sname = proc_state[0]; /* guess */ >+ info->pr_zomb = (proc_state[0] == 'Z'); >+ info->pr_nice = proc_nice; /* guess */ >+ /* info->pr_flag; - no idea */ >+ info->pr_uid = sb.st_uid; >+ info->pr_gid = sb.st_gid; >+ info->pr_pid = pid; >+ info->pr_ppid = proc_ppid; >+ info->pr_pgrp = proc_pgid; >+ info->pr_sid = proc_sid; >+ return info; >+ } >+#endif >+ if (gdbarch_ptr_bit(current_gdbarch) == 32) >+ { >+ struct elf_prpsinfo32 *info = calloc(1, sizeof (*info)); >+ if (!info) >+ return info; >+ /*info->pr_state is "numeric process state" - ?! */ >+ info->pr_sname = proc_state[0]; /* guess */ >+ info->pr_zomb = (proc_state[0] == 'Z'); >+ info->pr_nice = proc_nice; /* guess */ >+ /* info->pr_flag; - no idea */ >+ info->pr_uid = sb.st_uid; >+ info->pr_gid = sb.st_gid; >+ info->pr_pid = pid; >+ info->pr_ppid = proc_ppid; >+ info->pr_pgrp = proc_pgid; >+ info->pr_sid = proc_sid; >+ return info; >+ } >+ return NULL; >+} >+#endif >+ > /* Fills the "to_make_corefile_note" target vector. Builds the note > section for a corefile, and returns it in a malloc buffer. */ > >@@ -2831,6 +2934,12 @@ linux_nat_make_corefile_notes (bfd *obfd > > if (get_exec_file (0)) > { >+#if defined (HAVE_PRPSINFO_T) >+ void *data = fill_prpsinfo (); >+#define DATAPTR data >+#else >+#define DATAPTR NULL >+#endif > strncpy (fname, strrchr (get_exec_file (0), '/') + 1, sizeof (fname)); > strncpy (psargs, get_exec_file (0), sizeof (psargs)); > if (get_inferior_args ()) >@@ -2848,9 +2957,13 @@ linux_nat_make_corefile_notes (bfd *obfd > psargs_end - string_end); > } > } >- note_data = (char *) linux_elfcore_write_prpsinfo (obfd, note_data, >- note_size, fname, >+ note_data = (char *) linux_elfcore_write_prpsinfo (obfd, note_data, note_size, >+ DATAPTR, >+ fname, > psargs); >+#if defined (HAVE_PRPSINFO_T) >+ free(DATAPTR); >+#endif > } > > /* Dump information for threads. */ >diff -d -urpN gdb-6.8.3/gdb/linux-nat.h gdb-6.8.4/gdb/linux-nat.h >--- gdb-6.8.3/gdb/linux-nat.h 2008-07-24 11:14:22.000000000 +0200 >+++ gdb-6.8.4/gdb/linux-nat.h 2008-07-24 13:40:01.000000000 +0200 >@@ -133,7 +133,7 @@ struct siginfo *linux_nat_get_siginfo (p > /* These functions make elfcore note sections. > They may get overriden by code adjusting data for multi-target builds. */ > extern char *(*linux_elfcore_write_prpsinfo) >- (bfd *, char *, int *, const char *, const char *); >+ (bfd *, char *, int *, void *, const char *, const char *); > extern char *(*linux_elfcore_write_prstatus) > (bfd *, char *, int *, long, int, const void *); > extern char *(*linux_elfcore_write_prfpreg) >diff -d -urpN gdb-6.8.3/gdb/procfs.c gdb-6.8.4/gdb/procfs.c >--- gdb-6.8.3/gdb/procfs.c 2008-07-24 11:14:21.000000000 +0200 >+++ gdb-6.8.4/gdb/procfs.c 2008-07-24 13:37:37.000000000 +0200 >@@ -6118,6 +6118,7 @@ procfs_make_note_section (bfd *obfd, int > note_data = (char *) elfcore_write_prpsinfo (obfd, > note_data, > note_size, >+ NULL, > fname, > psargs); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 254229
:
312485
|
312566
|
312652
|
312653
|
312823
|
312860
|
312861