gdb/gdb-gcc47-gcore-zero.patch
2012-01-03 16:00:12 +01:00

119 lines
3.6 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

http://sourceware.org/ml/binutils/2011-12/msg00298.html
Subject: [patch] Fix zero registers core files w/gcc-4.7
Hello H.J.,
there is a regression by:
commit 2c9c556617a7de8657c25b512d272c26b070ae22
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Jun 16 22:08:10 2011 +0000
Suport x32 gcore.
when built with -O2 by
gcc (GCC) 4.7.0 20111223 (experimental)
(not by 4.6.x)
as the code violates ISO C99 6.2.4 item 5 by using local variable outside of
its block, GCC optimizes out the second memcpy, keeping there only that
memset.
./gdb -nx ./gdb -ex start -ex 'gcore 1' -ex 'set confirm no' -ex q;gdb -nx ./gdb ./1 -ex q
will print:
Core was generated by `.../gdb/gdb'.
#0 0x0000000000000000 in ?? ()
No regressions on x86_64-fedora16-linux-gnu.
Probably obvious, OK to check it in?
Thanks,
Jan
bfd/
2011-12-23 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix zero registers core files when built by gcc-4.7.
* elf64-x86-64.c (elf_x86_64_write_core_note): Remove variables p and
size. Call elfcore_write_note for the local variables. Remove the
final elfcore_write_note call. Add NOTREACHED comments.
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -420,8 +420,6 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
int note_type, ...)
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
- const void *p;
- int size;
va_list ap;
const char *fname, *psargs;
long pid;
@@ -445,8 +443,8 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
memset (&data, 0, sizeof (data));
strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
- p = (const void *) &data;
- size = sizeof (data);
+ return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
+ &data, sizeof (data));
}
else
{
@@ -454,10 +452,10 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
memset (&data, 0, sizeof (data));
strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
- p = (const void *) &data;
- size = sizeof (data);
+ return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
+ &data, sizeof (data));
}
- break;
+ /* NOTREACHED */
case NT_PRSTATUS:
va_start (ap, note_type);
@@ -475,8 +473,8 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
prstat.pr_pid = pid;
prstat.pr_cursig = cursig;
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
- p = (const void *) &prstat;
- size = sizeof (prstat);
+ return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
+ &prstat, sizeof (prstat));
}
else
{
@@ -485,8 +483,8 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
prstat.pr_pid = pid;
prstat.pr_cursig = cursig;
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
- p = (const void *) &prstat;
- size = sizeof (prstat);
+ return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
+ &prstat, sizeof (prstat));
}
}
else
@@ -496,14 +494,11 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
prstat.pr_pid = pid;
prstat.pr_cursig = cursig;
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
- p = (const void *) &prstat;
- size = sizeof (prstat);
+ return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
+ &prstat, sizeof (prstat));
}
- break;
}
-
- return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type, p,
- size);
+ /* NOTREACHED */
}
#endif