Documentation
¶
Overview ¶
Package callgraph provides call graph analysis for coverage-guided test exploration. This integrates with Go's toolchain to analyze code structure and guide fuzzing efforts.
Index ¶
- type AnalysisMode
- type AnalysisRecommendation
- type AnalysisResult
- type CallGraphAnalyzer
- func (a *CallGraphAnalyzer) AnalyzeCallGraph() (*AnalysisResult, error)
- func (a *CallGraphAnalyzer) GetCoverageGuidance() ([]*coverage.CoverageTarget, error)
- func (a *CallGraphAnalyzer) GetCriticalPaths(maxPaths int) ([]*CriticalPath, error)
- func (a *CallGraphAnalyzer) GetHotPaths(maxPaths int) ([]*HotPath, error)
- func (a *CallGraphAnalyzer) GetMetrics() map[string]interface{}
- func (a *CallGraphAnalyzer) SetAnalysisMode(mode AnalysisMode)
- func (a *CallGraphAnalyzer) SetEventHandlers(onAnalysisComplete func(*AnalysisResult), onHotPathsFound func([]*HotPath), ...)
- func (a *CallGraphAnalyzer) Stop()
- type CoverageCallGraphIntegrator
- func (i *CoverageCallGraphIntegrator) GetLatestResult() *IntegrationResult
- func (i *CoverageCallGraphIntegrator) GetMetrics() map[string]interface{}
- func (i *CoverageCallGraphIntegrator) GetResults() []*IntegrationResult
- func (i *CoverageCallGraphIntegrator) PerformIntegration() (*IntegrationResult, error)
- func (i *CoverageCallGraphIntegrator) SetEventHandlers(onTargetsGenerated func([]*coverage.CoverageTarget), ...)
- func (i *CoverageCallGraphIntegrator) Stop()
- type CoverageGap
- type CoverageInsight
- type CriticalPath
- type FunctionNode
- type GraphSummary
- type HotPath
- type IntegrationRecommendation
- type IntegrationResult
- type PackageInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalysisMode ¶
type AnalysisMode int
AnalysisMode represents different call graph analysis approaches
const ( ModeStatic AnalysisMode = iota // Static analysis (fast, less precise) ModeCHA // Class Hierarchy Analysis (medium speed/precision) ModeRTA // Rapid Type Analysis (slower, more precise) ModePointer // Pointer analysis (slowest, most precise) ModeAdaptive // Adaptive selection based on code characteristics )
type AnalysisRecommendation ¶
type AnalysisRecommendation struct {
ID string `json:"id"`
Type string `json:"type"`
Priority float64 `json:"priority"`
Title string `json:"title"`
Description string `json:"description"`
Actions []string `json:"actions"`
TargetFuncs []*FunctionNode `json:"target_functions"`
Metadata map[string]interface{} `json:"metadata"`
}
AnalysisRecommendation provides actionable insights from call graph analysis
type AnalysisResult ¶
type AnalysisResult struct {
Timestamp time.Time `json:"timestamp"`
Mode AnalysisMode `json:"mode"`
PackageCount int `json:"package_count"`
FunctionCount int `json:"function_count"`
CallSiteCount int `json:"call_site_count"`
AnalysisTime time.Duration `json:"analysis_time"`
// Analysis outputs
CallGraph *GraphSummary `json:"call_graph"`
HotPaths []*HotPath `json:"hot_paths"`
CriticalPaths []*CriticalPath `json:"critical_paths"`
CoverageGaps []*CoverageGap `json:"coverage_gaps"`
Recommendations []*AnalysisRecommendation `json:"recommendations"`
// Metadata
Metadata map[string]interface{} `json:"metadata"`
}
AnalysisResult contains the results of call graph analysis
type CallGraphAnalyzer ¶
type CallGraphAnalyzer struct {
// contains filtered or unexported fields
}
CallGraphAnalyzer provides call graph analysis capabilities
func NewCallGraphAnalyzer ¶
func NewCallGraphAnalyzer(ctx context.Context, rootDir string, packagePaths []string) *CallGraphAnalyzer
NewCallGraphAnalyzer creates a new call graph analyzer
func (*CallGraphAnalyzer) AnalyzeCallGraph ¶
func (a *CallGraphAnalyzer) AnalyzeCallGraph() (*AnalysisResult, error)
AnalyzeCallGraph performs call graph analysis
func (*CallGraphAnalyzer) GetCoverageGuidance ¶
func (a *CallGraphAnalyzer) GetCoverageGuidance() ([]*coverage.CoverageTarget, error)
GetCoverageGuidance provides coverage guidance based on call graph analysis
func (*CallGraphAnalyzer) GetCriticalPaths ¶
func (a *CallGraphAnalyzer) GetCriticalPaths(maxPaths int) ([]*CriticalPath, error)
GetCriticalPaths identifies paths critical for system functionality
func (*CallGraphAnalyzer) GetHotPaths ¶
func (a *CallGraphAnalyzer) GetHotPaths(maxPaths int) ([]*HotPath, error)
GetHotPaths identifies frequently executed paths
func (*CallGraphAnalyzer) GetMetrics ¶
func (a *CallGraphAnalyzer) GetMetrics() map[string]interface{}
GetMetrics returns analyzer metrics
func (*CallGraphAnalyzer) SetAnalysisMode ¶
func (a *CallGraphAnalyzer) SetAnalysisMode(mode AnalysisMode)
SetAnalysisMode configures the analysis mode
func (*CallGraphAnalyzer) SetEventHandlers ¶
func (a *CallGraphAnalyzer) SetEventHandlers( onAnalysisComplete func(*AnalysisResult), onHotPathsFound func([]*HotPath), onCriticalPathsFound func([]*CriticalPath), )
SetEventHandlers configures event callbacks
type CoverageCallGraphIntegrator ¶
type CoverageCallGraphIntegrator struct {
// contains filtered or unexported fields
}
CoverageCallGraphIntegrator connects call graph analysis with coverage tracking
func NewCoverageCallGraphIntegrator ¶
func NewCoverageCallGraphIntegrator(ctx context.Context, rootDir string, packagePaths []string) (*CoverageCallGraphIntegrator, error)
NewCoverageCallGraphIntegrator creates a new integrator
func (*CoverageCallGraphIntegrator) GetLatestResult ¶
func (i *CoverageCallGraphIntegrator) GetLatestResult() *IntegrationResult
GetLatestResult returns the most recent integration result
func (*CoverageCallGraphIntegrator) GetMetrics ¶
func (i *CoverageCallGraphIntegrator) GetMetrics() map[string]interface{}
GetMetrics returns integrator metrics
func (*CoverageCallGraphIntegrator) GetResults ¶
func (i *CoverageCallGraphIntegrator) GetResults() []*IntegrationResult
GetResults returns all integration results
func (*CoverageCallGraphIntegrator) PerformIntegration ¶
func (i *CoverageCallGraphIntegrator) PerformIntegration() (*IntegrationResult, error)
PerformIntegration runs the complete integration analysis
func (*CoverageCallGraphIntegrator) SetEventHandlers ¶
func (i *CoverageCallGraphIntegrator) SetEventHandlers( onTargetsGenerated func([]*coverage.CoverageTarget), onInsightsGenerated func([]*CoverageInsight), )
SetEventHandlers configures event callbacks
func (*CoverageCallGraphIntegrator) Stop ¶
func (i *CoverageCallGraphIntegrator) Stop()
Stop shuts down the integrator
type CoverageGap ¶
type CoverageGap struct {
ID string `json:"id"`
Function *FunctionNode `json:"function"`
CurrentCoverage float64 `json:"current_coverage"`
TargetCoverage float64 `json:"target_coverage"`
Priority float64 `json:"priority"`
Reason string `json:"reason"`
SuggestedTests []string `json:"suggested_tests"`
}
CoverageGap represents areas with insufficient test coverage
type CoverageInsight ¶
type CoverageInsight struct {
ID string `json:"id"`
Type string `json:"type"`
Severity string `json:"severity"`
Title string `json:"title"`
Description string `json:"description"`
Functions []*FunctionNode `json:"functions"`
Paths []*HotPath `json:"paths"`
Suggestions []string `json:"suggestions"`
Metadata map[string]interface{} `json:"metadata"`
}
CoverageInsight provides insights from combining coverage and call graph data
type CriticalPath ¶
type CriticalPath struct {
ID string `json:"id"`
Path []*FunctionNode `json:"path"`
CriticalityScore float64 `json:"criticality_score"`
RiskLevel string `json:"risk_level"`
CoverageGap float64 `json:"coverage_gap"`
Reason string `json:"reason"`
}
CriticalPath represents a path critical for system functionality
type FunctionNode ¶
type FunctionNode struct {
ID string `json:"id"`
Package string `json:"package"`
Name string `json:"name"`
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column"`
Signature string `json:"signature"`
IsEntryPoint bool `json:"is_entry_point"`
IsLeaf bool `json:"is_leaf"`
CallCount int `json:"call_count"`
CallerCount int `json:"caller_count"`
Complexity float64 `json:"complexity"`
CoverageRatio float64 `json:"coverage_ratio"`
}
FunctionNode represents a function in the call graph
type GraphSummary ¶
type GraphSummary struct {
TotalNodes int `json:"total_nodes"`
TotalEdges int `json:"total_edges"`
MaxDepth int `json:"max_depth"`
CyclicNodes int `json:"cyclic_nodes"`
EntryPoints []*FunctionNode `json:"entry_points"`
LeafNodes []*FunctionNode `json:"leaf_nodes"`
Packages map[string]*PackageInfo `json:"packages"`
}
GraphSummary provides a high-level summary of the call graph
type HotPath ¶
type HotPath struct {
ID string `json:"id"`
Path []*FunctionNode `json:"path"`
ExecutionFreq float64 `json:"execution_frequency"`
CoverageRatio float64 `json:"coverage_ratio"`
Importance float64 `json:"importance"`
Reason string `json:"reason"`
}
HotPath represents a frequently executed call path
type IntegrationRecommendation ¶
type IntegrationRecommendation struct {
ID string `json:"id"`
Priority float64 `json:"priority"`
Category string `json:"category"`
Title string `json:"title"`
Description string `json:"description"`
ActionPlan []string `json:"action_plan"`
TargetFuncs []*FunctionNode `json:"target_functions"`
ExpectedImpact string `json:"expected_impact"`
Effort string `json:"effort"`
Metadata map[string]interface{} `json:"metadata"`
}
IntegrationRecommendation provides actionable recommendations from integrated analysis
type IntegrationResult ¶
type IntegrationResult struct {
Timestamp time.Time `json:"timestamp"`
CoverageSnapshot *coverage.CoverageSnapshot `json:"coverage_snapshot"`
CallGraphSummary *GraphSummary `json:"call_graph_summary"`
GeneratedTargets []*coverage.CoverageTarget `json:"generated_targets"`
CoverageInsights []*CoverageInsight `json:"coverage_insights"`
Recommendations []*IntegrationRecommendation `json:"recommendations"`
Metrics map[string]interface{} `json:"metrics"`
}
IntegrationResult contains the results of call graph + coverage integration
type PackageInfo ¶
type PackageInfo struct {
Name string `json:"name"`
Path string `json:"path"`
FunctionCount int `json:"function_count"`
CallSiteCount int `json:"call_site_count"`
CoverageRatio float64 `json:"coverage_ratio"`
Complexity float64 `json:"complexity"`
}
PackageInfo provides information about a package