aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-connection.exp
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2021-08-31 14:04:36 +0100
committerAndrew Burgess <aburgess@redhat.com>2021-11-30 12:10:40 +0000
commit24b2de7b776f8f23788d855b1eec290c6e208821 (patch)
tree9a2d7b705087364d8e4ce6585bf6f7ad39664004 /gdb/testsuite/gdb.python/py-connection.exp
parente5b176f25ff51f6811b82f549b7524618d5c2f6b (diff)
downloadbinutils-24b2de7b776f8f23788d855b1eec290c6e208821.zip
binutils-24b2de7b776f8f23788d855b1eec290c6e208821.tar.gz
binutils-24b2de7b776f8f23788d855b1eec290c6e208821.tar.bz2
gdb/python: add gdb.RemoteTargetConnection.send_packet
This commits adds a new sub-class of gdb.TargetConnection, gdb.RemoteTargetConnection. This sub-class is created for all 'remote' and 'extended-remote' targets. This new sub-class has one additional method over its base class, 'send_packet'. This new method is equivalent to the 'maint packet' CLI command, it allows a custom packet to be sent to a remote target. The outgoing packet can either be a bytes object, or a Unicode string, so long as the Unicode string contains only ASCII characters. The result of calling RemoteTargetConnection.send_packet is a bytes object containing the reply that came from the remote.
Diffstat (limited to 'gdb/testsuite/gdb.python/py-connection.exp')
-rw-r--r--gdb/testsuite/gdb.python/py-connection.exp14
1 files changed, 10 insertions, 4 deletions
diff --git a/gdb/testsuite/gdb.python/py-connection.exp b/gdb/testsuite/gdb.python/py-connection.exp
index b805b05..96c8378 100644
--- a/gdb/testsuite/gdb.python/py-connection.exp
+++ b/gdb/testsuite/gdb.python/py-connection.exp
@@ -33,12 +33,18 @@ if ![runto_main] then {
return 0
}
+if { [target_info exists gdb_protocol] } {
+ set connection_type "RemoteTargetConnection"
+} else {
+ set connection_type "TargetConnection"
+}
+
# Create a gdb.TargetConnection object and check it is initially
# valid.
gdb_test_no_output "python conn = gdb.selected_inferior().connection"
gdb_test "python print(conn)" \
- "<gdb.TargetConnection num=1, what=\"\[^\"\]+\">" \
- "print gdb.TargetConnection while it is still valid"
+ "<gdb.${connection_type} num=1, what=\"\[^\"\]+\">" \
+ "print gdb.${connection_type} while it is still valid"
gdb_test "python print(conn.is_valid())" "True" "is_valid returns True"
# Get the connection again, and ensure we get the exact same object.
@@ -53,8 +59,8 @@ gdb_test "disconnect" "" "kill the inferior" \
"A program is being debugged already\\. Kill it\\? .*y or n. $" "y"
gdb_test "info connections" "No connections\\." \
"info connections now all the connections have gone"
-gdb_test "python print(conn)" "<gdb.TargetConnection \\(invalid\\)>" \
- "print gdb.TargetConnection now its invalid"
+gdb_test "python print(conn)" "<gdb.${connection_type} \\(invalid\\)>" \
+ "print gdb.${connection_type} now its invalid"
gdb_test "python print(conn.is_valid())" "False" "is_valid returns False"
# Now check that accessing properties of the invalid connection cases