Dynamic debug step 1

This commit is contained in:
Edouard Dupin 2012-05-13 19:04:57 +02:00
parent 4cba690678
commit 43793efc7c
5 changed files with 282 additions and 164 deletions

View File

@ -32,54 +32,23 @@
void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName, const char* libName); void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName, const char* libName);
void TOOLS_DisplayTime(void); void TOOLS_DisplayTime(void);
//regular colors
#define ETK_BASH_COLOR_BLACK "\e[0;30m"
#define ETK_BASH_COLOR_RED "\e[0;31m"
#define ETK_BASH_COLOR_GREEN "\e[0;32m"
#define ETK_BASH_COLOR_YELLOW "\e[0;33m"
#define ETK_BASH_COLOR_BLUE "\e[0;34m"
#define ETK_BASH_COLOR_MAGENTA "\e[0;35m"
#define ETK_BASH_COLOR_CYAN "\e[0;36m"
#define ETK_BASH_COLOR_WHITE "\e[0;37m"
//emphasized (bolded) colors
#define ETK_BASH_COLOR_BOLD_BLACK "\e[1;30m"
#define ETK_BASH_COLOR_BOLD_RED "\e[1;31m"
#define ETK_BASH_COLOR_BOLD_GREEN "\e[1;32m"
#define ETK_BASH_COLOR_BOLD_YELLOW "\e[1;33m"
#define ETK_BASH_COLOR_BOLD_BLUE "\e[1;34m"
#define ETK_BASH_COLOR_BOLD_MAGENTA "\e[1;35m"
#define ETK_BASH_COLOR_BOLD_CYAN "\e[1;36m"
#define ETK_BASH_COLOR_BOLD_WHITE "\e[1;37m"
//background colors
#define ETK_BASH_COLOR_BG_BLACK "\e[40m"
#define ETK_BASH_COLOR_BG_RED "\e[41m"
#define ETK_BASH_COLOR_BG_GREEN "\e[42m"
#define ETK_BASH_COLOR_BG_YELLOW "\e[43m"
#define ETK_BASH_COLOR_BG_BLUE "\e[44m"
#define ETK_BASH_COLOR_BG_MAGENTA "\e[45m"
#define ETK_BASH_COLOR_BG_CYAN "\e[46m"
#define ETK_BASH_COLOR_BG_WHITE "\e[47m"
// Return to the normal color setings
#define ETK_BASH_COLOR_NORMAL "\e[0m"
//go to the Top of bash
#define ETK_BASH_GO_TOP "\e[0;0f"
#undef __class__ #undef __class__
#define __class__ (NULL) #define __class__ (NULL)
#define ETK_DBG_COMMON(libName, color, info, data) do { \ #define ETK_DBG_COMMON(libName, info, data) do { \
etk::cout << etk::cstart << color; \ etk::cout << etk::cstart << info; \
TOOLS_DisplayTime(); \ TOOLS_DisplayTime(); \
TOOLS_DisplayFuncName(__LINE__, __class__, __func__, libName); \ TOOLS_DisplayFuncName(__LINE__, __class__, __func__, libName); \
etk::cout << "[" << info << "] " << data; \ etk::cout << data; \
etk::cout << ETK_BASH_COLOR_NORMAL <<etk::endl; \ etk::cout <<etk::endl; \
}while(0) }while(0)
#define ETK_CRITICAL(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_BOLD_RED, 'C', data) #define ETK_CRITICAL(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_CRITICAL, data)
#define ETK_WARNING(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_MAGENTA, 'W', data) #define ETK_ERROR(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_ERROR, data)
#define ETK_ERROR(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_BOLD_RED, 'E', data) #define ETK_WARNING(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_WARNING, data)
#define ETK_INFO(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_CYAN, 'I', data) #define ETK_INFO(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_INFO, data)
#define ETK_DEBUG(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_YELLOW, 'D', data) #define ETK_DEBUG(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_DEBUG, data)
#define ETK_VERBOSE(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_WHITE, 'V', data) #define ETK_VERBOSE(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_VERBOSE, data)
#define ETK_ASSERT(libName, cond, data) do { \ #define ETK_ASSERT(libName, cond, data) do { \
if (!(cond)) { \ if (!(cond)) { \
ETK_CRITICAL(libName, data); \ ETK_CRITICAL(libName, data); \

View File

@ -115,10 +115,15 @@ void etk::InitDefaultFolder(const char * applName)
baseFolderCache += baseApplName; baseFolderCache += baseApplName;
baseFolderCache += "/"; baseFolderCache += "/";
#endif #endif
TK_INFO("baseFolderHome : \"" << baseFolderHome << "\""); #ifdef MODE_RELEASE
TK_INFO("baseFolderData : \"" << baseFolderData << "\""); if (strncmp("ewolApplNoName",applName, 256) != 0) {
TK_INFO("baseFolderDataUser : \"" << baseFolderDataUser << "\""); // start log
TK_INFO("baseFolderCache : \"" << baseFolderCache << "\""); }
#endif
TK_ERROR("baseFolderHome : \"" << baseFolderHome << "\"");
TK_ERROR("baseFolderData : \"" << baseFolderData << "\"");
TK_ERROR("baseFolderDataUser : \"" << baseFolderDataUser << "\"");
TK_ERROR("baseFolderCache : \"" << baseFolderCache << "\"");
} }
etk::UString etk::GetUserHomeFolder(void) etk::UString etk::GetUserHomeFolder(void)

View File

@ -42,129 +42,253 @@
#define MAX_LOG_SIZE (16000) #define MAX_LOG_SIZE (16000)
#define MAX_LOG_SIZE_TMP (512) #define MAX_LOG_SIZE_TMP (512)
//regular colors
#define ETK_BASH_COLOR_BLACK "\e[0;30m"
#define ETK_BASH_COLOR_RED "\e[0;31m"
#define ETK_BASH_COLOR_GREEN "\e[0;32m"
#define ETK_BASH_COLOR_YELLOW "\e[0;33m"
#define ETK_BASH_COLOR_BLUE "\e[0;34m"
#define ETK_BASH_COLOR_MAGENTA "\e[0;35m"
#define ETK_BASH_COLOR_CYAN "\e[0;36m"
#define ETK_BASH_COLOR_WHITE "\e[0;37m"
//emphasized (bolded) colors
#define ETK_BASH_COLOR_BOLD_BLACK "\e[1;30m"
#define ETK_BASH_COLOR_BOLD_RED "\e[1;31m"
#define ETK_BASH_COLOR_BOLD_GREEN "\e[1;32m"
#define ETK_BASH_COLOR_BOLD_YELLOW "\e[1;33m"
#define ETK_BASH_COLOR_BOLD_BLUE "\e[1;34m"
#define ETK_BASH_COLOR_BOLD_MAGENTA "\e[1;35m"
#define ETK_BASH_COLOR_BOLD_CYAN "\e[1;36m"
#define ETK_BASH_COLOR_BOLD_WHITE "\e[1;37m"
//background colors
#define ETK_BASH_COLOR_BG_BLACK "\e[40m"
#define ETK_BASH_COLOR_BG_RED "\e[41m"
#define ETK_BASH_COLOR_BG_GREEN "\e[42m"
#define ETK_BASH_COLOR_BG_YELLOW "\e[43m"
#define ETK_BASH_COLOR_BG_BLUE "\e[44m"
#define ETK_BASH_COLOR_BG_MAGENTA "\e[45m"
#define ETK_BASH_COLOR_BG_CYAN "\e[46m"
#define ETK_BASH_COLOR_BG_WHITE "\e[47m"
// Return to the normal color setings
#define ETK_BASH_COLOR_NORMAL "\e[0m"
//go to the Top of bash
#define ETK_BASH_GO_TOP "\e[0;0f"
namespace etk{ namespace etk{
class CEndl{}; class CEndl{};
class CHex{}; class CHex{};
class CStart{}; class CStart{};
typedef enum {
LOG_LEVEL_NONE,
LOG_LEVEL_CRITICAL,
LOG_LEVEL_ERROR,
LOG_LEVEL_WARNING,
LOG_LEVEL_INFO,
LOG_LEVEL_DEBUG,
LOG_LEVEL_VERBOSE
} logLevel_te;
class CCout{ class CCout{
private: private:
bool hex; bool hex;
logLevel_te m_requestedLevel;
bool m_writing;
char m_tmpChar[MAX_LOG_SIZE+1];
char tmp[MAX_LOG_SIZE_TMP];
pthread_mutex_t m_mutex;
public: public:
private: CCout(){
char m_tmpChar[MAX_LOG_SIZE+1]; hex=false;
char tmp[MAX_LOG_SIZE_TMP]; m_writing = true;
pthread_mutex_t m_mutex; m_requestedLevel = LOG_LEVEL_ERROR;
public: memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char));
CCout(){ pthread_mutex_init(&m_mutex, NULL);
hex=false; };
memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char)); ~CCout() {
pthread_mutex_init(&m_mutex, NULL); pthread_mutex_destroy(&m_mutex);
}; };
~CCout() {
pthread_mutex_destroy(&m_mutex);
};
CCout& operator << (int t) { CCout& operator << (int t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t); if (true == m_writing) {
strncat(m_tmpChar, tmp, MAX_LOG_SIZE); snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t);
return *this; strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
} }
CCout& operator << (unsigned int t) { return *this;
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
/*
CCout& operator << (uniChar_t t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
*/
CCout& operator << (long t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (long long t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (double t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (float t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (char * t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (const char * t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (char t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (bool t) {
if (t) {
strncat(m_tmpChar, "true", MAX_LOG_SIZE);
} else {
strncat(m_tmpChar, "false", MAX_LOG_SIZE);
} }
return *this; CCout& operator << (unsigned int t) {
} if (true == m_writing) {
CCout& operator << (coord2D_ts t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f)", t.x, t.y); strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE); }
return *this; return *this;
} }
CCout& operator << (coord3D_ts t) { /*
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f,%f)", t.x, t.y, t.z); CCout& operator << (uniChar_t t) {
strncat(m_tmpChar, tmp, MAX_LOG_SIZE); if (true == m_writing) {
return *this; snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t);
} strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
CCout& operator << (texCoord_ts t) { }
snprintf(tmp, MAX_LOG_SIZE_TMP, "{%f,%f}", t.u, t.v); return *this;
strncat(m_tmpChar, tmp, MAX_LOG_SIZE); }
return *this; */
} CCout& operator << (long t) {
CCout& operator << (color_ts t) { if (true == m_writing) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "#%02X%02X%02X%02X", t.red, t.green, t.blue, t.alpha); snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE); strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this; }
} return *this;
CCout& operator << (clipping_ts t) { }
snprintf(tmp, MAX_LOG_SIZE_TMP, "origin=(%f,%f) size=(%f,%f)", t.x, t.y, t.w, t.h); CCout& operator << (long long t) {
strncat(m_tmpChar, tmp, MAX_LOG_SIZE); if (true == m_writing) {
return *this; snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t);
} strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
CCout& operator << (CStart ccc) { }
pthread_mutex_lock(&m_mutex); return *this;
return *this; }
} CCout& operator << (double t) {
CCout& operator << (etk::CEndl t) { if (true == m_writing) {
strncat(m_tmpChar, "\n", MAX_LOG_SIZE); snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t);
m_tmpChar[MAX_LOG_SIZE] = '\0'; strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (float t) {
if (true == m_writing) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (char * t) {
if (true == m_writing) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (const char * t) {
if (true == m_writing) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (char t) {
if (true == m_writing) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (bool t) {
if (true == m_writing) {
if (t) {
strncat(m_tmpChar, "true", MAX_LOG_SIZE);
} else {
strncat(m_tmpChar, "false", MAX_LOG_SIZE);
}
}
return *this;
}
CCout& operator << (coord2D_ts t) {
if (true == m_writing) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f)", t.x, t.y);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (coord3D_ts t) {
if (true == m_writing) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f,%f)", t.x, t.y, t.z);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (texCoord_ts t) {
if (true == m_writing) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "{%f,%f}", t.u, t.v);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (color_ts t) {
if (true == m_writing) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "#%02X%02X%02X%02X", t.red, t.green, t.blue, t.alpha);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (clipping_ts t) {
if (true == m_writing) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "origin=(%f,%f) size=(%f,%f)", t.x, t.y, t.w, t.h);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (CStart ccc) {
pthread_mutex_lock(&m_mutex);
return *this;
}
void SetLevel(logLevel_te ccc) {
m_requestedLevel = ccc;
}
CCout& operator << (logLevel_te ccc) {
if (ccc <= m_requestedLevel) {
m_writing = true;
} else {
m_writing = false;
}
if (true == m_writing) {
switch (ccc)
{
case LOG_LEVEL_CRITICAL:
strncat(m_tmpChar, ETK_BASH_COLOR_BOLD_RED, MAX_LOG_SIZE);
strncat(m_tmpChar, "[C]", MAX_LOG_SIZE);
break;
case LOG_LEVEL_ERROR:
strncat(m_tmpChar, ETK_BASH_COLOR_MAGENTA, MAX_LOG_SIZE);
strncat(m_tmpChar, "[E]", MAX_LOG_SIZE);
break;
case LOG_LEVEL_WARNING:
strncat(m_tmpChar, ETK_BASH_COLOR_BOLD_RED, MAX_LOG_SIZE);
strncat(m_tmpChar, "[W]", MAX_LOG_SIZE);
break;
case LOG_LEVEL_INFO:
strncat(m_tmpChar, ETK_BASH_COLOR_CYAN, MAX_LOG_SIZE);
strncat(m_tmpChar, "[I]", MAX_LOG_SIZE);
break;
case LOG_LEVEL_DEBUG:
strncat(m_tmpChar, ETK_BASH_COLOR_YELLOW, MAX_LOG_SIZE);
strncat(m_tmpChar, "[D]", MAX_LOG_SIZE);
break;
case LOG_LEVEL_VERBOSE:
strncat(m_tmpChar, ETK_BASH_COLOR_WHITE, MAX_LOG_SIZE);
strncat(m_tmpChar, "[V]", MAX_LOG_SIZE);
break;
default:
strncat(m_tmpChar, "[?]", MAX_LOG_SIZE);
break;
}
}
return *this;
}
CCout& operator << (etk::CEndl t) {
if (true == m_writing) {
strncat(m_tmpChar, ETK_BASH_COLOR_NORMAL, MAX_LOG_SIZE);
strncat(m_tmpChar, "\n", MAX_LOG_SIZE);
m_tmpChar[MAX_LOG_SIZE] = '\0';
#if defined(__PLATFORM__Android) #if defined(__PLATFORM__Android)
LOGI("%s", m_tmpChar); LOGI("%s", m_tmpChar);
#else #else
printf("%s", m_tmpChar); printf("%s", m_tmpChar);
#endif #endif
memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char)); memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char));
pthread_mutex_unlock(&m_mutex); }
return *this; pthread_mutex_unlock(&m_mutex);
} return *this;
}
}; };
extern etk::CCout cout; extern etk::CCout cout;
extern etk::CEndl endl; extern etk::CEndl endl;

View File

@ -31,9 +31,9 @@ LOCAL_CFLAGS := -D__PLATFORM__Linux \
else else
LOCAL_CFLAGS := -D__PLATFORM__Linux \ LOCAL_CFLAGS := -D__PLATFORM__Linux \
-Wno-write-strings \ -Wno-write-strings \
-DETK_DEBUG_LEVEL=1 \ -DETK_DEBUG_LEVEL=3 \
-DEWOL_DEBUG_LEVEL=1 \ -DEWOL_DEBUG_LEVEL=3 \
-DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-debug\"" \ -DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-release\"" \
-DVERSION_BUILD_TIME="\"pasd_heure\"" \ -DVERSION_BUILD_TIME="\"pasd_heure\"" \
-DEWOL_USE_FREE_TYPE -DEWOL_USE_FREE_TYPE

View File

@ -473,8 +473,10 @@ void X11_Run(void)
{ {
case ClientMessage: case ClientMessage:
{ {
EWOL_INFO("Receive : ClientMessage");
Atom atom = XInternAtom(m_display, "WM_DELETE_WINDOW", false); Atom atom = XInternAtom(m_display, "WM_DELETE_WINDOW", false);
if((int64_t)atom == (int64_t)event.xclient.data.l[0]) { if((int64_t)atom == (int64_t)event.xclient.data.l[0]) {
EWOL_INFO(" ==> Kill Requested ...");
if (NULL != gui_uniqueWindows) { if (NULL != gui_uniqueWindows) {
gui_uniqueWindows->SysOnKill(); gui_uniqueWindows->SysOnKill();
} }
@ -881,7 +883,9 @@ void X11_Run(void)
EWOL_DEBUG("X11 event : " << event.type << " = \"???\""); EWOL_DEBUG("X11 event : " << event.type << " = \"???\"");
} }
} }
EWOL_NativeRender(); if(true == m_run) {
EWOL_NativeRender();
}
} }
}; };
@ -1071,9 +1075,25 @@ int main(int argc, char *argv[])
{ {
for( int32_t i=1 ; i<argc; i++) { for( int32_t i=1 ; i<argc; i++) {
EWOL_INFO("CmdLine : \"" << argv[i] << "\"" ); EWOL_INFO("CmdLine : \"" << argv[i] << "\"" );
etk::UString* tmpString = new etk::UString(argv[i]); if (0==strncmp("-l0", argv[i], 256)) {
if (NULL != tmpString) { etk::cout.SetLevel(etk::LOG_LEVEL_NONE);
listArgs.PushBack(tmpString); } else if (0==strncmp("-l1", argv[i], 256)) {
etk::cout.SetLevel(etk::LOG_LEVEL_CRITICAL);
} else if (0==strncmp("-l2", argv[i], 256)) {
etk::cout.SetLevel(etk::LOG_LEVEL_ERROR);
} else if (0==strncmp("-l3", argv[i], 256)) {
etk::cout.SetLevel(etk::LOG_LEVEL_WARNING);
} else if (0==strncmp("-l4", argv[i], 256)) {
etk::cout.SetLevel(etk::LOG_LEVEL_INFO);
} else if (0==strncmp("-l5", argv[i], 256)) {
etk::cout.SetLevel(etk::LOG_LEVEL_DEBUG);
} else if (0==strncmp("-l6", argv[i], 256)) {
etk::cout.SetLevel(etk::LOG_LEVEL_VERBOSE);
} else {
etk::UString* tmpString = new etk::UString(argv[i]);
if (NULL != tmpString) {
listArgs.PushBack(tmpString);
}
} }
} }
// start X11 thread ... // start X11 thread ...