Debugging in FreeCAD

From Open Source Ecology
Revision as of 17:34, 10 November 2018 by Ruslan (talk | contribs) (Add instructions how to debug FreeCAD scripts)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

How to setup a system to debug FreeCAD python scripts.

Check system stability

In some Linux systems the debugger will crash. The problem is caused by in expat library. This is happens for example on Ubuntu 18.04. To find out, if our system has this problem, run two python lines below. If Freecad crashes, we need to fix our system first.

  1. Launch Freecad
  2. Normally, the python console is hidden. To show the console, go to Menu View->Panels->Python console.
  3. Now ran these lines below
 from xml.dom import minidom
 minidom.parseString("<test></test>")

If FreeCAD crashes you need to fix it. We follow the instructions on [1]. They suggest to downgrade the libexpat file:

For Ubuntu download Ubuntu 16.04 versions of libexpat1_2.1.0 from [2]. These is usually libexpat1_2.1.0-7ubuntu0.16.04.3_amd64.deb (or libexpat1_2.1.0-7ubuntu0.16.04.3_i386.deb for 32 bit system)

Than go to your Download directory and install it with

sudo dpkg -i libexpat1_2.1.0-7ubuntu0.16.04.3_amd64.deb

Try again. If freecad does not crash, the debugger will probably work.

Install and the debugger

We need a python debugger winpdb. If you did not installed before, install it with:

sudo apt-get install winpdb 

Now lets setup the debugger.

  1. Start winpdb.
  2. Set the debugger password to "test": Go to menu File->Password" and set the password.

Now we will run a test python script in FreeCAD step by step.