Skip to content

Commit cc16438

Browse files
committed
feat: process sections
1 parent 08c8d18 commit cc16438

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

thorlog/v3/process.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,29 @@ type ProcessInfo struct {
4646

4747
ProcessConnections `textlog:",expand"`
4848

49-
Memory *SparseData `json:"memory,omitempty" textlog:"memory,expand,omitempty"`
49+
Sections []Section `json:"sections,omitempty" textlog:"-"`
50+
}
51+
52+
// Section describes a memory range in a process's virtual memory.
53+
// This typically corresponds to a section in an executable file or library, such as .text, .data, etc.,
54+
// or a stack, heap, or similar.
55+
// In linux terms: it corresponds to a line in /proc/<pid>/maps.
56+
type Section struct {
57+
// Name of the section. For sections from loaded libraries, this is the library's file path.
58+
// For other memory ranges, this is OS specific and may be empty.
59+
Name string `json:"name"`
60+
// Address is the start address of the section in the process's virtual memory.
61+
// The end address of the section can be calculated as Address + SparseData.Length.
62+
Address uint64 `json:"address"`
63+
// Offset is the offset within the mapped file or library, if this section
64+
// corresponds to a file section. If this section does not correspond to a file,
65+
// this is empty.
66+
Offset uint64 `json:"offset,omitempty"`
67+
// SparseData contains a sparse representation of the section's data.
68+
// Only the interesting parts of the section are included, typically those that have been matched.
69+
SparseData SparseData `json:"sparse_data"`
70+
// Permissions of the section.
71+
Permissions RwxPermissions `json:"permissions"`
5072
}
5173

5274
type ProcessConnections struct {

thorlog/v3/sparsedata.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import (
1212
type SparseData struct {
1313
jsonlog.ObjectHeader
1414
Elements []SparseDataElement `json:"elements" jsonschema:"nullable"`
15-
Length int64 `json:"length"`
15+
// Length is the total length of the data that this sparse data object describes.
16+
// In other words, all Elements are within an address range of [0, Length).
17+
Length int64 `json:"length"`
1618
}
1719

1820
const truncateSequence = "[...]"

0 commit comments

Comments
 (0)