On 12 August 2015 at 12:50, Denis V. Lunev <d...@openvz.org> wrote: > From: Pavel Butsykin <pbutsy...@virtuozzo.com> > > Move target-specific code out of /monitor.c to /target-*/monitor.c, > this will avoid code cluttering and using random ifdeffery. The solution > is quite simple, but solves the issue of the separation of target-specific > code from monitor > > Signed-off-by: Pavel Butsykin <pbutsy...@virtuozzo.com> > Signed-off-by: Denis V. Lunev <d...@openvz.org> > CC: Luiz Capitulino <lcapitul...@redhat.com> > CC: Paolo Bonzini <pbonz...@redhat.com> > CC: Peter Maydell <peter.mayd...@linaro.org> > --- > include/monitor/monitor-common.h | 43 ++ > monitor.c | 854 > +-------------------------------------- > target-i386/Makefile.objs | 2 +- > target-i386/monitor.c | 489 ++++++++++++++++++++++ > target-ppc/Makefile.objs | 2 +- > target-ppc/monitor.c | 250 ++++++++++++ > target-sh4/Makefile.objs | 1 + > target-sh4/monitor.c | 52 +++ > target-sparc/Makefile.objs | 2 +- > target-sparc/monitor.c | 153 +++++++ > target-xtensa/Makefile.objs | 1 + > target-xtensa/monitor.c | 34 ++ > 12 files changed, 1032 insertions(+), 851 deletions(-) > create mode 100644 include/monitor/monitor-common.h > create mode 100644 target-i386/monitor.c > create mode 100644 target-ppc/monitor.c > create mode 100644 target-sh4/monitor.c > create mode 100644 target-sparc/monitor.c > create mode 100644 target-xtensa/monitor.c
> +#if defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_I386) > +extern const MonitorDef monitor_defs[]; > +#else > +const MonitorDef monitor_defs[] = {}; > #endif So, rather than having to have a list of which targets provide a monitor_defs[], I would suggest that we make the API implemented by the target be a function, like: const MonitorDef *target_monitor_defs(void); (which just returns a pointer to a static const array in the target-*/monitor.c file). Then you can add a file stubs/target-monitor-defs.c which provides the "stub" version of this function (just returns a pointer to the no-commands array). The link process will arrange that the stub version is pulled in for any target that doesn't provide its own implementation of the function. Other than that, I suspect we can improve the separation out of target-specific things, but this is a good improvement and it'll be easier to do the rest as incremental fixes on top of this later. thanks -- PMM