Overriding environment variable when debugging on Win32 does not work lazarus / 12-Debugger ---------------------------------------------------------------------- tom.tom · 2013-04-24 17:04 Hi, Am I doing something wrong or is it a bug: 1) Go to Run Parameters -> Environment -> Overrides 2) create there a new variable say XYZ 3) in your sample app put this: ShowMessage(GetEnvironmentVariable('XYZ')) ...in my case it returns an empty string. I need that to override the system PATH when debugging my app. Am I missing something? ---------------------------------------------------------------------- Martin_fr · 2013-04-24 18:01 It is a known issue: http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Bugs_in_GDB Currently GDB 7.2 is shipped with Lazarus. You need 7.4 or up for the environment. But *all* versions above and including 7.3 have other regressions, including the "PC register not available" bug, that can make the debugger stop in the middle of your debug session. And then the debug work is lost. I do not know if this happens on all windows systems, but it happens on the ones I tested. You can try if it works for you (Lazarus is tested with 7.4 and 7.5). Alternatively you can downgrade. GDB 6.5 (maybe 6.6) should work. They are also supported by Lazarus. ---------------------------------------------------------------------- tom.tom · 2013-04-25 08:13 OK, thanks Martin - I could have looked better for this explanation since it's on wiki... But thanks for your explanation - I'll give other GDBs a try. ---------------------------------------------------------------------- tom.tom · 2013-05-10 12:47 Just to update this thread - I switched to GDB 7.5 and it works fine so far - recognizes the environment variables and seems to work, well... OK - it crashes from time to time on variable lookup, but the original GDB happened to to that as well ---------------------------------------------------------------------- Martin_fr · 2013-05-10 13:09 7.5(-1) or 7.5.9 ? Do you have a reproducible example where the original (7.2) GDB crashed? Is that using dwarf or stabs (project settings / linker)? Just double check: You are win 32 bit? Win 7, vista, xp, ...? -------------------- btw all gdb crash on Code: [Select]type   TFoo = array [0..maxint] of TSomething;   PFoo = ^TFoo;   Because it does not fit into memory. An app can however use it like Code: [Select]  mempointer := allocMem(5*sizeof(TSomething));   AFoo :=  PFoo(mempointer)^[1]; No GDB is smart enough for that. So such type declarations can be a problem. ---------------------------------------------------------------------- tom.tom · 2013-05-13 20:33 Hi Martin,   It's GNU gdb (GDB) 7.5.91.20130328-cvs. It crashes almost always when using Inspect/Modify on some properties - is it normal? ---------------------------------------------------------------------- Martin_fr · 2013-05-13 21:25 http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Issues_with_GDB_7 .5.9_or_7.6 Yes. There is a bug in GDB. 7.5.9 or 7.6 can not be used. You wrote Code: [Select]but the original GDB happened to to that as well So I thought you crashed a lower version of GDB too? ---------------------------------------------------------------------- tom.tom · 2013-05-23 13:17 Well, I sort of learned I had to live with Watch/Modify not working ---------------------------------------------------------------------- Martin_fr · 2013-05-23 13:20 Quote from: tom.tom on May 23, 2013, 03:17:32 pmWell, I sort of learned I had to live with Watch/Modify not working  WAtch should work But modify only works for integer, probably boolean and some/most NOT managed types It does not work for strings (or dynamic array) !!! It is on my list to add a detection, and prevent it..... ---------------------------------------------------------------------- tom.tom · 2013-05-23 16:13 thanks marting for the WATCH hint - I'll try it out ---------------------------------------------------------------------- Martin_fr · 2013-05-23 16:46 To be clear: Watching should not lead to crashes of the IDE. Not all values can be watched, but if they cant, then it should say so. http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Inspecting_data_t ypes_.28Watch.2FHint.29 Exceptions: The type   Array[0..maxint] of .... or any array that would require 2 GB of continues memory will crash GDB. In general you can also not have a variable of that type, because there would be a mem alloc error (it may work on 64 bit) But the type sometime is used as a pointer type cast, and then only 10 elements may exist. ---- I can not guarantee that there are no other issues in GDB itself. But I have not yet experienced them myself. ---- Also some people had problems, when there is an error somewhere in the debug info. (for example when using smart linking) If you try and watch a variable that does not exist (enter "Foo123ThisVarDoeNotExist") in watches, then GDB scans all debug info. So that forces the error. So cases are very rare. And if you do encounter any, it would be good to try and track it down. ---------------------------------------------------------------------- Martin_fr · 2013-05-27 14:34 Update on the watches front. Just found a case Code: [Select]  const a = 'text' untyped string constant. Sends gdb 7.2 (win 32) into sudden death (at least in some cases) gdb 7.5.1 (win 32) survives. But has other issues. ----- So now its a decision where and when you want your gdb to die, or loose the debug session. Either one will in some case. ### EDIT see http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Bugs_in_GDB So you can use gdb 7.3 and up, but then you get the win-err 5 issue. Your safest bet is to use gdb 6.7.5.  (on win 32) Unless you write and need to debug libraries in pascal. For other OS I do not know. ---------------------------------------------------------------------- tom.tom · 2013-06-05 16:14 ok, I'll take all your advices into account - thanks