gadget: add gadget.bytes_maxlen to truncate /Rt bytes column#6409
gadget: add gadget.bytes_maxlen to truncate /Rt bytes column#6409clmoon2 wants to merge 1 commit into
Conversation
…ggh-6359) The /Rt gadget search table prints the full hex of every gadget in the bytes column, which gets visually unmanageable once gadgets are more than a handful of instructions long. Add gadget.bytes_maxlen (default 0 = no truncation, preserves current behavior). When set to N, the bytes column for each row is capped at N bytes (2*N hex chars) with a trailing ... so the table stays readable even with long gadgets. Only affects table mode (/Rt); JSON, quiet, and standard modes are unchanged.
| // gh-6359: optionally cap the bytes column. The hex string | ||
| // has two characters per byte, so a byte limit of N maps to | ||
| // 2*N hex chars before the truncation marker. |
| SETBPREF("gadget.subchains", "false", "Display every length gadget from gadget.len=X to 2"); | ||
| SETBPREF("gadget.conditional", "false", "Include conditional jump, calls and returns in gadget search"); | ||
| SETBPREF("gadget.comments", "false", "Display comments in gadget search output"); | ||
| SETI("gadget.bytes_maxlen", 0, "Truncate the bytes column in /Rt table output to N bytes (0 = no truncation, append ... when truncated)"); |
There was a problem hiding this comment.
| SETI("gadget.bytes_maxlen", 0, "Truncate the bytes column in /Rt table output to N bytes (0 = no truncation, append ... when truncated)"); | |
| SETI("gadget.bytes_maxlen", 0, "Truncate the bytes column in the gadget output table to N bytes (0 = disabled)"); |
|
It's forbidden to remove the checklist. i have added it back. fill it up |
|
filled in the checklist, sorry for stripping it out. let me know if anything else is needed. |
|
@MrQuantum1915 have a look. |
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 15 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
MrQuantum1915
left a comment
There was a problem hiding this comment.
See one suggestion below
Also I think we should add 1 related test in test/db/cmd/cmd_rop.
otherwise LGTM
| SETBPREF("gadget.subchains", "false", "Display every length gadget from gadget.len=X to 2"); | ||
| SETBPREF("gadget.conditional", "false", "Include conditional jump, calls and returns in gadget search"); | ||
| SETBPREF("gadget.comments", "false", "Display comments in gadget search output"); | ||
| SETI("gadget.bytes_maxlen", 0, "Truncate the bytes column in /Rt table output to N bytes (0 = no truncation, append ... when truncated)"); |
There was a problem hiding this comment.
since this config is restricted to only table mode, it would be better to use something like gadget.table.maxbytes
@wargio WDYT?
Your checklist for this pull request
RZ_APIfunction and struct this PR changes.RZ_API).Closes #6359.
The bytes column in
/Rttable mode shows the full concatenated hex of every instruction in the gadget, which gets visually unmanageable once gadgets are more than a handful of instructions long. The issue asks for a config var to cap that with an ellipsis when it overflows.Added
gadget.bytes_maxlen. Default is0so nothing changes for existing users. When set to N, each row's bytes column is capped at2*Nhex chars and a trailing...is appended.Scoped to
RZ_OUTPUT_MODE_TABLEonly. JSON, quiet, and standard modes need the full bytes for downstream consumption, so left alone.This config option could use a line in the Rizin book; left box 5 unchecked since the book is a separate repo. No test in this PR: the existing /Rt fixture (
bins/elf/varsub) has short gadgets that don't exercise the truncation.