浏览代码

Merge pull request #67 from rauls5382/deleted

Parse correctly mappings where the binary has been deleted
Raul Silvera 8 年前
父节点
当前提交
5af1fccf7b
共有 2 个文件被更改,包括 12 次插入4 次删除
  1. 3
    3
      profile/legacy_profile.go
  2. 9
    1
      profile/legacy_profile_test.go

+ 3
- 3
profile/legacy_profile.go 查看文件

57
 	cHex           = `(?:0x)?([[:xdigit:]]+)`
57
 	cHex           = `(?:0x)?([[:xdigit:]]+)`
58
 	cHexRange      = `\s*` + cHex + `[\s-]?` + oSpace + cHex + `:?`
58
 	cHexRange      = `\s*` + cHex + `[\s-]?` + oSpace + cHex + `:?`
59
 	cSpaceString   = `(?:\s+(\S+))?`
59
 	cSpaceString   = `(?:\s+(\S+))?`
60
-	cSpaceHex      = `\s+([[:xdigit:]]+)`
60
+	cSpaceHex      = `(?:\s+([[:xdigit:]]+))?`
61
 	cSpaceAtOffset = `(?:\s+\(@([[:xdigit:]]+)\))?`
61
 	cSpaceAtOffset = `(?:\s+\(@([[:xdigit:]]+)\))?`
62
 	cPerm          = `(?:\s+([-rwxp]+))?`
62
 	cPerm          = `(?:\s+([-rwxp]+))?`
63
 
63
 
64
-	procMapsRE  = regexp.MustCompile(`^` + cHexRange + cPerm + cSpaceHex + hexPair + spaceDigits + cSpaceString + `\s*$`)
65
-	briefMapsRE = regexp.MustCompile(`^` + cHexRange + cPerm + cSpaceString + cSpaceAtOffset + cSpaceString + `\s*$`)
64
+	procMapsRE  = regexp.MustCompile(`^` + cHexRange + cPerm + cSpaceHex + hexPair + spaceDigits + cSpaceString)
65
+	briefMapsRE = regexp.MustCompile(`^` + cHexRange + cPerm + cSpaceString + cSpaceAtOffset + cSpaceHex)
66
 )
66
 )
67
 
67
 
68
 func isSpaceOrComment(line string) bool {
68
 func isSpaceOrComment(line string) bool {

+ 9
- 1
profile/legacy_profile_test.go 查看文件

157
 				File:   "/foo/bin",
157
 				File:   "/foo/bin",
158
 			},
158
 			},
159
 		},
159
 		},
160
+		{
161
+			entry: "  02e00000-02e8a000: /foo/bin (deleted)",
162
+			want: &Mapping{
163
+				Start: 0x2e00000,
164
+				Limit: 0x2e8a000,
165
+				File:  "/foo/bin",
166
+			},
167
+		},
160
 		{
168
 		{
161
 			entry: "  02e00000-02e8a000: /foo/bin",
169
 			entry: "  02e00000-02e8a000: /foo/bin",
162
 			want: &Mapping{
170
 			want: &Mapping{
218
 	} {
226
 	} {
219
 		got, err := parseMappingEntry(test.entry)
227
 		got, err := parseMappingEntry(test.entry)
220
 		if err != nil {
228
 		if err != nil {
221
-			t.Error(err)
229
+			t.Errorf("%s: %v", test.entry, err)
222
 		}
230
 		}
223
 		if !reflect.DeepEqual(test.want, got) {
231
 		if !reflect.DeepEqual(test.want, got) {
224
 			t.Errorf("%s want=%v got=%v", test.entry, test.want, got)
232
 			t.Errorf("%s want=%v got=%v", test.entry, test.want, got)