Overview
Ghidra’s Graph Visualization capabilities enable you to create and display visual representations of program structure, function relationships, data types, control flow, and more. Graph services provide extensible rendering and export options.Graphing features are available through the Graph menu in the CodeBrowser toolbar and via programmatic APIs for script-based graph generation.
Graph Types
Ghidra supports multiple graph visualization types:Function Call Graph
Visualize function call relationships and program structure
Control Flow Graph
Display basic block flow within functions
Data Type Graph
Show data type hierarchies and relationships
Reference Graph
Explore code and data reference patterns
Graph Services
The Graph Display Broker provides a plugin architecture for graph rendering:Service Providers
Multiple graph service providers can be installed:- Default Graph Display: Built-in Jung-based renderer
- Third-party Renderers: Extensible plugin system
- Export Services: Save graphs to various formats
Display Capabilities
Graph displays support:Interactive Navigation
Interactive Navigation
Layout Algorithms
Layout Algorithms
- Hierarchical layout
- Force-directed layout
- Tree layout
- Circular layout
- Custom layouts
Customization
Customization
- Color coding by type
- Shape customization
- Edge styling and labels
- Filter and search
Export Options
Export Options
- PNG/JPEG image export
- SVG vector graphics
- GraphML XML format
- DOT format for Graphviz
Function Call Graphs
Generating Call Graphs
Configure Options
Set options:
- Maximum depth (caller/callee levels)
- Show incoming/outgoing calls
- Filter by function type
Call Graph Features
- Caller Graph
- Callee Graph
- Combined Graph
Shows functions that call the selected function.Use: Understand how a function is used throughout the program
Graph Elements
| Element | Description |
|---|---|
| Nodes | Represent functions |
| Edges | Represent call relationships |
| Colors | Indicate function types (user, library, thunk) |
| Shapes | May indicate entry points or special functions |
Control Flow Graphs
Control flow graphs show execution paths within a single function:Basic Blocks
Nodes represent basic blocks:- Entry Block: Function entry point (highlighted)
- Code Blocks: Sequences of instructions with single entry/exit
- Exit Blocks: Return or terminal instructions
Edges
Edges represent control flow:- Unconditional: Solid lines for direct flow
- Conditional: Different colors for true/false branches
- Fall-through: Default execution path
Layout Options
Compact
Minimize space usage
Hierarchical
Top-down flow layout
Nested
Show loop nesting
Data Type Graphs
Visualize data type hierarchies and relationships:Generating Type Graphs
Type Graph Elements
- Structures
- Inheritance
- References
- Typedefs
Shows structure composition with member relationships.
Graph Display Features
Navigation and Selection
Zooming
Zooming
- Mouse wheel: Zoom in/out
- Zoom to fit: View entire graph
- Zoom to selection: Focus on selected nodes
Panning
Panning
- Click and drag background to pan
- Arrow keys for fine movement
- Minimap for large graphs
Selection
Selection
- Click to select single node
- Ctrl+Click for multi-select
- Drag to select region
- Select connected components
Search
Search
- Text search for nodes
- Highlight matching nodes
- Navigate between matches
Filtering
Filter graphs to focus on relevant information:- Hide/Show nodes by type or criteria
- Filter edges by relationship type
- Depth limiting for large graphs
- Scope restriction to address ranges
Customization
Customize node colors by function type, address range, or custom criteria
Choose shapes: Rectangle, Ellipse, Diamond, or custom
Configure edge rendering: Straight, Curved, Orthogonal
Show/hide node and edge labels
Export and Sharing
Export Formats
Programmatic Graph Generation
Using Scripts
Create custom graphs using Ghidra’s scripting API:Example Scripts
Ghidra includes example graph scripts:See the Graph directory in help topics for comprehensive scripting documentation.
Graph Services API
The Graph Services framework provides:Core Interfaces
- GraphDisplayBroker
- AttributedGraph
- GraphDisplay
Main service for obtaining graph displays.
Graph Attributes
Vertices and edges support custom attributes:Advanced Graphing
Address-Based Graphs
Graphs synchronized with program addresses:- Automatic highlighting: Selected code highlights in graph
- Bidirectional navigation: Graph to listing and vice versa
- Address tracking: Graph updates with program changes
Custom Graph Providers
Extend Ghidra with custom graph implementations:- Implement
GraphDisplayinterface - Register as service provider
- Handle graph rendering and interaction
- Support standard graph operations
Use Cases
Architecture Analysis
Understand program architecture and module dependencies
Malware Analysis
Trace execution flow and identify malicious behavior
Vulnerability Research
Identify vulnerable code paths and attack surfaces
Reverse Engineering
Visualize complex algorithms and data structures
Documentation
Generate visual documentation of program structure
Code Review
Review function interactions and dependencies
Performance Considerations
Graph Size Recommendations
| Nodes | Performance | Recommendation |
|---|---|---|
| < 100 | Excellent | Full interaction |
| 100-500 | Good | Minor delays |
| 500-1000 | Moderate | Use filtering |
| > 1000 | Slow | Export to specialized tools |
Troubleshooting
Graph Won't Display
Graph Won't Display
Checks:
- Verify graph service is available
- Check for errors in console log
- Try different graph provider
- Ensure function/data is analyzable
Empty Graph Generated
Empty Graph Generated
Causes:
- No relationships found (isolated function)
- Depth limit too restrictive
- Filtering too aggressive
Graph Performance Issues
Graph Performance Issues
Solutions:
- Reduce maximum depth
- Enable filtering
- Export to external tool
- Use hierarchical layout
Source Code References
Next Steps
Program Diff
Compare programs with visual difference highlighting
Version Tracking
Track changes across program versions
