Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c7ec152b authored by David Li's avatar David Li Committed by Android (Google) Code Review
Browse files

Merge "Initial commit of GLESv2 debugger server"

parents c740f330 2f5a6557
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -13,8 +13,8 @@ LOCAL_SRC_FILES:= \
	EGL/hooks.cpp 	       \
	EGL/Loader.cpp 	       \
#

LOCAL_SHARED_LIBRARIES += libcutils libutils
LOCAL_STATIC_LIBRARIES += libGLESv2_dbg libprotobuf-cpp-2.3.0-lite
LOCAL_SHARED_LIBRARIES += libcutils libutils libstlport
LOCAL_LDLIBS := -lpthread -ldl
LOCAL_MODULE:= libEGL

@@ -164,3 +164,6 @@ LOCAL_LDLIBS := -lpthread -ldl
LOCAL_MODULE:= libETC1

include $(BUILD_SHARED_LIBRARY)

include $(call all-makefiles-under,$(LOCAL_PATH))
+2 −0
Original line number Diff line number Diff line
@@ -114,6 +114,8 @@ Loader::Loader()

Loader::~Loader()
{
    extern void StopDebugServer();
    StopDebugServer();
}

const char* Loader::getTag(int dpy, int impl)
+28 −3
Original line number Diff line number Diff line
@@ -296,9 +296,9 @@ EGLAPI pthread_key_t gGLTraceKey = -1;

// ----------------------------------------------------------------------------

static int gEGLTraceLevel;
static int gEGLTraceLevel, gEGLDebugLevel;
static int gEGLApplicationTraceLevel;
extern EGLAPI gl_hooks_t gHooksTrace;
extern EGLAPI gl_hooks_t gHooksTrace, gHooksDebug;

static inline void setGlTraceThreadSpecific(gl_hooks_t const *value) {
    pthread_setspecific(gGLTraceKey, value);
@@ -314,12 +314,37 @@ static void initEglTraceLevel() {
    int propertyLevel = atoi(value);
    int applicationLevel = gEGLApplicationTraceLevel;
    gEGLTraceLevel = propertyLevel > applicationLevel ? propertyLevel : applicationLevel;
    
    property_get("debug.egl.debug_proc", value, "");
    long pid = getpid();
    char procPath[128] = {};
    sprintf(procPath, "/proc/%ld/cmdline", pid);
    FILE * file = fopen(procPath, "r");
    if (file)
    {
        char cmdline[256] = {};
        if (fgets(cmdline, sizeof(cmdline) - 1, file))
        {
            LOGD("\n*\n*\n* initEglTraceLevel cmdline='%s' \n*\n*", cmdline);
            if (!strcmp(value, cmdline))
                gEGLDebugLevel = 1;
        }    
        fclose(file);
    }
    
    extern void StartDebugServer();
    if (gEGLDebugLevel > 0)
        StartDebugServer();
}

static void setGLHooksThreadSpecific(gl_hooks_t const *value) {
    if (gEGLTraceLevel > 0) {
        setGlTraceThreadSpecific(value);
        setGlThreadSpecific(&gHooksTrace);
    } else if (gEGLDebugLevel > 0) {
        setGlTraceThreadSpecific(value);
        setGlThreadSpecific(&gHooksDebug);
        LOGD("\n* setGLHooksThreadSpecific gHooksDebug");
    } else {
        setGlThreadSpecific(value);
    }
@@ -1597,7 +1622,7 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
                    cnx->hooks[GLESv1_INDEX]->ext.extensions[slot] =
                    cnx->hooks[GLESv2_INDEX]->ext.extensions[slot] =
#if EGL_TRACE
                    gHooksTrace.ext.extensions[slot] =
                    gHooksDebug.ext.extensions[slot] = gHooksTrace.ext.extensions[slot] =
#endif
                            cnx->egl.eglGetProcAddress(procname);
                }
+44 −2
Original line number Diff line number Diff line
@@ -333,11 +333,11 @@ static _type Tracing_ ## _api _args { \
extern "C" {
#include "../trace.in"
}

#undef TRACE_GL_VOID
#undef TRACE_GL

#define GL_ENTRY(_r, _api, ...) Tracing_ ## _api,

EGLAPI gl_hooks_t gHooksTrace = {
    {
        #include "entries.in"
@@ -348,6 +348,48 @@ EGLAPI gl_hooks_t gHooksTrace = {
};
#undef GL_ENTRY


#undef TRACE_GL_VOID
#undef TRACE_GL

// define the ES 1.0 Debug_gl* functions as Tracing_gl functions
#define TRACE_GL_VOID(_api, _args, _argList, ...)                         \
static void Debug_ ## _api _args {                                      \
    TraceGL(#_api, __VA_ARGS__);                                          \
    gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl;  \
    _c->_api _argList;                                                    \
}

#define TRACE_GL(_type, _api, _args, _argList, ...)                       \
static _type Debug_ ## _api _args {                                     \
    TraceGL(#_api, __VA_ARGS__);                                        \
    gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl;  \
    return _c->_api _argList;                                             \
}

extern "C" {
#include "../debug.in"
}

#undef TRACE_GL_VOID
#undef TRACE_GL

// declare all Debug_gl* functions
#define GL_ENTRY(_r, _api, ...) _r Debug_##_api ( __VA_ARGS__ );
#include "../GLES2_dbg/include/glesv2_dbg.h"
#undef GL_ENTRY

#define GL_ENTRY(_r, _api, ...) Debug_ ## _api,
EGLAPI gl_hooks_t gHooksDebug = {
    {
        #include "entries.in"
    },
    {
        {0}
    }
};
#undef GL_ENTRY

// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------
+46 −0
Original line number Diff line number Diff line
LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SRC_FILES := \
    src/DebuggerMessage.pb.cpp \
    src/api.cpp \
    src/server.cpp \
    src/shader.cpp \
    src/texture.cpp

LOCAL_C_INCLUDES :=	\
    $(LOCAL_PATH) \
    $(LOCAL_PATH)/../ \
    external/stlport/stlport \
    external/protobuf/src \
    bionic

LOCAL_SHARED_LIBRARIES := libstlport libcutils libutils
LOCAL_LDLIBS := -lpthread

#LOCAL_CFLAGS += -O0 -g -DDEBUG -UNDEBUG
LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI

ifeq ($(TARGET_ARCH),arm)
	LOCAL_CFLAGS += -fstrict-aliasing
endif

ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
    LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
endif

ifneq ($(TARGET_SIMULATOR),true)
    # we need to access the private Bionic header <bionic_tls.h>
    # on ARM platforms, we need to mirror the ARCH_ARM_HAVE_TLS_REGISTER
    # behavior from the bionic Android.mk file
    ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true)
        LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
    endif
    LOCAL_C_INCLUDES += bionic/libc/private
endif

LOCAL_MODULE:= libGLESv2_dbg
LOCAL_MODULE_TAGS := optional

include $(BUILD_STATIC_LIBRARY)
Loading