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

#534 Support for line debugging #656

Merged

Conversation

99NIMI
Copy link
Member

@99NIMI 99NIMI commented Nov 17, 2022

Add support for line debugging
Debugging works on any assignment statement or function call
Loops and other conditions are still not supported
Variables are correctly associated during debugging.

Fixes: #534 #537

@99NIMI 99NIMI requested a review from ghaith November 17, 2022 15:07
@99NIMI 99NIMI linked an issue Nov 17, 2022 that may be closed by this pull request
@ghaith ghaith force-pushed the 534-debug-support-setting-breakpoints-on-different-lines-in-code branch 2 times, most recently from 0527b99 to 37bf7b8 Compare November 25, 2022 04:39
Local variables and parameters are now supported
…etting-breakpoints-on-different-lines-in-code
@ghaith ghaith force-pushed the 534-debug-support-setting-breakpoints-on-different-lines-in-code branch from dd5d20c to 8d3eeb8 Compare November 28, 2022 15:53
@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2022

Codecov Report

Base: 94.09% // Head: 94.11% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (5b3d7ac) compared to base (b7d887d).
Patch coverage: 94.34% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #656      +/-   ##
==========================================
+ Coverage   94.09%   94.11%   +0.01%     
==========================================
  Files          46       46              
  Lines       18245    18763     +518     
==========================================
+ Hits        17168    17658     +490     
- Misses       1077     1105      +28     
Impacted Files Coverage Δ
src/codegen/debug.rs 94.12% <91.76%> (-2.94%) ⬇️
src/codegen/generators/pou_generator.rs 93.75% <97.20%> (+0.77%) ⬆️
src/codegen.rs 99.25% <100.00%> (+0.04%) ⬆️
src/codegen/generators/expression_generator.rs 89.74% <100.00%> (+0.08%) ⬆️
src/codegen/generators/statement_generator.rs 97.91% <100.00%> (+0.06%) ⬆️
src/codegen/generators/variable_generator.rs 94.11% <100.00%> (ø)
src/index.rs 97.19% <100.00%> (-0.02%) ⬇️
src/index/visitor.rs 96.45% <100.00%> (+0.04%) ⬆️
src/lib.rs 87.91% <100.00%> (+0.34%) ⬆️
src/resolver/generics.rs 96.82% <100.00%> (+<0.01%) ⬆️
... and 6 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ghaith ghaith changed the title #534 debug locations wip #534 Support for line debugging Dec 2, 2022
@ghaith ghaith requested a review from riederm December 2, 2022 06:47
@ghaith ghaith marked this pull request as ready for review December 2, 2022 06:48
@ghaith ghaith linked an issue Dec 2, 2022 that may be closed by this pull request
scope: DIScope<'ink>,
line: usize,
column: usize,
) -> Result<DILocation, Diagnostic> {
Copy link
Collaborator

@riederm riederm Dec 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result not required - in fact I believe most of these functions will never return an Err?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should, I think I mostly forgot to remove / change some panics, I'll take another look

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction: I had not seen the methods this is on, this one was useless i removed the method

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 methods in DebugBuilder impl look like they will never fail
others could benefit from a .expect(...)( when calling types.get(...)

.expect("A POU will have an impl at this stage");
if implementation.implementation_type != ImplementationType::Function {
if implementation.get_implementation_type() == &ImplementationType::Method {
todo!("Method debugging");
Copy link
Collaborator

@riederm riederm Dec 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will codegen now panic for methods?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not unless it's being compiled with -g, but I could make this a diagnostic instead.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its now an Err(...). we should just ignore it for the moment so a method will not permit a debug-build

.map(|dt| {
self.types
.get(dt.get_name().to_lowercase().as_str())
.expect("at this point we should have all types") // TODO: error msg
Copy link
Collaborator

@riederm riederm Dec 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mention dt.get_name() in the message

@@ -413,14 +484,27 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> {
m.get_name(),
&index.get_associated_type(m.get_type_name())?,
);

if let Some(block) = self.llvm.builder.get_insert_block() {
debug.add_variable_declaration(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we also register variable declaration for the return variable? (aggregate and normal ones?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already do, there's also a test for aggregate return types
We can maybe do a walkthrough for it

…etting-breakpoints-on-different-lines-in-code
@ghaith ghaith removed their request for review December 2, 2022 14:05
@ghaith ghaith merged commit 54301a0 into master Dec 7, 2022
@ghaith ghaith deleted the 534-debug-support-setting-breakpoints-on-different-lines-in-code branch December 7, 2022 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug - Jump into / out of functions Debug - Support setting breakpoints on different lines in code.
4 participants