disas: introduce show_opcodes
authorAlex Bennée <alex.bennee@linaro.org>
Tue, 5 Mar 2024 12:10:02 +0000 (12:10 +0000)
committerAlex Bennée <alex.bennee@linaro.org>
Wed, 6 Mar 2024 12:35:51 +0000 (12:35 +0000)
For plugins we don't expect the raw opcodes in the disassembly. We
already deal with this by hand crafting our capstone call but for
other diassemblers we need a flag. Introduce show_opcodes which
defaults to off.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240305121005.3528075-27-alex.bennee@linaro.org>

disas/disas.c
include/disas/dis-asm.h

index 0d2d06c2ecc87571de36299efe2f948cf2923110..17170d291ec2f9518bf4400b7fafdbee4e141a42 100644 (file)
@@ -299,6 +299,7 @@ void disas(FILE *out, const void *code, size_t size)
     s.info.buffer = code;
     s.info.buffer_vma = (uintptr_t)code;
     s.info.buffer_length = size;
+    s.info.show_opcodes = true;
 
     if (s.info.cap_arch >= 0 && cap_disas_host(&s.info, code, size)) {
         return;
index 2324f6b1a467d6897bb6c729cb1152c2c6eb9248..b26867b64179482e5b08e99a90ff5787d9e0e871 100644 (file)
@@ -396,6 +396,14 @@ typedef struct disassemble_info {
   /* Command line options specific to the target disassembler.  */
   char * disassembler_options;
 
+  /*
+   * When true instruct the disassembler it may preface the
+   * disassembly with the opcodes values if it wants to. This is
+   * mainly for the benefit of the plugin interface which doesn't want
+   * that.
+   */
+  bool show_opcodes;
+
   /* Field intended to be used by targets in any way they deem suitable.  */
   void *target_info;