Commit 981173f4 authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova

Merge remote-tracking branch 'origin/T-tracer-float-support' into integration_2024_w46 (!3109)

T tracer: support float types in traces
parents b18f3931 0eb0325b
...@@ -94,6 +94,10 @@ event new_event(int type, int length, char *buffer, void *database) ...@@ -94,6 +94,10 @@ event new_event(int type, int length, char *buffer, void *database)
e.e[i].type = EVENT_ULONG; e.e[i].type = EVENT_ULONG;
e.e[i].ul = *(unsigned long *)(&buffer[offset]); e.e[i].ul = *(unsigned long *)(&buffer[offset]);
offset += sizeof(unsigned long); 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")) { } else if (!strcmp(f.type[i], "string")) {
e.e[i].type = EVENT_STRING; e.e[i].type = EVENT_STRING;
e.e[i].s = &buffer[offset]; e.e[i].s = &buffer[offset];
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
enum event_arg_type { enum event_arg_type {
EVENT_INT, EVENT_INT,
EVENT_ULONG, EVENT_ULONG,
EVENT_FLOAT,
EVENT_STRING, EVENT_STRING,
EVENT_BUFFER EVENT_BUFFER
}; };
...@@ -23,6 +24,7 @@ typedef struct { ...@@ -23,6 +24,7 @@ typedef struct {
union { union {
int i; int i;
unsigned long ul; unsigned long ul;
float f;
char *s; char *s;
struct { struct {
int bsize; int bsize;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
enum format_item_type { enum format_item_type {
INSTRING, INSTRING,
INT, ULONG, STRING, BUFFER }; INT, ULONG, FLOAT, STRING, BUFFER };
struct format_item { struct format_item {
enum format_item_type type; enum format_item_type type;
...@@ -67,6 +67,7 @@ static void _event(void *p, event e) ...@@ -67,6 +67,7 @@ static void _event(void *p, event e)
case INSTRING: PUTS(&l->o, l->f[i].s); break; 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 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 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 STRING: PUTS_CLEAN(&l->o, e.e[l->f[i].event_arg].s); break;
case BUFFER: case BUFFER:
PUTS(&l->o, "{buffer size:"); PUTS(&l->o, "{buffer size:");
...@@ -106,6 +107,7 @@ static int find_argument(char *name, database_event_format f, ...@@ -106,6 +107,7 @@ static int find_argument(char *name, database_event_format f,
*event_arg = i; *event_arg = i;
if (!strcmp(f.type[i], "int")) *it = INT; if (!strcmp(f.type[i], "int")) *it = INT;
else if (!strcmp(f.type[i], "ulong")) *it = ULONG; 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], "string")) *it = STRING;
else if (!strcmp(f.type[i], "buffer")) *it = BUFFER; else if (!strcmp(f.type[i], "buffer")) *it = BUFFER;
else return 0; else return 0;
......
...@@ -276,3 +276,9 @@ void PUTUL(OBUF *o, unsigned long l) { ...@@ -276,3 +276,9 @@ void PUTUL(OBUF *o, unsigned long l) {
sprintf(s, "%lu", l); sprintf(s, "%lu", l);
PUTS(o, s); 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); ...@@ -50,5 +50,6 @@ void PUTS_CLEAN(OBUF *o, char *s);
void PUTI(OBUF *o, int i); void PUTI(OBUF *o, int i);
void PUTX2(OBUF *o, int i); void PUTX2(OBUF *o, int i);
void PUTUL(OBUF *o, unsigned long i); void PUTUL(OBUF *o, unsigned long i);
void PUTF(OBUF *o, float f);
#endif /* _UTILS_H_ */ #endif /* _UTILS_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment