function::usymline - Linux


Overview

function::usymline interrogates C++ classes, functions, and variables for user-specified symbols. It allows for easy and efficient analysis of source code for specific symbols.

Syntax

function::usymline [options] [<file> | --all]

Options/Flags

  • -a, –all: Scans all source files in the current directory and subdirectories.
  • -c, –count-files: Prints the number of files containing the specified symbol(s).
  • -f, –function-symbol: Searches for the specified function symbol.
  • -g, –global-symbol: Searches for the specified global variable or class symbol.
  • -s, –symbol: Specifies the symbol to search for.
  • -t, –type: Specifies the type of symbol to search for (function or global).
  • -v, –verbose: Displays more detailed output, including the path and line number where symbols are found.

Examples

Simple usage:

function::usymline -s MyFunction

Search for all functions named "MyFunction":

function::usymline -f MyFunction

Search for all global variables named "MyVariable":

function::usymline -g MyVariable

Count files containing the symbol "MySymbol":

function::usymline -c -s MySymbol

Common Issues

  • No matching symbols found: Ensure that the specified symbol exists in the source code and that the search parameters are correct.
  • Access denied: Verify that you have the necessary permissions to access the source files.

Integration

Combine with grep:

function::usymline -s MyFunction | grep -E "int|float"

Parse results with Python:

import subprocess

output = subprocess.run(["function::usymline", "-s", "MyFunction"], stdout=subprocess.PIPE).stdout
symbols = [line.strip() for line in output.decode("utf-8").splitlines()]

Related Commands

  • c++filt
  • ctags
  • nm