-
Notifications
You must be signed in to change notification settings - Fork 56
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
remove alignment for debug data #1434
base: master
Are you sure you want to change the base?
Conversation
f38a04c
to
57c9755
Compare
I have tried to debug a quick example and it seems we cannot remove the alignment in the debuginfo after all. I'm getting quite a few garbage values in the debugger.
After stopping on a breakpoint in main, using
After trying this on master, I've noticed that the output is not correct either (also tried before the latest commit in regards to
Notice that here the first floating point value is still correct, but soon after this statement is no longer true - we are back to being confronted with garbage. |
@@ -310,7 +309,7 @@ impl<'ink> DebugBuilder<'ink> { | |||
file, | |||
location.get_line_plus_one() as u32, | |||
size.bits().into(), | |||
alignment.bits(), | |||
0, // no alignment for now |
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 wording of this comment is a bit confusing - can we either remove it or give a reason as to why there is no alignment? Someone reading this 6 months down the line/someone not aware of this change might not appreciate the mystery 😄
//Create a struct type | ||
let struct_type = self.debug_info.create_struct_type( | ||
file.as_debug_info_scope(), | ||
name, | ||
file, | ||
location.get_line_plus_one() as u32, | ||
running_offset.bits().into(), | ||
struct_dt.get_alignment(index).bits(), | ||
0, // no alignment for now |
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.
see above
@@ -458,7 +455,7 @@ impl<'ink> DebugBuilder<'ink> { | |||
file, | |||
location.get_line_plus_one() as u32, | |||
file.as_debug_info_scope(), | |||
inner_dt.get_type_information().get_alignment(index).bits(), | |||
0, // no alignment for now |
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.
see above
.expect("Type should exist at this stage"); | ||
let alignment = var_type.get_type_information().get_alignment(index).bits(); | ||
self.register_local_variable(variable, alignment, func); | ||
self.register_local_variable(variable, 0, func); |
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.
do we still need the alignment argument? If the alignment for debuginfo is now always 0, I think we can remove it from the API
let location = &datatype.location; | ||
match type_info { | ||
DataTypeInformation::Struct { members, .. } => { | ||
self.create_struct_type(name, members.as_slice(), index, location) | ||
} | ||
DataTypeInformation::Array { name, inner_type_name, dimensions, .. } => { | ||
self.create_array_type(name, inner_type_name, dimensions, size, alignment, index) | ||
self.create_array_type(name, inner_type_name, dimensions, size, Bytes::new(0), index) |
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.
see above
} | ||
DataTypeInformation::Pointer { name, inner_type_name, .. } => { | ||
self.create_pointer_type(name, inner_type_name, size, alignment, index) | ||
self.create_pointer_type(name, inner_type_name, size, Bytes::new(0), index) |
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.
see above
@@ -671,7 +663,7 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> { | |||
let length = string_size | |||
.as_int_value(index) | |||
.map_err(|err| Diagnostic::codegen_error(err, SourceLocation::undefined()))?; | |||
self.create_string_type(name, length, *encoding, size, alignment, index) | |||
self.create_string_type(name, length, *encoding, size, Bytes::new(0), index) |
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.
see above
I would recommend we look at clang's behavior in a similar setting, effectively the same application in C. This tells us how they are handling these situations. |
This PR fixes the issue of values not showing for methods of an inherited functionblock while debugging. The reason for this wrong behavior is an alignment issue where structs are not aligned in the way the debugger expects them to be. The runtime behavior is not affected by this issue. As discussed with @ghaith we'll remove alignment for debug data for now. This remedies the issue.
TODO: