#!/usr/bin/env php
<?php
require 'TraceParser.php';
require 'StackTraceForSymbol.php';

if (count($argv) < 3) {
  printf("Parses an XT file and prints stack traces for all occurances of the given symbol.

\tUsage: %s symbol file.xt
\n", $argv[0]);
 exit(1);
}

$symbol = $argv[1];
$file = $argv[2];

$collector = new StackTraceForSymbol($symbol);

$parser = new TraceParser($file);
$parser->register($collector);
$parser->parse();

$report = $collector->getReport();

if (empty($report)) {
  die("No symbols found");
}

$counter = 0;
foreach ($report as $trace) {
  ++$counter;
  print $counter . ".\t";// . "\t" . array_shift($trace) . PHP_EOL . "\t";
  print implode(PHP_EOL . "\t", $trace);
  print PHP_EOL . PHP_EOL;
}
?>