0

List items 1- 4 are the steps that I did. List item 5 describes the problem List item 6 provides additional information

  1. I have compiled a C source code say c1.c with -g flag.
  2. I have also a dynamic shared library say liba1.so built with -g for all the source files that it has.
  3. I built the executable say exe1 by linking c1.o (c1.c object code) with the liba1.so .
  4. I do gdb exe1. and am able to step through the sources of c1.c. When c1 calls the shared library, I am also able to put a breakpoint on a function in the shared library.

  5. However, when I try to step through the function, it says that "Single stepping until exit from function foo1 ,which has no line number information" Also it should ordinarily show the value of the parameters passed into the function foo1 but does not do that. This happens for all functions in the shared library including some very big ones so the values cannot be optimized out

  6. I did an objdump -t on the shared library AND the executable - it shows the symbol table (the fact that I can set a breakpoint on the function also supports this). Also, I can see the values of the variables used in the file c1.c So what should I do in order to ensure that I can see the values of the local variables inside the shared library. Here are the other arguments that are being used to compile the shared library "-O2 -std=gnu99 -Werror -fno-stack-protector -Wstack-protector --param ssp-buffer-size=1 -g -nostdinc". doing info f and trying to look at memory addresses on the frame also does not give any information.

I am looking for some suggestion to at least troubleshoot it. Can I know using objdump (or any other utility) if a shared library has line number information.

4

1 回答 1

0

我正在寻找一些建议来至少解决它。

, 最可能的原因no line number information实际上没有行号信息,最可能的原因是您有两份副本liba1.so——一份有调试信息,一份没有,而且您正在加载在运行时后者。

第一步:(gdb) info shared准确liba1.so告诉您加载了哪个。

如果它实际上是您刚刚构建的版本-g,您应该验证它确实具有您期望的调试信息。执行此操作的确切命令是特定于平台的(并且您没有告诉您在哪个平台上)。在 ELF 平台上,objdump -g liba1.so或者readelf -w liba1.so应该可以工作。

-g代码没有调试信息的一个常见原因是-s链接行上存在 (strip) 标志;确保您的链接线上没有“杂散”标志。除了编译时,某些平台还需要-g在链接时使用。

于 2013-04-26T14:54:07.520 回答