Skip to content

Commit 986a2f2

Browse files
committed
Plan for LLDB Fortran
1 parent e22c3e4 commit 986a2f2

File tree

3 files changed

+50
-25
lines changed

3 files changed

+50
-25
lines changed

BACKLOG.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222

2323
### Story 1.2: Test Infrastructure Foundation
2424
- [ ] Set up basic test structure in `lldb/test/API/lang/fortran/`
25-
- [ ] Create simple Fortran test programs (.f90 files)
26-
- [ ] Establish lit test configuration
25+
- [ ] Create simple Fortran test programs (.f90 files) with Makefile
26+
- [ ] Add Python test classes inheriting from `lldbsuite.test.TestBase`
27+
- [ ] Configure lit test discovery for Fortran API tests
2728
- [ ] Add CMake integration for Fortran tests
2829

2930
**Acceptance Criteria**:
@@ -55,23 +56,27 @@
5556

5657
### Story 2.1: Plugin Registration Infrastructure (RED)
5758
- [ ] Create `lldb/source/Plugins/Language/Fortran/` directory structure
58-
- [ ] Implement basic `FortranLanguage.h` class declaration
59-
- [ ] Add plugin registration in PluginManager
59+
- [ ] Implement basic `FortranLanguage.h` class declaration inheriting from `Language`
60+
- [ ] Add `LLDB_PLUGIN_DEFINE(FortranLanguage)` macro
61+
- [ ] Register plugin with PluginManager using standard pattern
62+
- [ ] Add to `lldb/source/Plugins/Language/CMakeLists.txt`
6063
- [ ] Write failing test for language recognition
6164

6265
**Acceptance Criteria**:
6366
- LLDB recognizes Fortran as a supported language
6467
- No "unsupported language" warnings for Fortran files
6568
- Plugin loads without errors
69+
- Follows LLVM coding standards (C++17, proper includes, naming)
6670

6771
**Test Cases (RED phase)**:
6872
```python
69-
# Test: test_fortran_language_recognition.py
70-
def test_fortran_language_detected(self):
71-
"""Test that LLDB recognizes Fortran source files"""
72-
# This should FAIL initially
73-
self.expect("settings show target.language",
74-
substrs=["fortran"])
73+
# Test: test_fortran_language_recognition.py (in lldb/test/API/lang/fortran/)
74+
class FortranLanguageTestCase(TestBase):
75+
def test_fortran_language_detected(self):
76+
"""Test that LLDB recognizes Fortran source files"""
77+
# This should FAIL initially
78+
self.expect("settings show target.language",
79+
substrs=["fortran"])
7580
```
7681

7782
### Story 2.2: Language Type Recognition (GREEN)

CLAUDE.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,18 @@ llvm-lit --filter="NamePattern" test/directory/
170170

171171
**LLDB Build Configuration for Development:**
172172
```bash
173-
# Minimal LLDB build for language plugin development
173+
# Recommended LLDB build for language plugin development
174174
cmake -S llvm -B build -G Ninja \
175175
-DLLVM_ENABLE_PROJECTS="clang;lldb;flang" \
176176
-DLLVM_TARGETS_TO_BUILD="X86" \
177-
-DCMAKE_BUILD_TYPE=Debug \
177+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
178178
-DLLVM_ENABLE_ASSERTIONS=ON \
179-
-DLLDB_INCLUDE_TESTS=ON
179+
-DLLDB_INCLUDE_TESTS=ON \
180+
-DLLVM_INSTALL_UTILS=ON \
181+
-DLLVM_USE_LINKER=lld
182+
183+
# For debugging LLDB itself, use Debug instead of RelWithDebInfo
184+
# cmake -S llvm -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug ...
180185
```
181186

182187
**LLDB Testing:**
@@ -198,9 +203,11 @@ lldb-dotest lldb/test/API/functionalities/breakpoint/
198203
**Language Plugin Development Pattern:**
199204
1. Create plugin directory: `lldb/source/Plugins/Language/LanguageName/`
200205
2. Implement `LanguageName.h` and `LanguageName.cpp` inheriting from `Language`
201-
3. Register plugin in `lldb/source/Plugins/Language/CMakeLists.txt`
202-
4. Add plugin initialization in appropriate registry
203-
5. Create tests in `lldb/test/API/lang/languagename/`
206+
3. Use `LLDB_PLUGIN_DEFINE(LanguageName)` macro for plugin definition
207+
4. Register with PluginManager in Initialize/Terminate methods
208+
5. Add to `lldb/source/Plugins/Language/CMakeLists.txt` using `add_subdirectory()`
209+
6. Create tests in `lldb/test/API/lang/languagename/` with proper Python test classes
210+
7. Follow LLVM coding standards: C++17, CamelCase types, lowerCamelCase variables
204211

205212
**Key LLDB Classes for Language Plugins:**
206213
- `Language`: Base class for language-specific functionality
@@ -212,5 +219,14 @@ lldb-dotest lldb/test/API/functionalities/breakpoint/
212219
**Fortran Development Workflow:**
213220
- Use TDD: Write failing test first, implement to pass, refactor
214221
- Build only LLDB components: `ninja -C build lldb lldb-test`
215-
- Test frequently: `ninja -C build check-lldb-api-lang-fortran`
216-
- Use selective building to save time on large codebase
222+
- Test frequently: `llvm-lit lldb/test/API/lang/fortran/`
223+
- Format code: `git clang-format HEAD~1` before committing
224+
- Follow LLVM conventions: single commit per PR, no unrelated changes
225+
- Use selective building to save time on large codebase
226+
227+
**LLVM Contribution Guidelines:**
228+
- Base patches on recent `main` branch commit
229+
- Include test cases with all patches
230+
- Format code with clang-format
231+
- Follow C++17 standards and LLVM data structures (SmallVector, DenseMap)
232+
- Use LLVM error handling (Expected<T>, Error) over exceptions

LLDB_FORTRAN.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ lldb/source/Plugins/Language/Fortran/
5656
├── CMakeLists.txt
5757
├── FortranLanguage.h
5858
├── FortranLanguage.cpp
59-
├── FortranFormatters.h
60-
├── FortranFormatters.cpp
61-
└── FortranExpressionParser.h
59+
└── FortranFormatters.cpp
6260
```
6361

62+
**Plugin Registration**: Use `LLDB_PLUGIN_DEFINE(FortranLanguage)` macro and register with PluginManager following the pattern from CPlusPlusLanguage and ObjCLanguage.
63+
6464
### DWARF Integration Points
6565

6666
Leverage existing Fortran-specific DWARF features:
@@ -127,18 +127,22 @@ Leverage existing Fortran-specific DWARF features:
127127
## Build System Integration
128128

129129
### Selective Building Strategy
130-
Given the massive LLVM codebase, we need a minimal build configuration:
130+
Following LLVM best practices for focused development:
131131

132132
```bash
133-
# Minimal LLDB build for Fortran development
133+
# Recommended LLDB build for Fortran development
134134
cmake -S llvm -B build -G Ninja \
135135
-DLLVM_ENABLE_PROJECTS="clang;lldb;flang" \
136136
-DLLVM_TARGETS_TO_BUILD="X86" \
137-
-DCMAKE_BUILD_TYPE=Debug \
137+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
138138
-DLLVM_ENABLE_ASSERTIONS=ON \
139-
-DLLDB_INCLUDE_TESTS=ON
139+
-DLLDB_INCLUDE_TESTS=ON \
140+
-DLLVM_INSTALL_UTILS=ON \
141+
-DLLVM_USE_LINKER=lld
140142
```
141143

144+
**Note**: Using `RelWithDebInfo` provides better performance than `Debug` while maintaining debug symbols. Use `Debug` only when debugging LLDB itself.
145+
142146
### Test-Driven Development Workflow
143147
1. Write failing test for new functionality
144148
2. Implement minimal code to pass test

0 commit comments

Comments
 (0)