I have a problem I have absolutely no clue why this happens: https://github.com/nim-lang/Nim/pull/5664

In order to find out why this happens I would like to debug the compiler. Since I think that the problem is somewhere in the generated C code I would like to debug the generated C code. This means I would like to compile the nim files in release mode (no source map), but then when I compile the c files, I would like to compile them with debug information, so that I can see where in the C code I am. So how can I do this?

2017-04-19 19:14:59

Your problem is very unlikely to be in the generated C code and just a logical bug. (Of course that's just a very educated guess though.)

Your question is easily answered when you consider that compiler flags are orthogonal, so -d:release --debugger:native works. Or --checks:off --lineDir:off --debugger:native.

nim.cfg contains this:

@if release or quick:
  obj_checks:off
  field_checks:off
  range_checks:off
  bound_checks:off
  overflow_checks:off
  assertions:off
  stacktrace:off
  linetrace:off
  debugger:off
  line_dir:off
  dead_code_elim:on
@end

@if release:
  opt:speed
@end

Knowing this, you can also use -d:quick --debugger:native.

2017-04-19 19:48:18
Thanks a lot for this information. I got the problem and yes it was not a bug in the generated source code. But still without the dubugger I had no chance of finding it, because there was a hidden layer of function calls that I was simply not able to see at all. 2017-04-19 19:59:38