MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / AllocationSize

Method AllocationSize

pkg/callstack/callstack.go:82–127  ·  view source on GitHub ↗

AllocationSize calculates the private region size to which the frame return address pertains if the memory pages within the region are private and non-shareable pages.

(proc windows.Handle)

Source from the content-addressed store, hash-verified

80// memory pages within the region are private and
81// non-shareable pages.
82func (f *Frame) AllocationSize(proc windows.Handle) uint64 {
83 if f.Addr.InSystemRange() {
84 return 0
85 }
86
87 r := va.VirtualQuery(proc, f.Addr.Uint64())
88
89 if r == nil || (r.State != windows.MEM_COMMIT || r.Protect == windows.PAGE_NOACCESS || r.Type != va.MemImage) {
90 return 0
91 }
92
93 pageCount := r.Size / pageSize
94 m := make([]sys.MemoryWorkingSetExInformation, pageCount)
95 for n := range pageCount {
96 addr := f.Addr.Inc(n * pageSize)
97 m[n].VirtualAddress = addr.Uintptr()
98 }
99
100 ws := va.QueryWorkingSet(proc, m)
101 if ws == nil {
102 return 0
103 }
104
105 var size uint64
106
107 // traverse all pages in the region
108 for _, r := range ws {
109 attr := r.VirtualAttributes
110 if !attr.Valid() {
111 continue
112 }
113
114 // use SharedOriginal after RS3/1709
115 if buildNumber >= 16299 {
116 if !attr.SharedOriginal() {
117 size += pageSize
118 }
119 } else {
120 if !attr.Shared() {
121 size += pageSize
122 }
123 }
124 }
125
126 return size
127}
128
129// Protection resolves the memory protection
130// of the pages within the region that contains the

Callers 2

AllocationSizesMethod · 0.80
callstackMapValuerMethod · 0.80

Calls 9

VirtualQueryFunction · 0.92
QueryWorkingSetFunction · 0.92
InSystemRangeMethod · 0.80
UintptrMethod · 0.80
ValidMethod · 0.80
SharedOriginalMethod · 0.80
SharedMethod · 0.80
Uint64Method · 0.45
IncMethod · 0.45

Tested by

no test coverage detected