-
Notifications
You must be signed in to change notification settings - Fork 688
Add restart command to the debugger #2401
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
Add restart command to the debugger #2401
Conversation
zherczeg
left a comment
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 happens if client source is enabled and a r353t comes?
jerry-main/main-unix.c
Outdated
| register_js_function ("assert", jerryx_handler_assert); | ||
| register_js_function ("gc", jerryx_handler_gc); | ||
| register_js_function ("print", jerryx_handler_print); | ||
| if (jerry_is_feature_enabled (JERRY_FEATURE_DEBUGGER)) |
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 (jerry_is_feature_enabled (JERRY_FEATURE_DEBUGGER))
&& jerry_value_is_abort (ret_value))
| break; | ||
| } | ||
|
|
||
| jerry_cleanup (); |
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 happens with ret_value?
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.
The ret_value is released in case of "r353t" match, otherwise that value is needed in the global error checking, around line 840.
jerry-main/main-unix.c
Outdated
|
|
||
| register_js_function ("assert", jerryx_handler_assert); | ||
| register_js_function ("gc", jerryx_handler_gc); | ||
| register_js_function ("print", jerryx_handler_print); |
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 looks like a code duplication (init engine). Would be good to move it into a static function.
|
@zherczeg I've updated the PR. |
|
Closes the connection and restart jerry and wait for sources again? Sounds ok. |
|
@zherczeg I've updated the PR, now the restart works properly in wait mode, too. |
jerry-main/main-unix.c
Outdated
| jerry_value_t str_val = jerry_value_to_string (abort_value); | ||
| jerry_size_t str_size = jerry_get_string_size (str_val); | ||
| jerry_size_t str_end = jerry_string_to_char_buffer (str_val, str_buf, str_size); | ||
| assert (str_end == str_size); |
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 assert please!
Abort can contain any string. Just check if str size is 5, and compare it.
jerry-main/main-unix.c
Outdated
| assert (str_end == str_size); | ||
| str_buf[str_end] = 0; | ||
|
|
||
| if (strcmp ("r353t", (const char *) (str_buf)) == 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.
I would prefer memcmp here. It would make str_buf[str_end] = 0; unnecessary.
|
@zherczeg done, removed the assert and used memcmp instead of strcmp. |
jerry-main/main-unix.c
Outdated
| jerry_char_t str_buf[6]; | ||
| jerry_value_t str_val = jerry_value_to_string (abort_value); | ||
| jerry_size_t str_size = jerry_get_string_size (str_val); | ||
| jerry_size_t str_end = jerry_string_to_char_buffer (str_val, str_buf, str_size); |
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.
Better but this is still not 100%
+ jerry_size_t str_size = jerry_get_string_size (str_val);
+ jerry_size_t str_end = jerry_string_to_char_buffer (str_val, str_buf, str_size);
Please check the str_size before jerry_string_to_char_buffer because this might be a memory overwrite.
I also think that jerry_size_t str_end is unnecessary.
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.
You are right.
With this feature the use can restart the actual debug session (similar to the multiple source context reset) within a client. JerryScript-DCO-1.0-Signed-off-by: Imre Kiss kissi.szeged@partner.samsung.com
|
@zherczeg I've updated the PR. |
zherczeg
left a comment
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
yichoi
left a comment
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
With this feature the use can restart the actual debug session
(similar to the multiple source context reset) within a client.
JerryScript-DCO-1.0-Signed-off-by: Imre Kiss kissi.szeged@partner.samsung.com