Fix breaking on request start/end/psp
[hiphop-php.git] / hphp / doc / debugger.refs
blob0d7e0215ad068173eece933da90ede7eee0ffd79
2     --------------------------- Abort Command ---------------------------
4     [a]bort              aborts current PHP code input
7 You will have to type this command on a new line, while you're typing
8 ad-hoc PHP code to evaluate. In other words, it only works when you see
9 continuation prompt like ">>>>".
12     --------------------------- Break Command ---------------------------
14     [b]reak                               breaks at current line of code
15     [b]reak {exp}                         breaks at matching location
17     [b]reak [o]nce  {above}               breaks just once then disables it
19     [b]reak {above} if {php}              breaks if condition meets
20     [b]reak {above} && {php}              breaks and evaluates an expression
22     [b]reak [l]ist                        lists all breakpoints
23     [b]reak [c]lear {index}               clears the n-th breakpoint on list
24     [b]reak [c]lear [a]ll                 clears all breakpoints
25     [b]reak [c]lear                       clears current breakpoint
26     [b]reak [t]oggle {index}              toggles the n-th breakpoint on list
27     [b]reak [t]oggle [a]ll                toggles all breakpoints
28     [b]reak [t]oggle                      toggles current breakpoint
29     [b]reak [e]nable {index}              enables the n-th breakpoint on list
30     [b]reak [e]nable [a]ll                enables all breakpoints
31     [b]reak [e]nable                      enables current breakpoint
32     [b]reak [d]isable {index}             disables the n-th breakpoint on list
33     [b]reak [d]isable [a]ll               disables all breakpoints
34     [b]reak [d]isable                     disables current breakpoint
37     -------------------------- Where to break? --------------------------
39 There are many ways to specify a source file location to set a breakpoint,
40 but it's ONE single string without whitespaces. The format looks like this,
42         file location: {file}:{line}
43         function call: {func}()
44         method invoke: {cls}::{method}()
46 For examples,
48         b mypage.php:123
49         b foo()
50         b MyClass::foo()
52     ------------------------ Special Breakpoints ------------------------
54 There are special breakpoints what can only be set by names:
56       start
57       end
58       psp
60 They represent different time points of a web request. 'start' is at the
61 beginning of a web request, when no PHP file is invoked yet, but query
62 string and server variables are already prepared. 'end' is at the end of
63 a web request, but BEFORE post-send processing (psp). 'psp' is at END of
64 psp, not beginning. To set a breakpoint at the beginning of psp, use
65 'end', because end of a request is the same as beginning of psp.
67     -------------- Conditional Breakpoints and Watchpoints --------------
69 Every breakpoint can specify a condition, which is an arbitrary PHP expression
70 that will be evaluated to TRUE or FALSE. When TRUE, it will break. When FALSE,
71 it will continue without break. "&&" is similar to "if", except it will always
72 break, regardless what the expression returns. This is useful to watch
73 variables at breakpoints. For example,
75         b mypage.php:123 && print $a
77 So every time it breaks at mypage.php line 123, it will print out $a.
79     --------------------- Breakpoint States and List ---------------------
81 Every breakpoint has 3 states: ALWAYS, ONCE, DISABLED. Without keyword "once",
82 a breakpoint is in ALWAYS state. ONCE breakpoints will turn into DISABLED after
83 it's hit once. DISABLED breakpoints will not break, but they are kept in the
84 list, so one can run 'b l' command and 'b t' command to toggle their states.
86 Use '[b]reak [l]ist' command to view indices of different breakpoints. Then use
87 those indices to clear or toggle their states. This list of breakpoints and
88 their states will remain the same when switching to different machines,
89 sandboxes and threads.
91     -------------------------- Hard Breakpoints --------------------------
93 From within PHP code, you can place a function call hphpd_break() to embed a
94 breakpoint. You may also specify a condition as the function's parameter, so it
95 breaks when the condition is met. Please read about this function for more
96 details with '[i]nfo hphpd_break'.
98     -------------------------- Continue Command --------------------------
100     [c]ontinue           continues program execution
101       {count=1}
104 Use this command at break to resume program execution. Specify a count
105 to repeat the same command many times.
108     ---------------------------- Down Command ----------------------------
110     [d]own {num=1}       moves to inner frames (callees) on stacktrace
113 Use this command to walk down on stacktrace to find out inner callees of
114 current frame. By default it moves down by one level. Specify a number
115 to move down several levels a time.
118     ------------------------- Exception Command -------------------------
120     [e]xception {cls}    breaks if class of exception throws
121     [e]xception          breaks if class of exception throws
122       {ns}\{cls}
123     [e]xception error    breaks on errors, warnings and notices
124     [e]xception          breaks only if url also matches
125       {above}@{url}
127     [e]xception          breaks at matching regex pattern
128       [r]egex {above}
129     [e]xception          breaks just once then disables it
130       [o]nce  {above}
132     [e]xception          breaks if condition meets
133       {above} if {php}
134     [e]xception          breaks and evaluates an expression
135       {above} && {php}
138 Exception command is similar to '[b]reak' command, except it's used to
139 specify how to break on (or catch) a throw of an exception. Program
140 stops right before the exception is about to throw. Resuming program
141 execution will continue to throw the exception as is.
143 Only a class name can be specified with an optional namespace. All
144 exceptions of the class or its sub-classes will be matched. To specify a
145 perfect match without sub-classing test, use '[e]xception [r]egex
146 ^{exact class name}$', although regex can match in a lot more different
147 ways.
149 An exception breakpoint can be listed, cleared or toggled with '[b]reak'
150 commands.
153     --------------------------- Frame Command ---------------------------
155     [f]rame {index}      jumps to one particular frame
158 Use '[w]here' command to find out the frame number. Use 'f 0' to jump
159 back to the most recent frame or the innermost frame. Use 'f 999' or
160 some big number to jump to the outermost frame.
163     --------------------------- Global Command ---------------------------
165     [g]lobal             lists all global variables
166     [g]lobal {text}      full-text search global variables
169 This will print names and values of all global variables, if {text} is
170 not speified. Otherwise, it will print global variables that contain the
171 text in their names or values. The search is case-insensitive and
172 string-based.
175     ---------------------------- Help Command ----------------------------
177     [h]elp [s]tart       displays material for getting started
178     [h]elp [t]utorial    changing tutorial modes
179       on|off|auto
182 Please read "Getting Started" material with '[h]elp [s]tart' for first
183 time use to get yourself familiar with basics.
185 Tutorial mode displays extra information when something didn't work as
186 you expected. "auto" mode will display the same information just once.
187 "on" mode will display it as long as you run into the same situation.
188 "off" mode completely turns off all tutorial texts.
190 To get detailed information of a command, type '{cmd} [h]elp' or '{cmd}
191 ?' or 'help {cmd}' or '? {cmd}'.
194     ---------------------------- Info Command ----------------------------
196     info                 displays current function's info
197     info {cls}           displays declaration of this class
198     info {function}      displays declaration of this function
199     info                 displays declaration of this method
200       {cls::method}
201     info                 displays declaration of this constant
202       {cls::constant}
203     info                 displays declaration of this property
204       {cls::$property}
207 Use this command to display declaration of a symbol.
210     ---------------------------- Jump Command ----------------------------
212     [j]ump               jumps over one expression
213     [j]ump {line}        goto the specified line
214     [j]ump               goto the specified line
215       {file}:{line}
216     [j]ump {label}       goto the specified label
219 This command changes program execution to the specified place without
220 executing remaining code on current line. When no label or source
221 location is specified, it jumps over just one expression without
222 evaluating it. This may be useful to not throw an exception when breaks
223 at a throw, for example.
226     -------------------------- Constant Command --------------------------
228     [k]onstant           lists all constants
229     [k]onstant {text}    full-text search constants
232 This will print names and values of all constants, if {text} is not
233 speified. Otherwise, it will print names and values of all constants
234 that contain the text in their names or values. The search is
235 case-insensitive and string-based.
238     ---------------------------- List Command ----------------------------
240     list                 displays current block of source code
241     list {line}          displays code around specified line
242     list                 displays specified block of source code
243       {line1}-{line2}
244     list {line1}-        displays code starting with the line
245     list -{line2}        displays code ending with the line
246     list {file}          displays beginning lines of the file
247     list                 displays code around specified file:line
248       {file}:{line}
249     list                 displays specified block in the file
250       {file}:{l1}-{l2}
251     list {file}:{l1}-    displays specified block in the file
252     list {file}:-{l2}    displays specified block in the file
253     list {directory}     sets PHP source root directory
256 Use list command to display PHP source code. In remote debugging, this
257 is displaying source code on server side. When server side cannot find
258 the file, it will fall back to local files.
260 Hit return to display more lines of code after current display.
262 When a directory name is specified, this will be set to root directory
263 for resolving relative paths of PHP files. Files with absolute paths
264 will not be affected by this setting. This directory will be stored in
265 configuration file for future sessions as well.
268     -------------------------- Machine Command --------------------------
270     [m]achine            debugging remote server natively
271       [c]onnect {host}
272     [m]achine            debugging remote server natively
273       [c]onnect
274       {host}:{port}
275     [m]achine [r]pc      debugging remote server with RPC
276       {host}
277     [m]achine [r]pc      debugging remote server with RPC
278       {host}:{port}
279     [m]achine            debugging local script
280       [d]isconnect
281     [m]achine [l]ist     list all sandboxes
282     [m]achine            attach to a sandbox
283       [a]ttach {index}
284     [m]achine            attach to my sandbox by name
285       [a]ttach
286       {sandbox}
287     [m]achine            attach to a sandbox by user and name
288       [a]ttach {user}
289       {sandbox}
292 Use this command to switch between different machines or sandboxes.
294 If command prompt says "hphpd", all evaluation of PHP code happens
295 locally within the debugger. This is the mode when debugger is started
296 without a remote server name. No user libraries are pre-loaded in this
297 mode.
299 When connecting to a remote server, it will automatically attach to
300 "default" sandbox under current user. If "default" sandbox does not
301 exist, it will attach to a random sandbox under current user. In sandbox
302 mode, a file specified in server's configuration of
303 "Eval.Debugger.StartupDocument" is pre-loaded.
305 If there is no sandbox available, it will create a "dummy" sandbox and
306 attach to it.
308 When your sandbox is not available, please hit it at least once from
309 your browser. Then run '[m]achine [l]ist' command again.
311 If a HipHop server has RPC port open, one can also debug the server in a
312 very special RPC mode. In this mode, one can type in PHP scripts to run,
313 but all functions will be executed on server through RPC. Because states
314 are still maintained locally and only functions are executed remotely,
315 it may not work with functions or scripts that depend on global
316 variables or low-level raw resource pointers. As a simple rule,
317 stateless functions will work just fine. This is true to objects and
318 method calls as well, except classes will have to be loaded on client
319 side by '=include("file-containing-the-class.php")'.
322     ---------------------------- Next Command ----------------------------
324     [n]ext {count=1}     steps over lines of code
327 Use this command at break to step over lines of code. Specify a count to
328 step over more than one line of code.
331     ---------------------------- Out Command ----------------------------
333     [o]ut {count=1}      steps out function calls
336 Use this command at break to step out function calls. Specify a count to
337 step out more than one level of function calls.
340     --------------------------- Print Command ---------------------------
342     [p]rint {php}        prints result of PHP code
343     [p]rint x {php}      prints hex encoded string or number
344     [p]rint [h]ex        prints hex encoded string or number
345       {php}
346     [p]rint [o]ct        prints octal encoded string or number
347       {php}
348     [p]rint [d]ec        prints as signed integer
349       {php}
350     [p]rint              prints as unsigned integer
351       [u]nsigned {php}
352     [p]rint [t]ime       converts between time and timestamp
353       {php}
355     [p]rint [a]lways     adds a watch expression at break
356       {above}
357     [p]rint [l]ist       lists watch expressions
358     [p]rint [c]lear      clears a watch expression
359       {index}
360     [p]rint [c]lear      clears all watch expressions
361       [a]ll
364 Prints result of an expression in certain format. If '[a]lways' is
365 specified, the expression will be added to a watch list. At every break,
366 either at a breakpoint or caused by step commands, these expressions
367 will be evaluated and printed out.
370     ---------------------------- Quit Command ----------------------------
372     [q]uit               quits this program
375 After you type this command, you will not see me anymore.
378     ---------------------------- Run Command ----------------------------
380     [r]un                restarts program
381     [r]un {file}         starts a new program
382       {arg1} {arg2} ...
385 Aborts current execution and restarts program with specified arguments.
386 If no arguments are specified, it will reuse the PHP file and old
387 arguments. If arguments are to be changed, please include file name,
388 even if it is the same, as the first one.
390 In server mode, this command will simply abort current page handling
391 without restarting anything.
394     ---------------------------- Step Command ----------------------------
396     [s]tep {count=1}     steps into lines of code
399 Use this command at break to step into lines of code. Specify a count to
400 step more than once.
403     --------------------------- Thread Command ---------------------------
405     [t]hread             displays current thread's information
406     [t]hread [l]ist      lists all threads at break
407     [t]hread {index}     switches to the specified thread
408     [t]hread [n]ormal    breaks all threads
409     [t]hread [s]ticky    only send command to current thread
410     [t]hread             only break current thread
411       [e]xclusive
414 Use '[t]hread' alone to display information of current thread.
416 When a thread is at break, you may specify how other threads should
417 behave if they also happen to hit some breakpoints. Normally, other
418 threads will also break, and they will interrupt debugger session with
419 their breakpoints. So breaks from different threads may interleave. If
420 '[t]hread [s]ticky' is specified, all other threads will wait until
421 current thread is finished. This will help debugging to focus on just
422 one thread without losing breaks from other threads. If there is no need
423 to hold up any other threads, use '[t]hread [e]xclusive'. Then other
424 threads will not break at all. This mode is useful for live debugging a
425 production server, without interrupting many threads at a time. Use
426 '[t]hread [n]ormal' to change thread mode back to normal.
428 Some debugging commands will automatically turn thread mode to sticky.
429 These include continue, step, next or out commands with a counter of
430 more than 1. Or a jump command. These commands imply non-interruption
431 from another thread. The mode will remain even after these commands
432 until '[t]hread [n]ormal' is issued.
433 When multple threads hit breakpoints at the same time, use '[t]hread
434 [l]ist' command to display their indices, which can be used to switch
435 between them with '[t]hread {index}'.
438     ----------------------------- Up Command -----------------------------
440     [u]p {num=1}         moves to outer frames (callers) on stacktrace
443 Use this command to walk up on stacktrace to find out outer callers of
444 current frame. By default it moves up by one level. Specify a number to
445 move up several levels a time.
448     -------------------------- Variable Command --------------------------
450     [v]ariable           lists all local variables on stack
451     [v]ariable {text}    full-text search local variables
454 This will print names and values of all variables that are currently
455 accessible by simple names. Use '[w]here', '[u]p {num}', '[d]own {num}',
456 '[f]rame {index}' commands to choose a different frame to view variables
457 at different level of the stack.
459 Specify some free text to print local variables that contain the text
460 either in their names or values. The search is case-insensitive and
461 string-based.
464     --------------------------- Where Command ---------------------------
466     [w]here              displays current stacktrace
467     [w]here {num}        displays number of innermost frames
468     [w]here -{num}       displays number of outermost frames
471 Use '[u]p {num}' or '[d]own {num}' to walk up or down the stacktrace.
472 Use '[f]rame {index}' to jump to one particular frame. At any frame, use
473 '[v]ariable' command to display all local variables.
476     -------------------------- Extended Command --------------------------
478     x {cmd} {arg1}       invoke specified command
479       {arg2} ...
480     x{cmd} {arg1}        invoke specified command
481       {arg2} ...
484 where {cmd} can be:
486         [a]mple
487         [t]ension
489 Type 'x [h]elp|? {cmd} to read their usages.
491     ----------------------- User Extended Command -----------------------
493     y {cmd} {arg1}       invoke specified command
494       {arg2} ...
495     y{cmd} {arg1}        invoke specified command
496       {arg2} ...
499 These commands are implemented and installed in PHP by implementing
500 DebuggerCommand and calling hphpd_install_user_command(). For example
502   class MyCommand implements DebuggerCommand {
503     public function help($client) {
504       $client->helpTitle("Hello Command");
505       $client->helpCmds("y [h]ello", "prints welcome message");
506       return true;
507     }
508     public function onClient($client) {
509       $client->output("Hello, world!");
510       return true;
511     }
512   }
514   hphpd_install_user_command('hello', 'MyCommand');
516 Type '[i]nfo DebuggerCommand' for complete DebuggerCommand interface.
517 Type '[i]nfo DebuggerClient' for complete DebuggerClient interface that
518 you can use when implementing those $client callbacks. Type '[i]nfo
519 DebuggerProxy' for complete DebuggerProxy interface that you can use
520 when implementing those $proxy callbacks.
523     ---------------------------- Zend Command ----------------------------
525     [z]end               running the most recent code snippet in Zend PHP
528 This is mainly for comparing results from PHP vs. HipHop. After you type
529 in some PHP code, it will be evaluated immediately in HipHop. Then you
530 can type '[z]end' command to re-run the same script in Zend PHP. Please
531 note that only the most recent block of code you manually typed in was
532 evaluated, not any earlier ones, nor the ones from a PHP file.
535     --------------------------- Macro Command ---------------------------
537     & [s]tart            starts recording of default macro
538     & [s]tart {name}     starts recording of a named macro
539     & [e]nd              stops and saves recorded macro
540     & [r]eplay           replays default macro
541     & [r]eplay {name}    replays a named macro
542     & [l]ist             lists all macros
543     & [c]lear {index}    deletes a macro
546 Macro command allows you to record a series of debugger command, so you
547 can replay later by its name. When name is not specified, it will use
548 "default" as the name.
550 There is also a special macro "startup" that will be replayed every time
551 when debugger is just started. Use startup macro to load certain PHP
552 files or perform certain debugging environment setup.
554 The space between & and command is not needed. '&s' works as well.
557     --------------------------- Shell Command ---------------------------
559 ! {cmd} {arg1} {arg2} ...    remotely executes shell command
561 Executes the shell command on connected machine.
563 The space between ! and command is not needed. '!ls' works as well.