Class DEBUGGER__
In: debug.rb
Parent: Object

Classes and Modules

Class DEBUGGER__::Context
Class DEBUGGER__::Mutex

Constants

MUTEX = Mutex.new

Public Class methods

[Source]

     # File debug.rb, line 779
779:   def break_points
780:     @break_points
781:   end

[Source]

     # File debug.rb, line 832
832:   def context(thread=Thread.current)
833:     c = thread[:__debugger_data__]
834:     unless c
835:       thread[:__debugger_data__] = c = Context.new
836:     end
837:     c
838:   end

[Source]

     # File debug.rb, line 888
888:   def debug_thread_info(input, binding)
889:     case input
890:     when /^l(?:ist)?/
891:       make_thread_list
892:       thread_list_all
893: 
894:     when /^c(?:ur(?:rent)?)?$/
895:       make_thread_list
896:       thread_list(@thread_list[Thread.current])
897: 
898:     when /^(?:sw(?:itch)?\s+)?(\d+)/
899:       make_thread_list
900:       th = get_thread($1.to_i)
901:       if th == Thread.current
902:         @stdout.print "It's the current thread.\n"
903:       else
904:         thread_list(@thread_list[th])
905:         context(th).stop_next
906:         th.run
907:         return :cont
908:       end
909: 
910:     when /^stop\s+(\d+)/
911:       make_thread_list
912:       th = get_thread($1.to_i)
913:       if th == Thread.current
914:         @stdout.print "It's the current thread.\n"
915:       elsif th.stop?
916:         @stdout.print "Already stopped.\n"
917:       else
918:         thread_list(@thread_list[th])
919:         context(th).suspend 
920:       end
921: 
922:     when /^resume\s+(\d+)/
923:       make_thread_list
924:       th = get_thread($1.to_i)
925:       if th == Thread.current
926:         @stdout.print "It's the current thread.\n"
927:       elsif !th.stop?
928:         @stdout.print "Already running."
929:       else
930:         thread_list(@thread_list[th])
931:         th.run
932:       end
933:     end
934:   end

[Source]

     # File debug.rb, line 775
775:   def display
776:     @display
777:   end

[Source]

     # File debug.rb, line 844
844:   def get_thread(num)
845:     th = @thread_list.index(num)
846:     unless th
847:       @stdout.print "No thread ##{num}\n"
848:       throw :debug_error
849:     end
850:     th
851:   end

[Source]

     # File debug.rb, line 840
840:   def interrupt
841:     context(@last_thread).stop_next
842:   end

[Source]

     # File debug.rb, line 875
875:   def make_thread_list
876:     hash = {}
877:     for th in Thread::list
878:       if @thread_list.key? th
879:         hash[th] = @thread_list[th]
880:       else
881:         @max_thread += 1
882:         hash[th] = @max_thread
883:       end
884:     end
885:     @thread_list = hash
886:   end

[Source]

     # File debug.rb, line 815
815:   def resume
816:     saved_crit = Thread.critical
817:     Thread.critical = true
818:     make_thread_list
819:     for th, in @thread_list
820:       next if th == Thread.current
821:       context(th).clear_suspend
822:     end
823:     waiting.each do |th|
824:       th.run
825:     end
826:     waiting.clear
827:     Thread.critical = saved_crit
828:     # Schedule other threads to restart as soon as possible.
829:     Thread.pass
830:   end

[Source]

     # File debug.rb, line 798
798:   def set_last_thread(th)
799:     @last_thread = th
800:   end

[Source]

     # File debug.rb, line 787
787:   def set_trace( arg )
788:     saved_crit = Thread.critical
789:     Thread.critical = true
790:     make_thread_list
791:     for th, in @thread_list
792:       context(th).set_trace arg
793:     end
794:     Thread.critical = saved_crit
795:     arg
796:   end

[Source]

     # File debug.rb, line 767
767:   def stdout
768:     @stdout
769:   end

[Source]

     # File debug.rb, line 771
771:   def stdout=(s)
772:     @stdout = s
773:   end

[Source]

     # File debug.rb, line 802
802:   def suspend
803:     saved_crit = Thread.critical
804:     Thread.critical = true
805:     make_thread_list
806:     for th, in @thread_list
807:       next if th == Thread.current
808:       context(th).set_suspend
809:     end
810:     Thread.critical = saved_crit
811:     # Schedule other threads to suspend as soon as possible.
812:     Thread.pass unless Thread.critical
813:   end

[Source]

     # File debug.rb, line 853
853:   def thread_list(num)
854:     th = get_thread(num)
855:     if th == Thread.current
856:       @stdout.print "+"
857:     else
858:       @stdout.print " "
859:     end
860:     @stdout.printf "%d ", num
861:     @stdout.print th.inspect, "\t"
862:     file = context(th).instance_eval{@file}
863:     if file
864:       @stdout.print file,":",context(th).instance_eval{@line}
865:     end
866:     @stdout.print "\n"
867:   end

[Source]

     # File debug.rb, line 869
869:   def thread_list_all
870:     for th in @thread_list.values.sort
871:       thread_list(th)
872:     end
873:   end

[Source]

     # File debug.rb, line 783
783:   def waiting
784:     @waiting
785:   end

Search

Google

Ruby API Docs

Links