From mboxrd@z Thu Jan 1 00:00:00 1970 From: simon.marchi@polymtl.ca (Simon Marchi) Date: Wed, 10 Jun 2015 17:28:42 -0400 Subject: [lttng-dev] Printing bit fields with LTTng In-Reply-To: References: Message-ID: On 10 June 2015 at 17:16, Chidhu R wrote: > Hello, > > I am getting compilation issues while trying to print bit field values with > LTTng. > > Error: > > hello.c: In function ?main?: > hello.c:36:1: error: ?typeof? applied to a bit-field > hello.c:36:1: error: ?typeof? applied to a bit-field > hello.c:36:1: error: ?typeof? applied to a bit-field > hello.c:36:1: error: ?sizeof? applied to a bit-field > > Snippet: > > struct abc{ > int a:16; > int b:8; > }; > > Line 36: tracepoint(hello_world, my_third_tracepoint, aa.a, "welcome"); > Line 37: printf("val = %x\n",aa.a); > > tracepoint line results in compilation error. > printf succeeds. > > Tp definition looks like this. > > TRACEPOINT_EVENT( > hello_world, > my_third_tracepoint, > TP_ARGS( > uint32_t, arg, > const char * , my_string_arg > ), > TP_FIELDS( > ctf_integer_hex(uint32_t, my_arg, arg) > ctf_string(field, my_string_arg) > ) > ) > > How to print bit field values? > > Thanks > Chid I have no idea what the right fix would be, but an easy workaround could be to add 0 to your value: tracepoint(hello_world, my_third_tracepoint, aa.a + 0, "welcome"); I just tried it and it works. Simon