Skip to content

Commit

Permalink
8295810: cleanup debug agent removeThread() api
Browse files Browse the repository at this point in the history
Reviewed-by: kevinw, sspitsyn, amenkov
  • Loading branch information
plummercj committed Oct 25, 2022
1 parent 5c4d99a commit 6289600
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/jdk.jdwp.agent/share/native/libjdwp/threadControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ removeNode(ThreadList *list, ThreadNode *node)
ThreadNode *prev;
ThreadNode *next;

JDI_ASSERT(list == node->list);
prev = node->prev;
next = node->next;
if ( prev != NULL ) {
Expand Down Expand Up @@ -487,15 +488,11 @@ clearThread(JNIEnv *env, ThreadNode *node)
}

static void
removeThread(JNIEnv *env, ThreadList *list, jthread thread)
removeThread(JNIEnv *env, ThreadNode *node)
{
ThreadNode *node;

node = findThread(list, thread);
if (node != NULL) {
removeNode(list, node);
clearThread(env, node);
}
JDI_ASSERT(node != NULL);
removeNode(node->list, node);
clearThread(env, node);
}

static void
Expand All @@ -507,7 +504,7 @@ removeResumed(JNIEnv *env, ThreadList *list)
while (node != NULL) {
ThreadNode *temp = node->next;
if (node->suspendCount == 0) {
removeThread(env, list, node->thread);
removeThread(env, node);
}
node = temp;
}
Expand Down Expand Up @@ -2476,11 +2473,7 @@ threadControl_onEventHandlerExit(EventIndex ei, jthread thread,
env = getEnv();
if (ei == EI_THREAD_END) {
jboolean inResume = (node->resumeFrameDepth > 0);
if (isVThread(thread)) {
removeThread(env, &runningVThreads, thread);
} else {
removeThread(env, &runningThreads, thread);
}
removeThread(env, node);
node = NULL; /* has been freed */

/*
Expand Down Expand Up @@ -2930,7 +2923,7 @@ dumpThread(ThreadNode *node) {
#ifdef DEBUG_THREADNAME
tty_message("\tname: %s", node->name);
#endif
// More fields can be printed here when needed. The amount of output is intentionlly
// More fields can be printed here when needed. The amount of output is intentionally
// kept small so it doesn't generate too much output.
tty_message("\tsuspendCount: %d", node->suspendCount);
}
Expand Down

1 comment on commit 6289600

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.