Fix some style issues in the python debugger client. (#3603)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2020-03-11 16:01:12 +01:00
committed by GitHub
parent 055f753d02
commit 57b8599581
3 changed files with 19 additions and 18 deletions
+3 -1
View File
@@ -133,6 +133,8 @@ class DebuggerPrompt(Cmd):
line_num = src_check_args(args) line_num = src_check_args(args)
if line_num >= 0: if line_num >= 0:
write(self.debugger.print_source(line_num, 0)) write(self.debugger.print_source(line_num, 0))
else:
write(self.debugger.print_source(0, 0))
do_source = do_src do_source = do_src
def do_scroll(self, _): def do_scroll(self, _):
@@ -150,7 +152,7 @@ class DebuggerPrompt(Cmd):
def do_continue(self, _): def do_continue(self, _):
""" Continue execution """ """ Continue execution """
self.debugger.get_continue() self.debugger.do_continue()
self.stop = True self.stop = True
if not self.debugger.non_interactive: if not self.debugger.non_interactive:
print("Press enter to stop JavaScript execution.") print("Press enter to stop JavaScript execution.")
+14 -17
View File
@@ -340,16 +340,19 @@ class JerryDebugger(object):
self.channel.close() self.channel.close()
def _exec_command(self, command_id): def _exec_command(self, command_id):
self.send_command(command_id) message = struct.pack(self.byte_order + "BB",
1,
command_id)
self.channel.send_message(self.byte_order, message)
def quit(self): def quit(self):
self.prompt = False self.prompt = False
self._exec_command(JERRY_DEBUGGER_CONTINUE) self._exec_command(JERRY_DEBUGGER_CONTINUE)
def stop(self): def stop(self):
self.send_command(JERRY_DEBUGGER_STOP) self._exec_command(JERRY_DEBUGGER_STOP)
def get_continue(self): def do_continue(self):
self.prompt = False self.prompt = False
self._exec_command(JERRY_DEBUGGER_CONTINUE) self._exec_command(JERRY_DEBUGGER_CONTINUE)
@@ -628,12 +631,6 @@ class JerryDebugger(object):
byte_code_cp) byte_code_cp)
self.channel.send_message(self.byte_order, message) self.channel.send_message(self.byte_order, message)
def send_command(self, command):
message = struct.pack(self.byte_order + "BB",
1,
command)
self.channel.send_message(self.byte_order, message)
def send_exception_config(self, enable): def send_exception_config(self, enable):
message = struct.pack(self.byte_order + "BBB", message = struct.pack(self.byte_order + "BBB",
1 + 1, 1 + 1,
@@ -715,7 +712,7 @@ class JerryDebugger(object):
return DebuggerAction(DebuggerAction.TEXT, result) return DebuggerAction(DebuggerAction.TEXT, result)
elif buffer_type == JERRY_DEBUGGER_WAITING_AFTER_PARSE: elif buffer_type == JERRY_DEBUGGER_WAITING_AFTER_PARSE:
self.send_command(JERRY_DEBUGGER_PARSER_RESUME) self._exec_command(JERRY_DEBUGGER_PARSER_RESUME)
elif buffer_type == JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP: elif buffer_type == JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP:
self._release_function(data) self._release_function(data)
@@ -811,7 +808,7 @@ class JerryDebugger(object):
self.scopes = data[1:] self.scopes = data[1:]
if buffer_type == JERRY_DEBUGGER_SCOPE_CHAIN_END: if buffer_type == JERRY_DEBUGGER_SCOPE_CHAIN_END:
result = self.process_scopes() result = self._process_scopes()
self.scopes = "" self.scopes = ""
self.prompt = True self.prompt = True
@@ -822,7 +819,7 @@ class JerryDebugger(object):
self.scope_vars += "".join(data[1:]) self.scope_vars += "".join(data[1:])
if buffer_type == JERRY_DEBUGGER_SCOPE_VARIABLES_END: if buffer_type == JERRY_DEBUGGER_SCOPE_VARIABLES_END:
result = self.process_scope_variables() result = self._process_scope_variables()
self.scope_vars = "" self.scope_vars = ""
self.prompt = True self.prompt = True
@@ -1194,7 +1191,7 @@ class JerryDebugger(object):
return "Uncaught exception: %s" % (message) return "Uncaught exception: %s" % (message)
return message return message
def process_scope_variables(self): def _process_scope_variables(self):
buff_size = len(self.scope_vars) buff_size = len(self.scope_vars)
buff_pos = 0 buff_pos = 0
@@ -1234,11 +1231,11 @@ class JerryDebugger(object):
elif value_type == JERRY_DEBUGGER_VALUE_OBJECT: elif value_type == JERRY_DEBUGGER_VALUE_OBJECT:
table.append([name, 'Object', value]) table.append([name, 'Object', value])
result = self.form_table(table) result = self._form_table(table)
return result return result
def process_scopes(self): def _process_scopes(self):
result = "" result = ""
table = [['level', 'type']] table = [['level', 'type']]
@@ -1257,11 +1254,11 @@ class JerryDebugger(object):
else: else:
raise Exception("Unexpected scope chain element") raise Exception("Unexpected scope chain element")
result = self.form_table(table) result = self._form_table(table)
return result return result
def form_table(self, table): def _form_table(self, table):
result = "" result = ""
col_width = [max(len(x) for x in col) for col in zip(*table)] col_width = [max(len(x) for x in col) for col in zip(*table)]
for line in table: for line in table:
+2
View File
@@ -17,5 +17,7 @@ Stopped at tests/debugger/do_src.js:21
(jerry-debugger) step (jerry-debugger) step
Stopped at <unknown>:2 (in f() at line:1, col:5) Stopped at <unknown>:2 (in f() at line:1, col:5)
(jerry-debugger) src (jerry-debugger) src
1 f = function f() {
2 > print('F2') }
(jerry-debugger) c (jerry-debugger) c
out: F2 out: F2