Recent

Author Topic: Problems with Debugger on OSX  (Read 4204 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5524
    • wiki
Re: Problems with Debugger on OSX
« Reply #45 on: April 26, 2019, 11:16:56 am »
The dylib info was only for if you were interested. Its of no difference to me.

The watches would be down to whatever caused that error.
Btw, the text of the error, is it "The debugger encountered some errors/warnings while launching the target application"?
Because "Unable to load Dwarf Debug Info", I am not aware of.

The error dlg, does it have a "more" button? What info does it provide?

ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #46 on: April 26, 2019, 02:10:35 pm »
Hi

Quote
Btw, the text of the error, is it "The debugger encountered some errors/warnings while launching the target application"?
Because "Unable to load Dwarf Debug Info", I am not aware of.

The error dlg, does it have a "more" button? What info does it provide?

The exact message is attached

Cheers
OS: OSX High Sierra 10.13.6
Lazarus: 2.1.0, r61162

Widgetset: Cocoa
Target: 64bit OSX

Compiler:
FPC 3.0.4 [2017/11/26] for x86_64

Debug:
LLDB  (with fpdebug)(Beta)
Path: /usr/bin/lldb
Version: lldb-1000.11.38.2

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5524
    • wiki
Re: Problems with Debugger on OSX
« Reply #47 on: April 26, 2019, 08:47:06 pm »
Ok, I did a patch with some more debugln output.

To apply it, download then
Code: [Select]
cd /path_to/lazarus
patch -p1 <path_to_download/lldb-debugln.patch

If you can also add
DBG_ERRORS to the list of --debug-enable, or if you added it to "config build laz" then there you add: -dDBG_ERRORS (and recompile the IDE)
Thanks

ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #48 on: April 26, 2019, 10:56:47 pm »
Thanks

Patch applied, recompile done, application run incl. break point and new log attached

Cheers
OS: OSX High Sierra 10.13.6
Lazarus: 2.1.0, r61162

Widgetset: Cocoa
Target: 64bit OSX

Compiler:
FPC 3.0.4 [2017/11/26] for x86_64

Debug:
LLDB  (with fpdebug)(Beta)
Path: /usr/bin/lldb
Version: lldb-1000.11.38.2

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5524
    • wiki
Re: Problems with Debugger on OSX
« Reply #49 on: April 26, 2019, 11:26:11 pm »
And we are one step closer. This one is probably the reason why you got the crash at the very beginning of this forum-thread.


Now, your project should have (and with the given upper/lower case)
/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app

I assume that is the app bundle?
So if looked at from a terminal "ls /mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/*" Should list the content of that bundle.

Can you get me the contents of that folder (recursive)?

I would expect
/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/ Contents / MacOs / MyStamps

In the given upper/lower case. (without the spaces, they are for human readability only)

This file should be a symlink to
/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps

Would be good to do an
ls -la
on each folder.

For some reason the IDE does not find that nested file.

It could also be that the IDE has issues recognizing symlinks on your NAS.

Thanks


ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #50 on: April 26, 2019, 11:42:55 pm »
Hi.

Here you go ...

Quote
study:~ andy$
study:~ andy$ ls -laR /mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app
total 0
drwxrwxr-x  1 andy  wheel   264 16 Apr 08:56 .
drwxrwxr-x  1 andy  wheel  2744 27 Apr 08:52 ..
drwxrwxr-x  1 andy  wheel   264 16 Apr 09:17 Contents

/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents:
total 16
drwxrwxr-x  1 andy  wheel   264 16 Apr 09:17 .
drwxrwxr-x  1 andy  wheel   264 16 Apr 08:56 ..
-rwxrwxr--  1 andy  wheel  1231 16 Apr 09:17 Info.plist
drwxrwxr-x  1 andy  wheel   264 16 Apr 08:56 MacOS
-rwxrwxr--  1 andy  wheel     9 16 Apr 08:56 PkgInfo
drwxrwxr-x  1 andy  wheel   264 16 Apr 08:56 Resources

/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/MacOS:
total 8
drwxrwxr-x  1 andy  wheel  264 16 Apr 08:56 .
drwxrwxr-x  1 andy  wheel  264 16 Apr 09:17 ..
lrwxrwxrwx  1 andy  wheel   17 16 Apr 08:56 MyStamps -> ../../../MyStamps

/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/Resources:
total 0
drwxrwxr-x  1 andy  wheel  264 16 Apr 08:56 .
drwxrwxr-x  1 andy  wheel  264 16 Apr 09:17 ..
study:~ andy$


.. and just for good measure to show the symbolic link points to the executable. ...

Quote
study:~ andy$ ls -l /mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps
-rwxrwxr-x  1 andy  wheel  51689624 27 Apr 08:46 /mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps

study:~ andy$ file /mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps
/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps: Mach-O 64-bit executable x86_64

I'm going to copy the project to my local drive and try off-NAS. Might take a little longer so I'll get back to you on that

Cheers
OS: OSX High Sierra 10.13.6
Lazarus: 2.1.0, r61162

Widgetset: Cocoa
Target: 64bit OSX

Compiler:
FPC 3.0.4 [2017/11/26] for x86_64

Debug:
LLDB  (with fpdebug)(Beta)
Path: /usr/bin/lldb
Version: lldb-1000.11.38.2

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5524
    • wiki
Re: Problems with Debugger on OSX
« Reply #51 on: April 26, 2019, 11:46:52 pm »
May have to have a look at fpc fileexist....

Just on the off chance, is the folder containing the project
/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/
by any chance a sym link?


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5524
    • wiki
Re: Problems with Debugger on OSX
« Reply #52 on: April 26, 2019, 11:54:22 pm »
Also just create a new project, and exectue the following code, and see what output you get:


Code: Pascal  [Select]
  1. debugln(['fileexist ', fileexists('/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/MacOs/MyStamps')])
  2. debugln(['fpgeterrno ', fpgeterrno()]);
  3. debugln([ToSingleByteFileSystemEncodedFileName('/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/MacOs/MyStamps')]);
  4.  

ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #53 on: April 27, 2019, 01:45:45 am »

I copied the project my local drive and the debug works fine locally.

Quote
Just on the off chance, is the folder containing the project /mnt/NAS/Documents/Andy/Pascal/src/MyStamps/ by any chance a sym link?

No it's not.

I have an AFP share on the NAS mounted on the Mac as /mnt/NAS/Documents, all of the folders that make up Andy/Pascal/src/MyStamps are real, none are links

To help eliminate any possibility that I might have missed, or maybe any issue with path length, I created and moved everything to a new mount, but it made no difference


Quote
Also just create a new project, and exectue the following code, and see what output you get:

I've done that, but I don't think anything was logged by debugln's you asked for .. Heres the code .... Have I missed anything?

Code: Pascal  [Select]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, LazLogger, LazLoggerBase, FileUtil, BaseUnix;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     procedure Button1Click(Sender: TObject);
  17.   private
  18.  
  19.   public
  20.  
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. { TForm1 }
  31.  
  32. procedure TForm1.Button1Click(Sender: TObject);
  33. begin
  34.      debugln(['fileexist ', fileexists('/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/MacOs/MyStamps')]);
  35.      debugln(['fpgeterrno ', fpgeterrno()]);
  36.      debugln([ToSingleByteFileSystemEncodedFileName('/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/MacOs/MyStamps')]);
  37.      Close;
  38. end;
  39.  
  40. end.
  41.  

The log is attached. I was surprised to see the size of it...its much bigger than previous logs, for a much simpler program

On the up side, my wife is mowing the lawn, so this has saved me from that work :)

Cheers
OS: OSX High Sierra 10.13.6
Lazarus: 2.1.0, r61162

Widgetset: Cocoa
Target: 64bit OSX

Compiler:
FPC 3.0.4 [2017/11/26] for x86_64

Debug:
LLDB  (with fpdebug)(Beta)
Path: /usr/bin/lldb
Version: lldb-1000.11.38.2

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5524
    • wiki
Re: Problems with Debugger on OSX
« Reply #54 on: April 27, 2019, 01:58:24 am »
My bad. I should have been more clear.

I did not need the IDE log for that small app.

Instead, either:
- compile the app
- go to the console
- run the app from the console
It will print its own output

or:
- compile the app
- run it with commandline arg (Run >Run Parameters)
    --debug-log=file
And the output will be in the file.


Of course when you run the app, the file
/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/MacOs/MyStamps
should exist.

The hope is, that the "fileexists" will fail the same way, is it does in the IDE. And that the next line prints why it failed.

The last line, is copied from inside the fpc implementation of fileexists. Just to be sure there is nothing unexpected in that part.

ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #55 on: April 27, 2019, 02:00:04 am »
No worries, I'd just figured that out!...

Quote
fileexist False
fpgeterrno 25
/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/MacOs/MyStamps
OS: OSX High Sierra 10.13.6
Lazarus: 2.1.0, r61162

Widgetset: Cocoa
Target: 64bit OSX

Compiler:
FPC 3.0.4 [2017/11/26] for x86_64

Debug:
LLDB  (with fpdebug)(Beta)
Path: /usr/bin/lldb
Version: lldb-1000.11.38.2

ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #56 on: April 27, 2019, 02:06:44 am »
Cancel my last post!


I noticed a typo MacOs should have been MacOS ...


Quote
fileexist True
fpgeterrno 25
/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/MacOS/MyStamps
OS: OSX High Sierra 10.13.6
Lazarus: 2.1.0, r61162

Widgetset: Cocoa
Target: 64bit OSX

Compiler:
FPC 3.0.4 [2017/11/26] for x86_64

Debug:
LLDB  (with fpdebug)(Beta)
Path: /usr/bin/lldb
Version: lldb-1000.11.38.2

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5524
    • wiki
Re: Problems with Debugger on OSX
« Reply #57 on: April 27, 2019, 02:36:48 am »
Ah!

And yes, Apple documents it as MacOS too.

Though the IDE has several places that do MacOs (that where I copied it from, so it was no type (not in my post, maybe in the IDE though)).

Strange that it works sometimes....
Maybe if files are on a case-insensitive filesystem. Or maybe don't know.

Well, I will look into it.

Thanks a ton, for your persistence.

ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #58 on: April 27, 2019, 03:14:12 am »
I noticed that in one of the logs I sent you that its clearly referencing MacOs ...

Quote
TDbgFileLoader /Users/andy/Documents/Pascal/src/MyStamps/MyStamps.app/Contents/MacOs/MyStamps

So I did a little playing with case... check this out..

Quote
study:Contents andy$ pwd
/Users/andy/Documents/Pascal/src/MyStamps/MyStamps.app/Contents
study:Contents andy$ ls -l
total 16
-rw-r--r--  1 andy  staff  1231 27 Apr 09:56 Info.plist
drwxr-xr-x  3 andy  staff   102 27 Apr 09:52 MacOS
-rw-r--r--  1 andy  staff     9 27 Apr 09:52 PkgInfo
drwxr-xr-x  2 andy  staff    68 27 Apr 09:52 Resources
study:Contents andy$

study:Contents andy$ cd Macos
study:Macos andy$ pwd

/Users/andy/Documents/Pascal/src/MyStamps/MyStamps.app/Contents/Macos
study:Macos andy$ ls
MyStamps

study:Macos andy$ ls -l
total 8
lrwxr-xr-x  1 andy  staff  17 27 Apr 09:52 MyStamps -> ../../../MyStamps
study:Macos andy$

study:Macos andy$ cd /users/andy/documents/pascal/src/mystamps/mystamps.app/contents/macos
study:macos andy$ pwd
/users/andy/documents/pascal/src/mystamps/mystamps.app/contents/macos

study:macos andy$ ls -l
total 8
lrwxr-xr-x  1 andy  staff  17 27 Apr 09:52 MyStamps -> ../../../MyStamps

study:macos andy$ ls -l ..
total 16
-rw-r--r--  1 andy  staff  1231 27 Apr 09:56 Info.plist
drwxr-xr-x  3 andy  staff   102 27 Apr 09:52 MacOS
-rw-r--r--  1 andy  staff     9 27 Apr 09:52 PkgInfo
drwxr-xr-x  2 andy  staff    68 27 Apr 09:52 Resources

study:macos andy$

So while on the surface, OSX appears to be case sensitive, it is clearly tolerant of differences in case. But on the NAS here is no tolerance for errors in case

Quote
study:macos andy$ cd /mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/
study:Contents andy$ ls -l
total 16
-rwxrwxr--  1 andy  wheel  1231 16 Apr 09:17 Info.plist
drwxrwxr-x  1 andy  wheel   264 16 Apr 08:56 MacOS
-rwxrwxr--  1 andy  wheel     9 16 Apr 08:56 PkgInfo
drwxrwxr-x  1 andy  wheel   264 16 Apr 08:56 Resources

study:Contents andy$ cd Macos
-bash: cd: Macos: No such file or directory

study:Contents andy$ cd MacOs
-bash: cd: MacOs: No such file or directory

study:Contents andy$ cd MacOS
study:MacOS andy$


So I guess it's not surprising that when reference is made to "/Users/andy/Documents/Pascal/src/MyStamps/MyStamps.app/Contents/MacOs/MyStamps", being local to the machine, errors in case are tolerated and the app runs with Debug Ok, where as if a similar attempt were made to access "/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/MacOs/MyStamps" on the NAS, errors in case would not be tolerated and it would fail.

Trouble is, I can't find any reference to  "/mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/MacOs/MyStamps" in any of the logs I've sent. Maybe there is, maybe I've missed it.

So to maybe prove it I created a symbolic link in the app bundle ...

Quote
study:Contents andy$ cd /
study:/ andy$ cd /mnt/NAS/Documents/Andy/Pascal/src/MyStamps/MyStamps.app/Contents/
study:Contents andy$ ls -l
total 24
-rwxrwxr--  1 andy  wheel  1231 16 Apr 09:17 Info.plist
drwxrwxr-x  1 andy  wheel   264 27 Apr 12:57 MacOS
lrwxrwxrwx  1 andy  wheel     5 27 Apr 12:57 MacOs -> MacOS
-rwxrwxr--  1 andy  wheel     9 16 Apr 08:56 PkgInfo
drwxrwxr-x  1 andy  wheel   264 16 Apr 08:56 Resources
study:Contents andy$

Now, when I run run the App with Debug there are no errors or warning about Dwarf info not being found, debugging appears to work fine, including viewing local variables. And I'm left with the EXC_BAD_ACCESS when the app terminates to sort out.

Quote
Strange that it works sometimes....
Maybe if files are on a case-insensitive filesystem. Or maybe don't know.

I think this could be the case (no pun intended) and it would appear the issue is around MacOS v. MacOs.

I'm going to play a bit more with creating a case insensitive share on the NAS

I'll let you know

Quote
Thanks a ton, for your persistence.

and thank you!!!

 
« Last Edit: April 27, 2019, 09:48:38 am by ahnz »
OS: OSX High Sierra 10.13.6
Lazarus: 2.1.0, r61162

Widgetset: Cocoa
Target: 64bit OSX

Compiler:
FPC 3.0.4 [2017/11/26] for x86_64

Debug:
LLDB  (with fpdebug)(Beta)
Path: /usr/bin/lldb
Version: lldb-1000.11.38.2

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5524
    • wiki
Re: Problems with Debugger on OSX
« Reply #59 on: April 27, 2019, 05:12:01 pm »
Should be fixed https://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&root=lazarus&revision=61066

Interestingly, I found that the "s" at the end of "MacOS" seems case-insensitive, but the "M" at the start case sensitive (on the same filesystem, the same folder even.)