3

I am facing an issue with two release versions of our software. I have two executables (MS and Linux) respectively using MSVC and GCC compiled libraries.

Context:

My program contains a message_queue.hpp templated class, which inherits from a message_queue_inter.h interface. This interface contains includes from the static library. Both of the libraries are O2 optimized and without any debug info (Debug Information Format -> None for MSVC and -g0 for GCC).

The fact is that while I am debugging both of the executables (within Eclipse), GDB can find symbols for members in my derived class AND the base class (interface) in my MSVC executable (I can expand variables content in Eclipse in the Debug view)

On the contrary, the version using the GNU/Linux library cannot find symbols for members which are in the interface ONLY. If I try to access to a member from my interface, GDB returns "No Data Fields" for it. All the members of the derived (.hpp) class are displayed properly.

Why such a difference between the MSCV and GCC compilers ? I notice, of course, that the MSVC library is much bigger than the GCC one. Thanks to the "nm" tool, I can notice that the interface symbols are found in my MSVC lib, but are missing in the GNU/Linux one.

I am aware that release versions should not contain any debug information but I am wondering why I have access to this variable using MSVC and not with GCC. (I need to build a GCC debug version with g2 minimum to generate more symbols in order to display the content of the message queue).

I am lost !

Thanks for your help.

David
  • 83
  • 1
  • 7

2 Answers2

1

Presumably this is because the MS version of /NODEBUG doesn't actually turn off (all) debugging information and it left more behind than g++ does on -g0. Alternately it's possible MS is writing a .pdb symbol file that gdb is finding and reading to get more detailed symbol information.

If you need to debug I can't see any harm in compiling with -g2.

Mark B
  • 95,107
  • 10
  • 109
  • 188
  • Thank you Mark for your answer. The PDB file is removed on purpose so that no extra info is left to the customers. We would like to avoid making our static library "debug" because of performance and visibility reasons. I suppose that in this current case, we will be obliged to compile our GNU/Linux library with the g2 flag ? – David Mar 31 '15 at 15:33
  • Just a few more details: I just did a dumpbin.exe /ALL on my windows library and I can see symbols relative to the attributes that I would like to access. But when I do a "nm" on my Linux library, I can't see any symbols for my attributes. – David Apr 02 '15 at 14:42
0

You can use 'strip' to get rid of symbols/debug info before shipping your executable. You then have two versions of the executable, before and after you run strip. You can even debug the stripped executbale, and then point gdb at the unstripped version by using gdb's `file' command.

Note that -gN or stripped/unstripped doesn't affect the executable in any way - it's only the debug info sections that are affected.

Greg Law
  • 79
  • 1