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

Errors in #line directives on Windows #19388

Open
sukus21 opened this issue Sep 19, 2023 · 2 comments
Open

Errors in #line directives on Windows #19388

sukus21 opened this issue Sep 19, 2023 · 2 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@sukus21
Copy link

sukus21 commented Sep 19, 2023

Describe the bug

When passing -g to v on windows, the generated files contain incorrectly formatted file paths in the #line directives. This makes debugging through GDB+VScode harder than it has to be, as it cannot correctly map the C files to the V source code.

The breakpoints are still hit, I can still use the symbol watchers. I can still see the stack trace, and tell where the breakpoint was hit through that, but it is less than convenient.

Reproduction Steps

Everything described below is happening on Windows.

  1. Create new V project using v new hello.
  2. Inside this folder, run v -g ..
  3. Locate generated C file (in my case, located in %localappdata%/Temp/v_0).
  4. Find any #line directive, and check file path.

Expected Behavior

This is what I would expect it to output, assuming it was developed for Linux first:

#line 3 "../../../../../../OneDrive\\Programmering\\V\\spin\\src\\main.v"
void main__main(void) {
	
#line 4 "../../../../../../OneDrive\\Programmering\\V\\spin\\src\\main.v"
	println(_SLIT("Hello World!"));

Current Behavior

Notice how the drive letter is right in the middle of the path. I get this would work on Linux, because the root is just / on there, so it still produces a valid path. Doesn't work like that on Windows, unfortunately.

#line 3 "../../../../../..C:\\OneDrive\\Programmering\\V\\spin\\src\\main.v"
void main__main(void) {
	
#line 4 "../../../../../..C:\\OneDrive\\Programmering\\V\\spin\\src\\main.v"
	println(_SLIT("Hello World!"));

Possible Solution

If on windows, strip the drive name from the path, and replace it with a forward slash, to mimic the Linux paths.
Another solution would be to use absolute paths, instead of relative paths. I don't know how realistic that is, though.

Additional Information/Context

This might also be problematic for windows users trying to debug V code not on the C:\\ drive.

V version

V 0.4.1 fdabd27

Environment details (OS name and version, etc.)

Windows 10, x86_64.
GDB installed through msys64.
V built from source only hours ago.

Important

You can vote for this issue using the 👍 reaction. More votes increase the issue's priority
for developers.

Take into account that only the 👍 reaction counts as a vote.
Only reactions to the issue itself will be counted as votes, not comments.

@sukus21 sukus21 added the Bug This tag is applied to issues which reports bugs. label Sep 19, 2023
@yuyi98
Copy link
Member

yuyi98 commented Sep 20, 2023

	if is_cc_tcc {
		// tcc currently has a bug, causing all #line files,
		// to be prefixed with the *same folder as the .tmp.c file*
		// this ../../ escaping, is a temporary workaround for that
		return '../../../../../..' + cescaped_path(os.real_path(path))
	}

@sukus21
Copy link
Author

sukus21 commented Sep 20, 2023

Ah, well that's annoying. I'll hack something together in my end to get it working temporarily, until a more permanent fix is in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

2 participants