diff options
author | Thomas Martitz <kugel@rockbox.org> | 2012-01-17 07:55:20 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2012-01-21 18:39:19 +0100 |
commit | 5b4a6c4267074c40655213e443ab4997530a4a98 (patch) | |
tree | ddcaa5d0971a61aaa4856943e00c50e5096c1698 /firmware | |
parent | cf333a61c7861361b4025cb0f67c8f75b0b07eef (diff) | |
download | rockbox-5b4a6c4267074c40655213e443ab4997530a4a98.tar.gz rockbox-5b4a6c4267074c40655213e443ab4997530a4a98.zip |
Hosted: Merge debugf() implementations. Cleanup debug.h.
Fixes debug build for ypr0.
Change-Id: I9c0eff651dcf268a3fafed1a71fcc47f3e323d36
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 5 | ||||
-rw-r--r-- | firmware/export/debug.h | 23 | ||||
-rw-r--r-- | firmware/target/hosted/debug-hosted.c | 65 |
3 files changed, 77 insertions, 16 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 */ |
17 | target/hosted/rtc.c | 17 | target/hosted/rtc.c |
18 | #endif | 18 | #endif |
19 | |||
20 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) == 0 | ||
21 | target/hosted/debug-hosted.c | ||
22 | #endif | ||
23 | |||
19 | #endif | 24 | #endif |
20 | system.c | 25 | system.c |
21 | usb.c | 26 | usb.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); | |||
29 | extern void ldebugf(const char* file, int line, const char *fmt, ...) | 29 | extern 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 |
44 | void breakpoint(void); | 41 | void 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 | ||
27 | static unsigned old_cp; | ||
28 | |||
29 | void debug_exit(void) | ||
30 | { | ||
31 | /* Reset console output codepage */ | ||
32 | SetConsoleOutputCP(old_cp); | ||
33 | } | ||
34 | |||
35 | void 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 | ||
44 | void debug_init(void) | ||
45 | { | ||
46 | /* nothing to be done */ | ||
47 | } | ||
48 | #endif | ||
49 | |||
50 | void 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 | |||
58 | void 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 | } | ||