2
votes

Here is a function in my program

void
quicksort (int *num, int p, int r, int june)
{
  int q, bbc, ccd;
  if (p < r)
    {
      call++;
      q = partition (num, p, r, june);//<--I want to skip this call in gdb session
      bbc = q - 1 - p + 1;//<-- and want to continue execution step by step from here
      quicksort (num, p, q - 1, bbc);
           ccd=r-q+1;
      quicksort (num, q + 1, r, ccd);
    }
} //since it is a recursive function each time quicksort is called partition is also executed I want to focus my debugging only to quicksort

If you notice it calls another function partition in between.While running in a gdb session I want to skip the gdb showing me steps of parition i.e. I know function partition is correct so do what partition does and then jump to next instruction

     bbc = q - 1 - p + 1;

and in my debugging session do not show info about partition. So how can I skip that part and continue debugging quicksort.

3

3 Answers

3
votes

I think you are looking for a step over.

Step Over is the same as Step Into, except that when it reaches a call for another procedure, it will not step into the procedure. The procedure will run, and you will be brought to the next statement in the current procedure.

In GDB, you do this by issuing the next command. When you are running the q = partition (num, p, r, june); line in gdb, type next and it will just execute the partition function without going into its code in detail.

You can find detailed information about stepping in gdb in this reference.

2
votes
b <line number>

will set a break point

c

will continue until the next breakpoint.

1
votes

You can either set a breakpoint for the line after partition:

b <line number>

Then use c to continue until the breakpoint.

Or you can use n to skip over the partition call (that is, type n when you reach the partition call, and it will skip the body of the function).

Or you can type finish to exit the partition function after entering it.