28 #if defined(_WIN32) || defined(_WIN64) 29 #define snprintf _snprintf 42 #define MAX_STACK_DEPTH 50 43 #define MAX_FUNCTION_NAME_LENGTH 30 44 #define MAX_THREADS 255 63 #if !defined(NOSTACKTRACE) 69 #if defined(_WIN32) || defined(_WIN64) 88 if (threads[i].
id == curid)
90 my_thread = &threads[i];
95 if (my_thread == NULL && create && thread_count <
MAX_THREADS)
98 my_thread->
id = curid;
103 return my_thread != NULL;
111 if (trace_level != -1)
130 Log(
LOG_FATAL, -1,
"Minimum stack depth exceeded for thread %lu", my_thread->
id);
133 if (trace_level != -1)
156 if (cur_thread->
id > 0)
160 fprintf(file,
"=========== Start of stack trace for thread %lu ==========\n", (
unsigned long)cur_thread->
id);
167 fprintf(file,
"=========== End of stack trace for thread %lu ==========\n\n", (
unsigned long)cur_thread->
id);
170 if (file != stdout && file != stderr && file != NULL)
186 if (cur_thread->
id == threadid)
193 curpos += snprintf(&buf[curpos], bufsize - curpos -1,
196 curpos += snprintf(&buf[curpos], bufsize - curpos -1,
198 if (buf[--curpos] ==
'\n')
void StackTrace_exit(const char *name, int line, void *rc, enum LOG_LEVELS trace_level)
stackEntry callstack[MAX_STACK_DEPTH]
int Thread_lock_mutex(mutex_type mutex)
void StackTrace_entry(const char *name, int line, enum LOG_LEVELS trace_level)
char * StackTrace_get(thread_id_type threadid, char *buf, int bufsize)
static mutex_type stack_mutex
static pthread_mutex_t stack_mutex_store
int Thread_unlock_mutex(mutex_type mutex)
#define MAX_FUNCTION_NAME_LENGTH
void Log(enum LOG_LEVELS log_level, int msgno, const char *format,...)
void Log_stackTrace(enum LOG_LEVELS log_level, int msgno, int thread_id, int current_depth, const char *name, int line, int *rc)
static threadEntry * my_thread
thread_id_type Thread_getid(void)
void StackTrace_printStack(FILE *dest)
char name[MAX_FUNCTION_NAME_LENGTH]
static threadEntry threads[MAX_THREADS]