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

Marking edges on disassembly graph view #18374

Open
rhythmize opened this issue Feb 22, 2021 · 20 comments
Open

Marking edges on disassembly graph view #18374

rhythmize opened this issue Feb 22, 2021 · 20 comments
Assignees

Comments

@rhythmize
Copy link

Hi,
I'm just wondering if there's some way for selecting/ marking the visited edges in the disassembly graph while doing code traversal. What happens is when the control flow is too big to fit on one screen or even when there are too many jumps/ calls to a particular code block, it gets pretty difficult to keep track of what's already visited and whats not.

I can't find any help from the documentation regarding the same.

Inputs are appreciated.

@trufae
Copy link
Collaborator

trufae commented Feb 27, 2021

You can set a color for the basic blocks, not for the edges yet. Do this work for you?

@rhythmize
Copy link
Author

Hi,
It'll work in a linear flow, but in case where we have different edges coming into the same block, it'll not be possible to backtrace the previous block or distinguish among which edge we came through or already traversed.

I hope it makes sense.

@trufae
Copy link
Collaborator

trufae commented Feb 28, 2021

Yep totally makes sense to me. I have opened a pr with an initial implementation for this feature. Feel free to try it out. Ill close this issue when merged

@rhythmize
Copy link
Author

Sure.
Thanks a lot.

@trufae
Copy link
Collaborator

trufae commented Feb 28, 2021

Check the new ageh command. works well when the graph is properly generated, i have identified some deep bugs in the way graphs are generated that make this new logic break.. and actually most jump table analysis are wrong because of this. But this will help me to debug and fix it. Thanks! hope it works for you now!

PD: i will also extend ageh to also highlight the edges in the graphviz output

@rhythmize
Copy link
Author

Thanks, I'll check.

@rhythmize
Copy link
Author

Hi,
For the testing sake, I wanted to highlight the edge between block 0xad8 and 0xae3. The help message shows the command format as

ageh 0xad8 0xae3

I see the edge in the list of highlighted edges with property set to true, using following command

ageh

But visually there's no difference I can see. Am I missing something?
Thanks for your help

image

@trufae
Copy link
Collaborator

trufae commented Feb 28, 2021

Oh found the bug, fixing now :)

@trufae
Copy link
Collaborator

trufae commented Feb 28, 2021

also adding tests

@rhythmize
Copy link
Author

Thanks

@trufae
Copy link
Collaborator

trufae commented Feb 28, 2021

Fixed your bug in a PR (will merge as soon as it passes the CI), but i found another one that is making some edges not highlightable. But ill need more time to find a proper fix for this, maybe tomorrow.

@rhythmize
Copy link
Author

Hi, yeah sure no worries.
Thanks for taking up this issue on such a short notice.

@trufae trufae self-assigned this Mar 8, 2021
@rhythmize
Copy link
Author

Hi,
Just wanted to update that I was able to successfully test these changes and now I'm able to mark the necessary edges as I need.

Just another query: So in visual graph mode, I have noticed that whatever changes I make using command console in radare2 for example, marking an edge or renaming a variable, the changes doesn't reflect immediately, I need to close the graph view and then reopen it so as to be able to see the changes. Is there any workaround for this?
Moreover, I noticed that while adding a comment (using the shortcut key ";") changes are reflected immediately, but whereas doing the same from command console requires re-opening the graph mode.

Thanks

@trufae
Copy link
Collaborator

trufae commented Mar 13, 2021

There are two issues to be solved for this issue:

  • long edges use fake nodes to draw the paths which result in non colorized lines in some situations because the split of anal graph and ascii graph which is a little pain to work on.
  • the refresh can be done by pressing R key. But other actions refresh the graph so those may work too for u no need to leave and join the graph

Im currently having some medical issues in the eyes that dont permit me to use any screen for more than few minutes in a row. Otherwise all this stuff would be solved :( i hope to be better in a month but meanwhile i would appreciate contribs or feedback in any case im not forgetting those issues which i hope to get solved soon or late

@trufae
Copy link
Collaborator

trufae commented Mar 13, 2021

Thanks for the update :)

@rhythmize
Copy link
Author

Hi,
Thanks for information the refresh using R key is working fine for me.
Actually, I started using this project recently and really liked it and wanted to contribute to the codebase so I started delving into the codebase, but I wasn't even able to understand the control flow of basic r2 modules. Even developer guide doesn't specifically explain various submodules, or maybe I need to invest more time to make sense of it. It's a pretty mature codebase and seems a bit complicated to directly understand it. Perhaps maybe sometime in future I'd be able to do that once I have enough bandwidth to investigate and contribure to this codebase.

Take care and thanks for all your help.
Cheers!

@radare
Copy link
Collaborator

radare commented Mar 15, 2021 via email

@rhythmize
Copy link
Author

Yeah, I have good understanding of development in C, although I have worked more with C++, working is C isn't that big a challenge for me. I'll try to find resources on youtube and try to see if I can pickup some small issues to get started with. In case I face some problems or need assistance, I'll definitely ping.

Thanks.

@rhythmize
Copy link
Author

Hi,
I have a very basic question. Since radare2 seems to use the current terminal console as its display window, where are the log messages are being redirected? For example, in order to understand the control flow, if I add a printf statements, where is that message being logged, I'm not able to see those messages, since it appears like radare2 output overlays the actual terminal.

Maybe I have some wrong understanding, in case, please correct me. Or is there any other way that is used by developers to track the control flow at runtime?

Thanks for your inputs.

@trufae
Copy link
Collaborator

trufae commented Mar 18, 2021

if you use printf debugging in visual mode, the best way to debug that is using eprintf, which print things to stderr and just run r2 with 2> /tmp/log.txt, in another terminal you can tail -f /tmp/log.txt

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