Skip to content

Commit

Permalink
debug: always enable debug messages on Android
Browse files Browse the repository at this point in the history
We'll send them to a specific file.

Signed-off-by: Valentin Hoyet <valentin.hoyet@inria.fr>
Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
Valentin Hoyet authored and bgoglin committed Sep 25, 2020
1 parent e4abefd commit 9c1b1ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion contrib/android/include/private/autogen/config.h
Expand Up @@ -409,7 +409,7 @@
/* #undef HWLOC_DARWIN_SYS */

/* Whether we are in debugging mode or not */
/* #undef HWLOC_DEBUG */
#define HWLOC_DEBUG 1

/* Define to 1 on *FREEBSD */
/* #undef HWLOC_FREEBSD_SYS */
Expand Down
14 changes: 13 additions & 1 deletion include/private/debug.h
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
* Copyright © 2009-2017 Inria. All rights reserved.
* Copyright © 2009-2020 Inria. All rights reserved.
* Copyright © 2009, 2011 Université Bordeaux
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
Expand All @@ -19,6 +19,10 @@
#include <stdio.h>
#endif

#ifdef ANDROID
extern void JNIDebug(char *text);
#endif

/* Compile-time assertion */
#define HWLOC_BUILD_ASSERT(condition) ((void)sizeof(char[1 - 2*!(condition)]))

Expand All @@ -44,9 +48,17 @@ static __hwloc_inline void hwloc_debug(const char *s __hwloc_attribute_unused, .
{
#ifdef HWLOC_DEBUG
if (hwloc_debug_enabled()) {
#ifdef ANDROID
char buffer[256];
#endif
va_list ap;
va_start(ap, s);
#ifdef ANDROID
vsprintf(buffer, s, ap);
JNIDebug(buffer);
#else
vfprintf(stderr, s, ap);
#endif
va_end(ap);
}
#endif
Expand Down

0 comments on commit 9c1b1ae

Please sign in to comment.