aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-09-15 13:34:14 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-10-22 13:42:49 +0100
commit8b87fbe6bb5f682fef889630664884ea8e7d6444 (patch)
treec6e54c9f2311f10a9195ffb80f059eb26899ddfd /gdb/testsuite
parent431be556b0bdd0733dedec2368d8d6a72cacea72 (diff)
downloadgdb-8b87fbe6bb5f682fef889630664884ea8e7d6444.zip
gdb-8b87fbe6bb5f682fef889630664884ea8e7d6444.tar.gz
gdb-8b87fbe6bb5f682fef889630664884ea8e7d6444.tar.bz2
gdb/python: new gdb.architecture_names function
Add a new function to the Python API, gdb.architecture_names(). This function returns a list containing all of the supported architecture names within the current build of GDB. The values returned in this list are all of the possible values that can be returned from gdb.Architecture.name().
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.python/py-arch.exp51
1 files changed, 51 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp
index 4f97112..415fbd4 100644
--- a/gdb/testsuite/gdb.python/py-arch.exp
+++ b/gdb/testsuite/gdb.python/py-arch.exp
@@ -62,3 +62,54 @@ if { ![is_address_zero_readable] } {
gdb_test "python arch.disassemble(0, 0)" ".*gdb\.MemoryError.*" \
"test bad memory access"
}
+
+# Test for gdb.architecture_names(). First we're going to grab the
+# complete list of architecture names using the 'complete' command.
+set arch_names []
+gdb_test_no_output "set max-completions unlimited"
+gdb_test_multiple "complete set architecture " "" {
+ -re "complete set architecture\[^\r\n\]+\r\n" {
+ exp_continue
+ }
+ -re "^set architecture \(\[^\r\n\]+\)\r\n" {
+ set arch $expect_out(1,string)
+ if { "$arch" != "auto" } {
+ set arch_names [lappend arch_names $arch]
+ }
+ exp_continue
+ }
+ -re "^$gdb_prompt $" {
+ gdb_assert { [llength $arch_names] > 0 }
+ }
+}
+
+# Now find all of the architecture names using Python.
+set py_arch_names []
+gdb_test_no_output "python all_arch = gdb.architecture_names()"
+gdb_test_no_output "python all_arch.sort()"
+gdb_test_multiple "python print(\"\\n\".join((\"Arch: %s\" % a) for a in all_arch))" "" {
+ -re "python \[^\r\n\]+\r\n" {
+ exp_continue
+ }
+ -re "^Arch: \(\[^\r\n\]+\)\r\n" {
+ set arch $expect_out(1,string)
+ set py_arch_names [lappend py_arch_names $arch]
+ exp_continue
+ }
+ -re "$gdb_prompt $" {
+ gdb_assert { [llength $py_arch_names] > 0 }
+ }
+}
+
+# Check the two lists of architecture names are the same length, and
+# that the list contents all match.
+gdb_assert { [llength $arch_names] == [llength $py_arch_names] }
+set lists_match true
+foreach a $arch_names b $py_arch_names {
+ if { $a != $b } {
+ set lists_match false
+ verbose -log "Mismatch is architecture list '$a' != '$b'"
+ break
+ }
+}
+gdb_assert { $lists_match }