示例#1
0
    def __init__(self, screen, e, elf_name, comp_dir, cfg):
        self.cfg = cfg
        self.fcache = {}
        self.e = e
        self.comp_dir = comp_dir
        self.screen = screen
        self.dw = None
        self.dw_loc = None
        self.record = None
        self.record_idx = 0
        self.record_pos = 0
        self.symname = ""
        self.file = ""
        self.line = -1
        self.search_sym = ""
        self.debugf = None
        self.addrloc = {}
        self.log = []
        self.log_lines = 15

        if elf_name != None:
            self.a2l = addr2line.addr2line(elf_name, comp_dir)

            self.screen.clear()
            self.screen.addstr(0, 0, "Processing ELF file.")
            self.screen.refresh()
            self.screen.addstr(1, 0, "Done. Step into first src line")
            self.screen.refresh()
示例#2
0
	def __init__(self, screen, e, elf_name, comp_dir, cfg):
		self.cfg = cfg
		self.fcache = {}
		self.e = e
		self.comp_dir = comp_dir
		self.screen = screen
		self.dw = None
		self.dw_loc = None
		self.record = None
		self.record_idx = 0
		self.record_pos = 0
		self.symname = ""
		self.file = ""
		self.line = -1
		self.search_sym = ""
		self.debugf = None
		self.addrloc = {}
		self.log = []
		self.log_lines =15

		if elf_name != None:
			self.a2l = addr2line.addr2line(elf_name, comp_dir)

			self.screen.clear()
			self.screen.addstr(0, 0, "Processing ELF file.")
			self.screen.refresh()
			self.screen.addstr(1, 0, "Done. Step into first src line")
			self.screen.refresh()
        data = file(sys.argv[1]).readlines()
else:
    data = file('sim_timers.out').readlines()

addr2line.set_rdtsc(long(data[0]))

data = [
    map(long,
        line.split()[:4]) +
    [map(long,
         line.split()[4:10]),
     line.split(' ', 10)[10].strip()] for line in data[1:]
]
data.sort(key=lambda line: line[0], reverse=True)

height, width = ex('stty size').split()
width = int(width)
if width < 120:
    width = 2 * width  # if we're line-wrapping anyway: use 2 full lines

for line in data[:15]:
    total, n, max, n_switched, trace, name = line
    result = '%6.1f s, %8u calls, avg %5.0f us/call, max %5.1f ms, switched = %.3f%% (%3u) ' % \
        (total / 1e9, n, total / (n or 1) / 1e3, max / 1e6, 100. * n_switched / (n or 1), n_switched)
    print '%-85s %s' % (result, name)
    for a in trace[1:6]:
        if a:
            (file, function, line) = addr2line.addr2line(a)
            function = function[:(width - 86 - len(file) - 1 - 1 - len(line))]
            print ' ' * 85, ':'.join((file, function, line)).strip()
示例#4
0
allocations = {}
for line in data:
  l = line.split()
  site, size, count = tuple(map(long, l[:-2])), long(l[-2]), long(l[-1])
  if site not in allocations:
    allocations[site] = [0, 0]
  allocations[site][0] += size
  allocations[site][1] += count

allocations = allocations.items()
allocations.sort(key = lambda (site, (size, count)): size, reverse = True)


height, width = ex('stty size').split()
width = int(width)
if width < 120:
  width = 2*width # if we're line-wrapping anyway: use 2 full lines

print 'Bytes (net)  Allocations (total)'
for site, (size, count) in allocations[:20]:
  print '%6.2fM %6dk' % (size/1024.**2, count/1000.),
  lines = []
  for addr in site:
    if not addr: continue
    (file, function, line) = addr2line.addr2line(addr)
    if file.endswith('logmem.cc'): continue
    function = function[:(width - 8 - 8 - len(file) - 1 - 1 - len(line))]
    lines.append(':'.join((file, function, line)).strip())
  print '\n                '.join(lines)
示例#5
0
    exe_file = None
    for o, a in opts:
        if o in ("-h", "--help"):
            usage()
            sys.exit()
        elif o in ("-e", "--exe"):
            exe = a
        else:
            assert False, "unhandled option"

    if exe == None:
        print >> sys.stderr, "No executable specified."
        sys.exit(1)

    try:
        a = addr2line.addr2line(exe)
        while True:
            l = raw_input().strip()
            if l == "" or l[0] == "#":
                print l
                continue

            (s_addr, s_type, sd) = l.split(":")

            try:
                addr = int(s_addr, 0)
                (file_name, lineno) = a.lookup(addr)
#                print "%s:%i" % a.lookup(addr)
                print "%s:%i:%s:%d"%(file_name, lineno, s_type, int(sd))
            except ValueError, e:
                print >> sys.stderr, "Invalid patch: %s" % e