Skip to content

Commit

Permalink
fix on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Nov 24, 2021
1 parent 9684cc1 commit 7465458
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/asmrepl/macos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def self.jitbuffer size
Fisk::Helpers::JITBuffer.new mmap_jit(size), size
end

def self.traceme
raise unless ptrace(PT_TRACE_ME, 0, 0, 0).zero?
end

class ThreadState
fields = (<<-eostruct).scan(/uint64_t ([^;]*);/).flatten
struct x86_thread_state64_t {
Expand Down
15 changes: 11 additions & 4 deletions lib/asmrepl/repl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
require "fisk/helpers"
require "crabstone"
require "reline"
#require "asmrepl/macos"
require "asmrepl/linux"

if RUBY_PLATFORM =~ /darwin/
require "asmrepl/macos"
else
require "asmrepl/linux"
end

class Crabstone::Binding::Instruction
class << self
Expand All @@ -20,8 +24,11 @@ module ASMREPL
class REPL
include Fiddle

#CFuncs = MacOS
CFuncs = Linux
if RUBY_PLATFORM =~ /darwin/
CFuncs = MacOS
else
CFuncs = Linux
end

def initialize
size = 1024 * 16 # 16k is enough for anyone!
Expand Down

0 comments on commit 7465458

Please sign in to comment.