Timo Gransch wrote:
Hi everyone!I installed LDC on my Ubuntu 9.04/x86-64 system from the Launchpad Apt repository. So far it works great, but debugging is strange. I compile using ldc -g -debug test.d which should add symbolic debugger information to the executable, but when I run 'list' in gdb (original Debian/Ubuntu version as well as a self-compiled version with the current D patches) subsequently, I won't be shown the compiled source code, but obviously code from a lower level, which looks like 159 */ 160 int main(char[][] args); 161 162 /*********************************** 163 * Substitutes for the C main() function. 164 * It's purpose is to wrap the call to the D main() 165 * function and catch any unhandled exceptions. 166 */ 167 168 extern (C) int main(int argc, char **argv, char** env) (gdb) 169 { (...) Is there any way to fix this? Do I need other parameters to compile? Best regards, Timo
Actually, I believe this is right. If you look in runtime/internal/dmain2.d:168, you will see that exact function. You will also see that it calls _Dmain (what you know as main()) further down in the function as a delegate. I have not had this issue when compiling with ldc, but the solution is probably to break at _Dmain rather than main. Another solution would be to compile the runtime without debug information, then gdb will use _Dmain anyway, as it is the first point it encounters debug info (This is probably why I don't have this issue, my runtime is compiled in release mode).
You might want to try updating ldc to one of the nightly builds (or 0.9.1 when it's released), as debugging info is vastly improved over that of 0.9. Note that you should use ldmd instead of ldc when this happens (or learn the new syntax for ldc), as ldc has switched to llvm for command line parsing instead of dmd. This means -debug and -version (as well as a few others) will function differently unless you use ldmd.
