gdb break line thread thread-id
来源:互联网 发布:世嘉 倒闭 知乎 编辑:程序博客网 时间:2024/05/21 08:01
#include <stdio.h>#include <pthread.h>#include <sched.h>/*****************************************************************/typedef unsigned char BYTE_T;typedef int INT32_T;#define MAX_CHAR_LEN (10)/****************************************************************/BYTE_T g_pu8Str[MAX_CHAR_LEN] = "abc";pthread_t g_stPid;/***************************************************************/static void task_fun(void){ int i32Num = 0; while (1) { sleep(1); printf("%d\n", i32Num); i32Num++; }}void init_thread(void){ pthread_attr_t stAttr; struct sched_param sched_proi; pthread_attr_init(&stAttr); /*ÉèÖÃÏß³ÌÓÅÏÈŒ¶*/ pthread_attr_setschedpolicy(&stAttr, SCHED_FIFO); /*set thread pri*/ pthread_attr_setscope(&stAttr, PTHREAD_SCOPE_SYSTEM); /**/ pthread_attr_setdetachstate(&stAttr, PTHREAD_CREATE_DETACHED); /**/ sched_proi.__sched_priority = 66; pthread_attr_setschedparam(&stAttr, &sched_proi); pthread_attr_setstacksize(&stAttr, 0x20000); if (0 != pthread_create(&g_stPid, &stAttr, (void *)task_fun, NULL)) { /**/ pthread_detach((pthread_t)g_stPid); }}int main(int argc, char *argv[]){ INT32_T i32Num = 0; init_thread(); printf("%s\n", g_pu8Str); printf("%d\n", i32Num); i32Num = 32; printf("i32Num = [%d]\n", i32Num); getchar(); return 0;}
root@ubuntu:/home/commander/project/gdb_test# gdb ./gdb_test.elf -qReading symbols from /home/commander/project/gdb_test/gdb_test.elf...done.
(gdb) l task_fun
15 pthread_t g_stPid;
16
17 /***************************************************************/
18
19 static void task_fun(void)
20 {
21 int i32Num = 0;
22
23 while (1)
24 {
(gdb)
25 sleep(1);
26 printf("%d\n", i32Num);
27 i32Num++;
28 }
29 }
30
31 void init_thread(void)
32 {
33 pthread_attr_t stAttr;
34 struct sched_param sched_proi;
(gdb) break task_fun
Breakpoint 1 at 0x804873a: file ./gdb_test.c, line 21.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x0804873a in task_fun at ./gdb_test.c:21
(gdb) r
Starting program: /home/commander/project/gdb_test/gdb_test.elf
[Thread debugging using libthread_db enabled]
[New Thread 0xb7febb70 (LWP 5277)]
abc
0
i32Num = [32]
[Switching to Thread 0xb7febb70 (LWP 5277)]
Breakpoint 1, task_fun () at ./gdb_test.c:21
21 int i32Num = 0;
(gdb) info threads
Id Target Id Frame
* 2 Thread 0xb7febb70 (LWP 5277) "gdb_test.elf" task_fun () at ./gdb_test.c:21 ------------thread-id = 2
1 Thread 0xb7fec6c0 (LWP 5274) "gdb_test.elf" 0x00130416 in __kernel_vsyscall ()
(gdb) break gdb_test.c:25 thread 2 ------------filename:line thread thread-id
Breakpoint 2 at 0x8048741: file ./gdb_test.c, line 25.
(gdb) c
Continuing.
Breakpoint 2, task_fun () at ./gdb_test.c:25
25 sleep(1);
(gdb) c
Continuing.
0
Breakpoint 2, task_fun () at ./gdb_test.c:25
25 sleep(1);
(gdb) c
Continuing.
1
Breakpoint 2, task_fun () at ./gdb_test.c:25
25 sleep(1);
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x0804873a in task_fun at ./gdb_test.c:21
breakpoint already hit 1 time
2 breakpoint keep y 0x08048741 in task_fun at ./gdb_test.c:25 thread 2
stop only in thread 2
breakpoint already hit 3 times
(gdb)
- gdb break line thread thread-id
- Thread id
- Thread Id and Thread Handle
- gdb thread related command
- get linux thread id
- Thread
- thread
- Thread
- Thread
- thread
- thread
- Thread
- Thread
- Thread
- Thread
- Thread
- Thread
- Thread
- django1.5 官方文档阅读笔记(四)
- window下Slik SVN的安装配置
- java面试题2013/5/14
- 目录树-文件夹目录树-图片列表
- eclipse maven plugin 插件 安装 和 配置
- gdb break line thread thread-id
- Poj 2407 Relatives
- Python中的字典
- web.py 入门demo遇到的问题
- Processing XML in Python with ElementTree
- tr整行同上和选中td的内容与上一行同列的单元格内容相同
- java学习笔记04--数组
- 第一篇文章
- hdu 4505 小Q系列故事——电梯里的爱情 (水题)