# This testcase is part of GDB, the GNU debugger. # # Copyright 2023-2025 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 . # Some kernel core files have PID 0 (for the idle task), check that # GDB can handle such a core file. standard_testfile # Set CF_NAME, the name of the compressed core file within the source # tree, and CF_SIZE, the size (in bytes) of the uncompressed core # file. if {[istarget "x86_64-*-linux*"]} { set cf_name ${testfile}.x86-64.core.bz2 set cf_size 8757248 } else { unsupported "no pre-generated core file for this target" return -1 } # Decompress the core file. set corebz2file ${srcdir}/${subdir}/${cf_name} set corefile [decompress_bz2 $corebz2file] if { $corefile eq "" } { untested "failed to bunzip2 the core file" return -1 } # Check the size of the decompressed core file. Just for sanity. file stat ${corefile} corestat if { $corestat(size) != ${cf_size} } { untested "uncompressed core file is the wrong size" return -1 } # Copy over the corefile if we are remote testing. set corefile [gdb_remote_download host $corefile] clean_restart # Load the core file. At one point GDB would assert, complaining that # the inferior was nullptr. For now we see a message about the # current thread having terminated, this is because GDB gets confused # and incorrectly deletes what should be the current thread. gdb_test "core-file ${corefile}" \ [multi_line \ "warning: found threads with pid 0, assigned replacement Target Ids: LWP 1, LWP 2" \ ".*" \ "Core was generated by \[^\r\n\]+\\." \ "Program terminated with signal (?:11|SIGSEGV), Segmentation fault\\." \ "#0\\s+$hex in \[^\r\n\]+" \ "\\\[Current thread is 1 \\(LWP 1\\)\\\]"] \ "check core file termination reason" # And check GDB has found both threads. gdb_test "info threads" \ [multi_line \ "\\* 1\\s+LWP 1\\s+$hex in \[^\r\n\]+" \ " 2\\s+LWP 2\\s+$hex in \[^\r\n\]+"] \ "check both threads are visible"