Search code examples
gdb

Is there a way to execute ```info sources``` command with more than one pattern?


When I'm trying to search for sources, and specify both: directory name and base name (or file name pattern - doesn't make any difference) it takes everything after the first option name as a pattern and shows nothing. Is there any special syntax I missed?

(gdb) info sources -dirname src -basename stat
Source files for which symbols have been read in:
(dirname matching regular expression "src -basename stat")

Solution

  • Right now, info sources takes a maximum of one option, either -dirname or -basename, and uses basic regular expressions.

    If you have access to POSIX commands, you can match multiple patterns by piping the output of info sources to egrep or grep -E, which use extended regular expressions, including alternation.

    Here's how to match multiple basenames (assuming pathname components are separated by /):

    pipe info sources | sed 's/, /\n/g' | grep -E '(word1|word2)[^/]*$'