8255858: Add debug agent support for storing thread names
Reviewed-by: sspitsyn, amenkov
This commit is contained in:
parent
a0ade22057
commit
166c728300
@ -84,6 +84,9 @@ typedef struct ThreadNode {
|
||||
struct ThreadNode *prev;
|
||||
jlong frameGeneration;
|
||||
struct ThreadList *list; /* Tells us what list this thread is in */
|
||||
#ifdef DEBUG_THREADNAME
|
||||
char name[256];
|
||||
#endif
|
||||
} ThreadNode;
|
||||
|
||||
static jint suspendAllCount;
|
||||
@ -349,6 +352,22 @@ insertThread(JNIEnv *env, ThreadList *list, jthread thread)
|
||||
node->eventBag = eventBag;
|
||||
addNode(list, node);
|
||||
|
||||
#ifdef DEBUG_THREADNAME
|
||||
{
|
||||
/* Set the thread name */
|
||||
jvmtiThreadInfo info;
|
||||
jvmtiError error;
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
error = JVMTI_FUNC_PTR(gdata->jvmti,GetThreadInfo)
|
||||
(gdata->jvmti, node->thread, &info);
|
||||
if (info.name != NULL) {
|
||||
strncpy(node->name, info.name, sizeof(node->name) - 1);
|
||||
jvmtiDeallocate(info.name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set thread local storage for quick thread -> node access.
|
||||
* Some threads may not be in a state that allows setting of TLS,
|
||||
* which is ok, see findThread, it deals with threads without TLS set.
|
||||
|
Loading…
Reference in New Issue
Block a user