Repository navigation
feat: consider variable types at extraction - #2078
szokeasaurusrex wants to merge 4 commits into
Conversation
| let (start_truncation_notice, end_truncation_notice) = match value.truncated { | ||
| Some((count, Endian::Little)) => (Some(truncation_notice(count)), None), | ||
| Some((count, Endian::Big)) => (None, Some(truncation_notice(count))), | ||
| None => (None, None), |
There was a problem hiding this comment.
I don't think that makes sense, even with different endianness we're still just formatting a plain slice of memory from small to large.
There was a problem hiding this comment.
What exactly is confusing?
We are considering endianness when reading this memory slice, as we don't use the general method for reading slices that does not consider the endianness. So, where to place the truncation notice does depend on endianness in this case.
There was a problem hiding this comment.
It's a slice of bytes, where the notice is doesn't depend on the endianness - it's just raw bytes. Seems like you already dealt with this though.
89d5a70 to
819d4af
Compare
819d4af to
41ab4cd
Compare
| // TODO: Is it correct to extract both signed and unsigned chars as u8 in this way? | ||
| (Primitive(SignedChar | UnsignedChar), 1) => { | ||
| get_value!(u8, |v| format_variable!("'{}'", v.escape_ascii())) | ||
| } |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b6bc016. Configure here.
| .find_map(|loc| resolve_value(cache, registers, memory, loc, variable.ty())); | ||
| let value = variable.locations().find_map(|loc| { | ||
| resolve_variable_value(cache, registers, memory, loc, variable.ty()) | ||
| })?; |
There was a problem hiding this comment.
Missing values omit variables
Medium Severity
do_extract now drops a variable when every location fails to produce a value. The name, type, and kind were already resolved, and the previous code still emitted the variable with an empty value. Those names disappear whenever memory is missing or the type is unsupported.
Reviewed by Cursor Bugbot for commit b6bc016. Configure here.
There was a problem hiding this comment.
I guess we can still emit such variables without a value. @Dav1dde what do you think?
There was a problem hiding this comment.
Yeah I think we should, to give the user at least some confidence that what we're doing is correct, we just failed to extract the value.
Can definitely do that in a follow-up/separate ticket.
| // Floating-point types. Reading f128 from memory is currently not supported, so we don't | ||
| // handle it for now. | ||
| (Primitive(Float), 4) => get_value!(f32), | ||
| (Primitive(Float), 8) => get_value!(f64), |
There was a problem hiding this comment.
Float JSON conversion misrepresents values
Medium Severity
Float reads go through VariableValue::value, which converts with Into<serde_json::Value>. NaN and infinities become JSON null, and f32 is widened to f64, so many finite 32-bit values pick up extra digits when serialized.
Reviewed by Cursor Bugbot for commit b6bc016. Configure here.
There was a problem hiding this comment.
I guess it would make sense to support infinity and NaN
I am not sure about whether we should care about 32-bit values picking up additional digits when serialized. Apparently enabling arbitrary_precision may fix this; otherwise we might need custom serialization logic. Should we enable arbitrary_precision?
There was a problem hiding this comment.
Let's not enable it, we can track this is a separate issue we can come back to later if we think that's an issue with real data.
If we fix this on this end, we'd also need to make sure the frontend deals with it properly (e.g. keeps the same precision), which I doubt it does.
b6bc016 to
7466db0
Compare
Create a separate module for extracting variables, per @Dav1dde's suggestion: #2078 (comment).
7466db0 to
9b26271
Compare
| } | ||
| } | ||
|
|
||
| impl FromStr for PointerAddress { |
There was a problem hiding this comment.
Is this used, I can't find a usage 🤔
If the deserialization part is unused, I would keep it out of the module for now and focus purely on serialization.
| .find_map(|loc| resolve_value(cache, registers, memory, loc, variable.ty())); | ||
| let value = variable.locations().find_map(|loc| { | ||
| resolve_variable_value(cache, registers, memory, loc, variable.ty()) | ||
| })?; |
There was a problem hiding this comment.
Yeah I think we should, to give the user at least some confidence that what we're doing is correct, we just failed to extract the value.
Can definitely do that in a follow-up/separate ticket.
| // Actual beginning of the function is here, everything above are helper type and macro defs. | ||
|
|
There was a problem hiding this comment.
| // Actual beginning of the function is here, everything above are helper type and macro defs. |
| // Floating-point types. Reading f128 from memory is currently not supported, so we don't | ||
| // handle it for now. | ||
| (Primitive(Float), 4) => get_value!(f32), | ||
| (Primitive(Float), 8) => get_value!(f64), |
There was a problem hiding this comment.
Let's not enable it, we can track this is a separate issue we can come back to later if we think that's an issue with real data.
If we fix this on this end, we'd also need to make sure the frontend deals with it properly (e.g. keeps the same precision), which I doubt it does.
| // TODO: Is it correct to extract both signed and unsigned chars as u8 in this way? | ||
| (Primitive(SignedChar | UnsignedChar), 1) => { | ||
| get_value!(u8, |v| format_variable!("'{}'", v.escape_ascii())) | ||
| } |
| } | ||
|
|
||
| #[derive(Debug, PartialEq, Eq, Clone, Copy)] | ||
| pub(crate) enum PointerAddress { |
There was a problem hiding this comment.
| pub(crate) enum PointerAddress { | |
| pub enum PointerAddress { |


WIP change to consider variable types when extracting the variables
Stack created with GitHub Stacks CLI • Give Feedback 💬