how do you debug console apps lazarus / 12-Debugger ---------------------------------------------------------------------- mikaelo · 2008-04-09 14:03 I have many projects which are targetiing small semi embedded systems with no real graphic ability but have character console. My programs are written using the video and keyboard units to draw forms similar to gui forms in a framework I have made. My problem is tha I can't figure out how to use the debugger with this. Since the video unit requires a console, I have enabled the checkbox in the run parameters dialog to run xterm to execute the program, but I seemingly can connect with the debugger to the program at that point, as it wount stop at break points and if I try to start the program by steping into it, it simply just run. Is there a trick to connect the debugger to prcesses that are launched via a helper program such as xterm? Mikael ---------------------------------------------------------------------- Marc · 2008-04-15 09:00 debugging console apps is not possible with Lazarus atm. ---------------------------------------------------------------------- mikaelo · 2008-04-15 14:36 Wow so lazarus is totaly incompatible with the video and KB units then. Thats a bummer, as that means I have to move to C and re-invent the wheel as I have all my CUI framework written and have a large library of units/classes that I use to quickly whip up applications. Either that or come  up with some alternate GUI rendering of my CUI form for debugging purpose. ---------------------------------------------------------------------- Ahi · 2008-04-15 17:02 debugging console apps Lazarus' internal debugger cannot do it. But there are other alternatives (so no need to switch to C): how about Insight ? On (K)Ubuntu, debian and the like, try this: aptitude install insight This should automatically also install gdb, if not already installed. Insight (if I understand it correctly) internally uses gdb, but when you use Insight, this fact is well hidden - no need to learn cryptic commands. Pros: It works and has an intuitive GUI It can show source listing and you can step into or step over at source level - just like Lazarus' integrated debugger (or Borland's),however note that keyboard shortcuts are different! Watch out for this ! It can also show disassembly listings - but only of code that it also has source available. In assembly mode you can also step into or step over. In assembly mode  the default is the AT&T; syntax (mov 5, %eax), but fortunately you can change it (from menu/ dropdown box)  to the more familiar intel syntax (mov eax, 5). Cons: It cannot show disassembly of code it does not have source. It cannot debug XWindow -related code during times when the application debugged has the XWINDOW system locked. - this can lead to a total lockup of the machine. (but ssh-ing from an other computer and logging in may give you the opportunity to kill the offending process). --------------- I think that Lazarus needs a possibility to do remote debugging. I think an external program would be better - no need to recompile lazarus every time some external utility is updated. And, btw,here is a good hint,how to "integrate" external tools into lazarus (just like the "tools" -menu of Delphi: I do not know if lazarus has some problem in the idea that if you add an external tool to a tools menu, that would make it necessary to recompile lazarus and why - but if the reason is that for some odd reason dynamically creating TMenuItem's and adding them to an existing menu does not work, an easy workaround would be to create about 25 TMenuitems to be associated with external tools -all of them (by default) having Visible=False. Once you install an external tool, lazarus would then find the first unused TMenuitem, set a correct caption for it and associate it with the external tool the user wants to install, and set Visible := True. The need to recompile lazarus is actually the reason why I have restricted myself to only use the commandline version of h2pas and not the GUI version. I wish to avoid recompiling lazarus, because I was afraid that after trying to recompile it, I would no more have a working lazarus. - UPDATE: I just downloaded the lazarus snapshot and compiled it. Seems no problems, but: What is that talk about bookmarks in the readme -file? In lazarus, that feature has never worked for me -but in Delphi I have used them a lot the ^K 4 - and then ^Q 4 -style. Does the readme -file try to document features that have not been implemented? The bookmarks at least seem not too hard to implement... but then, to actually do it would demand resolving 2 things: 1.in what file is the editor implemented (the level where bookmarks could be added) ? 2. How to deal with the possibility, that say, you put a bookmark on line 20. Then you insert 4 new lines between 1 and 20. That bookmark should, of course, now point to line 24. Should it be the simple solution that if you insert/delete lines,then all bookmarks after the  insert/deletion point shouldmove accordingly? Maybe I should check how is it done in Delphi. That has already happened to me with a previous version of lazarus - I installed the newest freepascal compiler - and after installation freepascal (from command line) would work fine -but lazarus would not start anymore. However, remote debugging is more important than making the editor perfect, although it would be nice to correct all those little annoyances of the integrated editor (like that after editing aline, you need to switch to another tab and back to get it redrawn - otherwise it looks ugly due to some letter being degraded after editing). ---------------------------------------------------------------------- mikaelo · 2008-04-17 21:02 Thanks for the tip.. I will definatley research Insight and I don't mind if I need to confiigure the tools menu or running extrenally to the code editor. I would definately want to stay with FPC/Lazarus is at all possible so if that requires an external tool for those few times I need to debug CUI related pieces (I put a precompliler directive in to allow me debug other code..it will simply not draw the screen). Mikael