Exemplo n.º 1
0
func listLocks(parser tdformat.Parser, minWaitingThreads int, lockObjectClass string, out io.Writer) {
	locks := Locks{}

	for parser.NextThread() {
		if parser.SwitchedDump() {
			printLocks(locks, minWaitingThreads, out)

			dump := parser.Dump()
			locks = Locks{
				&dump,
				make(map[string]LockedThreads, 0),
			}
		}

		thread := parser.Thread()
		if len(thread.Locks) > 0 {
			for _, lock := range thread.Locks {
				if lockObjectClass == "" || lockObjectClass == lock.ClassName {
					rememberLock(&locks, &lock, &thread)
				}
			}
		}
	}

	printLocks(locks, minWaitingThreads, out)
}
Exemplo n.º 2
0
func allStats(parser tdformat.Parser) []StateStats {
	stats := make([]StateStats, 0)
	var currentStats StateStats

	for parser.NextThread() {
		if parser.SwitchedDump() {
			currentStats = newStats(parser.Dump())
			stats = append(stats, currentStats)
		}
		currentStats.stats[parser.Thread().State]++
	}

	return stats
}
Exemplo n.º 3
0
func grepThreads(parser tdformat.Parser, filters Filters, out io.Writer) {
	for parser.NextThread() {
		if parser.SwitchedDump() {
			// TODO: print dump start
		}

		thread := parser.Thread()
		if isMatching(&thread, &filters) {
			fmt.Fprintln(out, thread.TextContent)
		}
	}
}
Exemplo n.º 4
0
func listThreads(parser tdformat.Parser, conf Conf, out io.Writer) {
	// TODO: print header
	var threads []tdformat.Thread
	sorter := NewSortableThreads(nil, conf.sortBy, conf.reverseOrder)

	for parser.NextThread() {
		if parser.SwitchedDump() {
			printThreads(threads[0:], &sorter, conf, out)
			threads = make([]tdformat.Thread, 0)
		}

		threads = append(threads, parser.Thread())
	}

	// Flush the recorded list of threads
	//sorter = NewSortableThreads(threads, sortBy, reverseOrder)
	printThreads(threads[0:], &sorter, conf, out)
}