Coder Social home page Coder Social logo

vscode-mock-debug's Introduction

VS Code Mock Debug

This is a starter sample for developing VS Code debug adapters.

Mock Debug simulates a debug adapter for Visual Studio Code. It supports step, continue, breakpoints, exceptions, and variable access but it is not connected to any real debugger.

The sample is meant as an educational piece showing how to implement a debug adapter for VS Code. It can be used as a starting point for developing a real adapter.

More information about how to develop a new debug adapter can be found here.

Using Mock Debug

  • Install the Mock Debug extension in VS Code.
  • Create a new 'program' file readme.md and enter several lines of arbitrary text.
  • Switch to the debug viewlet and press the gear dropdown.
  • Select the debug environment "Mock Debug".
  • Press the green 'play' button to start debugging.

You can now 'step through' the readme.md file, set and hit breakpoints, and run into exceptions (if the word exception appears in a line).

Mock Debug

Build and Run

  • Clone the project https://github.com/Microsoft/vscode-mock-debug.git
  • Open the project folder in VS Code.
  • Press F5 to build and launch Mock Debug in another VS Code window.
  • In the explorer view of the new window open the 'program' file readme.md
  • Set some breakpoints
  • From the editor's "Run and Debug" toolbar dropdown menu select "Debug File"

vscode-mock-debug's People

Contributors

aweinand avatar chrisdias avatar connor4312 avatar dependabot[bot] avatar isidorn avatar itowlson avatar lszomoru avatar microsoft-github-policy-service[bot] avatar roblourens avatar tylerleonhardt avatar udith avatar weinand avatar yannickowow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-mock-debug's Issues

Add an example of ui feedback

I've created a debugger for perl, I've used this repo to get started, made things much easier so thanks!

Now I'm facing a challenge where the adapter should communicate to the user eg. "Please install PadWalker for variable inspection to work" - It would be nice to trigger a snackbar in the ui.

Maybe an example on how to do dependency checks on activation and on the fly?

Should debug protocol support variables for evaluate expression?

I would like to start a discussion on watches and why the debugger should have the option to return a Variable if it knows the expression is one of the variables already referenced in the current scope. Not sure where to do it though. Here or on the vsc repo, or even somewhere else.

The idea is that if we know the expression is a variable it can be much more efficient to return a reference to it than to evaluate it again. Especially when the variables is expensive to evaluate.

[Question] How can I run a server for debugger?

Hi, apologize for my "newbie" question.

I'd like to create a lua debuger extension, where the debuger (on the vscode side) is TCP Server waiting for client (lua program) to connect. But I have no idea how to connect the Debug Adapter with the "_runtime" (mockRuntime in this example) which works as a server waiting for connection and messeges with debug info.

Could you help me? What should I focus on?

When i try to download the node modules it throws errors.

C:\Chroma\Projects\vscode-mock-debug-main\vscode-mock-debug-main>npm i
npm WARN config global --global, --local are deprecated. Use --location=global instead.
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm ERR! code 1
npm ERR! path C:\Chroma\Projects\vscode-mock-debug-main\vscode-mock-debug-main\node_modules\keytar
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c prebuild-install || npm run build
npm ERR! > [email protected] build
npm ERR! > node-gyp rebuild
npm ERR! prebuild-install WARN install unable to get local issuer certificate
npm ERR! npm WARN config global --global, --local are deprecated. Use --location=global instead.
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.10.5 found at "C:\Python310\python.exe"
npm ERR! gyp http GET https://nodejs.org/download/release/v16.15.1/node-v16.15.1-headers.tar.gz
npm ERR! gyp WARN install got an error, rolling back install
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack FetchError: request to https://nodejs.org/download/release/v16.15.1/node-v16.15.1-headers.tar.gz failed, reason: unable to get local issuer certificate
npm ERR! gyp ERR! stack at ClientRequest. (C:\Program Files\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\index.js:130:14)
npm ERR! gyp ERR! stack at ClientRequest.emit (node:events:527:28)
npm ERR! gyp ERR! stack at TLSSocket.socketErrorListener (node:_http_client:454:9)
npm ERR! gyp ERR! stack at TLSSocket.emit (node:events:539:35)
npm ERR! gyp ERR! stack at emitErrorNT (node:internal/streams/destroy:157:8)
npm ERR! gyp ERR! stack at emitErrorCloseNT (node:internal/streams/destroy:122:3)
npm ERR! gyp ERR! stack at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gnode_modules\node-gyp\bin\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Chroma\Projects\vscode-mock-debug-main\vscode-mock-debug-main\node_modules\keytar
npm ERR! gyp ERR! node -v v16.15.1
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:

How to debug the code?

How do i debug the code in mockDebug.ts?

I have launched VS Code using the Extension + Server debug configuration and added the necessary breakpoints. In the new VS Code window debugging a readme.md works as expected, however no breakpoints in the extension code are hit?

Note: The following is displayed in the VS Code debug console

Error: certificate has expired
    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:1060:38)
    at emitNone (events.js:86:13)
    at TLSSocket.emit (events.js:185:7)
    at TLSSocket._finishInit (_tls_wrap.js:584:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:416:38)
Error: certificate has expired
    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:1060:38)
    at emitNone (events.js:86:13)
    at TLSSocket.emit (events.js:185:7)
    at TLSSocket._finishInit (_tls_wrap.js:584:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:416:38)

On trying to debug Runtime process using 'mock' configuration, getting 'Cannot find a program to debug' as info response.

I am currently trying to use mock debug to build a customised debugger. On trying to use mock-debugger to debug the Runtime process ('mock' configuration for type field) , I am getting an info pop up that says 'Cannot find a program to debug'. I am getting the same issue in the customised debugger as well. Here is my launch.json

{
    "version": "0.1.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "node attach",
            "address": "localhost",
            "port": 9222,
            "protocol": "inspector",
            "trace": true,
        },
        {
            "type": "mock",
            "request": "attach",
            "name": "Attach to Remote",
            "address": "localhost",
            "port": 9222,
            "trace": true,
            "webRoot": "${workspaceFolder}"
        }
   ]
}

The debugger works fine and loads the scripts on using 'node' configuration in type field.
No traces are being generated for mock.
Is something wrong with my approach, or is it a known issue?

Run from scratch - Failed at the [email protected] watch script.

I ran into an issue where the debugger wouldn't run when building a local version of the vscode-mock-debug extension from scratch.

Steps to reproduce:

  1. clone a fresh copy of this repo:
    git clone https://github.com/Microsoft/vscode-mock-debug.git C:\temp\vscode-mock-debug
  2. Open C:\temp\vscode-mock-debug with vscode
  3. Press F5 to debug the extension. The following is output to the console

Executing task: "npm run watch" <

[email protected] watch c:\Temp\vscode-mock-debug
tsc -w -p ./src

error TS5023: Unknown compiler option 'noUnusedLocals'.
error TS5023: Unknown compiler option 'noImplicitThis'.
error TS5023: Unknown compiler option 'strictNullChecks'.
error TS5023: Unknown compiler option 'noUnusedParameters'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] watch: tsc -w -p ./src
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users[username]\AppData\Roaming\npm-cache_logs\2018-03-13T15_11_52_966Z-debug.log
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

  1. A new VSCode window (let's call it "Extension VSCode") opens with the extension running inside
  2. In Extension VSCode, open a new folder C:\temp\markdown-project
  3. In Extension VSCode, create a new file C:\temp\markdown-project\readme.md and add a few lines of valid markdown
  4. Open the new file and add a few breakpoints.
  5. In Extension VSCode, run the debugger by pressing F5 on your keyboard.
  6. In Extension VSCode, a popup appears in the bottom right with the following message:

Activating extension 'andreweinand.mock-debug' failed: Cannot find module 'C:\Temp\vscode-mock-debug\out\extension'.

Environment Information

NodeJS Version
NodeJS v9.6.1

VSCode version:
Version 1.22.0-insider
Commit 112670122d3acf863aa9542b1642d64c69be10bf
Date 2018-03-13T05:16:22.707Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

Unable to use the debug functionality when used as a web extension

Using this example as a web extension doesn't appear to work - at least when tested as per the VS Code docs. It appears from recent commits (e.g. 354c0e9) this should be supported.

I've cloned this repo and built, and I'm trying to test as outlined at https://code.visualstudio.com/api/extension-guides/web-extensions#test-your-web-extension .

When I try I on vscode.dev (or github using the "open in github.dev" option) and load the locally built extension as outlined using npx serve and npx localtunnel I see CORS errors in the console as shown below, and the extension is not available.

Refused to connect to 'https://eager-otters-kick-67-183-2-129.loca.lt/package.json' because it violates the following Content Security Policy directive: "connect-src 'self'
            wss://vsls-prod-ins-usw2-private-relay.servicebus.windows.net
            wss://vsls-prod-rel-usw2-relay-1.servicebus.windows.net
            wss://vsls-prod-rel-usw2-relay-2.servicebus.windows.net

When I try as outlined in the docs using @vscode/test-web (e.g. running the command vscode-test-web --extensionDevelopmentPath=. . from the package.json) then I can see the extension is loaded and I can set a breakpoint in the .md file in the workspace, but on trying to debug via the command "Mock Debug: Debug File" then the debugger appears to launch but just sits there, and in the console output I see the below error (truncated):

Uncaught (in promise) Error (FileSystemError): Unable to read file '/vscode-test-web://mount/README.md' (Unavailable (FileSystemError): Error: No file system handle registered (/vscode-test-web:/))
	at Yt._handleError (../../../vs/workbench/api/worker/extensionHostWorker.js:76:30420)
	at Object.readFile (../../../vs/workbench/api/worker/extensionHostWorker.js:76:28894)
	at async Object.readFile (http://localhost:3000/static/devextensions/dist/web-extension.js#vscode-extension:4303:12)
	at async MockRuntime.loadSource (http://localhost:3000/static/devextensions/dist/web-extension.js#vscode-extension:3335:31)
	at async MockRuntime.verifyBreakpoints (http://localhost:3000/static/devextensions/dist/web-extension.js#vscode-extension:3462:7)
	at async MockRuntime.setBreakPoint (http://localhost:3000/static/devextensions/dist/web-extension.js#vscode-extension:3241:5)
	at async eval (http://localhost:3000/static/devextensions/dist/web-extension.js#vscode-extension:3652:38)
	at async Promise.all (index 0)
at async _MockDebugSession.setBreakPointsRequest (http://localhost:3000/static/devextensions/dist/web-extension.js#vscode-extension:3657:31)

Something I'm doing wrong? Are the docs wrong (or incomplete)? Or is there an issue here? Thanks.

Documentation for Source File Concerns?

I've been perusing the source files in this project to get a better understanding of the structure of a Debugger Extension implementation. One thing that has been a constant source of frustration is trying to divine what the role is for each main file in the repository. Specifically I'm referring to:

  • extension.ts
  • mockDebug.ts
  • mockRuntime.ts

Unless I've straight-up missed something (please advise if I have!), I can't find anything that offers any sort of codebase orientation.

I think it would be extremely helpful to have documentation around what each class/module in the repository does; what it's role is in providing debugger features. I imagine such documentation would be available in a ReadMe.md, perhaps even directly within the src folder. Or, perhaps, in documentation comments above each of the main classes in the repository.

Another way to put it, I guess, is that this repository is missing an architecture overview.

Use of browser entry point?

Could I ask what the intent of the Browser entry point is and how it's handled by VS Code?

I'm keen to see if there is a way to have a debug adapter run in the UI host and this seems to suggest this is possible.
However, my experiments show that browser entry points are ignored and main is always used.
Does it tie in somehow with the VSCE --web flag or UI Extensions?

Runtime errors after publish

Hi, I have been developing this new vscode extension debugger https://github.com/jschmidt42/stingray-vscode-debugger, so far everything is going well. When I run and debug from the extension repo and it launches a new instance of vscode for debugging, everything works fine.

But as soon as I try to copy the extension under C:\Users\<user>\.vscode\extensions (or publish the extension using vsce) and try it out for real, it doesn't work anymore and the only error I am getting is:

Unexpected token t in JSON at position 3. Stopping the debug adapter.

And I have no clue where the error comes from.

Is there some tricks to debug this kind of issue?

Thanks,

1.43 isn't released yet.

Was pretty much just chance that I worked out what the problem was with trying to run latest, there is no obvious error given: running it just doesn't work.
This should be been put in a branch for merging when people actually HAVE 1.43.

You installed esbuild on another platform than the one you're currently using.

To reproduce:

Could the issue be that VSCode is running a different node version?

I get this output below:

> Executing task: yarn run watch <

yarn run v1.22.18
warning [email protected]: The engine "vscode" appears to be invalid.
$ npm run -S esbuild-base -- --sourcemap --sources-content=false --watch
npm WARN lifecycle The node binary used for scripts is /var/folders/ft/v4gkgn3x5_z6qr0m28p15htw0000gp/T/yarn--1658792157214-0.43111544680776226/node but npm is using /Users/mkunzmann/.nvm/versions/node/v12.20.1/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> [email protected] esbuild-base /Users/mkunzmann/gitlab.com/rivian/me/factory-systems/rockwell/vscode-mock-debug
> esbuild ./src/extension.ts --bundle --tsconfig=./tsconfig.json --external:vscode --format=cjs --platform=node --outfile=dist/extension.js "--sourcemap" "--sources-content=false" "--watch"

/Users/mkunzmann/gitlab.com/rivian/me/factory-systems/rockwell/vscode-mock-debug/node_modules/esbuild/bin/esbuild:112
          throw new Error(`
          ^

Error: 
You installed esbuild on another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.

Specifically the "esbuild-darwin-arm64" package is present but this platform
needs the "esbuild-darwin-64" package instead. People often get into this
situation by installing esbuild on Windows or macOS and copying "node_modules"
into a Docker image that runs Linux, or by copying "node_modules" between
Windows and WSL environments.

If you are installing with npm, you can try not copying the "node_modules"
directory when you copy the files over, and running "npm ci" or "npm install"
on the destination platform after the copy. Or you could consider using yarn
instead which has built-in support for installing a package on multiple
platforms simultaneously.

If you are installing with yarn, you can try listing both this platform and the
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.

Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not
want to do that.

    at generateBinPath (/Users/mkunzmann/gitlab.com/rivian/me/factory-systems/rockwell/vscode-mock-debug/node_modules/esbuild/bin/esbuild:112:17)
    at Object.<anonymous> (/Users/mkunzmann/gitlab.com/rivian/me/factory-systems/rockwell/vscode-mock-debug/node_modules/esbuild/bin/esbuild:168:27)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] esbuild-base: `esbuild ./src/extension.ts --bundle --tsconfig=./tsconfig.json --external:vscode --format=cjs --platform=node --outfile=dist/extension.js "--sourcemap" "--sources-content=false" "--watch"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] esbuild-base script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mkunzmann/.npm/_logs/2022-07-25T23_35_58_194Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The terminal process "/bin/zsh '-c', 'yarn run watch'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Link broken in README.md

I realized that a link in the README is broken.

More information about how to develop a new debug adapter can be found [here].

Web Extension no longer works

It used to be possible to run mock-debug in a web extension host (e.g. vscode.dev), but this now fails.

Version 0.49.6 is the last release that works as expected.

Releases since then have the following error:

ReferenceError: process is not defined

launchRequest doesn't wait for setBreakPointsRequest response.

Not sure if this is a new feature, but before launchRequest would not get called before the this.sendResponse(response); from setBreakPointsRequest(). Now it does, which breaks my code. I need to finish setting the breakpoints before I can call start. Is the plugin supposed to handle that now? If so what's the point of this.sendResponse(response);?

Cannot start debugging sampleWorkspace/readme.md on Linux due to filename case-sensitivity problem

In [Extension Development Host] started by "Extension + Server", "Debug readme.md" fails to run with the following error in the DEBUG CONSOLE:

rejected promise not handled within 1 second: EntryNotFound (FileSystemError): Unable to read file '/home/wsh/qjs/vscode-mock-debug/sampleworkspace/readme.md' (Error: Unable to resolve nonexistent file '/home/wsh/qjs/vscode-mock-debug/sampleworkspace/readme.md')
/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:112
stack trace: EntryNotFound (FileSystemError): Unable to read file '/home/wsh/qjs/vscode-mock-debug/sampleworkspace/readme.md' (Error: Unable to resolve nonexistent file '/home/wsh/qjs/vscode-mock-debug/sampleworkspace/readme.md')
    at Function._handleError (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:93:83879)
    at Object.readFile (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:93:82793)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Object.readFile (/home/wsh/qjs/vscode-mock-debug/src/activateMockDebug.ts:194:10)
    at MockRuntime.loadSource (/home/wsh/qjs/vscode-mock-debug/src/mockRuntime.ts:473:28)
    at MockRuntime.verifyBreakpoints (/home/wsh/qjs/vscode-mock-debug/src/mockRuntime.ts:646:4)
    at MockRuntime.setBreakPoint (/home/wsh/qjs/vscode-mock-debug/src/mockRuntime.ts:347:3)
    at /home/wsh/qjs/vscode-mock-debug/src/mockDebug.ts:268:35
    at async Promise.all (index 0)
    at _MockDebugSession.setBreakPointsRequest (/home/wsh/qjs/vscode-mock-debug/src/mockDebug.ts:273:29)

Note that this prints sampleworkspace/ instead of sampleWorkspace/.
When sampleWorkspace/ is renamed to sampleworkspace with the following patch, "Debug readme.md" starts successfully.

diff --git a/.vscode/launch.json b/.vscode/launch.json
index 377ddb3..393239e 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -7,7 +7,7 @@
 			"request": "launch",
 			"args": [
 				"--extensionDevelopmentPath=${workspaceFolder}",
-				"${workspaceFolder}/sampleWorkspace"
+				"${workspaceFolder}/sampleworkspace"
 			],
 			"outFiles": [
 				"${workspaceFolder}/dist/**/*.js"
@@ -22,7 +22,7 @@
 			"args": [
 				"--extensionDevelopmentPath=${workspaceFolder}",
 				"--extensionDevelopmentKind=web",
-				"${workspaceFolder}/sampleWorkspace"
+				"${workspaceFolder}/sampleworkspace"
 			],
 			"outFiles": [
 				"${workspaceFolder}/dist/**/*.js"
diff --git a/sampleWorkspace/.vscode/launch.json b/sampleworkspace/.vscode/launch.json
similarity index 100%
rename from sampleWorkspace/.vscode/launch.json
rename to sampleworkspace/.vscode/launch.json
diff --git a/sampleWorkspace/readme.md b/sampleworkspace/readme.md
similarity index 100%
rename from sampleWorkspace/readme.md
rename to sampleworkspace/readme.md

Environments:

$ code --version
1.64.2
f80445acd5a3dadef24aa209168452a3d97cc326
x64

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS"

$ uname -a  # kernel is built by myself (not an Ubuntu official kernel)
Linux wsh64 5.13.19+ #1 SMP Tue Oct 26 18:07:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

[Question] showInputBox vs. showOpenDialog

I'm working on a debug adapter that requires a local file in the launch config. I like that the mock-debug allows the file to be specified in the launch config or prompt the user for it. I noticed the prompt uses showInputBox so the user would have to type/paste the file path. Is that the preferred design instead of something like showOpenDialog? Any downside of using showOpenDialog?

vscode stack frameId can get out of sync

When the user selects a stack frame, vscode will send a scopesRequest which contains the selected frameId. Then, it seems vscode caches the variables in that scope, but if the user selects a previous scope no event is sent informing of this change.

In my case this becomes a problem when evaluating hover expressions. This is because it's likely the user wants to evaluate a variable in the scope of last stack frame he selected. Since vscode doesn't share the info of the current selected frame id, all expressions will be evaluated against the scope of the most recent cached stack frame, independently of it being the selected frame.

If this is "the way it should work", how does one get the current selected stack frame id?
Thank you.

Make mock-debug a yeoman generator, publish /common as NPM module

From @felixfbecker on December 15, 2015 22:59

The whole process of cloning mock-debug to make a debugger extension and then changing it is cumbersome. Like for normal extensions, there should be a yeoman generator that asks you questions about what languages the debugger is for, what the name should be etc.

Secondly, in the docs you express the intent to move the common part of the mock-debug repo to a NPM module, which makes sense, as it's the TS implementation of the debugger protocol so we can write extensions in TS using it. You would be able to add more features over time etc.

I think this would make writing debugger extensions more straight forward.

Copied from original issue: microsoft/vscode#1356

Improve debugEditorContents and runEditorContents command examples

Proposed improvements to the features recently added in support of microsoft/vscode#92269

  • Prefix the commands with Mock Debug:
  • Hide the commands from the Command Palette
  • Disable the commands when in debug mode, otherwise the editor command buttons remain active and could be mistaken for ways to interact with the debugging just launched. If they remain active and are clicked the user ends up with multiple concurrent debug sessions, which could be another source of confusion.

I will submit a PR shortly.

Cannot find module 'supports-color'

Hello here. There is a need for a debugger for a specific device. I started by learning from here https://code.visualstudio.com/api/extension-guides/debugger-extension , but almost a day can not solve this problem.

Exception has occurred: Error Error: Cannot find module 'supports-color' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:584:15) at Function.Module._load (internal/modules/cjs/loader.js:510:25) at Function.define._installInterceptor.i._load (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:491:111) at Module.require (internal/modules/cjs/loader.js:640:17) at n (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:488) at Object.<anonymous> (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\http-proxy-agent\node_modules\debug\src\node.js:29:23) at Object.<anonymous> (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\http-proxy-agent\node_modules\debug\src\node.js:188:3) at Module.t._initNodeRequire.o._compile (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:713) at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10) at Module.load (internal/modules/cjs/loader.js:602:32) at tryModuleLoad (internal/modules/cjs/loader.js:541:12) at Function.Module._load (internal/modules/cjs/loader.js:533:3) at Function.define._installInterceptor.i._load (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:491:111) at Module.require (internal/modules/cjs/loader.js:640:17) at n (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:488) at Object.<anonymous> (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\http-proxy-agent\node_modules\debug\src\index.js:9:20) at Object.<anonymous> (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\http-proxy-agent\node_modules\debug\src\index.js:12:3) at Module.t._initNodeRequire.o._compile (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:713) at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10) at Module.load (internal/modules/cjs/loader.js:602:32) at tryModuleLoad (internal/modules/cjs/loader.js:541:12) at Function.Module._load (internal/modules/cjs/loader.js:533:3) at Function.define._installInterceptor.i._load (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:491:111) at Module.require (internal/modules/cjs/loader.js:640:17) at n (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:488) at Object.<anonymous> (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\http-proxy-agent\index.js:11:13) at Object.<anonymous> (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\http-proxy-agent\index.js:113:3) at Module.t._initNodeRequire.o._compile (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:713) at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10) at Module.load (internal/modules/cjs/loader.js:602:32) at tryModuleLoad (internal/modules/cjs/loader.js:541:12) at Function.Module._load (internal/modules/cjs/loader.js:533:3) at Function.define._installInterceptor.i._load (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:491:111) at Module.require (internal/modules/cjs/loader.js:640:17) at n (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:488) at Object.<anonymous> (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\vscode-proxy-agent\index.js:15:22) at Object.<anonymous> (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\vscode-proxy-agent\index.js:115:3) at Module.t._initNodeRequire.o._compile (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:713) at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10) at Module.load (internal/modules/cjs/loader.js:602:32) at tryModuleLoad (internal/modules/cjs/loader.js:541:12) at Function.Module._load (internal/modules/cjs/loader.js:533:3) at Function.define._installInterceptor.i._load (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:491:111) at Module.require (internal/modules/cjs/loader.js:640:17) at require (internal/modules/cjs/helpers.js:20:18) at t.load (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:16:247) at e.load (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:13:587) at i (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:28:371) at Object.errorback (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:28:492) at e.triggerErrorback (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:13:952) at c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:13:657 at c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:16:617 at a (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:18:530) at ReadFileContext.callback (c:\Users\DDS\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:18:614) at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:235:13)

Version: 1.36.1 (user setup)
Commit: 2213894ea0415ee8c85c5eea0d0ff81ecc191529
Date: 2019-07-08T22:59:35.033Z
Electron: 4.2.5
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.17763

node --version
v11.8.0

append some thing to the outputchanel

I have create it an outputchanel in the extension.ts , i would like to append to it some thing from the function variablerequest in the mockdebug.ts , i dont no how to do it.

With many thanks

`vscode-mock-debug` sends `StackFrame#column: 0` response although the debug client sends `columnsStartAt1: true` for initialize

Hi There,

This is more like a question, but I could not get my head around whether vscode-mock-debug violates the DAP constraints or not. Please help to figure out if this sample adapter implementation behaves correctly.

When I start the Debug readme.md launch configuration on the sampleWorkspace as described in the docs, I can see that the debugger will send the following response for the 'stackTrace' request back to the client:

{
    "seq": 0,
    "type": "response",
    "request_seq": 10,
    "command": "stackTrace",
    "success": true,
    "body": {
        "stackFrames": [
            {
                "id": 0,
                "source": {
                    "name": "readme.md",
                    "path": "/Users/a.kitta/dev/git/vscode-mock-debug/sampleWorkspace/readme.md",
                    "sourceReference": 0,
                    "adapterData": "mock-adapter-data"
                },
                "line": 1,
                "column": 0,
                "name": "VS(0)"
            }
        ],
        "totalFrames": 5
    }
}

StackFrame#column from the specs:

Start position of the range covered by the stack frame. It is measured in UTF-16 code units and the client capability columnsStartAt1 determines whether it is 0- or 1-based. If attribute source is missing or doesn't exist, column is 0 and should be ignored by the client.

Since my debug client is initialized with linesStartAt1: true and columnsStartAt1: true, I would expect that the debugger won't send 0 if the source is available.

This is not a problem in VS Code because the range to reveal is adjusted based on the backing ITextModel before dispatching the revealRange API call. 0 will be mapped to 1. So there are no errors if "stopOnEntry": true is in the lunach.json and the debugger starts and stops at the entry point.

But there are other implementations. For example, in Eclipse Theia, the client knows that the debug sessions are initialized with linesStartAt1: true and columnsStartAt1: true and will expect 1-based line and column values as defined in the specs. Theia will map the position of the StackFrame to an LSP (0-based) position, then when revealing the range in the monaco editor, Theia will convert the 0-based LSP position to a 1-based monaco position. Unfortunately, it does not work reliably as the vscode-mock-debug unexpectedly sends column: 0 although columnsStartAt1: true.

One can argue that it's the client's responsibility to map the Position of the stack frame to the appropriate one, and I have tried to "repair" the position based on the ITextModel, but it does not work. For example, a { line: 0, character: -1 } is not a valid Position in the LSP word, as the properties must be unsigned integers.

Question:
Is the vscode-mock-debugger DAP compliant when it's using the default col: number = 0 0 value for the column when creating the StackFrame instance here:

const sf: DebugProtocol.StackFrame = new StackFrame(f.index, f.name, this.createSource(f.file), this.convertDebuggerLineToClient(f.line));

Thank you!

TODO: enable named pipe support as soon as VS Code 1.49 is out

createDebugAdapterDescriptor(session: vscode.DebugSession, executable: vscode.DebugAdapterExecutable | undefined): vscode.ProviderResult<vscode.DebugAdapterDescriptor> {
if (!this.server) {
// start listening on a random named pipe path
const pipeName = randomBytes(10).toString('utf8');
const pipePath = platform === "win32" ? join('\\\\.\\pipe\\', pipeName) : join(tmpdir(), pipeName);
this.server = Net.createServer(socket => {
const session = new MockDebugSession(workspaceFileAccessor);
session.setRunAsServer(true);
session.start(<NodeJS.ReadableStream>socket, socket);
}).listen(pipePath);
}
// make VS Code connect to debug server
// TODO: enable named pipe support as soon as VS Code 1.49 is out
//return new vscode.DebugAdapterNamedPipeServer(this.server.address() as string);
return undefined;
}

Running mock debugger gives error during activation

Os: Windows 10
NodeJs version: 14.6

Reproduction steps:

  1. Start extension
  2. Open test.md in extension development host
  3. Debug the markdown file (hit F5)
  4. Error

image

Error message:
Activating extension 'andreweinand.mock-debug' failed: a DebugAdapterDescriptorFactory can only be registered from the extension that defines the 'mock' debugger..

I also tested it on Ubuntu with NodeJs 14.13.1. It works on Ubuntu.

How to display error info to the user on failed launchRequest?

I'm trying to warn the user that the debugger failed to start, but I'm not seeing how to do that from the debugger extension.

We don't seem to be able to display dialogs to the user (different process).

Throwing an exception only displays the word '{stack}', which I don't understand the point. Might just be a bug on the exception handling. Missing a $ in '${stack}'?

If the error is on launchRequest, e.g. the extension failed to find the executable it needs to connect to, and therefore can't continue, using logger.error('foo') never gets the opportunity to be displayed on the client console as the extension exits before that. Maybe I could delay the exit and pretend for a while that everything went well. but that seems like a contrived way to achieve the simple objective of displaying a message to the user.

This being a didactic sample, it think it would be good if it also covered this kind of error feedback as it doesn't seem to obvious.

Sorry to post a question as an issue. I've posted it on stackoverflow, but it's not getting much traction.

AskForProgramName command did not work

If the try to edit the launch.json file and select Mock Debug: Launch completion. The AskForProgramName dit not fired even, if it's set in the package.json file.

"configurationSnippets": [
  {
    "label": "Mock Debug: Launch",
    "description": "A new configuration for 'debugging' a user selected markdown file.",
    "body": {
      "type": "mock",
      "request": "launch",
      "name": "Ask for file name",
      "program": "${command:AskForProgramName}",
      "stopOnEntry": true
    }
  }
],
"variables": {
  "AskForProgramName": "extension.mock-debug.getProgramName"
}

Or I am missing something ?

Can not Set Value in "Variables"

Hello everyone,

I implemented a working version of the debug adapter based on the vscode-mock-debug.
I however couldn't set value in "Variables" even with setting supportsSetVariable = true.

I run the vscode-mock-debug with the readme.md file and found out that the mock-debug has the same problem.

Could you please help me with this problem?
Thank you.
ttran

How do I get a clone of this project to have mock as a recognized debug type without installing the mock debug extension from the markeplace?

I am investigating developing a debugger adapter. I'm working with the mock debug extension described here: https://code.visualstudio.com/api/extension-guides/debugger-extension. Just before the section titled, 'Development Setup for Mock Debug' it instructs you to uninstall the mock debug extension installed earlier from the Marketplace. When I uninstall the mock debug extension the 'mock' extension type is no longer recognized. Therefore, even though I can use the Extension launch from the vscode-mock-debug folder and get the [Extension Development Host] on the mock-test folder. When I try to launch the 'Ask for file name' launch', I get a pop-up with the message, "Configured debug type 'mock' is not supported.' If I reinstall the mock debug extension from the marketplace this error goes away and the example works, but I can't debug the code in the vscode-mock-debug folder.

Doesn't work as intended (needs an update?)

I cloned the repo and played a bit with this extension. Adding a launch config works fine, but the program default value is something that seems to be broken. I left the default value as inserted by the "Add Configuration .." selector ("${workspaceFolder}/Program") and tried to start debugging, which resulted in the message: "No such file or directory, open '/Program'". Changing the program value to: ${workspaceFolder}/${command:AskForProgramName} (which I guess is the intended value to be inserted there by default) asks me for a file name. After entering one (valid or not), nothing happens anymore. Same behavior, when I manually enter the path to a text file for program and started debugging again.

So, at the moment, the mock debug extension doesn't work and probably requires an overhaul (maybe do to latest vscode changes, no idea).

Setting required to use the c# debugger

Hi, this is not really an issue, but a question. I tested the mock debugger and it worked very well, just need to congratulate you for making this the easiest mock debugger I got working straight away.
Now the question, I have a specific requirement to create a project like this, that then debugs a C# app and we can catch the info of the breakpoint in the main project app. What settings do I need to change though, to use the Omni C# debugger and not the Mock one.
Sorry I know this might be obvious, but I'm moving to vscode now after 30 years on visual studio, lol.

(Tried finding an example for this, but could not find one, I would love to spend some time on this topic, but can only afford to once I get it working)

Kind regards,
Jos Wilson

Create forum for asking questions and link to it in the readme.md

It would be very helpful to have a forum for asking questions about building debuggers based on mock debug. Please create one and add a link to it in the readme.md. If such a forum already exists I cannot find it anywhere on the vscode portal or github page.

Thanks,

James

Demo of data breakpoints has a mistake

The intent of the data breakpoints sample is that the user should be able to set a data breakpoint on one of the (mock) globals but not the locals. However with the current code the "Break when value changes" command never appears.

The reason is that in the mockDebug.dataBreakpointInfoRequest method at https://github.com/microsoft/vscode-mock-debug/blob/master/src/mockDebug.ts#L380, the code tests if the breakpoint candidate is global by checking if the variable handle starts with global_. The mock globals' names start with global_ but the handle for all globals is global. The if statement should read if (id === "global").

.vscodeignore containing node_modules causes problems

I just recently found out, while packaging my debugger (it was forked from the mock-debug extension), that vsce won't package files found in the .vscodeignore file.

This may be a fine choice, but unfortunately this caused a hard to debug problem for me. After installing my extension I repeatedly got: "Debug adapter process has terminated unexpectedly" errors when trying to launch a new debug session.
After I started manually my debugger.js file, had I noticed that vsce didn't package my dependency node modules.

I suggest removing the line ignoring node_modules from the .vscodeignore file, as the same issue can happen with other developers too.
Always remembering to white-list new dependencies (and all of their dependencies!) is a tedious task in my opinion. Looks like vsce is smart enough to package dependent node modules.

I realize that this can be solved differently (like vsce having a different ignore file etc.), but probably having an easy to use setup in the mock-debug project would help out many new debug extension developers.

Debugger won't start

Pressing F5 will not start the debugger if "program" in launch.json is already set to "readme.md"

The build/run instructions are incomplete and flawed.

I had to run yarn manually (after installing it), and the default runMode is set to external which doesn't allow you to debug the adapter when you press F5.
It should be setup for debugging not testing by default, but even if not, it should at least explicitly say the runMode needs to be changed so that debugging will work.
People writing debug adapters for VSCode aren't going to be javascript or node.js experts (or even novices) on a lot of cases, they are just trying to get their language/whatever to work.
The examples and instructions should reflect that.

Property does not exist from net.Server.address()

Hello everyone,

The error occurs from the file extension.ts line 79
config.debugServer = this._server.address().port;

Error:

Property 'port' does not exist on type 'string | AddressInfo'. Property 'port' does not exist on type 'string'.

I went to the file index.d.ts and changed line 2841 from
address(): AddressInfo | string;
to
address(): AddressInfo;

And the error will disappear and everything works fine.
Could you please help me with this problem?
Thank you.

Here are some info:

VS Code

Version 1.22.2
Commit 3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9
Date 2018-04-12T16:34:44.222Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

OS: ubuntu 18.04

Howto prevent evaluation of comments?

The language selected should be marking certain blocks as comments - I imagine.
Assuming that this is the case, does vsc still request evaluation of these blocks?
It seems to do so in the case of my plugin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.