mbox series

[v2,0/4] Enable plugin support on msys2/mingw

Message ID 20200927081901.771-1-luoyonggang@gmail.com
Headers show
Series Enable plugin support on msys2/mingw | expand

Message

罗勇刚(Yonggang Luo) Sept. 27, 2020, 8:18 a.m. UTC
V1-V2
1. Fixes review comments
2. Increase QEMU_PLUGIN_VERSION to 1 for compat  QEMU_PLUGIN_VERSION 0
3. Revise the loader to support for version 0 and 1
4. By export function qemu_plugin_initialize in plugin, and call it in loader=
, so
  we have no need call it in every plugin. And also provide a standard implem=
entation,
  anyway, use can also override it.

Add this feature on msys2/mingw by using glib provided cross-platform dlsym f=
unctional.

Yonggang Luo (4):
  plugins: Fixes a issue when dlsym failed, the handle not closed
  plugin: Fixes compiling errors on msys2/mingw
  cirrus: Enable plugin in cirrus for windows
  Getting qemu-plugin works under win32.

 .cirrus.yml                  |   3 +-
 Makefile                     |   1 -
 configure                    |  71 -------------
 contrib/plugins/hotblocks.c  |   3 +-
 contrib/plugins/hotpages.c   |   1 +
 contrib/plugins/howvec.c     |   1 +
 contrib/plugins/lockstep.c   |   1 +
 include/qemu/qemu-plugin.h   | 197 +++++++++++++++++++++++++++--------
 meson.build                  |   6 +-
 plugins/api.c                |  65 ++++++------
 plugins/core.c               |   7 +-
 plugins/loader.c             |  51 ++++++++-
 plugins/meson.build          |  10 +-
 plugins/plugin.h             |   1 +
 plugins/qemu-plugins.symbols |  40 -------
 tests/plugin/bb.c            |   5 +-
 tests/plugin/empty.c         |   1 +
 tests/plugin/insn.c          |   1 +
 tests/plugin/mem.c           |   1 +
 19 files changed, 258 insertions(+), 208 deletions(-)
 delete mode 100644 plugins/qemu-plugins.symbols

--=20
2.28.0.windows.1

Comments

Philippe Mathieu-Daudé Sept. 27, 2020, 8:45 a.m. UTC | #1
On 9/27/20 10:18 AM, Yonggang Luo wrote:
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  contrib/plugins/hotblocks.c | 2 +-
>  tests/plugin/bb.c           | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c
> index 3942a2ca54..37435a3fc7 100644
> --- a/contrib/plugins/hotblocks.c
> +++ b/contrib/plugins/hotblocks.c
> @@ -102,7 +102,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
>  {
>      ExecCount *cnt;
>      uint64_t pc = qemu_plugin_tb_vaddr(tb);
> -    unsigned long insns = qemu_plugin_tb_n_insns(tb);
> +    size_t insns = qemu_plugin_tb_n_insns(tb);
>      uint64_t hash = pc ^ insns;
>  
>      g_mutex_lock(&lock);
> diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c
> index e4cc7fdd6e..de09bdde4e 100644
> --- a/tests/plugin/bb.c
> +++ b/tests/plugin/bb.c
> @@ -72,7 +72,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata)
>      CPUCount *count = max_cpus ?
>          g_ptr_array_index(counts, cpu_index) : &inline_count;
>  
> -    unsigned long n_insns = (unsigned long)udata;
> +    uintptr_t n_insns = (uintptr_t)udata;

Shouldn't this be:

       uint64_t n_insns = (uint64_t)(uintptr_t)udata;

?

>      g_mutex_lock(&count->lock);
>      count->insn_count += n_insns;
>      count->bb_count++;
> @@ -81,7 +81,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata)
>  
>  static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
>  {
> -    unsigned long n_insns = qemu_plugin_tb_n_insns(tb);
> +    size_t n_insns = qemu_plugin_tb_n_insns(tb);
>  
>      if (do_inline) {
>          qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64,
>
罗勇刚(Yonggang Luo) Sept. 27, 2020, 3:40 p.m. UTC | #2
On Sun, Sep 27, 2020 at 4:45 PM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:
>
> On 9/27/20 10:18 AM, Yonggang Luo wrote:
> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> > Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > ---
> >  contrib/plugins/hotblocks.c | 2 +-
> >  tests/plugin/bb.c           | 4 ++--
> >  2 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c
> > index 3942a2ca54..37435a3fc7 100644
> > --- a/contrib/plugins/hotblocks.c
> > +++ b/contrib/plugins/hotblocks.c
> > @@ -102,7 +102,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id,
struct qemu_plugin_tb *tb)
> >  {
> >      ExecCount *cnt;
> >      uint64_t pc = qemu_plugin_tb_vaddr(tb);
> > -    unsigned long insns = qemu_plugin_tb_n_insns(tb);
> > +    size_t insns = qemu_plugin_tb_n_insns(tb);
> >      uint64_t hash = pc ^ insns;
> >
> >      g_mutex_lock(&lock);
> > diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c
> > index e4cc7fdd6e..de09bdde4e 100644
> > --- a/tests/plugin/bb.c
> > +++ b/tests/plugin/bb.c
> > @@ -72,7 +72,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void
*udata)
> >      CPUCount *count = max_cpus ?
> >          g_ptr_array_index(counts, cpu_index) : &inline_count;
> >
> > -    unsigned long n_insns = (unsigned long)udata;
> > +    uintptr_t n_insns = (uintptr_t)udata;
>
> Shouldn't this be:
>
>        uint64_t n_insns = (uint64_t)(uintptr_t)udata;
don't know, may i assmue  uintptr_t  <=  uint64_t , then that's not a prolem
>
> ?
>
> >      g_mutex_lock(&count->lock);
> >      count->insn_count += n_insns;
> >      count->bb_count++;
> > @@ -81,7 +81,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void
*udata)
> >
> >  static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb
*tb)
> >  {
> > -    unsigned long n_insns = qemu_plugin_tb_n_insns(tb);
> > +    size_t n_insns = qemu_plugin_tb_n_insns(tb);
> >
> >      if (do_inline) {
> >          qemu_plugin_register_vcpu_tb_exec_inline(tb,
QEMU_PLUGIN_INLINE_ADD_U64,
> >



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
<div dir="ltr"><br><br>On Sun, Sep 27, 2020 at 4:45 PM Philippe Mathieu-Daudé &lt;<a href="mailto:f4bug@amsat.org">f4bug@amsat.org</a>&gt; wrote:<br>&gt;<br>&gt; On 9/27/20 10:18 AM, Yonggang Luo wrote:<br>&gt; &gt; Signed-off-by: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;<br>&gt; &gt; Reviewed-by: Philippe Mathieu-Daudé &lt;<a href="mailto:f4bug@amsat.org">f4bug@amsat.org</a>&gt;<br>&gt; &gt; ---<br>&gt; &gt;  contrib/plugins/hotblocks.c | 2 +-<br>&gt; &gt;  tests/plugin/bb.c           | 4 ++--<br>&gt; &gt;  2 files changed, 3 insertions(+), 3 deletions(-)<br>&gt; &gt;<br>&gt; &gt; diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c<br>&gt; &gt; index 3942a2ca54..37435a3fc7 100644<br>&gt; &gt; --- a/contrib/plugins/hotblocks.c<br>&gt; &gt; +++ b/contrib/plugins/hotblocks.c<br>&gt; &gt; @@ -102,7 +102,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)<br>&gt; &gt;  {<br>&gt; &gt;      ExecCount *cnt;<br>&gt; &gt;      uint64_t pc = qemu_plugin_tb_vaddr(tb);<br>&gt; &gt; -    unsigned long insns = qemu_plugin_tb_n_insns(tb);<br>&gt; &gt; +    size_t insns = qemu_plugin_tb_n_insns(tb);<br>&gt; &gt;      uint64_t hash = pc ^ insns;<br>&gt; &gt; <br>&gt; &gt;      g_mutex_lock(&amp;lock);<br>&gt; &gt; diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c<br>&gt; &gt; index e4cc7fdd6e..de09bdde4e 100644<br>&gt; &gt; --- a/tests/plugin/bb.c<br>&gt; &gt; +++ b/tests/plugin/bb.c<br>&gt; &gt; @@ -72,7 +72,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata)<br>&gt; &gt;      CPUCount *count = max_cpus ?<br>&gt; &gt;          g_ptr_array_index(counts, cpu_index) : &amp;inline_count;<br>&gt; &gt; <br>&gt; &gt; -    unsigned long n_insns = (unsigned long)udata;<br>&gt; &gt; +    uintptr_t n_insns = (uintptr_t)udata;<br>&gt;<br>&gt; Shouldn&#39;t this be:<br>&gt;<br>&gt;        uint64_t n_insns = (uint64_t)(uintptr_t)udata;<div>don&#39;t know, may i assmue 



uintptr_t  &lt;= 

uint64_t , then that&#39;s not a prolem<br>&gt;<br>&gt; ?<br>&gt;<br>&gt; &gt;      g_mutex_lock(&amp;count-&gt;lock);<br>&gt; &gt;      count-&gt;insn_count += n_insns;<br>&gt; &gt;      count-&gt;bb_count++;<br>&gt; &gt; @@ -81,7 +81,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata)<br>&gt; &gt; <br>&gt; &gt;  static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)<br>&gt; &gt;  {<br>&gt; &gt; -    unsigned long n_insns = qemu_plugin_tb_n_insns(tb);<br>&gt; &gt; +    size_t n_insns = qemu_plugin_tb_n_insns(tb);<br>&gt; &gt; <br>&gt; &gt;      if (do_inline) {<br>&gt; &gt;          qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64,<br>&gt; &gt;<br><br><br><br>--<br>         此致<br>礼<br>罗勇刚<br>Yours<br>    sincerely,<br>Yonggang Luo</div></div>