Ejemplo n.º 1
0
    def disassemble(self, byte_parser):
        """Disassemble code, for ad-hoc experimenting."""

        for bp in byte_parser.child_parsers():
            chunks = bp._split_into_chunks()
            chunkd = dict((chunk.byte, chunk) for chunk in chunks)
            if bp.text:
                srclines = bp.text.splitlines()
            else:
                srclines = None
            print("\n%s: " % bp.code)
            upto = None
            for disline in disgen.disgen(bp.code):
                if disline.first:
                    if srclines:
                        upto = upto or disline.lineno-1
                        while upto <= disline.lineno-1:
                            print("%100s%s" % ("", srclines[upto]))
                            upto += 1
                    elif disline.offset > 0:
                        print("")
                line = disgen.format_dis_line(disline)
                chunk = chunkd.get(disline.offset)
                if chunk:
                    chunkstr = ":: %r" % chunk
                else:
                    chunkstr = ""
                print("%-70s%s" % (line, chunkstr))

        print("")
Ejemplo n.º 2
0
    def disassemble(self, byte_parser):
        """Disassemble code, for ad-hoc experimenting."""

        for bp in byte_parser.child_parsers():
            chunks = bp._split_into_chunks()
            chunkd = dict((chunk.byte, chunk) for chunk in chunks)
            if bp.text:
                srclines = bp.text.splitlines()
            else:
                srclines = None
            print("\n%s: " % bp.code)
            for disline in disgen.disgen(bp.code):
                if disline.first:
                    if srclines:
                        print("%80s%s" % ("", srclines[disline.lineno-1]))
                    elif disline.offset > 0:
                        print("")
                line = disgen.format_dis_line(disline)
                chunk = chunkd.get(disline.offset)
                if chunk:
                    exits = " ".join(str(e) for e in sorted(chunk.exits))
                    chunkstr = ": %s" % exits
                else:
                    chunkstr = ""
                print("%-70s%s" % (line, chunkstr))

        print("")
Ejemplo n.º 3
0
    def disassemble(self, byte_parser, histogram=False):
        """Disassemble code, for ad-hoc experimenting."""

        for bp in byte_parser.child_parsers():
            chunks = bp._split_into_chunks()
            chunkd = dict((chunk.byte, chunk) for chunk in chunks)
            if bp.text:
                srclines = bp.text.splitlines()
            else:
                srclines = None
            print("\n%s: " % bp.code)
            upto = None
            for disline in disgen.disgen(bp.code):
                if histogram:
                    opcode_counts[disline.opcode] += 1
                    continue
                if disline.first:
                    if srclines:
                        upto = upto or disline.lineno - 1
                        while upto <= disline.lineno - 1:
                            print("%100s%s" % ("", srclines[upto]))
                            upto += 1
                    elif disline.offset > 0:
                        print("")
                line = disgen.format_dis_line(disline)
                chunk = chunkd.get(disline.offset)
                if chunk:
                    chunkstr = ":: %r" % chunk
                else:
                    chunkstr = ""
                print("%-70s%s" % (line, chunkstr))

        print("")
Ejemplo n.º 4
0
    def disassemble(self, byte_parser, histogram=False):
        """Disassemble code, for ad-hoc experimenting."""

        for bp in byte_parser.child_parsers():
            if bp.text:
                srclines = bp.text.splitlines()
            else:
                srclines = None
            print("\n%s: " % bp.code)
            upto = None
            for disline in disgen.disgen(bp.code):
                if histogram:
                    opcode_counts[disline.opcode] += 1
                    continue
                if disline.first:
                    if srclines:
                        upto = upto or disline.lineno-1
                        while upto <= disline.lineno-1:
                            print("%100s%s" % ("", srclines[upto]))
                            upto += 1
                    elif disline.offset > 0:
                        print("")
                line = disgen.format_dis_line(disline)
                print("%-70s" % (line,))

        print("")
Ejemplo n.º 5
0
    def disassemble(self, byte_parser, histogram=False):
        """Disassemble code, for ad-hoc experimenting."""

        for bp in byte_parser.child_parsers():
            if bp.text:
                srclines = bp.text.splitlines()
            else:
                srclines = None
            print("\n%s: " % bp.code)
            upto = None
            for disline in disgen.disgen(bp.code):
                if histogram:
                    opcode_counts[disline.opcode] += 1
                    continue
                if disline.first:
                    if srclines:
                        upto = upto or disline.lineno - 1
                        while upto <= disline.lineno - 1:
                            print("%100s%s" % ("", srclines[upto]))
                            upto += 1
                    elif disline.offset > 0:
                        print("")
                line = disgen.format_dis_line(disline)
                print("%-70s" % (line, ))

        print("")