00001 #include "common/utilities.h" 00002 00003 #include "platform_config.h" 00004 00005 #include "common/gxlowmem.h" 00006 00007 #include <glib.h> 00008 #include <glib/gprintf.h> 00009 00010 #if defined(__EPOC32__) && __HAS_THREAD_STACK_INFO__ 00011 // This functionality is inspired by RLogMan. 00012 EXTERN_C char* get_stack_info_string() 00013 { 00014 // Seeing as we are dealing with TUint32 values, converting these to 00015 // Python integers is non-trivial, as Py_BuildValue does not take 00016 // unsigned int values. So we better calculate values that ought to 00017 // fit into a signed integer. 00018 TLinAddr sp = 0; // TLinAddr == TUint32, TLinAddr in v9-up 00019 sp = (TLinAddr)&sp; 00020 RThread thread; 00021 TThreadStackInfo threadStackInfo; 00022 thread.StackInfo(threadStackInfo); 00023 TUint32 cFree = sp - threadStackInfo.iLimit; 00024 TUint32 cUsed = threadStackInfo.iBase - sp; 00025 TUint32 cTotal = threadStackInfo.iBase - threadStackInfo.iLimit; 00026 00027 gchar* s; 00028 TRAP_OOM_VALUE(NULL, 00029 s = g_strdup_printf("stack free:%u used:%u total:%u", 00030 static_cast<unsigned int>(cFree), 00031 static_cast<unsigned int>(cUsed), 00032 static_cast<unsigned int>(cTotal))); 00033 return s; 00034 00035 } 00036 #else 00037 EXTERN_C char* get_stack_info_string() 00038 { 00039 return gx_strdup("<stack info unavailable>"); 00040 } 00041 #endif
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:57 2011 by Doxygen 1.6.1