Lines Matching full:self
104 def raise_error(self, filepath, reason): argument
110 def is_readable_file(self, filepath): argument
112 self.raise_error(filepath, "is not a valid path")
116 self.raise_error(filepath, "is not a readable file")
118 def __call__(self, parser, namespace, values, option_string=None): argument
120 if (self.is_readable_file(filepath)):
121 setattr(namespace, self.dest, filepath)
124 def raise_error(self, filepath, reason): argument
130 def is_writeable_file(self, filepath): argument
136 self.raise_error(filepath, "is not a valid path")
140 self.raise_error(filepath, "is not a writeable file")
142 def __call__(self, parser, namespace, values, option_string=None): argument
144 if (self.is_writeable_file(filepath)):
145 setattr(namespace, self.dest, filepath)
147 self.raise_error(
153 def raise_error(self, value, reason): argument
159 def is_valid_architecture(self, value): argument
163 def __call__(self, parser, namespace, values, option_string=None): argument
165 if (self.is_valid_architecture(value)):
166 setattr(namespace, self.dest, VALID_ARCHS[value])
168 self.raise_error(
277 def __str__(self): argument
278 return "{}:{:d}".format(self.filename.decode(), self.line_no)
302 def __init__(self): argument
304 self.matchings = [
306 lambda x: self.enstyleNumHex(x.group()),
310 lambda x: '0x' + self.enstyleNumHex(x.group(2)),
314 lambda x: self.enstyleNumBin(x.group()),
320 self.enstyle( fg.green , r'\3') ,
324 self.enstyle(bg.green , r'\1') +
331 self.enstyle( fg.green , r'\3') +
333 self.enstyle( fg.magenta , r'\4') ,
339 self.enstyle(fg.green, x.group(2))+
340 self.enstyleFuncParenth(x.group(3)),
344 self.matchingsInParenth = [
346 self.enstyle( fg.yellow , r'\1') +
347 self.enstyle( fg.magenta , r'=' ) +
352 self.enstyle( fg.magenta , r'\1') ,
356 self.enstyle( fg.magenta , r', ') ,
360 self.matchingsInStderr = [
362 self.enstyle(bg.yellow + fg.black , r'\1') ,
366 self.enstyle(bg.red + fg.black , r'\1') ,
370 self.enstyle(bg.magenta + fg.black , r'\1') ,
375 def toGroup(self, txt): argument
379 def leadingZero(self, txt, char): argument
381 groups = self.toGroup(txt)
389 def findSub(self, txt, mask, sub, char): argument
396 def enstyleFuncParenth(self, txt): argument
398 for repl, regex in self.matchingsInParenth:
402 def enstyleNumBin(self, txt): argument
415 def enstyleNumHex(self, txt): argument
426 [self.leadingZero(string, style)
432 [self.findSub(txt, styleMask, string, style)
442 result += rs.all + self.__style[thisstyle]
447 def enstyleStderr(self, txt): argument
451 for repl, regex in self.matchingsInStderr:
453 for repl, regex in self.matchings:
457 def enstyle(self, style, txt): argument
460 def produce_string(self, txt): argument
462 for repl, regex in self.matchings:
466 def print(self, txt): argument
467 self.__print(self.produce_string(txt))
505 def __init__(self, columncount): argument
506 self.dsp_arch = dsp_arch
507 self._fields_
508 self.ar_regex = re.compile(r'ar[0-9]+')
510 self._longest_field = len(max([x[0] for x in self._fields_], key=len))
512 self.columncount = max (1, int(columncount[0]))
514 self.columncount = max(1,
515 int(TERM_SIZE[0]/(self._longest_field + 2 + 2 * AR_WINDOW_WIDTH + 2))
517 self.columncount_ar = (
518 self.columncount
519 if self.columncount <= AR_WINDOW_WIDTH else
520 AR_WINDOW_WIDTH * int(self.columncount/AR_WINDOW_WIDTH)
523 def __windowbase_shift(self, iter, direction): argument
524 return (iter + self.windowbase * AR_WINDOW_WIDTH * direction)\
525 % self.dsp_arch.bitness
526 def windowbase_shift_left(self, iter): argument
527 return self.__windowbase_shift(iter, -1)
528 def windowbase_shift_right(self, iter): argument
529 return self.__windowbase_shift(iter, 1)
531 def reg_from_string(self, string): argument
532 if self.ar_regex.fullmatch(string):
533 return self.a[self.windowbase_shift_left(int(string[2:]))]
535 return self.__getattribute__(string)
537 def __str__(self): argument
542 def to_string(self, is_gdb): argument
545 self.windowbase * AR_WINDOW_WIDTH,
546 self.dsp_arch.bitness
549 string = ''.join([self.fmt(is_gdb, x)
551 [chunks(word, self.columncount) for word in [
560 string += ''.join([self.fmt(is_gdb, x)
562 [chunks(word, self.columncount) for word in [
570 [chunks(word, self.columncount_ar) for word in [
572 range( windowbase_shift, self.dsp_arch.bitness),
583 def fmt_gdb_command(self): argument
586 def fmt_pretty_form(self, separator = "|"): argument
587 return separator + "{:" + str(self._longest_field) + "} {:08x} "
589 def fmt_separator(self, name): argument
593 def fmt_pretty_auto(self, name): argument
594 return self.fmt_pretty_form(self.fmt_separator(name))
596 def fmt(self, is_gdb, names): argument
598 fmtr = lambda name: self.fmt_gdb_command()
600 fmtr = lambda name: self.fmt_pretty_auto(name)
605 name, self.reg_from_string(name)
611 def windowstart_process(self): argument
613 binary = "{0:b}".format(self.windowstart)
614 bit_start = len(binary)-1-self.windowbase
630 header = header[self.windowbase+1:]+ header[:self.windowbase+1]
632 string += "# windowbase: {:0X}\n".format(self.windowbase)
641 reg = "ar{0}".format(AR_WINDOW_WIDTH * (self.windowbase - iter))
642 reg1 = "ar{0}".format(AR_WINDOW_WIDTH * (self.windowbase - iter) + 1)
644 string += self.fmt_pretty_auto(reg).format(
645 reg, self.reg_from_string(reg)
646 ) + " {:0x} ".format(self.reg_from_string(reg1)) + "\n"
653 string += self.fmt_pretty_auto(reg).format(
654 reg, self.reg_from_string(reg)
655 ) + " {:0x} ".format(self.reg_from_string(reg1)) + "\n"
667 def __init__(self, args): argument
668 self.core_dump = CoreDumpFactory(args.arch)(
671 self.file_info = FileInfoFactory(args.arch, 32)()
705 self.core_dump,
706 self.file_info
708 self.stack = cd_file.read()
711 verbosePrint(self.core_dump.to_string(0))
713 verbosePrint(self.core_dump.windowstart_process())
715 stack_base = self.core_dump.stackptr
716 stack_dw_num = int(len(self.stack)/AR_WINDOW_WIDTH)
731 stdoutPrint(self.core_dump.to_string(1))
735 struct.unpack("I", self.stack[i*AR_WINDOW_WIDTH : (i+1)*AR_WINDOW_WIDTH])[0],
743 if self.core_dump.exccause != 63:
745 verbosePrint("# exccause: " + EXCCAUSE_CODE[self.core_dump.exccause][0])
746 if EXCCAUSE_CODE[self.core_dump.exccause][1]:
747 verbosePrint("# excvaddr: " + str(self.core_dump.excvaddr))
750 verbosePrint("# Location: " + str(self.file_info));