-
Notifications
You must be signed in to change notification settings - Fork 44
High-level disassembly API #522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/src/disasm.jl b/src/disasm.jl
index fc8f3e98..8cf26bfa 100644
--- a/src/disasm.jl
+++ b/src/disasm.jl
@@ -13,7 +13,7 @@ function dispose(ctx::DisasmContext)
return nothing
end
-function disassemble_code(io, ctx::DisasmContext, native_code::Vector{UInt8}, code_addr::Csize_t = 0; bufsize=32)
+function disassemble_code(io, ctx::DisasmContext, native_code::Vector{UInt8}, code_addr::Csize_t = 0; bufsize = 32)
pos = 1
buf = Vector{UInt8}(undef, bufsize)
@@ -37,4 +37,4 @@ function disassemble_code(io, ctx::DisasmContext, native_code::Vector{UInt8}, co
write(io, '\n')
end
return nothing
-end
\ No newline at end of file
+end
diff --git a/test/disasm.jl b/test/disasm.jl
index 679358cc..8e30d500 100644
--- a/test/disasm.jl
+++ b/test/disasm.jl
@@ -10,4 +10,4 @@ import LLVM: create_disasm, disassemble_code
LLVM.dispose(ctx)
@test disassembled == "\tpushq\t%rbp\n\tmovq\t%rsp, %rbp\n\tmovq\t16(%r13), %rax\n\tmovq\t16(%rax), %rax\n\tmovq\t(%rax), %rax\n\tmovq\t(%rsi), %rdx\n\taddq\t\$8, %rsi\n\tmovabsq\t\$140619409620192, %rax\n\tcallq\t*%rax\n\tpopq\t%rbp\n"
-end
\ No newline at end of file
+end
diff --git a/test/runtests.jl b/test/runtests.jl
index 81ead7d5..6c2e7dd6 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -41,7 +41,7 @@ include("debuginfo.jl")
include("util.jl")
include("interop.jl")
include("orc.jl")
-include("disasm.jl")
+ include("disasm.jl")
if !Sys.iswindows()
# XXX: hangs on Windows
include("jljit.jl") |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## master #522 +/- ##
==========================================
+ Coverage 87.91% 87.98% +0.07%
==========================================
Files 45 46 +1
Lines 2705 2731 +26
==========================================
+ Hits 2378 2403 +25
- Misses 327 328 +1
🚀 New features to boost your workflow:
|
@testset "X86 Disassembly" begin | ||
# Example from jitdump | ||
native_code = UInt8[0x55, 0x48, 0x89, 0xe5, 0x49, 0x8b, 0x45, 0x10, 0x48, 0x8b, 0x40, 0x10, 0x48, 0x8b, 0x00, 0x48, 0x8b, 0x16, 0x48, 0x83, 0xc6, 0x08, 0x48, 0xb8, 0xe0, 0x7c, 0xf5, 0x81, 0xe4, 0x7f, 0x00, 0x00, 0xff, 0xd0, 0x5d, 0xc3] | ||
code_addr = 0x00007fe48befcde0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a comment explaining the PC
function create_disasm(triple) | ||
ctx = DisasmContext(API.LLVMCreateDisasm(triple, C_NULL, 0, C_NULL, C_NULL)) | ||
return ctx | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is my OOP kicking in, but why not tie this to a DisasmContext
constructor like we do for other objects-like things (Context, IRBuilder, etc)?
return nothing | ||
end | ||
|
||
function disassemble_code(io, ctx::DisasmContext, native_code::Vector{UInt8}, code_addr::Csize_t = 0; bufsize=32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about simply disassemble
? A do-block version could be provided that does the context construction for you.
cc: @gbaraldi