Debugging/ro: Difference between revisions
(Updating to match new version of source page) |
(Updating to match new version of source page) |
||
(33 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
<languages/> |
||
{{Docnav|Module Creation|Testing}} |
|||
== Test First == |
|||
Before you go through the pain of debugging use the [[Testing|Test framework]] to check if the standard tests work properly. If they do not run complete there is possibly a broken installation. |
|||
== Testează mai întâi == |
|||
Înainte de a trece prin durerea de a depana utilizați [[Testing|Test framework]] pentru a verifica dacă testele standard funcționează corect. Dacă acestea nu se execută complet, este posibil să fie o instalare defectuoasă. |
|||
== |
== 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: |
Generic options: |
||
Line 20: | Line 22: | ||
arbitrary file |
arbitrary file |
||
-u [ --user-cfg ] arg User config file to load/save user settings |
-u [ --user-cfg ] arg User config file to load/save user settings |
||
-s [ --system-cfg ] arg |
-s [ --system-cfg ] arg System config file to load/save system settings |
||
-t [ --run-test ] arg Test level |
-t [ --run-test ] arg Test level |
||
-M [ --module-path ] arg Additional module paths |
-M [ --module-path ] arg Additional module paths |
||
-P [ --python-path ] arg Additional python paths |
-P [ --python-path ] arg Additional python paths |
||
== |
== Generarea unei Backtrace == |
||
Dacă rulați o versiune experimentală de FreeCAD care este încă în curs de dezvoltare, aceasta poate "îngheța". 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 "Debug build" a software-ului. "Debug build" este un parametru care este setat în timpul compilării, deci va trebui fie să compilați FreeCAD dvs înșivă, fie să obțineți o versiune "debug" precompilată. |
|||
=== For Linux === |
=== For Linux === |
||
Line 34: | Line 36: | ||
Prerequisites: |
Prerequisites: |
||
* software package gdb |
* varianta software de package gdb instalat |
||
* a |
* o depanare a variantei compilate a FreeCAD (în acest moment disponibilă prin [[CompileOnUnix#For_a_Debug_build|building from source]]) |
||
* |
* un model FreeCAD care a cauzat crash-ul |
||
Pași: |
|||
Steps: |
|||
Introduceți următoarelor în fereastra terminalului dvs: |
|||
Enter the following in your terminal window: |
|||
{{Code|code= |
|||
<pre> |
|||
$ cd FreeCAD/bin |
$ cd FreeCAD/bin |
||
$ gdb FreeCAD |
$ gdb FreeCAD |
||
}} |
|||
</pre> |
|||
GNUdebugger will output some initializing information. The (gdb) shows GNUDebugger is running in the terminal, now input: |
GNUdebugger will output some initializing information. The (gdb) shows GNUDebugger is running in the terminal, now input: |
||
{{Code|code= |
|||
<pre> |
|||
(gdb) handle SIG33 noprint nostop |
(gdb) handle SIG33 noprint nostop |
||
(gdb) run |
(gdb) run |
||
}} |
|||
</pre> |
|||
<div class="mw-translate-fuzzy"> |
|||
FreeCAD will now start up. Perform the steps that cause FreeCAD to crash or freeze, then enter in the terminal window: |
|||
FreeCAD va porni. Efectuați pașii care determină ca FreeCAD să se prăbușească sau să înghețe, apoi introduceți în fereastra terminalului: |
|||
<pre> |
|||
{{Code|code= |
|||
(gdb) bt |
(gdb) bt |
||
}} |
|||
</pre> |
|||
Aceasta va genera o listă lungă a exact ceea ce a făcut programul atunci când sa prăbușit sau a înghețat. Includeți acest lucru cu raportul problemei dvs. |
|||
This will generate a lengthy listing of exactly what the program was doing when it crashed or froze. Include this with your problem report. |
|||
</div></div> <!-- END OF COLLAPSIBLE DIV --> |
|||
</div> |
|||
{{Code|code= |
|||
(gdb) bt full |
|||
}} |
|||
Print the values of the local variables also. This can be combined with a number to limit the number of frames shown. |
|||
</div></div> <!-- END OF COLLAPSIBLE DIV --> |
</div></div> <!-- END OF COLLAPSIBLE DIV --> |
||
Line 69: | Line 79: | ||
Enter the following in your terminal window: |
Enter the following in your terminal window: |
||
{{Code|code= |
|||
<pre> |
|||
$ cd FreeCAD/bin |
$ cd FreeCAD/bin |
||
$ lldb FreeCAD |
$ lldb FreeCAD |
||
}} |
|||
</pre> |
|||
LLDB will output some initializing information. The (lldb) shows the debugger is running in the terminal, now input: |
LLDB will output some initializing information. The (lldb) shows the debugger is running in the terminal, now input: |
||
{{Code|code= |
|||
<pre> |
|||
(lldb) run |
(lldb) run |
||
}} |
|||
</pre> |
|||
FreeCAD |
FreeCAD va porni. Efectuați pașii care determină ca FreeCAD să se prăbușească sau să înghețe, apoi introduceți în fereastra terminalului: |
||
{{Code|code= |
|||
<pre> |
|||
(lldb) bt |
(lldb) bt |
||
}} |
|||
</pre> |
|||
Aceasta va genera o listă lungă a exact ceea ce a făcut programul atunci când sa prăbușit sau a înghețat. Includeți acest lucru cu raportul problemei dvs. |
|||
This will generate a lengthy listing of exactly what the program was doing when it crashed or froze. Include this with your problem report. |
|||
</div></div> <!-- END OF COLLAPSIBLE DIV --> |
</div></div> <!-- END OF COLLAPSIBLE DIV --> |
||
<div class="mw-translate-fuzzy"> |
|||
== Python Debugging == |
== Python Debugging == |
||
''' |
'''Pentru o abordare mai modernă a depanării Python, cel puțin în Windows, a se vedea asta [https://forum.freecadweb.org/viewtopic.php?f=22&t=28901&hilit=2017| post in the Forum].''' |
||
</div> |
|||
=== winpdb === |
|||
<!-- START OF COLLAPSIBLE DIV --><div class="toccolours mw-collapsible mw-collapsed" style="width:800px;"> |
|||
winpdb Debugging ----> |
|||
<div class="mw-collapsible-content"> |
|||
Here is an example of using ''Winpdb'' inside FreeCAD: |
|||
Avem nevoie de depanatorul Python: '' Winpdb ''. Dacă nu aveți instalat, instalați-l sub Ubuntu / Debian cu: |
|||
{{Code|code= |
|||
Here is an example of using winpdb inside FreeCAD: |
|||
sudo apt-get install winpdb |
|||
}} |
|||
Acum permiteți configurarea programului de depanare. |
|||
# Run winpdb and set the password (e.g. test) |
|||
# Create a Python file with this content |
|||
# Start ''Winpdb''. |
|||
<syntaxhighlight> |
|||
# Set the debugger password to "test": Go to menu ''File''->''Password" and set the password. |
|||
import rpdb2 |
|||
rpdb2.start_embedded_debugger("test") |
|||
Acum vom rula pas cu pas un script de testare Python în FreeCAD. |
|||
import FreeCAD |
|||
import Part |
|||
# Rulați winpdb și definiți password (e.g. test) |
|||
import Draft |
|||
# Creați un fișier Python cu acest conținut |
|||
print "hello" |
|||
{{Code|code= |
|||
print "hello" |
|||
import rpdb2 |
|||
rpdb2.start_embedded_debugger("test") |
|||
points=[FreeCAD.Vector(-3.0,-1.0,0.0),FreeCAD.Vector(-2.0,0.0,0.0)] |
|||
import FreeCAD |
|||
Draft.makeWire(points,closed=False,face=False,support=None) |
|||
import Part |
|||
</syntaxhighlight> |
|||
import Draft |
|||
# Start FreeCAD and load the above file into FreeCAD |
|||
print "hello" |
|||
# Press F6 to execute it |
|||
print "hello" |
|||
# Now FreeCAD will become unresponsive because the Python debugger is waiting |
|||
import Draft |
|||
# Switch to the Windpdb GUI and click on "Attach". After a few seconds an item "<Input>" appears where you have to double-click |
|||
points=[FreeCAD.Vector(-3.0,-1.0,0.0),FreeCAD.Vector(-2.0,0.0,0.0)] |
|||
# Now the currently executed script appears in Winpdb. |
|||
Draft.makeWire(points,closed=False,face=False,support=None) |
|||
# Set a break at the last line and press F5 |
|||
}} |
|||
# Now press F7 to step into the Python code of Draft.makeWire |
|||
<div class="mw-translate-fuzzy"> |
|||
# Dați Start la FreeCAD și încărcați fișierul de mai sus în FreeCAD |
|||
# Apăsați F6 ptru al-l executa |
|||
# Acum FreeCAD se va bloca (nu va răspunde) deoarece debuggerul Python este în așteptare |
|||
# 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 |
|||
# Acum Scriptul aflat în execuție curentă apare în Winpdb. |
|||
# Definiți o pauză la ultima linie și apăsați F5 |
|||
# Acum apăsați F7 pentru a intra în codul Python al Draft.makeWire |
|||
</div> |
|||
=== Visual Studio Code (VS Code) === |
|||
<!-- START OF COLLAPSIBLE DIV --><div class="toccolours mw-collapsible mw-collapsed" style="width:800px;"> |
|||
VS Code Debugging ----> |
|||
<div class="mw-collapsible-content"> |
|||
Prerequisites: |
|||
* ptvsd package need to be installed{{Code|code= |
|||
pip install ptvsd |
|||
}}[https://pypi.org/project/ptvsd/ pypi page] |
|||
[https://code.visualstudio.com/docs/python/debugging#_remote-debugging Visual Studio Code documentation for remote debugging] |
|||
Steps: |
|||
* Add following code at the beginning of your script |
|||
<pre> |
|||
import ptvsd |
|||
print("Waiting for debugger attach") |
|||
# 5678 is the default attach port in the VS Code debug configurations |
|||
ptvsd.enable_attach(address=('localhost', 5678), redirect_output=True) |
|||
ptvsd.wait_for_attach() |
|||
</pre> |
|||
* Add a debug configuration in Visual Studio Code {{MenuCommand|Debug → Add Configurations…}}. It should looks like this : |
|||
<pre> |
|||
"configurations": [ |
|||
{ |
|||
"name": "Python: Attacher", |
|||
"type": "python", |
|||
"request": "attach", |
|||
"port": 5678, |
|||
"host": "localhost", |
|||
"pathMappings": [ |
|||
{ |
|||
"localRoot": "${workspaceFolder}", |
|||
"remoteRoot": "." |
|||
} |
|||
] |
|||
}, |
|||
</pre> |
|||
* In VS Code add a breakpoint anywhere you want. |
|||
* Launch the script in FreeCAD. FreeCAD freeze waiting for attachment. |
|||
* In VS Code start debugging used created configuration. You should see variables in debugger area. |
|||
</div></div> <!-- END OF COLLAPSIBLE DIV --> |
|||
{{Docnav|Module Creation|Testing}} |
{{Docnav|Module Creation|Testing}} |
||
{{Userdocnavi}} |
|||
[[Category:Developer Documentation/ro]] |
[[Category:Developer Documentation/ro]] |
Revision as of 13:56, 25 September 2019
Testează mai întâi
Înainte de a trece prin durerea de a depana utilizați Test framework pentru a verifica dacă testele standard funcționează corect. Dacă acestea nu se execută complet, este posibil să fie o instalare defectuoasă.
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 System 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 experimentală de FreeCAD care este încă în curs de dezvoltare, aceasta poate "îngheța". 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 "Debug build" a software-ului. "Debug build" este un parametru care este setat în timpul compilării, deci va trebui fie să compilați FreeCAD dvs înșivă, fie să obțineți o versiune "debug" precompilată.
For Linux
Linux Debugging ---->
Prerequisites:
- varianta software de package gdb instalat
- o depanare a variantei compilate a FreeCAD (în acest moment disponibilă prin building from source)
- un model FreeCAD care a cauzat crash-ul
Pași: Introduceți următoarelor în fereastra terminalului dvs:
$ 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 va porni. Efectuați pașii care determină ca FreeCAD să se prăbușească sau să înghețe, apoi introduceți în fereastra terminalului:
(gdb) bt
Aceasta va genera o listă lungă a exact ceea ce a făcut programul atunci când sa prăbușit sau a înghețat. Includeți acest lucru cu raportul problemei dvs.
(gdb) bt full
Print the values of the local variables also. This can be combined with a number to limit the number of frames shown.
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 va porni. Efectuați pașii care determină ca FreeCAD să se prăbușească sau să înghețe, apoi introduceți în fereastra terminalului:
(lldb) bt
Aceasta va genera o listă lungă a exact ceea ce a făcut programul atunci când sa prăbușit sau a înghețat. Includeți acest lucru cu raportul problemei dvs.
Python Debugging
Pentru o abordare mai modernă a depanării Python, cel puțin în Windows, a se vedea asta post in the Forum.
winpdb
winpdb Debugging ---->
Here is an example of using Winpdb inside FreeCAD:
Avem nevoie de depanatorul Python: Winpdb . Dacă nu aveți instalat, instalați-l sub Ubuntu / Debian cu:
sudo apt-get install winpdb
Acum permiteți configurarea programului de depanare.
- Start Winpdb.
- Set the debugger password to "test": Go to menu File->Password" and set the password.
Acum vom rula pas cu pas un script de testare Python în FreeCAD.
- Rulați winpdb și definiți password (e.g. test)
- 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)
- Dați Start la FreeCAD și încărcați fișierul de mai sus în FreeCAD
- Apăsați F6 ptru al-l executa
- Acum FreeCAD se va bloca (nu va răspunde) deoarece debuggerul Python este în așteptare
- 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
- Acum Scriptul aflat în execuție curentă apare în Winpdb.
- Definiți o pauză la ultima linie și apăsați F5
- Acum apăsați F7 pentru a intra în codul Python al Draft.makeWire
Visual Studio Code (VS Code)
VS Code Debugging ---->
Prerequisites:
- ptvsd package need to be installedpypi page
pip install ptvsd
Visual Studio Code documentation for remote debugging
Steps:
- Add following code at the beginning of your script
import ptvsd print("Waiting for debugger attach") # 5678 is the default attach port in the VS Code debug configurations ptvsd.enable_attach(address=('localhost', 5678), redirect_output=True) ptvsd.wait_for_attach()
- Add a debug configuration in Visual Studio Code Debug → Add Configurations…. It should looks like this :
"configurations": [ { "name": "Python: Attacher", "type": "python", "request": "attach", "port": 5678, "host": "localhost", "pathMappings": [ { "localRoot": "${workspaceFolder}", "remoteRoot": "." } ] },
- In VS Code add a breakpoint anywhere you want.
- Launch the script in FreeCAD. FreeCAD freeze waiting for attachment.
- In VS Code start debugging used created configuration. You should see variables in debugger area.
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Start, Surface, TechDraw, Test Framework, Web
- Hubs: User hub, Power users hub, Developer hub