Skip to content

Commit

Permalink
Handle IsLiteralLabel in AsmLabelAttr (#862)
Browse files Browse the repository at this point in the history
Fixes #860
  • Loading branch information
kroppt committed Jul 20, 2020
1 parent b603e1d commit d3c9135
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
25 changes: 14 additions & 11 deletions ast/asm_label_attr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@ package ast

// AsmLabelAttr is a type of attribute for assembler label
type AsmLabelAttr struct {
Addr Address
Pos Position
Inherited bool
FunctionName string
ChildNodes []Node
Addr Address
Pos Position
Inherited bool
FunctionName string
ChildNodes []Node
IsLiteralLabel bool
}

func parseAsmLabelAttr(line string) *AsmLabelAttr {
groups := groupsFromRegex(
`<(?P<position>.*)>
(?P<inherited> Inherited)?
"(?P<function>.+)"`,
"(?P<function>.+)"
(?P<literal> IsLiteralLabel)?`,
line,
)

return &AsmLabelAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Inherited: len(groups["inherited"]) > 0,
FunctionName: groups["function"],
ChildNodes: []Node{},
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Inherited: len(groups["inherited"]) > 0,
FunctionName: groups["function"],
ChildNodes: []Node{},
IsLiteralLabel: len(groups["literal"]) > 0,
}
}

Expand Down
30 changes: 20 additions & 10 deletions ast/asm_label_attr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,28 @@ import (
func TestAsmLabelAttr(t *testing.T) {
nodes := map[string]Node{
`0x7ff26d8224e8 </usr/include/sys/cdefs.h:569:36> "_fopen"`: &AsmLabelAttr{
Addr: 0x7ff26d8224e8,
Pos: NewPositionFromString("/usr/include/sys/cdefs.h:569:36"),
Inherited: false,
FunctionName: "_fopen",
ChildNodes: []Node{},
Addr: 0x7ff26d8224e8,
Pos: NewPositionFromString("/usr/include/sys/cdefs.h:569:36"),
Inherited: false,
FunctionName: "_fopen",
ChildNodes: []Node{},
IsLiteralLabel: false,
},
`0x7fd55a169318 </usr/include/stdio.h:325:47> Inherited "_popen"`: &AsmLabelAttr{
Addr: 0x7fd55a169318,
Pos: NewPositionFromString("/usr/include/stdio.h:325:47"),
Inherited: true,
FunctionName: "_popen",
ChildNodes: []Node{},
Addr: 0x7fd55a169318,
Pos: NewPositionFromString("/usr/include/stdio.h:325:47"),
Inherited: true,
FunctionName: "_popen",
ChildNodes: []Node{},
IsLiteralLabel: false,
},
`0x559fea32f5f0 <line:407:94> "__isoc99_fscanf" IsLiteralLabel`: &AsmLabelAttr{
Addr: 0x559fea32f5f0,
Pos: NewPositionFromString("line:407:94"),
Inherited: false,
FunctionName: "__isoc99_fscanf",
ChildNodes: []Node{},
IsLiteralLabel: true,
},
}

Expand Down

0 comments on commit d3c9135

Please sign in to comment.