首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

求问gdb远程调试时奇怪的跳转有关问题

2012-05-10 
求问gdb远程调试时奇怪的跳转问题在ubuntu上远程调试android上的可执行程序。用next进行单步执行的时候,执

求问gdb远程调试时奇怪的跳转问题
在ubuntu上远程调试android上的可执行程序。用next进行单步执行的时候,执行的代码总是会诡异的跳回去(没有循环),不知为何?
下面给出一个调试流程,谢谢大家!!

ubuntu@ubuntu:~$ gdb /home/ubuntu/android-x86/out/target/product/generic_x86/system/bin/getaddrinfo
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 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 "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/ubuntu/android-x86/out/target/product/generic_x86/system/bin/getaddrinfo...done.
(gdb) target remote 210.25.132.164:1235
Remote debugging using 210.25.132.164:1235
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0xb0001000 in ?? ()
(gdb) tb main //调试开始
Temporary breakpoint 1 at 0x804c0f0: file bionic/libc/netbsd/net/getaddrinfo.c, line 2536.
(gdb) c
Continuing.
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
Error while mapping shared library sections:
libc.so: No such file or directory.

Temporary breakpoint 1, main (argc=Cannot access memory at address 0x1
) at bionic/libc/netbsd/net/getaddrinfo.c:2536
2536{
(gdb) n
main (argc=1, argv=0xbf8ae124) at bionic/libc/netbsd/net/getaddrinfo.c:2539
2539 memset(&hints, 0, sizeof(hints));
(gdb) n
2536{ //重复执行若干次
(gdb) n
2539 memset(&hints, 0, sizeof(hints));
(gdb) n
2536{
(gdb) n
2539 memset(&hints, 0, sizeof(hints));
(gdb) n
2536{
(gdb) n
2537 struct addrinfo hints, *addressList = NULL, *addrInfo;
(gdb) n
2539 memset(&hints, 0, sizeof(hints));
(gdb) n
2540 hints.ai_family = AF_UNSPEC;//zq
(gdb) n
2541 hints.ai_flags = AI_CANONNAME;//zq
(gdb) n
2543 hints.ai_socktype = SOCK_STREAM;
(gdb) n
2545printf("argv[1] = %s\n", argv[1]);
(gdb) n
2546 int result = getaddrinfo(argv[1], NULL, &hints, &addressList);
(gdb) step
getaddrinfo (hostname=0x0, servname=0x0, hints=0xbf8ae0a4, res=0xbf8ae0c4) at bionic/libc/netbsd/net/getaddrinfo.c:669
669printf("1hostname = %s\n", hostname);
(gdb) set hostname = "www.baidu.com"
(gdb) n
654{
(gdb) n
669printf("1hostname = %s\n", hostname);
(gdb) n
672memset(&sentinel, 0, sizeof(sentinel));
(gdb) n
684if (hostname == NULL && servname == NULL)
(gdb) n
675pai->ai_flags = 0;
(gdb) n
676pai->ai_family = PF_UNSPEC;
(gdb) n
684if (hostname == NULL && servname == NULL)
(gdb) n
677pai->ai_socktype = ANY;
(gdb) n
678pai->ai_protocol = ANY;
(gdb) n
679pai->ai_addrlen = 0;
(gdb) n
680pai->ai_canonname = NULL;
(gdb) n
681pai->ai_addr = NULL;
(gdb) n
682pai->ai_next = NULL;
(gdb) n
684if (hostname == NULL && servname == NULL)
(gdb) n
686if (hints) {


[解决办法]
关注,你在ubuntu远程通过数据线调试android,终端内只要正常执行程序即可?
[解决办法]
诡异的问题最终都是因为代码有问题..
[解决办法]
程序编译时,有没有开启优化?优化后,源代码级调试时,乱跳很正常。

热点排行