This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: ping: [testsuite patch] for: [PATCH] [PR corefiles/17808] i386: Fix internal error when prstatus in core file is too big
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org, Andreas Arnez <arnez at linux dot vnet dot ibm dot com>
- Date: Sat, 14 Feb 2015 16:12:31 +0100
- Subject: Re: ping: [testsuite patch] for: [PATCH] [PR corefiles/17808] i386: Fix internal error when prstatus in core file is too big
- Authentication-results: sourceware.org; auth=none
- References: <874ms18cyz dot fsf at br87z6lw dot de dot ibm dot com> <20150108164327 dot GA29029 at host2 dot jankratochvil dot net> <20150205073758 dot GA25305 at host1 dot jankratochvil dot net> <54D33C45 dot 4010706 at redhat dot com>
On Thu, 05 Feb 2015 10:47:49 +0100, Pedro Alves wrote:
> It's not obvious to me why is the file uuencoded. What's the
> reason for that?
I do not find it convenient to check in a binary, while GIT can handle that
diff+patch do not.
If you prefer a different encoding method I do not mind.
> > +# Wrongly built GDB complains by:
> > +# "..." is not a core dump: File format not recognized
> > +# As the provided test core has 64bit PRSTATUS i386 built GDB cannot parse it.
> > +# This is just a problem of the test care, real-world elf64-i386 file will have
> > +# 32bit PRSTATUS. One cannot prepare elf64-i386 core file from elf32-i386 by
> > +# objcopy as it corrupts the core file beyond all recognition.
> > +# "\r\nCore was generated by `\[^\r\n\]*'\\.\r\nProgram terminated with signal 11, Segmentation fault\\.\r\n.*"
>
> Hmm, this line is commented out, but there's no explanation of why
> that is. Is that a left over that was intended to be used in the
> gdb_test below? As is, it seems like the gdb_test below will PASS
> even on buggy GDB?
The goal of this testcase is the final test:
x/i 0x400078
0x400078: hlt
(gdb) PASS: gdb.arch/i386-biarch-core.exp: .text is readable
If the core-file command fails to load the core file data it will get caught
by this final test anyway.
I really have no idea after 6 years why the expect string is commented out
there. Therefore I have put in into the gdb_test command now together with
the new warning:
(gdb) core-file /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.arch/i386-biarch-core.core^M
[New LWP 6901]^M
warning: Unexpected size of section `.reg/6901' in core file.^M
Failed to read a valid object file image from memory.^M
Core was generated by `./bad'.^M
Program terminated with signal SIGSEGV, Segmentation fault.^M
warning: Unexpected size of section `.reg/6901' in core file.^M
#0 0x00000200 in ?? ()^M
(gdb) PASS: gdb.arch/i386-biarch-core.exp: core-file
->
gdb_test "core-file ${corefile}" "\r\nwarning: Unexpected size of section `\\.reg/6901' in core file\\.\r\n.*Core was generated by `\[^\r\n\]*'\\.\r\nProgram terminated with signal SIGSEGV, Segmentation fault\\.\r\n.*" "core-file"
Thanks,
Jan
gdb/testsuite/ChangeLog
2015-02-14 Jan Kratochvil <jan.kratochvil@redhat.com>
PR corefiles/17808
* gdb.arch/i386-biarch-core.core.bz2.uu: New file.
* gdb.arch/i386-biarch-core.exp: New file.
diff --git a/gdb/testsuite/gdb.arch/i386-biarch-core.core.bz2.uu b/gdb/testsuite/gdb.arch/i386-biarch-core.core.bz2.uu
new file mode 100644
index 0000000..4221e99
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/i386-biarch-core.core.bz2.uu
@@ -0,0 +1,28 @@
+# Copyright 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+begin 600 i386-biarch-core.core.bz2
+M0EIH.3%!629361`P1\P`!)?_____\9'@"8Q)6P380'9@'&#`0D@``"``%(``
+M@`#`"!<(L`%F"(:$GH13::F-)M&D&U,AD:`--#)M0&FT0XR9--,)D9`P(Q-&
+M",(-&F``02)%38HT]0T`&AH```'H@``T^>9T*(,("&)SE`>`9@+GP=[,N)KB
+M'I8BL(L]N5TCY\%V]/?DB.BN*UZ'U@]TN7-]UJ5\_%0QTT<*086#%MHT7XVJ
+M9D"+C!"2*L:8D1XPD!`--M@*XT1H5RFYN&)(!0P0#:`I:;2;$5M&\*9"0@%:
+MK@X[T()M)9N7`D$VA!^63)%,;@8LT`(7\K&[7G;U:"B6'!GG+46ALOZF.2F-
+M!@>C*%86X$-]C2`KE;HG)UL(913VR2G]0BD:J=Z_`G@S,`W%.8RMS-#5P:J0
+MAJ2\8&X?@DE;UF68QHM<,D`('::J65/S:PAG*R-09["8DBI)'V]Y.[(/AM*L
+M"X_O^V;%FY.S6Q]FM=D37>5F,%4-F1ZF#,CFJVU;H*^IT<(%<V`.32$`JU["
+/G`68?\7<D4X4)`0,$?,`
+`
+end
diff --git a/gdb/testsuite/gdb.arch/i386-biarch-core.exp b/gdb/testsuite/gdb.arch/i386-biarch-core.exp
new file mode 100644
index 0000000..350e417
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/i386-biarch-core.exp
@@ -0,0 +1,58 @@
+# Copyright 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test ability to load an elf64-i386 core file. The provided core file was
+# elf64-x8664 one but it got binary patched to i386:
+# Elf32_Ehdr.e_machine @0x12..0x13
+# Elf64_Ehdr.e_machine @0x12..0x13
+# #define EM_386 3 /* Intel 80386 */
+# #define EM_X86_64 62 /* AMD x86-64 architecture */
+# patch @0x12: 0x3E -> 0x03
+
+standard_testfile
+
+if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
+ verbose "Skipping i386-biarch-core test."
+ return
+}
+
+set corebz2uufile ${srcdir}/${subdir}/${testfile}.core.bz2.uu
+set corefile ${objdir}/${subdir}/${testfile}.core
+# Entry point of the original executable.
+set address 0x400078
+
+if {[catch "system \"uudecode -o - ${corebz2uufile} | bzip2 -dc >${corefile}\""] != 0} {
+ untested "failed uudecode or bzip2"
+ return -1
+}
+file stat ${corefile} corestat
+if {$corestat(size) != 102400} {
+ untested "uudecode or bzip2 produce invalid result"
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# Wrongly built GDB complains by:
+# "..." is not a core dump: File format not recognized
+# As the provided test core has 64bit PRSTATUS i386 built GDB cannot parse it.
+# This is just a problem of the test care, real-world elf64-i386 file will have
+# 32bit PRSTATUS. One cannot prepare elf64-i386 core file from elf32-i386 by
+# objcopy as it corrupts the core file beyond all recognition.
+gdb_test "core-file ${corefile}" "\r\nwarning: Unexpected size of section `\\.reg/6901' in core file\\.\r\n.*Core was generated by `\[^\r\n\]*'\\.\r\nProgram terminated with signal SIGSEGV, Segmentation fault\\.\r\n.*" "core-file"
+
+gdb_test "x/i $address" "\r\n\[ \t\]*$address:\[ \t\]*hlt\[ \t\]*" ".text is readable"