-# Copyright 2015 Free Software Foundation, Inc.
+# Copyright 2015-2019 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
standard_testfile
-if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
- verbose "Skipping i386-biarch-core test."
- return
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+set test "complete set gnutarget"
+gdb_test_multiple "complete set gnutarget " $test {
+ -re "set gnutarget elf64-little\r\n(.*\r\n)?$gdb_prompt $" {
+ pass $test
+ }
+ -re "\r\n$gdb_prompt $" {
+ pass $test
+ untested ".text is readable"
+ return
+ }
}
set corebz2file ${srcdir}/${subdir}/${testfile}.core.bz2
-set corefile ${objdir}/${subdir}/${testfile}.core
+set corefile [standard_output_file ${testfile}.core]
# Entry point of the original executable.
set address 0x400078
return -1
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+# First check if this particular GDB supports i386, otherwise we should not
+# expect the i386 core file to be loaded successfully.
+set supports_arch_i386 1
+set test "complete set architecture i386"
+gdb_test_multiple $test $test {
+ -re "\r\nset architecture i386\r\n(.*\r\n)?$gdb_prompt $" {
+ }
+ -re "\r\n$gdb_prompt $" {
+ set supports_arch_i386 0
+ }
+}
# Wrongly built GDB complains by:
# "..." is not a core dump: File format not recognized
# This is just a problem of the test case, 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"
+# The output therefore does not matter much, just we should not get GDB
+# internal error.
+#
+# If this particular GDB does not support i386, it is expected GDB will not
+# recognize the core file. If it does anyway, it should not crash.
+set test "load core file"
+gdb_test_multiple "core-file ${corefile}" $test {
+ -re "no core file handler recognizes format.*\r\n$gdb_prompt $" {
+ if { $supports_arch_i386 } {
+ fail $test
+ } else {
+ pass $test
+ untested ".text is readable (core file unrecognized)"
+ return
+ }
+ }
+ -re "\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
-gdb_test "x/i $address" "\r\n\[ \t\]*$address:\[ \t\]*hlt\[ \t\]*" ".text is readable"
+# Test if at least the core file segments memory has been loaded.
+# https://bugzilla.redhat.com/show_bug.cgi?id=457187
+gdb_test "x/bx $address" "\r\n\[ \t\]*$address:\[ \t\]*0xf4\[ \t\]*" ".text is readable"