aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib/gdb-utils.exp
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/lib/gdb-utils.exp')
-rw-r--r--gdb/testsuite/lib/gdb-utils.exp60
1 files changed, 47 insertions, 13 deletions
diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp
index 95c53d0..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
@@ -38,6 +38,14 @@ proc string_to_regexp {str} {
return $result
}
+# Convenience function that calls string_to_regexp for each arg, and
+# joins the results using "\r\n".
+
+proc multi_line_string_to_regexp { args } {
+ set res [lmap arg $args {string_to_regexp $arg}]
+ return [multi_line {*}$res]
+}
+
# Given a list of strings, adds backslashes as needed to each string to
# create a regexp that will match the string, and join the result.
@@ -56,21 +64,27 @@ proc string_list_to_regexp { args } {
# STYLE can either be the payload part of an ANSI terminal sequence,
# or a shorthand for one of the gdb standard styles: "file",
-# "function", "variable", or "address".
+# "function", "variable", "address", etc.
proc style {str style} {
+ set fg 39
+ set bg 49
+ set intensity 22
+ set reverse 27
switch -exact -- $style {
- title { set style 1 }
- file { set style 32 }
- function { set style 33 }
- highlight { set style 31 }
- variable { set style 36 }
- address { set style 34 }
- metadata { set style 2 }
- version { set style "35;1" }
+ title { set intensity 1 }
+ command { set intensity 1 }
+ file { set fg 32 }
+ function { set fg 33 }
+ highlight { set fg 31 }
+ variable { set fg 36 }
+ address { set fg 34 }
+ metadata { set intensity 2 }
+ version { set fg 35; set intensity 1 }
+ line-number { set intensity 2 }
none { return $str }
}
- return "\033\\\[${style}m${str}\033\\\[m"
+ return "\033\\\[${fg};${bg};${intensity};${reverse}m${str}\033\\\[m"
}
# gdb_get_bp_addr num
@@ -102,14 +116,34 @@ 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.
+# return 1 if the comparison is true. OP can be "<", "<=", ">", ">=",
+# 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 {
"==" -
"<=" -
"<" {}
+
+ ">=" {
+ # a >= b => b <= a
+ set x $l2
+ set l2 $l1
+ set l1 $x
+ set op "<="
+ }
+
+ ">" {
+ # a > b => b < a
+ set x $l2
+ set l2 $l1
+ set l1 $x
+ set op "<"
+ }
+
default { error "unsupported op: $op" }
}