Class DEBUGGER__
In: lib/debug.rb
Parent: Object

Methods

Classes and Modules

Class DEBUGGER__::Context
Class DEBUGGER__::Mutex

Constants

MUTEX = Mutex.new

Public Class methods

[Source]

     # File lib/debug.rb, line 785
785:   def break_points
786:     @break_points
787:   end

[Source]

     # File lib/debug.rb, line 838
838:   def context(thread=Thread.current)
839:     c = thread[:__debugger_data__]
840:     unless c
841:       thread[:__debugger_data__] = c = Context.new
842:     end
843:     c
844:   end

[Source]

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

[Source]

     # File lib/debug.rb, line 781
781:   def display
782:     @display
783:   end

[Source]

     # File lib/debug.rb, line 850
850:   def get_thread(num)
851:     th = @thread_list.index(num)
852:     unless th
853:       @stdout.print "No thread ##{num}\n"
854:       throw :debug_error
855:     end
856:     th
857:   end

[Source]

     # File lib/debug.rb, line 846
846:   def interrupt
847:     context(@last_thread).stop_next
848:   end

[Source]

     # File lib/debug.rb, line 881
881:   def make_thread_list
882:     hash = {}
883:     for th in Thread::list
884:       if @thread_list.key? th
885:         hash[th] = @thread_list[th]
886:       else
887:         @max_thread += 1
888:         hash[th] = @max_thread
889:       end
890:     end
891:     @thread_list = hash
892:   end

[Source]

     # File lib/debug.rb, line 821
821:   def resume
822:     saved_crit = Thread.critical
823:     Thread.critical = true
824:     make_thread_list
825:     for th, in @thread_list
826:       next if th == Thread.current
827:       context(th).clear_suspend
828:     end
829:     waiting.each do |th|
830:       th.run
831:     end
832:     waiting.clear
833:     Thread.critical = saved_crit
834:     # Schedule other threads to restart as soon as possible.
835:     Thread.pass
836:   end

[Source]

     # File lib/debug.rb, line 804
804:   def set_last_thread(th)
805:     @last_thread = th
806:   end

[Source]

     # File lib/debug.rb, line 793
793:   def set_trace( arg )
794:     saved_crit = Thread.critical
795:     Thread.critical = true
796:     make_thread_list
797:     for th, in @thread_list
798:       context(th).set_trace arg
799:     end
800:     Thread.critical = saved_crit
801:     arg
802:   end

[Source]

     # File lib/debug.rb, line 773
773:   def stdout
774:     @stdout
775:   end

[Source]

     # File lib/debug.rb, line 777
777:   def stdout=(s)
778:     @stdout = s
779:   end

[Source]

     # File lib/debug.rb, line 808
808:   def suspend
809:     saved_crit = Thread.critical
810:     Thread.critical = true
811:     make_thread_list
812:     for th, in @thread_list
813:       next if th == Thread.current
814:       context(th).set_suspend
815:     end
816:     Thread.critical = saved_crit
817:     # Schedule other threads to suspend as soon as possible.
818:     Thread.pass unless Thread.critical
819:   end

[Source]

     # File lib/debug.rb, line 859
859:   def thread_list(num)
860:     th = get_thread(num)
861:     if th == Thread.current
862:       @stdout.print "+"
863:     else
864:       @stdout.print " "
865:     end
866:     @stdout.printf "%d ", num
867:     @stdout.print th.inspect, "\t"
868:     file = context(th).instance_eval{@file}
869:     if file
870:       @stdout.print file,":",context(th).instance_eval{@line}
871:     end
872:     @stdout.print "\n"
873:   end

[Source]

     # File lib/debug.rb, line 875
875:   def thread_list_all
876:     for th in @thread_list.values.sort
877:       thread_list(th)
878:     end
879:   end

[Source]

     # File lib/debug.rb, line 789
789:   def waiting
790:     @waiting
791:   end

[Validate]