Recent

Author Topic: Problem debugging Lazarus app using Xcode/lldb [SOLVED]  (Read 10580 times)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Problem debugging Lazarus app using Xcode/lldb [SOLVED]
« on: July 17, 2017, 09:58:26 pm »
Hello, I have used the techniques described by Phil in order to debug Lazarus apps using Xcode/lldb under macOS and by and large it's been very successful. One of my apps is causing problems, though. I keep getting the message within Xcode that "Command /bin/sh failed with exit code 2". The detail for the error says
Code: Pascal  [Select][+][-]
  1. "Error: (lazbuild) Strange lpi file
  2. The file /Users/carlca/Code/fpc/caIDE/MethodGroup/MethodGroup.lpi does not look like a lpi file.
  3. lazbuild is non interactive, aborting now.
  4. Command /bin/sh failed with exit code 2'
  5.  
The only thing that sets this apart from previous apps I have written is that this one has Codetools as a required package. Maybe this is something similar to the old Delphi problem of building in design-time dependencies to a run-time build. Thoughts anyone?
« Last Edit: July 18, 2017, 07:58:26 pm by carl_caulkett »
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #1 on: July 17, 2017, 10:00:56 pm »
Thoughts anyone?

I assume you've tried running lazbuild from the command line on that .lpi file. Did that give the same error message?


carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #2 on: July 17, 2017, 10:13:03 pm »
I've just tried that. Exactly the same error. No surprise, I guess since this presumably is the first part of lazcmd.tmp.sh which is running.
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #3 on: July 17, 2017, 10:18:46 pm »
I've just tried that. Exactly the same error. No surprise, I guess since this presumably is the first part of lazcmd.tmp.sh which is running.

Right, has nothing to do with Xcode. Maybe a lazbuild bug. Maybe file a bug report if so.


carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #4 on: July 17, 2017, 10:29:27 pm »
Point taken. And yet, when I build the project within the Lazarus IDE, I don't get any errors. I also did a line by line file compare of the offending .lpi file with a .lpi that definitely does work with Xcode. I couldn't see anything untoward in the offending .lpi file. Very strange. I'll submit a bug report, and attach the offending project.
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #5 on: July 17, 2017, 10:33:34 pm »
Point taken. And yet, when I build the project within the Lazarus IDE, I don't get any errors. I also did a line by line file compare of the offending .lpi file with a .lpi that definitely does work with Xcode. I couldn't see anything untoward in the offending .lpi file. Very strange. I'll submit a bug report, and attach the offending project.

Look at source for lazbuild.lpr. It probably gives that when it's been asked to do something interactive (eg, put up a dialog).



carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #6 on: July 17, 2017, 11:06:50 pm »
https://bugs.freepascal.org/view.php?id=32157

I had a look at the code for lazbuild.lpr and I could see where the error message was being generated. A search for the text "strange" didn't find anything. Strange!
« Last Edit: July 17, 2017, 11:09:05 pm by carl_caulkett »
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #7 on: July 17, 2017, 11:12:02 pm »
https://bugs.freepascal.org/view.php?id=32157

I had a look at the code for lazbuild.lpr and I could see where the error message was being generated. A search for the text "strange" didn't find anything. Strange!

lazarusidestrconsts.pas

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #8 on: July 18, 2017, 12:23:34 am »
I've just created a fresh empty Lazarus project. I'm still having the same problems when Lazbuild is invoked. At the risk of jumping to conclusions, it seems that the problems started just as I followed some advice from @thaddy https://forum.lazarus.freepascal.org/index.php/topic,37586.msg253041.html#msg253041
It involved my deleting my /etc/fpc.cfg. As I pointed out, it didn't seem to have any effect other than temporarily screw up my ability to build within Lazarus. I quickly reinstated the /etc/fpc.cfg but I'm wondering if it has had the effect of permanently screwing up my ability to use Lazbuild. If that's the case then I will be mighty pissed off, since the ability to use Lazbuild is the only thing enabling me to debug under macOS 10.12.5 Sierra.

What do I have to do to preserve all my IDE changes if I have to reinstall Lazarus (I cannot believe I'm having to ask this - I'm so f***ing pissed off)?
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #9 on: July 18, 2017, 12:28:23 am »
What do I have to do to preserve all my IDE changes if I have to reinstall Lazarus

fpc.cfg is created by the FPC installer, not the Lazarus installer, so try reinstalling FPC. I believe it creates a new fpc.cfg, renaming your old one.


carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #10 on: July 18, 2017, 12:36:02 am »
Should I uninstall anything or just reinstall FPC over the top?
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #11 on: July 18, 2017, 12:40:30 am »
Should I uninstall anything or just reinstall FPC over the top?

Yeah, just run the .dmg again (fpc-3.0.2.intel-macosx.dmg). Normally you don't make any changes to the FPC installation, with possible exception of fpc.cfg, so writing over the compilers (/usr/local/lib/fpc/3.0.2) and installed units (/usr/local/lib/fpc/3.0.2/units) shouldn't affect anything.


carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #12 on: July 18, 2017, 01:15:21 am »
OK. I think we're getting somewhere. The projects which would not build using lazbuild on the command line, now build OK with only console output, no dialog interaction. However, the two projects (out of a total of eight) still do not build in Xcode. I've noticed something else, which may or may not be significant. The two projects which fail, leave a shell script called lazcmd.tmp.sh with lines like this contained therein:
Code: Pascal  [Select][+][-]
  1.  set -e
  2. '/usr/local/bin/lazbuild' '/Users/carlca/Code/fpc/Test/TestLazbuild/TestLazbuild.lpi'
  3. cp -p '/Users/carlca/Code/fpc/Test/TestLazbuild/testlazbuild' '/Users/carlca/Library/Developer/Xcode/DerivedData/TestLazbuild-dxqebgtvlqoefdbumbwgbbqthksb/Build/Products/Debug/TestLazbuild.app/Contents/MacOS/TestLazbuild'
  4. cp -p -R '/Users/carlca/Code/fpc/Test/TestLazbuild/testlazbuild.app/Contents/Resources/' '/Users/carlca/Library/Developer/Xcode/DerivedData/TestLazbuild-dxqebgtvlqoefdbumbwgbbqthksb/Build/Products/Debug/TestLazbuild.app/Contents/Resources'
  5.  

I'm guessing that a similar file is created in the successful project folders as well, but is deleted on completion of a successful build and run.
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #13 on: July 18, 2017, 01:24:51 am »
I'm guessing that a similar file is created in the successful project folders as well, but is deleted on completion of a successful build and run.

Right, look in the Xcode project's Run Script on the Build Settings tab.

Also, look at the Xcode build log to see why it's not building.

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: Problem debugging Lazarus app using Xcode/lldb
« Reply #14 on: July 18, 2017, 01:49:58 am »
Firstly the app which is not building:
Code: Pascal  [Select][+][-]
  1. Showing Recent Issues
  2. '/usr/local/bin/lazbuild' '/Users/carlca/Code/fpc/Test/TestLazbuild/TestLazbuild.lpi'
  3. Hint: (lazarus) [RunTool] /usr/local/bin/ppc386 "-iWTOTP"
  4. Hint: (lazarus) [RunTool] /usr/local/bin/ppc386 "-va" "compilertest.pas"
  5.   $0021F38B
  6.   $000114F2
  7.   $00185B75
  8.   $001866FA
  9.   $00186C3E
  10.   $00014043
  11.   $00012E1C
  12.   $0001192B
  13.   $0001628C
  14. Error: (lazbuild) Strange lpi file
  15. The file /Users/carlca/Code/fpc/Test/TestLazbuild/TestLazbuild.lpi does not look like a lpi file.
  16. lazbuild is non interactive, aborting now.
  17. Command /bin/sh failed with exit code 2
  18.  
As you can see according to Xcode I'm still getting the Lazbuild error, and yet if I run Lazbuild against the same project in iTerm, it all seems to run OK.

And now the app that build correctly in Xcode:
Code: Pascal  [Select][+][-]
  1. Showing Recent Issues
  2. Build target CodePreview of project CodePreview with configuration Debug
  3. Check dependencies
  4. warning: no rule to process file '/Users/carlca/Code/fpc/calibrary/cafontselectorlist.pas' of type sourcecode.pascal for architecture i386
  5. warning: no rule to process file '/Users/carlca/Code/fpc/casynedit/caSynedit.pas' of type sourcecode.pascal for architecture i386
  6. warning: no rule to process file '/Users/carlca/Code/fpc/casynedit/casyncolorgrid.pas' of type sourcecode.pascal for architecture i386
  7. warning: no rule to process file '/Users/carlca/Code/fpc/casynedit/casynconfig.pas' of type sourcecode.pascal for architecture i386
  8. warning: no rule to process file '/Users/carlca/Code/fpc/calibrary/cafontselector.pas' of type sourcecode.pascal for architecture i386
  9. warning: no rule to process file '/Users/carlca/Code/fpc/casynedit/casyneditreg.pas' of type sourcecode.pascal for architecture i386
  10. warning: no rule to process file '/Users/carlca/Code/fpc/calibrary/cahint.pas' of type sourcecode.pascal for architecture i386
  11. warning: no rule to process file '/Users/carlca/Code/fpc/casynedit/casynhighlightergolang.pas' of type sourcecode.pascal for architecture i386
  12.  

I've also looked at the Build Settings for the app that doesn't build, but I can't find any mention of "Run Script" in there. Mind there's a veritable shed load of info in there so I may be looking at the wrong thing.
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

 

TinyPortal © 2005-2018