-
-
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
Show Caller Name in XREF #3417
base: dev
Are you sure you want to change the base?
Show Caller Name in XREF #3417
Conversation
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.
Looks good! @karliss
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.
^
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.
Hmm makes sense. this is true also for xrefs that are not calls. (like data xrefs etc..), where there is "no caller"
Yes, there is a function: if (f->offset != addr) {
rz_cons_printf("%s + %d\n", name, (int)(addr - f->offset)); |
I didn't found a specific function which given an address formats it as "name+offset", rather it seems it's copy pasted in different parts in Rizin: If I can't do it the way @notxvilka suggests it, I'm not sure what I could do. |
The last link you have shared does exactly what you have described. flag + offset (just called delta there) |
Sorry, I'm confused @wargio , I could do something like this: index e674d9a6..3abd9b21 100644
--- a/src/core/Cutter.cpp
+++ b/src/core/Cutter.cpp
@@ -4021,7 +4021,24 @@ QList<XrefDescription> CutterCore::getXRefs(RVA addr, bool to, bool whole_functi
continue;
}
- xd.from_str = RzAddressString(xd.from);
+ if(to) {
+ RzFlagItem *f = rz_flag_get_at(Core()->core()->flags, xd.from, true);
+ if(f) {
+ int delta = xd.from - f->offset;
+ if (delta > 0) {
+ xd.from_str = rz_str_newf("%s+%x", f->name, delta);
+ } else if (delta < 0) {
+ xd.from_str = rz_str_newf("%s-%x", f->name, delta);
+ } else {
+ xd.from_str = rz_str_newf("%s", f->name);
+ }
+ } else {
+ xd.from_str = RzAddressString(xd.from);
+ }
+ }
+ else {
+ xd.from_str = RzAddressString(xd.from);
+ }
xd.to_str = Core()->flagAt(xd.to); But wouldn't that contradict what @karliss was saying about not reimplementing things on cutter side? |
yes, but delta is already an and modify the negative to not include the sign, which will be added by
|
This comment was marked as resolved.
This comment was marked as resolved.
I wonder if it makes sense to make it an API function from the Rizin side. To avoid copy-pasting the same code between Rizin and cutter. Something like But then it would be blocked on #3418 So, for now, this change should be ok, I think. |
yes probably we can merge this and then have an api returning a string. |
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.
LGTM
@karliss give it a look |
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.
As a side note I highly recommend to find a suitable resource and learn the basics of git. Making pull requests from the dev branch of your fork will likely cause you problems in future.
Sorry for the mess but I think I'm finally on the right track: I replaced |
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 code is fine.
But I have doubts about merging it in current state.
It adds a bunch of code which will have to be later thrown out, and contains no code which will be useful later once rizin has appropriate API. Sure there are situations where it's useful where it's useful to merge partial implementation first, and then replace some of it withe calls to better API when available. But that assumes that the changes contain at least some useful code (some UI additions or code restructuring) which will be reusable once the better API is available.
Other case where it might be worth merging partial implementation is if it still provides significant improvement in usability. That in current state is also limited due to inconsistency with rizin and not handling a bunch of cases which rizin does.
Here are some examples:
Useless "case.xxx.yy+offset" since the current version takes any flag without considering it's type.
Uses different style of formatting fcn.00b200+81
vs fcn.00b200+0x51
.
I have also seen cases where current implementation displays data_something+offset
even though asm.reloff displayed fcn.xxxx+offset
. And that was with asm.relof.flags
also enabled.
For the temporary implementation might be better to use CutterCore::functionIn
like the initial implementation did (but keeping rest of the structure from current version). While in theory this feature should display of not just function relative stuff, in the current version use of rz_flag_get_at
makes the result worse more often than it improves. Need to try out with functionIn to be sure.
Also should use offset as hexadecimal(1) number like the asm.reloff
mode does.
Correction:
(1) asm.reloff
chooses base based on asm.decoff
Your checklist for this pull request
Detailed description
Ref #3416
Test plan (required)
Open a project, select a function and check for xref.
The dialogue now can also show the name of the caller.
Closing issues
Closes #3416