Graph view of a switch statement
I had a lot of fun spending this summer coding for radare. I learned so many things, and had an amazing experience overall. I am very grateful to my mentors, Xvilka, Pancake and Maijin, they were always present and closely followed me during the entire summer.
My task was to improve some aspects of the terminal interface of radare2. Here you can find a more detailed description of the GSoC task. Unfortunately I didn't manage to complete all the subtasks listed in the project idea; However, I also took care of many things that were not included in the original task. There is still a huge amount of work to do: radare2 is still not very much user friendly, but it's definitely getting better with time.
Here's a list of my contributions to the project. All the pull requests mentioned below are already merged into the master
branch.
The commands for drawing graphs in radare2 (all those starting with ag
) had a bit confusing syntax. Even when consulting the help (ag?
), it was not exactly clear what graph a certain command would draw and how. I implemented a new syntax for those commands (ag<graph type><output format>
) and made sure to support every type / format combination. Here's a list of the relevant pull requests:
- Added ag autocompletion + final ag fixes
- Ag argument handling + fix agj @ 0
- Remove agft tiny graph edges on by default
- Added 'agR' and 'agA' global references and data references graphs
- Add import graph (agi) + new ag? help
- Added data graph (aga) + partial support for diff graph (agd) output formats
- Add jpg, svg, pdf.... extensions for 'w' graph output format
- Support for every output format for callgraph (agc and agC)
- Support every output format for the xrefs graph (agx)
- Support all output formats for the refs graph (agr)
- add every output support for agg graph + some agf fixes
- Support every output format for the bb graph (agf)
RConsCanvas
, radare2's own way of drawing complex interfaces in the terminal, had some glitches with UTF-8 characters because it didn't take into account the different byte-length of those special characters. Implementing the support for UTF-8 took quite a lot of time because it meant rewriting many things from scratch and because I had to keep intact the support for ANSI escape codes.
But I'm pretty happy with the result, as now with UTF-8 we can create even more beautiful interfaces:
Here's a screen of the "panels" view with some comments in arabic and braille
List of relevant pull requests:
- Support for fullwidth characters of the CJK charset (Chinese, Japanese, Korean).
- Fixed '-' bug in canvas.c
- Fixes in panels: correct color crop + correct rendering of graph in panels
- Fix color bugs in panels + other coverity issues in panels.c
- Fix panels horizontal scroll glitch + fix some coverity defects
- Fix heap overflow in canvas.c + fix utf8 wrong crop in panels
- UTF-8 support in canvas (panels, graph)
Radare2 already had autocompletion in the visual offset prompt, which worked similarly to bash's autocompletion. My job was to make it more visually appealing by implementing something similar to the autocompletion inside (terminal) vim, where an interactive widget appears under the cursor. Here's the result:
A gif demonstrating the scrolling of the autocompletion widget while in visual offset prompt
List of relevant pull requests:
- Vim-like autocompletion in visual offset prompt
- Fix auto complete in offset seek in visual
- Offset history
Here's a list of pull requests that are not related to the previous major features but were made to address issues that were urgent at that time:
- Fix color ascii escapes in json output, again
- Fix: color ascii escapes in json output
- Fix arrow keys not working in visual refs mode
- Fix last three coverities
- Add "save to file" to agw commands + colorize comments like ";arg1"
- Restyling graph backedges + bring back 't' and 'f' hints
- Separate command history for sdb shell "ks"
- Dotted lines for conditional jumps in graph
- Colorize pxr + use color palette for visual types menu
- Added r_file_globsearch and zfs
**.sig
support - Fix regression in master by adding
Ct
command - Fixed nasty segfault in vasm.c
- Colorize function arguments and variables part 2
- Fix cursor color when scr.color=0
- Colorize function arguments
- Fix grep : after []
- Fix some last coverities
- Fix #10690 + fix delete_dup_edges
- Fix #10719 line graph not correctly
- Compact xrefs
- File completion in V! > open file + file history for up/down arrow keys
- Add shortcuts in mini graph + colorize shortcuts
- Improve jmptbl edges, second try
- Fix gcc8 warnings in str.c and canvas.c
- Show unicode strings in disasm
- Fix flags cut function lines
- Fold switch cases pointing to the same instruction
- Fixed R key not working in custom graph
- Revert to old graph edges positioning (added an option)
- Graph edges improvements
- Add
asm.lines.jmp
and makeasm.lines
config var for all lines - Fix #10165 compact cross references
- Add -L flag to curl to follow redirects in pdb downloader
- Fixed asm.bytes on by default in cursor mode
- Fix #6220 garbage print when clicking on graph
- Fix #9608
- Fix "simple edges" graph