-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add a scrollbar to the disassembly window #3430
base: dev
Are you sure you want to change the base?
Conversation
This needs a lot more serious testing and a test plan across various usecases supported by cutter/rizin as mentioned in the mattermost discussion. |
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.
Just playing with it for 10minutes made it break in so many different ways there is no point in me listing them or doing further review until you come up with more serious test plan and go through with it fixing any problems you find during the process.
Try actually using the Cutter (with the new scrollbar) and not just opening single unspecified file and doing 5 seconds of scrolling without paying attention what you are looking at beyond the fact that it changes somehow as you scroll. Try actually reading the disassembly while using the scrollbar. If you have no reverse engineering experience or understanding about various executable formats, feel free to spend a week trying to learn basics first and then return to this PR, otherwise it will be very hard for you to evaluate whether stuff you see makes any sense.
it's ok karliss. it's not a simple issue. they are trying to fix some issues to get used to the code. |
Karliss, first of all, thank you for taking the time to test my PR. I'm aware of my limitations when it comes to testing PRs here - I'm not a reverse engineer, and even a week using Cutter would not be enough to find every edge case. I had assumed that tying the scroll bar to the disassembly window refresh function would be enough, but it clearly was not. It would be very helpful if you listed all the ways you made the scroll bar break, but I understand your frustration. I will spend more time with Cutter, prodding around for bugs in the scroll bar, in order to iron out the remaining kinks in its implementation. |
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.
Looking more promising already.
Compared to initiatial version doesn't crash when opening small files anymore, works better when debugging, doesn't use completely nonsensical range when opening PE(.exe) executables.
There seems to be some bug with handling end of range. Here are the steps I did:
- copy and paste 0x00008a0b copies of "90" in open shellcode tab and open it, exact count probably doesn't matter but it should be on the same order of magnitude
- reduce the height of disassembly window as much as possible
- attempt scrolling to the bottom using scrollbar
Expected result:
Instruction at 0x00008a0b is either somewhere in screen or one instruction above the first visible instruction. (Not asking for it to be perfectly at bottom, as that's currently not easily possible due to line!=byte) .
Actual result:
last visible instruction is at 0x89ef, cutting off some of the last instructions.
Another problem I observed is where you can't reach use scrollbar to reach the top under certain conditions. Something like:
- Jump to the middle of executable
- jump to an address 20 bytes after the scrollbar top using "Type flag name or address here".
- try to drag the scrollbar up to reach the actual top -> position doesn't change
I am guessing that both problems are actually caused by bad edge case handling in with the max 100 and currentVScrollAddr()
logic. Once you bump the max value as requested in other comment, it might look like the problem disasppeared. But it will likely still be there, just harder to trigger. So I recommend fixing these 2 first and only then dealing with raising max scroll value.
Both issues should be fixed. Let me know if there's anything else that needs work. |
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.
Don't forget to fix CI failures.
There is something very weird happening near the end.
Open shellcode with 0x00000168 bytes an slowly drag the scrollbar to bottom. Near the end it suddenly jumps to the end, but keeps reacting mouse movement.
Probably related, if you slowly scroll with a scrollwheel of such file (tested with 0x87), there is point near end where scrolling by 3 lines suddenly cause scrollbar position to jump by a lot. I am guessing some kind of inconsistency in scrolbar->address, adress->scrollbar mapping in combination with callback loop (scrollbar updates seek position, seek position updates scrollbar pos).
Problem is even more exaggerated if you open raw binary file (64 bytes) and in advanced options during opening set map offset to 0x1000 (it's equally bad for the same file without setting map offset)
With small files for example 43, there is a different 2 byte jump near the end. As you scroll with scrollbar, the top position changes 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2b. , skipping 0x2a. Not sure if it's related or separate problem from the one described above.
Instead, we set the scroll bar's end offset to the file's end offset - 1, so the file end offset will always be at the top of the disassembly window when you scroll to the bottom
Addressed those issues as well. Scrolling to the bottom now should place the binary's end offset at the top of the disassembly viewer. Not ideal, but it's hard to do better. The only other option I see is to perform a binary search using CutterCore::disassembleLines with different offsets until we find an offset where the binary's end offset is at the last line. |
Like i said in #3430 (review) that's acceptable. I have some plans for improving line handling in disassembly widget but that's a separate giant task. |
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.
Was using the fallback formula for small files while testing and forgot to change it back before committing
The scroll bar buttons work even if you're viewing something outside the scroll bar's range. They behave somewhat weirdly in that if you're past the end of the scroll bar's range and try to scroll up, it works fine, but scrolling down won't work. How should the scroll bar behave in such cases? Some options:
|
I don't have any strong feeling with regards to button behavior outside the range, except that they shouldn't cause snapping behavior. Working always (2.1) or as is towards range (4) would be fine with me. |
Your checklist for this pull request
Detailed description
Implements a scroll bar for the disassembly window. Helps with viewing different sections of a file in multiple disassembly windows, and is useful for scrolling through the binary during a debug session.
Test plan (required)
Tested with multiple, different binaries:
Things I could not test:
Closing issues
Closes #2907.