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

Add support for function breakpoints #136

Merged
merged 1 commit into from Nov 21, 2019

Conversation

thegecko
Copy link
Contributor

Signed-off-by: Rob Moran rob.moran@arm.com

Introduced support for adding function breakpoints, see:

https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_function-breakpoints

Copy link
Contributor

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

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

This kind of change needs some kind of basic test please.

src/mi/breakpoint.ts Outdated Show resolved Hide resolved
@thegecko
Copy link
Contributor Author

Tests would be a lot easier to write if they worked on MacOS or ran on PRs (with the output shown)

@jonahgraham
Copy link
Contributor

Tests would be a lot easier to write if they worked on MacOS or ran on PRs (with the output shown)

Please add details on Issue #12 - or raise a new issue if needed.

@jonahgraham jonahgraham mentioned this pull request Sep 26, 2019
@thegecko thegecko force-pushed the function-breakpoints branch 2 times, most recently from 7c9230e to e46403b Compare September 26, 2019 21:53
@jonahgraham jonahgraham self-requested a review October 29, 2019 16:15
Copy link
Contributor

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

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

In addition to the missing tests, this doesn't quite work. See spec:

↩️ SetFunctionBreakpoints Request
Replaces all existing function breakpoints with new function breakpoints.

The current implementation in this commit just keeps adding to the installed breakpoints. This probably wants to be merged with setBreakPointsRequest as that (sort of) handles the case.

As for a minimal test, something like this would be a start.


    it('hits a function breakpoint', async () => {
        await dc.setFunctionBreakpointsRequest({
            breakpoints: [
                {
                    name: 'main',
                },
            ],
        });
        await dc.configurationDoneRequest();
        const scope = await getScopes(dc);
        const vr = scope.scopes.body.scopes[0].variablesReference;
        const vars = await dc.variablesRequest({ variablesReference: vr });
        verifyVariable(vars.body.variables[0], 'count', 'int', '0');
    });

Although it would probably be better to add to count.c to add an additional function.

Copy link
Contributor

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

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

Thanks for the test. I think this still doesn't meet the DAP spec: #136 (review)

@thegecko
Copy link
Contributor Author

thegecko commented Nov 6, 2019

I think this still doesn't meet the DAP spec

Still WiP

@thegecko
Copy link
Contributor Author

Rebased and added tests, still need to resolve the issue with not removing them...

@jonahgraham
Copy link
Contributor

@thegecko pushed 1 commit.

88fcd1f Support removing function breakpoints

@thegecko does this mean it is ready for review? Let me know when/if it is and I will try to get it in.

@thegecko
Copy link
Contributor Author

@jonahgraham This should be good to go. I've got a change which de-duplicates the breakpoint resolving in setBreakpoints and setFunctionBreakpoints, but felt that should be a PR after this one. Let me know if you'd prefer to see it added here, however.

@jonahgraham
Copy link
Contributor

Let me know if you'd prefer to see it added here, however.

Lets avoid the duplication in the first place - if you are ready to add it now, please do that. It will save me having to compare the setBreakpoints and setFunctionBreakpoints versions.

Signed-off-by: Rob Moran <rob.moran@arm.com>
@thegecko
Copy link
Contributor Author

@jonahgraham, I've introduced a common resolveBreakpoints() function for determining the breakpoints to add and delete across setBreakpoints() and setFunctionBreakpoints().

I've introduced a few more tests to exercise this new common function and I've tested it all locally.

It's probably worth focussing your checks on the breakpoint handling overall as there is some churn in that area.

I've also added a few minor bug-fixes and comments.

Copy link
Contributor

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

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

Looks good. I am going to do a touch of code cleanup as commented below and push it.

@@ -30,7 +30,7 @@ export interface MIBreakpointInfo {
line?: string;
threadGroups: string[];
times: string;
originalLocation?: string;
'original-location'?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, I didn't know you could do this. I am fixing up some other code because of this - PR coming soon.

(vsbp, gdbbp) => {

// Always invalidate hit conditions as they have a one-way mapping to gdb ignore and temporary
if (vsbp.hitCondition) {
Copy link
Contributor

Choose a reason for hiding this comment

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

hitCondition and condition - VSCode does not yet have UI for this so it seems acceptable to not implement support for now, but we are at some point going to need our own fork of the debug protocol spec to document our differences and extensions and this is one of them.

Comment on lines +65 to +68
const event = await dc.waitForEvent('stopped') as StoppedEvent;
expect(event.body.reason).to.eq('function breakpoint');
const scope = await getScopes(dc);
expect(scope.frame.line).to.eq(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

There is already a helper that does this:

        dc.assertStoppedLocation('function breakpoint', {line: 2});

@jonahgraham jonahgraham self-requested a review November 21, 2019 16:54
@jonahgraham jonahgraham merged commit 73f1054 into eclipse-cdt-cloud:master Nov 21, 2019
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.

None yet

2 participants