summaryrefslogtreecommitdiffhomepage
path: root/digital
diff options
context:
space:
mode:
authorNélio Laranjeiro2010-04-12 00:10:43 +0200
committerNélio Laranjeiro2010-04-12 00:10:43 +0200
commit3f9ec36bf414b08ac2ee0f62927997b8e0c127cb (patch)
tree17a6dfc9bb865081ed5a8b2b6d634b3e0d187720 /digital
parent0eb3874c27be75da36f39093ecfb603dc8fe7012 (diff)
{tools/trace, digital/avr/modules/trace}: print trace on host execution, closes #92
Diffstat (limited to 'digital')
-rw-r--r--digital/avr/modules/trace/Makefile.module2
-rw-r--r--digital/avr/modules/trace/test/Makefile6
-rw-r--r--digital/avr/modules/trace/test/events.h36
-rw-r--r--digital/avr/modules/trace/test/flood.c2
-rw-r--r--digital/avr/modules/trace/test/test-trace.c4
-rw-r--r--digital/avr/modules/trace/trace.h12
6 files changed, 21 insertions, 41 deletions
diff --git a/digital/avr/modules/trace/Makefile.module b/digital/avr/modules/trace/Makefile.module
index e5fcdfc2..2465f835 100644
--- a/digital/avr/modules/trace/Makefile.module
+++ b/digital/avr/modules/trace/Makefile.module
@@ -1 +1 @@
-trace_SOURCES=trace.c
+trace_SOURCES=trace.c events.host.c
diff --git a/digital/avr/modules/trace/test/Makefile b/digital/avr/modules/trace/test/Makefile
index c3ea960e..dec8b36b 100644
--- a/digital/avr/modules/trace/test/Makefile
+++ b/digital/avr/modules/trace/test/Makefile
@@ -1,4 +1,5 @@
BASE = ../../..
+TOOLS= $(BASE)/../../tools
AVR_PROGS = test_trace flood
HOST_PROGS = test_trace flood
@@ -13,4 +14,9 @@ AVR_MCU = atmega128
# -Os : size
OPTIMIZE = -O2
+events:
+ python $(TOOLS)/trace/trace.py -i $(TOOLS)/trace/example/trace.trc -t create -o
+ mv events.h ..
+ mv events.host.c ..
+
include $(BASE)/make/Makefile.gen
diff --git a/digital/avr/modules/trace/test/events.h b/digital/avr/modules/trace/test/events.h
deleted file mode 100644
index d5a972a1..00000000
--- a/digital/avr/modules/trace/test/events.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef events_h
-#define events_h
-/* events_h */
-/* {{{
- *
- * Copyright (C) 2008 APBTeam
- *
- * APBTeam:
- * Web: http://apbteam.org/
- * Email: team AT apbteam DOT org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * }}} */
-
-enum events_t
-{
- TRACE_ASSERV__RIGHT_MOTOR,
- TRACE_ASSERV__LEFT_MOTOR,
- TRACE_IA__IA_CMD,
- TRACE_NB
-};
-
-#endif /* events_h */
diff --git a/digital/avr/modules/trace/test/flood.c b/digital/avr/modules/trace/test/flood.c
index 6cc88a32..7675808a 100644
--- a/digital/avr/modules/trace/test/flood.c
+++ b/digital/avr/modules/trace/test/flood.c
@@ -26,12 +26,12 @@
#include "io.h"
#include "modules/flash/flash.h"
#include "modules/trace/trace.h"
+#include "modules/trace/events.h"
#include "modules/proto/proto.h"
#include "modules/utils/utils.h"
#include "modules/utils/byte.h"
#include "modules/uart/uart.h"
-#include "events.h"
void
flood (void)
diff --git a/digital/avr/modules/trace/test/test-trace.c b/digital/avr/modules/trace/test/test-trace.c
index 932b99a5..7bfde18b 100644
--- a/digital/avr/modules/trace/test/test-trace.c
+++ b/digital/avr/modules/trace/test/test-trace.c
@@ -28,14 +28,12 @@
#include "io.h"
#include "modules/flash/flash.h"
#include "modules/trace/trace.h"
+#include "modules/trace/events.h"
#include "modules/proto/proto.h"
#include "modules/utils/utils.h"
#include "modules/utils/byte.h"
#include "modules/uart/uart.h"
-
-#include "events.h"
-
void
flood (void)
{
diff --git a/digital/avr/modules/trace/trace.h b/digital/avr/modules/trace/trace.h
index ce83bdaa..069f5e7c 100644
--- a/digital/avr/modules/trace/trace.h
+++ b/digital/avr/modules/trace/trace.h
@@ -28,6 +28,7 @@
* You can find the example on the website :
* http://gcc.gnu.org/ml/gcc-patches/2000-11/msg00016.html
*/
+#include "modules/trace/events.h"
#define PASTE_EXPAND(a, b) PASTE(a, b)
#define PASTE(a, b) a ## b
@@ -40,8 +41,19 @@
#define _TRACE_ARGS_COUNT2(_ ,_0,_1,_2,_3,_4,_5,_6,_7,_8,_9, n,...) n
+#ifndef HOST
#define TRACE(args...) \
PASTE_EXPAND(TRACE_PRINT, TRACE_ARGS_COUNT(args...)) (args)
+#else /* HOST */
+#include <stdio.h>
+extern char *trace_table[];
+#define TRACE(id, args...) \
+ do {\
+ fprintf (stderr, trace_table[id], ## args);\
+ PASTE_EXPAND(TRACE_PRINT, TRACE_ARGS_COUNT(id, ## args...))\
+ (id, ## args);\
+ } while (0)
+#endif /* HOST */
#define TRACE_PRINT1(args)\
({TRACE_PRINT_ARG_TYPE(args);})