diff options
Diffstat (limited to 'gdb/testsuite/lib/ada.exp')
-rw-r--r-- | gdb/testsuite/lib/ada.exp | 71 |
1 files changed, 66 insertions, 5 deletions
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 + }] +} |