Use info() for information messages
Prefix err() messages with "ERROR:" too.
This commit is contained in:
parent
76efd7c216
commit
2c09e40c44
13
src/common.c
13
src/common.c
@ -18,11 +18,14 @@ progname_set(char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vaerr(const char *func, const char *errstr, va_list ap)
|
vaerr(const char *prefix, const char *func, const char *errstr, va_list ap)
|
||||||
{
|
{
|
||||||
if (progname != NULL)
|
if (progname != NULL)
|
||||||
fprintf(stderr, "%s: ", progname);
|
fprintf(stderr, "%s: ", progname);
|
||||||
|
|
||||||
|
if (prefix != NULL)
|
||||||
|
fprintf(stderr, "%s: ", prefix);
|
||||||
|
|
||||||
if (func != NULL)
|
if (func != NULL)
|
||||||
fprintf(stderr, "%s: ", func);
|
fprintf(stderr, "%s: ", func);
|
||||||
|
|
||||||
@ -40,20 +43,20 @@ vaerr(const char *func, const char *errstr, va_list ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
verr(const char *func, const char *errstr, ...)
|
verr(const char *prefix, const char *func, const char *errstr, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, errstr);
|
va_start(ap, errstr);
|
||||||
vaerr(func, errstr, ap);
|
vaerr(prefix, func, errstr, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
vdie(const char *func, const char *errstr, ...)
|
vdie(const char *prefix, const char *func, const char *errstr, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, errstr);
|
va_start(ap, errstr);
|
||||||
vaerr(func, errstr, ap);
|
vaerr(prefix, func, errstr, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
16
src/common.h
16
src/common.h
@ -9,21 +9,21 @@
|
|||||||
/* Debug macros */
|
/* Debug macros */
|
||||||
|
|
||||||
void progname_set(char *name);
|
void progname_set(char *name);
|
||||||
void verr(const char *func, const char *errstr, ...);
|
void verr(const char *prefix, const char *func, const char *errstr, ...);
|
||||||
void vdie(const char *func, const char *errstr, ...);
|
void vdie(const char *prefix, const char *func, const char *errstr, ...);
|
||||||
|
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
|
|
||||||
#define rerr(...) fprintf(stderr, __VA_ARGS__)
|
#define rerr(...) fprintf(stderr, __VA_ARGS__)
|
||||||
#define err(...) verr(__func__, __VA_ARGS__)
|
#define err(...) verr("ERROR", __func__, __VA_ARGS__)
|
||||||
#define die(...) vdie(__func__, __VA_ARGS__)
|
#define die(...) vdie("FATAL", __func__, __VA_ARGS__)
|
||||||
#define info(...) verr("INFO", __VA_ARGS__)
|
#define info(...) verr("INFO", NULL, __VA_ARGS__)
|
||||||
#define warn(...) verr("WARN", __VA_ARGS__)
|
#define warn(...) verr("WARN", NULL, __VA_ARGS__)
|
||||||
|
|
||||||
#ifdef ENABLE_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
# define dbg(...) verr(__func__, __VA_ARGS__)
|
# define dbg(...) verr("DEBUG", __func__, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
# define dbg(...) do { if (0) { verr(__func__, __VA_ARGS__); } } while(0)
|
# define dbg(...) do { if (0) { verr("DEBUG", __func__, __VA_ARGS__); } } while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define likely(x) __builtin_expect(!!(x), 1)
|
#define likely(x) __builtin_expect(!!(x), 1)
|
||||||
|
@ -56,14 +56,14 @@ emu_stat_report(struct emu_stat *stat, struct player *player, int last)
|
|||||||
if (last) {
|
if (last) {
|
||||||
int tmin = (int) (time_elapsed / 60.0);
|
int tmin = (int) (time_elapsed / 60.0);
|
||||||
int tsec = (int) ((time_elapsed / 60.0 - tmin) * 60.0);
|
int tsec = (int) ((time_elapsed / 60.0 - tmin) * 60.0);
|
||||||
verr(NULL, "%5.1f%% done at avg %.0f kev/s\n",
|
info("%5.1f%% done at avg %.0f kev/s\n",
|
||||||
progress * 100.0, avgspeed * 1e-3, tmin, tsec);
|
progress * 100.0, avgspeed * 1e-3, tmin, tsec);
|
||||||
verr(NULL, "processed %ld input events in %d min %d s\n",
|
info("processed %ld input events in %d min %d s\n",
|
||||||
nprocessed, tmin, tsec);
|
nprocessed, tmin, tsec);
|
||||||
} else {
|
} else {
|
||||||
int tmin = (int) (time_left / 60.0);
|
int tmin = (int) (time_left / 60.0);
|
||||||
int tsec = (int) ((time_left / 60.0 - tmin) * 60.0);
|
int tsec = (int) ((time_left / 60.0 - tmin) * 60.0);
|
||||||
verr(NULL, "%5.1f%% done at %.0f kev/s (%d min %d s left) \r",
|
info("%5.1f%% done at %.0f kev/s (%d min %d s left) \r",
|
||||||
progress * 100.0, speed * 1e-3, tmin, tsec);
|
progress * 100.0, speed * 1e-3, tmin, tsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,31 +40,39 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
signal(SIGINT, stop_emulation);
|
signal(SIGINT, stop_emulation);
|
||||||
|
|
||||||
err("emulation starts");
|
info("emulation starts");
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int partial = 0;
|
||||||
while (run && (ret = emu_step(emu)) == 0);
|
while (run && (ret = emu_step(emu)) == 0);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
err("emu_step failed");
|
err("emu_step failed");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
/* continue to close the trace files */
|
/* continue to close the trace files */
|
||||||
err("emulation aborts!");
|
info("emulation aborts!");
|
||||||
} else {
|
} else {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (run == 0)
|
if (run == 0) {
|
||||||
err("stopping emulation by user (^C again to abort)");
|
info("stopping emulation by user (^C again to abort)");
|
||||||
|
partial = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (emu_finish(emu) != 0) {
|
if (emu_finish(emu) != 0) {
|
||||||
err("emu_finish failed");
|
err("emu_finish failed");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0) {
|
||||||
err("emulation finished ok");
|
if (partial) {
|
||||||
else
|
info("emulation finished partially but ok");
|
||||||
err("emulation finished with errors");
|
} else {
|
||||||
|
info("emulation finished ok");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info("emulation finished with errors");
|
||||||
|
}
|
||||||
|
|
||||||
free(emu);
|
free(emu);
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ cfg_generate(const char *tracedir)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(dst, &st) == 0) {
|
if (stat(dst, &st) == 0) {
|
||||||
warn("directory '%s' already exists, skipping config copy", dst);
|
warn("directory '%s' already exists, skipping config copy", dst);
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_recursive(src, dst) != 0) {
|
if (copy_recursive(src, dst) != 0) {
|
||||||
|
@ -72,7 +72,7 @@ recorder_advance(struct recorder *rec, int64_t time)
|
|||||||
int
|
int
|
||||||
recorder_finish(struct recorder *rec)
|
recorder_finish(struct recorder *rec)
|
||||||
{
|
{
|
||||||
err("writting the traces to disk, please wait");
|
info("writing traces to disk, please wait");
|
||||||
|
|
||||||
for (struct pvt *pvt = rec->pvt; pvt; pvt = pvt->hh.next) {
|
for (struct pvt *pvt = rec->pvt; pvt; pvt = pvt->hh.next) {
|
||||||
if (pvt_close(pvt) != 0) {
|
if (pvt_close(pvt) != 0) {
|
||||||
@ -84,7 +84,7 @@ recorder_finish(struct recorder *rec)
|
|||||||
/* TODO: Use configs per pvt */
|
/* TODO: Use configs per pvt */
|
||||||
if (cfg_generate(rec->dir) != 0) {
|
if (cfg_generate(rec->dir) != 0) {
|
||||||
err("cfg_generate failed");
|
err("cfg_generate failed");
|
||||||
/* Ignore error */
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -332,6 +332,10 @@ init_end_system(struct system *sys)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info("loaded %ld looms, %ld processes, %ld threads and %ld cpus",
|
||||||
|
sys->nlooms, sys->nprocs, sys->nthreads, sys->nphycpus);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +378,7 @@ load_clock_offsets(struct clkoff *clkoff, struct emu_args *args)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err("loaded clock offset table from '%s' with %d entries",
|
info("loaded clock offset table from '%s' with %d entries",
|
||||||
offset_file, clkoff_count(clkoff));
|
offset_file, clkoff_count(clkoff));
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -30,7 +30,7 @@ load_stream(struct trace *trace, const char *path)
|
|||||||
struct stream *stream = calloc(1, sizeof(struct stream));
|
struct stream *stream = calloc(1, sizeof(struct stream));
|
||||||
|
|
||||||
if (stream == NULL) {
|
if (stream == NULL) {
|
||||||
perror("calloc failed");
|
err("calloc failed:");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ trace_load(struct trace *trace, const char *tracedir)
|
|||||||
/* Sort the streams */
|
/* Sort the streams */
|
||||||
DL_SORT(trace->streams, cmp_streams);
|
DL_SORT(trace->streams, cmp_streams);
|
||||||
|
|
||||||
err("loaded %ld streams", trace->nstreams);
|
info("loaded %ld streams", trace->nstreams);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user