Browse Source

Merge pull request #67 from rauls5382/deleted

Parse correctly mappings where the binary has been deleted
Raul Silvera 8 years ago
parent
commit
5af1fccf7b
2 changed files with 12 additions and 4 deletions
  1. 3
    3
      profile/legacy_profile.go
  2. 9
    1
      profile/legacy_profile_test.go

+ 3
- 3
profile/legacy_profile.go View File

@@ -57,12 +57,12 @@ var (
57 57
 	cHex           = `(?:0x)?([[:xdigit:]]+)`
58 58
 	cHexRange      = `\s*` + cHex + `[\s-]?` + oSpace + cHex + `:?`
59 59
 	cSpaceString   = `(?:\s+(\S+))?`
60
-	cSpaceHex      = `\s+([[:xdigit:]]+)`
60
+	cSpaceHex      = `(?:\s+([[:xdigit:]]+))?`
61 61
 	cSpaceAtOffset = `(?:\s+\(@([[:xdigit:]]+)\))?`
62 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 68
 func isSpaceOrComment(line string) bool {

+ 9
- 1
profile/legacy_profile_test.go View File

@@ -157,6 +157,14 @@ func TestParseMappingEntry(t *testing.T) {
157 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 169
 			entry: "  02e00000-02e8a000: /foo/bin",
162 170
 			want: &Mapping{
@@ -218,7 +226,7 @@ func TestParseMappingEntry(t *testing.T) {
218 226
 	} {
219 227
 		got, err := parseMappingEntry(test.entry)
220 228
 		if err != nil {
221
-			t.Error(err)
229
+			t.Errorf("%s: %v", test.entry, err)
222 230
 		}
223 231
 		if !reflect.DeepEqual(test.want, got) {
224 232
 			t.Errorf("%s want=%v got=%v", test.entry, test.want, got)