Skip to content

Conversation

@Yuyupo
Copy link
Contributor

@Yuyupo Yuyupo commented Jun 20, 2018

With this you can add a start where you want to start listing the backtraces, not just maximum depth.

JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu

typedef struct
{
uint8_t type; /**< type of the message */
uint8_t start; /**< starting point (0 - max_depth)*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be:
uint8_t min_depth[sizeof (uint32_t)]; /**< minimum depth */

Similar to:
uint8_t max_depth[sizeof (uint32_t)]; /**< maximum depth (0 - unlimited) */

@Yuyupo Yuyupo force-pushed the backtracestart branch 3 times, most recently from 3e43863 to 2732312 Compare June 22, 2018 12:50
@Yuyupo
Copy link
Contributor Author

Yuyupo commented Jun 25, 2018

@zherczeg Changed what was requested

max_depth = int(args)
if max_depth <= 0:
min_depth = int(args[0])
max_depth = int(args[1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if there is args length is 1 and there is no second element?
Both bt max_value and bt min_value max_value commands should work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now, this is intentional and the bt command has two mandatory arguments. IMHO this should be changed. One argument should mean a max_value and two arguments should mean min_value max_value pair.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind having two mandatory arguments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I misunderstood you. Yes, in the python debugger, only one argument must be mandatory. In the message, both values must be sent.

max_depth = int(args)
if max_depth <= 0:
min_depth = int(args[0])
max_depth = int(args[1])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I misunderstood you. Yes, in the python debugger, only one argument must be mandatory. In the message, both values must be sent.

Frame 1: tests/debugger/do_backtrace.js:33 (in test() at line:30, col:1)
Frame 2: tests/debugger/do_backtrace.js:40
(jerry-debugger) bt 1 1
Frame 0: tests/debugger/do_backtrace.js:23 (in foo() at line:21, col:1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you specify a min, then maximum (max-min) items could be sent. Here (1-1)==0, so the backtrace should be empty (empty backtrace is valid, you need to test it!!!)

So "bt 1 2" above should only send 1 item. Please also test a large number, e.g. "bt 1000 1001".

(jerry-debugger) s
Stopped at tests/debugger/do_backtrace.js:23 (in foo() at line:21, col:1)
(jerry-debugger) bt 1 2
Frame 0: tests/debugger/do_backtrace.js:23 (in foo() at line:21, col:1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? I thought this should be Frame 1: tests/debugger/do_backtrace.js:33 (in test() at line:30, col:1)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Hm, this can be confusing. The second number is the count, while the first number is the starting index. So bt 4 4 never returns with anything, since frame index 4 is bigger than the maximum number of frames.

backtrace
bt 4 4
bt 600 919
bt 3 500
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if min greater than the max? Can we test it?

@Yuyupo
Copy link
Contributor Author

Yuyupo commented Jul 4, 2018

@LaszloLango Fixed what was requested, and added the test case that was missing.

(jerry-debugger) s
Stopped at tests/debugger/do_backtrace.js:23 (in foo() at line:21, col:1)
(jerry-debugger) bt 1 2
Frame 0: tests/debugger/do_backtrace.js:33 (in test() at line:30, col:1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frame 1

@Yuyupo Yuyupo force-pushed the backtracestart branch 4 times, most recently from b44eb58 to 829e97f Compare July 4, 2018 10:37
(jerry-debugger) s
Stopped at tests/debugger/do_backtrace.js:23 (in foo() at line:21, col:1)
(jerry-debugger) bt 1 2
Frame 1: tests/debugger/do_backtrace.js:23 (in foo() at line:21, col:1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the frame index is still wrong

typedef struct
{
uint8_t type; /**< type of the message */
uint8_t min_depth[sizeof (uint32_t)]; /**< minimum depth*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we use uint16_t for both min_depth and max_depth? @zherczeg, what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently only uint8, cpointer, and uint32 types are used by the protocol. Adding new types would require adding new encoders/decoders for clients. This is certainly possible, but for this it does not seem worth the effort.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thanks for the explanation.

Copy link
Contributor

@LaszloLango LaszloLango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if (min_depth <= max_depth)
{
if (frame_ctx_p->bytecode_header_p->status_flags & CBC_CODE_FLAGS_DEBUGGER_IGNORE)
uint32_t min_depth_offset = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the start depth is 1?

(jerry-debugger) s
Stopped at tests/debugger/do_backtrace.js:23 (in foo() at line:21, col:1)
(jerry-debugger) bt 1 2
Frame 0: tests/debugger/do_backtrace.js:23 (in foo() at line:21, col:1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Hm, this can be confusing. The second number is the count, while the first number is the starting index. So bt 4 4 never returns with anything, since frame index 4 is bigger than the maximum number of frames.

Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one minor thing.

print("Error: Positive integer number expected")
return
if self.min_depth > max_depth:
print("Error: Start needs to be lower than depth")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error: start depth needs to be less equal than max depth

JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
@Yuyupo
Copy link
Contributor Author

Yuyupo commented Jul 12, 2018

@zherczeg Fixed that minor issue

Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zherczeg zherczeg merged commit 62cdb39 into jerryscript-project:master Jul 12, 2018
@Yuyupo Yuyupo deleted the backtracestart branch May 30, 2019 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants