summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2016-03-30 17:54:01 -0700
committerYang Ni <yangni@google.com>2016-07-25 22:14:14 +0000
commitec8778ceb0f7870d50f8a99f706c71e39f1add18 (patch)
tree0a64b098af4cc213ca6d1e8cd0ba0163f23215e4
parent68e30e410ce027099d0d85303aefa4134a461227 (diff)
Move gDebuggerPresent to libRS.so, and fix up driver after split.
Now that libRS.so has been split into public/private libraries, we must also move gDebuggerPresent into the public side. lldb uses this as a flag to indicate that the driver can proceed (after waiting for the debugger to attach). Change-Id: I4c8f5c466644a51d50368ac8dd91f0bfd699302d (cherry picked from commit 98cb2d1420a22536649af2c493a58595f7c2542e) Bug: 30312793
-rw-r--r--libRS.map1
-rw-r--r--rsApiContext.cpp11
-rw-r--r--rsContext.cpp6
-rw-r--r--rsContext.h9
4 files changed, 20 insertions, 7 deletions
diff --git a/libRS.map b/libRS.map
index 64b6cb6d..6b58b545 100644
--- a/libRS.map
+++ b/libRS.map
@@ -1,5 +1,6 @@
libRS {
global:
+ gDebuggerPresent;
rsaAllocationGetType;
rsaContextSetNativeLibDir;
rsaElementGetNativeData;
diff --git a/rsApiContext.cpp b/rsApiContext.cpp
index a5c7c3fd..8cb29930 100644
--- a/rsApiContext.cpp
+++ b/rsApiContext.cpp
@@ -24,8 +24,19 @@
using namespace android;
using namespace android::renderscript;
+/*
+ * This global will be found by the debugger and will have its value flipped.
+ * It's independent of the Context class to allow the debugger to do the above
+ * without knowing the type makeup. This allows the debugger to be attached at
+ * an earlier stage.
+ */
+extern "C" int gDebuggerPresent = 0;
+
extern "C" RsContext rsContextCreate(RsDevice vdev, uint32_t version, uint32_t sdkVersion,
RsContextType ct, uint32_t flags) {
+ if (!gInternalDebuggerPresent) {
+ gInternalDebuggerPresent = &gDebuggerPresent;
+ }
//ALOGV("rsContextCreate dev=%p", vdev);
Device * dev = static_cast<Device *>(vdev);
Context *rsc = Context::createContext(dev, nullptr, ct, flags);
diff --git a/rsContext.cpp b/rsContext.cpp
index 57b5d04b..ff636747 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -45,7 +45,7 @@
#include "rsCompatibilityLib.h"
#endif
-int gDebuggerPresent = 0;
+int *gInternalDebuggerPresent = nullptr;
#ifdef RS_SERVER
// Android exposes gettid(), standard Linux does not
@@ -484,7 +484,9 @@ void Context::setCacheDir(const char * cacheDir_arg, uint32_t length) {
}
void Context::waitForDebugger() {
- while (!gDebuggerPresent) {
+ // Wait until this symbol has been properly set up, and the flag itself is
+ // set to a non-zero value.
+ while (!gInternalDebuggerPresent || !*gInternalDebuggerPresent) {
sleep(0);
}
}
diff --git a/rsContext.h b/rsContext.h
index edc4bec2..4a8cd291 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -46,12 +46,11 @@
#endif
/*
- * This global will be found by the debugger and will have its value flipped.
- * It's independent of the Context class to allow the debugger to do the above
- * without knowing the type makeup. This allows the debugger to be attached at
- * an earlier stage.
+ * This is a pointer to the gDebuggerPresent global from libRS.so. The
+ * debugger will use this to signal that it is attached, and thus the
+ * driver can wait appropriately.
*/
-extern "C" int gDebuggerPresent;
+extern int *gInternalDebuggerPresent;
// ---------------------------------------------------------------------------
namespace android {