summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-01-17 07:55:20 +0100
committerThomas Martitz <kugel@rockbox.org>2012-01-21 18:39:19 +0100
commit5b4a6c4267074c40655213e443ab4997530a4a98 (patch)
treeddcaa5d0971a61aaa4856943e00c50e5096c1698
parentcf333a61c7861361b4025cb0f67c8f75b0b07eef (diff)
downloadrockbox-5b4a6c4267074c40655213e443ab4997530a4a98.tar.gz
rockbox-5b4a6c4267074c40655213e443ab4997530a4a98.zip
Hosted: Merge debugf() implementations. Cleanup debug.h.
Fixes debug build for ypr0. Change-Id: I9c0eff651dcf268a3fafed1a71fcc47f3e323d36
-rw-r--r--firmware/SOURCES5
-rw-r--r--firmware/export/debug.h23
-rw-r--r--firmware/target/hosted/debug-hosted.c65
-rw-r--r--uisimulator/common/io.c40
4 files changed, 77 insertions, 56 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index f2036734a5..18f877ba3d 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -16,6 +16,11 @@ target/hosted/cpuinfo-linux.c
16#ifndef SAMSUNG_YPR0 /* uses as3514 rtc */ 16#ifndef SAMSUNG_YPR0 /* uses as3514 rtc */
17target/hosted/rtc.c 17target/hosted/rtc.c
18#endif 18#endif
19
20#if (CONFIG_PLATFORM & PLATFORM_ANDROID) == 0
21target/hosted/debug-hosted.c
22#endif
23
19#endif 24#endif
20system.c 25system.c
21usb.c 26usb.c
diff --git a/firmware/export/debug.h b/firmware/export/debug.h
index b5458af487..3a4a774f42 100644
--- a/firmware/export/debug.h
+++ b/firmware/export/debug.h
@@ -29,16 +29,13 @@ extern void debugf(const char* fmt,...) ATTRIBUTE_PRINTF(1, 2);
29extern void ldebugf(const char* file, int line, const char *fmt, ...) 29extern void ldebugf(const char* file, int line, const char *fmt, ...)
30 ATTRIBUTE_PRINTF(3, 4); 30 ATTRIBUTE_PRINTF(3, 4);
31 31
32#ifndef CODEC 32#ifndef CODEC
33#ifdef __GNUC__
34 33
35/* */
36#if defined(SIMULATOR) && !defined(__PCTOOL__) \ 34#if defined(SIMULATOR) && !defined(__PCTOOL__) \
37 || ((CONFIG_PLATFORM & (PLATFORM_ANDROID|PLATFORM_MAEMO|PLATFORM_PANDORA)) && defined(DEBUG)) 35 || (defined(APPLICATION) && defined(DEBUG))
38#define DEBUGF debugf 36#define DEBUGF debugf
39#define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__) 37#define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__)
40#else 38#elif defined(DEBUG) /* DEBUG on native targets */
41#if defined(DEBUG)
42 39
43#ifdef HAVE_GDB_API 40#ifdef HAVE_GDB_API
44void breakpoint(void); 41void breakpoint(void);
@@ -46,19 +43,13 @@ void breakpoint(void);
46 43
47#define DEBUGF debugf 44#define DEBUGF debugf
48#define LDEBUGF debugf 45#define LDEBUGF debugf
49#else
50#define DEBUGF(...) do { } while(0)
51#define LDEBUGF(...) do { } while(0)
52#endif
53#endif
54 46
47#else /* !DEBUG */
55 48
56#else 49#define DEBUGF(...) do { } while(0)
57 50#define LDEBUGF(...) do { } while(0)
58#define DEBUGF debugf
59#define LDEBUGF debugf
60 51
61#endif /* GCC */ 52#endif /* SIMULATOR && !__PCTOOL__ || APPLICATION && DEBUG */
62 53
63#endif /* CODEC */ 54#endif /* CODEC */
64#endif 55#endif
diff --git a/firmware/target/hosted/debug-hosted.c b/firmware/target/hosted/debug-hosted.c
new file mode 100644
index 0000000000..35c487958b
--- /dev/null
+++ b/firmware/target/hosted/debug-hosted.c
@@ -0,0 +1,65 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2002 Daniel Stenberg
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdarg.h>
23#include <stdio.h>
24#include <string.h>
25
26#ifdef WIN32
27static unsigned old_cp;
28
29void debug_exit(void)
30{
31 /* Reset console output codepage */
32 SetConsoleOutputCP(old_cp);
33}
34
35void debug_init(void)
36{
37 old_cp = GetConsoleOutputCP();
38 /* Set console output codepage to UTF8. Only works
39 * correctly when the console uses a truetype font. */
40 SetConsoleOutputCP(65001);
41 atexit(debug_exit);
42}
43#else
44void debug_init(void)
45{
46 /* nothing to be done */
47}
48#endif
49
50void debugf(const char *fmt, ...)
51{
52 va_list ap;
53 va_start( ap, fmt );
54 vfprintf( stderr, fmt, ap );
55 va_end( ap );
56}
57
58void ldebugf(const char* file, int line, const char *fmt, ...)
59{
60 va_list ap;
61 va_start( ap, fmt );
62 fprintf( stderr, "%s:%d ", file, line );
63 vfprintf( stderr, fmt, ap );
64 va_end( ap );
65}
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 02542d15e3..1df36d3b34 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -608,46 +608,6 @@ void lc_close(void *handle)
608} 608}
609 609
610#endif /* __PCTOOL__ */ 610#endif /* __PCTOOL__ */
611#ifdef WIN32
612static unsigned old_cp;
613
614void debug_exit(void)
615{
616 /* Reset console output codepage */
617 SetConsoleOutputCP(old_cp);
618}
619
620void debug_init(void)
621{
622 old_cp = GetConsoleOutputCP();
623 /* Set console output codepage to UTF8. Only works
624 * correctly when the console uses a truetype font. */
625 SetConsoleOutputCP(65001);
626 atexit(debug_exit);
627}
628#else
629void debug_init(void)
630{
631 /* nothing to be done */
632}
633#endif
634
635void debugf(const char *fmt, ...)
636{
637 va_list ap;
638 va_start( ap, fmt );
639 vfprintf( stderr, fmt, ap );
640 va_end( ap );
641}
642
643void ldebugf(const char* file, int line, const char *fmt, ...)
644{
645 va_list ap;
646 va_start( ap, fmt );
647 fprintf( stderr, "%s:%d ", file, line );
648 vfprintf( stderr, fmt, ap );
649 va_end( ap );
650}
651 611
652/* rockbox off_t may be different from system off_t */ 612/* rockbox off_t may be different from system off_t */
653int sim_ftruncate(int fd, long length) 613int sim_ftruncate(int fd, long length)