]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
objtool: Compact output for alternatives with one instruction
authorAlexandre Chartre <alexandre.chartre@oracle.com>
Fri, 21 Nov 2025 09:53:38 +0000 (10:53 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 24 Nov 2025 19:40:48 +0000 (20:40 +0100)
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
tools/objtool/disas.c

index 731c4495b53c7ae87923570c077be47f4e8cd8f3..a4f905eac4e639ed51e847fe4da6835a1005fbde 100644 (file)
@@ -863,6 +863,7 @@ static void disas_alt_print_compact(char *alt_name, struct disas_alt *dalts,
                                    int alt_count, int insn_count)
 {
        struct instruction *orig_insn;
+       int width;
        int i, j;
        int len;
 
@@ -871,6 +872,27 @@ static void disas_alt_print_compact(char *alt_name, struct disas_alt *dalts,
        len = disas_print(stdout, orig_insn->sec, orig_insn->offset, 0, NULL);
        printf("%s\n", alt_name);
 
+       /*
+        * If all alternatives have a single instruction then print each
+        * alternative on a single line. Otherwise, print alternatives
+        * one above the other with a clear separation.
+        */
+
+       if (insn_count == 1) {
+               width = 0;
+               for (i = 0; i < alt_count; i++) {
+                       if (dalts[i].width > width)
+                               width = dalts[i].width;
+               }
+
+               for (i = 0; i < alt_count; i++) {
+                       printf("%*s= %-*s    (if %s)\n", len, "", width,
+                              dalts[i].insn[0].str, dalts[i].name);
+               }
+
+               return;
+       }
+
        for (i = 0; i < alt_count; i++) {
                printf("%*s= %s\n", len, "", dalts[i].name);
                for (j = 0; j < insn_count; j++) {