-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
Split afvx
to two commands - one for variables and one for function arguments
#332
Comments
How should the check to see whether the variable is a function argument or not, be implemented? |
@officialcjunior you can use the rz_list_foreach (all_vars, iter, var) {
if (var->isarg) {
if (!rz_strbuf_setf (&key, "func.%s.arg.%d", fcn->name, arg_count) ||
!rz_strbuf_setf (&value, "%s,%s", var->type, var->name)) {
goto exit;
}
sdb_set (core->analysis->sdb_types, rz_strbuf_get (&key), rz_strbuf_get (&value), 0);
arg_count++;
}
} |
Great. Currently, |
@officialcjunior I think it's better to use two separate functions. Just please avoid code duplication. |
Please note that |
@XVilka My idea is add a parameter of boolean in function list_vars(), then add two functions named cmd_afvxa() and cmd_afvxv() in file cmd_analysis.c. And both of them will be called in function cmd_afvx(). But I can't avoid code duplication. static void list_vars(RzCore *core, RzAnalysisFunction *fcn, PJ *pj, int type, const char *name, bool is_arg){
...
rz_list_foreach (list, iter, var) {
if(var->isarg == is_arg)
var_accesses_list(fcn, var, pj, access_type, var->name);
}
...
}
static void cmd_afvx(RzCore *core, RzAnalysisFunction *fcn, bool json) {
cmd_afvxa(core, fcn, json);
cmd_afvxv(core, fcn, json);
}
static void cmd_afvxa(RzCore *core, RzAnalysisFunction *fcn, bool json){
...
list_vars(core, fcn, pj, 'R/W', NULL, true);
...
}
// is similar to function cmd_afvxa()
static void cmd_afvxv(RzCore *core, RzAnalysisFunction *fcn, bool json){
...
list_vars(core, fcn, pj, 'R/W', NULL, false);
...
} sorry, I can't figure out a better way to solve the problem. |
@fhgkdhg you have to consider the code in |
@ret2libc thanks, I've added two subcommands below command afvx in file cmd_analysis.yaml, and added two functions in file cmd_analysis.c following instructions in new_shell.md. And next, I'd like to modify funciton list_vars() like I said yesterday and finish the code in the function I added. |
Yes, use |
@ret2libc I can't find any function that calls |
Those command handler functions are called automatically by the command parser ( The parameters passed to that handler are simply the arguments passed by the user when calling the |
@no1rr Make a PR for review please. Thanks. |
Is your feature request related to a problem? Please describe.
Currently it's
afvx[j]
returns the output for both local variables and function arguments which is not always desirable.Describe the solution you'd like
I suggest to split the command in two:
afvx
will show bothafvxa
will show only argumentsafvxv
will show only local variablesThe text was updated successfully, but these errors were encountered: