MSVCDebugTool + When to use Free()
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/02/2003 at 06:25, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.012
Platform: Windows ;
Language(s) : C++ ;---------
Hi,
after coding code for a couple of object und tag plugins, I have to state, that it's quite impossible to find bugs without any debugger. I tried the MSVCDebugTool but I can't get it work. I've done the steps described in the manual but all my breakpoints are ignored. I tried then to execute from MSVC, but it tells me, the file xy.cdl can't be found. I can't imagine at all, that it's possible to run the plugin from MSVC, even if C4D is open.
How can I debug my code?
Another question: I'm always reading that one have to use Free() to free the memory allocated e.g. for new objects. But when? How can I free the memory of an object that I want to insert it into the doc. I assume that c4d includes new objects into it's baselists rather than copy it. So I think I cannot free the object's memory!?
Thanks for answers in advance. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/02/2003 at 06:55, xxxxxxxx wrote:
It is not impossible to find bugs without a debugger, it is just harder and more skill is involved, it wasn't that many years ago us programmers didn't have debuggers of the standards we have now. I do know some people that don't use a debugger at all, or rarely. One of the main ways to do debugging, even when you have a debugger! is to output text to the console or a file, logging what is going on compared to what you think should be happening.
If you have MS VisualStudio you have an excellent debugger that works fine! I get the impression you don't know how to setup the project for debugging. The best way is to place your plugins source folder in the Plugins folder for CINEMA, then in the Project settings, set the Link output file without a path so it creates the CDL in the path of your plugin. Also in the Project settings, in the Debug tab, set the executable for the session to CINEMA. That is it! Now just start the debug (press F5 or click Go), it will load CINEMA, and you plugin can be debugged during runtime.
I think you have misunderstood memory/object allocation. If you have inserted an object/tag into the document, CINEMA will take care of it. You ONLY need to free objects/tags if they are not linked to a document, for example, if you create a temporary object, then when you are finished with it, you use the ::Free() for that object/tag type. If allocating memory, when you are finished you always free it.
Also, ensure you have a c4d_debug.txt file in your plugins folder, CINEMA will open a debug console giving you object/memory allocation leaks at exit and other useful info. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/02/2003 at 07:05, xxxxxxxx wrote:
Hi David,
again thanks for your help! I will try it directly. I know, it's not REALLY impossible to find bugs without a debugger. Since I also program php, javascript and coffee, I know these restrictions. But it's much easier with a debugger.
>>If you have MS VisualStudio you have an excellent debugger that works fine!<<
Do you mean, I don't need this debugtool?
The Free-stuff you explain, is exactly what I expected. But I want to go sure not having to examine all my code to insert Free calls, when my plugins are finished. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/02/2003 at 07:19, xxxxxxxx wrote:
I'm not sure what the "debug tool" is I'm afraid. Do you have MSVC++ 6? in the Build menu there should be Start Debug?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/02/2003 at 07:46, xxxxxxxx wrote:
The SDK documentation contains hints about pointer ownership. For example, under BaseDocument::InsertObject() it says for the parameter op: "Object to insert into the document. The document takes over the ownership of the pointed object.". You only need to Free() pointers that you own.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/02/2003 at 08:04, xxxxxxxx wrote:
Hi Klaus,
I'm using VC7 and so I don't know if the following applies to your IDE. To use the debugger I simply select the "DEBUG" configuration (see SDK examples). There I fill the property option "command" with the executable of Cinema4D (e.g. "..\..\..\CINEMA_4D.exe" - my plugin directory is always "...\MAXON\CINEMA_4D_R8\Plugins<Pluginname>"). Then you set a breakpoint and start the debugger via shortcut F5 or -> Debugging -> Start.
I have to admit that I was really amazed how great it worked - didn't expect that.Ciao,
Marcus -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/02/2003 at 08:46, xxxxxxxx wrote:
OK, now it stops at my breakpoints. But I'll get no c++ code window! Assembler only. When I start Debug (F5), I'll get the message: "CINEMA_4D.exe contains no debug information" (or similar, I'm using a german VC6). The "Debug Info" option of the project property dialog/Linker is checked.
I'm also wondering, that it stops at my breakpoint (inside Execute() of my expression plugin) before I'll get a view onto cinema. How can Cinema execute my plugin, before I use it?
Marcus: Du meinst "Projekteinstellungen, Tab Debug, "Ausführbares Programm für Debug-Sitzung"? Da habe ich CINEMA_4D.exe eingetragen. Es wird ja auch gestartet. Die anderen drei Felder sind leer.(?).
Sorry for this german include about the german terms of the vc6 gui. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/02/2003 at 09:03, xxxxxxxx wrote:
You have to set debug option in compiler options and in linker options. The settings of the SDK examples (configuration "DEBUG") should work for you.
My debug-related settings (perhaps different from VC6) are:Debuggen:
-> Befehl = "..\..\..\CINEMA_4D_R8"
-> Arbeitsverzeichnis = "..\..\.."
-> Debuggertyp = "Automatisch"C/C++:
-> Allgemein
--> Debuginformationsformat = "&Programmdatenbank; zum Bearbeiten und Fortfahren"
-> Präprozessor
--> Präprozessordefinitionen = "WIN32;__PC;_DEBUG;_WINDOWS"
-> Codeerstellung
--> Laufzeitbibliothek = "Multithreaded-Debug"Linker:
-> Eingabe
--> Zusätzliche Abhängigkeiten = "_api_r8_deb.lib"
-> Debuggen
--> Debuginfo generieren = "Ja"
--> Programmdatenbank-Datei erstellen = "$(OutDir)$(ProjectName).pdbI think the last option activates the generation of a symbol file which the debugger uses for code display.
Ciao,
Marcus -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/02/2003 at 09:40, xxxxxxxx wrote:
Thanks. I'm really confused. I deleted all breakpoints, but when i start debugging (F5), I always get the same assembler code break with the message: "User defined breakpoint called from source at 0x77f9eea9." (I have no breakpoints set!).
I switched to the api-v8 project, set the configuration to Debug, build it. Switched back to cinema4dsdk project, did the same. I always get the result described above!
Maybe, I have to try finding bugs without debugger support. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/02/2003 at 10:31, xxxxxxxx wrote:
Where did you place your breakpoint?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/02/2003 at 02:41, xxxxxxxx wrote:
In my first attepts I set a breakpoint at the beginning of the ::Execute(PluginTag *tag, BaseDocument *doc,...) function in the cpp window if vc6. Then I deleted all breakpoints, but it stops - don't know where exactly - all the same here:
77F9EEA9 int 3
77F9EEAA ret
77F9EEAB int 3
77F9EEAC ret
77F9EEAD mov eax,dword ptr [esp+4]
77F9EEB1 int 3
77F9EEB2 ret 4
77F9EEB5 mov eax,dword ptr [ebp-14h]
...
Oh, I see: "Context" is NTDLL! 77f9eea9()
Why does the debugger stop in a system dll? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/02/2003 at 03:33, xxxxxxxx wrote:
Perhaps the load process of your plugin is crashing, the debugger sees this and begins to debug. If you want to step to the next breakpoint, simply click on "Starten" (F5) again. You should get an error message some time.
Or perhaps you should check your debugger settings (Extras -> Optionen... -> Debugger).
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/02/2003 at 03:56, xxxxxxxx wrote:
I may click on "Starten" as much as I want. It always stops at the same point described above.
The output window (debug tab) lists all dlls that are loaded. The ntdll.dll is the first one, and the break is obviously in the ntdll.dll. So maybe I have to set an entry point (like it is "main()" in a standalone exe). In the project properties dialog under the linker tab I found an input field "Symbol für Einstiegspunkt" (symbol for entry point), but I don't know what kind of data this input accepts. I tried to type in <pluginname>.cdl, but then I got linker errors (symbol can't be resolved or similar). The windows context help says about this field: "Into this field you may input a start address for an executable file or a DLL". Don't know what "start address" means in this context.
These are the main settings in the Options dialog under Debug:
Source code notes (Quellcodeanmerkung) : CHECKED
Code Bytes: UNCHECKED
Symbols: CHECKED
Just in Time-Debugging: CHECKED
OLE RPC-Debugging: CHECKED
Debug Commands call Edit and Continue: CHECKED -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/02/2003 at 04:07, xxxxxxxx wrote:
Does your plugin load correctly if you don't use the debugger? To test it just put a GePrint("test") in your PluginStart() function.
Meanwhile I'll try to get the same behaviour as you.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/02/2003 at 04:18, xxxxxxxx wrote:
Yes. In the meantime I found the main bug that had let C4D crashed and now the plugin runs if I call it from c4d. But it doesn't do exactly what I want and so a debugger would be very helpful. Since I cannot compile while c4d is running, I have to restart c4d for every new try
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/02/2003 at 04:28, xxxxxxxx wrote:
Hmm, sorry I have noe ideas anymore. I couldn't reproduce the behaviour of your debugger. Perhaps the NTDLL.dll has a breakpoint set? Which OS do you use, what is the file size and version of yout NTDLL.dll?
Perhaps you can send me your project and workspace files (without sources) so that I can test them.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/02/2003 at 11:19, xxxxxxxx wrote:
IT RUNS!
Maybe it was only the ntdll.dll of windows 2000 that breaks. On win xp everything is ok!
thanks to all for your support. I hope I can help users too in the near future -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/02/2003 at 14:49, xxxxxxxx wrote:
Hey great. :))
Just try to install the Service Pack 2 for Windows 2000. This way the ntdll.dll should be updated. My one has a newer version number.
Happy hacking. Ciao,
Marcus -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/02/2003 at 03:59, xxxxxxxx wrote:
YES! I've installed Service Pack 3 and now it works also on Win 2000. I transfered the whole directory of my plugin from xp to win 2000 and I only have to adjust the path to cinema_4d.exe!
Thanks again!