All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 12/17] qom/cpu: Simplify how CPUClass::dump_statistics() prints
Date: Fri, 12 Apr 2019 18:50:56 +0100	[thread overview]
Message-ID: <20190412175055.GO2906@work-vm> (raw)
In-Reply-To: <20190411152520.10061-13-armbru@redhat.com>

* Markus Armbruster (armbru@redhat.com) wrote:
> CPUClass method dump_statistics() takes an fprintf()-like callback and
> a FILE * to pass to it.
> 
> Its only caller hmp_info_cpustats() (via cpu_dump_statistics()) passes
> monitor_fprintf() and the current monitor cast to FILE *.
> monitor_fprintf() casts it right back, and is otherwise identical to
> monitor_printf().  The type-punning is ugly.
> 
> Drop the callback, and call qemu_printf() instead.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  include/qom/cpu.h      | 11 ++++-------
>  monitor.c              |  2 +-
>  qom/cpu.c              |  5 ++---
>  target/ppc/cpu.h       |  3 +--
>  target/ppc/translate.c |  9 ++++-----
>  5 files changed, 12 insertions(+), 18 deletions(-)
> 
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index 1d6099e5d4..31bafee2b1 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -184,8 +184,7 @@ typedef struct CPUClass {
>      void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
>                         int flags);
>      GuestPanicInformation* (*get_crash_info)(CPUState *cpu);
> -    void (*dump_statistics)(CPUState *cpu, FILE *f,
> -                            fprintf_function cpu_fprintf, int flags);
> +    void (*dump_statistics)(CPUState *cpu, int flags);
>      int64_t (*get_arch_id)(CPUState *cpu);
>      bool (*get_paging_enabled)(const CPUState *cpu);
>      void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list,
> @@ -576,14 +575,12 @@ void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
>  /**
>   * cpu_dump_statistics:
>   * @cpu: The CPU whose state is to be dumped.
> - * @f: File to dump to.
> - * @cpu_fprintf: Function to dump with.
>   * @flags: Flags what to dump.
>   *
> - * Dumps CPU statistics.
> + * Dump CPU statistics to the current monitor if we have one, else to
> + * stdout.
>   */
> -void cpu_dump_statistics(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
> -                         int flags);
> +void cpu_dump_statistics(CPUState *cpu, int flags);
>  
>  #ifndef CONFIG_USER_ONLY
>  /**
> diff --git a/monitor.c b/monitor.c
> index 0819b99ef7..fb5b681099 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1364,7 +1364,7 @@ static void hmp_info_cpustats(Monitor *mon, const QDict *qdict)
>          monitor_printf(mon, "No CPU available\n");
>          return;
>      }
> -    cpu_dump_statistics(cs, (FILE *)mon, &monitor_fprintf, 0);
> +    cpu_dump_statistics(cs, 0);
>  }
>  
>  static void hmp_info_trace_events(Monitor *mon, const QDict *qdict)
> diff --git a/qom/cpu.c b/qom/cpu.c
> index a8d2958956..029e7fe9b0 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -230,13 +230,12 @@ void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
>      }
>  }
>  
> -void cpu_dump_statistics(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
> -                         int flags)
> +void cpu_dump_statistics(CPUState *cpu, int flags)
>  {
>      CPUClass *cc = CPU_GET_CLASS(cpu);
>  
>      if (cc->dump_statistics) {
> -        cc->dump_statistics(cpu, f, cpu_fprintf, flags);
> +        cc->dump_statistics(cpu, flags);
>      }
>  }
>  
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index 8572241364..27a36b9605 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1270,8 +1270,7 @@ void ppc_cpu_do_interrupt(CPUState *cpu);
>  bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req);
>  void ppc_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
>                          int flags);
> -void ppc_cpu_dump_statistics(CPUState *cpu, FILE *f,
> -                             fprintf_function cpu_fprintf, int flags);
> +void ppc_cpu_dump_statistics(CPUState *cpu, int flags);
>  hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  int ppc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
>  int ppc_cpu_gdb_read_register_apple(CPUState *cpu, uint8_t *buf, int reg);
> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> index badc1ae1a3..f99f27a134 100644
> --- a/target/ppc/translate.c
> +++ b/target/ppc/translate.c
> @@ -7593,8 +7593,7 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
>  #undef RFPL
>  }
>  
> -void ppc_cpu_dump_statistics(CPUState *cs, FILE*f,
> -                             fprintf_function cpu_fprintf, int flags)
> +void ppc_cpu_dump_statistics(CPUState *cs, int flags)
>  {
>  #if defined(DO_PPC_STATISTICS)
>      PowerPCCPU *cpu = POWERPC_CPU(cs);
> @@ -7614,7 +7613,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f,
>                          handler = t3[op3];
>                          if (handler->count == 0)
>                              continue;
> -                        cpu_fprintf(f, "%02x %02x %02x (%02x %04d) %16s: "
> +                        qemu_printf("%02x %02x %02x (%02x %04d) %16s: "
>                                      "%016" PRIx64 " %" PRId64 "\n",
>                                      op1, op2, op3, op1, (op3 << 5) | op2,
>                                      handler->oname,
> @@ -7623,7 +7622,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f,
>                  } else {
>                      if (handler->count == 0)
>                          continue;
> -                    cpu_fprintf(f, "%02x %02x    (%02x %04d) %16s: "
> +                    qemu_printf("%02x %02x    (%02x %04d) %16s: "
>                                  "%016" PRIx64 " %" PRId64 "\n",
>                                  op1, op2, op1, op2, handler->oname,
>                                  handler->count, handler->count);
> @@ -7632,7 +7631,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f,
>          } else {
>              if (handler->count == 0)
>                  continue;
> -            cpu_fprintf(f, "%02x       (%02x     ) %16s: %016" PRIx64
> +            qemu_printf("%02x       (%02x     ) %16s: %016" PRIx64
>                          " %" PRId64 "\n",
>                          op1, op1, handler->oname,
>                          handler->count, handler->count);
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2019-04-12 17:51 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 15:25 [Qemu-devel] [PATCH 00/17] Clean up and simplify around fprintf_function Markus Armbruster
2019-04-11 15:25 ` [Qemu-devel] [PATCH 01/17] include: Include fprintf-fn.h only where needed Markus Armbruster
2019-04-12 16:53   ` Dr. David Alan Gilbert
2019-04-11 15:25 ` [Qemu-devel] [PATCH 02/17] trace: Simplify how st_print_trace_file_status() prints Markus Armbruster
2019-04-12 16:55   ` Dr. David Alan Gilbert
2019-04-11 15:25 ` [Qemu-devel] [PATCH 03/17] tcg: Simplify how dump_opcount_info() prints Markus Armbruster
2019-04-12 16:58   ` Dr. David Alan Gilbert
2019-04-11 15:25 ` [Qemu-devel] [PATCH 04/17] tcg: Simplify how dump_exec_info() prints Markus Armbruster
2019-04-12 17:09   ` Dr. David Alan Gilbert
2019-04-11 15:25 ` [Qemu-devel] [PATCH 05/17] tcg: Simplify how dump_drift_info() prints Markus Armbruster
2019-04-12 17:18   ` Dr. David Alan Gilbert
2019-04-11 15:25 ` [Qemu-devel] [PATCH 06/17] qsp: Simplify how qsp_report() prints Markus Armbruster
2019-04-12 17:25   ` Dr. David Alan Gilbert
2019-04-11 15:25 ` [Qemu-devel] [PATCH 07/17] block/qapi: Clean up how we print to monitor or stdout Markus Armbruster
2019-04-12 17:59   ` Dr. David Alan Gilbert
2019-04-11 15:25 ` [Qemu-devel] [PATCH 08/17] memory: Clean up how mtree_info() prints Markus Armbruster
2019-04-12 17:44   ` Dr. David Alan Gilbert
2019-04-12 18:25     ` Markus Armbruster
2019-04-11 15:25 ` [Qemu-devel] [PATCH 09/17] target: Simplify how the TARGET_cpu_list() print Markus Armbruster
2019-04-15 15:43   ` Dr. David Alan Gilbert
2019-04-16  6:14     ` Markus Armbruster
2019-04-16  8:20       ` Dr. David Alan Gilbert
2019-04-11 15:25 ` [Qemu-devel] [PATCH 10/17] target: Clean up how the dump_mmu() print Markus Armbruster
2019-04-15 15:53   ` Dr. David Alan Gilbert
2019-04-16  6:23     ` Markus Armbruster
2019-04-16  6:23       ` Markus Armbruster
2019-04-11 15:25 ` [Qemu-devel] [PATCH 11/17] target/i386: Simplify how x86_cpu_dump_local_apic_state() prints Markus Armbruster
2019-04-12 17:49   ` Dr. David Alan Gilbert
2019-04-11 15:25 ` [Qemu-devel] [PATCH 12/17] qom/cpu: Simplify how CPUClass::dump_statistics() prints Markus Armbruster
2019-04-12 17:50   ` Dr. David Alan Gilbert [this message]
2019-04-11 15:25 ` [Qemu-devel] [PATCH 13/17] qemu-print: New qemu_fprintf(), qemu_vfprintf() Markus Armbruster
2019-04-12 17:53   ` Dr. David Alan Gilbert
2019-04-11 15:25 ` [Qemu-devel] [PATCH 14/17] qom/cpu: Simplify how CPUClass:cpu_dump_state() prints Markus Armbruster
2019-04-15 16:47   ` Dr. David Alan Gilbert
2019-04-16  6:32     ` Markus Armbruster
2019-04-11 15:25 ` [Qemu-devel] [PATCH 15/17] monitor: Clean up how monitor_disas() funnels output to monitor Markus Armbruster
2019-04-12 18:01   ` Dr. David Alan Gilbert
2019-04-11 15:25 ` [Qemu-devel] [PATCH 16/17] disas: Rename include/disas/bfd.h back to include/disas/dis-asm.h Markus Armbruster
2019-04-11 15:25   ` Markus Armbruster
2019-04-11 15:25 ` [Qemu-devel] [PATCH 17/17] include: Move fprintf_function to disas/ Markus Armbruster
2019-04-12 18:39   ` Dr. David Alan Gilbert
2019-04-13  4:59     ` Markus Armbruster
2019-04-11 15:49 ` [Qemu-devel] [PATCH 00/17] Clean up and simplify around fprintf_function no-reply

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=20190412175055.GO2906@work-vm \
    --to=dgilbert@redhat.com \
    --cc=armbru@redhat.com \
    --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 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.