0

I am trying to debug a code in C++, compiling -O0 -g flag.

Function is like

void abc(){
    //stuff
    for(int i=0; i<n; i++){
        //stuff
    }
}

I want to put a conditional gdb breakpoint at the end of the function. I can put a statement like int a=1 before the function ends and put a breakpoint there, but is there any other way to do it without making changes to the code?

How to set a breakpoint in GDB where the function returns?

The question above has lot of return statements, so it is easier to put a break point there. This one does not have any RETURN statement and placing breakpoint to see the local variables is the thing I want to know.

Sagar Chand
  • 260
  • 7
  • 18
  • There are answers in the question you've linked that on assembly return instruction which will be generated regardless of whether of you put explicit return in the code or not. – Piotr Siupa Jan 31 '23 at 13:07

0 Answers0