Linux heracles.o2switch.net 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
/
opt
/
alt
/
ruby27
/
share
/
ri
/
system
/
DEBUGGER__
/
//opt/alt/ruby27/share/ri/system/DEBUGGER__/cdesc-DEBUGGER__.ri
U:RDoc::NormalClass[iI"DEBUGGER__:ET@I"Object;To:RDoc::Markup::Document:@parts[o;;[Do:RDoc::Markup::Paragraph;[I";This library provides debugging functionality to Ruby.;To:RDoc::Markup::BlankLine o; ;[I"HTo add a debugger to your code, start by requiring +debug+ in your ;TI" program:;T@o:RDoc::Markup::Verbatim;[ I"def say(word) ;TI" require 'debug' ;TI" puts word ;TI" end ;T:@format0o; ;[I"RThis will cause Ruby to interrupt execution and show a prompt when the +say+ ;TI"method is run.;T@o; ;[I"IOnce you're inside the prompt, you can start debugging your program.;T@o;;[I"(rdb:1) p word ;TI" "hello" ;T;0S:RDoc::Markup::Heading: leveli: textI"Getting help;T@o; ;[I"2You can get help at any time by pressing +h+.;T@o;;[-I"(rdb:1) h ;TI"Debugger help v.-0.002b ;TI"Commands ;TI"+ b[reak] [file:|class:]<line|method> ;TI"% b[reak] [class.]<line|method> ;TI"B set breakpoint to some position ;TI"D wat[ch] <expression> set watchpoint to some expression ;TI"A cat[ch] (<exception>|off) set catchpoint to an exception ;TI"3 b[reak] list breakpoints ;TI"2 cat[ch] show catchpoint ;TI"A del[ete][ nnn] delete some or all breakpoints ;TI"N disp[lay] <expression> add expression into display expression list ;TI"S undisp[lay][ nnn] delete one particular or all display expressions ;TI"K c[ont] run until program ends or hit breakpoint ;TI"P s[tep][ nnn] step (into methods) one line or till line nnn ;TI"D n[ext][ nnn] go over one line or till line nnn ;TI"1 w[here] display frames ;TI"2 f[rame] alias for where ;TI"B l[ist][ (-|nn-mm)] list program, - lists backwards ;TI": nn-mm lists given lines ;TI"7 up[ nn] move to higher frame ;TI"6 down[ nn] move to lower frame ;TI"8 fin[ish] return to outer frame ;TI"C tr[ace] (on|off) set trace mode of current thread ;TI"@ tr[ace] (on|off) all set trace mode of all threads ;TI"5 q[uit] exit from debugger ;TI"8 v[ar] g[lobal] show global variables ;TI"7 v[ar] l[ocal] show local variables ;TI"D v[ar] i[nstance] <object> show instance variables of object ;TI"; v[ar] c[onst] <object> show constants of object ;TI"9 m[ethod] i[nstance] <obj> show methods of object ;TI"K m[ethod] <class|module> show instance methods of class or module ;TI"3 th[read] l[ist] list all threads ;TI"6 th[read] c[ur[rent]] show current thread ;TI"? th[read] [sw[itch]] <nnn> switch thread context to nnn ;TI"2 th[read] stop <nnn> stop thread nnn ;TI"4 th[read] resume <nnn> resume thread nnn ;TI"J p expression evaluate expression and print its value ;TI"2 h[elp] print this help ;TI"+ <everything else> evaluate ;T;0S; ;i;I" Usage;T@o; ;[I"IThe following is a list of common functionalities that the debugger ;TI"provides.;T@S; ;i;I"!Navigating through your code;T@o; ;[I"HIn general, a debugger is used to find bugs in your program, which ;TI"Joften means pausing execution and inspecting variables at some point ;TI" in time.;T@o; ;[I"Let's look at an example:;T@o;;[ I"def my_method(foo) ;TI" require 'debug' ;TI"! foo = get_foo if foo.nil? ;TI" raise if foo.nil? ;TI" end ;T;0o; ;[I"JWhen you run this program, the debugger will kick in just before the ;TI"+foo+ assignment.;T@o;;[I"(rdb:1) p foo ;TI" nil ;T;0o; ;[I"GIn this example, it'd be interesting to move to the next line and ;TI"Ginspect the value of +foo+ again. You can do that by pressing +n+:;T@o;;[I"#(rdb:1) n # goes to next line ;TI"(rdb:1) p foo ;TI" nil ;T;0o; ;[I"HYou now know that the original value of +foo+ was nil, and that it ;TI"+still was nil after calling +get_foo+.;T@o; ;[I"@Other useful commands for navigating through your code are:;T@o:RDoc::Markup::List: @type: NOTE:@items[ o:RDoc::Markup::ListItem:@label[I"+c+;T;[o; ;[I"ORuns the program until it either exists or encounters another breakpoint. ;TI"LYou usually press +c+ when you are finished debugging your program and ;TI""want to resume its execution.;To;;[I"+s+;T;[o; ;[I"OSteps into method definition. In the previous example, +s+ would take you ;TI"/inside the method definition of +get_foo+.;To;;[I"+r+;T;[o; ;[I"Restart the program.;To;;[I"+q+;T;[o; ;[I"Quit the program.;T@S; ;i;I"Inspecting variables;T@o; ;[I"QYou can use the debugger to easily inspect both local and global variables. ;TI"6We've seen how to inspect local variables before:;T@o;;[I"(rdb:1) p my_arg ;TI"42 ;T;0o; ;[I"FYou can also pretty print the result of variables or expressions:;T@o;;[I"A(rdb:1) pp %w{a very long long array containing many words} ;TI"["a", ;TI" "very", ;TI" "long", ;TI" ... ;TI"] ;T;0o; ;[I"1You can list all local variables with +v l+:;T@o;;[I"(rdb:1) v l ;TI" foo => "hello" ;T;0o; ;[I"=Similarly, you can show all global variables with +v g+:;T@o;;[I"(rdb:1) v g ;TI" all global variables ;T;0o; ;[I"LFinally, you can omit +p+ if you simply want to evaluate a variable or ;TI"expression;T@o;;[I"(rdb:1) 5**2 ;TI"25 ;T;0S; ;i;I"Going beyond basics;T@o; ;[I"FRuby Debug provides more advanced functionalities like switching ;TI"Kbetween threads, setting breakpoints and watch expressions, and more. ;TI"HThe full list of commands is available at any time by pressing +h+.;T@S; ;i;I"Staying out of trouble;T@o; ;[I"EMake sure you remove every instance of +require 'debug'+ before ;TI"Eshipping your code. Failing to do so may result in your program ;TI"hanging unpredictably.;T@o; ;[I")Debug is not available in safe mode.;T: @fileI"lib/debug.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[ [ [ [[I" class;T[[:public[ [:protected[ [:private[[I"break_points;TI"lib/debug.rb;T[I"context;T@�[I"debug_thread_info;T@�[I"display;T@�[I"get_thread;T@�[I"interrupt;T@�[I"make_thread_list;T@�[I"resume;T@�[I"set_last_thread;T@�[I"set_trace;T@�[I"stdout;T@�[I"stdout=;T@�[I"suspend;T@�[I"thread_list;T@�[I"thread_list_all;T@�[I"waiting;T@�[I" instance;T[[;[ [;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[I"lib/debug.rb;T@�cRDoc::TopLevel