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

Refactor Visual mode (librz/core/tui/visual.c) to use API instead of commands #382

Open
XVilka opened this issue Jan 18, 2021 · 3 comments
Labels
API cmd-api Switch from cmd calls to API help wanted Extra attention is needed refactor Refactoring requests visual
Milestone

Comments

@XVilka
Copy link
Member

XVilka commented Jan 18, 2021

Currently, the code of Visual modes heavily relies on running commands instead of just calling the proper API functions.
To reduce the overhead, code cruft, and code breakage in case of the command changes it is important to remove all those command calls and call the proper API directly.

[i] ℤ rg "rz_core_cmd[0f_]*\(" librz/core/tui/visual.c                                                                                                                                                                                 12:21:36 
494:                    rz_core_cmd0(core, p + 1);
795:                    ch = rz_core_cmd0(core, cmd);
803:                    ch = rz_core_cmd0(core, cmd);
811:                    ch = rz_core_cmd0(core, cmd);
817:                    ch = rz_core_cmd0(core, cmd);
828:                    ch = rz_core_cmd0(core, cmd);
834:                    ch = rz_core_cmd0(core, cmd);
840:                    ch = rz_core_cmd0(core, cmd);
848:                    ch = rz_core_cmd0(core, cmd);
856:                    ch = rz_core_cmd0(core, cmd);
864:                    ch = rz_core_cmd0(core, cmd);
870:                    ch = rz_core_cmd0(core, cmd);
876:                    ch = rz_core_cmd0(core, cmd);
1525:           rz_core_cmd0(core, "?i highlight;e scr.highlight=`yp`");
2144:                   rz_core_cmd0(core, "eco $(eco~...)");
2147:                   rz_core_cmd0(core, "dpt=$(dpt~[1-])");
2150:                   rz_core_cmd0(core, "s $(afb~...)");
2154:                   rz_core_cmd0(core, "s $(ii~...)");
2157:                   rz_core_cmd0(core, "s $(isq~...)");
2160:                   rz_core_cmd0(core, "s $(dm~...)");
2169:                   rz_core_cmdf(core, "sH~...");
2968:                           rz_core_cmd0(core, key_s);
2976:                           rz_core_cmd0(core, key_s);
3145:                                   rz_core_cmd0(core, "?i highlight;e scr.highlight=`yp`");
3784:                           rz_core_cmd0(core, vi);
3799:           rz_core_cmd0(core, vi);
3841:                   rz_core_cmd0(core, cmd_str);
3954:           int ret = rz_core_cmd0(core, cmd);

librz/core/tui/visual.c
1426:                                   char *res = rz_core_cmd_strf(core, "pd 4 @ 0x%08" PFMT64x "@e:asm.flags.limit=1", xaddr2);
1428:                                   // dis = rz_core_cmd_strf (core, "pd $r-4 @ 0x%08"PFMT64x, xaddr);
1433:                                           dis = rz_core_cmd_strf(core, "pd $r-4 @ 0x%08" PFMT64x, xaddr1);
1436:                                           dis = rz_core_cmd_strf(core, "pd @ 0x%08" PFMT64x "-32", xaddr1);
1439:                                           dis = rz_core_cmd_strf(core, "px @ 0x%08" PFMT64x, xaddr1);
1442:                                           dis = rz_core_cmd_strf(core, "pds @ 0x%08" PFMT64x, xaddr1);
@officialcjunior
Copy link
Member

rz_core_cmd0(core, "pg");

For the above command, if this is what's getting executed, I can get an API just for that, I suppose. Same calls are in agraph as well.

@ret2libc
Copy link
Member

I think this can probably be moved to a later release. It's just refactoring and we seem to have already a lot of things in our hands.

@ret2libc ret2libc modified the milestones: 0.3.0, 1.0.0 Jun 29, 2021
@ret2libc ret2libc added the cmd-api Switch from cmd calls to API label Sep 3, 2021
@XVilka XVilka added the API label Sep 23, 2021
@XVilka XVilka changed the title Refactor Visual mode (librz/core/visual.c) to use API instead of commands Refactor Visual mode (librz/core/tui/visual.c) to use API instead of commands Oct 18, 2021
@stale
Copy link

stale bot commented Apr 22, 2022

This issue has been automatically marked as stale because it has not had recent activity. Considering a lot has probably changed since its creation, we kindly ask you to check again if the issue you reported is still relevant in the current version of rizin. If it is, update this issue with a comment, otherwise it will be automatically closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 22, 2022
@XVilka XVilka removed the stale label Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API cmd-api Switch from cmd calls to API help wanted Extra attention is needed refactor Refactoring requests visual
Development

No branches or pull requests

3 participants