From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 04/10] disas: Support the Capstone disassembler library
Date: Fri, 15 Sep 2017 09:58:19 -0700 [thread overview]
Message-ID: <2db5e483-771c-db9e-2e5c-39ddd8cee811@linaro.org> (raw)
In-Reply-To: <3897b0b2-8da9-8921-1380-57380e6f0879@amsat.org>
On 09/14/2017 09:46 PM, Philippe Mathieu-Daudé wrote:
>> +static bool cap_disas(disassemble_info *info, uint64_t pc, size_t size)
>
> I'd rather use:
>
> ..,, target_ulong code, ...
>> +{
>
> uint64_t pc = (uint64_t)code;
Why?
>
>> + bool ret = false;
>
> Isn't it cleaner to have a stubs/disas_capstone.c?
>
>> +#ifdef CONFIG_CAPSTONE
If this one function warranted a separate file of its own, maybe, but certainly
not without that.
>> + cap_mode += (info->endian == BFD_ENDIAN_BIG ? CS_MODE_BIG_ENDIAN
>> + : CS_MODE_LITTLE_ENDIAN);
>> +
>
> assert(size); ?
The existing disassembler doesn't have it. So, no?
> err = cs_open(info->cap_arch, cap_mode, &handle);
> if (err != CS_ERR_OK) {
> (*info->fprintf_func)(info->stream, "Capstone: %s\n",
> cs_strerror(err));
No. Or not without extra limits. We don't want 100k instances of this error
as we dump all of the hunks for "-d in_asm".
We'd be assuming the distro didn't do anything silly wrt compiling with "diet"
mode or with only the host cpu enabled. I really don't know what to do about
such an eventuality except continue to fall back to the binutils code.
>> + cbuf = buf = g_malloc(size);
>
> if (buf == NULL) {
> goto err2;
> }
g_malloc cannot fail.
>
> cs_free(insn, 1);
> err2:
>
>> + g_free(buf);
>> + err1:
Oops, yes.
>> +
>> + if (s.info.cap_arch >= 0 && cap_disas(&s.info, (uintptr_t)code, size)) {
>
> (target_ulong)(uintptr_t)code, ?
Why? Even if I did change the type of the argument?
The extra cast would be implied by the language.
>> + /* ??? Capstone requires that we copy the data into a host-addressable
>> + buffer first and has no call-back to read more. Therefore we need
>> + an estimate of buffer size. This will work for most RISC, but we'll
>> + need to figure out something else for variable-length ISAs. */
>> + if (s.info.cap_arch >= 0 && cap_disas(&s.info, pc, 4 * nb_insn)) {
>
> .., MIN(16 * nb_insn, TARGET_PAGE_SIZE))) ?
That's no better than what I have; it simply prints more. I need a *real*
solution. It will probably involve not re-using cap_disas but writing code
just for the monitor.
r~
next prev parent reply other threads:[~2017-09-15 16:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-14 18:35 [Qemu-devel] [PATCH 00/10] Support the Capstone disassembler Richard Henderson
2017-09-14 18:35 ` [Qemu-devel] [PATCH 01/10] target/i386: Convert to disas_set_info hook Richard Henderson
2017-09-18 11:47 ` Alex Bennée
2017-09-14 18:35 ` [Qemu-devel] [PATCH 02/10] target/ppc: " Richard Henderson
2017-09-18 11:58 ` Alex Bennée
2017-09-14 18:35 ` [Qemu-devel] [PATCH 03/10] disas: Remove unused flags arguments Richard Henderson
2017-09-18 11:59 ` Alex Bennée
2017-09-14 18:35 ` [Qemu-devel] [PATCH 04/10] disas: Support the Capstone disassembler library Richard Henderson
2017-09-15 4:46 ` Philippe Mathieu-Daudé
2017-09-15 16:58 ` Richard Henderson [this message]
2017-09-16 18:32 ` Peter Maydell
2017-09-16 18:52 ` Peter Maydell
2017-09-14 18:35 ` [Qemu-devel] [PATCH 05/10] target/i386: Support Capstone in disas_set_info Richard Henderson
2017-09-14 18:35 ` [Qemu-devel] [PATCH 06/10] target/arm: " Richard Henderson
2017-09-14 18:35 ` [Qemu-devel] [PATCH 07/10] target/ppc: " Richard Henderson
2017-09-14 18:35 ` [Qemu-devel] [PATCH 08/10] target/s390x: " Richard Henderson
2017-09-14 18:35 ` [Qemu-devel] [PATCH 09/10] target/sparc: " Richard Henderson
2017-09-14 18:35 ` [Qemu-devel] [PATCH 10/10] target/mips: " Richard Henderson
2017-09-15 2:47 ` Philippe Mathieu-Daudé
2017-09-15 4:53 ` [Qemu-devel] [PATCH 00/10] Support the Capstone disassembler Philippe Mathieu-Daudé
2017-09-19 16:13 ` Richard Henderson
2017-09-19 17:30 ` Philippe Mathieu-Daudé
2017-09-19 18:36 ` 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=2db5e483-771c-db9e-2e5c-39ddd8cee811@linaro.org \
--to=richard.henderson@linaro.org \
--cc=f4bug@amsat.org \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).