-
Notifications
You must be signed in to change notification settings - Fork 47
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
[Feat] Debug improvements #474
[Feat] Debug improvements #474
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also add an example output in the PR!
@@ -614,6 +618,7 @@ for ({i_ty} {i} = {start}; {i} {cmp} {end}; {increment}) {{ | |||
} | |||
} | |||
Instruction::Pipeline(pipeline_ops) => write!(f, "{pipeline_ops}"), | |||
Instruction::Line { file, line } => writeln!(f, "#line {line} \"{file}\""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious what it looks like!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an example to the PR text. A debugger/profiler should use these to keep track of actual source locations, but I don't know how well they actually keep track of things especially with the JIT compiler.
pub source_loc: Option<SourceLoc>, | ||
pub entry_loc: Option<SourceLoc>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between the two?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entry_loc is basically just the first source_loc ever set for a kernel, so we can set the source loc at the start of a kernel without having to look ahead to the first update. Otherwise you'd need to always scan ahead which is harder than just keeping track of the first value.
NonSemantic::Source
s and correlate them to specific functions.#line
directives to C++ so we have at least some debug info. Example:Finally, the actual Rust source can now be attached in one of two ways:
src_file
argument on at least one#[cube]
macro per file. This uses the fact thatinclude_str!
is relative by just including a file in itself. But to do that we need to know the actual name of the file.CUBECL_DEBUG_NIGHTLY
environment variable during compilation. This will use the unstableSpan::source_file
API to automatically fetch the source and include it in thesource_expand
invocation.