(21)调试指定进程 :
++ 给出 对 sleep 进程的调试举例:
(22) 调试多线程。先给出 非常简化的源码:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void f()
{
unsigned long long num = 0;
for(;;)
num++;
}
void* thread_function(void* arg) // 线程函数
{
f();
}
int main()
{
pthread_t threadA,threadB;
long thread_arg = 1;
int rc;
rc = pthread_create(&threadA, NULL, thread_function, (void*)&thread_arg);
rc = pthread_create(&threadB, NULL, thread_function, (void*)&thread_arg);
rc = 5 ; // 此处是为了方便打断点
pthread_join(threadA, NULL); // 等待线程完成
pthread_join(threadB, NULL);
return 0;
}
++ 编译:
++ 给出一言里关于多线程的调试命令介绍:
++ 给出调试实践:
(23)
thread name [name] # 为当前线程设置命名。 这个实验过了,感觉并不实用。
thread apply [command] # 为当前线程应用对应的命令
thread find # 查找符合描述的线程,查找条件一般按照线程命名查找, find 后接正则表达式
# Will display thread ids whose name, target ID, or extra info matches REGEXP
(24) 打印变量值 info locals :
++ 举例:
(25) 监视某个值的变化 watch :
++ 举例实践:
(26)完成函数的剩余部分的执行 finish :
++ 举例:
(27) 记录 record :
++ 实践一下:
++ 以及:
(28)
谢谢