<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import capstone
import pwndbg.chain
import pwndbg.color
import pwndbg.disasm.jump

capstone_branch_groups = set((
capstone.CS_GRP_CALL,
capstone.CS_GRP_JUMP
))

def instruction(ins):
    asm = u'%-06s %s' % (ins.mnemonic, ins.op_str)

    branch = set(ins.groups) & capstone_branch_groups

    if branch:
        asm = pwndbg.color.bold(asm)


    if ins.condition:
        asm = pwndbg.color.green(u'✔ ') + asm
    else:
        asm = '  ' + asm

    if ins.target not in (None, ins.address + ins.size):
        sym    = pwndbg.symbol.get(ins.target)
        target = pwndbg.color.get(ins.target)
        const  = ins.target_constant

        # If it's a constant expression, color it directly in the asm.
        if const:
            asm = asm.replace(hex(ins.target), target)

            if sym:
                asm = '%-36s <%s>' % (asm, sym)
        elif sym:
            asm = '%-36s <%s; %s>' % (asm, target, sym)
        else:
            asm = '%-36s <%s>' % (asm, target)

    elif ins.symbol:
        if branch and not ins.target:
            asm = '%s <%s>' % (asm, ins.symbol)
        else:
            asm = '%-50s # %s <%s>' % (asm, pwndbg.color.get(ins.symbol_addr), ins.symbol)

    return asm<commit_msg>Enhancements to readability of disassembly output<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import capstone
import pwndbg.chain
import pwndbg.color
import pwndbg.disasm.jump

capstone_branch_groups = set((
capstone.CS_GRP_CALL,
capstone.CS_GRP_JUMP
))

def instruction(ins):
    asm = u'%-06s %s' % (ins.mnemonic, ins.op_str)

    branch = set(ins.groups) & capstone_branch_groups

    asm = asm.ljust(36)

    if branch:
        asm = pwndbg.color.bold(asm)


    if ins.condition:
        asm = pwndbg.color.green(u'✔ ') + asm
    else:
        asm = '  ' + asm

    if ins.target not in (None, ins.address + ins.size):
        sym    = pwndbg.symbol.get(ins.target) or None
        target = pwndbg.color.get(ins.target)
        const  = ins.target_const
        hextarget = hex(ins.target)
        hexlen    = len(hextarget)

        # If it's a constant expression, color it directly in the asm.
        if const:
            if sym:
                asm = asm.replace(hextarget, sym.ljust(hexlen))
                asm += '<%s>' % (target)
            else:
                targ_col_len = target.ljust(hexlen)
                targ_col_len = pwndbg.color.get(ins.target, targ_col_len)
                asm = asm.replace(hextarget, targ_col_len)
                asm += '<%s>' % (sym)
        elif sym:
            asm += '<%s; %s>' % (target, sym)
        else:
            asm += '<%s>' % (target)

    elif ins.symbol:
        if branch and not ins.target:
            asm += '<%s>' % (ins.symbol)
        else:
            asm += '<%s>' % (pwndbg.color.get(ins.symbol_addr, ins.symbol or None))

    return asm
{'fraction_non_alphanumeric': 0.13687821612349915, 'fraction_numerical': 0.005488850771869639, 'mean_word_length': 1.9877049180327868, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7520626', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1010, 'n_words': 237}