Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] Lazarus - MacOS X - XCode 4.6.3 GDB files

41 Posts
11 Users
0 Reactions
8,317 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

The file mentioned and attached in these posts have been signed by Apple - so no signing needed for gdb.

The time-out however might be avoidable, I've had that problem as well and I'm trying to remember what I did to fix it.

In the Tools -> Options -> Debugger section of Lazarus I've set the values as can be seen in the attachment.
It will give an error message because when you start debugging, I just have been to lazy to look at the "Debbuger_Startup_Option" (set to: "--eval-command=set startup-with-shell off" which has an error in it). However ... timeout does not occur and debugging works just fine ...


   
ReplyQuote
(@kenkelso)
Active Member
Joined: 11 years ago
Posts: 5
 

Thank you Hans but still no joy, I now get the following error:

The GDB command:

"-exec-run"

did not return any result.

Ken


   
ReplyQuote
(@kenkelso)
Active Member
Joined: 11 years ago
Posts: 5
 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

I stand corrected, sorry ... I totally forgot that I used the brew install method for GDB and signed it myself.

See also: Lazarus Forum, Lazarus Wiki and this article at GetLazarus.org (recommend reading this one!).

It seems that not Lazarus has been affected by this, even Embarcadero's Delphi is running into this issue.
Seems the latest version of GDB is needed, since it seems to address one of these macOS Sierra related issues.

I'm a little disappointed in Apple for dropping GDB, but I'm also wondering why LLDB is not used by the Lazarus team. There probably is a good reason, I'm just not aware what it might be.


   
ReplyQuote
(@kenkelso)
Active Member
Joined: 11 years ago
Posts: 5
 

@Hans

I finally got it working, there has been an update to gdb to fix it for Seirra, (gdb-7.12.1.sierra.bottle.tar.gz) deleted gdb then re-install with HomeBrew, codesigned and all was well.

brew install gdb

Thanks for your help

Ken


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

Awesome Ken! 

Good to hear you've got it to work - wish someone would precompile and presign gdb so we just would have to download gdb hahah ...
Like a package deal for the Mac: FPC, FPC sources, Lazarus and GDB in one install file.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

Just tested 7.12.1 but when I clear the "startup-options" line, it fails as well.
Re-entering the startup options, generates the error message again, but ... it works otherwise (breakpoints included).

Did you do any special settings?
I even tried

echo "set startup-with-shell off" >> ~/.gdbinit

But that did not seem to have any effect in 7.12 and 7.12.1. (recommended here)


   
ReplyQuote
(@kenkelso)
Active Member
Joined: 11 years ago
Posts: 5
 

Settings in the attached screenshot:


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

Alright, so here the steps I followed to get GDB installed under macOS Sierra using HomeBrew (MacPorts and Fink is an option as well).

1. Install HomeBrew

ruby -e "$(curl -fsSL  https://raw.githubusercontent.com/Homebrew/install/master/install )"

2. Install GDB

brew install gdb

3. Create a certificate for code signing

Start the Keychain Access application (Applications -> Utilities -> Keychain Access.app).
Open the menu item Keychain Access -> Certificate Assistant -> Create a Certificate...

Choose a name (gdb-cert for example),
set Identity Type to Self Signed Root,
set Certificate Type to Code Signing and
check the Let me override defaults option. 

Click several times on Continue until you get to the Specify a Location For The Certificate screen, and set Keychain to System.

Right click the new certificate in the list, select Get Info, open the Trust item, and set Code Signing to Always Trust.

Finally, quit Keychain Access application to refresh the certificate store.
It is best to reboot your computer now to refresh everything, but you can also kill and restart taskgated but that seems the less reliable method.

4. Code Sign GDB

Assuming that the certificate is known as gdb-cert, use:

sudo codesign -s gdb-cert gdb

The easiest way is to first cd to the location of GDB, or specify the full path (mine was located in /usr/local/Cellar/gdb/7.12.1/bin).

5. GDB tweaking for Sierra (might not be needed)

For macOS 10.12 (Sierra) and later, you must gdb 7.12.1 or later.

Additionally prevent gdb from using a shell to start the program to be debugged.
You can use the following command for this inside gdb:

set startup-with-shell off

You can also put this last command in a file named ".gdbinit" in your home directory, in which case it will be applied automatically every time you start gdb.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

Troubleshooting;

1) Verify if GDB is signed correctly:

codesign -v gdb

should print nothing if everything is OK.

2) Debugger settings in Lazarus:

In Lazarus go to Tools -> Options -> Debugger -> General.
Check "DisbaleLoadSymbolsForLibraries" (unless you're writing your own library of course).
Uncheck "WarnOnTimeOut".

Optional:
- I have set "TimeoutForEval" to 5000 - which might be a little high and I'm not sure if it's needed.
- I have checked "Reset Debugger after each run"

3) Force GDB permissions and owners in Terminal:

chmod 755 gdb
chgrp admin gdb

4) If this still doesn't work ...

Well, this seemed to do the trick for me (again; In Lazarus go to Tools -> Options -> Debugger -> General.
Set "Debugger_Startup_Options" to "--eval-command=set startup-with-shell off" (include the double quotes!!!).
The only annoying issue with this approach is the message that appears each time you run one of your projects (see attachment). Click OK and your project runs and can be debugged ,... including breakpoints.


   
ReplyQuote
(@sunshinechen)
New Member
Joined: 8 years ago
Posts: 2
 

Thanks for you post. I'm reading on here to learn more details in this filed. You guide is much helpful to me. 


   
ReplyQuote
Page 3 / 3
Share: