Recent

Author Topic: How to run Lazarus and GNU GDB on OS X Maverick  (Read 34433 times)

rale

  • New member
  • *
  • Posts: 5
How to run Lazarus and GNU GDB on OS X Maverick
« on: November 03, 2013, 09:33:59 pm »
With Maverick, Apple introduced Xcode 5 and dropped GDB in favor of the LLDB debugger. Because Lazarus doesn't support LLDB (yet), Lazarus fails running compiled applications if the Debugger (Default: GNU debugger (gdb)) isn't disabled. Developing without debugger isn't really funny :(

Searching the forum and the internet suggests to compile GDB from the sources, for example using MacPorts. Even MacPorts successfully compiled and installed GDB, I run into errors using GDB from inside Lazarus, as others too. 

SOLUTION

A much simpler approach is, to install Xcode 4.x side by side to Xcode 5.x. I could retrieve Xcode 4.6.3 from my TimeMachine backup and copied it into the /Application folder, renamed to Xcode_4.6.3. Inside the package Xcode_4.6.3.app gdb is located in the folder Contents/Developer/usr/bin, named gdb. Thus the complete path to gdb (in my example) is

/Applications/Xcode_4.6.3.app/Contents/Developer/usr/bin/gdb

Copy this path into the debugger configuration field of Lazarus.

Have fun again, using Lazarus and GDB on OS X Mavericks.

rale
« Last Edit: November 06, 2013, 01:14:45 pm by rale »
OS : OS X Maverics 10.9.4
Laz: Lazarus 1.2.4 FPC 2.6.4 i386-darwin-carbon

Brian Coleman

  • New Member
  • *
  • Posts: 34
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #1 on: November 05, 2013, 07:58:53 pm »
Hi rale,

I just did what you wrote. It took about 3 minutes in all and it works perfectly.

I copied the Xcode app - 3.54 GB - via network cable from my MacBook Pro (still OS 10.8) - renamed as you said - into my MacMini Applications folder, started Lazarus which straightaway asked for the Debugger file path it couldn't locate.
 A simple cut and paste from your posted message, and IT WORKS !!

CANT THANK YOU ENOUGH.

Hopefully this gets noticed by all who need it.

It would be nice if someone could persuade Apple to do a simple fix for the next update.

Brian Coleman

jwdietrich

  • Hero Member
  • *****
  • Posts: 1188
    • formatio reticularis
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #2 on: November 05, 2013, 08:51:15 pm »
That is very good news. I have updated the corresponding article in the Lazarus wiki to reflect your suggestion.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.0.12 | FPC 3.2.0 | PPC, Intel, ARM | macOS, Windows, Linux

Brian Coleman

  • New Member
  • *
  • Posts: 34
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #3 on: November 06, 2013, 12:07:51 pm »
Hi again,
As rale's great discovery is currently so important to every Lazarus user who has a Mac, I add a few specific details which might be of use to people who, like myself, have gaps in their IT knowledge.

Up to about 10 days ago, I was running Lazarus 1.0.12 on my MacMini and MacBook Pro, both under OS 10.8 with Xcode installed and running as described by others on this forum.
The previous snapshot 1.1.40800 of last April no longer worked by the way, so I was happy with 1.0.12. (and updated fpc and fpc sources).

Then I installed Mavericks on the MacMini, followed by Xcode etc. and ran the terminal command recommended:  Xcode-select --install

Delight in Mavericks was followed by the shock of Lazarus not working.
Fortunately I still had OS 10.8 on my MacBook Pro.
Scanning the Forum and Google gave the impression that there may be no short term solution and that I would need to install Ubuntu Linux on my MacMini just to be able to use Lazarus on it.
In desperation I installed pre-release version 1.1.99 (and fpc/fpc sources).
Same problem. Then I spotted rale's posting as described above.

So (partly repeating myself) the solution is to get hold of someone with a MacBook with OS 10.8, and using a 5GB usb stick (Mac-formatted), or by networking,  copy the Xcode app (3.54GB) from their Applications file onto your own Desktop. Rename it (as rale recommends) Xcode_4.6.3 and move it beside the Xcode 5 version in your Applications folder.
On Lazarus start a "Configure Lazarus IDE" appears.
Paste in rale's path:  "/Applications/Xcode_4.6.3.app/Contents/Developer/usr/bin/gdb"

Click "Start IDE" and you're airborne.

I presume this works also with 1.0.12, as it does with pre-release version 1.1.99.

Alan Turing would be smiling.

Brian Coleman











rale

  • New member
  • *
  • Posts: 5
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #4 on: November 06, 2013, 01:02:39 pm »
@Brian
@jwdietrich

I'am glad I could help.

rale
OS : OS X Maverics 10.9.4
Laz: Lazarus 1.2.4 FPC 2.6.4 i386-darwin-carbon

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 922
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #5 on: November 07, 2013, 12:29:22 am »
For the record: Apple does not support running any Xcode version other than 5.0.1 under OS X 10.9 (that includes command line tools that are installed alongside Xcode, such as gdb). So while that gdb may currently work, it can break at any time.

peteness

  • Newbie
  • Posts: 4
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #6 on: November 07, 2013, 12:35:10 am »
More details here - I had no backup of Xcode 4, so tried a few things.  First off, I got a locally-built gdb *mostly* working (in a lot of cases), but it wasn't reliable on complex applications. My advice is to not try to get a V7 gdb built if you want reliable debugging.

Thanks to the tips in this thread, though, I got it going with the following steps:

* Download Xcode 4.6.3 from developer.apple.com.
* Open the .dmg - it will open with a "Drag to your apps folder" instruction.  Instead of doing that, right-click Xcode and "Show Package Contents".
* Copy the (.app)/Contents/Developer/usr/bin/gdb file to your local /usr/bin folder.
* Copy the (.app)/Contents/Developer/usr/libexec/gdb *folder* to /usr/libexec
* Point Lazarus at /usr/bin/gdb (if it's not already pointed there).

Done!

Hope that saves some time for someone.  This way you don't need to have a full 4.6.3 Xcode.app...

Brian Coleman

  • New Member
  • *
  • Posts: 34
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #7 on: November 07, 2013, 06:56:20 pm »
Hi,

peteness's great insight actually means that only two files TOTALLING 7MB are needed.

      (.app)/Contents/Developer/usr/bin/gdb

and

     (.app)/Contents/Developer/usr/libexec/gdb/gdb-i386-apple-darwin

So if you have a friend who can email you these two files (Xcode 4.6.3), put them in a Desktop/TEMPDIR folder together.

Then get superuser permission:
  see  http://support.apple.com/kb/PH14281
Note: 'Choose edit..' means select Edit in the top screen menu bar etc.

Four terminal commands must then be executed.
(1)  Make the current directory /usr/libexec:

   cd /usr/libexec

(2) Make a directory gdb in this folder /usr/libexec  :

    mkdir gdb     
   
(3)   copy the gdb-i386-apple-darwin into the newly created folder: 

     /bin/cp   /Users/.../Desktop/TEMPDIR/gdb-i386-apple-darwin      /usr/libexec/gdb/gdb-i386-apple-darwin


(4)   copy the gdb file  :

    /bin/cp /Users/.../Desktop/TEMPDIR/gdb    /usr/bin/gdb

Thats all.

You check things using pwd and ls commands.

Don't forget to change back i.e. disable your root permissions (or you may be sorry later).

All this is of course child's play for the guru's, but it's so easy to foul up.

I have just installed Lazarus 1.2RC1 and it works fine if told where to find gdb (i.e. in /usr/bin) .

Maybe someone can twist Apple's arm to just please include these two files in their next upgrade.

After all, the coming Mac Pro (red or black) is worth far less if the best software package on the planet (not kidding) can't run on it.

Thanks again to rale and peteness.

Brian Coleman

« Last Edit: November 07, 2013, 07:00:59 pm by Brian Coleman »

Brian Coleman

  • New Member
  • *
  • Posts: 34
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #8 on: November 14, 2013, 06:03:34 pm »
Hi again,

Following my own advice as above, I upgraded my Macbook Pro to Mavericks OS 10.9, with new Xcode, and inserted the two gdb files as suggested above.

The project code which which runs ok on the Macmini (see terminal script test below), HANGS on the newly upgraded Macbook Pro, although everything is seemingly identical.

To try to figure out what is going on I started lazarus in a terminal and got the following results:

SUCCESSFUL MacMini TERMINAL LAUNCH:

Last login: Thu Nov 14 16:21:26 on ttys000
Brian-Colemans-Mac-mini:~ briancoleman$ /Developer/lazarus/lazarus
CarbonFontIDToFontName Error: ATSUFindFontName Length failed with result -8905
.
.
.
CarbonFontIDToFontName Error: ATSUFindFontName Length failed with result -8905
TMainIDE.ParseCmdLineOptions:
  PrimaryConfigPath="/Users/briancoleman/.lazarus"
  SecondaryConfigPath="/etc/lazarus"

==============================================

TLazSourceFileManager.LoadLFM Creating designer for hidden component of /Users/briancoleman/Desktop/AKROCONSOLENNEW/umain.pas
TLazSourceFileManager.OpenProjectFile select form in designer: FormM:TFormM TDesigner


THIS RUNS OK !!!!
*************************************************************


FAILED MacBookPro TERMINAL LAUNCH  (Exactly the same project Folder contents / OS10.9 and two gdb files):

BCBook-Pro:~ briancoleman$ /Developer/lazarus/lazarus
CarbonFontIDToFontName Error: ATSUFindFontName Length failed with result -8905
.
.
.
CarbonFontIDToFontName Error: ATSUFindFontName Length failed with result -8905
TMainIDE.ParseCmdLineOptions:
  PrimaryConfigPath="/Users/briancoleman/.lazarus"
  SecondaryConfigPath="/etc/lazarus

===============================================

TCarbonTabsControl.SetFocus Error: SetKeyboardFocus  failed with result -30585
TSourceEditorSharedValues.GetMainLinkScanner CodeBuffer=nil

MacBook Pro HANGS !!!!

*************************************************************


Any hints towards a remedy would be most welcome.

Brian Coleman

Hansaplast

  • Hero Member
  • *****
  • Posts: 612
  • Tweaking4All.com
    • Tweaking4All
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #9 on: November 20, 2013, 07:57:51 am »
This trick worked great on my MacBook Pro (15" Retina),... thanks! 

If anyone is looking for the needed files; I've made them available here:  :-[
Tweaking4All Forum (2.7 Mb download).

sysrpl

  • Sr. Member
  • ****
  • Posts: 250
    • Get Lazarus
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #10 on: November 20, 2013, 04:27:45 pm »
Another solution which I came up with:

I have Mavericks installed and was able to setup debugging using macports:

curl https://distfiles.macports.org/MacPorts/MacPorts-2.2.1-10.9-Mavericks.pkg -o macports.pkg
sudo installer -pkg macports.pkg -target /
sudo port install gdb

The debugger will then be located at:

/opt/local/bin/ggdb

You will need to sign ggdb using the setups provided here:

http://www.opensource.apple.com/source/lldb/lldb-69/docs/code-signing.txt

Substitute ggdb for lldb and it should work.

Brian Coleman

  • New Member
  • *
  • Posts: 34
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #11 on: November 20, 2013, 06:23:42 pm »
Hi again   - happy to report progress:

Having got Lazarus 1.21 running successfully as described above on my MacMini under Mavericks, but failed to do so on my subsequently newly fresh installed Mavericks on my McBook Pro 17" (early 2009) since Lazarus 1.21 just `hung' on start.
See results above on terminal starts.

I then tried installing gdb using 'home-brew' on the Macbook and this seemed to complete ok, although gdb landed in /usr/local/bin instead of /usr/bin etc.
Still the same problem on starting lazarus and the same response info on terminal start.
This terminal info (see above posting) however GOT ME WONDERING. So I downloaded lazarus-1.0.12 again AND IT WORKED !
I then tried the latest lazarus-1.0.14. IT WORKS ALSO !!

So I'm much relieved but still wonder why lazarus-21 works under mavericks on my MacMini but not on my MacBook Pro.

It seems the simple two file approach is fine available per download from Hansaplast (see above) for everybody. Danke schoen.

I suppose this info may interest the developers of lazarus-1.21  -please someone pass on, as I'm not sure how to contact them.

Thanks again anyway to all those involved.

Brian Coleman


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7519
  • Debugger - SynEdit - and more
    • wiki
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #12 on: November 20, 2013, 07:15:06 pm »
the hang on startup is not related to the gdb issue. But it is known, and there are bug reports

Hansaplast

  • Hero Member
  • *****
  • Posts: 612
  • Tweaking4All.com
    • Tweaking4All
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #13 on: November 20, 2013, 09:32:32 pm »
It seems the simple two file approach is fine available per download from Hansaplast (see above) for everybody. Danke schoen.

Gern geschehen  8)
(you're welcome)

p.s. I tend to agree with Martin_fr ... my MacBook Pro works just fine with the XCode gdb files ...

sysrpl

  • Sr. Member
  • ****
  • Posts: 250
    • Get Lazarus
Re: How to run Lazarus and GNU GDB on OS X Maverick
« Reply #14 on: November 21, 2013, 04:19:13 am »
Still the same problem on starting lazarus and the same response info on terminal start.

http://bugs.freepascal.org/view.php?id=25322

Try the patch in the bug report above. I had a hang on startup problem and the patch fixed it for me.

 

TinyPortal © 2005-2018