Skip to content

Commit 07d70b2

Browse files
achartrePeter Zijlstra
authored andcommitted
objtool: Compact output for alternatives with one instruction
When disassembling, if an instruction has alternatives which are all made of a single instruction then print each alternative on a single line (instruction + description) so that the output is more compact. Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Link: https://patch.msgid.link/20251121095340.464045-29-alexandre.chartre@oracle.com
1 parent 56967b9 commit 07d70b2

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tools/objtool/disas.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ static void disas_alt_print_compact(char *alt_name, struct disas_alt *dalts,
863863
int alt_count, int insn_count)
864864
{
865865
struct instruction *orig_insn;
866+
int width;
866867
int i, j;
867868
int len;
868869

@@ -871,6 +872,27 @@ static void disas_alt_print_compact(char *alt_name, struct disas_alt *dalts,
871872
len = disas_print(stdout, orig_insn->sec, orig_insn->offset, 0, NULL);
872873
printf("%s\n", alt_name);
873874

875+
/*
876+
* If all alternatives have a single instruction then print each
877+
* alternative on a single line. Otherwise, print alternatives
878+
* one above the other with a clear separation.
879+
*/
880+
881+
if (insn_count == 1) {
882+
width = 0;
883+
for (i = 0; i < alt_count; i++) {
884+
if (dalts[i].width > width)
885+
width = dalts[i].width;
886+
}
887+
888+
for (i = 0; i < alt_count; i++) {
889+
printf("%*s= %-*s (if %s)\n", len, "", width,
890+
dalts[i].insn[0].str, dalts[i].name);
891+
}
892+
893+
return;
894+
}
895+
874896
for (i = 0; i < alt_count; i++) {
875897
printf("%*s= %s\n", len, "", dalts[i].name);
876898
for (j = 0; j < insn_count; j++) {

0 commit comments

Comments
 (0)