Skip to content

Commit

Permalink
Remove unused code (it's also insecure: creates predictable tmp files)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Knoppel (Phusion) committed Nov 14, 2016
1 parent 65db273 commit 79f6d0b
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions lib/crash_watch/gdb_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ def attach(pid)
result !~ /(No such process|Unable to access task|Operation not permitted)/
end

def call(code)
result = execute("call #{code}")
result =~ /= (.*)$/
$1
end

def program_counter
execute("p/x $pc").gsub(/.* = /, '')
end
Expand All @@ -147,38 +141,6 @@ def all_threads_backtraces
execute("thread apply all bt full").strip
end

def ruby_backtrace
filename = "/tmp/gdb-capture.#{@pid}.txt"

orig_stdout_fd_copy = call("(int) dup(1)")
new_stdout = call(%Q{(void *) fopen("#{filename}", "w")})
new_stdout_fd = call("(int) fileno(#{new_stdout})")
call("(int) dup2(#{new_stdout_fd}, 1)")

# Let's hope stdout is set to line buffered or unbuffered mode...
call("(void) rb_backtrace()")

call("(int) dup2(#{orig_stdout_fd_copy}, 1)")
call("(int) fclose(#{new_stdout})")
call("(int) close(#{orig_stdout_fd_copy})")

if File.exist?(filename)
result = File.read(filename)
result.strip!
if result.empty?
nil
else
result
end
else
nil
end
ensure
if filename
File.unlink(filename) rescue nil
end
end

def wait_until_exit
execute("break _exit")

Expand Down

0 comments on commit 79f6d0b

Please sign in to comment.