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

Debug Emscripten translated C/C++ with source maps #20

Closed
weinand opened this issue Aug 18, 2017 · 6 comments
Closed

Debug Emscripten translated C/C++ with source maps #20

weinand opened this issue Aug 18, 2017 · 6 comments
Assignees

Comments

@weinand
Copy link
Contributor

weinand commented Aug 18, 2017

I tried to help a user debugging Emscripten translated C/C++ to JavaScript:

2017-08-18_17-21-59

I compiled with:

./emcc -g4 tests/hello_world.c

The launch config for this looks like this:

{
	// Use IntelliSense to learn about possible Node.js debug attributes.
	// Hover to view descriptions of existing attributes.
	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [
		{
			"type": "node",
			"request": "launch",
			"name": "Launch Program",
			"protocol": "inspector",
			"program": "${workspaceRoot}/a.out.js"
		}
	]
}

In order to set breakpoints in *.c files (without having a C/C++ extension installed), I had to enable a special VS Code option for the workspace:

2017-08-18_17-32-35

The source map looks like this:

{
	"version": 3,
	"sources": [
		"tests/hello_world.c"
	],
	"names": [

	],
	"mappings": ";;;;;;;;;;;;;AAGA;AAAA;;;;AACA;AAAA;AAAA;AADA;AAAA;AAAA;;AAGA",
	"file": "a.out.js",
	"sourcesContent": [
		"#include <stdio.h>\n\nint main() {\n  for (int i; i < 100; i++) {\n    printf(\"hello, world: %d\\n\", i);\n  }\n  return 0;\n}\n"
	]
}

As you can see the hello_world.c file is inlined in the source map.

@weinand weinand self-assigned this Aug 18, 2017
@minkir014
Copy link

Do you mean that this worked for you. If yes, make a vs code recipe and share it with others.

@hkleynhans
Copy link

Does this work with the cpptools extension installed?

@kinglezhuang
Copy link

Can not debug for me on VS Code
Version: 1.44.2
Commit: ff915844119ce9485abfe8aa9076ec76b5300ddd
Date: 2020-04-16T17:07:18.473Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 18.7.0

@weinand
Copy link
Contributor Author

weinand commented Apr 29, 2020

@hkleynhans I see no reason why this should not work if you have cpptools installed. However, you will have to know what you are doing if you want to translate this with emscripten and debug the result. cpptools are out of the loop here...

@weinand
Copy link
Contributor Author

weinand commented Apr 29, 2020

@kinglezhuang "Can not debug for me on VS Code" is not a helpful bug descrption.
Please explain in more detail what you are trying to do and what problems you are seeing.
And provide reproducible steps.

@connor4312
Copy link
Member

js-debug needs to support this first. WebAssembly is no longer 'hacked into' the CDP protocol like before, duplicates microsoft/vscode-js-debug#853

@meetsussie
Copy link

WebAssembly is no longer 'hacked into' the CDP protocol like before, duplicates microsoft/vscode-js-debug#853

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
@weinand @connor4312 @hkleynhans @kinglezhuang @minkir014 @meetsussie and others