Linux 中 gdb 调试 Redis

这月开启实战 gdb 调试 Redis 源码系列,以目前官网上最新的稳定版本 6.2.4 来调式。

首先,下载源码。

wget https://download.redis.io/releases/redis-6.2.4.tar.gz
tar xf redis-6.2.4.tar.gz
cd redis-6.2.4

其次,解压并编译 make CFLAGS="-g -O0",不用 make install。

最后,使用 gdb src/redis-server 进行调试。

# gdb src/redis-server 
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/local/redis-6.2.4/src/redis-server...done.
(gdb) r
Starting program: /usr/local/redis-6.2.4/src/redis-server 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
10988:C 05 Jun 2021 10:34:39.825 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10988:C 05 Jun 2021 10:34:39.825 # Redis version=6.2.4, bits=64, commit=00000000, modified=0, pid=10988, just started
10988:C 05 Jun 2021 10:34:39.825 # Warning: no config file specified, using the default config. In order to specify a config file use /usr/local/redis-6.2.4/src/redis-server /path/to/redis.conf
10988:M 05 Jun 2021 10:34:39.829 * monotonic clock: POSIX clock_gettime
10988:M 05 Jun 2021 10:34:39.830 # Warning: Could not create server TCP listening socket ::*:6379: unable to bind socket, errno: 97
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.2.4 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 10988
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

10988:M 05 Jun 2021 10:34:39.830 # Server initialized
10988:M 05 Jun 2021 10:34:39.830 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
10988:M 05 Jun 2021 10:34:39.830 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo madvise > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled (set to 'madvise' or 'never').
[New Thread 0x7ffff096e700 (LWP 10994)]
[New Thread 0x7fffeff6d700 (LWP 10995)]
[New Thread 0x7fffef56c700 (LWP 10996)]
[New Thread 0x7fffeeb6b700 (LWP 10997)]
10988:M 05 Jun 2021 10:34:39.833 * Ready to accept connections
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值