jameschennerd commited on
Commit
955ae84
Β·
verified Β·
1 Parent(s): 1407db0

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +181 -0
README.md ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CG-Bench: A Call Graph Construction Benchmark for Language Models
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![Paper](https://img.shields.io/badge/Paper-PDF-red.svg)](CG_Bench_Can_Language_Models_Assist_Call_Graph_Construction_in_the_Real_World.pdf)
5
+
6
+ > **πŸ“„ Paper**: [CG-Bench: Can Language Models Assist Call Graph Construction in the Real World?](CG_Bench_Can_Language_Models_Assist_Call_Graph_Construction_in_the_Real_World.pdf) - Published at LMPL@SPLASH2025
7
+
8
+ CG-Bench is a comprehensive benchmark dataset designed to evaluate the capabilities of Large Language Models (LLMs) in assisting with call graph construction in real-world C/C++ codebases. The benchmark focuses specifically on challenging indirect function calls through function pointers, which are notoriously difficult for traditional static analysis tools to resolve.
9
+
10
+ ## πŸ“‹ Overview
11
+
12
+ Call graph construction is a fundamental program analysis technique crucial for various software engineering tasks including debugging, optimization, security analysis, and program comprehension. While direct function calls are straightforward to analyze, indirect calls through function pointers present significant challenges for automated tools.
13
+
14
+ This benchmark provides:
15
+ - **Real-world complexity**: Examples extracted from popular open-source projects
16
+ - **Diverse patterns**: Multiple categories of function pointer usage patterns
17
+ - **Structured format**: Consistent annotation format for evaluation
18
+ - **Comprehensive coverage**: 104 examples across 7 major open-source projects
19
+
20
+ ## πŸ—‚οΈ Dataset Structure
21
+
22
+ ### Projects Included
23
+ The benchmark includes examples from seven major C/C++ projects:
24
+
25
+ | Project | Domain | Lines of Code(KLoC) | Description |
26
+ |---------|--------|---------------|-------------|
27
+ | **openssh** | Security | ~120 | Secure Shell (SSH) protocol implementation |
28
+ | **curl** | Networking | ~182 | Command line tool and library for transferring data |
29
+ | **redis** | Database | ~200 | In-memory data structure store |
30
+ | **zfs** | File System | ~380 | ZFS file system implementation |
31
+ | **wrk** | Benchmarking | ~601 | HTTP benchmarking tool |
32
+ | **ffmpeg** | Multimedia | ~1,257 | Complete multimedia framework |
33
+ | **gcc** | Compiler | ~6,200 | GNU Compiler Collection |
34
+ | **Total** | **All Domains** | **~8,940** | **7 major open-source projects** |
35
+
36
+ ### Function Pointer Categories
37
+
38
+ The benchmark categorizes function pointer usage patterns into 11 distinct types:
39
+
40
+ 1. **`fnptr-callback`** (15 examples): Function pointers used as callbacks
41
+ 2. **`fnptr-cast`** (7 examples): Function pointers with type casting
42
+ 3. **`fnptr-dynamic-call`** (5 examples): Dynamically resolved function calls
43
+ 4. **`fnptr-global-array`** (6 examples): Function pointers in global arrays
44
+ 5. **`fnptr-global-struct-array`** (12 examples): Function pointers in arrays within global structures
45
+ 6. **`fnptr-global-struct`** (11 examples): Function pointers in global structures
46
+ 7. **`fnptr-library`** (20 examples): Function pointers in library interfaces
47
+ 8. **`fnptr-only`** (12 examples): Basic function pointer calls without complex patterns
48
+ 9. **`fnptr-struct`** (14 examples): Function pointers stored in structures
49
+ 10. **`fnptr-varargs`** (1 example): Function pointers with variable arguments
50
+ 11. **`fnptr-virtual`** (1 example): Virtual function-like patterns in C
51
+
52
+ ## πŸ“ Repository Contents
53
+
54
+ ```
55
+ CG-Bench/
56
+ β”œβ”€β”€ README.md # This file
57
+ β”œβ”€β”€ LICENSE # MIT License
58
+ β”œβ”€β”€ projects.md # Detailed project statistics
59
+ β”œβ”€β”€ extract_from_markdowns.py # Data extraction script
60
+ β”œβ”€β”€ fnptr-*.md # Category-specific examples
61
+ └── CG_Bench_Can_Language_Models_Assist_Call_Graph_Construction_in_the_Real_World.pdf
62
+ ```
63
+
64
+ ### Example Format
65
+
66
+ Each example follows a consistent structure:
67
+
68
+ ```markdown
69
+ # Example N
70
+
71
+ ## Callsite
72
+ *Full path and location of the function pointer call*
73
+
74
+ fnptr: *function_pointer_name*
75
+ targets: target_function1, target_function2, ...
76
+
77
+ ## Related Code Snippets
78
+ ```c
79
+ // Relevant code context showing the function pointer usage
80
+ ```
81
+
82
+ ## πŸš€ Usage
83
+
84
+ ### Extracting Benchmark Data
85
+
86
+ To generate a structured JSON dataset from the markdown files:
87
+
88
+ ```bash
89
+ python3 extract_from_markdowns.py
90
+ ```
91
+
92
+ This creates `cgbench.json` containing all examples in a structured format suitable for evaluation.
93
+
94
+ ### Data Format
95
+
96
+ The generated JSON follows this structure:
97
+
98
+ ```json
99
+ {
100
+ "project_name": {
101
+ "callsite_path": {
102
+ "callsite": "function_pointer_name",
103
+ "type": "category",
104
+ "chain_summary": [
105
+ {
106
+ "source_code": ["line1", "line2", ...],
107
+ "parent": ""
108
+ }
109
+ ],
110
+ "callees": {
111
+ "targets": {
112
+ "target_function": ""
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+ ```
119
+
120
+ ## πŸ“Š Benchmark Statistics
121
+
122
+ - **Total Examples**: 104
123
+ - **Project Categories**: 7 major open-source projects
124
+ - **Function Pointer Patterns**: 11 distinct categories
125
+ - **Code Contexts**: Multiple code snippets per example showing usage patterns
126
+ - **Real-world Complexity**: Examples from production codebases
127
+
128
+ ## 🎯 Use Cases
129
+
130
+ This benchmark is designed for:
131
+
132
+ 1. **LLM Evaluation**: Assessing language models' ability to understand complex code patterns
133
+ 2. **Tool Development**: Benchmarking static analysis tools for call graph construction
134
+ 3. **Research**: Studying function pointer resolution in real-world codebases
135
+ 4. **Education**: Understanding various function pointer usage patterns in C/C++
136
+
137
+ ## πŸ“– Paper Reference
138
+
139
+ This benchmark accompanies the research paper:
140
+ **"CG-Bench: Can Language Models Assist Call Graph Construction in the Real World?"**
141
+
142
+ The paper provides detailed methodology, evaluation results, and analysis of LLM performance on call graph construction tasks.
143
+
144
+ ## 🀝 Contributing
145
+
146
+ We welcome contributions to expand the benchmark! Please consider:
147
+
148
+ - Adding examples from additional open-source projects
149
+ - Identifying new function pointer usage patterns
150
+ - Improving the extraction and annotation process
151
+ - Reporting issues or inconsistencies
152
+
153
+ ## πŸ“„ License
154
+
155
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
156
+
157
+ ## πŸ”— Citation
158
+
159
+ If you use this benchmark in your research, please cite:
160
+
161
+ ```bibtex
162
+ @inproceedings{cgbench2025,
163
+ title={CG-Bench: Can Language Models Assist Call Graph Construction in the Real World?},
164
+ author={[Authors]},
165
+ booktitle={Proceedings of the 1st ACM SIGPLAN International Workshop on Language Models for Programming (LMPL 2025)},
166
+ year={2025},
167
+ publisher={ACM},
168
+ address={New York, NY, USA},
169
+ url={https://conf.researchr.org/home/icfp-splash-2025/lmpl-2025},
170
+ note={Co-located with SPLASH 2025}
171
+ }
172
+ ```
173
+
174
+ ## πŸ“ž Contact
175
+
176
+ For questions or collaboration opportunities, please open an issue on GitHub or contact the maintainers.
177
+
178
+ ---
179
+
180
+ **Keywords**: Call Graph Construction, Function Pointers, Static Analysis, Large Language Models, C/C++ Analysis, Software Engineering, Program Analysis
181
+