<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">No, using sprintf() is not the right way to do this. Please try to <br>
understand the referenced code section. The string is converted char by <br>
char into a sequence of integers. You have to reverse this and convert <br>
an integer into a sequence of chars.<br><br>
>     3. You don't need extra memcpy() calls, just store the string directly<br>
>     in ctx->thread_names[api_id][thread_id]. The first<br>
>     RTEMS_RECORD_THREAD_NAME uses<br>
>     ctx->thread_names[api_id][thread_id][0..7], the second uses<br>
>     ctx->thread_names[api_id][thread_id][8..15]. The third and later are an<br>
>     error, just ignore it.<br>
> <br>
> We can store the 16 char all at once then why are we doing this in two <br>
> parts.<br>
<br>
You get the name fragments event by event. When you receive the first <br>
name you don't know how many fragments will come in total.<br>
<br>
> <br>
> My approach is like this:<br>
> Get the api_id from thread_id and for the same api_id increase the <br>
> thread_id counter and store the string whenever new <br>
> RTEMS_RECORD_THREAD_NAME is received.<br>
> eg.<br>
> <api_id=0><thread_id=0><thread_name><br>
> <api_id=0><thread_id=1><thread_name><br>
> <api_id=0><thread_id=2><thread_name><br>
> <br>
> <api_id=1><thread_id=0><thread_name><br>
> <api_id=1><thread_id=1><thread_name><br>
> <api_id=1><thread_id=2><thread_name><br>
<br>
This makes no sense to me. The thread id is fixed for a sequence of <br>
thread name events. From the thread id you get the API index and the <br>
object index.<br></blockquote><div><br></div><div>Have made changes. Simplified the code.</div><div><a href="https://github.com/rmeena840/rtems-tools/commit/9e09be40db85e4e903118f8eb5eb1ea1e41baf46">https://github.com/rmeena840/rtems-tools/commit/9e09be40db85e4e903118f8eb5eb1ea1e41baf46</a></div><div> </div></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><font size="4"><b>Ravindra Kumar Meena</b></font>,<div><span style="color:rgb(102,102,102)">B. Tech. Computer Science and Engineering,<br></span></div><div><span style="color:rgb(102,102,102)"><a href="https://www.iitism.ac.in/" style="color:rgb(17,85,204)" target="_blank">Indian Institute of Technology (Indian School of Mines)</a>, Dhanbad</span></div></div></div></div></div></div>