Lazarus

Using the Lazarus IDE => Debugger => Topic started by: GillesH on June 16, 2017, 03:38:55 pm

Title: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: GillesH on June 16, 2017, 03:38:55 pm
Hello,

I usually use Qt and LLDB. Xcode 8.3.3 is installed.
This morning I installed Lazarus to test unidac with Mac OS 10.12.5. I use it with Delphi.

Install of Lazarus : i386-darwin is already very unhappy. But I knew it.
But use gdb with Lazarus will quickly confuse you and rapidly send you crazy. :o I did not even imagine that.
So I'm looking for a step-by-step method to be able to debug from Lazarus with my configuration.
I built gdb-7.12.1 from its sources and signed it correctly, that is to say in the usual manner under 10.12.
The result with Lazarus :
Quote
La commande GDB :
"-exec-run"
a renvoyé l'erreur :
",msg="Unable to find Mach task port for process-id 699: (os/kern) failure (0x5).\n (please check gdb is codesigned - see 
It's.... impressive ! So a little bit out of a time loss for a normally so simple thing, I wonder if anyone has a reliable method, not for 10.8, 10.9... but 10.12.5, the current version of Mac OS X. Thank you in advance. Cordially. Gilles

Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: Phil on June 16, 2017, 03:52:00 pm
I usually use Qt and LLDB. Xcode 8.3.3 is installed.
This morning I installed Lazarus to test unidac with Mac OS 10.12.5. I use it with Delphi.

I would recommend that you create a temporary Xcode project for the Lazarus project and debug in Xcode with lldb. Here's how:

https://macpgmr.github.io/ObjP/ProjectXC.html
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: GillesH on June 16, 2017, 04:02:06 pm
Thank you for this answer.

No,... This is not what I'm looking for. Does your answer mean that we can not integrate a debugger in Lazarus mac ?

Regards.
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: GillesH on June 18, 2017, 03:33:38 pm
Hello,

Continuation and provisional end...

Sources : ftp://sourceware.org/pub/gdb/releases/
Tested :
gdb-7.12.1 without and with patch
ftp://sourceware.org/pub/gdb/releases/gdb-7.12.1.tar.gz
>> failed even with the patch https://mega.nz/#!VkBWVJ7J!LzA51cXfWPK_o7TrNz6jU5jMaNGGmkgH-tj5kj-DIpI

gdb-8.0
ftp://sourceware.org/pub/gdb/releases/gdb-8.0.tar.gz
>> Ok for the first tests

My approach :
1. In command lines :
Code: Pascal  [Select][+][-]
  1. cd downloads/gdb-8.0
  2. ./configure
  3. make
  4. make install (by default in /usr/local/bin, /usr/local/lib, etc)

2. Create a gdb-cert :
Do not forget to double click on your new gb-cert certificate : Turn down the "Trust" disclosure triangle and change :
3. In command lines :
Code: Pascal  [Select][+][-]
  1. sudo killall taskgated
  2. sudo codesign -fs gdb-cert /usr/local/bin/gdb

4. In Lazarus->Tools->Options->Debugger :

Close Lazarus and reboot.

Regards. Gilles
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: GillesH on June 19, 2017, 09:28:53 am
Hello,
It is true that I carried out many operations before they succeeded. I propose to check some settings ...

Regards. Gilles
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: carl_caulkett on June 19, 2017, 01:00:51 pm
Hello,
It is true that I carried out many operations before they succeeded. I propose to check some settings ...
  • Lazarus :
    • Version (http://www.sdeidev.com/lazarus/mac/debugger/170619-00.png)
    • Debugger (http://www.sdeidev.com/lazarus/mac/debugger/170619-01.png)
  • /usr/local/bin/gdb : executable permission

    Quote
    unMac:~ untel$ ls -l /usr/local/bin/gdb
    -r-xr-xr-x  1 untel  admin  8407456 18 jui 14:10 /usr/local/bin/gdb
    unMac:~ untel$ /quote]

Regards. Gilles
0
My system:

macOS 10.12.5
Lazarus 1.6.4
FPC 3.0.2
gdb --version
    GNU gdb (GDB) 8.0
ls -l /usr/local/bin/gdb
    -rwxr-xr-x  1 root  admin  8333564 18 Jun 16:44 /usr/local/bin/gdb
csrutil status
    System Integrity Protection status: disabled.


It's very much like your system, Gilles. Yet there must be some subtle difference. I wonder what it can be!

Cheers,
Carl
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: carl_caulkett on June 19, 2017, 01:03:44 pm
I usually use Qt and LLDB. Xcode 8.3.3 is installed.
This morning I installed Lazarus to test unidac with Mac OS 10.12.5. I use it with Delphi.

I would recommend that you create a temporary Xcode project for the Lazarus project and debug in Xcode with lldb. Here's how:

https://macpgmr.github.io/ObjP/ProjectXC.html

I can confirm that this suggestion of Phil's works pretty well, although there seem to be difficulties in accessing the contents of UnicodeStrings - AnsiStrings are ok.
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: GillesH on June 20, 2017, 12:09:14 pm
Hello,
The XCode method works well. But how can we integrate it more satisfactorily in Lazarus ?I do not see myself using this method every time I change my code when I encounter a serious problem.

Not definitely either there is a way to debug quickly and easily my programs compiled with Lazarus as with Qt, or I have to find something other than Lazarus.

Carl : We will not let go gdb any more so that I have to be able to replicate the method  ;D
/usr/local/bin/gdb size
Conclusion: these are not the same. I rebuild it to check that I was not mistaken in the references I gave.
Time to do the job and I come back. Gilles.
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: GillesH on June 20, 2017, 07:52:25 pm
Hello,

I took the time to completely uninstall gdb and Qt.
I run Lazarus and debug a project : Error ",msg...". OK. :D

I unarchived the archive gdb-8.0.tar.gz (http://www.sdeidev.com/lazarus/mac/debugger/gdb-8.0.tar.gz) in ~/downloads/gdb-8.0
Code: Pascal  [Select][+][-]
  1. cd ~/downloads/gdb-8.0
In sudo mode :
Code: Pascal  [Select][+][-]
  1. ./configure
  2. make
  3. make install

I keep my certificate "gdb-cert" which does not present anything particular.
In sudo mode :
Code: Pascal  [Select][+][-]
  1. killall taskgated
  2. codesign -fs gdb-cert /usr/local/bin/gdb

Reboot.

I run Lazarus. Result : It seems to work fine* (http://www.sdeidev.com/lazarus/mac/debugger/170620-03.png)

I will try again on another Mac later. Regards. Gilles

---
* I expect to use it more fully to be more affirmative.  :D
PS : System Integrity Protection status: disabled.

Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: carl_caulkett on June 20, 2017, 10:53:09 pm
Hello, I downloaded the GDB that you are hosting and did...
Code: Pascal  [Select][+][-]
  1. sudo ./configure
  2. sudo make
  3. sudo make install
  4.  

I am still getting the same size for gdb, namely...
Code: Pascal  [Select][+][-]
  1. s -l /usr/local/bin/gdb
  2. -rwxr-xr-x  1 root  admin  8333564 20 Jun 20:28 /usr/local/bin/gdb
  3.  ~ 
  4.  

This would suggest that the make and make install processes are different on our machines.

In any case, I think the problem in my case has more to do with the way Lazarus is configured to use GDB. Here is a screenshot of the Debugger options on my machine.

When I try to run an application I get an error message which mentions the Debugger_Startup_Options "set startup-with-shell off"
parameter. Am I doing something wrong here?


Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: GillesH on June 21, 2017, 12:06:43 pm
Hello Carl,

in Lazarus, this is my current debugger's configuration (http://www.sdeidev.com/lazarus/mac/debugger/170621-05.png).

I suppose your xcode (http://www.sdeidev.com/lazarus/mac/debugger/170621-04.png) command line tools is installed.

Regards. Gilles
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: carl_caulkett on June 21, 2017, 12:18:10 pm
Hello Gilles. I'm afraid it's still not working for me, but thanks very much for the trouble you've taken so far to help.

Could I ask one more favour? Could you post screenshots of your Project Options/Compiler Options, in particular, the "Compilation and Linking" page and the "Debugging" page? Mine are shown below:

 
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: GillesH on June 21, 2017, 12:36:23 pm
No problem.

But I'm going to start to worry if the installation is not reproducible.
I have 2 other mac mini but they are reserved for development Qt ... and if I start to tinker them, I will draw the wrath of my small team. (I do not know if this is said in English but it is the literal translation of well-french expressions)

Here are my 2 screenshots : 1 (http://www.sdeidev.com/lazarus/mac/debugger/170621-06.png) and 2 (http://www.sdeidev.com/lazarus/mac/debugger/170621-07.png)

Perhaps : sourceware.org/gdb/wiki/BuildingOnDarwin (https://sourceware.org/gdb/wiki/BuildingOnDarwin)
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: carl_caulkett on June 21, 2017, 05:19:21 pm
My versions from gcc and make are as follows:

Code: Pascal  [Select][+][-]
  1.  ~  gcc --version
  2. Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
  3. Apple LLVM version 8.1.0 (clang-802.0.42)
  4. Target: x86_64-apple-darwin16.6.0
  5. Thread model: posix
  6. InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  7.  ~  make --version
  8. GNU Make 3.81
  9. Copyright (C) 2006  Free Software Foundation, Inc.
  10. This is free software; see the source for copying conditions.
  11. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
  12. PARTICULAR PURPOSE.
  13.  
  14. This program built for i386-apple-darwin11.3.0
  15.  ~ 

What are yours? Since we built gdb from the same download, the difference must be in the build process, I would have thought.

Cheers,
Carl
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: GillesH on June 22, 2017, 09:20:50 am
Hello Carl,

gcc --version
Quote
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Have a nice day!
Regards. Gilles
make --versionGNU Make 3.81
Quote
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: carl_caulkett on June 22, 2017, 01:55:59 pm
LOL. They are identical! In any case, I am getting used to using Xcode to debug. It helps that I can still make GUI changes in Lazarus and have them instantly updated in Xcode. Obviously, this represents a mystery to be solved but it's not massively urgent. I guess we'll just have to wait for Lazarus 2.0, in which all the debugging shortcomings will have been solved!

Cheers,
Carl
Title: Re: Debugger Mac OS 10.12.5 Lazarus 1.6.4 rexported FPC 3.0.2 i386-darwin-carbon
Post by: Wil on July 28, 2017, 01:36:12 pm
Hello,

OMG, I had to much trouble getting gdb to play nice. Always got the dreaded error that my gdb was not signed.

This part of your message however was what made me realize the problem was elsewhere
Quote
unMac:~ untel$ ls -l /usr/local/bin/gdb
-r-xr-xr-x  1 untel  admin  8407456 18 jui 14:10 /usr/local/bin/gdb
unMac:~ untel$ /quote]

I had installed the fsf-gdb version of the debugger via fink and it turned out it had set the ownership of the file to defaults not under my user account.
Eg.
Quote
$ ls -al /sw/lib/fsf-gdb/fsf-gdb
-rwxr-sr-x  1 root  procmod  8792912 Jul 28 13:15 /sw/lib/fsf-gdb/fsf-gdb

Once I changed that via:
Quote
$ sudo chown myusername:admin /sw/lib/fsf-gdb/fsf-gdb

The debugger credential request login came up and things started to work.

Thank You so much for writing it out. Can't believe how long this took me to get right.

--
Wil
TinyPortal © 2005-2018