On 21/06/2019 08:57, Ravindra Kumar Meena wrote:
> seconds = (uint32_t) ( item->ns / 1000000000 );
> nanoseconds = (uint32_t) ( item->ns % 1000000000 );
> + ns=nanoseconds;
Why not move the nanoseconds variable into the upper block?
Okay
> fprintf( f, "%" PRIu32 ".%09" PRIu32 ":", seconds, nanoseconds );
> } else {
Which value has "ns" in this path?
na does not have a unique value. It is changing eveytime print_item() is
called upon
> fprintf( f, "*:" );
> @@ -153,6 +164,22 @@ static void print_item( FILE *f, const
client_item *item )
> rtems_record_event_text( item->event ),
> item->data
> );
> +
> + FILE *fptr = fopen("event", "a");
How often gets this file opened and closed? Do you think that
opening and closing a file is a cheap operation? Could there be a
more efficient solution?
I would like to know your approach. I will implement that only. It's
better to implement your approach instead of mine. It will save some time.
The
static void print_item( FILE *f, const client_item *item )
gets already a file, please use it.
The file is currently stdout. This should be changed to an event stream
file. Add the file pointer to client_context and open the file in main().
> +
> + if (fptr == NULL)
> + {
> + printf("Could not open file");
> + return 0;
Can void functions return something?
Ooops. I didn't see the void.
You get also a compiler warning for this.
../misc/record/record-main.c: In function ‘print_item’:
../misc/record/record-main.c:173:15: warning: ‘return’ with a value, in
function returning void
return 0;
^
> + }
> +
> + ctf_item->cpu=item->cpu;
To which object points the the ctf_item pointer here?
Are you expecting pointer here?
The ctf_item pointer points to a random memory location. You get also a
warning for this:
../misc/record/record-main.c: In function ‘handler’:
../misc/record/record-main.c:181:3: warning: ‘ctf_item’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
fprintf(fptr,ctf_item);
^~~~~~~~~~~~~~~~~~~~~~
It must be:
ctf_event ctf_item;
> + ctf_item->event=item->event;
> + ctf_item->data=item->data;
> + ctf_item->ns=ns;
> +
> + fprintf(fptr,ctf_item);
> + fclose(fptr);
> }
>
> static void flush_items( client_context *cctx )
> --
> 2.7.4
Did you compile and run the program with this patch?
Yes the rtems-tools was building successfully but I was getting nothing
in file.
A build with such warnings is not successful. You can use GDB to debug
your program.
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel