diff options
Diffstat (limited to 'gdb/testsuite/lib')
61 files changed, 709 insertions, 256 deletions
diff --git a/gdb/testsuite/lib/aarch64-scalable.exp b/gdb/testsuite/lib/aarch64-scalable.exp index 2ba7d15..c9f2463 100644 --- a/gdb/testsuite/lib/aarch64-scalable.exp +++ b/gdb/testsuite/lib/aarch64-scalable.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# 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 diff --git a/gdb/testsuite/lib/aarch64-test-sme.c b/gdb/testsuite/lib/aarch64-test-sme.c index 2925b48..c5d7a8a 100644 --- a/gdb/testsuite/lib/aarch64-test-sme.c +++ b/gdb/testsuite/lib/aarch64-test-sme.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + 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 diff --git a/gdb/testsuite/lib/aarch64-test-sve.c b/gdb/testsuite/lib/aarch64-test-sve.c index d558a40..3eed754 100644 --- a/gdb/testsuite/lib/aarch64-test-sve.c +++ b/gdb/testsuite/lib/aarch64-test-sve.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + 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 diff --git a/gdb/testsuite/lib/aarch64.exp b/gdb/testsuite/lib/aarch64.exp index 602120a..ef64489 100644 --- a/gdb/testsuite/lib/aarch64.exp +++ b/gdb/testsuite/lib/aarch64.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# 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 diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp index 83b419a..37bed85 100644 --- a/gdb/testsuite/lib/ada.exp +++ b/gdb/testsuite/lib/ada.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -21,11 +21,21 @@ # to run, and BODY is what actually does the work. proc foreach_gnat_encoding {scenario_arg flags_arg list body} { + # gnat-llvm does not understand -fgnat-encodings at all. However, + # some tests examine the precise setting of the scenario -- so + # pretend we support minimal. What is going on here is that for + # gnat-llvm, there are no "GNAT encodings", only minimal + # encodings, aka, real DWARF. + set has_flag [ada_minimal_encodings] + if {!$has_flag} { + set list minimal + } + upvar 1 $scenario_arg scenario upvar 1 $flags_arg flags foreach_with_prefix scenario $list { set flags {} - if {$scenario != "none"} { + if {$scenario != "none" && $has_flag} { lappend flags additional_flags=-fgnat-encodings=$scenario } uplevel 1 $body @@ -171,12 +181,16 @@ proc find_ada_tool {tool} { # compiler does not appear to be GCC, this will always return false. proc gnat_version_compare {op l2} { - set gccvers [gcc_major_version] - if {$gccvers == -1} { + set gnatmake [find_gnatmake] + set gnatmake [lindex [split $gnatmake] 0] + if {[catch {exec $gnatmake --version} output]} { + return 0 + } + if {![regexp {GNATMAKE ([0-9]+(\.[0-9]+)*)} $output match version]} { return 0 } - return [version_compare [split $gccvers .] $op $l2] + return [version_compare [split $version .] $op $l2] } # Return 1 if the GNAT runtime appears to have debug info. @@ -241,3 +255,50 @@ gdb_caching_proc gnat_runtime_has_debug_info {} { gdb_caching_proc shared_gnat_runtime_has_debug_info {} { return [gnat_runtime_has_debug_info_1 1] } + +# A helper that writes an Ada source file, then tries to compile it +# with the given compiler options (a list like one accepted by +# gdb_compile_ada). Returns 1 if the flags are supported, 0 +# otherwise. +proc ada_simple_compile {name options} { + set src [standard_temp_file $name.adb] + set dest [standard_temp_file $name.x] + set f [open $src w] + puts $f "procedure $name is" + puts $f "begin" + puts $f " null;" + puts $f "end $name;" + close $f + + # Note that we create an executable here. For -fvar-tracking, at + # least, the option is supported and ignored by llvm-gnatmake -- + # but then is passed to clang during further compilation, and this + # fails. So to detect it we can't just stop with a .o file. + set output [gdb_compile_ada_1 $src $dest executable $options] + return [expr {[gdb_compile_test_nofail $output] == 1}] +} + +# Return 1 if GNAT supports -fvar-tracking. +gdb_caching_proc ada_fvar_tracking {} { + return [ada_simple_compile fvar_tracking additional_flags=-fvar-tracking] +} + +# Return 1 if GNAT supports the minimal encodings option. +gdb_caching_proc ada_minimal_encodings {} { + return [ada_simple_compile minimal_encodings \ + additional_flags=-fgnat-encodings=minimal] +} + +# Return 1 if GNAT supports -Og. +gdb_caching_proc ada_og {} { + return [ada_simple_compile gnat_og additional_flags=-Og] +} + +# Return 1 if GNAT can link with -shared. +gdb_caching_proc ada_shared_link {} { + return [ada_simple_compile ada_shared_link { + additional_flags=-bargs + additional_flags=-shared + additional_flags=-margs + }] +} diff --git a/gdb/testsuite/lib/append_gdb_boards_dir.exp b/gdb/testsuite/lib/append_gdb_boards_dir.exp index 4aedba9..fadb372 100644 --- a/gdb/testsuite/lib/append_gdb_boards_dir.exp +++ b/gdb/testsuite/lib/append_gdb_boards_dir.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/lib/attributes.h b/gdb/testsuite/lib/attributes.h index 5dabd03..626c226 100644 --- a/gdb/testsuite/lib/attributes.h +++ b/gdb/testsuite/lib/attributes.h @@ -1,6 +1,6 @@ /* This file is part of GDB, the GNU debugger. - Copyright (C) 2020-2024 Free Software Foundation, Inc. + Copyright (C) 2020-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 diff --git a/gdb/testsuite/lib/build-piece.exp b/gdb/testsuite/lib/build-piece.exp index 879fbf3..7de1f51 100644 --- a/gdb/testsuite/lib/build-piece.exp +++ b/gdb/testsuite/lib/build-piece.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-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 diff --git a/gdb/testsuite/lib/cache.exp b/gdb/testsuite/lib/cache.exp index ca3dca2..6ca3f18 100644 --- a/gdb/testsuite/lib/cache.exp +++ b/gdb/testsuite/lib/cache.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/lib/check-test-names.exp b/gdb/testsuite/lib/check-test-names.exp index 11aed63..049addd 100644 --- a/gdb/testsuite/lib/check-test-names.exp +++ b/gdb/testsuite/lib/check-test-names.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/lib/cl_util.c b/gdb/testsuite/lib/cl_util.c index 048346b..e5eb369 100644 --- a/gdb/testsuite/lib/cl_util.c +++ b/gdb/testsuite/lib/cl_util.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/lib/cl_util.h b/gdb/testsuite/lib/cl_util.h index 3d03c84..6034518 100644 --- a/gdb/testsuite/lib/cl_util.h +++ b/gdb/testsuite/lib/cl_util.h @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/lib/compile-support.exp b/gdb/testsuite/lib/compile-support.exp index aa8aaf3..dd0b9a9 100644 --- a/gdb/testsuite/lib/compile-support.exp +++ b/gdb/testsuite/lib/compile-support.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -45,6 +45,9 @@ proc _do_check_compile {expr} { # This appears to be a bug in the compiler plugin. set result "apparent compiler plugin bug" } + -re "This command is not supported." { + set result "compiler disabled at configure time" + } -re "\r\n$gdb_prompt $" { } } diff --git a/gdb/testsuite/lib/compiler.F90 b/gdb/testsuite/lib/compiler.F90 index 07f9852..b92b9c6 100644 --- a/gdb/testsuite/lib/compiler.F90 +++ b/gdb/testsuite/lib/compiler.F90 @@ -1,4 +1,4 @@ -/* Copyright 2022-2024 Free Software Foundation, Inc. +/* Copyright 2022-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 diff --git a/gdb/testsuite/lib/compiler.c b/gdb/testsuite/lib/compiler.c index 0749435..e457fba 100644 --- a/gdb/testsuite/lib/compiler.c +++ b/gdb/testsuite/lib/compiler.c @@ -1,6 +1,6 @@ /* This test file is part of GDB, the GNU debugger. - Copyright 1995-2024 Free Software Foundation, Inc. + Copyright 1995-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 diff --git a/gdb/testsuite/lib/compiler.cc b/gdb/testsuite/lib/compiler.cc index aa46228..ee2280f 100755 --- a/gdb/testsuite/lib/compiler.cc +++ b/gdb/testsuite/lib/compiler.cc @@ -1,6 +1,6 @@ /* This test file is part of GDB, the GNU debugger. - Copyright 1995-2024 Free Software Foundation, Inc. + Copyright 1995-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 diff --git a/gdb/testsuite/lib/completion-support.exp b/gdb/testsuite/lib/completion-support.exp index 5f0f619..15f59e6 100644 --- a/gdb/testsuite/lib/completion-support.exp +++ b/gdb/testsuite/lib/completion-support.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 diff --git a/gdb/testsuite/lib/cp-support.exp b/gdb/testsuite/lib/cp-support.exp index d883309..40351c6 100644 --- a/gdb/testsuite/lib/cp-support.exp +++ b/gdb/testsuite/lib/cp-support.exp @@ -1,6 +1,6 @@ # This test code is part of GDB, the GNU debugger. -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 diff --git a/gdb/testsuite/lib/d-support.exp b/gdb/testsuite/lib/d-support.exp index 3edb664..717d88b 100644 --- a/gdb/testsuite/lib/d-support.exp +++ b/gdb/testsuite/lib/d-support.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index 5c192e5..d61b1c4 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/lib/data-structures.exp b/gdb/testsuite/lib/data-structures.exp index 461a11c..ccf7e81 100644 --- a/gdb/testsuite/lib/data-structures.exp +++ b/gdb/testsuite/lib/data-structures.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 diff --git a/gdb/testsuite/lib/debuginfod-support.exp b/gdb/testsuite/lib/debuginfod-support.exp index 0096448..674888a 100644 --- a/gdb/testsuite/lib/debuginfod-support.exp +++ b/gdb/testsuite/lib/debuginfod-support.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/lib/dg-add-core-file-count.sh b/gdb/testsuite/lib/dg-add-core-file-count.sh index b4cb6b9..115cf51 100755 --- a/gdb/testsuite/lib/dg-add-core-file-count.sh +++ b/gdb/testsuite/lib/dg-add-core-file-count.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2022-2024 Free Software Foundation, Inc. +# Copyright (C) 2022-2025 Free Software Foundation, Inc. # This file is part of GDB. diff --git a/gdb/testsuite/lib/dtrace.exp b/gdb/testsuite/lib/dtrace.exp index fb6204f..d558aba 100644 --- a/gdb/testsuite/lib/dtrace.exp +++ b/gdb/testsuite/lib/dtrace.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index bcf3d73..3a182c2 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -678,6 +678,11 @@ namespace eval Dwarf { } } close $fd + + variable _constants + + # Add DW_FORM_strx_id as alias of DW_FORM_strx. + _process_one_constant DW_FORM_strx_id $_constants(DW_FORM_strx) } proc _quote {string} { @@ -823,6 +828,12 @@ namespace eval Dwarf { DW_FORM_indirect - DW_FORM_exprloc - + # Generate a DW_FORM_str index, but assume generation of .debug_str and + # .debug_str_offsets is taken care of elsewhere. + DW_FORM_strx_id { + _op .uleb128 $value + } + DW_FORM_strx - DW_FORM_strx1 - DW_FORM_strx2 - @@ -1061,7 +1072,10 @@ namespace eval Dwarf { } proc _section {name {flags ""} {type ""}} { - if {$flags == "" && $type == ""} { + if {$name == ".debug_str"} { + # Hard-code this because it's always desirable. + _emit " .section $name, \"MS\", %progbits, 1" + } elseif {$flags == "" && $type == ""} { _emit " .section $name" } elseif {$type == ""} { _emit " .section $name, \"$flags\"" @@ -1244,7 +1258,6 @@ namespace eval Dwarf { # used, as indicated in the header of the section where the location # description is found. # - # (FIXME should use 'info complete' here.) # Each list's first element is the opcode, either short or long # forms are accepted. # FIXME argument handling @@ -1252,9 +1265,18 @@ namespace eval Dwarf { proc _location { body dwarf_version addr_size offset_size } { variable _constants + set collected_lines "" foreach line [split $body \n] { # Ignore blank lines, and allow embedded comments. - if {[lindex $line 0] == "" || [regexp -- {^[ \t]*#} $line]} { + if { [regexp -- {^[ \t]*$} $line] || [regexp -- {^[ \t]*#} $line] } { + continue + } + if { $collected_lines != "" } { + set line "$collected_lines\n$line" + set collected_lines "" + } + if { ! [info complete $line] } { + set collected_lines $line continue } set opcode [_map_name [lindex $line 0] _OP] @@ -1340,6 +1362,17 @@ namespace eval Dwarf { _op .2byte $argvec(label) } + DW_OP_entry_value { + _get_args $line $opcode body + set l1 [new_label "expr_start"] + set l2 [new_label "expr_end"] + _op .uleb128 "$l2 - $l1" "expression" + define_label $l1 + _location $argvec(body) $dwarf_version $addr_size \ + $offset_size + define_label $l2 + } + DW_OP_implicit_value { set l1 [new_label "value_start"] set l2 [new_label "value_end"] @@ -1441,6 +1474,17 @@ namespace eval Dwarf { # default = default # fission 0|1 - boolean indicating if generating Fission debug info # default = 0 + # dwo_id - The value to use as the dwo_id field of skeleton and + # split_compile unit headers. May only be used with DWARF + # version 5. + # + # If a dwo_id value is specified (is non-zero), this unit is + # assumed to be part of a skeleton/split_unit pair. The unit + # type will be chosen according to the `fission` value. + # + # When using DWARF version 5 and fission is non-zero, it is + # mandatory to provide a non-zero dwo_id value. + # default = 0 # label <label> # - string indicating label to be defined at the start # of the CU header. @@ -1463,6 +1507,7 @@ namespace eval Dwarf { set _cu_version 4 set _cu_addr_size default set _cu_is_fission 0 + set dwo_id 0 set section ".debug_info" set _abbrev_section ".debug_abbrev" set label "" @@ -1474,6 +1519,7 @@ namespace eval Dwarf { version { set _cu_version $value } addr_size { set _cu_addr_size $value } fission { set _cu_is_fission $value } + dwo_id { set dwo_id $value } label { set label $value } default { error "unknown option $name" } } @@ -1524,12 +1570,42 @@ namespace eval Dwarf { # The CU header for DWARF 4 and 5 are slightly different. if { $_cu_version == 5 } { - _op .byte 0x1 "DW_UT_compile" + # The presence of a DWO_ID indicates that we generate a skeleton + # or split_compile unit. + if { $dwo_id != 0 } { + if { $_cu_is_fission } { + set unit_type_name "DW_UT_split_compile" + } else { + set unit_type_name "DW_UT_skeleton" + } + } else { + set unit_type_name "DW_UT_compile" + } + + _op .byte $_constants($unit_type_name) $unit_type_name _op .byte $_cu_addr_size "Pointer size" _op_offset $_cu_offset_size $my_abbrevs Abbrevs + + # Output DWO ID, if specified. + if { $dwo_id != 0 } { + _op .8byte $dwo_id "DWO_ID" + } else { + # To help catch user errors: if the caller asked to put this + # unit in the DWO file but didn't provide a DWO ID, it is likely + # an error. + if { $_cu_is_fission } { + error "DWO ID not specified for DWARF 5 split compile" + } + } } else { _op_offset $_cu_offset_size $my_abbrevs Abbrevs _op .byte $_cu_addr_size "Pointer size" + + # For DWARF versions < 5, the DWO ID is not in the unit header, + # so it makes not sense to specify one. + if { $dwo_id != 0 } { + error "DWO ID specified for DWARF < 5 unit" + } } _defer_output $_abbrev_section { @@ -1606,7 +1682,7 @@ namespace eval Dwarf { } if { $_cu_is_fission } { set section "$section.dwo" - set _abbrev_section "$section.dwo" + set _abbrev_section "$_abbrev_section.dwo" } _section $section @@ -3006,6 +3082,24 @@ namespace eval Dwarf { } } + # Emit a .debug_sup section with the given file name and build-id. + # The buildid should be represented as a hexadecimal string, like + # "ffeeddcc". + proc debug_sup {is_sup filename buildid} { + _defer_output .debug_sup { + # The version. + _op .2byte 0x5 + # Supplementary marker. + _op .byte $is_sup + _op .ascii [_quote $filename] + set len [expr {[string length $buildid] / 2}] + _op .uleb128 $len + foreach {a b} [split $buildid {}] { + _op .byte 0x$a$b + } + } + } + proc _note {type name hexdata} { set namelen [expr [string length $name] + 1] set datalen [expr [string length $hexdata] / 2] @@ -3130,10 +3224,11 @@ namespace eval Dwarf { } variable _debug_names set _debug_names [] - proc _debug_names_name { name tag cu hash } { + proc _debug_names_name { name tag cu hash {extra {}} } { variable _debug_names declare_labels entry_pool_offset - lappend _debug_names [list $name $tag $cu $hash $entry_pool_offset] + lappend _debug_names [list $name $tag $cu $hash $extra \ + $entry_pool_offset] } with_override Dwarf::cu Dwarf::_debug_names_cu { with_override Dwarf::tu Dwarf::_debug_names_tu { @@ -3196,14 +3291,13 @@ namespace eval Dwarf { # Hash Lookup Table - array of hashes. foreach idx $_debug_names { - set name [lindex $idx 0] - set hash [lindex $idx 3] + lassign $idx name tag cu hash extra label _op .4byte $hash "hash: $name" } # Name Table - array of string offsets. foreach idx $_debug_names { - set name [lindex $idx 0] + lassign $idx name tag cu hash extra label variable _strings if {![info exists _strings($name)]} { @@ -3220,8 +3314,7 @@ namespace eval Dwarf { # Name Table - array of entry offsets. set base_label "" foreach idx $_debug_names { - set name [lindex $idx 0] - set label [lindex $idx 4] + lassign $idx name tag cu hash extra label if { [string equal $base_label ""]} { set base_label $label } @@ -3234,31 +3327,42 @@ namespace eval Dwarf { set abbrev 1 variable _constants foreach idx $_debug_names { - set name [lindex $idx 0] - set tag [lindex $idx 1] - set cu [lindex $idx 2] + lassign $idx name tag cu hash extra label if { [regexp "^CU-($decimal)$" $cu dummy cu_index] } { - set attr_name compile_unit - set attr_val 1 + set attr_name DW_IDX_compile_unit } elseif { [regexp "^TU-($decimal)$" $cu dummy cu_index] } { - set attr_name type_unit - set attr_val 2 + set attr_name DW_IDX_type_unit } else { set cu_index [lsearch -exact $_debug_names_cus $cu] if { $cu_index == -1 } { - set attr_name type_unit - set attr_val 2 + set attr_name DW_IDX_type_unit } else { - set attr_name compile_unit - set attr_val 1 + set attr_name DW_IDX_compile_unit } } - _op .byte $abbrev "abbrev $abbrev" + _op .uleb128 $abbrev "abbrev $abbrev" _op .uleb128 $_constants(DW_TAG_$tag) "DW_TAG_$tag" - _op .byte $attr_val "DW_IDX_$attr_name (attribute)" - _op .byte 0x0f "DW_FORM_udata (form)" + _op .uleb128 $_constants($attr_name) \ + "$attr_name (attribute)" + _op .uleb128 0x0f "DW_FORM_udata (form)" + foreach word $extra { + if {$word == "static"} { + _op .uleb128 $_constants(DW_IDX_GNU_internal) \ + "DW_IDX_GNU_internal" + _op .uleb128 $_constants(DW_FORM_flag_present) \ + "DW_FORM_flag_present" + } elseif {[string match DW_LANG_* $word]} { + _op .uleb128 $_constants(DW_IDX_GNU_language) \ + "DW_IDX_GNU_language" + _op .uleb128 $_constants(DW_FORM_implicit_const) \ + "DW_FORM_flag_present" + _op .sleb128 $_constants($word) $word + } else { + error "unrecognized extra keyword $word" + } + } _op .byte 0 "abbrev terminator (attribute)" _op .byte 0 "abbrev terminator (form)" incr abbrev @@ -3269,9 +3373,7 @@ namespace eval Dwarf { # Entry Pool set abbrev 1 foreach idx $_debug_names { - set name [lindex $idx 0] - set cu [lindex $idx 2] - set label [lindex $idx 4] + lassign $idx name tag cu hash extra label if { [regexp "^CU-($decimal)$" $cu dummy cu_index] } { set comment "$name: CU index" @@ -3297,6 +3399,58 @@ namespace eval Dwarf { debug_names_end: } + # Add the strings in ARGS to the .debug_str section, and create a + # .debug_str_offsets section pointing to those strings. + # Current options are: + # dwo 0|1 - boolean indicating if the sections have the dwo suffix. + # default = 0 (no .dwo suffix) + # base_offset label + # - generate label, to be used in DW_AT_str_offsets_base. + # default = "" (don't generate a label). + proc debug_str_offsets { options args } { + parse_options { + { dwo 0 } + { base_offset "" } + } + + if { $dwo } { + _section .debug_str.dwo + } else { + _section .debug_str + } + + set num 0 + foreach arg $args { + set str_label [_compute_label "str_${num}"] + define_label $str_label + _op .asciz \"$arg\" ".debug_str_offsets string $num" + incr num + } + + declare_labels debug_str_offsets_start debug_str_offsets_end + set initial_length "$debug_str_offsets_end - $debug_str_offsets_start" + + if { $dwo } { + _section .debug_str_offsets.dwo + } else { + _section .debug_str_offsets + } + _op .4byte $initial_length "Initial_length" + debug_str_offsets_start: + _op .2byte 0x5 "version" + _op .2byte 0x0 "padding" + if { $base_offset != "" } { + $base_offset: + } + set num 0 + foreach arg $args { + set str_label [_compute_label "str_${num}"] + _op .4byte $str_label "string $num" + incr num + } + debug_str_offsets_end: + } + # The top-level interface to the DWARF assembler. # OPTIONS is a list with an even number of elements containing # option-name and option-value pairs. diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp index cddcc3a..6f2bbd8 100644 --- a/gdb/testsuite/lib/fortran.exp +++ b/gdb/testsuite/lib/fortran.exp @@ -1,6 +1,6 @@ # This test code is part of GDB, the GNU debugger. -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp index 62913cb..161c31c 100644 --- a/gdb/testsuite/lib/future.exp +++ b/gdb/testsuite/lib/future.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 diff --git a/gdb/testsuite/lib/gdb-guile.exp b/gdb/testsuite/lib/gdb-guile.exp index 412dd56..776dbc6 100644 --- a/gdb/testsuite/lib/gdb-guile.exp +++ b/gdb/testsuite/lib/gdb-guile.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/lib/gdb-python.exp b/gdb/testsuite/lib/gdb-python.exp index a820c87..e026c1b 100644 --- a/gdb/testsuite/lib/gdb-python.exp +++ b/gdb/testsuite/lib/gdb-python.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -77,3 +77,24 @@ proc gdb_py_module_available { name } { return ${available} } + +# Run a memory leak test within the Python script FILENAME. This proc +# checks that the required Python modules are available, sets up the +# syspath so that the helper module can be found (in the same +# directory as FILENAME), then loads FILENAME to run the test. +proc gdb_py_run_memory_leak_test { filename testname } { + if { ![gdb_py_module_available "tracemalloc"] } { + unsupported "$testname (tracemalloc module not available)" + } + + gdb_test_no_output -nopass "python import sys" + gdb_test_no_output -nopass \ + "python sys.path.insert(0, \"[file dirname $filename]\")" \ + "setup sys.path" + + set pyfile [gdb_remote_download host ${filename}] + + # Source the Python script, this runs the test, and either prints + # PASS, or throws an exception. + gdb_test "source ${pyfile}" "^PASS" $testname +} diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp index b8ab30a..fe2cfca 100644 --- a/gdb/testsuite/lib/gdb-utils.exp +++ b/gdb/testsuite/lib/gdb-utils.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -117,7 +117,10 @@ proc gdb_get_bp_addr { num } { # Compare the version numbers in L1 to those in L2 using OP, and # return 1 if the comparison is true. OP can be "<", "<=", ">", ">=", -# or "==". It is ok if the lengths of the lists differ. +# or "==". +# It is ok if the lengths of the lists differ, but note that we have +# "{1} < {1 0}" instead of "{1} == {1 0}". See also +# gdb.testsuite/version-compare.exp. proc version_compare { l1 op l2 } { switch -exact $op { diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 56dc835..777d64d 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -45,9 +45,9 @@ proc cond_wrap { cond wrap body } { } } -# Helper function for set_sanitizer/set_sanitizer_default. +# Helper function for append_environment/append_environment_default. -proc set_sanitizer_1 { env_var var_id val default} { +proc append_environment_1 { env_var var_id val default} { global env if { ![info exists env($env_var) ] @@ -70,17 +70,17 @@ proc set_sanitizer_1 { env_var var_id val default} { # Add VAR_ID=VAL to ENV_VAR. -proc set_sanitizer { env_var var_id val } { - set_sanitizer_1 $env_var $var_id $val 0 +proc append_environment { env_var var_id val } { + append_environment_1 $env_var $var_id $val 0 } # Add VAR_ID=VAL to ENV_VAR, unless ENV_VAR already contains a VAR_ID setting. -proc set_sanitizer_default { env_var var_id val } { - set_sanitizer_1 $env_var $var_id $val 1 +proc append_environment_default { env_var var_id val } { + append_environment_1 $env_var $var_id $val 1 } -set_sanitizer_default TSAN_OPTIONS suppressions \ +append_environment_default TSAN_OPTIONS suppressions \ $srcdir/../tsan-suppressions.txt # When using ThreadSanitizer we may run into the case that a race is detected, @@ -89,14 +89,14 @@ set_sanitizer_default TSAN_OPTIONS suppressions \ # Try to prevent this by setting history_size to the maximum (7) by default. # See also the ThreadSanitizer docs ( # https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags ). -set_sanitizer_default TSAN_OPTIONS history_size 7 +append_environment_default TSAN_OPTIONS history_size 7 # If GDB is built with ASAN (and because there are leaks), it will output a # leak report when exiting as well as exit with a non-zero (failure) status. # This can affect tests that are sensitive to what GDB prints on stderr or its # exit status. Add `detect_leaks=0` to the ASAN_OPTIONS environment variable # (which will affect any spawned sub-process) to avoid this. -set_sanitizer_default ASAN_OPTIONS detect_leaks 0 +append_environment_default ASAN_OPTIONS detect_leaks 0 # List of procs to run in gdb_finish. set gdb_finish_hooks [list] @@ -269,6 +269,13 @@ if ![info exists INTERNAL_GDBFLAGS] { } set INTERNAL_GDBFLAGS [append_gdb_data_directory_option $INTERNAL_GDBFLAGS] + + # Handle the case that "interactive-mode auto" reports off. + append INTERNAL_GDBFLAGS { -iex "set interactive-mode on"} + + if { [ishost "*-*-mingw*"] } { + append INTERNAL_GDBFLAGS { -iex "maint set console-translation-mode binary"} + } } # The variable gdb_prompt is a regexp which matches the gdb prompt. @@ -1026,7 +1033,10 @@ proc command_to_message { command } { # should not be anchored at the end of the buffer. This means that the # pattern can match even if there is stuff output after the prompt. Does not # have any effect if -prompt is specified. -# -lbl specifies that line-by-line matching will be used. +# -lbl specifies that line-by-line matching will be used. This means +# that lines from GDB not matched by any pattern will be consumed from +# the output buffer. This helps avoid buffer overflows and timeouts +# when testing verbose commands. # EXPECT_ARGUMENTS will be fed to expect in addition to the standard # patterns. Pattern elements will be evaluated in the caller's # context; action elements will be executed in the caller's context. @@ -1124,6 +1134,7 @@ proc gdb_test_multiple { command message args } { global any_spawn_id set line_by_line 0 + set lbl_anchor_re "" set prompt_regexp "" set prompt_anchor 1 for {set i 0} {$i < [llength $args]} {incr i} { @@ -1133,6 +1144,7 @@ proc gdb_test_multiple { command message args } { set prompt_regexp [lindex $args $i] } elseif { $arg == "-lbl" } { set line_by_line 1 + set lbl_anchor_re "^" } elseif { $arg == "-no-prompt-anchor" } { set prompt_anchor 0 } else { @@ -1391,7 +1403,7 @@ proc gdb_test_multiple { command message args } { fail "$errmsg" set result -1 } - -re "\r\n$prompt_regexp" { + -re "${lbl_anchor_re}\r\n$prompt_regexp" { if {![string match "" $message]} { fail "$message" } @@ -2301,7 +2313,8 @@ proc default_gdb_exit {} { } } - if { [is_remote host] && [board_info host exists fileid] } { + if { ([is_remote host] && [board_info host exists fileid]) + || [istarget *-*-mingw*] } { send_gdb "quit\n" gdb_expect 10 { -re "y or n" { @@ -2314,7 +2327,9 @@ proc default_gdb_exit {} { } if ![is_remote host] { - remote_close host + if {[catch { remote_close host } message]} { + warning "closing gdb failed with: $message" + } } unset gdb_spawn_id unset ::gdb_tty_name @@ -2491,7 +2506,7 @@ proc default_gdb_spawn { } { global INTERNAL_GDBFLAGS GDBFLAGS global gdb_spawn_id - # Set the default value, it may be overriden later by specific testfile. + # Set the default value, it may be overridden later by specific testfile. # # Use `set_board_info use_gdb_stub' for the board file to flag the inferior # is already started after connecting and run/attach are not supported. @@ -2577,6 +2592,17 @@ proc default_gdb_start { } { # Output with -q, and bracketed paste mode enabled, see above. verbose "GDB initialized." } + -re "^\033\\\[6n$gdb_prompt $" { + # With MSYS2 and TERM={xterm,ansi}, I get: + # + # builtin_spawn gdb -q ... + # ^[[6n(gdb) + # + # We set TERM to dumb by default to avoid this, but some + # test-cases set TERM to xterm or ansi, in which case we get this + # output. + verbose "GDB initialized." + } -re "$gdb_prompt $" { perror "GDB never initialized." unset gdb_spawn_id @@ -2641,35 +2667,58 @@ proc gdb_interact { } { # Examine the output of compilation to determine whether compilation # failed or not. If it failed determine whether it is due to missing +# compiler or due to compiler error. Return 1 for pass, 0 for fail, +# -1 for unsupported (missing compiler), and -2 for unsupported (bad +# option) -- but do not issue a pass/fail directly. + +proc gdb_compile_test_nofail {output} { + if { $output == "" } { + return 1 + } + + if { [regexp {^[a-zA-Z_0-9]+: Can't find [^ ]+\.$} $output] + || [regexp {.*: command not found[\r|\n]*$} $output] + || [regexp {.*: [^\r\n]*compiler not installed[^\r\n]*[\r|\n]*$} $output] } { + return -1 + } + + set gcc_re ".*: error: unrecognized command line option " + set clang_re ".*: error: unsupported option " + if { [regexp "(?:$gcc_re|$clang_re)(\[^ \t;\r\n\]*)" $output dummy option] + && $option != "" } { + return -2 + } + + # Unclassified compilation failure, be more verbose. + verbose -log "compilation failed: $output" 2 + return 0 +} + +# Examine the output of compilation to determine whether compilation +# failed or not. If it failed determine whether it is due to missing # compiler or due to compiler error. Report pass, fail or unsupported # as appropriate. proc gdb_compile_test {src output} { set msg "compilation [file tail $src]" - if { $output == "" } { + set result [gdb_compile_test_nofail $output] + if {$result == 1} { pass $msg return } - if { [regexp {^[a-zA-Z_0-9]+: Can't find [^ ]+\.$} $output] - || [regexp {.*: command not found[\r|\n]*$} $output] - || [regexp {.*: [^\r\n]*compiler not installed[^\r\n]*[\r|\n]*$} $output] } { + if {$result == -1} { unsupported "$msg (missing compiler)" return } - set gcc_re ".*: error: unrecognized command line option " - set clang_re ".*: error: unsupported option " - if { [regexp "(?:$gcc_re|$clang_re)(\[^ \t;\r\n\]*)" $output dummy option] - && $option != "" } { + if {$result == -2} { unsupported "$msg (unsupported option $option)" return } - # Unclassified compilation failure, be more verbose. - verbose -log "compilation failed: $output" 2 - fail "$msg" + fail $msg } # Return a 1 for configurations for which we want to try to test C++. @@ -2776,6 +2825,12 @@ gdb_caching_proc allow_python_tests {} { return [expr {[string first "--with-python" $output] != -1}] } +# Return a 1 if GDB was configured to support compile commands. +gdb_caching_proc allow_compile_tests {} { + set output [remote_exec host $::GDB "$::INTERNAL_GDBFLAGS -ex \"compile int x = 1\" -batch"] + return [expr {[string first "The program must be running" $output] != -1}] +} + # Return a 1 for configurations that use system readline rather than the # in-repo copy. @@ -3729,7 +3784,8 @@ proc supports_reverse {} { || [istarget "aarch64*-*-linux*"] || [istarget "loongarch*-*-linux*"] || [istarget "powerpc*-*-linux*"] - || [istarget "s390*-*-linux*"] } { + || [istarget "s390*-*-linux*"] + || [istarget "riscv*-*-*"] } { return 1 } @@ -3908,13 +3964,16 @@ gdb_caching_proc is_aarch32_target {} { return 0 } - set list {} - foreach reg \ - {r0 r1 r2 r3} { - lappend list "\tmov $reg, $reg" - } + return [gdb_can_simple_compile aarch32 { + int main (void) { + asm ("\tmov r0, r0"); + asm ("\tmov r1, r1"); + asm ("\tmov r2, r2"); + asm ("\tmov r3, r3"); - return [gdb_can_simple_compile aarch32 [join $list \n]] + return 0; + } + }] } # Return 1 if this target is an aarch64, either lp64 or ilp32. @@ -5054,6 +5113,40 @@ proc skip_inline_var_tests {} { return 0 } +# Return whether we allow running fork-related testcases. Targets +# that don't even have any concept of fork will just fail to compile +# the testcases and skip the tests that way if this returns true for +# them. Unix targets that do have a fork system call, but don't +# support intercepting forks will want to return false here, otherwise +# the testcases that exercise fork may hit a number of long cascading +# time out sequences. + +proc allow_fork_tests {} { + if {[istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"]} { + return 0 + } + + return 1 +} + +# Return whether we allow running testcases that want to debug +# multiple inferiors with the same target. Not all targets support +# this. Note that some tests add a second inferior but never start +# it. Those tests should not be skipped due to this proc returning +# false. + +proc allow_multi_inferior_tests {} { + if {[istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"]} { + return 0 + } + + if {[use_gdb_stub]} { + return 0 + } + + return 1 +} + # Return a 1 if we should run tests that require hardware breakpoints proc allow_hw_breakpoint_tests {} { @@ -5241,7 +5334,7 @@ proc is_any_target {args} { # # This is the preferred way of checking use_gdb_stub, since it allows to check # the value before the gdb has been spawned and it will return the correct value -# even when it was overriden by the test. +# even when it was overridden by the test. # # Note that stub targets are not able to spawn new inferiors. Use this # check for skipping respective tests. @@ -5917,6 +6010,23 @@ proc gdb_compile {source dest type options} { } } + # On AIX systems, until GCC 12 (maybe later), stabs was the default + # debug option, but we'd like to have dwarf instead. + # If we're running on one of those systems and debug was requested, + # but no explicit -g<format> option was given, use -gdwarf to force + # that as the debug info for the inferior. + # This list should be exhaustive: + set debug_format "btf|ctf|stabs|vms|coff|xcoff" + # Since additional_flags is a comma separated list, identify if there + # are other (optional) flags in the list. + set other_options "-\[a-zA-Z0-9\]*," + set full_regexp "^additional_flags=\($other_options\)*-g\($debug_format\)" + if { [istarget *-*-aix*] + && [lsearch -exact $options debug] != -1 + && [lsearch -regexp $options $full_regexp] == -1} { + lappend new_options "additional_flags=-gdwarf" + } + set shlib_found 0 set shlib_load 0 foreach opt $options { @@ -6870,7 +6980,7 @@ proc kill_wait_spawned_process { proc_spawn_id } { proc spawn_id_get_pid { spawn_id } { set testpid [exp_pid -i $spawn_id] - if { [istarget "*-*-cygwin*"] } { + if { [istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"] } { # testpid is the Cygwin PID, GDB uses the Windows PID, which # might be different due to the way fork/exec works. set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] @@ -6957,6 +7067,24 @@ proc gdb_load_cmd { args } { return -1 } +# Return non-zero if 'gcore' command is available. +gdb_caching_proc gcore_cmd_available { } { + gdb_exit + gdb_start + + # Does this gdb support gcore? + gdb_test_multiple "help gcore" "" { + -re -wrap "Undefined command: .*" { + return 0 + } + -re -wrap "Save a core file .*" { + return 1 + } + } + + return 0 +} + # Invoke "gcore". CORE is the name of the core file to write. TEST # is the name of the test case. This will return 1 if the core file # was created, 0 otherwise. If this fails to make a core file because @@ -7421,6 +7549,22 @@ proc default_gdb_init { test_file_name } { setenv LC_CTYPE C setenv LANG C + # With MSYS2 and TERM={xterm,ansi}, I get: + # + # builtin_spawn gdb -q ... + # ^[[6n(gdb) + # + # While we're addressing this in default_gdb_start, this is not specific + # to gdb, other tools produce the same CSI sequence, and consequently we + # run into trouble in other places (like get_compiler_info). + # + # Set TERM to dumb to prevent the '^[[6n' from occurring. + # + # We could do this only for ishost *-*-mingw*, but that introduces + # inconsistency between platforms, with test-cases passing on one platform + # but failing on the other. So, we do this for all platforms. + setenv TERM dumb + # Don't let a .inputrc file or an existing setting of INPUTRC mess # up the test results. Certain tests (style tests and TUI tests) # want to set the terminal to a non-"dumb" value, and for those we @@ -9236,7 +9380,12 @@ proc core_find {binfile {deletefiles {}} {arg ""}} { file mkdir $coredir catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile} ${arg}; true) >/dev/null 2>&1\"" # remote_exec host "${binfile}" - foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" { + set binfile_basename [file tail $binfile] + foreach i [list \ + ${coredir}/core \ + ${coredir}/core.coremaker.c \ + ${coredir}/${binfile_basename}.core \ + ${coredir}/${binfile_basename}.exe.core] { if [remote_file build exists $i] { remote_exec build "mv $i $destcore" set found 1 @@ -11016,5 +11165,50 @@ gdb_caching_proc root_user {} { return [expr $uid == 0] } +# Return nul-terminated string read from section SECTION of EXEC. Return "" +# if no such section or nul-terminated string was found. Function is useful +# for sections ".interp" or ".gnu_debuglink". + +proc section_get {exec section} { + global subdir + set tmp [standard_output_file section_get.tmp] + set objcopy_program [gdb_find_objcopy] + + set command "exec $objcopy_program -O binary --set-section-flags $section=A --change-section-address $section=0 -j $section $exec $tmp" + verbose -log "command is $command" + set result [catch $command output] + verbose -log "result is $result" + verbose -log "output is $output" + if {$result == 1} { + return "" + } + set fi [open $tmp] + fconfigure $fi -translation binary + set data [read $fi] + close $fi + file delete $tmp + # .interp has size $len + 1 but .gnu_debuglink contains garbage after \000. + set len [string first \000 $data] + if {$len < 0} { + verbose -log "section $section not found" + return "" + } + set retval [string range $data 0 [expr $len - 1]] + verbose -log "section $section is <$retval>" + return $retval +} + +# Return 1 if the compiler supports __builtin_trap, else return 0. + +gdb_caching_proc have_builtin_trap {} { + + return [gdb_can_simple_compile builtin_trap { + int main() { + __builtin_trap (); + return 0; + } + } executable] +} + # Always load compatibility stuff. load_lib future.exp diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp index 346c9b9..2389206 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -1,4 +1,4 @@ -# Copyright 2000-2024 Free Software Foundation, Inc. +# Copyright 2000-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 @@ -69,7 +69,7 @@ proc gdb_target_cmd_ext { targetname serialport {additional_text ""} } { } -re "Non-stop mode requested, but remote does not support non-stop.*$gdb_prompt $" { verbose "remote does not support non-stop" - return 1 + return 2 } -re "Remote MIPS debugging.*$additional_text.*$gdb_prompt" { verbose "Set target to $targetname" diff --git a/gdb/testsuite/lib/gen-perf-test.exp b/gdb/testsuite/lib/gen-perf-test.exp index a4debf8..dbdc79b 100644 --- a/gdb/testsuite/lib/gen-perf-test.exp +++ b/gdb/testsuite/lib/gen-perf-test.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2024 Free Software Foundation, Inc. +# Copyright (C) 2013-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 diff --git a/gdb/testsuite/lib/gnat_debug_info_test.adb b/gdb/testsuite/lib/gnat_debug_info_test.adb index b8f0b03..b195cb8 100644 --- a/gdb/testsuite/lib/gnat_debug_info_test.adb +++ b/gdb/testsuite/lib/gnat_debug_info_test.adb @@ -1,3 +1,18 @@ +-- Copyright 2019-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 <http://www.gnu.org/licenses/>. + with Ada.Text_IO; procedure GNAT_Debug_Info_Test is diff --git a/gdb/testsuite/lib/go.exp b/gdb/testsuite/lib/go.exp index 4525d77..5f668e2 100644 --- a/gdb/testsuite/lib/go.exp +++ b/gdb/testsuite/lib/go.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/lib/jit-elf-helpers.exp b/gdb/testsuite/lib/jit-elf-helpers.exp index 4d9c055..e5c328e 100644 --- a/gdb/testsuite/lib/jit-elf-helpers.exp +++ b/gdb/testsuite/lib/jit-elf-helpers.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/lib/memory.exp b/gdb/testsuite/lib/memory.exp index 6675641..b8aadb6 100644 --- a/gdb/testsuite/lib/memory.exp +++ b/gdb/testsuite/lib/memory.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 3832137..aba13a2 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -1,4 +1,4 @@ -# Copyright 1999-2024 Free Software Foundation, Inc. +# Copyright 1999-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 @@ -131,7 +131,7 @@ proc mi_create_inferior_pty {} { } } -# Create a new pty, and reate a new MI UI (using the new-ui command) on it. +# Create a new pty, and create a new MI UI (using the new-ui command) on it. # # Return a list with the spawn id for that pty and the pty file name. @@ -247,7 +247,7 @@ proc default_mi_gdb_start { { flags {} } } { return [mi_gdb_start_separate_mi_tty $flags] } - # Set the default value, it may be overriden later by specific testfile. + # Set the default value, it may be overridden later by specific testfile. set use_gdb_stub [target_info exists use_gdb_stub] # Start SID. @@ -1953,40 +1953,41 @@ proc mi_run_inline_test { testcase } { } proc get_mi_thread_list {name} { - global expect_out - - # MI will return a list of thread ids: - # - # -thread-list-ids - # ^done,thread-ids=[thread-id="1",thread-id="2",...],number-of-threads="N" - # (gdb) - mi_gdb_test "-thread-list-ids" \ - {.*\^done,thread-ids={(thread-id="[0-9]+"(,)?)+},current-thread-id="[0-9]+",number-of-threads="[0-9]+"} \ - "-thread_list_ids ($name)" - - set output {} - if {[info exists expect_out(buffer)]} { - set output $expect_out(buffer) - } - - set thread_list {} - if {![regexp {thread-ids=\{(thread-id="[0-9]+"(,)?)*\}} $output threads]} { - fail "finding threads in MI output ($name)" - } else { - pass "finding threads in MI output ($name)" - - # Make list of console threads - set start [expr {[string first \{ $threads] + 1}] - set end [expr {[string first \} $threads] - 1}] - set threads [string range $threads $start $end] - foreach thread [split $threads ,] { - if {[scan $thread {thread-id="%d"} num]} { - lappend thread_list $num - } + # MI will return a list of thread ids: + # + # -thread-list-ids + # ^done,thread-ids={thread-id="1",thread-id="2",...},number-of-threads="N" + # (gdb) + # + # In case there are too many threads, the expect buffer would + # become full. Process the buffer contents in small chunks. + set thread_list {} + set num_threads "unknown" + set test "$name: get MI thread list" + gdb_test_multiple "-thread-list-ids" $test -prompt "$::mi_gdb_prompt" { + -re "done,thread-ids=\{" { + exp_continue + } + -re "^thread-id=\"($::decimal)\"(,|\})" { + lappend thread_list $expect_out(1,string) + exp_continue + } + -re "^,current-thread-id=\"$::decimal\"" { + exp_continue + } + -re "^,number-of-threads=\"($::decimal)\"" { + set num_threads $expect_out(1,string) + exp_continue + } + -re "^\r\n$::mi_gdb_prompt" { + pass $gdb_test_name + } } - } - return $thread_list + gdb_assert {[llength $thread_list] == $num_threads} \ + "$name: found thread ids in MI output" + + return $thread_list } # Helper function for check_mi_and_console_threads. diff --git a/gdb/testsuite/lib/my-syscalls.S b/gdb/testsuite/lib/my-syscalls.S index 19df0ca..c514b32 100644 --- a/gdb/testsuite/lib/my-syscalls.S +++ b/gdb/testsuite/lib/my-syscalls.S @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/lib/my-syscalls.h b/gdb/testsuite/lib/my-syscalls.h index 8de28ae..03c6f7e 100644 --- a/gdb/testsuite/lib/my-syscalls.h +++ b/gdb/testsuite/lib/my-syscalls.h @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/lib/notty-wrap b/gdb/testsuite/lib/notty-wrap index 93b81fb..3011753 100755 --- a/gdb/testsuite/lib/notty-wrap +++ b/gdb/testsuite/lib/notty-wrap @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2021-2024 Free Software Foundation, Inc. +# Copyright (C) 2021-2025 Free Software Foundation, Inc. # # This file is part of GDB. # diff --git a/gdb/testsuite/lib/objc.exp b/gdb/testsuite/lib/objc.exp index 1378f56..cf1fed9 100644 --- a/gdb/testsuite/lib/objc.exp +++ b/gdb/testsuite/lib/objc.exp @@ -1,6 +1,6 @@ # This test code is part of GDB, the GNU debugger. -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/lib/opencl.exp b/gdb/testsuite/lib/opencl.exp index caa0e1e..2a5300e 100644 --- a/gdb/testsuite/lib/opencl.exp +++ b/gdb/testsuite/lib/opencl.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/lib/opencl_hostapp.c b/gdb/testsuite/lib/opencl_hostapp.c index 7637a0f..c39995f 100644 --- a/gdb/testsuite/lib/opencl_hostapp.c +++ b/gdb/testsuite/lib/opencl_hostapp.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp index 236eca1..d76cdca 100644 --- a/gdb/testsuite/lib/pascal.exp +++ b/gdb/testsuite/lib/pascal.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 diff --git a/gdb/testsuite/lib/pdtrace.in b/gdb/testsuite/lib/pdtrace.in index 08b9efa..a629ff6 100755 --- a/gdb/testsuite/lib/pdtrace.in +++ b/gdb/testsuite/lib/pdtrace.in @@ -2,7 +2,7 @@ # A Poor (but Free) Man's dtrace # -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-2025 Free Software Foundation, Inc. # # Contributed by Oracle, Inc. # diff --git a/gdb/testsuite/lib/perftest.exp b/gdb/testsuite/lib/perftest.exp index b4c997a..cca0ede 100644 --- a/gdb/testsuite/lib/perftest.exp +++ b/gdb/testsuite/lib/perftest.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2024 Free Software Foundation, Inc. +# Copyright (C) 2013-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 diff --git a/gdb/testsuite/lib/precise-aligned-alloc.c b/gdb/testsuite/lib/precise-aligned-alloc.c index 4f55ffd..b914afe 100644 --- a/gdb/testsuite/lib/precise-aligned-alloc.c +++ b/gdb/testsuite/lib/precise-aligned-alloc.c @@ -1,6 +1,6 @@ /* This test file is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/lib/prelink-support.exp b/gdb/testsuite/lib/prelink-support.exp index 894af39..a712a7a 100644 --- a/gdb/testsuite/lib/prelink-support.exp +++ b/gdb/testsuite/lib/prelink-support.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2024 Free Software Foundation, Inc. +# Copyright (C) 2010-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 @@ -13,39 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# Return nul-terminated string read from section SECTION of EXEC. Return "" -# if no such section or nul-terminated string was found. Function is useful -# for sections ".interp" or ".gnu_debuglink". - -proc section_get {exec section} { - global subdir - set tmp [standard_output_file section_get.tmp] - set objcopy_program [gdb_find_objcopy] - - set command "exec $objcopy_program -O binary --set-section-flags $section=A --change-section-address $section=0 -j $section $exec $tmp" - verbose -log "command is $command" - set result [catch $command output] - verbose -log "result is $result" - verbose -log "output is $output" - if {$result == 1} { - return "" - } - set fi [open $tmp] - fconfigure $fi -translation binary - set data [read $fi] - close $fi - file delete $tmp - # .interp has size $len + 1 but .gnu_debuglink contains garbage after \000. - set len [string first \000 $data] - if {$len < 0} { - verbose -log "section $section not found" - return "" - } - set retval [string range $data 0 [expr $len - 1]] - verbose -log "section $section is <$retval>" - return $retval -} - # Resolve symlinks. proc symlink_resolve {file} { diff --git a/gdb/testsuite/lib/prompt.exp b/gdb/testsuite/lib/prompt.exp index a19a057..7fa131b 100644 --- a/gdb/testsuite/lib/prompt.exp +++ b/gdb/testsuite/lib/prompt.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -32,7 +32,7 @@ proc default_prompt_gdb_start { } { global timeout global gdb_spawn_id - # Set the default value, it may be overriden later by specific testfile. + # Set the default value, it may be overridden later by specific testfile. # # Use `set_board_info use_gdb_stub' for the board file to flag the inferior # is already started after connecting and run/attach are not supported. diff --git a/gdb/testsuite/lib/range-stepping-support.exp b/gdb/testsuite/lib/range-stepping-support.exp index 1f1f9d7..27587e5 100644 --- a/gdb/testsuite/lib/range-stepping-support.exp +++ b/gdb/testsuite/lib/range-stepping-support.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 diff --git a/gdb/testsuite/lib/read1.c b/gdb/testsuite/lib/read1.c index 29570c9..c4c9ee2 100644 --- a/gdb/testsuite/lib/read1.c +++ b/gdb/testsuite/lib/read1.c @@ -1,6 +1,6 @@ /* This is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/lib/rocm.exp b/gdb/testsuite/lib/rocm.exp index b2db0d5..d3f201c 100644 --- a/gdb/testsuite/lib/rocm.exp +++ b/gdb/testsuite/lib/rocm.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2024 Free Software Foundation, Inc. +# Copyright (C) 2019-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 @@ -15,48 +15,83 @@ # # Support library for testing ROCm (AMD GPU) GDB features. -# Get the list of gpu targets to compile for. -# -# If HCC_AMDGPU_TARGET is set in the environment, use it. Otherwise, -# try reading it from the system using the rocm_agent_enumerator -# utility. +# ROCM_PATH is used by hipcc as well. +if {[info exists ::env(ROCM_PATH)]} { + set rocm_path $::env(ROCM_PATH) +} else { + set rocm_path "/opt/rocm" +} -proc hcc_amdgpu_targets {} { - # Look for HCC_AMDGPU_TARGET (same env var hipcc uses). If - # that fails, try using rocm_agent_enumerator (again, same as - # hipcc does). - if {[info exists ::env(HCC_AMDGPU_TARGET)]} { - return [split $::env(HCC_AMDGPU_TARGET) ","] +# Act as a drop-in replacement for "remote_exec host" +# that logs the failures. + +proc log_host_exec { cmd } { + set result [remote_exec host "$cmd"] + set exit_status [lindex $result 0] + if {$exit_status != 0} { + # -1 indicates that $cmd could not be executed at all. + if {$exit_status == -1} { + verbose -log "Cannot execute $cmd." + } else { + verbose -log "$cmd returned an error." + } } - set rocm_agent_enumerator "rocm_agent_enumerator" + return $result +} - # If available, use ROCM_PATH to locate rocm_agent_enumerator. - if { [info exists ::env(ROCM_PATH)] } { - set rocm_agent_enumerator \ - "$::env(ROCM_PATH)/bin/rocm_agent_enumerator" +# Detect available AMDGPU devices. +# +# Return a list of GPU devices that do exist on the system. +# The list will be empty when there's no GPU or the execution +# of rocm_agent_enumerator does not succeed. It is up to the +# caller of this procedure that what should happen when an empty +# list is returned. + +gdb_caching_proc find_amdgpu_devices {} { + global rocm_path + set hip_gpu_devices [list] + set enumerator "rocm_agent_enumerator" + set targets "" + + # Try the PATH first + set result [log_host_exec "$enumerator"] + if {[lindex $result 0] == 0} { + set targets [lindex $result 1] + } else { + # Now try the ROCM_PATH + set result [log_host_exec "$rocm_path/bin/$enumerator"] + if {[lindex $result 0] == 0} { + set targets [lindex $result 1] + } } - # If we fail to locate the rocm_agent_enumerator, just return an empty - # list of targets and let the caller decide if this should be an error. - if { [which $rocm_agent_enumerator] == 0 } { - return [list] + if {$targets != ""} { + foreach dev $targets { + # Ignore the 'gfx000' device which identifies the host. + if {$dev != "gfx000"} { + lappend hip_gpu_devices $dev + } + } } - set result [remote_exec host $rocm_agent_enumerator] - if { [lindex $result 0] != 0 } { - error "rocm_agent_enumerator failed" - } + return $hip_gpu_devices +} - set targets [list] - foreach target [lindex $result 1] { - # Ignore gfx000 which is the host CPU. - if { $target ne "gfx000" } { - lappend targets $target - } +# Get the list of GPU targets to compile for. +# +# If HCC_AMDGPU_TARGET is set in the environment, use it. +# Otherwise, consider the devices available on the system. + +proc hcc_amdgpu_targets {} { + # First, look for HCC_AMDGPU_TARGET (same env var hipcc uses). + if {[info exists ::env(HCC_AMDGPU_TARGET)]} { + # We don't verify the contents of HCC_AMDGPU_TARGET. + # That's the toolchain's job. + return [split $::env(HCC_AMDGPU_TARGET) ","] } - return $targets + return [find_amdgpu_devices] } gdb_caching_proc allow_hipcc_tests {} { @@ -77,12 +112,15 @@ gdb_caching_proc allow_hipcc_tests {} { return {0 "amd-dbgapi not supported"} } - # Check we have a working hipcc compiler available. - set targets [hcc_amdgpu_targets] - if { [llength $targets] == 0} { + # Check if there's any GPU device to run the tests on. + set devices [find_amdgpu_devices] + if {[llength $devices] == 0} { return {0 "no suitable amdgpu targets found"} } + # Check if we have a working hipcc compiler available. + # TARGETS won't be empty, because there's at least one GPU device. + set targets [hcc_amdgpu_targets] set flags [list hip additional_flags=--offload-arch=[join $targets ","]] if {![gdb_simple_compile hipprobe { #include <hip/hip_runtime.h> @@ -126,26 +164,7 @@ proc hip_devices_support_debug_multi_process {} { set unsupported_targets \ {gfx900 gfx906 gfx908 gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032} - set targets [hcc_amdgpu_targets] - if { [llength $targets] == 0 } { - return 0 - } - - foreach target $targets { - if { [lsearch -exact $unsupported_targets $target] != -1 } { - return 0 - } - } - return 1 -} - -# Return true if all the devices on the host support precise memory. - -proc hip_devices_support_precise_memory {} { - set unsupported_targets \ - {gfx900 gfx906 gfx908 gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032} - - set targets [hcc_amdgpu_targets] + set targets [find_amdgpu_devices] if { [llength $targets] == 0 } { return 0 } diff --git a/gdb/testsuite/lib/rust-support.exp b/gdb/testsuite/lib/rust-support.exp index 971a4a6..94888e9 100644 --- a/gdb/testsuite/lib/rust-support.exp +++ b/gdb/testsuite/lib/rust-support.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp index 0d76e2f..e037664 100644 --- a/gdb/testsuite/lib/selftest-support.exp +++ b/gdb/testsuite/lib/selftest-support.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 diff --git a/gdb/testsuite/lib/set_unbuffered_mode.c b/gdb/testsuite/lib/set_unbuffered_mode.c index 0c92d55..f0604a0 100644 --- a/gdb/testsuite/lib/set_unbuffered_mode.c +++ b/gdb/testsuite/lib/set_unbuffered_mode.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2024 Free Software Foundation, Inc. +/* Copyright (C) 2008-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/lib/sym-info-cmds.exp b/gdb/testsuite/lib/sym-info-cmds.exp index 9714529..c94b06f 100644 --- a/gdb/testsuite/lib/sym-info-cmds.exp +++ b/gdb/testsuite/lib/sym-info-cmds.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/lib/trace-support.exp b/gdb/testsuite/lib/trace-support.exp index 770a930..a8d0699 100644 --- a/gdb/testsuite/lib/trace-support.exp +++ b/gdb/testsuite/lib/trace-support.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2024 Free Software Foundation, Inc. +# Copyright (C) 1998-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 diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 0c4e3d1..a0cd199 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -1133,11 +1133,16 @@ namespace eval Term { gdb_assert {![regexp -- $regexp $contents]} $test_name } - # Get the region of the screen described by X, Y, WIDTH, - # and HEIGHT, and separate the lines using SEP. - proc get_region { x y width height sep } { + # Get the region of the screen described by X, Y, WIDTH, and + # HEIGHT, and separate the lines using SEP. If ATTRS is true then + # include attribute information in the output. + proc get_region { x y width height sep { attrs false } } { variable _chars + if { $attrs } { + _reset_attrs region_attrs + } + # Grab the contents of the box, join each line together # using $sep. set result "" @@ -1148,9 +1153,19 @@ namespace eval Term { append result $sep } for {set xx $x} {$xx < [expr {$x + $width}]} {incr xx} { - append result [lindex $_chars($xx,$yy) 0] + if { $attrs } { + set char_attrs [lindex $_chars($xx,$yy) 1] + append result [apply_attrs region_attrs $char_attrs] + } + + append result [get_char $xx $yy] } } + if { $attrs } { + _reset_attrs zero_attrs + set char_attrs [array get zero_attrs] + append result [apply_attrs region_attrs $char_attrs] + } return $result } diff --git a/gdb/testsuite/lib/unbuffer_output.c b/gdb/testsuite/lib/unbuffer_output.c index a286e3f..cdaa227 100644 --- a/gdb/testsuite/lib/unbuffer_output.c +++ b/gdb/testsuite/lib/unbuffer_output.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2024 Free Software Foundation, Inc. +/* Copyright (C) 2008-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/lib/valgrind.exp b/gdb/testsuite/lib/valgrind.exp index c952e92..aad0a3b 100644 --- a/gdb/testsuite/lib/valgrind.exp +++ b/gdb/testsuite/lib/valgrind.exp @@ -1,4 +1,4 @@ -# Copyright 2009-2024 Free Software Foundation, Inc. +# Copyright 2009-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 |