unicorn/qemu/util/qemu-error.c
Peter Maydell 56d213f16c
util: Clean up includes
Clean up includes so that osdep.h is included first and headers
which it implies are not included manually.

This commit was created with scripts/clean-includes.

Backports commit aafd758410015e08b1aa8964d739ba8587ce58dc from qemu
2018-02-19 01:27:55 -05:00

81 lines
1.8 KiB
C

/*
* Error reporting
*
* Copyright (C) 2010 Red Hat Inc.
*
* Authors:
* Markus Armbruster <armbru@redhat.com>,
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#include "qemu/osdep.h"
#include <stdarg.h>
#include <string.h>
static const char *progname;
/*
* Set the program name for error_print_loc().
*/
void error_set_progname(const char *argv0)
{
const char *p = strrchr(argv0, '/');
progname = p ? p + 1 : argv0;
}
const char *error_get_progname(void)
{
return progname;
}
/*
* Print current location to current monitor if we have one, else to stderr.
*/
static void error_print_loc(void)
{
}
/*
* Print an error message to current monitor if we have one, else to stderr.
* Format arguments like vsprintf(). The resulting message should be
* a single phrase, with no newline or trailing punctuation.
* Prepend the current location and append a newline.
* It's wrong to call this in a QMP monitor. Use qerror_report() there.
*/
#ifdef _MSC_VER
void error_vreport(const char *fmt, va_list ap)
{
error_print_loc();
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
}
#else
void error_vreport(const char *fmt, va_list ap)
{
GTimeVal tv;
gchar *timestr;
error_print_loc();
error_vprintf(fmt, ap);
error_printf("\n");
}
#endif
/*
* Print an error message to current monitor if we have one, else to stderr.
* Format arguments like sprintf(). The resulting message should be a
* single phrase, with no newline or trailing punctuation.
* Prepend the current location and append a newline.
* It's wrong to call this in a QMP monitor. Use qerror_report() there.
*/
void error_report(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
error_vreport(fmt, ap);
va_end(ap);
}