Several different problems with debugging lazarus / 12-Debugger ---------------------------------------------------------------------- HomePlaneR · 2012-10-07 21:31 Hi. I always had several complex problems with the debugger that make the debugging process heavy. Several times I tried to deal with it, but usually I ignored it thinking "when I upgrade Lazarus, it will disappear". But the upgrades doesn't help and the project's code become more and more complicated, so I can't ignore it any more. It seems to me that there is some global setting which is not correct in my configuration and that causes all the problems. I have tried to find the answers but I haven't succeeded a lot. Sorry if some of the questions were already discussed. 1) When the option "generate debug info for GDB" is off, an exception "External: SIGILL" occurs when the application is just launched (no forms appearing before the exception). Any option change doesn't help and doesn't change the situation at all. 2) The debugger never shows objects properties or variables values, it always says things like "Bitmap has no property named Width". It can show the object's content, but when I put Object.Property into Watches or just put the cursor over the code, I always see "... has no property named ...". Frankly I have never seen a property value within the debugger in Lazarus neither with current version I use nor with all older versions I had before. 3) Shown local variables values are often incorrectly. I mean after several launches it starts to show strange things for all variables of simple types. The values change randomly on each step. Several more launches and/or restarts of Lazarus help but not for long time. I can't detect when it happens, it arrives quite spontaneously. 4) The stack is sometimes not full, even if several simple instructions are called within the main thread. All that it shows are two or three calls with question marks instead of the function names. Restarts helps as well. I can't detect when it happens. I use Lazarus 1.0 with FPC 2.6.0 over Windows 7 64 bit. SVN version is 38415. I used several older versions on the same PC and with another one over Windows XP SP2 32 bit, but I almost always had pretty the same problems. I try to change all the compilation / linking options proposed by IDE, but it doesn't help at all. So, what is it? What I should do? Thanks in advance. ---------------------------------------------------------------------- Martin_fr · 2012-10-07 22:38 Ok, a lot of issues indeed. Before getting started: Please check the entire setup:  http://wiki.lazarus.freepascal.org/Debugger_Setup - Try "dwarf (with sets)" if possible. - Make sure the following is turned off  -- optimization (except -O1 (one)). If you use packages, and debug them, check the settings of each package.  -- smart linking Serious those two can screw the debugging real big time. Read  http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips debugging of properties is limited. And there is no quick way to fix this for Lazarus. So this problem will stay for some time. Sorry. Check your gdb version. And if need try updating. Pre compiled w64 GDB can be found here:  http://www.drangon.org/mingw/ --------------------------------------- Please provide the following info: - version of gdb (if you test on w64 and w32, then specify each) - Anti virus software used (some have trouble with gdb) --------------------------------------- About your points: 1) SIGILL - Please provide a log: http://wiki.lazarus.freepascal.org/GDB_Debugge r_Tips#Log_info_for_debug_session - Try with AntiVirus in GameMode 2) Properties: Already mentioned above: http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Properties a) use dwarf b) instead of Bitmap.Width, try Bitmap.FWidth (only works in watches win, not for hint-eval) Sorry, there is no better... 3) incorrect locals That does sound a lot like optimization -O2 or higher. Maybe smart linking. ONLY if happens without optimization: If you do get a correct value on the 1st debug run, and a wrong one on the 2nd (or 3rd), then go to the options, and check "reset debugger after each run". It adds 1 or 2 seconds to each time you press "run"(F9) to start an app. Though I have not seen an issue like yours, that required the reset. If it happens pleas generate another log-file. Also specify the variable name, and expected value. And how did you determine the actual value, if not with the debugger? 4) Stack: This probably happens when you are in a callback. e.g.: OnButtonClick. If the calling code (probably LCL) is compiled with optimization, then the compiler did not add full stackframes, and the debugger can not read the stack. Try building the LCL (or any used package) without optimization. If the callback comes from the RTL, then it is a problem. Unless you want to build your own fpc. Same with callbacks, that are called through external dll, or the windows kernel. You can't rebuild them. But win kernel usually goes to LCL, and that means you should get at least the LCL part of the stack. In order to be able to compile releases with optimization, please search the wiki for build modes. They can be toggled with one click (there will be a dropdown, next to the run icon). And they can change the settings you need, including recompiling all the packages whenever needed. If you need help on build modes, start a new thread. I don't know them that well. And lets keep this thread to the debugger. -------------- Ok. That should get you a step forward. Please report back after you tried all this. ---------------------------------------------------------------------- HomePlaneR · 2012-10-08 18:08 Martin_fr, I'm pretty glad  to see your post remembering how quickly the problem with the extra tabs in the editor was solved once. I fixed all the parameters and updated gdb.exe. It was crashing when dwarf was enabled until I had found a stupid error in my code (sorry ): Code: [Select]  R := waveOutOpen(     @FWaveOut,     WAVE_MAPPER,     @FWaveFormat,     DWORD(@PlayerCallback),     0,     CALLBACK_FUNCTION or WAVE_ALLOWSYNC   ); PlayerCallback is a callback function, the requested parameter of waveOutOpen function is of DWORD type, so I put DWORD. But when I did that, I forgot that I'm over 64 bit system, so after changing the typecast to QWORD it started work when dwarf is enabled as well as when the debugging is switched off (one of my issues)! I don't know why it was working before when the debugging was switched on. Concerning the rest, I have a general impression that now it is much better (after dwarf and reset on each launch were enabled). I understood what you wrote, so I'll try to deal with eventual errors. If I met something particular, I'll ask in this thread. So the moral to be drawn: post to the forum only after having thoroughly looked the code. However, a little notion that maybe useful for others: it was already discovered that actual version of MMSystem.pas is not yet 100% compatible with 64 bit platforms. I discovered once that using TWAVEHDR declared in the unit causes an error when one tries to start the playback. In that case the problem is quite similar: some of the fields of this record must be QWord, not DWord. But it is another story... Thanks a lot, Martin_fr!