1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Deduplicated some native code and stopped the OSX juce_isRunningUnderDebugger function from caching its result.

This commit is contained in:
jules 2015-12-23 14:31:06 +00:00
parent 8c5f433691
commit 86a745dc35
9 changed files with 18 additions and 39 deletions

View file

@ -168,7 +168,7 @@ class FileOutputStream;
class XmlElement;
class JSONFormatter;
extern JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger();
extern JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept;
extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noexcept;
#include "memory/juce_Memory.h"

View file

@ -62,16 +62,11 @@ JUCE_API void JUCE_CALLTYPE Process::setPriority (ProcessPriority prior)
pthread_setschedparam (pthread_self(), policy, &param);
}
JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger()
JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept
{
return false;
}
JUCE_API bool JUCE_CALLTYPE Process::isRunningUnderDebugger()
{
return juce_isRunningUnderDebugger();
}
JUCE_API void JUCE_CALLTYPE Process::raisePrivilege() {}
JUCE_API void JUCE_CALLTYPE Process::lowerPrivilege() {}

View file

@ -197,7 +197,7 @@ bool Time::setSystemTimeToThisTime() const
return settimeofday (&t, 0) == 0;
}
JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger()
JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept
{
#if JUCE_BSD
return false;

View file

@ -52,11 +52,6 @@ JUCE_API void JUCE_CALLTYPE Process::setPriority (const ProcessPriority prior)
pthread_setschedparam (pthread_self(), policy, &param);
}
JUCE_API bool JUCE_CALLTYPE Process::isRunningUnderDebugger()
{
return juce_isRunningUnderDebugger();
}
static bool swapUserAndEffectiveUser()
{
int result1 = setreuid (geteuid(), getuid());

View file

@ -75,23 +75,11 @@ JUCE_API void JUCE_CALLTYPE Process::setPriority (ProcessPriority)
}
//==============================================================================
JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger()
JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept
{
static char testResult = 0;
if (testResult == 0)
{
struct kinfo_proc info;
int m[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
size_t sz = sizeof (info);
sysctl (m, 4, &info, &sz, 0, 0);
testResult = ((info.kp_proc.p_flag & P_TRACED) != 0) ? 1 : -1;
}
return testResult > 0;
}
JUCE_API bool JUCE_CALLTYPE Process::isRunningUnderDebugger()
{
return juce_isRunningUnderDebugger();
struct kinfo_proc info;
int m[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
size_t sz = sizeof (info);
sysctl (m, 4, &info, &sz, 0, 0);
return (info.kp_proc.p_flag & P_TRACED) != 0;
}

View file

@ -259,16 +259,11 @@ void JUCE_CALLTYPE Process::setPriority (ProcessPriority prior)
}
}
JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger()
JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept
{
return IsDebuggerPresent() != FALSE;
}
bool JUCE_CALLTYPE Process::isRunningUnderDebugger()
{
return juce_isRunningUnderDebugger();
}
static void* currentModuleHandle = nullptr;
void* JUCE_CALLTYPE Process::getCurrentModuleInstanceHandle() noexcept

View file

@ -111,7 +111,7 @@
//==============================================================================
#if JUCE_DEBUG || DOXYGEN
/** Writes a string to the standard error stream.
Note that as well as a single string, you can use this to write multiple items
Note that as well as a single string, you can use this to write multiple items
as a stream, e.g.
@code
DBG ("foo = " << foo << "bar = " << bar);

View file

@ -98,7 +98,7 @@ public:
//==============================================================================
/** Returns true if this process is being hosted by a debugger. */
static bool JUCE_CALLTYPE isRunningUnderDebugger();
static bool JUCE_CALLTYPE isRunningUnderDebugger() noexcept;
//==============================================================================

View file

@ -268,6 +268,12 @@ void SpinLock::enter() const noexcept
}
}
//==============================================================================
bool JUCE_CALLTYPE Process::isRunningUnderDebugger() noexcept
{
return juce_isRunningUnderDebugger();
}
//==============================================================================
#if JUCE_UNIT_TESTS