From 71c9732bffcc2b7d29b7e19b57b07a744d9b3ece Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 31 Oct 2020 19:30:56 +0800 Subject: [PATCH] Support gdb/srs.py to stat coroutines. 4.0.44 --- README.md | 1 + trunk/gdb/srs.py | 30 ++++++++++++++++++++++++++++ trunk/src/core/srs_core_version4.hpp | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 trunk/gdb/srs.py diff --git a/README.md b/README.md index dae637c09..7e61d6419 100755 --- a/README.md +++ b/README.md @@ -155,6 +155,7 @@ For previous versions, please read: ## V4 changes +* v4.0, 2020-10-31, Support gdb/srs.py to stat coroutines. 4.0.44 * v4.0, 2020-09-19, RTC: Extract resource manager. Use any UDP packet to keep alive. 4.0.43 * v4.0, 2020-09-09, RTC: Refine NACK RTT and efficiency. 4.0.42 * v4.0, 2020-09-08, Refine PLI/NACK/DTLS logs. 4.0.41 diff --git a/trunk/gdb/srs.py b/trunk/gdb/srs.py new file mode 100644 index 000000000..9bb71f597 --- /dev/null +++ b/trunk/gdb/srs.py @@ -0,0 +1,30 @@ +import gdb, sys, traceback; + +class NnCouroutines(gdb.Command): + def __init__(self): + super(NnCouroutines, self).__init__('nn_coroutines', gdb.COMMAND_DATA) + + def invoke(self, arg, from_tty): + try: + if len(arg) > 0: + prev = pthis = arg + print('start from %s'%(arg)) + else: + prev = pthis = gdb.parse_and_eval('&_st_this_thread->tlink').__str__() + print('start from &_st_this_thread->tlink') + print('first is: %s'%(pthis)) + nn_coroutines, pnext = 1, pthis + while True: + v = gdb.parse_and_eval('((_st_clist_t*)%s)->next'%pnext) + prev = pnext = str(v.__str__()).split(' ')[0] + if pnext == pthis: + break + nn_coroutines += 1 + if len(arg) > 0 or (nn_coroutines%1000) == 0: + print('next is %s, total %s'%(pnext, nn_coroutines)) + print('total coroutines: %s'%(nn_coroutines)) + except: + print('Error: prev=%s, this=%s, next=%s, v=%s'%(prev, pthis, pnext, v)) + traceback.print_exc() + +NnCouroutines() \ No newline at end of file diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index d175950fb..c736bd197 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION4_HPP #define SRS_CORE_VERSION4_HPP -#define SRS_VERSION4_REVISION 43 +#define SRS_VERSION4_REVISION 44 #endif