Closed trycatchx closed 2 years ago
我先这么解决了
void *thr_fn(void *arg){
char pname[32] = {0};
prctl(PR_GET_NAME, pname);
pthread_t tid = -1;
tid = pthread_self();
ALOG("stack call name: = %s,tid = %lu", pname,tid);
return ((void *)0);
}
int pthread_create_hook(pthread_t* thread, const pthread_attr_t* attr,
void* (*start_routine) (void *), void* arg) {
pthread_t new_tid = -1;
pthread_create(&new_tid, NULL, thr_fn, arg);
pthread_join(new_tid,NULL);
printJavaStack();
int ret = CALL_PREV(pthread_create_hook, thread, attr, *start_routine, arg);
return ret;
}
如何打印当前子线程的名字?