mysql debug_Mysql的Debug模式实现

| error: message: 2003/HY000 (Can't connect to MySQL server on 'localhost' (0))

后面的数字是行号。从这个文件就可以追踪程序的执行啦!

好牛逼啊!我们不禁感叹。之余,学习了一下这个调试模式的具体实现:

在 CMakeList.txt 中,有这么一段代码:

[plain]

IF(WITH_DEBUG)

SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING ${BUILDTYPE_DOCSTRING} FORCE)

[plain]

IF(NOT CMAKE_BUILD_TYPE

AND NOT CMAKE_GENERATOR MATCHES "Visual Studio"

AND NOT CMAKE_GENERATOR MATCHES "Xcode")

# This is the case of no CMAKE_BUILD_TYPE choosen, typical for VS and Xcode

# or if custom C flags are set. In VS and Xcode for non-Debug configurations

# DBUG_OFF is already correctly set. Use DBUG_OFF for Makefile based projects

# without build type too, unless user specifically requests DBUG.

IF(NOT CMAKE_C_FLAGS MATCHES "-DDBUG_ON")

ADD_DEFINITIONS(-DDBUG_OFF)

ENDIF()

ENDIF()

如果没有设置 CMAKE_BUILD_TYPE ,那么就会执行下面一段代码。如果这时候也没有设置一个名为-DDBUG_ON的CFLAGS的环境变量的话,就会增加一个CFLAGS:-DDBUG_OFF.

之后,当编译器编译的时候,根据编译器的参数增加的宏来决定 怎么定义 DBUG_ENTER 之类的函数是空代码,还是实际的报错代码。

[cpp]

/*

* These macros provide a user interface into functions in the

* dbug runtime support library. They isolate users from changes

* in the MACROS and/or runtime support.

*

* The symbols "__LINE__" and "__FILE__" are expanded by the

* preprocessor to the current source file line number and file

* name respectively.

*

* WARNING --- Because the DBUG_ENTER macro allocates space on

* the user function's stack, it must precede any executable

* statements in the user function.

*

*/

[1] [2]

test.jsp?url=http%3A%2F%2Fwww.chinaitlab.com%2Fcms%2Fimages%2Flogo14.gif&refer=http%3A%2F%2FLinux.chinaitlab.com%2FMYSQL%2F939840.html

f68f2add0b68e4f9810432fce46917b7.png

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值