Xdebug Document (iii) stack trace, xdebug document stack trace _php tutorial

Source: Internet
Author: User
Tags derick disk usage

Xdebug Document (iii) stack trace, xdebug document Stack trace


When Xdebug is activated, PHP xdebug displays the stack trace information as soon as the notification, warning, or error is displayed. This stack of information can be configured to display according to your needs.

The stack trace displayed by Xdebug displays information in a conservative number of States. Because a lot of information processing and rendering will slow down the execution of the script. It is possible to display more detailed information with different settings.

Variables for stack traces

Xdebug typically displays variable information on stack traces. Variable information can carry a lot of resources in the case of collection and display. However, in many cases, the display of these variable information is helpful, which is why there are xdebug.clollect_params settings. The following script outputs different information when different values are set:

The script

 
  PHPfunction$a  ) {    for ($i$i$a$i+ + {        if ($i = = 500000) xdebug_break ();}    } Set_time_limit (1); $c New StdClass; $c->bar = +; $a Array (    false, ' foo ' = 912124,    $cnewfopen('/etc/ passwd ', ' R '$a  );? >

Default value:

(!) Fatal error:maximum Execution time of 1 second exceeded in/home/httpd/html/test/xdebug/docs/stack.php on line em>34

call Stack

#

time

Memory

Function

location

1

0.0001

58564

{main} ()

... /stack.php : 0

2

0.0004

td>

62764

Foo ()

... /stack.php :

1 Value:

Ini_set (' Xdebug.collect_params ', ' 1 ');

(!) Fatal error:maximum Execution time of 1 second exceeded in/home/httpd/html/test/xdebug/docs/stack.php on line em>31

call Stack

#

time

Memory

Function

location

1

0.0001

58132

{main} ()

... /stack.php : 0

2

0.0004

td>

62380

Foo (array (5))

... /stack.php :

2 Value:

Ini_set (' Xdebug.collect_params ', ' 2 ');

(!) Fatal error:maximum Execution time of 1 second exceeded in/home/httpd/html/test/xdebug/docs/stack.php on line em>31

call Stack

#

time

Memory

Function

location

1

0.0001

58564

{main} ()

... /stack.php : 0

2

0.0004

td>

62812

Foo (array (5))

... /stack.php :

3 Value:

Ini_set (' Xdebug.collect_params ', ' 3 ');

( ! ) Fatal error:maximum Execution time of 1 second exceeded in/home/httpd/html/test/xdebug/docs/stack.php on line 3 1

Call Stack

#

Time

Memory

Function

Location

1

0.0001

58564

{main} ( )

.. /stack.php:0

2

0.0004

62812

Foo (array = FALSE, ' foo ' = = 912124, +/-class StdClass {public $bar = +}, + = + class StdClass {} , resource (2) of type (stream))

.. /stack.php:47


4 Value:
Ini_set (' Xdebug.collect_params ', ' 4 ');

( ! ) Fatal error:maximum Execution time of 1 second exceeded in/home/httpd/html/test/xdebug/docs/stack.php on line 3 1

Call Stack

#

Time

Memory

Function

Location

1

0.0001

58132

{main} ( )

.. /stack.php:0

2

0.0004

62380

Foo ($a = array ($ = FALSE, ' foo ' = = 912124, + = class StdClass {public $bar = +}, and Stdclas s {}, Resource (2) of type (stream))

.. /stack.php:47

Related settings:

Xdebug.cli_color

Type: integer, default: 0, starting at 2.2 version

When set to 1 o'clock, Xdebug will track output text in a colored display var_dump in CLI mode and when the TTY terminal outputs. window, the Ansicon tool needs to be installed.

When set to 2 o'clock, Xdebug will always display var_dump and debug trace information in color, regardless of whether the connection to the TTY terminal or Ansicon is installed. In this case, you may see the escape code at the end.

Xdebug.collect_includes

Type: boolean, default value: 1

By default, Xdebug is written to the trace file using the file name referenced by the include (), include_once (), require (), or require_once () method.

Xdebug.collect_params

Type: integer, default value: 0

The default is 0 o'clock, which controls whether a function trace or a stack trace collects the parameters of the calling function Xdebug.

The default value of 0 is that large-scale scripting consumes a lot of memory, so it is not run for Bigfoot. You can safely turn this setting on, but you'll expect some scripting problems to be passed as parameters like a large number of function calls and large data structures. XDEBUG2 does not have the problem of increasing memory usage because it is not stored in memory, but is only saved to disk. This only requires you to have enough disk usage.

There are 4 setting values for this setting. Each of these will present different information. The following table shows the various setting value information:

Value

Argument Information shown

0

No.

1

Displays the value type and value of the variable element.

2

Displays the value type and value of the variable element, with a mouse hint showing the complete information. (There is no mouse hint in CLI mode)

3

Full variable content (content is limited by the following settings: Xdebug.var_display_max_children,xdebug.var_display_max_data and xdebug.var_display_max_depth.)

4

The full variable content and name.

5

PHP serializes variable contents without a name. (2.3 version new features )

Xdebug.collect_vars

Type: boolean, default value: 0

This setting allows Xdebug to collect variable information within a certain range. This analysis works rather slowly because Xdebug will parse the PHP code backwards. This setting does not record values for different variables. If you want to take advantage of the xdebug_get_declared_vars () function, then you need to turn on the setting.

xdebug.dump.*

Type: string, default value: Empty

* Can be replaced by any one of the cookies, FILES, GET, POST, REQUEST, SERVER, session. These seven setting values control the data of the hyper-global variable at the time of the error.

Each setting value in php.ini is separated by commas to form a list of variables, or the * number represents all. Make sure you have no spaces in the settings.

In order to receive REMOTE_ADDR and Request_method information and all get parameters when an error occurs, you can set:

Xdebug.dump.SERVER = Remote_addr,request_method

Xdebug.dump.GET = *

Xdebug.dump_globals

Type: boolean, Default: 1

Controls whether the value of the hyper-global variable is displayed, regardless of what is set in the xdebug.dump.*.

Xdebug.dump_once

Type: boolean, default value: 1

Controls whether to display the Super global variable value (set to 0 value) or only the first occurrence (set to 1 value) in all error cases.

xdebug.dump_undefined

Type: boolean, default value: 0

If you need to display an undefined value in a hyper-global variable, the item is set to 1, otherwise the 0 default is preserved.

Xdebug.manual_url

Type: string, default: http://www.php.net, starting from Xdebug 2.2.1 the following version

Specifies the source of link descriptions for function tracking and error messages. It is recommended to use the most recent mirror link.

Xdebug.show_exception_trace

Type: integer, default value: 0

When set to 1 o'clock, Xdebug will also display its stack trace information when an exception occurs, even if the exception is snapped.

Xdebug.show_local_vars

Type: integer, default value: 0

When set to a value other than 0, the stack trace produced by Xdebug in error conditions displays all variable information at the topmost range. This can generate a lot of information, so it is turned off by default.

Xdebug.show_mem_delta

Type: integer, Default value: 0

When this setting is not 0 o'clock, Xdebug's human readability tracking record file shows memory usage when the function is called. If the xdebug is equipped to produce machine-readable tracking files, they often display this information. 、

Xdebug.var_display_max_children

Type: Integer, default value: 128

This setting controls the display of the number of array elements and object properties when using Xdebug_var_dump (), xdebug.show_local_vars, or trace functions.

It can be set to a value of 1 if not restricted.

This setting is not affected by Remot_debuggin remote debugging.

Xdebug.var_display_max_data

Type: Integer, default value: 512

This setting controls the length of the string to display the maximum value when using the Xdebug_var_dump (), xdebug.show_local_vars, or trace function.

It can be set to a value of 1 if not restricted.

This setting is not affected by remot_debugging remote debugging.

Xdebug.var_display_max_depth

Type: integer, default value: 3

This setting controls the display level of array elements and object properties when using Xdebug_var_dump (), xdebug.show_local_vars, or trace functions.

The maximum value is 1023, and you can set it to 1 to indicate its maximum value.

This setting is not affected by remot_debugging remote debugging.

Related functions:

Array Xdebug_get_declared_vars ()

Returns an array whose elements are defined variable names within the current scope. The xdebug.collect_vars must be turned on for the function to take effect.

Example:

 
  PHP    class  strings {        staticfunction fix_strings ($a$b ) {            foreach ($bas$item) {            }             Var_dump (Xdebug_get_declared_vars ());        }    }    Strings:: fix_strings (arrayarray(4,5,6));? >/**returns:array  0 = String ' a ' (length=1)  1 = string ' B ' (length=1  ) */

PHP5.1 the previous version, the variable name "a" is not in the returned array because the variable was not used when the Xdebug_get_declared_vars () function was executed.

Array Xdebug_get_function_stack ()

Returns an array that contains information similar to the stack trace displayed at the point of the function.

Example:

 PhpclassStrings {functionFix_string ($a)        {            Var_dump(Xdebug_get_function_stack ()); }        functionFix_strings ($b) {            foreach($b  as $item) {                $this->fix_string ($item); }        }    }    $s=Newstrings (); $ret=$s->fix_strings (Array(' Derick '));?>/**returns:array 0 = = Array ' function ' = = String ' {main} ' (length=6) ' file ' = = String '/var/www/ Xdebug_get_function_stack.php ' (length=63) ' line ' = + int 0 ' params ' = = array empty 1 =&G     T Array ' function ' = = String ' fix_strings ' (length=11) ' class ' = = String ' Strings ' (length=7) ' file ' =& Gt          String '/var/www/xdebug_get_function_stack.php ' (length=63) ' line ' = + int ' params ' = = array  ' b ' = = String ' Array (0 = ' Derick ') ' (length=21) 2 = = Array ' function ' = = String ' fix_string '      (length=10)      ' Class ' = = String ' Strings ' (length=7) ' file ' = = String '/var/www/xdebug_get_function_stack.php ' (length=63) ' line ' = + int ' params ' = = Array ' A ' = ' + string ' Derick ' (length=8)*/

integer xdebug_get_stack_depth ()

Returns the stack depth level. The script body is level 0 and various references or calling functions add a stack depth level.

None Xdebug_print_function_stack ( [string message [, int options]] )

Displays the current function tracking information in a similar error condition.

The "message" parameter allows you to customize display information. ( starting with Xdebug 2.1 version ).

Example:

 
  PHPfunction$far$out  ) {    ' Your own message '42, 3141592654 );? >

Returns:

( ! ) xdebug:your own message in/home/httpd/html/test/xdebug/print_function_stack.php on line 5

Call Stack

#

Time

Memory

Function

Location

1

0.0006

653896

{main} ( )

.. /print_function_stack.php:0

2

0.0007

654616

Foo (42, 3141592654)

.. /print_function_stack.php:7

3

0.0007

654736

Xdebug_print_function_stack (' Your own message ')

.. /print_function_stack.php:5

The Mask parameter "Options" allows you to configure some additional parameter options. The supported options are:

XDEBUG_STACK_NO_DESC

If this item is set, the tracking information displayed does not contain a header. This is useful if you want to display your own error tracking information from a custom error handler. In addition, you can call the XDEBUG_PRINT_FUNCTION_STATCK () function where you want it to appear. (Starting from xdebug2.3)

void xdebug_start_function_monitor ( array $list _of_functions_to_monitor )

Start function monitoring.

start from version 2.4

The function begins to monitor these functions when passing a series of function names as parameters. The function Monitor will find out the code that contains the functions you provided. This can be used to track old functions or obsolete functions.

Example:

 
  Phpxdebug_start_function_monitor ([' Strrev ', ' Array_push ' ]);? >

You can also add class methods or static methods to the array for monitoring. For example, in order to capture static calls to Drammodel::cansee and dynamically call Whisky->drink, you can start the following monitoring:

Example:

 
  Phpxdebug_start_function_monitor ([' Drammodel::cansee ', ' Whisky->drink ']);? >

The function to be defined is case-sensitive and will not be captured if the dynamic call to the static method.

void xdebug_stop_function_monitor ()

Stop function monitoring

start from version 2.4

The function stops monitoring the function. To get a list of the monitored functions, you can use the Xdebug_get_monitored_functions () function.

http://www.bkjia.com/PHPjc/1133572.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133572.html techarticle Xdebug Document (iii) stack trace, xdebug document stack trace when xdebug is activated, PHP displays the stack trace information as soon as the notification, warning, or error is displayed. This stack information ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.