Skip to content

Conversation

@radical
Copy link
Member

@radical radical commented Feb 24, 2022

  • improved surfacing of errors from expression evaluation, which leads to more useful error messages
  • SendDebuggerAgentCommand will now throw if the result is an error. Earlier, the returned reader was rarely checked. This should help to find issues more readily.
  • All this should provide better error messages, and logging. And remove instances of cryptic Unable to evaluate errors.
  • Also, tests will now fail on any error/warning raised by the runtime
    • this helped to catch a couple of new issues

Fixes #65744

@ghost ghost added the area-Debugger-mono label Feb 24, 2022
@ghost ghost assigned radical Feb 24, 2022
@ghost
Copy link

ghost commented Feb 24, 2022

Tagging subscribers to this area: @thaystg
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: radical
Assignees: -
Labels:

area-Debugger-mono

Milestone: -

@radical radical force-pushed the debugger-improvements branch 2 times, most recently from 461bbbd to 67e7d08 Compare February 24, 2022 21:35
@radical
Copy link
Member Author

radical commented Feb 25, 2022

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@radical
Copy link
Member Author

radical commented Feb 25, 2022

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

.. like for getting locals. Instead, surface the original errors which
have details of the actual failure, to the point before we send a
response.

This helps debugging a lot, so instead of `Unable to evaluate dotnet:scope:1`,
we get more detailed errors.
We are checking `HasError` property on the binary reader in very few
places. Other places just try to use the reader which then fails with
errors in reading, or base64 conversion etc, and we don't get any info
about what command failed.

Instead, throw an exception on error by default. But the existing
locations that do check `HasError`, don't throw for them.
Issue: dotnet#65744

The test doesn't fail because it is expecting an error, and it gets
that.

But the log shows an assertion:

`console.error: * Assertion at /workspaces/runtime/src/mono/mono/metadata/class-accessors.c:71, condition `<disabled>' not met`

1. This is because the debugger-agent does not check that the `klass`
argument is NULL, which is fixed by adding that check.

2. But the reason why this got called with `klass==NULL`, is because
`MemberReferenceResolver.Resolve` tries first to find the non-existant
method on the type itself. Then it tries to find the method on
`System.Linq.Enumerable`, but fails to find a typeid for that.
  - but continues to send a command to get the methods on that
  `linqTypeId==0`.
@radical radical force-pushed the debugger-improvements branch from eef6e56 to 79e0833 Compare February 25, 2022 07:37
@radical radical added the arch-wasm WebAssembly architecture label Feb 25, 2022
@ghost
Copy link

ghost commented Feb 25, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details
  • improved surfacing of errors from expression evaluation, which leads to more useful error messages
  • SendDebuggerAgentCommand will now throw if the result is an error. Earlier, the returned reader was rarely checked. This should help to find issues more readily.
  • All this should provide better error messages, and logging. And remove instances of cryptic Unable to evaluate errors.
  • Also, tests will now fail on any error/warning raised by the runtime
    • this helped to catch a couple of new issues
Author: radical
Assignees: radical
Labels:

arch-wasm, area-Debugger-mono

Milestone: -

@radical radical marked this pull request as ready for review February 25, 2022 07:46
@radical radical requested a review from marek-safar as a code owner February 25, 2022 07:46
@radical
Copy link
Member Author

radical commented Mar 19, 2022

We should try to merge this. It has some useful fixes.

@radical radical merged commit 83e2529 into dotnet:main Mar 28, 2022
@radical radical deleted the debugger-improvements branch March 28, 2022 22:49
radekdoulik pushed a commit to radekdoulik/runtime that referenced this pull request Mar 30, 2022
* [wasm] Mark result as Error if it has 'exceptionDetails' field

* [wasm] Don't swallow errors from methods that enumerate properties

.. like for getting locals. Instead, surface the original errors which
have details of the actual failure, to the point before we send a
response.

This helps debugging a lot, so instead of `Unable to evaluate dotnet:scope:1`,
we get more detailed errors.

* [wasm] Throw an exception when a debugger agent command fails

We are checking `HasError` property on the binary reader in very few
places. Other places just try to use the reader which then fails with
errors in reading, or base64 conversion etc, and we don't get any info
about what command failed.

Instead, throw an exception on error by default. But the existing
locations that do check `HasError`, don't throw for them.

* [wasm] Fix evaluating expression calling a non-existant method

Issue: dotnet#65744

The test doesn't fail because it is expecting an error, and it gets
that.

But the log shows an assertion:

`console.error: * Assertion at /workspaces/runtime/src/mono/mono/metadata/class-accessors.c:71, condition `<disabled>' not met`

1. This is because the debugger-agent does not check that the `klass`
argument is NULL, which is fixed by adding that check.

2. But the reason why this got called with `klass==NULL`, is because
`MemberReferenceResolver.Resolve` tries first to find the non-existant
method on the type itself. Then it tries to find the method on
`System.Linq.Enumerable`, but fails to find a typeid for that.
  - but continues to send a command to get the methods on that
  `linqTypeId==0`.

* [wasm] Add some missing exception logging in the proxy

* cleaup

* [wasm] GetMethodIdByName: throw on invalid type ids

* [wasm] Improve error handling in expression evaluation

* Cleanup

* Disable failing test - dotnet#65881

* Add missed files

* Address @ilonatommy's feedback
@ghost ghost locked as resolved and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture area-Debugger-mono

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm][debugger] Assertion in DebuggerTests.EvaluateOnCallFrameTests.EvaluateSimpleMethodCallsError

3 participants