YJIT: Colorize outlined code differently on --yjit-dump-disasm (#7073)

* YJIT: Colorize outlined code differently

on --yjit-dump-disasm

* YJIT: Reduce the number of escape sequences
This commit is contained in:
Takashi Kokubun 2023-01-06 11:49:45 -08:00 committed by GitHub
parent 66bc620963
commit 311ce91733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2023-01-06 19:50:08 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>

View File

@ -173,15 +173,23 @@ pub fn disasm_addr_range(cb: &CodeBlock, start_addr: usize, end_addr: usize) ->
let code_slice = unsafe { std::slice::from_raw_parts(start_addr as _, code_size) };
let insns = cs.disasm_all(code_slice, start_addr as u64).unwrap();
// Colorize outlined code in blue
if cb.outlined {
write!(&mut out, "\x1b[34m").unwrap();
}
// For each instruction in this block
for insn in insns.as_ref() {
// Comments for this block
if let Some(comment_list) = cb.comments_at(insn.address() as usize) {
for comment in comment_list {
writeln!(&mut out, " \x1b[1m# {}\x1b[0m", comment).unwrap();
writeln!(&mut out, " \x1b[1m# {comment}\x1b[22m").unwrap(); // Make comments bold
}
}
writeln!(&mut out, " {}", insn).unwrap();
writeln!(&mut out, " {insn}").unwrap();
}
// Disable blue color
if cb.outlined {
write!(&mut out, "\x1b[0m").unwrap();
}
return out;