linux-user: Use `qemu_log' for strace

This change switches linux-user strace logging to use the newer `qemu_log`
logging subsystem rather than the older `gemu_log` (notice the "g")
logger. `qemu_log` has several advantages, namely that it allows logging
to a file, and provides a more unified interface for configuration
of logging (via the QEMU_LOG environment variable or options).

This change introduces a new log mask: `LOG_STRACE` which is used for
logging of user-mode strace messages.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Josh Kunz <jkz@google.com>
Message-Id: <20200204025416.111409-3-jkz@google.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
Josh Kunz 2020-02-03 18:54:14 -08:00 committed by Laurent Vivier
parent 39be535008
commit 4b25a50674
7 changed files with 278 additions and 251 deletions

View file

@ -60,6 +60,19 @@ unsigned long mmap_min_addr;
unsigned long guest_base;
int have_guest_base;
/*
* Used to implement backwards-compatibility for the `-strace`, and
* QEMU_STRACE options. Without this, the QEMU_LOG can be overwritten by
* -strace, or vice versa.
*/
static bool enable_strace;
/*
* The last log mask given by the user in an environment variable or argument.
* Used to support command line arguments overriding environment variables.
*/
static int last_log_mask;
/*
* When running 32-on-64 we should make sure we can fit all of the possible
* guest address space into a contiguous chunk of virtual host memory.
@ -223,15 +236,11 @@ static void handle_arg_help(const char *arg)
static void handle_arg_log(const char *arg)
{
int mask;
mask = qemu_str_to_log_mask(arg);
if (!mask) {
last_log_mask = qemu_str_to_log_mask(arg);
if (!last_log_mask) {
qemu_print_log_usage(stdout);
exit(EXIT_FAILURE);
}
qemu_log_needs_buffers();
qemu_set_log(mask);
}
static void handle_arg_dfilter(const char *arg)
@ -375,7 +384,7 @@ static void handle_arg_singlestep(const char *arg)
static void handle_arg_strace(const char *arg)
{
do_strace = 1;
enable_strace = true;
}
static void handle_arg_version(const char *arg)
@ -629,6 +638,7 @@ int main(int argc, char **argv, char **envp)
int i;
int ret;
int execfd;
int log_mask;
unsigned long max_reserved_va;
error_init(argv[0]);
@ -661,6 +671,12 @@ int main(int argc, char **argv, char **envp)
optind = parse_args(argc, argv);
log_mask = last_log_mask | (enable_strace ? LOG_STRACE : 0);
if (log_mask) {
qemu_log_needs_buffers();
qemu_set_log(log_mask);
}
if (!trace_init_backends()) {
exit(1);
}