summaryrefslogtreecommitdiffstats
path: root/opengl/libs/GLES2_dbg/src
diff options
context:
space:
mode:
authorDavid Li <davidxli@google.com>2011-04-08 18:43:16 -0700
committerDavid Li <davidxli@google.com>2011-04-12 15:56:10 -0700
commit499c6f02e696622a532a504be9706896aea5a304 (patch)
treefd0ac92160ca6efb088050cbca07b1fb4af126b4 /opengl/libs/GLES2_dbg/src
parent904f18f792fa9205a980a36152db61086a9b8374 (diff)
downloadframeworks_native-499c6f02e696622a532a504be9706896aea5a304.zip
frameworks_native-499c6f02e696622a532a504be9706896aea5a304.tar.gz
frameworks_native-499c6f02e696622a532a504be9706896aea5a304.tar.bz2
GLES2Dbg: use dump.gles2dbg file when fails to create socket
setprop debug.egl.debug_forceUseFile 1: always use file setprop debug.egl.debug_maxFileSize <int MB>: exit when reached setprop debug.egl.debug_filePath <path>: may need to make the file writable first. setprop debug.egl.debug_port <unsigned short> setprop debug.egl.debug_proc <proc cmdline>: to match debuggee process Change-Id: I34ca1f3092f3abf17e2ded9d1689d0cdef6e07e8 Signed-off-by: David Li <davidxli@google.com>
Diffstat (limited to 'opengl/libs/GLES2_dbg/src')
-rw-r--r--opengl/libs/GLES2_dbg/src/api.h13
-rw-r--r--opengl/libs/GLES2_dbg/src/dbgcontext.cpp18
-rw-r--r--opengl/libs/GLES2_dbg/src/debugger_message.pb.cpp2
-rw-r--r--opengl/libs/GLES2_dbg/src/debugger_message.pb.h6
-rw-r--r--opengl/libs/GLES2_dbg/src/server.cpp43
5 files changed, 56 insertions, 26 deletions
diff --git a/opengl/libs/GLES2_dbg/src/api.h b/opengl/libs/GLES2_dbg/src/api.h
index 2afbe35..0b227bc 100644
--- a/opengl/libs/GLES2_dbg/src/api.h
+++ b/opengl/libs/GLES2_dbg/src/api.h
@@ -16,16 +16,13 @@
#define EXTEND_Debug_glCopyTexImage2D \
DbgContext * const dbg = getDbgContextThreadSpecific(); \
- GLint readFormat, readType; \
- dbg->hooks->gl.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat); \
- dbg->hooks->gl.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType); \
- unsigned readSize = GetBytesPerPixel(readFormat, readType) * width * height; \
- void * readData = dbg->GetReadPixelsBuffer(readSize); \
- dbg->hooks->gl.glReadPixels(x, y, width, height, readFormat, readType, readData); \
+ void * readData = dbg->GetReadPixelsBuffer(4 * width * height); \
+ /* pick easy format for client to convert */ \
+ dbg->hooks->gl.glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, readData); \
dbg->CompressReadPixelBuffer(msg.mutable_data()); \
msg.set_data_type(msg.ReferencedImage); \
- msg.set_pixel_format(readFormat); \
- msg.set_pixel_type(readType);
+ msg.set_pixel_format(GL_RGBA); \
+ msg.set_pixel_type(GL_UNSIGNED_BYTE);
#define EXTEND_Debug_glCopyTexSubImage2D EXTEND_Debug_glCopyTexImage2D
diff --git a/opengl/libs/GLES2_dbg/src/dbgcontext.cpp b/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
index eb0e1a9..3e8e852 100644
--- a/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
+++ b/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
@@ -195,10 +195,12 @@ unsigned int DbgContext::GetBufferSize()
void DbgContext::glUseProgram(GLuint program)
{
while (GLenum error = hooks->gl.glGetError())
- LOGD("DbgContext::glUseProgram: before glGetError() = 0x%.4X", error);
-
+ LOGD("DbgContext::glUseProgram(%u): before glGetError() = 0x%.4X",
+ program, error);
this->program = program;
-
+ maxAttrib = 0;
+ if (program == 0)
+ return;
GLint activeAttributes = 0;
hooks->gl.glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &activeAttributes);
maxAttrib = 0;
@@ -236,9 +238,9 @@ void DbgContext::glUseProgram(GLuint program)
maxAttrib = slot;
}
delete name;
-
while (GLenum error = hooks->gl.glGetError())
- LOGD("DbgContext::glUseProgram: after glGetError() = 0x%.4X", error);
+ LOGD("DbgContext::glUseProgram(%u): after glGetError() = 0x%.4X",
+ program, error);
}
static bool HasNonVBOAttribs(const DbgContext * const ctx)
@@ -288,14 +290,16 @@ void DbgContext::glVertexAttribPointer(GLuint indx, GLint size, GLenum type,
void DbgContext::glEnableVertexAttribArray(GLuint index)
{
- assert(index < MAX_VERTEX_ATTRIBS);
+ if (index >= MAX_VERTEX_ATTRIBS)
+ return;
vertexAttribs[index].enabled = true;
hasNonVBOAttribs = HasNonVBOAttribs(this);
}
void DbgContext::glDisableVertexAttribArray(GLuint index)
{
- assert(index < MAX_VERTEX_ATTRIBS);
+ if (index >= MAX_VERTEX_ATTRIBS)
+ return;
vertexAttribs[index].enabled = false;
hasNonVBOAttribs = HasNonVBOAttribs(this);
}
diff --git a/opengl/libs/GLES2_dbg/src/debugger_message.pb.cpp b/opengl/libs/GLES2_dbg/src/debugger_message.pb.cpp
index ee76847..b0f639d 100644
--- a/opengl/libs/GLES2_dbg/src/debugger_message.pb.cpp
+++ b/opengl/libs/GLES2_dbg/src/debugger_message.pb.cpp
@@ -437,6 +437,7 @@ bool Message_Type_IsValid(int value) {
case 1:
case 2:
case 3:
+ case 4:
return true;
default:
return false;
@@ -448,6 +449,7 @@ const Message_Type Message::BeforeCall;
const Message_Type Message::AfterCall;
const Message_Type Message::AfterGeneratedCall;
const Message_Type Message::Response;
+const Message_Type Message::CompleteCall;
const Message_Type Message::Type_MIN;
const Message_Type Message::Type_MAX;
const int Message::Type_ARRAYSIZE;
diff --git a/opengl/libs/GLES2_dbg/src/debugger_message.pb.h b/opengl/libs/GLES2_dbg/src/debugger_message.pb.h
index 63b952c..c3f98ba 100644
--- a/opengl/libs/GLES2_dbg/src/debugger_message.pb.h
+++ b/opengl/libs/GLES2_dbg/src/debugger_message.pb.h
@@ -237,11 +237,12 @@ enum Message_Type {
Message_Type_BeforeCall = 0,
Message_Type_AfterCall = 1,
Message_Type_AfterGeneratedCall = 2,
- Message_Type_Response = 3
+ Message_Type_Response = 3,
+ Message_Type_CompleteCall = 4
};
bool Message_Type_IsValid(int value);
const Message_Type Message_Type_Type_MIN = Message_Type_BeforeCall;
-const Message_Type Message_Type_Type_MAX = Message_Type_Response;
+const Message_Type Message_Type_Type_MAX = Message_Type_CompleteCall;
const int Message_Type_Type_ARRAYSIZE = Message_Type_Type_MAX + 1;
enum Message_DataType {
@@ -513,6 +514,7 @@ class Message : public ::google::protobuf::MessageLite {
static const Type AfterCall = Message_Type_AfterCall;
static const Type AfterGeneratedCall = Message_Type_AfterGeneratedCall;
static const Type Response = Message_Type_Response;
+ static const Type CompleteCall = Message_Type_CompleteCall;
static inline bool Type_IsValid(int value) {
return Message_Type_IsValid(value);
}
diff --git a/opengl/libs/GLES2_dbg/src/server.cpp b/opengl/libs/GLES2_dbg/src/server.cpp
index e740e92..c354bd0 100644
--- a/opengl/libs/GLES2_dbg/src/server.cpp
+++ b/opengl/libs/GLES2_dbg/src/server.cpp
@@ -28,7 +28,8 @@ namespace android
{
int serverSock = -1, clientSock = -1;
-
+FILE * file = NULL;
+unsigned int MAX_FILE_SIZE = 0;
int timeMode = SYSTEM_TIME_THREAD;
static void Die(const char * msg)
@@ -38,18 +39,25 @@ static void Die(const char * msg)
exit(1);
}
-void StartDebugServer(unsigned short port)
+void StartDebugServer(const unsigned short port, const bool forceUseFile,
+ const unsigned int maxFileSize, const char * const filePath)
{
+ MAX_FILE_SIZE = maxFileSize;
+
LOGD("GLESv2_dbg: StartDebugServer");
- if (serverSock >= 0)
+ if (serverSock >= 0 || file)
return;
LOGD("GLESv2_dbg: StartDebugServer create socket");
struct sockaddr_in server = {}, client = {};
/* Create the TCP socket */
- if ((serverSock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
- Die("Failed to create socket");
+ if (forceUseFile || (serverSock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
+ file = fopen(filePath, "wb");
+ if (!file)
+ Die("Failed to create socket and file");
+ else
+ return;
}
/* Construct the server sockaddr_in structure */
server.sin_family = AF_INET; /* Internet/IP */
@@ -92,13 +100,17 @@ void StopDebugServer()
close(serverSock);
serverSock = -1;
}
-
+ if (file) {
+ fclose(file);
+ file = NULL;
+ }
}
void Receive(glesv2debugger::Message & cmd)
{
+ if (clientSock < 0)
+ return;
unsigned len = 0;
-
int received = recv(clientSock, &len, 4, MSG_WAITALL);
if (received < 0)
Die("Failed to receive response length");
@@ -106,7 +118,6 @@ void Receive(glesv2debugger::Message & cmd)
LOGD("received %dB: %.8X", received, len);
Die("Received length mismatch, expected 4");
}
- len = ntohl(len);
static void * buffer = NULL;
static unsigned bufferSize = 0;
if (bufferSize < len) {
@@ -125,6 +136,8 @@ void Receive(glesv2debugger::Message & cmd)
bool TryReceive(glesv2debugger::Message & cmd)
{
+ if (clientSock < 0)
+ return false;
fd_set readSet;
FD_ZERO(&readSet);
FD_SET(clientSock, &readSet);
@@ -153,7 +166,19 @@ float Send(const glesv2debugger::Message & msg, glesv2debugger::Message & cmd)
assert(msg.has_context_id() && msg.context_id() != 0);
static std::string str;
msg.SerializeToString(&str);
- uint32_t len = htonl(str.length());
+ const uint32_t len = str.length();
+ if (clientSock < 0) {
+ if (file) {
+ fwrite(&len, sizeof(len), 1, file);
+ fwrite(str.data(), len, 1, file);
+ if (ftell(file) >= MAX_FILE_SIZE) {
+ fclose(file);
+ Die("MAX_FILE_SIZE reached");
+ }
+ }
+ pthread_mutex_unlock(&mutex);
+ return 0;
+ }
int sent = -1;
sent = send(clientSock, &len, sizeof(len), 0);
if (sent != sizeof(len)) {