-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Change the order where register aliases fetch their numeric value to prioritize r_reg_get over r_flag_get ##radare2 #24792
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
base: master
Are you sure you want to change the base?
Conversation
|
Do not do merge commits. Always rebase |
|
There r 2 ways to fix that:
|
|
The problem of the first is that it is different symtax, the problem of the second is that it will slowdown the thing because it will sync regs all the time unless we mark a dirty bit somewhere to avoid syncing the regs all the time |
|
I tried to follow the instructions regarding rebasing but I am not a git wizard. Is there any action that needs to be taken to fix this branch now or? I personally prefer the second approach you describe because I value that scripting works as similar to the interactive mode as possible, I think it is very hard for a new user to debug and understand the nuances in how the context of the invocation of the commands affect their output, but that is just my opinion. Is r_reg_get and r_reg_get_value expensive operations compared to r_flag_get? The changes I have in this pull request resolved the issue for me, but do you think that this solution is undesirable because of performance? I would otherwise be willing to test to implement the dirty bit solution, but is there a way to know which commands affect the state of the binary? Continuing the execution of the program would I guess always need to set the registers dirty, but just seeking to an adress would not. |
|
sorry rebase again please |
|
rebase |
… of arbitrarily large number.
…prioritize r_reg_get over r_flag_get
|
I have seen on some other pull requests that not all tests have been successful, but are there tests here that should pass unless my changes introduced some bugs? |
|
your pr introduces bugs: this is clearly eax not being usable as a normal flag because its hooked by the rreg api so it fails and returns -1. ^thats an empty line with trailing spaces |
trufae
left a comment
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.
changes look good. can you rebase, apply the fixes and take care of the broken tests? maybe the way to fix those tests is by adding a config var to disable this behaviour by default for now. and we can enable it when running in debug mode , but i wont include that change in this release.
the timeout thing is somthing that should be merged before the rls
| if ((flag = r_flag_get (core->flags, str))) { | ||
| ret = flag->addr; | ||
| // check for reg alias | ||
| RRegItem *r = r_reg_get (core->dbg->reg, str, -1); |
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.
you can also use r_reg_getv
| return false; | ||
| } | ||
| r_socket_block_time(fd, true, 99999, 0); | ||
| r_socket_block_time(fd, true, 0, 0); |
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.
| r_socket_block_time(fd, true, 0, 0); | |
| r_socket_block_time (fd, true, 0, 0); |
Description
When starting radare with the -i option to execute a script, so did the alias for registers not work correctly for math operations such as "? rbp". The reason, as I understand it, is that when a debugger is attached, so is a part of the setup to set all the registers as flags using the ".dr*" command, but that on startup just sets them all to 0x0. Later, when the token's numerical value is fetched, so does it first lookup flags rather than registers, which means it always gets the flag value. This makes it so that using "? rbp" in a -i script will always yield 0x0.
The reason why it works normally otherwise as I understand it, is because during the regular command loop so does it always execute a certain number of commands after each user inputed command, and one of them is ".dr*" which makes the register flags always up to date.
The way to fix this issue would be either to make it so that the same "cleanup" commands are executed after each -i command in the startup script, or the suggested change that I made, which I find to be less intrusive. It does, on the other hand, change the way that "? rbp" is executed in almost all scenarios, but I do not feel that I have the knowledge to say if that is necessarily a bad thing.
This pull request also includes a commit that was supposed to me made in this previous pull request but I did not push it before it was merged. #24767