Recent

Author Topic: Debugger Error  (Read 365 times)

Jimmy Camel

  • Newbie
  • Posts: 4
Debugger Error
« on: November 21, 2020, 07:03:09 pm »
Whenever I try to run a GUI program using the Launching application option in Run Parameters I get this error message


Debugger error

Oooops, the debugger entered the error state
Save your work now !

etc



And when I click the more button for extra info this is what the text box contents

The GDB command:
"info address main"
returned the error:
",msg="No symbol \"main\" in current context.""


 PLEASE HELP!))))



Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6716
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger Error
« Reply #1 on: November 21, 2020, 07:24:15 pm »
Check your setup. https://wiki.lazarus.freepascal.org/Debugger_Setup

Have you enabled debug info?

Jimmy Camel

  • Newbie
  • Posts: 4
Re: Debugger Error
« Reply #2 on: November 21, 2020, 07:45:04 pm »
Already did it, i'm on linux OS , and did all cases which found on this forum

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6716
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger Error
« Reply #3 on: November 21, 2020, 07:53:43 pm »
What kind of app are you running?

Graphical (with forms)?
Console?
library project?

Note: Using a "launching app" (e.g. a bash/shell/console) via "run parameters" may not work.
Linux, Console apps => menu: view > debug windows > console output

What version of Lazarus?

Jimmy Camel

  • Newbie
  • Posts: 4
Re: Debugger Error
« Reply #4 on: November 21, 2020, 09:01:42 pm »
Version Lazarus - 2.0.10 (latest on today)
Running Console App
Using green button for start App)
 I don't now what the problem real

https://forum.lazarus.freepascal.org/index.php?topic=34922.0
Did all what in this post, but keep this error

May be in linking need some instructions write ? But i don't know what is this and how do it)

The GDB command:
"info address main"
returned the error:
",msg="No symbol \"main\" in current context.""
« Last Edit: November 21, 2020, 09:05:00 pm by Jimmy Camel »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6716
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger Error
« Reply #5 on: November 21, 2020, 10:25:18 pm »
Does it work, if you switch off "use launching application"?

The problem is, that "launching app" does no longer work on any linux that I know. "gnome-terminal" (and any other terminal that I am aware off) have changed. 10 years ago, they could be used inside the debugger (as launcher). Nowadays, afaik not.

If you do normal readln/writeln then the you can switch it off, and use the "console output" window from menu "view > Debug windows" (this also allows input to the app).

If you use control sequences (clear screen, move cursor, color, ....) then it is a problem.
There are some work-arounds: https://wiki.lazarus.freepascal.org/Debugger_Console_App#Redirect_input_and_output_to_a_pty_.28terminal.29


Jimmy Camel

  • Newbie
  • Posts: 4
Re: Debugger Error
« Reply #6 on: November 29, 2020, 01:58:20 am »
When i'm run App without debugger , all good, gnome terminal work, but when i'm run App with debugger then i get this error. How it can be?

lucamar

  • Hero Member
  • *****
  • Posts: 3236
Re: Debugger Error
« Reply #7 on: November 29, 2020, 04:03:38 am »
Because the problem is caused by how the debugger is launched; if you run without debugger then no problem arises.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6716
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger Error
« Reply #8 on: November 29, 2020, 04:40:20 am »
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_App

From 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.
« Last Edit: November 29, 2020, 04:58:10 am by Martin_fr »

 

TinyPortal © 2005-2018