Debugging - Individuare gli errori
Prima prova
Prima di provare il debug usare il framework (macro) di test per verificare se i test standard funzionano correttamente. Se non funzionano, è possibile che l'installazione sia danneggiata.
Riga di comando
Il debug di FreeCAD è supportato da alcuni meccanismi interni. La versione a riga di comando di FreeCAD fornisce delle opzioni di supporto del debug:
- -v
- Con la opzione "v" FreeCAD fornisce un output più dettagliato.
- -l
- Con la opzione "l" FreeCAD scrive informazioni aggiuntive in un file di log.
Generare un Backtrace
Se si esegue una versione sperimentale di FreeCAD ancora in fase sviluppo, essa potrebbe "bloccarsi". Si può aiutare a risolvere questi problemi, fornendo agli sviluppatori un "backtrace". Per fare questo, è necessario eseguire un "debug build" del software. "Debug build" è un parametro che viene impostato al momento della compilazione, perciò bisogna autocompilare FreeCAD, oppure ottenere una versione "debug" pre-compilata.
For Linux
Prerequisites:
- software package gdb installed
- a debug build of FreeCAD
- a FreeCAD model that causes a crash
Steps: Enter the following in your terminal window:
cd FreeCAD/bin
gdb FreeCAD
handle SIG33 noprint nostop
run
FreeCAD will now start up. Perform the steps that cause FreeCAD to crash, then enter 'bt' in your terminal window. This will generate a lengthy listing of exactly what the program was doing when it crash. Include this with your problem report.
Python debugging
Here is an example of using winpdb inside FreeCAD:
- Run winpdb and set the password (e.g. test)
- Create a Python file with this content
import rpdb2
rpdb2.start_embedded_debugger("test")
import FreeCAD
import Part
import Draft
print "hello"
print "hello"
import Draft
points=[FreeCAD.Vector(-3.0,-1.0,0.0),FreeCAD.Vector(-2.0,0.0,0.0)]
Draft.makeWire(points,closed=False,face=False,support=None)
- Start FreeCAD and load the above file into FreeCAD
- Press F6 to execute it
- Now FreeCAD will become unresponsive because the Python debugger is waiting
- Switch to the Windpdb GUI and click on "Attach". After a few seconds an item "<Input>" appears where you have to double-click
- Now the currently executed script appears in Winpdb.
- Set a break at the last line and press F5
- Now press F7 to step into the Python code of Draft.makeWire