Searching the Content of Source Files

The following search commands search through the current source file to help you find the lines to list:

DBX Mode

search_source_file_command

        : / [ string ]

        | ? [ string ]

GDB Mode

search_source_file_command

        : forward-search [ string ]

        | reverse-search [ string ]

DBX Mode

Note:

The string is actually just the rest of the line, not a string literal. The rest of the line is still having alias expansion done on it.

Use a slash (/) to search forward from the most recently listed line; use a question mark (?) to search backward. Like most searches, it will stop at the end (or beginning) of the file being searched, and will wrap if the command is repeated at that point.

When the string is omitted, the previous search continues from where it found the string. When the string is present, the search starts from either the start (/) or the end (?) of the current line.

When a match is found, the debugger lists the line number and the line. That line becomes the starting point for any further searches, or for a list command. For example:

  1. To locate _firstNode:

    DBX Mode

    (idb) /_firstNode

         69     NODETYPE* _firstNode;

    GDB Mode

    (idb) forward-search _firstNode

    69     NODETYPE* _firstNode;

  2. Then to locate append before line 69:

    DBX Mode

    (idb) ?append

         65     void      append  (NODETYPE* const node);

    GDB Mode

    (idb) reverse-search append

    65     void      append  (NODETYPE* const node);

  3. Then to locate append after line 65:

    DBX Mode

    (idb) /append

        145 void List<NODETYPE>::append(NODETYPE* const node)

    GDB Mode

    (idb) forward-search append

    145 void List<NODETYPE>::append(NODETYPE* const node)

The debugger provides parameterized aliases and debugger variables of arbitrary types. You can use these to do list traversal (see the array navigation example).