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

Print dirty bytes for removed variables #11

Open
ZeroEkkusu opened this issue Dec 13, 2023 · 13 comments
Open

Print dirty bytes for removed variables #11

ZeroEkkusu opened this issue Dec 13, 2023 · 13 comments

Comments

@ZeroEkkusu
Copy link
Member

ZeroEkkusu commented Dec 13, 2023

If a variable is removed (not overridden), print dirty bytes to mask.

Context

Let's say we start with:

    bytes1 a
    bytes2 b

If we remove b:

    bytes1 a
🪦  2 dirty bytes

Case: a doesn't overlap b

In this case we print how many dirty bytes there are.


If we change a to bytes2, and remove b:

🏴  bytes2 a
🪦
    1 dirty byte

Case: a partially overlaps b

In this case we don't print how many dirty bytes there are in the overlap, only after it.


If we change a to bytes3, and remove b:

🏴  bytes3 a
🪦

Case: a completely overlaps b

In this case we don't print how many dirty bytes there are.


I can suggest one way to solve this:

Create a new function addDirtyAfterRemoved that takes two inputs: the old and new layouts.

By that, I mean these two variables here:

const [alignedOverlayedVisualized, alignedOldVisualized] = alignLayouts(overlayedVisualized, oldVisualized);

Call the function immediately after the above line.

What it should do:

For each item in the new layout, check if it's undefined.
If it is, add a dirty item after it to the new layout and an undefined item to the old layout, if applicable, according to the rules we set above.

That should take care of the new dirty items.
For printing dirty bytes at the same line as 🪦, I think we'll have to handle that on the 'ANALYZE' level instead; I mean here:

// ========== ANALYZE ==========

For example by adding a helper function that checks whether we should just print 🪦 to the report with an empty line, or with the dirty bytes info.


I know this can get complex at times, so feel free to ping me to help you out.

Additional notes

Beware of a situation like this one (I'll add positions for clarity):

0     bytes2 a
2     bytes4 b

Change to:

0     bytes3 a
3     bytes1 c

In this case, the finding should be:

0 🏴  bytes3 a
2 🪦
3 🏴  bytes1 c
4     2 dirty bytes
@ZeroEkkusu ZeroEkkusu added the good first issue Good for newcomers label Dec 13, 2023
@triggeredcode
Copy link
Contributor

@ZeroEkkusu Can you assign this to me? Also I am a beginner so some context would be nice. Thanks

@ZeroEkkusu
Copy link
Member Author

Gm, @triggeredcode.

Yes, I can! Though, you may find #7 more interesting (and it's more useful).

I'll add some description there, in case you change your mind. If not, let me know, and we'll return to this one!

@kamuik16
Copy link
Contributor

If a variable is removed (not overridden), print dirty bytes to mask.

Hey @ZeroEkkusu ! Is this issue still open for contribution? I would like to work on this.

@ZeroEkkusu
Copy link
Member Author

@kamuik16 Replied to you in #9!

@kamuik16
Copy link
Contributor

kamuik16 commented Jan 7, 2024

@kamuik16 Replied to you in #9!

Ready to do this, some context and what output is needed would be great!

@ZeroEkkusu
Copy link
Member Author

@kamuik16 Added!

@ZeroEkkusu
Copy link
Member Author

@kamuik16, just a heads up that I think I've spotted an edge case. I'll modify the description to explain it. Also, I'll remove the second part (legacy) for now, if that's okay with you.

@kamuik16
Copy link
Contributor

kamuik16 commented Jan 8, 2024

@kamuik16, just a heads up that I think I've spotted an edge case. I'll modify the description to explain it. Also, I'll remove the second part (legacy) for now, if that's okay with you.

Yeah sure.

@ZeroEkkusu
Copy link
Member Author

@kamuik16 Explained.

Please feel free to ping me if I can help with the development.

@kamuik16
Copy link
Contributor

kamuik16 commented Jan 8, 2024

@kamuik16 Explained.

Please feel free to ping me if I can help with the development.

Okay.

@ZeroEkkusu
Copy link
Member Author

ZeroEkkusu commented Jan 8, 2024

Btw, if this is complicated, #8 may be another good choice.

I've came up with an easier way to solve it and will describe it there as well.

@kamuik16
Copy link
Contributor

kamuik16 commented Jan 8, 2024

Btw, if this is complicated, #8 may be another good choice.

I've came up with an easier way to solve it and will describe it there as well.

Yeah, I guess this is complicated for me as I am yet to take a deeper understanding of the whole script.

@ZeroEkkusu
Copy link
Member Author

No worries, that's totally understandable.

@ZeroEkkusu ZeroEkkusu removed the good first issue Good for newcomers label Jan 8, 2024
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

No branches or pull requests

3 participants