-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Creating a dedicated issue to track the bug identified at #17 (comment)
Edit: For added context, the only hand-written files are parser.go and tree.go, both of which are mostly identical copies of the original parser.go and tree.go of the TextMapper project. Which is why this bug is interesting to fix as it pertains to TextMapper itself.
I'll add my latest debug session below, feel free to skim as it's quite long :)
The debug session below is debugging the none command, which uses the mini.tm grammar, and is invoked on the example.ll input file.
Specifically the following commands may be used to reproduce the debug session:
$ go get -u github.com/mewspring/foo/none/cmd/none
$ go get -u github.com/derekparker/delve/cmd/dlv
$ go get -u github.com/aarzilli/gdlv
$ cd $GOPATH/src/github.com/mewspring/foo/none/cmd/none
$ $GOPATH/bin/gdlv debug ../../example.llCheers,
Robin
Debug session
Is it correct that next should be overwritten here?
Then we will skip /* empty */ nonterminals that are in between other nonterminals.
Should it really be o >= endoffset? And not o > endoffset? Now, we decrease the end, so that InstMetadata will not be part of the call instruction.
OperandBundles and InstMetadata were not assigned to have CallInst as parent. They should have been. Note, end was too small. Most likely as a cause of using if o >= offset { end-- } instead of if o > offset { end-- }
This is probably wrong, as now OperandBundles and InstMetadata won't have CallInst as parent.
This is where it goes wrong. Really wrong. As the OperandBundles and InstMetadata of the previous CallInst are added to the current CallInst.
The only reason this happens is since OperandBundles and InstMetadata are zero in length, thus offset if not enough to distinguish which parent nonterminal they belong to.
This is the incorrect firstChild. It points to InstMetadata, but should really point to
Incorrect parents have now been set for InstMetadata and OperandBundles.
No parent was set for OperandBundles and InstMetadata. They should have both been assigned the last CallInst as parent (i.e. index 18).
Since InstMetadata (at index 10) is now the firstChild of the CallInst at index 18, and since the InstMetadata does not have a next (i.e. next is 0), the CallInst will not have any other children than the incorrectly added InstMetadata child. Therefore, calling Typ on CallInst will result in NONE type.
InstMetadata (at index 17) of previous instruction being added to have RetTerm as parent. The correct InstMetadata to add to RetTerm is at index 20.
FuncMetadata incorrectly added to have FuncBody as parent.
InstMetadata incorrectly added to have FuncBody as parent (should have been part of TermRet).
Panic with unknown node type NONE, since CallInst has InstMetadata as first child.












