From 508127e243122cf3ed67d2aaa472a1b4f1be055e Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 7 Jan 2016 16:55:28 +0300 Subject: log: do not unnecessarily include qom/cpu.h Split the bits that require it to exec/log.h. Signed-off-by: Paolo Bonzini Signed-off-by: Denis V. Lunev Acked-by: Christian Borntraeger Message-id: 1452174932-28657-8-git-send-email-den@openvz.org Signed-off-by: Stefan Hajnoczi --- include/qemu/log.h | 59 ------------------------------------------------------ 1 file changed, 59 deletions(-) (limited to 'include/qemu/log.h') diff --git a/include/qemu/log.h b/include/qemu/log.h index d837d90e77..09722e3c6c 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -5,10 +5,6 @@ #include #include #include "qemu/compiler.h" -#include "qom/cpu.h" -#ifdef NEED_CPU_H -#include "disas/disas.h" -#endif /* Private global variables, don't use */ extern FILE *qemu_logfile; @@ -78,61 +74,6 @@ qemu_log_vprintf(const char *fmt, va_list va) void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...); -/* Special cases: */ - -/* cpu_dump_state() logging functions: */ -/** - * log_cpu_state: - * @cpu: The CPU whose state is to be logged. - * @flags: Flags what to log. - * - * Logs the output of cpu_dump_state(). - */ -static inline void log_cpu_state(CPUState *cpu, int flags) -{ - if (qemu_log_enabled()) { - cpu_dump_state(cpu, qemu_logfile, fprintf, flags); - } -} - -/** - * log_cpu_state_mask: - * @mask: Mask when to log. - * @cpu: The CPU whose state is to be logged. - * @flags: Flags what to log. - * - * Logs the output of cpu_dump_state() if loglevel includes @mask. - */ -static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) -{ - if (qemu_loglevel & mask) { - log_cpu_state(cpu, flags); - } -} - -#ifdef NEED_CPU_H -/* disas() and target_disas() to qemu_logfile: */ -static inline void log_target_disas(CPUState *cpu, target_ulong start, - target_ulong len, int flags) -{ - target_disas(qemu_logfile, cpu, start, len, flags); -} - -static inline void log_disas(void *code, unsigned long size) -{ - disas(qemu_logfile, code, size); -} - -#if defined(CONFIG_USER_ONLY) -/* page_dump() output to the log file: */ -static inline void log_page_dump(void) -{ - page_dump(qemu_logfile); -} -#endif -#endif - - /* Maintenance: */ /* fflush() the log file */ -- cgit v1.2.3-55-g7522 From ed7f5f1d8db06fc31352a5ef4f54985e630c575a Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 7 Jan 2016 16:55:30 +0300 Subject: trace: convert stderr backend to log [Also update .travis.yml --enable-trace-backends=stderr --Stefan] Signed-off-by: Paolo Bonzini Signed-off-by: Denis V. Lunev Acked-by: Christian Borntraeger Message-id: 1452174932-28657-10-git-send-email-den@openvz.org Signed-off-by: Stefan Hajnoczi --- .travis.yml | 2 +- configure | 4 ++-- include/qemu/log.h | 1 + scripts/tracetool/backend/log.py | 48 +++++++++++++++++++++++++++++++++++++ scripts/tracetool/backend/stderr.py | 47 ------------------------------------ trace/control.c | 10 ++++++++ util/log.c | 3 +++ vl.c | 2 ++ 8 files changed, 67 insertions(+), 50 deletions(-) create mode 100644 scripts/tracetool/backend/log.py delete mode 100644 scripts/tracetool/backend/stderr.py (limited to 'include/qemu/log.h') diff --git a/.travis.yml b/.travis.yml index 6ca0260941..0428aed0ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -78,7 +78,7 @@ matrix: compiler: gcc # All the trace backends (apart from dtrace) - env: TARGETS=i386-softmmu,x86_64-softmmu - EXTRA_CONFIG="--enable-trace-backends=stderr" + EXTRA_CONFIG="--enable-trace-backends=log" compiler: gcc - env: TARGETS=i386-softmmu,x86_64-softmmu EXTRA_CONFIG="--enable-trace-backends=simple" diff --git a/configure b/configure index 297bfc7997..92c2616287 100755 --- a/configure +++ b/configure @@ -5445,8 +5445,8 @@ if have_backend "simple"; then # Set the appropriate trace file. trace_file="\"$trace_file-\" FMT_pid" fi -if have_backend "stderr"; then - echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak +if have_backend "log"; then + echo "CONFIG_TRACE_LOG=y" >> $config_host_mak fi if have_backend "ust"; then echo "CONFIG_TRACE_UST=y" >> $config_host_mak diff --git a/include/qemu/log.h b/include/qemu/log.h index 09722e3c6c..30817f7b42 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -45,6 +45,7 @@ static inline bool qemu_log_separate(void) #define CPU_LOG_MMU (1 << 12) #define CPU_LOG_TB_NOCHAIN (1 << 13) #define CPU_LOG_PAGE (1 << 14) +#define LOG_TRACE (1 << 15) /* Returns true if a bit is set in the current loglevel mask */ diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py new file mode 100644 index 0000000000..a62c310705 --- /dev/null +++ b/scripts/tracetool/backend/log.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Stderr built-in backend. +""" + +__author__ = "Lluís Vilanova " +__copyright__ = "Copyright 2012-2014, Lluís Vilanova " +__license__ = "GPL version 2 or (at your option) any later version" + +__maintainer__ = "Stefan Hajnoczi" +__email__ = "stefanha@linux.vnet.ibm.com" + + +from tracetool import out + + +PUBLIC = True + + +def generate_h_begin(events): + out('#include ', + '#include ', + '#include ', + '#include ', + '#include "trace/control.h"', + '#include "qemu/log.h"', + '') + + +def generate_h(event): + argnames = ", ".join(event.args.names()) + if len(event.args) > 0: + argnames = ", " + argnames + + out(' if (trace_event_get_state(%(event_id)s)) {', + ' struct timeval _now;', + ' gettimeofday(&_now, NULL);', + ' qemu_log_mask(LOG_TRACE, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",', + ' getpid(),', + ' (size_t)_now.tv_sec, (size_t)_now.tv_usec', + ' %(argnames)s);', + ' }', + event_id="TRACE_" + event.name.upper(), + name=event.name, + fmt=event.fmt.rstrip("\n"), + argnames=argnames) diff --git a/scripts/tracetool/backend/stderr.py b/scripts/tracetool/backend/stderr.py deleted file mode 100644 index ca58054621..0000000000 --- a/scripts/tracetool/backend/stderr.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -""" -Stderr built-in backend. -""" - -__author__ = "Lluís Vilanova " -__copyright__ = "Copyright 2012-2014, Lluís Vilanova " -__license__ = "GPL version 2 or (at your option) any later version" - -__maintainer__ = "Stefan Hajnoczi" -__email__ = "stefanha@linux.vnet.ibm.com" - - -from tracetool import out - - -PUBLIC = True - - -def generate_h_begin(events): - out('#include ', - '#include ', - '#include ', - '#include ', - '#include "trace/control.h"', - '') - - -def generate_h(event): - argnames = ", ".join(event.args.names()) - if len(event.args) > 0: - argnames = ", " + argnames - - out(' if (trace_event_get_state(%(event_id)s)) {', - ' struct timeval _now;', - ' gettimeofday(&_now, NULL);', - ' fprintf(stderr, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",', - ' getpid(),', - ' (size_t)_now.tv_sec, (size_t)_now.tv_usec', - ' %(argnames)s);', - ' }', - event_id="TRACE_" + event.name.upper(), - name=event.name, - fmt=event.fmt.rstrip("\n"), - argnames=argnames) diff --git a/trace/control.c b/trace/control.c index bef7884ee1..84ea840892 100644 --- a/trace/control.c +++ b/trace/control.c @@ -14,6 +14,9 @@ #ifdef CONFIG_TRACE_FTRACE #include "trace/ftrace.h" #endif +#ifdef CONFIG_TRACE_LOG +#include "qemu/log.h" +#endif #include "qemu/error-report.h" int trace_events_enabled_count; @@ -174,6 +177,13 @@ void trace_init_file(const char *file) { #ifdef CONFIG_TRACE_SIMPLE st_set_trace_file(file); +#elif defined CONFIG_TRACE_LOG + /* If both the simple and the log backends are enabled, "-trace file" + * only applies to the simple backend; use "-D" for the log backend. + */ + if (file) { + qemu_set_log_filename(file); + } #else if (file) { fprintf(stderr, "error: -trace file=...: " diff --git a/util/log.c b/util/log.c index 901b93087d..37185a5e77 100644 --- a/util/log.c +++ b/util/log.c @@ -51,6 +51,9 @@ void qemu_log_mask(int mask, const char *fmt, ...) void do_qemu_set_log(int log_flags, bool use_own_buffers) { qemu_loglevel = log_flags; +#ifdef CONFIG_TRACE_LOG + qemu_loglevel |= LOG_TRACE; +#endif if (qemu_loglevel && !qemu_logfile) { if (logfilename) { qemu_logfile = fopen(logfilename, log_append ? "a" : "w"); diff --git a/vl.c b/vl.c index 58cc0507fe..a7d7c39c34 100644 --- a/vl.c +++ b/vl.c @@ -4115,6 +4115,8 @@ int main(int argc, char **argv, char **envp) exit(1); } qemu_set_log(mask); + } else { + qemu_set_log(0); } if (!trace_init_backends()) { -- cgit v1.2.3-55-g7522