From 376b83986aca5f4e31a952b647e44bfba7186548 Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 9 Feb 2017 17:42:44 +0000 Subject: [PATCH] Fixed a bug that would cause asserts to be ignored on some android platforms --- modules/juce_core/native/juce_android_Threads.cpp | 7 +++++++ modules/juce_core/system/juce_PlatformDefs.h | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/juce_core/native/juce_android_Threads.cpp b/modules/juce_core/native/juce_android_Threads.cpp index c7a0b73b78..692e73d429 100644 --- a/modules/juce_core/native/juce_android_Threads.cpp +++ b/modules/juce_core/native/juce_android_Threads.cpp @@ -66,6 +66,13 @@ JUCE_API void JUCE_CALLTYPE Process::setPriority (ProcessPriority prior) JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept { + StringArray lines; + File ("/proc/self/status").readLines (lines); + + for (int i = lines.size(); --i >= 0;) // (NB - it's important that this runs in reverse order) + if (lines[i].upToFirstOccurrenceOf (":", false, false).trim().equalsIgnoreCase ("TracerPid")) + return (lines[i].fromFirstOccurrenceOf (":", false, false).trim().getIntValue() > 0); + return false; } diff --git a/modules/juce_core/system/juce_PlatformDefs.h b/modules/juce_core/system/juce_PlatformDefs.h index 7616707a6c..838eeb10c6 100644 --- a/modules/juce_core/system/juce_PlatformDefs.h +++ b/modules/juce_core/system/juce_PlatformDefs.h @@ -62,7 +62,7 @@ #endif //============================================================================== -#if JUCE_IOS || JUCE_LINUX || JUCE_ANDROID +#if JUCE_IOS || JUCE_LINUX /** This will try to break into the debugger if the app is currently being debugged. If called by an app that's not being debugged, the behaviour isn't defined - it may crash or not, depending on the platform. @@ -80,6 +80,8 @@ #else #define JUCE_BREAK_IN_DEBUGGER { asm ("int $3"); } #endif +#elif JUCE_ANDROID + #define JUCE_BREAK_IN_DEBUGGER { __builtin_trap(); } #else #define JUCE_BREAK_IN_DEBUGGER { __asm int 3 } #endif