@@ -46,7 +46,48 @@ type ProcessInfo struct {
4646
4747 ProcessConnections `textlog:",expand"`
4848
49- Memory * SparseData `json:"memory,omitempty" textlog:"memory,expand,omitempty"`
49+ Sections Sections `json:"sections,omitempty" textlog:"-"`
50+ }
51+
52+ type Sections []Section
53+
54+ // Section describes a memory range in a process's virtual memory.
55+ // This typically corresponds to a section in an executable file or library, such as .text, .data, etc.,
56+ // or a stack, heap, or similar.
57+ // In Linux terms: it corresponds to a line in /proc/<pid>/maps.
58+ type Section struct {
59+ // Name of the section. For sections from loaded libraries, this is the library's file path.
60+ // For other memory ranges, this is OS specific and may be empty.
61+ Name string `json:"name"`
62+ // Address is the start address of the section in the process's virtual memory.
63+ Address uint64 `json:"address"`
64+ // Size is the size of the section in bytes.
65+ Size uint64 `json:"size" textlog:"size"`
66+ // Offset is the offset within the mapped file or library, if this section
67+ // corresponds to a file section. If this section does not correspond to a file,
68+ // this is empty.
69+ Offset uint64 `json:"offset,omitempty"`
70+ // SparseData contains a sparse representation of the section's data.
71+ // Only the interesting parts of the section are included, typically those that have been matched.
72+ SparseData * SparseData `json:"sparse_data,omitempty"`
73+ // Permissions of the section.
74+ Permissions RwxPermissions `json:"permissions"`
75+ }
76+
77+ // RelativeTextPointer implements the jsonlog.TextReferenceResolver interface for Sections.
78+ // It resolves a reference to a Section's SparseData field to a human-readable string.
79+ func (s * Sections ) RelativeTextPointer (pointee any ) (string , bool ) {
80+ for i := range * s {
81+ section := & (* s )[i ]
82+ if pointee == & section .SparseData {
83+ if section .Name != "" {
84+ return section .Name , true
85+ } else {
86+ return fmt .Sprintf ("0x%x" , section .Address ), true
87+ }
88+ }
89+ }
90+ return "" , false
5091}
5192
5293type ProcessConnections struct {
0 commit comments