syntax: highlight code for chain format during enhance (#400)

pull/403/head
Levente Polyak 8 years ago committed by Disconnect3d
parent a2cf4e4225
commit d043720272

@ -33,7 +33,7 @@ def check_style():
style.value = style.default style.value = style.default
def syntax_highlight(code, filename): def syntax_highlight(code, filename='.asm'):
# No syntax highlight if pygment is not installed # No syntax highlight if pygment is not installed
if not pygments: if not pygments:
return code return code

@ -20,12 +20,14 @@ import gdb
import pwndbg.arch import pwndbg.arch
import pwndbg.color as color import pwndbg.color as color
import pwndbg.color.enhance as E import pwndbg.color.enhance as E
import pwndbg.config
import pwndbg.disasm import pwndbg.disasm
import pwndbg.memoize import pwndbg.memoize
import pwndbg.memory import pwndbg.memory
import pwndbg.strings import pwndbg.strings
import pwndbg.symbol import pwndbg.symbol
import pwndbg.typeinfo import pwndbg.typeinfo
from pwndbg.color.syntax_highlight import syntax_highlight
bad_instrs = [ bad_instrs = [
'.byte', '.byte',
@ -100,6 +102,8 @@ def enhance(value, code = True):
instr = pwndbg.disasm.one(value) instr = pwndbg.disasm.one(value)
if instr: if instr:
instr = "%-6s %s" % (instr.mnemonic, instr.op_str) instr = "%-6s %s" % (instr.mnemonic, instr.op_str)
if pwndbg.config.syntax_highlight:
instr = syntax_highlight(instr)
szval = pwndbg.strings.get(value) or None szval = pwndbg.strings.get(value) or None
szval0 = szval szval0 = szval

Loading…
Cancel
Save