-
Notifications
You must be signed in to change notification settings - Fork 686
Add the ability to throw an error to python debugger #2188
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 the ability to throw an error to python debugger #2188
Conversation
efd640f to
e1bdb40
Compare
| || JERRY_CONTEXT (debugger_stop_context) == JERRY_CONTEXT (vm_top_context_p))) | ||
| { | ||
| jerry_debugger_breakpoint_hit (JERRY_DEBUGGER_BREAKPOINT_HIT); | ||
| if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_THROW_ERROR_FLAG) |
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 think there are multiple jerry_debugger_breakpoint_hits in the vm. What happns when the others are called and an exception is thrown?
jerry-core/vm/vm.c
Outdated
| ecma_string_t *string_p = ecma_get_string_from_value (to_string_value); | ||
| ECMA_STRING_TO_UTF8_STRING (string_p, buffer_p, buffer_size); | ||
| jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Uncaught exception: %.*s\n", buffer_size, buffer_p); | ||
| ECMA_FINALIZE_UTF8_STRING (buffer_p, buffer_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.
Do we need to log this? The user sent the request after all.
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've removed the logging part.
jerry-debugger/jerry-client-ws.py
Outdated
| JERRY_DEBUGGER_OUTPUT_RESULT = 25 | ||
| JERRY_DEBUGGER_OUTPUT_RESULT_END = 26 | ||
| JERRY_DEBUGGER_STHROW = 27 | ||
| JERRY_DEBUGGER_STHROW_END = 28 |
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 function sends a byte, not a string. Actually only two values are allowed. What about sending a stop instead?
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've changed the function to send a 0 or 1 only to the client.
jerry-core/debugger/debugger.h
Outdated
|
|
||
| JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT, /**< number of different type of input messages */ | ||
| JERRY_DEBUGGER_THROW = 18, | ||
| JERRY_DEBUGGER_THROW_PART = 19, |
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.
Where is this symbol is used?
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've updated the python client, so these messages are used, when the string is sent.
e1bdb40 to
cfec624
Compare
|
@zherczeg PR Updated, thanks for the review! |
8dc5df5 to
eee7051
Compare
jerry-core/debugger/debugger.c
Outdated
| JERRY_ASSERT (*expected_message_type_p == JERRY_DEBUGGER_EVAL_PART | ||
| || *expected_message_type_p == JERRY_DEBUGGER_CLIENT_SOURCE_PART); | ||
| || *expected_message_type_p == JERRY_DEBUGGER_CLIENT_SOURCE_PART | ||
| || *expected_message_type_p == JERRY_DEBUGGER_THROW_PART); |
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.
swap the last two lines.
| { | ||
| *expected_message_type_p = JERRY_DEBUGGER_THROW_PART; | ||
| } | ||
|
|
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.
*expected_message_type_p = (is_eval ? JERRY_DEBUGGER_EVAL_PART
: JERRY_DEBUGGER_THROW_PART);
jerry-core/debugger/debugger.h
Outdated
| JERRY_DEBUGGER_OUTPUT_RESULT_END = 26, /**< last output result data */ | ||
|
|
||
| JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT, /**< number of different type of output messages by the debugger */ | ||
| JERRY_DEBUGGER_THROW_STOP = 27, /**< sends the client the info to terminate */ |
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.
comment: "signals the client that the throw is successful" ?
eee7051 to
33f1ece
Compare
|
@zherczeg I have updated the PR, thank you for the suggestions! |
dc56350 to
24c12e5
Compare
jerry-core/vm/vm.c
Outdated
| { | ||
| result = JERRY_CONTEXT (error_value); | ||
| ecma_free_value (local_err); | ||
| goto error; |
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.
Would this work here:
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_THROW_ERROR_FLAG)
{
ecma_free_value (local_err);
}
else
{
JERRY_CONTEXT (error_value) = local_err;
}
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.
Perhaps I would rename local_err to current_error_value
jerry-core/debugger/debugger.c
Outdated
| size_t eval_string_size) /**< evaluated string size */ | ||
| jerry_debugger_send_eval_or_throw (const lit_utf8_byte_t *eval_string_p, /**< evaluated string */ | ||
| size_t eval_string_size, /**< evaluated string size */ | ||
| bool *is_eval) /**< throw or eval call*/ |
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.
Add [in,out] to the comment.
24c12e5 to
948d01c
Compare
|
@zherczeg Sorry for the late update, thank you for the review. |
|
Please rebase. The debugger tests are failing at the moment. |
948d01c to
4a0af3f
Compare
This patch makes it possible to throw an error from the python debugger client using the `throw` command. JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
4a0af3f to
4ee1040
Compare
|
@zherczeg I've rebased 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
| print("An error will be thrown."); | ||
| } | ||
|
|
||
| inevitable(); |
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.
Just curious: why is any code needed in this file for this test case?
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.
Well, we could leave it empty as well.
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 don't think it hurts to keep the current file.
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 was just wondering... I thought perhaps it was needed to get a breakpoint opcode emitted or something.
LaszloLango
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
* Add the ability to throw an error to python debugger (jerryscript-project#2188) This patch makes it possible to throw an error from the python debugger client using the `throw` command. JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu * Fix typo and redundant text in the documentation. (jerryscript-project#2260) JerryScript-DCO-1.0-Signed-off-by: Daniel Vince vinced@inf.u-szeged.hu * Fix accessing the contents of a direct string (jerryscript-project#2261) In the `ecma_string_get_chars` method the contents of a direct string is accessed incorrectly. It tries to extract the magic string id from the string pointer but the direct string does not need this step. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com * Remove websocket message macros in debugger (jerryscript-project#2262) JERRY_DEBUGGER_INIT_SEND_MESSAGE JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE JerryScript-DCO-1.0-Signed-off-by: Jimmy Huang jimmy.huang@intel.com * Remove TARGET_HOST macros (jerryscript-project#2264) Remove TARGET_HOST defines from the jerry-libc module and replace with compiler provided macros. JerryScript-DCO-1.0-Signed-off-by: Istvan Miklos imiklos2@inf.u-szeged.hu * Fix bug in stringToCesu8 conversion for 0x7ff (jerryscript-project#2267) JerryScript-DCO-1.0-Signed-off-by: Geoff Gustafson geoff@linux.intel.com * Add ecma_free_all_enqueued_jobs function (jerryscript-project#2265) This function releases any remaining promise job that wasn't completed. Also added this function to `jerry_cleanup ()`, therefore it will be automatically run. JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu * Improve jerry_is_feature_enabled with object availability information (jerryscript-project#2250) JerryScript-DCO-1.0-Signed-off-by: Zsolt Raduska rzsolt@inf.u-szeged.hu * Add json parse and stringify function to jerryscript c api (jerryscript-project#2243) JerryScript-DCO-1.0-Signed-off-by: Zsolt Raduska rzsolt@inf.u-szeged.hu * Simplify debugger-ws.h (jerryscript-project#2266) Remove several macros and types from it. This change simplifies the external debugger interface. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com * Add finalize_cb to jerry_context_data_manager_t (jerryscript-project#2269) This patch adds a new finalize_cb callback to jerry_context_data_manager_t. The callback is run as the very last thing in jerry_cleanup, after the VM has been torn down entirely. There was already the deinit_cb, which is run while the VM is still in the process of being torn down. The reason the deinit_cb is not always sufficient is that there may still be objects alive (because they still being referenced) that have native pointers associated with the context manager that is being deinit'ed. As a result, the free_cb's for those objects can get called *after* the associated context manager's deinit_cb is run. This makes cleanup of manager state that is depended on by the live objects impossible to do in the deinit_cb. That type of cleanup can only be done when all values have been torn down completely. JerryScript-DCO-1.0-Signed-off-by: Martijn The martijn.the@intel.com * Rework snapshot generation API. (jerryscript-project#2259) Also remove eval context support. It provides no practical advantage. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com * Implement the ES2015 version of Object.getPrototypeOf and add a test file for it (jerryscript-project#2256) JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu * Move DevTools integration code into jerry-client-ts subdir JerryScript-DCO-1.0-Signed-off-by: Geoff Gustafson geoff@linux.intel.com * Fix some things to match the new directory for TS code JerryScript-DCO-1.0-Signed-off-by: Geoff Gustafson geoff@linux.intel.com
This patch makes it possible to throw an error from the python debugger client using the
throwcommand.JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu