Class: DEBUGGER__
Defined Under Namespace
Constant Summary collapse
Class Method Summary collapse
- .break_points ⇒ Object
- .context(thread = Thread.current) ⇒ Object
- .debug_thread_info(input, binding) ⇒ Object
- .display ⇒ Object
- .get_thread(num) ⇒ Object
- .interrupt ⇒ Object
- .make_thread_list ⇒ Object
- .resume ⇒ Object
- .set_last_thread(th) ⇒ Object
- .set_trace(arg) ⇒ Object
- .start_debugger ⇒ Object
- .stdout ⇒ Object
- .stdout=(s) ⇒ Object
- .suspend ⇒ Object
- .thread_list(num) ⇒ Object
- .thread_list_all ⇒ Object
- .waiting ⇒ Object
Class Method Details
.break_points ⇒ Object
778 779 780 |
# File 'lib/innate/debugger.rb', line 778 def break_points @break_points end |
.context(thread = Thread.current) ⇒ Object
831 832 833 834 835 836 837 |
# File 'lib/innate/debugger.rb', line 831 def context(thread=Thread.current) c = thread[:__debugger_data__] unless c thread[:__debugger_data__] = c = Context.new end c end |
.debug_thread_info(input, binding) ⇒ Object
887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 |
# File 'lib/innate/debugger.rb', line 887 def debug_thread_info(input, binding) case input when /^l(?:ist)?/ make_thread_list thread_list_all when /^c(?:ur(?:rent)?)?$/ make_thread_list thread_list(@thread_list[Thread.current]) when /^(?:sw(?:itch)?\s+)?(\d+)/ make_thread_list th = get_thread($1.to_i) if th == Thread.current @stdout.print "It's the current thread.\n" else thread_list(@thread_list[th]) context(th).stop_next th.run return :cont end when /^stop\s+(\d+)/ make_thread_list th = get_thread($1.to_i) if th == Thread.current @stdout.print "It's the current thread.\n" elsif th.stop? @stdout.print "Already stopped.\n" else thread_list(@thread_list[th]) context(th).suspend end when /^resume\s+(\d+)/ make_thread_list th = get_thread($1.to_i) if th == Thread.current @stdout.print "It's the current thread.\n" elsif !th.stop? @stdout.print "Already running." else thread_list(@thread_list[th]) th.run end end end |
.display ⇒ Object
774 775 776 |
# File 'lib/innate/debugger.rb', line 774 def display @display end |
.get_thread(num) ⇒ Object
843 844 845 846 847 848 849 850 |
# File 'lib/innate/debugger.rb', line 843 def get_thread(num) th = @thread_list.index(num) unless th @stdout.print "No thread ##{num}\n" throw :debug_error end th end |
.interrupt ⇒ Object
839 840 841 |
# File 'lib/innate/debugger.rb', line 839 def interrupt context(@last_thread).stop_next end |
.make_thread_list ⇒ Object
874 875 876 877 878 879 880 881 882 883 884 885 |
# File 'lib/innate/debugger.rb', line 874 def make_thread_list hash = {} for th in Thread::list if @thread_list.key? th hash[th] = @thread_list[th] else @max_thread += 1 hash[th] = @max_thread end end @thread_list = hash end |
.resume ⇒ Object
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
# File 'lib/innate/debugger.rb', line 814 def resume saved_crit = Thread.critical Thread.critical = true make_thread_list for th, in @thread_list next if th == Thread.current context(th).clear_suspend end waiting.each do |th| th.run end waiting.clear Thread.critical = saved_crit # Schedule other threads to restart as soon as possible. Thread.pass end |
.set_last_thread(th) ⇒ Object
797 798 799 |
# File 'lib/innate/debugger.rb', line 797 def set_last_thread(th) @last_thread = th end |
.set_trace(arg) ⇒ Object
786 787 788 789 790 791 792 793 794 795 |
# File 'lib/innate/debugger.rb', line 786 def set_trace( arg ) saved_crit = Thread.critical Thread.critical = true make_thread_list for th, in @thread_list context(th).set_trace arg end Thread.critical = saved_crit arg end |
.start_debugger ⇒ Object
935 936 937 938 939 940 941 |
# File 'lib/innate/debugger.rb', line 935 def start_debugger stdout.printf "Debug.rb\n" stdout.printf "Emacs support available.\n\n" set_trace_func proc { |event, file, line, id, binding, klass, *rest| DEBUGGER__.context.trace_func event, file, line, id, binding, klass } end |
.stdout ⇒ Object
766 767 768 |
# File 'lib/innate/debugger.rb', line 766 def stdout @stdout end |
.stdout=(s) ⇒ Object
770 771 772 |
# File 'lib/innate/debugger.rb', line 770 def stdout=(s) @stdout = s end |
.suspend ⇒ Object
801 802 803 804 805 806 807 808 809 810 811 812 |
# File 'lib/innate/debugger.rb', line 801 def suspend saved_crit = Thread.critical Thread.critical = true make_thread_list for th, in @thread_list next if th == Thread.current context(th).set_suspend end Thread.critical = saved_crit # Schedule other threads to suspend as soon as possible. Thread.pass unless Thread.critical end |
.thread_list(num) ⇒ Object
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 |
# File 'lib/innate/debugger.rb', line 852 def thread_list(num) th = get_thread(num) if th == Thread.current @stdout.print "+" else @stdout.print " " end @stdout.printf "%d ", num @stdout.print th.inspect, "\t" file = context(th).instance_eval{@file} if file @stdout.print file,":",context(th).instance_eval{@line} end @stdout.print "\n" end |
.thread_list_all ⇒ Object
868 869 870 871 872 |
# File 'lib/innate/debugger.rb', line 868 def thread_list_all for th in @thread_list.values.sort thread_list(th) end end |
.waiting ⇒ Object
782 783 784 |
# File 'lib/innate/debugger.rb', line 782 def waiting @waiting end |