JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++
Binaries

Procedures: cs_pdg.h

Defines a set of procedure (cs_pdg) operations for CodeSonar.



Links


Defines

#define CS_PDG_H
#define CS_PDG_NULL (cs_pdg_get_null()) The null cs_pdg.
#define CS_PDG_INL_H

Types

typedef cs_pdg_kind
Definition typedef __cs_pdg_kind_enum cs_pdg_kind
Notes Enumeration of kinds associated with cs_pdg.
enum __cs_pdg_kind_enum
Definition typedef enum { } __cs_pdg_kind_enum
Notes Enumeration of PDG kinds.

Functions

cs_pdg_kind cs_pdg_get_kind ( cs_pdg pdg )
Retrieve the cs_pdg_kind of a cs_pdg.
cs_result cs_pdg_kind_name ( cs_pdg_kind kind, cs_const_string * out_string )
Retrieve the name of a cs_pdg_kind.
cs_result cs_pdg_find ( cs_const_string proc_name, cs_pdg * out_pdg )
Retrieve the cs_pdg with a given name.
cs_result cs_pdg_compilation_unit ( cs_pdg pdg, cs_file_path compilation_unit, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Retrieve the path of the top-level file in the compilation unit containing a given cs_pdg.
cs_result cs_pdg_ast ( cs_pdg pdg, cs_ast_family ast_family, cs_ast * out_ast )
Retrieve the cs_ast for a given cs_pdg.
cs_result cs_pdg_file_line ( cs_pdg pdg, cs_sfid * out_sfid, cs_line * out_line )
Find the cs_sfid and cs_line of the smallest offset of the entry vertex for a given cs_pdg.
cs_result cs_pdg_abs_loc ( cs_pdg pdg, cs_abs_loc * out_loc )
Retrieve the cs_abs_loc for a specified cs_pdg.
cs_result cs_pdg_compilation_uid ( cs_pdg pdg, cs_uid * out_uid )
Retrieve the cs_uid of the compilation unit containing a specified cs_pdg.
cs_result cs_pdg_entry_vertex ( cs_pdg pdg, cs_pdg_vertex * out_vertex )
Retrieve the entry cs_pdg_vertex of a specified cs_pdg.
cs_result cs_pdg_preexit_vertex ( cs_pdg pdg, cs_pdg_vertex * out_vertex )
Return the preexit cs_pdg_vertex of a specified cs_pdg.
cs_result cs_pdg_exit_vertex ( cs_pdg pdg, cs_pdg_vertex * out_vertex )
Return the exit cs_pdg_vertex of a specified cs_pdg.
csint64 cs_pdg_procedure_id ( cs_pdg pdg )
Find the unique identifier of a given cs_pdg.
cs_result cs_pdg_procedure_name ( cs_pdg pdg, cs_string proc_name, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Retrieve the name of the procedure associated with a cs_pdg.
cs_result cs_pdg_friendly_name ( cs_pdg pdg, cs_string proc_name, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Retrieve the user-friendly name of the procedure associated with a cs_pdg.
cs_result cs_pdg_friendly_name64 ( cs_pdg pdg, cs_const_string64 * proc_name )
Retrieve the user-friendly name of the procedure associated with a cs_pdg, as a cs_const_string64.
cs_result cs_pdg_basename ( cs_pdg pdg, cs_string bname, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Retrieve the basename of the procedure associated with a cs_pdg.
cs_result cs_pdg_vertices ( cs_pdg pdg, cs_const_pdg_vertex_set * out_vertex )
Retrieve a cs_pdg_vertex_set containing all vertices of a specified cs_pdg.
cs_result cs_pdg_locals_iter_first ( cs_pdg pdg, cs_abs_loc * abs_loc, cs_pdg_locals_iter * iter )
Retrieve the symbol (cs_abs_loc) corresponding to the first local variable declared in a specified cs_pdg and open a cs_pdg_locals_iter for the remaining local variables.
cs_result cs_pdg_locals_iter_next ( cs_abs_loc * abs_loc, cs_pdg_locals_iter * iter )
Advance the provided cs_pdg_locals_iter iterator and retrieve the next element.
cs_result cs_pdg_locals_iter_close ( cs_pdg_locals_iter * iter )
Close a cs_pdg_locals_iter iterator.
cs_result cs_pdg_call_sites ( cs_pdg pdg, cs_pdg_call_sites_flags flags, cs_pdg_vertex call_sites[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Retrieve a list of cs_pdg_vertex elements representing the call sites within a specified cs_pdg.
cs_size_t cs_pdg_call_sites_count ( cs_pdg pdg, cs_pdg_call_sites_flags flags )
Get the number of call sites in a cs_pdg.
cs_result cs_pdg_call_sites_iter_first ( cs_pdg pdg, cs_pdg_call_sites_flags flags, cs_pdg_vertex * call_site, cs_pdg_call_sites_iter * itr )
Open a cs_pdg_call_sites_iter iterator for traversing the call sites in a specified cs_pdg, and retrieve the first call site cs_pdg_vertex from the iterator.
cs_result cs_pdg_call_sites_iter_next ( cs_pdg_vertex * call_site, cs_pdg_call_sites_iter * itr )
Advance the provided cs_pdg_call_sites_iter iterator and retrieve the next element.
cs_result cs_pdg_call_sites_iter_close ( cs_pdg_call_sites_iter * itr )
Close a cs_pdg_call_sites_iter iterator.
cs_size_t cs_pdg_callers_count ( cs_pdg pdg )
Get the number of call sites to a cs_pdg.
cs_result cs_pdg_callers_iter_first ( cs_pdg pdg, cs_pdg_vertex * calling_site, cs_pdg_callers_iter * itr )
Open a cs_pdg_callers_iter iterator for traversing the call sites to a specified cs_pdg, and retrieve the first call site cs_pdg_vertex from the iterator.
cs_result cs_pdg_callers_iter_next ( cs_pdg_vertex * calling_site, cs_pdg_callers_iter * itr )
Advance the provided cs_pdg_callers_iter iterator and retrieve the next element.
cs_result cs_pdg_callers_iter_close ( cs_pdg_callers_iter * itr )
Close a cs_pdg_callers_iter iterator.
cs_result cs_pdg_formals_in ( cs_pdg pdg, cs_pdg_vertex_set * out_set )
Retrieve a cs_pdg_vertex_set containing the formal-in and global-formal-in vertices of a cs_pdg.
cs_result cs_pdg_formals_in_as_list ( cs_pdg pdg, cs_pdg_vertex formal_ins[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Retrieve a list containing the formal-in vertices of a cs_pdg in the order in which they occur in the code.
cs_result cs_pdg_formal_in ( cs_pdg pdg, cs_size_t fi_rank, cs_pdg_vertex * out_vertex )
Retrieve the cs_pdg_vertex corresponding to the formal-in parameter of pdg with the specified rank.
cs_result cs_pdg_formals_out ( cs_pdg pdg, cs_pdg_vertex_set * out_set )
Retrieve a cs_pdg_vertex_set containing the formal-in and global-formal-out vertices of a cs_pdg.
cs_result cs_pdg_formals_out_as_list ( cs_pdg pdg, cs_pdg_vertex formal_outs[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Retrieve a list containing the formal-out vertices of a cs_pdg in the order in which they occur in the code.
cs_result cs_pdg_retrieve_vertex ( cs_pdg pdg, csint64 id, cs_pdg_vertex * out_vertex )
Retrieve the cs_pdg_vertex in a given cs_pdg with a given ID.
cs_boolean cs_pdg_has_vararg ( cs_pdg pdg )
Check if a cs_pdg has a formal vararg parameter.
const char * cs_pdg_string ( cs_pdg pdg )
Get the name of the procedure associated with a cs_pdg.
const char * cs_pdg_friendly_string ( cs_pdg pdg )
Get the user-friendly name of the procedure associated with a cs_pdg.
const char * cs_pdg_basename_string ( cs_pdg pdg )
Get the basename of the procedure associated with a cs_pdg.
cs_hash_t cs_pdg_stable_hash ( cs_pdg pdg )
Get a hash value for a cs_pdg, with stable results across sufficiently-similar analyses.
int cs_pdg_stable_compare ( cs_pdg pdg_a, cs_pdg pdg_b )
Compare two cs_pdg objects, with stable results across sufficiently-similar analyses.
cs_result cs_pdg_get_handle ( cs_pdg pdg, cs_string pdg_handle, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get a storable handle for a procedure (cs_pdg).
cs_result cs_pdg_lookup_handle ( cs_const_string pdg_handle, cs_pdg * pdg )
Retrieve a procedure (cs_pdg) from a handle.
cs_boolean cs_pdg_equal ( cs_pdg pdg1, cs_pdg pdg2 )
Check: are two cs_pdg objects equal?
int cs_pdg_compare ( cs_pdg pdg_a, cs_pdg pdg_b )
Compare two cs_pdg objects.
cs_hash_t cs_pdg_hash ( cs_pdg pdg )
Hash function for cs_pdg.
cs_boolean cs_pdg_is_null ( cs_pdg pdg )
Determine whether a cs_pdg is null.
cs_pdg cs_pdg_get_null ( )
Return a null cs_pdg.

Function Descriptions

Function cs_pdg_get_kind
cs_pdg_kind cs_pdg_get_kind (
Retrieve the cs_pdg_kind of a cs_pdg.
Parameters
pdg [in] The cs_pdg for which to find the cs_pdg_kind.
Returns The cs_pdg_kind of pdg.
Function cs_pdg_kind_name
cs_result cs_pdg_kind_name (
Retrieve the name of a cs_pdg_kind.
Parameters
kind [in] The cs_pdg_kind for which to retrieve the name.
out_string [out] The string representation of the name of kind.
Returns A cs_result:
Time-Complexity O(1)
Function cs_pdg_find
cs_result cs_pdg_find (
Retrieve the cs_pdg with a given name.
Parameters
proc_name [in] The name of a procedure.
out_pdg [out] The first cs_pdg found whose name is proc_name.
Returns A cs_result:
Time-Complexity O(n) where n is the number of procedures in the program.
Notes It is possible for a project to have multiple cs_pdg objects whose name is proc_name. For example, two compilation units may each have a static function called proc_name. In this case, cs_pdg_find() will return the first one it encounters.
Function cs_pdg_compilation_unit
cs_result cs_pdg_compilation_unit (
Retrieve the path of the top-level file in the compilation unit containing a given cs_pdg.
Parameters
pdg [in] The cs_pdg for which the path is to be obtained.
compilation_unit [out] A user-allocated buffer, to be populated with the compilation unit filename of pdg. Note that this is the unnormalized filename as returned by cs_file_get_name().
capacity_bytes [in] The capacity of compilation_unit, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire compilation unit file name.
Returns A cs_result:
  • CS_TRUNCATED if compilation_unit is not large enough to hold the entire filename (and so the filename is truncated),
  • CS_SUCCESS otherwise.
Notes Write the path of the top-level file in the compilation unit containing a given cs_pdg into a user-allocated buffer. If the buffer is not large enough to hold the entire path, the path is truncated to fit into the buffer.

Call this function with compilation_unit NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire path.

Function cs_pdg_ast
cs_result cs_pdg_ast (
Retrieve the cs_ast for a given cs_pdg.
Parameters
pdg [in] The cs_pdg for which to get the AST
ast_family [in] a single cs_pdg may be associated with multiple ASTs. This specifies which one to get. Each language dependent AST header file will define its AST families.
out_ast [out] The cs_ast of pdg.
Returns A cs_result:
Time-Complexity O(1)
Function cs_pdg_file_line
cs_result cs_pdg_file_line (
Find the cs_sfid and cs_line of the smallest offset of the entry vertex for a given cs_pdg.
Parameters
pdg [in] The cs_pdg for which the sfid and line are to be obtained.
out_sfid [out] The cs_sfid of the file containing the entry vertex.
out_line [out] The cs_line on which the entry vertex occurs in the file denoted by out_sfid.
Returns A cs_result:
  • CS_NO_POSITION if pdg has kind cs_pdg_kind_undefined or its entry vertex does not have a position.
  • CS_SUCCESS otherwise.
Time-Complexity O(n) where n is the number of pairs in cs_pdg_vertex_charpos(pdg_entry_vertex,...)
Function cs_pdg_abs_loc
cs_result cs_pdg_abs_loc (
Retrieve the cs_abs_loc for a specified cs_pdg.
Parameters
pdg [in] The cs_pdg for which the cs_abs_loc is to be obtained.
out_loc [out] A cs_abs_loc corresponding to pdg.
Returns CS_SUCCESS on success.
Function cs_pdg_compilation_uid
cs_result cs_pdg_compilation_uid (
Retrieve the cs_uid of the compilation unit containing a specified cs_pdg.
Parameters
pdg [in] The cs_pdg whose compilation unit cs_uid is to be obtained.
out_uid [out] The cs_uid of the compilation unit containing pdg.
Returns CS_SUCCESS on success.
Function cs_pdg_entry_vertex
cs_result cs_pdg_entry_vertex (
Retrieve the entry cs_pdg_vertex of a specified cs_pdg.
Parameters
pdg [in] The cs_pdg for which the entry cs_pdg_vertex is to be obtained.
out_vertex [out] The entry cs_pdg_vertex (whose cs_vertex_kind is cs_vertex_kind_entry) for pdg.
Returns A cs_result:
Function cs_pdg_preexit_vertex
cs_result cs_pdg_preexit_vertex (
Return the preexit cs_pdg_vertex of a specified cs_pdg.
Parameters
pdg [in] The cs_pdg for which the preexit cs_pdg_vertex is to be obtained.
out_vertex [out] The preexit cs_pdg_vertex (whose cs_vertex_kind is cs_vertex_kind_preexit ) for pdg.
Returns A cs_result:
Notes Retrieves the preexit cs_pdg_vertex of pdg. The preexit vertex has no incoming or outgoing control dependences or data dependences. It is part of the CFG.
Function cs_pdg_exit_vertex
cs_result cs_pdg_exit_vertex (
Return the exit cs_pdg_vertex of a specified cs_pdg.
Parameters
pdg [in] The cs_pdg for which the exit cs_pdg_vertex is to be obtained.
out_vertex [out] The exit cs_pdg_vertex (whose cs_vertex_kind is cs_vertex_kind_exit ) for pdg.
Returns A cs_result:
Notes Retrieves the exit cs_pdg_vertex of pdg. The exit vertex has no incoming or outgoing control dependences or data dependences. It is part of the CFG.
Function cs_pdg_procedure_id
csint64 cs_pdg_procedure_id (
Find the unique identifier of a given cs_pdg.
Parameters
pdg [in] The cs_pdg for which the id is to be obtained.
Returns The unique identifier of pdg.
  • In an incremental analysis, a procedure will have the same identifier that it did in the incremental parent if and only if the containing compilation unit is not recompiled.
  • In all other cases identifiers do not persist between different analyses of the same project (or the same code in a different project).
Notes To get a cs_pdg given its ID, use cs_sdg_retrieve_pdg().
Function cs_pdg_procedure_name
cs_result cs_pdg_procedure_name (
Retrieve the name of the procedure associated with a cs_pdg.
Parameters
pdg [in] The cs_pdg whose name is to be obtained.
proc_name [out] A user-allocated buffer to be populated with the name of the procedure associated with pdg.
capacity_bytes [in] The capacity of proc_name, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire name of the procedure associated with pdg.
Returns A cs_result:
  • CS_TRUNCATED if proc_name is not large enough to hold the entire procedure name (and so the procedure name is truncated),
  • CS_SUCCESS otherwise.
Notes Retrieves the name of the procedure associated with a cs_pdg and writes it to proc_name. If proc_name is not large enough to hold the entire name, the name is truncated to fit into proc_name.

Call this function with proc_name NULL and capacity_bytes 0 to obtain the required capacity of proc_name.

Function cs_pdg_friendly_name
cs_result cs_pdg_friendly_name (
Retrieve the user-friendly name of the procedure associated with a cs_pdg.
Parameters
pdg [in] The cs_pdg whose name is to be obtained.
proc_name [out] A user-allocated buffer to be populated with the name of the procedure associated with pdg.
capacity_bytes [in] The capacity of proc_name, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire name of the procedure associated with pdg.
Returns A cs_result:
  • CS_TRUNCATED if proc_name is not large enough to hold the entire procedure name (and so the procedure name is truncated),
  • CS_SUCCESS otherwise.
Notes Retrieves the user-friendly name of the procedure associated with a cs_pdg and writes it to proc_name. If proc_name is not large enough to hold the entire name, the name is truncated to fit into proc_name.

Call this function with proc_name NULL and capacity_bytes 0 to obtain the required capacity of proc_name.

For C++ methods, proc_name will be of the form ClassName::MethodName.

  • Namespace::ClassName::MethodName if the class is a member of a namespace.
  • Class1Name::ClassName::MethodName if the class is nested inside another class.
  • (etc)

Use this function only to retrieve user-friendly procedure names for display.

In some cases the "friendly name" of a cs_pdg will differ markedly from its "procedure name". For example, for the following program:

void foo() asm("bar");

void foo() {
  printf("1234");
}

int main() {
  foo();
}

The cs_pdg for function foo() has friendly name "foo", but procedure name "bar".
Function cs_pdg_friendly_name64
cs_result cs_pdg_friendly_name64 (
Retrieve the user-friendly name of the procedure associated with a cs_pdg, as a cs_const_string64.
Parameters
pdg [in] The cs_pdg whose name is to be obtained.
proc_name [out] A cs_const_string64 to be populated with the name of the procedure associated with pdg.
Returns CS_SUCCESS
Notes Retrieves the user-friendly name of the procedure associated with a cs_pdg and puts it in proc_name. Unlike cs_pdg_friendly_name(), cs_pdg_friendly_name64() retains any trailing tick marks that CodeSurfer/CodeSonar has appended to the name (e.g., 1,2, etc.).

For C++ methods, proc_name will be of the form ClassName::MethodName.

  • Namespace::ClassName::MethodName if the class is a member of a namespace.
  • Class1Name::ClassName::MethodName if the class is nested inside another class.
  • (etc)

Use this function only to retrieve user-friendly procedure names for display.

In some cases the "friendly name" of a cs_pdg will differ markedly from its "procedure name". For example, for the following program:

void foo() asm("bar");

void foo() {
  printf("1234");
}

int main() {
  foo();
}

The cs_pdg for function foo() has friendly name "foo", but procedure name "bar".
Function cs_pdg_basename
cs_result cs_pdg_basename (
Retrieve the basename of the procedure associated with a cs_pdg.
Parameters
pdg [in] The cs_pdg whose basename is to be obtained.
bname [out] A user-allocated buffer to be populated with the basename of the procedure associated with pdg.
capacity_bytes [in] The capacity of bname, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire basename of the procedure associated with pdg.
Returns A cs_result:
  • CS_TRUNCATED if bname is not large enough to hold the entire procedure basename (and so the basename is truncated),
  • CS_SUCCESS otherwise.
Notes Retrieves the basename of the procedure associated with a cs_pdg and writes it to bname. If bname is not large enough to hold the entire basename, the basename is truncated to fit into bname.

The basename of a procedure is defined with respect to the friendly name (as obtained with cs_pdg_friendly_name()) as follows.

  • If the friendly name contains one or more scope resolution operators "::", the basename is the method name component (i.e., rightmost token). For example, if the friendly name is ClassName::MethodName, the basename is MethodName.
  • Otherwise, the basename is the same as the friendly name.

When cross-referencing queries (cs_xref_def_iter_first(), cs_xref_occ_iter_first()) are executed, the specified tokens are compared against procedure basenames, and query results (cs_xref_tuple) from procedure name matches contain a hash of this basename. Therefore, use cs_pdg_basename() to extract any procedure name that you want to use as a cross-referencing query token or compare against query results.

Call this function with bname NULL and capacity_bytes 0 to obtain the required capacity of name.

Function cs_pdg_vertices
cs_result cs_pdg_vertices (
Retrieve a cs_pdg_vertex_set containing all vertices of a specified cs_pdg.
Parameters
pdg [in] The cs_pdg for which the cs_pdg_vertex_set is to be obtained.
out_vertex [out] A cs_pdg_vertex_set containing all vertices of pdg. This set is immutable and must not be modified or freed.
Returns A cs_result:
Function cs_pdg_locals_iter_first
cs_result cs_pdg_locals_iter_first (
Retrieve the symbol (cs_abs_loc) corresponding to the first local variable declared in a specified cs_pdg and open a cs_pdg_locals_iter for the remaining local variables.
Parameters
pdg [in] The cs_pdg for which to retrieve local variables.
abs_loc [out] The cs_abs_loc corresponding to the first local variable in pdg.
iter [out] A cs_pdg_locals_iter iterator opened to traverse the symbols (cs_abs_loc) corresponding to the local variables of pdg.
Returns A cs_result:
Notes To iterate over nonlocal variables for a compilation unit, use a cs_uid_nonlocals_iter iterator (cs_uid_nonlocals_iter_first(), cs_uid_nonlocals_iter_next(), cs_uid_nonlocals_iter_close()). Note that neither a UID nonlocals iterator nor a PDG locals iterator will access symbols (cs_abs_loc) of kind cs_abs_loc_kind_param. To iterate over these, call cs_abs_loc_get_param() with increasing num argument until it returns CS_ELEMENT_NOT_PRESENT.
Function cs_pdg_locals_iter_next
cs_result cs_pdg_locals_iter_next (
Advance the provided cs_pdg_locals_iter iterator and retrieve the next element.
Parameters
abs_loc [out] The cs_abs_loc corresponding to the next local variable retrieved from iter.
iter [out] The cs_pdg_locals_iter iterator from which to retrieve the next child.
Returns A cs_result:
Function cs_pdg_locals_iter_close
cs_result cs_pdg_locals_iter_close (
Close a cs_pdg_locals_iter iterator.
Parameters
iter [out] The cs_pdg_locals_iter iterator to close.
Returns CS_SUCCESS on successful close.
Function cs_pdg_call_sites
cs_result cs_pdg_call_sites (
Retrieve a list of cs_pdg_vertex elements representing the call sites within a specified cs_pdg.
Parameters
pdg [in] The cs_pdg for which the cs_pdg_vertex list is to be obtained.
flags [in] The kind or kinds of call sites to retrieve.
call_sites [out] A user-allocated cs_pdg_vertex array to be populated with the list of call sites.
capacity_bytes [in] The capacity of call_sites, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire list of call sites.
Returns A cs_result:
Time-Complexity O(n) where n is the number of call sites.
Notes Call this function with call_sites NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire list.
Function cs_pdg_call_sites_count
cs_size_t cs_pdg_call_sites_count (
Get the number of call sites in a cs_pdg.
Parameters
pdg [in] The cs_pdg of interest.
flags [in] The kind or kinds of call sites to count.
Returns The number of call sites in pdg.
Notes This value will match the iteration count of an equivalent cs_pdg_call_sites_iter.
Function cs_pdg_call_sites_iter_first
cs_result cs_pdg_call_sites_iter_first (
Open a cs_pdg_call_sites_iter iterator for traversing the call sites in a specified cs_pdg, and retrieve the first call site cs_pdg_vertex from the iterator.
Parameters
pdg [in] The cs_pdg whose call sites are to be iterated over.
flags [in] The kind or kinds of call sites to iterate over.
call_site [out] The cs_pdg_vertex corresponding to the first call site in pdg.
itr [out] A cs_pdg_call_sites_iter iterator opened to traverse the call sites in pdg.
Returns A cs_result:
Notes For a fixed project build and cs_pdg, the iteration order is deterministic but does not correspond to the execution order or source file location of the call sites.
Function cs_pdg_call_sites_iter_next
cs_result cs_pdg_call_sites_iter_next (
Advance the provided cs_pdg_call_sites_iter iterator and retrieve the next element.
Parameters
call_site [out] The cs_pdg_vertex corresponding to the next call site retrieved from itr.
itr [out] The cs_pdg_call_sites_iter iterator from which to retrieve the next call site.
Returns A cs_result:
Function cs_pdg_call_sites_iter_close
cs_result cs_pdg_call_sites_iter_close (
Close a cs_pdg_call_sites_iter iterator.
Parameters
itr [out] The cs_pdg_call_sites_iter iterator to close.
Returns CS_SUCCESS on successful close.
Function cs_pdg_callers_count
cs_size_t cs_pdg_callers_count (
Get the number of call sites to a cs_pdg.
Parameters
pdg [in] The cs_pdg of interest.
Returns The number of call sites to pdg.
Notes This value will match the iteration count of an equivalent cs_pdg_callers_iter.
Function cs_pdg_callers_iter_first
cs_result cs_pdg_callers_iter_first (
Open a cs_pdg_callers_iter iterator for traversing the call sites to a specified cs_pdg, and retrieve the first call site cs_pdg_vertex from the iterator.
Parameters
pdg [in] The cs_pdg for which to retrieve calling site.
calling_site [out] The cs_pdg_vertex corresponding to the first call site to pdg.
itr [out] A cs_pdg_callers_iter iterator opened to traverse the call sites to pdg.
Returns A cs_result:
Notes For a fixed project build and cs_pdg, the iteration order is deterministic but does not correspond to the execution order or source file location of the call sites.
Function cs_pdg_callers_iter_next
cs_result cs_pdg_callers_iter_next (
Advance the provided cs_pdg_callers_iter iterator and retrieve the next element.
Parameters
calling_site [out] The cs_pdg_vertex corresponding to the next call site retrieved from itr.
itr [out] The cs_pdg_callers_iter iterator from which to retrieve the next call site.
Returns A cs_result:
Function cs_pdg_callers_iter_close
cs_result cs_pdg_callers_iter_close (
Close a cs_pdg_callers_iter iterator.
Parameters
itr [out] The cs_pdg_callers_iter iterator to close.
Returns CS_SUCCESS on successful close.
Function cs_pdg_formals_in
cs_result cs_pdg_formals_in (
Retrieve a cs_pdg_vertex_set containing the formal-in and global-formal-in vertices of a cs_pdg.
Parameters
pdg [in] The cs_pdg for which the formal-in vertices are to be obtained.
out_set [out] A cs_pdg_vertex_set containing the formal-ins (including global-formal-ins) of pdg.
Returns A cs_result:
Notes It is the responsibility of the user to close the returned set: use cs_pdg_vertex_set_close().

Functions cs_pdg_formals_in() and cs_pdg_formals_in_as_list() retrieve different sets of vertices:

Function cs_pdg_formals_in_as_list
cs_result cs_pdg_formals_in_as_list (
Retrieve a list containing the formal-in vertices of a cs_pdg in the order in which they occur in the code.
Parameters
pdg [in] The cs_pdg for which the list of formal-ins is to be obtained.
formal_ins [out] A user-allocated cs_pdg_vertex array to be populated with the list of the formal-in vertices of pdg.
capacity_bytes [in] The capacity of formal_ins, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire list of formal-in vertices.
Returns A cs_result:
  • CS_PDG_IS_UNDEFINED if pdg represents an undefined function.
  • CS_TRUNCATED if formal_ins is not large enough to hold the entire list of formal-in vertices (and so the list was truncated).
  • CS_SUCCESS otherwise.
Notes The elements of formal_ins are the formal-in vertices of pdg in the order in which they occur in the code.

Functions cs_pdg_formals_in() and cs_pdg_formals_in_as_list() retrieve different sets of vertices:

Call this function with formal_ins NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire list.

Function cs_pdg_formal_in
cs_result cs_pdg_formal_in (
Retrieve the cs_pdg_vertex corresponding to the formal-in parameter of pdg with the specified rank.
Parameters
pdg [in] The cs_pdg for which the formal-in is to be obtained.
fi_rank [in] The rank of the desired parameter.
out_vertex [out] The cs_pdg_vertex corresponding to the formal-in parameter of pdg whose rank is fi_rank.
Returns A cs_result:
Notes Rank starts at 1, with globals coming first, followed by non-globals. Note that only non-globals can be retrieved by this function.
Function cs_pdg_formals_out
cs_result cs_pdg_formals_out (
Retrieve a cs_pdg_vertex_set containing the formal-in and global-formal-out vertices of a cs_pdg.
Parameters
pdg [in] The cs_pdg whose formal-outs (including global-formal-outs) are to be obtained.
out_set [out] A cs_pdg_vertex_set containing the formal-outs (including global-formal-outs) of pdg.
Returns A cs_result:
Notes It is the responsibility of the user to close the returned set: use cs_pdg_vertex_set_close().
Function cs_pdg_formals_out_as_list
cs_result cs_pdg_formals_out_as_list (
Retrieve a list containing the formal-out vertices of a cs_pdg in the order in which they occur in the code.
Parameters
pdg [in] The cs_pdg for which the list of formal-outs is to be obtained.
formal_outs [out] A user-allocated cs_pdg_vertex array to be populated with the list of the formal-out vertices of pdg.
capacity_bytes [in] The capacity of formal_outs, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire list of formal-out vertices.
Returns A cs_result:
  • CS_PDG_IS_UNDEFINED if pdg represents an undefined function.
  • CS_TRUNCATED if formal_outs is not large enough to hold the entire list of formal-out vertices (and so the list was truncated),
  • CS_SUCCESS otherwise.
Notes The elements of formal_outs are the formal-out vertices of pdg in the order in which they occur in the code.

Call this function with formal_outs NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire list.

Function cs_pdg_retrieve_vertex
cs_result cs_pdg_retrieve_vertex (
Retrieve the cs_pdg_vertex in a given cs_pdg with a given ID.
Parameters
pdg [in] The cs_pdg in which to look for the cs_pdg_vertex.
id [in] The ID of the desired cs_pdg_vertex.
out_vertex [out] The cs_pdg_vertex in pdg whose unique identifier is id.
Returns A cs_result:
Time-Complexity O(n) where n is the number of vertices in pdg.
Notes To get the ID of a cs_pdg_vertex, use cs_pdg_vertex_id().
Function cs_pdg_has_vararg
cs_boolean cs_pdg_has_vararg (
Check if a cs_pdg has a formal vararg parameter.
Parameters
pdg [in] The cs_pdg to check.
Returns cs_true if pdg has a formal vararg parameter; cs_false otherwise.
Function cs_pdg_string
const char * cs_pdg_string (
Get the name of the procedure associated with a cs_pdg.
Parameters
pdg [in] The cs_pdg whose name is to be obtained.
Returns A pointer to a buffer containing the name of the procedure associated with pdg (as a char*). The buffer is only valid until another API function is invoked.
Notes Do not modify or free the returned buffer.

This function entails less user overhead than cs_pdg_procedure_name(), and so can be more convenient to use; the tradeoff is that the returned value is not under user control and has a constrained lifetime.

Function cs_pdg_friendly_string
const char * cs_pdg_friendly_string (
Get the user-friendly name of the procedure associated with a cs_pdg.
Parameters
pdg [in] The cs_pdg whose name is to be obtained.
Returns A pointer to a buffer containing the user-friendly name of the procedure associated with pdg (as a char*). The buffer is only valid until another API function is invoked.
Notes See the cs_pdg_friendly_name() documentation for information about the form and uses of user-friendly procedure names.

Do not modify or free the returned buffer.

This function entails less user overhead than cs_pdg_friendly_name(), and so can be more convenient to use; the tradeoff is that the returned value is not under user control and has a constrained lifetime.

Function cs_pdg_basename_string
const char * cs_pdg_basename_string (
Get the basename of the procedure associated with a cs_pdg.
Parameters
pdg [in] The cs_pdg whose basename is to be obtained.
Returns A pointer to a buffer containing the basename of the procedure associated with pdg (as a char*). The buffer is only valid until another API function is invoked.
Notes See the cs_pdg_basename() documentation for information about the form and uses of procedure basenames.

Do not modify or free the returned buffer.

This function entails less user overhead than cs_pdg_basename(), and so can be more convenient to use; the tradeoff is that the returned value is not under user control and has a constrained lifetime.

Function cs_pdg_stable_hash
cs_hash_t cs_pdg_stable_hash (
Get a hash value for a cs_pdg, with stable results across sufficiently-similar analyses.
Parameters
pdg [in] The cs_pdg value to hash.
Returns A hash derived from pdg.
Notes This hash value is stable in the following sense. Suppose there are two analyses A1 and A2 generated with exactly the same inputs (including identical analyzed code, underlying build commands and ordering, command line and configuration settings, increment order and contents). Let p1 be a cs_pdg in A1, and p2 be the cs_pdg in A2 that corresponds to p1. Then cs_pdg_stable_hash(p1)==cs_pdg_stable_hash(p2).

If you do not need hash values to be stable across analyses, use cs_pdg_hash(): it has better performance.

Function cs_pdg_stable_compare
int cs_pdg_stable_compare (
Compare two cs_pdg objects, with stable results across sufficiently-similar analyses.
Parameters
pdg_a [in] First argument to comparison.
pdg_b [in] Second argument to comparison.
Returns An integer N, such that:
  • N<0 if pdg_a considered less than pdg_b
  • N==0 if pdg_a considered equal to pdg_b
  • N>0 if pdg_a considered greater than pdg_b
Notes This function is provided so cs_pdg objects can be stored in ordered containers that provide stable iteration order.

The comparison is stable in the following sense. Suppose there are two analyses A1 and A2 generated with exactly the same inputs (including identical analyzed code, underlying build commands and ordering, command line and configuration settings, increment order and contents). Let a1 and b1 be two cs_pdg values in A1, and a2 and b2 be the cs_pdg values in A2 that correspond to a1 and b1 respectively. Then cs_pdg_stable_compare(a1,b1)==cs_pdg_stable_compare(a2,b2).

If you do not need comparison results to be stable across different analyses, use cs_pdg_compare(): it has better performance.

Function cs_pdg_get_handle
cs_result cs_pdg_get_handle (
Get a storable handle for a procedure (cs_pdg).
Parameters
pdg [in] The cs_pdg to return a handle for.
proc_handle [out] The handle of the procedure.
capacity_bytes [in] The size of the provided buffer.
bytes_needed [out] Buffer size needed for the handle.
Returns A cs_result:
Notes This function returns a handle to the procedure which is suitable for storing externally, allowing the procedure to be retrieved whenever needed.
Function cs_pdg_lookup_handle
cs_result cs_pdg_lookup_handle (
Retrieve a procedure (cs_pdg) from a handle.
Parameters
pdg_handle [in] The handle of the procedure.
pdg [out] A cs_pdg matching the handle.
Returns A cs_result:
Notes This function uses the provided handle to retrieve a procedure.
Function cs_pdg_equal
cs_boolean cs_pdg_equal (
Check: are two cs_pdg objects equal?
Parameters
pdg1 [in] First argument to equality test.
pdg2 [in] Second argument to equality test.
Returns cs_true if pdg1 and pdg2 are equal; cs_false if not.
Function cs_pdg_compare
int cs_pdg_compare (
Compare two cs_pdg objects.
Parameters
pdg_a [in] First argument to comparison.
pdg_b [in] Second argument to comparison.
Returns An integer N, such that:
  • N<0 if pdg_a is considered less than pdg_b
  • N==0 if pdg_a and pdg_b are the same cs_pdg
  • N>0 if pdg_a is considered greater than pdg_b
Notes This function is provided so cs_pdg objects can be stored in ordered containers. It is not based on any user-perceivable order of cs_pdg values.

For fixed cs_pdg values a and b in a single analysis, cs_pdg_compare(a,b) will always return the same value. However, cs_pdg_compare() will not necessarily return this same value when called on the corresponding cs_pdg values a' and b' in a different analysis. Function cs_pdg_stable_compare() provides some degree of stability across analyses, although restrictions still apply. If you do not need comparison results to be stable across different analyses, use cs_pdg_compare(): it has better performance.

Function cs_pdg_hash
cs_hash_t cs_pdg_hash (
Hash function for cs_pdg.
Parameters
pdg [in] A cs_pdg to hash.
Returns A hash of pdg.
Notes For a fixed cs_pdg p in a single analysis, cs_pdg_hash(p) will always return the same value. However, cs_pdg_hash() will not necessarily return this same value when called on the corresponding cs_pdg p' in a different analysis. Function cs_pdg_stable_hash() provides some degree of stability across analyses, although restrictions still apply. If you do not need hash values to be stable across different analyses, use cs_pdg_hash(): it has better performance.
Function cs_pdg_is_null
cs_boolean cs_pdg_is_null (
Determine whether a cs_pdg is null.
Parameters
pdg [in] The cs_pdg to check for nullity.
Returns cs_true if all bits of pdg are zeroed; cs_false otherwise.
Notes No API function (except for cs_pdg_get_null()) should ever return a null cs_pdg.
Function cs_pdg_get_null
cs_pdg cs_pdg_get_null ( )
Return a null cs_pdg.
Returns A null cs_pdg.
 

To report problems with this documentation, please visit https://support.codesecure.com/.