mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-11 23:54:18 +00:00
Improved the way juce_isRunningUnderDebugger() works on linux.
This commit is contained in:
parent
4e4a9968a3
commit
cfb3c5459a
2 changed files with 17 additions and 24 deletions
|
|
@ -55,10 +55,10 @@ bool SystemStats::isOperatingSystem64Bit()
|
|||
//==============================================================================
|
||||
namespace LinuxStatsHelpers
|
||||
{
|
||||
String getCpuInfo (const char* const key)
|
||||
String getConfigFileValue (const char* file, const char* const key)
|
||||
{
|
||||
StringArray lines;
|
||||
File ("/proc/cpuinfo").readLines (lines);
|
||||
File (file).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 (key))
|
||||
|
|
@ -66,6 +66,11 @@ namespace LinuxStatsHelpers
|
|||
|
||||
return String();
|
||||
}
|
||||
|
||||
String getCpuInfo (const char* key)
|
||||
{
|
||||
return getConfigFileValue ("/proc/cpuinfo", key);
|
||||
}
|
||||
}
|
||||
|
||||
String SystemStats::getDeviceDescription()
|
||||
|
|
@ -189,3 +194,13 @@ bool Time::setSystemTimeToThisTime() const
|
|||
|
||||
return settimeofday (&t, 0) == 0;
|
||||
}
|
||||
|
||||
JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger()
|
||||
{
|
||||
#if JUCE_BSD
|
||||
return false;
|
||||
#else
|
||||
return LinuxStatsHelpers::getConfigFileValue ("/proc/self/status", "TracerPid")
|
||||
.getIntValue() > 0;
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,28 +52,6 @@ JUCE_API void JUCE_CALLTYPE Process::setPriority (const ProcessPriority prior)
|
|||
pthread_setschedparam (pthread_self(), policy, ¶m);
|
||||
}
|
||||
|
||||
JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger()
|
||||
{
|
||||
#if JUCE_BSD
|
||||
return false;
|
||||
#else
|
||||
static char testResult = 0;
|
||||
|
||||
if (testResult == 0)
|
||||
{
|
||||
testResult = (char) ptrace (PT_TRACE_ME, 0, 0, 0);
|
||||
|
||||
if (testResult >= 0)
|
||||
{
|
||||
ptrace (PT_DETACH, 0, (caddr_t) 1, 0);
|
||||
testResult = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return testResult < 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
JUCE_API bool JUCE_CALLTYPE Process::isRunningUnderDebugger()
|
||||
{
|
||||
return juce_isRunningUnderDebugger();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue