Hi, louisepb.
I encountered an intricate problem when debugging the source code of TexGen. I want some help to solve this problem. As we know, the commands or operations in TexGen are executed by sending the corresponding "code" by the function "SendPythonCode" of class "CTexGenMainFrame". Then, this code is executed by the function "SendCodeBlock" of class "CPythonWrapper", and it is executed finally by the C function of python "PyObject_CallObject". The relation between python and C++ is accomplished automatically by SWIG. But in the process of parsing python command (i.e. from PyObject_CallObject to the corresponding function of class "CTexGen"), I don't understand how to accomplish this process.
For example, the executing process of "Save TexGen File…" operation before executing "PopulateTiXmlElement" function is listed below.
OnSave(CTexGenMainFrame)->SendPythonCode->SendCodeBlock(CPythonWrapper)->PyObject_CallObject->SaveToXML(CTexGen)
1) Why does the code "SaveToXML(r"F:\…\test.tg3",…)" have a individual character "r" before the file path?
2) How is the code parsed by the function PyObject_CallObject? And how is the function SaveToXML called?
I want to get more details about this to add some functions in TexGen.
Thanks.
Best regards,
Hao wang.
Debugging problem of source code
Moderators: Martin, Developers
Re: Debugging problem of source code
Hi Hao wang,
It would be interesting to know what you are using TexGen for. What functions are you hoping to add? If it's something that isn't commercially sensitive and would be an improvement to TexGen please consider sending it to me so that I can see if we can integrate it into the release code.
In answer to your questions:
1) The 'r' before the filepath is a Python instruction which means that '\' within the string will be read as part of the string and not as escape characters.
2) I have to confess that I let the SWIG wrapper take care of things and don't worry about the path that is taken to get to the C++ code when I'm debugging. If, for example, you want to debug the SaveToXML function simply place a breakpoint at the start of the function and let it run to that point. From there you're into the TexGen C++ code and you can debug as you like. There's no point in tracking through the SWIG generated code as you won't be making any changes to that anyway.
Are you working in Windows or Linux? In Windows I use Visual Studio. In Linux I use the ddd debugger. I'm not much of an expert on that. I normally work in VS and just build in Linux (and then use ddd) when I'm preparing a release to make sure that everything builds. Linux C++ is sometimes a little less forgiving than VS so there are occassional things which work fine in VS which cause issues in Linux.
I hope that helps (and answers your question). Let me know if you need to know anything else.
Louise
It would be interesting to know what you are using TexGen for. What functions are you hoping to add? If it's something that isn't commercially sensitive and would be an improvement to TexGen please consider sending it to me so that I can see if we can integrate it into the release code.
In answer to your questions:
1) The 'r' before the filepath is a Python instruction which means that '\' within the string will be read as part of the string and not as escape characters.
2) I have to confess that I let the SWIG wrapper take care of things and don't worry about the path that is taken to get to the C++ code when I'm debugging. If, for example, you want to debug the SaveToXML function simply place a breakpoint at the start of the function and let it run to that point. From there you're into the TexGen C++ code and you can debug as you like. There's no point in tracking through the SWIG generated code as you won't be making any changes to that anyway.
Are you working in Windows or Linux? In Windows I use Visual Studio. In Linux I use the ddd debugger. I'm not much of an expert on that. I normally work in VS and just build in Linux (and then use ddd) when I'm preparing a release to make sure that everything builds. Linux C++ is sometimes a little less forgiving than VS so there are occassional things which work fine in VS which cause issues in Linux.
I hope that helps (and answers your question). Let me know if you need to know anything else.
Louise
Re: Debugging problem of source code
Hi, louisepb.
Actually, I want to integrate stochastic modelling function into TexGen. Now, I can debug the source code 3.6.2 successfully in VS2010 x64, except several unimportant problems. Reading XML file of the required input information of the modelling function, is user-defined, has been completed by existing function "ReadFromXml". For ease of use in future, I want to add a function that can save the input information as XML file at any time. But this function can not be completed by the existing function "SaveToXml", since this function is designed to save CAD model to XML file. So, I want to add a new defined SAVE function in CTexGen class similar to the "SaveToXml" to achieve the purpose. Now, I have already added the new SAVE function in "TexGen.h", "TexGen.cpp", "Core.i". The debugging process looks good, but the SAVE function of class "CTexGen" cannot be called by "PyObject_CallObject". It seems that the SAVE function drops some parameters or the python compiler does not "recogonize" this function. I don't know where the problem is in?
BTW, the input operation of the required modelling information is completed in a user-defined window in GUI project.
Any help will be appreciated.
Best regards,
Hao wang.
Actually, I want to integrate stochastic modelling function into TexGen. Now, I can debug the source code 3.6.2 successfully in VS2010 x64, except several unimportant problems. Reading XML file of the required input information of the modelling function, is user-defined, has been completed by existing function "ReadFromXml". For ease of use in future, I want to add a function that can save the input information as XML file at any time. But this function can not be completed by the existing function "SaveToXml", since this function is designed to save CAD model to XML file. So, I want to add a new defined SAVE function in CTexGen class similar to the "SaveToXml" to achieve the purpose. Now, I have already added the new SAVE function in "TexGen.h", "TexGen.cpp", "Core.i". The debugging process looks good, but the SAVE function of class "CTexGen" cannot be called by "PyObject_CallObject". It seems that the SAVE function drops some parameters or the python compiler does not "recogonize" this function. I don't know where the problem is in?
BTW, the input operation of the required modelling information is completed in a user-defined window in GUI project.
Any help will be appreciated.
Best regards,
Hao wang.
Re: Debugging problem of source code
Hi Hao wang,
That sounds interesting.
The SaveToXml function, as you say, is actually a function to save the textile model as a .tg3 file which is in XML format.
It sounds like you have changed the correct files. Have you built the install project after you built the code? If you go to SolutionExplorer, right click on the INSTALL project and select build this will save the generated python code to the right place for it to be able to run and be found by the GUI.
Hopefully that's the issue. Let me know if not.
Best regards,
Louise
That sounds interesting.
The SaveToXml function, as you say, is actually a function to save the textile model as a .tg3 file which is in XML format.
It sounds like you have changed the correct files. Have you built the install project after you built the code? If you go to SolutionExplorer, right click on the INSTALL project and select build this will save the generated python code to the right place for it to be able to run and be found by the GUI.
Hopefully that's the issue. Let me know if not.
Best regards,
Louise
Re: Debugging problem of source code
Hi, louisepb,
When I built or rebuilt the INSTALL project, I got two errors. One is a "Intellisense: linkage specification is incompatible with previous "_hypot" (declared at line 161 of "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h")". The other is [error MSB3073: The command "setlocal "C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake if %errorlevel% neq 0 goto :cmd ……] in Line 113 in file Microsoft.CppCommon.targets.
Firstly, I never built the INSTALL project before, because I don't know what's the function of INSTALL project. So, I wonder wether the errors when building the project are induced by adding the new functions or not. In addition, in the INSTALL project, there are only two folders, "CMake Rules" and empty "External Dependencies". And there is only one file "INSTALL_force.rule" with only one sentence "# generated from CMake" in "CMake Rules". I still don't know what's the problem.
Best regards,
Hao wang.
When I built or rebuilt the INSTALL project, I got two errors. One is a "Intellisense: linkage specification is incompatible with previous "_hypot" (declared at line 161 of "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h")". The other is [error MSB3073: The command "setlocal "C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake if %errorlevel% neq 0 goto :cmd ……] in Line 113 in file Microsoft.CppCommon.targets.
Firstly, I never built the INSTALL project before, because I don't know what's the function of INSTALL project. So, I wonder wether the errors when building the project are induced by adding the new functions or not. In addition, in the INSTALL project, there are only two folders, "CMake Rules" and empty "External Dependencies". And there is only one file "INSTALL_force.rule" with only one sentence "# generated from CMake" in "CMake Rules". I still don't know what's the problem.
Best regards,
Hao wang.
Re: Debugging problem of source code
Hi Hao wang,
You can find a description of the INSTALL project in the Compiling section here: http://texgen.sourceforge.net/index.php ... #Compiling
I'm afraid that I haven't built TexGen using VS2010 so I'm not sure what the problems would be with the error messages. I'm having problems with my VS2010 installation at the moment. If I sort them out I'll try building TexGen using VS2010 and see if I get the same problems. If you manage to sort it out it would be useful to know what the problem was.
Sorry not to be more help,
Louise
You can find a description of the INSTALL project in the Compiling section here: http://texgen.sourceforge.net/index.php ... #Compiling
I'm afraid that I haven't built TexGen using VS2010 so I'm not sure what the problems would be with the error messages. I'm having problems with my VS2010 installation at the moment. If I sort them out I'll try building TexGen using VS2010 and see if I get the same problems. If you manage to sort it out it would be useful to know what the problem was.
Sorry not to be more help,
Louise
Re: Debugging problem of source code
Hi, louisepb.
I have found the problem from the output information of building "INSTALL" project.
…
3> CMake Error at GUI/cmake_install.cmake:139 (FILE):
3> file INSTALL cannot find
3> "…/Debug/TexGenGUI.exe.manifest".
…
Obviously, this problem is related to "manifest" of "TexGenGUI" project. The solution for this problem can be found in http://texgen.sourceforge.net/index.php ... #Compiling, which is shown below.
If building the Graphical User Interface with Visual Studio 2008 open the properties page for the TexGenGUI project. Select Configuration Properties -> Manifest Tool -> Input and Output and change the Embed Manifest option to 'No'.
Best regards,
Hao wang.
I have found the problem from the output information of building "INSTALL" project.
…
3> CMake Error at GUI/cmake_install.cmake:139 (FILE):
3> file INSTALL cannot find
3> "…/Debug/TexGenGUI.exe.manifest".
…
Obviously, this problem is related to "manifest" of "TexGenGUI" project. The solution for this problem can be found in http://texgen.sourceforge.net/index.php ... #Compiling, which is shown below.
If building the Graphical User Interface with Visual Studio 2008 open the properties page for the TexGenGUI project. Select Configuration Properties -> Manifest Tool -> Input and Output and change the Embed Manifest option to 'No'.
Best regards,
Hao wang.
Re: Debugging problem of source code
Hi Hao wang,
Apologies, I forgot to make sure that you'd done that. Glad you've got it working.
Best regards,
Louise
Apologies, I forgot to make sure that you'd done that. Glad you've got it working.
Best regards,
Louise