Difference between revisions of "Cocoa Debugging"

From Lazarus wiki
Jump to navigationJump to search
Line 29: Line 29:
 
It's likely you might have some closed-source code that you're not allowed to share.
 
It's likely you might have some closed-source code that you're not allowed to share.
  
It's preferred to have a simple sample project. Simple meaning:
+
It's preferred to have a simple project demonstrating the problem. "Simple" meaning:
 
* it's small in size one (or two forms) only.
 
* it's small in size one (or two forms) only.
 
* minimal set of controls
 
* minimal set of controls

Revision as of 21:56, 12 September 2018

Having problems running a project compiled for Cocoa? Here are steps to try

Run from Terminal

  • open up Terminal (Applications -> Utilities -> Terminal).
  • cd to your project directory
  • cd to the bundle (a bundle is specialy structured directory, where binary resides. bundle directory extensions is ".app" )
 cd project1.app/Contents/MacOS

(for your project "project1.app" needs to be adjusted towards the name)

  • run the project
./project1

(for your project "project1" needs to be adjusted towards the executable name) See the output! The output might suggest what's going on. (any OS or error warning messages, would be shown)

Console App

The log entries could also be acquired from Console utillity.

Run with lldb debugger

Repeat the same steps as in "Run from Terminal", but run the program as

lldb project1

(loading of lldb requires admin rights, and well as takes some time) once loaded enter command

r

and wait for it to stop or catch the application crash. See more here

Troubleshooting

  • if a project can compile and run for Carbon, yet it cannot do the same for Cocoa, then the issue is likely with Cocoa widgetset. Creating a minimal sample project is suggested
  • if a project runs but does nothing and provides a constant CPU load (i.e. 99%, 50% or 25%, depending on the number of cores), then there's an endless loop triggered by some code.

Creating a Minimal Sample Project

It's likely you would encounter a problem when working with a big production project.

It's likely you might have some closed-source code that you're not allowed to share.

It's preferred to have a simple project demonstrating the problem. "Simple" meaning:

  • it's small in size one (or two forms) only.
  • minimal set of controls
  • NO external package dependencies (packages supplied with Lazarus is ok)

In order to get a simple project from the big production project you can do the following:

  • copy the project stand-alone (not to harm the existing code base)
  • remove (delete) pieces that are not related to the bug
  • (i.e. if you're having problems with placement of a control, you might want to remove main menu, TActions, if any)
  • remove bigger pieces first (it might be much easier than you think)
  • after each piece removed, run the project, to make sure you're still getting the error.
  • keep removing code (and reference to any other external dependencie) until you reach the point that you cannot remove anything without affecting the bug.

At this point you should have small enough project to demonstrate the problem and bug report it.

See Also