* * *

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

vfclists

  • Hero Member
  • *****
  • Posts: 823
    • 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?
Windows - Lazarus 1.0.8/FPC 2.6.0
Linux - Lazarus 1.4.4 /FPC 2.6.4

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4350
    • 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: 823
    • 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.
Windows - Lazarus 1.0.8/FPC 2.6.0
Linux - Lazarus 1.4.4 /FPC 2.6.4

AnthonyTekatch

  • New member
  • *
  • Posts: 20
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: 4350
    • 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

  • New member
  • *
  • Posts: 20
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: 4350
    • 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

  • New member
  • *
  • Posts: 20
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!

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus