search
HomePHP FrameworkSwooleWhat to use to debug swoole program

What to use to debug swoole program

Feb 12, 2020 pm 02:01 PM
swooletooldebug

What to use to debug swoole program

What to use to debug the swoole program

You can use GDB to debug the swoole program. gdb is the abbreviation of GNU debugger, which is a programming debugging tool.

Function of gdb:

1. Start the program and run the program as you like according to user-defined requirements.

2. The debugged program can be stopped at the debugging breakpoint specified by the user (the breakpoint can be a conditional expression).

3. When the program stops, you can check what happened in the program at this time. For example, you can print the value of a variable.

4. Dynamically change the execution environment of the variable program.

Recommended learning: swoole tutorial

How to use gdb to debug swoole:

Enter gdb

gdb php test.php

gdbinit

(gdb) source /path/to/swoole-src/gdbinit

Set breakpoints

For example, co::sleep function

(gdb) b zim_swoole_coroutine_util_sleep

Print all coroutines and status of the current progress

(gdb) co_list 
coroutine 1 SW_CORO_YIELD
coroutine 2 SW_CORO_RUNNING

Print the current run The call stack of the current coroutine

(gdb) co_bt 
coroutine cid:[2]
[0x7ffff148a100] Swoole\Coroutine->sleep(0.500000) [internal function]
[0x7ffff148a0a0] {closure}() /home/shiguangqi/php/swoole-src/examples/coroutine/exception/test.php:7 
[0x7ffff141e0c0] go(object[0x7ffff141e110]) [internal function]
[0x7ffff141e030] (main) /home/shiguangqi/php/swoole-src/examples/coroutine/exception/test.php:10

Print the call stack of the specified coroutine ID

(gdb) co_bt 1
[0x7ffff1487100] Swoole\Coroutine->sleep(0.500000) [internal function]
[0x7ffff14870a0] {closure}() /home/shiguangqi/php/swoole-src/examples/coroutine/exception/test.php:3 
[0x7ffff141e0c0] go(object[0x7ffff141e110]) [internal function]
[0x7ffff141e030] (main) /home/shiguangqi/php/swoole-src/examples/coroutine/exception/test.php:10

Print the status of the serial coroutine

(gdb) co_status 
     stack_size: 2097152
     call_stack_size: 1
     active: 1
     coro_num: 2
     max_coro_num: 3000
     peak_coro_num: 2

The above is the detailed content of What to use to debug swoole program. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.