Skip to content

Commit

Permalink
Generate metadata in client-side
Browse files Browse the repository at this point in the history
  • Loading branch information
rmeena840 committed Aug 7, 2019
1 parent 6eb069c commit 1e07b1e
Showing 1 changed file with 111 additions and 1 deletion.
112 changes: 111 additions & 1 deletion misc/record/record-main.c
Expand Up @@ -110,7 +110,6 @@ typedef struct switch_event{
typedef struct switch_out_int{
uint64_t ns;
uint64_t out_data;
uint64_t in_data;
int64_t prev_state;
} __attribute__((__packed__)) switch_out_int;

Expand Down Expand Up @@ -423,6 +422,115 @@ static rtems_record_client_status handler(
return RTEMS_RECORD_CLIENT_SUCCESS;
}

void generate_metadata(){
FILE *metadata = fopen("metadata","w");
assert( metadata != NULL );

fprintf(metadata, "/* CTF 1.8 */\n\n");
fprintf(metadata, "typealias integer { size = 5; align = 1; signed = false; } := uint5_t;\
\ntypealias integer { size = 8; align = 8; signed = false; } := uint8_t;\
\ntypealias integer { size = 32; align = 8; signed = false; } := uint32_t;\
\ntypealias integer { size = 64; align = 8; signed = false; } := uint64_t;\
\ntypealias integer { size = 64; align = 8; signed = false; } := unsigned long;\n\n"
);

fprintf(metadata, "trace {\
\n\tmajor = 1;\
\n\tminor = 8;\
\n\tuuid = \"6a7715d0-b502-4c65-8678-6777ac7f755a\";\
\n\tbyte_order = le;\
\n\tpacket.header := struct {\
\n\t\tuint32_t magic;\
\n\t\tuint8_t uuid[16];\
\n\t\tuint32_t stream_id;\
\n\t\tuint64_t stream_instance_id;\
\n\t};\
\n};\n\n");

fprintf(metadata, "env {\
\n\thostname = \"Record_Item\";\
\n\tdomain = \"kernel\";\
\n\tsysname = \"Linux\";\
\n\tkernel_release = \"4.18.14-arch1-1-ARCH\";\
\n\tkernel_version = \"#1 SMP PREEMPT Sat Thu 17 13:42:37 UTC 2019\";\
\n\ttracer_name = \"lttng-modules\";\
\n\ttracer_major = 2;\
\n\ttracer_minor = 11;\
\n\ttracer_patchlevel = 0;\
\n};\n\n");

fprintf(metadata, "clock {\
\n\tname = \"monotonic\";\
\n\tuuid = \"234d669d-7651-4bc1-a7fd-af581ecc6232\";\
\n\tdescription = \"Monotonic Clock\";\
\n\tfreq = 1000000000;\
\n\toffset = 1539783991179109789;\
\n};\n\n");

fprintf(metadata, "typealias integer {\
\n\tsize = 27; align = 1; signed = false;\
\n\tmap = clock.monotonic.value;\
\n} := uint27_clock_monotonic_t;\
\n\n");

fprintf(metadata, "typealias integer {\
\n\tsize = 64; align = 8; signed = false;\
\n\tmap = clock.monotonic.value;\
\n} := uint64_clock_monotonic_t;\
\n\n");

fprintf(metadata, "struct packet_context {\
\n\tuint64_clock_monotonic_t timestamp_begin;\
\n\tuint64_clock_monotonic_t timestamp_end;\
\n\tuint64_t content_size;\
\n\tuint64_t packet_size;\
\n\tuint64_t packet_seq_num;\
\n\tunsigned long events_discarded;\
\n\tuint32_t cpu_id;\
\n};\
\n\n");

fprintf(metadata, "struct event_header_compact {\
\n\tenum : uint5_t { compact = 0 ... 30, extended = 31 } id;\
\n\tvariant <id> {\
\n\t\tstruct {\
\n\t\t\tuint27_clock_monotonic_t timestamp;\
\n\t\t} compact;\
\n\t\tstruct {\
\n\t\t\tuint32_t id;\
\n\t\t\tuint64_clock_monotonic_t timestamp;\
\n\t\t} extended;\
\n\t} v;\
\n} align(8);\
\n\n");

fprintf(metadata, "stream {\
\n\tid = 0;\
\n\tevent.header := struct event_header_compact;\
\n\tpacket.context := struct packet_context;\
\n};\
\n\n");

fprintf(metadata, "event {\
\n\tname = \"sched_switch\";\
\n\tid = 0;\
\n\tstream_id = 0;\
\n\tfields := struct {\
\n\t\tinteger { size = 8; align = 8; signed = 0; encoding = UTF8; base = 10;} _prev_comm[16];\
\n\t\tinteger { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _prev_tid;\
\n\t\tinteger { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _prev_prio;\
\n\t\tinteger { size = 64; align = 8; signed = 1; encoding = none; base = 10; } _prev_state;\
\n\t\tinteger { size = 8; align = 8; signed = 0; encoding = UTF8; base = 10; } _next_comm[16];\
\n\t\tinteger { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _next_tid;\
\n\t\tinteger { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _next_prio;\
\n\t};\
\n};\
\n");

fclose( metadata );

}

int main( int argc, char **argv )
{
rtems_record_client_context ctx;
Expand Down Expand Up @@ -492,6 +600,8 @@ int main( int argc, char **argv )

memcpy( ctf_packet_header.uuid, uuid, sizeof( ctf_packet_header.uuid ) );

generate_metadata();

FILE *event_streams[ RTEMS_RECORD_CLIENT_MAXIMUM_CPU_COUNT ];

for( i = 0; i < RTEMS_RECORD_CLIENT_MAXIMUM_CPU_COUNT ; i++ ) {
Expand Down

0 comments on commit 1e07b1e

Please sign in to comment.