Skip to content

Commit e956d9d

Browse files
committed
add default feature set of some features
If we look at https://xdebug.org/docs/dbgp#options-and-configuration in the feature names we see any dbgp debugger must provide some feature set by default. Even if that feature is not actually supported. So from now on we will set multiple_sessions = 0 because Vdebug does not support this at the moment and we will try to set extended_properties = 1; if the used debugger does not support it we will silently continue without the feature. fixes #369 Signed-off-by: BlackEagle <ike.devolder@gmail.com>
1 parent 6955437 commit e956d9d

2 files changed

Lines changed: 65 additions & 3 deletions

File tree

‎python3/vdebug/connection.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def send_msg(self, cmd):
8181
8282
cmd -- command to send
8383
"""
84-
#self.sock.send(cmd + '\0')
84+
# self.sock.send(cmd + '\0')
8585
MSGLEN = len(cmd)
8686
totalsent = 0
8787
while totalsent < MSGLEN:

‎python3/vdebug/session.py‎

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ def listen(self):
3737
print("Waiting for a connection: none found so far")
3838
elif self.listener and self.listener.is_ready():
3939
print("Found connection, starting debugger")
40+
log.Log("Got connection, starting", log.Logger.DEBUG)
4041
self.__new_session()
4142
else:
4243
self.start_listener()
4344

4445
def start_listener(self):
4546
self.listener = listener.Listener.create()
46-
print("Vdebug will wait for a connection in the background")
47+
print("Vdebug will wait for a connection")
4748
util.Environment.reload()
4849
if self.is_open():
4950
self.ui().set_status("listening")
@@ -103,6 +104,7 @@ def start_if_ready(self):
103104
try:
104105
if self.listener.is_ready():
105106
print("Found connection, starting debugger")
107+
log.Log("Got connection, starting", log.Logger.DEBUG)
106108
self.__new_session()
107109
return True
108110
return False
@@ -206,7 +208,9 @@ def start(self, connection):
206208
self.__ui.set_conn_details(addr[0], addr[1])
207209

208210
self.__collect_context_names()
209-
self.__set_features()
211+
self.__check_features() # only for debugging at the moment
212+
self.__set_default_features() # features we try by default
213+
self.__set_features() # user defined features
210214
self.__initialize_breakpoints()
211215

212216
if opts.Options.get('break_on_open', int) == 1:
@@ -229,6 +233,64 @@ def detach(self):
229233

230234
self.close_connection(False)
231235

236+
def __check_features(self):
237+
must_features = [
238+
'language_supports_threads',
239+
'language_name',
240+
'language_version',
241+
'encoding', # has set
242+
'protocol_version',
243+
'supports_async',
244+
'data_encoding',
245+
'breakpoint_languages',
246+
'breakpoint_types',
247+
'resolved_breakpoints',
248+
'multiple_sessions', # has set
249+
'max_children', # has set
250+
'max_data', # has set
251+
'max_depth', # has set
252+
'extended_properties', # has set
253+
]
254+
maybe_features = [
255+
'supported_encodings',
256+
'supports_postmortem',
257+
'show_hidden', # has set
258+
'notify_ok', # has set
259+
]
260+
for feature in must_features:
261+
try:
262+
feature_value = self.__api.feature_get(feature)
263+
log.Log(
264+
"Must Feature: %s = %s" % (feature, str(feature_value)),
265+
log.Logger.DEBUG
266+
)
267+
except dbgp.DBGPError:
268+
error_str = "Failed to get feature %s" % feature
269+
log.Log(error_str, log.Logger.DEBUG)
270+
271+
for feature in maybe_features:
272+
try:
273+
feature_value = self.__api.feature_get(feature)
274+
log.Log(
275+
"Maybe Feature: %s = %s" % (feature, str(feature_value)),
276+
log.Logger.DEBUG
277+
)
278+
except dbgp.DBGPError:
279+
error_str = "Failed to get feature %s" % feature
280+
log.Log(error_str, log.Logger.DEBUG)
281+
282+
def __set_default_features(self):
283+
features = {
284+
'multiple_sessions': 0, # explicitly disable multiple sessions atm
285+
'extended_properties': 1,
286+
}
287+
for name, value in features.items():
288+
try:
289+
self.__api.feature_set(name, value)
290+
except dbgp.DBGPError as e:
291+
error_str = "Failed to set feature %s: %s" % (name, e.args[0])
292+
log.Log(error_str, log.Logger.DEBUG)
293+
232294
def __set_features(self):
233295
"""Evaluate vim dictionary of features and pass to debugger.
234296

0 commit comments

Comments
 (0)