github.com/Rookout/GoSDK@v0.1.48/pkg/services/instrumentation/binary_info/compile_unit.go (about) 1 // The MIT License (MIT) 2 3 // Copyright (c) 2014 Derek Parker 4 5 // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 // this software and associated documentation files (the "Software"), to deal in 7 // the Software without restriction, including without limitation the rights to 8 // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 // the Software, and to permit persons to whom the Software is furnished to do so, 10 // subject to the following conditions: 11 12 // The above copyright notice and this permission notice shall be included in all 13 // copies or substantial portions of the Software. 14 15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 22 package binary_info 23 24 import ( 25 "debug/dwarf" 26 27 "github.com/Rookout/GoSDK/pkg/services/instrumentation/dwarf/line" 28 ) 29 30 type compileUnit struct { 31 name string 32 Version uint8 33 lowPC uint64 34 ranges [][2]uint64 35 36 entry *dwarf.Entry 37 IsGo bool 38 lineInfo *line.DebugLineInfo 39 optimized bool 40 producer string 41 42 offset dwarf.Offset 43 44 image *Image 45 } 46 47 type compileUnitsByOffset []*compileUnit 48 49 func (v compileUnitsByOffset) Len() int { return len(v) } 50 func (v compileUnitsByOffset) Less(i int, j int) bool { return v[i].offset < v[j].offset } 51 func (v compileUnitsByOffset) Swap(i int, j int) { v[i], v[j] = v[j], v[i] } 52 53 func (c *compileUnit) pcInRange(pc uint64) bool { 54 for _, rng := range c.ranges { 55 if pc >= rng[0] && pc < rng[1] { 56 return true 57 } 58 } 59 return false 60 }