-
Notifications
You must be signed in to change notification settings - Fork 79
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
vm: add RemoveBreakPoint support #3674
base: master
Are you sure you want to change the base?
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.
LGTM.
@@ -275,6 +275,14 @@ func (v *VM) AddBreakPoint(n int) { | |||
ctx.sc.breakPoints = append(ctx.sc.breakPoints, n) | |||
} | |||
|
|||
// RemoveBreakPoint removes the breakpoint in the current context. | |||
func (v *VM) RemoveBreakPoint(n int) { |
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.
BTW, can you also add a support of respective VM CLI command? Similar to
Line 104 in 66fbcb2
Name: "break", |
If not, then let's move it to a separate issue.
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.
should I also add a list breakpoints
?
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.
To me it's a useful feature. It may be supported as a separate command and may be even as an extension of (v *VM) PrintOps
(some special symbol may be added to every output line that has a breakpoint).
But keep in mind that step
command is also handled with the help of breakpoints:
Line 1191 in 66fbcb2
v.AddBreakPointRel(n) |
Hence, the output of list breakpoints
contains not only user-defined-breakpoints. This fact should be mentioned in the command doc.
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.
Another note is that we now actually have a set of breakpoint-related commands, hence we may group them under a single breakpoints
command as a set of subcommands, something like: breakpoints break
, breakpoints remove
and breakpoints list
:
var commands = []*cli.Command{
{
Name: "breakpoints",
Subcommands: []*cli.Command{
{
Name: "break",
...
},
{
Name: "remove",
...
},
{
Name: "list",
...
},
},
},
But it's an incompatible change. @roman-khimov, what do you think?
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 man gdb
.
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, I had to be more clear: what do you think about incompatibility of this change, can we afford this?
Regarding gdb
: it has the same concept as proposed above: gdb breakpoints
has a subset of breakpoint-related commands including break
, clear
, delete
. Although I haven't find something similar to list
to display all breakpoints.
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.
ib
lists breakpoints in gdb
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.
incompatibility of this change
If you really want to debug something with this CLI you won't be happy typing "breakpoints break" and alike, these:
break, brea, bre, br, b -- Set breakpoint at specified location.
delete, del, d -- Delete all or some breakpoints.
are all available at the top level in GDB. Also, good commands start with verbs.
Strict compatibility is not critical for this CLI (and can be done with some transition period), but likely we can extend it in a compatible way now.
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.
OK, let's then agree on compatible extension and use delete
and ib
for breakpoints removal and listing correspondingly.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3674 +/- ##
==========================================
- Coverage 83.08% 83.06% -0.03%
==========================================
Files 334 334
Lines 46590 46608 +18
==========================================
+ Hits 38710 38714 +4
- Misses 6310 6325 +15
+ Partials 1570 1569 -1 ☔ View full report in Codecov by Sentry. |
7f7b264
to
d91a6d2
Compare
@@ -275,6 +275,14 @@ func (v *VM) AddBreakPoint(n int) { | |||
ctx.sc.breakPoints = append(ctx.sc.breakPoints, n) | |||
} | |||
|
|||
// RemoveBreakPoint removes the breakpoint in the current context. | |||
func (v *VM) RemoveBreakPoint(n int) { |
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.
To me it's a useful feature. It may be supported as a separate command and may be even as an extension of (v *VM) PrintOps
(some special symbol may be added to every output line that has a breakpoint).
But keep in mind that step
command is also handled with the help of breakpoints:
Line 1191 in 66fbcb2
v.AddBreakPointRel(n) |
Hence, the output of list breakpoints
contains not only user-defined-breakpoints. This fact should be mentioned in the command doc.
@@ -275,6 +275,14 @@ func (v *VM) AddBreakPoint(n int) { | |||
ctx.sc.breakPoints = append(ctx.sc.breakPoints, n) | |||
} | |||
|
|||
// RemoveBreakPoint removes the breakpoint in the current context. | |||
func (v *VM) RemoveBreakPoint(n int) { |
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.
Another note is that we now actually have a set of breakpoint-related commands, hence we may group them under a single breakpoints
command as a set of subcommands, something like: breakpoints break
, breakpoints remove
and breakpoints list
:
var commands = []*cli.Command{
{
Name: "breakpoints",
Subcommands: []*cli.Command{
{
Name: "break",
...
},
{
Name: "remove",
...
},
{
Name: "list",
...
},
},
},
But it's an incompatible change. @roman-khimov, what do you think?
Some extensions need to be reviewed.
Slightly off-topic but relevant for me. Are you open to exposing the following? Line 33 in dda2caf
and Lines 68 to 69 in dda2caf
because if not then I'll have to fork anyway and we can skip this PR and #3675 to save you some time. I need access to these slots or I can't display stack frame information. I'm aware of the |
If an external application needs it, then I don't have objections. But
Could you please clarify, which issues? Because I'd expect
Let's finalize it, I consider this PR useful. |
I understand this is sensitive data that shouldn't be changed, but how are they different from the current
I'll consume whatever is made available 🙏
Assume the following type DebugContext {
StackFrames []StackFrame `json:"stackFrames"`
}
type StackFrame struct {
Arguments string `json:"arguments"`
Statics string `json:"statics"`
Locals string `json:"locals"`
NextIP int `json:"nextIp"`
CurIP int `json:"curIp"`
}
...
for i, ctx := range ic.VM.Istack() {
frames[i] = StackFrame{
Arguments: ctx.DumpArgumentsSlot(),
Statics: ctx.DumpStaticSlot(),
Locals: ctx.DumpLocalSlot(),
NextIP: ctx.NextIP(),
CurIP: ctx.IP(),
}
} marshalling this gives for example
1 problem here is that
|
From that point you're right, so to be honest I don't have any strong objections against of creating a set of |
Signed-off-by: ixje <erik@coz.io>
d91a6d2
to
31706a7
Compare
I can't seem to reply to #3674 (comment) so I'll do it here
I did not add a mention because I believe the current implementation of |
Problem
#3673
Solution
add function