what IDE do you use

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
wmayer
Site Admin
Posts: 14814
Joined: Thu Feb 19, 2009 10:32 am

Re: what IDE do you use

Postby wmayer » Wed Jan 02, 2013 12:05 pm

Another very nice and lightweight debugger is winpdb. http://winpdb.org/
To start remote debugging go to File > Attach of the running winpdb application and enter the requested password. At the top of the script add

Code: Select all

import rpdb2
rpdb2.start_embedded_debugger(password)
and run it from within FreeCAD. Now go back to the winpdb application and press the Refresh button. You'll see the PID of FreeCAD, select it and press OK. On the right you'll see the script being executed.
jonasthomas
Posts: 120
Joined: Wed Feb 01, 2012 3:29 am

Re: what IDE do you use

Postby jonasthomas » Wed Jan 02, 2013 5:14 pm

Workplane comes somewhere from the Draft module. But you said you get a crash. Is it really a crash, i.e. you get a segmentation fault or something similar or is only an exception raised but FreeCAD is still working?
This is curious
I put my code back to this:

Code: Select all

#test.py
#this is a test routine to get run freecad entirely from the eric4 ide
import sys
# This is the standard location for the libraries in ubuntu.
#sys.path.append("/usr/lib/freecad/lib/")

#jonas thomas has his debug libraries here.
sys.path.append("/home/jonas/freecad/qtcreator-build/lib/")

# jrheinlaender has his debug libary here.
#sys.path.append(".../freecad-build-dbg/lib")

import FreeCADGui
FreeCADGui.showMainWindow()
FreeCADGui.exec_loop()
Then I commented the line which was causing the problem in DraftSnap.py:
if not hasattr(FreeCADGui,"Snapper"):
FreeCADGui.Snapper = Snapper()
if not hasattr(FreeCAD,"DraftWorkingPlane"):
import WorkingPlane, Draft_rc
FreeCAD.DraftWorkingPlane = WorkingPlane.plane()
#print FreeCAD.DraftWorkingPlane
FreeCADGui.addIconPath(":/icons")

When I did that, the FreeCad Gui fired up :D
I uncommented the comment and ran gdb from terminal (

Code: Select all

jonas@jonas-laptop:~/freecad$ cd teststuff
jonas@jonas-laptop:~/freecad/teststuff$ ls
test.py
jonas@jonas-laptop:~/freecad/teststuff$ gdb python
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/python...(no debugging symbols found)...done.
(gdb) r test.py
Starting program: /usr/bin/python test.py
[Thread debugging using libthread_db enabled]
FreeCAD 0.13, Libs: 0.13R1801 (Git)
Attach observer 0xc3a620
Attach observer 0xc46290
Attach observer 0xcae210
Attach observer 0xc67258
Attach observer 0xdb8388
Attach observer 0xdb8388
Attach observer 0xdc5e00
Attach observer 0xde7d80
[New Thread 0x7fffddf91700 (LWP 2100)]
matplotlib not found, Plot module will be disabled

Program received signal SIGSEGV, Segmentation fault.
0x00007fffef0347c4 in __cxa_allocate_exception () from /usr/lib/libstdc++.so.6
(gdb) bt
#0  0x00007fffef0347c4 in __cxa_allocate_exception ()
   from /usr/lib/libstdc++.so.6
#1  0x00007ffff5fd0654 in Py::PythonExtension<Gui::OutputStdout>::getattr_methods (this=0xdbde90, _name=0x553043 "softspace")
    at /home/jonas/freecad/free-cad/src/CXX/Python2/ExtensionOldType.hxx:173
#2  0x00007ffff5fd01cb in Py::PythonExtension<Gui::OutputStdout>::getattr (
    this=0xdbde90, name=0x553043 "softspace")
    at /home/jonas/freecad/free-cad/src/CXX/Python2/ExtensionOldType.hxx:69
#3  0x00007ffff5183120 in getattr_handler (self=0xdbde98, 
    name=0x553043 "softspace")
    at /home/jonas/freecad/free-cad/src/CXX/Python2/cxx_extensions.cxx:690
#4  0x000000000043576d in PyFile_SoftSpace ()
#5  0x00000000004a3c6f in PyEval_EvalFrameEx ()
#6  0x00000000004a9811 in PyEval_EvalCodeEx ()
#7  0x00000000004a98e2 in PyEval_EvalCode ()
#8  0x00000000004bc18e in PyImport_ExecCodeModuleEx ()
#9  0x00000000004be0fe in ?? ()
#10 0x00000000004bef33 in ?? ()
#11 0x00000000004bf1af in ?? ()
#12 0x00000000004bf86b in ?? ()
#13 0x00000000004bfdb4 in PyImport_ImportModuleLevel ()
#14 0x00000000004a184b in ?? ()
#15 0x000000000041f227 in PyObject_Call ()
---Type <return> to continue, or q <return> to quit---
#16 0x00000000004a240f in ?? ()
#17 0x00000000004a579c in PyEval_EvalFrameEx ()
#18 0x00000000004a9811 in PyEval_EvalCodeEx ()
#19 0x00000000004a98e2 in PyEval_EvalCode ()
#20 0x00000000004bc18e in PyImport_ExecCodeModuleEx ()
#21 0x00000000004be0fe in ?? ()
#22 0x00000000004bef33 in ?? ()
#23 0x00000000004bf1af in ?? ()
#24 0x00000000004bf86b in ?? ()
#25 0x00000000004bfdb4 in PyImport_ImportModuleLevel ()
#26 0x00000000004a184b in ?? ()
#27 0x000000000041f227 in PyObject_Call ()
#28 0x00000000004a240f in ?? ()
#29 0x00000000004a579c in PyEval_EvalFrameEx ()
#30 0x00000000004a9811 in PyEval_EvalCodeEx ()
#31 0x00000000004a98e2 in PyEval_EvalCode ()
#32 0x00000000004bc18e in PyImport_ExecCodeModuleEx ()
#33 0x00000000004be0fe in ?? ()
#34 0x00000000004bef33 in ?? ()
#35 0x00000000004bf1af in ?? ()
#36 0x00000000004bf86b in ?? ()
#37 0x00000000004bfdb4 in PyImport_ImportModuleLevel ()
#38 0x00000000004a184b in ?? ()
---Type <return> to continue, or q <return> to quit---
#39 0x000000000041f227 in PyObject_Call ()
#40 0x00000000004a240f in ?? ()
#41 0x00000000004a579c in PyEval_EvalFrameEx ()
#42 0x00000000004a9811 in PyEval_EvalCodeEx ()
#43 0x00000000004a98e2 in PyEval_EvalCode ()
#44 0x00000000004bc18e in PyImport_ExecCodeModuleEx ()
#45 0x00000000004be0fe in ?? ()
#46 0x00000000004bef33 in ?? ()
#47 0x00000000004bf1af in ?? ()
#48 0x00000000004bf86b in ?? ()
#49 0x00000000004bfdb4 in PyImport_ImportModuleLevel ()
#50 0x00000000004a184b in ?? ()
#51 0x000000000041f227 in PyObject_Call ()
#52 0x00000000004a240f in ?? ()
#53 0x00000000004a579c in PyEval_EvalFrameEx ()
#54 0x00000000004a9811 in PyEval_EvalCodeEx ()
#55 0x00000000004a98e2 in PyEval_EvalCode ()
#56 0x00000000004c9bae in PyRun_FileExFlags ()
#57 0x00000000004a0dd7 in ?? ()
#58 0x00000000004a7dfe in PyEval_EvalFrameEx ()
#59 0x00000000004a86f0 in PyEval_EvalFrameEx ()
#60 0x00000000004a9811 in PyEval_EvalCodeEx ()
#61 0x00000000004a98e2 in PyEval_EvalCode ()
---Type <return> to continue, or q <return> to quit---
#62 0x00000000004ca62b in PyRun_StringFlags ()
#63 0x00007ffff51b090f in Base::InterpreterSingleton::runString (
    this=0x951290, 
    sCmd=0x7ffff61db760 "# FreeCAD gui init module\n# (c) 2003 J\374rgen Riegel\n#\n# Gathering all the information to start FreeCAD\n# This is the second one of three init scripts, the third one\n# runs when the gui is up\n\n#********"...) at /home/jonas/freecad/free-cad/src/Base/Interpreter.cpp:148
#64 0x00007ffff67b12e6 in setupMainWindow ()
    at /home/jonas/freecad/free-cad/src/Main/FreeCADGuiPy.cpp:270
#65 0x00007ffff67b0953 in FreeCADGui_showMainWindow (args=0x7ffff7f8f050)
    at /home/jonas/freecad/free-cad/src/Main/FreeCADGuiPy.cpp:119
#66 0x00000000004a7dfe in PyEval_EvalFrameEx ()
#67 0x00000000004a9811 in PyEval_EvalCodeEx ()
#68 0x00000000004a98e2 in PyEval_EvalCode ()
#69 0x00000000004c9bae in PyRun_FileExFlags ()
#70 0x00000000004c9dc4 in PyRun_SimpleFileExFlags ()
#71 0x000000000041a95f in Py_Main ()
#72 0x00007ffff69d4c4d in __libc_start_main () from /lib/libc.so.6
#73 0x0000000000419b39 in _start ()
(gdb) 
(gdb) 
So I guess the problem is a segmentation fault.
wmayer
Site Admin
Posts: 14814
Joined: Thu Feb 19, 2009 10:32 am

Re: what IDE do you use

Postby wmayer » Wed Jan 02, 2013 7:12 pm

So I guess the problem is a segmentation fault.
I get a similar crash when using git version 0ebffa930ac0e68ecfb52e2f1d5d98673df65c22 or older. The strack trace is quite similar but on top it says it's an unhandled exception -- not a segmentation fault. And this also only happens when FreeCAD was built using cmake, using automake everything is fine.

But with git 408cc7c938fac308e02931f8dac1692db047cbb2 everything is working correctly for cmake and automake. And there I don't even need the workaround to import FreeCAD before FreeCADGui.

So, my tip is to update your git source tree and try again...
jonasthomas
Posts: 120
Joined: Wed Feb 01, 2012 3:29 am

Re: what IDE do you use

Postby jonasthomas » Wed Jan 02, 2013 7:34 pm

So, my tip is to update your git source tree and try again...
I'm pretty sure I was already on the current source tree, but I'm going to clean the project, re-run cmake and recompile.. (This is going to take a while.)

Code: Select all

jonas@jonas-laptop:~/freecad/free-cad$ git pull origin master
From git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
 * branch            master     -> FETCH_HEAD
Already up-to-date.
jonas@jonas-laptop:~/freecad/free-cad$ git checkout master
M	src/Mod/Sketcher/Gui/SoDatumLabel.cpp
M	src/Mod/Sketcher/Gui/SoDatumLabel.h
Already on 'master'
Your branch is ahead of 'jtGitHubOrigin/master' by 567 commits.
jonas@jonas-laptop:~/freecad/free-cad$ 
Btw.. After I commented out that line, it allowed Freecad to start, but as soon I tried create a sketch it crashed again. I ran from dgb and it was the same exception.
This seems related
Image
The strange thing is when I run from qt-creator I don't crash.
wmayer
Site Admin
Posts: 14814
Joined: Thu Feb 19, 2009 10:32 am

Re: what IDE do you use

Postby wmayer » Wed Jan 02, 2013 8:17 pm

The strange thing is when I run from qt-creator I don't crash.
There is a difference between running FreeCAD as application (running from QtCreator or menu or terminal) or as Python extension module. Theoretically, this shouldn't make a difference but it does.
And strange is also that the binaries built with automake and cmake don't behave identically.
jonasthomas
Posts: 120
Joined: Wed Feb 01, 2012 3:29 am

Re: what IDE do you use

Postby jonasthomas » Wed Jan 02, 2013 9:04 pm

wmayer wrote:
The strange thing is when I run from qt-creator I don't crash.
There is a difference between running FreeCAD as application (running from QtCreator or menu or terminal) or as Python extension module. Theoretically, this shouldn't make a difference but it does.
And strange is also that the binaries built with automake and cmake don't behave identically.
I cleaned, ran cmake, I'm still getting the exact same error same spot.

Code: Select all

[New Thread 0x7fffddf91700 (LWP 11748)]
matplotlib not found, Plot module will be disabled

Program received signal SIGSEGV, Segmentation fault.
0x00007fffef0347c4 in __cxa_allocate_exception () from /usr/lib/libstdc++.so.6
(gdb) bt
#0  0x00007fffef0347c4 in __cxa_allocate_exception ()
   from /usr/lib/libstdc++.so.6
#1  0x00007ffff5fd0654 in Py::PythonExtension<Gui::OutputStdout>::getattr_methods (this=0xdbe2f0, _name=0x553043 "softspace")
    at /home/jonas/freecad/free-cad/src/CXX/Python2/ExtensionOldType.hxx:173
#2  0x00007ffff5fd01cb in Py::PythonExtension<Gui::OutputStdout>::getattr (
    this=0xdbe2f0, name=0x553043 "softspace")
    at /home/jonas/freecad/free-cad/src/CXX/Python2/ExtensionOldType.hxx:69
#3  0x00007ffff5183120 in getattr_handler (self=0xdbe2f8, 
    name=0x553043 "softspace")
    at /home/jonas/freecad/free-cad/src/CXX/Python2/cxx_extensions.cxx:690
I'm wonder if this is related to the whitespace issues with the constraints. The link I referenced talked about libmesa.. .. Something to look at.. Do you have any thoughts?
[EDIT] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=364907 At least I thought I referenced it.
[EDIT#2] That's not it... This one looks interesting: https://bugs.launchpad.net/ubuntu/+sour ... bug/259219
[Edit #3]
Hmmm... Supposedly libgl1-mesa-glx 7.10.1-0ubuntu2 fixes all kinds of problems...
I'm running 7.7.1-1ubuntu3.1 in 10.04 I need to figure out how to backport this somehow to try the 7.10.... I should be able to do that right??? (Oth... 10.04 support ends in march. I suppose I should just bit the bullet and upgrade)
jonasthomas
Posts: 120
Joined: Wed Feb 01, 2012 3:29 am

Re: what IDE do you use

Postby jonasthomas » Sun Jan 06, 2013 8:00 am

I am delighted with my eric4 results I'm getting after my 10.04 to 12.04 Os upgrade.
All problems seemed to have vanished.

I managed to open up freecad within Eric4 as well as a widget that I'm working on.... Also, I setup some breakpoints inside the widget code and they worked the way they were supposed to and I was able to single step through the code.

He're the start up code I used.

Code: Select all

#test.py
#this is a test routine to get run freecad entirely from the eric4 ide
import sys
# This is the standard location for the libraries in ubuntu.
#sys.path.append("/usr/lib/freecad/lib/")

#jonas thomas has his debug libraries here.
sys.path.append("/home/jonasthomas/freecad/qtcreator-build/lib/")

# jrheinlaender has his debug libary here.
#sys.path.append(".../freecad-build-dbg/lib")

import FreeCADGui
FreeCADGui.showMainWindow()
sys.path.append("/home/jonasthomas/freecad/FreeCADPyCode/")
import mywidgetold

FreeCADGui.exec_loop()
balazs
Posts: 100
Joined: Thu Oct 16, 2014 3:40 pm

Re: what IDE do you use

Postby balazs » Tue Nov 11, 2014 1:44 pm

Hi All,

I have similar question, but couldn't find the answer here.
What kind of IDE do you use for C++ development and debugging under Linux? Formerly I was a pure vim+gdb fan, but FreeCAD complexity makes me think an IDE is more efficient.
What is the case with Python?
Is it possible (most probably with two different IDEs) for simultaneous C++ and Python debugging?

Thank you in advance.
Best regards: Balázs
ickby
Posts: 2918
Joined: Wed Oct 05, 2011 7:36 am

Re: what IDE do you use

Postby ickby » Tue Nov 11, 2014 1:55 pm

I use KDevelop. Once you get used to their interface this is IMHO the most productive tool out there. I realy love working with it, the support in code navigation and completition you get from KDevelop is far better than other IDE's I used.
But I have no idea about python debuging and coding.
abdullah
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

Re: what IDE do you use

Postby abdullah » Tue Nov 11, 2014 8:32 pm

+1 kdevelop

For me it is the most productive free tool for c++. You can split the view, jump to the previously navigated file and lines within each file (view)... very good...