Windows executables with complete embedded debug symbols? - windows

Are there cases when a Windows executable (written in C++ with Visual Studio) can contain its full debug symbols? Or are the full set of debugging symbols contained only in its .pdb file?
Is there a way to configure building a windows application so that we can debug it without having the .pdb file?

From the documentation for your toolchain:
The compiler's C7 Compatible (/Z7) option causes the compiler to leave the debugging information in the .obj files. You can also use the Program Database (/Zi) compiler option to store the debugging information in a PDB for the .obj file. The linker looks for the object's PDB first in the absolute path written in the .obj file, and then in the directory that contains the .obj file. You cannot specify an object's PDB file name or location to the linker.
It is not possible to create an .exe or .dll that contains debug information. Debug information is always placed in a .obj or .pdb file.
This doesn't rule out debug information placed into a section of an EXE file by other tools... but Microsoft Visual Studio's C++ tools never do.
For information on placing debug information into OBJ files (possibly contained inside LIB static libraries) instead of a PDB, read the documentation on the compiler option for Debug Information Format

Related

Debug third-party library dll in Visual Studio

I have third-party dll with lib files.
A.dll, A.lib, Ad.lib.
One dll, but two lib files - one for debug other for release. And headers. Is there a way to debug into this dll? I don't have source code and don't have pdb files.
PS: I'm using MS Visual Studio.
That is obvious. You cannot do that. If you want to debug into the dll, you must have the PDB file of it. And there is no other way unless you have the source code in recompile to get PDB file.
Or you could use decompilation tools to parse the dll and get the source code to realize it. But it might have some risks.

How to compile a VB6 program with extra debugging information?

How to compile a VB6 program with extra debugging information (PDB file / symbols)?
If I just choose "Make DLL" from the File menu, no PDB file is created.
From https://support.smartbear.com/viewarticle/2357/
Compiling Microsoft Visual Basic 6.0 Applications With Debug Information
This topic explains how to compile Microsoft Visual Basic 6.0
applications with debug information...
Visual Basic may include debug information in the executable file, or
add debug info to an external PDB file. ...if you compile a release
version of your product, it is recommended to generate debug
information as an external file. This will decrease the overall size
of your executable.
To specify the way in which debug information will be generated, use
the Link environment variable. If this variable is not defined, Visual
Basic will generate an external PDB file. Else, the compiler will
include the debug information in the executable. For more information
on this, see Visual Basic documentation.
To compile your Visual Basic application ... follow these steps:
If you compile a release version of your product, make certain that the Link environment variable is not defined. If this
environment variable exists, Visual Basic will embed debug information
in the executable and thus the overall size of your application will
increase.
Open your project in Microsoft Visual Basic.
Select Project | Project Properties from Visual Basic’s main menu. This will open the Project Properties dialog.
Move to the Compile tabbed page and select the Create Symbolic Debug Info check box:
Press OK to close the dialog.
Recompile your application.
There is no need to ship the generated PDB files along with your
application.

Debugging a managed dump with Visual Studio

Situation:
We create full dumps with WER and then they are sent to us thru automated systems. We have the pdbs and we can have the executable files as well.
If we don't put the pdbs together with the binary files Visual Studio does not show correct stack trace information. We were planing to use a Symbol Server so the symbols won't go with the binaries.
Question:
How can I tell Visual Studio where it should look for the binaries?
The reason why you need the binary executables is that the binaries contain the path to the PDBs. Using the path stored in the executable is unreliable, since the executable might e.g. be built on a build server that has different paths.
Instead, set up the symbol path in Visual Studio by going to Debug | Options and Settings ... | Debugging | Symbols and add the folder of your symbols or the location of your symbol server.

Specify PDB path in Visual Studio 2003

In Visual Studio 2003, if I link with a library that doesn't have its corresponding PDB file, I get a warning:
foo.lib(bar.obj) : warning LNK4099: PDB 'other.pdb' was not found; linking object as if no debug info
If the PDBs are in their original build location VS can find them, as well as if they're in the current build directory, but that seems to be it. Is there a way I can tell Visual Studio exactly where it should look for PDBs? I have a vague notion that a symbol server might work, but that seems like a lot of overhead; I'm just looking for something like link.exe /pdbpath c:\pdbs_are_right_here that adds a path to search, like /I adds an include path. Alternately, are there other paths it searches besides the current directory and the original absolute path the PDB was written to?
I believe the path to the corresponding pdb's is embedded in the libraries themselves, and you can change it into c:\pdbs_are_right_here at the build switches for your libraries (assuming they are indeed yours and not 3rd party).
For DLL's that means project properties\linker\debugging\generate program database file.
For static libraries the default name is uniform in VS2013 ('vc120.pdb'), but I think this changed in VS2015 and have no idea about VS2003. Anyway if you're working in VS2013\2012\2010 you'd have to explicitly override the name too.

Visual Studio cannot find CPPUNIT debugging database

I am using Visual Studio 2008 with CPPUNIT. I already compiled CPPUNIT and added the CPPUNIT path to Include and Library path. Currently, I can compile my program with CPPUNIT library.
However, the linker generates the following warning:
Warning 2 warning LNK4099: PDB 'vc90.pdb' was not found with
'C:\Program Files\cppunit\cppunit-1.12.1\lib\cppunitd.lib' or at
'c:\Users\hide1713\Desktop\3d_tank\cpp_pj\bin\vc90.pdb'; linking
object as if no debug info cppunitd.lib GameUnitTest
There's a cppunitd_dll.pdb file along with cppunitd.lib. How do I tell the linker where to find the CPPUNIT debug database?
Thanks all.
In your CppUnit project, be sure you have your compiler emitting a program database file that's compatible with your main project. In the CppUnit project properties window, under the Config properties / C++ / General tree, you'll see the Debug Information Format box. Select "Program Database /Zi" or whatever value exactly matches the same setting on your main project. You'll then have to recompile them both, of course.

Resources