Diff of /libpp/parse_filename.cpp [261633] .. [a6d955] Maximize Restore

  Switch to unified view

a/libpp/parse_filename.cpp b/libpp/parse_filename.cpp
...
...
71
    path.erase(path.begin(), it);
71
    path.erase(path.begin(), it);
72
}
72
}
73
73
74
74
75
/// Handle an anon region. Pretty print the details.
75
/// Handle an anon region. Pretty print the details.
76
/// The second argument is the anon portion of the path which will
77
/// contain extra details such as the anon region name (unknown, vdso, heap etc.)
76
string const parse_anon(string const & str)
78
string const parse_anon(string const & str, string const & str2)
77
{
79
{
80
  string name = str2;
81
  name.erase(0,6); // Get rid of "{anon:
82
  name.erase(name.size() - 1,1); // Get rid of the trailing '}'
78
    vector<string> parts = separate_token(str, '.');
83
    vector<string> parts = separate_token(str, '.');
79
    if (parts.size() != 3)
84
    if (parts.size() != 3)
80
        throw invalid_argument("parse_anon() invalid name: " + str);
85
        throw invalid_argument("parse_anon() invalid name: " + str);
81
86
82
    string ret = "anon (tgid:";
87
    string ret = name +" (tgid:";
83
    ret += parts[0] + " range:" + parts[1] + "-" + parts[2] + ")";
88
    ret += parts[0] + " range:" + parts[1] + "-" + parts[2] + ")";
84
    return ret;
89
    return ret;
85
}
90
}
86
91
87
92
...
...
91
/*
96
/*
92
 *  valid filename are variations on:
97
 *  valid filename are variations on:
93
 *
98
 *
94
 * {kern}/name/event_spec
99
 * {kern}/name/event_spec
95
 * {root}/path/to/bin/{dep}/{root}/path/to/bin/event_spec
100
 * {root}/path/to/bin/{dep}/{root}/path/to/bin/event_spec
96
 * {root}/path/to/bin/{dep}/{anon}/pid.start.end/event_spec
101
 * {root}/path/to/bin/{dep}/{anon:anon}/pid.start.end/event_spec
102
 * {root}/path/to/bin/{dep}/{anon:[vdso]}/pid.start.end/event_spec
97
 * {root}/path/to/bin/{dep}/{kern}/name/event_spec
103
 * {root}/path/to/bin/{dep}/{kern}/name/event_spec
98
 * {root}/path/to/bin/{dep}/{root}/path/to/bin/{cg}/{root}/path/to/bin/event_spec
104
 * {root}/path/to/bin/{dep}/{root}/path/to/bin/{cg}/{root}/path/to/bin/event_spec
99
105
100
 *
106
 *
101
 * where /name/ denote a unique path component
107
 * where /name/ denote a unique path component
...
...
141
147
142
    // skip "{dep}"
148
    // skip "{dep}"
143
    ++i;
149
    ++i;
144
150
145
    // PP:3.19 {dep}/ must be followed by {kern}/, {root}/ or {anon}/
151
    // PP:3.19 {dep}/ must be followed by {kern}/, {root}/ or {anon}/
146
    if (path[i] != "{kern}" && path[i] != "{root}" && path[i] != "{anon}") {
152
    if (path[i] != "{kern}" && path[i] != "{root}" &&
153
      path[i].find("{anon", 0) != 0) {
147
        throw invalid_argument("parse_filename() invalid filename: " +
154
        throw invalid_argument("parse_filename() invalid filename: " +
148
                       filename);
155
                       filename);
149
    }
156
    }
150
157
151
  bool anon = path[i] == "{anon}";
158
  bool anon = path[i].find("{anon:" ,0) == 0;
152
159
153
    // skip "{root}", "{kern}" or "{anon}"
160
    // skip "{root}", "{kern}" or "{anon:.*}"
154
    ++i;
161
    ++i;
155
162
156
    for (; i < path.size(); ++i) {
163
    for (; i < path.size(); ++i) {
157
        if (path[i] == "{cg}")
164
        if (path[i] == "{cg}")
158
            break;
165
            break;
159
166
160
        if (anon) {
167
        if (anon) {
161
          result.lib_image = parse_anon(path[i++]);
168
          result.lib_image = parse_anon(path[i], path[i - 1]);
169
          i++;
162
            break;
170
            break;
163
        }
171
        }
164
        result.lib_image += "/" + path[i];
172
        result.lib_image += "/" + path[i];
165
    }
173
    }
166
174
...
...
168
        return result;
176
        return result;
169
177
170
    // skip "{cg}"
178
    // skip "{cg}"
171
    ++i;
179
    ++i;
172
    if (i == path.size() ||
180
    if (i == path.size() ||
173
        (path[i] != "{kern}" && path[i] != "{root}" && path[i] != "{anon}")) {
181
        (path[i] != "{kern}" && path[i] != "{root}" &&
182
       path[i].find("{anon", 0) != 0)) {
174
        throw invalid_argument("parse_filename() invalid filename: "
183
        throw invalid_argument("parse_filename() invalid filename: "
175
                               + filename);
184
                               + filename);
176
    }
185
    }
177
186
178
    // skip "{root}", "{kern}" or "{anon}"
187
    // skip "{root}", "{kern}" or "{anon}"
179
  anon = path[i] == "{anon}";
188
  anon = (path[i].find("{anon",0) == 0);
180
    ++i;
189
    ++i;
181
190
182
    if (anon) {
191
    if (anon) {
183
        result.cg_image = parse_anon(path[i++]);
192
        result.cg_image = parse_anon(path[i], path[i - 1]);
193
      i++;
184
    } else {
194
    } else {
185
        for (; i < path.size(); ++i)
195
        for (; i < path.size(); ++i)
186
            result.cg_image += "/" + path[i];
196
            result.cg_image += "/" + path[i];
187
    }
197
    }
188
198