8
8
import socket
9
9
import binascii
10
10
import xml .parsers .expat
11
+ import xml .etree .ElementTree as ET
11
12
12
13
from . import rsp
13
14
from . import DebugAdapter
@@ -50,7 +51,7 @@ def connect(host, port):
50
51
51
52
def connect_sense (address , port ):
52
53
# connect to gdbserver, sense environment, return appropriate adapter
53
- sock = gdblike . connect (address , port )
54
+ sock = connect (address , port )
54
55
rsp_conn = rsp .RspConnection (sock )
55
56
56
57
adapt = None
@@ -69,12 +70,15 @@ def connect_sense(address, port):
69
70
if feature_name :
70
71
# select adapter type based on feature name
71
72
if feature_name == 'mame.z80' :
73
+ from . import mame_coleco
72
74
adapt = mame_coleco .DebugAdapterMameColeco ()
73
- elif feature_name == 'com.apple.debugserver.x86_64' :
75
+ elif feature_name .startswith ('com.apple.debugserver' ): # eg 'com.apple.debugserver.x86_64'
76
+ from . import lldb
74
77
adapt = lldb .DebugAdapterLLDB
75
78
else :
76
79
return None
77
80
if not adapt :
81
+ # TODO: can we "see" this if we're positioned above?
78
82
adapt = gdblike .DebugAdapterGdbLike
79
83
80
84
adapt .setup ()
@@ -83,7 +87,7 @@ def connect_sense(address, port):
83
87
return adapt
84
88
85
89
finally :
86
- if not ok :
90
+ if not adapt :
87
91
sock .close ()
88
92
89
93
def preexec ():
@@ -447,9 +451,9 @@ def handle_stop(self, reason, data):
447
451
448
452
reply = self .rspConn .tx_rx ('?' )
449
453
context = rsp .packet_T_to_dict (reply )
450
- if not 'thread' in context :
451
- raise DebugAdapter .GeneralError ('determing thread responsible for stop' )
452
- self .tid = context .get ('thread' )
454
+ # if not 'thread' in context:
455
+ # raise DebugAdapter.GeneralError('determing thread responsible for stop')
456
+ self .tid = context .get ('thread' , 0 )
453
457
454
458
def get_remote_file (self , fpath ):
455
459
#print('get_remote_file(%s)' % fpath)
@@ -633,7 +637,7 @@ def go_generic(self, gotype, handler_async_pkt=None):
633
637
# https://sourceware.org/gdb/current/onlinedocs/gdb/Stop-Reply-Packets.html#Stop-Reply-Packets
634
638
if reply [0 ] == 'T' :
635
639
tdict = rsp .packet_T_to_dict (reply )
636
- self .active_thread_tid = tdict [ 'thread' ]
640
+ self .active_thread_tid = tdict . get ( 'thread' , 0 )
637
641
(reason , reason_data ) = self .thread_stop_pkt_to_reason (tdict )
638
642
639
643
# exit status
0 commit comments