From: José Fonseca Date: Thu, 27 Oct 2011 07:10:56 +0000 (+0100) Subject: Switch os functions to camelcase. X-Git-Tag: 2.0_alpha^2~551 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=559d5349e8039871ff14509a26c54c980c8e2cc7;p=tools%2Fapitrace.git Switch os functions to camelcase. --- diff --git a/cgltrace.py b/cgltrace.py index 0fac46d..b6a6fd0 100644 --- a/cgltrace.py +++ b/cgltrace.py @@ -106,8 +106,8 @@ void * __libgl_sym(const char *symbol) } if (!libgl_handle) { - os::DebugMessage("apitrace: error: couldn't load %s\n", libgl_filename); - os::Abort(); + os::log("apitrace: error: couldn't load %s\n", libgl_filename); + os::abort(); return NULL; } } @@ -115,8 +115,8 @@ void * __libgl_sym(const char *symbol) result = dlsym(libgl_handle, symbol); if (result == dlsym(RTLD_SELF, symbol)) { - os::DebugMessage("apitrace: error: symbol lookup recursion\n"); - os::Abort(); + os::log("apitrace: error: symbol lookup recursion\n"); + os::abort(); return NULL; } diff --git a/common/os.hpp b/common/os.hpp index 24a38ef..02625c2 100644 --- a/common/os.hpp +++ b/common/os.hpp @@ -52,14 +52,14 @@ namespace os { -void AcquireMutex(void); +void acquireMutex(void); -void ReleaseMutex(void); +void releaseMutex(void); -bool GetProcessName(char *str, size_t size); -bool GetCurrentDir(char *str, size_t size); +bool getProcessName(char *str, size_t size); +bool getCurrentDir(char *str, size_t size); -void DebugMessage(const char *format, ...) +void log(const char *format, ...) #ifdef __GNUC__ __attribute__ ((format (printf, 1, 2))) #endif @@ -86,12 +86,12 @@ void DebugMessage(const char *format, ...) /** * Get the current time in microseconds from an unknown base. */ -long long GetTime(void); +long long getTime(void); -void Abort(void); +void abort(void); -void SetExceptionCallback(void (*callback)(void)); -void ResetExceptionCallback(void); +void setExceptionCallback(void (*callback)(void)); +void resetExceptionCallback(void); } /* namespace os */ diff --git a/common/os_posix.cpp b/common/os_posix.cpp index 9271e88..e797220 100644 --- a/common/os_posix.cpp +++ b/common/os_posix.cpp @@ -51,21 +51,21 @@ mutex = PTHREAD_MUTEX_INITIALIZER; void -AcquireMutex(void) +acquireMutex(void) { pthread_mutex_lock(&mutex); } void -ReleaseMutex(void) +releaseMutex(void) { pthread_mutex_unlock(&mutex); } bool -GetProcessName(char *str, size_t size) +getProcessName(char *str, size_t size) { char szProcessPath[PATH_MAX + 1]; char *lpProcessName; @@ -107,7 +107,7 @@ GetProcessName(char *str, size_t size) } bool -GetCurrentDir(char *str, size_t size) +getCurrentDir(char *str, size_t size) { char *ret; ret = getcwd(str, size); @@ -116,7 +116,7 @@ GetCurrentDir(char *str, size_t size) } void -DebugMessage(const char *format, ...) +log(const char *format, ...) { va_list ap; va_start(ap, format); @@ -125,7 +125,8 @@ DebugMessage(const char *format, ...) va_end(ap); } -long long GetTime(void) +long long +getTime(void) { struct timeval tv; gettimeofday(&tv, NULL); @@ -133,7 +134,7 @@ long long GetTime(void) } void -Abort(void) +abort(void) { exit(0); } @@ -151,14 +152,15 @@ struct sigaction old_actions[NUM_SIGNALS]; * - http://sourceware.org/git/?p=glibc.git;a=blob;f=debug/segfault.c * - http://ggi.cvs.sourceforge.net/viewvc/ggi/ggi-core/libgg/gg/cleanup.c?view=markup */ -static void signal_handler(int sig, siginfo_t *info, void *context) +static void +signalHandler(int sig, siginfo_t *info, void *context) { static int recursion_count = 0; - fprintf(stderr, "signal_handler: sig = %i\n", sig); + fprintf(stderr, "apitrace: warning: caught signal %i\n", sig); if (recursion_count) { - fprintf(stderr, "recursion with sig %i\n", sig); + fprintf(stderr, "apitrace: warning: recursion handling signal %i\n", sig); } else { if (gCallback) { ++recursion_count; @@ -170,7 +172,7 @@ static void signal_handler(int sig, siginfo_t *info, void *context) struct sigaction *old_action; if (sig >= NUM_SIGNALS) { /* This should never happen */ - fprintf(stderr, "Unexpected signal %i\n", sig); + fprintf(stderr, "error: unexpected signal %i\n", sig); raise(SIGKILL); } old_action = &old_actions[sig]; @@ -180,7 +182,7 @@ static void signal_handler(int sig, siginfo_t *info, void *context) old_action->sa_sigaction(sig, info, context); } else { if (old_action->sa_handler == SIG_DFL) { - fprintf(stderr, "taking default action for signal %i\n", sig); + fprintf(stderr, "apitrace: info: taking default action for signal %i\n", sig); #if 1 struct sigaction dfl_action; @@ -203,14 +205,14 @@ static void signal_handler(int sig, siginfo_t *info, void *context) } void -SetExceptionCallback(void (*callback)(void)) +setExceptionCallback(void (*callback)(void)) { assert(!gCallback); if (!gCallback) { gCallback = callback; struct sigaction new_action; - new_action.sa_sigaction = signal_handler; + new_action.sa_sigaction = signalHandler; sigemptyset(&new_action.sa_mask); new_action.sa_flags = SA_SIGINFO | SA_RESTART; @@ -227,7 +229,7 @@ SetExceptionCallback(void (*callback)(void)) } void -ResetExceptionCallback(void) +resetExceptionCallback(void) { gCallback = NULL; } diff --git a/common/os_win32.cpp b/common/os_win32.cpp index 4e48da5..27b8c0a 100644 --- a/common/os_win32.cpp +++ b/common/os_win32.cpp @@ -39,27 +39,27 @@ namespace os { * Trick from http://locklessinc.com/articles/pthreads_on_windows/ */ static CRITICAL_SECTION -CriticalSection = { +criticalSection = { (PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0 }; void -AcquireMutex(void) +acquireMutex(void) { - EnterCriticalSection(&CriticalSection); + EnterCriticalSection(&criticalSection); } void -ReleaseMutex(void) +releaseMutex(void) { - LeaveCriticalSection(&CriticalSection); + LeaveCriticalSection(&criticalSection); } bool -GetProcessName(char *str, size_t size) +getProcessName(char *str, size_t size) { char szProcessPath[PATH_MAX]; char *lpProcessName; @@ -81,7 +81,7 @@ GetProcessName(char *str, size_t size) } bool -GetCurrentDir(char *str, size_t size) +getCurrentDir(char *str, size_t size) { DWORD ret; ret = GetCurrentDirectoryA(size, str); @@ -90,7 +90,7 @@ GetCurrentDir(char *str, size_t size) } void -DebugMessage(const char *format, ...) +log(const char *format, ...) { char buf[4096]; @@ -115,7 +115,8 @@ DebugMessage(const char *format, ...) #endif } -long long GetTime(void) +long long +getTime(void) { static LARGE_INTEGER frequency; LARGE_INTEGER counter; @@ -126,7 +127,7 @@ long long GetTime(void) } void -Abort(void) +abort(void) { #ifndef NDEBUG DebugBreak(); @@ -139,7 +140,8 @@ Abort(void) static LPTOP_LEVEL_EXCEPTION_FILTER prevExceptionFilter = NULL; static void (*gCallback)(void) = NULL; -static LONG WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo) +static LONG WINAPI +unhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo) { if (gCallback) { gCallback(); @@ -153,7 +155,7 @@ static LONG WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo) } void -SetExceptionCallback(void (*callback)(void)) +setExceptionCallback(void (*callback)(void)) { assert(!gCallback); @@ -167,12 +169,12 @@ SetExceptionCallback(void (*callback)(void)) * handler in certain circumnstances. See * http://www.codeproject.com/KB/winsdk/crash_hook.aspx */ - prevExceptionFilter = SetUnhandledExceptionFilter(UnhandledExceptionFilter); + prevExceptionFilter = SetUnhandledExceptionFilter(unhandledExceptionFilter); } } void -ResetExceptionCallback(void) +resetExceptionCallback(void) { gCallback = NULL; } diff --git a/common/trace_writer.cpp b/common/trace_writer.cpp index 84acfd8..897c7b1 100644 --- a/common/trace_writer.cpp +++ b/common/trace_writer.cpp @@ -275,7 +275,7 @@ void Writer::writeBitmask(const BitmaskSig *sig, unsigned long long value) { _writeUInt(sig->num_flags); for (unsigned i = 0; i < sig->num_flags; ++i) { if (i != 0 && sig->flags[i].value == 0) { - os::DebugMessage("apitrace: warning: sig %s is zero but is not first flag\n", sig->flags[i].name); + os::log("apitrace: warning: sig %s is zero but is not first flag\n", sig->flags[i].name); } _writeString(sig->flags[i].name); _writeUInt(sig->flags[i].value); diff --git a/common/trace_writer_local.cpp b/common/trace_writer_local.cpp index eb76e05..d03e1ae 100644 --- a/common/trace_writer_local.cpp +++ b/common/trace_writer_local.cpp @@ -63,12 +63,12 @@ LocalWriter::LocalWriter() : { // Install the signal handlers as early as possible, to prevent // interfering with the application's signal handling. - os::SetExceptionCallback(exceptionCallback); + os::setExceptionCallback(exceptionCallback); } LocalWriter::~LocalWriter() { - os::ResetExceptionCallback(); + os::resetExceptionCallback(); } void @@ -87,8 +87,8 @@ LocalWriter::open(void) { else { char szProcessName[PATH_MAX]; char szCurrentDir[PATH_MAX]; - os::GetProcessName(szProcessName, PATH_MAX); - os::GetCurrentDir(szCurrentDir, PATH_MAX); + os::getProcessName(szProcessName, PATH_MAX); + os::getCurrentDir(szCurrentDir, PATH_MAX); for (;;) { FILE *file; @@ -108,7 +108,7 @@ LocalWriter::open(void) { } } - os::DebugMessage("apitrace: tracing to %s\n", szFileName); + os::log("apitrace: tracing to %s\n", szFileName); Writer::open(szFileName); @@ -119,7 +119,7 @@ LocalWriter::open(void) { } unsigned LocalWriter::beginEnter(const FunctionSig *sig) { - os::AcquireMutex(); + os::acquireMutex(); ++acquired; if (!m_file->isOpened()) { @@ -132,11 +132,11 @@ unsigned LocalWriter::beginEnter(const FunctionSig *sig) { void LocalWriter::endEnter(void) { Writer::endEnter(); --acquired; - os::ReleaseMutex(); + os::releaseMutex(); } void LocalWriter::beginLeave(unsigned call) { - os::AcquireMutex(); + os::acquireMutex(); ++acquired; Writer::beginLeave(call); } @@ -144,7 +144,7 @@ void LocalWriter::beginLeave(unsigned call) { void LocalWriter::endLeave(void) { Writer::endLeave(); --acquired; - os::ReleaseMutex(); + os::releaseMutex(); } void LocalWriter::flush(void) { @@ -154,12 +154,12 @@ void LocalWriter::flush(void) { */ if (!acquired) { - os::AcquireMutex(); + os::acquireMutex(); if (m_file->isOpened()) { - os::DebugMessage("apitrace: flushing trace due to an exception\n"); + os::log("apitrace: flushing trace due to an exception\n"); m_file->flush(); } - os::ReleaseMutex(); + os::releaseMutex(); } } diff --git a/dispatch.py b/dispatch.py index bd17e0d..a2f23e9 100644 --- a/dispatch.py +++ b/dispatch.py @@ -110,7 +110,7 @@ class Dispatcher: def fail_function(self, function): if function.type is stdapi.Void or function.fail is not None: - print r' os::DebugMessage("warning: ignoring call to unavailable function %s\n", __name);' + print r' os::log("warning: ignoring call to unavailable function %s\n", __name);' if function.type is stdapi.Void: assert function.fail is None print ' return;' @@ -118,7 +118,7 @@ class Dispatcher: assert function.fail is not None print ' return %s;' % function.fail else: - print r' os::DebugMessage("error: unavailable function %s\n", __name);' - print r' os::Abort();' + print r' os::log("error: unavailable function %s\n", __name);' + print r' os::abort();' diff --git a/glretrace_main.cpp b/glretrace_main.cpp index 9def1c6..2f6d371 100644 --- a/glretrace_main.cpp +++ b/glretrace_main.cpp @@ -204,7 +204,7 @@ static void display(void) { retracer.addCallbacks(wgl_callbacks); retracer.addCallbacks(cgl_callbacks); - startTime = os::GetTime(); + startTime = os::getTime(); trace::Call *call; while ((call = parser.parse_call())) { @@ -223,7 +223,7 @@ static void display(void) { // Reached the end of trace glFlush(); - long long endTime = os::GetTime(); + long long endTime = os::getTime(); float timeInterval = (endTime - startTime) * 1.0E-6; if (retrace::verbosity >= -1) { diff --git a/glsize.hpp b/glsize.hpp index 55a3f99..00356ae 100644 --- a/glsize.hpp +++ b/glsize.hpp @@ -64,7 +64,7 @@ __gl_type_size(GLenum type) case GL_DOUBLE: return 8; default: - os::DebugMessage("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type); + os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type); return 0; } } @@ -268,7 +268,7 @@ __gl_uniform_size(GLenum type, GLenum &elemType, GLint &numElems) { numElems = 1; break; default: - os::DebugMessage("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type); + os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type); elemType = GL_NONE; numElems = 0; return; @@ -360,7 +360,7 @@ __glDrawElementsBaseVertex_maxindex(GLsizei count, GLenum type, const GLvoid *in } } } else { - os::DebugMessage("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type); + os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type); } if (__element_array_buffer) { @@ -396,13 +396,13 @@ __glDrawElementsBaseVertex_maxindex(GLsizei count, GLenum type, const GLvoid *in static inline GLuint __glDrawArraysIndirect_maxindex(const GLvoid *indirect) { - os::DebugMessage("apitrace: warning: %s: unsupported\n", __FUNCTION__); + os::log("apitrace: warning: %s: unsupported\n", __FUNCTION__); return 0; } static inline GLuint __glDrawElementsIndirect_maxindex(GLenum type, const GLvoid *indirect) { - os::DebugMessage("apitrace: warning: %s: unsupported\n", __FUNCTION__); + os::log("apitrace: warning: %s: unsupported\n", __FUNCTION__); return 0; } @@ -476,7 +476,7 @@ __glMap1d_size(GLenum target, GLint stride, GLint order) channels = 4; break; default: - os::DebugMessage("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, target); + os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, target); return 0; } @@ -516,7 +516,7 @@ __glMap2d_size(GLenum target, GLint ustride, GLint uorder, GLint vstride, GLint channels = 4; break; default: - os::DebugMessage("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, target); + os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, target); return 0; } @@ -563,7 +563,7 @@ __gl_format_channels(GLenum format) { case GL_CMYKA_EXT: return 5; default: - os::DebugMessage("apitrace: warning: %s: unexpected format GLenum 0x%04X\n", __FUNCTION__, format); + os::log("apitrace: warning: %s: unexpected format GLenum 0x%04X\n", __FUNCTION__, format); return 0; } } @@ -632,7 +632,7 @@ __gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsiz bits_per_pixel = 64; break; default: - os::DebugMessage("apitrace: warning: %s: unexpected type GLenum 0x%04X\n", __FUNCTION__, type); + os::log("apitrace: warning: %s: unexpected type GLenum 0x%04X\n", __FUNCTION__, type); bits_per_pixel = 0; break; } @@ -734,7 +734,7 @@ __glClearBuffer_size(GLenum buffer) case GL_STENCIL: return 1; default: - os::DebugMessage("apitrace: warning: %s: unexpected buffer GLenum 0x%04X\n", __FUNCTION__, buffer); + os::log("apitrace: warning: %s: unexpected buffer GLenum 0x%04X\n", __FUNCTION__, buffer); return 0; } } diff --git a/glsnapshot.cpp b/glsnapshot.cpp index 2e69062..1f95db1 100644 --- a/glsnapshot.cpp +++ b/glsnapshot.cpp @@ -160,7 +160,7 @@ getDrawableImage(void) { } } } else { - os::DebugMessage("apitrace: unexpected XImage: " + os::log("apitrace: unexpected XImage: " "bits_per_pixel = %i, " "depth = %i, " "red_mask = 0x%08lx, " @@ -208,7 +208,7 @@ void snapshot(unsigned call_no) { char filename[PATH_MAX]; snprintf(filename, sizeof filename, "%s%010u.png", snapshot_prefix, call_no); if (src->writePNG(filename)) { - os::DebugMessage("apitrace: wrote %s\n", filename); + os::log("apitrace: wrote %s\n", filename); } delete src; diff --git a/gltrace.py b/gltrace.py index a0d155e..e4dea6e 100644 --- a/gltrace.py +++ b/gltrace.py @@ -238,7 +238,7 @@ class GlTracer(Tracer): print ' case GL_%s:' % target print ' return & __%s_mapping;' % target.lower() print ' default:' - print ' os::DebugMessage("apitrace: warning: unknown buffer target 0x%04X\\n", target);' + print ' os::log("apitrace: warning: unknown buffer target 0x%04X\\n", target);' print ' return NULL;' print ' }' print '}' @@ -282,7 +282,7 @@ class GlTracer(Tracer): print ' return num_compressed_texture_formats;' print ' }' print ' default:' - print r' os::DebugMessage("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, pname);' + print r' os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, pname);' print ' return 1;' print ' }' print '}' diff --git a/glxtrace.py b/glxtrace.py index 74164e1..3e91f00 100644 --- a/glxtrace.py +++ b/glxtrace.py @@ -105,7 +105,7 @@ if __name__ == '__main__': print ' %s = (%s)procPtr;' % (pvalue, ptype) print ' return (__GLXextFuncPtr)&%s;' % (f.name,) print ' }' - print ' os::DebugMessage("apitrace: warning: unknown function \\"%s\\"\\n", (const char *)procName);' + print ' os::log("apitrace: warning: unknown function \\"%s\\"\\n", (const char *)procName);' print ' return procPtr;' print '}' print @@ -129,7 +129,7 @@ static void *__dlopen(const char *filename, int flag) if (!dlopen_ptr) { dlopen_ptr = (PFNDLOPEN)dlsym(RTLD_NEXT, "dlopen"); if (!dlopen_ptr) { - os::DebugMessage("apitrace: error: dlsym(RTLD_NEXT, \"dlopen\") failed\n"); + os::log("apitrace: error: dlsym(RTLD_NEXT, \"dlopen\") failed\n"); return NULL; } } @@ -155,7 +155,7 @@ void * dlopen(const char *filename, int flag) if (filename && handle && !libgl_filename) { if (0) { - os::DebugMessage("apitrace: warning: dlopen(\"%s\", 0x%x)\n", filename, flag); + os::log("apitrace: warning: dlopen(\"%s\", 0x%x)\n", filename, flag); } // FIXME: handle absolute paths and other versions @@ -169,10 +169,10 @@ void * dlopen(const char *filename, int flag) static int dummy = 0xdeedbeef; Dl_info info; if (dladdr(&dummy, &info)) { - os::DebugMessage("apitrace: redirecting dlopen(\"%s\", 0x%x)\n", filename, flag); + os::log("apitrace: redirecting dlopen(\"%s\", 0x%x)\n", filename, flag); handle = __dlopen(info.dli_fname, flag); } else { - os::DebugMessage("apitrace: warning: dladdr() failed\n"); + os::log("apitrace: warning: dladdr() failed\n"); } } } @@ -219,7 +219,7 @@ void * __libgl_sym(const char *symbol) libgl_handle = __dlopen(libgl_filename, RTLD_GLOBAL | RTLD_LAZY); if (!libgl_handle) { - os::DebugMessage("apitrace: error: couldn't find libGL.so\n"); + os::log("apitrace: error: couldn't find libGL.so\n"); return NULL; } } diff --git a/wgltrace.py b/wgltrace.py index ddc1f27..cf2cc97 100644 --- a/wgltrace.py +++ b/wgltrace.py @@ -53,7 +53,7 @@ class WglTracer(GlTracer): print ' %s = (%s)&%s;' % (instance, function.type, f.name); def handle_default(): - print ' os::DebugMessage("apitrace: warning: unknown function \\"%s\\"\\n", lpszProc);' + print ' os::log("apitrace: warning: unknown function \\"%s\\"\\n", lpszProc);' string_switch('lpszProc', func_dict.keys(), handle_case, handle_default) print ' }'