[lldb] Add syntax color highlighting for disassembly

Add support for syntax color highlighting disassembly in LLDB. This
patch relies on 77d1032516, which introduces support for syntax
highlighting in MC.

Currently only AArch64 and X86 have color support, but other interested
backends can adopt WithColor in their respective MCInstPrinter.

Differential revision: https://reviews.llvm.org/D159164
This commit is contained in:
Jonas Devlieghere
2023-09-01 14:20:08 -07:00
parent a168135487
commit a69f78b080
5 changed files with 91 additions and 7 deletions

View File

@@ -59,9 +59,19 @@ class DisassembleRawDataTestCase(TestBase):
elif arch in ("aarch64", "arm64"):
self.assertEqual(inst.GetMnemonic(target), "mov")
self.assertEqual(inst.GetOperands(target), "w0, #0x63")
self.assertEqual(inst.GetComment(target), "=99 ")
self.assertEqual(
inst.GetControlFlowKind(target), lldb.eInstructionControlFlowKindUnknown
)
# Make sure that using colors doesn't affect the output here.
res = lldb.SBCommandReturnObject()
ci = self.dbg.GetCommandInterpreter()
ci.HandleCommand("settings set use-color true", res)
self.assertEqual(inst.GetOperands(target), "w0, #0x63")
self.assertEqual(inst.GetMnemonic(target), "mov")
self.assertEqual(inst.GetComment(target), "=99 ")
ci.HandleCommand("settings set use-color false", res)
elif arch == "arm":
self.assertEqual(inst.GetMnemonic(target), "mov")
self.assertEqual(inst.GetOperands(target), "r3, #99")