使用什么調試swoole程序

使用什么調試swoole程序

使用什么調試swoole程序

可以使用GDB調試swoole程序。gdb是gnu debugger的縮寫,是編程調試工具

gdb的功能:

1. 啟動程序,可以按照用戶自定義的要求隨心所欲的運行程序。

2. 可讓被調試的程序在用戶所指定的調試斷點處停住(斷點可以是條件表達式)。

3. 當程序停住時,可以檢查此時程序中所發生的事。比如,可以打印變量的值。

4. 動態改變變量程序的執行環境。

?推薦學習: swoole教程

使用gdb調試swoole的方法:

進入gdb

gdb?php?test.php

gdbinit

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

設置斷點

例如co::sleep函數

(gdb)?b?zim_swoole_coroutine_util_sleep

打印當前進展的所有協程和狀態

(gdb)?co_list? coroutine?1?SW_CORO_YIELD coroutine?2?SW_CORO_RUNNING

打印當前運行時協程的調用

(gdb)?co_bt? coroutine?cid:[2] [0x7ffff148a100]?SwooleCoroutine->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

打印指定協程id的調用棧

(gdb)?co_bt?1 [0x7ffff1487100]?SwooleCoroutine->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

打印串聯協程的狀態

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

以上就是使用什么調試

? 版權聲明
THE END
喜歡就支持一下吧
點贊12 分享