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编译的,经查有可能是下列几个原因或解决方法:

  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进入指定的帧,如下:

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

参考:

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

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

上一篇:Linux管线命令 - cut,grep,sort,uniq,wc,tee,tr,col,join,paste,expand,split,xargs


下一篇:解决方案命名空间“System.Web.Mvc”中不存在类型或命名空间名称“Ajax”(是否缺少程序集引用?)