10bet网址
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr)- 41.5Mb
PDF (A4)- 41.6Mb
Man Pages (TGZ)- 262.1Kb
Man Pages (Zip)- 372.2Kb
Info (Gzip)- 4.0Mb
Info (Zip)- 4.0Mb
Excerpts from this Manual

5.9.4 The DBUG Package

The MySQL server and most MySQL clients are compiled with the DBUG package originally created by Fred Fish. When you have configured MySQL for debugging, this package makes it possible to get a trace file of what the program is doing. SeeSection 5.9.1.2, “Creating Trace Files”.

This section summarizes the argument values that you can specify in debug options on the command line for MySQL programs that have been built with debugging support.

The DBUG package can be used by invoking a program with the--debug[=debug_options]or-# [debug_options]option. If you specify the--debugor-#option without adebug_optionsvalue, most MySQL programs use a default value. The server default isd:t:i:o,/tmp/mysqld.traceon Unix andd:t:i:O,\mysqld.trace在Windows上。th的影响is default is:

  • d: Enable output for all debug macros

  • t: Trace function calls and exits

  • i: Add PID to output lines

  • o,/tmp/mysqld.trace,O,\mysqld.trace: Set the debug output file.

Most client programs use a defaultdebug_optionsvalue ofd:t:o,/tmp/program_name.trace, regardless of platform.

Here are some example debug control strings as they might be specified on a shell command line:

--debug=d:t --debug=d:f,main,subr1:F:L:t,20 --debug=d,input,output,files:n --debug=d:t:i:O,\\mysqld.trace

Formysqld,也有可能改变DBUG设置在runtime by setting thedebugsystem variable. This variable has global and session values:

mysql> SET GLOBAL debug = 'debug_options'; mysql> SET SESSION debug = 'debug_options';

Changing the globaldebugvalue requires privileges sufficient to set global system variables. Changing the sessiondebugvalue requires privileges sufficient to set restricted session system variables. SeeSection 5.1.9.1, “System Variable Privileges”.

Thedebug_optionsvalue is a sequence of colon-separated fields:

field_1:field_2:...:field_N

Each field within the value consists of a mandatory flag character, optionally preceded by a+or-character, and optionally followed by a comma-separated list of modifiers:

[+|-]flag[,modifier,modifier,...,modifier]

The following table describes the permitted flag characters. Unrecognized flag characters are silently ignored.

Flag

Description

d

Enable output from DBUG_XXXmacros for the current state. May be followed by a list of keywords, which enables output only for the DBUG macros with that keyword. An empty list of keywords enables output for all macros.

在MySQL中,常见的调试宏关键词,使基于“增大化现实”技术eenter,exit,error,warning,info, andloop.

D

Delay after each debugger output line. The argument is the delay, in tenths of seconds, subject to machine capabilities. For example,D,20specifies a delay of two seconds.

f

Limit debugging, tracing, and profiling to the list of named functions. An empty list enables all functions. The appropriatedortflags must still be given; this flag only limits their actions if they are enabled.

F

Identify the source file name for each line of debug or trace output.

i

Identify the process with the PID or thread ID for each line of debug or trace output.

L

Identify the source file line number for each line of debug or trace output.

n

Print the current function nesting depth for each line of debug or trace output.

N

Number each line of debug output.

o

Redirect the debugger output stream to the specified file. The default output isstderr.

O

Likeo, but the file is really flushed between each write. When needed, the file is closed and reopened between each write.

p

Limit debugger actions to specified processes. A process must be identified with theDBUG_PROCESSmacro and match one in the list for debugger actions to occur.

P

Print the current process name for each line of debug or trace output.

r

When pushing a new state, do not inherit the previous state's function nesting level. Useful when the output is to start at the left margin.

S

Do function_sanity(_file_,_line_)at each debugged function until_sanity()returns something that differs from 0.

t

Enable function call/exit trace lines. May be followed by a list (containing only one modifier) giving a numeric maximum trace level, beyond which no output occurs for either debugging or tracing macros. The default is a compile time option.

The leading+or-character and trailing list of modifiers are used for flag characters such asdorfthat can enable a debug operation for all applicable modifiers or just some of them:

  • With no leading+or-, the flag value is set to exactly the modifier list as given.

  • With a leading+or-, the modifiers in the list are added to or subtracted from the current modifier list.

The following examples show how this works for thedflag. An emptydlist enabled output for all debug macros. A nonempty list enables output only for the macro keywords in the list.

These statements set thedvalue to the modifier list as given:

mysql> SET debug = 'd'; mysql> SELECT @@debug; +---------+ | @@debug | +---------+ | d | +---------+ mysql> SET debug = 'd,error,warning'; mysql> SELECT @@debug; +-----------------+ | @@debug | +-----------------+ | d,error,warning | +-----------------+

A leading+or-adds to or subtracts from the currentdvalue:

mysql> SET debug = '+d,loop'; mysql> SELECT @@debug; +----------------------+ | @@debug | +----------------------+ | d,error,warning,loop | +----------------------+ mysql> SET debug = '-d,error,loop'; mysql> SELECT @@debug; +-----------+ | @@debug | +-----------+ | d,warning | +-----------+

Adding toall macros enabledresults in no change:

mysql> SET debug = 'd'; mysql> SELECT @@debug; +---------+ | @@debug | +---------+ | d | +---------+ mysql> SET debug = '+d,loop'; mysql> SELECT @@debug; +---------+ | @@debug | +---------+ | d | +---------+

Disabling all enabled macros disables thedflag entirely:

mysql> SET debug = 'd,error,loop'; mysql> SELECT @@debug; +--------------+ | @@debug | +--------------+ | d,error,loop | +--------------+ mysql> SET debug = '-d,error,loop'; mysql> SELECT @@debug; +---------+ | @@debug | +---------+ | | +---------+