class NPGRT::Report
Constants
- MAX_MODULE_NAME_LEN
Public Class Methods
new(io, &b)
click to toggle source
# File lib/npgrt/report.rb, line 5 def initialize(io, &b) @io = io @binding = b.binding end
Public Instance Methods
basic(io)
click to toggle source
# File lib/npgrt/report.rb, line 40 def basic(io) form io, "Basic Information" do |io| io << "path:" << Dir.getwd << "\n" io << "Ruby Version:" << RUBY_VERSION << "\n" io << "NPGRT Version:" << NPGRT::VERSION << "\n" io << "Platform:" << NPGRT::PlatformWidth << "\n" begin str = "" << "FPS:" << Graphics.frame_rate.to_s << "\n" str << "Frame Count:" << Graphics.frame_count.to_s << "\n" io << str rescue end io << "Command Line:" << NPGRT.wstrread(NPGRT.api('kernel32', 'GetCommandLineW').call) << "\n" end end
exception(io)
click to toggle source
# File lib/npgrt/report.rb, line 69 def exception(io) form io, "Exceptions" do if $! io << $!.to_s << "\n" io << $!.backtrace.join("\n") << "\n" else io << "No exception." << "\n" end end end
inifile(io)
click to toggle source
# File lib/npgrt/report.rb, line 26 def inifile(io) return unless FileTest.file?("Game.ini") form io, "Game.ini" do |io| io << File.read("Game.ini") end end
minidump(io)
click to toggle source
# File lib/npgrt/report.rb, line 121 def minidump(io) x = NPGRT.api('Kernel32', 'CreateFileW').call( NPGRT.to_unicode("minidump.dmp\0\0")+"\0\0", 0x40000000, 0, 0, 2, 0x80, 0 ) NPGRT.api('DbgHelp.dll', 'MiniDumpWriteDump').call( NPGRT.api('kernel32', 'GetCurrentProcess').call, NPGRT.api('kernel32', 'GetCurrentProcessId').call, x, 0, 0, 0, 0 ) NPGRT.api('kernel32', 'CloseHandle').call x form io, "Core Dump" do io << "Dump file written to minidump.dmp.\n" end end
normal()
click to toggle source
# File lib/npgrt/report.rb, line 169 def normal basic(@io) inifile(@io) exception(@io) plugins(@io) sysmodules(@io) rubyobjects(@io) position(@io) scripts(@io) minidump(@io) end
plugins(io)
click to toggle source
# File lib/npgrt/report.rb, line 112 def plugins(io) form io, "LOADED_FEATURES" do io << $LOADED_FEATURES.join("\n") << "\n" end form io, "PATH" do io << ENV['PATH'] << "\n" end end
position(io)
click to toggle source
# File lib/npgrt/report.rb, line 57 def position(io) form io, "Position" do |io| io << "__FILE__:" << eval('__FILE__', @binding) << "\n" if eval('__FILE__', @binding) =~ /\d+/ && $RGSS_SCRIPTS io << "Section name :[" << $RGSS_SCRIPTS[$1.to_i][1] << "]\n" end io << "__LINE__:" <<eval('__LINE__', @binding) << "\n" io << "Nesting:" << eval('Module.nesting', @binding) << "\n" io << "caller:" << eval('caller', @binding).join("\n") << "\n" end end
rubyobjects(io)
click to toggle source
# File lib/npgrt/report.rb, line 80 def rubyobjects(io) form io, "Global Variables" do (global_variables - [:$RGSS_SCRIPTS]).each{|g| begin v = eval(g.to_s, @binding) io << (" #{g}:" << v.inspect << "\n") rescue end } io << " $RGSS_SCRIPTS: [#{$RGSS_SCRIPTS.size} scripts]" << "\n" if defined?($RGSS_SCRIPTS) end form io, "Local Variables" do eval('local_variables', @binding).each{|g| begin v = eval(g.to_s, @binding) io << (" #{g}:" << v.inspect << "\n") rescue end } end form io, "Modules" do ret = [] ObjectSpace.each_object(Module) do |m| ret << m end ret.sort_by{|x| x.to_s}.each do |m| io << " " << (m.is_a?(Class) ? "C " : "M ") << m << (m.is_a?(Class) ? "(class)" : "(module)") << ObjectSpace.each_object(m){} << "\n" end end end
scripts(io)
click to toggle source
# File lib/npgrt/report.rb, line 33 def scripts(io) return unless defined?($RGSS_SCRIPTS) form io, "Scripts" do |io| io << $RGSS_SCRIPTS.map{|x| " [%s] " % x[1]}.join("\n") end end
sysmodules(io)
click to toggle source
# File lib/npgrt/report.rb, line 142 def sysmodules(io) ph = NPGRT.api('kernel32', 'GetCurrentProcess').call num = [0].pack("L") NPGRT.api('psapi', 'EnumProcessModules').call ph, 0, 0, num num = num.unpack("L").first arr = [0].pack("L")*num lnum = [0].pack("L") NPGRT.api('psapi', 'EnumProcessModules').call ph, arr, num, lnum ret = [] lnum = lnum.unpack("L").first arr.unpack(NPGRT::PtrType + "*")[0, lnum].each{|ptr| break if ptr == 0 && !ret.empty? buf = [0].pack("S")*MAX_MODULE_NAME_LEN NPGRT.api('kernel32', 'GetModuleFileNameW').call ptr, buf, MAX_MODULE_NAME_LEN ret << NPGRT.wstrread(buf) } form io, "System Modules" do |io| ret.each{|x| io << " - " << x << "\n" } end end
Private Instance Methods
form(io, title) { |io| ... }
click to toggle source
# File lib/npgrt/report.rb, line 19 def form(io, title) io << title(title) yield io io << tail io end
tail()
click to toggle source
# File lib/npgrt/report.rb, line 15 def tail "\n\n\n" end
title(str)
click to toggle source
# File lib/npgrt/report.rb, line 11 def title(str) "#{str} ----------\n" end