最近,在debug core的时候,发现p 变量的时候提示“No symbol "*" in current context”,我们的代码使用-g编译的,经查有可能是下列几个原因或解决方法:

  1. 使用add-symbol-file将foo.o文件的符号添加至二进制文件中,如下:
    (gdb) add-symbol-file XXXX.o     #提示The address where xxx has been loaded is missing,所以应该还有其他原因
  2. gdb的版本低于gcc的版本,环境中使用的gcc是4.8.5,gdb是7.6.2,gdb发布之间早于gcc,所以升级gdb到7.10,兼容性可参考https://www.cnblogs.com/zhjh256/p/9367852.html

注:make gdb的时候可能会出现/gdb-7.10/missing: line 81: makeinfo: command not found,makeinfo在textinfo中

yum install texinfo

可能会提示zlib 1.2.3.3缺少,baidu搜下应该就可以解决。

编译7.10过程中,出现异常如下:

ser-unix.c:119:43: warning: 'struct hardwire_ttystate' declared inside parameter list [enabled by default]
get_tty_state (struct serial *scb, struct hardwire_ttystate *state)
^
ser-unix.c:119:1: error: conflicting types for 'get_tty_state'
get_tty_state (struct serial *scb, struct hardwire_ttystate *state)
^
ser-unix.c:88:12: note: previous declaration of 'get_tty_state' was here
static int get_tty_state (struct serial *scb,
^
ser-unix.c: In function 'get_tty_state':
ser-unix.c:146:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
ser-unix.c: At top level:
ser-unix.c:149:43: warning: 'struct hardwire_ttystate' declared inside parameter list [enabled by default]
set_tty_state (struct serial *scb, struct hardwire_ttystate *state)
^
ser-unix.c:149:1: error: conflicting types for 'set_tty_state'
set_tty_state (struct serial *scb, struct hardwire_ttystate *state)
^
ser-unix.c:90:12: note: previous declaration of 'set_tty_state' was here
static int set_tty_state (struct serial *scb,
^
ser-unix.c: In function 'set_tty_state':
ser-unix.c:176:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
ser-unix.c: In function 'hardwire_get_tty_state':
ser-unix.c:183:56: error: dereferencing pointer to incomplete type
state = (struct hardwire_ttystate *) xmalloc (sizeof *state);
^
ser-unix.c:185:3: warning: passing argument 2 of 'get_tty_state' from incompatible pointer type [enabled by default]
if (get_tty_state (scb, state))
^
ser-unix.c:119:1: note: expected 'struct hardwire_ttystate *' but argument is of type 'struct hardwire_ttystate *'
get_tty_state (struct serial *scb, struct hardwire_ttystate *state)
^
ser-unix.c: In function 'hardwire_copy_tty_state':
ser-unix.c:199:56: error: dereferencing pointer to incomplete type
state = (struct hardwire_ttystate *) xmalloc (sizeof *state);
^
ser-unix.c:200:3: error: dereferencing pointer to incomplete type
*state = *(struct hardwire_ttystate *) ttystate;
^
ser-unix.c:200:12: error: dereferencing pointer to incomplete type
*state = *(struct hardwire_ttystate *) ttystate;
^
ser-unix.c: In function 'hardwire_set_tty_state':
ser-unix.c:212:3: warning: passing argument 2 of 'set_tty_state' from incompatible pointer type [enabled by default]
return set_tty_state (scb, state);
^
ser-unix.c:149:1: note: expected 'struct hardwire_ttystate *' but argument is of type 'struct hardwire_ttystate *'
set_tty_state (struct serial *scb, struct hardwire_ttystate *state)
^
ser-unix.c: In function 'hardwire_noflush_set_tty_state':
ser-unix.c:220:28: error: storage size of 'new_state' isn't known
struct hardwire_ttystate new_state;
^
ser-unix.c:225:15: error: dereferencing pointer to incomplete type
new_state = *(struct hardwire_ttystate *) new_ttystate;
^
ser-unix.c: In function 'hardwire_drain_output':
ser-unix.c:335:1: warning: no return statement in function returning non-void [-Wreturn-type]

有个帖子说“编译过程中遇到莫名奇妙的报错,例如:ser-unix.c:118:1: error: conflicting types for ‘get_tty_state’,清理干净configure目录,使用root用户安装就好”,试了下不行。

换了一台测试服务器,直接编译,没有报错。

注:上下文中没有符号这个问题除了可能和gdb版本有关系外,还有可能我们要查看的变量的上下文不在给定的栈帧中,也就是不在相关的函数上下文,此时要通过frame N进入指定的帧,如下:

参考:

https://blog.csdn.net/hanchengxi/article/details/50380819

https://blog.csdn.net/sinat_24820331/article/details/54579913

The address where a.out.debug has been loaded is missing以及No symbol "*" in current context原因与解决方法的更多相关文章

  1. [Python Debug]Kernel Crash While Running Neural Network with Keras|Jupyter Notebook运行Keras服务器宕机原因及解决方法

    最近做Machine Learning作业,要在Jupyter Notebook上用Keras搭建Neural Network.结果连最简单的一层神经网络都运行不了,更奇怪的是我先用iris数据集跑了 ...

  2. Play! 1.x Eclipse Debug调试报错解决方法记录

    使用Play eclipsify xxxx[项目路径],可以把play new xxxx[项目路径]创建的工程生成为Eclipse的项目 但是在Debug AS 调试的时候,会报以下错误 Error ...

  3. Jenkins启动时报错:java.net.BindException: Address already in use: bind 解决方法

    下载jenkins.war包后,进入Jenkins.war包目录下,运行java -jar jenkins.war时报端口被占用的错误:java.net.BindException: Address ...

  4. Address already in use的解决方法

    当客户端保持着与服务器端的连接,这时服务器端断开,再开启服务器时会出现: Address already in usr. 可以用netstat -anp | more 可以看到客户端还保持着与服务器的 ...

  5. Myeclipse在启动Tomcat服务器的时候总是进入debug视图的解决方法

    最近调试程序,由于出现过一些错误,在调试的时候,更改过一些东西,但是后来在myeclipse下启动Tomcat服务器的时候,自动的跳入到debug视图了(以前是一启动Tomcat服务器后,直接就加载t ...

  6. log4j中Spring控制台输出Debug级信息过多解决方法

    log4j中Spring控制台输出Debug级信息过多解决方法 >>>>>>>>>>>>>>>>> ...

  7. 关于Ubuntu12.04下code::blocks不能使用debug解决方法

    问题描述:   系统:ubuntu 12.04   code::blocks版本:10.05   问题现象:debug->start        之后出现:warning: GDB: Fail ...

  8. Window8.1 64位无法使用Debug命令的解决方法[附牛人代码]

    偶然看到网上一篇文章,讲的是世界黑客编程大赛第一名的一个很酷的程序,大小仅有4KB,使用debug命令执行. 悲催的是win8.1的debug命令不能使用. 错误例如以下: 解决方法例如以下: 1. ...

  9. OpenCV程序在Debug时出现「PDB文件无法加载」的一个解决方法

    这几天毕设要用到OpenCV,按照网上的教程来搭建开发环境. 用的是OpenCV 3.0 beta + Visual Studio Community 2013.我的系统64位是Win 8.1,但在加 ...

随机推荐

  1. js动态规划---最少硬币找零问题

    给定钱币的面值 1.5.10.25 需要找给客户 36 最少找零数为: 1.10.25 function MinCoinChange(coins){ var coins = coins; var ca ...

  2. 大数据工具比较:R 语言和 Spark 谁更胜一筹?

    本文有两重目的,一是在性能方面快速对比下R语言和Spark,二是想向大家介绍下Spark的机器学习库 背景介绍 由于R语言本身是单线程的,所以可能从性能方面对比Spark和R并不是很明智的做法.即使这 ...

  3. MySQL--5子查询与连接小结

    子查询:出现在其他sql语句中的 SELECT,必须出现在小括号内,子查询外层可以是常见的SELECT语句,INSERT语句 UPDATE语句 DELETE语句,在子查询中可以包含多个关键字和条件 ( ...

  4. Cocos Creator EditBox(编辑框/输入框)添加事件的两种方法

    EditBox添加事件方法一这种方法添加的事件回调和使用编辑器添加的事件回调是一样的,通过代码添加, 你需要首先构造一个 cc.Component.EventHandler 对象,然后设置好对应的 t ...

  5. Faster-rcnn实现目标检测

      Faster-rcnn实现目标检测 前言:本文浅谈目标检测的概念,发展过程以及RCNN系列的发展.为了实现基于Faster-RCNN算法的目标检测,初步了解了RCNN和Fast-RCNN实现目标检 ...

  6. js中call,caller,callee,aplly

    1.函数的caller属性 (1).区分函数是在函数体调用还是顶层代码中调用:顶层中调用函数,该函数的caller属性返回null,在函数中调用,会返回调用发i函数的函数: <script> ...

  7. Opcode是啥以及如何使用好Opcache

    转载  https://www.zybuluo.com/phper/note/1016714 啥是Opcode? 我们在日常的PHP开发过程中,应该经常会听见Opcache这个词,那么啥是Opcode ...

  8. mysql字符集问题,及排序规则

    字符集问题: 基本概念 • 字符(Character)是指人类语言中最小的表义符号.例如’A'.’B'等:• 给定一系列字符,对每个字符赋予一个数值,用数值来代表对应的字符,这一数值就是字符的编码(E ...

  9. Code Review(转)

    Code Review是一种通过复查代码提高代码质量的过程,在XP方法中占有极为重要的地位,也已经成为软件工程中一个不可缺少的环节.本文通过对Code Review的一些概念和经验的探讨,就如何进行C ...

  10. hdu5290树形dp

    题意 给了n个点的数 每个点有一个w[i]权值,如果你选择了i这个点那么距离i这个点距离为w[i]的点将被除去,最后问 选则尽量少的点把这n个点全部删除 1<=n<=100000, 0&l ...