Browse Source

Improved the way juce_isRunningUnderDebugger() works on linux.

tags/2021-05-28
jules 11 years ago
parent
commit
cfb3c5459a
2 changed files with 17 additions and 24 deletions
  1. +17
    -2
      modules/juce_core/native/juce_linux_SystemStats.cpp
  2. +0
    -22
      modules/juce_core/native/juce_linux_Threads.cpp

+ 17
- 2
modules/juce_core/native/juce_linux_SystemStats.cpp View File

@@ -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
}

+ 0
- 22
modules/juce_core/native/juce_linux_Threads.cpp View File

@@ -52,28 +52,6 @@ JUCE_API void JUCE_CALLTYPE Process::setPriority (const ProcessPriority prior)
pthread_setschedparam (pthread_self(), policy, &param);
}
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…
Cancel
Save