forked from OSchip/llvm-project
[lldb-vscode ]Add Syntax Highlighting to Disassembly View
When lldb cannot find source file thus IDE renders a disassembly view, add syntax highlighting for constants, registers and final line comments for better debugging experience. The original plain disassembly view looks like: {F12401687} An ideal view is like the screenshot attached. {F12401515} In this diff, the mimeType is a kind of media type for formatting the content in the response to a source request. Elements in the disassembly view, like constants, registers and final line comments are colored for highlighting. A built-in support in the VSCode IDE for syntax highlighting will identify the which mimeType to apply and render the disassembly view as expected. Reviewed By: wallace, clayborg Differential Revision: https://reviews.llvm.org/D84555
This commit is contained in:
parent
95efea4b93
commit
e7af98680a
|
@ -2188,6 +2188,7 @@ void request_source(const llvm::json::Object &request) {
|
|||
} else {
|
||||
response["success"] = llvm::json::Value(false);
|
||||
}
|
||||
EmplaceSafeString(body, "mimeType", "text/x-lldb.disassembly");
|
||||
response.try_emplace("body", std::move(body));
|
||||
g_vsc.SendJSON(llvm::json::Value(std::move(response)));
|
||||
}
|
||||
|
|
|
@ -32,6 +32,24 @@
|
|||
"vsce": "^1.36.3"
|
||||
},
|
||||
"contributes": {
|
||||
"languages": [
|
||||
{
|
||||
"id": "lldb.disassembly",
|
||||
"aliases": [
|
||||
"Disassembly"
|
||||
],
|
||||
"extensions": [
|
||||
".disasm"
|
||||
]
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
{
|
||||
"language": "lldb.disassembly",
|
||||
"scopeName": "source.disassembly",
|
||||
"path": "./syntaxes/disassembly.json"
|
||||
}
|
||||
],
|
||||
"debuggers": [
|
||||
{
|
||||
"type": "lldb-vscode",
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
(lldb)
|
||||
libIGL.so`igl::RenderPipelineDesc::TargetDesc::ColorAttachment::operator==:
|
||||
libIGL.so[0x7694] <+0>: ldr r2, [r1]
|
||||
libIGL.so[0x7696] <+2>: ldr r3, [r0]
|
||||
libIGL.so[0x7698] <+4>: cmp r3, r2
|
||||
libIGL.so[0x769a] <+6>: bne 0x76da ; <+70> at RenderPipelineState.cpp
|
||||
libIGL.so[0x769c] <+8>: ldrb r2, [r1, #0x5]
|
||||
libIGL.so[0x769e] <+10>: ldrb r3, [r0, #0x5]
|
||||
libIGL.so[0x76a0] <+12>: cmp r3, r2
|
||||
libIGL.so[0x76a2] <+14>: bne 0x76da ; <+70> at RenderPipelineState.cpp
|
||||
libIGL.so[0x76a4] <+16>: ldr r2, [r1, #0x8]
|
||||
libIGL.so[0x76a6] <+18>: ldr r3, [r0, #0x8]
|
||||
libIGL.so[0x76a8] <+20>: cmp r3, r2
|
||||
libIGL.so[0x76aa] <+22>: bne 0x76da ; <+70> at RenderPipelineState.cpp
|
||||
libIGL.so[0x76ac] <+24>: ldr r2, [r1, #0xc]
|
||||
libIGL.so[0x76ae] <+26>: ldr r3, [r0, #0xc]
|
||||
libIGL.so[0x76b0] <+28>: cmp r3, r2
|
||||
libIGL.so[0x76b2] <+30>: bne 0x76da ; <+70> at RenderPipelineState.cpp
|
||||
libIGL.so[0x76b4] <+32>: ldr r2, [r1, #0x10]
|
||||
libIGL.so[0x76b6] <+34>: ldr r3, [r0, #0x10]
|
||||
libIGL.so[0x76b8] <+36>: cmp r3, r2
|
||||
libIGL.so[0x76ba] <+38>: bne 0x76da ; <+70> at RenderPipelineState.cpp
|
||||
libIGL.so[0x76bc] <+40>: ldr r2, [r1, #0x14]
|
||||
libIGL.so[0x76be] <+42>: ldr r3, [r0, #0x14]
|
||||
libIGL.so[0x76c0] <+44>: cmp r3, r2
|
||||
libIGL.so[0x76c2] <+46>: bne 0x76da ; <+70> at RenderPipelineState.cpp
|
||||
libIGL.so[0x76c4] <+48>: ldr r2, [r1, #0x18]
|
||||
libIGL.so[0x76c6] <+50>: ldr r3, [r0, #0x18]
|
||||
libIGL.so[0x76c8] <+52>: cmp r3, r2
|
||||
libIGL.so[0x76ca] <+54>: bne 0x76da ; <+70> at RenderPipelineState.cpp
|
||||
libIGL.so[0x76cc] <+56>: ldr r1, [r1, #0x1c]
|
||||
libIGL.so[0x76ce] <+58>: ldr r0, [r0, #0x1c]
|
||||
libIGL.so[0x76d0] <+60>: subs r0, r0, r1
|
||||
libIGL.so[0x76d2] <+62>: clz r0, r0
|
||||
libIGL.so[0x76d6] <+66>: lsrs r0, r0, #0x5
|
||||
libIGL.so[0x76d8] <+68>: bx lr
|
||||
libIGL.so[0x76da] <+70>: movs r0, #0x0
|
||||
libIGL.so[0x76dc] <+72>: bx lr
|
||||
(lldb) disassemble --name _ZN3igl20VertexInputStateDesc28sizeForVertexAttributeFormatENS_21VertexAttributeFormatE
|
||||
libIGL.so`igl::VertexInputStateDesc::sizeForVertexAttributeFormat:
|
||||
libIGL.so[0x787c] <+0>: ldr r1, [pc, #0x8] ; <+12> at VertexInputState.cpp
|
||||
libIGL.so[0x787e] <+2>: add r1, pc
|
||||
libIGL.so[0x7880] <+4>: ldr.w r0, [r1, r0, lsl #2]
|
||||
libIGL.so[0x7884] <+8>: bx lr
|
||||
libIGL.so[0x7886] <+10>: nop
|
|
@ -0,0 +1,91 @@
|
|||
(lldb) disassemble --name __android_log_config_read
|
||||
liblog.so`::__android_log_config_read():
|
||||
liblog.so[0x6014] <+0>: stp x22, x21, [sp, #-0x30]!
|
||||
liblog.so[0x6018] <+4>: stp x20, x19, [sp, #0x10]
|
||||
liblog.so[0x601c] <+8>: stp x29, x30, [sp, #0x20]
|
||||
liblog.so[0x6020] <+12>: add x29, sp, #0x20 ; =0x20
|
||||
liblog.so[0x6024] <+16>: adrp x8, 15
|
||||
liblog.so[0x6028] <+20>: ldr x8, [x8, #0x230]
|
||||
liblog.so[0x602c] <+24>: ldr w8, [x8]
|
||||
liblog.so[0x6030] <+28>: cbz w8, 0x6038 ; <+36> at config_read.cpp
|
||||
liblog.so[0x6034] <+32>: tbz w8, #0x0, 0x6168 ; <+340> at config_read.cpp:65:1
|
||||
liblog.so[0x6038] <+36>: adrp x20, 15
|
||||
liblog.so[0x603c] <+40>: adrp x21, 15
|
||||
liblog.so[0x6040] <+44>: ldr x20, [x20, #0x238]
|
||||
liblog.so[0x6044] <+48>: ldr x21, [x21, #0x240]
|
||||
liblog.so[0x6048] <+52>: mov w19, wzr
|
||||
liblog.so[0x604c] <+56>: ldr x22, [x20]
|
||||
liblog.so[0x6050] <+60>: cmp x22, x20
|
||||
liblog.so[0x6054] <+64>: b.eq 0x609c ; <+136> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 80 at config_read.cpp:61
|
||||
liblog.so[0x6058] <+68>: ldr x8, [x22]
|
||||
liblog.so[0x605c] <+72>: cmp x22, x8
|
||||
liblog.so[0x6060] <+76>: b.eq 0x60b0 ; <+156> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 100 at config_read.cpp:61
|
||||
liblog.so[0x6064] <+80>: ldr x8, [x22, #0x18]
|
||||
liblog.so[0x6068] <+84>: cbz x8, 0x60d0 ; <+188> at config_read.cpp
|
||||
liblog.so[0x606c] <+88>: mov w0, w19
|
||||
liblog.so[0x6070] <+92>: blr x8
|
||||
liblog.so[0x6074] <+96>: tbz w0, #0x1f, 0x608c ; <+120> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 64 at config_read.cpp:61
|
||||
liblog.so[0x6078] <+100>: ldr x8, [x21, #0x18]
|
||||
liblog.so[0x607c] <+104>: cbz x8, 0x60c0 ; <+172> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 116 at config_read.cpp:61
|
||||
liblog.so[0x6080] <+108>: mov w0, w19
|
||||
liblog.so[0x6084] <+112>: blr x8
|
||||
liblog.so[0x6088] <+116>: tbz w0, #0x1f, 0x60c0 ; <+172> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 116 at config_read.cpp:61
|
||||
liblog.so[0x608c] <+120>: ldr x22, [x22]
|
||||
liblog.so[0x6090] <+124>: cmp x22, x20
|
||||
liblog.so[0x6094] <+128>: b.ne 0x6058 ; <+68> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 12 at config_read.cpp:61
|
||||
liblog.so[0x6098] <+132>: b 0x60b0 ; <+156> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 100 at config_read.cpp:61
|
||||
liblog.so[0x609c] <+136>: ldr x8, [x21, #0x18]
|
||||
liblog.so[0x60a0] <+140>: cbz x8, 0x60c0 ; <+172> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 116 at config_read.cpp:61
|
||||
liblog.so[0x60a4] <+144>: mov w0, w19
|
||||
liblog.so[0x60a8] <+148>: blr x8
|
||||
liblog.so[0x60ac] <+152>: tbz w0, #0x1f, 0x60c0 ; <+172> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 116 at config_read.cpp:61
|
||||
liblog.so[0x60b0] <+156>: add w19, w19, #0x1 ; =0x1
|
||||
liblog.so[0x60b4] <+160>: cmp w19, #0x8 ; =0x8
|
||||
liblog.so[0x60b8] <+164>: b.lo 0x604c ; <+56> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) at config_read.cpp:61
|
||||
liblog.so[0x60bc] <+168>: b 0x60d0 ; <+188> at config_read.cpp
|
||||
liblog.so[0x60c0] <+172>: ldr x8, [x20, #0x8]
|
||||
liblog.so[0x60c4] <+176>: stp x20, x8, [x21]
|
||||
liblog.so[0x60c8] <+180>: str x21, [x8]
|
||||
liblog.so[0x60cc] <+184>: str x21, [x20, #0x8]
|
||||
liblog.so[0x60d0] <+188>: adrp x20, 15
|
||||
liblog.so[0x60d4] <+192>: adrp x21, 15
|
||||
liblog.so[0x60d8] <+196>: ldr x20, [x20, #0x248]
|
||||
liblog.so[0x60dc] <+200>: ldr x21, [x21, #0x250]
|
||||
liblog.so[0x60e0] <+204>: mov w19, wzr
|
||||
liblog.so[0x60e4] <+208>: ldr x22, [x20]
|
||||
liblog.so[0x60e8] <+212>: cmp x22, x20
|
||||
liblog.so[0x60ec] <+216>: b.eq 0x6134 ; <+288> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 80 at config_read.cpp:62
|
||||
liblog.so[0x60f0] <+220>: ldr x8, [x22]
|
||||
liblog.so[0x60f4] <+224>: cmp x22, x8
|
||||
liblog.so[0x60f8] <+228>: b.eq 0x6148 ; <+308> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 100 at config_read.cpp:62
|
||||
liblog.so[0x60fc] <+232>: ldr x8, [x22, #0x18]
|
||||
liblog.so[0x6100] <+236>: cbz x8, 0x6168 ; <+340> at config_read.cpp:65:1
|
||||
liblog.so[0x6104] <+240>: mov w0, w19
|
||||
liblog.so[0x6108] <+244>: blr x8
|
||||
liblog.so[0x610c] <+248>: tbz w0, #0x1f, 0x6124 ; <+272> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 64 at config_read.cpp:62
|
||||
liblog.so[0x6110] <+252>: ldr x8, [x21, #0x18]
|
||||
liblog.so[0x6114] <+256>: cbz x8, 0x6158 ; <+324> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 116 at config_read.cpp:62
|
||||
liblog.so[0x6118] <+260>: mov w0, w19
|
||||
liblog.so[0x611c] <+264>: blr x8
|
||||
liblog.so[0x6120] <+268>: tbz w0, #0x1f, 0x6158 ; <+324> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 116 at config_read.cpp:62
|
||||
liblog.so[0x6124] <+272>: ldr x22, [x22]
|
||||
liblog.so[0x6128] <+276>: cmp x22, x20
|
||||
liblog.so[0x612c] <+280>: b.ne 0x60f0 ; <+220> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 12 at config_read.cpp:62
|
||||
liblog.so[0x6130] <+284>: b 0x6148 ; <+308> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 100 at config_read.cpp:62
|
||||
liblog.so[0x6134] <+288>: ldr x8, [x21, #0x18]
|
||||
liblog.so[0x6138] <+292>: cbz x8, 0x6158 ; <+324> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 116 at config_read.cpp:62
|
||||
liblog.so[0x613c] <+296>: mov w0, w19
|
||||
liblog.so[0x6140] <+300>: blr x8
|
||||
liblog.so[0x6144] <+304>: tbz w0, #0x1f, 0x6158 ; <+324> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) + 116 at config_read.cpp:62
|
||||
liblog.so[0x6148] <+308>: add w19, w19, #0x1 ; =0x1
|
||||
liblog.so[0x614c] <+312>: cmp w19, #0x8 ; =0x8
|
||||
liblog.so[0x6150] <+316>: b.lo 0x60e4 ; <+208> [inlined] __android_log_add_transport(listnode*, android_log_transport_read*) at config_read.cpp:62
|
||||
liblog.so[0x6154] <+320>: b 0x6168 ; <+340> at config_read.cpp:65:1
|
||||
liblog.so[0x6158] <+324>: ldr x8, [x20, #0x8]
|
||||
liblog.so[0x615c] <+328>: stp x20, x8, [x21]
|
||||
liblog.so[0x6160] <+332>: str x21, [x8]
|
||||
liblog.so[0x6164] <+336>: str x21, [x20, #0x8]
|
||||
liblog.so[0x6168] <+340>: ldp x29, x30, [sp, #0x20]
|
||||
liblog.so[0x616c] <+344>: ldp x20, x19, [sp, #0x10]
|
||||
liblog.so[0x6170] <+348>: ldp x22, x21, [sp], #0x30
|
||||
liblog.so[0x6174] <+352>: ret
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"name": "Disassembly",
|
||||
"scopeName": "source.disassembly",
|
||||
"uuid": "9ade615f-5d82-4ac5-b22f-a1998c356ebe",
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "x86 Address, bytes and opcode",
|
||||
"name": "meta.instruction",
|
||||
"match": "^([A-Za-z0-9]+):\\s([A-Z0-9]{2}\\s)+>?\\s+(\\w+)",
|
||||
"captures": {
|
||||
"1": {"name": "constant.numeric"},
|
||||
"3": {"name": "keyword.opcode"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": "ARM Address, bytes and opcode",
|
||||
"name": "meta.instruction",
|
||||
"match": "^libIGL.so\\[([A-Za-z0-9]+)\\]\\s+(\\<\\+[0-9]*\\>):\\s+([A-Za-z]+.?[A-Za-z]*)",
|
||||
"captures": {
|
||||
"1": {"name": "constant.numeric"},
|
||||
"3": {"name": "keyword.opcode"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": "ARM64 Address, bytes and opcode",
|
||||
"name": "meta.instruction",
|
||||
"match": "^liblog.so\\[([A-Za-z0-9]+)\\]\\s+(\\<\\+[0-9]*\\>):\\s+([A-Za-z]+.?[A-Za-z]*)",
|
||||
"captures": {
|
||||
"1": {"name": "constant.numeric"},
|
||||
"3": {"name": "keyword.opcode"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": "Numeric constant",
|
||||
"name": "constant.numeric",
|
||||
"match": "(\\$|\\b)((0x)|[0-9])[A-Za-z0-9]+\\b"
|
||||
},
|
||||
{
|
||||
"comment": "x86 Register",
|
||||
"name": "variable.language",
|
||||
"match": "%[A-Za-z][A-Za-z0-9]*"
|
||||
},
|
||||
{
|
||||
"comment": "ARM Register",
|
||||
"name": "variable.language",
|
||||
"match": "r\\d+"
|
||||
},
|
||||
{
|
||||
"comment": "ARM Register Shortnames",
|
||||
"name": "variable.language",
|
||||
"match": "(fp|sp|lr|pc|wzr|xzr)"
|
||||
},
|
||||
{
|
||||
"comment": "ARM64 Register",
|
||||
"name": "variable.language",
|
||||
"match": "(x|w)[0-9]+"
|
||||
},
|
||||
{
|
||||
"comment": "End of line comment",
|
||||
"name": "comment.line.semicolon",
|
||||
"match": ";.*$"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
0x100008000: <0> popq %rdi
|
||||
0x100008001: <1> pushq $0x0
|
||||
0x100008003: <3> movq %rsp, %rbp
|
||||
0x100008006: <6> andq $-0x10, %rsp
|
||||
0x10000800A: <10> subq $0x10, %rsp
|
||||
0x10000800E: <14> movl 0x8(%rbp), %esi
|
||||
0x100008011: <17> leaq 0x10(%rbp), %rdx
|
||||
0x100008015: <21> leaq -0x101c(%rip), %rcx
|
||||
0x10000801C: <28> leaq -0x8(%rbp), %r8
|
||||
0x100008020: <32> callq 0x100008062 # dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*)
|
||||
0x100008025: <37> movq -0x8(%rbp), %rdi
|
||||
0x100008029: <41> cmpq $0x0, %rdi
|
||||
0x10000802D: <45> jne 0x10000803f # <+63>
|
||||
0x10000802F: <47> movq %rbp, %rsp
|
||||
0x100008032: <50> addq $0x8, %rsp
|
||||
0x100008036: <54> movq $0x0, %rbp
|
||||
0x10000803D: <61> jmpq *%rax
|
||||
0x10000803F: <63> addq $0x10, %rsp
|
||||
0x100008043: <67> pushq %rdi
|
||||
0x100008044: <68> movq 0x8(%rbp), %rdi
|
||||
0x100008048: <72> leaq 0x10(%rbp), %rsi
|
||||
0x10000804C: <76> leaq 0x8(%rsi,%rdi,8), %rdx
|
||||
0x100008051: <81> movq %rdx, %rcx
|
||||
0x100008054: <84> movq (%rcx), %r8
|
||||
0x100008057: <87> addq $0x8, %rcx
|
||||
0x10000805B: <91> testq %r8, %r8
|
||||
0x10000805E: <94> jne 0x100008054 # <+84>
|
||||
0x100008060: <96> jmpq *%rax
|
Loading…
Reference in New Issue