Difference between revisions of "Various development tips"
Line 40: | Line 40: | ||
this will install drmingw as the jit debugger (drmingw -u to later uninstall) | this will install drmingw as the jit debugger (drmingw -u to later uninstall) | ||
(windbg from the platform sdk can be installed as the jit debugger with windbg -I | (windbg from the platform sdk can be installed as the jit debugger with windbg -I | ||
− | but it doesn't support | + | but it doesn't support gcc debug symbols. it does support vc5/6/7 .pdb files |
generated by vc++ toolkit, providing true source level debugging) | generated by vc++ toolkit, providing true source level debugging) | ||
Revision as of 10:15, 24 August 2005
This page contains various tips for developing for Code::Blocks. It is meant for developers wanting to extend Code::Blocks.
Using Code::Blocks' global configuration
There are many cases where you may need to have persistent configuration values. For example, you may be writing a new plugin (or extend an existing). The global configuration object is a singleton, meaning that only one exists for the program's lifetime. It can be accessed like this:
#include <configmanager.h> ... ConfigManager::Get()->Read(...); // "read" example ConfigManager::Get()->Write(...); // "write" example
As you can see, all that's needed is to include the relevant header file. To access the configuration then, you use the static member function ConfigManager::Get() which returns a ConfigManager object (the only). ConfigManager descends from wxConfigBase and so it inherits all its public methods for working with configuration files.
Let's see a real world example. Suppose you 're writing a new plugin and it needs to keep a directory path in a configuration value. To write the configuration value, possibly prior to exiting (or after its imaginary configuration window is closed), do this:
// somehow set pluginDir to the value you want wxString pluginDir; // write it in the global configuration ConfigManager::Get()->Write("/new_plugin/directory", pluginDir);
And to read the saved value, do this:
// write it in the global configuration // if we never written the value before, "default" will be returned wxString pluginDir = ConfigManager::Get()->Read("/new_plugin/directory", "default");
In the above examples, the "/new_plugin" part of the string should be replaced with something unique for the plugin you 're writing. For example, the compiler plugin uses "/compiler_gcc", the internal editor class uses "/editor" and so on. That's how simple is to use Code::Blocks' global configuration :)
One more thing: if you want your plugin's configuration to be included in the import/export list in "Settings->Import/export configuration", just add in your plugin's constructor(s) the following:
ConfigManager::AddConfiguration(m_PluginInfo.title, "/new_plugin");
This line will add your plugin in the import/export list. Neat huh?
JIT debugging
cd C:\mingw\bin drmingw -i -v
this will install drmingw as the jit debugger (drmingw -u to later uninstall) (windbg from the platform sdk can be installed as the jit debugger with windbg -I but it doesn't support gcc debug symbols. it does support vc5/6/7 .pdb files generated by vc++ toolkit, providing true source level debugging)
to test:
- create a win32 project using the gcc compiler as default - place __asm("int3"); somewhere in the code - compile & run gcc -g
- create a win32 project using vc++ toolkit compiler as default - place __asm{ int 3 }; somewhere in the code - compile & run cl /Zi link /debug