5.9.4 The DBUG PackageDBUG软件包

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. MySQL服务器和大多数MySQL客户端都是用Fred Fish最初创建的DBUG包编译的。当您配置MySQL进行调试时,此包可以获取程序正在进行的操作的跟踪文件。See Section 5.9.1.2, “Creating Trace Files”.请参阅第5.9.1.2节,“创建跟踪文件”

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.本节总结了可以在命令行上的调试选项中为已使用调试支持构建的MySQL程序指定的参数值。

The DBUG package can be used by invoking a program with the --debug[=debug_options] or -# [debug_options] option. DBUG包可以通过调用带有--debug[=debug_options]-# [debug_objects]选项的程序来使用。If you specify the --debug or -# option without a debug_options value, most MySQL programs use a default value. 如果指定--debug-#选项而不指定debug_options值,则大多数MySQL程序使用默认值。The server default is d:t:i:o,/tmp/mysqld.trace on Unix and d:t:i:O,\mysqld.trace on Windows. The effect of this default is:服务器默认值在Unix上为d:t:i:o,/tmp/mysqld.trace,在Windows上为d:t:i:O,\mysqld.trace。此默认值的效果是:

Most client programs use a default debug_options value of d:t:o,/tmp/program_name.trace, regardless of platform.大多数客户端程序使用默认的debug_optionsd:t:o,/tmp/program_name.trace,而不管平台如何。

Here are some example debug control strings as they might be specified on a shell command line:以下是一些可能在shell命令行上指定的调试控制字符串示例:

--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

For mysqld, it is also possible to change DBUG settings at runtime by setting the debug system variable. This variable has global and session values:对于mysqld,还可以通过设置debug系统变量在运行时更改DBUG设置。此变量具有全局值和会话值:

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

Changing the global debug value requires privileges sufficient to set global system variables. 更改全局debug值需要足够的权限来设置全局系统变量。Changing the session debug value requires privileges sufficient to set restricted session system variables. 更改会话debug值需要足够的权限来设置受限的会话系统变量。See Section 5.1.9.1, “System Variable Privileges”.请参阅第5.1.9.1节,“系统变量权限”

The debug_options value is a sequence of colon-separated fields:debug_options值是一系列用冒号分隔的字段:

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_XXX macros 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.启用DBUG_XXX宏的当前状态输出。后面可能是一个关键字列表,这仅允许具有该关键字的DBUG宏输出。一个空的关键字列表可以为所有宏提供输出。

In MySQL, common debug macro keywords to enable are enter, exit, error, warning, info, and loop.在MySQL中,要启用的常见调试宏关键字是enterexiterrorwarninginfoloop

D

Delay after each debugger output line. The argument is the delay, in tenths of seconds, subject to machine capabilities. For example, D,20 specifies a delay of two seconds.每个调试器输出行后的延迟。争论的焦点是延迟,以十分之一秒为单位,取决于机器的能力。例如,D,20指定了两秒的延迟。

f

Limit debugging, tracing, and profiling to the list of named functions. An empty list enables all functions. The appropriate d or t flags must still be given; this flag only limits their actions if they are enabled.将调试、跟踪和分析限制在命名函数列表中。空列表启用所有功能。仍然必须给出适当的dt标志;此标志仅在启用时限制其操作

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.为每一行调试或跟踪输出使用PID或线程ID标识进程。

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 is stderr.将调试器输出流重定向到指定文件。默认输出为stderr

O

Like o, but the file is really flushed between each write. When needed, the file is closed and reopened between each write.类似于o,但文件在每次写入之间都会被刷新。需要时,在每次写入之间关闭并重新打开文件。

p

Limit debugger actions to specified processes. A process must be identified with the DBUG_PROCESS macro and match one in the list for debugger actions to occur.将调试器操作限制到指定进程。必须使用DBUG_PROCESS宏标识一个进程,并将其与列表中的一个相匹配,才能执行调试器操作。

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.在每个调试的函数上执行函数_sanity(_file_,_line_),直到_sanity返回与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 as d or f that can enable a debug operation for all applicable modifiers or just some of them:前导+-字符和尾随修饰符列表用于标记字符,如df,可以对所有适用的修饰符或仅对其中一些修饰符启用调试操作:

The following examples show how this works for the d flag. An empty d list enabled output for all debug macros. A nonempty list enables output only for the macro keywords in the list.以下示例显示了d标志的工作原理。为所有调试宏启用了空d列表输出。非空列表仅允许输出列表中的宏关键字。

These statements set the d value to the modifier list as given:这些语句将d值设置为给定的修饰符列表:

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 current d value:前导+-对当前d值进行加减运算:

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 to all macros enabled results 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 the d flag entirely:禁用所有启用的宏将完全禁用d标志:

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

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