0

While debugging using gdb, I am calling the nc_print function as
(gdb)call nc_print() but there is no output and no warning.

void nc_print()
{
     printf("ramanuj\n");
}

I am finding that gdb fails to call the nc_print. I am not getting why is it happening. May i know the possible reason.

2
  • 1
    I can't reproduce it, can you post whole gdb session from very beginning ? Commented Nov 23, 2016 at 16:48
  • atleast you can say in which situation gdb fails to call the function Commented Nov 23, 2016 at 23:24

1 Answer 1

2

I am finding that gdb fails to call the nc_print.

Your conclusion that GDB did not call nc_print is likely wrong. If you add a call to abort() to nc_print, does your program abort? If so, your conclusion is wrong.

I am not getting why is it happening

What is most likely happening is that your inferior (being debugged) program has its stdout redirected to a file (or a pipe), and thus fully buffered.

Things will likely work as you expect them if you add fflush(stdout), or use fprintf(stderr, "ramanuj\n").

Sign up to request clarification or add additional context in comments.

1 Comment

Many Thanks It works. Is there any way to increase the buffer size while debugging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.