Skip to content
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

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

ixje
Copy link
Contributor

@ixje ixje commented Nov 12, 2024

Problem

#3673

Solution

add function

AnnaShaleva
AnnaShaleva previously approved these changes Nov 12, 2024
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

LGTM.

@AnnaShaleva
Copy link
Member

Contribution guidelines workflow is failing, could you please add a signed-off-by line to the commit message? Ref. https://github.com/nspcc-dev/.github/blob/master/git.md#commit-messages.

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 65.38462% with 9 lines in your changes missing coverage. Please review.

Project coverage is 83.14%. Comparing base (66fbcb2) to head (d8ea410).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
cli/vm/cli.go 57.14% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3674      +/-   ##
==========================================
+ Coverage   83.08%   83.14%   +0.06%     
==========================================
  Files         334      334              
  Lines       46590    46599       +9     
==========================================
+ Hits        38710    38746      +36     
+ Misses       6310     6279      -31     
- Partials     1570     1574       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ixje ixje force-pushed the remove-breakpoint branch from 7f7b264 to d91a6d2 Compare November 12, 2024 11:17
cli/vm/cli.go Outdated Show resolved Hide resolved
pkg/vm/vm.go Show resolved Hide resolved
pkg/vm/vm.go Show resolved Hide resolved
cli/vm/cli.go Show resolved Hide resolved
@AnnaShaleva AnnaShaleva dismissed their stale review November 12, 2024 13:27

Some extensions need to be reviewed.

@ixje
Copy link
Contributor Author

ixje commented Nov 12, 2024

Slightly off-topic but relevant for me. Are you open to exposing the following?

static slot

and

neo-go/pkg/vm/context.go

Lines 68 to 69 in dda2caf

local slot
arguments slot

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 dumpSlot() output but that has some issues and I'd prefer to transfer the information to the IDE in a binary format

@AnnaShaleva
Copy link
Member

Are you open to exposing the following?

If an external application needs it, then I don't have objections. But (c *Context) Dump*Slot methods exist because vm.slot structure is unexported and I think we should not export it because it's an internal VM structure. Hence, I'd suggest to make a set of func (c *Context) *SlotBytes() []byte helpers in a separate commit that will serialize slots using binary representation instead of JSON.

but that has some issues

Could you please clarify, which issues? Because I'd expect dumpSlot to output a proper JSON that may be reused by other applications.

we can skip this PR and #3675

Let's finalize it, I consider this PR useful.

@ixje
Copy link
Contributor Author

ixje commented Nov 13, 2024

vm.slot structure is unexported and I think we should not export it because it's an internal VM structure.

I understand this is sensitive data that shouldn't be changed, but how are they different from the current Estack() and Istack() methods? Those equally give you enough power to wreck the VM state.

Hence, I'd suggest to make a set of func (c *Context) *SlotBytes() []byte helpers in a separate commit that will serialize slots using binary representation instead of JSON.

I'll consume whatever is made available 🙏

Could you please clarify, which issues? Because I'd expect dumpSlot to output a proper JSON that may be reused by other applications.

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

{"stackFrames":[{"arguments":"[\n    {\n        \"type\": \"Integer\",\n        \"value\": \"1\"\n    }\n]","statics":"[]","locals":"[\n    null,\n    null\n]","nextIp":3,"curIp":0}]}

1 problem here is that arguments (as are statics & locals) is a string not an array. So to get it into a usable format I have 2 choices

  1. on the neo-go side, unmarshal the dumpSlot returned string into a slice of some new type. Then when the whole DebugContext is marshaled arguments will be a proper array
  2. on the consumer side read the value of e.g. arguments, then run another JSON parser instance on the value.

@AnnaShaleva
Copy link
Member

but how are they different from the current Estack() and Istack() methods?

From that point you're right, so to be honest I don't have any strong objections against of creating a set of func (c *Context) *Slot() Slot methods. Let's implement this.

@ixje ixje force-pushed the remove-breakpoint branch from d91a6d2 to 31706a7 Compare November 13, 2024 13:52
@ixje
Copy link
Contributor Author

ixje commented Nov 13, 2024

I can't seem to reply to #3674 (comment) so I'll do it here

Hence, the output of list breakpoints contains not only user-defined-breakpoints. This fact should be mentioned in the command doc.

I did not add a mention because I believe the current implementation of step n is flawed (see
#3676). I expect the solution to not use a break point, therefore it won't show up.

@ixje ixje mentioned this pull request Nov 13, 2024
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

Please, adjust the commit message to describe all changes implemented in this commit or split the RP into multiple commits (ref. https://github.com/nspcc-dev/.github/blob/master/git.md#logical-separation). Also, Contribution guidelines and Lint jobs are failing, add signed-off-by to the commit message and fix the linter issues.

Otherwise LGTM.

@ixje ixje force-pushed the remove-breakpoint branch 3 times, most recently from 472262e to a220795 Compare November 14, 2024 08:36
@ixje
Copy link
Contributor Author

ixje commented Nov 14, 2024

if this ain't the right format then I give up

@AnnaShaleva
Copy link
Member

if this ain't the right format

It's the right one!

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

Also needs @roman-khimov's approval.

@AnnaShaleva
Copy link
Member

BTW, please also add Close #3673. to the commit message to auto-close related GH issue after merge.

@ixje ixje force-pushed the remove-breakpoint branch from a220795 to d8ea410 Compare November 14, 2024 08:54
Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

I'd really prefer to see real names in Author/SOB (and log, respectively), but it's up to you.

@AnnaShaleva AnnaShaleva merged commit 3ec06f3 into nspcc-dev:master Nov 14, 2024
33 of 34 checks passed
@ixje ixje deleted the remove-breakpoint branch November 14, 2024 18:38
@ixje ixje mentioned this pull request Dec 3, 2024
4 tasks
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