Add kernel vDSO workaround (`no loadable ...') on RHEL-5 (kernel BZ 765875).
- Fix skipping of prologues on RHEL-5 gcc-4.1 -O2 -g code (BZ 797889). - Fix breakpoint warning during 'next' over exit() (Tom Tromey, BZ 797892).
This commit is contained in:
parent
9e9d7b2bbb
commit
e05ce76998
119
gdb-6.6-bfd-vdso8k.patch
Normal file
119
gdb-6.6-bfd-vdso8k.patch
Normal file
@ -0,0 +1,119 @@
|
||||
2007-09-23 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* elfcode.h (NAME(_bfd_elf,bfd_from_remote_memory)): New variables
|
||||
X_SHDR_SHSTRTAB and I_SHDR_SHSTRTAB. Fixed the CONTENTS_SIZE trimming
|
||||
check for its aligned size between the last segment and still before
|
||||
the section header end. Added variables check to cover also the
|
||||
section header string table.
|
||||
|
||||
--- gdb-7.4.50.20120120-orig/bfd/elfcode.h 2012-02-29 09:17:08.000000000 +0100
|
||||
+++ gdb-7.4.50.20120120/bfd/elfcode.h 2012-02-29 10:23:03.000000000 +0100
|
||||
@@ -1621,6 +1621,8 @@ NAME(_bfd_elf,bfd_from_remote_memory)
|
||||
Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */
|
||||
Elf_External_Phdr *x_phdrs;
|
||||
Elf_Internal_Phdr *i_phdrs, *last_phdr;
|
||||
+ Elf_External_Shdr *x_shdrs;
|
||||
+ Elf_Internal_Shdr *i_shdrs;
|
||||
bfd *nbfd;
|
||||
struct bfd_in_memory *bim;
|
||||
int contents_size;
|
||||
@@ -1740,24 +1742,46 @@ NAME(_bfd_elf,bfd_from_remote_memory)
|
||||
|
||||
/* Trim the last segment so we don't bother with zeros in the last page
|
||||
that are off the end of the file. However, if the extra bit in that
|
||||
- page includes the section headers, keep them. */
|
||||
- if ((bfd_vma) contents_size > last_phdr->p_offset + last_phdr->p_filesz
|
||||
- && (bfd_vma) contents_size >= (i_ehdr.e_shoff
|
||||
- + i_ehdr.e_shnum * i_ehdr.e_shentsize))
|
||||
+ page includes the section headers os the section header string table,
|
||||
+ keep them. */
|
||||
+ if ((bfd_vma) contents_size > last_phdr->p_offset + last_phdr->p_filesz)
|
||||
+ contents_size = last_phdr->p_offset + last_phdr->p_filesz;
|
||||
+
|
||||
+ if ((bfd_vma) contents_size < i_ehdr.e_shoff
|
||||
+ + i_ehdr.e_shnum * i_ehdr.e_shentsize)
|
||||
+ contents_size = i_ehdr.e_shoff + i_ehdr.e_shnum * i_ehdr.e_shentsize;
|
||||
+
|
||||
+ /* Verify also all the sections fit into CONTENTS_SIZE. */
|
||||
+
|
||||
+ x_shdrs = bfd_malloc (i_ehdr.e_shnum * (sizeof *x_shdrs + sizeof *i_shdrs));
|
||||
+ if (x_shdrs == NULL)
|
||||
{
|
||||
- contents_size = last_phdr->p_offset + last_phdr->p_filesz;
|
||||
- if ((bfd_vma) contents_size < (i_ehdr.e_shoff
|
||||
- + i_ehdr.e_shnum * i_ehdr.e_shentsize))
|
||||
- contents_size = i_ehdr.e_shoff + i_ehdr.e_shnum * i_ehdr.e_shentsize;
|
||||
+ free (x_phdrs);
|
||||
+ bfd_set_error (bfd_error_no_memory);
|
||||
+ return NULL;
|
||||
}
|
||||
+ err = target_read_memory (ehdr_vma + i_ehdr.e_shoff, (bfd_byte *) x_shdrs,
|
||||
+ i_ehdr.e_shnum * sizeof *x_shdrs);
|
||||
+ if (err)
|
||||
+ i_shdrs = NULL;
|
||||
else
|
||||
- contents_size = last_phdr->p_offset + last_phdr->p_filesz;
|
||||
+ {
|
||||
+ i_shdrs = (Elf_Internal_Shdr *) &x_shdrs[i_ehdr.e_shnum];
|
||||
+ for (i = 0; i < i_ehdr.e_shnum; ++i)
|
||||
+ {
|
||||
+ elf_swap_shdr_in (templ, &x_shdrs[i], &i_shdrs[i]);
|
||||
+
|
||||
+ if ((bfd_vma) contents_size < i_shdrs[i].sh_offset + i_shdrs[i].sh_size)
|
||||
+ contents_size = i_shdrs[i].sh_offset + i_shdrs[i].sh_size;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
/* Now we know the size of the whole image we want read in. */
|
||||
contents = (bfd_byte *) bfd_zmalloc (contents_size);
|
||||
if (contents == NULL)
|
||||
{
|
||||
free (x_phdrs);
|
||||
+ free (x_shdrs);
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1776,6 +1800,7 @@ NAME(_bfd_elf,bfd_from_remote_memory)
|
||||
if (err)
|
||||
{
|
||||
free (x_phdrs);
|
||||
+ free (x_shdrs);
|
||||
free (contents);
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
errno = err;
|
||||
@@ -1784,10 +1809,32 @@ NAME(_bfd_elf,bfd_from_remote_memory)
|
||||
}
|
||||
free (x_phdrs);
|
||||
|
||||
- /* If the segments visible in memory didn't include the section headers,
|
||||
+ if (i_shdrs)
|
||||
+ {
|
||||
+ memcpy (contents + i_ehdr.e_shoff, x_shdrs,
|
||||
+ i_ehdr.e_shnum * sizeof *x_shdrs);
|
||||
+
|
||||
+ for (i = 0; i < i_ehdr.e_shnum; ++i)
|
||||
+ {
|
||||
+ bfd_vma start = i_shdrs[i].sh_offset;
|
||||
+ bfd_vma end = i_shdrs[i].sh_offset + i_shdrs[i].sh_size;
|
||||
+
|
||||
+ if (end > (bfd_vma) contents_size)
|
||||
+ end = contents_size;
|
||||
+ err = target_read_memory (ehdr_vma + start, contents + start,
|
||||
+ end - start);
|
||||
+ if (err)
|
||||
+ {
|
||||
+ i_shdrs = NULL;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ free (x_shdrs);
|
||||
+
|
||||
+ /* If the segments readable in memory didn't include the section headers,
|
||||
then clear them from the file header. */
|
||||
- if ((bfd_vma) contents_size < (i_ehdr.e_shoff
|
||||
- + i_ehdr.e_shnum * i_ehdr.e_shentsize))
|
||||
+ if (i_shdrs == NULL)
|
||||
{
|
||||
memset (&x_ehdr.e_shoff, 0, sizeof x_ehdr.e_shoff);
|
||||
memset (&x_ehdr.e_shnum, 0, sizeof x_ehdr.e_shnum);
|
93
gdb-exit-warning.patch
Normal file
93
gdb-exit-warning.patch
Normal file
@ -0,0 +1,93 @@
|
||||
http://sourceware.org/ml/gdb-patches/2012-02/msg00664.html
|
||||
Subject: RFA: fix PR breakpoints/13776
|
||||
|
||||
I'd appreciate comments on this patch.
|
||||
I have no idea whether it is the best way to fix the problem.
|
||||
|
||||
Bug 13776 concerns 'next'ing over an exit. For the trivial:
|
||||
|
||||
#include <stdlib.h>
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
exit (0);
|
||||
}
|
||||
|
||||
We get this behavior:
|
||||
|
||||
(gdb) start
|
||||
Temporary breakpoint 1, main () at exit0.c:5
|
||||
5 exit (0);
|
||||
(gdb) next
|
||||
[Inferior 1 (process 2428) exited normally]
|
||||
warning: Error removing breakpoint 0
|
||||
warning: Error removing breakpoint 0
|
||||
warning: Error removing breakpoint 0
|
||||
|
||||
The bug is that exit_inferior ends up calling delete_longjmp_breakpoint,
|
||||
which tries to delete the longjmp breakpoints -- but as the inferior is
|
||||
dead, this fails.
|
||||
|
||||
This patch fixes this problem by moving the breakpoint_init_inferior
|
||||
call earlier in generic_mourn_inferior. This causes the breakpoints to
|
||||
be marked as uninserted before they are deleted.
|
||||
|
||||
While doing this I noticed that after the inferior exits, we are left
|
||||
with a step-resume breakpoint:
|
||||
|
||||
(gdb) maint info b
|
||||
Num Type Disp Enb Address What
|
||||
[...]
|
||||
0 step resume dstp y 0x00000000004004d2 inf 1 thread 1
|
||||
stop only in thread 1
|
||||
|
||||
The breakpoint.c patch causes this to be removed as well.
|
||||
|
||||
Built and regtested on x86-64 Fedora 16.
|
||||
|
||||
Tom
|
||||
|
||||
2012-02-28 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
PR breakpoints/13776:
|
||||
* target.c (generic_mourn_inferior): Call breakpoint_init_inferior
|
||||
earlier.
|
||||
* breakpoint.c (breakpoint_init_inferior): Delete step-resume
|
||||
breakpoints.
|
||||
|
||||
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
|
||||
index db05b97..048cc63 100644
|
||||
--- a/gdb/breakpoint.c
|
||||
+++ b/gdb/breakpoint.c
|
||||
@@ -3341,6 +3341,10 @@ breakpoint_init_inferior (enum inf_context context)
|
||||
(gdb) tar rem :9999 # remote Windows gdbserver.
|
||||
*/
|
||||
|
||||
+ case bp_step_resume:
|
||||
+
|
||||
+ /* Also remove step-resume breakpoints. */
|
||||
+
|
||||
delete_breakpoint (b);
|
||||
break;
|
||||
|
||||
diff --git a/gdb/target.c b/gdb/target.c
|
||||
index 1f408f6..65a6c23 100644
|
||||
--- a/gdb/target.c
|
||||
+++ b/gdb/target.c
|
||||
@@ -3583,13 +3583,14 @@ generic_mourn_inferior (void)
|
||||
ptid = inferior_ptid;
|
||||
inferior_ptid = null_ptid;
|
||||
|
||||
+ breakpoint_init_inferior (inf_exited);
|
||||
+
|
||||
if (!ptid_equal (ptid, null_ptid))
|
||||
{
|
||||
int pid = ptid_get_pid (ptid);
|
||||
exit_inferior (pid);
|
||||
}
|
||||
|
||||
- breakpoint_init_inferior (inf_exited);
|
||||
registers_changed ();
|
||||
|
||||
reopen_exec_file ();
|
||||
|
102
gdb-prologue-not-skipped.patch
Normal file
102
gdb-prologue-not-skipped.patch
Normal file
@ -0,0 +1,102 @@
|
||||
http://sourceware.org/ml/gdb-patches/2012-02/msg00673.html
|
||||
Subject: [patch] Fix regression by me for gcc-4.0...gcc-4.4 i386 -O2 -g parameters (PR 13777)
|
||||
|
||||
Hi,
|
||||
|
||||
http://sourceware.org/bugzilla/show_bug.cgi?id=13777
|
||||
|
||||
for CentOS-5 i386 ls:
|
||||
|
||||
$ gdb ls
|
||||
(gdb) start
|
||||
Temporary breakpoint 1, main (argc=Cannot access memory at address 0x81b7c7cd
|
||||
|
||||
instead of GDB before my PR 12573 fix/change:
|
||||
|
||||
Temporary breakpoint 1, main (argc=1, ...
|
||||
|
||||
I asked before on #gcc since which versions GCC produced DW_AT_location which
|
||||
is for any PC either optimized-out or it has valid value. I was told since
|
||||
gcc-4.0. But that is not true.
|
||||
|
||||
I have bisected gcc and I found 4.4.0 was still broken, 4.5.0 was correct,
|
||||
thanks to:
|
||||
commit 25e880b1917bd6bbf07e86b5574c698f3e9472d9
|
||||
Author: rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Sat May 30 00:33:46 2009 +0000
|
||||
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147995 138bc75d-0d04-0410-961f-82ee72b054a4
|
||||
unwind info for epilogues
|
||||
|
||||
Curiously 4.4.x branch got later also fixed in this case by:
|
||||
commit 61db8bd232daeed3751b43570fab16146145e096
|
||||
Author: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
|
||||
Date: Tue Jun 2 07:18:16 2009 +0000
|
||||
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_4-branch@148070 138bc75d-0d04-0410-961f-82ee72b054a4
|
||||
(but that missed 4.4.0)
|
||||
|
||||
As 4.5.0 was first FSF GCC with VTA I was trusting more the validity only
|
||||
after VTA and these heuristic results seems to confirm that.
|
||||
|
||||
I find the change below definitely safe.
|
||||
|
||||
Someone may object the original PR 12573 (do not try to skip prologue for -O2
|
||||
-g code as it may cause more confusion than anything else) as while it fixed
|
||||
some GDB crashes there is no such purpose anymore with Tom's
|
||||
ambiguous-linespec patch. Still I believe PR 12573 was right to do.
|
||||
|
||||
No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu.
|
||||
|
||||
I will check it in.
|
||||
|
||||
|
||||
Thanks,
|
||||
Jan
|
||||
|
||||
|
||||
gdb/
|
||||
2012-02-28 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
PR symtab/13777
|
||||
* dwarf2read.c (process_full_comp_unit): Set LOCATIONS_VALID only for
|
||||
GCC >=4.5.
|
||||
|
||||
gdb/testsuite/
|
||||
2012-02-28 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
PR symtab/13777
|
||||
* gdb.dwarf2/dw2-skip-prologue.S (DW_AT_producer): Set it to 4.5.0.
|
||||
|
||||
--- a/gdb/dwarf2read.c
|
||||
+++ b/gdb/dwarf2read.c
|
||||
@@ -4841,7 +4841,9 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
|
||||
|
||||
/* GCC-4.0 has started to support -fvar-tracking. GCC-3.x still can
|
||||
produce DW_AT_location with location lists but it can be possibly
|
||||
- invalid without -fvar-tracking.
|
||||
+ invalid without -fvar-tracking. Still up to GCC-4.4.x incl. 4.4.0
|
||||
+ there were bugs in prologue debug info, fixed later in GCC-4.5
|
||||
+ by "unwind info for epilogues" patch (which is not directly related).
|
||||
|
||||
For -gdwarf-4 type units LOCATIONS_VALID indication is fortunately not
|
||||
needed, it would be wrong due to missing DW_AT_producer there.
|
||||
@@ -4849,7 +4851,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
|
||||
Still one can confuse GDB by using non-standard GCC compilation
|
||||
options - this waits on GCC PR other/32998 (-frecord-gcc-switches).
|
||||
*/
|
||||
- if (cu->has_loclist && gcc_4_minor >= 0)
|
||||
+ if (cu->has_loclist && gcc_4_minor >= 5)
|
||||
symtab->locations_valid = 1;
|
||||
|
||||
if (gcc_4_minor >= 5)
|
||||
--- a/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.S
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.S
|
||||
@@ -30,7 +30,7 @@
|
||||
.4byte func_start /* DW_AT_low_pc */
|
||||
.4byte func_end /* DW_AT_high_pc */
|
||||
.ascii "main.c\0" /* DW_AT_name */
|
||||
- .ascii "GNU C 4.0.0\0" /* DW_AT_producer must be >= 4.0 */
|
||||
+ .ascii "GNU C 4.5.0\0" /* DW_AT_producer must be >= 4.5 */
|
||||
.byte 2 /* DW_AT_language (DW_LANG_C) */
|
||||
|
||||
.uleb128 2 /* Abbrev: DW_TAG_subprogram */
|
||||
|
22
gdb.spec
22
gdb.spec
@ -33,7 +33,7 @@ Version: 7.4.50.%{snap}
|
||||
|
||||
# The release always contains a leading reserved number, start it at 1.
|
||||
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
|
||||
Release: 22%{?dist}
|
||||
Release: 23%{?dist}
|
||||
|
||||
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain
|
||||
Group: Development/Debuggers
|
||||
@ -307,6 +307,10 @@ Patch415: gdb-6.6-buildid-locate-core-as-arg.patch
|
||||
#=push
|
||||
Patch519: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
|
||||
|
||||
# Add kernel vDSO workaround (`no loadable ...') on RHEL-5 (kernel BZ 765875).
|
||||
#=push
|
||||
Patch276: gdb-6.6-bfd-vdso8k.patch
|
||||
|
||||
# Fix displaying of numeric char arrays as strings (BZ 224128).
|
||||
#=fedoratest: But it is failing anyway, one should check the behavior more.
|
||||
Patch282: gdb-6.7-charsign-test.patch
|
||||
@ -536,6 +540,14 @@ Patch643: gdb-python-rdynamic.patch
|
||||
#=push
|
||||
Patch644: gdb-expand-cxx-accel.patch
|
||||
|
||||
# Fix skipping of prologues on RHEL-5 gcc-4.1 -O2 -g code (BZ 797889).
|
||||
#=push
|
||||
Patch645: gdb-prologue-not-skipped.patch
|
||||
|
||||
# Fix breakpoint warning during 'next' over exit() (Tom Tromey, BZ 797892).
|
||||
#=push
|
||||
Patch646: gdb-exit-warning.patch
|
||||
|
||||
%if 0%{!?rhel:1} || 0%{?rhel} > 6
|
||||
# RL_STATE_FEDORA_GDB would not be found for:
|
||||
# Patch642: gdb-readline62-ask-more-rh.patch
|
||||
@ -740,6 +752,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
|
||||
%patch271 -p1
|
||||
%patch274 -p1
|
||||
%patch353 -p1
|
||||
%patch276 -p1
|
||||
%patch282 -p1
|
||||
%patch284 -p1
|
||||
%patch287 -p1
|
||||
@ -796,6 +809,8 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
|
||||
%patch634 -p1
|
||||
%patch643 -p1
|
||||
%patch644 -p1
|
||||
%patch645 -p1
|
||||
%patch646 -p1
|
||||
|
||||
%patch393 -p1
|
||||
%if 0%{!?el5:1} || 0%{?scl:1}
|
||||
@ -1233,6 +1248,11 @@ fi
|
||||
%{_infodir}/gdb.info*
|
||||
|
||||
%changelog
|
||||
* Wed Feb 29 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.4.50.20120120-23.fc17
|
||||
- Add kernel vDSO workaround (`no loadable ...') on RHEL-5 (kernel BZ 765875).
|
||||
- Fix skipping of prologues on RHEL-5 gcc-4.1 -O2 -g code (BZ 797889).
|
||||
- Fix breakpoint warning during 'next' over exit() (Tom Tromey, BZ 797892).
|
||||
|
||||
* Tue Feb 28 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.4.50.20120120-22.fc17
|
||||
- testsuite: Fix gdb.base/macscp.exp ccache workaround in SCL mode.
|
||||
- Adjust the RHEL/F version string automatically (BZ 797651, BZ 797646).
|
||||
|
Loading…
Reference in New Issue
Block a user