当前位置: 首页 > news >正文

04 dnsmasq 的环境搭建

前言

这里介绍一下 dnsmasq 的调试环境的搭建 

这是一种比较常见的开远的 dns 服务器 

git 仓库在 git://thekelleys.org.uk/dnsmasq.git

 

 

dnsmasq 的编译

首先是 clone 代码, git clone git://thekelleys.org.uk/dnsmasq.git

然后是开始编译 dnsmasq

最顶层的目录结构如下 

drwxr-xr-x  9 root root 4.0K Sep  4 02:19 ./
drwxr-xr-x  3 root root 4.0K Sep  4 02:19 ../
-rwxrwxrwx  1 root root   79 Sep  1 02:01 Android.mk*
drwxrwxrwx  2 root root 4.0K Sep  1 02:01 bld/
-rwxrwxrwx  1 root root 118K Sep  1 02:01 CHANGELOG*
-rwxrwxrwx  1 root root 105K Sep  1 02:01 CHANGELOG.archive*
drwxrwxrwx 23 root root 4.0K Sep  1 02:01 contrib/
-rwxrwxrwx  1 root root  18K Sep  1 02:01 COPYING*
-rwxrwxrwx  1 root root  35K Sep  1 02:01 COPYING-v3*
drwxrwxrwx  2 root root 4.0K Sep  1 02:01 dbus/
-rwxrwxrwx  1 root root  28K Sep  1 02:01 dnsmasq.conf.example*
-rwxrwxrwx  1 root root 5.8K Sep  1 02:01 doc.html*
-rwxrwxrwx  1 root root  28K Sep  1 02:01 FAQ*
-rwxrwxrwx  1 root root   22 Sep  1 02:01 .gitattributes*
-rwxrwxrwx  1 root root  277 Sep  1 02:01 .gitignore*
drwxrwxrwx  2 root root 4.0K Sep  1 02:01 logo/
-rwxrwxrwx  1 root root 7.7K Sep  4 02:18 Makefile*
drwxrwxrwx  4 root root 4.0K Sep  1 02:01 man/
drwxrwxrwx  2 root root 4.0K Sep  1 02:01 po/
drwxrwxrwx  2 root root 4.0K Sep  4 02:18 src/
-rwxrwxrwx  1 root root  310 Sep  1 02:01 trust-anchors.conf*
-rwxrwxrwx  1 root root   13 Sep  1 02:01 VERSION*

 

调试需要去掉 gcc 的优化, 以及增加调试信息, 更新 Makefile 

将 CFLAGS 的值配置为 “-Wall -O0 -g”

然后使用 make 进行编译 

root@ubuntu:~/docker/nginx/nginx/html/dns# make clean
rm -f src/*.mo src/*.pot
rm -f src/.copts_* src/*.o src/dnsmasq.a src/dnsmasq
rm -f src/dnsmasq_baseline
rm -f core */core
rm -f *~ contrib/*/*~ */*~
root@ubuntu:~/docker/nginx/nginx/html/dns# make
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/get-version: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
/bin/sh: 1: /root/docker/nginx/nginx/html/dns/bld/pkg-wrapper: not found
make[1]: Entering directory '/root/docker/nginx/nginx/html/dns/src'
cc -Wall -O0 -g   -DVERSION='""'             -c cache.c
cc -Wall -O0 -g   -DVERSION='""'             -c rfc1035.c
cc -Wall -O0 -g   -DVERSION='""'             -c util.c
cc -Wall -O0 -g   -DVERSION='""'             -c option.c
cc -Wall -O0 -g   -DVERSION='""'             -c forward.c
cc -Wall -O0 -g   -DVERSION='""'             -c network.c
cc -Wall -O0 -g   -DVERSION='""'             -c dnsmasq.c
cc -Wall -O0 -g   -DVERSION='""'             -c dhcp.c
cc -Wall -O0 -g   -DVERSION='""'             -c lease.c
cc -Wall -O0 -g   -DVERSION='""'             -c rfc2131.c
cc -Wall -O0 -g   -DVERSION='""'             -c netlink.c
cc -Wall -O0 -g   -DVERSION='""'             -c dbus.c
cc -Wall -O0 -g   -DVERSION='""'             -c bpf.c
cc -Wall -O0 -g   -DVERSION='""'             -c helper.c
cc -Wall -O0 -g   -DVERSION='""'             -c tftp.c
cc -Wall -O0 -g   -DVERSION='""'             -c log.c
cc -Wall -O0 -g   -DVERSION='""'             -c conntrack.c
cc -Wall -O0 -g   -DVERSION='""'             -c dhcp6.c
cc -Wall -O0 -g   -DVERSION='""'             -c rfc3315.c
cc -Wall -O0 -g   -DVERSION='""'             -c dhcp-common.c
cc -Wall -O0 -g   -DVERSION='""'             -c outpacket.c
cc -Wall -O0 -g   -DVERSION='""'             -c radv.c
cc -Wall -O0 -g   -DVERSION='""'             -c slaac.c
cc -Wall -O0 -g   -DVERSION='""'             -c auth.c
cc -Wall -O0 -g   -DVERSION='""'             -c ipset.c
cc -Wall -O0 -g   -DVERSION='""'             -c pattern.c
cc -Wall -O0 -g   -DVERSION='""'             -c domain.c
cc -Wall -O0 -g   -DVERSION='""'             -c dnssec.c
cc -Wall -O0 -g   -DVERSION='""'             -c blockdata.c
cc -Wall -O0 -g   -DVERSION='""'             -c tables.c
cc -Wall -O0 -g   -DVERSION='""'             -c loop.c
cc -Wall -O0 -g   -DVERSION='""'             -c inotify.c
cc -Wall -O0 -g   -DVERSION='""'             -c poll.c
cc -Wall -O0 -g   -DVERSION='""'             -c rrfilter.c
cc -Wall -O0 -g   -DVERSION='""'             -c edns0.c
cc -Wall -O0 -g   -DVERSION='""'             -c arp.c
cc -Wall -O0 -g   -DVERSION='""'             -c crypto.c
cc -Wall -O0 -g   -DVERSION='""'             -c dump.c
cc -Wall -O0 -g   -DVERSION='""'             -c ubus.c
cc -Wall -O0 -g   -DVERSION='""'             -c metrics.c
cc -Wall -O0 -g   -DVERSION='""'             -c hash-questions.c
cc -Wall -O0 -g   -DVERSION='""'             -c domain-match.c
cc -Wall -O0 -g   -DVERSION='""'             -c nftset.c
cc  -o dnsmasq cache.o rfc1035.o util.o option.o forward.o network.o dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o pattern.o domain.o dnssec.o blockdata.o tables.o loop.o inotify.o poll.o rrfilter.o edns0.o arp.o crypto.o dump.o ubus.o metrics.o hash-questions.o domain-match.o nftset.o
make[1]: Leaving directory '/root/docker/nginx/nginx/html/dns/src'

 

然后编译出来的 binary 如下, 其中包含了调试信息 

root@ubuntu:~/docker/nginx/nginx/html/dns# ll -h src/ | grep dnsmasq
-rwxr-xr-x 1 root root 1.1M Sep  4 02:35 dnsmasq*
-rwxrwxrwx 1 root root  62K Sep  1 02:01 dnsmasq.c*
-rwxrwxrwx 1 root root  60K Sep  1 02:01 dnsmasq.h*
-rw-r--r-- 1 root root 112K Sep  4 02:35 dnsmasq.o

 

查看 elf 中的 调试信息如下

root@ubuntu:~/docker/nginx/nginx/html/dns# readelf -a src/dnsmasq | grep debug[28] .debug_aranges    PROGBITS         0000000000000000  00072065[29] .debug_info       PROGBITS         0000000000000000  000727e5[30] .debug_abbrev     PROGBITS         0000000000000000  000e8703[31] .debug_line       PROGBITS         0000000000000000  000ee9d0[32] .debug_str        PROGBITS         0000000000000000  001010b4[33] .debug_ranges     PROGBITS         0000000000000000  00108426

 

 

 clion 中进行调试 

将编译好的整个项目拷贝到 调试机器, 该目录如下, 这里是 dnsmasq 的 binary 

 

然后 clion 中新建 MakeApplication, 配置 Target, 配置 binary, 配置程序参数 

这里为了演示, 配置为 “–version”

 

然后调试如下, 这里是 “--version” 输出的地方的具体的代码, 可以看到 断点停下来了

调试环境搭建完成 

 

 

 

 

 

相关文章:

  • MySQL库操作
  • P25:LSTM实现糖尿病探索与预测
  • 【碎碎念】60秒! 卡牌游戏 60 Seconds! [特殊字符] 桌游版《求生60秒》
  • iOS安全和逆向系列教程 第19篇:ARM64汇编语言基础与逆向分析
  • 【Qt/数据结构 QMap是什么类型的数据结构?】
  • 工业PID算法在温控器的应用与参数说明
  • Windows 远程桌面添加 SSL 证书指南
  • 《B4A安卓开发实战秘籍》
  • 静态库和共享库(动态库)的编译链接
  • SHELL 编程正则表达式
  • NY230NY233美光固态闪存NY237NY246
  • 社区养老模式:现状、困境与破局之道
  • 准确--CentOS 7.9在线安装docker
  • 8.4.1简单选择排序
  • idea maven打包很慢,怎么提速-多线程
  • 中级统计师-经济学基础知识-第二章 企业生产理论
  • ES6+核心特性
  • 电商运营公司排名
  • 挑战杯应用赛道
  • xss注入遇到转义,html编码绕过了解一哈
  • 做网站要到公安局去备案么/seosem是什么职位
  • 网站keyword如何排序/代发关键词包收录
  • 周到的做pc端网站/靠谱的代运营公司
  • wordpress积分内容/seo关键词排名优化是什么
  • 武汉网站建设推广服务/seo优化公司
  • 睢县做网站/如何制作自己的网站教程