Normally when you run a program, it is started by some other program (called the parent process):
- if you run vim in a bash, then bash is the parent process.
- If you run from Desktop, then some system process is the parent
That is often the Desktop does not act as parent process, but tells another background process to do that
- If you run in a terminal, then the terminal is the parent process.
Well actually, 10 years ago the terminal was the parent process. Now most terminals have a "terminal server" process in the background....
- If you run in the Lazarus IDE (without debugger), then the IDE is the parent process.
- If you run in the Lazarus IDE (without debugger) with "launch app", then the above rules apply: bash may be a parent process, terminal will hand to terminal server.
When you use the debugger (any debugger), then
the debugger must be the parent process. Otherwise the debugger can not get hold of the process.
Well, the debugger could be the "grand parent" process. E.g. putting bash in the middle might work. But would need some more fiddling in other places.
If you use a "terminal" as "launch app" then this does not work. And there is no way to make it work (at least I could not find a way).
So the bottom line is:
- that you can not debug an application running in a terminal.
- the IDE setting in "Run param" works for none debug only. (10 years ago it worked in the debugger, and no one has added a warning to the IDE since....)
The 2nd issue is than if you want to run in grant parent (e.g. bash) that used to work (partly). But for that to work, the debugger had to ignore other errors, and that lead to user getting other problems.
NOT TESTED: In Lazarus 2.1 it may work by setting "InternalStartBreak" (in the property grid in debugger options) to gdsbNONE or gdsbAddZero. But again not tested. Because it no longe works for terminals, this has not been receiving much attention.
Also I am not sure if bash actually always used to create a sub process. Or re-used the existing one. Long time since that was tested
To debug you must disable "launching app"On Linux, terminal apps should be debugged using menu:
View > Debug Windows > Terminal output. (includes input too)
This is plain text however. NO color, no cursor movement....
So if you need more than that,
there are a couple of "workarounds". All of them require some extra work. And I have not tested any of them lately:
https://wiki.lazarus.freepascal.org/Debugger_Console_AppFrom memory / hope I got it approx right.
1) ConsoleTty
This is part of the global property grid in debugger options.
Open your consoe, outside of the IDE. run "pty" => This prints the consoles /dev/pty12 or similar.
Run something in the console, so the shell does not take the input. (i.e run gedit, or a bash loop)
In the IDE enter the /dev/..... as ConsoleTty
The debugger will redirect all in/output.
Undo the setting, when done.
2) gdbserver.
Compile your app, but do not run it in the IDE.
Run the terminal. In the terminal start (after compiling) gdbserver yourapp
In the IDE configure (install if needed) the debugger to use gdbserver. (when installed its in the dropdown)
package LazDebuggerGdbServer (or similar)
3) If you do not need to debug immediately, you can run the app without debugger, and then "attach" to it (run menu)
Unfortunately that are all the options.