cscope

cscope is an interactive, screen-oriented tool that allows the user to browse through C source files for specified elements of code. By default, cscope examines the C (.c and .h), lex (.l), and yacc (.y) source files in the current directory. for more info visit man cscope.

Create cscope cross-reference(or database)

 cscope -bcqR

Open cscope to browse code

cscope -d

It will will display this menu:

Screenshot

So the whole screen is devided into two part

  1. Input Area Screenshot

  2. Result Area Screenshot

By looking the curser, you can get which area you are in. Bydefault, cursor will be in input area.

Press the or keys repeatedly to move to the desired input field, type the text to search for, and then press the key to search and display results.

After searching it will display this menu:

Press +d to exit from cscope

Script to create cscore with selectable directory

#!/bin/bash

if [ 0 -eq $# ]; then
    echo "Uses: $0 dir1 dir2 ..."
    exit
fi

echo $#

find_cmd="find"

for path in "$@"
do
    find_cmd+=" "
    find_cmd+="$path"
done

for ext in cc hh h c cpp p1 xml py
do
    find_cmd+=" "
    if [ "cc" == $ext ]; then
        find_cmd+="-name \"*.$ext\""
    else
        find_cmd+="-o -name \"*.$ext\""
    fi
done

find_cmd+=" > cscope.files"

echo $find_cmd

eval $find_cmd

cscope -q -b -i cscope.files

ctags -L cscope.files


©2023-2024 rculock.com