Skip to content

Commit 7a57009

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge "add an option to EGL to dump stack traces on errors"
2 parents a674c9b + 8ec2ff6 commit 7a57009

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

opengl/libs/EGL/egl.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,13 @@ static int gl_no_context() {
148148
if (egl_tls_t::logNoContextCall()) {
149149
LOGE("call to OpenGL ES API with no current context "
150150
"(logged once per thread)");
151-
LOGE("call stack before error:");
152-
CallStack stack;
153-
stack.update();
154-
stack.dump();
151+
char value[PROPERTY_VALUE_MAX];
152+
property_get("debug.egl.callstack", value, "0");
153+
if (atoi(value)) {
154+
CallStack stack;
155+
stack.update();
156+
stack.dump();
157+
}
155158
}
156159
return 0;
157160
}

opengl/libs/EGL/egl_tls.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
** limitations under the License.
1515
*/
1616

17+
#include <stdlib.h>
1718
#include <pthread.h>
1819

1920
#include <cutils/log.h>
21+
#include <cutils/properties.h>
22+
23+
#include <utils/CallStack.h>
2024

2125
#include <EGL/egl.h>
2226

@@ -69,6 +73,13 @@ void egl_tls_t::setErrorEtcImpl(const char* caller, int line, EGLint error) {
6973
if (tls->error != error) {
7074
LOGE("%s:%d error %x (%s)", caller, line, error, egl_strerror(error));
7175
tls->error = error;
76+
char value[PROPERTY_VALUE_MAX];
77+
property_get("debug.egl.callstack", value, "0");
78+
if (atoi(value)) {
79+
CallStack stack;
80+
stack.update();
81+
stack.dump();
82+
}
7283
}
7384
}
7485

0 commit comments

Comments
 (0)