| 239 | }; |
| 240 | |
| 241 | static int |
| 242 | command(int argc, char *argv[]) |
| 243 | { |
| 244 | bool symbolic = false; |
| 245 | |
| 246 | int opt; |
| 247 | while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) { |
| 248 | switch (opt) { |
| 249 | case 'h': |
| 250 | usage(); |
| 251 | return 0; |
| 252 | case 's': |
| 253 | symbolic = true; |
| 254 | break; |
| 255 | case CALLS_OPT: |
| 256 | calls.merge(optarg); |
| 257 | break; |
| 258 | default: |
| 259 | std::cerr << "error: unexpected option `" << (char)opt << "`\n"; |
| 260 | usage(); |
| 261 | return 1; |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | os::setBinaryMode(stdout); |
| 266 | |
| 267 | std::cout.sync_with_stdio(false); |
| 268 | |
| 269 | PickleWriter writer(std::cout); |
| 270 | PickleVisitor visitor(writer, symbolic); |
| 271 | |
| 272 | for (int i = optind; i < argc; ++i) { |
| 273 | trace::Parser parser; |
| 274 | |
| 275 | if (!parser.open(argv[i])) { |
| 276 | return 1; |
| 277 | } |
| 278 | |
| 279 | trace::Call *call; |
| 280 | while ((call = parser.parse_call())) { |
| 281 | if (call->no > calls.getLast()) { |
| 282 | delete call; |
| 283 | break; |
| 284 | } |
| 285 | if (calls.contains(*call)) { |
| 286 | writer.begin(); |
| 287 | visitor.visit(call); |
| 288 | writer.end(); |
| 289 | } |
| 290 | delete call; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | const Command pickle_command = { |
| 298 | "pickle", |
nothing calls this directly
no test coverage detected