Improve and unify API for describing address
Is your feature request related to a problem? Please describe.
Based on discussion in rizinorg/cutter#3417 and rizinorg/cutter#3416 .
Create an API for printing address in a more human readable format like name+offset. Currently rizin has a bunch of places doing similar thing in slightly different ways, and many of them is tightly integrated into more complex commands directly printing output to terminal, which makes them unsuitable for reuse in other parts of code or Cutter.
Parts of rizin code to consider:
- stuff asm.reloff and all the related flags
- stacktrace printing
- maybe axt (currently prints function and absolute address)
- anything else??
- disasm.c/rz_print_offset_sg https://github.com/rizinorg/rizin/blob/7ee14fb85390a0f38882b223c5a6c5a10944da4a/librz/core/cmd_print.c#L6846
- print.c/print_addr https://github.com/rizinorg/rizin/blob/83a26bd07e12cf14a0e2cb9c7b0d84fa6f5204f5/librz/util/print.c#L379
Describe the solution you'd like
- have an api for describing an address in a similar way as asm.reloff and few other places (it should share the code with at least one of them)
- (optional) currently there are multiple implementations with slightly different behavior. Partially that's inconsistency, partially there are slightly different needs in different contexts. Not sure how much it can be unified (potentially with flags for tweaking behavior) or not.
- The API should be made with assumption that it isn't limited to name+offset, in case of debug symbols it might even include source line info.
- Needs a balance between API configurability (ability to override in specific contexts) and sharing settings for unified behavior.isabling relative offset addresses in disassembly
asm.relloff=falsedoesn't mean they should be disabled everywhere else. On the other stuff likeasm.decoffshould have unified behavior.
Describe alternatives you've considered
Additional context
Also, search hits for some searches could profit from this. E.g. if instructions are searched, it would be nice to not just show the address, but also the function it is part of.
Just generally being able to enrich an address with its meta-info would be so nice to have.
Likely the config options should be ignored and such functions just receive a structure or bitmask with necessary flags to configure output instead.