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 |
Defines a set of procedure (cs_pdg) operations for CodeSonar.
| #define CS_PDG_H | ||
| #define CS_PDG_NULL | (cs_pdg_get_null()) | The null cs_pdg. |
| #define CS_PDG_INL_H |
| Definition | typedef __cs_pdg_kind_enum cs_pdg_kind |
|---|---|
| Notes | Enumeration of kinds associated with cs_pdg. |
| Definition | typedef enum {
|
||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Notes | Enumeration of PDG kinds. |
| 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 ) |
| cs_result | cs_pdg_file_line ( cs_pdg pdg, cs_sfid * out_sfid, cs_line * out_line ) |
| 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 ) |
| cs_result | cs_pdg_entry_vertex ( cs_pdg pdg, cs_pdg_vertex * out_vertex ) |
| cs_result | cs_pdg_preexit_vertex ( cs_pdg pdg, cs_pdg_vertex * out_vertex ) |
| cs_result | cs_pdg_exit_vertex ( cs_pdg pdg, cs_pdg_vertex * out_vertex ) |
| 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 ) |
| 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 ) |
| 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 ) |
| cs_result | cs_pdg_formal_in ( cs_pdg pdg, cs_size_t fi_rank, cs_pdg_vertex * out_vertex ) |
| cs_result | cs_pdg_formals_out ( cs_pdg pdg, cs_pdg_vertex_set * out_set ) |
| 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.
|
| Parameters |
|
|||
|---|---|---|---|---|
| Returns | The cs_pdg_kind of pdg. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
||||||
| Time-Complexity | O(1) |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| 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. |
| Parameters |
|
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
||||||||||||
| 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. |
| Parameters |
|
|||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
|||||||||
| Time-Complexity | O(1) |
| Parameters |
|
|||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
|||||||||
| Time-Complexity | O(n) where n is the number of pairs in cs_pdg_vertex_charpos(pdg_entry_vertex,...) |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns | CS_SUCCESS on success. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| 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. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| 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. |
| Parameters |
|
|||
|---|---|---|---|---|
| Returns |
The unique identifier of pdg.
|
|||
| Notes | To get a cs_pdg given its ID, use cs_sdg_retrieve_pdg(). |
| Parameters |
|
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
||||||||||||
| 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. |
| Parameters |
|
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
||||||||||||
| 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.
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();
}
|
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| 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.
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();
}
|
| Parameters |
|
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
||||||||||||
| 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.
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. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
| Parameters |
|
|||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 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. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
| Parameters |
|
|||
|---|---|---|---|---|
| Returns | CS_SUCCESS on successful close. |
| Parameters |
|
|||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns | The number of call sites in pdg. | ||||||
| Notes | This value will match the iteration count of an equivalent cs_pdg_call_sites_iter. |
| Parameters |
|
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
| Parameters |
|
|||
|---|---|---|---|---|
| Returns | CS_SUCCESS on successful close. |
| Parameters |
|
|||
|---|---|---|---|---|
| Returns | The number of call sites to pdg. | |||
| Notes | This value will match the iteration count of an equivalent cs_pdg_callers_iter. |
| Parameters |
|
|||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 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. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
| Parameters |
|
|||
|---|---|---|---|---|
| Returns | CS_SUCCESS on successful close. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| 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:
|
| Parameters |
|
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
||||||||||||
| 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. |
| Parameters |
|
|||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 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. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
||||||
| Notes | It is the responsibility of the user to close the returned set: use cs_pdg_vertex_set_close(). |
| Parameters |
|
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
||||||||||||
| 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. |
| Parameters |
|
|||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 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(). |
| Parameters |
|
|||
|---|---|---|---|---|
| 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. |
| Parameters |
|
|||
|---|---|---|---|---|
| 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. |
| Parameters |
|
|||
|---|---|---|---|---|
| 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. |
| Parameters |
|
|||
|---|---|---|---|---|
| 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. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns |
An integer N, such that:
|
||||||
| 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. |
| Parameters |
|
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns |
A cs_result:
|
||||||
| Notes | This function uses the provided handle to retrieve a procedure. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns | cs_true if pdg1 and pdg2 are equal; cs_false if not. |
| Parameters |
|
||||||
|---|---|---|---|---|---|---|---|
| Returns |
An integer N, such that:
|
||||||
| 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. |
| Parameters |
|
|||
|---|---|---|---|---|
| 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. |
| Parameters |
|
|||
|---|---|---|---|---|
| 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. |
To report problems with this documentation, please visit https://support.codesecure.com/.