Send this to the correct mailing list...

Op 20-09-10 19:38, mai...@svn.rockbox.org schreef:
> Date: 2010-09-20 19:38:47 +0200 (Mon, 20 Sep 2010)
> New Revision: 28125
> 
> Log Message:
> Redirect (L)DEBUGFs to adb logcat in DEBUG enabled builds.
> Exclude compilation of firmware/debug.c for hosted platforms.
> 
> Added:
>    trunk/firmware/target/hosted/android/debug-android.c
> Modified:
>    trunk/firmware/SOURCES
>    trunk/firmware/debug.c
>    trunk/firmware/export/debug.h
>    trunk/firmware/target/hosted/android/pcm-android.c
>    trunk/firmware/target/hosted/android/system-target.h
> 
[snip]
> Modified: trunk/firmware/export/debug.h
> ===================================================================
> --- trunk/firmware/export/debug.h     2010-09-20 17:09:55 UTC (rev 28124)
> +++ trunk/firmware/export/debug.h     2010-09-20 17:38:47 UTC (rev 28125)
> @@ -33,13 +33,10 @@
>  #ifdef __GNUC__
>  
>  /*  */
> -#if defined(SIMULATOR) && !defined(__PCTOOL__)
> +#if (SIMULATOR) && !defined(__PCTOOL__) \
> +    || ((CONFIG_PLATFORM & PLATFORM_ANDROID) && defined(DEBUG))
>  #define DEBUGF  debugf
>  #define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__)

Another way of doing this could be (not sure if we have a STRINGIFY macro):
#define LDEBUGF(fmt, ...) DEBUGF(__FILE__ ":" STRINGIFY(__LINE__) " " fmt,     \
                                 __VA_ARGS__)

That way there's no need for the separate ldebugf() function and buffer.

[snip]

> +void debugf(const char *fmt, ...)
> +{
> +    va_list ap;
> +    va_start(ap, fmt);
> +     __android_log_vprint(ANDROID_LOG_DEBUG, LOG_TAG, fmt, ap);
> +    va_end(ap);
> +}
> +

(which is done here)

> +void ldebugf(const char* file, int line, const char *fmt, ...)
> +{
> +    va_list ap;
> +    char buf[1024];
> +    snprintf(buf, sizeof(buf), "%s:%d %s", file, line, fmt);
> +    va_start(ap, fmt);
> +    __android_log_vprint(ANDROID_LOG_DEBUG, LOG_TAG " L", buf, ap);
> +    va_end(ap);
> +}

Reply via email to