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

Method namesForSubprogram

dwarf.go:372–414  ·  view source on GitHub ↗

Returns a human-readable name and the name the most likely to match the one used in the wasm module. Walks up the inlining chain. Subprogram is optional. This function will look for the associated subprogram if spgm is nil.

(e *dwarf.Entry, spgm *subprogram)

Source from the content-addressed store, hash-verified

370// Subprogram is optional. This function will look for the associated subprogram
371// if spgm is nil.
372func (d *dwarfmapper) namesForSubprogram(e *dwarf.Entry, spgm *subprogram) (string, string) {
373 // If an inlined function, grab the name from the origin.
374 var err error
375 r := d.d.Reader()
376 for {
377 ao, ok := e.Val(dwarf.AttrAbstractOrigin).(dwarf.Offset)
378 if !ok {
379 break
380 }
381 r.Seek(ao)
382 e, err = r.Next()
383 if err != nil {
384 // malformed dwarf
385 break
386 }
387 }
388
389 // TODO: index
390 if spgm == nil {
391 for _, s := range d.subprograms {
392 if s.Subprogram.Entry.Offset == e.Offset {
393 spgm = s.Subprogram
394 break
395 }
396 }
397 }
398
399 var ns string
400 if spgm != nil {
401 ns = spgm.Namespace
402 // } else {
403 // panic("spgm not found")
404 }
405
406 name, _ := e.Val(dwarf.AttrName).(string)
407 name = ns + name
408 stableName, ok := e.Val(dwarf.AttrLinkageName).(string)
409 if !ok {
410 stableName = name
411 }
412
413 return name, stableName
414}

Callers 1

LocationsMethod · 0.95

Calls 1

NextMethod · 0.45

Tested by

no test coverage detected