Analysis Overview
Ghidra’s analysis system is a sophisticated pipeline that automatically processes programs to identify functions, data structures, references, and other program semantics. The system is designed to be extensible, prioritized, and incremental.Auto-Analysis Manager
TheAutoAnalysisManager coordinates all analysis activities for a program:
- Schedule analyzers by priority
- Manage address sets for incremental analysis
- Coordinate parallel analysis tasks
- Track analysis state and progress
- Handle analysis events and dependencies
ghidra/app/plugin/core/analysis/AutoAnalysisManager.java:63-150
Analyzer Interface
All analyzers implement theAnalyzer interface:
Analyzer Properties
Name
Unique identifier for the analyzer
Type
Classification (bytes, instructions, functions, data)
Priority
Execution order relative to other analyzers
Enablement
Default enabled/disabled state
Analysis Types
Analyzers are categorized by what they analyze:1
Byte Analysis
Process raw bytes to identify patterns and structures
2
Instruction Analysis
Analyze disassembled instructions and code flow
3
Function Analysis
Identify and analyze function boundaries and properties
4
Data Analysis
Identify and type data structures
Analyzer Priorities
Priority determines execution order within each analysis type:- Lower numbers run first
- Disassembly before function analysis
- Function analysis before data propagation
- Reference analysis runs late
Built-in Analyzers
Ghidra includes many standard analyzers:Core Analyzers
Disassembler
Disassembler
Converts bytes to instructions at entry points and code references.Priority: Very High
Type: Instruction Analyzer
Type: Instruction Analyzer
Function Start Search
Function Start Search
Identifies function entry points using various heuristics:
Type: Function Analyzer
- Call targets
- Code patterns
- External references
- Entry points
Type: Function Analyzer
Decompiler Parameter ID
Decompiler Parameter ID
Uses decompiler to identify function parameters and return values.Priority: Medium
Type: Function Signatures AnalyzerRequires the decompiler to be available.
Type: Function Signatures AnalyzerRequires the decompiler to be available.
Stack Analysis
Stack Analysis
Analyzes stack frame usage to identify local variables and parameters.Priority: Medium
Type: Function Analyzer
Type: Function Analyzer
Data Reference
Data Reference
Identifies data references from code:
Type: Instruction Analyzer
- Immediate operands
- Memory references
- String references
Type: Instruction Analyzer
Demangler
Demangler
Demangles C++ and other mangled symbol names.Priority: Low
Type: Function AnalyzerSupports multiple demangling schemes (GNU, Microsoft, etc.)
Type: Function AnalyzerSupports multiple demangling schemes (GNU, Microsoft, etc.)
Writing Custom Analyzers
Basic Analyzer Template
Analyzer class names must end with “Analyzer” to be discovered by the
ClassSearcher system.
Analyzer Best Practices
Check Cancellation
Check Cancellation
Always check for cancellation in loops:
Update Progress
Update Progress
Keep the user informed:
Log Important Info
Log Important Info
Use the MessageLog:
Use Transactions
Use Transactions
Wrap modifications in transactions:
Manage Dependencies
Manage Dependencies
Document analyzer dependencies and set appropriate priorities.
Analysis Lifecycle
Starting Analysis
Analysis can be triggered multiple ways:Analysis Flow
Analysis Tasks
Tasks are queued for each analyzer and address range:ghidra/app/plugin/core/analysis/AutoAnalysisManager.java:96-103
Parallel Analysis
Some analyzers support parallel execution:Analysis Options
Analyzers can be configured via the analysis options:Common Options
- Enable/disable specific analyzers
- Configure analyzer-specific behavior
- Set analysis boundaries
- Control aggressiveness
Analysis State
Programs track whether they’ve been analyzed:ghidra/program/model/listing/Program.java:61-64
Incremental Analysis
Ghidra supports incremental re-analysis:- User clears code/data
- Function boundaries change
- New memory blocks added
- Data types modified
Analysis Performance
Optimization Tips
Minimize Address Set Iteration
Minimize Address Set Iteration
Process addresses in batches:
Cache Frequently Used Data
Cache Frequently Used Data
Avoid repeated lookups:
Use Efficient Data Structures
Use Efficient Data Structures
AddressSet is optimized for range operations:
Avoid Excessive Transactions
Avoid Excessive Transactions
Batch related changes:
Debugging Analyzers
Logging
Testing
Analysis Events
Monitor analysis progress:Best Practices
Analyzer Design
Analyzer Design
- Keep analyzers focused on one task
- Document dependencies and requirements
- Provide meaningful options
- Handle edge cases gracefully
Performance
Performance
- Minimize database access
- Use efficient data structures
- Consider parallel execution
- Profile and optimize hot paths
User Experience
User Experience
- Provide clear progress feedback
- Allow cancellation
- Log important findings
- Document what the analyzer does
Testing
Testing
- Test on diverse programs
- Verify correctness
- Check performance
- Test cancellation behavior
Next Steps
Programs
Learn about the program model
Projects
Understand project organization
Architecture
Explore framework architecture
Overview
Return to framework overview
