Recent

Author Topic: Debugger error when running Lazarus when using Launching application  (Read 9617 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
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.""


Any ideas of what the problem is?
Lazarus 3.0/FPC 3.2.2

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger error when running Lazarus when using Launching application
« Reply #1 on: November 25, 2016, 09:24:09 pm »
OS ? 32/64 bit? gdb version ?

I assume that the app has debug info?

"Run params" start/host app is empty?

If nothing helps, in Tools > Config > debugger: search the property grid for InternalStartBreak... and try some other values

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
Re: Debugger error when running Lazarus when using Launching application
« Reply #2 on: November 26, 2016, 02:57:40 pm »
OS ? 32/64 bit? gdb version ?
OS = 64bit Debian/Stretch/Sid
Lazarus 32bit
Gdb GNU gdb (Debian 7.11.1-2) 7.11.1

Quote
I assume that the app has debug info?

Quote
"Run params" start/host app is empty?
Yes
Quote
If nothing helps, in Tools > Config > debugger: search the property grid for InternalStartBreak... and try some other values

I have a standard Debian Sid system and I will test it there as well. It could be that the Sid system has some incompatibilities that haven't yet been sorted out.
Lazarus 3.0/FPC 3.2.2

AnthonyTekatch

  • Jr. Member
  • **
  • Posts: 78
Re: Debugger error when running Lazarus when using Launching application
« Reply #3 on: October 16, 2017, 02:56:37 am »
Has anyone found a solution to this problem? I am having the exact same thing with Debian 9.

A brand new simple project does not have this error, but I do not know where to look in my existing project.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger error when running Lazarus when using Launching application
« Reply #4 on: October 16, 2017, 06:49:12 am »
Do you get the exact same error, including the details about
Code: Pascal  [Select][+][-]
  1. "info address main"
... ?

Otherwise try
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#gdb.exe_has_stopped_working
Quote
o to the debugger options and set the field "DisableLoadSymbolsForLibraries" to "True"


If it as about the main address, in the options dialog (same page as DisableLoadSymbolsForLibraries) find the setting:
   "InternalStartBreak"
and change it to: gdsbEntry


Also what gdb version?

Since you read the thread, I assume that you
- have debug info enabled (check http://wiki.lazarus.freepascal.org/Debugger_Setup )
- do NOT have any "Host application" in menu Run > Run params (almost anything in there will break the debugger)


Also what Lazarus Version?
« Last Edit: October 16, 2017, 06:50:49 am by Martin_fr »

AnthonyTekatch

  • Jr. Member
  • **
  • Posts: 78
Re: Debugger error when running Lazarus when using Launching application
« Reply #5 on: October 16, 2017, 11:53:00 am »
Do you get the exact same error, including the details about
Code: Pascal  [Select][+][-]
  1. "info address main"
... ?

Yes, I also get the "info address main.
Code: Pascal  [Select][+][-]
  1. The GDB command:
  2. "info address main"
  3. returned the error:
  4. ",msg="No symbol \"main\" in current context.""


If it as about the main address, in the options dialog (same page as DisableLoadSymbolsForLibraries) find the setting:
   "InternalStartBreak"
and change it to: gdsbEntry

I tried that and now get this error:
Code: Pascal  [Select][+][-]
  1. The GDB command:
  2. "-break-insert main"
  3. returned the error:
  4. ",msg="Function \"main\" not defined.""


Also what gdb version?

Code: Pascal  [Select][+][-]
  1. GNU gdb (Debian 7.12-6) 7.12.0.20161007-git


Since you read the thread, I assume that you
- have debug info enabled (check http://wiki.lazarus.freepascal.org/Debugger_Setup )
- do NOT have any "Host application" in menu Run > Run params (almost anything in there will break the debugger)

Yes, I have debugging info enabled.
Yes, I have no host applications in Run > Run params.

Also what Lazarus Version?
Lazarus Version 1.6.4
Date 2017-07-24
FPC Vesion 3.0.2
SVN Revision: Unvesioned directory
x86_64-linux-gtk 2
« Last Edit: October 16, 2017, 12:01:57 pm by AnthonyTekatch »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger error when running Lazarus when using Launching application
« Reply #6 on: October 16, 2017, 12:42:01 pm »
Now I am not sure:

Code: [Select]
    The GDB command:
    "-gdb-set confirm off"
    did not return any result.
     
    The GDB process is no longer running.

I assume that is the error you originally got?

So not the "info address main"?

But when you changed settings you got "-break-insert main" ?

-----------
Or maybe you get different errors at different times?

-----------
Anyway lets have a look.

Since "InternalStartBreak" did not help, set it back to "Default"

If DisableLoadSymbolsForLibraries does not cause the "confirm off", then you may keep this on.

You may also add "DisableForcedBreakpoint" to true. (Unlikely that it is related, but it want hurt / you can later try to set it off again)

-------

Each error happens at a different internal stage.

"-gdb-set confirm off" happens right at the start. When gdb was just launched.

So that would meant your gdb was killed before the IDE could even do anything.

But there is another possibility:
You get that error only, on your 2nd attempt to debug your exe.
The IDE keeps using the same instance of GDB. So if it gave some error the first round, then it may give this error on the 2nd round.

To make sure this is not the case:
* Open the Tools > Options, go to debugger, and check "Reset debugger after each run"
* Restart the IDE


If you keep getting the  "-gdb-set confirm off"  even after this, then supply a logfile:
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session

-------------------
If you then get the error containing the word "main"

There are 2 reasons I can think of.

1) Normally fpc includes that for every program (I am assuming you are not trying to debug a library, or something alike?) But maybe for some reason (settings) this get removed

2) GDB has issues reading the debug info. Maybe it is some other structure in your program that adds something to debug info, and gdb fails reading the entire thing.

Either case is probably a question of settings.

Open Menu Project > Project Options

Make sure:
(And if you use buildmodes, make sure to use the right one)

- smart linking is off / both checkboxes. (Page: Compilation and Linking)
- Optimization is 0 (off) / Optimization 1 should be ok too for this, but 0 is recommended.
- "Use external gdb debug symbols" is off (Page: Debugging). Also make sure your project folder (where the exe is, may be in the lib folder) does not have any *.dbg files or *.sym or similar)
- "Generate debug info" is on. and it is on "Dwarf with sets (...)" or "Dwarf 2"

Actually you may try "Dwarf with sets (...)"  or "Stabs" ("default" will probably create stabs).

But Stabs may cause issues with gdb. And may be the source of the problem.

Also when you set "Generate debug info", this only affects your source files, but there is also debug info for the packages (like LCL)

So at the same time go to "Additions and Overrides"
- Select "Stored is lps"
- Add "new target", unless "Target *" already exists. ("Target *" will be created by this)
- Select "Target *"
- Add custom option

Into custom option type either of the following
-If you selected Dwarf ..., type:  -gw
-If you selected Stabs ..., type:  -gs

Select "Build" from the Run menu. This may take a moment, as packages will be rebuild too.

---------------
I dont know if that is the issue, but it is the best guess.

I have seen some versions of gdb, that reported errors (alas different errors than you got), when stabs was used. those errors only show sometimes. Depending on what kind of data structures are used in the project (I dont know the exact ones).
That would match with your statement that new projects work, but your one big project does not.

The "additions and overrides" means you do not have to change every package from stabs to dwarf, but you can do it all in one place.


If none of this helps, it may get complicated. The next step then would for you to generate a logfile
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session

AnthonyTekatch

  • Jr. Member
  • **
  • Posts: 78
Re: Debugger error when running Lazarus when using Launching application
« Reply #7 on: October 16, 2017, 01:18:06 pm »
Now I am not sure:

Sorry for that confusion, I was editing my post when you saw that note. Yes, I still got the info address main. The set confirm off was from me trying all things in your post which was not necessary.

I have just tried your other settings and still get the "info address main".

I had tried build modes before, but am not using them now and setting to debug or default build mode makes no difference.

I know that having a launching application causes problems and I had turned it off and on many times, now after playing with the settings you recommended and putting them all back to what I had before, I do not get that "info address main" when the launching application is turned off.

So it seems that my problem is solved, but I cannot replicate the crash except for doing this:
Run - > Run Parameters - Use launching application = On

Thank you for your patience!

Mladen

  • New Member
  • *
  • Posts: 30
Re: Debugger error when running Lazarus when using Launching application
« Reply #8 on: July 13, 2018, 09:04:38 am »
I am getting the same error when using Ubuntu MATE 18.04 or Linux Mint 19 XFCE. GDB version is 8.1.
Any news about this issue?
Using Lazarus 2.0.12 with FPC 3.2.2 on Linux Mint 20.2 Xfce

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger error when running Lazarus when using Launching application
« Reply #9 on: July 13, 2018, 12:42:24 pm »
@Mladen: Most launching applications will break the debugger. There is not much that can be done about it.

Mladen

  • New Member
  • *
  • Posts: 30
Re: Debugger error when running Lazarus when using Launching application
« Reply #10 on: July 13, 2018, 12:47:42 pm »
Ok friend, thank you for your answer!

Cheers
Using Lazarus 2.0.12 with FPC 3.2.2 on Linux Mint 20.2 Xfce

abou.almontacir

  • New member
  • *
  • Posts: 7
Re: Debugger error when running Lazarus when using Launching application
« Reply #11 on: September 02, 2019, 11:40:20 pm »
I'm facing this very same issue. The debugger does not find the address of main on 64 bit systems when using launching application. However it will work correctly on 32 bits version.

The issue seems to be available on all Debian versions (1.6, 1.8, 2.0, 2.2). This makes Lazarus not usable for teaching programming to teenagers, unfortunately.

Can anyone help debugging or giving some hints how to debug this please?
« Last Edit: September 02, 2019, 11:54:03 pm by abou.almontacir »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger error when running Lazarus when using Launching application
« Reply #12 on: September 03, 2019, 01:03:58 am »
First of all there is no guarantee that a particular shell/terminal will work as launch-app.

But as for your error, that can probably be worked around:
Tools -> Options: Debugger > General (or Backend in Lazarus 2.1(

In the grid of options is an entry "InternalStartBreak". Set it to gdbsAddZero. That should get you one step further.

In Lazarus 2.1 you can also choose gdbsNone

------------------
Note that there is a simple input/output window in the menu View > debug windows > console output / yes it takes input too.

If you do need a real terminal to debug in, then there is another option. Use gdbserver. It is a bit more inconvinient...
In the terminal start  (I need to lookup what options you need to give)
  gdbserver ..... yourapp

Then yourapp will get access to the terminal.
In the IDE use the gdb-server debugger to connect to it.

Yes its a lot of extra steps... :(

« Last Edit: September 03, 2019, 01:08:06 am by Martin_fr »

abou.almontacir

  • New member
  • *
  • Posts: 7
Re: Debugger error when running Lazarus when using Launching application
« Reply #13 on: September 03, 2019, 03:57:51 pm »
Thank you Martin for you answer.

Actually I'm trying to setup Lazarus for teaching teenagers programming, so I need a very simple solution not involving running the program by hands in the terminal.

I've played with the configuration fields you mentioned but none worked on 2.0.2. However I finished by finding by finding something that my work by setting the gdb path to (none).

This will work for first courses as it will only involve ReadLn and WriteLn, but as soon as a debugger will be needed this will stop working.

I hope I can find the right solution till then, especially that as I've said the 32 bits Lazarus seems to do it right.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger error when running Lazarus when using Launching application
« Reply #14 on: September 03, 2019, 04:11:26 pm »
The problem is (IIRC, and that is memory from very long ago) that gdb only follows one process.

Most terminals (at least nowadays) fork a process (or several). If that happens gdb stays with the main process, and never sees the program that you launch in the terminal.
Therefore the Lauch-app is 99% no longer working.


Your problem with "main not found" happened before that. Pascal programs have a "main" location, that the IDE use for start-the-debugger tasks. Your terminal did not have that, so the IDE got lost. When you changed to dbgsAddZero, the error you get should have changed.


If all you do is readln/writeln without use of ansi sequences (that is: no fancy colors, no moving the cursor...), just plain text out and plian text in
Quote
writeln('What is your name');
readln(n);
writeln('Hello '+n);

Then the IDE's buildin console window (from the menu view > debug windows) should be just fine for you. (In that case you need no launch app).
IIRC it is called output, but it support input too. While focused, any key pressed is sent to the debugged app.


 

TinyPortal © 2005-2018