免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 13560 | 回复: 10
打印 上一主题 下一主题

我输入了“step”,gdb不会进入函数内部去调试 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-06-19 22:10 |只看该作者 |倒序浏览
I typed "step", but gdb did not step into the specified function.
我输入了“step”,gdb不会进入函数内部去调试
the code is:


  1. #include "file.h"
  2. #include "WordAnalyze.h"
  3. #include "OperatorPriorAnalyze.h"
  4. #include <cstring>
  5. #include <iostream>

  6. using namespace std;

  7. int main(int argc, char** argv) {
  8.   unsigned int size;
  9.   char *mem;
  10.   char* line;
  11.   char tc[100];
  12.   file f1;
  13.   OperatorPriorAnalyze operator_analyze;
  14.   WordAnalyze w1;
  15.   size = f1.readfile("./test.txt", &mem );
  16.   w1.setSource(mem);
  17.   w1.setSize(size);
  18.   while( !w1.atEnd() ){
  19. unsigned int i = w1.getLineSize();
  20. line = w1.getLine(); //gdb能进入getLine()函数内部
  21. operator_analyze.setSize(i); //但gdb不会进入getSize()内部
  22. operator_analyze.setSource(line); //同样不会进入
  23. unsigned int k = 0;
  24. while(k<i){
  25. tc[k] = line[k];
  26. k++;
  27. }
  28. tc[k] = '\0';
  29. cout<< tc;
  30.   operator_analyze.restart();
  31. if(operator_analyze.Judge() == 0 )
  32. cout<< "Right!" << endl;
  33. else
  34. cout<< "Wrong! " << operator_analyze.getError() << endl;
  35. delete line;
  36.   }
  37.   return 0;
  38. }
复制代码
键入“step”,好像gdb不会进入 "operator_analyze"类内部的函数,能进入其它的函数。
Can anyone explain to me?
Thanks !

论坛徽章:
0
2 [报告]
发表于 2010-06-20 11:19 |只看该作者
编译的时候需要加上-g 选项..

论坛徽章:
0
3 [报告]
发表于 2010-06-20 12:28 |只看该作者
没细看你的代码,应为不知道你要干什么。

另外你可以按照楼上的试看,-g选项生成调试信息。

论坛徽章:
0
4 [报告]
发表于 2010-06-20 14:33 |只看该作者
所有的源文件都加了-g选项,如果是键入“stepi”,能进入函数,但健入“step”和键入“next”的效果一样,仅仅是执行并跳过函数,而不会进入函数体内,为什么?

论坛徽章:
0
5 [报告]
发表于 2010-06-20 14:37 |只看该作者
operator_analyze.setSize(i);
这个函数的实现呢?-g了没有?

论坛徽章:
2
摩羯座
日期:2013-10-10 14:29:04天蝎座
日期:2014-01-03 09:14:49
6 [报告]
发表于 2010-06-20 18:52 |只看该作者
-g -O0

论坛徽章:
1
双子座
日期:2015-01-04 14:25:06
7 [报告]
发表于 2010-06-21 17:24 |只看该作者
I typed "step", but gdb did not step into the specified function.
我输入了“step”,gdb不会进入函数 ...
915086731 发表于 2010-06-19 22:10

OperatorPriorAnalyze是别的库里的?

论坛徽章:
0
8 [报告]
发表于 2010-06-21 23:15 |只看该作者
没有调试信息的函数默认不跟进,可以设置 set step-mode on 强插进去

论坛徽章:
0
9 [报告]
发表于 2010-06-22 02:33 |只看该作者
没有调试信息可以用汇编调试,就能跟进去了。用命令stepi 或者 si

论坛徽章:
0
10 [报告]
发表于 2010-06-22 09:59 |只看该作者
step进入函数,这是肯定的,不能进入肯定是自身原因。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP