Refactor: Implement red/black tree for FDE lookup

This commit is contained in:
Derek Parker
2014-08-04 18:02:08 -05:00
parent 8a5865e5d0
commit c59f19cfb2
7 changed files with 219 additions and 63 deletions

View File

@ -51,7 +51,6 @@ func parseLength(ctx *parseContext) parsefunc {
fn = parseVersion
} else {
ctx.Frame = &FrameDescriptionEntry{Length: ctx.Length, CIE: ctx.Common, AddressRange: &addrange{}}
ctx.Entries = append(ctx.Entries, ctx.Frame)
fn = parseInitialLocation
}
@ -64,6 +63,10 @@ func parseLength(ctx *parseContext) parsefunc {
func parseInitialLocation(ctx *parseContext) parsefunc {
ctx.Frame.AddressRange.begin = binary.LittleEndian.Uint64(ctx.Buf.Next(8))
// Insert into the tree after setting address range begin
// otherwise compares won't work.
ctx.Entries.Put(ctx.Frame)
ctx.Length -= 8
return parseAddressRange