I have a C program where the main function creates threads and I have to debug one thread. I am using gdb for he same. However I cannot "break" or "watch" variables on specific C files of this program. For eg. my thread 6 is programmed and uses certain C files and I have to break at line 601 on say call_connect.c. Is this not possible? If I try to, this is what happens:
(gdb) info threads
6 Thread 0xb5c96b70 (LWP 3608) 0xb7fe1424 in __kernel_vsyscall ()
5 Thread 0xb6497b70 (LWP 3607) 0xb7fe1424 in __kernel_vsyscall ()
4 Thread 0xb6c98b70 (LWP 3606) 0xb7fe1424 in __kernel_vsyscall ()
3 Thread 0xb7499b70 (LWP 3605) 0xb7fe1424 in __kernel_vsyscall ()
2 Thread 0xb7c9ab70 (LWP 3604) 0xb7fe1424 in __kernel_vsyscall ()
* 1 Thread 0xb7c9b6c0 (LWP 3603) 0x0804a178 in main ()
(gdb) break 601 thread 6
No line 601 in file "events.c".
(gdb) break call_connect.c:601 thread 6
No source file named call_connect.c.
Also I debugged my C code with -O0 -ggdb and still I can't watch variables. This is what I get when I try to read a char *ptext variable.
(gdb) print ptext
No symbol "ptext" in current context.
(gdb) watch ptext
No symbol "ptext" in current context.
Can somebody please help?