diff options
| author | Tamas Koczka <poprdi@google.com> | 2026-01-28 14:34:43 +0000 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2026-01-28 16:30:57 +0000 |
| commit | 0ce7d86d6a53b38ed75045173da33b277415254d (patch) | |
| tree | 7adfdaafad8f402b3d1983426d7817c637664424 /pkg/codesearch/database.go | |
| parent | bb732b9882d4a11b56b97fcf41ce9625d82171c9 (diff) | |
pkg/codesearch: expose struct layout in codesearch
- Extract struct field offsets and sizes in the C++ codesearch indexer.
- Add 'fields' to the JSON definition output.
- Update pkg/codesearch to parse and expose the new field information.
- Add 'struct-layout' command to syz-codesearch for debugging.
- Add 'codesearch-struct-layout' tool to pkg/aflow/tool/codesearcher/
to allow LLM agents to query struct memory layout and map byte offsets to fields.
- Support pointer marshaling for optional JSON values (e.g. *uint)
Diffstat (limited to 'pkg/codesearch/database.go')
| -rw-r--r-- | pkg/codesearch/database.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/pkg/codesearch/database.go b/pkg/codesearch/database.go index 92f0944a9..9185804ed 100644 --- a/pkg/codesearch/database.go +++ b/pkg/codesearch/database.go @@ -31,6 +31,13 @@ type Definition struct { Body LineRange `json:"body,omitempty"` Comment LineRange `json:"comment,omitempty"` Refs []Reference `json:"refs,omitempty"` + Fields []FieldInfo `json:"fields,omitempty"` +} + +type FieldInfo struct { + Name string `json:"name,omitempty"` + OffsetBits uint64 `json:"offset"` + SizeBits uint64 `json:"size"` } type Reference struct { @@ -152,7 +159,7 @@ func (v *RefKind) UnmarshalJSON(data []byte) error { var DatabaseFormatHash = func() string { // Semantic version should be bumped when the schema does not change, // but stored values changes. - const semanticVersion = "3" + const semanticVersion = "4" schema, err := jsonschema.For[Database](nil) if err != nil { panic(err) @@ -184,6 +191,9 @@ func (db *Database) Merge(other *Database, v *clangtool.Verifier) { for _, ref := range def.Refs { db.intern(&ref.Name) } + for i := range def.Fields { + db.intern(&def.Fields[i].Name) + } } } |
