Common Queries
Basic Analysis
Methods
List all methods that match
.*parse.*to the shell
ocular> cpg.method.name(".*parse.*").name.lDump all methods that match
.*parse.*to the shell (syntax-highlighted)
ocular> cpg.method.name(".*parse.*").dumpCreate K-V pair of all methods that match
.*parse.*and their code
ocular> cpg.method.name(".*parse.*").map( m=> (m.name, m.start.dump)).lDump all methods that match
.*parse.*to file (no highlighting)
ocular> cpg.method.name(".*parse.*").dumpRaw |> "/tmp/foo.c"View all methods that match
.*parse.*in a pager (e.g., less)
ocular> browse(cpg.method.name(".*parse.*").dump)Dump dot representations of ASTs for all methods that match
parseinto file
ocular> cpg.method.name("parse_public_key_packet").dot |> "/tmp/foo.dot"Find all local variables defined in a method
ocular> cpg.method.name("parse_public_key_packet").local.name.lFind which file and line number they are in
Find the type of the first local variable defined in a method
Find all outgoing calls (call-sites) in a method
Find which method calls a method
Types and Filters
List all local variables of type
vlc_.*
Find member variables of a struct
Find local variables and filter them by their type
Which method are they used in?
Get the filenames where these methods are
Insights
Overview
Identify functions with more than 4 parameters
Identify functions with > 4 control structures (cyclomatic complexity)
Identify functions with more than 500 lines of code
Identify functions with multiple return statements
Identify functions with more than 4 loop statements (including loops nested inside other loops)
Identify functions with nesting depth larger than 3
Calls into libraries
All names of external methods used by the program
All calls to strcpy
All methods that call strcpy
Looking into parameters: second argument to sprintf is NOT a literal
Quickly see this method above
Last updated
Was this helpful?