CBMC
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
call_grapht Class Reference

A call graph (https://en.wikipedia.org/wiki/Call_graph) for a GOTO model or GOTO functions collection. More...

#include <call_graph.h>

+ Collaboration diagram for call_grapht:

Classes

class   directed_grapht
  Directed graph representation of this call graph. More...
 
  Edge of the directed graph representation of this call graph. More...
 
struct   function_nodet
  Node of the directed graph representation of this call graph. More...
 

Public Types

typedef std::unordered_set< irep_idt, irep_id_hashnodest
  Type of the nodes in the call graph.
 
typedef std::multimap< irep_idt, irep_idtedgest
  Type of the edges in the call graph.
 
typedef std::pair< irep_idt, irep_idtedget
  Type of a call graph edge in edgest
 
  Type of a callsite stored in member callsites
 
  Type of a set of callsites.
 
  Type mapping from call-graph edges onto the set of call instructions that make that call.
 

Public Member Functions

  Create empty call graph.
 
  Create complete call graph.
 
  Create complete call graph.
 
void  output_dot (std::ostream &out) const
 
void  output (std::ostream &out) const
 
void  output_xml (std::ostream &out) const
 
  Add edge.
 
  Add edge with optional callsite information.
 
  Returns an inverted copy of this call graph.
 
  Returns a grapht representation of this call graph, suitable for use with generic grapht algorithms.
 

Static Public Member Functions

 
 

Public Attributes

  Call graph, including duplicate key-value pairs when there are parallel edges (see grapht documentation).
 
 
  Map from call-graph edges to a set of callsites that make the given call.
 

Protected Member Functions

void  add (const irep_idt &function, const goto_programt &body)
 

Private Member Functions

  Create call graph restricted to functions reachable from root
 
  Create call graph restricted to functions reachable from root
 
std::string  format_callsites (const edget &edge) const
  Prints callsites responsible for a graph edge as comma-separated location numbers, e.g.
 

Private Attributes

 

Detailed Description

A call graph (https://en.wikipedia.org/wiki/Call_graph) for a GOTO model or GOTO functions collection.

The public constructors build a complete call graph, while call_grapht::create_from_root_function can be used to create a partial call graph rooted at a particular function.

The graph is stored as a std::multimap, and this class only provides basic tools to construct and query graphs, but it can be exported to a grapht and thus processed using the full graph algorithms library using the get_directed_graph method. See also call_graph_helpers.h for helper methods that work with such grapht-derived call graphs.

The graph may optionally collect (and export) the callsite associated with each edge; pass the collect_callsites parameter to a constructor if you want this functionality, and query the call_grapht::callsites collection.

Definition at line 43 of file call_graph.h.

Member Typedef Documentation

◆  callsitest

Type mapping from call-graph edges onto the set of call instructions that make that call.

Definition at line 105 of file call_graph.h.

◆  edgest

Type of the edges in the call graph.

Note parallel edges (e.g. A having two callsites both targeting B) result in multiple graph edges.

Definition at line 92 of file call_graph.h.

◆  edget

Type of a call graph edge in edgest

Definition at line 95 of file call_graph.h.

◆  locationst

Type of a set of callsites.

Definition at line 101 of file call_graph.h.

◆  locationt

Type of a callsite stored in member callsites

Definition at line 98 of file call_graph.h.

◆  nodest

Type of the nodes in the call graph.

Definition at line 88 of file call_graph.h.

Constructor & Destructor Documentation

◆  call_grapht() [1/5]

call_grapht::call_grapht ( bool  collect_callsites = false )
explicit

Create empty call graph.

Parameters
collect_callsites if true, then each added graph edge will have the calling instruction recorded in callsites map.

Definition at line 21 of file call_graph.cpp.

◆  call_grapht() [2/5]

call_grapht::call_grapht ( const goto_modeltgoto_model,
bool  collect_callsites = false  
)
explicit

Create complete call graph.

Parameters
goto_model model to search for callsites
collect_callsites if true, then each added graph edge will have the calling instruction recorded in callsites map.

Definition at line 30 of file call_graph.cpp.

◆  call_grapht() [3/5]

call_grapht::call_grapht ( const goto_functionstgoto_functions,
bool  collect_callsites = false  
)
explicit

Create complete call graph.

Parameters
goto_functions functions to search for callsites
collect_callsites if true, then each added graph edge will have the calling instruction recorded in callsites map.

Definition at line 39 of file call_graph.cpp.

◆  call_grapht() [4/5]

call_grapht::call_grapht ( const goto_modeltgoto_model,
const irep_idtroot,
bool  collect_callsites 
)
private

Create call graph restricted to functions reachable from root

Parameters
goto_model model to search for callsites
root function to start exploring the graph
collect_callsites if true, then each added graph edge will have the calling instruction recorded in callsites map.

Definition at line 115 of file call_graph.cpp.

◆  call_grapht() [5/5]

call_grapht::call_grapht ( const goto_functionstgoto_functions,
const irep_idtroot,
bool  collect_callsites 
)
private

Create call graph restricted to functions reachable from root

Parameters
goto_functions functions to search for callsites
root function to start exploring the graph
collect_callsites if true, then each added graph edge will have the calling instruction recorded in callsites map.

Definition at line 75 of file call_graph.cpp.

Member Function Documentation

◆  add() [1/3]

void call_grapht::add ( const irep_idtcaller,
const irep_idtcallee 
)

Add edge.

Parameters
caller caller function
callee callee function

Definition at line 139 of file call_graph.cpp.

◆  add() [2/3]

void call_grapht::add ( const irep_idtcaller,
const irep_idtcallee,
locationt  callsite 
)

Add edge with optional callsite information.

Parameters
caller caller function
callee callee function
callsite call instruction responsible for this edge. Note this is only stored if collect_callsites was specified during construction.

Definition at line 153 of file call_graph.cpp.

◆  add() [3/3]

void call_grapht::add ( const irep_idtfunction,
const goto_programtbody 
)
protected

Definition at line 123 of file call_graph.cpp.

◆  create_from_root_function() [1/2]

static call_grapht call_grapht::create_from_root_function ( const goto_functionstfunctions,
const irep_idtroot,
bool  collect_callsites 
)
inlinestatic

Definition at line 61 of file call_graph.h.

◆  create_from_root_function() [2/2]

static call_grapht call_grapht::create_from_root_function ( const goto_modeltmodel,
const irep_idtroot,
bool  collect_callsites 
)
inlinestatic

Definition at line 53 of file call_graph.h.

◆  format_callsites()

std::string call_grapht::format_callsites ( const edgetedge ) const
private

Prints callsites responsible for a graph edge as comma-separated location numbers, e.g.

"{1, 2, 3}".

Parameters
edge graph edge
Returns
pretty representation of edge callsites

Definition at line 241 of file call_graph.cpp.

◆  get_directed_graph()

call_grapht::directed_grapht call_grapht::get_directed_graph ( ) const

Returns a grapht representation of this call graph, suitable for use with generic grapht algorithms.

Note that parallel edges in call_grapht (e.g. A { B(); B(); } appearing as two A->B edges) will be condensed in the grapht output, so only one edge will appear. If collect_callsites was set when this call-graph was constructed the edge will be annotated with the call-site set.

Returns
grapht representation of this call_grapht

Definition at line 209 of file call_graph.cpp.

◆  get_inverted()

call_grapht call_grapht::get_inverted ( ) const

Returns an inverted copy of this call graph.

Returns
Inverted (callee -> caller) call graph

Definition at line 165 of file call_graph.cpp.

◆  output()

void call_grapht::output ( std::ostream &  out ) const

Definition at line 272 of file call_graph.cpp.

◆  output_dot()

void call_grapht::output_dot ( std::ostream &  out ) const

Definition at line 255 of file call_graph.cpp.

◆  output_xml()

void call_grapht::output_xml ( std::ostream &  out ) const

Definition at line 282 of file call_graph.cpp.

Member Data Documentation

◆  callsites

callsitest call_grapht::callsites

Map from call-graph edges to a set of callsites that make the given call.

Definition at line 116 of file call_graph.h.

◆  collect_callsites

bool call_grapht::collect_callsites
private

Definition at line 169 of file call_graph.h.

◆  edges

edgest call_grapht::edges

Call graph, including duplicate key-value pairs when there are parallel edges (see grapht documentation).

This representation is retained for backward compatibility; use get_directed_graph() to get a generic directed graph representation that provides more graph algorithms (shortest path, SCCs and so on).

Definition at line 112 of file call_graph.h.

◆  nodes

nodest call_grapht::nodes

Definition at line 113 of file call_graph.h.


The documentation for this class was generated from the following files:

AltStyle によって変換されたページ (->オリジナル) /