Getting thread names with thread_private

47 views
Skip to first unread message

Edgar Neubauer

unread,
Aug 29, 2023, 4:40:36 AM8/29/23
to DynamoRIO Users
Greetings,

is there a method to dump the pthread thread names along with the thread local data for example with drcov? I want to use it to track which threads exactly access which code.

Regards.

Derek Bruening

unread,
Aug 29, 2023, 9:56:53 AM8/29/23
to Edgar Neubauer, DynamoRIO Users
There is no existing convenience routine.  If those are set on Linux with prctl(PR_SET_NAME then invoking SYS_prctl with PR_GET_NAME should be safe to run directly in a client context.  If that works out, please consider contributing a pull request to add a convenience API routine.

--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dynamorio-users/d9ed854a-e8ac-4338-a5bc-812124e15566n%40googlegroups.com.

Edgar Neubauer

unread,
Aug 30, 2023, 5:23:45 AM8/30/23
to DynamoRIO Users
Hello,

thanks for your answer. The name is indeed set via prctl. I assume one should make the name part of per_thread_t ? Is this data structure created at a point where the calling thread is the one per_thread_t belongs to? I propose making the thread name part of the output file name. 

Edgar Neubauer

unread,
Aug 30, 2023, 6:34:57 AM8/30/23
to DynamoRIO Users
I see that the process id is already added to the filename. Can you tell me where this string is generated?

Derek Bruening

unread,
Aug 30, 2023, 11:38:52 AM8/30/23
to Edgar Neubauer, DynamoRIO Users
Yes, the thread init event is always run in the context of that thread (but the thread exit event does not have that guarantee).  Probably it uses drx_open_unique_appid_file() so searching for that should find it.

Edgar Neubauer

unread,
Aug 31, 2023, 9:37:15 AM8/31/23
to DynamoRIO Users
Can I assume that every method that gets a valid drcontext is called by the thread this drcontext belongs to?

Derek Bruening

unread,
Aug 31, 2023, 10:01:01 PM8/31/23
to Edgar Neubauer, DynamoRIO Users
As mentioned, not in the thread exit event.

Reply all
Reply to author
Forward
0 new messages