added the ASSERT and VERIFY macros to logging to help detect problems
This commit is contained in:
parent
82ca8371e6
commit
0dc56d49e5
|
@ -1,6 +1,6 @@
|
|||
OBJS=main.o sysinput.o fbinit.o fbprimitive.o log.o gpio.o msg_queue.o time_func.o config.o splash.o
|
||||
LIBS=-lbcm2835 -lpthread
|
||||
CFLAGS=-g
|
||||
CFLAGS=-g -O -DDEBUG_ASSERT
|
||||
|
||||
upiwin: $(OBJS)
|
||||
gcc -o upiwin $(OBJS) $(LIBS)
|
||||
|
|
|
@ -47,8 +47,10 @@ static void run_exit_funcs(void)
|
|||
p = exitfuncs;
|
||||
exitfuncs = p->next;
|
||||
for (i = p->num_funcs - 1; i >= 0; i--)
|
||||
if (p->funcs[i])
|
||||
{
|
||||
ASSERT(p->funcs[i]);
|
||||
(*(p->funcs[i]))();
|
||||
}
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,3 +23,8 @@ void Log(int level, const char *format, ...)
|
|||
strftime(timestamp, 32, "%F %T", &tm);
|
||||
printf("%s.%06u %s %s\n", timestamp, tv.tv_usec, severities[level], buf);
|
||||
}
|
||||
|
||||
void Log_assert_failed(const char *test, const char *file, int line)
|
||||
{
|
||||
Log(LERROR, "ASSERT FAILED: %s at %s:%d", test, file, line);
|
||||
}
|
||||
|
|
12
src/log.h
12
src/log.h
|
@ -8,5 +8,17 @@
|
|||
#define LDEBUG 4
|
||||
|
||||
extern void Log(int level, const char *format, ...);
|
||||
extern void Log_assert_failed(const char *test, const char *file, int line);
|
||||
|
||||
#define THIS_FILE __FILE__
|
||||
#define DECLARE_THIS_FILE() static const char THIS_FILE[] = __FILE__
|
||||
|
||||
#ifdef DEBUG_ASSERT
|
||||
#define ASSERT(x) ((x) ? (void)0 : Log_assert_failed(#x, THIS_FILE, __LINE__))
|
||||
#define VERIFY(x) ASSERT(x)
|
||||
#else
|
||||
#define ASSERT(x) ((void)0)
|
||||
#define VERIFY(x) ((void)(x))
|
||||
#endif
|
||||
|
||||
#endif /* __LOG_H_INCLUDED */
|
||||
|
|
Loading…
Reference in New Issue
Block a user