Lines Matching refs:self

99     def __init__(self, out, dirs, strip_path):  argument
100 self._out = out
101 self._dirs = dirs
102 self._strip_path = strip_path
103 self._addr2line = None
104 self.reset()
106 def my_Popen(self, cmd): argument
118 def get_elf(self, elf_or_uuid): argument
121 for d in self._dirs:
128 def set_arch(self, elf): argument
129 self._arch = os.getenv('CROSS_COMPILE')
130 if self._arch:
136 self._arch = 'aarch64-linux-gnu-'
138 self._arch = 'arm-linux-gnueabihf-'
140 def arch_prefix(self, cmd, elf): argument
141 self.set_arch(elf)
142 if self._arch is None:
144 return self._arch + cmd
146 def spawn_addr2line(self, elf_name): argument
149 if self._addr2line_elf_name is elf_name:
151 if self._addr2line:
152 self._addr2line.terminate
153 self._addr2line = None
154 elf = self.get_elf(elf_name)
157 cmd = self.arch_prefix('addr2line', elf)
160 self._addr2line = self.my_Popen([cmd, '-f', '-p', '-e', elf])
161 self._addr2line_elf_name = elf_name
165 def elf_load_addr(self, addr): argument
166 if self._regions:
167 for r in self._regions:
175 return self._elfs[int(elf_idx)][1]
180 return self._tee_load_addr
183 return self._tee_load_addr
185 def elf_for_addr(self, addr): argument
186 l_addr = self.elf_load_addr(addr)
187 if l_addr == self._tee_load_addr:
189 for k in self._elfs:
190 e = self._elfs[k]
195 def subtract_load_addr(self, addr): argument
196 l_addr = self.elf_load_addr(addr)
203 def resolve(self, addr): argument
204 reladdr = self.subtract_load_addr(addr)
205 self.spawn_addr2line(self.elf_for_addr(addr))
206 if not reladdr or not self._addr2line:
208 if self.elf_for_addr(addr) == 'tee.elf':
210 int(self.first_vma('tee.elf'), 16))
212 print(reladdr, file=self._addr2line.stdin)
213 ret = self._addr2line.stdout.readline().rstrip('\n')
218 def symbol_plus_offset(self, addr): argument
221 reladdr = self.subtract_load_addr(addr)
222 elf_name = self.elf_for_addr(addr)
225 elf = self.get_elf(elf_name)
226 cmd = self.arch_prefix('nm', elf)
230 nm = self.my_Popen([cmd, '--numeric-sort', '--print-size', elf])
260 def section_plus_offset(self, addr): argument
262 reladdr = self.subtract_load_addr(addr)
263 elf_name = self.elf_for_addr(addr)
266 elf = self.get_elf(elf_name)
267 cmd = self.arch_prefix('objdump', elf)
271 objdump = self.my_Popen([cmd, '--section-headers', elf])
289 def process_abort(self, line): argument
295 sym = self.symbol_plus_offset(addr)
296 sec = self.section_plus_offset(addr)
308 def read_sections(self, elf_name): argument
311 if elf_name in self._sections:
313 elf = self.get_elf(elf_name)
316 cmd = self.arch_prefix('objdump', elf)
319 self._sections[elf_name] = []
320 objdump = self.my_Popen([cmd, '--section-headers', elf])
326 self._sections[elf_name].append([name, int(vma, 16),
329 def first_vma(self, elf_name): argument
330 self.read_sections(elf_name)
331 return '0x{:x}'.format(self._sections[elf_name][0][1])
333 def overlaps(self, section, addr, size): argument
341 def sections_in_region(self, addr, size, elf_idx): argument
343 addr = self.subtract_load_addr(addr)
348 elf = self._elfs[int(elf_idx)][0]
351 self.read_sections(elf)
352 if elf not in self._sections:
354 for s in self._sections[elf]:
355 if self.overlaps(s, iaddr, isize):
359 def reset(self): argument
360 self._call_stack_found = False
361 if self._addr2line:
362 self._addr2line.terminate()
363 self._addr2line = None
364 self._addr2line_elf_name = None
365 self._arch = None
366 self._saved_abort_line = ''
367 self._sections = {} # {elf_name: [[name, addr, size], ...], ...}
368 self._regions = [] # [[addr, size, elf_idx, saved line], ...]
369 self._elfs = {0: ["tee.elf", 0]} # {idx: [uuid, load_addr], ...}
370 self._tee_load_addr = '0x0'
371 self._func_graph_found = False
372 self._func_graph_skip_line = True
374 def pretty_print_path(self, path): argument
375 if self._strip_path:
376 return re.sub(re.escape(self._strip_path) + '/*', '', path)
379 def write(self, line): argument
380 if self._call_stack_found:
386 self._out.write(line[:pre])
387 self._out.write(addr)
396 res = self.resolve('0x{:x}'.format(pc))
397 res = self.pretty_print_path(res)
398 self._out.write(' ' + res)
399 self._out.write(line[post:])
402 self.reset()
403 if self._func_graph_found:
410 self._out.write(line[:pre])
411 res = self.resolve(addr)
413 self._out.write(res_arr[0])
414 self._out.write(line[post:])
415 self._func_graph_skip_line = False
418 self._out.write(line)
420 elif self._func_graph_skip_line:
423 self.reset()
431 self._regions.append([addr, size, elf_idx, line])
438 self._elfs[i] = [match.group('uuid'), match.group('load_addr'),
443 self._tee_load_addr = match.group('load_addr')
446 self._call_stack_found = True
447 if self._regions:
448 for r in self._regions:
454 self._out.write(saved_line)
456 self._out.write(saved_line.strip() +
457 self.sections_in_region(r_addr,
461 if self._elfs:
462 for k in self._elfs:
463 e = self._elfs[k]
466 self._out.write(e[2].strip())
467 elf = self.get_elf(e[0])
470 path = self.pretty_print_path(rpath)
471 self._out.write(' (' + path + ')')
472 self._out.write('\n')
475 if self._saved_abort_line:
476 self._out.write(self.process_abort(self._saved_abort_line))
479 self._func_graph_found = True
482 self.reset()
485 self._saved_abort_line = line
486 self._out.write(line)
488 def flush(self): argument
489 self._out.flush()