-
Notifications
You must be signed in to change notification settings - Fork 684
Splitting the debugger and console part of the python debugger #2406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good direction.
jerry-debugger/jerry_client.py
Outdated
return -1 | ||
|
||
|
||
def print_source(debugger, line_num, offset): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be part of the debugger, retuning a list of lines
jerry-debugger/jerry_client.py
Outdated
|
||
if result is None: | ||
continue | ||
elif '\3' in result: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\3?
jerry-debugger/jerry_client.py
Outdated
break | ||
|
||
prompt.debugger.mainloop() | ||
result = prompt.debugger.smessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't mainloop() return with this?
jerry-debugger/jerry_client_ws.py
Outdated
self._exec_command(JERRY_DEBUGGER_FINISH) | ||
|
||
def next(self): | ||
""" Next breakpoint in the same context """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these comments are used?
36874be
to
d39cd04
Compare
jerry-debugger/jerry_client.py
Outdated
self.quit = False | ||
self.cont = True | ||
self.debugger.non_interactive = False | ||
self.dsp = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this variable means or serve? This should be a more talkative name.
jerry-debugger/jerry_client.py
Outdated
if line_num >= 0: | ||
print(self.debugger.print_source(line_num, 0)) | ||
elif line_num == 0: | ||
print(self.debugger.print_source(self.debugger.default_viewrange, 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will never be reached (the previous condition already checked it).
jerry-debugger/jerry_client.py
Outdated
debugger.src_offset_diff = int(max(math.floor(debugger.display / 3), 1)) | ||
if direction == "up": | ||
debugger.src_offset -= debugger.src_offset_diff | ||
print(debugger.print_source(debugger.display, debugger.src_offset)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the print functions after the else statement to eliminate the code duplication.
jerry-debugger/jerry_client.py
Outdated
|
||
if args.client_source is not None: | ||
if args.client_source != []: | ||
prompt.debugger.store_client_sources(args.client_source) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for two if statements.
if args.client_source:
prompt.debugger.store_client_sources(args.client_source)
479a8d1
to
e545934
Compare
jerry-debugger/jerry_client.py
Outdated
|
||
prompt = DebuggerPrompt(debugger) | ||
prompt.prompt = "(jerry-debugger) " | ||
prompt.debugger.non_interactive = non_interactive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This non_interactive
variable is unnecessary. You can use arg.non_interactive
directly.
jerry-debugger/jerry_client_ws.py
Outdated
sbp = self.breakpoint_info | ||
self.breakpoint_info = '' | ||
return sbp | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be prettier.
_set_breakpoint(self, args, False)
if self.breakpoint_info == '':
return None
sbp = self.breakpoint_info
self.breakpoint_info = ''
return sbp
jerry-debugger/jerry_client_ws.py
Outdated
if not args: | ||
result = "Error: Status expected!" | ||
else: | ||
enable = int(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will leads to a crash if I gave a non integer argument. Please handle it also.
bf793e9
to
be9f4c2
Compare
jerry-debugger/jerry_client_ws.py
Outdated
self.breakpoint_info = '' | ||
return sbp | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the extra line.
jerry-debugger/jerry_client_ws.py
Outdated
else: | ||
result = "Error: Invalid input! Usage 1: [Enable] or 0: [Disable]." | ||
return result | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the nitpicks, but maybe you could rewrite this function to increase the readability.
def exception(self, args):
try:
enabled = int(args)
except (ValueError, TypeError) as val_errno:
return "Error: Positive integer number expected, %s" % (val_errno)
if enabled not in [0,1]:
return "Error: Invalid input! Usage 1: [Enable] or 0: [Disable]."
if enabled:
logging.debug("Stop at exception enabled")
self.send_exception_config(enabled)
return "Stop at exception enabled"
logging.debug("Stop at exception disabled")
self.send_exception_config(enabled)
return "Stop at exception disabled"
jerry-debugger/jerry_client.py
Outdated
except ValueError as val_errno: | ||
print("Error: Positive breakpoint index expected: %s" % val_errno) | ||
else: | ||
sbreak = self.debugger.set_break(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would do these checks on the other side (set_break), and return with a text. If the text is empty, don't print anything. Otherwise print the text.
jerry-debugger/jerry_client.py
Outdated
""" Lists the available breakpoints """ | ||
if self.debugger.active_breakpoint_list: | ||
print("=== %sActive breakpoints %s ===" % (self.debugger.green_bg, self.debugger.nocolor)) | ||
for breakpoint in self.debugger.active_breakpoint_list.values(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use functions to return these values instead of directly access private variables. Please make these variables private.
jerry-debugger/jerry_client.py
Outdated
|
||
result = prompt.debugger.mainloop() | ||
|
||
if result == '': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like a result with a type and data fields, where data depends on the type. It can be a simple class.
jerry-debugger/jerry_client.py
Outdated
if not args: | ||
print("Error: Breakpoint index expected") | ||
print("Delete the given breakpoint, use 'delete all|active|pending' to clear all the given breakpoints ") | ||
elif args in ['all', 'pending', 'active']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move all of these checks to debugger side.
fdd1c71
to
56718fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@TamasZakor Please rebase it to the master. |
61677d6
to
36f3a22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work just a minor suggestion.
jerry-debugger/jerry_client_ws.py
Outdated
@@ -169,7 +166,7 @@ def __str__(self): | |||
class JerryFunction(object): | |||
# pylint: disable=too-many-instance-attributes,too-many-arguments | |||
def __init__(self, is_func, byte_code_cp, source, source_name, line, column, name, lines, offsets): | |||
self.is_func = is_func | |||
self.is_func = True if is_func else False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the bool cast is necessary I'd rather use self.is_func = bool (is_func)
.
Move DebuggerPrompt to jerry_client.py Implement JerryDebugger functions in the jerry_client_ws.py file Server response is displayed by jerry_client.py JerryScript-DCO-1.0-Signed-off-by: Tamas Zakor [email protected]
Can we land this? |
Move DebuggerPrompt to jerry_client.py
Implement JerryDebugger functions in the jerry_client_ws.py file
Server response is displayed by jerry_client.py
JerryScript-DCO-1.0-Signed-off-by: Tamas Zakor [email protected]