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, two step commands continue executing a C++ program:

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 0x0804c579]

    152         while (currentNode->getNextNode())

(idb) step

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

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

(idb) step

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

    152         while (currentNode->getNextNode())

(idb) step

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

    154 currentNode->setNextNode(node);

(idb) step

stopped at [void Node::setNextNode(class Node*):82 0x080534c3]

     82 void  Node::setNextNode(Node* next)  { _nextNode = next;}

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=0xbfff9fe8) at src/x_list.cxx:81

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

(idb) step

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

152         while (currentNode->getNextNode())

(idb) step

154 currentNode->setNextNode(node);

(idb) step

Node::setNextNode (this=0xbfff9fe8, next=0x805e608) at src/x_list.cxx:82

82 void  Node::setNextNode(Node* next)  { _nextNode = next;}

 

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

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) stepi

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

(idb) stepi $count - 1

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

(idb) stepi

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) stepi

0x0804c574      151         Node* currentNode = _firstNode;

(idb) x /1i $pc

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

(idb) stepi $count - 1

0x0804c574      151         Node* currentNode = _firstNode;

(idb) x /1i $pc

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

(idb) stepi

0x0804c576      151         Node* currentNode = _firstNode;

(idb) x /1i $pc

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