Debugging/ro: Difference between revisions

From FreeCAD Documentation
No edit summary
No edit summary
Line 92: Line 92:
Here is an example of using winpdb inside FreeCAD:
Here is an example of using winpdb inside FreeCAD:


# Run winpdb and set the password (e.g. test)
# Rulați winpdb și definiți password (e.g. test)
# Creați un fișier Python cu acest conținut
# Create a Python file with this content
<syntaxhighlight>
<syntaxhighlight>
import rpdb2
import rpdb2

Revision as of 14:39, 21 August 2018

Testează mai întâi

Înainte de a trece prin durerea de depanare utilizați Test framework pentru a verifica dacă testele standard funcționează corect. Dacă acestea nu se execută complet, este posibilă o instalare defectă.

Linie de Commandă

Depanarea debugging în FreeCAD este susținută de câteva mecanisme interne. Versiunea liniei de comandă a FreeCAD oferă câteva opțiuni pentru suportul de depanare.

Acestea sunt opțiunile recunoscute curent în FreeCAD 0.15:

Generic options:

 -v [ --version ]      Prints version string
 -h [ --help ]         Prints help message
 -c [ --console ]      Starts in console mode
 --response-file arg   Can be specified with '@name', too

Configuration:

 -l [ --write-log ]       Writes a log file to:
                          $HOME/.FreeCAD/FreeCAD.log
 --log-file arg           Unlike to --write-log this allows to log to an 
                          arbitrary file
 -u [ --user-cfg ] arg    User config file to load/save user settings
 -s [ --system-cfg ] arg  Systen config file to load/save system settings
 -t [ --run-test ] arg    Test level
 -M [ --module-path ] arg Additional module paths
 -P [ --python-path ] arg Additional python paths

Generarea unei Backtrace

Dacă rulați o versiune de FreeCAD de la muchia încă sângerândă a vârfului de lance a curbei de dezvoltare a produsului, acesta poate să "se prăbușească". Vă puteți ajuta să rezolvați astfel de probleme furnizând dezvoltatorilor o "backtrace". Pentru a face acest lucru, trebuie să executați o "depanare de construire" a software-ului. "Debug build" este un parametru care este setat la timpul de compilare, deci va trebui fie să compilați FreeCAD însuși, fie să obțineți o versiune "debug" precompilată.

For Linux

Linux Debugging ---->

Prerequisites:

  • software package gdb installed
  • a debug build of FreeCAD (at this time only available by building from source)
  • a FreeCAD model that causes a crash

Steps: Enter the following in your terminal window:

$ cd FreeCAD/bin
$ gdb FreeCAD

GNUdebugger will output some initializing information. The (gdb) shows GNUDebugger is running in the terminal, now input:

(gdb) handle SIG33 noprint nostop
(gdb) run

FreeCAD will now start up. Perform the steps that cause FreeCAD to crash or freeze, then enter in the terminal window:

(gdb) bt

This will generate a lengthy listing of exactly what the program was doing when it crashed or froze. Include this with your problem report.

For MacOSX

MacOSX Debugging ---->

Prerequisites:

  • software package lldb installed
  • a debug build of FreeCAD
  • a FreeCAD model that causes a crash

Steps: Enter the following in your terminal window:

$ cd FreeCAD/bin
$ lldb FreeCAD

LLDB will output some initializing information. The (lldb) shows the debugger is running in the terminal, now input:

(lldb) run

FreeCAD will now start up. Perform the steps that cause FreeCAD to crash or freeze, then enter in the terminal window:

(lldb) bt

This will generate a lengthy listing of exactly what the program was doing when it crashed or froze. Include this with your problem report.

Python Debugging

For a more modern approach to debugging Python, at least on Windows, see this post in the Forum.


Here is an example of using winpdb inside FreeCAD:

  1. Rulați winpdb și definiți password (e.g. test)
  2. Creați un fișier Python cu acest conținut
 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)
  1. Dați Start la FreeCAD și încărcați fișierul de mai sus în FreeCAD
  2. Apăsați F6 ptru al-l executa
  3. Acum FreeCAD se va bloca (nu va răspunde) deoarece debuggerul Python este în așteptare
  4. Comutați pe Windpdb GUI și click on "Attach". După câteva secunde un articol "<Input>" apare acolo unde ați făcut dublu clic
  5. Acum Scriptul aflat în execuție curentă apare în Winpdb.
  6. Definiți o pauză la ultima linie și apăsați F5
  7. Acum apăsați F7 pentru a intra în codul Python al Draft.makeWire
Module Creation
Testing