-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #15, support inline function on traceback
- Loading branch information
Showing
10 changed files
with
262 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// +build go1.9 | ||
// +build !go1.15 | ||
|
||
package goloader | ||
|
||
import ( | ||
"cmd/objfile/goobj" | ||
"strings" | ||
"unsafe" | ||
) | ||
|
||
func readPCInline(codeReloc *CodeReloc, symbol *goobj.Sym, fd *readAtSeeker) { | ||
fd.ReadAtWithSize(&(codeReloc.pclntable), symbol.Func.PCInline.Size, symbol.Func.PCInline.Offset) | ||
} | ||
|
||
func findFuncNameOff(codereloc *CodeReloc, funcname string) int32 { | ||
for index, _ := range codereloc._func { | ||
name := gostringnocopy(&codereloc.pclntable[codereloc._func[index].nameoff]) | ||
if name == funcname { | ||
return codereloc._func[index].nameoff | ||
} | ||
} | ||
return -1 | ||
} | ||
|
||
func findFileTab(codereloc *CodeReloc, filename string) int32 { | ||
tab := codereloc.fileMap[strings.TrimLeft(filename, FILE_SYM_PREFIX)] | ||
for index, value := range codereloc.filetab { | ||
if uint32(tab) == value { | ||
return int32(index) | ||
} | ||
} | ||
return -1 | ||
} | ||
|
||
func _addInlineTree(codereloc *CodeReloc, _func *_func, funcdata *[]uintptr, pcdata *[]uint32, inlineOffset uint32) (err error) { | ||
funcname := gostringnocopy(&codereloc.pclntable[_func.nameoff]) | ||
Func := codereloc.symMap[funcname].Func | ||
if Func != nil && len(Func.InlTree) != 0 { | ||
name := funcname + INLINETREE_SUFFIX | ||
bytes := make([]byte, len(Func.InlTree)*InlinedCallSize) | ||
for k, inl := range Func.InlTree { | ||
inlinedcall := initInlinedCall(codereloc, inl, _func) | ||
copy2Slice(bytes[k*InlinedCallSize:], uintptr(unsafe.Pointer(&inlinedcall)), InlinedCallSize) | ||
} | ||
codereloc.stkmaps[name] = bytes | ||
for _func.nfuncdata <= _FUNCDATA_InlTree { | ||
*funcdata = append(*funcdata, uintptr(0)) | ||
_func.nfuncdata++ | ||
} | ||
(*funcdata)[_FUNCDATA_InlTree] = (uintptr)(unsafe.Pointer(&(codereloc.stkmaps[name][0]))) | ||
for _func.npcdata <= _PCDATA_InlTreeIndex { | ||
*pcdata = append(*pcdata, uint32(0)) | ||
_func.npcdata++ | ||
} | ||
(*pcdata)[_PCDATA_InlTreeIndex] = inlineOffset | ||
} | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// +build go1.9 | ||
// +build !go1.10,!go1.11,!go1.12,!go1.13,!go1.14,!go1.15 | ||
|
||
package goloader | ||
|
||
import ( | ||
"cmd/objfile/goobj" | ||
) | ||
|
||
// PCDATA and FUNCDATA table indexes. | ||
// | ||
// See funcdata.h and ../cmd/internal/obj/funcdata.go. | ||
const ( | ||
_PCDATA_StackMapIndex = 0 | ||
_PCDATA_InlTreeIndex = 1 | ||
_FUNCDATA_ArgsPointerMaps = 0 | ||
_FUNCDATA_LocalsPointerMaps = 1 | ||
_FUNCDATA_InlTree = 2 | ||
_ArgsSizeUnknown = -0x80000000 | ||
) | ||
|
||
// moduledata records information about the layout of the executable | ||
// image. It is written by the linker. Any changes here must be | ||
// matched changes to the code in cmd/internal/ld/symtab.go:symtab. | ||
// moduledata is stored in read-only memory; none of the pointers here | ||
// are visible to the garbage collector. | ||
type moduledata struct { | ||
pclntable []byte | ||
ftab []functab | ||
filetab []uint32 | ||
findfunctab uintptr | ||
minpc, maxpc uintptr | ||
|
||
text, etext uintptr | ||
noptrdata, enoptrdata uintptr | ||
data, edata uintptr | ||
bss, ebss uintptr | ||
noptrbss, enoptrbss uintptr | ||
end, gcdata, gcbss uintptr | ||
types, etypes uintptr | ||
|
||
textsectmap []textsect | ||
typelinks []int32 // offsets from types | ||
itablinks []*itab | ||
|
||
ptab []ptabEntry | ||
|
||
pluginpath string | ||
pkghashes []modulehash | ||
|
||
modulename string | ||
modulehashes []modulehash | ||
|
||
gcdatamask, gcbssmask bitvector | ||
|
||
typemap map[typeOff]uintptr // offset to *_rtype in previous module | ||
|
||
next *moduledata | ||
} | ||
|
||
type _func struct { | ||
entry uintptr // start pc | ||
nameoff int32 // function name | ||
|
||
args int32 // in/out args size | ||
_ int32 // previously legacy frame size; kept for layout compatibility | ||
|
||
pcsp int32 | ||
pcfile int32 | ||
pcln int32 | ||
npcdata int32 | ||
nfuncdata int32 | ||
} | ||
|
||
func init_func(symbol *goobj.Sym, nameOff, spOff, pcfileOff, pclnOff int) _func { | ||
fdata := _func{ | ||
entry: uintptr(0), | ||
nameoff: int32(nameOff), | ||
args: int32(symbol.Func.Args), | ||
pcsp: int32(spOff), | ||
pcfile: int32(pcfileOff), | ||
pcln: int32(pclnOff), | ||
npcdata: int32(len(symbol.Func.PCData)), | ||
nfuncdata: int32(len(symbol.Func.FuncData)), | ||
} | ||
return fdata | ||
} |
Oops, something went wrong.