MCPcopy Create free account
hub / github.com/dispatchrun/wzprof / parseSubprogram

Method parseSubprogram

dwarf.go:173–233  ·  view source on GitHub ↗
(cu *dwarf.Entry, ns string, e *dwarf.Entry)

Source from the content-addressed store, hash-verified

171}
172
173func (d *dwarfparser) parseSubprogram(cu *dwarf.Entry, ns string, e *dwarf.Entry) {
174 // Assumption is r has just read the top entry of the subprogram, which
175 // is e.
176
177 var inlines []entryRanges
178 for e.Children {
179 ent, err := d.r.Next()
180 if err != nil || ent == nil {
181 break
182 }
183 if ent.Tag == 0 {
184 break
185 }
186 if ent.Tag != dwarf.TagInlinedSubroutine {
187 d.r.SkipChildren()
188 continue
189 }
190 ranges, err := d.d.Ranges(ent)
191 if err != nil {
192 d.r.SkipChildren()
193 continue
194 }
195 inlines = append(inlines, entryRanges{ent, ranges})
196 // Inlines can have children that describe which variables were
197 // used during inlining.
198 d.r.SkipChildren()
199 }
200
201 ranges, err := d.d.Ranges(e)
202 if err != nil {
203 log.Printf("dwarf: failed to read ranges: %s\n", err)
204 return
205 }
206
207 spgm := &subprogram{
208 Entry: e,
209 CU: cu,
210 Inlines: inlines,
211 Namespace: ns,
212 }
213
214 if len(ranges) == 0 {
215 // If there is no range provided by dwarf, attach this
216 // subprogram to an artificial empty range unlikely to be used.
217 // This is so that we still have a record of the function in the
218 // subprograms collection, as that's where the name resolution
219 // for inline functions searches for the inlined function.
220 // Notably, it's likely that a subprogram without range
221 // represent a function that has only been inlined. This
222 // situation is temporary until we rework the subprograms data
223 // structure.
224 ranges = append(ranges, sourceOffsetRange{math.MaxUint64, math.MaxUint64})
225 }
226
227 for _, pcr := range ranges {
228 d.subprograms = append(d.subprograms, subprogramRange{
229 Range: pcr,
230 Subprogram: spgm,

Callers 1

parseAnyMethod · 0.95

Calls 1

NextMethod · 0.45

Tested by

no test coverage detected