The address where a.out.debug has been loaded is missing以及No symbol "*" in current context原因与解决方法
最近,在debug core的时候,发现p 变量的时候提示“No symbol "*" in current context”,我们的代码使用-g编译的,经查有可能是下列几个原因或解决方法:
- 使用add-symbol-file将foo.o文件的符号添加至二进制文件中,如下:
(gdb) add-symbol-file XXXX.o #提示The address where xxx has been loaded is missing,所以应该还有其他原因 - 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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
2016-08-04 线上mysql内存持续增长直至内存溢出被killed分析(已解决)