GSoC Project | Basic Support for Trace Compass

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Jun 27 15:37:36 UTC 2019


----- Am 27. Jun 2019 um 16:52 schrieb Ravindra Kumar Meena rmeena840 at gmail.com:

>>
>> >     For whatever reason this file has only 98304 bytes. The
>> >     content looks
>> >      >     all right. So, the next step is to modify the client so that
>> >     it can
>> >      >     read
>> >      >     from a file instead of the TCP stream.
>> >      >
>> >      > I am trying to write code to read from the original raw record
>> item.
>> >
>> >     I am not sure why you want to do this. On which task are you
>> currently
>> >     working?
>> >
>> > I am working on the 2nd task to modify the record-client program to read
>> > from a file if a --input=<FILE> command line option is given.
>>
>> Could you please check in the part which adds the new option and the
>> code which opens the file.
>>
>> >
>> > client_item record;
>> > while(fread(&record, sizeof(record), 1, input_file))
>> >          printf ("CPU=%d\n",record.cpu);
>> >
>> > Here input_file is a file provided through the command.
>>
>> The TCP stream you saved with nc from the target consists of struct
>> rtems_record_item_32. In the code above you read struct client_item
>> items. This cannot be right. When you don't know which content a file
>> has, please ask.
>>
> typedef struct {
>  uint32_t event;
>  uint32_t data;
> } rtems_record_item_32;
> 
> Okay. Raw file contents have this structure. It means raw file will only
> contain event and data in binary format. How should I get it's
> corresponding ns and cpu values.

1. Instead of the socket() and connect() you open the file descriptor with open().

2. Instead of using recv() to read from the file descriptor you use read().  See below.

This is all you need to change in the program.

> 
>>
>> You have to change this code here:
>>
>>    while ( true ) {
>>      int buf[ 8192 ];
>>      ssize_t n;
>>
>>      n = recv( fd, buf, sizeof( buf ), 0 );
>>      if ( n >= 0 ) {
>>        rtems_record_client_run( &ctx, buf, (size_t) n );
>>      } else {
>>        break;
>>      }
>>    }
>>
>> First you should refactor the code and move the TCP relates stuff into
>> separate functions.
> 
> 
> 
> The command line should like this right?
> ./build/misc/rtems-record --input=<file> | head

Yes.


More information about the devel mailing list