The step and stepi Commands

Use the step command to execute a line of source code. When the line being stepped contains a function call, the step command steps into the function and stops at the first executable statement.

Use the stepi command to step into the next machine instruction. When the instruction contains a function call, the stepi command steps into the function being called.

For multithreaded applications, use the stepi command to step the current thread one machine instruction while putting all other threads on hold.

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_into_command

: step  [ step_number ]

| stepi [ step_number ]

step_number

:  expression

In the following example, five step commands continue executing a C++ program:

GDB Mode

(idb) list +0,+4

151         Node* currentNode = _firstNode;

152         while (currentNode->getNextNode())

153             currentNode = currentNode->getNextNode();

154 currentNode->setNextNode(node);

(idb) step

152         while (currentNode->getNextNode())

(idb) step

Node::getNextNode (this=0x805c500) at src/x_list.cxx:81

81 Node* Node::getNextNode()            {return _nextNode; }

(idb) step

81 Node* Node::getNextNode()            {return _nextNode; }

(idb) step

List<Node>::append (this=0xbfffcbe0, node=0x805c510) at src/x_list.cxx:152

152         while (currentNode->getNextNode())

(idb) step

154 currentNode->setNextNode(node);

DBX Mode

(idb) list $curline:4

>   151         Node* currentNode = _firstNode;

    152         while (currentNode->getNextNode())

    153             currentNode = currentNode->getNextNode();

    154 currentNode->setNextNode(node);

(idb) step

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

    152         while (currentNode->getNextNode())

(idb) step

stopped at [class Node* Node::getNextNode(void):81 0x08051be5]

     81 Node* Node::getNextNode()            {return _nextNode; }

(idb) step

stopped at [class Node* Node::getNextNode(void):81 0x08051bec]

     81 Node* Node::getNextNode()            {return _nextNode; }

(idb) step

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

    152         while (currentNode->getNextNode())

(idb) step

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

    154 currentNode->setNextNode(node);

The following example shows stepping by instruction (stepi). To see stepping over calls, see the example of the next command.

GDB Mode

(idb) x /8i $pc

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

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

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

0x0804ae75 <append+33>:                 pushl    %edi

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

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

0x0804ae7c <append+40>:                 call     0x08051be2 <getNextNode>

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

(idb) stepi

0x0804ae70      151         Node* currentNode = _firstNode;

(idb) x /1i $pc

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

(idb) stepi $count - 1

0x0804ae70      151         Node* currentNode = _firstNode;

(idb) x /1i $pc

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

(idb) stepi

0x0804ae72      151         Node* currentNode = _firstNode;

(idb) x /1i $pc

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

DBX Mode

(idb) $curpc/8i

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

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

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

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

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

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

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

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

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

(idb) stepi

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

(idb) stepi $count - 1

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

(idb) stepi

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