当前位置:   article > 正文

Linux 中 gdb 调试 Redis_linux gdb调试 redis 源码

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
  • 1
  • 2
  • 3

其次,解压并编译 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号