Added in wait for attach context flag. Added in a small flag which is passed to the context from the Java/C++ API which causes the context to delay execution until a debugger is a attached. This gives time to the developer to attach a debugger to the process before the kernel is executed. Change-Id: I5bb8e75100436920f9e1a0f414f3b0bcf0d2b439 Signed-off-by: Stephen McGroarty <[email protected]>
diff --git a/rsContext.cpp b/rsContext.cpp index fba06cd..c21542f 100644 --- a/rsContext.cpp +++ b/rsContext.cpp
@@ -45,6 +45,8 @@ #include "rsCompatibilityLib.h" #endif +int gDebuggerPresent = 0; + #ifdef RS_SERVER // Android exposes gettid(), standard Linux does not static pid_t gettid() { @@ -478,6 +480,11 @@ } } +void Context::waitForDebugger() { + while (!gDebuggerPresent) { + sleep(0); + } +} Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc, RsContextType ct, uint32_t flags) { @@ -496,6 +503,11 @@ delete rsc; return nullptr; } + + if (flags & RS_CONTEXT_WAIT_FOR_ATTACH) { + rsc->waitForDebugger(); + } + return rsc; }