Operation steps
1. Download source code
2. Install
./configure --prefix = 指定安装路径 --with-config-file-path = 指定配置文件读取路径 --with-iconv = 指定 iconv 安装的路径 --enable-debug make && make install
3. Use clion to create project
4. Modify the automatically generated CMakeLists.txt file. Note that the source code path should be adjusted according to the situation.
cmake_minimum_required(VERSION 3.14) project(php_7_2_4) set(CMAKE_CXX_STANDARD 14) set(PHP_SOURCE /usr/local/src/php-7.2.4) include_directories(${PHP_SOURCE}/main) include_directories(${PHP_SOURCE}/Zend) include_directories(${PHP_SOURCE}/sapi) include_directories(${PHP_SOURCE}/pear) include_directories(${PHP_SOURCE}/TSRM) include_directories(${PHP_SOURCE}) add_custom_target(makefile COMMAND make && make install WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
5. Configure running parameters
6. Find the main function in the sapi/cli/php_cli.c file and break the point
7. Click debug and then you can debug
Problems encountered
iconv is not installed, and after installation it prompts "ld: symbol (s) not found for architecture x86_64"
Solution :
Edit the Makefile under the project root path, modify the EXTRA_LIBS variable, delete - liconv, and add /usr/local/opt/libiconv/lib/libiconv.dylib
The above is the detailed content of Use clion to debug PHP kernel source code on Mac. For more information, please follow other related articles on the PHP Chinese website!