Recent

Author Topic: Debugger broken in Yosemite  (Read 8920 times)

Daniello

  • Jr. Member
  • **
  • Posts: 64
Debugger broken in Yosemite
« on: May 01, 2015, 09:11:50 pm »
I got a new Macbook, with Yosemite (before I was using Lion) and the debugger in Lazarus no longer works  %)

I followed the instructions from here
http://wiki.lazarus.freepascal.org/GDB_on_OS_X_Mavericks_and_Xcode_5

When launch Lazarus and run my app I get a popup asking for inserting a password. I insert, the program runs, but no breakpoints trigger.

After I stop the program, I get 2 or 3 Lazarus popups with debugger error message ("something wrong happened").

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger broken in Yosemite
« Reply #1 on: May 01, 2015, 09:28:42 pm »
Have you checked those steps of your setup http://wiki.lazarus.freepascal.org/Debugger_Setup

Ensure to use dwarf. You may have to chekc *every* package, since every package can have its own options.


Can you run gdb form the console?

/path/to/gdb /path/to/yourproject.app/Contents/MacOS/yourproject
then in gdb enter "r" (without the quotes) and hit return.


What are the errors?

kamischi

  • Full Member
  • ***
  • Posts: 177
Re: Debugger broken in Yosemite
« Reply #2 on: May 01, 2015, 10:00:57 pm »
As much as I know, Xcode on Yosemite has only lldb and no gdb. I have no experience, whether and if so how well lldb works. gdb can still be installed through fink in an older version with apple-hacks and a recent version without apple-hacks.

Michael.
fpc 2.6.4, lazarus 1.4.0, Mac OS X, fink

Daniello

  • Jr. Member
  • **
  • Posts: 64
Re: Debugger broken in Yosemite
« Reply #3 on: May 01, 2015, 10:07:28 pm »
kamishi, in the link I posted to the lazarus wiki there's a tutorial how to get gdb in latest OSX, I had followed it before.

Martin_fr, thanks for the link, I double checked everything, there was only one thing missing in my project settings, I changed debug info from 'automatic' to 'dwarf with sets' and now breakpoints work!

If someone from Lazarus team reads this,  I suggest checking what's the problem with the 'automatic' settings in OSX.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger broken in Yosemite
« Reply #4 on: May 01, 2015, 11:08:14 pm »
Automatic actually means "fpc default"
So it seems at least in fpc 2.6.4 that is still stabs on OSX.


The general problem is known, and some sort of better feedback or setting in the IDE will be needed. Not sure how soon we will be able to provide this.


kamischi

  • Full Member
  • ***
  • Posts: 177
Re: Debugger broken in Yosemite
« Reply #5 on: May 01, 2015, 11:55:39 pm »
Automatic actually means "fpc default"
So it seems at least in fpc 2.6.4 that is still stabs on OSX.

The general problem is known, and some sort of better feedback or setting in the IDE will be needed. Not sure how soon we will be able to provide this.
The fink package description of lazarus has an according patch of ide/compileroptions.pp. Here it is:

# change Debug format from stabs to dwarf
   sed -i.bak "s|GenerateDwarf/Value', false|GenerateDwarf/Value', true|g" ide/compileroptions.pp
fpc 2.6.4, lazarus 1.4.0, Mac OS X, fink

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Debugger broken in Yosemite
« Reply #6 on: June 12, 2015, 03:42:26 pm »
I just installed Yosemite 10.10.3 and am still having some issues running gdb in Lazarus 1.4.0. I used Homebrew to install gdb 7.9.1, and set "Type of debug info" to "Dwarf with sets".

The debugger is stopping at breakpoints, but when I stop the program I get a "GDB has encountered an internal error" message, and then a "Debugger error" message.

Any additional information on how to fix this would be greatly appreciated.

Cheers,
VTwin

“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

kamischi

  • Full Member
  • ***
  • Posts: 177
Re: Debugger broken in Yosemite
« Reply #7 on: June 12, 2015, 03:49:39 pm »
Code signing might be the problem. Check the wiki for how to code signing gdb.
fpc 2.6.4, lazarus 1.4.0, Mac OS X, fink

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Debugger broken in Yosemite
« Reply #8 on: June 12, 2015, 03:55:59 pm »
Thanks kamischi,

I did follow the code signing wiki, and it seemed to run in the terminal after, so I think I did it right.

Code: [Select]
GNU gdb (GDB) 7.9.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin14.3.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb)

VTwin
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Debugger broken in Yosemite
« Reply #9 on: June 12, 2015, 04:02:32 pm »
I did notice that "Dwarf with sets (-gw -godwarfsets)" actually generates -gw2 -godwarfsets.

Trying "Automatic (-g)" and adding -gw in "Additions and Overrides" did not make a difference.

Trying Dwarf2 (-gw2) did not make a difference.
« Last Edit: June 12, 2015, 04:06:27 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger broken in Yosemite
« Reply #10 on: June 12, 2015, 04:29:40 pm »
The debugger is stopping at breakpoints, but when I stop the program I get a "GDB has encountered an internal error" message, and then a "Debugger error" message.

If the debugger stops at breakpoints, and by implication it launches your exe, then
1) yes codesigning is ok
2) at least the code/unit in which it stops at breakpoints uses dwarf

"internal error"
Some version of gdb do that. This indicates a bug in gdb.

A few common possibilities (though most have been encountered on windows, it is possible that it applies to other platforms too.)

1) Try DisableLoadSymbolsForLibraries
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#internal-error:_clear_dangling_display_expressions

2) My own tests have shown that GDB 7.8.x does crash more often than 7.7.1. I have not tested 7.9.x yet. You may whish to try and build a version 7.7.1 GDB

3) You can supply a logfile
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session
This may (or may not) reveal any clue into what is happening

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Debugger broken in Yosemite
« Reply #11 on: June 12, 2015, 04:56:16 pm »
Martin,

I set "DisableLoadSymbolsForLibraries" to "True", but that did not make a difference.

I will try to figure out how to build GDB 7.7.1

Thanks,
VTwin
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Debugger broken in Yosemite
« Reply #12 on: June 12, 2015, 06:55:56 pm »
Thanks, I seem to have it running. For anyone running into this, here are some tips that worked for me:

Upgrade to Xcode 6.3.2.

Install the Apple version of GDB gdb-apple using MacPorts. I followed directions here:

http://ntraft.com/installing-gdb-on-os-x-mavericks/

This appears to be GNU gdb 6.3.50. You can ignore the warning about the Yosemite patch, it seems to be fixed. I also installed apple-gcc42, which may not be necessary.

I certified it following the instructions there, except I named it "gdb-apple-cert", and set the validity period to "3650".

Finally, in Lazarus I set the debugger path to "/opt/local/bin/gdb-apple"

 
« Last Edit: June 12, 2015, 07:04:12 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger broken in Yosemite
« Reply #13 on: June 12, 2015, 08:47:55 pm »
Note that the "apple" gd 6.3.50 is not bug free either (but no gdb version is)

The IDE by default gives warnings in some situations that are caused by the 6.3.50. You can disable them in the options, by setting  "WarnOnTimeOut" to False.
You can also set "TimeOutForEval" to 50.

Background:
gdb does not print the prompt " (gdb)" for the next command. The reason for his is not known. But probably an internal error in GDB. Yet so far everyone who had this, reported that it did *not* cause any problems for the rest of the debug session.

So the IDE has to guess (actually it performs some tests to establish the correct state)

I also recommend to check the option "Reset debugger after each run" (This may slightly increase the time F9 needs to start your app)

 

TinyPortal © 2005-2018