当前位置:网站首页>How to find out the function calling process of complex code running as soon as possible
How to find out the function calling process of complex code running as soon as possible
2022-07-24 12:09:00 【Be true】

summary
Recently in use freeswitch Test send DTMF Code time , There is a problem with the function call process .
fs There are many modules in itself , There are many and complex callback functions registered , Sometimes I see a log , But I don't know where the originator of the process is .
There are usually several ways to sort out the code call process .
1, Sort out the source code process , The effect is poor when the code is too complex .
2, Print the log in the calling function , The effect is poor when the code is too complex .
3, adopt backtrace Function tracks the current stack , Many changes , Lots of details .
4, gdb debugging , Commands are complex and difficult to remember .
Today, I suddenly thought of a lazy way , It is faster and simpler than the above methods .
Environmental Science
centos7
freeswitch 1.6.19
gcc version 4.8.5
origin
fs The log of is as follows , Simple view , stay dialplan Called in sleep after ,rtp Process start sending DTMF.
EXECUTE sofia/external/[email protected]:5080 sleep(5000)
2022-06-17 14:42:54.890047 [DEBUG] switch_rtp.c:5237 Send start packet for [1] ts=160 dur=160/160/2000 seq=8238 lw=160
however rtp The calling procedures of are too far apart , I haven't seen the source code for a long time, so , Mainly food .
Modify the source code
First find “switch_rtp.c:5237” The location of , Modify the source code , Add a line of assertion judgment .
switch_assert(FALSE);
Back to the fs Compilation and installation .
test
start-up fs, And execute the test command , The log is as follows .
[email protected]> originate {originator_codec=PCMA,origination_caller_id_number=0755110}sofia/external/sip:[email protected]:5080 1001 XML ext_test
…
EXECUTE sofia/external/[email protected]:5080 sleep(5000)
freeswitch: src/switch_rtp.c:5236: do_2833: Assertion `0' failed.
Aborted
Ha , As expected ,fs Program coredump 了
core Stack
stay bin In the directory core file
-rw-------. 1 root root 71778304 Jun 17 15:24 core.14650
Use gdb open core file , And display the stack .
sudo gdb freeswitch core.14650
…
(gdb) bt
#0 0x00007f0b9e371387 in raise () from /lib64/libc.so.6
#1 0x00007f0b9e372a78 in abort () from /lib64/libc.so.6
#2 0x00007f0b9e36a1a6 in __assert_fail_base () from /lib64/libc.so.6
#3 0x00007f0b9e36a252 in __assert_fail () from /lib64/libc.so.6
#4 0x00007f0ba0e8be2a in do_2833 ([email protected]=0x7f0b1c012d98) at src/switch_rtp.c:5236
#5 0x00007f0ba0e8d4fb in rtp_common_read ([email protected]=0x7f0b1c012d98, [email protected]=0x7f0b34040aa4 "", [email protected]=0x7f0b34040ac8, [email protected]=0x7f0b34040ab8, [email protected]=0) at src/switch_rtp.c:7321
#6 0x00007f0ba0e8e59f in switch_rtp_zerocopy_read_frame (rtp_session=0x7f0b1c012d98, [email protected]=0x7f0b34040a60, [email protected]=0) at src/switch_rtp.c:7617
#7 0x00007f0ba0e41990 in switch_core_media_read_frame ([email protected]=0x7f0b3402f3b8, [email protected]=0x7f0b482795d8, [email protected]=0, [email protected]=0, t[email protected]=SWITCH_MEDIA_TYPE_AUDIO) at src/switch_core_media.c:2219
#8 0x00007f0b984f1298 in sofia_read_frame (session=0x7f0b3402f3b8, frame=0x7f0b482795d8, flags=0, stream_id=0) at mod_sofia.c:1044
#9 0x00007f0ba0e2a5d6 in switch_core_session_read_frame ([email protected]=0x7f0b3402f3b8, [email protected]=0x7f0b482795d8, [email protected]=0, [email protected]=0) at src/switch_core_io.c:188
#10 0x00007f0ba0ec426d in switch_ivr_sleep ([email protected]=0x7f0b3402f3b8, [email protected]=5000, [email protected]=SWITCH_TRUE, [email protected]=0x7f0b48279850) at src/switch_ivr.c:294
#11 0x00007f0b7273d5c4 in sleep_function (session=0x7f0b3402f3b8, data=<optimized out>) at mod_dptools.c:2288
#12 0x00007f0ba0e2472b in switch_core_session_exec ([email protected]=0x7f0b3402f3b8, [email protected]=0x1ccfcd8, [email protected]=0x7f0b34053240 "5000") at src/switch_core_session.c:2802
#13 0x00007f0ba0e24cb9 in switch_core_session_execute_application_get_flags ([email protected]=0x7f0b3402f3b8, app=0x7f0b34053238 "sleep", arg=0x7f0b34053240 "5000", [email protected]=0x0) at src/switch_core_session.c:2672
#14 0x00007f0ba0e28ae4 in switch_core_standard_on_execute (session=0x7f0b3402f3b8) at src/switch_core_state_machine.c:353
#15 switch_core_session_run (session=0x7f0b3402f3b8) at src/switch_core_state_machine.c:650
#16 0x00007f0ba0e21f7e in switch_core_session_thread (thread=<optimized out>, obj=0x7f0b3402f3b8) at src/switch_core_session.c:1648
#17 0x00007f0ba0e1dc73 in switch_core_session_thread_pool_worker (thread=0x7f0b3404f340, obj=<optimized out>) at src/switch_core_session.c:1711
#18 0x00007f0ba10d8b10 in dummy_worker (opaque=0x7f0b3404f340) at threadproc/unix/thread.c:151
#19 0x00007f0b9ede5ea5 in start_thread () from /lib64/libpthread.so.0
#20 0x00007f0b9e439b0d in clone () from /lib64/libc.so.6
(gdb)
Click on the tongue , Clear function call process , Take in everything in a glance .
summary
fs There are many modules , Most of the code call chains are long , When it comes to media, the process is more complex and difficult to track .
The sword moves sideways , develop a new method of one 's own .
Empty as usual
Be serious
边栏推荐
- QT notes - realize form adaptation
- L2-011 play with binary tree
- Import the data in MariaDB into columnstore
- [rust] Why do I suggest you learn rust | a preliminary study of rust
- Literature record (part109) -- self representation based unsupervised exemplar selection in a union of subspaces
- Share the typora tool
- Pushgateway installation and Prometheus configuration
- Common formulas and application scenarios of discrete distribution
- leetcode:51. N 皇后
- LogBack & MDC & a simple use
猜你喜欢

JVM visualvm: multi hop fault handling tool

Basic usage of GCC

Do you regret learning it?

Share the typora tool

How to use a third party without obtaining root permission topic: MIUI chapter

NFT digital collection system construction - app development
Learn some programming: anti unemployment "vaccine"

6k+ star, a deep learning code base for Xiaobai! One line of code implements all attention mechanisms!

leetcode:51. N 皇后

Online XML to CSV tool
随机推荐
CCF 1-2 question answering record (1)
Optimization method of "great mathematics for use" -- optimal design of Cascade Reservoir Irrigation
scrapy-redis写项目备忘
Basic usage of GCC
【C和指针第14章】预处理器
Agile? DevOps ?
The art of management - driving software R & D efficiency through leadership
The difference between synchronized and lock locks
Counter attack dark horse: devdbops training, give you the best courses!
Time processing of basic library in go
L2-011 play with binary tree
C进阶——数据的存储
【网络空间安全数学基础第3章】同余
如何将Typora中图片上传到csdn
1184. Distance between bus stops: simple simulation problem
Learn some programming: anti unemployment "vaccine"
一周精彩内容分享(第13期)
Source code analysis sentry user behavior record implementation process
L1-059 ring stupid bell
Is there any charge for PDF processing? impossible!