I have a binary that creates multiple threads during execution. I am trying to debug a flow for which I have inserted printf statements as milestones in code. But strange they are not getting printed on console and via GDB - I am not sure what wrong am I doing and how to correct the same:
./mycore.exe
When I start the flow I do not see my printf strings printed on console - but have a look at the GDB trace:
gdb ./mycore.exe
break filename:linenum
run
[New Thread 11533.0x282c]
[New Thread 11533.0x283c]
[New Thread 11533.0x21d4]
[New Thread 11533.0x24f8]
[New Thread 11533.0x580]
[New Thread 11533.0x10e0]
[Switching to Thread 11533.0x283c]
Breakpoint 1, fuction ()
at file.c:623
warning: Source file is more recent than executable.
623 {
(gdb) s
629 .........
(gdb) n
631 printf("reached here\n");
(gdb) n
640 ....................
(gdb) n
641 ....................
(gdb) quit
A debugging session is active.
Inferior 1 [process 11592] will be killed.
As you can see GDB step flow of the execution did lead to code - print statement introduced by me.
How to resolve the issue - make print the printf on the console?
===================UPDATE=================================
I re-compiled the code and ran again and same problem - still the printf string did not got printed:
[Switching to Thread 5868.0x2c0c]
Breakpoint 1, fuction ()
at file.c:623
623 {
(gdb) s
629 .........
(gdb) n
631 printf("reached here\n");
(gdb) n
640 ....................
(gdb) n
641 ....................
(gdb) quit