Merge remote-tracking branch 'origin/T-tracer-float-support' into integration_2024_w46 (!3109)
T tracer: support float types in traces
This commit is contained in:
@@ -94,6 +94,10 @@ event new_event(int type, int length, char *buffer, void *database)
|
||||
e.e[i].type = EVENT_ULONG;
|
||||
e.e[i].ul = *(unsigned long *)(&buffer[offset]);
|
||||
offset += sizeof(unsigned long);
|
||||
} else if (!strcmp(f.type[i], "float")) {
|
||||
e.e[i].type = EVENT_FLOAT;
|
||||
e.e[i].f = *(float *)(&buffer[offset]);
|
||||
offset += sizeof(float);
|
||||
} else if (!strcmp(f.type[i], "string")) {
|
||||
e.e[i].type = EVENT_STRING;
|
||||
e.e[i].s = &buffer[offset];
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
enum event_arg_type {
|
||||
EVENT_INT,
|
||||
EVENT_ULONG,
|
||||
EVENT_FLOAT,
|
||||
EVENT_STRING,
|
||||
EVENT_BUFFER
|
||||
};
|
||||
@@ -23,6 +24,7 @@ typedef struct {
|
||||
union {
|
||||
int i;
|
||||
unsigned long ul;
|
||||
float f;
|
||||
char *s;
|
||||
struct {
|
||||
int bsize;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
enum format_item_type {
|
||||
INSTRING,
|
||||
INT, ULONG, STRING, BUFFER };
|
||||
INT, ULONG, FLOAT, STRING, BUFFER };
|
||||
|
||||
struct format_item {
|
||||
enum format_item_type type;
|
||||
@@ -67,6 +67,7 @@ static void _event(void *p, event e)
|
||||
case INSTRING: PUTS(&l->o, l->f[i].s); break;
|
||||
case INT: PUTI(&l->o, e.e[l->f[i].event_arg].i); break;
|
||||
case ULONG: PUTUL(&l->o, e.e[l->f[i].event_arg].ul); break;
|
||||
case FLOAT: PUTF(&l->o, e.e[l->f[i].event_arg].f); break;
|
||||
case STRING: PUTS_CLEAN(&l->o, e.e[l->f[i].event_arg].s); break;
|
||||
case BUFFER:
|
||||
PUTS(&l->o, "{buffer size:");
|
||||
@@ -106,6 +107,7 @@ static int find_argument(char *name, database_event_format f,
|
||||
*event_arg = i;
|
||||
if (!strcmp(f.type[i], "int")) *it = INT;
|
||||
else if (!strcmp(f.type[i], "ulong")) *it = ULONG;
|
||||
else if (!strcmp(f.type[i], "float")) *it = FLOAT;
|
||||
else if (!strcmp(f.type[i], "string")) *it = STRING;
|
||||
else if (!strcmp(f.type[i], "buffer")) *it = BUFFER;
|
||||
else return 0;
|
||||
|
||||
@@ -276,3 +276,9 @@ void PUTUL(OBUF *o, unsigned long l) {
|
||||
sprintf(s, "%lu", l);
|
||||
PUTS(o, s);
|
||||
}
|
||||
|
||||
void PUTF(OBUF *o, float f) {
|
||||
char s[256];
|
||||
sprintf(s, "%g", f);
|
||||
PUTS(o, s);
|
||||
}
|
||||
|
||||
@@ -50,5 +50,6 @@ void PUTS_CLEAN(OBUF *o, char *s);
|
||||
void PUTI(OBUF *o, int i);
|
||||
void PUTX2(OBUF *o, int i);
|
||||
void PUTUL(OBUF *o, unsigned long i);
|
||||
void PUTF(OBUF *o, float f);
|
||||
|
||||
#endif /* _UTILS_H_ */
|
||||
|
||||
Reference in New Issue
Block a user