forked from cory/tildefriends
Fix tf_min and some crashes in trace. Wow.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4659 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
dd909bfe53
commit
e677b0ac3c
@ -5,6 +5,7 @@
|
|||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
|
#include "util.js.h"
|
||||||
|
|
||||||
#include "sqlite3.h"
|
#include "sqlite3.h"
|
||||||
#include "uv.h"
|
#include "uv.h"
|
||||||
@ -138,7 +139,7 @@ void tf_trace_counter(tf_trace_t* trace, const char* name, int argc, const char*
|
|||||||
{
|
{
|
||||||
p += snprintf(line + p, sizeof(line) - p, "\"%s\": %" PRId64 "%s", arg_names[i], arg_values[i], i == argc - 1 ? "}}," : ", ");
|
p += snprintf(line + p, sizeof(line) - p, "\"%s\": %" PRId64 "%s", arg_names[i], arg_values[i], i == argc - 1 ? "}}," : ", ");
|
||||||
}
|
}
|
||||||
|
p = tf_min(p, _countof(line));
|
||||||
trace->callback(trace, line, p, trace->user_data);
|
trace->callback(trace, line, p, trace->user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,6 +280,7 @@ static void _tf_trace_begin_tagged(tf_trace_t* trace, const char* name, void* ta
|
|||||||
int p = snprintf(line, sizeof(line), "{\"ph\": \"B\", \"pid\": %d, \"tid\": \"0x%" PRIx64 "\", \"ts\": %" PRId64 ", \"name\": \"", getpid(), (int64_t)self, _trace_ts());
|
int p = snprintf(line, sizeof(line), "{\"ph\": \"B\", \"pid\": %d, \"tid\": \"0x%" PRIx64 "\", \"ts\": %" PRId64 ", \"name\": \"", getpid(), (int64_t)self, _trace_ts());
|
||||||
p += _tf_trace_escape_name(line + p, sizeof(line) - p, name);
|
p += _tf_trace_escape_name(line + p, sizeof(line) - p, name);
|
||||||
p += snprintf(line + p, sizeof(line) - p, "\"},");
|
p += snprintf(line + p, sizeof(line) - p, "\"},");
|
||||||
|
p = tf_min(p, _countof(line));
|
||||||
trace->callback(trace, line, p, trace->user_data);
|
trace->callback(trace, line, p, trace->user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,6 +307,7 @@ static void _tf_trace_end_tagged(tf_trace_t* trace, void* tag)
|
|||||||
int p = snprintf(line, sizeof(line), "{\"ph\": \"E\", \"pid\": %d, \"tid\": \"0x%" PRIx64 "\", \"ts\": %" PRId64 ", \"name\": \"", getpid(), (int64_t)pthread_self(), _trace_ts());
|
int p = snprintf(line, sizeof(line), "{\"ph\": \"E\", \"pid\": %d, \"tid\": \"0x%" PRIx64 "\", \"ts\": %" PRId64 ", \"name\": \"", getpid(), (int64_t)pthread_self(), _trace_ts());
|
||||||
p += _tf_trace_escape_name(line + p, sizeof(line) - p, name);
|
p += _tf_trace_escape_name(line + p, sizeof(line) - p, name);
|
||||||
p += snprintf(line + p, sizeof(line) - p, "\"},");
|
p += snprintf(line + p, sizeof(line) - p, "\"},");
|
||||||
|
p = tf_min(p, _countof(line));
|
||||||
trace->callback(trace, line, p, trace->user_data);
|
trace->callback(trace, line, p, trace->user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,4 +22,4 @@ const char* tf_util_backtrace_string();
|
|||||||
|
|
||||||
const char* tf_util_function_to_string(void* function);
|
const char* tf_util_function_to_string(void* function);
|
||||||
|
|
||||||
#define tf_min(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
|
#define tf_min(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _b : _a; })
|
||||||
|
Loading…
Reference in New Issue
Block a user