-# Copyright (C) 2009-2017 Free Software Foundation, Inc.
+# Copyright (C) 2009-2020 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
# Test basic gdb.Inferior attributes and methods.
gdb_py_test_silent_cmd "python inferiors = gdb.inferiors ()" "get inferiors list" 1
-gdb_test "python print (inferiors)" "\\(<gdb.Inferior object at 0x\[\[:xdigit:\]\]+>,\\)" "verify inferiors list"
+gdb_test "python print (inferiors)" \
+ "\\(<gdb.Inferior num=1, pid=$decimal>,\\)" "verify inferiors list"
gdb_py_test_silent_cmd "python i0 = inferiors\[0\]" "get first inferior" 0
gdb_test "python print ('result = %s' % (i0 == inferiors\[0\]))" " = True" "test equality comparison (true)"
gdb_test "python print ('result = %s' % i0.was_attached)" " = False" "test Inferior.was_attached"
gdb_test "python print (i0.threads ())" "\\(<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>,\\)" "test Inferior.threads"
+gdb_test "python print (i0.progspace)" "<gdb.Progspace object at $hex>"
+gdb_test "python print (i0.progspace == gdb.progspaces()\[0\])" "True"
+
# Test the number of inferior threads.
gdb_breakpoint check_threads
gdb_test "python print (my_inferior_count)" "1" \
"test inferior-deleted event handler"
+
+ # Test that other properties and methods handle the removed inferior
+ # correctly.
+ gdb_test "python print (inf_list\[1\].num)" \
+ "RuntimeError: Inferior no longer exists.*"
+ gdb_test "python print (inf_list\[1\].pid)" \
+ "RuntimeError: Inferior no longer exists.*"
+ gdb_test "python print (inf_list\[1\].was_attached)" \
+ "RuntimeError: Inferior no longer exists.*"
+ gdb_test "python print (inf_list\[1\].progspace)" \
+ "RuntimeError: Inferior no longer exists.*"
+ gdb_test "python print (inf_list\[1\].threads ())" \
+ "RuntimeError: Inferior no longer exists.*"
+ gdb_test "python print (inf_list\[1\].thread_from_thread_handle (1))" \
+ "RuntimeError: Inferior no longer exists.*"
}
# Test gdb.selected_inferior()
gdb_test "inferior 1" ".*" "switch to first inferior"
gdb_test "py print (gdb.selected_inferior().num)" "1" "first inferior selected"
- gdb_test "add-inferior" "Added inferior 3" "create new inferior"
+ gdb_test "add-inferior" "Added inferior 3 on connection .*" "create new inferior"
gdb_test "inferior 3" ".*" "switch to third inferior"
gdb_test "py print (gdb.selected_inferior().num)" "3" "third inferior selected"
gdb_test "inferior 1" ".*" "switch back to first inferior"
gdb_test_no_output "remove-inferiors 3" "remove second inferior"
}
+
+# Test repr()/str()
+with_test_prefix "__repr__" {
+ gdb_test "add-inferior" "Added inferior 4 on connection .*" "add inferior 4"
+ gdb_py_test_silent_cmd "python infs = gdb.inferiors()" "get inferior list" 1
+ gdb_test "python print (infs\[0\])" "<gdb.Inferior num=1, pid=$decimal>"
+ gdb_test "python print (infs)" \
+ "\\\(<gdb.Inferior num=1, pid=$decimal>, <gdb.Inferior num=4, pid=$decimal>\\\)" \
+ "print all inferiors 1"
+ gdb_test_no_output "remove-inferiors 4"
+ gdb_test "python print (infs)" \
+ "\\\(<gdb.Inferior num=1, pid=$decimal>, <gdb.Inferior \\\(invalid\\\)>\\\)" \
+ "print all inferiors 2"
+}
+
+# Test architecture.
+with_test_prefix "architecture" {
+ gdb_test "inferior 1" ".*" "switch to first inferior"
+ gdb_test "python print(gdb.selected_frame().architecture() is gdb.selected_inferior().architecture())" \
+ "True" \
+ "inferior architecture matches frame architecture"
+}