rizinorg / rizin

UNIX-like reverse engineering framework and command-line toolset.
https://rizin.re
GNU Lesser General Public License v3.0
2.57k stars 346 forks source link

Refactor asm string building (`disasm.c`) #4238

Open Rot127 opened 5 months ago

Rot127 commented 5 months ago

Is your feature request related to a problem? Please describe.

The asm string building functions are of low quality (performance wise and general code quality). E.g. ds_build_op_str() is 130 LOC, quite deeply nested, manipulate values which don't belong to it (core->parser) and allocates and frees ds->opstr at a minimum 4 times, if a number is replaced with a symbol name.

The whole building of an asm string (be it the colored or black & white version) should be refactored. It shouldn't work, at a minimum, on raw strings but on our asm-tokens. Direct string manipulations are error prone, because the string can be a colored or a b&w string. Making pattern searches more difficult than they need to be.

Describe the solution you'd like

A sensible route to follow could be:

Describe alternatives you've considered

It's pretty much open to discussion.

Additional context

filter.c must probably be refactored in this process (https://github.com/rizinorg/rizin/issues/2766). There seems to be a heavy dependency on it.

LukeTheEngineer commented 3 months ago

I'll take this

XVilka commented 2 months ago

@LukeTheEngineer have you had a chance to look into this?

LukeTheEngineer commented 2 months ago

@LukeTheEngineer have you had a chance to look into this?

Sorry, I've been busy having just graduated high school. In the meantime, I've been studying the code base to understand what does what do I can actually implement something feasible.