Recent

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

ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #30 on: April 15, 2019, 10:34:17 pm »
Hi

Quote
Just for clarification:

It is your project that is on the NAS (except the compiled app?):

Originally, my project was on the NAS, including the compiled App. But cognisant of strange occurrences with other, entirely unrelated apps, I decided to copy the project to my local drive to eliminate the possibility of issues with an AFP share an the NAS.

When I first tried the things I did for you yesterday I noticed the NAS being referenced in the debug_log so I (a) completely deleted the project from the NAS and (b) checked there was no occurrences of NAS in any of the project files.

Then, when I did the final debug for you I could see no references to NAS so there shouldn't be any reference to it now

Quote
2) The reason for the failed launch (debug session aborted before project is started) is a filename matching the IDE trigger for another error message. Working on a fix.

3) The reason some debug info is not loaded (timestamp issues).

It looks like I've fixed these - though I have said that before and was proven wrong, so I do want to do some ore testing before I confirm completely. What had happened is, when I copied my project from the NAS to the local drive, the Application Bundle which is effectively a symbolic link to the compiled app, was expanded and the then compiled app copied rather than the link. The result being that no matter how many changes and compiles I did, I was always running the same version of the app from days ago. Instead of running the freshly compiled ./BareBones/project1 I was always running BareBones/project1.app/Contents/MacOS/project1

Once the Application Bundles was deleted and recreated I can now compile and run with debug and, step through. though I do have one question.

When I step though this ...

Code: Pascal  [Select]
  1. function TForm1.GetHe: string;
  2. begin
  3.   GetHe := 'He ';
  4. end;
  5.  
  6. procedure TForm1.Button1Click(Sender: TObject);
  7. var
  8.   s: string;
  9.   i: integer;
  10. begin
  11.   s := 'That Tickles, ';
  12.   for i := 1 to 3 do
  13.     s := s + GetHe;
  14.   Label1.Caption := s;
  15. end;
  16.  

... and view the local variables, the string 's' only shows the first character... is that normal?

All up it looks like the issue is resolve - but I say that once before so.. I'm off to do some more testing

Just for good measure, the debug_log is attached

Anything else you want me look at, just let me know

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: 5463
    • wiki
Re: Problems with Debugger on OSX
« Reply #31 on: April 15, 2019, 10:47:28 pm »
... and view the local variables, the string 's' only shows the first character... is that normal?

I have to check, so I would expect not.
Does it happen in the watches win too?

Are you using dwarf+sets or dwarf-3 ?

----------------
Just noted something in the log.
That is a 32bit app?
« Last Edit: April 15, 2019, 10:49:12 pm by Martin_fr »

ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #32 on: April 16, 2019, 12:23:28 am »
I was using dwarf-3. The same thing happened with the watch Window, only the 'T' was shown.

With dwarf-2 and with-sets, it appears to work ok with both the local variables and watch windows correctly showing the string.

I've compiled my bare bones with 32bit and 64bit and all appears well with debug.

I've now got another issue which may or may not be a debug problem, I don't know.

Copied my main project to my local drive, fixed up the application bundle. Its 64bit. Its uses SQLite and works perfectly Ok if compiled with a bog standard Lazarus v2.0.0. However, with rev 60971 ....

Clean & Build, Run without Debug.. It errors with "Can not load SQLite Client library "libsqlite3.dylib". Check you installation" - If I Ok this app runs ok (without access to the DB) and terminates cleanly when I close

Clean & Build, Run WITH Debug.. It errors with "Can not load SQLite Client library "libsqlite3.dylib". Check you installation" - If I Ok this app runs ok (without access to the DB) but when I close the app it error with an exception

/usr/lib/libsqlite3.dylib exists and including /usr/lib with -FI make no difference

Q.

Why would rev 60971 failed to find the SQLlite library, when the same app compiled under Laz 2.0.0 work perfectly Ok

Does this also point to a debugger issue not dealing with another nil object somewhere?

Attached is the debug log from the failed Run with Debug
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: 5463
    • wiki
Re: Problems with Debugger on OSX
« Reply #33 on: April 16, 2019, 12:53:06 am »
I cant see how the sqlite issue would be debug related.  The exception may just be un-noted outside the debugger.

AFAIK sqlite is part of the fpc packages (the stuff in lazarus seems to be just the component editor and registration). Since your updated lazarus use the same fpc, it should use the same code.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5463
    • wiki
Re: Problems with Debugger on OSX
« Reply #34 on: April 16, 2019, 01:36:51 am »
The string len issue appears to be an fpc issue https://bugs.freepascal.org/view.php?id=35386

It only applies to 32 bit with dwarf-3.

You may be able to inspect the value using (if pchar is used by your app, and the debugger can find it)
pchar(thestring)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5463
    • wiki
Re: Problems with Debugger on OSX
« Reply #35 on: April 17, 2019, 05:15:05 pm »
I improved error detection during launch. For now in trunk only. (2.0.4 depends on further testing)
Trunk Revision: 61001
LazDebugger(Fp)Lldb: improve checks for errors during launch command. Ignore text in file names.
https://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&root=lazarus&revision=61001


So if the timestamps are wrong, the app should now launch (it did fail in some cases, if certain filename where involved, i.e. the word "process" in a filename).

However debug info for any file with wrong timestamp is not loaded. Not by the IDE, and not by LLDB. So for those files (listed in the something went wrong dialog), neither breakpoints nor watches will work.

As to what exactly causes the wrong timestamps is unclear. And currently all the info suggests that it is done by Apple's toolchain. But that is a guess....


At the very start of this thread (when things were still crashing) there also was an issue that the IDE could not watch variables in files with correct time stamp. This has not been reproducible since the use of fixes branch.
For now I will assume that it was fixed since the release.

If it re-occurs (breakpoint works in a file, but watches do not) then logs for this are welcome.


As for issues with values of watches (such as the string being shortened). Those should be kept to be reported.

Currently known:
- interfaces => do not show / ident not found
- function references (type TFOo= function...) => ident not found
- Most string types will cut off at the first #0
- there are hardcoded length limits (string/array) 3000 or 5000
- ansistring, 32bit dwarf 3 => only first char
- most values of untyped constants are not shown: const a= 5;



ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #36 on: April 17, 2019, 10:06:47 pm »
Hi,

Quote
As to what exactly causes the wrong timestamps is unclear.

I believe the problem was a mistake on my behalf...

Quote
What had happened is, when I copied my project from the NAS to the local drive, the Application Bundle which is effectively a symbolic link to the compiled app, was expanded and the then compiled app copied rather than the link. The result being that no matter how many changes and compiles I did, I was always running the same version of the app from days ago. Instead of running the freshly compiled ./BareBones/project1 I was always running BareBones/project1.app/Contents/MacOS/project1

The only problem I have now that I need to solve is why my app compiles and runs ok for 2.0.0 but fails to find/load libsqlite3.dylib when compiled and run with/without debug under  rev 60971

Thanks for all your help with this - much appreciated
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 #37 on: April 24, 2019, 02:58:15 am »
Hi,

I have an update.

I've installed 2.0.2 and removed the second install I had.

My app, which is 64bit using cocoa, with project files saved locally to my machine

(1) If I do a Clean & Build and run without debug... all is fine. App executes and terminates normally

(2) If I Clean & Build, and then run with debug. The App executes and debugs fine, but throws a EXC_BAD_ACCESS at winapi.inc line 180 (I've overcome the early issue with an Invalid Image error so don't understand why with not other handled exceptions this would occur)

When my app project files are on my NAS - same app, same files, no mistakes with the application Bundle, same .lpi

(3) I do a Clean & Build and run without debug... all is fine. App executes and terminates normally

(4) However, from the NAS if I Clean & Build and run with debug I get the "Failed loading Dwarf debug info"

Then, in order to help debug the loading problem (4) I run Lazarus from the command line ...

Quote
/Developer/lazarus/lazarus.app/Contents/MacOS/lazarus --debug-log=/Users/andy/Desktop/laz.log --debug-enable=DBG_CMD_ECHO,DBG_STATE,DBG_DATA_MONITORS,DBGMI_QUEUE_DEBUG,FPDBG_DWARF_ERRORS,FPDBG_DWARF_WARNINGS,FPDBG_DWARF_VERBOSE_LOAD,FPDBG_DWARF_DATA_WARNINGS,DBG_VERBOSE,DBG_WARNINGS,DBG_STATE,DBG_EVENTS,DBG_THREAD_AND_FRAME

.. I hit the problem with unable to load the sqlite3 library. This happens after a Clean Build, Running with and without debug, with both the Local and NAS based project files

Below are the subsequent logs for (4) run with and without Debug

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: 5463
    • wiki
Re: Problems with Debugger on OSX
« Reply #38 on: April 24, 2019, 11:38:43 pm »
Ok, the log only shows the not found lib. And a crash at exit of the app (LCL cocoa code attempts to free some object)

If the dyLib issue is to do with starting the IDE from command line (I don't know, but it could be that this inherits diff environment from the terminal...), then we need a way to get the log. But start the IDE without using a terminal.

This should be possible.
Afaik you already have created a "lazarus.cfg" file for the primary config path?

Open that file, and put (2 lines) into it
Code: [Select]
--debug-log=/Users/andy/Desktop/laz.log
--debug-enable=DBG_CMD_ECHO,DBG_STATE,DBG_DATA_MONITORS,DBGMI_QUEUE_DEBUG,FPDBG_DWARF_ERRORS,FPDBG_DWARF_WARNINGS,FPDBG_DWARF_VERBOSE_LOAD,FPDBG_DWARF_DATA_WARNINGS,DBG_VERBOSE,DBG_WARNINGS,DBG_STATE,DBG_EVENTS,DBG_THREAD_AND_FRAME

That should (I hope) do the same job. Otherwise it would be possible to recompile the IDE with some flags, and permanently enable the log.

If you do not want to always write the file, then install the package IdeLazLogger
From the 2 lines above, only add the 2nd ("--debug-enable") line.
No logging should happen. But you can open the Tools menu, and select Logging, and specify a file.

ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #39 on: April 25, 2019, 10:30:48 pm »
Ok, I hadn't created a lazarus.cfg ... we did that as part of an earlier exercise where I had two installs, but now I only have one install of 2.0.2.

I created the file as suggested and yes, it stops the sqlite3 lib error....

Here the log it produces.

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

ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #40 on: April 25, 2019, 10:49:13 pm »
UPDATE

FWIW, even though I get the "unable to load dwarf info" message, the debug stops ok at the breakpoints but no local variables or watchpoints is shown
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: 5463
    • wiki
Re: Problems with Debugger on OSX
« Reply #41 on: April 26, 2019, 12:54:52 am »
Maybe this helps with the dylib? https://stackoverflow.com/questions/17703510/dyld-library-not-loaded-reason-image-not-found

Unfortunately the laz.txt (April 25, 2019, 10:30:48 pm) is incomplete.
So the cfg file did not do the trick.

Is that laz.txt for the case: breakpoint works, but watches not? It does not show reaching any breakpoint?


Before I ask for more work:
I am happy if you are willing to contribute your time. And my time is available too.
For some of the issues, the investigation is probably at best (if at all) going to improve error messages. The problem itself may be out of reach. (I.e. the wrong timestamps seem to be down to tools from Apple. Those I can not change.

The best way to get the log working, without needing a console would now be:

Menu: Tools -> Configure build Lazarus
In the big "Options" field add the following:
Code: [Select]
-dDBG_CMD_ECHO -dDBG_STATE -dDBG_DATA_MONITORS -dDBGMI_QUEUE_DEBUG -dFPDBG_DWARF_ERRORS -dFPDBG_DWARF_WARNINGS -dFPDBG_DWARF_VERBOSE_LOAD -dFPDBG_DWARF_DATA_WARNINGS -dDBG_VERBOSE -dDBG_WARNINGS -dDBG_STATE -dDBG_EVENTS -dDBG_THREAD_AND_FRAMESave the settings, you do not need to build at this time.

Menu: Package -> Install/Unistall Packages
On the right hand find the package "IdeLazLogger" and install it.
"Save and rebuild"
Confirm the next dialog.

When you restart the IDE, the tools menu has an entry "Logging".
It shows all the enabled logging tags (from the list above), the one from the list should all be checked. The others can be ignored (eg Syn*). And you can specify a logfile.

Then hopefully we will get full logs.

Sorry for all the complications.
And as I said, I appreciate any info I can get, even if it may only lead to very small improvements.
But I also understand, if at some stage you have other work to get done.


ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #42 on: April 26, 2019, 01:21:49 am »
Quote
Before I ask for more work:
I am happy if you are willing to contribute your time. And my time is available too.

Sorry for all the complications.
And as I said, I appreciate any info I can get, even if it may only lead to very small improvements.
But I also understand, if at some stage you have other work to get done.
I am more than happy to continue to work through this - I'm semi-retired with plenty of time and I'm learning much... though I do need to cut the grass this afternoon :(

Suggested changes made, and a new log file its attached. This includes executing the application with breakpoint enabled and hit, though to termination. A quick look a the log file and its clear there is much more information, and even I believe an suggestion that the EXC_BAD_ACCESS at the end might be related to my Splash screen

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: 5463
    • wiki
Re: Problems with Debugger on OSX
« Reply #43 on: April 26, 2019, 01:57:12 am »
Ok, better. Yes the log seems complete.

It does not yet tell me, why watches are empty (and presumingly "locals" vars in the locals window are empty to?).
For that I will have to add more debugln. (i.e. attach a patch for you). Gimme a day or two...

Which version of Lazarus did you use for this?
svn fixes, 2.0.0, or 2.0.2 ? (I can then make sure, I base the patch on the correct version)



As for the dylib issue.
I noted that your environment option are different when starting from a terminal. (the terminal may change them)
Maybe that affects were the dylib is expected?

You can see the env, in the IDE under menu View > ide internals > about IDE (and then scroll down).
Or run "env" in the terminal.

If you run from terminal this is present:  DYLD_FALLBACK_LIBRARY_PATH=:/usr/local/mysql/lib
Without terminal this is not set.

Also PWD (working dir) is only set, under the terminal.
And PATH has a lot more entries.

You can try to set/unset it for your app (when running from the IDE), under menu Run > Run Parameters

I do not know if any of that is related to the dylib issue. But it may be worth a shot.

ahnz

  • Jr. Member
  • **
  • Posts: 57
Re: Problems with Debugger on OSX
« Reply #44 on: April 26, 2019, 03:41:26 am »
Thanks

Quote
As for the dylib issue.
I noted that your environment option are different when starting from a terminal. (the terminal may change them)
Maybe that affects were the dylib is expected?

If it's all the same to you, and the logging works ok now, I'll just accept theres a difference and leave it at that. Unless of course you particularly want me to delve in for your interest?

Quote
Which version of Lazarus did you use for this?
svn fixes, 2.0.0, or 2.0.2 ? (I can then make sure, I base the patch on the correct version)

Yes, its a standard 2.0.2 install on OSX and the only version I have installed.

Would I be right in believing the locals and watches having no info is directly related to the "Unable to load Dwarf Debug Info" message I get when running the app with debug???

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