The next and nexti Commands

Use the next command to execute a line of source code. When the next line to be executed contains a function call, the next command executes the function being called and stops the process at the line immediately after the function call.

Use the nexti command to execute a machine instruction. When the instruction contains a function call, the nexti command executes the function being called and stops the process at the instruction immediately after the call instruction.

If you supply the optional expression argument, the debugger evaluates the expression as a positive integer that specifies the number of times to execute the command. The expression can be any expression that is valid in the current context.

 

step_over_command

        : next  [ step_number ]

        | nexti [ step_number ]

 

step_number

        :  expression

 

For example:

DBX Mode

 

(idb) list $curline:4

>   151         Node* currentNode = _firstNode;

    152         while (currentNode->getNextNode())

    153             currentNode = currentNode->getNextNode();

    154 currentNode->setNextNode(node);

(idb) next

stopped at [void List<Node>::append(class Node* const):152 0x0804c579]

    152         while (currentNode->getNextNode())

(idb) next

stopped at [void List<Node>::append(class Node* const):153 0x0804c592]

    153             currentNode = currentNode->getNextNode();

(idb) next

stopped at [void List<Node>::append(class Node* const):152 0x0804c5aa]

    152         while (currentNode->getNextNode())

(idb) next

stopped at [void List<Node>::append(class Node* const):154 0x0804c5c3]

    154 currentNode->setNextNode(node);

GDB Mode

 

(idb) list +0,+4

151         Node* currentNode = _firstNode;

152         while (currentNode->getNextNode())

153             currentNode = currentNode->getNextNode();

154 currentNode->setNextNode(node);

(idb) next

152         while (currentNode->getNextNode())

(idb) next

153             currentNode = currentNode->getNextNode();

(idb) next

152         while (currentNode->getNextNode())

(idb) next

154 currentNode->setNextNode(node);

 

The following example shows the difference between stepi and nexti over the same call:

DBX Mode

 

(idb) $curpc/8i

void List<Node>::append(class Node* const): src/x_list.cxx

*[line 151, 0x0804c571] append(class Node* const)+0x19:                 movlr    0x8(%ebp), %eax

 [line 151, 0x0804c574] append(class Node* const)+0x1c:                 movlr    (%eax), %eax

 [line 151, 0x0804c576] append(class Node* const)+0x1e:                 movl     %eax, -16(%ebp)

 [line 152, 0x0804c579] append(class Node* const)+0x21:                 pushl    %edi

 [line 152, 0x0804c57a] append(class Node* const)+0x22:                 movlr    -16(%ebp), %eax

 [line 152, 0x0804c57d] append(class Node* const)+0x25:                 movl     %eax, (%esp)

 [line 152, 0x0804c580] append(class Node* const)+0x28:                 call     getNextNode

 [line 152, 0x0804c585] append(class Node* const)+0x2d:                 addl     $0x4, %esp

(idb) nexti

stopped at [void List<Node>::append(class Node* const):151 0x0804c574] append(class Node* const)+0x1c:                 movlr    (%eax), %eax

(idb) nexti $count - 1

stopped at [void List<Node>::append(class Node* const):151 0x0804c574] append(class Node* const)+0x1c:                 movlr    (%eax), %eax

(idb) nexti

stopped at [void List<Node>::append(class Node* const):151 0x0804c576] append(class Node* const)+0x1e:                 movl     %eax, -16(%ebp)

GDB Mode

 

(idb) x /8i $pc

0x0804c571 <append+25>:                 movlr    0x8(%ebp), %eax

0x0804c574 <append+28>:                 movlr    (%eax), %eax

0x0804c576 <append+30>:                 movl     %eax, -16(%ebp)

0x0804c579 <append+33>:                 pushl    %edi

0x0804c57a <append+34>:                 movlr    -16(%ebp), %eax

0x0804c57d <append+37>:                 movl     %eax, (%esp)

0x0804c580 <append+40>:                 call     0x080534aa <getNextNode>

0x0804c585 <append+45>:                 addl     $0x4, %esp

(idb) nexti

0x0804c574      151         Node* currentNode = _firstNode;

(idb) x /1i $pc

0x0804c574 <append+28>:                 movlr    (%eax), %eax

(idb) nexti $count - 1

0x0804c574      151         Node* currentNode = _firstNode;

(idb) x /1i $pc

0x0804c574 <append+28>:                 movlr    (%eax), %eax

(idb) nexti

0x0804c576      151         Node* currentNode = _firstNode;

(idb) x /1i $pc

0x0804c576 <append+30>:                 movl     %eax, -16(%ebp)