All of lore.kernel.org
 help / color / mirror / Atom feed
From: Claudio Fontana <claudio.fontana@huawei.com>
To: Peter Crosthwaite <crosthwaitepeter@gmail.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, claudio.fontana@gmail.com,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	agraf@suse.de, edgari@xilinx.com, edgar.iglesias@gmail.com,
	rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH 5/7] disas: arm-a64: Make printfer and stream variable
Date: Tue, 5 May 2015 16:41:01 +0200	[thread overview]
Message-ID: <5548D67D.90603@huawei.com> (raw)
In-Reply-To: <d99c7edf85168916b973679f34e75920d2a6b8d6.1430798763.git.crosthwaite.peter@gmail.com>

On 05.05.2015 06:45, Peter Crosthwaite wrote:
> In a normal disassembly flow, the printf and stream being used varies
> from disas job to job. In particular it varies if mixing monitor_disas
> and target_disas.
> 
> Make both the printfer function and target stream settable in the
> QEMUDisassmbler class. Remove the stream_ initialisation from the
> constructor as it will now runtime vary (and an initial value won't
> mean very much).
> 
> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
> ---
>  disas/arm-a64.cc | 22 +++++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/disas/arm-a64.cc b/disas/arm-a64.cc
> index e04f946..d725e75 100644
> --- a/disas/arm-a64.cc
> +++ b/disas/arm-a64.cc
> @@ -35,16 +35,25 @@ static Disassembler *vixl_disasm = NULL;
>   */
>  class QEMUDisassembler : public Disassembler {
>  public:
> -    explicit QEMUDisassembler(FILE *stream) : stream_(stream) { }
> +    explicit QEMUDisassembler() { }
>      ~QEMUDisassembler() { }
>  
> +    void SetStream(FILE *stream) {
> +        stream_ = stream;
> +    }
> +
> +    void SetPrintf(int (*printf_fn)(FILE *, const char *, ...)) {
> +        printf_ = printf_fn;
> +    }
> +
>  protected:
>      virtual void ProcessOutput(const Instruction *instr) {
> -        fprintf(stream_, "%08" PRIx32 "      %s",
> +        printf_(stream_, "%08" PRIx32 "      %s",
>                  instr->InstructionBits(), GetOutput());
>      }
>  
>  private:
> +    int (*printf_)(FILE *, const char *, ...);
>      FILE *stream_;
>  };
>  
> @@ -53,9 +62,9 @@ static int vixl_is_initialized(void)
>      return vixl_decoder != NULL;
>  }
>  
> -static void vixl_init(FILE *f) {
> +static void vixl_init() {
>      vixl_decoder = new Decoder();
> -    vixl_disasm = new QEMUDisassembler(f);
> +    vixl_disasm = new QEMUDisassembler();
>      vixl_decoder->AppendVisitor(vixl_disasm);
>  }
>  
> @@ -78,9 +87,12 @@ int print_insn_arm_a64(uint64_t addr, disassemble_info *info)
>      }
>  
>      if (!vixl_is_initialized()) {
> -        vixl_init(info->stream);
> +        vixl_init();
>      }
>  
> +    ((QEMUDisassembler *)vixl_disasm)->SetPrintf(info->fprintf_func);
> +    ((QEMUDisassembler *)vixl_disasm)->SetStream(info->stream);
> +
>      instrval = bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24;
>      instr = reinterpret_cast<const Instruction *>(&instrval);
>      vixl_disasm->MapCodeAddress(addr, instr);
> 

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Tested-by: Claudio Fontana <claudio.fontana@huawei.com>

  reply	other threads:[~2015-05-05 14:41 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-05  4:44 [Qemu-devel] [PATCH 0/7] disas: Unify target_disas and monitor_disas Peter Crosthwaite
2015-05-05  4:44 ` [Qemu-devel] [PATCH 1/7] disas: Create factored out fn for monitor and target disas Peter Crosthwaite
2015-05-05 14:45   ` Claudio Fontana
2015-05-05  4:44 ` [Qemu-devel] [PATCH 2/7] disas: microblaze: Migrate setup to common code Peter Crosthwaite
2015-05-05  4:45 ` [Qemu-devel] [PATCH 3/7] disas: cris: Fix 0 buffer length case Peter Crosthwaite
2015-05-05  4:45 ` [Qemu-devel] [PATCH 4/7] disas: cris: Migrate setup to common code Peter Crosthwaite
2015-05-05  4:45 ` [Qemu-devel] [PATCH 5/7] disas: arm-a64: Make printfer and stream variable Peter Crosthwaite
2015-05-05 14:41   ` Claudio Fontana [this message]
2015-05-05 17:22   ` Richard Henderson
2015-05-05  4:45 ` [Qemu-devel] [PATCH 6/7] monitor: "i": Add ARM specifics Peter Crosthwaite
2015-05-05 14:40   ` Claudio Fontana
2015-05-05 17:19   ` Peter Maydell
2015-05-05 17:43     ` Richard Henderson
2015-05-06  6:57       ` Peter Crosthwaite
2015-05-06 13:57         ` Richard Henderson
2015-05-06  7:06       ` Peter Crosthwaite
2015-05-06 14:12         ` Richard Henderson
2015-05-06 14:17           ` Paolo Bonzini
2015-05-06 14:32             ` Stefano Stabellini
2015-05-06 15:44           ` Peter Maydell
2015-05-06 18:24             ` Richard Henderson
2015-05-06 18:39               ` Peter Maydell
2015-05-05  4:45 ` [Qemu-devel] [PATCH 7/7] disas: arm: Use target_disas impl for monitor Peter Crosthwaite
2015-05-05 14:38   ` Claudio Fontana
2015-05-05 16:48     ` Peter Crosthwaite
2015-05-05 17:18 ` [Qemu-devel] [PATCH 0/7] disas: Unify target_disas and monitor_disas Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5548D67D.90603@huawei.com \
    --to=claudio.fontana@huawei.com \
    --cc=agraf@suse.de \
    --cc=claudio.fontana@gmail.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=crosthwaitepeter@gmail.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=edgari@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.