HOW-TO:Debug Dynamic Link Libraries

From XBMC
Jump to: navigation, search
Cleanup.png This page or section may require cleanup, updating, spellchecking, reformatting and/or updated images. Please improve this page if you can. The discussion page may contain suggestions.

Contents

1 Configuration properties for the DLL

The DLL must be built with the following project settings:







Note that settings 2, 4 and 5 aren't needed for a normal dll for CVS. Also, the Runtime Library setting (3) should be set to Multi-threaded DLL (/MD) to reduce the dll size for CVS.

It is suggested that you configure the project settings for 2 configurations – a release build that will disable debugging and link against the Multi-threaded DLL, and a debug build using the above configuration. Example DLL sources using this configuration are the sources for libmpcdec.dll found in docs/sources/paplayer.

2 Normal dlls

Dll's are accessed via a wrapper class in xbmc. If you add a new dll please define your own wrapper class. An exception are screensaves and visualisations these dlls have a predefined interface. (See below)

2.1 Example declaration of a dll wrapper class

 public:
   virtual void foo (unsigned int type, char* szTest)=0;
   virtual void bar (char* szTest, unsigned int type)=0;
 };
 class DllExample : public DllDynamic, DllExampleInterface
 {
   DECLARE_DLL_WRAPPER(DllExample, Q:\\system\\Example.dll)
   LOAD_SYMBOLS()  // add this if you want to load debug symbols for the dll
   DEFINE_METHOD2(void, foo, (int p1, char* p2))
   DEFINE_METHOD_LINKAGE2(void, __stdcall, bar, (char* p1, int p2))
   BEGIN_METHOD_RESOLVE()
     RESOLVE_METHOD(foo)
     RESOLVE_METHOD_RENAME("_bar@8", bar)
   END_METHOD_RESOLVE()
 };


Just add the LOAD_SYMBOLS() macro to the dll wrapper class, to tell the DllLoader it should try to load symbols for your dll. If you want to find out more about the dll wrapper class see DynamicDll.h for more info.

3 Visualisations and Screensaver

Screensaver and visualisation dlls have a predefined interface. If you want to enable symbol loading for them, add the LOAD_SYMBOLS() macro to the DllScreensaver / DllVisualisation wrapper class.

4 Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Wiki help
Google Search
Toolbox