def main(): # Handle the command line usage = "usage: %prog [options] rlis trace" parser = OptionParser(usage) parser.add_option("-m", "--mode", dest="mode", metavar="STRING", default="network", help="Specify the trace mode that " + "may be either network or system [default: %default]") parser.add_option("-s", "--spread", action="store_true", dest="spread", help="Output a fully spread tree, rather than " + "overlaying similar calls") (options, args) = parser.parse_args() if len(args) != 2: parser.error("Must specify both the rlis and trace file names") (rlis_file, trace_file) = args # Load the token table and the parser token_table = rlisTokens.TokenTable(rlis_file) roi_parser = parseLog.RoiParser(token_table) # Read in the packets and make list of bitlog packets if options.mode == "network": packet_class = packet.AMPacket elif options.mode == "system": packet_class = packet.SystemPacket else: parser.error("option -m must be either network or system") packets = packet.read_packets(trace_file, packet_class) bitlog_packets = packet.BitlogPacket.get_bitlog_packets(packets) # Create a source trace from the packets bitlog_traces = packetTrace.SourceTrace(bitlog_packets) # Print tokens start_time = bitlog_traces.traces[0][0].timestamp for trace_id in sorted(bitlog_traces.traces.keys()): print "# ==== Trace for node %d ====" % (trace_id) trace = bitlog_traces.traces[trace_id] tokens_and_times = roi_parser.tokenize_trace(trace, start_time) [tokens, times] = zip(*tokens_and_times) if options.spread: tree = FullCallTree("root") else: tree = OverlayCallTree("root") tree.build_from_tokens(tokens) print "digraph {" print str(tree) print "}"
(options, args) = parser.parse_args() if len(args) != 2: parser.error("Must specify both the rlis and trace file names") (rlis_file, trace_file) = args # Read in the packets and make list of bitlog packets if options.mode == "network": packet_class = packet.AMPacket elif options.mode == "system": packet_class = packet.SystemPacket else: parser.error("option -m must be either network or system") packets = packet.read_packets(trace_file, packet_class) bitlog_packets = packet.BitlogPacket.get_bitlog_packets(packets) # Create a source trace from the packets bitlog_traces = packetTrace.SourceTrace(bitlog_packets) start_time = bitlog_traces.get_start_time() # Print packets and exit if requested if options.print_packets: print bitlog_traces sys.exit(0) # Initialize the token tables and parser token_table = rlisTokens.TokenTable(rlis_file) roi_parser = RoiParser(token_table)
def main(): # Handle the command line usage = "usage: %prog [options] rlis trace" parser = OptionParser(usage) parser.add_option("-m", "--mode", dest="mode", metavar="STRING", default="system", help="Specify the trace mode that " + "may be either network or system [default: %default]") parser.add_option("-n", "--node", dest="node_id", default=None, type="int", help="Only print trace for node with specified " + "identifier [default: all nodes]") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="Print full token data rather than " + "the standard token trace") (options, args) = parser.parse_args() if len(args) != 2: parser.error("Must specify both the rlis and trace file names") (rlis_file, trace_file) = args # Read in the packets and make list of bitlog packets if options.mode == "network": packet_class = packet.AMPacket elif options.mode == "system": packet_class = packet.SystemPacket else: parser.error("option -m must be either network or system") packets = packet.read_packets(trace_file, packet_class) bitlog_packets = packet.BitlogPacket.get_bitlog_packets(packets) # Create a source trace from the packets bitlog_traces = packetTrace.SourceTrace(bitlog_packets) # Load the token table and the parser token_table = rlisTokens.TokenTable(rlis_file) roi_parser = parseLog.RoiParser(token_table) # Tokenize the stream for each node node_tokens = {} start_time = bitlog_traces.get_start_time() for trace_id in sorted(bitlog_traces.traces.keys()): trace = bitlog_traces.traces[trace_id] tokens_and_times = roi_parser.tokenize_trace(trace, start_time) [tokens, times] = zip(*tokens_and_times) node_tokens[trace_id] = tokens for id in sorted(node_tokens.keys()): # If node_id is specified then skip non-node_id nodes if options.node_id and id != options.node_id: pass # Print the output if not options.verbose: print " ".join(serialize_tokens(id, node_tokens[id])) else: print print_tokens(id, node_tokens[id])