Can't compile dll with debug info

Started by
1 comment, last by OrangyTang 16 years, 5 months ago
I'm trying to compile a debug version of someone elses library (a dll) so I can step through it. But for some reason VS always says that it's been built without debug information when I actually try and use it in the debugger. The build script is written in ant, and I've modified it to build a debug version as follows:

	<target name="compile_debug" if="debug">
		<echo>Compiling code as debug build</echo>
		<apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true">
			<arg line="/Od /Wp64 /W2 /FD /EHsc /MT /Gy /nologo /c /Zi"/> 
			<arg value="/DEBUG" />
			<arg value="/DDEBUG=TRUE"/>
			<arg value="/I${sdkhome}\include"/>
			<arg value="/I${dxhome}\include"/>
			<arg value="/I${alhome}\include"/>
			<arg value="/I${java.home}\..\include"/>
			<arg value="/I${java.home}\..\include\win32"/>
			<arg value="/I${native}\common"/>
			<arg value="/I${native}\windows"/>
			<srcfile/>
			<fileset dir="${native}/windows" includes="*.c"/>
			<fileset dir="${native}/common" includes="*.c"/>
			<fileset dir="${native}/generated" includes="*.c"/>
			<mapper type="glob" from="*.c" to="*.obj"/>
		</apply>
	</target>

	<target name="link_debug" if="debug">
		<echo>linking as debug build</echo>
		<apply dir="." parallel="true" executable="cl" failonerror="true">
			<arg line="/LDd /MTd /nologo"/>
			<arg value="/DEBUG" />
			<srcfile/>
			<arg line="/Fe${dllname} /link"/>
			<arg value="/LIBPATH:${java.home}\..\lib"/>
			<arg value="/LIBPATH:${dxhome}\lib\x86"/>
			<arg value="/LIBPATH:${sdkhome}\lib"/>
			<arg value="/LIBPATH:${alhome}\libs"/>
			<arg line="/DLL /DELAYLOAD:jawt.dll ${libs}"/>
			<arg value="/OPT:NOREF" />
			<fileset dir="." includes="*.obj"/>
		</apply>
	</target>
(Compiled via the VS 2005 compiler) I've been trawling through the docs for the command line flags, but as far as I can see the /Zi and /LDd options should be enough, I don't think the /Od, /MTd and /DEBUG flags are needed but adding them doesn't seem to make any difference. Switching /Zi for /ZI doesn't make any difference either. [sad] Has anyone any ideas for what I might be missing? Cheers
Advertisement
Have you tried viewing the DLL in a PE editor, to see if the symbols are there? This would eliminate the possibility that VS is misbehaving. As I understand it, the linker has the choice to embed the PDB into the binary or create it separately. In the latter case, you'd need to be sure that the debugger knows where to look.

The only other thing I can think of is that you may be compiling or linking with some (possibly default) options that are incompatible with the ones you require. I'd hope that this would flag up some warnings, but can't be sure. I'm afraid I have no experience with ant, so I can't be more helpful.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
Quote:Original post by TheAdmiral
Have you tried viewing the DLL in a PE editor, to see if the symbols are there? This would eliminate the possibility that VS is misbehaving. As I understand it, the linker has the choice to embed the PDB into the binary or create it separately. In the latter case, you'd need to be sure that the debugger knows where to look.

I'm fairly sure the dll doesn't contain any debug info. Theres a .pdb file generated at compile, but telling the debugger to use it for the dll (via the modules window) doesn't work (VS says the .pdb file does not match the dll). I ran a little third party app to check whether they did in fact match and it reported that there were no symbols in the dll.

Quote:The only other thing I can think of is that you may be compiling or linking with some (possibly default) options that are incompatible with the ones you require. I'd hope that this would flag up some warnings, but can't be sure. I'm afraid I have no experience with ant, so I can't be more helpful.

Thats what I suspect too, but it compiles and links with no errors or warnings. I did try explicitly setting a .pdb filename to output with /PDB:test.pdb but both the compiler and linker reported this as an unknown flag, which is odd since thats exactly how it's specified on MSDN.

This topic is closed to new replies.

Advertisement