当前位置: 技术问答>linux和unix
gdb调试出现No such file or directory错误 百思不得其解 急求仁兄帮忙!
来源: 互联网 发布时间:2016-02-24
本文导语: 问题是这样的: [color=#800000]在编译程序时出现了错误,本人初学想用gdb调试,结果发现No such file or directory,苦恼中。。。 望接触的同仁指点,谢谢![/color] [caoj...
问题是这样的:
[color=#800000]在编译程序时出现了错误,本人初学想用gdb调试,结果发现No such file or directory,苦恼中。。。 望接触的同仁指点,谢谢![/color]
[caojian@localhost ~]$ gcc arp.c -lnet -lpcap -o arp -g
arp.c: 在函数 ‘main’ 中:
arp.c:29: 错误:‘packet’ 重声明为没有外部链接
arp.c:20: 错误:‘packet’ 的上一个声明在此
arp.c:78: 警告:赋值丢弃了指针目标类型的限定
arp.c:127: 警告:传递参数 3 (属于 ‘libnet_adv_cull_packet’)时在不兼容的指针类型间转换
[caojian@localhost ~]$ gdb arp
GNU gdb Red Hat Linux (6.6-8.fc7rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
arp: No such file or directory.
(gdb)
望解答!
[color=#800000]在编译程序时出现了错误,本人初学想用gdb调试,结果发现No such file or directory,苦恼中。。。 望接触的同仁指点,谢谢![/color]
[caojian@localhost ~]$ gcc arp.c -lnet -lpcap -o arp -g
arp.c: 在函数 ‘main’ 中:
arp.c:29: 错误:‘packet’ 重声明为没有外部链接
arp.c:20: 错误:‘packet’ 的上一个声明在此
arp.c:78: 警告:赋值丢弃了指针目标类型的限定
arp.c:127: 警告:传递参数 3 (属于 ‘libnet_adv_cull_packet’)时在不兼容的指针类型间转换
[caojian@localhost ~]$ gdb arp
GNU gdb Red Hat Linux (6.6-8.fc7rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
arp: No such file or directory.
(gdb)
望解答!
|
居然google不到mac_strtochar6的实现,只好自己写了一个。
Makefile:
arp.c:
Makefile:
#
# Makefile for arp.c
# Please modify CPPFLAGS and LDFLAGS according your system
#
CPPFLAGS += -I/usr/local/include/libnet11
LDFLAGS += -L/usr/local/lib -L/usr/local/lib/libnet11
LDLIBS += -lnet -lpcap
all: arp
arp.c:
/* tell destination host with ip 'dstip' that the host with request ip'
* srcip' is with mac address srcmac
* author: white cpf 2003.5.15.
* compile: gcc arp.c -lnet -lpcap -o arp
*/
/*
* from http://www.ibm.com/developerworks/cn/linux/l-tcpip/index.html
* 2007-12-09 mymtom modified
* add function definition: mac_strtochar6 according to
* /usr/src/lib/libc/net/ether_addr.c
* from FreeBSD 6.3-PRERELEASE
*/
#include
#include
#include
void usage(char * exename){
printf(" tell dstip with dstmac that srcip is at srcmac. n");
printf(" usage: %s -d dstip -s srcip -D dstmac -S srcmac n",
exename);
return ;
}
/* 程序输入:来自命令行参数 */
u_char ip_src[4],ip_dst[4];
u_char enet_src[6],enet_dst[6];
/* 将字符串格式的MAC地址转换为6字节类型 */
extern int mac_strtochar6(u_char * enet,char * macstr);
/* 命令行参数处理函数 */
int get_cmdline(int argc,char *argv[]);
int main(int argc, char *argv[]){
libnet_t *l;
libnet_ptag_t t;
u_char *packet;
u_long packet_s;
char device[5]="eth0";
char errbuf[LIBNET_ERRBUF_SIZE];
char filter_str[100]="";
struct bpf_program fp; /* hold compiled program */
char *dev;
pcap_t* descr;
struct pcap_pkthdr hdr; /* pcap.h */
/* u_char * packet; */ /* XXX it's a bug??? */
bpf_u_int32 maskp; /* subnet mask */
bpf_u_int32 netp; /* ip */
int promisc=0; /* set to promisc mode? */
int pcap_time_out=5;
int c, ret;
u_long i;
if(get_cmdline(argc,argv)
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。