当前位置: 首页 > 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” 输出的地方的具体的代码, 可以看到 断点停下来了

调试环境搭建完成 

 

 

 

 

 

http://www.xdnf.cn/news/1027459.html

相关文章:

  • 【MIPI屏幕调试记录】个人记录用
  • Python+requests+pytest接口自动化测试框架的搭建
  • 专项提升-分析dump堆文件 服务器内存占用排查
  • 在死胡同里 做加法是什么意思?
  • 坚持做一件事情和好奇做一件事,本质区别和思考
  • 开发者视角:一键拉起功能解析
  • XAttention 计算步骤详解及示例
  • 【Qt】Qt控件
  • 【组件】纯html+css实现图片预览+切换图片的功能
  • 189. 轮转数组
  • Linux --基础IO
  • 大模型的开发应用(十):对话风格微调项目(上):数据工程与模型选型
  • 安卓开发常用框架与库详解
  • 发现 Kotlin MultiPlatform 的一点小变化
  • 技术干货 | 注塑件电磁网格划分指南(HyperMesh+SimLab)
  • BIO网络通信基础(TCP协议)
  • Dock最新方法
  • 第二十三章 23.Wireless LAN(CCNA)
  • Linux 文件系统核心概念
  • Atlassian AI(Rovo)在不同场景中的实际应用:ITSM、HR服务、需求管理、配置管理
  • Git Switch 与 Git Restore 详解
  • yum查看历史操作
  • 高并发场景下接口安全实现方案:全方位构建防护体系
  • 重复的囚徒困境博弈中应该如何决策?--阿克塞尔罗德竞赛(Axelrod‘s Tournament)实验
  • Spring注解的深层含义
  • 人工智能 倒底是 智能 还是 智障?
  • OmoFun动漫官网,动漫共和国最新入口|网页版
  • java集合篇(七) ---- ArrayList 类
  • BeckHoff_FB --> F_SEQ_X3_TrigJob 函数
  • TCP客户端进程分割输入输出