Skip to content

Conversation

vchuravy
Copy link
Collaborator

@vchuravy vchuravy commented Aug 26, 2025

cc: @gbaraldi

Copy link
Contributor

github-actions bot commented Aug 26, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

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-commenter
Copy link

codecov-commenter commented Aug 26, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/disasm.jl 96.15% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
@@            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     
Files with missing lines Coverage Δ
src/LLVM.jl 76.92% <ø> (ø)
src/disasm.jl 96.15% <96.15%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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
Copy link
Contributor

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

Comment on lines +6 to +9
function create_disasm(triple)
ctx = DisasmContext(API.LLVMCreateDisasm(triple, C_NULL, 0, C_NULL, C_NULL))
return ctx
end
Copy link
Collaborator

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)
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants