Initial contribution of EPL licensed sources
authorravikurupati
Tue, 02 Mar 2010 10:33:16 +0530
changeset 0 c6b0df440bee
child 1 a94395f1946b
Initial contribution of EPL licensed sources
dbgagents/trkagent/Distribution.Policy.S60
dbgagents/trkagent/app/Distribution.Policy.S60
dbgagents/trkagent/app/common/Distribution.Policy.S60
dbgagents/trkagent/app/common/resources/Distribution.Policy.S60
dbgagents/trkagent/app/common/resources/TrkIcn24.bmp
dbgagents/trkagent/app/common/resources/TrkIcn24m.bmp
dbgagents/trkagent/app/common/resources/TrkIcn32.bmp
dbgagents/trkagent/app/common/resources/TrkIcn32m.bmp
dbgagents/trkagent/app/common/resources/TrkIcn48.bmp
dbgagents/trkagent/app/common/resources/TrkIcn48m.bmp
dbgagents/trkagent/app/common/trkconnstatelistener.cpp
dbgagents/trkagent/app/common/trkconnstatelistener.h
dbgagents/trkagent/app/common/trkdebugstatelistener.cpp
dbgagents/trkagent/app/common/trkdebugstatelistener.h
dbgagents/trkagent/app/common/trkservereventcallback.h
dbgagents/trkagent/app/common/trkservereventlistener.h
dbgagents/trkagent/app/console/Distribution.Policy.S60
dbgagents/trkagent/app/console/TrkConsole.cpp
dbgagents/trkagent/app/console/TrkConsole.h
dbgagents/trkagent/app/console/TrkConsole.mmp
dbgagents/trkagent/app/s60/Distribution.Policy.S60
dbgagents/trkagent/app/s60/Isv_TrkApp_s60.mmp
dbgagents/trkagent/app/s60/TrkApp.cpp
dbgagents/trkagent/app/s60/TrkApp.hrh
dbgagents/trkagent/app/s60/TrkAppContainer.cpp
dbgagents/trkagent/app/s60/TrkAppContainer.h
dbgagents/trkagent/app/s60/TrkAppUi.cpp
dbgagents/trkagent/app/s60/TrkAppUi.h
dbgagents/trkagent/app/s60/TrkAppView.cpp
dbgagents/trkagent/app/s60/TrkAppView.h
dbgagents/trkagent/app/s60/TrkApp_s60.mmp
dbgagents/trkagent/app/s60/TrkApplication.cpp
dbgagents/trkagent/app/s60/TrkApplication.h
dbgagents/trkagent/app/s60/TrkConsole_s60.mmp
dbgagents/trkagent/app/s60/TrkDocument.cpp
dbgagents/trkagent/app/s60/TrkDocument.h
dbgagents/trkagent/app/s60/TrkSettingsContainer.cpp
dbgagents/trkagent/app/s60/TrkSettingsContainer.h
dbgagents/trkagent/app/s60/TrkSettingsData.cpp
dbgagents/trkagent/app/s60/TrkSettingsData.h
dbgagents/trkagent/app/s60/TrkSettingsList.cpp
dbgagents/trkagent/app/s60/TrkSettingsList.h
dbgagents/trkagent/app/s60/TrkSettingsView.cpp
dbgagents/trkagent/app/s60/TrkSettingsView.h
dbgagents/trkagent/app/s60/TrkUids.h
dbgagents/trkagent/app/s60/resources/Distribution.Policy.S60
dbgagents/trkagent/app/s60/resources/isv_build/Distribution.Policy.S60
dbgagents/trkagent/app/s60/resources/isv_build/trkapp_200170bb.rss
dbgagents/trkagent/app/s60/resources/isv_build/trkapp_200170bb_loc.rss
dbgagents/trkagent/app/s60/resources/trkapp_200170bb.rss
dbgagents/trkagent/app/s60/resources/trkapp_200170bb_loc.rls
dbgagents/trkagent/app/s60/resources/trkapp_200170bb_loc.rss
dbgagents/trkagent/app/s60/resources/trkapp_200170bb_reg.rss
dbgagents/trkagent/app/s60/trkconsole_tshell.mmp
dbgagents/trkagent/app/tv/Distribution.Policy.S60
dbgagents/trkagent/app/tv/resources/Distribution.Policy.S60
dbgagents/trkagent/app/tv/resources/trkapp_200170bb.rss
dbgagents/trkagent/app/tv/resources/trkapp_200170bb_loc.rls
dbgagents/trkagent/app/tv/resources/trkapp_200170bb_loc.rss
dbgagents/trkagent/app/tv/resources/trkapp_200170bb_reg.rss
dbgagents/trkagent/app/tv/trkapp.cpp
dbgagents/trkagent/app/tv/trkapp_tv.mmp
dbgagents/trkagent/app/tv/trkapplication.cpp
dbgagents/trkagent/app/tv/trkapplication.h
dbgagents/trkagent/app/tv/trkappui.cpp
dbgagents/trkagent/app/tv/trkappui.h
dbgagents/trkagent/app/tv/trkappview.cpp
dbgagents/trkagent/app/tv/trkappview.h
dbgagents/trkagent/app/tv/trkdocument.cpp
dbgagents/trkagent/app/tv/trkdocument.h
dbgagents/trkagent/dbgtrccomm/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/bwinscw/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/bwinscw/dbgtrccomm_win.def
dbgagents/trkagent/dbgtrccomm/client/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/client/dbgtrccli_s60.mmp
dbgagents/trkagent/dbgtrccomm/client/dbgtrccli_tv.mmp
dbgagents/trkagent/dbgtrccomm/client/dbgtrccli_uiq.mmp
dbgagents/trkagent/dbgtrccomm/client/dbgtrcclidefs.cpp
dbgagents/trkagent/dbgtrccomm/client/dbgtrcclidefs.h
dbgagents/trkagent/dbgtrccomm/client/dbgtrccliutils.cpp
dbgagents/trkagent/dbgtrccomm/client/dbgtrccliutils.h
dbgagents/trkagent/dbgtrccomm/client/dbgtrccomm.cpp
dbgagents/trkagent/dbgtrccomm/eabi/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/eabi/dbgtrccomm_eabi.def
dbgagents/trkagent/dbgtrccomm/group/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/group/s60/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/group/s60/bld.inf
dbgagents/trkagent/dbgtrccomm/group/tv/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/group/tv/bld.inf
dbgagents/trkagent/dbgtrccomm/group/uiq/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/group/uiq/bld.inf
dbgagents/trkagent/dbgtrccomm/inc/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/inc/dbgtrccmdcodes.h
dbgagents/trkagent/dbgtrccomm/inc/dbgtrccomm.h
dbgagents/trkagent/dbgtrccomm/inc/ostprotdefs.h
dbgagents/trkagent/dbgtrccomm/internal/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/internal/doc/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/internal/doc/USB_Comm_Design_API_Spec.doc
dbgagents/trkagent/dbgtrccomm/rom/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/rom/dbgtrccomm.iby
dbgagents/trkagent/dbgtrccomm/server/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/server/datalistener.h
dbgagents/trkagent/dbgtrccomm/server/dbgtrcportmgr.cpp
dbgagents/trkagent/dbgtrccomm/server/dbgtrcportmgr.h
dbgagents/trkagent/dbgtrccomm/server/dbgtrcserver.cpp
dbgagents/trkagent/dbgtrccomm/server/dbgtrcserver.h
dbgagents/trkagent/dbgtrccomm/server/dbgtrcserver_s60.mmp
dbgagents/trkagent/dbgtrccomm/server/dbgtrcserver_tv.mmp
dbgagents/trkagent/dbgtrccomm/server/dbgtrcserver_uiq.mmp
dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvmain.cpp
dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvscheduler.cpp
dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvscheduler.h
dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvserver.cpp
dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvserver.h
dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvsession.cpp
dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvsession.h
dbgagents/trkagent/dbgtrccomm/server/logging.h
dbgagents/trkagent/dbgtrccomm/server/ostbaserouter.cpp
dbgagents/trkagent/dbgtrccomm/server/ostbaserouter.h
dbgagents/trkagent/dbgtrccomm/server/ostmessage.cpp
dbgagents/trkagent/dbgtrccomm/server/ostmessage.h
dbgagents/trkagent/dbgtrccomm/server/ostprotregistry.cpp
dbgagents/trkagent/dbgtrccomm/server/ostprotregistry.h
dbgagents/trkagent/dbgtrccomm/server/ostwritemsgqueue.cpp
dbgagents/trkagent/dbgtrccomm/server/ostwritemsgqueue.h
dbgagents/trkagent/dbgtrccomm/server/portreader.cpp
dbgagents/trkagent/dbgtrccomm/server/portreader.h
dbgagents/trkagent/dbgtrccomm/server/portwriter.cpp
dbgagents/trkagent/dbgtrccomm/server/portwriter.h
dbgagents/trkagent/dbgtrccomm/server/shutdowntimer.cpp
dbgagents/trkagent/dbgtrccomm/server/shutdowntimer.h
dbgagents/trkagent/dbgtrccomm/test/Distribution.Policy.S60
dbgagents/trkagent/dbgtrccomm/test/dbgtrctest.cpp
dbgagents/trkagent/dbgtrccomm/test/dbgtrctest.h
dbgagents/trkagent/dbgtrccomm/test/dbgtrctest_s60.mmp
dbgagents/trkagent/dbgtrccomm/test/dbgtrctest_tv.mmp
dbgagents/trkagent/dbgtrccomm/test/dbgtrctest_uiq.mmp
dbgagents/trkagent/dbgtrccomm/test/dummytraceserver.cpp
dbgagents/trkagent/dbgtrccomm/test/dummytraceserver.h
dbgagents/trkagent/dccdriver/Distribution.Policy.S60
dbgagents/trkagent/dccdriver/TrkDccComm.h
dbgagents/trkagent/dccdriver/TrkDccDriver.cpp
dbgagents/trkagent/dccdriver/TrkDccDriver.h
dbgagents/trkagent/dccdriver/TrkDccDriver_s60.mmp
dbgagents/trkagent/dccdriver/TrkDccDriver_tv.mmp
dbgagents/trkagent/debugnotifier/DebugNotifier.h
dbgagents/trkagent/debugnotifier/DebugNotifierImplementation.cpp
dbgagents/trkagent/debugnotifier/DebugNotifier_s60.mmp
dbgagents/trkagent/debugnotifier/DebugNotifierimplementation.h
dbgagents/trkagent/debugnotifier/Distribution.Policy.S60
dbgagents/trkagent/debugnotifier/eabi/DebugNotifier.def
dbgagents/trkagent/debugnotifier/eabi/Distribution.Policy.S60
dbgagents/trkagent/doc/Distribution.Policy.S60
dbgagents/trkagent/doc/S60_3_0_Using_TRK_v2_5_on_S60_Devices_C.doc
dbgagents/trkagent/eabi/Distribution.Policy.S60
dbgagents/trkagent/eabi/isv_trkengine.def
dbgagents/trkagent/eabi/trkdccdriver.def
dbgagents/trkagent/eabi/trkengine_nokia_tshell.def
dbgagents/trkagent/eabi/trkengine_s60.def
dbgagents/trkagent/eabi/trkengine_tshell.def
dbgagents/trkagent/eabi/trkengine_tv.def
dbgagents/trkagent/eabi/trkengine_uiq.def
dbgagents/trkagent/eabi/trkkerneldriver.def
dbgagents/trkagent/eabi/trkxtidriver.def
dbgagents/trkagent/eka2driver/Distribution.Policy.S60
dbgagents/trkagent/eka2driver/Isv_TrkKernelDriver_s60.mmp
dbgagents/trkagent/eka2driver/Isv_TrkKernelDriver_tv.mmp
dbgagents/trkagent/eka2driver/TrkDriver.h
dbgagents/trkagent/eka2driver/TrkEventHandler.cpp
dbgagents/trkagent/eka2driver/TrkEventHandler.h
dbgagents/trkagent/eka2driver/TrkKernelDriver.cpp
dbgagents/trkagent/eka2driver/TrkKernelDriver.h
dbgagents/trkagent/eka2driver/TrkKernelDriver_s60.mmh
dbgagents/trkagent/eka2driver/TrkKernelDriver_s60.mmp
dbgagents/trkagent/eka2driver/TrkKernelDriver_tv.mmh
dbgagents/trkagent/eka2driver/TrkKernelDriver_tv.mmp
dbgagents/trkagent/eka2driver/isv_trkKerneldriver_uiq.mmp
dbgagents/trkagent/eka2driver/trkkerneldriver_uiq.mmh
dbgagents/trkagent/eka2driver/trkkerneldriver_uiq.mmp
dbgagents/trkagent/engine/DateTimeConverter.cpp
dbgagents/trkagent/engine/DateTimeConverter.h
dbgagents/trkagent/engine/Distribution.Policy.S60
dbgagents/trkagent/engine/Isv_TrkEngine_s60.mmp
dbgagents/trkagent/engine/Isv_TrkEngine_tv.mmp
dbgagents/trkagent/engine/TrkBtSocketCommPort.cpp
dbgagents/trkagent/engine/TrkBtSocketCommPort.h
dbgagents/trkagent/engine/TrkCommPort.h
dbgagents/trkagent/engine/TrkCommPortListener.h
dbgagents/trkagent/engine/TrkConnData.h
dbgagents/trkagent/engine/TrkConnectionListener.h
dbgagents/trkagent/engine/TrkDbgTrcCommPort.cpp
dbgagents/trkagent/engine/TrkDbgTrcCommPort.h
dbgagents/trkagent/engine/TrkDccCommPort.cpp
dbgagents/trkagent/engine/TrkDccCommPort.h
dbgagents/trkagent/engine/TrkDispatchLayer.cpp
dbgagents/trkagent/engine/TrkDispatchLayer.h
dbgagents/trkagent/engine/TrkEngine.cpp
dbgagents/trkagent/engine/TrkEngine.h
dbgagents/trkagent/engine/TrkEngineCallback.h
dbgagents/trkagent/engine/TrkEngineModel.cpp
dbgagents/trkagent/engine/TrkEngineModel.h
dbgagents/trkagent/engine/TrkEngine_s60.mmp
dbgagents/trkagent/engine/TrkEngine_tv.mmp
dbgagents/trkagent/engine/TrkFramingLayer.cpp
dbgagents/trkagent/engine/TrkFramingLayer.h
dbgagents/trkagent/engine/TrkSerialCommPort.cpp
dbgagents/trkagent/engine/TrkSerialCommPort.h
dbgagents/trkagent/engine/TrkSocketCommPort.cpp
dbgagents/trkagent/engine/TrkSocketCommPort.h
dbgagents/trkagent/engine/TrkSwInstUIHandler.cpp
dbgagents/trkagent/engine/TrkSwInstUIHandler.h
dbgagents/trkagent/engine/TrkSwInstall.cpp
dbgagents/trkagent/engine/TrkSwInstall.h
dbgagents/trkagent/engine/TrkUsbConnectionListener.h
dbgagents/trkagent/engine/TrkUsbPortListener.cpp
dbgagents/trkagent/engine/TrkUsbPortListener.h
dbgagents/trkagent/engine/TrkXtiCommPort.cpp
dbgagents/trkagent/engine/TrkXtiCommPort.h
dbgagents/trkagent/engine/dstypes.h
dbgagents/trkagent/engine/in_sock.h
dbgagents/trkagent/engine/isv_trkengine_uiq.mmp
dbgagents/trkagent/engine/msgcmd.h
dbgagents/trkagent/engine/serframe.h
dbgagents/trkagent/engine/trkengine_nokia_tshell.mmp
dbgagents/trkagent/engine/trkengine_tshell.mmp
dbgagents/trkagent/engine/trkengine_uiq.mmp
dbgagents/trkagent/engine/trkengu_win.def
dbgagents/trkagent/engine/trklogging.h
dbgagents/trkagent/group/Distribution.Policy.S60
dbgagents/trkagent/group/Trk.ini
dbgagents/trkagent/group/bld.inf
dbgagents/trkagent/group/nokia_tshell/Distribution.Policy.S60
dbgagents/trkagent/group/nokia_tshell/bld.inf
dbgagents/trkagent/group/nokia_tshell/trk_tshell.iby
dbgagents/trkagent/group/s60/Distribution.Policy.S60
dbgagents/trkagent/group/s60/bld.inf
dbgagents/trkagent/group/s60/isv_build/Distribution.Policy.S60
dbgagents/trkagent/group/s60/isv_build/bld.inf
dbgagents/trkagent/group/s60/isv_build/isv_trk.iby
dbgagents/trkagent/group/s60/sis/Distribution.Policy.S60
dbgagents/trkagent/group/s60/sis/app_trk_s60.pkg
dbgagents/trkagent/group/s60/sis/app_trk_s60_5_0.pkg
dbgagents/trkagent/group/s60/sis/eula.txt
dbgagents/trkagent/group/s60/sis/mk_s60_app_sis.bat
dbgagents/trkagent/group/s60/sis/mk_s60_app_sis_5_0.bat
dbgagents/trkagent/group/s60/sis/mk_s60_sys_sis.bat
dbgagents/trkagent/group/s60/sis/mk_s60_sys_sis_5_0.bat
dbgagents/trkagent/group/s60/sis/sys_trk_s60.pkg
dbgagents/trkagent/group/s60/sis/sys_trk_s60_5_0.pkg
dbgagents/trkagent/group/s60/trk_aif_svg_icons_dc.mk
dbgagents/trkagent/group/s60/trk_xti.ini
dbgagents/trkagent/group/trk_bt.ini
dbgagents/trkagent/group/trk_dcc.ini
dbgagents/trkagent/group/trk_usb.ini
dbgagents/trkagent/group/tshell/Distribution.Policy.S60
dbgagents/trkagent/group/tshell/bld.inf
dbgagents/trkagent/group/tshell/trk_tshell.iby
dbgagents/trkagent/group/tv/Distribution.Policy.S60
dbgagents/trkagent/group/tv/bld.inf
dbgagents/trkagent/group/tv/isv_build/Distribution.Policy.S60
dbgagents/trkagent/group/tv/isv_build/bld.inf
dbgagents/trkagent/group/tv/isv_build/isv_trk.iby
dbgagents/trkagent/group/tv/trk.iby
dbgagents/trkagent/group/tv/trk_h4hrp.ini
dbgagents/trkagent/group/tv/trk_om.ini
dbgagents/trkagent/internal/Distribution.Policy.S60
dbgagents/trkagent/internal/Readme.txt
dbgagents/trkagent/rom/Distribution.Policy.S60
dbgagents/trkagent/rom/trk.iby
dbgagents/trkagent/rom/trk_rom.iby
dbgagents/trkagent/tcbclient/Distribution.Policy.S60
dbgagents/trkagent/tcbclient/TrkTcbCliSession.cpp
dbgagents/trkagent/tcbclient/TrkTcbCliSession.h
dbgagents/trkagent/tcbclient/TrkTcbClientDefs.cpp
dbgagents/trkagent/tcbclient/TrkTcbClientDefs.h
dbgagents/trkagent/tcbclient/TrkTcbClientUtils.cpp
dbgagents/trkagent/tcbclient/TrkTcbClientUtils.h
dbgagents/trkagent/tcbserver/Distribution.Policy.S60
dbgagents/trkagent/tcbserver/TrkTcbCmdCodes.h
dbgagents/trkagent/tcbserver/TrkTcbServer.cpp
dbgagents/trkagent/tcbserver/TrkTcbServer.h
dbgagents/trkagent/tcbserver/TrkTcbServer_s60.mmp
dbgagents/trkagent/tcbserver/TrkTcbServer_tv.mmp
dbgagents/trkagent/tcbserver/TrkTcbSrvMain.cpp
dbgagents/trkagent/tcbserver/TrkTcbSrvScheduler.cpp
dbgagents/trkagent/tcbserver/TrkTcbSrvScheduler.h
dbgagents/trkagent/tcbserver/TrkTcbSrvServer.cpp
dbgagents/trkagent/tcbserver/TrkTcbSrvServer.h
dbgagents/trkagent/tcbserver/TrkTcbSrvSession.cpp
dbgagents/trkagent/tcbserver/TrkTcbSrvSession.h
dbgagents/trkagent/tcbserver/TrkTcbSrvSessionEngine.cpp
dbgagents/trkagent/tcbserver/TrkTcbSrvSessionEngine.h
dbgagents/trkagent/tcbserver/trktcbserver_uiq.mmp
dbgagents/trkagent/toolsstarter/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/bld.inf
dbgagents/trkagent/toolsstarter/common/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/common/ToolsCmdCodes.h
dbgagents/trkagent/toolsstarter/rom/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/rom/toolsstarter.iby
dbgagents/trkagent/toolsstarter/toolsstarterclient/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/toolsstarterclient/eabi/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/toolsstarterclient/eabi/toolsstarterclient.def
dbgagents/trkagent/toolsstarter/toolsstarterclient/group/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/toolsstarterclient/group/bld.inf
dbgagents/trkagent/toolsstarter/toolsstarterclient/group/toolsstarterclient.mmp
dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/toolsclient.h
dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/toolsclient.pan
dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/toolsclientdefs.h
dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/toolsclientsession.h
dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/toolsclientutils.h
dbgagents/trkagent/toolsstarter/toolsstarterclient/src/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/toolsstarterclient/src/toolsclientdefs.cpp
dbgagents/trkagent/toolsstarter/toolsstarterclient/src/toolsclientdllmain.cpp
dbgagents/trkagent/toolsstarter/toolsstarterclient/src/toolsclientsession.cpp
dbgagents/trkagent/toolsstarter/toolsstarterclient/src/toolsclientutils.cpp
dbgagents/trkagent/toolsstarter/toolsstarterserver/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/data/distribution.policy.s60
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/data/toolsstarterautolaunch.rss
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/distribution.policy.s60
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/group/bld.inf
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/group/distribution.policy.s60
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/group/toolsstarterautolaunch.mmp
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/inc/distribution.policy.s60
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/inc/logging.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/inc/toolsstarterautolaunch.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/inc/toolsstarteruiobserver.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/src/distribution.policy.s60
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/src/toolsstarterautolaunch.cpp
dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/src/toolsstarteruiobserver.cpp
dbgagents/trkagent/toolsstarter/toolsstarterserver/data/0x200170B5.rss
dbgagents/trkagent/toolsstarter/toolsstarterserver/data/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/toolsstarterserver/group/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/toolsstarterserver/group/bld.inf
dbgagents/trkagent/toolsstarter/toolsstarterserver/group/toolsstarterserver.mmp
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/connectionvariables.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/launchmanagerinterface.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/logging.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/sessionmessgelistener.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolscommportListener.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolsconnectionlistener.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolslaunchmgr.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolsprocess.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolsserver.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolssrvscheduler.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolssrvserver.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolssrvsession.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolsstarter.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolsusbportlistener.h
dbgagents/trkagent/toolsstarter/toolsstarterserver/sis/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/toolsstarterserver/sis/eula.txt
dbgagents/trkagent/toolsstarter/toolsstarterserver/sis/mk_s60_sys_sis_5_0.bat
dbgagents/trkagent/toolsstarter/toolsstarterserver/sis/toolsstarterserver_s60_5_0.pkg
dbgagents/trkagent/toolsstarter/toolsstarterserver/src/Distribution.Policy.S60
dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolslaunchmgr.cpp
dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolsprocess.cpp
dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolsserver.cpp
dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolssrvmain.cpp
dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolssrvscheduler.cpp
dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolssrvserver.cpp
dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolssrvsession.cpp
dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolsusbportlistener.cpp
dbgagents/trkagent/trklauncher/0x200159DC.rss
dbgagents/trkagent/trklauncher/Distribution.Policy.S60
dbgagents/trkagent/trklauncher/trkdummyrecognizer.cpp
dbgagents/trkagent/trklauncher/trkdummyrecognizer.h
dbgagents/trkagent/trklauncher/trklauncher.cpp
dbgagents/trkagent/trklauncher/trklauncher_s60.mmp
dbgagents/trkagent/trklauncher/trklauncher_tv.mmp
dbgagents/trkagent/trkserver/Distribution.Policy.S60
dbgagents/trkagent/trkserver/toolsconnectionlistener.cpp
dbgagents/trkagent/trkserver/toolsconnectionlistener.h
dbgagents/trkagent/trkserver/trkdebugmanager.cpp
dbgagents/trkagent/trkserver/trkdebugmanager.h
dbgagents/trkagent/trkserver/trkdebugmgrcallbacks.h
dbgagents/trkagent/trkserver/trkserver_s60.mmp
dbgagents/trkagent/trkserver/trkserver_tv.mmp
dbgagents/trkagent/trkserver/trkserverconsole.cpp
dbgagents/trkagent/trkserver/trkserverconsole.h
dbgagents/trkagent/trkserver/trksrvcmdcodes.h
dbgagents/trkagent/trkserver/trksrvmain.cpp
dbgagents/trkagent/trkserver/trksrvserver.cpp
dbgagents/trkagent/trkserver/trksrvserver.h
dbgagents/trkagent/trkserver/trksrvsession.cpp
dbgagents/trkagent/trkserver/trksrvsession.h
dbgagents/trkagent/trksrvclient/Distribution.Policy.S60
dbgagents/trkagent/trksrvclient/trksrvclientdefs.cpp
dbgagents/trkagent/trksrvclient/trksrvclientdefs.h
dbgagents/trkagent/trksrvclient/trksrvclientutils.cpp
dbgagents/trkagent/trksrvclient/trksrvclientutils.h
dbgagents/trkagent/trksrvclient/trksrvclisession.cpp
dbgagents/trkagent/trksrvclient/trksrvclisession.h
dbgagents/trkagent/xtidriver/Distribution.Policy.S60
dbgagents/trkagent/xtidriver/TrkXtiComm.h
dbgagents/trkagent/xtidriver/TrkXtiDriver.cpp
dbgagents/trkagent/xtidriver/TrkXtiDriver.h
dbgagents/trkagent/xtidriver/TrkXtiDriver.mmp
dbgagents/trkagent/xtidriver/TrkXtiSubscriber.cpp
dbgagents/trkagent/xtidriver/TrkXtiSubscriber.h
dbgguides/dbgsolutionsguide/com.nokia.debug_0.1.jar
dbgguides/dbgsolutionsguide/group/bld.inf
dbgguides/dbgsolutionsguide/group/dbgsolutionsguide.mrp
dbgsrv/coredumpserver/cdssupport/bwins/cdssupportu.def
dbgsrv/coredumpserver/cdssupport/bwins/distribution.policy.s60
dbgsrv/coredumpserver/cdssupport/distribution.policy.s60
dbgsrv/coredumpserver/cdssupport/eabi/cdssupportu.def
dbgsrv/coredumpserver/cdssupport/eabi/distribution.policy.s60
dbgsrv/coredumpserver/cdssupport/group/cdssupport.mmp
dbgsrv/coredumpserver/cdssupport/group/distribution.policy.s60
dbgsrv/coredumpserver/cdssupport/group/readme.txt
dbgsrv/coredumpserver/cdssupport/src/crashdata.cpp
dbgsrv/coredumpserver/cdssupport/src/distribution.policy.s60
dbgsrv/coredumpserver/cdssupport/src/executabledata.cpp
dbgsrv/coredumpserver/cdssupport/src/optionconfig.cpp
dbgsrv/coredumpserver/cdssupport/src/plugindata.cpp
dbgsrv/coredumpserver/cdssupport/src/processdata.cpp
dbgsrv/coredumpserver/cdssupport/src/streamelement.cpp
dbgsrv/coredumpserver/cdssupport/src/threaddata.cpp
dbgsrv/coredumpserver/config/bwins/coredumpinterfaceu.def
dbgsrv/coredumpserver/config/bwins/distribution.policy.s60
dbgsrv/coredumpserver/config/distribution.policy.s60
dbgsrv/coredumpserver/config/eabi/coredumpinterfaceu.def
dbgsrv/coredumpserver/config/eabi/distribution.policy.s60
dbgsrv/coredumpserver/config/src/coredumpinterface.cpp
dbgsrv/coredumpserver/config/src/coredumpinterface.mmp
dbgsrv/coredumpserver/config/src/distribution.policy.s60
dbgsrv/coredumpserver/config/src/readme.txt
dbgsrv/coredumpserver/distribution.policy.s60
dbgsrv/coredumpserver/group/all.mbc
dbgsrv/coredumpserver/group/bld.inf
dbgsrv/coredumpserver/group/coredumpserver.mrp
dbgsrv/coredumpserver/group/distribution.policy.s60
dbgsrv/coredumpserver/group/readme.txt
dbgsrv/coredumpserver/group/t_core_dump_all.iby
dbgsrv/coredumpserver/interface/common/crashdata.h
dbgsrv/coredumpserver/interface/common/debuglogging.h
dbgsrv/coredumpserver/interface/common/distribution.policy.s60
dbgsrv/coredumpserver/interface/common/executabledata.h
dbgsrv/coredumpserver/interface/common/plugindata.h
dbgsrv/coredumpserver/interface/common/processdata.h
dbgsrv/coredumpserver/interface/common/streamelement.h
dbgsrv/coredumpserver/interface/common/threaddata.h
dbgsrv/coredumpserver/interface/config/distribution.policy.s60
dbgsrv/coredumpserver/interface/config/optionconfig.h
dbgsrv/coredumpserver/interface/config/readme.txt
dbgsrv/coredumpserver/interface/datasave/crashdatasave.h
dbgsrv/coredumpserver/interface/datasave/crashdatasave.inl
dbgsrv/coredumpserver/interface/datasave/distribution.policy.s60
dbgsrv/coredumpserver/interface/datasave/readme.txt
dbgsrv/coredumpserver/interface/datasource/crashdatasource.h
dbgsrv/coredumpserver/interface/datasource/distribution.policy.s60
dbgsrv/coredumpserver/interface/datasource/readme.txt
dbgsrv/coredumpserver/interface/distribution.policy.s60
dbgsrv/coredumpserver/interface/formatter/distribution.policy.s60
dbgsrv/coredumpserver/interface/formatter/formatterapi.h
dbgsrv/coredumpserver/interface/formatter/formatterapi.inl
dbgsrv/coredumpserver/interface/formatter/readme.txt
dbgsrv/coredumpserver/interface/readme.txt
dbgsrv/coredumpserver/interface/server/coredumpinterface.h
dbgsrv/coredumpserver/interface/server/coredumpserverapi.h
dbgsrv/coredumpserver/interface/server/distribution.policy.s60
dbgsrv/coredumpserver/plugins/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/dexc/data/dexcformatter.rss
dbgsrv/coredumpserver/plugins/formatters/dexc/data/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/dexc/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/dexc/group/bld.inf
dbgsrv/coredumpserver/plugins/formatters/dexc/group/dexcformatter.iby
dbgsrv/coredumpserver/plugins/formatters/dexc/group/dexcformatter.mmp
dbgsrv/coredumpserver/plugins/formatters/dexc/group/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/dexc/inc/dexcformatter.h
dbgsrv/coredumpserver/plugins/formatters/dexc/inc/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/dexc/inc/tdexcformatter.h
dbgsrv/coredumpserver/plugins/formatters/dexc/src/dexcformatter.cpp
dbgsrv/coredumpserver/plugins/formatters/dexc/src/dexcproxy.cpp
dbgsrv/coredumpserver/plugins/formatters/dexc/src/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/dexc/src/readme.txt
dbgsrv/coredumpserver/plugins/formatters/dexc/test/bld.inf
dbgsrv/coredumpserver/plugins/formatters/dexc/test/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/dexc/test/readme.txt
dbgsrv/coredumpserver/plugins/formatters/dexc/test/tdexcformatter.cpp
dbgsrv/coredumpserver/plugins/formatters/dexc/test/tdexcformatter.iby
dbgsrv/coredumpserver/plugins/formatters/dexc/test/tdexcformatter.mmp
dbgsrv/coredumpserver/plugins/formatters/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/bwins/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/bwins/selflibu.def
dbgsrv/coredumpserver/plugins/formatters/symbianelf/data/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/data/symbianelfformatter.rss
dbgsrv/coredumpserver/plugins/formatters/symbianelf/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/documentation/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/documentation/sgl_ts0028_027_symbian_core_dump_file_format_1.6.doc
dbgsrv/coredumpserver/plugins/formatters/symbianelf/eabi/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/eabi/selflibu.def
dbgsrv/coredumpserver/plugins/formatters/symbianelf/group/bld.inf
dbgsrv/coredumpserver/plugins/formatters/symbianelf/group/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/group/selflib.mmp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/group/symbianelfformatter.iby
dbgsrv/coredumpserver/plugins/formatters/symbianelf/group/symbianelfformatter.mmp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/symbianelfdefs.h
dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/symbianelfformatter.h
dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/symbianelfoptions.h
dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/symbianelfstringinfo.h
dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/tsymbianelfformatter.h
dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/tsymbianelfstringinfo.h
dbgsrv/coredumpserver/plugins/formatters/symbianelf/incv2/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/incv2/symbianelfformatterv2.h
dbgsrv/coredumpserver/plugins/formatters/symbianelf/incv2/symbianelfoptionsv2.h
dbgsrv/coredumpserver/plugins/formatters/symbianelf/incv2/symbianelfstringinfov2.h
dbgsrv/coredumpserver/plugins/formatters/symbianelf/selflib/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/selflib/selflib.cpp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/selflib/selflib.h
dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/readme.txt
dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/symbianelfformatter.cpp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/symbianelfoptions.cpp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/symbianelfproxy.cpp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/symbianelfstringinfo.cpp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/srcv2/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/srcv2/readme.txt
dbgsrv/coredumpserver/plugins/formatters/symbianelf/srcv2/symbianelfformatterv2.cpp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/srcv2/symbianelfoptionsv2.cpp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/srcv2/symbianelfstringinfov2.cpp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/readme.txt
dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/tsymbianelfformatter.cpp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/tsymbianelfformatter.iby
dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/tsymbianelfformatter.mmp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/tsymbianelfstringinfo.cpp
dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/tsymbianelfstringinfo.mmp
dbgsrv/coredumpserver/plugins/formatters/test/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/test/readme.txt
dbgsrv/coredumpserver/plugins/formatters/test/testcrashdatasave.cpp
dbgsrv/coredumpserver/plugins/formatters/test/testcrashdatasave.h
dbgsrv/coredumpserver/plugins/formatters/test/testcrashdatasource.cpp
dbgsrv/coredumpserver/plugins/formatters/test/testcrashdatasource.h
dbgsrv/coredumpserver/plugins/formatters/utrace/data/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/utrace/data/utraceformatter.rss
dbgsrv/coredumpserver/plugins/formatters/utrace/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/utrace/group/bld.inf
dbgsrv/coredumpserver/plugins/formatters/utrace/group/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/utrace/group/utraceformatter.iby
dbgsrv/coredumpserver/plugins/formatters/utrace/group/utraceformatter.mmp
dbgsrv/coredumpserver/plugins/formatters/utrace/group/utraceformatter.mrp
dbgsrv/coredumpserver/plugins/formatters/utrace/inc/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/utrace/inc/utraceformatter.h
dbgsrv/coredumpserver/plugins/formatters/utrace/src/distribution.policy.s60
dbgsrv/coredumpserver/plugins/formatters/utrace/src/utraceformatter.cpp
dbgsrv/coredumpserver/plugins/formatters/utrace/src/utraceproxy.cpp
dbgsrv/coredumpserver/plugins/writers/distribution.policy.s60
dbgsrv/coredumpserver/plugins/writers/file/data/distribution.policy.s60
dbgsrv/coredumpserver/plugins/writers/file/data/filewriter.rss
dbgsrv/coredumpserver/plugins/writers/file/distribution.policy.s60
dbgsrv/coredumpserver/plugins/writers/file/group/bld.inf
dbgsrv/coredumpserver/plugins/writers/file/group/distribution.policy.s60
dbgsrv/coredumpserver/plugins/writers/file/group/filewriter.iby
dbgsrv/coredumpserver/plugins/writers/file/group/filewriter.mmp
dbgsrv/coredumpserver/plugins/writers/file/inc/distribution.policy.s60
dbgsrv/coredumpserver/plugins/writers/file/inc/filewriter.h
dbgsrv/coredumpserver/plugins/writers/file/src/distribution.policy.s60
dbgsrv/coredumpserver/plugins/writers/file/src/filewriter.cpp
dbgsrv/coredumpserver/plugins/writers/file/src/filewriterproxy.cpp
dbgsrv/coredumpserver/plugins/writers/file/src/readme.txt
dbgsrv/coredumpserver/plugins/writers/file/test/autoexec.bat
dbgsrv/coredumpserver/plugins/writers/file/test/bld.inf
dbgsrv/coredumpserver/plugins/writers/file/test/distribution.policy.s60
dbgsrv/coredumpserver/plugins/writers/file/test/filewritertest.script
dbgsrv/coredumpserver/plugins/writers/file/test/filewritertestserver.cpp
dbgsrv/coredumpserver/plugins/writers/file/test/filewritertestserver.h
dbgsrv/coredumpserver/plugins/writers/file/test/filewritertestserver.iby
dbgsrv/coredumpserver/plugins/writers/file/test/filewritertestserver.mmp
dbgsrv/coredumpserver/plugins/writers/file/test/filewriterteststeps.cpp
dbgsrv/coredumpserver/plugins/writers/file/test/filewriterteststeps.h
dbgsrv/coredumpserver/plugins/writers/file/test/readme.txt
dbgsrv/coredumpserver/readme.txt
dbgsrv/coredumpserver/server/distribution.policy.s60
dbgsrv/coredumpserver/server/eabi/coredump_svru.def
dbgsrv/coredumpserver/server/eabi/distribution.policy.s60
dbgsrv/coredumpserver/server/inc/corecrashhandler.h
dbgsrv/coredumpserver/server/inc/coredumpserver.h
dbgsrv/coredumpserver/server/inc/coredumpsession.h
dbgsrv/coredumpserver/server/inc/coretargetobserver.h
dbgsrv/coredumpserver/server/inc/distribution.policy.s60
dbgsrv/coredumpserver/server/inc/flashdatasource.h
dbgsrv/coredumpserver/server/inc/servercrashdatasource.h
dbgsrv/coredumpserver/server/plugins/coredumpserverstub.SIS
dbgsrv/coredumpserver/server/plugins/coredumpserverstub.pkg
dbgsrv/coredumpserver/server/plugins/distribution.policy.s60
dbgsrv/coredumpserver/server/plugins/pluginList1.plugin
dbgsrv/coredumpserver/server/src/corecrashhandler.cpp
dbgsrv/coredumpserver/server/src/coredumpmain.cpp
dbgsrv/coredumpserver/server/src/coredumpserver.cpp
dbgsrv/coredumpserver/server/src/coredumpserver.iby
dbgsrv/coredumpserver/server/src/coredumpserver.mmp
dbgsrv/coredumpserver/server/src/coredumpserverstub.iby
dbgsrv/coredumpserver/server/src/coredumpsession.cpp
dbgsrv/coredumpserver/server/src/coredumpsessioncalls.cpp
dbgsrv/coredumpserver/server/src/coretargetobserver.cpp
dbgsrv/coredumpserver/server/src/distribution.policy.s60
dbgsrv/coredumpserver/server/src/flashdatasource.cpp
dbgsrv/coredumpserver/server/src/readme.txt
dbgsrv/coredumpserver/server/src/servercrashdatasource.cpp
dbgsrv/coredumpserver/test/automatictests/common/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/common/tcoredumpcommon.h
dbgsrv/coredumpserver/test/automatictests/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/nand/coredump_nandloader.bat
dbgsrv/coredumpserver/test/automatictests/nand/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_app/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_app/group/bld.inf
dbgsrv/coredumpserver/test/automatictests/tcds_app/group/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_app/group/tcds_app.driver
dbgsrv/coredumpserver/test/automatictests/tcds_app/group/tcds_app_config.xml
dbgsrv/coredumpserver/test/automatictests/tcds_app/group/tcoredumpserversuite.iby
dbgsrv/coredumpserver/test/automatictests/tcds_app/group/tcoredumpserversuite.mmp
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/CDSconnectionstep.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/CDStokenstep.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/DEXCpluginstep.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/DEXCusersidestep.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/SELFpluginstep.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/SELFusersidestep.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/SELFusersidetrace.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/liststep.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/parameterstep.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/tcoredumpserversuitedefs.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/tcoredumpserversuiteserver.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/tcoredumpserversuitestepbase.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/testformatterusersidestep.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/testsignaling.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/utracestep.h
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_cdsconnections.script
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_coredumpserversuite.script
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_dexec.script
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_lists.script
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_parameters.script
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_self.script
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_self_trace.script
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_signaling.script
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_testformatter.script
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_token.script
dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_utrace.script
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/CDSconnectionstep.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/CDStokenstep.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/DEXCpluginstep.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/DEXCusersidestep.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/SELFpluginstep.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/SELFusersidestep.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/SELFusersidestrace.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/liststep.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/parameterstep.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/tcoredumpserversuiteserver.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/tcoredumpserversuitestepbase.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/testformatterusersidestep.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/testsignaling.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/src/utracestep.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/te_coredumpserversuite.ini
dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/te_dexec.ini
dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/te_self.ini
dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/te_self_trace.ini
dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/te_signaling.ini
dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/tcoredumpserversuite.xml
dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/tcoredumpserversuite/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/tcoredumpserversuite/tcoredumpservertest.xml
dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/tcoredumpserversuite/testexecuteservers/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/tcoredumpserversuite/testexecuteservers/tcoredumpserversuite.xml
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-002.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-004.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-005.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-007.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-009.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-010.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-011.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-012.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-013.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-014.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-015.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-performance-001.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-server-001.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-server-002.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-server-003.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-formatters-SELF-001.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-formatters-SELF-0010.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-formatters-SELF-0011.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-formatters-SELF-005.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-formatters-SELF-009.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-runall.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/autoexec.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/buildandconfigtestdriver.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/loopthetests.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/maintestexecute.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/shortersleepandrestart.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/sleepandrestart.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/wait.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/data/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/data/tcds_kernel.ini
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/data/tcds_scm_config.ini
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/data/tcds_self.ini
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/bld.inf
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/tcds_kernel.driver
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/tcds_kernel.mmp
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/tcds_kernel_autoexec.bat
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/tcds_kernel_config.xml
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_common_defs.h
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_coredumpmonitor.h
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_coredumpserver.h
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_crash_board.h
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_process_crash.h
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_scm_config.h
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_self.h
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/tcds_kernelBlockController.h
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/tcds_kernelBlockServer.h
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/DT-coredump-monitor.script
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/DT-coredump-performance.script
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/DT-coredump-server.script
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/DT-formatters-SELF.script
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/tcds_kernel_crash.script
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/tcds_kernel_process.script
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/tcds_scm_config.script
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_coredumpmonitor.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_coredumpserver.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_crash_board.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_process_crash.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_scm_config.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_self.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/tcds_kernelBlockController.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/tcds_kernelBlockServer.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/bld.inf
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/coredump_debug_token.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/coredump_debug_token.pkg
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/coredumptest_debug_token.iby
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/coredumptest_debug_token.mmp
dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/tcds_unit.ini
dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/tcds_unit_selflib.ini
dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/testelf1.elf
dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/testelfexecutable.elf
dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/testelfinvalid.elf
dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/testelfinvalidsize.elf
dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/tinytestelf.elf
dbgsrv/coredumpserver/test/automatictests/tcds_unit/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/bld.inf
dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/coredumptest_debug_token.mmp
dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/tcds_unit.driver
dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/tcds_unit.iby
dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/tcds_unit.mmp
dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/tcds_unit_autoexec.bat
dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/tcds_unit_selflib.mmp
dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/cds/CFlashDataSourceWrapper.h
dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/cds/CSELFLibWrapper.h
dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/cds/CServerDataSourceWrapper.h
dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/cds/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/tcds_unitBlockController.h
dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/tcds_unitBlockServer.h
dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/tcds_unit_selflib_block.h
dbgsrv/coredumpserver/test/automatictests/tcds_unit/scripts/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_unit/scripts/tcds_unit.script
dbgsrv/coredumpserver/test/automatictests/tcds_unit/scripts/tcds_unit_selflib.script
dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/cds/CFlashDataSourceWrapper.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/cds/CSelfLibWrapper.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/cds/CServerDataSourceWrapper.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/cds/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/coredump_debug_token.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/tcds_unitBlockController.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/tcds_unitBlockServer.cpp
dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/tcds_unit_selflib_block.cpp
dbgsrv/coredumpserver/test/automatictests/testdriver/coredump_testdriver.bat
dbgsrv/coredumpserver/test/automatictests/testdriver/distribution.policy.s60
dbgsrv/coredumpserver/test/automatictests/testdriver/html_file_copier.pl
dbgsrv/coredumpserver/test/crashapps/distribution.policy.s60
dbgsrv/coredumpserver/test/crashapps/group/bld.inf
dbgsrv/coredumpserver/test/crashapps/group/crashapp.iby
dbgsrv/coredumpserver/test/crashapps/group/crashapp.mmp
dbgsrv/coredumpserver/test/crashapps/group/crashapp_nodebugbit.mmp
dbgsrv/coredumpserver/test/crashapps/group/crashdriver.iby
dbgsrv/coredumpserver/test/crashapps/group/crashdriver.mmp
dbgsrv/coredumpserver/test/crashapps/group/distribution.policy.s60
dbgsrv/coredumpserver/test/crashapps/inc/crash.h
dbgsrv/coredumpserver/test/crashapps/inc/crashdefs.h
dbgsrv/coredumpserver/test/crashapps/inc/d_crashdriver_ldd.h
dbgsrv/coredumpserver/test/crashapps/inc/distribution.policy.s60
dbgsrv/coredumpserver/test/crashapps/inc/t_crashdriver_drv.h
dbgsrv/coredumpserver/test/crashapps/src/crash.s
dbgsrv/coredumpserver/test/crashapps/src/crashapp.cpp
dbgsrv/coredumpserver/test/crashapps/src/d_crashdriver_ldd.cpp
dbgsrv/coredumpserver/test/crashapps/src/distribution.policy.s60
dbgsrv/coredumpserver/test/distribution.policy.s60
dbgsrv/coredumpserver/test/elfdump/bld.inf
dbgsrv/coredumpserver/test/elfdump/distribution.policy.s60
dbgsrv/coredumpserver/test/elfdump/elfdump.cpp
dbgsrv/coredumpserver/test/elfdump/elfdump.mmp
dbgsrv/coredumpserver/test/elfdump/testelf1.elf
dbgsrv/coredumpserver/test/flashdump/distribution.policy.s60
dbgsrv/coredumpserver/test/flashdump/group/bld.inf
dbgsrv/coredumpserver/test/flashdump/group/distribution.policy.s60
dbgsrv/coredumpserver/test/flashdump/group/flashdump.iby
dbgsrv/coredumpserver/test/flashdump/group/flashdump.mmp
dbgsrv/coredumpserver/test/flashdump/inc/debuglogging.h
dbgsrv/coredumpserver/test/flashdump/inc/distribution.policy.s60
dbgsrv/coredumpserver/test/flashdump/inc/flashdump.h
dbgsrv/coredumpserver/test/flashdump/src/distribution.policy.s60
dbgsrv/coredumpserver/test/flashdump/src/flashdump.cpp
dbgsrv/coredumpserver/test/flashdump/src/main.cpp
dbgsrv/coredumpserver/test/oeelfdump/bld.inf
dbgsrv/coredumpserver/test/oeelfdump/distribution.policy.s60
dbgsrv/coredumpserver/test/oeelfdump/oeelfdump.c
dbgsrv/coredumpserver/test/oeelfdump/oeelfdump.iby
dbgsrv/coredumpserver/test/oeelfdump/oeelfdump.mmp
dbgsrv/coredumpserver/test/oemtoken/bld.inf
dbgsrv/coredumpserver/test/oemtoken/coredump_debug_token.cpp
dbgsrv/coredumpserver/test/oemtoken/coredump_debug_token.iby
dbgsrv/coredumpserver/test/oemtoken/coredump_debug_token.mmp
dbgsrv/coredumpserver/test/oemtoken/coredump_debug_token.pkg
dbgsrv/coredumpserver/test/oemtoken/distribution.policy.s60
dbgsrv/coredumpserver/test/plugins/distribution.policy.s60
dbgsrv/coredumpserver/test/plugins/testplugin/data/coredumptestplugin.rss
dbgsrv/coredumpserver/test/plugins/testplugin/data/distribution.policy.s60
dbgsrv/coredumpserver/test/plugins/testplugin/distribution.policy.s60
dbgsrv/coredumpserver/test/plugins/testplugin/group/bld.inf
dbgsrv/coredumpserver/test/plugins/testplugin/group/coredumptestplugin.iby
dbgsrv/coredumpserver/test/plugins/testplugin/group/coredumptestplugin.mmp
dbgsrv/coredumpserver/test/plugins/testplugin/group/distribution.policy.s60
dbgsrv/coredumpserver/test/plugins/testplugin/inc/coredumptestplugin.h
dbgsrv/coredumpserver/test/plugins/testplugin/inc/distribution.policy.s60
dbgsrv/coredumpserver/test/plugins/testplugin/src/coredumptestplugin.cpp
dbgsrv/coredumpserver/test/plugins/testplugin/src/coredumptestpluginproxy.cpp
dbgsrv/coredumpserver/test/plugins/testplugin/src/distribution.policy.s60
dbgsrv/coredumpserver/test/readme.txt
dbgsrv/coredumpserver/test/rundump/distribution.policy.s60
dbgsrv/coredumpserver/test/rundump/group/bld.inf
dbgsrv/coredumpserver/test/rundump/group/distribution.policy.s60
dbgsrv/coredumpserver/test/rundump/group/rundump.iby
dbgsrv/coredumpserver/test/rundump/group/rundump.mmp
dbgsrv/coredumpserver/test/rundump/inc/distribution.policy.s60
dbgsrv/coredumpserver/test/rundump/inc/rundump.h
dbgsrv/coredumpserver/test/rundump/src/distribution.policy.s60
dbgsrv/coredumpserver/test/rundump/src/rundump.cpp
dbgsrv/coredumpserver/test/testclient/bld.inf
dbgsrv/coredumpserver/test/testclient/distribution.policy.s60
dbgsrv/coredumpserver/test/testclient/testclient.cpp
dbgsrv/coredumpserver/test/testclient/testclient.iby
dbgsrv/coredumpserver/test/testclient/testclient.mmp
dbgsrv/coredumpserver/ui/coredumpui/distribution.policy.s60
dbgsrv/coredumpserver/ui/coredumpui/group/Bld.inf
dbgsrv/coredumpserver/ui/coredumpui/group/coredumpresource.mmp
dbgsrv/coredumpserver/ui/coredumpui/group/coredumpui.iby
dbgsrv/coredumpserver/ui/coredumpui/group/coredumpui.mmp
dbgsrv/coredumpserver/ui/coredumpui/group/coredumpui.rss
dbgsrv/coredumpserver/ui/coredumpui/group/coredumpuiaif.rss
dbgsrv/coredumpserver/ui/coredumpui/group/coredumpuiloc.rss
dbgsrv/coredumpserver/ui/coredumpui/group/coredumpuireg.rss
dbgsrv/coredumpserver/ui/coredumpui/group/distribution.policy.s60
dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpcdsdialog.h
dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpscmdialog.h
dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpui.h
dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpui.hrh
dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpuidatastructs.h
dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpuidialogs.h
dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpuinotifier.h
dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpuiplatform.hrh
dbgsrv/coredumpserver/ui/coredumpui/inc/distribution.policy.s60
dbgsrv/coredumpserver/ui/coredumpui/src/coredumpcdsdialog.cpp
dbgsrv/coredumpserver/ui/coredumpui/src/coredumpscmdialog.cpp
dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuiapplication.cpp
dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuiappui.cpp
dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuidialogs.cpp
dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuidocument.cpp
dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuimain.cpp
dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuinotifier.cpp
dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuiresourcelist.cpp
dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuiresourceview.cpp
dbgsrv/coredumpserver/ui/coredumpui/src/distribution.policy.s60
dbgsrv/coredumpserver/ui/distribution.policy.s60
dbgsrv/coredumpserver/ui/scriptconfig/bld.inf
dbgsrv/coredumpserver/ui/scriptconfig/coredumpscriptconfig.cpp
dbgsrv/coredumpserver/ui/scriptconfig/coredumpscriptconfig.iby
dbgsrv/coredumpserver/ui/scriptconfig/coredumpscriptconfig.mmp
dbgsrv/coredumpserver/ui/scriptconfig/distribution.policy.s60
dbgsrv/coredumpserver/ui/text/bld.inf
dbgsrv/coredumpserver/ui/text/distribution.policy.s60
dbgsrv/coredumpserver/ui/text/textcrashconfig.cpp
dbgsrv/coredumpserver/ui/text/textcrashconfig.iby
dbgsrv/coredumpserver/ui/text/textcrashconfig.mmp
genericunixprotocols/ftpsrv/distribution.policy.s60
genericunixprotocols/ftpsrv/group/bld.inf
genericunixprotocols/ftpsrv/group/distribution.policy.s60
genericunixprotocols/ftpsrv/group/ftpd.iby
genericunixprotocols/ftpsrv/group/ftpd.mmp
genericunixprotocols/ftpsrv/group/ftpd.tdf
genericunixprotocols/ftpsrv/group/ftpsrv.mrp
genericunixprotocols/ftpsrv/inc/distribution.policy.s60
genericunixprotocols/ftpsrv/inc/extern.h
genericunixprotocols/ftpsrv/inc/pathnames.h
genericunixprotocols/ftpsrv/inc/version.h
genericunixprotocols/ftpsrv/readme.txt
genericunixprotocols/ftpsrv/src/distribution.policy.s60
genericunixprotocols/ftpsrv/src/ftpcmd.cpp
genericunixprotocols/ftpsrv/src/ftpcmd.y
genericunixprotocols/ftpsrv/src/ftpd.cpp
genericunixprotocols/ftpsrv/src/logutmp.cpp
genericunixprotocols/ftpsrv/src/popen.cpp
genericunixprotocols/ftpsrv/test/.classpath
genericunixprotocols/ftpsrv/test/.project
genericunixprotocols/ftpsrv/test/bin/FTPPassiveTest.class
genericunixprotocols/ftpsrv/test/bin/FTPTest.class
genericunixprotocols/ftpsrv/test/bin/distribution.policy.s60
genericunixprotocols/ftpsrv/test/data/bigfile.bin
genericunixprotocols/ftpsrv/test/data/bigfile.txt
genericunixprotocols/ftpsrv/test/data/distribution.policy.s60
genericunixprotocols/ftpsrv/test/data/smallfile.bin
genericunixprotocols/ftpsrv/test/data/smallfile.txt
genericunixprotocols/ftpsrv/test/distribution.policy.s60
genericunixprotocols/ftpsrv/test/lib/commons-net-1.4.1.jar
genericunixprotocols/ftpsrv/test/lib/distribution.policy.s60
genericunixprotocols/ftpsrv/test/lib/jakarta-oro-2.0.8.jar
genericunixprotocols/ftpsrv/test/lib/junit.jar
genericunixprotocols/ftpsrv/test/src/FTPPassiveTest.java
genericunixprotocols/ftpsrv/test/src/FTPTest.java
genericunixprotocols/ftpsrv/test/src/distribution.policy.s60
genericunixprotocols/ftpsrv/test/test.bat
genericunixprotocols/telnetsrv/distribution.policy.s60
genericunixprotocols/telnetsrv/group/bld.inf
genericunixprotocols/telnetsrv/group/distribution.policy.s60
genericunixprotocols/telnetsrv/group/install.mmp
genericunixprotocols/telnetsrv/group/kill.mmp
genericunixprotocols/telnetsrv/group/restart.mmp
genericunixprotocols/telnetsrv/group/telnetd.iby
genericunixprotocols/telnetsrv/group/telnetd.mmp
genericunixprotocols/telnetsrv/group/telnetd.tdf
genericunixprotocols/telnetsrv/group/telnetsrv.mrp
genericunixprotocols/telnetsrv/group/uninstall.mmp
genericunixprotocols/telnetsrv/inc/distribution.policy.s60
genericunixprotocols/telnetsrv/inc/uihandler.h
genericunixprotocols/telnetsrv/readme.txt
genericunixprotocols/telnetsrv/src/distribution.policy.s60
genericunixprotocols/telnetsrv/src/install.cpp
genericunixprotocols/telnetsrv/src/kill.cpp
genericunixprotocols/telnetsrv/src/restart.cpp
genericunixprotocols/telnetsrv/src/telnetd.cpp
genericunixprotocols/telnetsrv/src/uihandler.cpp
genericunixprotocols/telnetsrv/src/uninstall.cpp
genericunixprotocols/telnetsrv/test/.classpath
genericunixprotocols/telnetsrv/test/.project
genericunixprotocols/telnetsrv/test/bin/TelnetTest.class
genericunixprotocols/telnetsrv/test/bin/distribution.policy.s60
genericunixprotocols/telnetsrv/test/distribution.policy.s60
genericunixprotocols/telnetsrv/test/lib/commons-net-1.4.1.jar
genericunixprotocols/telnetsrv/test/lib/distribution.policy.s60
genericunixprotocols/telnetsrv/test/lib/jakarta-oro-2.0.8.jar
genericunixprotocols/telnetsrv/test/lib/junit.jar
genericunixprotocols/telnetsrv/test/src/TelnetTest.java
genericunixprotocols/telnetsrv/test/src/distribution.policy.s60
genericunixprotocols/telnetsrv/test/test.bat
genericunixprotocolsguides/ftpandtelnetdaemonsguide/com.nokia.ftptelnet_0.1.jar
genericunixprotocolsguides/ftpandtelnetdaemonsguide/group/bld.inf
genericunixprotocolsguides/ftpandtelnetdaemonsguide/group/dbgconsolutionsguide.mrp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/common/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/common/resources/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
Binary file dbgagents/trkagent/app/common/resources/TrkIcn24.bmp has changed
Binary file dbgagents/trkagent/app/common/resources/TrkIcn24m.bmp has changed
Binary file dbgagents/trkagent/app/common/resources/TrkIcn32.bmp has changed
Binary file dbgagents/trkagent/app/common/resources/TrkIcn32m.bmp has changed
Binary file dbgagents/trkagent/app/common/resources/TrkIcn48.bmp has changed
Binary file dbgagents/trkagent/app/common/resources/TrkIcn48m.bmp has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/common/trkconnstatelistener.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// INCLUDE FILES
+#include <e32std.h>                      
+
+#include "trksrvclisession.h"
+#include "trkconnstatelistener.h" 
+                   
+// LOCAL FUNCTION PROTOTYPES
+
+// LOCAL CONSTANTS
+
+//
+// CTrkConnStateListener::CTrkConnStateListener
+// Constructor
+//
+CTrkConnStateListener::CTrkConnStateListener (RTrkSrvCliSession& aTrkSrvSession, MTrkServerEventCallback *aTrkServerEventCallback) 
+              :CTrkServerEventListener(aTrkSrvSession, aTrkServerEventCallback, CActive::EPriorityStandard), iConnMsg(KNullDesC), iConnState(iConnStatus)
+{
+    iConnStatus = ETrkNotConnected;
+    iTrkSrvSession.GetDebugConnStatus(iConnStatus, iConnMsg);
+    CActiveScheduler::Add( this ); 
+}
+
+//
+// CTrkConnStateListener::~CTrkConnStateListener
+// Destructor
+//
+CTrkConnStateListener::~CTrkConnStateListener()
+{
+    Cancel();   // Ensure that any outstanding requests are cancelled
+    Deque();
+}
+
+//
+// CTrkConnStateListener::ListenL
+// Starts listening for usb connection status notifications..
+//
+void CTrkConnStateListener::ListenL()
+{       
+    IssueRequestL();        
+}
+
+
+
+//
+// CTrkConnStateListener::StopListening
+// Cancel any pending requests for connection status notifications.
+//
+void CTrkConnStateListener::StopListening()
+{
+    Cancel();   
+}
+
+//
+// CTrkConnStateListener::IssueRequestL
+//
+TBool CTrkConnStateListener::IsConnected()
+{       
+   iTrkSrvSession.GetDebugConnStatus(iConnStatus, iConnMsg);
+   return (iConnStatus==ETrkConnected);
+}
+
+//
+// CTrkConnStateListener::IssueRequestL
+//
+void CTrkConnStateListener::IssueRequestL()
+{       
+    if (IsActive()) //already listening, just return...
+        return;
+    iTrkSrvSession.DebugConnStatusNotify(iConnState, iConnMsg, iStatus);
+    
+    SetActive();    
+}
+
+//
+// CTrkConnStateListener::DoCancel
+// This method gets called from CActive::Cancel();
+//
+void CTrkConnStateListener::DoCancel()
+{
+    iTrkSrvSession.DebugConnStatusNotifyCancel();   
+}
+
+//
+// CTrkConnStateListener::RunL
+// This method gets called whenever there is a change in the connection status.
+//
+void CTrkConnStateListener::RunL()
+{
+    User::LeaveIfError( iStatus.Int() );
+    if (iTrkServerEventCallback)
+        iTrkServerEventCallback->ConnectionStateChanged(iConnStatus);
+    
+    IssueRequestL();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/common/trkconnstatelistener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef TRKCONNSTATELISTENER_H_
+#define TRKCONNSTATELISTENER_H_
+
+//  INCLUDES
+#include <e32std.h>
+
+#include "trksrvclisession.h"
+#include "trkservereventlistener.h"
+
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+class CTrkConnStateListener: public CTrkServerEventListener
+{
+    public:  
+
+        CTrkConnStateListener(RTrkSrvCliSession& aTrkSrvSession, MTrkServerEventCallback *aTrkServerEventCallback);    
+        ~CTrkConnStateListener();
+
+        // From CTrkCommPortListener
+        void ListenL();
+        void StopListening();
+        
+        TBool IsConnected();
+        
+    protected: 
+        // From CActive
+        void DoCancel();
+        void RunL();        
+
+    private:
+    
+        void IssueRequestL();
+
+    private:        
+        TTrkConnStatus iConnStatus;
+        TBuf<KMaxPath> iConnMsg;
+        TConnState iConnState;        
+};
+
+#endif /* TRKCONNSTATELISTENER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/common/trkdebugstatelistener.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// INCLUDE FILES
+#include <e32std.h>                      
+
+#include "trksrvclisession.h"
+#include "trkdebugstatelistener.h" 
+                   
+// LOCAL FUNCTION PROTOTYPES
+
+// LOCAL CONSTANTS
+
+//
+// CTrkDebugStateListener::CTrkDebugStateListener
+// Constructor
+//
+CTrkDebugStateListener::CTrkDebugStateListener (RTrkSrvCliSession& aTrkSrvSession, MTrkServerEventCallback *aTrkServerEventCallback) 
+		  	  :CTrkServerEventListener(aTrkSrvSession, aTrkServerEventCallback, CActive::EPriorityStandard), iDebugState(iDebugging)
+{
+	iDebugging = EFalse;
+	iTrkSrvSession.GetDebuggingStatus(iDebugging);
+    CActiveScheduler::Add( this ); 
+}
+
+//
+// CTrkDebugStateListener::~CTrkDebugStateListener
+// Destructor
+//
+CTrkDebugStateListener::~CTrkDebugStateListener()
+{
+    Cancel();   // Ensure that any outstanding requests are cancelled
+    Deque();
+}
+
+//
+// CTrkDebugStateListener::ListenL
+// Starts listening for usb connection status notifications..
+//
+void CTrkDebugStateListener::ListenL()
+{		
+	IssueRequestL();		
+}
+
+
+
+//
+// CTrkDebugStateListener::StopListening
+// Cancel any pending requests for connection status notifications.
+//
+void CTrkDebugStateListener::StopListening()
+{
+	Cancel();	
+}
+
+//
+// CTrkDebugStateListener::IssueRequestL
+//
+TBool CTrkDebugStateListener::IsDebugging()
+{       
+   iTrkSrvSession.GetDebuggingStatus(iDebugging);
+   return iDebugging;
+}
+
+//
+// CTrkDebugStateListener::IssueRequestL
+//
+void CTrkDebugStateListener::IssueRequestL()
+{       
+    if (IsActive()) //already listening, just return...
+        return;
+    iTrkSrvSession.DebuggingStatusNotify(iDebugState, iStatus);
+    
+    SetActive();    
+}
+
+//
+// CTrkDebugStateListener::DoCancel
+// This method gets called from CActive::Cancel();
+//
+void CTrkDebugStateListener::DoCancel()
+{
+    iTrkSrvSession.DebuggingStatusNotifyCancel();	
+}
+
+//
+// CTrkDebugStateListener::RunL
+// This method gets called whenever there is a change in the debugging status.
+//
+void CTrkDebugStateListener::RunL()
+{
+	User::LeaveIfError( iStatus.Int() );
+	if (iTrkServerEventCallback)
+	    iTrkServerEventCallback->DebugStateChanged(iDebugging);
+	
+	IssueRequestL();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/common/trkdebugstatelistener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef     _TRKDEBUGSTATELISTENER_H_
+#define     _TRKDEBUGSTATELISTENER_H_
+
+//  INCLUDES
+#include <e32std.h>
+#include "trksrvclisession.h"
+#include "trkservereventlistener.h"
+
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+class CTrkDebugStateListener: public CTrkServerEventListener
+{
+    public:  
+
+		CTrkDebugStateListener(RTrkSrvCliSession& aTrkSrvSession, MTrkServerEventCallback *aTrkServerEventCallback);	
+        ~CTrkDebugStateListener();
+
+		// From CTrkCommPortListener
+        void ListenL();
+        void StopListening();
+        
+        TBool IsDebugging();
+        
+    protected: 
+    	// From CActive
+        void DoCancel();
+        void RunL();	    
+
+	private:
+	
+		void IssueRequestL();
+
+    private:		
+		TBool iDebugging;
+		TDebugState iDebugState;		
+};
+
+
+#endif      //  _TRKDEBUGSTATELISTENER_H_
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/common/trkservereventcallback.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKSERVEREVENTCALLBACK_H__
+#define __TRKSERVEREVENTCALLBACK_H__
+#include "TrkConnData.h" 
+/**
+*  Abstract callback interface for TRK event listeners to call into the app for certain situations.
+*  All callbacks into the app from TRK event listeners can be added here.
+*/
+class MTrkServerEventCallback
+{
+    public:
+
+        /**
+        * Called by TRK debug state listener when debugging state changes
+        */
+        virtual void DebugStateChanged(TBool& aDebugging) = 0;
+
+        /**
+        * Called when a connection state changes               
+        */
+        virtual void ConnectionStateChanged(TTrkConnStatus& aConnected) = 0; 
+      
+};
+
+#endif //__TRKSERVEREVENTCALLBACK_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/common/trkservereventlistener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKSERVEREVENTLISTENER_H__
+#define __TRKSERVEREVENTLISTENER_H__
+
+#include <e32base.h>
+
+#include "trkservereventcallback.h"
+//
+// class CTrkServerEventListener
+//
+// Abstract base class for trk server event listener
+//
+class RTrkSrvCliSession;
+
+class CTrkServerEventListener : public CActive
+{
+public:
+	
+	virtual ~CTrkServerEventListener();
+	
+	virtual void ListenL() = 0;
+	virtual void StopListening() = 0;
+
+protected:
+	
+	CTrkServerEventListener(RTrkSrvCliSession& aTrkSrvSession, MTrkServerEventCallback *aTrkServerEventCallback, TInt aPriority);
+	virtual TInt RunError( TInt aError );
+
+protected:
+    RTrkSrvCliSession& iTrkSrvSession;
+	MTrkServerEventCallback* iTrkServerEventCallback;
+};
+
+inline CTrkServerEventListener::CTrkServerEventListener(RTrkSrvCliSession& aTrkSrvSession, MTrkServerEventCallback *aTrkServerEventCallback, TInt aPriority)
+	: CActive(aPriority),
+	iTrkSrvSession(aTrkSrvSession),
+	iTrkServerEventCallback(aTrkServerEventCallback)
+{
+}
+
+inline CTrkServerEventListener::~CTrkServerEventListener()
+{
+}
+
+inline TInt CTrkServerEventListener::RunError(TInt aError)
+{
+	User::Panic( _L("TRK"), aError );	
+	return aError;
+}
+
+#endif // __TRKSERVEREVENTLISTENER_H__
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/console/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/console/TrkConsole.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,260 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "TrkConsole.h"
+#include  "trksrvclisession.h"
+
+
+#define SHOW_CONSOLE
+
+#ifdef SHOW_CONSOLE
+static CTrkConsoleIO* TrkIO = NULL;
+#endif
+
+#define SafeDelete(x) { if (x) delete x; x = NULL; }
+
+
+
+
+//
+//
+// CKeyboardInput implementation
+//
+//
+
+//
+// CKeyboardInput constructor
+//
+CKeyboardInput::CKeyboardInput(CConsoleBase* aConsole)
+	: CActive(EPriorityUserInput),
+	  iConsole(aConsole)
+{
+	CActiveScheduler::Add(this);
+}
+
+//
+// CKeyboardInput destructor
+//
+CKeyboardInput::~CKeyboardInput()
+{
+	Cancel();
+	Deque();
+}
+
+//
+// CKeyboardInput::ListenToKeyboard
+//
+// Wait for a key to be pressed
+//
+void CKeyboardInput::ListenToKeyboard()
+{
+	iConsole->Read(iStatus);
+	SetActive();
+}
+
+//
+// CKeyboardInput::RunL
+//
+// Called when a key is pressed
+//
+void CKeyboardInput::RunL()
+{
+	TKeyCode key = iConsole->KeyCode();
+	if (key == 'q' || key == 'Q')
+		CActiveScheduler::Stop();
+	else
+		ListenToKeyboard();
+}
+
+//
+// CKeyboardInput::DoCancel
+//
+// Stop waiting for keyboard input
+//
+void CKeyboardInput::DoCancel()
+{
+	iConsole->ReadCancel();
+}
+
+
+//
+//
+// CTrkConsoleIO implementation
+//
+//
+
+//
+// CTrkConsoleIO constructor
+//
+CTrkConsoleIO::CTrkConsoleIO()
+	: iConsole(0),
+	  iKeyboardInput(0)
+{
+	TRAPD(error, iConsole = Console::NewL(_L("TRK"), TSize(KConsFullScreen, KConsFullScreen)));
+	if (error != KErrNone)
+		User::Panic(_L("TRK failed to allocate CConsoleBase"), __LINE__);
+
+	iKeyboardInput = new CKeyboardInput(iConsole);
+	if (iKeyboardInput == 0)
+		User::Panic(_L("TRK failed to allocate CKeyboardInput"), __LINE__);
+
+	iKeyboardInput->ListenToKeyboard();
+}
+
+//
+// CTrkConsoleIO destructor
+//
+CTrkConsoleIO::~CTrkConsoleIO()
+{
+	SafeDelete(iKeyboardInput);
+	SafeDelete(iConsole);
+}
+
+//
+// CTrkConsoleIO::PrintToScreen
+//
+//	Print a message to the screen
+//
+void CTrkConsoleIO::PrintToScreen(TRefByValue<const TDesC> aFmt, ...)
+{
+	VA_LIST(l);
+	VA_START(l, aFmt);
+	iBuffer.FormatList(aFmt, l);
+
+	iConsole->Printf(iBuffer);
+}
+
+//
+// CTrkConsoleIO::Terminating
+//
+//	Notify user of termination
+//
+void CTrkConsoleIO::Terminating()
+{
+	iConsole->Printf(_L("\r\nPress any key to exit."));
+	iKeyboardInput->Cancel();
+	iConsole->Getch();
+}
+//
+// MainL
+//
+// Create the engine and the communications interface and start the active scheduler
+//
+void MainL()
+{
+	RProcess().SetPriority(EPriorityHigh);
+	RThread().SetPriority(EPriorityAbsoluteHigh);
+	
+	RTrkSrvCliSession trkSession;
+	TTrkConnStatus iConnStatus;
+	TBuf<KMaxPath> buf;
+	TInt majorVersion, minorVersion, majorAPIVersion, minorAPIVersion, buildNumber;
+	
+	TInt err = trkSession.ConnectToServer();
+	if (!err)
+	{
+	    // Ideally we need to connect here, but when the TRK server is started, connect automatically happens.
+	    // So we don't need to explicitly connect here. If the server is changed not to connect automatically at startup
+	    // then we need to connect here.	 
+	    //err = trkSession.Connect();	        
+        if(!err)
+        {
+            trkSession.GetDebugConnStatus(iConnStatus, buf);
+            trkSession.GetTrkVersion(majorVersion, minorVersion, majorAPIVersion, minorAPIVersion, buildNumber);
+        }
+	 }
+
+#ifdef SHOW_CONSOLE		
+	TrkIO->PrintToScreen(_L("Welcome to TRK for Symbian OS\r\n"));
+	TrkIO->PrintToScreen(_L("Version %d.%d.%d\r\n"), majorVersion, minorVersion, buildNumber);
+	TrkIO->PrintToScreen(_L("Implementing TRK API version %d.%d\r\n"), majorAPIVersion, minorAPIVersion);
+	TrkIO->PrintToScreen(_L("Press 'Q' to quit.\r\n\r\n"));
+#endif
+  	
+#ifdef SHOW_CONSOLE	
+	_LIT(KLfCr, "\r\n");
+	
+	TPtrC ptr(buf);
+	TInt pos = 0;
+	TInt lineStart = 0;
+	TInt length = 0;
+	
+	while (KErrNotFound != (pos = ptr.Find(KLfCr)))
+	{
+		ptr.Set(&buf[lineStart], pos);
+		lineStart = lineStart + pos + 2;
+		TrkIO->PrintToScreen(ptr);
+		TrkIO->PrintToScreen(KLfCr);
+		length = buf.Length() - lineStart;
+		if (length > 0)
+		{
+			ptr.Set(&buf[lineStart], length);
+		}
+	}
+#endif
+
+	CActiveScheduler::Start();
+	
+	trkSession.DisConnect();
+	trkSession.ShutDownServer();
+	trkSession.Close();
+}
+
+//
+// EXE entrypoint
+//
+TInt E32Main()
+{	
+	__UHEAP_MARK;
+
+	CTrapCleanup* cleanupStack = CTrapCleanup::New();
+	if (cleanupStack == 0)
+		User::Panic(_L("TRK failed to allocate CTrapCleanup"), __LINE__);
+	
+	CActiveScheduler* scheduler = new CActiveScheduler;
+	if (scheduler == 0)
+		User::Panic(_L("TRK failed to allocate CActiveScheduler"), __LINE__);
+
+	CActiveScheduler::Install(scheduler);
+
+#ifdef SHOW_CONSOLE
+	TrkIO = new CTrkConsoleIO;
+	
+	if (!TrkIO)
+		User::Panic(_L("TRK failed to allocate CTrkConsoleIO"), __LINE__);
+#endif
+	
+	TRAPD(error, MainL());
+
+#ifdef SHOW_CONSOLE
+	if (error != KErrNone)
+	{
+		TrkIO->PrintToScreen(_L("\r\nUnexpected error %d"), error);
+		TrkIO->Terminating();
+	}
+	SafeDelete(TrkIO);
+#endif
+	
+	SafeDelete(scheduler);
+	SafeDelete(cleanupStack);
+
+	__UHEAP_MARKEND;
+
+	User::Exit(0);
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/console/TrkConsole.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TrkConsole_H__
+#define __TrkConsole_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include <e32cons.h>
+#include <hal.h>
+
+
+//
+// class CKeyboardInput
+//
+// Handles input from the keyboard
+//
+class CKeyboardInput : public CActive
+{
+public:
+
+	CKeyboardInput(CConsoleBase* aConsole);
+	~CKeyboardInput();
+
+	void ListenToKeyboard();
+
+protected:
+
+	void RunL();
+	void DoCancel();
+
+private:
+
+	CConsoleBase* iConsole;
+};
+
+
+//
+// class CTrkConsoleIO
+//
+// Handles input and output from/to the console
+//
+class CTrkConsoleIO : public CBase
+{
+public:
+
+	CTrkConsoleIO();
+	~CTrkConsoleIO();
+
+	void PrintToScreen(TRefByValue<const TDesC> aFmt, ...);
+	void Terminating();
+
+private:
+
+	CConsoleBase* iConsole;
+	CKeyboardInput* iKeyboardInput;
+	TBuf<50> iBuffer;
+};
+
+#endif // __TrkConsole_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/console/TrkConsole.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+TARGET			TrkConsole.exe
+TARGETTYPE		exe
+
+UID			0x1000008C 0x200159E2
+
+SOURCEPATH		.
+SOURCE			TrkConsole.cpp
+
+SOURCEPATH    ..\..\trksrvclient
+SOURCE 		   trksrvclisession.cpp trksrvclientutils.cpp trksrvclientdefs.cpp
+
+LIBRARY			euser.lib
+
+SYSTEMINCLUDE  \epoc32\include
+USERINCLUDE    ..\..\engine
+USERINCLUDE    ..\..\trksrvclient
+USERINCLUDE    ..\..\trkserver
+ 
+
+VENDORID 0x101FB657
+
+CAPABILITY All -TCB -DRM
+
+EPOCSTACKSIZE 0x12000
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/Isv_TrkApp_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+macro 		__S60__
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+
+TARGET		  trkapp_200170bb.exe
+TARGETTYPE    exe
+epocstacksize 0x12000
+
+UID           0x100039CE 0x200170BB
+VENDORID      VID_DEFAULT
+CAPABILITY 	  ALL -TCB -DRM
+
+
+SOURCEPATH    .
+SOURCE        TrkApplication.cpp TrkDocument.cpp TrkAppUi.cpp TrkApp.cpp
+SOURCE		  TrkAppView.cpp TrkAppContainer.cpp TrkSettingsView.cpp TrkSettingsContainer.cpp 
+SOURCE	 	  TrkSettingsList.cpp TrkSettingsData.cpp
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+  	SYSTEMINCLUDE	\epoc32\include
+  	USERINCLUDE   ..\..\engine 
+#else
+    MW_LAYER_SYSTEMINCLUDE
+    USERINCLUDE   ../../engine
+#endif
+
+LIBRARY       euser.lib apparc.lib cone.lib eikcore.lib eikctl.lib eikcoctl.lib viewcli.lib
+LIBRARY       gdi.lib
+LIBRARY	      avkon.lib aknnotify.lib
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+
+sourcepath	.\resources\isv_build
+userinclude .
+userinclude .\resources
+START RESOURCE	trkapp_200170bb.rss
+HEADER
+targetpath	\resource\apps
+lang		sc
+end
+
+sourcepath	.\resources
+START RESOURCE	trkapp_200170bb_reg.rss
+TARGETPATH	\private\10003a3f\apps
+END
+
+sourcepath	.\resources\isv_build
+userinclude .
+userinclude .\resources
+start resource trkapp_200170bb_loc.rss
+targetpath \resource\apps
+lang sc
+end
+
+START BITMAP    trkapp_200170bb.mbm
+HEADER
+TARGETPATH      \resource\apps
+SOURCEPATH 		..\common\resources
+SOURCE          c8  TrkIcn24.bmp TrkIcn24m.bmp TrkIcn32.bmp TrkIcn32m.bmp TrkIcn48.bmp TrkIcn48m.bmp
+END
+
+#else
+
+sourcepath	./resources/isv_build
+userinclude .
+userinclude ./resources
+START RESOURCE	trkapp_200170bb.rss
+HEADER
+targetpath	/resource/apps
+lang		sc
+end
+
+sourcepath	./resources
+START RESOURCE	trkapp_200170bb_reg.rss
+TARGETPATH	/private/10003a3f/apps
+END
+
+sourcepath	./resources/isv_build
+userinclude .
+userinclude ./resources
+start resource trkapp_200170bb_loc.rss
+targetpath /resource/apps
+lang sc
+end
+
+START BITMAP    trkapp_200170bb.mbm
+HEADER
+TARGETPATH      /resource/apps
+SOURCEPATH 		../common/resources
+SOURCE          c8  TrkIcn24.bmp TrkIcn24m.bmp TrkIcn32.bmp TrkIcn32m.bmp TrkIcn48.bmp TrkIcn48m.bmp
+END
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkApp.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifdef __UI_FRAMEWORKS_V2__
+#include <eikstart.h>
+#endif
+
+#include "TrkApplication.h"
+
+
+#ifdef __UI_FRAMEWORKS_V2__
+
+	LOCAL_C CApaApplication* NewApplication()
+		{
+		return new CTrkApplication;
+		}
+
+	GLDEF_C TInt E32Main()
+		{
+		return EikStart::RunApplication(NewApplication);
+		}
+
+	#if defined(__WINS__) && !defined(EKA2)
+	EXPORT_C TInt WinsMain(TDesC* aCmdLine)
+		{
+		return EikStart::RunApplication(NewApplication, aCmdLine);
+		}
+
+	GLDEF_C TInt E32Dll(TDllReason)
+		{
+		return KErrNone;
+		}
+	#endif //__WINS__ && !EKA2
+	
+#else //__UI_FRAMEWORKS_V2__
+
+	EXPORT_C CApaApplication* NewApplication()
+	{
+		return new CTrkApplication;
+	}
+
+	#ifndef EKA2
+	GLDEF_C TInt E32Dll(TDllReason)
+	{
+		return KErrNone;
+	}
+	#endif
+	
+#endif //__UI_FRAMEWORKS_V2__
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkApp.hrh	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKAPP_HRH__
+#define __TRKAPP_HRH__
+
+// HelloWorldBasic enumerate command codes
+enum TTrkMenuCommands
+    {
+    ETrkConnect = 100,  // start value must not be 0
+    ETrkDisconnect,
+	ETrkSettings,
+	ETrkAbout,
+    ETrkCmdChange
+    };
+
+enum TExpressPrefControls
+	{
+	ETrkConnectionType = 200,
+	ETrkConnectionPort,
+	ETrkConnectionBaudRate,
+	ETrkPlugAndPlayOption
+    };
+
+#endif // __TRKAPP_HRH__
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkAppContainer.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// INCLUDE FILES
+#include <barsread.h>       // TResourceReader
+#include <gdi.h>
+
+#include "TrkAppUi.h"
+#include "TrkAppView.h"
+#include "TrkConnData.h"
+#include "TrkAppContainer.h"
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CTrkAppContainer::CTrkAppContainer
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CTrkAppContainer::CTrkAppContainer(CTrkAppView* aTrkAppView)
+:iTrkAppView(aTrkAppView)
+{
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkAppContainer::ConstructL
+// Symbian OS 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CTrkAppContainer::ConstructL(const TRect& aRect)
+{
+	CreateWindowL();
+	//Window().SetShadowDisabled(EFalse);
+
+	SetBlank();
+
+	SetRect(aRect);
+	ActivateL(); 
+}
+
+
+// Destructor
+CTrkAppContainer::~CTrkAppContainer()
+{
+}
+
+// ---------------------------------------------------------
+// CConnTestContainer::Draw(const TRect& aRect) const
+// ---------------------------------------------------------
+//
+void CTrkAppContainer::Draw(const TRect& /*aRect*/) const
+{
+    CWindowGc& gc = SystemGc();
+    gc.Clear(Rect());
+	
+	TRect drawRect = Rect();
+	
+	const CFont *font = iEikonEnv->AnnotationFont();
+	gc.UseFont(font);
+	
+	TBuf<KMaxPath> buf;
+
+	_LIT(KTrkWelcome,"Welcome to TRK for Symbian OS");
+
+	TInt vert = 25;
+	
+	gc.DrawText(KTrkWelcome, drawRect, vert, CGraphicsContext::ELeft, 2);
+	vert += font->HeightInPixels()*2;
+	
+	if (iTrkAppView)
+	{
+        
+        TTrkConnStatus statusType = iTrkAppView->GetConnectionStatus();
+	    switch(statusType)
+        {
+		    case ETrkConnected:
+			{
+				gc.DrawText(KStatusConnected, drawRect, vert, CGraphicsContext::ELeft, 2);
+		        break;
+		        
+			}
+		    case ETrkNotConnected:
+			{
+				gc.DrawText(KStatusDisconnected, drawRect, vert, CGraphicsContext::ELeft, 2);
+		        break;
+	        }
+		    case ETrkConnecting:
+	        {
+		        gc.DrawText(KStatusConnecting, drawRect, vert, CGraphicsContext::ELeft, 2);
+		        break;
+	        }
+		    case ETrkConnectionError:
+	        {
+		        gc.DrawText(KStatusError, drawRect, vert, CGraphicsContext::ELeft, 2);
+		        break;	            
+	        }         
+        }
+		
+		vert += font->HeightInPixels()*1.5;
+		
+		iTrkAppView->GetConnectionMsg(buf);
+		_LIT(KLfCr, "\r\n");
+		
+		TPtrC ptr(buf);
+		TInt pos = 0;
+		TInt lineStart = 0;
+		TInt length = 0;
+		
+		while (KErrNotFound != (pos = ptr.Find(KLfCr)))
+		{
+			ptr.Set(&buf[lineStart], pos);
+			lineStart = lineStart + pos + 2;
+			gc.DrawText(ptr, drawRect, vert, CGraphicsContext::ELeft, 2);
+			vert += font->HeightInPixels();
+			length = buf.Length() - lineStart;
+			if (length > 0)
+			{
+				ptr.Set(&buf[lineStart], length);
+			}
+		}
+	}
+	
+	gc.DiscardFont();
+}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkAppContainer.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TRKAPPCONTAINER_H__
+#define __TRKAPPCONTAINER_H__
+
+// INCLUDES
+#include <coecntrl.h>
+
+class CTrkAppView;
+
+class CTrkAppContainer : public CCoeControl
+{
+    public: // Constructors and destructor
+        /**
+        * C++ constructor.
+        * @since 2.1
+        * @param aController reference to CCcorController
+        */
+        CTrkAppContainer(CTrkAppView* aTrkAppView);
+
+        /**
+        * Symbian OS default constructor.
+        * @since 2.1
+        */
+        void ConstructL(const TRect& aRect);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CTrkAppContainer();
+        
+    public: // Functions from base classes
+        /**
+        * From CCoeControl set the size and position of its component controls.
+        */
+        //void SizeChanged();
+    
+    public: // New functions
+ 
+    protected: // Functions from base classes
+	 	/**
+	    * From CCoeControl,Draw.
+	    */
+    	void Draw(const TRect& aRect) const;
+    
+    private: //data
+	
+		CTrkAppView* iTrkAppView;
+};
+
+#endif  //__TRKAPPCONTAINER_H__
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkAppUi.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <avkon.hrh>
+#include <eikmenub.h>
+#include <akntitle.h>
+#include <barsread.h>
+#include <avkon.rsg>
+#include <trkapp_200170bb.rsg>
+
+#include "TrkApp.hrh"
+#include "TrkSettingsData.h"
+#include "TrkUids.h"
+#include "TrkSettingsView.h"
+
+#include "TrkAppUi.h"
+
+_LIT(KErrorNotification,"Error in connecting to TRK server . Please restart the phone and try.");
+//
+// CTrkAppUi::ConstructL
+//
+void CTrkAppUi::ConstructL()
+{
+    BaseConstructL(EAknEnableSkin);
+	
+    TInt err = iTrkSession.ConnectToServer();
+    if(err)
+    {
+        CAknGlobalNote* errNote = CAknGlobalNote::NewL();
+        CleanupStack::PushL( errNote );
+        TInt noteid = errNote->ShowNoteL(EAknGlobalErrorNote, KErrorNotification);
+        CleanupStack::PopAndDestroy();  
+        User::Leave(err);
+    }
+   	iSettingsData = CTrkSettingsData::NewL(iTrkSession); 
+
+	iAppView = CTrkAppView::NewL(iSettingsData, iTrkSession);
+	AddViewL(iAppView);
+
+	iSettingsView = CTrkSettingsView::NewL(iSettingsData);
+	AddViewL(iSettingsView);
+
+	//set the main app view as the default view
+	SetDefaultViewL(*iAppView);
+}
+
+//
+// CTrkAppUi Desctructor
+//
+CTrkAppUi::~CTrkAppUi()
+{	
+	if (iSettingsData)
+	{
+		delete iSettingsData;
+		iSettingsData = NULL;
+	}
+
+	iSettingsView = NULL;
+	iAppView = NULL;
+}
+
+//
+// CTrkAppUi::HandleCommandL
+//
+void CTrkAppUi::HandleCommandL(TInt aCommand)
+{
+	switch (aCommand)
+	{
+		case EEikCmdExit:
+		case EAknSoftkeyExit:
+		{
+			//if (!iEngine->IsDebugging())
+			{
+            	Exit();
+	        }
+			break;
+		}
+	}
+}
+
+//
+// CTrkAppUi::HandleResourceChangeL
+//
+void CTrkAppUi::HandleResourceChangeL( TInt aType )
+{
+	CAknViewAppUi::HandleResourceChangeL(aType);
+	
+	if (aType == KEikDynamicLayoutVariantSwitch ||
+		aType == KEikMessageUnfadeWindows ||
+		aType == KEikMessageWindowsFadeChange ) 
+	{
+		iAppView->HandleSizeChange();
+		iSettingsView->HandleSizeChange();
+		
+	  	CEikStatusPane* pane = StatusPane();
+    	if (pane)
+        {
+        	pane->HandleResourceChange(aType);
+        }
+	}
+}
+
+// ----------------------------------------------------
+// CCcorAppUi::SetTitleL
+// Set title pane text from a resource.
+// ----------------------------------------------------
+//
+void CTrkAppUi::SetTitleL(TInt aResourceId)
+{
+    // Set title
+    CAknTitlePane* title = static_cast<CAknTitlePane*>(StatusPane()->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
+    TResourceReader reader;
+    iCoeEnv->CreateResourceReaderLC(reader, aResourceId);
+    title->SetFromResourceL(reader);
+    CleanupStack::PopAndDestroy();  // resource reader
+}
+
+
+// ----------------------------------------------------
+// CTrkAppUi::SetTitleL
+// Set title pane text from a descriptor.
+// ----------------------------------------------------
+//
+void CTrkAppUi::SetTitleL(const TDesC& aText)
+{
+    CAknTitlePane* title = static_cast<CAknTitlePane*>(StatusPane()->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
+    title->SetTextL(aText);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkAppUi.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <eikappui.h>
+#include <aknViewAppUi.h>
+#include <AknGlobalNote.h>
+
+#include "trksrvclisession.h"
+#include "TrkAppView.h"
+
+class CTrkSettingsView;
+class CTrkSettingsData;
+
+//
+//
+// CTrkAppUi
+//
+//
+class CTrkAppUi : public CAknViewAppUi
+{
+public:
+
+    void ConstructL();
+	~CTrkAppUi();
+
+public: // New functions
+    void SetTitleL(TInt aResourceId);
+    void SetTitleL(const TDesC& aText);
+
+private:
+
+    void HandleCommandL(TInt aCommand);
+
+   /**
+    * From CEikAppUi
+    * Handle skin change event.
+    */
+    void HandleResourceChangeL( TInt aType );
+	    
+private:
+	CTrkSettingsData* iSettingsData;
+	CTrkAppView* iAppView;
+	CTrkSettingsView* iSettingsView;
+    RTrkSrvCliSession iTrkSession;
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkAppView.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,439 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <coecntrl.h>
+#include <eikenv.h>
+#include <eikmenup.h>
+#include <akntitle.h>
+#include <AknUtils.h>
+#include <aknmessagequerydialog.h>
+#include <AknGlobalNote.h>
+
+#include <avkon.rsg>
+#include <trkapp_200170bb.rsg>
+
+#include "trkservereventlistener.h"
+#include "trkdebugstatelistener.h"
+#include "trkconnstatelistener.h"
+#include "TrkUids.h"
+#include "TrkSettingsData.h"
+#include "TrkAppContainer.h"
+#include "TrkAppUi.h"
+#include "TrkAppView.h"
+#include "TrkApp.hrh"
+
+#ifdef __OEM_TRK__
+_LIT(KAboutText, "System TRK \nVersion %d.%d.%d \nTRK API Version %d.%d\nCopyright (c) 2006-2008, Nokia\n All rights reserved");
+#else
+_LIT(KAboutText, "Application TRK \nVersion %d.%d.%d \nTRK API Version %d.%d\nCopyright (c) 2006-2008, Nokia\n All rights reserved");
+#endif
+
+#define DISABLE_CRASH_LOGGER
+#define KMaxCmdLineLength 20
+
+// ---------------------------------------------------------
+// CTrkAppView::CTrkAppView
+// Constructor
+// ---------------------------------------------------------
+//
+CTrkAppView::CTrkAppView(CTrkSettingsData* aSettingsData, RTrkSrvCliSession& aTrkSession)
+	: //iVwsSession(NULL),
+	  iSettingsData(aSettingsData),
+	  iContainer(NULL),
+	  iTrkSession(aTrkSession),
+	  iConnStatus(ETrkNotConnected),
+	  iConnMsg(KNullDesC),
+	  iDebugging(EFalse),
+	  iTrkDebugStateListener(NULL),
+	  iTrkConnStateListener(NULL)
+{
+}
+
+// ---------------------------------------------------------
+// CTrkAppView::NewL
+// 
+// ---------------------------------------------------------
+//
+CTrkAppView* CTrkAppView::NewL(CTrkSettingsData* aSettingsData, RTrkSrvCliSession& aTrkSession)
+{
+	CTrkAppView* self = new(ELeave) CTrkAppView(aSettingsData, aTrkSession);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+}
+// ---------------------------------------------------------
+// CTrkAppView::~CTrkAppView
+// Desctructor
+// ---------------------------------------------------------
+//
+CTrkAppView::~CTrkAppView()
+{
+	//if (iVwsSession)
+	//{
+	//	iVwsSession->EnableServerEventTimeOut(ETrue);
+	//	delete iVwsSession;
+	//}
+	
+    if (iContainer)
+    {
+	    AppUi()->RemoveFromStack(iContainer);
+	    delete iContainer;
+	    iContainer = NULL;
+    }
+
+    if (iTrkDebugStateListener)
+    {
+        delete iTrkDebugStateListener;
+        iTrkDebugStateListener = NULL;
+    }
+    if (iTrkConnStateListener)
+    {
+        delete iTrkConnStateListener;
+        iTrkConnStateListener = NULL;
+    }
+}
+
+// ---------------------------------------------------------
+// CTrkAppView::ConstructL
+// 
+// ---------------------------------------------------------
+//
+
+void CTrkAppView::ConstructL()
+{
+    BaseConstructL(R_TRKAPP_VIEW);
+
+	RProcess().SetPriority(EPriorityHigh);
+	RThread().SetPriority(EPriorityAbsoluteHigh);
+
+#ifdef DISABLE_CRASH_LOGGER	
+	//Close the Mobile Crash Logger.
+	//CloseCrashLogger();
+#endif
+	
+    iTrkSession.GetTrkVersion(iMajorVersion, iMinorVersion, iMajorAPIVersion, iMinorAPIVersion, iBuildNumber);    
+    iTrkSession.GetDebugConnStatus(iConnStatus, iConnMsg);
+    iTrkSession.GetDebuggingStatus(iDebugging);
+    
+    iTrkDebugStateListener = new CTrkDebugStateListener(iTrkSession, this);
+    iTrkDebugStateListener->ListenL();
+    
+    iTrkConnStateListener = new CTrkConnStateListener(iTrkSession, this);
+    iTrkConnStateListener->ListenL();
+	}
+	
+// ---------------------------------------------------------
+// CTrkAppView::GetCmdLineConnTypeL
+// Now this function wont be used
+// ---------------------------------------------------------
+//
+TTrkConnType CTrkAppView::GetCmdLineConnTypeL()
+{
+    TTrkConnType connType = ETrkConnInvalid;
+    
+	// Get command line argument
+    if (User::CommandLineLength() > 0)
+    {
+        TBuf<512> commandLineArguments;
+		User::CommandLine( commandLineArguments );
+
+		// Check command line argument
+	    if (0 == commandLineArguments.Compare(KCmdLineConnTypeUsb))
+	    {
+	        connType = ETrkUsbDbgTrc;
+	    }
+	    else if (0 == commandLineArguments.Compare(KCmdLineConnTypeXti))
+	    {
+            connType =  ETrkXti;
+        }
+    }
+    if (connType == ETrkConnInvalid)
+    	User::Leave(KErrNotFound);
+    
+    return connType;  
+}
+
+// ---------------------------------------------------------
+// TUid CTrkAppView::Id()
+// Return id of this view instance
+// ---------------------------------------------------------
+//
+TUid CTrkAppView::Id() const
+{
+    return KUidTrkAppView;
+}
+
+// ---------------------------------------------------------
+// CTrkAppView::HandleCommandL(TInt aCommand)
+// Command handler
+// ---------------------------------------------------------
+//
+void CTrkAppView::HandleCommandL(TInt aCommand)
+{
+  	switch (aCommand)
+	{
+  	    case EAknSoftkeyBack:
+  	    {
+            AppUi()->ActivateViewL(iPrevViewId);
+            break;
+  	    }
+		case ETrkConnect:
+		{
+            TInt err = iTrkSession.Connect();
+            if(!err)
+            {
+                iTrkSession.GetDebugConnStatus(iConnStatus, iConnMsg);
+			}
+			
+			// force redraw here
+			iContainer->DrawNow();
+			break;
+		}
+		case ETrkDisconnect:
+		{
+            iTrkSession.DisConnect();
+            iConnStatus = ETrkNotConnected;
+			iConnMsg = KNullDesC;
+			// force redraw here
+			iContainer->DrawNow();
+			break;
+		}		
+		case ETrkSettings:
+		{
+			AppUi()->ActivateLocalViewL(KUidTrkConnSettingsView);
+			break;
+		}
+		case ETrkAbout:
+		{
+    		// Show the dialog.
+    		TBuf<KMaxPath> versionInfo;
+    		versionInfo.Format(KAboutText, iMajorVersion, iMinorVersion, iBuildNumber, iMajorAPIVersion, iMinorAPIVersion);
+    		
+		    CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(versionInfo);
+		    dlg->PrepareLC(R_TRK_ABOUT_DIALOG);
+		    CAknPopupHeadingPane* hPane = dlg->QueryHeading();
+
+		    if (hPane)
+			{
+				hPane->SetTextL(_L("TRK for Symbian OS"));
+			}
+		    dlg->RunLD();
+
+    		break;
+		}
+		default:
+		{
+			AppUi()->HandleCommandL(aCommand);
+			break;
+		}
+	}
+}
+
+
+// ---------------------------------------------------------
+// CTrkAppView::DoActivateL(...)
+// Activation of this view instance.
+// ---------------------------------------------------------
+//
+void CTrkAppView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
+{
+    if (!iContainer)
+	{
+        iContainer = new (ELeave) CTrkAppContainer(this);
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL(ClientRect());
+	    AppUi()->AddToStackL(*this, iContainer);
+			    
+	    iContainer->MakeVisible(ETrue);
+	    iContainer->ActivateL();
+	} 
+}
+
+// ---------------------------------------------------------
+// CConnTestView::DoDeactivate()
+// Deactivation of this view instance. Controls are not 
+// deleted, so that old information in status and output
+// windows stays visible.
+// ---------------------------------------------------------
+//
+void CTrkAppView::DoDeactivate()
+{
+    if (iContainer)
+    {
+        AppUi()->RemoveFromStack(iContainer);
+	   	iContainer->MakeVisible(EFalse);
+	    delete iContainer;
+	    iContainer = NULL;    
+    }
+ }
+
+void CTrkAppView::ViewActivatedL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage)
+{
+    // save the previous view id
+    if ((KUidTrk != aPrevViewId.iAppUid) && (KUidTrkConnSettingsView != aPrevViewId.iViewUid))
+    {
+        iPrevViewId = aPrevViewId;
+    }
+    CAknView::ViewActivatedL(aPrevViewId, aCustomMessageId, aCustomMessage);
+}
+
+void CTrkAppView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+{
+	if (R_TRK_MAIN_MENU == aResourceId)
+	{
+		switch (iConnStatus)
+	    {
+		    case ETrkConnected:
+			{
+				aMenuPane->SetItemDimmed(ETrkConnect, ETrue);
+				//If there is an active debug session, don't allow the user to disconnect.
+		        aMenuPane->SetItemDimmed(ETrkDisconnect, iDebugging);
+		        aMenuPane->SetItemDimmed(EAknSoftkeyExit, EFalse);
+		        break;
+	        }
+		    case ETrkNotConnected:
+		    case ETrkConnectionError:
+			{
+				aMenuPane->SetItemDimmed(ETrkConnect, EFalse);
+		        aMenuPane->SetItemDimmed(ETrkDisconnect, ETrue);            
+		        aMenuPane->SetItemDimmed(EAknSoftkeyExit, EFalse);
+		        break;
+	        }
+		    case ETrkConnecting:
+	        {
+		        aMenuPane->SetItemDimmed(ETrkConnect, ETrue);
+				aMenuPane->SetItemDimmed(ETrkDisconnect, ETrue);			
+		        aMenuPane->SetItemDimmed(EAknSoftkeyExit, ETrue);
+		        break;
+	        }		    	        	        
+		}
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CTrkAppView::HandleSizeChange
+// Handle screen size change.
+// -----------------------------------------------------------------------------
+//
+void CTrkAppView::HandleSizeChange()
+{
+    if (iContainer)
+    {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        iContainer->SetRect(mainPaneRect);
+    }
+}
+
+/** 
+ * Handle status pane size change for this view (override)
+ */
+void CTrkAppView::HandleStatusPaneSizeChange()
+{
+	CAknView::HandleStatusPaneSizeChange();
+}
+
+
+// -----------------------------------------------------------------------------
+// CTrkAppView::GetConnectionMsg
+// -----------------------------------------------------------------------------
+//
+void CTrkAppView::GetConnectionMsg(TDes& aMessage)
+{
+	aMessage = iConnMsg;
+}
+
+void CTrkAppView::DebugStateChanged(TBool& aDebugging)
+{
+    iDebugging = aDebugging;
+}
+
+void CTrkAppView::ConnectionStateChanged(TTrkConnStatus& aConnStatus) 
+{
+    iConnStatus = aConnStatus;
+    
+    switch(iConnStatus)
+    {
+        case ETrkConnected:
+        case ETrkConnecting:
+        case ETrkConnectionError:
+        case ETrkNotConnected:
+             iTrkSession.GetDebugConnStatus(iConnStatus, iConnMsg);
+             break;
+                    
+        default: 
+            iConnMsg = KNullDesC;
+            break;
+	}
+
+    // force redraw here
+    iContainer->DrawDeferred();
+}
+
+// -----------------------------------------------------------------------------
+// CTrkAppView::CloseCrashLogger
+// -----------------------------------------------------------------------------
+//
+TInt CTrkAppView::CloseCrashLogger()
+{
+	TInt err = KErrNone;
+	
+	//The old mobile crash file name is "d_exc_mc.exe" and the new one is "mc_useragent.exe"	
+	//This is the string that needs to be passed to the RProcess::Open call to get a handle.
+	//The complete process name actually includes the UID info as well.
+	//Instead of hard coding the process name, its better to just 
+	//search for the process and find it that way.		
+	//_LIT16(KCrashLoggerName, "mc_useragent.exe[1020e519]0001");
+	_LIT16(KOldCrashLoggerName, "d_exc_mc*");
+	_LIT16(KCrashLoggerName, "mc_useragent*");
+	
+	err = TerminateProcess(KOldCrashLoggerName);
+	err = TerminateProcess(KCrashLoggerName);
+
+	return err;
+}
+
+// -----------------------------------------------------------------------------
+// CTrkAppView::TerminateProcess()
+// -----------------------------------------------------------------------------
+//
+TInt CTrkAppView::TerminateProcess(const TDesC& aProcessName)
+{
+	_LIT16(KCrashLoggerClMsg, "Closing crash logger");
+	
+	TFindProcess find(aProcessName);
+	TFullName name;	
+		
+	TInt err = find.Next(name);
+	if (KErrNone == err)
+	{	
+		RProcess process;
+		err = process.Open(find);
+	
+		if (KErrNone == err)
+		{
+			User::InfoPrint(KCrashLoggerClMsg);
+			process.Kill(KErrNone);
+		}
+	}
+	return err;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkAppView.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,131 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TRKAPPVIEW_H
+#define __TRKAPPVIEW_H
+
+#include <viewcli.h>
+#include <aknview.h>
+#include "TrkConnData.h"
+#include "trkservereventcallback.h"
+#include "trksrvclisession.h"
+
+//
+//
+// CTrkAppView
+//
+//
+class CTrkSettingsData;
+class CTrkAppContainer;
+class CTrkServerEventListener;
+
+class CTrkAppView : public CAknView, public MTrkServerEventCallback
+{
+public:
+
+	static CTrkAppView* NewL(CTrkSettingsData* aSettings, RTrkSrvCliSession& aTrkSession);
+	~CTrkAppView();
+    void ConstructL();
+    
+    /** 
+    * Handle screen size change.
+    * @since 2.8
+    */
+    void HandleSizeChange();
+    
+    TBool IsConnected() { return iConnStatus == ETrkConnected; }
+    TTrkConnStatus GetConnectionStatus(){ return iConnStatus; } 
+    
+    void GetConnectionMsg(TDes& aMessage);
+    
+public:
+    // From MTrkServerEventCallback
+    void DebugStateChanged(TBool& aDebugging);
+    void ConnectionStateChanged(TTrkConnStatus& aConnStatus); 
+    
+private:
+
+    /**
+    * From CAknView
+    */
+    TUid Id() const;
+    
+    /**
+    * From CAknView
+    */
+    void HandleCommandL(TInt aCommand);
+    
+    /**
+    * From CAknView
+    */
+    void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+        const TDesC8& aCustomMessage);
+    
+    /**
+    * From CAknView
+    */
+    void DoDeactivate();
+   
+    /**
+     * From MCoeView
+     */
+    void ViewActivatedL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage);
+   
+    /**
+    * Adjusts the visible items in menu pane accordding to
+    * socket engine state.
+    * @aResourceId Resource ID identifying the menu pane to initialise
+    * @aMenuPane The in-memory representation of the menu pane
+    */
+    void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+
+	void HandleStatusPaneSizeChange();
+
+
+private:
+	CTrkAppView(CTrkSettingsData* aSettings, RTrkSrvCliSession& aTrkSession);
+
+    TInt CloseCrashLogger();
+	TInt TerminateProcess(const TDesC& aProcessName);
+	
+	TTrkConnType GetCmdLineConnTypeL();
+
+private:
+
+    CTrkSettingsData* iSettingsData;
+    CTrkAppContainer* iContainer;
+	//CVwsSessionWrapper* iVwsSession;
+    RTrkSrvCliSession& iTrkSession;
+    TVwsViewId iPrevViewId;
+			
+	TInt iMajorVersion;
+	TInt iMinorVersion;
+	TInt iMajorAPIVersion;
+	TInt iMinorAPIVersion;
+	TInt iBuildNumber;
+    TTrkConnStatus iConnStatus;
+	
+	TBuf<KMaxPath> iConnMsg;
+	
+	TBool iDebugging;
+	
+	CTrkServerEventListener* iTrkDebugStateListener;
+	CTrkServerEventListener* iTrkConnStateListener;
+};
+
+#endif //__TRKAPPVIEW_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkApp_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,121 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+macro 		__OEM_TRK__
+macro 		__S60__
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+
+TARGET		  trkapp_200170bb.exe
+TARGETTYPE    exe
+epocstacksize 0x12000
+
+UID           0x100039CE 0x200170BB
+VENDORID      VID_DEFAULT
+CAPABILITY 	  ALL -TCB -DRM
+
+
+SOURCEPATH    .
+SOURCE        TrkApplication.cpp TrkDocument.cpp TrkAppUi.cpp TrkApp.cpp
+SOURCE		  TrkAppView.cpp TrkAppContainer.cpp TrkSettingsView.cpp TrkSettingsContainer.cpp 
+SOURCE	 	  TrkSettingsList.cpp TrkSettingsData.cpp
+
+SOURCEPATH    ../common
+SOURCE 		  trkdebugstatelistener.cpp trkconnstatelistener.cpp
+
+SOURCEPATH    ../../trksrvclient
+SOURCE 		   trksrvclisession.cpp trksrvclientutils.cpp trksrvclientdefs.cpp
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+  	SYSTEMINCLUDE	\epoc32\include
+  	USERINCLUDE   ..\..\engine
+	USERINCLUDE   ..\..\trkserver
+	USERINCLUDE   ..\..\trksrvclient
+	USERINCLUDE   ..\common
+#else
+    MW_LAYER_SYSTEMINCLUDE
+    USERINCLUDE   ../../engine
+	USERINCLUDE   ../../trkserver
+	USERINCLUDE   ../../trksrvclient  
+	USERINCLUDE   ../common  
+#endif
+
+LIBRARY       euser.lib apparc.lib cone.lib eikcore.lib eikctl.lib eikcoctl.lib viewcli.lib
+LIBRARY       gdi.lib
+LIBRARY	      avkon.lib aknnotify.lib
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+
+sourcepath	.\resources
+userinclude .
+START RESOURCE	trkapp_200170bb.rss
+HEADER
+targetpath	\resource\apps
+lang		sc
+end
+
+sourcepath	.\resources
+START RESOURCE	trkapp_200170bb_reg.rss
+TARGETPATH	\private\10003a3f\apps
+END
+
+sourcepath	.\resources
+start resource trkapp_200170bb_loc.rss
+targetpath \resource\apps
+lang sc
+end
+
+START BITMAP    trkapp_200170bb.mbm
+HEADER
+TARGETPATH      \resource\apps
+SOURCEPATH 		..\common\resources
+SOURCE          c8  TrkIcn24.bmp TrkIcn24m.bmp TrkIcn32.bmp TrkIcn32m.bmp TrkIcn48.bmp TrkIcn48m.bmp
+END
+
+#else
+
+sourcepath	./resources
+userinclude .
+START RESOURCE	trkapp_200170bb.rss
+HEADER
+targetpath	/resource/apps
+lang		sc
+end
+
+sourcepath	./resources
+START RESOURCE	trkapp_200170bb_reg.rss
+TARGETPATH	/private/10003a3f/apps
+END
+
+sourcepath	./resources
+start resource trkapp_200170bb_loc.rss
+targetpath /resource/apps
+lang sc
+end
+
+START BITMAP    trkapp_200170bb.mbm
+HEADER
+TARGETPATH      /resource/apps
+SOURCEPATH 		../common/resources
+SOURCE          c8  TrkIcn24.bmp TrkIcn24m.bmp TrkIcn32.bmp TrkIcn32m.bmp TrkIcn48.bmp TrkIcn48m.bmp
+END
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkApplication.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "TrkUids.h"
+#include "TrkDocument.h"
+#include "TrkApplication.h"
+
+TUid CTrkApplication::AppDllUid() const
+{
+	return KUidTrk;
+}
+
+CApaDocument* CTrkApplication::CreateDocumentL()
+{
+	return new (ELeave) CTrkDocument(*this);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkApplication.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TRKAPPLICATION_H
+#define __TRKAPPLICATION_H
+
+#include <aknapp.h>
+
+//
+// CTrkApplication
+//
+class CTrkApplication : public CAknApplication
+{
+private: 
+
+	CApaDocument* CreateDocumentL();
+	TUid AppDllUid() const;
+};
+
+#endif //__TRKAPPLICATION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkConsole_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+TARGET			TrkConsole.exe
+TARGETTYPE		exe
+
+UID			0x1000008C 0x200159E2
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+SOURCEPATH 	  ..\console
+#else
+SOURCEPATH 	  ../console
+#endif
+SOURCE			TrkConsole.cpp
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+SOURCEPATH    ..\..\trksrvclient
+#else
+SOURCEPATH    ../../trksrvclient
+#endif
+SOURCE 		    trksrvclisession.cpp trksrvclientutils.cpp trksrvclientdefs.cpp
+
+LIBRARY			euser.lib
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+  	SYSTEMINCLUDE	\epoc32\include
+  	USERINCLUDE   ..\..\engine
+  	USERINCLUDE   ..\..\trksrvclient  
+  	USERINCLUDE    ..\..\trkserver
+#else
+    MW_LAYER_SYSTEMINCLUDE
+    USERINCLUDE   ../../engine
+	USERINCLUDE   ../../trksrvclient  
+	USERINCLUDE    ../../trkserver
+#endif
+
+VENDORID VID_DEFAULT
+CAPABILITY All -TCB -DRM
+EPOCSTACKSIZE 0x12000
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkDocument.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "TrkAppUi.h"
+#include "TrkDocument.h"
+
+CTrkDocument::CTrkDocument(CEikApplication& aApp)
+		: CAknDocument(aApp)
+{
+}
+
+CEikAppUi* CTrkDocument::CreateAppUiL()
+{
+    return new(ELeave) CTrkAppUi;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkDocument.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKDOCUMENT_H
+#define __TRKDOCUMENT_H
+
+// INCLUDES
+#include <AknDoc.h>
+
+// FORWARD DECLARATIONS
+class CEikApplication;
+
+//
+//
+// CTrkDocument
+//
+//
+class CTrkDocument : public CAknDocument
+{
+public:
+
+	static CTrkDocument* NewL(CEikApplication& aApp);
+	CTrkDocument(CEikApplication& aApp);
+	void ConstructL();
+
+private: 
+
+	CEikAppUi* CreateAppUiL();
+
+private:
+};
+
+#endif //__TRKDOCUMENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkSettingsContainer.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,155 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// INCLUDE FILES
+#include <AknGlobalNote.h>
+#include <trkapp_200170bb.rsg>
+
+#include "TrkAppUi.h"
+#include "TrkSettingsData.h"
+#include "TrkSettingsList.h"
+#include "TrkSettingsContainer.h"
+
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsContainer::CTrkSettingsContainer
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CTrkSettingsContainer::CTrkSettingsContainer(CTrkSettingsData* aSettingsData)
+: iSettingsData(aSettingsData)
+{
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsContainer::ConstructL
+// Symbian OS 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CTrkSettingsContainer::ConstructL(const TRect& aRect)
+{
+	SetRect(aRect);
+
+    iSettingsList = new ( ELeave ) CTrkConnSettingsList(iSettingsData);
+    iSettingsList->SetContainerWindowL(*this);
+    iSettingsList->ConstructFromResourceL(R_TRK_CONNECTION_SETTINGS_LIST);
+    iSettingsList->SetRect(aRect);
+    iSettingsList->ControlStateChangedAfterL(0);
+}
+
+
+// Destructor
+CTrkSettingsContainer::~CTrkSettingsContainer()
+{
+    delete iSettingsList;
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsContainer::CountComponentControls
+// From CCoeControl return the number of controls owned
+// ---------------------------------------------------------------------------
+//
+TInt CTrkSettingsContainer::CountComponentControls() const
+{
+    return 1;
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsContainer::ComponentControl
+// From CCoeControl returns a control
+// ---------------------------------------------------------------------------
+//
+CCoeControl* CTrkSettingsContainer::ComponentControl(TInt /* aIndex */ ) const
+{
+    return iSettingsList;
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsContainer::EditCurrentL
+// Open setting page for currently selected setting item.
+// ---------------------------------------------------------------------------
+//
+void CTrkSettingsContainer::EditCurrentL()
+{
+    TInt index = iSettingsList->ListBox()->CurrentItemIndex();
+
+    iSettingsList->EditItemL(index, ETrue);
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsContainer::SaveSettingsL
+// Save all settings.
+// ---------------------------------------------------------------------------
+//
+void CTrkSettingsContainer::SaveSettingsL()
+{
+    TRAPD(err, iSettingsList->StoreSettingsL());
+    if (!err)
+    {
+    	err = iSettingsData->SaveSettings();
+    }
+    
+    if (err!= KErrNone)
+    {
+		_LIT(KUnableToSave, "Unable to save the specified settings");
+		CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
+		globalNote->ShowNoteL(EAknGlobalErrorNote, KUnableToSave);
+		CleanupStack::PopAndDestroy(globalNote);
+    }
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsContainer::OfferKeyEventL
+// Key event handling
+// ---------------------------------------------------------------------------
+//
+TKeyResponse CTrkSettingsContainer::OfferKeyEventL(
+    const TKeyEvent& aKeyEvent,
+    TEventCode aType )
+{
+    if ( aKeyEvent.iCode == EKeyLeftArrow ||
+         aKeyEvent.iCode == EKeyRightArrow )
+	{
+        // Listbox takes all events even if it doesn't use them
+        return EKeyWasNotConsumed; 
+	}
+
+    return iSettingsList->OfferKeyEventL( aKeyEvent, aType );
+}
+    
+// ---------------------------------------------------------------------------
+// CTrkSettingsContainer::SizeChanged
+// Set the size and position of component controls.
+// ---------------------------------------------------------------------------
+//
+void CTrkSettingsContainer::SizeChanged()
+{
+    if (iSettingsList)
+	{
+        iSettingsList->SetRect(Rect());
+
+	}
+}
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkSettingsContainer.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef TRKSETTINGSCONTAINER_H
+#define TRKSETTINGSCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+
+class CTrkSettingsData;
+class CTrkConnSettingsList;
+
+
+class CTrkSettingsContainer : public CCoeControl
+{
+    public: // Constructors and destructor
+        /**
+        * C++ constructor.
+        */
+        CTrkSettingsContainer(CTrkSettingsData* aSettingsData);
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL(const TRect& aRect);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CTrkSettingsContainer();
+
+    public: // Functions from base classes
+        /**
+        * From CCoeControl set the size and position of its component controls.
+        */
+        void SizeChanged();
+    
+    public: // New functions
+        /**
+        * Open setting page for currently selected setting item.
+        */
+        void EditCurrentL();
+
+        /**
+        * Save all settings.
+        */
+        void SaveSettingsL();
+
+    protected: // Functions from base classes
+
+        /**
+        * From CCoeControl return the number of controls owned
+        * @return TInt number of controls
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl returns a control
+        * @param aIndex index of a control
+        * @return CCoeControl* pointer on a control
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl event handling section
+        * @param aKeyEvent the key event
+        * @param aType the type of the event
+        * @return TKeyResponse key event was used by this control or not
+        */
+        TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
+                                     TEventCode aType );
+
+
+    private: //data
+        CTrkConnSettingsList* iSettingsList;
+        CTrkSettingsData* iSettingsData;
+};
+
+#endif  //TRKSETTINGSCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkSettingsData.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,210 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "TrkSettingsData.h"
+
+// ================= MEMBER FUNCTIONS =========================================
+
+// ----------------------------------------------------------------------------
+// CTrkSettingsData::NewL
+// Two-phase constructor
+// ----------------------------------------------------------------------------
+//
+CTrkSettingsData* CTrkSettingsData::NewL(RTrkSrvCliSession& aTrkSession)
+{
+    CTrkSettingsData* data = new(ELeave) CTrkSettingsData(aTrkSession);
+    CleanupStack::PushL(data);
+    data->ConstructL();
+    CleanupStack::Pop(); // data
+    return data;
+}
+
+// Destructor
+//
+CTrkSettingsData::~CTrkSettingsData()
+{
+}
+
+// Constructor
+//
+CTrkSettingsData::CTrkSettingsData(RTrkSrvCliSession& aTrkSession)
+:iTrkSession(aTrkSession)
+{
+    iConnTypeIndex = 1;
+
+	iPortNumber = KDefaultUsbPortNumber;
+	iBaudRateIndex = 8;
+}
+
+// Epoc default constructor
+//
+void CTrkSettingsData::ConstructL()
+{
+    iTrkSession.GetCurrentConnData(iTrkConnData);
+	iConnTypeIndex = iTrkConnData.iConnType;
+
+#ifdef __OEM_TRK__
+	if (iConnTypeIndex>ETrkDcc)
+#else
+	if (iConnTypeIndex>ETrkBt)
+#endif
+	{
+		iTrkConnData.iConnType = ETrkBt;
+		iConnTypeIndex = ETrkBt;
+	}
+	iPlugAndPlay = iTrkConnData.iPlugPlay;
+	iPortNumber = iTrkConnData.iPortNumber;
+	iBaudRateIndex = GetIndexForBaudRate(iTrkConnData.iRate);
+	
+	if(iPlugAndPlay == 1)
+	  iPlugAndPlayType = 0;
+	else
+	  iPlugAndPlayType = 1;
+	
+}
+
+TInt CTrkSettingsData::SaveSettings()
+{
+	iTrkConnData.iConnType = (TTrkConnType)iConnTypeIndex;
+	iTrkConnData.iRate = GetBaudRateForIndex(iBaudRateIndex);
+	iTrkConnData.iPortNumber = iPortNumber;
+	
+	if(iPlugAndPlayType == 1)
+	    iPlugAndPlay = 0;
+	else
+	    iPlugAndPlay = 1;
+	
+	
+	switch (iTrkConnData.iConnType)
+	{
+		case ETrkUsbDbgTrc:
+		{
+			iTrkConnData.iCommType = EDbgTrcComm;
+			iTrkConnData.iPDD.Copy(KDefaultUsbPDD);
+			iTrkConnData.iLDD.Copy(KDefaultUsbLDD);
+			iTrkConnData.iCSY.Copy(KDefaultUsbCSY);
+			iTrkConnData.iPlugPlay = iPlugAndPlay;
+			break;
+		}
+		case ETrkBt:
+		{
+			iTrkConnData.iCommType = EBtSocket;
+			iTrkConnData.iPDD = KNullDesC;
+			iTrkConnData.iLDD = KNullDesC;
+			iTrkConnData.iCSY = KNullDesC;
+			iTrkConnData.iPlugPlay = iPlugAndPlay;
+			break;
+		}
+		case ETrkXti:
+		{
+			iTrkConnData.iCommType = EXti;
+			iTrkConnData.iPDD = KNullDesC;
+			iTrkConnData.iLDD.Copy(KTrkXTILDD);
+			iTrkConnData.iCSY = KNullDesC;
+			iTrkConnData.iPlugPlay = iPlugAndPlay;
+			break;
+		}
+		case ETrkDcc:
+		{
+			iTrkConnData.iCommType = EDcc;
+			iTrkConnData.iPDD = KNullDesC;
+			iTrkConnData.iLDD.Copy(KTrkDCCLDD);
+			iTrkConnData.iCSY = KNullDesC;
+			iTrkConnData.iPortNumber = 42;
+			iTrkConnData.iPlugPlay = iPlugAndPlay;
+			break;
+		}
+		case ETrkUsb:
+		{
+			iTrkConnData.iCommType = ESerialComm;
+			iTrkConnData.iPDD.Copy(KDefaultUsbPDD);
+			iTrkConnData.iLDD.Copy(KDefaultUsbLDD);
+			iTrkConnData.iCSY.Copy(KDefaultUsbCSY);
+			iTrkConnData.iPlugPlay = iPlugAndPlay;
+			break;
+		}
+		case ETrkIr:
+		{
+			iTrkConnData.iCommType = ESerialComm;
+			iTrkConnData.iPDD.Copy(KDefaultIrPDD);
+			iTrkConnData.iLDD.Copy(KDefaultIrLDD);
+			iTrkConnData.iCSY.Copy(KDefaultIrCSY);
+			iTrkConnData.iPlugPlay = iPlugAndPlay;
+			break;
+		}
+		default:
+		{
+			iTrkConnData.iCommType = ESerialComm;
+			break;
+		}
+	}
+	return iTrkSession.SetCurrentConnData(iTrkConnData);
+}
+
+TInt CTrkSettingsData::GetIndexForBaudRate(TUint aRate)
+{
+	switch (aRate)
+	{
+		case 300:     return 0;
+		case 1200:    return 1;
+		case 2400:    return 2;
+		case 4800:    return 3;
+		case 9600:    return 4;
+		case 19200:   return 5;
+		case 38400:   return 6;
+		case 57600:   return 7;
+		case 115200:  return 8;
+		case 234000:  return 9;
+		case 460800:  return 10;
+		case 576000:  return 11;
+		case 1152000: return 12;
+		case 4000000: return 13;
+		
+		default: return 8;
+		
+	}
+	
+}
+
+TUint CTrkSettingsData::GetBaudRateForIndex(TInt aIndex)
+{
+	switch (aIndex)
+	{
+		case 0:  return 300;
+		case 1:  return 1200;
+		case 2:  return 2400;
+		case 3:  return 4800;
+		case 4:  return 9600;
+		case 5:  return 19200;
+		case 6:  return 38400;
+		case 7:  return 57600;
+		case 8:  return 115200;
+		case 9:  return 234000;
+		case 10: return 460800;
+		case 11: return 576000;
+		case 12: return 1152000;
+		case 13: return 4000000;
+		
+		default: return 115200;
+		
+	}
+	
+}
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkSettingsData.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TrkSettingsData_h__
+#define __TrkSettingsData_h__
+
+// INCLUDES
+#include <e32base.h>
+
+#include "trksrvclisession.h"
+#include "TrkConnData.h"
+
+/**
+* CTrkSettingsData 
+*/
+class CTrkSettingsData : public CBase
+{
+    public:
+        static CTrkSettingsData* NewL(RTrkSrvCliSession& aTrkSession);
+        ~CTrkSettingsData();
+        TInt SaveSettings();
+
+    private:
+        CTrkSettingsData(RTrkSrvCliSession& aTrkSession);
+        void ConstructL();
+		TInt GetIndexForBaudRate(TUint aRate);
+		TUint GetBaudRateForIndex(TInt aIndex);
+    public:       	
+    	TInt 	  iConnTypeIndex;
+    	TInt      iPortNumber;
+    	TInt	  iBaudRateIndex;
+    	TInt      iPlugAndPlay;
+    	TInt      iPlugAndPlayType;
+    	
+    	TTrkConnData iTrkConnData;
+    
+    private:
+        RTrkSrvCliSession& iTrkSession;
+};
+
+
+#endif //__TrkSettingsData_h__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkSettingsList.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,179 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <AknGlobalNote.h>
+
+#include "TrkSettingsData.h"
+#include "TrkSettingsList.h"
+#include "TrkUids.h"
+#include "TrkApp.hrh"
+
+CTrkSettingsList::CTrkSettingsList(CTrkSettingsData* aSettingsData)	
+:iSettingsData(aSettingsData)
+{
+}
+
+TKeyResponse CTrkSettingsList::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
+{
+	if (aType != EEventKey) // Is not key event?
+	{
+		return EKeyWasNotConsumed;
+	}
+
+	switch (aKeyEvent.iCode) // The code of key event is...
+	{
+		default:
+			CAknSettingItemList::OfferKeyEventL(aKeyEvent, aType);
+			break;
+	}
+
+	return EKeyWasConsumed;
+}
+
+void CTrkSettingsList::SizeChanged()
+{
+	if (ListBox())
+		ListBox()->SetRect(Rect());
+}
+
+void CTrkSettingsList::ChangeSelectedItemL()
+{
+	if (ListBox())
+		EditItemL(ListBox()->CurrentItemIndex(), ETrue);
+}
+
+
+
+
+CTrkConnSettingsList::CTrkConnSettingsList(CTrkSettingsData* aSettingsData)
+:CTrkSettingsList(aSettingsData)
+{
+}
+
+CAknSettingItem* CTrkConnSettingsList::CreateSettingItemL(TInt aIdentifier)
+{
+	CAknSettingItem* item = NULL;
+	
+	switch (aIdentifier)
+	{
+		case ETrkConnectionType:
+		{
+			item = new (ELeave) CTrkConnIndexPopupSettingItem(aIdentifier, iSettingsData->iConnTypeIndex);
+			break;
+		}
+		case ETrkConnectionPort:
+		{
+			item = new (ELeave) CAknIntegerEdwinSettingItem(aIdentifier, iSettingsData->iPortNumber);			
+			break;
+		}
+		case ETrkConnectionBaudRate:
+		{		
+			item = new (ELeave) CTrkConnIndexPopupSettingItem(aIdentifier, iSettingsData->iBaudRateIndex);
+			break;
+		}
+		case ETrkPlugAndPlayOption:
+	    {
+            item = new (ELeave) CTrkConnIndexPopupSettingItem(aIdentifier, iSettingsData->iPlugAndPlayType);
+			break;
+		}
+	}
+	
+	return item;
+}
+
+void CTrkConnSettingsList::ControlStateChangedAfterL(TInt aIndex)
+{
+	CAknSettingItemArray* array = SettingItemArray();
+	
+	CTrkConnIndexPopupSettingItem* connTypePopUp = (CTrkConnIndexPopupSettingItem *)array->At(0);
+	TInt index = connTypePopUp->CurrentIndex();
+	
+	CAknSettingItem* portEditor = array->At(1);
+	CAknSettingItem* baudRatePopUp = array->At(2);
+
+	switch(aIndex)
+	{
+		case 0:
+		{
+			switch (index)
+			{
+				// Now port and baud rate are hidden for 
+				case 0: // USB (Dbg&Trc)
+				case 1: // BT
+				case 2: // XTI
+				case 3: // DCC
+				{
+					portEditor->SetHidden(ETrue);
+					baudRatePopUp->SetHidden(ETrue);
+					HandleChangeInItemArrayOrVisibilityL();				
+						break;			
+				}
+				default:
+					break;
+			}
+			break;
+		}
+		default:
+			break;
+	}
+}
+
+void CTrkConnSettingsList::ControlStateChangedBeforeL(TInt aIndex)
+{
+	CAknSettingItemArray* array = SettingItemArray();
+	
+	CTrkConnIndexPopupSettingItem* connTypePopUp = (CTrkConnIndexPopupSettingItem *)array->At(0);
+	TInt index = connTypePopUp->CurrentIndex();
+	
+	CAknSettingItem* portEditor = array->At(1);
+	CAknSettingItem* baudRatePopUp = array->At(2);
+
+	switch(aIndex)
+	{
+		case 1:
+		{
+			switch(index)
+			{
+				case 2:
+				{
+					_LIT(KPortNumberInfo, "Recommended port for IR connection is 0.");
+					CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
+					globalNote->ShowNoteL(EAknGlobalInformationNote, KPortNumberInfo);
+					CleanupStack::PopAndDestroy(globalNote);
+					break;	
+				}
+				default:
+					break;
+			}
+		}
+		default:
+			break;
+	}
+}
+
+void CTrkConnSettingsList::EditItemL(TInt aIndex, TBool aCalledFromMenu)
+{
+	CAknSettingItemList::EditItemL(aIndex, aCalledFromMenu);
+	ControlStateChangedAfterL(aIndex);
+}
+
+
+
+CTrkConnIndexPopupSettingItem::CTrkConnIndexPopupSettingItem(TInt aResourceId, TInt& aValue)
+	: CAknEnumeratedTextPopupSettingItem(aResourceId, aValue)
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkSettingsList.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkSettingsList_h__
+#define __TrkSettingsList_h__
+
+
+#include <aknsettingitemlist.h>
+
+class CTrkSettingsList : public CAknSettingItemList
+{
+public:
+	CTrkSettingsList(CTrkSettingsData* aSettingsData);
+
+	virtual CAknSettingItem* CreateSettingItemL(TInt aIdentifier) = 0;
+	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+	
+	void ChangeSelectedItemL(); 
+
+private:
+	void SizeChanged();
+	
+protected:
+	CTrkSettingsData* iSettingsData;
+
+};
+
+class CTrkConnSettingsList : public CTrkSettingsList
+{
+public:	
+	CTrkConnSettingsList(CTrkSettingsData* aSettingsData);
+	CAknSettingItem* CreateSettingItemL(TInt aIdentifier);
+	virtual void EditItemL(TInt aIndex, TBool aCalledFromMenu);
+	void ControlStateChangedAfterL(TInt aIndex);
+	void ControlStateChangedBeforeL(TInt aIndex);
+
+private:
+
+};
+
+class CTrkConnIndexPopupSettingItem : public CAknEnumeratedTextPopupSettingItem
+{
+public:
+	CTrkConnIndexPopupSettingItem(TInt aResourceId, TInt& aValue);
+	TInt CurrentIndex() { return InternalValue();};
+};
+
+
+#endif //__TrkSettingsList_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkSettingsView.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,198 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// INCLUDE FILES
+#include <AknUtils.h>
+#include "TrkAppUi.h"
+
+#include <trkapp_200170bb.rsg>
+
+#include "TrkApp.hrh"
+#include "TrkUids.h"
+#include "TrkSettingsContainer.h"
+#include "TrkSettingsData.h"
+#include "TrkSettingsView.h"
+
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsView::CTrkSettingsView
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CTrkSettingsView::CTrkSettingsView(CTrkSettingsData* aSettingsData)
+: iSettingsData(aSettingsData)
+{
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsView.::NewLC
+// Symbian OS two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CTrkSettingsView* CTrkSettingsView::NewL(CTrkSettingsData* aSettingsData)
+{
+    CTrkSettingsView* self = new (ELeave) CTrkSettingsView(aSettingsData);
+    self->ConstructL();
+
+    return self;
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsView::ConstructL
+// Symbian OS 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CTrkSettingsView::ConstructL()
+{
+    BaseConstructL(R_TRKSETTINGS_VIEW);
+}
+
+
+// Destructor
+CTrkSettingsView::~CTrkSettingsView()
+{
+    if (iContainer)
+	{
+        AppUi()->RemoveFromStack(iContainer);
+        delete iContainer;
+        iContainer = NULL;
+	}
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsView::Id
+// From CAknView, returns Uid of View
+// ---------------------------------------------------------------------------
+//
+TUid CTrkSettingsView::Id() const
+{
+    return KUidTrkConnSettingsView;
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsView::HandleCommandL
+// From MEikMenuObserver delegate commands from the menu
+// ---------------------------------------------------------------------------
+//
+void CTrkSettingsView::HandleCommandL(TInt aCommand)
+{
+    switch (aCommand)
+	{
+        case ETrkCmdChange:
+		{
+            iContainer->EditCurrentL();
+            break;
+		}
+        case EAknSoftkeyBack:
+		{
+			if (iContainer)
+			{
+				iContainer->SaveSettingsL();
+			}
+            AppUi()->ActivateLocalViewL(KUidTrkAppView);
+            break;
+		}
+
+        default:
+		{
+            AppUi()->HandleCommandL( aCommand );
+            break;
+		}
+ 	}
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsView::DoActivateL
+// Activate this view
+// ---------------------------------------------------------------------------
+//
+void CTrkSettingsView::DoActivateL( const TVwsViewId& /* aPrevViewId */,
+                                          TUid /*aCustomMessageId*/,
+                                          const TDesC8& /*aCustomMessage*/ )
+{
+
+    if (!iContainer)
+	{
+        iContainer = new (ELeave) CTrkSettingsContainer(iSettingsData);
+        iContainer->SetMopParent( this );
+        iContainer->ConstructL(ClientRect());
+        AppUi()->AddToStackL( *this, iContainer );
+        iContainer->ActivateL();
+	}
+	
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsView::DoDeactivate
+// Deactivate this view
+// ---------------------------------------------------------------------------
+//
+void CTrkSettingsView::DoDeactivate()
+{
+    if (iContainer)
+	{   
+        AppUi()->RemoveFromStack(iContainer);
+        delete iContainer;
+        iContainer = NULL;
+	}
+}
+
+
+// ---------------------------------------------------------------------------
+// CTrkSettingsView::DynInitMenuPaneL
+// Dynamically customize menu items
+// ---------------------------------------------------------------------------
+//
+void CTrkSettingsView::DynInitMenuPaneL( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/)
+{
+}
+
+
+
+// -----------------------------------------------------------------------------
+// CTrkSettingsView::HandleSizeChange
+// Handle screen size change.
+// -----------------------------------------------------------------------------
+//
+void CTrkSettingsView::HandleSizeChange()
+{
+    if (iContainer)
+	{
+		TRect mainPaneRect;
+     	AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+		iContainer->SetRect(mainPaneRect);
+    }
+}
+
+/** 
+ * Handle status pane size change for this view (override)
+ */
+void CTrkSettingsView::HandleStatusPaneSizeChange()
+{
+	CAknView::HandleStatusPaneSizeChange();
+}
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkSettingsView.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,110 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef TRKSETTINGSVIEW_H
+#define TRKSETTINGSVIEW_H
+
+// INCLUDES
+#include <aknview.h>
+   
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CTrkSettingsContainer;
+class CTrkSettingsData;
+
+// CLASS DECLARATION
+
+class CTrkSettingsView : public CAknView
+{
+    public: // Constructors and destructor
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CTrkSettingsView* NewL(CTrkSettingsData* aSettingsData);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CTrkSettingsView();
+
+        /** 
+        * Handle screen size change.
+        * @since 2.8
+        */
+        void HandleSizeChange();
+
+    private: // Functions from base classes
+        
+        /**
+        * From CAknView returns Uid of View
+        * @return TUid uid of the view
+        */
+        TUid Id() const;
+
+        /**
+        * From CAknView, handle commands
+        * @param aCommand command to be handled
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * From CAknView Activate this view
+        * @param aPrevViewId 
+        * @param aCustomMessageId 
+        * @param aCustomMessage 
+        */
+        void DoActivateL( const TVwsViewId& aPrevViewId,
+                          TUid aCustomMessageId,
+                          const TDesC8& aCustomMessage );
+
+        /**
+        * From CAknView Deactivate this view
+        */
+        void DoDeactivate();
+
+   
+        /**
+        * From MEikMenuObserver Dynamically customize menu items
+        * @param aResourceId Menu pane resource ID
+        * @param aMenuPane Menu pane pointer
+        */
+        void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+        
+        void HandleStatusPaneSizeChange();
+
+    private:
+        /**
+        * C++ constructor.
+        */
+        CTrkSettingsView(CTrkSettingsData* aSettingsData);
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+    private: // Data
+        CTrkSettingsContainer* iContainer;
+        CTrkSettingsData* iSettingsData;
+        TBool iViewActivated;
+};
+
+#endif //TRKSETTINGSVIEW_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/TrkUids.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkUids_h__
+#define __TrkUids_h__
+
+#include <e32uid.h>
+
+// application uid
+const TUid KUidTrk = { 0x200170BB };
+
+// main application view uid
+const TUid KUidTrkAppView = { 1 };
+
+// settings view uid
+const TUid KUidTrkConnSettingsView = { 2 };
+
+
+#endif // __TrkUids_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/resources/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/resources/isv_build/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/resources/isv_build/trkapp_200170bb.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,427 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+NAME TRKD
+
+#include <eikon.rh>
+#include <eikcore.rsg>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.hrh>
+
+#include <trkapp_200170bb.mbg>
+
+#include "TrkApp.hrh"
+#include "trkapp_200170bb_loc.rls"
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf="TRK"; }
+
+RESOURCE EIK_APP_INFO
+	{
+	hotkeys=r_trk_hotkeys;
+	menubar=r_trk_menubar;
+	cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+	}
+
+
+
+//
+//
+// Resources for the trk hot keys
+//
+//
+RESOURCE HOTKEYS r_trk_hotkeys
+    {
+    control=
+        {
+        HOTKEY 
+        	{ 
+        	command=EEikCmdExit; 
+        	key='e'; 
+        	}
+        };
+    }
+//----------------------------------------------------
+//   
+//    r_trkapp_view
+//    Conn settings view
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_trkapp_view
+    {
+    menubar = r_trk_menubar;
+
+    cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;    
+    }    
+
+//----------------------------------------------------
+//   
+//    r_trksettings_view
+//    Conn settings view
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_trksettings_view
+    {
+    menubar = r_settings_view_menubar;
+
+    cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;    
+    }   
+    
+//
+//
+// Resources for the trk menu bar.
+//
+//
+RESOURCE MENU_BAR r_trk_menubar
+    {
+    titles=
+        {
+        MENU_TITLE 
+        	{ 
+        	menu_pane=r_trk_main_menu; 
+        	txt=STRING_r_trk_menu; 
+        	}
+		};
+    }
+
+
+//
+//
+// Resources for the trk main menu bar.
+//
+//
+RESOURCE MENU_PANE r_trk_main_menu
+	{
+	items=
+		{		
+		MENU_ITEM 
+			{ 
+			command=ETrkConnect;
+			txt=STRING_r_trk_menu_connect;
+			},
+		MENU_ITEM 
+			{ 
+			command=ETrkDisconnect;
+			txt=STRING_r_trk_menu_disconnect;
+			},
+		MENU_ITEM 
+			{ 
+			command=ETrkSettings;
+			txt=STRING_r_trk_menu_settings;
+			},
+		MENU_ITEM 
+			{ 
+			command=ETrkAbout;
+			txt=STRING_r_trk_menu_about;
+			},
+		MENU_ITEM 
+			{ 
+			command=EAknSoftkeyExit;
+			txt=STRING_r_trk_menu_exit; 
+			}
+        };
+    }
+
+
+//
+//
+// Resources for the settings view menu bar.
+//
+//
+RESOURCE MENU_BAR r_settings_view_menubar
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_settings_view_menu;  txt=STRING_r_trk_menu; }
+		};
+    }
+
+//
+//
+// Resources for the settings view menu pane.
+//
+//
+RESOURCE MENU_PANE r_settings_view_menu
+	{
+	items=
+		{
+		MENU_ITEM
+			{
+			command=ETrkCmdChange;
+			txt=STRING_r_settings_view_menu_change;
+			}
+		};
+    }
+    
+ 
+//
+//
+// Resources for the trk connection settings list.
+//
+//
+RESOURCE AVKON_SETTING_ITEM_LIST r_trk_connection_settings_list
+	{
+	flags= EAknSettingItemIncludeHiddenInOrdinal;
+	title = STRING_r_trk_settings_dialog_title;
+	initial_number = 1;
+	items =
+		{
+		AVKON_SETTING_ITEM
+			{
+			identifier = ETrkConnectionType;
+			setting_page_resource = r_connectiontype_setting_page;
+			associated_resource = r_connectiontype_texts;
+			name = STRING_r_trk_settings_connection_type;
+			},
+		AVKON_SETTING_ITEM
+			{
+			identifier = ETrkConnectionPort;
+			setting_page_resource = r_port_setting_page;         
+			name = STRING_r_trk_settings_connection_port;
+			},
+		AVKON_SETTING_ITEM
+			{
+			identifier = ETrkConnectionBaudRate;
+			setting_page_resource = r_baudrate_setting_page;
+            associated_resource = r_baudrate_texts;
+			name = STRING_r_trk_settings_connection_baudrate;
+			}
+		};
+	}
+
+
+RESOURCE AVKON_SETTING_PAGE r_connectiontype_setting_page
+	{
+	number = EAknSettingPageNoOrdinalDisplayed;
+	label = STRING_r_trk_settings_connection_type;
+	softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL;	
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_connectiontype_popupsettings_editor;
+	}
+
+RESOURCE POPUP_SETTING_LIST r_connectiontype_popupsettings_editor
+    {
+    }
+
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_connectiontype_texts
+    {
+    flags = 0;
+    setting_texts_resource = r_connectiontypes_enum_text;
+    popped_up_texts_resource = r_connectiontypes_array;
+    }
+
+RESOURCE ARRAY r_connectiontypes_enum_text
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 0;
+            text = STRING_r_trk_settings_connection_usb_dbg_trc;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 1;
+            text = STRING_r_trk_settings_connection_bluetooth;
+            }
+        };
+    }
+
+RESOURCE ARRAY r_connectiontypes_array
+	{
+	items =
+		{
+		LBUF { txt=STRING_r_trk_settings_connection_usb_dbg_trc; },
+		LBUF { txt=STRING_r_trk_settings_connection_bluetooth; }
+		};
+	}  
+
+
+RESOURCE AVKON_SETTING_PAGE r_port_setting_page
+	{
+	number = EAknSettingPageNoOrdinalDisplayed;
+	label = STRING_r_trk_settings_connection_port;
+	softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL;
+	type = EAknCtIntegerEdwin;
+	editor_resource_id = r_port_editor;
+	}
+
+RESOURCE AVKON_INTEGER_EDWIN r_port_editor
+    {
+    maxlength = 2;
+    min = 0;
+    max = 100;
+    }
+	
+RESOURCE AVKON_SETTING_PAGE r_baudrate_setting_page
+	{
+	number = EAknSettingPageNoOrdinalDisplayed;
+	label = STRING_r_trk_settings_connection_baudrate;
+	softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL;	
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_baudrate_popupsettings_editor;
+	}
+
+RESOURCE POPUP_SETTING_LIST r_baudrate_popupsettings_editor
+    {
+    }
+
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_baudrate_texts
+    {
+    flags = 0;
+    setting_texts_resource = r_baudrates_enum_text;
+    popped_up_texts_resource = r_baudrates_array;
+    }
+
+RESOURCE ARRAY r_baudrates_enum_text
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 0;
+            text = STRING_r_trk_settings_connection_baud_300;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 1;
+            text = STRING_r_trk_settings_connection_baud_1200;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 2;
+            text = STRING_r_trk_settings_connection_baud_2400;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 3;
+            text = STRING_r_trk_settings_connection_baud_48600;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 4;
+            text = STRING_r_trk_settings_connection_baud_9600;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 5;
+            text = STRING_r_trk_settings_connection_baud_19200;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 6;
+            text = STRING_r_trk_settings_connection_baud_38400;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 7;
+            text = STRING_r_trk_settings_connection_baud_57600;
+            },
+    	AVKON_ENUMERATED_TEXT
+            {
+            value = 8;
+            text = STRING_r_trk_settings_connection_baud_115200;
+            },
+      	AVKON_ENUMERATED_TEXT
+            {
+            value = 9;
+            text = STRING_r_trk_settings_connection_baud_230400;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 10;
+            text = STRING_r_trk_settings_connection_baud_460800;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 11;
+            text = STRING_r_trk_settings_connection_baud_576000;
+            },
+    	AVKON_ENUMERATED_TEXT
+            {
+            value = 12;
+            text = STRING_r_trk_settings_connection_baud_1152000;
+            },
+      	AVKON_ENUMERATED_TEXT
+            {
+            value = 13;
+            text = STRING_r_trk_settings_connection_baud_4000000;
+            }
+        };
+    }
+
+RESOURCE ARRAY r_baudrates_array
+	{
+	items=
+		{
+		LBUF { txt=STRING_r_trk_settings_connection_baud_300; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_1200; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_2400; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_4800; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_9600; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_19200; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_38400; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_57600; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_115200; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_230400; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_460800; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_576000; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_1152000; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_4000000; }
+        };
+    }
+
+
+// *****************************************************************************
+// Trk AboutDialog
+// -----------------------------------------------------------------------------
+//
+//    r_trk_about_dialog
+//    About dialog.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_trk_about_dialog
+    {
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+        {
+        DLG_LINE
+			{
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+                {
+                };
+            }
+		};
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/resources/isv_build/trkapp_200170bb_loc.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <appinfo.rh>
+#include "trkapp_200170bb_loc.rls"
+
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = STRING_r_trk_short_caption;
+	caption_and_icon =
+		{
+			CAPTION_AND_ICON_INFO 
+			{
+				caption=STRING_r_trk_app_caption;
+        		
+        		number_of_icons = 1;
+				icon_file=STRING_r_trk_svg_icon_path;
+			}
+
+		};
+
+	}
+
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/resources/trkapp_200170bb.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,498 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+NAME TRKD
+
+#include <eikon.rh>
+#include <eikcore.rsg>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.hrh>
+
+#include <trkapp_200170bb.mbg>
+
+#include "TrkApp.hrh"
+#include "trkapp_200170bb_loc.rls"
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf="TRK"; }
+
+RESOURCE EIK_APP_INFO
+	{
+	hotkeys=r_trk_hotkeys;
+	menubar=r_trk_menubar;
+	cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+	}
+
+
+
+//
+//
+// Resources for the trk hot keys
+//
+//
+RESOURCE HOTKEYS r_trk_hotkeys
+    {
+    control=
+        {
+        HOTKEY 
+        	{ 
+        	command=EEikCmdExit; 
+        	key='e'; 
+        	}
+        };
+    }
+//----------------------------------------------------
+//   
+//    r_trkapp_view
+//    Conn settings view
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_trkapp_view
+    {
+    menubar = r_trk_menubar;
+
+    cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;    
+    }    
+
+//----------------------------------------------------
+//   
+//    r_trksettings_view
+//    Conn settings view
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_trksettings_view
+    {
+    menubar = r_settings_view_menubar;
+
+    cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;    
+    }   
+    
+//
+//
+// Resources for the trk menu bar.
+//
+//
+RESOURCE MENU_BAR r_trk_menubar
+    {
+    titles=
+        {
+        MENU_TITLE 
+        	{ 
+        	menu_pane=r_trk_main_menu; 
+        	txt=STRING_r_trk_menu; 
+        	}
+		};
+    }
+
+
+//
+//
+// Resources for the trk main menu bar.
+//
+//
+RESOURCE MENU_PANE r_trk_main_menu
+	{
+	items=
+		{		
+		MENU_ITEM 
+			{ 
+			command=ETrkConnect;
+			txt=STRING_r_trk_menu_connect;
+			},
+		MENU_ITEM 
+			{ 
+			command=ETrkDisconnect;
+			txt=STRING_r_trk_menu_disconnect;
+			},
+		MENU_ITEM 
+			{ 
+			command=ETrkSettings;
+			txt=STRING_r_trk_menu_settings;
+			},
+		MENU_ITEM 
+			{ 
+			command=ETrkAbout;
+			txt=STRING_r_trk_menu_about;
+			},
+		MENU_ITEM 
+			{ 
+			command=EAknSoftkeyExit;
+			txt=STRING_r_trk_menu_exit; 
+			}
+        };
+    }
+
+
+//
+//
+// Resources for the settings view menu bar.
+//
+//
+RESOURCE MENU_BAR r_settings_view_menubar
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_settings_view_menu;  txt=STRING_r_trk_menu; }
+		};
+    }
+
+//
+//
+// Resources for the settings view menu pane.
+//
+//
+RESOURCE MENU_PANE r_settings_view_menu
+	{
+	items=
+		{
+		MENU_ITEM
+			{
+			command=ETrkCmdChange;
+			txt=STRING_r_settings_view_menu_change;
+			}
+		};
+    }
+    
+ 
+//
+//
+// Resources for the trk connection settings list.
+//
+//
+RESOURCE AVKON_SETTING_ITEM_LIST r_trk_connection_settings_list
+	{
+	flags= EAknSettingItemIncludeHiddenInOrdinal;
+	title = STRING_r_trk_settings_dialog_title;
+	initial_number = 1;
+	items =
+		{
+		AVKON_SETTING_ITEM
+			{
+			identifier = ETrkConnectionType;
+			setting_page_resource = r_connectiontype_setting_page;
+			associated_resource = r_connectiontype_texts;
+			name = STRING_r_trk_settings_connection_type;
+			},
+		AVKON_SETTING_ITEM
+			{
+			identifier = ETrkConnectionPort;
+			setting_page_resource = r_port_setting_page;         
+			name = STRING_r_trk_settings_connection_port;
+			},
+		AVKON_SETTING_ITEM
+			{
+			identifier = ETrkConnectionBaudRate;
+			setting_page_resource = r_baudrate_setting_page;
+            associated_resource = r_baudrate_texts;
+			name = STRING_r_trk_settings_connection_baudrate;
+			},
+		AVKON_SETTING_ITEM
+		    {
+		    identifier = ETrkPlugAndPlayOption;
+		    setting_page_resource = r_plugandplay_options_page;
+		    associated_resource = r_plugandplay_texts;
+		    name = STRING_r_trk_settings_plugandplay_options;
+		    }
+			
+		};
+	}
+
+
+RESOURCE AVKON_SETTING_PAGE r_connectiontype_setting_page
+	{
+	number = EAknSettingPageNoOrdinalDisplayed;
+	label = STRING_r_trk_settings_connection_type;
+	softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL;	
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_connectiontype_popupsettings_editor;
+	}
+
+RESOURCE POPUP_SETTING_LIST r_connectiontype_popupsettings_editor
+    {
+    }
+
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_connectiontype_texts
+    {
+    flags = 0;
+    setting_texts_resource = r_connectiontypes_enum_text;
+    popped_up_texts_resource = r_connectiontypes_array;
+    }
+
+RESOURCE ARRAY r_connectiontypes_enum_text
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 0;
+            text = STRING_r_trk_settings_connection_usb_dbg_trc;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 1;
+            text = STRING_r_trk_settings_connection_bluetooth;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 2;
+            text = STRING_r_trk_settings_connection_xti ;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 3;
+            text = STRING_r_trk_settings_connection_dcc;
+            }    
+        };
+    }
+
+RESOURCE ARRAY r_connectiontypes_array
+	{
+	items =
+		{
+		LBUF { txt=STRING_r_trk_settings_connection_usb_dbg_trc; },
+		LBUF { txt=STRING_r_trk_settings_connection_bluetooth; },
+		LBUF { txt=STRING_r_trk_settings_connection_xti; },
+		LBUF { txt=STRING_r_trk_settings_connection_dcc; }
+		};
+	}  
+
+//Plug and play resource entries start
+
+RESOURCE AVKON_SETTING_PAGE r_plugandplay_options_page
+    {
+    number = EAknSettingPageNoOrdinalDisplayed;
+    label = STRING_r_trk_settings_plugandplay_options;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL;  
+    type = EAknCtPopupSettingList;
+    editor_resource_id = r_plugandplay_popupoptions_editor;
+    }
+
+RESOURCE POPUP_SETTING_LIST r_plugandplay_popupoptions_editor
+    {
+    }
+
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_plugandplay_texts
+    {
+    flags = 0;
+    setting_texts_resource = r_plugandplayoptions_enum_text;
+    popped_up_texts_resource = r_plugandplayoptions_array;
+    }
+
+RESOURCE ARRAY r_plugandplayoptions_enum_text
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 0;
+            text = STRING_r_trk_plugandplay_options_yes;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 1;
+            text = STRING_r_trk_plugandplay_options_no;
+            }
+       
+		};
+	}  
+
+RESOURCE ARRAY r_plugandplayoptions_array
+    {
+    items =
+        {
+        LBUF { txt=STRING_r_trk_plugandplay_options_yes; },
+        LBUF { txt=STRING_r_trk_plugandplay_options_no; }
+        };
+    }  
+
+//plug and play resource entries end
+
+
+RESOURCE AVKON_SETTING_PAGE r_port_setting_page
+	{
+	number = EAknSettingPageNoOrdinalDisplayed;
+	label = STRING_r_trk_settings_connection_port;
+	softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL;
+	type = EAknCtIntegerEdwin;
+	editor_resource_id = r_port_editor;
+	}
+
+RESOURCE AVKON_INTEGER_EDWIN r_port_editor
+    {
+    maxlength = 2;
+    min = 0;
+    max = 100;
+    }
+	
+RESOURCE AVKON_SETTING_PAGE r_baudrate_setting_page
+	{
+	number = EAknSettingPageNoOrdinalDisplayed;
+	label = STRING_r_trk_settings_connection_baudrate;
+	softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL;	
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_baudrate_popupsettings_editor;
+	}
+
+RESOURCE POPUP_SETTING_LIST r_baudrate_popupsettings_editor
+    {
+    }
+
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_baudrate_texts
+    {
+    flags = 0;
+    setting_texts_resource = r_baudrates_enum_text;
+    popped_up_texts_resource = r_baudrates_array;
+    }
+
+RESOURCE ARRAY r_baudrates_enum_text
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 0;
+            text = STRING_r_trk_settings_connection_baud_300;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 1;
+            text = STRING_r_trk_settings_connection_baud_1200;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 2;
+            text = STRING_r_trk_settings_connection_baud_2400;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 3;
+            text = STRING_r_trk_settings_connection_baud_48600;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 4;
+            text = STRING_r_trk_settings_connection_baud_9600;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 5;
+            text = STRING_r_trk_settings_connection_baud_19200;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 6;
+            text = STRING_r_trk_settings_connection_baud_38400;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 7;
+            text = STRING_r_trk_settings_connection_baud_57600;
+            },
+    	AVKON_ENUMERATED_TEXT
+            {
+            value = 8;
+            text = STRING_r_trk_settings_connection_baud_115200;
+            },
+      	AVKON_ENUMERATED_TEXT
+            {
+            value = 9;
+            text = STRING_r_trk_settings_connection_baud_230400;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 10;
+            text = STRING_r_trk_settings_connection_baud_460800;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = 11;
+            text = STRING_r_trk_settings_connection_baud_576000;
+            },
+    	AVKON_ENUMERATED_TEXT
+            {
+            value = 12;
+            text = STRING_r_trk_settings_connection_baud_1152000;
+            },
+      	AVKON_ENUMERATED_TEXT
+            {
+            value = 13;
+            text = STRING_r_trk_settings_connection_baud_4000000;
+            }
+        };
+    }
+
+RESOURCE ARRAY r_baudrates_array
+	{
+	items=
+		{
+		LBUF { txt=STRING_r_trk_settings_connection_baud_300; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_1200; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_2400; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_4800; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_9600; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_19200; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_38400; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_57600; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_115200; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_230400; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_460800; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_576000; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_1152000; },
+		LBUF { txt=STRING_r_trk_settings_connection_baud_4000000; }
+        };
+    }
+
+
+// *****************************************************************************
+// Trk AboutDialog
+// -----------------------------------------------------------------------------
+//
+//    r_trk_about_dialog
+//    About dialog.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_trk_about_dialog
+    {
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+        {
+        DLG_LINE
+			{
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+                {
+                };
+            }
+		};
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/resources/trkapp_200170bb_loc.rls	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+rls_string STRING_r_trk_short_caption "TRK"
+rls_string STRING_r_trk_app_caption "App TRK"
+rls_string STRING_r_trk_sys_caption "System TRK"
+
+rls_string STRING_r_trk_welcome "TRK for Symbian OS\n"
+rls_string STRING_r_trk_version "Version 2.8"
+
+rls_string STRING_r_trk_icon_path "Z:\\resource\\apps\\trkapp_200170bb.mbm"
+rls_string STRING_r_trk_svg_icon_path "Z:\\resource\\apps\\trkapp_200170bb.mif"
+
+rls_string STRING_r_trk_menu "Options"
+rls_string STRING_r_settings_view_menu_change "Change"
+
+rls_string STRING_r_trk_menu_connect "Connect"
+rls_string STRING_r_trk_menu_disconnect "Disconnect"
+rls_string STRING_r_trk_menu_settings "Settings"
+rls_string STRING_r_trk_menu_about "About"
+rls_string STRING_r_trk_menu_help "Help"
+rls_string STRING_r_trk_menu_exit "Exit"
+
+rls_string STRING_r_trk_settings_dialog_title "\tSettings"
+
+rls_string STRING_r_trk_settings_connection_type "Connection"
+rls_string STRING_r_trk_settings_connection_port "Port"
+rls_string STRING_r_trk_settings_connection_baudrate "Baud Rate"
+rls_string STRING_r_trk_settings_plugandplay_options "USB Plug and Play"
+
+
+rls_string STRING_r_trk_settings_connection_usb "USB" // no longer used, always use the one below
+rls_string STRING_r_trk_settings_connection_usb_dbg_trc "USB"
+rls_string STRING_r_trk_settings_connection_bluetooth "Bluetooth"
+rls_string STRING_r_trk_settings_connection_infrared "Infra Red"
+rls_string STRING_r_trk_settings_connection_dcc "DCC"
+rls_string STRING_r_trk_settings_connection_xti "XTI"
+
+rls_string STRING_r_trk_plugandplay_options_yes "On"
+rls_string STRING_r_trk_plugandplay_options_no "Off"
+
+
+
+
+rls_string STRING_r_trk_settings_connection_baud_300     "300"
+rls_string STRING_r_trk_settings_connection_baud_1200    "1200"
+rls_string STRING_r_trk_settings_connection_baud_2400    "2400"
+rls_string STRING_r_trk_settings_connection_baud_4800    "4800"
+rls_string STRING_r_trk_settings_connection_baud_9600    "9600"
+rls_string STRING_r_trk_settings_connection_baud_19200   "19200"
+rls_string STRING_r_trk_settings_connection_baud_38400   "38400"
+rls_string STRING_r_trk_settings_connection_baud_57600   "57600"
+rls_string STRING_r_trk_settings_connection_baud_115200  "115200"
+rls_string STRING_r_trk_settings_connection_baud_230400  "230400"
+rls_string STRING_r_trk_settings_connection_baud_460800  "460800"
+rls_string STRING_r_trk_settings_connection_baud_576000  "576000"
+rls_string STRING_r_trk_settings_connection_baud_1152000 "1152000"
+rls_string STRING_r_trk_settings_connection_baud_4000000 "4000000"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/resources/trkapp_200170bb_loc.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <appinfo.rh>
+#include "trkapp_200170bb_loc.rls"
+
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = STRING_r_trk_short_caption;
+	caption_and_icon =
+		{
+			CAPTION_AND_ICON_INFO 
+			{
+				caption=STRING_r_trk_sys_caption;
+        		
+        		number_of_icons = 1;
+				icon_file=STRING_r_trk_svg_icon_path;
+			}
+
+		};
+
+	}
+
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/resources/trkapp_200170bb_reg.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <appinfo.rh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x200170BB
+
+RESOURCE APP_REGISTRATION_INFO 
+	{
+	app_file="trkapp_200170bb";
+	//
+	localisable_resource_file="\\resource\\apps\\trkapp_200170bb_loc";
+	//
+	hidden=KAppNotHidden;
+	embeddability=KAppNotEmbeddable;
+	newfile=KAppDoesNotSupportNewFile;
+	group_name = "RnD Tools";
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/s60/trkconsole_tshell.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+TARGET			TrkConsole.exe
+TARGETTYPE		exe
+
+UID			0x1000008C 0x200159E2
+
+SOURCEPATH		.
+SOURCE			TrkConsole.cpp
+
+LIBRARY			euser.lib
+
+SYSTEMINCLUDE	/epoc32/include
+USERINCLUDE    ../engine
+
+VENDORID VID_DEFAULT
+
+CAPABILITY All -TCB -DRM
+
+EPOCSTACKSIZE 0x12000
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/resources/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/resources/trkapp_200170bb.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+NAME METR
+
+#include <eikon.rh>
+#include <eikcore.rsg>
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf=""; }
+
+RESOURCE EIK_APP_INFO
+	{
+	hotkeys=r_trk_hotkeys;
+	menubar=r_trk_menubar;
+	}
+
+
+
+RESOURCE HOTKEYS r_trk_hotkeys
+    {
+    control=
+        {
+        HOTKEY { command=EEikCmdExit; key='e'; }
+        };
+    }
+
+RESOURCE MENU_BAR r_trk_menubar
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_trk_first_menu; txt="Trk"; }
+		};
+    }
+
+RESOURCE MENU_PANE r_trk_first_menu
+	{
+	items=
+		{
+		MENU_ITEM { command=EEikCmdExit; txt="Close"; }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/resources/trkapp_200170bb_loc.rls	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+rls_string STRING_r_trk_short_caption "Trk"
+rls_string STRING_r_trk_caption "Nokia Trk"
+rls_string STRING_r_trk_icon_path "Z:\\resource\\apps\\trkapp_200170bb.mbm"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/resources/trkapp_200170bb_loc.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <appinfo.rh>
+#include "trkapp_200170bb_loc.rls"
+
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = STRING_r_trk_short_caption;
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO 
+			{
+			caption=STRING_r_trk_short_caption;
+			number_of_icons=3;
+			icon_file=STRING_r_trk_icon_path;
+			}
+		};
+
+	}
+
+ 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/resources/trkapp_200170bb_reg.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <appinfo.rh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x200170BB
+
+RESOURCE APP_REGISTRATION_INFO 
+	{
+	app_file="trkapp_200170bb";
+	//
+	localisable_resource_file="\\resource\\apps\\trkapp_200170bb_loc";
+	//
+	hidden=KAppNotHidden;
+	embeddability=KAppNotEmbeddable;
+	newfile=KAppDoesNotSupportNewFile;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/trkapp.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifdef __UI_FRAMEWORKS_V2__
+#include <eikstart.h>
+#endif
+
+#include "trkapplication.h"
+
+
+#ifdef __UI_FRAMEWORKS_V2__
+
+	LOCAL_C CApaApplication* NewApplication()
+		{
+		return new CTrkApplication;
+		}
+
+	GLDEF_C TInt E32Main()
+		{
+		return EikStart::RunApplication(NewApplication);
+		}
+
+	#if defined(__WINS__) && !defined(EKA2)
+	EXPORT_C TInt WinsMain(TDesC* aCmdLine)
+		{
+		return EikStart::RunApplication(NewApplication, aCmdLine);
+		}
+
+	GLDEF_C TInt E32Dll(TDllReason)
+		{
+		return KErrNone;
+		}
+	#endif //__WINS__ && !EKA2
+	
+#else //__UI_FRAMEWORKS_V2__
+
+	EXPORT_C CApaApplication* NewApplication()
+	{
+		return new CTrkApplication;
+	}
+
+	#ifndef EKA2
+	GLDEF_C TInt E32Dll(TDllReason)
+	{
+		return KErrNone;
+	}
+	#endif
+	
+#endif //__UI_FRAMEWORKS_V2__
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/trkapp_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+TARGET		  trkapp_200170bb.exe
+TARGETTYPE    exe
+epocstacksize 0x12000
+
+
+UID           0x100039CE 0x200170BB
+VENDORID      0x101FB657
+CAPABILITY 	  ALL -TCB -DRM
+
+SOURCEPATH    .
+SOURCE        trkapp.cpp trkapplication.cpp trkdocument.cpp trkappui.cpp trkappview.cpp
+
+SOURCEPATH    ..\common
+SOURCE 		  trkdebugstatelistener.cpp trkconnstatelistener.cpp
+
+SOURCEPATH    ..\..\trksrvclient
+SOURCE 		   trksrvclisession.cpp trksrvclientutils.cpp trksrvclientdefs.cpp
+
+SYSTEMINCLUDE \epoc32\include
+SYSTEMINCLUDE \epoc32\include\techview
+
+USERINCLUDE   ..\..\engine
+USERINCLUDE   ..\..\trkserver
+USERINCLUDE   ..\..\trksrvclient
+USERINCLUDE   ..\common
+
+LIBRARY       euser.lib apparc.lib cone.lib eikcore.lib viewcli.lib gdi.lib
+
+
+sourcepath	.\resources
+START RESOURCE	trkapp_200170bb.rss
+HEADER
+targetpath	\resource\apps
+lang		sc
+end
+
+sourcepath	.\resources
+START RESOURCE	trkapp_200170bb_reg.rss
+TARGETPATH	\private\10003a3f\apps
+END
+
+sourcepath	.\resources
+start resource trkapp_200170bb_loc.rss
+targetpath \resource\apps
+lang sc
+end
+
+START BITMAP    trkapp_200170bb.mbm
+HEADER
+TARGETPATH      \resource\apps
+SOURCEPATH 	..\common\resources
+SOURCE          c8  TrkIcn24.bmp TrkIcn24m.bmp TrkIcn32.bmp TrkIcn32m.bmp TrkIcn48.bmp TrkIcn48m.bmp
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/trkapplication.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "trkdocument.h"
+#include "trkapplication.h"
+
+const TUid KUidTrk = { 0x200170BB }; 
+
+TUid CTrkApplication::AppDllUid() const
+{
+	return KUidTrk;
+}
+
+CApaDocument* CTrkApplication::CreateDocumentL()
+{
+	return new (ELeave) CTrkDocument(*this);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/trkapplication.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TRKAPPLICATION_H
+#define __TRKAPPLICATION_H
+
+#include <eikapp.h>
+
+//
+//
+// CTrkApplication
+//
+//
+
+class CTrkApplication : public CEikApplication
+{
+private: 
+
+	CApaDocument* CreateDocumentL();
+	TUid AppDllUid() const;
+};
+
+#endif //__TRKAPPLICATION_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/trkappui.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "trkappui.h"
+
+void CTrkAppUi::ConstructL()
+{
+    BaseConstructL();
+    TInt err = iTrkSession.ConnectToServer();
+   	iAppView = CTrkAppView::NewL(ClientRect(), iTrkSession);
+}
+
+CTrkAppUi::~CTrkAppUi()
+{
+	delete iAppView;
+	iTrkSession.ShutDownServer();
+	iTrkSession.Close();
+}
+
+void CTrkAppUi::HandleCommandL(TInt aCommand)
+{
+	switch (aCommand)
+	{
+		case EEikCmdExit:
+		{
+			Exit();
+			break;
+		}
+	}
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/trkappui.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TRKAPPUI_H
+#define __TRKAPPUI_H
+
+#include <eikappui.h>
+#include "trksrvclisession.h"
+#include "trkappview.h"
+
+//
+//
+// CTrkAppUi
+//
+//
+class CTrkAppUi : public CEikAppUi
+{
+public:
+
+    void ConstructL();
+	~CTrkAppUi();
+
+private:
+
+	void HandleCommandL(TInt aCommand);
+
+private:
+
+	CTrkAppView* iAppView;
+	RTrkSrvCliSession iTrkSession;
+};
+
+#endif //__TRKAPPUI_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/trkappview.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <viewcli.h>
+#include "trkappview.h"
+#include "trkservereventlistener.h"
+#include "trkdebugstatelistener.h"
+#include "trkconnstatelistener.h"
+
+CTrkAppView::CTrkAppView(RTrkSrvCliSession& aTrkSession)
+	: iVwsSession(NULL),
+	  iTrkSession(aTrkSession),
+	  iMajorVersion(0),
+	  iMinorVersion(0),
+	  iMajorAPIVersion(0),
+	  iMinorAPIVersion(0),
+	  iError(KErrNone)
+{
+}
+
+CTrkAppView* CTrkAppView::NewL(const TRect& aRect,  RTrkSrvCliSession& aTrkSession)
+{
+	CTrkAppView* self = new(ELeave) CTrkAppView(aTrkSession);
+	CleanupStack::PushL(self);
+	self->ConstructL(aRect);
+	CleanupStack::Pop();
+	return self;
+}
+
+CTrkAppView::~CTrkAppView()
+{
+    // Disconnect here
+	iTrkSession.DisConnect();
+	
+	if (iVwsSession)
+	{
+		iVwsSession->EnableServerEventTimeOut(ETrue);
+		delete iVwsSession;
+	}
+}
+
+void CTrkAppView::ConstructL(const TRect& aRect)
+{
+	CreateWindowL();
+	SetRect(aRect);
+	ActivateL();
+	
+	iVwsSession = CVwsSessionWrapper::NewL();
+	
+    iTrkSession.GetTrkVersion(iMajorVersion, iMinorVersion, iMajorAPIVersion, iMinorAPIVersion, iBuildNumber); 
+    // Ideally we need to connect here, but when the TRK server is started, connect automatically happens.
+    // So we don't need to explicitly connect here. If the server is changed not to connect automatically at startup
+    // then we need to connect here.
+    //iTrkSession.Connect();
+}
+
+void CTrkAppView::Draw(const TRect& /*aRect*/) const
+{
+    TTrkConnStatus iConnStatus;
+	CWindowGc& gc = SystemGc();
+
+	TRect      drawRect = Rect();
+	
+	gc.Clear();
+
+	const CFont *font = iEikonEnv->AnnotationFont();
+	gc.UseFont(font);
+	
+	TBuf<KMaxPath> buf;
+
+	_LIT(KTrkWelcome,"Welcome to Trk for Symbian OS");
+	_LIT(KTrkVersion,"Version %d.%d.%d");
+	_LIT(KTrkAPIVersion,"Implementing Trk API version %d.%d");
+
+	TInt vert = 15;
+	
+	gc.DrawText(KTrkWelcome, drawRect, vert);
+	vert += font->HeightInPixels();
+	buf.Format(KTrkVersion, iMajorVersion, iMinorVersion, iBuildNumber);
+	gc.DrawText(buf, drawRect, vert);
+	vert += font->HeightInPixels();
+	buf.Format(KTrkAPIVersion, iMajorAPIVersion, iMinorAPIVersion);
+	gc.DrawText(buf, drawRect, vert);
+	vert += font->HeightInPixels()*2;
+
+	iTrkSession.GetDebugConnStatus(iConnStatus, buf);
+	
+	_LIT(KLfCr, "\r\n");
+	
+	TPtrC ptr(buf);
+	TInt pos = 0;
+	TInt lineStart = 0;
+	TInt length = 0;
+	
+	while (KErrNotFound != (pos = ptr.Find(KLfCr)))
+	{
+		ptr.Set(&buf[lineStart], pos);
+		lineStart = lineStart + pos + 2;
+		gc.DrawText(ptr, drawRect, vert);
+		vert += font->HeightInPixels();
+		length = buf.Length() - lineStart;
+		if (length > 0)
+		{
+			ptr.Set(&buf[lineStart], length);
+		}
+	}
+
+	gc.DiscardFont();
+
+	iVwsSession->EnableServerEventTimeOut(EFalse);	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/trkappview.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TRKAPPVIEW_H
+#define __TRKAPPVIEW_H
+
+#include <eikenv.h>
+#include <eikmenup.h>
+#include "trksrvclisession.h"
+
+//
+//
+// CTrkAppView
+//
+//
+class CTrkAppView : public CCoeControl
+{
+public:
+
+	static CTrkAppView* NewL(const TRect& aRect,  RTrkSrvCliSession& aTrkSession);
+	CTrkAppView(RTrkSrvCliSession& aTrkSession);
+	~CTrkAppView();
+    void ConstructL(const TRect& aRect);
+    
+private:
+
+	void Draw(const TRect& /*aRect*/) const;
+	
+
+private:
+
+	CVwsSessionWrapper* iVwsSession;
+	RTrkSrvCliSession& iTrkSession;
+	TInt iMajorVersion;
+	TInt iMinorVersion;
+	TInt iMajorAPIVersion;
+	TInt iMinorAPIVersion;
+	TInt iBuildNumber;
+	TInt iError;
+};
+
+#endif //__TRKAPPVIEW_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/trkdocument.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "trkappui.h"
+#include "trkdocument.h"
+
+CTrkDocument::CTrkDocument(CEikApplication& aApp)
+		: CEikDocument(aApp)
+{
+}
+
+CEikAppUi* CTrkDocument::CreateAppUiL()
+{
+    return new(ELeave) CTrkAppUi;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/app/tv/trkdocument.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TRKDOCUMENT_H
+#define __TRKDOCUMENT_H
+
+#include <eikdoc.h>
+
+//
+//
+// CTrkDocument
+//
+//
+class CTrkDocument : public CEikDocument
+{
+public:
+
+	static CTrkDocument* NewL(CEikApplication& aApp);
+	CTrkDocument(CEikApplication& aApp);
+	void ConstructL();
+
+private: 
+
+	CEikAppUi* CreateAppUiL();
+};
+
+#endif //__TRKDOCUMENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/bwinscw/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/bwinscw/dbgtrccomm_win.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,18 @@
+EXPORTS
+	??0RDbgTrcComm@@QAE@XZ @ 1 NONAME ; RDbgTrcComm::RDbgTrcComm(void)
+	?Close@RDbgTrcComm@@QAEHXZ @ 2 NONAME ; int RDbgTrcComm::Close(void)
+	?Connect@RDbgTrcComm@@QAEHXZ @ 3 NONAME ; int RDbgTrcComm::Connect(void)
+	?Disconnect@RDbgTrcComm@@QAEHXZ @ 4 NONAME ; int RDbgTrcComm::Disconnect(void)
+	?GetAcmConfig@RDbgTrcComm@@QAEHAAVTDes8@@@Z @ 5 NONAME ; int RDbgTrcComm::GetAcmConfig(class TDes8 &)
+	?Open@RDbgTrcComm@@QAEHXZ @ 6 NONAME ; int RDbgTrcComm::Open(void)
+	?ReadCancel@RDbgTrcComm@@QAEHXZ @ 7 NONAME ; int RDbgTrcComm::ReadCancel(void)
+	?ReadMessage@RDbgTrcComm@@QAEXAAVTRequestStatus@@AAVTDes8@@@Z @ 8 NONAME ; void RDbgTrcComm::ReadMessage(class TRequestStatus &, class TDes8 &)
+	?RegisterProtocolID@RDbgTrcComm@@QAEHW4TOstProtIds@@H@Z @ 9 NONAME ; int RDbgTrcComm::RegisterProtocolID(enum TOstProtIds, int)
+	?RegisterProtocolIDs@RDbgTrcComm@@QAEHPBW4TOstProtIds@@IH@Z @ 10 NONAME ; int RDbgTrcComm::RegisterProtocolIDs(enum TOstProtIds const *, unsigned int, int)
+	?SetAcmConfig@RDbgTrcComm@@QAEHAAVTDesC8@@@Z @ 11 NONAME ; int RDbgTrcComm::SetAcmConfig(class TDesC8 &)
+	?UnRegisterProtocolID@RDbgTrcComm@@QAEHW4TOstProtIds@@@Z @ 12 NONAME ; int RDbgTrcComm::UnRegisterProtocolID(enum TOstProtIds)
+	?UnRegisterProtocolIDs@RDbgTrcComm@@QAEHPBW4TOstProtIds@@I@Z @ 13 NONAME ; int RDbgTrcComm::UnRegisterProtocolIDs(enum TOstProtIds const *, unsigned int)
+	?Version@RDbgTrcComm@@QBE?AVTVersion@@XZ @ 14 NONAME ; class TVersion RDbgTrcComm::Version(void) const
+	?WriteCancel@RDbgTrcComm@@QAEHXZ @ 15 NONAME ; int RDbgTrcComm::WriteCancel(void)
+	?WriteMessage@RDbgTrcComm@@QAEXAAVTRequestStatus@@ABVTDesC8@@H@Z @ 16 NONAME ; void RDbgTrcComm::WriteMessage(class TRequestStatus &, class TDesC8 const &, int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/client/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/client/dbgtrccli_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+macro 		__S60__
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+
+TARGET		usbostcomm.dll
+TARGETTYPE	dll
+UID		0x101F7417 0x200170BD 
+
+VENDORID VID_DEFAULT
+CAPABILITY ALL -TCB -DRM
+
+SOURCEPATH	.
+
+SOURCE		dbgtrccomm.cpp dbgtrccliutils.cpp dbgtrcclidefs.cpp
+
+LIBRARY	  euser.lib 
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+  	SYSTEMINCLUDE	\epoc32\include
+  	USERINCLUDE 	..\inc
+#else
+    MW_LAYER_SYSTEMINCLUDE
+    USERINCLUDE 	../inc
+#endif
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+
+#if defined(WINS)
+    deffile ..\bwinscw\dbgtrccomm_win.def
+#elif defined(EABI)
+    deffile ..\eabi\dbgtrccomm_eabi.def		
+#endif
+
+#else
+
+#if defined(WINS)
+    deffile ../bwinscw/dbgtrccomm_win.def
+#elif defined(EABI)
+    deffile ../eabi/dbgtrccomm_eabi.def		
+#endif
+
+#endif
+
+nostrictdef
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/client/dbgtrccli_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+TARGET		usbostcomm.dll
+TARGETTYPE	dll
+UID		0x101F7417 0x200170BD 
+
+VENDORID 0x101FB657
+CAPABILITY ALL -TCB -DRM
+
+SOURCEPATH	.
+
+SOURCE		dbgtrccomm.cpp dbgtrccliutils.cpp dbgtrcclidefs.cpp
+
+LIBRARY	  euser.lib 
+
+
+SYSTEMINCLUDE	/epoc32/include
+USERINCLUDE 	../inc
+
+
+#if defined(WINS)
+    deffile ../bwinscw/dbgtrccomm_win.def
+#elif defined(EABI)
+    deffile ../eabi/dbgtrccomm_eabi.def		
+#endif
+
+nostrictdef
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/client/dbgtrccli_uiq.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+TARGET		usbostcomm.dll
+TARGETTYPE	dll
+UID		0x101F7417 0x200170BD 
+
+VENDORID 0x101FB657
+CAPABILITY ALL -TCB -DRM
+
+SOURCEPATH	.
+
+SOURCE		dbgtrccomm.cpp dbgtrccliutils.cpp dbgtrcclidefs.cpp
+
+LIBRARY	  euser.lib 
+
+
+SYSTEMINCLUDE	\epoc32\include
+USERINCLUDE 	..\inc
+
+
+#if defined(WINS)
+    deffile ..\bwinscw\dbgtrccomm_win.def
+#elif defined(EABI)
+    deffile ..\eabi\dbgtrccomm_eabi.def		
+#endif
+
+nostrictdef
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/client/dbgtrcclidefs.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "dbgtrcclidefs.h"
+#include "dbgtrccmdcodes.h"
+
+
+//
+// DbgTrcCliDefs (source)
+//
+
+//
+// DbgTrcCliDefs::ServerAndThreadName()
+//
+// Returns the DbgTrc server's unique name.
+// @return Unique name of the DbgTrc server.
+//
+const TDesC& DbgTrcCliDefs::ServerAndThreadName()
+{
+	return KDbgTrcServerName;
+}
+
+//
+// DbgTrcCliDefs::ServerImageName()
+//
+// Return the name of the server image (Exe/Dll)
+//
+const TDesC& DbgTrcCliDefs::ServerImageName()
+{
+	return KDbgTrcServerImageName;
+}
+
+//
+// DbgTrcCliDefs::ServerUidType()
+//
+// Return the Uid associated with the server image
+//
+TUidType DbgTrcCliDefs::ServerUid()
+{
+	return TUidType(KNullUid, KNullUid, KDbgTrcServerUid);
+}
+
+
+//
+// DbgTrcCliDefs::Version()
+//
+// Return the version number of the server/client
+//
+TVersion DbgTrcCliDefs::Version()
+{
+	return TVersion(KDbgTrcServerMajorVN, KDbgTrcServerMinorVN, KDbgTrcServerBuildVN);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/client/dbgtrcclidefs.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __DbgTrcCliDefs_h__
+#define __DbgTrcCliDefs_h__
+
+// System includes
+#include <e32base.h>
+// User includes
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// DbgTrcCliDefs (header)
+//
+
+//This is a utility class that retrieves the name and version number of the DbgTrcServer 
+class DbgTrcCliDefs
+{
+	// STATIC ACCESS METHODS
+	public:										
+		static const TDesC&	ServerAndThreadName();
+
+		static const TDesC&	ServerImageName();
+
+		static TUidType		ServerUid();
+
+		static TVersion		Version();
+
+};
+
+#endif //__DbgTrcCliDefs_h__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/client/dbgtrccliutils.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "dbgtrccliutils.h"
+
+// System includes
+#include <e32std.h>
+
+// User includes
+#include "dbgtrcclidefs.h"
+
+
+
+//
+// DbgTrcCliUtils (source)
+//
+
+//
+// DbgTrcCliUtils::Panic()
+//
+// Panic the client
+//
+void DbgTrcCliUtils::Panic(TDbgTrcCliPanic aPanic)
+{
+	_LIT(KDbgTrcCliPanic, "DBGTRCCLI");
+	User::Panic(KDbgTrcCliPanic, aPanic);
+}
+
+//
+// DbgTrcCliUtils::Fault()
+//
+// Panic the client, indicating some form of logic error or terminal
+// fault.
+//
+void DbgTrcCliUtils::Fault(TDbgTrcCliFault aFault)
+{
+	_LIT(KDbgTrcCliFault, "DBGTRCCLIFAULT");
+	User::Panic(KDbgTrcCliFault, aFault);
+}
+
+//
+// DbgTrcCliUtils::StartDbgTrcServer()
+//
+// Starts the DbgTrc server.
+// @return KErrNone if successful, 
+//		   KErrAlreadyExists if the server is already running, otherwise a system-wide error.
+TInt DbgTrcCliUtils::StartDbgTrcServer()
+{
+
+	TInt ret = KErrNone;
+
+	//
+	// Create a new server process. Simultaneous launching
+	// of two such processes should be detected when the second one attempts to
+	// create the server object, failing with KErrAlreadyExists.
+	//
+	RProcess server;
+	ret = server.Create(DbgTrcCliDefs::ServerImageName(), KNullDesC, DbgTrcCliDefs::ServerUid());
+
+	// Did we manage to create the thread/process?
+	if	(ret != KErrNone)
+		return ret;
+
+	// Wait to see if the thread/process died during construction
+	TRequestStatus serverDiedRequestStatus;
+#if defined(EKA2)
+	server.Rendezvous(serverDiedRequestStatus);
+#else
+	server.Logon(serverDiedRequestStatus);
+#endif
+	
+	if	(serverDiedRequestStatus != KRequestPending)
+	{
+		// Abort startup
+		server.Kill(KErrNone);
+	}
+	else
+	{
+		// Logon OK - start the server
+		server.Resume();
+	}
+	
+	User::WaitForRequest(serverDiedRequestStatus);
+
+	// we can't use the 'exit reason' if the server panicked as this
+	// is the panic 'reason' and may be '0' which cannot be distinguished
+	// from KErrNone
+	
+	ret = (server.ExitType() == EExitPanic) ? KErrGeneral : serverDiedRequestStatus.Int();
+	
+	server.Close();
+
+	return ret;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/client/dbgtrccliutils.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __DbgTrcCliUtils_H__
+#define __DbgTrcCliUtils_H__
+
+// System includes
+#include <e32base.h>
+
+
+//
+//  DbgTrcCliUtils (header)
+//
+class DbgTrcCliUtils
+{
+public:										// ENUMERATIONS
+	/** Panic numbers associated with the DBTRCCLI panic category. */
+	enum TDbgTrcCliPanic
+	{
+		EDbgTrcCliPanicArgument			= 0,
+		EDbgTrcCliPanicCancel			= 1,
+		EDbgTrcCliPanicLast
+	};
+	/** Panic numbers associated with the DBGTRCCLIFAULT panic category. */
+	enum TDbgTrcCliFault
+	{
+		EDbgTrcCliFaultLogic				= 0,
+		EDbgTrcCliFaultData					= 1,
+		EDbgTrcCliFaultCouldNotLoadServer	= 2,
+		EDbgTrcCliFaultDebugFuncError		= 3,
+		EDbgTrcCliFaultLast
+	};
+
+public:
+
+	static void	Panic(TDbgTrcCliPanic aPanic);
+
+	static void	Fault(TDbgTrcCliFault aFault);
+
+	static TInt	StartDbgTrcServer();
+};
+
+#endif //__DbgTrcCliUtils_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/client/dbgtrccomm.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,295 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "dbgtrccomm.h"
+#include "dbgtrcclidefs.h"
+
+// System includes
+
+// User includes
+#include "dbgtrccmdcodes.h"
+#include "dbgtrccliutils.h"
+// Type definitions
+
+// Constants
+const TInt KNumberOfServerStartupAttempts = 2;
+
+// Enumerations
+
+//
+// RDbgTrcComm (source)
+//
+
+//
+// RDbgTrcComm::RDbgTrcComm
+//
+// Constructor
+//
+EXPORT_C RDbgTrcComm::RDbgTrcComm()
+{
+}
+
+//
+// RDbgTrcComm::Connect()
+//
+// Connects the client process to the DbgTrc server, starting the server 
+// if it is not already running.
+// return KErrNone if successful, otherwise one of the system-wide errors.
+//
+EXPORT_C TInt RDbgTrcComm::Connect()
+{
+	TInt startupAttempts = KNumberOfServerStartupAttempts;
+	for(;;)
+	{
+		TInt ret = CreateSession(DbgTrcCliDefs::ServerAndThreadName(), DbgTrcCliDefs::Version(), KDbgTrcServerAsynchronousSlotCount);
+		if (ret != KErrNotFound && ret != KErrServerTerminated)
+		{
+			return ret;
+		}
+		
+		if	(startupAttempts-- == 0)
+		{
+			return ret;
+		}
+		
+		ret = DbgTrcCliUtils::StartDbgTrcServer();
+		if	(ret != KErrNone && ret != KErrAlreadyExists)
+		{
+			return ret;
+		}
+	}
+}
+
+
+//
+//RDbgTrcComm::Disconnect()
+//
+// Connects the client process to the DbgTrc server, starting the server 
+// if it is not already running.
+// return KErrNone if successful, otherwise one of the system-wide errors.
+//
+EXPORT_C TInt RDbgTrcComm::Disconnect()
+{	
+	// let the session object that we are disconnecting.
+	TInt error = SendReceive(EDbgTrcCmdDisconnect);
+	
+	// needs to close the session somehow, there is no close session right now in RSessionBase.	
+	// Either we need to switch to RSubSessionBase or use HandleBase close to see if it closes the session.
+	return 	error;
+}
+
+
+//
+// RDbgTrcComm::Version()
+//
+// Provides the version number of the DbgTrc server.
+// @return The version number. 
+//
+EXPORT_C TVersion RDbgTrcComm::Version() const
+{
+	return DbgTrcCliDefs::Version();
+}
+
+//
+// RDbgTrcComm::GetAcmConfig(TDes8& aConfig)
+//
+// Get the current configuration for the ACM port.
+// This would be either the default ACM port settings or 
+// port settings set by another client if the port is already opened.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C TInt RDbgTrcComm::GetAcmConfig(TDes8& aConfig)
+{
+	TIpcArgs args(aConfig.Length(), &aConfig);
+	
+	return SendReceive(EDbgTrcCmdCodeGetAcmConfig, args);
+}
+
+//
+// RDbgTrcComm::SetAcmConfig(TDes8& aConfig)
+//
+// Set the current configuration for the ACM port.
+// If the port is already configured by another client, 
+// then the function would return KErrInUse, meaning its already set.
+//
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C TInt RDbgTrcComm::SetAcmConfig(TDesC8& aConfig)
+{
+	TIpcArgs args(aConfig.Length(), &aConfig);
+	
+	return SendReceive(EDbgTrcCmdCodeSetAcmConfig, args);
+}
+
+
+//
+// RDbgTrcComm::Open()
+//
+// Reads data from the already opened file.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C TInt RDbgTrcComm::Open()
+{
+	return SendReceive(EDbgTrcCmdCodeOpen);
+}
+
+//
+// RDbgTrcComm::WriteFile()
+//
+// Writes data into the already opened file.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C TInt RDbgTrcComm::Close()
+{
+	TInt err = SendReceive(EDbgTrcCmdCodeClose);
+	
+	RHandleBase::Close();	
+	return err;
+}
+
+//
+// RDbgTrcComm::RegisterProtocolID()
+//
+// Registers the protocol id with the dbgtrc server.
+// Only protocol id per session.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C TInt RDbgTrcComm::RegisterProtocolID(const TOstProtIds aId, TBool aNeedHeader)
+{	
+	TIpcArgs args(aId, aNeedHeader);
+
+	return SendReceive(EDbgTrcCmdCodeRegisterId, args);
+}
+
+//
+// RDbgTrcComm::RegisterProtocolIDs()
+//
+// Registers the protocol ids with the dbgtrc server.
+// Only protocol id per session.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C TInt RDbgTrcComm::RegisterProtocolIDs(const TOstProtIds* aIds, const TUint aNumberofIds, TBool aNeedHeader)
+{			
+	if (!aIds || aNumberofIds <= 0)
+		return KErrArgument;
+	
+	TPtr8 ids((TUint8*)aIds, aNumberofIds);
+	
+	TIpcArgs args(aNeedHeader, ids.Length(), &ids);
+	 		
+	return SendReceive(EDbgTrcCmdCodeRegisterIds, args);			
+}
+
+//
+// RDbgTrcComm::UnRegisterProtocolID()
+//
+// Unregisters the protocol id with the dbgtrc server.
+// This is probably not necessary, the only case 
+// where it might be necessary is when one client wants to recieve two types of messages.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C TInt RDbgTrcComm::UnRegisterProtocolID(const TOstProtIds aId)
+{	
+	TIpcArgs args(aId);
+
+	return SendReceive(EDbgTrcCmdCodeUnRegisterId, args);
+}
+
+//
+// RDbgTrcComm::UnRegisterProtocolIDs()
+//
+// Unregisters the protocol ids with the dbgtrc server.
+// This is probably not necessary, the only case 
+// where it might be necessary is when one client wants to recieve two types of messages.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C TInt RDbgTrcComm::UnRegisterProtocolIDs(const TOstProtIds* aIds, const TUint aNumberofIds)
+{			
+	if (!aIds || aNumberofIds <= 0)
+		return KErrArgument;
+	
+	TPtr8 ids((TUint8*)aIds, aNumberofIds);
+	
+	TIpcArgs args(ids.Length(), &ids);
+	 		
+	return SendReceive(EDbgTrcCmdCodeUnRegisterIds, args);			
+}
+
+//
+// RDbgTrcComm::ReadMessage(TRequestStatus& aStatus, TDes8& aDes)
+//
+// Reads the message from the message queue for this session if there is one.
+// Otherwise queues up the request.
+//
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C void RDbgTrcComm::ReadMessage(TRequestStatus& aStatus, TDes8& aDes)
+{
+	TIpcArgs args(aDes.MaxLength(), &aDes);
+	
+	SendReceive(EDbgTrcCmdCodeReadMsg, args, aStatus);	
+}
+
+//
+// RDbgTrcComm::ReadCancel()
+//
+// Reads the message from the message queue for this session if there is one.
+// Otherwise queues up the request.
+//
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C TInt RDbgTrcComm::ReadCancel()
+{
+	return SendReceive(EDbgTrcCmdCodeReadCancel);	
+}
+
+
+//
+// RDbgTrcComm::WriteMessage(TRequestStatus& aStatus, TDes8& aDes, TBool aHasHeader)
+//
+//
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C void RDbgTrcComm::WriteMessage(TRequestStatus& aStatus, const TDesC8& aDes, TBool aHasHeader)
+{
+	TIpcArgs args(aHasHeader, aDes.Length(), &aDes);
+	
+	SendReceive(EDbgTrcCmdCodeWriteMsg, args, aStatus);	
+}
+
+//
+// RDbgTrcComm::WriteCancel()
+//
+//
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+EXPORT_C TInt RDbgTrcComm::WriteCancel()
+{
+	return SendReceive(EDbgTrcCmdCodeWriteCancel);	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/eabi/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/eabi/dbgtrccomm_eabi.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,19 @@
+EXPORTS
+	_ZN11RDbgTrcComm10DisconnectEv @ 1 NONAME
+	_ZN11RDbgTrcComm10ReadCancelEv @ 2 NONAME
+	_ZN11RDbgTrcComm11ReadMessageER14TRequestStatusR5TDes8 @ 3 NONAME
+	_ZN11RDbgTrcComm11WriteCancelEv @ 4 NONAME
+	_ZN11RDbgTrcComm12GetAcmConfigER5TDes8 @ 5 NONAME
+	_ZN11RDbgTrcComm12SetAcmConfigER6TDesC8 @ 6 NONAME
+	_ZN11RDbgTrcComm12WriteMessageER14TRequestStatusRK6TDesC8i @ 7 NONAME
+	_ZN11RDbgTrcComm18RegisterProtocolIDE11TOstProtIdsi @ 8 NONAME
+	_ZN11RDbgTrcComm19RegisterProtocolIDsEPK11TOstProtIdsji @ 9 NONAME
+	_ZN11RDbgTrcComm20UnRegisterProtocolIDE11TOstProtIds @ 10 NONAME
+	_ZN11RDbgTrcComm21UnRegisterProtocolIDsEPK11TOstProtIdsj @ 11 NONAME
+	_ZN11RDbgTrcComm4OpenEv @ 12 NONAME
+	_ZN11RDbgTrcComm5CloseEv @ 13 NONAME
+	_ZN11RDbgTrcComm7ConnectEv @ 14 NONAME
+	_ZN11RDbgTrcCommC1Ev @ 15 NONAME
+	_ZN11RDbgTrcCommC2Ev @ 16 NONAME
+	_ZNK11RDbgTrcComm7VersionEv @ 17 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/group/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/group/s60/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/group/s60/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+      ../../rom/dbgtrccomm.iby     CORE_IBY_EXPORT_PATH(tools,dbgtrccomm.iby)
+#endif
+
+#if(defined __SERIES60_30__ || defined __SERIES60_31__)
+..\..\inc\dbgtrccomm.h	\epoc32\include\dbgtrccomm.h
+..\..\inc\ostprotdefs.h	\epoc32\include\ostprotdefs.h
+#else
+../../inc/dbgtrccomm.h	/epoc32/include/dbgtrccomm.h
+../../inc/ostprotdefs.h	/epoc32/include/ostprotdefs.h
+#endif
+
+
+PRJ_MMPFILES
+#ifdef MARM
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+..\..\client\dbgtrccli_s60.mmp
+..\..\server\dbgtrcserver_s60.mmp
+#else
+../../client/dbgtrccli_s60.mmp
+../../server/dbgtrcserver_s60.mmp
+#endif
+#endif
+
+PRJ_TESTMMPFILES
+#ifdef MARM 
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+..\..\test\dbgtrctest_s60.mmp
+#else
+../../test/dbgtrctest_s60.mmp
+#endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/group/tv/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/group/tv/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../../rom/dbgtrccomm.iby     /epoc32/rom/include/dbgtrccomm.iby
+../../inc/dbgtrccomm.h	/epoc32/include/dbgtrccomm.h
+../../inc/ostprotdefs.h	/epoc32/include/ostprotdefs.h
+
+
+PRJ_MMPFILES
+#ifdef MARM
+../../client/dbgtrccli_tv.mmp
+../../server/dbgtrcserver_tv.mmp
+#endif
+
+PRJ_TESTMMPFILES
+../../test/dbgtrctest_tv.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/group/uiq/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/group/uiq/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+..\..\rom\dbgtrccomm.iby     \epoc32\rom\include\dbgtrccomm.iby
+..\..\inc\dbgtrccomm.h	\epoc32\include\dbgtrccomm.h
+..\..\inc\ostprotdefs.h	\epoc32\include\ostprotdefs.h
+
+
+PRJ_MMPFILES
+#ifdef MARM
+..\..\client\dbgtrccli_uiq.mmp
+..\..\server\dbgtrcserver_uiq.mmp
+#endif
+
+PRJ_TESTMMPFILES
+..\..\test\dbgtrctest_uiq.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/inc/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/inc/dbgtrccmdcodes.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __DbgTrcCmdCodes_H__
+#define __DbgTrcCmdCodes_H__
+
+// System includes
+#include <e32std.h>
+
+// Constants
+const TInt KDbgTrcServerMajorVN = 1;
+const TInt KDbgTrcServerMinorVN = 0;
+const TInt KDbgTrcServerBuildVN = 0;
+
+// asynchronous cmd slot count
+const TInt KDbgTrcServerAsynchronousSlotCount	= 16;
+
+//
+const TUid KDbgTrcServerUid = { 0x200170BE };
+
+
+// Literal constants
+
+#if defined(EKA2)
+_LIT(KDbgTrcServerName, "!UsbOstRouter");
+#else
+_LIT(KDbgTrcServerName, "UsbOstRouter");
+#endif
+
+_LIT(KDbgTrcServerImageName, "usbostrouter");
+
+_LIT(KServerIntiatedSessionPanic, "USBOSTROUTER");
+
+#define KCapabilityCustomCheck 0
+
+// Enumerations
+//
+// The cmd-codes used to communicate between the DbgTrc client and DbgTrc server.
+//
+enum TDbgTrcCmdCode
+{
+	//Custom check
+	EDbgTrcCmdCodeFirst = KCapabilityCustomCheck,
+	EDbgTrcCmdConnect,
+	EDbgTrcCmdDisconnect,	
+	EDbgTrcCmdCodeGetAcmConfig,
+	EDbgTrcCmdCodeSetAcmConfig,
+	EDbgTrcCmdCodeOpen,					
+	EDbgTrcCmdCodeClose,						
+	EDbgTrcCmdCodeRegisterId,
+	EDbgTrcCmdCodeRegisterIds,
+	EDbgTrcCmdCodeUnRegisterId,
+	EDbgTrcCmdCodeUnRegisterIds,
+	EDbgTrcCmdCodeReadMsg,
+	EDbgTrcCmdCodeReadCancel,
+	EDbgTrcCmdCodeWriteMsg,
+	EDbgTrcCmdCodeWriteCancel,
+	EDbgTrcCmdCodeLast								
+};
+
+// Identifies server-initiated panics relating to the client session.
+enum TDbgTrcServerInitiatedClientPanic
+{
+
+	//This panic occurs when a client tries to perform an invalid operation.
+	EDbgTrcServerInitiatedClientPanicInvalidOperation = 1,
+
+	//This panic usually occurs when a client method tries to write to a descriptor 
+	//(sometimes asynchronously), and the client-supplied descriptor is not valid.
+	EDbgTrcServerInitiatedClientPanicBadDescriptor = 2,
+
+};
+
+#endif //__DbgTrcCmdCodes_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/inc/dbgtrccomm.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __RDbgTrcComm_h__
+#define __RDbgTrcComm_h__
+
+// System includes
+#include <e32base.h>
+
+// User includes
+#include "ostprotdefs.h"
+
+#define SafeDelete(x) { if (x) delete x; x = NULL; }
+
+
+/**
+ Enumeration of baud rates in bits per second for ACM port configuration.
+ * e.g EBaud1152000 is for 115200Bps data rate  
+ */
+enum TBaudRates
+	{
+	EBaud50,
+	EBaud75,
+	EBaud110,
+	EBaud134,
+	EBaud150,
+	EBaud300,
+	EBaud600,
+	EBaud1200,
+	EBaud1800,
+	EBaud2000,
+	EBaud2400,
+	EBaud3600,
+	EBaud4800,
+	EBaud7200,
+	EBaud9600,
+	EBaud19200,
+	EBaud38400,
+	EBaud57600,
+	EBaud115200,
+	EBaud230400,
+	EBaud460800,
+	EBaud576000,
+	EBaud1152000,
+	EBaud4000000,
+	EBaud921600,
+	EBaudAutobaud=0x40000000,
+	EBaudSpecial=0x80000000,
+	};
+
+class TAcmConfigV01
+    {
+public:
+	TUint iPortNumber; // port number for ACM port is always 1 with S60 devices, atleast when using the PC Suite drivers.
+	TBaudRates iBaudRate;
+    };
+typedef TPckgBuf< TAcmConfigV01> TAcmConfig;
+
+
+// Classes referenced
+
+//The client-side interface to the dbg trc comms server. 
+class RDbgTrcComm : public RSessionBase
+{
+	// CONNECT TO SERVER & VERSIONING
+	public:										
+		IMPORT_C			RDbgTrcComm();
+		IMPORT_C TInt		Connect();
+		IMPORT_C TInt		Disconnect();
+		IMPORT_C TVersion	Version() const;
+
+	// CMD SPECIFIC FUNCTIONALITY
+	public:										
+		IMPORT_C TInt	GetAcmConfig(TDes8& aConfig);
+		IMPORT_C TInt	SetAcmConfig(TDesC8& aConfig);
+		
+		IMPORT_C TInt	Open();
+		IMPORT_C TInt	Close();
+		IMPORT_C TInt	RegisterProtocolID(const TOstProtIds aId, TBool aNeedHeader);
+		IMPORT_C TInt   RegisterProtocolIDs(const TOstProtIds* aIds, const TUint aNumberofIds, TBool aNeedHeader);
+		IMPORT_C TInt	UnRegisterProtocolID(const TOstProtIds aId);
+		IMPORT_C TInt   UnRegisterProtocolIDs(const TOstProtIds* aIds, const TUint aNumberofIds);
+
+		IMPORT_C void 	ReadMessage(TRequestStatus& aStatus, TDes8& aDes);
+		IMPORT_C TInt 	ReadCancel();
+		IMPORT_C void 	WriteMessage(TRequestStatus& aStatus, const TDesC8& aDes, TBool aHasHeader=EFalse);
+		IMPORT_C TInt 	WriteCancel();
+};
+
+#endif //__RDbgTrcComm_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/inc/ostprotdefs.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __OstProtDefs_H__
+#define __OstProtDefs_H__
+
+#define OST_HEADER_LENGTH 4
+
+#define VERS_FIELD_INDEX 0
+#define PROTID_FIELD_INDEX 1
+#define LENGTH_FIELD_INDEX 2
+
+#define OST_PROTOCOL_VERSION 0x01 // first internal Nokia verion is 0.1
+#define OST_VERSION_PROTOCOL_VERSION 0x00
+
+// Constants
+const TInt KOstProtMajorVN = 1;
+const TInt KOstProtMinorVN = 0;
+
+
+
+enum TOstProtIds
+{
+	//Custom check
+	EOstProtOstSystem = 0x00,
+	EOstProtTrcActivation = 0x01,
+	EOstProtTrk = 0x90,	
+	EOstProtTraceCore = 0x91
+		
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/internal/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+1
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/internal/doc/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+1
\ No newline at end of file
Binary file dbgagents/trkagent/dbgtrccomm/internal/doc/USB_Comm_Design_API_Spec.doc has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/rom/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/rom/dbgtrccomm.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __DBGTRCCOMM_IBY__
+#define __DBGTRCCOMM_IBY__
+
+
+file=ABI_DIR\BUILD_DIR\usbostcomm.dll	sys\bin\usbostcomm.dll
+file=ABI_DIR\BUILD_DIR\usbostrouter.exe	sys\bin\usbostrouter.exe 
+
+//file=ABI_DIR\BUILD_DIR\usbosttest.exe	sys\bin\usbosttest.exe
+
+#endif //__DBGTRCCOMM_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/datalistener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __DATALISTENER_H__
+#define __DATALISTENER_H__
+
+
+#define MAX_BUF_SIZE 0x880 
+
+
+class MDataListener
+{
+    public:
+        
+        virtual void DataAvailable(TDesC8& aMsgData, TUint aLength) = 0;
+        
+        virtual void DataWriteComplete(TInt aErrCode) = 0;
+        
+      
+};
+
+#endif //__DATALISTENER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcportmgr.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,359 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <e32cons.h>
+#include <e32base.h>
+
+#include "logging.h"
+#include "portreader.h"
+#include "portwriter.h"
+#include "dbgtrcportmgr.h"
+
+//default USB settings
+_LIT(KDefaultUsbPDD, "NONE");
+_LIT(KDefaultUsbLDD, "EUSBC");
+_LIT(KDefaultUsbCSY, "ECACM");
+#define KDefaultUsbPort 1
+
+// uncomment the line below for testing with serial port on H4 or H2 board
+//#define SERIAL
+
+//
+// Static helper functions
+//
+static void BuildPortName(const TDesC& aModuleName, TUint aUnit, TDes& aCompleteName)
+{
+	aCompleteName.Zero();
+	aCompleteName.Append(aModuleName);
+	aCompleteName.AppendFill(':', 2);
+	aCompleteName.AppendNum(aUnit);
+}
+
+static TBps TBpsRateFromDbgTrcBaudRate(TBaudRates aRate)
+{
+	switch (aRate)
+	{
+		case EBaud50:      return EBps50;
+		case EBaud75:      return EBps75;
+		case EBaud110:     return EBps110;
+		case EBaud134:     return EBps134;
+		case EBaud150:     return EBps150;
+		case EBaud300:     return EBps300;
+		case EBaud600:     return EBps600;
+		case EBaud1200:    return EBps1200;
+		case EBaud1800:    return EBps1800;
+		case EBaud2000:    return EBps2000;
+		case EBaud2400:    return EBps2400;
+		case EBaud3600:    return EBps3600;
+		case EBaud4800:    return EBps4800;
+		case EBaud7200:    return EBps7200;
+		case EBaud9600:    return EBps9600;
+		case EBaud19200:   return EBps19200;
+		case EBaud38400:   return EBps38400;
+		case EBaud57600:   return EBps57600;
+		case EBaud115200:  return EBps115200;
+		case EBaud230400:  return EBps230400;
+		case EBaud460800:  return EBps460800;
+		case EBaud576000:  return EBps576000;
+		case EBaud1152000: return EBps1152000;
+		case EBaud4000000: return EBps4000000;
+		default:  		   return EBpsAutobaud;
+	}
+}
+
+
+CDbgTrcPortMgr*	CDbgTrcPortMgr::NewL()
+{
+	LOG_MSG("CDbgTrcPortMgr::NewL");
+
+	CDbgTrcPortMgr* self = new(ELeave) CDbgTrcPortMgr;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+}
+
+CDbgTrcPortMgr::~CDbgTrcPortMgr()
+{
+	LOG_MSG("CDbgTrcPortMgr::~CDbgTrcPortMgr");
+
+	SafeDelete(iReader);
+	SafeDelete(iWriter);
+}
+
+void CDbgTrcPortMgr::ConstructL()
+{
+	LOG_MSG("CDbgTrcPortMgr::ConstructL");
+
+	iReader = NULL;
+	iWriter = NULL;
+	
+#ifdef SERIAL // for testing with serial on H4 or H2 board.
+	iPDD.Copy(_L("EUART1"));
+	iLDD.Copy(_L("ECOMM"));
+	iCSY.Copy(_L("ECUART"));
+	iPortNumber = 3;
+#else
+	//set the default ACM port settings.	
+	iPDD.Copy(KDefaultUsbPDD);
+	iLDD.Copy(KDefaultUsbLDD);
+	iCSY.Copy(KDefaultUsbCSY);
+	iPortNumber = KDefaultUsbPort;	
+#endif
+
+	iRate = EBaud115200;
+	
+	iConnected = EFalse;
+	iActiveConnections = 0;
+	iServerStarted = EFalse;
+	
+	iAcmConfig.iBaudRate = iRate;
+	iAcmConfig.iPortNumber = iPortNumber;
+}
+
+void CDbgTrcPortMgr::GetPortConfig(TDes8& aDes)
+{
+	LOG_MSG("CDbgTrcPortMgr::GetPortConfig");
+
+	TPtrC8 cfg((const TUint8*)&iAcmConfig, sizeof(iAcmConfig));
+	aDes.Copy(cfg);	
+}
+
+TInt CDbgTrcPortMgr::SetPortConfig(const TDesC8& aDes)
+{
+	LOG_MSG("CDbgTrcPortMgr::SetPortConfig");
+
+	if (iConnected)
+		return KErrInUse;
+		
+	if (aDes.Length()<(TInt)sizeof(TAcmConfigV01))
+		return KErrGeneral;
+	TAcmConfigV01 config(*(TAcmConfigV01*)aDes.Ptr());
+	
+	iPortNumber = config.iPortNumber;
+	iRate = config.iBaudRate;
+	
+	iAcmConfig.iBaudRate = iRate;
+	iAcmConfig.iPortNumber = iPortNumber;
+	
+	return KErrNone;
+}
+
+
+//
+// CDbgTrcPortMgr::OpenPortL
+//
+// Open the ACM port
+//
+TInt CDbgTrcPortMgr::OpenPortL()
+{
+	LOG_MSG("CDbgTrcPortMgr::OpenPort");
+
+	TInt error = KErrNone;
+	
+	if (iConnected)
+	{
+		iActiveConnections++;
+		return error; //return KErrNone if the connection is already opened by another client.
+	}
+
+	if (!iServerStarted)
+	{
+		StartC32();
+		error = iServer.Connect();
+		if (error == KErrNone)
+		{
+			iServerStarted = ETrue;
+			LOG_MSG("C32 Server started");
+		}
+	}											  
+		
+	if (iServerStarted)
+	{
+		error = iServer.LoadCommModule(iCSY);
+		if (error == KErrNone)
+		{
+			LOG_MSG("CSY Loaded:");
+
+			TInt ports = 0;
+			error = iServer.NumPorts(ports);
+			
+			if (error == KErrNone)
+			{
+				LOG_MSG2("Number of ports: %d", ports);
+
+				// make sure the unit number is in range
+				TSerialInfo serialInfo;
+
+				error = KErrNotFound;
+				
+				TBuf<32> csyModule;
+				csyModule = iCSY;
+				csyModule.LowerCase();
+				for (TInt i=0; i<ports && error; i++)
+				{
+					TBuf<32> module;
+					TInt err1 = iServer.GetPortInfo(i, module, serialInfo);
+					
+					// come out of the loop and error out if we are not able
+					// to get the port info.
+					if (err1 != KErrNone) 
+						break;
+										   
+					module.LowerCase();
+					LOG_MSG("Module name: ");
+
+					if (!module.Compare(csyModule))
+					{
+						error = KErrNone;
+						LOG_MSG("CSY Module matched");
+					}
+				}
+				
+				if (error == KErrNone)
+				{		
+					LOG_MSG("CSY Module found");			
+					if (iPDD.Compare(KDefaultUsbPDD))
+						error = User::LoadPhysicalDevice(iPDD);
+					
+					if (error == KErrNone || error == KErrAlreadyExists)
+					{
+						error = User::LoadLogicalDevice(iLDD);
+						if (error == KErrNone || error == KErrAlreadyExists)
+						{
+							error = KErrNone;
+							TBuf<KMaxPortName+4> portName;
+							BuildPortName(serialInfo.iName, iPortNumber, portName);
+							
+							error = iPort.Open(iServer, portName, ECommExclusive, ECommRoleDTE);
+							if (error != KErrNone)
+							{
+								LOG_MSG("Unable to open port in DTE mode");
+								
+								error = iPort.Open(iServer, portName, ECommExclusive, ECommRoleDCE);												  
+							}
+							
+							if (error == KErrNone)
+							{
+								LOG_MSG("Port opened");
+								
+								// Configure physical and logical characteristics
+								TCommConfig config;
+								iPort.Config(config);
+								config().iRate = TBpsRateFromDbgTrcBaudRate(iRate);
+								config().iParity = EParityNone;
+								config().iDataBits = EData8;
+								config().iStopBits = EStop1;
+								config().iFifo = EFifoEnable;
+
+								config().iHandshake = 0;	// no flow control at all
+
+								error = iPort.SetConfig(config);
+								
+								if (error == KErrNone)
+								{
+									LOG_MSG("Port configuration set");
+
+									//iPort.SetReceiveBufferLength(MAX_BUF_SIZE);									
+									iConnected = ETrue;
+									//reset the rx and tx buffers just in case 
+									//if there is any stale data lying around from the previous debug sessions
+									iPort.ResetBuffers(); 
+									
+									// now increment the active connections counter
+									iActiveConnections++;
+									
+									// now create the port reader and writer.
+									iReader = CPortReader::NewL(iPort);
+									iWriter = CPortWriter::NewL(iPort);																
+								}							
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+	
+	if (iServerStarted && !iConnected)  
+	{
+		iServer.Close();
+		iServerStarted = EFalse;
+	}	
+
+	return error;
+}
+
+
+//
+// CDbgTrcPortMgr::ClosePort
+//
+// Close the ACM port
+//
+TInt CDbgTrcPortMgr::ClosePort()
+{	
+	// now decrement the active connections counter
+	if (iActiveConnections > 0)	
+		iActiveConnections--; 
+
+	if (iActiveConnections == 0) // close the actual port only when the number of active connections is 0
+	{
+		SafeDelete(iReader);
+		SafeDelete(iWriter);
+
+		if (iConnected)
+		{
+			iPort.Close();
+			iConnected = EFalse;
+		}
+
+		if (iServerStarted)
+		{
+			iServer.Close();
+			iServerStarted = EFalse;
+		}		
+	}
+	
+	return KErrNone;
+}
+
+//
+// CDbgTrcPortMgr::GetPortReader
+//
+//
+CPortReader* CDbgTrcPortMgr::GetPortReader()
+{
+	if (iConnected)
+		return iReader;
+	
+	return NULL;
+}
+
+//
+// CDbgTrcPortMgr::GetPortReader
+//
+//
+CPortWriter* CDbgTrcPortMgr::GetPortWriter()
+{
+	if (iConnected)
+		return iWriter;
+	
+	return NULL;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcportmgr.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __DbgTrcPortMgr_h__
+#define __DbgTrcPortMgr_h__
+
+// System includes
+#include <e32base.h>
+#include <c32comm.h>
+
+#include "dbgtrccomm.h"
+
+class CPortReader;
+class CPortWriter;
+
+class CDbgTrcPortMgr : public CBase
+{
+
+	public:
+		static 	CDbgTrcPortMgr*	NewL();
+				~CDbgTrcPortMgr();
+	
+	//private construct
+	private:
+			 CDbgTrcPortMgr() {};
+		void ConstructL();
+
+	public:
+		TInt OpenPortL();
+		TInt ClosePort();
+		
+		void GetPortConfig(TDes8& aDes);
+		TInt SetPortConfig(const TDesC8& aDes);
+		
+		CPortWriter* GetPortWriter();
+		CPortReader* GetPortReader();
+
+	// data members		
+	private:
+		
+		TBuf<32> iPDD;
+		TBuf<32> iLDD;
+		TBuf<32> iCSY;
+		TUint iPortNumber;
+		TBaudRates iRate;
+
+		RCommServ iServer;
+		RComm  iPort;
+
+		TBool iServerStarted;
+		TBool iConnected;
+		TBool iActiveConnections;
+
+		CPortReader* iReader;
+		CPortWriter* iWriter;
+		
+		TAcmConfigV01 iAcmConfig;
+						
+};
+
+#endif //__DbgTrcPortMgr_h__   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,202 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "TrkTcbServer.h"
+
+static CMetroTrkIO* TrkIO = NULL;
+
+#define SafeDelete(x) { if (x) delete x; x = NULL; }
+
+
+//
+//
+// CKeyboardInput implementation
+//
+//
+ 
+//
+// CKeyboardInput constructor
+//
+CKeyboardInput::CKeyboardInput(CConsoleBase* aConsole)
+	: CActive(EPriorityUserInput),
+	  iConsole(aConsole)
+{
+	CActiveScheduler::Add(this);
+}
+
+//
+// CKeyboardInput destructor
+//
+CKeyboardInput::~CKeyboardInput()
+{
+	Cancel();
+	Deque();
+}
+
+//
+// CKeyboardInput::ListenToKeyboard
+//
+// Wait for a key to be pressed
+//
+void CKeyboardInput::ListenToKeyboard()
+{
+	iConsole->Read(iStatus);
+	SetActive();
+}
+
+//
+// CKeyboardInput::RunL
+//
+// Called when a key is pressed
+//
+void CKeyboardInput::RunL()
+{
+	TKeyCode key = iConsole->KeyCode();
+	if (key == 'q' || key == 'Q')
+		CActiveScheduler::Stop();
+	else
+		ListenToKeyboard();
+}
+
+//
+// CKeyboardInput::DoCancel
+//
+// Stop waiting for keyboard input
+//
+void CKeyboardInput::DoCancel()
+{
+	iConsole->ReadCancel();
+}
+
+
+//
+//
+// CMetroTrkIO implementation
+//
+//
+
+//
+// CMetroTrkIO constructor
+//
+CMetroTrkIO::CMetroTrkIO()
+	: iConsole(0),
+	  iKeyboardInput(0)
+{
+	TRAPD(error, iConsole = Console::NewL(_L("MetroTrk"), TSize(KConsFullScreen, KConsFullScreen)));
+	if (error != KErrNone)
+		User::Panic(_L("TrkTcbServer failed to allocate CConsoleBase"), __LINE__);
+
+	iKeyboardInput = new CKeyboardInput(iConsole);
+	if (iKeyboardInput == 0)
+		User::Panic(_L("TrkTcbServer failed to allocate CKeyboardInput"), __LINE__);
+
+	iKeyboardInput->ListenToKeyboard();
+}
+
+//
+// CMetroTrkIO destructor
+//
+CMetroTrkIO::~CMetroTrkIO()
+{
+	SafeDelete(iKeyboardInput);
+	SafeDelete(iConsole);
+}
+
+//
+// CMetroTrkIO::PrintToScreen
+//
+//	Print a message to the screen
+//
+void CMetroTrkIO::PrintToScreen(TRefByValue<const TDesC> aFmt, ...)
+{
+	VA_LIST(l);
+	VA_START(l, aFmt);
+	iBuffer.FormatList(aFmt, l);
+
+	iConsole->Printf(iBuffer);
+}
+
+//
+// CMetroTrkIO::Terminating
+//
+//	Notify user of termination
+//
+void CMetroTrkIO::Terminating()
+{
+	iConsole->Printf(_L("\r\nPress any key to exit."));
+	iKeyboardInput->Cancel();
+	iConsole->Getch();
+}
+
+//
+// MainL
+//
+// Create the engine and the communications interface and start the active scheduler
+//
+void MainL()
+{
+	RProcess().SetPriority(EPriorityHigh);
+	RThread().SetPriority(EPriorityAbsoluteHigh);
+	
+	TInt sid = RProcess().SecureId();
+		
+	//TrkIO->PrintToScreen(_L("Welcome to TrkTcbServer for MetroTrk\r\n"));
+	//TrkIO->PrintToScreen(_L("Press 'Q' to quit.\r\n\r\n"));
+
+	CActiveScheduler::Start();
+}
+
+//
+// EXE entrypoint
+//
+TInt E32Main()
+{	
+	__UHEAP_MARK;
+
+	CTrapCleanup* cleanupStack = CTrapCleanup::New();
+	if (cleanupStack == 0)
+		User::Panic(_L("MetroTrk failed to allocate CTrapCleanup"), __LINE__);
+	
+	CActiveScheduler* scheduler = new CActiveScheduler;
+	if (scheduler == 0)
+		User::Panic(_L("MetroTrk failed to allocate CActiveScheduler"), __LINE__);
+
+	CActiveScheduler::Install(scheduler);
+
+//	TrkIO = new CMetroTrkIO;
+	
+//	if (!TrkIO)
+//		User::Panic(_L("TrkTcbServer failed to allocate CMetroTrkIO"), __LINE__);
+	
+	TRAPD(error, MainL());
+
+//	if (error != KErrNone)
+//	{
+//		TrkIO->PrintToScreen(_L("\r\nUnexpected error %d"), error);
+//		TrkIO->Terminating();
+//	}
+	
+//	SafeDelete(TrkIO);
+	SafeDelete(scheduler);
+	SafeDelete(cleanupStack);
+
+	__UHEAP_MARKEND;
+
+	User::Exit(0);
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKTCBSERVER_H__
+#define __TRKTCBSERVER_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include <e32cons.h>
+#include <hal.h>
+ 
+
+//
+// class CKeyboardInput
+//
+// Handles input from the keyboard
+//
+class CKeyboardInput : public CActive
+{
+public:
+
+	CKeyboardInput(CConsoleBase* aConsole);
+	~CKeyboardInput();
+
+	void ListenToKeyboard();
+
+protected:
+
+	void RunL();
+	void DoCancel();
+
+private:
+
+	CConsoleBase* iConsole;
+};
+
+
+//
+// class CMetroTrkIO
+//
+// Handles input and output from/to the console
+//
+class CMetroTrkIO : public CBase
+{
+public:
+
+	CMetroTrkIO();
+	~CMetroTrkIO();
+
+	void PrintToScreen(TRefByValue<const TDesC> aFmt, ...);
+	void Terminating();
+
+private:
+
+	CConsoleBase* iConsole;
+	CKeyboardInput* iKeyboardInput;
+	TBuf<50> iBuffer;
+};
+
+#endif // __TRKTCBSERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcserver_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+macro 		__S60__
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+TARGET			usbostrouter.exe
+#ifdef EKA2
+TARGETTYPE		EXE
+#else
+TARGETTYPE		epocexe
+#endif
+
+UID				0x1000008C  0x200170BE
+
+VENDORID 		VID_DEFAULT
+CAPABILITY 		ALL -TCB -DRM
+
+SOURCEPATH		.
+SOURCE			dbgtrcsrvmain.cpp  dbgtrcsrvscheduler.cpp dbgtrcsrvserver.cpp dbgtrcsrvsession.cpp shutdowntimer.cpp
+SOURCE			dbgtrcportmgr.cpp  portreader.cpp portwriter.cpp ostbaserouter.cpp ostmessage.cpp ostprotregistry.cpp
+
+LIBRARY			euser.lib c32.lib
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+  	SYSTEMINCLUDE	\epoc32\include
+  	USERINCLUDE 	..\inc
+#else
+    MW_LAYER_SYSTEMINCLUDE
+    USERINCLUDE 	../inc
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcserver_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+TARGET			usbostrouter.exe
+TARGETTYPE		EXE
+
+UID			0x1000008C  0x200170BE
+
+VENDORID 		0x101FB657
+CAPABILITY 		ALL -TCB -DRM
+
+SOURCEPATH		.
+SOURCE			dbgtrcsrvmain.cpp  dbgtrcsrvscheduler.cpp dbgtrcsrvserver.cpp dbgtrcsrvsession.cpp shutdowntimer.cpp
+SOURCE			dbgtrcportmgr.cpp  portreader.cpp portwriter.cpp ostbaserouter.cpp ostmessage.cpp ostprotregistry.cpp
+
+LIBRARY			euser.lib c32.lib
+
+
+SYSTEMINCLUDE	/epoc32/include
+USERINCLUDE 	../inc
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcserver_uiq.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+TARGET			usbostrouter.exe
+TARGETTYPE		EXE
+
+UID			0x1000008C  0x200170BE
+
+VENDORID 		0x101FB657
+CAPABILITY 		ALL -TCB -DRM
+
+SOURCEPATH		.
+SOURCE			dbgtrcsrvmain.cpp  dbgtrcsrvscheduler.cpp dbgtrcsrvserver.cpp dbgtrcsrvsession.cpp shutdowntimer.cpp
+SOURCE			dbgtrcportmgr.cpp  portreader.cpp portwriter.cpp ostbaserouter.cpp ostmessage.cpp ostprotregistry.cpp
+
+LIBRARY			euser.lib c32.lib
+
+
+SYSTEMINCLUDE	\epoc32\include
+USERINCLUDE 	..\inc
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvmain.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <e32std.h>
+#include <f32file.h>
+// User includes
+#include "dbgtrccmdcodes.h"
+#include "dbgtrcsrvscheduler.h"
+#include "dbgtrcsrvserver.h"
+
+
+void RunServerL();
+
+//
+// RunServerL()
+// Creates tcb server, signals the client and starts the server
+//
+
+void RunServerL()
+{
+	// Set the process and thread priority to absolute high.
+	//RProcess().SetPriority(EPriorityHigh);
+	//RThread().SetPriority(EPriorityAbsoluteHigh);
+
+	// Create and install the active scheduler we need
+	CDbgTrcSrvScheduler* scheduler = CDbgTrcSrvScheduler::NewLC();
+	if (scheduler == 0)
+		User::Leave(KErrNoMemory);
+		
+	CActiveScheduler::Install(scheduler);
+
+	// Create server
+	CDbgTrcSrvServer::NewLC();
+
+	// Initialisation complete, now signal the client
+#ifdef EKA2
+	User::LeaveIfError(User::RenameThread(KDbgTrcServerName));
+#else
+	User::LeaveIfError(RThread().RenameMe(KDbgTrcServerName));
+#endif
+	RProcess::Rendezvous(KErrNone);
+
+	// Ready to run
+	CActiveScheduler::Start();
+
+	// Cleanup the server and scheduler
+	CleanupStack::PopAndDestroy(2, scheduler);
+}
+
+
+
+//
+// Main Entry Point
+//
+
+TInt E32Main()
+{
+	__UHEAP_MARK;
+	
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if (cleanup == 0)
+		User::Panic(_L("MetroTrk Tcb Server failed to allocate CTrapCleanup"), __LINE__);
+	
+	TInt error = KErrNone;
+	
+	if (cleanup)
+	{
+		TRAP(error, RunServerL());
+		delete cleanup;
+	}
+	
+	if (error != KErrNone)
+	{
+		User::Panic(_L("MetroTrk Tcb Server failed to start"), __LINE__);
+	}
+	
+	__UHEAP_MARKEND;
+
+	return error;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvscheduler.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <e32base.h>
+
+// User includes
+#include "dbgtrcsrvscheduler.h"
+
+
+//
+// CDbgTrcSrvScheduler (source)
+//
+
+//
+// CDbgTrcSrvScheduler::CDbgTrcSrvScheduler()
+//
+// Constructor
+//
+CDbgTrcSrvScheduler::CDbgTrcSrvScheduler()
+{
+}
+
+
+//
+// CDbgTrcSrvScheduler::NewLC()
+//
+// Creates an instance of CDbgTrcSrvScheduler
+//
+CDbgTrcSrvScheduler* CDbgTrcSrvScheduler::NewLC()
+{
+	CDbgTrcSrvScheduler* self = new(ELeave) CDbgTrcSrvScheduler();
+	CleanupStack::PushL(self);
+	return self;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvscheduler.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __DbgTrcSrvScheduler_H__
+#define __DbgTrcSrvScheduler_H__
+
+// System includes
+#include <e32base.h>
+
+// User includes
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+// Classes referenced
+
+
+//
+// CDbgTrcSrvScheduler (header)
+//
+//
+// The Active Scheduler for the Trk TCB Server thread
+//
+class CDbgTrcSrvScheduler : public CActiveScheduler
+{
+	public:										
+		static CDbgTrcSrvScheduler* NewLC();
+
+	private:
+		CDbgTrcSrvScheduler();
+};
+
+#endif //__DbgTrcSrvScheduler_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,252 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <e32base.h>
+
+// User includes
+#include "logging.h"
+#include "dbgtrcportmgr.h"
+#include "ostbaserouter.h"
+#include "dbgtrcsrvsession.h"
+#include "dbgtrcsrvserver.h"
+
+
+// Type definitions
+
+// Constants
+#define TRK_SID 0x200170BB
+// Enumerations
+
+// Classes referenced
+
+#ifdef EKA2
+//Only include these in the secured platform 
+#include "dbgtrccmdcodes.h"
+
+const TUint KRangeCount = 2; 
+
+const TInt KOpCodeRanges[KRangeCount] = 
+{	
+	KCapabilityCustomCheck, 
+	EDbgTrcCmdCodeLast,
+};
+
+
+const TUint8 KElementsIndex[KRangeCount] =
+{
+	CPolicyServer::ECustomCheck, 	//Custom check for the Trk SID 	 0 		- ETrkTcbCmdCodeLast
+	CPolicyServer::ENotSupported, 	//Not Supported					 		 ETrkTcbCmdCodeLast-End
+};
+
+const CPolicyServer::TPolicyElement KPolicyElements[] = 
+{ 
+	{_INIT_SECURITY_POLICY_S0(TRK_SID), CPolicyServer::EFailClient},
+};
+
+const CPolicyServer::TPolicy KDbgTrcServerPolicy =
+{
+	CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
+	KRangeCount,
+	KOpCodeRanges,
+	KElementsIndex, 	// what each range is compared to 
+	KPolicyElements 	// what policies range is compared to
+};
+ 	
+#endif
+
+
+//
+// CDbgTrcSrvServer (source)
+//
+
+//
+// CDbgTrcSrvServer::CDbgTrcSrvServer()
+//
+// Constructor
+//
+CDbgTrcSrvServer::CDbgTrcSrvServer()
+#ifdef  EKA2
+ 	:CPolicyServer(CActive::EPriorityHigh, KDbgTrcServerPolicy),
+#else	
+   	:CServer2(CActive::EPriorityHigh), 
+#endif
+   	iSessionCount(0),
+   	iShutdown()
+{
+	LOG_MSG("CDbgTrcSrvServer::CDbgTrcSrvServer");
+
+}
+
+//
+// CDbgTrcSrvServer::~CDbgTrcSrvServer()
+//
+// Destructor
+//
+CDbgTrcSrvServer::~CDbgTrcSrvServer()
+{
+	LOG_MSG("CDbgTrcSrvServer::~CDbgTrcSrvServer");
+
+	// In order to prevent access violations as the server
+	// shuts down, we inform all sessions that the server is
+	// about to be destroyed
+	iSessionIter.SetToFirst();
+	//
+	CDbgTrcSrvSession* session = static_cast<CDbgTrcSrvSession*>(iSessionIter++);
+	while (session)
+	{
+		session->HandleServerDestruction();
+		session = static_cast<CDbgTrcSrvSession*>(iSessionIter++);
+	}
+	
+	SafeDelete(iOstRouter);	
+}
+
+//
+// CDbgTrcSrvServer::ConstructL()
+//
+// Second level construction
+//
+void CDbgTrcSrvServer::ConstructL()
+{
+	LOG_MSG("CDbgTrcSrvServer::ConstructL");
+
+	// Calling StartL here won't actually allow any connections
+	// to be created until the active scheduler has a chance to run. However, the 
+	// call below will leave should there already be a started TrkTcb server instance.
+	//
+	StartL(KDbgTrcServerName);
+	iShutdown.ConstructL();
+	// now create the ost router which will be the main worker object for all the sessions.
+	iOstRouter = COstBaseRouter::NewL();
+}
+
+//
+// CDbgTrcSrvServer::NewLC()
+//
+// Creates an instance of CDbgTrcSrvServer.
+//
+CDbgTrcSrvServer* CDbgTrcSrvServer::NewLC()
+{
+	LOG_MSG("CDbgTrcSrvServer::NewLC");
+
+	CDbgTrcSrvServer* self = new(ELeave) CDbgTrcSrvServer();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+}
+
+//
+// CDbgTrcSrvServer::NewSessionL()
+//
+// Creates a new session.
+// Called by the IPC framework everytime a client creates a new session.
+// Returns a CDbgTrcSrvSession object.
+//
+CSession2* CDbgTrcSrvServer::NewSessionL(const TVersion& aVersion,const RMessage2& /*aMessage*/) const
+{	
+	LOG_MSG("CDbgTrcSrvServer::NewSessionL");
+
+	// Check client version is correct
+	const TVersion dbgTrcServerVersion(KDbgTrcServerMajorVN, KDbgTrcServerMinorVN, KDbgTrcServerBuildVN);
+	if	(!User::QueryVersionSupported(dbgTrcServerVersion, aVersion))
+		User::Leave(KErrNotSupported);
+	
+	// Create new session
+	CDbgTrcSrvSession* session = CDbgTrcSrvSession::NewL(iOstRouter);
+	return session;
+}
+
+//
+// CDbgTrcSrvServer::RunError()
+//
+// Handles all the errors when handling a client request.
+// Called by the IPC framework whenever a leave occurs when handling a client request.
+// Returns KErrNone to complete the error handling.
+//
+TInt CDbgTrcSrvServer::RunError(TInt aError)
+{
+	LOG_MSG("CDbgTrcSrvServer::RunError");
+
+	// A bad descriptor error implies a badly programmed client, so panic it;
+	// otherwise report the error to the client
+	if	(aError == KErrBadDescriptor)
+	{
+		Message().Panic(KServerIntiatedSessionPanic, EDbgTrcServerInitiatedClientPanicBadDescriptor);
+	}
+	else
+	{
+		Message().Complete(aError);
+	}
+
+	// The leave will result in an early return from CServer2::RunL(), skipping
+	// the call to request another message. So do that now in order to keep the
+	// server running.
+	ReStart();
+
+	// Indicate that we've handled the error fully
+	return KErrNone;
+}
+	
+#ifdef EKA2	
+//
+// CDbgTrcSrvServer::CustomSecurityCheckL()
+//
+// The only security check that is done is to check for the cleint securid 
+// Returns EFail or EPass
+//
+CPolicyServer::TCustomResult CDbgTrcSrvServer::CustomSecurityCheckL(const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/)
+{
+	LOG_MSG("CDbgTrcSrvServer::CustomSecurityCheckL");
+
+	CPolicyServer::TCustomResult returnValue = CPolicyServer::EPass;	
+
+// Check for an appropriate capability, for now the plat sec check is disabled.
+// We need to see if we really need to do or not.
+
+/* 	
+	TSecureId ClientSID = aMsg.SecureId();
+
+	if ((KMetroTrkAppUid == ClientSID) || (KMetroTrkExeUid == ClientSID))
+	{
+		returnValue = CPolicyServer::EPass;
+	}				
+*/
+	return(returnValue);
+}
+#endif
+
+/**
+Decrements the server's count of how many sessions are connected to it and
+starts the shutdown timer if there are no sessions connected
+*/
+void CDbgTrcSrvServer::SessionClosed()
+{
+	if(--iSessionCount < 1)
+	{
+		iShutdown.Start();
+	}
+}
+
+/**
+Increments the servers count of how many sessions are connected to it and
+cancels the shutdown timer if it is running
+*/
+void CDbgTrcSrvServer::SessionOpened()
+{
+	iSessionCount++;
+	iShutdown.Cancel();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __DbgTrcSrvServer_H__
+#define __DbgTrcSrvServer_H__
+
+// System includes
+#include <e32base.h>
+#include "shutdowntimer.h"
+// User includes
+
+// Forward declarations
+class COstBaseRouter;
+
+
+//
+// CDbgTrcSrvServer (header)
+//
+//
+// The DbgTrc Server
+//
+#ifdef EKA2
+class CDbgTrcSrvServer : public CPolicyServer
+#else
+class CDbgTrcSrvServer : public CServer2
+#endif
+{
+	public:
+		static CDbgTrcSrvServer* NewLC();
+		~CDbgTrcSrvServer();
+
+	private:
+		CDbgTrcSrvServer();
+		void ConstructL();
+
+	public:
+		CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
+		// called by the session objects
+		void SessionOpened();
+		void SessionClosed();
+
+	private:
+		TInt RunError(TInt aError);
+
+	private:
+	#ifdef EKA2	
+		TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing);
+	#endif
+	
+	private:
+		COstBaseRouter* iOstRouter;
+		TInt iSessionCount;
+		CShutdownTimer iShutdown;
+};
+
+#endif //__DbgTrcSrvServer_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvsession.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,641 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "logging.h"
+#include "dbgtrcportmgr.h"
+#include "ostbaserouter.h"
+#include "dbgtrccmdcodes.h"
+#include "ostmessage.h"
+
+#include "dbgtrcsrvsession.h"
+#include "dbgtrcsrvserver.h"
+
+
+
+// Type definitions
+
+// Constants
+const TInt KDbgTrcServerTransferBufferExpandSize = 100;
+//const TInt KSlot0 = 0;
+const TInt KSlot1 = 1;
+const TInt KSlot2 = 2;
+//const TInt KSlot3 = 3;
+
+// Enumerations
+
+// Classes referenced
+
+// Static functions
+//
+// Checks for a null'd handle before attempting complete. 
+// If handle is null'd then don't complete as this will panic server.
+//
+void SafeComplete(const RMessagePtr2& aMessage, TInt aCompletionCode)
+{
+	if(!aMessage.IsNull())
+	{
+		aMessage.Complete(aCompletionCode);
+	}
+}
+
+
+//
+// CDbgTrcSrvSession (source)
+//
+
+//
+// CTrkTcbSrvServer::CDbgTrcSrvSession()
+//
+// Constructor
+//
+CDbgTrcSrvSession::CDbgTrcSrvSession(COstBaseRouter* aOstRouter)
+: 	iPendingRead(EFalse),
+	iPendingWrite(EFalse),
+	iPendingReadBufferLength(0),
+	iOstRouter(aOstRouter),
+	iRecvMessageQueue(1),
+	iProtocolIds(1)
+{
+	LOG_MSG("CDbgTrcSrvSession::CDbgTrcSrvSession");
+}
+
+//
+// CTrkTcbSrvServer::~CDbgTrcSrvSession()
+//
+// Destructor
+//
+CDbgTrcSrvSession::~CDbgTrcSrvSession()
+{
+	LOG_MSG("CDbgTrcSrvSession::~CDbgTrcSrvSession");
+	
+	HandleServerDestruction();
+	delete iTransferBuffer;
+	
+	iRecvMessageQueue.ResetAndDestroy();
+	iRecvMessageQueue.Close();
+	
+	iProtocolIds.Reset();
+	iProtocolIds.Close();
+	
+	//get a reference to the server
+	CDbgTrcSrvServer* dbgTrcServer = (CDbgTrcSrvServer*)Server();
+
+	//notify the server that the session has been opened
+	if (dbgTrcServer != NULL)
+		dbgTrcServer->SessionClosed();
+}
+
+//
+// CTrkTcbSrvServer::ConstructL()
+//
+// Creates an instance of CDbgTrcSrvSession.
+//
+void CDbgTrcSrvSession::ConstructL()
+{
+	LOG_MSG("CDbgTrcSrvSession::ConstructL");
+	
+	iTransferBuffer = CBufFlat::NewL(KDbgTrcServerTransferBufferExpandSize);
+	
+	iRecvMessageQueue.Reset();
+
+	iProtocolIds.Reset();
+	
+}
+
+void CDbgTrcSrvSession::CreateL()
+{
+	//get a reference to the server
+	CDbgTrcSrvServer* dbgTrcServer = (CDbgTrcSrvServer*)Server();
+	
+	//notify the server that the session has been opened
+	if (dbgTrcServer != NULL)
+		dbgTrcServer->SessionOpened();
+}
+//
+// CTrkTcbSrvServer::NewL()
+//
+// Static self construction
+//
+CDbgTrcSrvSession* CDbgTrcSrvSession::NewL(COstBaseRouter* aOstRouter)
+{
+	LOG_MSG("CDbgTrcSrvSession::NewL");
+
+	CDbgTrcSrvSession* self = new(ELeave) CDbgTrcSrvSession(aOstRouter);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+}
+
+//
+// CTrkTcbSrvServer::HandleServerDestruction()
+//
+// Called by the server's destructor. We need to be told that the server is
+// being destroyed.
+//
+void CDbgTrcSrvSession::HandleServerDestruction()
+{
+	LOG_MSG("CDbgTrcSrvSession::HandleServerDestruction");
+	
+	// disconnect here just in case if the client has not disconnected before shutting down.
+	DoDisconnect();
+}
+
+//
+// CTrkTcbSrvServer::ServiceL()
+//
+// Services requests from a client.
+// Called by the IPC framework whenever a client sends a request to the server.
+//
+void CDbgTrcSrvSession::ServiceL(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::ServiceL");
+
+	const TInt cmd = aMessage.Function();	
+	switch(cmd)
+	{
+		case EDbgTrcCmdCodeGetAcmConfig:
+			CmdGetAcmConfigL(aMessage);
+			break;
+		case EDbgTrcCmdCodeSetAcmConfig:
+			CmdSetAcmConfigL(aMessage);
+			break;
+		case EDbgTrcCmdCodeOpen:
+			CmdOpenCommPortL(aMessage);
+			break;
+		case EDbgTrcCmdCodeClose:
+			CmdCloseCommPort(aMessage);
+			break;
+		case EDbgTrcCmdCodeRegisterId:
+			CmdRegisterProtocol(aMessage);
+			break;
+		case EDbgTrcCmdCodeRegisterIds:
+			CmdRegisterProtocolIdsL(aMessage);
+			break;
+		case EDbgTrcCmdCodeUnRegisterId:
+			CmdUnRegisterProtocol(aMessage);
+			break;
+		case EDbgTrcCmdCodeUnRegisterIds:
+			CmdUnRegisterProtocolIdsL(aMessage);
+			break;
+		case EDbgTrcCmdCodeReadMsg:
+			CmdReadMsgL(aMessage);
+			break;
+		case EDbgTrcCmdCodeReadCancel:
+			CmdReadCancel(aMessage);			
+			break;
+		case EDbgTrcCmdCodeWriteMsg:
+			CmdWriteMsgL(aMessage);
+			break;
+		case EDbgTrcCmdCodeWriteCancel:
+			CmdWriteCancel(aMessage);			
+			break;
+		case EDbgTrcCmdDisconnect:
+			CmdDisconnect(aMessage);
+		default:
+			aMessage.Panic(KServerIntiatedSessionPanic, EDbgTrcServerInitiatedClientPanicInvalidOperation);
+			break;
+	}
+				
+}
+
+
+//
+// CTrkTcbSrvServer::CmdGetAcmConfigL()
+//
+// Gets the current port configuration 
+//
+void CDbgTrcSrvSession::CmdGetAcmConfigL(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdGetAcmConfigL");
+
+	const TInt desLength = static_cast<TInt>(aMessage.Int0());
+
+	if (desLength > 0 && desLength == sizeof(TAcmConfigV01))
+	{
+		TAcmConfig acmConfig;
+		iOstRouter->GetPortConfig(acmConfig);
+		
+		aMessage.WriteL(KSlot1, acmConfig);		
+		aMessage.Complete(KErrNone);
+	} 
+	else
+	{
+		aMessage.Complete(KErrBadDescriptor);		
+	}
+}
+
+//
+// CTrkTcbSrvServer::CmdSetAcmConfigL()
+//
+// Sets the port configuration if its not already set
+//
+void CDbgTrcSrvSession::CmdSetAcmConfigL(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdSetAcmConfigL");
+
+	const TInt desLength = static_cast<TInt>(aMessage.Int0());
+
+	if (desLength > 0 && desLength == sizeof(TAcmConfigV01))
+	{
+		TAcmConfig acmConfig;
+		aMessage.ReadL(KSlot1, acmConfig);
+		
+		TInt err = iOstRouter->SetPortConfig(acmConfig);		
+		
+		aMessage.Complete(err);
+	} 
+	else
+	{
+		aMessage.Complete(KErrBadDescriptor);
+	}
+}
+
+//
+// CTrkTcbSrvServer::CmdOpenCommPort()
+//
+// Opens the comm port, if its already opened, 
+// just increments the number of active connects and returns true
+//
+//
+void CDbgTrcSrvSession::CmdOpenCommPortL(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdOpenCommPort");
+
+	TInt err = iOstRouter->OpenCommPortL();
+	aMessage.Complete(err);
+}
+
+//
+// CTrkTcbSrvServer::CmdCloseCommPort()
+//
+// Closes the comm port, the port is actually closed when the
+// number of active connections is 0
+//
+//
+void CDbgTrcSrvSession::CmdCloseCommPort(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdCloseCommPort");
+
+	TInt err = iOstRouter->CloseCommPort();
+	aMessage.Complete(err);
+}
+
+//
+// CTrkTcbSrvServer::CmdRegisterProtocol()
+//
+// Registers the protocol with the id
+// This is necessary to be able to read messages
+//
+//
+void CDbgTrcSrvSession::CmdRegisterProtocol(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdRegisterProtocol");
+
+	const TOstProtIds aProtocolId = static_cast<TOstProtIds>(aMessage.Int0());
+	
+	TBool aNeedHeader = static_cast<TBool>(aMessage.Int1());
+	
+	iOstRouter->RegisterProtocol(aProtocolId, this, aNeedHeader);
+	
+	iProtocolIds.Append(aProtocolId);	
+	
+	aMessage.Complete(KErrNone);
+}
+
+//
+// CTrkTcbSrvServer::CmdUnRegisterProtocol()
+//
+// Registers the protocol with the id
+// This is necessary to be able to read messages
+//
+//
+void CDbgTrcSrvSession::CmdUnRegisterProtocol(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdUnRegisterProtocol");
+
+	const TOstProtIds aProtocolId = static_cast<TOstProtIds>(aMessage.Int0());
+	
+	iOstRouter->UnRegisterProtocol(aProtocolId);
+	for (TInt i=0; i<iProtocolIds.Count(); i++)
+	{
+		if (iProtocolIds[i] == aProtocolId)
+		{
+			iProtocolIds.Remove(i);
+			break;
+		}
+	}
+	
+	aMessage.Complete(KErrNone);
+}
+
+//
+// CTrkTcbSrvServer::CmdRegisterProtocolIds()
+//
+// Registers the protocol with the id
+// This is necessary to be able to read messages
+//
+//
+void CDbgTrcSrvSession::CmdRegisterProtocolIdsL(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdRegisterProtocolIdsL");
+
+	TBool aNeedHeader = static_cast<TBool>(aMessage.Int0());
+	const TInt numberOfIds = static_cast<TInt>(aMessage.Int1());
+
+	TBuf8<25> protocolIds;
+	aMessage.ReadL(KSlot2, protocolIds);
+	
+	const TUint8* protocolPtr = protocolIds.Ptr();
+	for (TInt i=0; i<numberOfIds; i++)
+	{
+		iOstRouter->RegisterProtocol((TOstProtIds)protocolPtr[i], this, aNeedHeader);
+		iProtocolIds.Append((TOstProtIds)protocolPtr[i]);
+	}
+	
+	aMessage.Complete(KErrNone);
+
+}
+
+//
+// CTrkTcbSrvServer::CmdUnRegisterProtocol()
+//
+// Registers the protocol with the id
+// This is necessary to be able to read messages
+//
+//
+void CDbgTrcSrvSession::CmdUnRegisterProtocolIdsL(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdUnRegisterProtocolIdsL");
+
+	const TInt numberOfIds = static_cast<TInt>(aMessage.Int0());
+	
+	TBuf8<25> protocolIds;
+	aMessage.ReadL(KSlot1, protocolIds);
+	
+	const TUint8* protocolPtr = protocolIds.Ptr();
+	for (TInt i=0; i<numberOfIds; i++)
+	{
+		iOstRouter->UnRegisterProtocol((TOstProtIds)protocolPtr[i]);
+		for (TInt j=0; j<iProtocolIds.Count(); j++)
+		{
+			if (iProtocolIds[j] == (TOstProtIds)protocolPtr[i])
+			{
+				iProtocolIds.Remove(j);
+				break;
+			}
+		}
+	}
+	
+	aMessage.Complete(KErrNone);
+}
+
+
+//
+// CTrkTcbSrvServer::CmdReadMsgL()
+//
+// Gets the data for read file request and calls the session engine read file method.
+//
+void CDbgTrcSrvSession::CmdReadMsgL(const RMessage2& aMessage)
+{		
+	LOG_MSG("CDbgTrcSrvSession::CmdReadMsg");
+
+	if (iProtocolIds.Count() <= 0)
+	{
+		// No protocols are registered, just complete request here.
+		aMessage.Complete(KErrAccessDenied);
+		return;
+	}
+	
+	if (iRecvMessageQueue.Count() > 0)
+	{
+		LOG_MSG("Message found in recieve queue");
+
+		iPendingReadBufferLength = static_cast<TUint>(aMessage.Int0());		
+		
+		COstMessage* ostMsg = iRecvMessageQueue[0];				
+		HBufC8* msg = ostMsg->iMsgBuffer;
+		
+		if (msg->Length() <= iPendingReadBufferLength)
+		{
+			//write the file data into the client descriptor
+			aMessage.WriteL(KSlot1, msg->Des());			
+			aMessage.Complete(KErrNone);
+			
+			// now remove the message from the queue
+			SafeDelete(iRecvMessageQueue[0]);			
+			iRecvMessageQueue.Remove(0);
+		}
+		else
+		{
+			aMessage.Complete(KErrBadDescriptor);
+		}
+	}
+	else
+	{
+		if (iPendingRead)
+		{			
+			aMessage.Complete(KErrAlreadyExists);
+		}
+		else
+		{
+			iBlockedRead = aMessage;
+			iPendingReadBufferLength = static_cast<TUint>(aMessage.Int0());		
+			
+			iPendingRead = ETrue;
+			
+			// initiate the read.
+			iOstRouter->ReadMessage();
+		}
+	}
+}
+
+void CDbgTrcSrvSession::CmdReadCancel(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdReadCancel");
+	
+	if (iPendingRead && iBlockedRead.Handle())
+	{
+		SafeComplete(iBlockedRead, KErrCancel);
+		iPendingRead = EFalse;						
+	}
+	
+	// now complete the read cancel request.	
+	SafeComplete(aMessage, KErrNone);
+}
+
+void CDbgTrcSrvSession::CmdWriteMsgL(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdWriteMsg");
+
+	if (iPendingWrite)
+	{
+		aMessage.Complete(KErrAlreadyExists);
+	}
+	else
+	{
+		const TBool hasHeader = static_cast<TInt>(aMessage.Int0());
+		const TInt msgLength = static_cast<TInt>(aMessage.Int1());
+	
+		if (msgLength > 0)
+		{
+			if (!hasHeader && iProtocolIds.Count() != 1)
+			{
+				// For now, if there is no header, then we should have only one protocol id registered by the client.
+				// otherwise we don't support writing the message.
+				aMessage.Complete(KErrNotSupported);
+				return;
+			}
+			
+			HBufC8* msgData = HBufC8::NewLC(msgLength);
+			TPtr8 pMsgData(msgData->Des());
+			aMessage.ReadL(KSlot2, pMsgData);
+			
+			iBlockedWrite = aMessage;
+			iPendingWrite = ETrue;
+			
+			if (hasHeader)
+				iOstRouter->WriteMessageL(*msgData, this);
+			else
+				iOstRouter->WriteMessageL(*msgData, this, iProtocolIds[0]);
+			//iOstRouter->WriteMessage(*msgData, this);
+			
+
+			CleanupStack::PopAndDestroy(msgData);			
+		}
+		else
+		{
+			aMessage.Complete(KErrBadDescriptor);
+		}		
+	}
+}
+
+void CDbgTrcSrvSession::CmdWriteCancel(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdWriteCancel");
+
+	// Just complete the pending writes, we don't really try to cancel the actual writes themselves.
+	if (iPendingWrite && iBlockedWrite.Handle())
+	{
+		SafeComplete(iBlockedWrite, KErrCancel);
+		iPendingWrite = EFalse;;							
+	}
+	
+	// now complete the write cancel message
+	aMessage.Complete(KErrNone);
+}
+
+void CDbgTrcSrvSession::CmdDisconnect(const RMessage2& aMessage)
+{
+	LOG_MSG("CDbgTrcSrvSession::CmdDisconnect");
+	
+	DoDisconnect();
+	aMessage.Complete(KErrNone);
+}
+
+
+void CDbgTrcSrvSession::DoDisconnect()
+{
+	LOG_MSG("CDbgTrcSrvSession::Disconnect");
+
+	for (TInt i=0; i<iProtocolIds.Count(); i++)
+	{
+		iOstRouter->UnRegisterProtocol(iProtocolIds[i]);				
+	}
+	iProtocolIds.Reset();
+
+	if (iPendingRead)
+	{
+		SafeComplete(iBlockedRead, KErrCancel);
+		iPendingRead = EFalse;					
+	}
+	if (iPendingWrite)
+	{
+		SafeComplete(iBlockedWrite, KErrCancel);
+		iPendingWrite = EFalse;				
+	}
+}
+
+//
+// CTrkTcbSrvServer::CmdShutDownServer()
+//
+// Stops the active scheduler. This way, server process will run to completion.
+//
+void CDbgTrcSrvSession::MessageAvailableL(TDesC8& aMsg)
+{
+	LOG_MSG("CDbgTrcSrvSession::MessageAvailable");
+
+	if (iPendingRead && iBlockedRead.Handle())
+	{
+		// read is pending, complete it now
+		if (aMsg.Length() <= iPendingReadBufferLength)
+		{
+			LOG_MSG("Completing read request");
+
+			//write the file data into the client descriptor
+			TRAPD(err, iBlockedRead.WriteL(KSlot1, aMsg))						
+			SafeComplete(iBlockedRead, err);	
+			
+			LOG_MSG("Completed read request");
+				
+			iPendingRead = EFalse;
+			// the message is completed, return from here
+			return;
+		}
+		else
+		{
+			LOG_MSG("Bad descriptor unable to complete read request");
+			SafeComplete(iBlockedRead, KErrBadDescriptor);
+			iPendingRead = EFalse;
+		}
+	}
+	else
+	{
+		LOG_MSG("Invalid read request handle");
+	}
+	
+	LOG_MSG("Queueing up the message");
+	//
+	// No pending read, so add the message to the recv queue
+	// Right now, there is no limit on the recv queue.
+	// Need to check if we need to limit the number of messages to be queued up.
+	// 
+	COstMessage* ostMessage = COstMessage::NewL(aMsg);
+	iRecvMessageQueue.Append(ostMessage);					
+}
+
+
+
+void CDbgTrcSrvSession::WriteComplete(TInt aErrCode)
+{
+	LOG_MSG("CDbgTrcSrvSession::WriteComplete");
+
+	if (iPendingWrite && iBlockedWrite.Handle())
+	{
+		LOG_MSG("Completing write request");
+
+		SafeComplete(iBlockedWrite, aErrCode);
+		iPendingWrite = EFalse;
+		
+		LOG_MSG("Completed write request");
+	}
+	else
+	{
+		LOG_MSG("Invalid write message handle");
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/dbgtrcsrvsession.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __DbgTrcSrvSession_h__
+#define __DbgTrcSrvSession_h__
+
+// System includes
+#include <e32base.h>
+
+// User includes
+#include "ostprotdefs.h"
+
+// Constants
+
+// Classes referenced
+class COstBaseRouter;
+class COstMessage;
+
+// Enumerations
+
+
+//
+// CDbgTrcSrvSession (header)
+//
+/**
+ * This class acts as a simple wrapper around the IPC client-server framework,
+ * and drives a real underlying engine, which is actually responsible for
+ * fulfulling all the client requests.
+ */
+ 
+class CDbgTrcSrvSession : public CSession2
+{
+	public:
+		static 	CDbgTrcSrvSession* NewL(COstBaseRouter* aOstRouter);
+				~CDbgTrcSrvSession();
+
+	private:
+				CDbgTrcSrvSession(COstBaseRouter* aOstRouter);
+		void 	ConstructL();
+
+	public:
+		void 	HandleServerDestruction();
+		void 	CreateL();
+
+	public: // callbacks for the OST router
+		void 	MessageAvailableL(TDesC8& aMsg);
+		void 	WriteComplete(TInt aErrCode);
+	
+	private:
+	//FROM CSession2
+		void 	ServiceL(const RMessage2& aMessage);
+
+		
+	private:
+	// CMD - SPECIFIC FUNCTIONALITY
+		void 	CmdGetAcmConfigL(const RMessage2& aMessage);
+		void 	CmdSetAcmConfigL(const RMessage2& aMessage);
+		
+		void 	CmdOpenCommPortL(const RMessage2& aMessage);
+		void 	CmdCloseCommPort(const RMessage2& aMessage);
+
+		void 	CmdRegisterProtocol(const RMessage2& aMessage);
+		void 	CmdUnRegisterProtocol(const RMessage2& aMessage);
+		
+		void 	CmdRegisterProtocolIdsL(const RMessage2& aMessage);
+		void 	CmdUnRegisterProtocolIdsL(const RMessage2& aMessage);
+		
+		void    CmdReadMsgL(const RMessage2& aMessage);
+		void 	CmdReadCancel(const RMessage2& aMessage);
+		
+		void 	CmdWriteMsgL(const RMessage2& aMessage);
+		void 	CmdWriteCancel(const RMessage2& aMessage);
+		void 	CmdDisconnect(const RMessage2& aMessage);
+		
+		void 	DoDisconnect();
+
+
+private:
+	/*
+	 * Used to transfer collections of objects between server and client.
+	 */
+	CBufBase*					iTransferBuffer;
+
+	RMessagePtr2			iBlockedRead;	
+	RMessagePtr2			iBlockedWrite;
+	TBool 					iPendingRead;
+	TBool 					iPendingWrite;
+	
+	TUint					iPendingReadBufferLength;
+	
+	COstBaseRouter* iOstRouter;
+	
+	RPointerArray<COstMessage>	iRecvMessageQueue;
+	RArray<TOstProtIds> iProtocolIds;
+};
+
+#endif //__DbgTrcSrvSession_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/logging.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __LOGGING_H__
+#define __LOGGING_H__
+
+#include <e32debug.h>
+
+
+//
+// Turn on this logging for debugging purposes when running with test code.  
+// If you turn on the logging either when tracing or while debugging, 
+// it won't work as the printf messages are handled both by trace core and debugger.
+//
+//#define _LOGGING_
+
+
+#ifdef _LOGGING_
+#define LOG_MSG(x) RDebug::Printf(x)
+#define LOG_MSG2(x, y) RDebug::Printf(x, y)
+#define LOG_MSG3(x, y, z) RDebug::Printf(x, y, z)
+#else
+#define LOG_MSG(x)
+#define LOG_MSG2(x, y)
+#define LOG_MSG3(x, y, z)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/ostbaserouter.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,519 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <e32debug.h>
+#include <e32base.h>
+#include <e32cons.h>
+
+#include "logging.h"
+#include "dbgtrcportmgr.h"
+#include "ostprotregistry.h"
+#include "portreader.h"
+#include "portwriter.h"
+#include "dbgtrcsrvsession.h"
+#include "ostmessage.h"
+#include "ostbaserouter.h"
+
+// Static functions
+
+//
+// Swap2
+//
+// Byte-swaps a 2-byte value.  Used to convert to/from little/big endian.
+//
+static TUint16 Swap2(TUint16 aSource)
+{
+	TUint16 dest = 0;
+	for (TInt i=0; i<2; i++)
+	{
+		dest <<= 8;
+		dest |= aSource & 0xFF;
+		aSource >>= 8;
+	}
+	
+	return dest;
+} 
+
+COstWriteMsgEntry* COstWriteMsgEntry::NewL(TDesC8& aMsg, CDbgTrcSrvSession* aMsgListener)
+{
+	LOG_MSG("COstWriteMsgEntry::NewL");
+
+	COstWriteMsgEntry* self = new(ELeave) COstWriteMsgEntry(aMsgListener);
+	CleanupStack::PushL(self);
+	self->ConstructL(aMsg);
+	CleanupStack::Pop(self);
+	return self;
+}
+
+COstWriteMsgEntry::COstWriteMsgEntry(CDbgTrcSrvSession* aMsgListener)
+: iMessage(NULL),
+  iWriteMsgListener(aMsgListener)
+{
+	LOG_MSG("COstWriteMsgEntry::COstWriteMsgEntry");
+
+
+}
+
+COstWriteMsgEntry::~COstWriteMsgEntry()
+{
+	LOG_MSG("COstWriteMsgEntry::~COstWriteMsgEntry");
+
+	SafeDelete(iMessage);
+	iWriteMsgListener = NULL; //don't delete the listener since we don't really own it.
+}
+
+void COstWriteMsgEntry::ConstructL(TDesC8& aMsg)
+{
+	LOG_MSG("COstWriteMsgEntry::ConstructL");
+
+	iMessage = COstMessage::NewL(aMsg);
+}
+
+
+COstBaseRouter*	COstBaseRouter::NewL()
+{
+	LOG_MSG("COstWriteMsgEntry::NewL");
+
+	COstBaseRouter* self = new(ELeave) COstBaseRouter;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+}
+
+COstBaseRouter::COstBaseRouter()
+: iPortManager(NULL),
+  iProtRegistry(NULL),
+  iWriteMsgListener(NULL),
+  iWriteMsgQueue(1)  
+{
+	LOG_MSG("COstBaseRouter::COstBaseRouter");
+
+}
+
+COstBaseRouter::~COstBaseRouter()
+{	
+	LOG_MSG("COstBaseRouter::~COstBaseRouter");
+
+	SafeDelete(iPortManager);
+	SafeDelete(iProtRegistry);
+	
+	iWriteMsgQueue.ResetAndDestroy();	
+	iWriteMsgQueue.Close();
+}
+
+void COstBaseRouter::ConstructL()
+{
+	LOG_MSG("COstBaseRouter::ConstructL");
+
+	iPortManager = CDbgTrcPortMgr::NewL();	
+	iProtRegistry = COstProtRegistry::NewL();
+	
+	// check the target endianness
+	TUint32	test;
+	TUint8 *byte_alias = (TUint8 *)&test;
+	
+	// Write a specific 4-byte sequence and then read it as
+	// a 32-bit word.  Big-endian systems yield one value and
+	// little-endian systems yield another.
+	
+	byte_alias[ 0 ] = 0x12;
+	byte_alias[ 1 ] = 0x34;
+	byte_alias[ 2 ] = 0x56;
+	byte_alias[ 3 ] = 0x78;
+	
+	if (test == 0x12345678)
+		iIsBigEndian = ETrue;
+	else
+		iIsBigEndian = EFalse;			
+	
+	iSendMsgBuffer.Zero();
+	iRecvMsgBuffer.Zero();
+	
+	iWriteMsgQueue.Reset();
+}
+
+void COstBaseRouter::RegisterProtocol(const TOstProtIds aProtId, CDbgTrcSrvSession* aProtMsgListener, TBool aNeedHeader)
+{
+	LOG_MSG("COstBaseRouter::RegisterProtocol");
+
+	iProtRegistry->RegisterProtocol(aProtId, aProtMsgListener, aNeedHeader);
+	
+	// Initiate the reads once someone registers a protocol.
+	//ReadMessage();
+}
+
+void COstBaseRouter::UnRegisterProtocol(const TOstProtIds aProtId)
+{
+	LOG_MSG("COstBaseRouter::UnRegisterProtocol");
+
+	iProtRegistry->UnRegisterProtocol(aProtId);
+	
+	// if listener count is 0, cancel the reads as well.
+	if (!iProtRegistry->GetProtListenerCount())
+	{
+		CPortReader* reader = iPortManager->GetPortReader();
+		if (reader)
+		{
+			reader->Cancel();
+		}
+	}	
+}
+
+
+void COstBaseRouter::ReadMessage()
+{	
+	LOG_MSG("COstBaseRouter::ReadMessage");
+
+	CPortReader* reader = iPortManager->GetPortReader();
+	
+	if (reader)
+		reader->StartRead(this);
+}
+
+
+void COstBaseRouter::WriteMessageL(TDesC8& aMsg, CDbgTrcSrvSession* aProtMsgListener)
+{
+	LOG_MSG("COstBaseRouter::WriteMessage");
+	
+	iSendMsgBuffer.Zero();
+	iSendMsgBuffer.Append(aMsg);
+			
+	DoWriteMessageL(aProtMsgListener);
+}
+
+void COstBaseRouter::WriteMessageL(TDesC8& aMsg, CDbgTrcSrvSession* aProtMsgListener, TOstProtIds aProtId)
+{
+	LOG_MSG("COstBaseRouter::WriteMessage");	
+	
+	// write now, we use a fixed size array for the write message,
+	// look below for the commented implementation if necessary in the future.
+	iSendMsgBuffer.Zero();
+
+	TUint16 msgLength = aMsg.Length();
+	
+	TUint8 version = OST_PROTOCOL_VERSION;		
+	
+	iSendMsgBuffer.Append(&version, sizeof(TUint8));
+	iSendMsgBuffer.Append((TUint8*)&aProtId, sizeof(TUint8));
+	
+	TUint16 temp = msgLength; 
+	if (!iIsBigEndian)
+		temp = Swap2(msgLength);
+		
+	iSendMsgBuffer.Append((TUint8*)&temp, sizeof(TUint16));
+			
+	// now append the msg data
+	iSendMsgBuffer.Append(aMsg);
+		
+	DoWriteMessageL(aProtMsgListener);
+}
+
+
+/*
+TInt COstBaseRouter::WriteMessage(TDesC8& aMsg, CDbgTrcSrvSession* aProtMsgListener, TOstProtIds aProtId)
+{	
+	HBufC8* msgBuffer = HBufC8::New(aMsg.Length() + OST_HEADER_LENGTH);
+	
+	TUint16 msgLength = aMsg.Length();
+	
+	TUint8 version = OST_PROTOCOL_VERSION;		
+	
+	msgBuffer->Des().Append(&version, sizeof(TUint8));
+	msgBuffer->Des().Append((TUint8*)&aProtId, sizeof(TUint8));
+	
+	TUint16 temp = msgLength; 
+	if (!iIsBigEndian)
+		temp = Swap2(msgLength);
+		
+	msgBuffer->Des().Append((TUint8*)&temp, sizeof(TUint16));
+			
+	// now append the msg data
+	msgBuffer->Des().Append(aMsg);
+	
+	
+}
+*/
+
+void COstBaseRouter::DoWriteMessageL(CDbgTrcSrvSession* aProtMsgListener)
+{
+	LOG_MSG("COstBaseRouter::DoWriteMessage");
+
+	CPortWriter* writer = iPortManager->GetPortWriter();
+	
+	if(writer)
+	{
+		if (writer->IsBusy())
+		{
+			LOG_MSG("Writer busy, queuing up the write message");
+
+			// we are already writing a message
+			// so queue up this one, we only have to queue up one message for each connected client for writing.
+			COstWriteMsgEntry* writeMsgEntry = COstWriteMsgEntry::NewL(iSendMsgBuffer, aProtMsgListener);
+			iWriteMsgQueue.Append(writeMsgEntry);
+		}
+		else
+		{
+			// set the write listener for completing the request when the write is done
+			iWriteMsgListener = aProtMsgListener;	
+			writer->StartWrite(iSendMsgBuffer, this);
+		}
+	}
+}
+
+void COstBaseRouter::DataAvailable(TDesC8& aMsgData, TUint aLength)
+{
+	LOG_MSG("COstBaseRouter::DataAvailable");
+	LOG_MSG2("Received bytes : %d", aLength);	
+
+	TInt remainingBytes = aMsgData.Length();
+	const TUint8* recvMsgDataPtr = aMsgData.Ptr();
+	while (remainingBytes > 0)
+	{	
+		TInt bytesToCopy = remainingBytes;
+		TInt spaceAvailable = MAX_BUF_SIZE-iRecvMsgBuffer.Length();
+		if (spaceAvailable == 0) //should never happen, if this happens, then we will loose messages.
+			return;
+			
+		if (remainingBytes > spaceAvailable)
+		{
+			bytesToCopy = spaceAvailable;
+		}
+		
+		remainingBytes -= bytesToCopy;		
+		iRecvMsgBuffer.Append(recvMsgDataPtr, bytesToCopy);
+		recvMsgDataPtr += bytesToCopy;
+							
+		LOG_MSG2("Bytes copied: %d", bytesToCopy);
+		LOG_MSG2("Remaining bytes : %d", remainingBytes);
+					
+		//
+		// We could possibly get more than one message at a time, 
+		// so check until we have atleast as many bytes as the OST header.
+		//
+		LOG_MSG2("Total bytes in the buffer : %d", iRecvMsgBuffer.Length());
+		while (iRecvMsgBuffer.Length() > OST_HEADER_LENGTH)
+		{
+			LOG_MSG("No of received bytes > OST header length");
+
+			const TUint8* ptr = iRecvMsgBuffer.Ptr();
+
+			TUint8 version = ptr[VERS_FIELD_INDEX];
+			TUint8 protId  = ptr[PROTID_FIELD_INDEX];
+			
+			// There could be some junk bytes in the data.
+			// With the latest PCSuite/USB cable drivers, there seems to be some 
+			// junk bytes in the USB channel. Also we can only do this simple check 
+			// only at the beginning of the packet. The only check we have right now 
+			// for the OST base protocol is to check for the version and the protocol id	
+			if ( !( (version == OST_PROTOCOL_VERSION || version == OST_VERSION_PROTOCOL_VERSION) &&
+				 (protId == EOstProtTrk || protId == EOstProtTraceCore || protId == EOstProtOstSystem || protId == EOstProtTrcActivation) ) )
+			{
+				LOG_MSG2("Invalid version byte: %x", version);
+				LOG_MSG2("Invalid protocol byte: %x", protId);
+				RemoveNonOstBytes(iRecvMsgBuffer);
+			}
+				
+			LOG_MSG2("Total bytes in the buffer after removing non ost : %d", iRecvMsgBuffer.Length());					
+			if (iRecvMsgBuffer.Length()>OST_HEADER_LENGTH)
+			{
+				// reset ptr just incase if we have deleted some junk bytes
+				ptr = iRecvMsgBuffer.Ptr();
+				TUint16 packetLength = 0;
+				SwapBytes((TUint8*)&packetLength, &ptr[LENGTH_FIELD_INDEX], 2);
+			
+				LOG_MSG2("packet length is %d", packetLength);			
+
+				if (iRecvMsgBuffer.Length() >= (packetLength+OST_HEADER_LENGTH))
+				{
+					LOG_MSG("Got one complete message");
+
+					// got one complete message, complete the message if someone is listening for this message.
+					TBool needHeader;
+					CDbgTrcSrvSession* protMsgListener = iProtRegistry->GetProtListenerForProtId((TOstProtIds)protId, needHeader);
+					
+					if (protMsgListener)
+					{
+						LOG_MSG("Found a listener");
+
+						TPtrC8 completeMessage;
+						// check to see if we need to strip the header or not.
+						if (needHeader)				
+							completeMessage.Set(iRecvMsgBuffer.Ptr(), packetLength+OST_HEADER_LENGTH);
+						else
+							completeMessage.Set(iRecvMsgBuffer.Ptr()+OST_HEADER_LENGTH, packetLength);
+							
+						TRAPD(err, protMsgListener->MessageAvailableL(completeMessage));
+						if (err != KErrNone)
+						    LOG_MSG2("Failed to deliver the message: %d", err);
+					}	
+				
+					LOG_MSG2("Deleting bytes in the recieve buffer: %d", packetLength+OST_HEADER_LENGTH);
+
+					// now remove this message from our buffer as its already given to the listener				
+					iRecvMsgBuffer.Delete(0, packetLength+OST_HEADER_LENGTH);
+					
+					LOG_MSG2("Remaining bytes in the recieve buffer: %d", iRecvMsgBuffer.Length());				
+				}
+				else
+				{
+					// We have more bytes than the header but we have an incomplete message.
+					// So we break out here.
+					break; 
+				}
+			}	
+		}
+	}
+}
+
+void COstBaseRouter::DataWriteComplete(TInt aErrCode)
+{		
+	LOG_MSG("COstBaseRouter::DataWriteComplete");
+
+	if (iWriteMsgListener != NULL)
+	{
+		iWriteMsgListener->WriteComplete(aErrCode);
+		iWriteMsgListener = NULL;
+	}
+	else
+	{
+		LOG_MSG("Invalid write message listener, should never happen");
+	}	
+	
+	if (iWriteMsgQueue.Count() > 0)
+	{
+		LOG_MSG("Message found in write queue");
+		
+		COstMessage* ostMsg = iWriteMsgQueue[0]->iMessage;
+		iWriteMsgListener = iWriteMsgQueue[0]->iWriteMsgListener;
+		HBufC8* msg = ostMsg->iMsgBuffer;
+		
+		CPortWriter* writer = iPortManager->GetPortWriter();
+		if(writer)
+			writer->StartWrite(*msg, this);
+		
+		// now remove the message from the queue
+		SafeDelete(iWriteMsgQueue[0]);			
+		iWriteMsgQueue.Remove(0);		
+	}
+}
+
+void COstBaseRouter::GetPortConfig(TDes8& aConfigDes)
+{
+	LOG_MSG("COstBaseRouter::GetPortConfig");
+
+	iPortManager->GetPortConfig(aConfigDes);
+}
+
+TInt COstBaseRouter::SetPortConfig(TDesC8& aConfigDes)
+{
+	LOG_MSG("COstBaseRouter::SetPortConfig");
+
+	return iPortManager->SetPortConfig(aConfigDes);
+}
+
+TInt COstBaseRouter::OpenCommPortL()
+{
+	LOG_MSG("COstBaseRouter::OpenCommPort");
+
+	return iPortManager->OpenPortL();
+}
+
+TInt COstBaseRouter::CloseCommPort()
+{
+	LOG_MSG("COstBaseRouter::CloseCommPort");
+	
+	return iPortManager->ClosePort();
+}
+
+
+void COstBaseRouter::SwapBytes(TUint8* aTrgtData, const TUint8* aSrcData, TInt aLength)
+{	
+	LOG_MSG("COstBaseRouter::SwapBytes");
+	
+	if (iIsBigEndian)
+	{
+		Mem::Copy(aTrgtData, aSrcData, aLength);
+	}
+	else
+	{
+		for (int i=aLength-1, j=0; i>=0; i--, j++)
+			aTrgtData[j] = aSrcData[i];
+	}		
+}
+
+
+void COstBaseRouter::RemoveNonOstBytes(TDes8& aMsgBuffer)
+{
+	LOG_MSG("COstBaseRouter::RemoveNonOstBytes");	
+	// We need to check for non OST bytes only in the beginning of the packet.
+	// The only check we have right now for the OST base protocol
+	// is to check for the version and the protocol id	
+	const TUint8* msgDataPtr = aMsgBuffer.Ptr(); 				
+	// look for the version byte..
+	// if found, bail out and check for protocol byte
+	TUint length = aMsgBuffer.Length();
+	LOG_MSG2("Total bytes in the buffer: %d", length);
+	for (TInt i=VERS_FIELD_INDEX; i<length; i++)
+	{			
+		if (msgDataPtr[VERS_FIELD_INDEX] == OST_PROTOCOL_VERSION ||
+			msgDataPtr[VERS_FIELD_INDEX] == OST_VERSION_PROTOCOL_VERSION)	
+		{
+			// If we have more than one byte and the first byte seems to be the version byte
+			// then check to see whether the second byte is the protocol byte or not.
+			// if not, then delete the two bytes and start looking for version byte in the remaining bytes
+			if (aMsgBuffer.Length()>1)
+			{
+				if (msgDataPtr[PROTID_FIELD_INDEX] == EOstProtTrk || 
+					msgDataPtr[PROTID_FIELD_INDEX] == EOstProtTraceCore  ||
+					msgDataPtr[PROTID_FIELD_INDEX] == EOstProtOstSystem ||
+					msgDataPtr[PROTID_FIELD_INDEX] == EOstProtTrcActivation)				
+				{
+					LOG_MSG("Found a valid packet");
+					break;					
+				}					
+				else
+				{
+					// we didn't find the version byte and the protocol byte together
+					// so delete the two bytes
+					LOG_MSG2("Deleting junk bytes, unexpected version: %x", msgDataPtr[VERS_FIELD_INDEX]);
+					LOG_MSG2("Deleting junk bytes, unexpected protocol id: %x", msgDataPtr[PROTID_FIELD_INDEX]);
+
+					aMsgBuffer.Delete(VERS_FIELD_INDEX, 2);
+					i++; //deleting more than one byte, so increment one more time here.
+				}					
+			}
+			else
+			{
+				// Special case handling when there is only one remaining byte 
+				// and that byte happens to be the version byte
+				// This could be an invalid byte from out of protocol data, just happens to be the version byte.
+				// So delete this byte as well just so that we don't treat this byte as the version byte by mistake.
+				LOG_MSG2("Deleting one remaining byte, unexpected version: %x", msgDataPtr[VERS_FIELD_INDEX]);
+				aMsgBuffer.Delete(VERS_FIELD_INDEX, 1);			
+			}
+		}
+		else
+		{
+			// if the first byte is not the version byte, delete it
+			// it could be out of protocol data, we just need throw away
+			LOG_MSG2("Deleting junk byte, unexpected version: %x", msgDataPtr[VERS_FIELD_INDEX]);
+			aMsgBuffer.Delete(VERS_FIELD_INDEX, 1);
+		}
+	}		
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/ostbaserouter.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __OstBaseRouter_h__
+#define __OstBaseRouter_h__
+
+// System includes
+#include <e32base.h>
+
+#include "datalistener.h"
+
+class CDbgTrcPortMgr;
+class CDbgTrcSrvSession;
+class COstProtRegistry;
+class COstMessage;
+
+class COstWriteMsgEntry : public CBase
+{
+	public:
+		static 	COstWriteMsgEntry*	NewL(TDesC8& aMsg, CDbgTrcSrvSession* aMsgListener);
+				~COstWriteMsgEntry();
+	
+	//private construct
+	private:
+				COstWriteMsgEntry(CDbgTrcSrvSession* aMsgListener);
+		void	ConstructL(TDesC8& aMsg);
+
+	public:	
+		COstMessage* iMessage;
+		CDbgTrcSrvSession* iWriteMsgListener;		
+};
+
+class COstBaseRouter : public CBase, MDataListener
+{
+	public:
+		static 	COstBaseRouter*	NewL();
+				~COstBaseRouter();
+	
+	//private construct
+	private:
+				COstBaseRouter();
+		void	ConstructL();		
+
+	public:
+	
+		void GetPortConfig(TDes8& aConfigDes);
+		TInt SetPortConfig(TDesC8& aConfigDes);
+
+		TInt OpenCommPortL();
+		TInt CloseCommPort();
+		
+		void RegisterProtocol(const TOstProtIds aProtId, CDbgTrcSrvSession* aProtMsgListener, TBool aStripHeader);
+		void UnRegisterProtocol(const TOstProtIds aProtId);
+		
+		void ReadMessage();
+		void WriteMessageL(TDesC8& aMsg, CDbgTrcSrvSession* aProtMsgListener);
+		void WriteMessageL(TDesC8& aMsg, CDbgTrcSrvSession* aProtMsgListener, TOstProtIds aProtId);
+
+		
+	public: // from MDataListener
+		void DataAvailable(TDesC8& aMsgData, TUint aLength);
+		void DataWriteComplete(TInt aErrCode);
+		
+	private:
+		void SwapBytes(TUint8* aTrgtData, const TUint8* aSrcData, TInt aLength);
+		void DoWriteMessageL(CDbgTrcSrvSession* aProtMsgListener);
+		void RemoveNonOstBytes(TDes8& aMsgBuffer);
+
+
+	// data members		
+	private:
+	
+		CDbgTrcPortMgr* iPortManager;
+		COstProtRegistry* iProtRegistry;
+		
+		CDbgTrcSrvSession* iWriteMsgListener;
+		
+		TBuf8<MAX_BUF_SIZE> iRecvMsgBuffer;
+		TBuf8<MAX_BUF_SIZE> iSendMsgBuffer;
+		
+		RPointerArray<COstWriteMsgEntry> iWriteMsgQueue;
+				
+		TBool iIsBigEndian;		
+};
+
+#endif //__OstBaseRouter_h__   
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/ostmessage.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "logging.h"
+#include "dbgtrccomm.h"
+#include "ostmessage.h"
+
+
+
+COstMessage* COstMessage::NewL(TDesC8& aMsg)
+{
+	LOG_MSG("COstMessage::NewL");
+
+	COstMessage* self = new(ELeave) COstMessage();
+	CleanupStack::PushL(self);
+	self->ConstructL(aMsg);
+	CleanupStack::Pop(self);
+	return self;
+}
+
+COstMessage::COstMessage()
+: iMsgBuffer(NULL)
+{
+	LOG_MSG("COstMessage::COstMessage");
+
+
+}
+
+COstMessage::~COstMessage()
+{
+	LOG_MSG("COstMessage::~COstMessage");
+
+	SafeDelete(iMsgBuffer);
+}
+
+void COstMessage::ConstructL(TDesC8& aMsg)
+{
+	LOG_MSG("COstMessage::ConstructL");
+
+	iMsgBuffer = aMsg.AllocL();		
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/ostmessage.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __OstMessage_h__
+#define __OstMessage_h__
+
+// System includes
+#include <e32base.h>
+#include "ostprotdefs.h"
+
+
+class COstMessage : public CBase
+{
+	public:
+		static 	COstMessage*	NewL(TDesC8& aMsg);
+				~COstMessage();
+	
+	//private construct
+	private:
+				COstMessage();
+		void	ConstructL(TDesC8& aMsg);
+
+	public:	
+		HBufC8 *iMsgBuffer;
+		TOstProtIds iProtId;
+		TUint iLength;
+};
+
+#endif //__OstMessage_h__   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/ostprotregistry.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <e32base.h>
+#include <e32cons.h>
+
+#include "logging.h"
+#include "ostprotregistry.h"
+
+COstProtRegistry*	COstProtRegistry::NewL()
+{
+	LOG_MSG("COstProtRegistry::NewL");
+	
+	COstProtRegistry* self = new(ELeave) COstProtRegistry;
+	return self;
+}
+
+COstProtRegistry::COstProtRegistry()
+{
+	LOG_MSG("COstProtRegistry::COstProtRegistry");
+
+	iProtListenerList.Reset();
+}
+
+COstProtRegistry::~COstProtRegistry()
+{
+	LOG_MSG("COstProtRegistry::~COstProtRegistry");
+
+	iProtListenerList.Close();
+}
+
+void COstProtRegistry::RegisterProtocol(const TOstProtIds aProtId, CDbgTrcSrvSession* aProtMsgListener, TBool aStripHeader)
+{
+	LOG_MSG("COstProtRegistry::RegisterProtocol");
+
+	TProtRegistryEntry protEntry(aProtId, aProtMsgListener, aStripHeader);
+	
+	iProtListenerList.Append(protEntry);	
+}
+
+
+void COstProtRegistry::UnRegisterProtocol(const TOstProtIds aProtId)
+{
+	LOG_MSG("COstProtRegistry::UnRegisterProtocol");
+
+	// remove this listener from our list
+	for (TInt i=0; i<iProtListenerList.Count(); i++)
+	{
+		if (iProtListenerList[i].iProtId == aProtId)
+		{
+			iProtListenerList.Remove(i);			
+			break;
+		}
+	}
+}
+
+TBool COstProtRegistry::IsHeaderNeedForProtId(TOstProtIds aProtId)
+{
+	LOG_MSG("COstProtRegistry::IsHeaderNeedForProtId");
+
+	for (TInt i=0; i<iProtListenerList.Count(); i++)
+	{
+		if (iProtListenerList[i].iProtId == aProtId)
+		{			
+			return iProtListenerList[i].iNeedHeader;
+		}
+	}
+	return EFalse;
+}
+
+CDbgTrcSrvSession* COstProtRegistry::GetProtListenerForProtId(const TOstProtIds aProtId, TBool& aNeedHeader)
+{
+	LOG_MSG("COstProtRegistry::GetProtListenerForProtId");
+
+	// remove this listener from our list
+	for (TInt i=0; i<iProtListenerList.Count(); i++)
+	{
+		if (iProtListenerList[i].iProtId == aProtId)
+		{
+			aNeedHeader = iProtListenerList[i].iNeedHeader;
+			return iProtListenerList[i].iProtListener;
+		}
+	}
+	return NULL;
+}
+
+TInt COstProtRegistry::GetProtListenerCount()
+{
+	LOG_MSG("COstProtRegistry::GetProtListenerCount");
+
+	return iProtListenerList.Count();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/ostprotregistry.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __OstProtRegistry_h__
+#define __OstProtRegistry_h__
+
+// System includes
+#include <e32base.h>
+#include "ostprotdefs.h"
+
+class CDbgTrcSrvSession;
+
+//
+// class TProtRegistryEntry
+//
+class TProtRegistryEntry
+{
+public:
+
+	inline TProtRegistryEntry(TOstProtIds aProtId, CDbgTrcSrvSession* aProtListener, TBool aNeedHeader)
+				: iProtId(aProtId),
+				  iProtListener(aProtListener),
+				  iNeedHeader(aNeedHeader) { }
+public:
+
+	TOstProtIds iProtId;
+	CDbgTrcSrvSession* iProtListener;
+	TBool iNeedHeader;	
+};
+
+class COstProtRegistry : public CBase
+{
+	public:
+		static 	COstProtRegistry*	NewL();
+				~COstProtRegistry();
+	
+	//private construct
+	private:
+				COstProtRegistry();
+
+	public:
+	
+		void RegisterProtocol(const TOstProtIds aProtId, CDbgTrcSrvSession* aProtMsgListener, TBool aStripHeader);
+		void UnRegisterProtocol(const TOstProtIds aProtId);
+		
+		TBool IsHeaderNeedForProtId(TOstProtIds aProtId);
+		CDbgTrcSrvSession* GetProtListenerForProtId(const TOstProtIds aProtId, TBool& aNeedHeader);
+		
+		TInt GetProtListenerCount();
+
+	// data members		
+	private:
+		RArray<TProtRegistryEntry> iProtListenerList;
+};
+
+#endif //__OstProtRegistry_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/ostwritemsgqueue.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "logging.h"
+#include "dbgtrccomm.h"
+#include "ostmessage.h"
+
+
+COstWriteMsgEntry* COstWriteMsgEntry::NewL(TDesC8& aMsg, CDbgTrcSrvSession* aMsgListener)
+{
+	LOG_MSG("COstWriteMsgEntry::NewL");
+
+	COstWriteMsgEntry* self = new(ELeave) COstWriteMsgEntry();
+	CleanupStack::PushL(self);
+	self->ConstructL(aMsg);
+	CleanupStack::Pop(self);
+	return self;
+}
+
+COstWriteMsgEntry::COstWriteMsgEntry(CDbgTrcSrvSession* aMsgListener)
+: iMessage(NULL),
+  iWriteMsgListener(aMsgListener)
+{
+	LOG_MSG("COstWriteMsgEntry::COstWriteMsgEntry");
+
+
+}
+
+COstWriteMsgEntry::~COstWriteMsgEntry()
+{
+	LOG_MSG("COstWriteMsgEntry::~COstWriteMsgEntry");
+
+	SafeDelete(iMessage);
+}
+
+void COstWriteMsgEntry::ConstructL(TDesC8& aMsg)
+{
+	LOG_MSG("COstWriteMsgEntry::ConstructL");
+
+	iMessage = new COstMessage(aMsg);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/ostwritemsgqueue.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __OstWriteMsgQueue_h__
+#define __OstWriteMsgQueue_h__
+
+// System includes
+#include <e32base.h>
+#include "OstProtDefs.h"
+
+
+class COstWriteMsgEntry : public CBase
+{
+	public:
+		static 	COstWriteMsgEntry*	NewL(TDesC8& aMsg, CDbgTrcSrvSession* aMsgListener);
+				~COstWriteMsgEntry();
+	
+	//private construct
+	private:
+				COstWriteMsgEntry();
+		void	ConstructL(TDesC8& aMsg);
+
+	public:	
+		COstMessage* iMessage;
+		CDbgTrcServSession* iWriteMsgListener;		
+};
+
+#endif //__OstWriteMsgQueue_h__   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/portreader.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <e32cons.h>
+#include <e32base.h>
+
+#include "logging.h"
+#include "portreader.h"
+
+
+
+CPortReader* CPortReader::NewL(RComm& aPort)
+{
+	LOG_MSG("CPortReader::NewL");
+
+	CPortReader* self = new(ELeave) CPortReader(aPort);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+}
+
+CPortReader::CPortReader(RComm& aPort) 
+: CActive(CActive::EPriorityStandard),
+  iPort(aPort),
+  iAlreadyReading(EFalse)
+{
+	LOG_MSG("CPortReader::CPortReader");
+
+}
+
+CPortReader::~CPortReader()
+{
+	LOG_MSG("CPortReader::~CPortReader");
+
+	Cancel();
+
+}
+
+void CPortReader::ConstructL()
+{
+	LOG_MSG("CPortReader::ConstructL");
+	
+	CActiveScheduler::Add(this);
+}
+
+void CPortReader::StartRead(MDataListener* aListener)
+{
+	LOG_MSG("CPortReader::StartRead");
+
+	if (iAlreadyReading)
+		return;
+	
+	iListener = aListener;
+	
+	IssueReadRequest();
+	iAlreadyReading = ETrue;
+}
+
+void CPortReader::IssueReadRequest()
+{
+	LOG_MSG("CPortReader::IssueReadRequest");
+
+	iNextReadChar = 0;
+	iReceivedChars.Zero();
+	iPort.ReadOneOrMore(iStatus, iReceivedChars);
+
+	SetActive();
+}
+
+void CPortReader::RunL()
+{
+	LOG_MSG("CPortReader::RunL");
+
+	// pass the data onto listener
+	if (iStatus.Int() == KErrNone && iListener)		
+		iListener->DataAvailable(iReceivedChars, iReceivedChars.Length());
+
+	// continue waiting for data
+	IssueReadRequest();	
+}
+
+void CPortReader::DoCancel()
+{	
+	LOG_MSG("CPortReader::DoCancel");
+
+	iPort.ReadCancel();
+	
+	iAlreadyReading = EFalse;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/portreader.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __PortReader_h__
+#define __PortReader_h__
+
+// System includes
+#include <e32base.h>
+#include <c32comm.h>
+
+#include "datalistener.h"
+
+
+class CPortReader : public CActive
+{
+
+	public:
+		static 	CPortReader*	NewL(RComm& aPort);
+				~CPortReader();
+	
+	//private construct
+	private:
+				CPortReader(RComm& aPort);
+		void	ConstructL();
+		void 	IssueReadRequest();
+
+	public:
+		void StartRead(MDataListener* aListener);
+		void RunL();
+		void DoCancel();
+
+	// data members		
+	private:
+		RComm iPort;
+				
+		TBuf8<MAX_BUF_SIZE> iReceivedChars;
+		TInt iNextReadChar;
+		
+		TBool iAlreadyReading;
+		
+		MDataListener* iListener;
+		
+
+};
+
+#endif //__PortMgr_h__   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/portwriter.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+
+#include <e32cons.h>
+
+#include "logging.h"
+#include "portwriter.h"
+
+
+
+CPortWriter* CPortWriter::NewL(RComm& aPort)
+{
+	LOG_MSG("CPortWriter::NewL");
+
+	CPortWriter* self = new(ELeave) CPortWriter(aPort);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+}
+
+CPortWriter::CPortWriter(RComm& aPort)
+: CActive(CActive::EPriorityStandard),
+  iPort(aPort),
+  iListener(NULL),
+  iAlreadyWriting(EFalse)
+{
+	LOG_MSG("CPortWriter::CPortWriter");
+
+
+}
+
+CPortWriter::~CPortWriter()
+{
+	LOG_MSG("CPortWriter::~CPortWriter");
+	Cancel();
+}
+
+void CPortWriter::ConstructL()
+{
+	LOG_MSG("CPortWriter::ConstructL");
+
+	CActiveScheduler::Add(this);
+}
+
+void CPortWriter::StartWrite(TDesC8& aMsg, MDataListener* aListener)
+{
+	LOG_MSG("CPortWriter::StartWrite");
+	iAlreadyWriting = ETrue;
+	iListener = aListener;
+	
+	iPort.Write(iStatus, aMsg);
+	
+	SetActive();	
+}
+
+void CPortWriter::RunL()
+{
+	LOG_MSG("CPortWriter::RunL");
+
+	iAlreadyWriting = EFalse;
+
+	if (iListener)
+		iListener->DataWriteComplete(iStatus.Int());
+	else
+		LOG_MSG("Invalid listener, something wrong");	
+}
+
+void CPortWriter::DoCancel()
+{
+	LOG_MSG("CPortWriter::DoCancel");
+
+	iPort.WriteCancel();
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/portwriter.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __PortWriter_h__
+#define __PortWriter_h__
+
+// System includes
+#include <e32base.h>
+#include <c32comm.h>
+
+#include "datalistener.h"
+
+
+class CPortWriter : public CActive
+{
+
+	public:
+		static 	CPortWriter*	NewL(RComm& aPort);
+				~CPortWriter();
+	
+	//private construct
+	private:
+				CPortWriter(RComm& aPort);
+		void	ConstructL();
+
+	public:
+		void StartWrite(TDesC8& aMsg, MDataListener* aListener);
+		void RunL();
+		void DoCancel();
+		TBool IsBusy() { return iAlreadyWriting; }
+
+	// data members		
+	private:	
+		RComm iPort;
+		MDataListener* iListener;
+
+		TBool iAlreadyWriting;
+
+
+};
+
+#endif //__PortWriter_h__   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/shutdowntimer.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "logging.h"
+#include "shutdowntimer.h"
+
+/**
+Constructor. Adds the timer to the thread's active scheduler,
+*/
+CShutdownTimer::CShutdownTimer()
+	:CTimer(KActivePriorityShutdown)
+	{
+	LOG_MSG("CShutdownTimer::CShutdownTimer()\n");
+	CActiveScheduler::Add(this);
+	}
+
+/**
+Initialisation of timer
+*/
+void CShutdownTimer::ConstructL()
+	{
+	LOG_MSG("CShutdownTimer::ConstructL()\n");
+	CTimer::ConstructL();
+	}
+
+/**
+Starts the timer which would expire after KShutdownDelay
+*/
+void CShutdownTimer::Start()
+	{
+	LOG_MSG("CShutdownTimer::Start()\n");
+	After(KShutdownDelay);
+	}
+
+/**
+Stops the active scheduler. Stopping the active scheduler effectively closes
+the server
+*/
+void CShutdownTimer::RunL()
+	{
+	LOG_MSG("CShutdownTimer::RunL()\n");
+	CActiveScheduler::Stop();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/server/shutdowntimer.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef _SHUTDOWNTIMER_H
+#define _SHUTDOWNTIMER_H
+
+/**
+@file
+@internalTechnology
+@prototype
+*/
+
+#include <e32base.h>
+
+const TInt KShutdownDelay = 1000000; // approx 1 second
+const TInt KActivePriorityShutdown = -1; // priority for shutdown AO
+
+/**
+Timer class used to manage shutdown of the server
+*/
+class CShutdownTimer : public CTimer
+{
+public:
+	CShutdownTimer();
+	void ConstructL();
+	void Start();
+private:
+	void RunL();
+};
+
+#endif // _SHUTDOWNTIMER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/test/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/test/dbgtrctest.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,252 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#include <e32base.h>
+#include <e32cons.h>
+
+#include "dbgtrccomm.h"
+#include "dummytraceserver.h"
+#include "dbgtrctest.h"
+
+LOCAL_C CConsoleIO* consoleIO = NULL;
+#define SafeDelete(x) { if (x) delete x; x = NULL; }
+
+
+
+CKeyboardInput::CKeyboardInput(CConsoleBase* aConsole)
+	: CActive(EPriorityUserInput),
+	  iConsole(aConsole)
+{
+	CActiveScheduler::Add(this);
+}
+
+CKeyboardInput::~CKeyboardInput()
+{
+	Cancel();
+	Deque();
+}
+
+
+void CKeyboardInput::ListenToKeyboard()
+{
+	iConsole->Read(iStatus);
+	SetActive();
+}
+
+void CKeyboardInput::RunL()
+{
+	TKeyCode key = iConsole->KeyCode();
+	if (key == 'q' || key == 'Q')
+		CActiveScheduler::Stop();
+	else
+		ListenToKeyboard();
+}
+
+void CKeyboardInput::DoCancel()
+{
+	iConsole->ReadCancel();
+}
+
+CConsoleIO::CConsoleIO()
+	: iConsole(0),
+	  iKeyboardInput(0)
+{
+	TRAPD(error, iConsole = Console::NewL(_L("DBGTRCTEST"), TSize(KConsFullScreen, KConsFullScreen)));
+	if (error != KErrNone)
+		User::Panic(_L("DBGTRCTEST failed to allocate CConsoleBase"), __LINE__);
+
+	iKeyboardInput = new CKeyboardInput(iConsole);
+	if (iKeyboardInput == 0)
+		User::Panic(_L("DBGTRCTEST failed to allocate CKeyboardInput"), __LINE__);
+
+	iKeyboardInput->ListenToKeyboard();
+}
+
+CConsoleIO::~CConsoleIO()
+{
+	SafeDelete(iKeyboardInput);
+	SafeDelete(iConsole);
+}
+
+//
+// CConsoleIO::PrintToScreen
+//
+//	Print a message to the screen
+//
+void CConsoleIO::PrintToScreen(TRefByValue<const TDesC> aFmt, ...)
+{
+	VA_LIST(l);
+	VA_START(l, aFmt);
+	iBuffer.FormatList(aFmt, l);
+
+	iConsole->Printf(iBuffer);
+}
+
+//
+// CConsoleIO::Terminating
+//
+//	Notify user of termination
+//
+void CConsoleIO::Terminating()
+{
+	iConsole->Printf(_L("\r\nPress any key to exit."));
+	iKeyboardInput->Cancel();
+	iConsole->Getch();
+}
+
+
+
+LOCAL_C void runBasicTests()
+{	
+	RDbgTrcComm acmPort;
+	
+	TInt err = acmPort.Connect();
+	if (err != KErrNone)
+	{
+		consoleIO->PrintToScreen(_L("Connect failed: %d"), err);
+		return;
+	}
+	consoleIO->PrintToScreen(_L("Successfully the DbgTrc Comms server\n"));
+
+	
+	err = acmPort.Open();
+	if (err != KErrNone)
+	{
+		consoleIO->PrintToScreen(_L("Opening port failed: %d\n"), err);
+		return;
+	}
+	consoleIO->PrintToScreen(_L("Successfully opened the DbgTrc Comm Port\n"));
+
+	
+	TAcmConfig config;	
+	err = acmPort.GetAcmConfig(config);
+	if (err != KErrNone)
+	{
+		consoleIO->PrintToScreen(_L("Unable to get port configuration: %d\n"), err);
+		return;
+	}
+	consoleIO->PrintToScreen(_L("Current ACM port number: %d\n"), config().iPortNumber);
+
+	err = acmPort.RegisterProtocolID(EOstProtTrk, EFalse);
+	if (err != KErrNone)
+	{
+		consoleIO->PrintToScreen(_L("Unable to register protocol: %d\n"), err);
+		return;
+	}
+	consoleIO->PrintToScreen(_L("Registered the protocol id: %d\n"), EOstProtTraceCore);
+	
+	TAcmConfigV01 config1(*(TAcmConfigV01*)config.Ptr());
+	
+	TBuf8<100> msg;
+	_LIT8(KTRACEMSG, "Test trace server message: %d\n");
+	
+	TRequestStatus status;
+	
+	for (TInt i=0; i<1000; i++)
+	{
+		msg.Format(KTRACEMSG, i);
+		acmPort.WriteMessage(status, msg, ETrue);
+		User::WaitForRequest(status);
+		
+		User::After(100);
+	}
+	
+	if (status.Int() != KErrNone)
+	{
+		consoleIO->PrintToScreen(_L("Unable to write the message: %d\n"), status.Int());
+		return;	
+	}
+	consoleIO->PrintToScreen(_L("Successfuly sent the message\n"));
+
+	err = acmPort.UnRegisterProtocolID(EOstProtTraceCore);
+	if (err != KErrNone)
+	{
+		consoleIO->PrintToScreen(_L("Unable to unregister protocol: %d\n"), err);
+		return;
+	}
+	consoleIO->PrintToScreen(_L("Successfuly unregistered the protocol id: %d\n"), EOstProtTraceCore);
+
+	
+	err = acmPort.Close();
+	if (err != KErrNone)
+	{
+		consoleIO->PrintToScreen(_L("Unable to close the port: %d\n"), err);
+		return;
+	}
+	consoleIO->PrintToScreen(_L("Successfuly closed the port\n"));
+}
+
+
+void MainL()
+{
+	//RProcess().SetPriority(EPriorityHigh);
+	//RThread().SetPriority(EPriorityAbsoluteHigh);
+	
+	consoleIO->PrintToScreen(_L("DBGTRCTEST App\r\n"));
+	
+	//runBasicTests();	
+	
+	CDummyTraceServer* traceServer = CDummyTraceServer::NewLC(consoleIO);
+	traceServer->Start();
+	consoleIO->PrintToScreen(_L("Press q or Q to quit\n"));
+
+	CActiveScheduler::Start();
+
+	CleanupStack::PopAndDestroy(traceServer);
+}
+
+//
+// EXE entrypoint
+//
+TInt E32Main()
+{	
+	__UHEAP_MARK;
+
+	CTrapCleanup* cleanupStack = CTrapCleanup::New();
+	if (cleanupStack == 0)
+		User::Panic(_L("DBGTRCTEST failed to allocate CTrapCleanup"), __LINE__);
+	
+	CActiveScheduler* scheduler = new CActiveScheduler;
+	if (scheduler == 0)
+		User::Panic(_L("DBGTRCTEST failed to allocate CActiveScheduler"), __LINE__);
+
+	CActiveScheduler::Install(scheduler);
+
+	consoleIO = new CConsoleIO;
+	
+	if (!consoleIO)
+		User::Panic(_L("DBGTRCTEST failed to allocate CTrkConsoleIO"), __LINE__);
+	
+	TRAPD(error, MainL());
+
+	if (error != KErrNone)
+	{
+		consoleIO->PrintToScreen(_L("\r\nUnexpected error %d"), error);
+		consoleIO->Terminating();
+	}
+	
+	SafeDelete(consoleIO);	
+	SafeDelete(scheduler);
+	SafeDelete(cleanupStack);
+
+	__UHEAP_MARKEND;
+
+	User::Exit(0);
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/test/dbgtrctest.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __DbgTrcTest_H__
+#define __DbgTrcTest_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include <e32cons.h>
+#include <hal.h>
+
+
+//
+// class CKeyboardInput
+//
+// Handles input from the keyboard
+//
+class CKeyboardInput : public CActive
+{
+public:
+
+	CKeyboardInput(CConsoleBase* aConsole);
+	~CKeyboardInput();
+
+	void ListenToKeyboard();
+
+protected:
+
+	void RunL();
+	void DoCancel();
+
+private:
+
+	CConsoleBase* iConsole;
+};
+
+
+//
+// class CConsoleIO
+//
+// Handles input and output from/to the console
+//
+class CConsoleIO : public CBase
+{
+public:
+
+	CConsoleIO();
+	~CConsoleIO();
+
+	void PrintToScreen(TRefByValue<const TDesC> aFmt, ...);
+	void Terminating();
+
+private:
+
+	CConsoleBase* iConsole;
+	CKeyboardInput* iKeyboardInput;
+	TBuf<50> iBuffer;
+};
+
+#endif // __DbgTrcTest_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/test/dbgtrctest_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+macro 		__S60__
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+TARGET        usbosttest.exe
+TARGETTYPE    exe
+UID           0x200159E1
+VENDORID VID_DEFAULT
+CAPABILITY 		ALL -TCB -DRM
+
+SOURCEPATH    .
+SOURCE       dbgtrctest.cpp dummytraceserver.cpp
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+  	SYSTEMINCLUDE	\epoc32\include
+  	USERINCLUDE 	..\inc
+#else
+    MW_LAYER_SYSTEMINCLUDE
+    USERINCLUDE 	../inc
+#endif
+
+LIBRARY       euser.lib usbostcomm.lib
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/test/dbgtrctest_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+
+TARGET        usbosttest.exe
+TARGETTYPE    exe
+UID           0x200159E1
+
+VENDORID 0x101FB657
+CAPABILITY 		ALL -TCB -DRM
+
+SOURCEPATH    .
+SOURCE       dbgtrctest.cpp dummytraceserver.cpp
+
+
+SYSTEMINCLUDE	/epoc32/include
+USERINCLUDE 	../inc
+
+
+LIBRARY       euser.lib usbostcomm.lib
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/test/dbgtrctest_uiq.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+
+TARGET        usbosttest.exe
+TARGETTYPE    exe
+UID           0x200159E1
+
+VENDORID 0x101FB657
+CAPABILITY 		ALL -TCB -DRM
+
+SOURCEPATH    .
+SOURCE       dbgtrctest.cpp dummytraceserver.cpp
+
+
+SYSTEMINCLUDE	\epoc32\include
+USERINCLUDE 	..\inc
+
+
+LIBRARY       euser.lib usbostcomm.lib
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/test/dummytraceserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,151 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "dummytraceserver.h"
+
+_LIT8(KTRACEMSG, "Test trace server message: %d\n");
+
+//
+//
+// CDummyTraceServer implementation
+//
+//
+
+CDummyTraceServer*	CDummyTraceServer::NewLC(CConsoleIO* aConsoleIO)
+{
+	CDummyTraceServer* self = new(ELeave) CDummyTraceServer(aConsoleIO);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	
+	return self;
+}
+
+CDummyTraceServer::CDummyTraceServer(CConsoleIO* aConsoleIO)
+	: CActive(EPriorityLow),
+	  iConsoleIO(aConsoleIO),
+	  iMessageId(0)
+	  
+{
+	CActiveScheduler::Add(this);
+}
+
+void CDummyTraceServer::ConstructL()
+{
+	User::LeaveIfError(iTimer.CreateLocal());
+}
+
+CDummyTraceServer::~CDummyTraceServer()
+{
+	
+}
+
+void CDummyTraceServer::Start()
+{
+	
+	TInt err = iAcmPort.Connect();
+	if (err != KErrNone)
+	{
+		iConsoleIO->PrintToScreen(_L("Connect failed: %d"), err);
+		return;
+	}
+	iConsoleIO->PrintToScreen(_L("Successfully the DbgTrc Comms server\n"));
+
+	
+	err = iAcmPort.Open();
+	if (err != KErrNone)
+	{
+		iConsoleIO->PrintToScreen(_L("Opening port failed: %d\n"), err);
+		return;
+	}
+	iConsoleIO->PrintToScreen(_L("Successfully opened the DbgTrc Comm Port\n"));
+
+	
+	TAcmConfig config;	
+	err = iAcmPort.GetAcmConfig(config);
+	if (err != KErrNone)
+	{
+		iConsoleIO->PrintToScreen(_L("Unable to get port configuration: %d\n"), err);
+		return;
+	}
+	iConsoleIO->PrintToScreen(_L("Current ACM port number: %d\n"), config().iPortNumber);
+
+	err = iAcmPort.RegisterProtocolID(EOstProtTraceCore, EFalse);
+	if (err != KErrNone)
+	{
+		iConsoleIO->PrintToScreen(_L("Unable to register protocol: %d\n"), err);
+		return;
+	}
+	iConsoleIO->PrintToScreen(_L("Registered the protocol id: %d\n"), EOstProtTraceCore);
+		
+	Activate();
+	
+	iConsoleIO->PrintToScreen(_L("Started sending dummy traces\n"));
+}
+
+void CDummyTraceServer::SendMessage()
+{
+	TBuf8<100> msg;
+	TRequestStatus status;
+		
+	msg.Format(KTRACEMSG, iMessageId++);
+	iAcmPort.WriteMessage(status, msg, EFalse);
+	User::WaitForRequest(status);
+}
+
+void CDummyTraceServer::Activate()
+{
+	iTimer.After(iStatus, KPeriod);
+	SetActive();		
+}
+
+
+
+void CDummyTraceServer::RunL()
+{
+	// now send the message
+	SendMessage();
+	// reactivate the timer
+	Activate();
+}
+
+void CDummyTraceServer::DoCancel()
+{
+	iTimer.Cancel();
+
+    Cancel();
+    iTimer.Close();
+    Deque();
+
+    TInt err = iAcmPort.UnRegisterProtocolID(EOstProtTraceCore);
+    if (err != KErrNone)
+    {
+        iConsoleIO->PrintToScreen(_L("Unable to unregister protocol: %d\n"), err);
+        return;
+    }
+    iConsoleIO->PrintToScreen(_L("Successfuly unregistered the protocol id: %d\n"), EOstProtTraceCore);
+
+    
+    err = iAcmPort.Close();
+    if (err != KErrNone)
+    {
+        iConsoleIO->PrintToScreen(_L("Unable to close the port: %d\n"), err);
+        return;
+    }
+    iConsoleIO->PrintToScreen(_L("Successfuly closed the port\n"));
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dbgtrccomm/test/dummytraceserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#ifndef __DBGTRCTESTTIMER_H__
+#define __DBGTRCTESTTIMER_H__
+
+#include <e32base.h>
+#include "dbgtrctest.h"
+#include "dbgtrccomm.h"
+//
+// class CDummyTraceServer
+//
+// Active object used to avoid auto-switch off
+//
+class CDummyTraceServer: public CActive
+{
+public:
+	static CDummyTraceServer*	NewLC(CConsoleIO* aConsoleIO);	
+	void ConstructL();
+	~CDummyTraceServer();
+	void Start();
+
+protected:
+	void RunL();
+	void DoCancel();
+	
+private:
+	CDummyTraceServer(CConsoleIO* aConsoleIO);
+	void Activate();
+	void SendMessage();
+
+private:
+
+	enum { KPeriod = 5 * 10 };
+	
+	CConsoleIO* iConsoleIO;
+
+	RTimer iTimer;	
+	RDbgTrcComm iAcmPort;
+	
+	TUint iMessageId;
+};
+
+#endif //__DBGTRCTESTTIMER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dccdriver/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dccdriver/TrkDccComm.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,135 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKDCCCOMM_H__
+#define __TRKDCCCOMM_H__
+
+//
+// class TCapsTrkDccDriver
+//
+class TCapsTrkDccDriver
+{
+public:
+	TVersion	iVersion;
+};
+
+
+
+
+//
+// class RTrkDccDriver
+//
+class RTrkDccDriver : public RBusLogicalChannel
+{
+public:
+
+	enum TControl
+	{
+		EControlWrite = 0,
+	};
+	
+	enum TRequest
+	{
+		ERequestRead=0x0, ERequestReadCancel=0x1,
+		ERequestWrite=0x1,ERequestWriteCancel=0x2,
+	};	
+		
+public:
+
+	inline TInt Open();
+	inline void Read(TRequestStatus &aStatus, TDes8 &aDes);
+	inline void Read(TRequestStatus &aStatus, TDes8 &aDes, TInt aLength);
+	inline void ReadOneOrMore(TRequestStatus &aStatus, TDes8 &aDes);
+	inline void ReadCancel();
+	inline void Write(TRequestStatus &aStatus, const TDesC8 &aDes);
+	inline void Write(TRequestStatus &aStatus, const TDesC8 &aDes, TInt aLength);
+	inline TInt Write(const TDesC8 &aDes);
+	inline TInt Write(const TDesC8 &aDes, TInt aLength);
+	inline void WriteCancel();
+
+};
+
+
+_LIT(KTrkDccDriverName,"TrkDcc Driver");
+
+// Version information
+const TInt KMajorDccVersionNumber=1;
+const TInt KMinorDccVersionNumber=0;
+const TInt KBuildDccVersionNumber=0;
+
+
+inline TInt RTrkDccDriver::Open()
+{
+	#ifdef EKA2
+	return DoCreate(KTrkDccDriverName, TVersion(KMajorDccVersionNumber, KMinorDccVersionNumber, KBuildDccVersionNumber), KNullUnit, NULL, NULL);
+	#else
+	return DoCreate(KTrkDccDriverName, TVersion(KMajorDccVersionNumber, KMinorDccVersionNumber, KBuildDccVersionNumber), NULL, KNullUnit, NULL, NULL);
+	#endif
+}
+
+inline void RTrkDccDriver::Read(TRequestStatus &aStatus, TDes8 &aDes)
+{
+	TInt len = aDes.MaxLength();
+	DoRequest(ERequestRead, aStatus, &aDes, &len);
+}
+
+inline void RTrkDccDriver::Read(TRequestStatus &aStatus, TDes8 &aDes, TInt aLength)
+{
+	DoRequest(ERequestRead, aStatus, &aDes, &aLength);
+}
+
+inline void RTrkDccDriver::ReadOneOrMore(TRequestStatus &aStatus, TDes8 &aDes)
+{
+	TInt len = (-aDes.MaxLength());
+	DoRequest(ERequestRead, aStatus, &aDes, &len);
+}
+
+inline void RTrkDccDriver::ReadCancel()
+{
+	DoCancel(ERequestReadCancel);
+}
+
+inline void RTrkDccDriver::Write(TRequestStatus &aStatus, const TDesC8 &aDes)
+{ 
+	TInt len=aDes.Length();
+	DoRequest(ERequestWrite, aStatus, (TAny *)&aDes, &len);
+}
+
+inline void RTrkDccDriver::Write(TRequestStatus &aStatus, const TDesC8 &aDes, TInt aLength)
+{
+	DoRequest(ERequestWrite, aStatus, (TAny *)&aDes, &aLength);
+}
+
+inline TInt RTrkDccDriver::Write(const TDesC8 &aDes)
+{ 
+	TInt len=aDes.Length();
+	return DoControl(EControlWrite, reinterpret_cast<TAny*>(len), (TAny*)&aDes);
+}
+
+inline TInt RTrkDccDriver::Write(const TDesC8 &aDes, TInt aLength)
+{
+	return DoControl(EControlWrite, reinterpret_cast<TAny*>(aLength), (TAny*)&aDes);
+}
+
+inline void RTrkDccDriver::WriteCancel()
+{
+	DoCancel(ERequestWriteCancel);
+}
+
+
+#endif // __TRKDCCCOMM_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dccdriver/TrkDccDriver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,553 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifdef __WINS__
+#error - this driver cannot be built for emulation
+#endif
+
+#include <e32def.h>
+#include <e32cmn.h>
+#include <kernel.h>
+#include <kern_priv.h>
+#include <arm.h>
+
+#include "TrkDccComm.h"
+#include "TrkDccDriver.h"
+
+//This macro turns on DCC3 mode, this is always turned on.
+//To test DCC1 mode, comment this out and make sure to configure T32 to use DCC1 as well.
+#define DCC3
+
+//currenly both start and end bytes for the packet are the same
+#define PKT_STRT_BYTE 0x7E
+#define PKT_END_BYTE 0x7E
+
+#define KTrkAppSecurUid 0x200170BB
+#define KTrkExeSecurUid 0x200159E2
+//
+// Static function definitions
+//
+
+
+//
+//
+// DTrkDccDriverFactory implementation
+//
+//
+
+//
+// DTrkDccDriverFactory constructor
+//
+DTrkDccDriverFactory::DTrkDccDriverFactory()
+{
+    iVersion = TVersion(KMajorDccVersionNumber, KMinorDccVersionNumber, KBuildDccVersionNumber);    
+}
+
+//
+// DTrkDccDriverFactory::Create
+//
+TInt DTrkDccDriverFactory::Create(DLogicalChannelBase*& aChannel)
+{
+	if (iOpenChannels != 0)
+		return KErrInUse; // a channel is already open
+	
+	aChannel = new DTrkDccChannel(this);
+	
+	return aChannel ? KErrNone : KErrNoMemory;
+}
+
+//
+// DTrkDccDriverFactory::Install
+//
+TInt DTrkDccDriverFactory::Install()
+{
+    return(SetName(&KTrkDccDriverName));
+}
+
+//
+// DTrkDccDriverFactory::Install
+//
+void DTrkDccDriverFactory::GetCaps(TDes8& aDes) const
+{
+    TCapsTrkDccDriver b;
+    b.iVersion = TVersion(KMajorDccVersionNumber, KMinorDccVersionNumber, KBuildDccVersionNumber);
+    
+    Kern::InfoCopy(aDes,(TUint8*)&b, sizeof(b));
+}
+
+
+//
+//
+// DTrkDccChannel implementation
+//
+//
+
+//
+// DTrkDccChannel constructor
+//
+DTrkDccChannel::DTrkDccChannel(DLogicalDevice* aLogicalDevice)
+				: iRxTimer(DTrkDccChannel::RxTimerCallBack, this),
+				  iRxBufSize(MAXMESSAGESIZE*2),
+				  iRxGetIndx(0),
+				  iRxPutIndx(0),
+				  iRxCompleteDfc(DTrkDccChannel::RxTimerDfc, this, 2),
+				  iInterruptId(76),
+				  iPacketStarted(EFalse),
+				  iPacketEnded(EFalse)
+
+
+{
+	LOG_MSG("DTrkDccChannel::DTrkDccChannel()");
+
+	iDevice = aLogicalDevice;
+	
+	iClientThread = &Kern::CurrentThread();
+	TInt err = iClientThread->Open();	
+	
+	iRxTimeOut = NKern::TimerTicks(1); 
+}
+
+//
+// DTrkDccChannel destructor
+//
+DTrkDccChannel::~DTrkDccChannel()
+{
+	LOG_MSG("DTrkDccChannel::~DTrkDccChannel()");
+
+	iRxTimer.Cancel();
+	
+	if (iRxBuffer)
+	{
+		delete iRxBuffer;
+		iRxBuffer = NULL;
+	}
+	if (iLock)
+		iLock->Close(NULL);
+
+	Kern::SafeClose((DObject*&)iClientThread, NULL);	
+}
+
+//
+// DTrkDccChannel::DoCreate
+//
+TInt DTrkDccChannel::DoCreate(TInt /*aUnit*/, const TDesC* /*anInfo*/, const TVersion& aVer)
+{
+	LOG_MSG("DTrkDccChannel::DoCreate()");
+
+  	if (!Kern::QueryVersionSupported(TVersion(KMajorDccVersionNumber, KMinorDccVersionNumber, KBuildDccVersionNumber), aVer))
+		return KErrNotSupported; 
+
+	//Setup the driver for receiving client messages
+	iDFCQue = NULL;
+	TBuf8<KMaxInfoName> dccDFC = _L8("DCC DFC");;
+	
+	TInt err = Kern::DfcQCreate(iDFCQue, 27, &dccDFC);
+	if (err == KErrNone)
+	{
+		SetDfcQ(iDFCQue);
+	}
+	else
+	{
+		SetDfcQ(Kern::DfcQue0());
+	}
+
+	iMsgQ.Receive();  	
+	
+	iRxCompleteDfc.SetDfcQ(Kern::TimerDfcQ());
+	
+	iRxBuffer=(TUint8*)Kern::Alloc(iRxBufSize);
+
+	err = Kern::SemaphoreCreate(iLock, _L("TrkDccDriverWriteLock"), 1 /* Initial count */);
+	if (err != KErrNone)
+		return err;
+
+	return KErrNone;
+}
+
+//
+// DTrkDccChannel::DoCancel
+//
+void DTrkDccChannel::DoCancel(TInt aReqNo)
+{
+	LOG_MSG("DTrkDccChannel::DoCancel()");
+	
+	switch(aReqNo)
+	{
+		case RTrkDccDriver::ERequestReadCancel:
+		{
+			Kern::RequestComplete(iClientThread, iRxRequestStatus, KErrCancel);
+			iRxClientBuffer = NULL;
+			iRxRequestStatus = NULL;
+			iRxClientBufferLength = 0;
+			
+			iRxTimer.Cancel();
+		}
+		break;
+	}
+
+}
+
+//
+// DTrkDccChannel::DoRequest
+//
+void DTrkDccChannel::DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2)
+{
+	LOG_MSG("DTrkDccChannel::DoRequest()");
+		
+	switch(aReqNo)
+	{
+		case RTrkDccDriver::ERequestRead:
+		{
+			iRxRequestStatus = aStatus;
+			iRxClientBuffer = a1;
+			iRxClientBufferLength = (TUint32)a2;
+			//start the polling timer...
+			iRxTimer.OneShot(iRxTimeOut);
+			break;
+		}		
+		default:
+			Kern::RequestComplete(iClientThread, aStatus, KErrNotSupported);
+	}
+}
+
+//
+// DTrkDccChannel::DoControl
+//
+TInt DTrkDccChannel::DoControl(TInt aFunction, TAny* a1, TAny* a2)
+{
+	LOG_MSG("DTrkDccChannel::DoControl()");
+	
+	TInt err = KErrNone;
+	
+	switch(aFunction)
+	{
+		case RTrkDccDriver::EControlWrite:
+		{
+			//lock the Semaphore so that write doesn't happen when a write is already in progress.
+			Kern::SemaphoreWait(*iLock);
+			err = DoWrite((TUint32)a1, a2);			
+			Kern::SemaphoreSignal(*iLock);			
+			break;
+		}
+		default:
+		{
+			return KErrGeneral;
+		}
+
+	}
+	if (KErrNone != err)
+	{
+		LOG_MSG2("Error %d from control function", err);
+	}
+	return err;
+}
+
+//
+// DTrkDccChannel::HandleMsg
+//
+void DTrkDccChannel::HandleMsg(TMessageBase* aMsg)
+{
+	LOG_MSG("DTrkDccChannel::HandleMsg()");
+	
+	TThreadMessage& m = *(TThreadMessage*)aMsg;
+	TInt id = m.iValue;
+
+
+	if (id == (TInt)ECloseMsg)
+	{
+		m.Complete(KErrNone, EFalse);
+		return;
+	}
+
+	if (id == KMaxTInt)
+	{
+		// DoCancel
+		DoCancel(m.Int0());
+		m.Complete(KErrNone, ETrue); 
+		return;
+	}
+
+	if (id < 0)
+	{
+		// DoRequest
+		TRequestStatus* pStatus = (TRequestStatus*)m.Ptr0();
+		DoRequest(~id, pStatus, m.Ptr1(), m.Ptr2());
+		m.Complete(KErrNone, ETrue);
+	}
+	else
+	{
+		// DoControl
+		TInt err = DoControl(id, m.Ptr0(), m.Ptr1());
+		m.Complete(err, ETrue);
+	}
+}
+
+//
+// DTrkDccChannel::DoWrite
+//
+TInt DTrkDccChannel::DoWrite(TUint32 aLength, TAny* a2)
+{
+	LOG_MSG("DTrkDccChannel::DoWrite()");
+
+	TInt err = KErrNone;
+
+	err = Kern::ThreadDesRead(iClientThread, a2, iTxBuffer, 0, KChunkShiftBy0);
+
+	if (err == KErrNone)
+	{	
+		err = WriteDccChannel(iTxBuffer);
+	}
+	return err;
+}
+
+//
+// DTrkDccChannel::DoRead
+//
+TInt DTrkDccChannel::DoRead()
+{	
+	TInt err = KErrNone;
+	
+	ReadDccChannel();
+
+	if (iRxPutIndx != iRxGetIndx)
+	{
+		if (iPacketEnded)
+		{
+			iPacketStarted = EFalse;
+			iPacketEnded = EFalse;
+		}
+		//there is some data, complete the read request if there is one pending
+		DoCompleteRx();
+		
+		if (iRxPutIndx == iRxGetIndx)
+		{
+			iRxPutIndx = iRxGetIndx = 0;
+		}
+	}
+	else
+	{
+		err = -1;
+		//start the timer again since we didn't complete the request
+		iRxTimer.OneShot(iRxTimeOut);
+	}
+	
+	return err;			
+}
+
+//
+// DTrkDccChannel::WriteDccChannel
+//
+// This function writes all the data in the descriptor word by word.
+// DCC3 mode is used for transferring the data to the DCC channel.
+// With DCC3, the number of bytes in the word is encoded in its MSB.
+// DCC3 mode can be turned of by commenting the DCC3 macro at the 
+// beginning of this file.
+//
+TInt DTrkDccChannel::WriteDccChannel(const TDesC8& aDes)
+{
+	TInt err = KErrNone;
+	
+	const TText8* pStart = aDes.Ptr();
+	const TText8* pEnd = pStart + aDes.Length();
+	if (pStart != pEnd)
+	{
+		while (pStart < pEnd)
+		{			
+			TUint retries = 10;
+
+		#ifdef DCC3
+			TUint32 data = 0;
+			//for DCC3 support
+			if ((pEnd-pStart) >= 3)
+			{
+				data = ((TUint32)(*pStart++)) | ((TUint32)(*pStart++))<<8 | ((TUint32)(*pStart++))<<16 | (0x02<<24);
+			}
+			else if ((pEnd-pStart) == 2)
+			{
+				data = ((TUint32)(*pStart++)) | ((TUint32)(*pStart++))<<8 |  (0x01<<24);
+			}
+			else if ((pEnd-pStart) == 1)
+			{
+				data = (TUint32)(*pStart++);
+			}
+		#endif
+			
+			while (retries--)
+			{
+			#ifdef DCC3
+				err = Arm::DebugOutJTAG(data);		
+			#else
+				err = Arm::DebugOutJTAG(*pStart);		
+			#endif
+				
+				//if we get timeout error, try three times sending the same byte
+				if (err == KErrTimedOut)
+				{
+					LOG_MSG("Write timed out, trying again\n");
+					continue;
+				}
+				else
+					break;
+			}
+			if (err)
+			{
+				LOG_MSG2("WriteDccChannel() failed %d", err);
+				return err;
+			}
+			
+		#ifndef DCC3
+			pStart++;
+		#endif
+		
+		}
+	}
+	return err;
+}
+
+//
+// DTrkDccChannel::ReadDccChannel
+//
+// Strictly reads packet by packets since TRK expects the host debugger 
+// to wait for the response for the cmd sent. 
+// This function will return if 
+// 	- the packet is completely read
+//  - if out of band data, i.e. data not conforming to TRK protocol packets
+//	- if an error other than KErrNotReady happens in while in the middle of 
+//    reading a packet.
+// Also the function uses DCC3 mode, where the no of bytes sent in the word
+// is encoded in the MSB and the actual data bytes in the remaining bytes.
+// Like for sending three bytes, the word will be 0x02CCBBAA.
+// For sending three bytes, the MSB should be 2.
+// For two bytes, the MSB should be 1.
+// For one bytes, the MSB should be 0.
+//
+void DTrkDccChannel::ReadDccChannel()
+{
+	TInt err = KErrNone;
+	TInt err1 = KErrNone;
+	
+	TUint i = iRxPutIndx;
+	TUint32 data;
+	
+	err = err1 = Arm::DebugInJTAG(data);	
+	while (KErrNone == err)
+	{	
+		if (KErrNone == err1)
+		{	
+			TUint8 nBytes = 0;
+			nBytes = TUint8(data>>24);
+			
+			for (int j=0; j<=nBytes; j++)
+			{									
+				iRxBuffer[i] = (TUint8)(data>>(j*8));	
+				if (iRxBuffer[i] == PKT_STRT_BYTE)	
+				{
+					if (!iPacketStarted)
+					{
+						iPacketStarted = ETrue;
+					}
+					else
+					{
+						iPacketEnded = ETrue;
+					}
+				}
+				i++; //increment i here so that put index can be appriopriately set later 
+			}
+			
+			if (i == iRxBufSize)
+			{
+				i = 0;
+				break;
+			}
+			//if cmd packet ended, send the data to the engine.
+			if (iPacketEnded)
+			{
+				break;
+			}
+		}
+
+		//read again to see if there is data already available
+		err = err1 = Arm::DebugInJTAG(data);	
+		
+		//if the packet is started, try to read the whole packet
+		//so set the err value to KErrNone so that we can continue reading
+		if ((err == KErrNotReady) && iPacketStarted && !iPacketEnded)
+			err = KErrNone; 				
+			
+		if (err != KErrNone && err != KErrNotReady)
+			LOG_MSG2("Read Error %d\n", err);
+	}
+
+	iRxPutIndx=i;	
+}
+
+//
+// DTrkDccChannel::RxTimerCallBack
+//
+void DTrkDccChannel::RxTimerCallBack(TAny* aPtr)
+{
+	// called from ISR when timer completes
+	DTrkDccChannel *pChannel = (DTrkDccChannel*)aPtr;
+	pChannel->iRxCompleteDfc.Add();
+}
+
+//
+// DTrkDccChannel::RxTimerDfc
+//
+void DTrkDccChannel::RxTimerDfc(TAny* aPtr)
+{
+	DTrkDccChannel *pChannel = (DTrkDccChannel*)aPtr;	
+	pChannel->DoRead();
+}
+
+//
+// DTrkDccChannel::DoCompleteRx
+//
+void DTrkDccChannel::DoCompleteRx()
+{
+	LOG_MSG("DTrkDccChannel::DoCompleteRx()");
+
+	if (iRxRequestStatus)
+	{
+		TInt avail = 0;
+		if (iRxPutIndx > iRxGetIndx) 
+			avail = iRxPutIndx-iRxGetIndx;
+		else
+			avail = iRxBufSize-iRxGetIndx;
+			
+		TInt len = Min(avail, iRxClientBufferLength);
+		
+		TPtrC8 des(iRxBuffer+iRxGetIndx, len);
+		
+		TInt err = Kern::ThreadDesWrite(iClientThread, iRxClientBuffer, des, 0, KChunkShiftBy0, iClientThread);
+
+		Kern::RequestComplete(iClientThread, iRxRequestStatus, err);
+		
+		iRxRequestStatus = NULL;
+		iRxGetIndx += len;
+	}
+			
+	if (iRxGetIndx >= iRxBufSize)
+		iRxGetIndx = 0;
+}
+
+
+DECLARE_STANDARD_LDD()
+{
+    return new DTrkDccDriverFactory;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dccdriver/TrkDccDriver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKDCCDRIVER_H__
+#define __TRKDCCDRIVER_H__
+
+// Debug messages
+#ifdef _DEBUG
+#define LOG_MSG(x) Kern::Printf(x)
+#define LOG_MSG2(x, y) Kern::Printf(x, y)
+#else
+#define LOG_MSG(x)
+#define LOG_MSG2(x, y)
+#endif
+
+
+//
+// Macros
+//
+#define MAXMESSAGESIZE	0x0880
+
+//
+// class DTrkDccDriverFactory
+//
+class DTrkDccDriverFactory : public DLogicalDevice
+{
+public:
+
+	DTrkDccDriverFactory();
+	virtual TInt Install();
+	virtual void GetCaps(TDes8& aDes) const;
+	virtual TInt Create(DLogicalChannelBase*& aChannel);
+};
+
+//
+// DTrkDccChannel
+//
+class DTrkDccChannel : public DLogicalChannel
+{
+public:
+
+	DTrkDccChannel(DLogicalDevice* aLogicalDevice);
+	~DTrkDccChannel();
+
+	virtual TInt DoCreate(TInt aUnit, const TDesC* anInfo, const TVersion& aVer);	
+	virtual void HandleMsg(TMessageBase* aMsg);
+	
+	
+protected:
+	virtual void DoCancel(TInt aReqNo);
+	virtual void DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
+	virtual TInt DoControl(TInt aFunction, TAny *a1, TAny *a2);
+	
+	
+private:
+	TInt DoWrite(TUint32 aLength, TAny* a2);
+	TInt DoRead();
+
+	TInt WriteDccChannel(const TDesC8& aDes);
+	void ReadDccChannel();
+
+	void DoCompleteRx();
+	
+	static void RxTimerDfc(TAny* aPtr);
+	static void RxTimerCallBack(TAny* aPtr);
+		
+private:
+	DThread* iClientThread;
+	
+	TRequestStatus* iRequestGetEventStatus;
+
+	NTimer iRxTimer;
+	
+	TBuf8<MAXMESSAGESIZE> iTxBuffer;
+	//TBuf8<MAXMESSAGESIZE*2> iRxBuffer;
+	TUint8 *iRxBuffer;
+	TInt iRxBufSize;
+	
+	TRequestStatus* iRxRequestStatus;
+	TAny* iRxClientBuffer;
+	TUint32 iRxClientBufferLength;
+	TInt iRxGetIndx, iRxPutIndx;
+	
+	TDfc iRxCompleteDfc;
+
+	TInt iInterruptId;
+	TInt iRxTimeOut;
+	TUint32 iPageSize;
+	
+	TBool iPacketStarted;
+	TBool iPacketEnded;
+	
+	/** Lock serialising calls to event handler */
+	DSemaphore* iLock;
+	
+	TDfcQue* iDFCQue;
+
+};
+
+#endif //__TRKDCCDRIVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dccdriver/TrkDccDriver_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+#include <kernel/kern_ext.mmh>
+
+macro 	__OEM_TRK__
+macro 	__S60__
+
+TARGET			TrkDccDriver.ldd
+TARGETTYPE		LDD
+UID				0x100000AF 0x200159DE
+SOURCEPATH		.
+SOURCE			TrkDccDriver.cpp
+
+
+NOSTRICTDEF
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+
+systeminclude		\epoc32\include
+systeminclude		\epoc32\include\nkern 
+systeminclude 		\epoc32\include\kernel
+systeminclude		\epoc32\include\kernel\arm
+systeminclude		\epoc32\include\nkern\arm
+systeminclude		\epoc32\include\memmodel\epoc
+systeminclude		\epoc32\include\memmodel\epoc\mmubase
+
+DEFFILE			..\eabi\trkdccdriver.def
+#else
+OS_LAYER_KERNEL_SYSTEMINCLUDE
+
+DEFFILE			../eabi/trkdccdriver.def
+#endif
+
+VENDORID VID_DEFAULT
+capability			all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/dccdriver/TrkDccDriver_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+macro 	__OEM_TRK__
+macro	__KERNEL_MODE__
+
+TARGET			TrkDccDriver.ldd
+TARGETTYPE		LDD
+UID				0x100000AF 0x200159DE
+SOURCEPATH		.
+SOURCE			TrkDccDriver.cpp
+LIBRARY			ekern.lib
+
+systeminclude		/epoc32/include
+systeminclude		/epoc32/include/nkern 
+systeminclude 		/epoc32/include/kernel
+systeminclude		/epoc32/include/kernel/arm
+systeminclude		/epoc32/include/nkern/arm
+systeminclude		/epoc32/include/memmodel/epoc
+systeminclude		/epoc32/include/memmodel/epoc/mmubase
+
+DEFFILE			../eabi/trkdccdriver.def
+NOSTRICTDEF
+
+VENDORID 0x101FB657
+capability			all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/debugnotifier/DebugNotifier.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+ */
+
+#ifndef __DEBUGNOTIFIER_H__
+#define __DEBUGNOTIFIER_H__
+
+
+class IDebugNotifier 
+    {
+public:
+   virtual void NotifyTheUserL()=0;
+    };
+
+#endif  // __DEBUGNOTIFIER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/debugnotifier/DebugNotifierImplementation.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+//  Include Files  
+
+#include "DebugNotifierimplementation.h"	// CDebugNotifier
+
+_LIT(KDeBugNotification,"Debug Services are available through USB");
+//
+// CDebugNotifier* FactoryFunction()
+//
+// Entry point for the dll
+//
+EXPORT_C CDebugNotifier* FactoryFunction()
+{
+    return new CDebugNotifier();    
+}
+
+//
+// CDebugNotifier::NotifyTheUser()
+//
+// This is the method to notify the user about the debug services
+//
+void CDebugNotifier::NotifyTheUserL()
+{
+    CAknGlobalNote* debugNote = CAknGlobalNote::NewL();
+    CleanupStack::PushL( debugNote );
+    TInt noteid = debugNote->ShowNoteL(EAknGlobalConfirmationNote, KDeBugNotification);
+    CleanupStack::PopAndDestroy();    
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/debugnotifier/DebugNotifier_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET		  DebugNotifier.dll
+TARGETTYPE	  dll
+UID           0x10004262 0x200170B3
+
+VENDORID VID_DEFAULT
+CAPABILITY ALL -TCB -DRM
+
+USERINCLUDE	 .
+MW_LAYER_SYSTEMINCLUDE
+
+
+SOURCEPATH	  .
+
+SOURCE DebugNotifierImplementation.cpp
+
+#ifdef MARM
+DEFFILE ./eabi/DebugNotifier.def
+#endif
+
+nostrictdef
+
+LIBRARY		 euser.lib
+LIBRARY      aknnotify.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/debugnotifier/DebugNotifierimplementation.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef DEBUGNOTIFIERIMPLEMENTATION_H_
+#define DEBUGNOTIFIERIMPLEMENTATION_H_
+#include "DebugNotifier.h"
+#include <AknGlobalNote.h>
+
+
+class CDebugNotifier: public IDebugNotifier,public CBase
+    {
+public:
+     CDebugNotifier(){};
+    ~CDebugNotifier(){};
+
+public:
+    void NotifyTheUserL();
+      
+    };
+
+#endif /* DEBUGNOTIFIERIMPLEMENTATION_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/debugnotifier/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/debugnotifier/eabi/DebugNotifier.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z15FactoryFunctionv @ 1 NONAME
+	_ZTI14CDebugNotifier @ 2 NONAME ; #<TI>#
+	_ZTV14CDebugNotifier @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/debugnotifier/eabi/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/doc/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
Binary file dbgagents/trkagent/doc/S60_3_0_Using_TRK_v2_5_on_S60_Devices_C.doc has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eabi/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eabi/isv_trkengine.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,45 @@
+EXPORTS
+	_ZN10CTrkEngine12GetErrorInfoER6TDes16 @ 1 NONAME
+	_ZN10CTrkEngine14GetVersionInfoERiS0_S0_S0_S0_ @ 2 NONAME
+	_ZN10CTrkEngine17GetConnectionInfoER6TDes16 @ 3 NONAME
+	_ZN10CTrkEngine4NewLEv @ 4 NONAME
+	_ZN10CTrkEngine4StopEv @ 5 NONAME
+	_ZN10CTrkEngine5NewLCEv @ 6 NONAME
+	_ZN10CTrkEngine6StartLEv @ 7 NONAME
+	_ZN10CTrkEngineD0Ev @ 8 NONAME
+	_ZN10CTrkEngineD1Ev @ 9 NONAME
+	_ZN10CTrkEngineD2Ev @ 10 NONAME
+	_ZTI10CTrkEngine @ 11 NONAME ; #<TI>#
+	_ZTI12CExitTrapper @ 12 NONAME ; #<TI>#
+	_ZTI13CDebugProcess @ 13 NONAME ; #<TI>#
+	_ZTI13CEventTrapper @ 14 NONAME ; #<TI>#
+	_ZTI16CTrkFramingLayer @ 15 NONAME ; #<TI>#
+	_ZTI17CTrkDispatchLayer @ 16 NONAME ; #<TI>#
+	_ZTI18CTrkSerialCommPort @ 17 NONAME ; #<TI>#
+	_ZTV10CTrkEngine @ 18 NONAME ; #<VT>#
+	_ZTV12CExitTrapper @ 19 NONAME ; #<VT>#
+	_ZTV13CDebugProcess @ 20 NONAME ; #<VT>#
+	_ZTV13CEventTrapper @ 21 NONAME ; #<VT>#
+	_ZTV16CTrkFramingLayer @ 22 NONAME ; #<VT>#
+	_ZTV17CTrkDispatchLayer @ 23 NONAME ; #<VT>#
+	_ZTV18CTrkSerialCommPort @ 24 NONAME ; #<VT>#
+	_ZTI20CTrkBtSocketCommPort @ 25 NONAME ; #<TI>#
+	_ZTV20CTrkBtSocketCommPort @ 26 NONAME ; #<VT>#
+	_ZTI19CTrkSWInstUIHandler @ 27 NONAME ; #<TI>#
+	_ZTV19CTrkSWInstUIHandler @ 28 NONAME ; #<VT>#
+	_ZN10CTrkEngine17GetConnectionDataER12TTrkConnData @ 29 NONAME
+	_ZN10CTrkEngine17SetConnectionDataE12TTrkConnData @ 30 NONAME
+	_ZTI15CTrkEngineModel @ 31 NONAME ; #<TI>#
+	_ZTV15CTrkEngineModel @ 32 NONAME ; #<VT>#
+	_ZN10CTrkEngine11IsDebuggingEv @ 33 NONAME
+	_ZN10CTrkEngine4NewLEP18MTrkEngineCallback @ 34 NONAME
+	_ZN10CTrkEngine5NewLCEP18MTrkEngineCallback @ 35 NONAME
+	_ZTI19CTrkUsbPortListener @ 36 NONAME ; #<TI>#
+	_ZTV19CTrkUsbPortListener @ 37 NONAME ; #<VT>#
+	_ZTI18CTrkDbgTrcCommPort @ 38 NONAME ; #<TI>#
+	_ZTV18CTrkDbgTrcCommPort @ 39 NONAME ; #<VT>#
+	_ZN10CTrkEngine6StartLE12TTrkConnType @ 40 NONAME
+	_ZTI10CPhoneInfo @ 41 NONAME ; #<TI>#
+	_ZTV10CPhoneInfo @ 42 NONAME ; #<VT>#
+	_ZN10CTrkEngine19GetConnectionStatusEv @ 43 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eabi/trkdccdriver.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,7 @@
+EXPORTS
+	_Z19CreateLogicalDevicev @ 1 NONAME
+	_ZTI14DTrkDccChannel @ 2 NONAME ; #<TI>#
+	_ZTI20DTrkDccDriverFactory @ 3 NONAME ; #<TI>#
+	_ZTV14DTrkDccChannel @ 4 NONAME ; #<VT>#
+	_ZTV20DTrkDccDriverFactory @ 5 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eabi/trkengine_nokia_tshell.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,39 @@
+EXPORTS
+	_ZN10CTrkEngine11IsDebuggingEv @ 1 NONAME
+	_ZN10CTrkEngine12GetErrorInfoER6TDes16 @ 2 NONAME
+	_ZN10CTrkEngine14GetVersionInfoERiS0_S0_S0_S0_ @ 3 NONAME
+	_ZN10CTrkEngine17GetConnectionDataER12TTrkConnData @ 4 NONAME
+	_ZN10CTrkEngine17GetConnectionInfoER6TDes16 @ 5 NONAME
+	_ZN10CTrkEngine17GetConnectionTypeEv @ 6 NONAME
+	_ZN10CTrkEngine17SetConnectionDataER12TTrkConnData @ 7 NONAME
+	_ZN10CTrkEngine18GetPlugPlaySettingEv @ 8 NONAME
+	_ZN10CTrkEngine19GetConnectionStatusEv @ 9 NONAME
+	_ZN10CTrkEngine4NewLEP18MTrkEngineCallback @ 10 NONAME
+	_ZN10CTrkEngine4NewLEv @ 11 NONAME
+	_ZN10CTrkEngine4StopEv @ 12 NONAME
+	_ZN10CTrkEngine5NewLCEP18MTrkEngineCallback @ 13 NONAME
+	_ZN10CTrkEngine5NewLCEv @ 14 NONAME
+	_ZN10CTrkEngine6StartLE12TTrkConnType @ 15 NONAME
+	_ZN10CTrkEngine6StartLEv @ 16 NONAME
+	_ZN10CTrkEngineD0Ev @ 17 NONAME
+	_ZN10CTrkEngineD1Ev @ 18 NONAME
+	_ZN10CTrkEngineD2Ev @ 19 NONAME
+	_ZTI10CTrkEngine @ 20 NONAME ; #<TI>#
+	_ZTI12CExitTrapper @ 21 NONAME ; #<TI>#
+	_ZTI13CDebugProcess @ 22 NONAME ; #<TI>#
+	_ZTI13CEventTrapper @ 23 NONAME ; #<TI>#
+	_ZTI15CTrkDccCommPort @ 24 NONAME ; #<TI>#
+	_ZTI15CTrkEngineModel @ 25 NONAME ; #<TI>#
+	_ZTI15CTrkXtiCommPort @ 26 NONAME ; #<TI>#
+	_ZTI16CTrkFramingLayer @ 27 NONAME ; #<TI>#
+	_ZTI17CTrkDispatchLayer @ 28 NONAME ; #<TI>#
+	_ZTV10CTrkEngine @ 29 NONAME ; #<VT>#
+	_ZTV12CExitTrapper @ 30 NONAME ; #<VT>#
+	_ZTV13CDebugProcess @ 31 NONAME ; #<VT>#
+	_ZTV13CEventTrapper @ 32 NONAME ; #<VT>#
+	_ZTV15CTrkDccCommPort @ 33 NONAME ; #<VT>#
+	_ZTV15CTrkEngineModel @ 34 NONAME ; #<VT>#
+	_ZTV15CTrkXtiCommPort @ 35 NONAME ; #<VT>#
+	_ZTV16CTrkFramingLayer @ 36 NONAME ; #<VT>#
+	_ZTV17CTrkDispatchLayer @ 37 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eabi/trkengine_s60.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,51 @@
+EXPORTS
+	_ZN10CTrkEngine11IsDebuggingEv @ 1 NONAME
+	_ZN10CTrkEngine12GetErrorInfoER6TDes16 @ 2 NONAME
+	_ZN10CTrkEngine14GetVersionInfoERiS0_S0_S0_S0_ @ 3 NONAME
+	_ZN10CTrkEngine17GetConnectionDataER12TTrkConnData @ 4 NONAME
+	_ZN10CTrkEngine17GetConnectionInfoER6TDes16 @ 5 NONAME
+	_ZN10CTrkEngine17GetConnectionTypeEv @ 6 NONAME
+	_ZN10CTrkEngine17SetConnectionDataER12TTrkConnData @ 7 NONAME
+	_ZN10CTrkEngine18GetPlugPlaySettingEv @ 8 NONAME
+	_ZN10CTrkEngine19GetConnectionStatusEv @ 9 NONAME
+	_ZN10CTrkEngine4NewLEP18MTrkEngineCallback @ 10 NONAME
+	_ZN10CTrkEngine4NewLEv @ 11 NONAME
+	_ZN10CTrkEngine4StopEv @ 12 NONAME
+	_ZN10CTrkEngine5NewLCEP18MTrkEngineCallback @ 13 NONAME
+	_ZN10CTrkEngine5NewLCEv @ 14 NONAME
+	_ZN10CTrkEngine6StartLE12TTrkConnType @ 15 NONAME
+	_ZN10CTrkEngine6StartLEv @ 16 NONAME
+	_ZN10CTrkEngineD0Ev @ 17 NONAME
+	_ZN10CTrkEngineD1Ev @ 18 NONAME
+	_ZN10CTrkEngineD2Ev @ 19 NONAME
+	_ZTI10CPhoneInfo @ 20 NONAME ; #<TI>#
+	_ZTI10CTrkEngine @ 21 NONAME ; #<TI>#
+	_ZTI12CExitTrapper @ 22 NONAME ; #<TI>#
+	_ZTI13CDebugProcess @ 23 NONAME ; #<TI>#
+	_ZTI13CEventTrapper @ 24 NONAME ; #<TI>#
+	_ZTI15CTrkDccCommPort @ 25 NONAME ; #<TI>#
+	_ZTI15CTrkEngineModel @ 26 NONAME ; #<TI>#
+	_ZTI15CTrkXtiCommPort @ 27 NONAME ; #<TI>#
+	_ZTI16CTrkFramingLayer @ 28 NONAME ; #<TI>#
+	_ZTI17CTrkDispatchLayer @ 29 NONAME ; #<TI>#
+	_ZTI18CTrkDbgTrcCommPort @ 30 NONAME ; #<TI>#
+	_ZTI18CTrkSerialCommPort @ 31 NONAME ; #<TI>#
+	_ZTI19CTrkSWInstUIHandler @ 32 NONAME ; #<TI>#
+	_ZTI19CTrkUsbPortListener @ 33 NONAME ; #<TI>#
+	_ZTI20CTrkBtSocketCommPort @ 34 NONAME ; #<TI>#
+	_ZTV10CPhoneInfo @ 35 NONAME ; #<VT>#
+	_ZTV10CTrkEngine @ 36 NONAME ; #<VT>#
+	_ZTV12CExitTrapper @ 37 NONAME ; #<VT>#
+	_ZTV13CDebugProcess @ 38 NONAME ; #<VT>#
+	_ZTV13CEventTrapper @ 39 NONAME ; #<VT>#
+	_ZTV15CTrkDccCommPort @ 40 NONAME ; #<VT>#
+	_ZTV15CTrkEngineModel @ 41 NONAME ; #<VT>#
+	_ZTV15CTrkXtiCommPort @ 42 NONAME ; #<VT>#
+	_ZTV16CTrkFramingLayer @ 43 NONAME ; #<VT>#
+	_ZTV17CTrkDispatchLayer @ 44 NONAME ; #<VT>#
+	_ZTV18CTrkDbgTrcCommPort @ 45 NONAME ; #<VT>#
+	_ZTV18CTrkSerialCommPort @ 46 NONAME ; #<VT>#
+	_ZTV19CTrkSWInstUIHandler @ 47 NONAME ; #<VT>#
+	_ZTV19CTrkUsbPortListener @ 48 NONAME ; #<VT>#
+	_ZTV20CTrkBtSocketCommPort @ 49 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eabi/trkengine_tshell.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,39 @@
+EXPORTS
+	_ZN10CTrkEngine11IsDebuggingEv @ 1 NONAME
+	_ZN10CTrkEngine12GetErrorInfoER6TDes16 @ 2 NONAME
+	_ZN10CTrkEngine14GetVersionInfoERiS0_S0_S0_S0_ @ 3 NONAME
+	_ZN10CTrkEngine17GetConnectionDataER12TTrkConnData @ 4 NONAME
+	_ZN10CTrkEngine17GetConnectionInfoER6TDes16 @ 5 NONAME
+	_ZN10CTrkEngine17GetConnectionTypeEv @ 6 NONAME
+	_ZN10CTrkEngine17SetConnectionDataER12TTrkConnData @ 7 NONAME
+	_ZN10CTrkEngine18GetPlugPlaySettingEv @ 8 NONAME
+	_ZN10CTrkEngine19GetConnectionStatusEv @ 9 NONAME
+	_ZN10CTrkEngine4NewLEP18MTrkEngineCallback @ 10 NONAME
+	_ZN10CTrkEngine4NewLEv @ 11 NONAME
+	_ZN10CTrkEngine4StopEv @ 12 NONAME
+	_ZN10CTrkEngine5NewLCEP18MTrkEngineCallback @ 13 NONAME
+	_ZN10CTrkEngine5NewLCEv @ 14 NONAME
+	_ZN10CTrkEngine6StartLE12TTrkConnType @ 15 NONAME
+	_ZN10CTrkEngine6StartLEv @ 16 NONAME
+	_ZN10CTrkEngineD0Ev @ 17 NONAME
+	_ZN10CTrkEngineD1Ev @ 18 NONAME
+	_ZN10CTrkEngineD2Ev @ 19 NONAME
+	_ZTI10CTrkEngine @ 20 NONAME
+	_ZTI12CExitTrapper @ 21 NONAME
+	_ZTI13CDebugProcess @ 22 NONAME
+	_ZTI13CEventTrapper @ 23 NONAME
+	_ZTI15CTrkDccCommPort @ 24 NONAME
+	_ZTI15CTrkEngineModel @ 25 NONAME
+	_ZTI16CTrkFramingLayer @ 26 NONAME
+	_ZTI17CTrkDispatchLayer @ 27 NONAME
+	_ZTI18CTrkSerialCommPort @ 28 NONAME
+	_ZTV10CTrkEngine @ 29 NONAME
+	_ZTV12CExitTrapper @ 30 NONAME
+	_ZTV13CDebugProcess @ 31 NONAME
+	_ZTV13CEventTrapper @ 32 NONAME
+	_ZTV15CTrkDccCommPort @ 33 NONAME
+	_ZTV15CTrkEngineModel @ 34 NONAME
+	_ZTV16CTrkFramingLayer @ 35 NONAME
+	_ZTV17CTrkDispatchLayer @ 36 NONAME
+	_ZTV18CTrkSerialCommPort @ 37 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eabi/trkengine_tv.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,49 @@
+EXPORTS
+	_ZN10CTrkEngine11IsDebuggingEv @ 1 NONAME
+	_ZN10CTrkEngine12GetErrorInfoER6TDes16 @ 2 NONAME
+	_ZN10CTrkEngine14GetVersionInfoERiS0_S0_S0_S0_ @ 3 NONAME
+	_ZN10CTrkEngine17GetConnectionDataER12TTrkConnData @ 4 NONAME
+	_ZN10CTrkEngine17GetConnectionInfoER6TDes16 @ 5 NONAME
+	_ZN10CTrkEngine17GetConnectionTypeEv @ 6 NONAME
+	_ZN10CTrkEngine17SetConnectionDataER12TTrkConnData @ 7 NONAME
+	_ZN10CTrkEngine18GetPlugPlaySettingEv @ 8 NONAME
+	_ZN10CTrkEngine19GetConnectionStatusEv @ 9 NONAME
+	_ZN10CTrkEngine4NewLEP18MTrkEngineCallback @ 10 NONAME
+	_ZN10CTrkEngine4NewLEv @ 11 NONAME
+	_ZN10CTrkEngine4StopEv @ 12 NONAME
+	_ZN10CTrkEngine5NewLCEP18MTrkEngineCallback @ 13 NONAME
+	_ZN10CTrkEngine5NewLCEv @ 14 NONAME
+	_ZN10CTrkEngine6StartLE12TTrkConnType @ 15 NONAME
+	_ZN10CTrkEngine6StartLEv @ 16 NONAME
+	_ZN10CTrkEngineD0Ev @ 17 NONAME
+	_ZN10CTrkEngineD1Ev @ 18 NONAME
+	_ZN10CTrkEngineD2Ev @ 19 NONAME
+	_ZTI10CPhoneInfo @ 20 NONAME
+	_ZTI10CTrkEngine @ 21 NONAME
+	_ZTI12CExitTrapper @ 22 NONAME
+	_ZTI13CDebugProcess @ 23 NONAME
+	_ZTI13CEventTrapper @ 24 NONAME
+	_ZTI15CTrkDccCommPort @ 25 NONAME
+	_ZTI15CTrkEngineModel @ 26 NONAME
+	_ZTI16CTrkFramingLayer @ 27 NONAME
+	_ZTI17CTrkDispatchLayer @ 28 NONAME
+	_ZTI18CTrkDbgTrcCommPort @ 29 NONAME
+	_ZTI18CTrkSerialCommPort @ 30 NONAME
+	_ZTI19CTrkSWInstUIHandler @ 31 NONAME
+	_ZTI19CTrkUsbPortListener @ 32 NONAME
+	_ZTI20CTrkBtSocketCommPort @ 33 NONAME
+	_ZTV10CPhoneInfo @ 34 NONAME
+	_ZTV10CTrkEngine @ 35 NONAME
+	_ZTV12CExitTrapper @ 36 NONAME
+	_ZTV13CDebugProcess @ 37 NONAME
+	_ZTV13CEventTrapper @ 38 NONAME
+	_ZTV15CTrkDccCommPort @ 39 NONAME
+	_ZTV15CTrkEngineModel @ 40 NONAME
+	_ZTV16CTrkFramingLayer @ 41 NONAME
+	_ZTV17CTrkDispatchLayer @ 42 NONAME
+	_ZTV18CTrkDbgTrcCommPort @ 43 NONAME
+	_ZTV18CTrkSerialCommPort @ 44 NONAME
+	_ZTV19CTrkSWInstUIHandler @ 45 NONAME
+	_ZTV19CTrkUsbPortListener @ 46 NONAME
+	_ZTV20CTrkBtSocketCommPort @ 47 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eabi/trkengine_uiq.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+EXPORTS
+	_ZN10CTrkEngine11IsDebuggingEv @ 1 NONAME
+	_ZN10CTrkEngine12GetErrorInfoER6TDes16 @ 2 NONAME
+	_ZN10CTrkEngine14GetVersionInfoERiS0_S0_S0_S0_ @ 3 NONAME
+	_ZN10CTrkEngine17GetConnectionDataER12TTrkConnData @ 4 NONAME
+	_ZN10CTrkEngine17GetConnectionInfoER6TDes16 @ 5 NONAME
+	_ZN10CTrkEngine17SetConnectionDataE12TTrkConnData @ 6 NONAME
+	_ZN10CTrkEngine4NewLEv @ 7 NONAME
+	_ZN10CTrkEngine4StopEv @ 8 NONAME
+	_ZN10CTrkEngine5NewLCEv @ 9 NONAME
+	_ZN10CTrkEngine6StartLEv @ 10 NONAME
+	_ZN10CTrkEngineD0Ev @ 11 NONAME
+	_ZN10CTrkEngineD1Ev @ 12 NONAME
+	_ZN10CTrkEngineD2Ev @ 13 NONAME
+	_ZTI10CTrkEngine @ 14 NONAME ; #<TI>#
+	_ZTI12CExitTrapper @ 15 NONAME ; #<TI>#
+	_ZTI13CDebugProcess @ 16 NONAME ; #<TI>#
+	_ZTI13CEventTrapper @ 17 NONAME ; #<TI>#
+	_ZTI15CTrkDccCommPort @ 18 NONAME ; #<TI>#
+	_ZTI15CTrkEngineModel @ 19 NONAME ; #<TI>#
+	_ZTI16CTrkFramingLayer @ 20 NONAME ; #<TI>#
+	_ZTI17CTrkDispatchLayer @ 21 NONAME ; #<TI>#
+	_ZTI18CTrkSerialCommPort @ 22 NONAME ; #<TI>#
+	_ZTI19CTrkSWInstUIHandler @ 23 NONAME ; #<TI>#
+	_ZTI20CTrkBtSocketCommPort @ 24 NONAME ; #<TI>#
+	_ZTV10CTrkEngine @ 25 NONAME ; #<VT>#
+	_ZTV12CExitTrapper @ 26 NONAME ; #<VT>#
+	_ZTV13CDebugProcess @ 27 NONAME ; #<VT>#
+	_ZTV13CEventTrapper @ 28 NONAME ; #<VT>#
+	_ZTV15CTrkDccCommPort @ 29 NONAME ; #<VT>#
+	_ZTV15CTrkEngineModel @ 30 NONAME ; #<VT>#
+	_ZTV16CTrkFramingLayer @ 31 NONAME ; #<VT>#
+	_ZTV17CTrkDispatchLayer @ 32 NONAME ; #<VT>#
+	_ZTV18CTrkSerialCommPort @ 33 NONAME ; #<VT>#
+	_ZTV19CTrkSWInstUIHandler @ 34 NONAME ; #<VT>#
+	_ZTV20CTrkBtSocketCommPort @ 35 NONAME ; #<VT>#
+	_ZN10CTrkEngine4NewLEP18MTrkEngineCallback @ 36 NONAME
+	_ZN10CTrkEngine5NewLCEP18MTrkEngineCallback @ 37 NONAME
+	_ZTI19CTrkUsbPortListener @ 38 NONAME ; #<TI>#
+	_ZTV19CTrkUsbPortListener @ 39 NONAME ; #<VT>#
+	_ZTI18CTrkDbgTrcCommPort @ 40 NONAME ; #<TI>#
+	_ZTV18CTrkDbgTrcCommPort @ 41 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eabi/trkkerneldriver.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,9 @@
+EXPORTS
+	_Z19CreateLogicalDevicev @ 1 NONAME
+	_ZTI16DMetroTrkChannel @ 2 NONAME ; #<TI>#
+	_ZTI21DMetroTrkEventHandler @ 3 NONAME ; #<TI>#
+	_ZTI22DMetroTrkDriverFactory @ 4 NONAME ; #<TI>#
+	_ZTV16DMetroTrkChannel @ 5 NONAME ; #<VT>#
+	_ZTV21DMetroTrkEventHandler @ 6 NONAME ; #<VT>#
+	_ZTV22DMetroTrkDriverFactory @ 7 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eabi/trkxtidriver.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,9 @@
+EXPORTS
+	_Z19CreateLogicalDevicev @ 1 NONAME
+	_ZTI14DTrkXtiChannel @ 2 NONAME ; #<TI>#
+	_ZTI17DTrkXtiSubscriber @ 3 NONAME ; #<TI>#
+	_ZTI20DTrkXtiDriverFactory @ 4 NONAME ; #<TI>#
+	_ZTV14DTrkXtiChannel @ 5 NONAME ; #<VT>#
+	_ZTV17DTrkXtiSubscriber @ 6 NONAME ; #<VT>#
+	_ZTV20DTrkXtiDriverFactory @ 7 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/Isv_TrkKernelDriver_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "TrkKernelDriver_s60.mmh"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/Isv_TrkKernelDriver_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "trkkerneldriver_tv.mmh"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/TrkDriver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,351 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKDRIVER_H__
+#define __TRKDRIVER_H__
+
+// Debug messages
+#ifdef _DEBUG
+#define LOG_MSG(x) __KTRACE_OPT(KDEBUGGER, Kern::Printf(x))
+#define LOG_MSG2(x, y) __KTRACE_OPT(KDEBUGGER, Kern::Printf(x, y))
+#else
+#define LOG_MSG(x)
+#define LOG_MSG2(x, y)
+#endif
+
+
+//
+// Macros
+//
+const TUint32 KArmBreakPoint = 0xE7F123F4;
+const TUint16 KThumbBreakPoint = 0xDE56;
+
+// From mmboot.h header
+const TLinAddr	KDataSectionEnd			=0x40000000u;
+const TLinAddr	KRomLinearBase			=0xF8000000u;
+
+const TLinAddr	KSuperPageMovingLinAddr		=0x60000000u;
+const TLinAddr	KSuperPageMultipleLinAddr	=0xC0000000u;
+const TLinAddr	KKernDataEndMovingLinAddr	=0x655FFFFFu;//0xF3FFFFFFu;
+const TLinAddr	KKernDataEndMultipleLinAddr	=0xFFEFFFFFu;
+
+#define NUMBER_OF_TEMP_BREAKPOINTS 10
+#define NUMBER_OF_EVENTS_TO_QUEUE 50
+#define NUMBER_OF_LIBS_TO_REGISTER 100
+#define ROM_LINEAR_BASE KRomLinearBase
+
+//for multiple memory model
+#define NUMBER_OF_MAX_BREAKPOINTS 100
+
+// Result checking
+#define ReturnIfError(x) { TInt y = x; if (KErrNone != y) return y; }
+
+// Register definitions
+#define SP_REGISTER			13
+#define LINK_REGISTER		14
+#define PC_REGISTER			15
+#define STATUS_REGISTER		16
+
+// ARM instruction bitmasks
+#define ARM_OPCODE(x)		(((TUint32)(x) & 0x0E000000) >> 25)
+
+// Generic instruction defines
+#define ARM_RM(x)				((TUint32)(x) & 0x0000000F)			// bit 0- 4
+#define ARM_RS(x)				(((TUint32)(x) & 0x00000F00) >> 8)	// bit 8-11
+#define ARM_RD(x)				(((TUint32)(x) & 0x0000F000) >> 12)	// bit 12-15
+#define ARM_RN(x)				(((TUint32)(x) & 0x000F0000) >> 16)	// bit 16-19
+#define ARM_LOAD(x)				(((TUint32)(x) & 0x00100000) >> 20)	// bit 20
+
+// Data processing instruction defines
+#define ARM_DATA_SHIFT(x)		(((TUint32)(x) & 0x00000060) >> 5) 	// bit 5- 6
+#define ARM_DATA_C(x)			(((TUint32)(x) & 0x00000F80) >> 7) 	// bit 7-11
+#define ARM_DATA_IMM(x)			((TUint32)(x) & 0x000000FF)			// bit 0-7
+#define ARM_DATA_ROT(x)			(((TUint32)(x) & 0x00000F00) >> 8) 	// bit 8-11
+
+// Single date transfer instruction defines
+#define ARM_SINGLE_IMM(x)		((TUint32)(x) & 0x00000FFF)			// bit 0-11
+#define ARM_SINGLE_BYTE(x)		(((TUint32)(x) & 0x00400000) >> 22)	// bit 22
+#define ARM_SINGLE_U(x)			(((TUint32)(x) & 0x00800000) >> 23)	// bit 23
+#define ARM_SINGLE_PRE(x)		(((TUint32)(x) & 0x01000000) >> 24)	// bit 24
+
+// Block data transfer instruction defines
+#define ARM_BLOCK_REGLIST(x)	((TUint32)(x) & 0x0000FFFF)		// bit 0-15
+#define ARM_BLOCK_U(x)			(((TUint32)(x) & 0x00800000) >> 23)	// bit 23
+#define ARM_BLOCK_PRE(x)		(((TUint32)(x) & 0x01000000) >> 24)	// bit 24
+
+// Branch instruction defines
+#define ARM_B_ADDR(x)			((x & 0x00800000) ? ((TUint32)(x) & 0x00FFFFFF | 0xFF000000) : (TUint32)(x) & 0x00FFFFFF)
+#define ARM_INSTR_B_DEST(x,a)	(ARM_B_ADDR(x) << 2) + ((TUint32)(a) + 8)
+
+#define ARM_CARRY_BIT			0x20000000	// bit 30
+
+
+// Thumb instruction bitmasks
+#define THUMB_OPCODE(x)		(((TUint16)(x) & 0xF800) >> 11)
+#define THUMB_INST_7_15(x)	(((TUint16)(x) & 0xFF80) >> 7)
+#define THUMB_INST_8_15(x)	(((TUint16)(x) & 0xFF00) >> 8)
+
+
+const TUint8 KArm4Stub[8] = { 0x00, 0xC0, 0x9F, 0xE5, 0x00, 0xF0, 0x9C, 0xE5 };
+const TUint8 KArmIStub[12] = { 0x04, 0xC0, 0x9F, 0xE5, 0x00, 0xC0, 0x9C, 0xE5, 0x1C, 0xFF, 0x2F, 0xE1 };
+const TUint8 KFastArmIStub[12] = { 0x04, 0xC0, 0x9F, 0xE5, 0x1C, 0xFF, 0x2F, 0xE1, 0x00, 0x00, 0x00, 0x00 };
+const TUint8 KThumbStub[12] = { 0x40, 0xB4, 0x02, 0x4E, 0x36, 0x68, 0xB4, 0x46, 0x40, 0xBC, 0x60, 0x47 };
+const TUint8 KThumbStub2[8] = { 0x01, 0x4B, 0x1B, 0x68, 0x18, 0x47, 0xC0, 0x46 };
+const TUint8 KFastThumbStub[12] = { 0x40, 0xB4, 0x02, 0x4E, 0xB4, 0x46, 0x40, 0xBC, 0x60, 0x47, 0xC0, 0x46 };
+const TUint8 KFastThumbStub2[8] = { 0x01, 0x4B, 0x18, 0x47, 0xC0, 0x46, 0xC0, 0x46 };
+
+const unsigned char KRvctArm4Stub[4] = { 0x04, 0xF0, 0x1F, 0xE5 };
+
+//
+// class TBreakEntry
+//
+class TBreakEntry
+{
+public:
+
+	inline TBreakEntry() { Reset(); };
+
+	inline TBreakEntry(TUint32 aId, TUint32 aThreadId, TUint32 aAddress, TBool aThumbMode)
+			: iId(aId),
+			  iThreadId(aThreadId),
+			  iAddress(aAddress),
+			  iThumbMode(aThumbMode)
+	{
+		 iInstruction.FillZ(4);
+		 iPageAddress = 0;
+		 iDisabledForStep = EFalse;
+		 iObsoleteLibraryBreakpoint = EFalse;
+		 iResumeOnceOutOfRange = EFalse;
+		 iSteppingInto = EFalse;
+		 iRangeStart = 0;
+		 iRangeEnd = 0;
+		 iThreadSpecific = EFalse;
+	};
+	
+	inline void Reset()
+	{
+		 iThreadId = 0;
+		 iAddress = 0;
+		 iThumbMode = EFalse;
+		 iInstruction.FillZ(4);
+		 iPageAddress = 0;
+		 iDisabledForStep = EFalse;
+		 iObsoleteLibraryBreakpoint = EFalse;
+		 iResumeOnceOutOfRange = EFalse;
+		 iSteppingInto = EFalse;
+		 iRangeStart = 0;
+		 iRangeEnd = 0;
+	};
+
+public:
+			
+	TInt32		iId;
+	TUint32		iThreadId;
+	TUint32		iAddress;
+	TBool		iThumbMode;
+	TBuf8<4>	iInstruction;
+	TUint32		iPageAddress;
+	TBool		iDisabledForStep;
+	TBool		iObsoleteLibraryBreakpoint;
+	TBool		iResumeOnceOutOfRange;
+	TBool		iSteppingInto;
+	TUint32		iRangeStart;
+	TUint32		iRangeEnd;
+	TBool		iThreadSpecific;
+};
+
+class TProcessInfo
+{
+	public:
+
+		inline TProcessInfo() { Reset(); }
+
+		inline TProcessInfo(TUint32 aId, TUint32 aCodeAddress, TUint32 aCodeSize, TUint32 aDataAddress)
+				: iId(aId),
+				  iCodeAddress(aCodeAddress),
+				  iCodeSize(aCodeSize),
+				  iDataAddress(aDataAddress) { }
+		
+		inline void Reset()
+		{
+			 iId = 0;
+			 iCodeAddress = 0;
+			 iCodeSize = 0;
+			 iDataAddress = 0;
+		}
+
+	public:
+		TUint32 iId;
+		TUint32 iCodeAddress;
+		TUint32 iCodeSize;
+		TUint32 iDataAddress;
+};
+
+
+//
+// class DMetroTrkDriverFactory
+//
+class DMetroTrkDriverFactory : public DLogicalDevice
+{
+public:
+
+	DMetroTrkDriverFactory();
+	virtual TInt Install();
+	virtual void GetCaps(TDes8& aDes) const;
+	virtual TInt Create(DLogicalChannelBase*& aChannel);
+};
+
+class DMetroTrkEventHandler;
+//
+// DMetroTrkChannel
+//
+class DMetroTrkChannel : public DLogicalChannel
+{
+public:
+
+	DMetroTrkChannel(DLogicalDevice* aLogicalDevice);
+	~DMetroTrkChannel();
+
+	virtual TInt DoCreate(TInt aUnit, const TDesC* anInfo, const TVersion& aVer);	
+	virtual void HandleMsg(TMessageBase* aMsg);
+	
+	//called from the event handler
+	void AddProcess(DProcess *aProcess, DThread* aThread);
+	void StartThread(DThread *aThread);
+	void RemoveProcess(DProcess *aProcess);
+	void AddLibrary(DLibrary *aLibrary, DThread *aThread);
+	void RemoveLibrary(DLibrary *aLibrary);
+	void AddCodeSegment(DCodeSeg *aCodeSeg, DProcess *aProcess);
+	void RemoveCodeSegment(DCodeSeg *aCodeSeg, DProcess *aProcess);
+	TBool HandleEventKillThread(DThread* aThread);
+	TBool HandleSwException(TExcType aExcType);
+	TBool HandleHwException(TArmExcInfo* aExcInfo);
+	TBool HandleUserTrace(TText* aStr, TInt aLen);
+	
+protected:
+	virtual void DoCancel(TInt aReqNo);
+	virtual void DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
+	virtual TInt DoControl(TInt aFunction, TAny *a1, TAny *a2);
+	
+private:
+	void HandleException(SEventInfo& aEventInfo, DThread* aCurrentThread);
+
+	TInt SetBreak(TUint32 aThreadId, TMetroTrkBreakInfo* aBreakInfo);
+	TInt StepRange(DThread* aThread, TMetroTrkStepInfo* aStepInfo);
+	TInt ReadMemory(DThread* aThread, TMetroTrkMemoryInfo* aMemoryInfo);
+	TInt WriteMemory(DThread* aThread, TMetroTrkMemoryInfo* aMemoryInfo);
+	TInt ReadRegisters(DThread* aThread, TMetroTrkRegisterInfo* aRegisterInfo);
+	TInt WriteRegisters(DThread* aThread, TMetroTrkRegisterInfo* aRegisterInfo);
+	TInt GetProcessInfo(TInt aIndex, TMetroTrkTaskInfo* aTaskInfo);
+	TInt GetThreadInfo(TInt aIndex, TMetroTrkTaskInfo* aTaskInfo);
+	TInt GetProcessAddresses(DThread* aThread, TMetroTrkProcessInfo* aProcessInfo);
+	TInt GetStaticLibraryInfo(TInt aIndex, SEventInfo* aEventInfo);
+	TInt GetLibraryInfo(TMetroTrkLibInfo* aLibInfo);
+	TInt GetExeInfo(TMetroTrkExeInfo* aExeInfo);
+	TInt GetProcUidInfo(TMetroTrkProcUidInfo* aProcUidInfo);
+	TInt DetachProcess(DProcess* aProcess);
+
+	TInt DoSetBreak(const TUint32 aProcessId, const TUint32 aThreadId, const TUint32 aAddress, const TBool aThumbMode, TInt32 &aId);
+	TInt DoEnableBreak(TBreakEntry &aEntry, TBool aSaveOldInstruction);
+	TInt DoClearBreak(const TInt32 aId);
+	TInt DoChangeBreakThread(TUint32 aThreadId, TInt32 aId);
+	TInt DoSuspendThread(DThread *aThread);
+	TInt DoResumeThread(DThread *aThread);
+	TInt DoStepRange(DThread *aThread, const TUint32 aStartAddress, const TUint32 aStopAddress, TBool aStepInto, TBool aResumeOnceOutOfRange, TBool aUserRequest = EFalse);
+	TInt DoReadMemory(DThread *aThread, const TUint32 aAddress, const TInt16 aLength, TDes8 &aData);
+	TInt DoWriteMemory(DThread *aThread, const TUint32 aAddress, const TInt16 aLength, TDes8 &aData);
+	TInt DoReadRegisters(DThread *aThread, const TInt16 aFirstRegister, const TInt16 aLastRegister, TDes8 &aValues);
+	TInt DoWriteRegisters(DThread *aThread, const TInt16 aFirstRegister, const TInt16 aLastRegister, TDesC8 &aValues);
+	TInt DoGetProcessInfo(const TInt aIndex, TMetroTrkTaskInfo *aInfo);
+	TInt DoGetThreadInfo(const TInt aIndex, TMetroTrkTaskInfo *aInfo);
+	TInt DoGetProcessAddresses(DThread *aThread, TUint32 &aCodeAddress, TUint32 &aDataAddress);
+	TInt DoGetStaticLibraryInfo(const TInt aIndex, SEventInfo *aInfo);
+	TInt DoGetLibraryInfo(TDesC8 &aDllName, TMetroTrkLibInfo* aLibInfo);
+	TInt DoGetExeInfo(TDesC8 &aExeName, TMetroTrkExeInfo* aExeInfo);
+	TInt DoGetProcUidInfo(TMetroTrkProcUidInfo* aProcUidInfo);
+
+	TBool DoSecurityCheck();
+	TInt TryToReadMemory(DThread *aThread, TAny *aSrc, TAny *aDest, TInt16 aLength);
+	TInt TryToWriteMemory(DThread *aThread, TAny *aDest, TAny *aSrc, TInt16 aLength);
+	TInt32 ReadRegister(DThread *aThread, TInt aNum);
+	TInt ModifyBreaksForStep(DThread *aThread, TUint32 aRangeStart, TUint32 aRangeEnd, TBool aStepInto, TBool aResumeOnceOutOfRange, TBool aCheckForStubs);
+	TBool IsExecuted(TUint8 aCondition, TUint32 aStatusRegister);
+	void ClearAllBreakPoints();
+	TInt DisableBreakAtAddress(TUint32 aAddress);
+	TInt DoEnableDisabledBreak(TUint32 aThreadId);
+	TUint32 ShiftedRegValue(DThread *aThread, TUint32 aInstruction, TUint32 aCurrentPC, TUint32 aStatusRegister);
+	TBool InstructionModifiesPC(DThread *aThread, TUint8 *aInstruction, TBool aThumbMode, TBool aStepInto);
+	TUint32 PCAfterInstructionExecutes(DThread *aThread, TUint32 aCurrentPC, TUint32 aStatusRegister, TInt aInstSize, TBool aStepInto, TUint32 &aNewRangeEnd, TBool &aChangingModes);
+	void DecodeDataProcessingInstruction(TUint8 aOpcode, TUint32 aOp1, TUint32 aOp2, TUint32 aStatusRegister, TUint32 &aBreakAddress);
+	TBool IsPreviousInstructionMovePCToLR(DThread *aThread);
+	
+	TBool IsAddressInRom(TUint32 aAddress);
+	TBool IsAddressSecure(TUint32 aAddress);
+	TBool IsRegisterSecure(TInt registerIndex);
+
+	TInt AllocateShadowPageIfNecessary(TUint32 aAddress, TUint32 &aPageAddress);
+	TInt FreeShadowPageIfNecessary(TUint32 aAddress, TUint32 aPageAddress);
+
+	void NotifyEvent(SEventInfo aEventInfo, TBool isTraceEvent=EFalse);
+	DThread* ThreadFromId(TUint32 aId);
+	DProcess* ProcessFromId(TUint32 aId);
+	TBool GetSystemThreadRegisters(TArmRegSet* aArmRegSet);
+	TInt DoGetLibInfoFromCodeSegList(TDesC8 &aDllName, TMetroTrkLibInfo *aInfo);
+	TInt DoGetLibInfoFromKernLibContainer(TDesC8 &aDllName, TMetroTrkLibInfo *aInfo);
+
+	TBool HasManufacturerCaps(DThread* aThread);
+	TBool IsBeingDebugged(const DThread* aThread);
+
+	void CheckLibraryNotifyList(TUint32 aProcessId);
+
+private:
+	DThread* iClientThread;
+	DMetroTrkEventHandler* iEventHandler;
+	
+	TUint32 iExcludedROMAddressStart;
+	TUint32 iExcludedROMAddressEnd;
+	
+	RArray<TBreakEntry> iBreakPointList;
+	TInt iNextBreakId;
+	
+	SEventInfo *iEventInfo;
+	RArray<SEventInfo> iEventQueue;
+	RArray<SEventInfo> iTraceEventQueue;
+	TRequestStatus* iRequestGetEventStatus;
+
+	TUint32 iPageSize;
+	
+	TBool  iNotifyLibLoadedEvent;
+	TBool  iMultipleMemModel;
+	
+	RArray<TProcessInfo> iDebugProcessList; //processes that we are debugging
+	RArray<SEventInfo> iProcessNotifyList; 
+	
+	TDfcQue* iDFCQue;
+
+	TArmExcInfo iCurrentExcInfo;
+	TBool iExcInfoValid;
+	TBool iDebugging;
+	// PANIC_BACKPORT
+	RPointerArray<NFastSemaphore> iFrozenThreadSemaphores;
+	// END PANIC_BACKPORT
+	RArray<TTrkLibName> iLibraryNotifyList;
+
+};
+
+#endif //__TRKDRIVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/TrkEventHandler.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,398 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <e32def.h>
+#include <e32cmn.h>
+#include <arm.h>
+#include <kernel.h>
+#include <kern_priv.h>
+#include <nk_trace.h>
+
+#include "TrkKernelDriver.h"
+#include "TrkDriver.h"
+#include "TrkEventHandler.h"
+
+
+DMetroTrkEventHandler::DMetroTrkEventHandler()
+	:	DKernelEventHandler(EventHandler, this)
+{
+	LOG_MSG("DMetroTrkEventHandler::DMetroTrkEventHandler()");
+
+}
+
+
+TInt DMetroTrkEventHandler::Create(DLogicalDevice* aDevice, DLogicalChannel* aChannel, DThread* aClient)
+{
+	LOG_MSG("DMetroTrkEventHandler::Create()");
+
+	TInt err;
+	err = aDevice->Open();
+	if (err != KErrNone)
+		return err;
+	iDevice = aDevice;
+	
+	iChannel = aChannel; //Don't add ref the channel, since channel closes the event handler before it ever gets destroyed.
+
+	err = aClient->Open();
+	if (err != KErrNone)
+		return err;
+	iClientThread = aClient;
+
+	// Use a semaphore to protect our data structures from concurrent access.
+	err = Kern::SemaphoreCreate(iLock, _L("TrkEventHandlerLock"), 1 /* Initial count */);
+
+	if (err != KErrNone)
+		return err;
+	
+	return Add();
+}
+
+
+DMetroTrkEventHandler::~DMetroTrkEventHandler()
+{
+	LOG_MSG("DMetroTrkEventHandler::~DMetroTrkEventHandler()");
+
+	if (iLock)
+		iLock->Close(NULL);
+	
+	if (iDevice)
+		iDevice->Close(NULL);	
+	
+	if (iClientThread)
+		Kern::SafeClose((DObject*&)iClientThread, NULL);
+		
+}
+
+
+TInt DMetroTrkEventHandler::Start()
+{
+	LOG_MSG("DMetroTrkEventHandler::Start()");
+
+	TInt r = KErrNone;
+	iTracking = ETrue;
+	return r;
+}
+
+
+TInt DMetroTrkEventHandler::Stop()
+{
+	LOG_MSG("DMetroTrkEventHandler::Stop()");
+
+	//NKern::ThreadEnterCS();
+	//Kern::SemaphoreWait(*iLock);
+	iTracking = EFalse;
+	//Kern::SemaphoreSignal(*iLock);
+	//NKern::ThreadLeaveCS();
+	
+	return KErrNone;
+}
+
+
+TUint DMetroTrkEventHandler::EventHandler(TKernelEvent aType, TAny* a1, TAny* a2, TAny* aThis)
+{
+	return ((DMetroTrkEventHandler*)aThis)->HandleEvent(aType, a1, a2);
+}
+
+TUint DMetroTrkEventHandler::HandleEvent(TKernelEvent aType, TAny* a1, TAny* a2)
+{
+	if (iTracking)
+	{
+		iCounters[aType]++;
+		switch (aType)
+		{
+			case EEventSwExc:
+			{
+				if (HandleSwException((TExcType)(TInt)a1))
+					return (TUint)DKernelEventHandler::EExcHandled;
+			}
+				
+			case EEventHwExc:
+			{
+				if (HandleHwException((TArmExcInfo*)a1))
+					return (TUint)DKernelEventHandler::EExcHandled; 
+			}
+			case EEventUpdateProcess:
+			case EEventAddThread:
+			case EEventUpdateThread:
+			case EEventRemoveThread:
+			case EEventNewChunk:
+			case EEventDeleteChunk:				
+			//currently we don't handle any of these events;
+				break;				
+			case EEventAddProcess:
+			{			
+				AddProcess((DProcess*)a1, (DThread*)a2);
+				break;
+			}		
+			case EEventRemoveProcess:
+			{
+				RemoveProcess((DProcess*)a1);
+				break;
+			}
+			case EEventStartThread:
+			{
+				StartThread((DThread*)a1);
+				break;
+			}
+			// According to Symbian, the only way to catch panics in EKA2 is through this event.
+			case EEventKillThread:
+			{
+				if (HandleEventKillThread((DThread*)a1))
+					return (TUint)DKernelEventHandler::EExcHandled; 
+				break;
+			}
+			case EEventAddLibrary:
+			{
+				AddLibrary((DLibrary*)a1, (DThread*)a2);
+				break;
+			}
+				
+			case EEventRemoveLibrary:
+			{
+				RemoveLibrary((DLibrary*)a1);
+				break;
+			}
+			
+			case EEventUserTrace:
+			{
+				HandleUserTrace((TText*)a1, (TInt)a2);
+				break;
+			}
+			case EEventAddCodeSeg:
+			{
+				//
+				// EventAddCodeSeg is not fired for all libs, for example, if a static lib is in ROM,
+				// then you don't need get AddCodeSeg event for that lib.
+				// 
+				//AddCodeSegment((DCodeSeg*)a1, (DProcess*)a2);
+				break;
+			}			
+			case EEventRemoveCodeSeg:
+			{
+				// RemoveCodeSegment((DCodeSeg*)a1, (DProcess*)a2);
+				break;
+			}
+			default:
+				break;
+		}
+	}
+	return DKernelEventHandler::ERunNext;
+}
+
+//
+// DMetroTrkEventHandler::HandleEventKillThread
+//
+
+TBool DMetroTrkEventHandler::HandleEventKillThread(DThread* aThread)
+{
+	LOG_MSG("DMetroTrkEventHandler::HandleEventKillThread()");
+	
+	//NKern::ThreadEnterCS();
+	//Kern::SemaphoreWait(*iLock);
+	
+	TBool ret = ((DMetroTrkChannel*)iChannel)->HandleEventKillThread(aThread);
+		
+	//Kern::SemaphoreSignal(*iLock);
+	//NKern::ThreadLeaveCS();
+	
+	return ret;
+}
+
+
+//
+// DMetroTrkEventHandler::HandleSwException
+//
+
+TBool DMetroTrkEventHandler::HandleSwException(TExcType aExcType)
+{
+	LOG_MSG("DMetroTrkEventHandler::HandleSwException()");
+	
+	NKern::ThreadEnterCS();
+	Kern::SemaphoreWait(*iLock);
+	
+	TBool ret = ((DMetroTrkChannel*)iChannel)->HandleSwException(aExcType);
+	
+	Kern::SemaphoreSignal(*iLock);
+	NKern::ThreadLeaveCS();
+	
+	return ret;
+}
+
+//
+// DMetroTrkEventHandler::HandleHwException
+//
+
+TBool DMetroTrkEventHandler::HandleHwException(TArmExcInfo* aExcInfo)
+{
+	LOG_MSG("DMetroTrkEventHandler::HandleHwException()");
+	
+	TBool ret = EFalse;
+		
+	NKern::ThreadEnterCS();
+	Kern::SemaphoreWait(*iLock);
+
+	if (aExcInfo)
+	{
+		ret = ((DMetroTrkChannel*)iChannel)->HandleHwException(aExcInfo);
+	}
+	
+	Kern::SemaphoreSignal(*iLock);
+	NKern::ThreadLeaveCS();
+	
+	return ret;
+}
+
+//
+// DMetroTrkEventHandler::HandleUserTrace
+//
+TBool DMetroTrkEventHandler::HandleUserTrace(TText* aStr, TInt aLen)
+{
+	LOG_MSG("DMetroTrkEventHandler::HandleUserTrace()");
+	TBool ret = EFalse;
+
+	NKern::ThreadEnterCS();
+	Kern::SemaphoreWait(*iLock);
+	
+	if (aStr && aLen > 0)
+	{
+		ret = ((DMetroTrkChannel*)iChannel)->HandleUserTrace(aStr, aLen);
+	}
+	
+	Kern::SemaphoreSignal(*iLock);
+	NKern::ThreadLeaveCS();
+	
+	return ret;
+}
+
+//
+// DMetroTrkEventHandler::AddProcess
+//
+void DMetroTrkEventHandler::AddProcess(DProcess* aProcess, DThread *aThread)
+{
+	LOG_MSG("DMetroTrkEventHandler::AddProcess()");
+	
+	NKern::ThreadEnterCS();
+	Kern::SemaphoreWait(*iLock);
+	
+	if (iChannel && aProcess && aThread)
+		((DMetroTrkChannel*)iChannel)->AddProcess(aProcess, aThread);
+
+	Kern::SemaphoreSignal(*iLock);
+	NKern::ThreadLeaveCS();
+}
+
+//
+// DMetroTrkEventHandler::StartThread
+//
+void DMetroTrkEventHandler::StartThread(DThread *aThread)
+{
+	LOG_MSG("DMetroTrkEventHandler::StartThread()");
+	
+	NKern::ThreadEnterCS();
+	Kern::SemaphoreWait(*iLock);
+	
+	if (iChannel && aThread)
+		((DMetroTrkChannel*)iChannel)->StartThread(aThread);
+
+	Kern::SemaphoreSignal(*iLock);
+	NKern::ThreadLeaveCS();
+}
+//
+// DMetroTrkEventHandler::RemoveProcess
+//
+void DMetroTrkEventHandler::RemoveProcess(DProcess *aProcess)
+{
+	LOG_MSG("DMetroTrkEventHandler::RemoveProcess()");
+
+	NKern::ThreadEnterCS();
+	Kern::SemaphoreWait(*iLock);
+	
+	if (iChannel && aProcess)
+		((DMetroTrkChannel*)iChannel)->RemoveProcess(aProcess);
+		
+	Kern::SemaphoreSignal(*iLock);
+	NKern::ThreadLeaveCS();
+}
+
+//
+// DMetroTrkEventHandler::AddLibrary
+//
+void DMetroTrkEventHandler::AddLibrary(DLibrary *aLibrary, DThread *aThread)
+{
+	LOG_MSG("DMetroTrkEventHandler::AddLibrary()");
+	
+	NKern::ThreadEnterCS();
+	Kern::SemaphoreWait(*iLock);
+	
+	if (iChannel && aLibrary)
+		((DMetroTrkChannel*)iChannel)->AddLibrary(aLibrary, aThread);
+
+	Kern::SemaphoreSignal(*iLock);
+	NKern::ThreadLeaveCS();
+}
+
+//
+// DMetroTrkEventHandler::RemoveLibrary
+//
+void DMetroTrkEventHandler::RemoveLibrary(DLibrary *aLibrary)
+{
+	LOG_MSG("DMetroTrkEventHandler::RemoveLibrary()");
+
+	NKern::ThreadEnterCS();
+	Kern::SemaphoreWait(*iLock);
+	
+	if (iChannel && aLibrary)
+		((DMetroTrkChannel*)iChannel)->RemoveLibrary(aLibrary);
+	
+	Kern::SemaphoreSignal(*iLock);
+	NKern::ThreadLeaveCS();
+}
+
+//
+// DMetroTrkEventHandler::AddCodeSegment
+//
+void DMetroTrkEventHandler::AddCodeSegment(DCodeSeg *aCodeSeg, DProcess *aProcess)
+{
+	LOG_MSG("DMetroTrkEventHandler::AddCodeSegment()");
+
+	NKern::ThreadEnterCS();
+	Kern::SemaphoreWait(*iLock);
+	
+	if (iChannel && aCodeSeg && aProcess)
+		((DMetroTrkChannel*)iChannel)->AddCodeSegment(aCodeSeg, aProcess);
+		
+	Kern::SemaphoreSignal(*iLock);
+	NKern::ThreadLeaveCS();
+}
+
+//
+// DMetroTrkEventHandler::RemoveCodeSegment
+//
+void DMetroTrkEventHandler::RemoveCodeSegment(DCodeSeg *aCodeSeg, DProcess *aProcess)
+{
+	LOG_MSG("DMetroTrkEventHandler::RemoveCodeSegment()");
+
+	NKern::ThreadEnterCS();
+	Kern::SemaphoreWait(*iLock);
+
+	if (iChannel && aCodeSeg && aProcess)
+		((DMetroTrkChannel*)iChannel)->RemoveCodeSegment(aCodeSeg, aProcess);
+	
+	Kern::SemaphoreSignal(*iLock);
+	NKern::ThreadLeaveCS();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/TrkEventHandler.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+/** Event handler and container for all objects being tracked.  */
+#ifndef __TRKEVENTHANDLER_H__
+#define __TRKEVENTHANDLER_H__
+
+
+class DMetroTrkEventHandler : public DKernelEventHandler
+{
+	public:
+		DMetroTrkEventHandler();
+		TInt Create(DLogicalDevice* aDevice, DLogicalChannel* aChannel, DThread* aClient);
+		~DMetroTrkEventHandler();
+		TInt Start();
+		TInt Stop();
+		
+	private:
+		static TUint EventHandler(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aThis);
+		TUint HandleEvent(TKernelEvent aType, TAny* a1, TAny* a2);
+		
+		TBool HandleEventKillThread(DThread* a1);
+		TBool HandleSwException(TExcType aExcType);
+		TBool HandleHwException(TArmExcInfo* aExcInfo);
+		TBool HandleUserTrace(TText* aStr, TInt aLen);
+		
+		void AddProcess(DProcess *aProcess, DThread *aThread);
+		void StartThread(DThread *aThread);
+		void RemoveProcess(DProcess *aProcess);
+		void AddLibrary(DLibrary *aLibrary, DThread *aThread);
+		void RemoveLibrary(DLibrary *aLibrary);
+		void AddCodeSegment(DCodeSeg *aCodeSeg, DProcess *aProcess);
+		void RemoveCodeSegment(DCodeSeg *aCodeSeg, DProcess *aProcess);
+
+	private:
+		/** Lock serialising calls to event handler */
+		DSemaphore* iLock;
+		TBool iTracking;
+		/** Tracking list (of TTrackedObject).
+			Must be accessed only when tracking is disabled or with iLock held.
+			Object addresses are used as keys and so must be unique.
+		 */
+		TInt iOOM;
+		TInt iErrorCount;
+		TInt iCounters[EEventLimit];
+		
+		DLogicalDevice* iDevice;	// open reference to LDD for avoiding lifetime issues
+		DThread* iClientThread;
+		DLogicalChannel* iChannel;
+};
+
+#endif //__TRKEVENTHANDLER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/TrkKernelDriver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,4780 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifdef __WINS__
+#error - this driver cannot be built for emulation
+#endif
+
+#include <e32def.h>
+#include <e32cmn.h>
+#include <u32std.h>
+#include <kernel.h>
+#include <kern_priv.h>
+#include <nk_trace.h>
+//#include <mmboot.h>
+#include <arm.h>
+#include <cache.h>
+#include <platform.h>
+#include <nkern.h>
+#include <u32hal.h>
+
+#include "TrkKernelDriver.h"
+#include "TrkDriver.h"
+#include "TrkEventHandler.h"
+
+#define KTrkAppSecurUid 0x200170BB
+#define KTrkExeSecurUid 0x200159E2
+#define KTrkSrvSecurUid 0x200170B7
+
+// Uncomment the line below for reading kernel thread registers.
+// There is a problem using NKern::Lock before calling UserContextType on old releases like S60 3.0
+// So for now, disabling the supporting reading kern thread registers as we are not really supporting
+// device driver debugging anyway.
+//#define SUPPORT_KERNCONTEXT
+
+//
+// Static function definitions
+//
+
+static TInt Bitcount(TUint32 val)
+{
+	TInt nbits;
+
+	for (nbits = 0; val != 0; nbits++)
+	{
+		val &= val - 1;		// delete rightmost 1-bit in val
+	}
+	
+	return nbits;
+}
+
+static TUint8 tolower(TUint8 c)
+{
+	if (c >= 'A' && c <= 'Z')
+		c = c + ('a' - 'A');
+	
+	return c;
+}
+
+
+static TInt _strnicmp(const TUint8 *s1, const TUint8 *s2, int n)
+{	
+    int i;
+    TUint8 c1, c2;
+    for (i=0; i<n; i++)
+    {
+        c1 = tolower(*s1++);
+        c2 = tolower(*s2++);
+        if (c1 < c2) return -1;
+        if (c1 > c2) return 1;
+        if (!c1) return 0;
+    }
+    return 0;
+}
+
+//
+//
+// DMetroTrkDriverFactory implementation
+//
+//
+
+//
+// DMetroTrkDriverFactory constructor
+//
+DMetroTrkDriverFactory::DMetroTrkDriverFactory()
+{
+    iVersion = TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);    
+}
+
+//
+// DMetroTrkDriverFactory::Create
+//
+TInt DMetroTrkDriverFactory::Create(DLogicalChannelBase*& aChannel)
+{
+	if (iOpenChannels != 0)
+		return KErrInUse; // a channel is already open
+	
+	aChannel = new DMetroTrkChannel(this);
+	
+	return aChannel ? KErrNone : KErrNoMemory;
+}
+
+//
+// DMetroTrkDriverFactory::Install
+//
+TInt DMetroTrkDriverFactory::Install()
+{
+    return(SetName(&KMetroTrkDriverName));
+}
+
+//
+// DMetroTrkDriverFactory::Install
+//
+void DMetroTrkDriverFactory::GetCaps(TDes8& aDes) const
+{
+    TCapsMetroTrkDriver b;
+    b.iVersion = TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber);
+    
+    Kern::InfoCopy(aDes,(TUint8*)&b, sizeof(b));
+}
+
+
+//
+//
+// DMetroTrkChannel implementation
+//
+//
+
+//
+// DMetroTrkChannel constructor
+//
+DMetroTrkChannel::DMetroTrkChannel(DLogicalDevice* aLogicalDevice)
+	: iExcludedROMAddressStart(ROM_LINEAR_BASE),
+      iExcludedROMAddressEnd(0),
+   	  iBreakPointList(NUMBER_OF_TEMP_BREAKPOINTS, 0),
+  	  iNextBreakId(NUMBER_OF_TEMP_BREAKPOINTS),
+      iEventInfo(NULL),
+  	  iEventQueue(NUMBER_OF_EVENTS_TO_QUEUE, 0),
+  	  iTraceEventQueue(NUMBER_OF_EVENTS_TO_QUEUE, 0),
+      iRequestGetEventStatus(NULL),
+   	  iPageSize(0x1000),
+   	  iNotifyLibLoadedEvent(ETrue),
+   	  iMultipleMemModel(EFalse),
+   	  iExcInfoValid(EFalse),
+   	  iDebugging(ETrue)
+{
+	LOG_MSG("DMetroTrkChannel::DMetroTrkChannel()");
+
+	iDevice = aLogicalDevice;
+	
+	iClientThread = &Kern::CurrentThread();
+	TInt err = iClientThread->Open();
+	
+	iBreakPointList.Reset();	
+	TBreakEntry emptyTempBreak;
+	
+	for (TInt i = 0; i < NUMBER_OF_TEMP_BREAKPOINTS; i++)
+	{
+		emptyTempBreak.iId = i;
+		
+		if (KErrNone != iBreakPointList.Append(emptyTempBreak))
+		{
+			LOG_MSG("Error appending blank temp break entry");
+		}
+	}
+	
+	SEventInfo emptyEvent;
+
+	for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
+	{
+		if (KErrNone != iEventQueue.Append(emptyEvent))
+		{
+			LOG_MSG("Error appending blank event entry");
+		}
+	}
+	
+	for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
+	{
+		if (KErrNone != iTraceEventQueue.Append(emptyEvent))
+		{
+			LOG_MSG("Error appending blank trace event entry");
+		}
+	}
+		
+	TTrkLibName emptyLib;
+	for (TInt i=0; i<NUMBER_OF_LIBS_TO_REGISTER; i++)
+    {
+        if (KErrNone != iLibraryNotifyList.Append(emptyLib))
+        {
+            LOG_MSG("Error appending blank empty lib entry");
+        }
+    }
+		
+	iPageSize = Kern::RoundToPageSize(1);
+}
+
+//
+// DMetroTrkChannel destructor
+//
+DMetroTrkChannel::~DMetroTrkChannel()
+{
+	LOG_MSG("DMetroTrkChannel::~DMetroTrkChannel()");
+	
+	iDebugging = EFalse;
+	
+	Kern::SafeClose((DObject*&)iClientThread, NULL);
+	
+	ClearAllBreakPoints();
+	
+	// close the breakpoint list and free the memory associated with it
+	iBreakPointList.Close();
+
+	// close the event queue and free the memory associated with it
+	iEventQueue.Close();
+	
+	// close the trace event queue and free the memory associated with it
+	iTraceEventQueue.Close();
+	
+	//close the debug process list
+	iDebugProcessList.Close();
+	
+	//close the process notify list
+	iProcessNotifyList.Close();
+	
+	//close the code modifier
+	DebugSupport::CloseCodeModifier();
+
+	// PANIC_BACKPORT
+	// Resume all the frozen threads with semaphores.
+	for(TInt i=0; i<iFrozenThreadSemaphores.Count(); i++)
+	{
+		NKern::FSSignal(iFrozenThreadSemaphores[i]);
+		NKern::ThreadEnterCS();
+		delete iFrozenThreadSemaphores[i];
+		NKern::ThreadLeaveCS();
+		iFrozenThreadSemaphores.Remove(i);		
+	}
+	//Reset the array and delete the objects that its members point to
+	iFrozenThreadSemaphores.ResetAndDestroy();
+	// END PANIC_BACKPORT
+}
+
+//
+// DMetroTrkChannel::DoCreate
+//
+TInt DMetroTrkChannel::DoCreate(TInt /*aUnit*/, const TDesC* anInfo, const TVersion& aVer)
+{
+	LOG_MSG("DMetroTrkChannel::DoCreate()");
+
+  	if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber), aVer))
+		return KErrNotSupported; 
+  	
+  	// Do the security check here so that any arbitrary application doesn't make 
+  	// use of Trk kernel driver.
+  	if (!DoSecurityCheck())
+  	{
+  		return KErrPermissionDenied;
+  	}
+  	
+  	if (anInfo)
+  	{
+  		// this is the end address of the user library. 
+  		// this doesn't seem to be valid for EKA2.
+  		// right now we dont need this for EKA2 since we are not worried
+  		// about kernel being stopped as kernel is multithreaded.
+  		// just retaining this for future use.		
+		TBuf8<32> buf;
+		TInt err = Kern::ThreadRawRead(iClientThread, anInfo, &buf, 32);
+		if(err != KErrNone)
+			return err;
+		
+		//iExcludedROMAddressEnd = *(TUint32 *)(&(buf.Ptr()[20]));
+	}
+  	
+  	//check whether the memory model is multiple or not.
+  	TUint32 memModelAttrib = (TUint32)Kern::HalFunction(EHalGroupKernel, EKernelHalMemModelInfo, NULL, NULL);	
+	if ((memModelAttrib & EMemModelTypeMask) == EMemModelTypeMultiple) 
+    { 
+        //Multiple memory model
+        iMultipleMemModel = ETrue;        
+    } 
+
+	TUint caps; //ignored for now
+	TInt err = DebugSupport::InitialiseCodeModifier(caps, NUMBER_OF_MAX_BREAKPOINTS);
+	//if code modifier initializer failed, 
+	//return here, since we can't set an breakpoints
+	if(err != KErrNone) 
+		return err;
+		       
+	//Setup the driver for receiving client messages
+	iDFCQue = NULL;
+	TBuf8<KMaxInfoName> trkDFC = _L8("TRK DFC");
+	
+	err = Kern::DfcQCreate(iDFCQue, 27, &trkDFC);
+	if (err == KErrNone)
+	{
+		SetDfcQ(iDFCQue);
+	}
+	else
+	{
+		SetDfcQ(Kern::DfcQue0());
+	}
+	iMsgQ.Receive();  	
+	
+	iEventHandler = new DMetroTrkEventHandler;
+	if (!iEventHandler)
+		return KErrNoMemory;
+	err = iEventHandler->Create(iDevice, this, iClientThread);
+	if (err != KErrNone)
+		return err;
+		
+	return iEventHandler->Start();
+}
+
+//
+// DMetroTrkChannel::DoCancel
+//
+void DMetroTrkChannel::DoCancel(TInt aReqNo)
+{
+	LOG_MSG("DMetroTrkChannel::DoCancel()");
+	
+	switch(aReqNo)
+	{
+		case RMetroTrkDriver::ERequestGetEventCancel:
+		{
+			Kern::RequestComplete(iClientThread, iRequestGetEventStatus, KErrCancel);
+			iEventInfo = NULL;
+			iRequestGetEventStatus = 0;
+		}
+		break;
+	}
+
+}
+
+//
+// DMetroTrkChannel::DoRequest
+//
+void DMetroTrkChannel::DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2)
+{
+	LOG_MSG("DMetroTrkChannel::DoRequest()");
+	
+	switch(aReqNo)
+	{
+		case RMetroTrkDriver::ERequestGetEvent:
+		{
+			// check to see if we have any queued up events
+			for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
+			{
+				if (SEventInfo::EUnknown != iEventQueue[i].iEventType)
+				{
+					LOG_MSG("DoRequest - slot NOT empty");
+					// iClientThread is the user side debugger thread, so use it to write the info to it memory
+					TInt err = Kern::ThreadRawWrite(iClientThread, a1, (TUint8 *)&iEventQueue[i], sizeof(SEventInfo), iClientThread);
+					if (KErrNone != err)
+						LOG_MSG2("Error writing event info: %d", err);
+
+					// signal the debugger thread
+					Kern::RequestComplete(iClientThread, aStatus, KErrNone);
+				
+					iEventQueue[i].Reset();
+					return;
+				}
+				
+				LOG_MSG("DoRequest - slot empty");
+			}
+
+			// check to see if we have any queued up trace events
+			for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
+			{
+				if (SEventInfo::EUnknown != iTraceEventQueue[i].iEventType)
+				{
+					LOG_MSG("DoRequest - slot NOT empty");
+					// iClientThread is the user side debugger thread, so use it to write the info to it memory
+					TInt err = Kern::ThreadRawWrite(iClientThread, a1, (TUint8 *)&iTraceEventQueue[i], sizeof(SEventInfo), iClientThread);
+					if (KErrNone != err)
+						LOG_MSG2("Error writing trace event info: %d", err);
+
+					// signal the debugger thread
+					Kern::RequestComplete(iClientThread, aStatus, KErrNone);
+				
+					iTraceEventQueue[i].Reset();
+					return;
+				}
+				
+				LOG_MSG("DoRequest - trace slot empty");
+			}
+			
+			// store the pointer so we can modify it later
+			iEventInfo = (SEventInfo *)a1;
+			iRequestGetEventStatus = aStatus;
+			break;
+		}		
+		default:
+			Kern::RequestComplete(iClientThread, aStatus, KErrNotSupported);
+	}
+
+}
+
+//
+// DMetroTrkChannel::DoControl
+//
+TInt DMetroTrkChannel::DoControl(TInt aFunction, TAny* a1, TAny* a2)
+{
+	LOG_MSG("DMetroTrkChannel::DoControl()");
+
+	LOG_MSG2("DoControl Function %d", aFunction);
+	
+	TInt err = KErrNone;
+	
+	switch(aFunction)
+	{
+		case RMetroTrkDriver::EControlSetBreak:
+		{
+			err = SetBreak((TUint32)a1, (TMetroTrkBreakInfo*)a2);
+			break;
+		}
+		case RMetroTrkDriver::EControlClearBreak:
+		{
+			err = DoClearBreak((TInt32)a1);
+			break;
+		}
+		case RMetroTrkDriver::EControlChangeBreakThread:
+		{
+			err = DoChangeBreakThread((TUint32)a1, (TInt32)a2);
+			break;
+		}
+		case RMetroTrkDriver::EControlSuspendThread:
+		{
+			err = DoSuspendThread(ThreadFromId((TUint32)a1));
+			break;
+		}
+		case RMetroTrkDriver::EControlResumeThread:
+		{			
+			err = DoResumeThread(ThreadFromId((TUint32)a1));
+			break;
+		}
+		case RMetroTrkDriver::EControlStepRange:
+		{
+			err = StepRange(ThreadFromId((TUint32)a1), (TMetroTrkStepInfo*)a2);
+			break;
+		}
+		case RMetroTrkDriver::EControlReadMemory:
+		{
+			err = ReadMemory(ThreadFromId((TUint32)a1), (TMetroTrkMemoryInfo*)a2);
+			break;
+		}
+		case RMetroTrkDriver::EControlWriteMemory:
+		{
+			err = WriteMemory(ThreadFromId((TUint32)a1), (TMetroTrkMemoryInfo*)a2);
+			break;
+		}
+		case RMetroTrkDriver::EControlReadRegisters:
+		{
+			err = ReadRegisters(ThreadFromId((TUint32)a1), (TMetroTrkRegisterInfo*)a2);
+			break;
+		}
+		case RMetroTrkDriver::EControlWriteRegisters:
+		{
+			err = WriteRegisters(ThreadFromId((TUint32)a1), (TMetroTrkRegisterInfo*)a2);
+			break;
+		}
+		case RMetroTrkDriver::EControlGetProcessInfo:
+		{
+			err = GetProcessInfo((TInt)a1, (TMetroTrkTaskInfo*)a2);
+			break;
+		}
+		case RMetroTrkDriver::EControlGetThreadInfo:
+		{
+			err = GetThreadInfo((TInt)a1, (TMetroTrkTaskInfo*)a2);
+			break;
+		}
+		case RMetroTrkDriver::EControlGetProcessAddresses:
+		{
+			err = GetProcessAddresses(ThreadFromId((TUint32)a1), (TMetroTrkProcessInfo*)a2);
+			break;
+		}
+		case RMetroTrkDriver::EControlGetStaticLibraryInfo:
+		{
+			err = GetStaticLibraryInfo((TInt)a1, (SEventInfo*)a2);
+			break;
+		}
+		case RMetroTrkDriver::EControlEnableLibLoadedEvent:
+		{
+			iNotifyLibLoadedEvent = ETrue;
+			break;
+		}
+		case RMetroTrkDriver::EControlDisableLibLoadedEvent:
+		{
+			iNotifyLibLoadedEvent = EFalse;
+			break;
+		}
+		case RMetroTrkDriver::EControlGetLibraryInfo:
+		{
+			err = GetLibraryInfo((TMetroTrkLibInfo*)a1);
+			break;
+		}
+		case RMetroTrkDriver::EControlGetExeInfo:
+		{
+			err = GetExeInfo((TMetroTrkExeInfo*)a1);
+			break;
+		}
+		case RMetroTrkDriver::EControlGetProcUidInfo:
+		{	
+			err = GetProcUidInfo((TMetroTrkProcUidInfo*)a1);
+			break;
+		}
+		case RMetroTrkDriver::EControlDetachProcess:
+		{
+		    err = DetachProcess(ProcessFromId((TInt32)a1));
+			break;
+		}
+		default:
+		{
+			return KErrGeneral;
+		}
+	}
+	
+	if (KErrNone != err)
+	{
+		LOG_MSG2("Error %d from control function", err);
+	}
+	
+	return err;
+}
+
+void DMetroTrkChannel::HandleMsg(TMessageBase* aMsg)
+{
+	LOG_MSG("DMetroTrkChannel::HandleMsg()");
+	
+	TThreadMessage& m = *(TThreadMessage*)aMsg;
+	TInt id = m.iValue;
+
+
+	if (id == (TInt)ECloseMsg)
+	{
+		if (iEventHandler)
+		{
+			iDebugging = EFalse;
+			iEventHandler->Stop();
+			iEventHandler->Close();
+			iEventHandler = NULL;
+		}
+		m.Complete(KErrNone, EFalse);
+		return;
+	}
+
+	if (id == KMaxTInt)
+	{
+		// DoCancel
+		DoCancel(m.Int0());
+		m.Complete(KErrNone, ETrue); 
+		return;
+	}
+
+	if (id < 0)
+	{
+		// DoRequest
+		TRequestStatus* pStatus = (TRequestStatus*)m.Ptr0();
+		DoRequest(~id, pStatus, m.Ptr1(), m.Ptr2());
+		m.Complete(KErrNone, ETrue);
+	}
+	else
+	{
+		// DoControl
+		TInt err = DoControl(id, m.Ptr0(), m.Ptr1());
+		m.Complete(err, ETrue);
+	}
+}
+
+//
+// DMetroTrkChannel::AddProcess
+//
+void DMetroTrkChannel::AddProcess(DProcess *aProcess, DThread *aThread)
+{
+	LOG_MSG("DMetroTrkChannel::AddProcess()");
+	// check to see if we are still debugging, otherwise just return
+	if (!iDebugging) 
+		return;
+
+	if (aProcess)
+	{		
+		if (!aThread)
+			LOG_MSG("Creator thread not available");
+	
+		// check to see if this process is being started by debug agent.
+		// If this is the case, we don't need to notify the agent since the debug agent already knows about it.
+		if (aThread && aThread->iOwningProcess->iId == iClientThread->iOwningProcess->iId)
+			return;		
+		
+		SEventInfo processEventInfo;
+		processEventInfo.iEventType = processEventInfo.EProcessAdded; 
+		processEventInfo.iProcessId = aProcess->iId;
+		processEventInfo.iFileName.Copy(*aProcess->iName);
+		processEventInfo.iUid = aProcess->iUids.iUid[2].iUid; 		
+
+		// Kernel hasn't created teh code segment yet for this process,
+		// so queue this event separately and wait for start thread event to notify.
+		iProcessNotifyList.Append(processEventInfo);	
+	}	
+}
+
+//
+// DMetroTrkChannel::StartThread
+//
+void DMetroTrkChannel::StartThread(DThread *aThread)
+{
+	LOG_MSG("DMetroTrkChannel::StartThread()");
+	// check to see if we are still debugging, otherwise just return
+	if (!iDebugging) 
+		return;
+	
+	// Using the lib loaded event flag for notifying processes as well.
+	// Check if lib loaded event is disabled. Lib loaded event
+	// is disabled temporarily in some situations, when the engine
+	// is performing some complex operations  like installing sis 
+	// files, in which case, suspending the thread for lib loaded 
+	// events would end up in a dead lock. This is due  to the fact 
+	// that the active object that handles the event notification 
+	// wouldn't get a chance to run since the code in TRK engine  
+	// which handles the commands from the host debugger is also 
+	// done in an active object which runs in the same thread. 
+	if (!iNotifyLibLoadedEvent)
+		return;
+	
+	if (aThread && aThread->iOwningProcess)
+	{				
+		DCodeSeg* codeSeg = aThread->iOwningProcess->iCodeSeg;		
+		if (codeSeg)
+		{
+			TModuleMemoryInfo processMemoryInfo;
+			TInt err = codeSeg->GetMemoryInfo(processMemoryInfo, aThread->iOwningProcess);
+			if (err == KErrNone)
+			{						
+				for (TInt i = 0; i < iProcessNotifyList.Count(); i++)
+				{
+					if (iProcessNotifyList[i].iProcessId == aThread->iOwningProcess->iId)
+					{
+						// Suspend the thread so that the host debugger can set breakpoints.
+						Kern::ThreadSuspend(*aThread, 1); 
+						iProcessNotifyList[i].iThreadId = aThread->iId;
+						iProcessNotifyList[i].iCodeAddress = processMemoryInfo.iCodeBase;
+						iProcessNotifyList[i].iDataAddress = processMemoryInfo.iInitialisedDataBase;
+						// Notify the process added event now that we have the code segment for the process
+						NotifyEvent(iProcessNotifyList[i]);
+						// Now remove from the list
+						iProcessNotifyList.Remove(i);
+						break;
+					}
+				}
+			}
+			else
+			{
+				LOG_MSG2("Error in getting memory info: %d", err);
+			}			
+		}
+		else
+		{
+			LOG_MSG2("Invalid code segment found for the started thread: %d", aThread->iId);
+		}
+	}	
+}
+
+//
+// DMetroTrkChannel::RemoveProcess
+//
+void DMetroTrkChannel::RemoveProcess(DProcess *aProcess)
+{
+	LOG_MSG("DMetroTrkChannel::RemoveProcess()");
+	// check to see if we are still debugging, otherwise just return
+	if (!iDebugging) 
+		return;
+
+	// this is called when a process dies.  we want to mark any breakpoints in this
+	// process space as obsolete.  the main reason for this is so we don't return
+	// an error when the host debugger tries to clear breakpoints for the process
+	
+	TUint32 codeAddress = 0;
+	TUint32 codeSize = 0;
+	
+	LOG_MSG2("Process being removed, Name %S", aProcess->iName);
+	
+	DCodeSeg* codeSeg = aProcess->iCodeSeg;
+	
+	if (codeSeg)
+	{
+		TModuleMemoryInfo processMemoryInfo;
+		TInt err = codeSeg->GetMemoryInfo(processMemoryInfo, aProcess);
+		if (err != KErrNone)
+		{
+		
+			codeAddress = processMemoryInfo.iCodeBase;
+			codeSize = processMemoryInfo.iCodeSize;
+		}
+		else
+		{
+			LOG_MSG2("Error in getting memory info: %d", err);
+		}
+		
+	}
+	
+	if (!codeAddress || !codeSize)
+	{
+		LOG_MSG2("Code segment not available for process %d", aProcess->iId);
+		// make sure there is not already a breakpoint at this address
+		for (TInt i = 0; i < iDebugProcessList.Count(); i++)
+		{
+			if (iDebugProcessList[i].iId == aProcess->iId)
+			{
+				codeAddress = iDebugProcessList[i].iCodeAddress;
+				codeSize = iDebugProcessList[i].iCodeSize;
+				
+				//now remove from the list
+				iDebugProcessList.Remove(i);
+				break;
+			}
+		}
+	}
+	
+	if (!codeAddress || !codeSize)
+		return;
+		
+	// first invalidate all breakpoints that were set in the library code
+	for (TInt i=0; i<iBreakPointList.Count(); i++)
+	{
+		if ((iBreakPointList[i].iAddress >= codeAddress) && (iBreakPointList[i].iAddress < (codeAddress + codeSize)))
+		{
+			LOG_MSG2("Disabling process breakpoint at address %x", iBreakPointList[i].iAddress);
+			iBreakPointList[i].iObsoleteLibraryBreakpoint = ETrue;
+		}
+	}
+}
+
+
+//
+// DMetroTrkChannel::AddLibrary
+//
+void DMetroTrkChannel::AddLibrary(DLibrary *aLibrary, DThread *aThread)
+{
+	LOG_MSG("DMetroTrkChannel::AddLibrary()");
+	
+	LOG_MSG2(("Lib loaded: %S"), aLibrary->iName);
+	
+	// check to see if we are still debugging, otherwise just return
+	if (!iDebugging) 
+		return;
+	
+	// Check if lib loaded event is disabled. Lib loaded event
+	// is disabled temporarily in some situations, when the engine
+	// is performing some complex operations  like installing sis 
+	// files, in which case, suspending the thread for lib loaded 
+	// events would end up in a dead lock. This is due  to the fact 
+	// that the active object that handles the event notification 
+	// wouldn't get a chance to run since the code in TRK engine  
+	// which handles the commands from the host debugger is also 
+	// done in an active object which runs in the same thread. 
+	if (!iNotifyLibLoadedEvent)
+		return;
+
+	TBool isDebugging = EFalse;	
+	for (TInt i = 0; i < iDebugProcessList.Count(); i++)
+	{
+		if (iDebugProcessList[i].iId == aThread->iOwningProcess->iId)
+		{
+			isDebugging = ETrue;
+			break;
+		}
+	}
+	if (isDebugging == EFalse)
+		return;
+
+	if (aThread)
+	{
+		// make sure this is not the debugger thread
+		if ((aThread != iClientThread) && (aThread->iOwningProcess->iId != iClientThread->iOwningProcess->iId))
+		{
+			SEventInfo info;
+
+			Kern::ThreadSuspend(*aThread, 1); 
+			
+			info.iEventType = SEventInfo::ELibraryLoaded;
+			info.iProcessId = aThread->iOwningProcess->iId;
+			info.iThreadId = aThread->iId;
+			
+			//get the code address
+			DCodeSeg* codeSeg = aLibrary->iCodeSeg;
+			if (!codeSeg)
+			{
+				LOG_MSG2("Code segment not available for library %S", aLibrary->iName);
+				return;
+			}
+			
+			TModuleMemoryInfo memoryInfo;
+			TInt err = codeSeg->GetMemoryInfo(memoryInfo, NULL); //NULL for DProcess should be ok;
+			if (err != KErrNone)
+			{
+				LOG_MSG2("Error in getting memory info: %d", err);
+				return;
+			}
+				
+			info.iCodeAddress = memoryInfo.iCodeBase;
+			info.iDataAddress = memoryInfo.iInitialisedDataBase;
+			
+			info.iFileName.Copy(*(aLibrary->iName)); //just the name, without uid info.
+						
+			// now remove this library if its in our notify list
+			for (TInt i =0; i<iLibraryNotifyList.Count(); i++)
+			{
+				if (!iLibraryNotifyList[i].iEmptySlot &&
+				    !_strnicmp(iLibraryNotifyList[i].iName.Ptr(), info.iFileName.Ptr(), info.iFileName.Length()))
+				{										
+					iLibraryNotifyList[i].iEmptySlot = ETrue;
+					break;
+				}
+			}
+			// now check to see if any libs are loaded because of this library load event.
+			CheckLibraryNotifyList(info.iProcessId);
+			//queue up or complete the event
+			NotifyEvent(info);
+		}
+	
+	}
+		
+}
+
+//
+// DMetroTrkChannel::RemoveLibrary
+//
+void DMetroTrkChannel::RemoveLibrary(DLibrary *aLibrary)
+{
+	LOG_MSG("DMetroTrkChannel::RemoveLibrary()");
+	LOG_MSG2(("Lib unloaded: %S"), aLibrary->iName);
+	
+	// check to see if we are still debugging, otherwise just return
+	if (!iDebugging) 
+		return;
+	
+	// this is called when all handles to this library have been closed.  this can happen when a process dies, or when a dll is
+	// unloaded while the process lives on.  in former case, we don't need to notify the host debugger because that process is
+	// dying anyway.  for the latter case, we do need to notify the host so it can unload the symbolics, etc.
+	
+	DThread* aThread = &Kern::CurrentThread();
+   
+	if ((aThread) &&
+       (aThread != iClientThread) && 
+       (aThread->iOwningProcess->iId != iClientThread->iOwningProcess->iId))
+	{
+		//the library gets unloaded only when the mapcount is 0.
+		if (aLibrary->iMapCount != 0)
+			return;
+		
+		DCodeSeg* codeSeg = aLibrary->iCodeSeg;
+		if (!codeSeg)
+		{
+			LOG_MSG2("Code segment not available for library %S", aLibrary->iName);
+			return;
+		}
+		
+		TModuleMemoryInfo processMemoryInfo;
+		TInt err = codeSeg->GetMemoryInfo(processMemoryInfo, NULL); //passing NULL for the DProcess argument should be ok;
+		if (err != KErrNone)
+		{
+			LOG_MSG2("Error in getting memory info: %d", err);
+			return;
+		}
+		
+		TUint32 codeAddress = processMemoryInfo.iCodeBase;
+		TUint32 codeSize = processMemoryInfo.iCodeSize;
+		
+		// first invalidate all breakpoints that were set in the library code
+		for (TInt i=0; i<iBreakPointList.Count(); i++)
+		{
+			if ((iBreakPointList[i].iAddress >= codeAddress) && (iBreakPointList[i].iAddress < (codeAddress + codeSize)))
+			{
+				LOG_MSG2("Disabling library breakpoint at address %x", iBreakPointList[i].iAddress);
+				iBreakPointList[i].iObsoleteLibraryBreakpoint = ETrue;
+			}
+		}
+
+	   	DProcess *process = &Kern::CurrentProcess();
+	   	if (process)
+	   	{
+			RArray<SCodeSegEntry>* dynamicCode = &(process->iDynamicCode);			
+			if (dynamicCode)
+			{
+				for (TInt j=0; j<dynamicCode->Count(); j++)
+				{
+					if ((*dynamicCode)[j].iLib == aLibrary)
+					{
+						SEventInfo info;
+						
+						info.iEventType = SEventInfo::ELibraryUnloaded;
+						info.iFileName.Copy(*(aLibrary->iName)); //lib name without uid info
+						//info.iFileName.ZeroTerminate();
+						info.iProcessId = process->iId;
+						info.iThreadId = 0xFFFFFFFF; // don't care!
+						
+						//queue up or complete the event
+						NotifyEvent(info);
+					}
+				}
+			}
+		}
+	}
+}
+
+
+//
+// DMetroTrkChannel::AddCodeSegment
+//
+void DMetroTrkChannel::AddCodeSegment(DCodeSeg *aCodeSeg, DProcess *aProcess)
+{
+	LOG_MSG("DMetroTrkChannel::AddCodeSegment()");
+	
+	// Check if lib loaded event is disabled. Lib loaded event
+	// is disabled temporarily in some situations, when the engine
+	// is performing some complex operations  like installing sis 
+	// files, in which case, suspending the thread for lib loaded 
+	// events would end up in a dead lock. This is due  to the fact 
+	// that the active object that handles the event notification 
+	// wouldn't get a chance to run since the code in TRK engine  
+	// which handles the commands from the host debugger is also 
+	// done in an active object which runs in the same thread. 
+	if (!iNotifyLibLoadedEvent)
+		return;	
+
+	TBool isDebugging = EFalse;	
+	for (TInt i = 0; i < iDebugProcessList.Count(); i++)
+	{
+		if (iDebugProcessList[i].iId == aProcess->iId)
+		{
+			isDebugging = ETrue;
+			break;
+		}
+	}
+	if (isDebugging == EFalse)
+		return;
+		
+	if (aCodeSeg)
+	{
+		const TUint8* ptr = aCodeSeg->iFileName->Ptr();
+		if (aCodeSeg->IsDll())
+		{
+			LOG_MSG2("DLL code segment is loaded: %s", ptr);
+			
+			DThread* mainThread = aProcess->FirstThread();
+			if (mainThread)
+			{
+				// make sure this is not the debugger thread
+				if ((mainThread->iId != iClientThread->iId) && (aProcess->iId != iClientThread->iOwningProcess->iId))
+				{
+					SEventInfo info;
+
+					//DoSuspendThread(mainThread); 
+					Kern::ThreadSuspend(*mainThread, 1);
+					
+					info.iEventType = SEventInfo::ELibraryLoaded;
+					info.iProcessId = aProcess->iId;
+					info.iThreadId = mainThread->iId;				
+					
+					TModuleMemoryInfo memoryInfo;
+					TInt err = aCodeSeg->GetMemoryInfo(memoryInfo, NULL); //NULL for DProcess should be ok;
+					if (err != KErrNone)
+					{
+						LOG_MSG2("Error in getting memory info: %d", err);
+						return;
+					}
+						
+					info.iCodeAddress = memoryInfo.iCodeBase;
+					info.iDataAddress = memoryInfo.iInitialisedDataBase;
+					
+					info.iFileName.Copy(aCodeSeg->iRootName); //just the name, without uid info.
+								
+					//queue up or complete the event
+					NotifyEvent(info);
+				}
+		
+			}
+			else
+			{
+				LOG_MSG2("Invalid main thread for this process: %d", aProcess->iId);
+			}
+
+		}
+		else 
+		{
+			if (aCodeSeg->IsExe())
+				LOG_MSG2("EXE code segment is loaded: %s", ptr);		
+		}
+		
+	}	
+
+}
+
+//
+// DMetroTrkChannel::RemoveCodeSegment
+//
+void DMetroTrkChannel::RemoveCodeSegment(DCodeSeg *aCodeSeg, DProcess *aProcess)
+{
+	LOG_MSG("DMetroTrkChannel::RemoveCodeSegment()");
+	
+	// We don't do anything right now as we are not using the code segment events.		
+
+}
+
+//
+// DMetroTrkChannel::HandleEventKillThread
+//
+TBool DMetroTrkChannel::HandleEventKillThread(DThread* aThread)
+{
+	LOG_MSG("DMetroTrkChannel::HandleEventKillThread");
+	// check to see if we are still debugging, otherwise just return
+	if (!iDebugging) 
+		return EFalse;
+
+	if (!aThread)
+	{
+		LOG_MSG("Invalid thread handle");
+		return EFalse;
+	}
+
+
+	DThread* currentThread = &Kern::CurrentThread();
+	if (!currentThread)
+	{
+		LOG_MSG("Error getting current thread");
+		return EFalse;
+	}
+
+	//Kern::ThreadSuspend(*currentThread, 1); 
+	
+	if (aThread->iExitType != EExitPanic)
+	{
+		return EFalse;
+	}
+		
+	SEventInfo info;
+	
+	info.iProcessId = aThread->iOwningProcess->iId;
+	info.iThreadId = aThread->iId;
+	info.iCurrentPC = ReadRegister(aThread, 14);//PC_REGISTER); 
+	info.iPanicCategory.Copy(aThread->iExitCategory);
+	
+	info.iExceptionNumber = 100;//aThread->iExitReason;
+	info.iPanicReason = aThread->iExitReason;
+	info.iEventType = SEventInfo::EThreadPanic;
+
+	// if its not an invalide opcode exception, check to see if we are debugging 
+	// the process.
+	TBool isDebugging = EFalse;	
+	for (TInt i = 0; i < iDebugProcessList.Count(); i++)
+	{
+		if (iDebugProcessList[i].iId == info.iProcessId)
+		{
+			isDebugging = ETrue;
+			break;
+		}
+	}
+	if (!isDebugging)
+		return EFalse;
+	
+#define DOFREEZE 1
+	// PANIC_BACKPORT
+#if DOFREEZE
+	NKern::ThreadEnterCS();
+	NFastSemaphore* sem = new NFastSemaphore();
+	NKern::ThreadLeaveCS();
+//	sem->iOwningThread = &(Kern::CurrentThread().iNThread);
+	sem->iOwningThread = &aThread->iNThread;
+	iFrozenThreadSemaphores.Append(sem);
+	// First do the notify, then FSWait
+	NotifyEvent(info);
+	NKern::FSWait(sem);	
+	return ETrue;
+#else
+	NotifyEvent(info);
+	LOG_MSG("DMetroTrkChannel::HandleEventKillThread - Panic Do Nothing");
+	return EFalse;
+#endif
+	// END PANIC_BACKPORT	
+}
+
+//
+// DMetroTrkChannel::HandleSwException
+//
+TBool DMetroTrkChannel::HandleSwException(TExcType aExcType)
+{
+	LOG_MSG("DMetroTrkChannel::HandleSwException");
+
+	SEventInfo info;
+	
+	DThread* currentThread = &Kern::CurrentThread();
+	if (!currentThread)
+	{
+		LOG_MSG("Error getting current thread");
+		return EFalse;
+	}
+
+	info.iProcessId = currentThread->iOwningProcess->iId;
+	info.iThreadId = currentThread->iId;
+	info.iCurrentPC = ReadRegister(currentThread, PC_REGISTER);
+	info.iExceptionNumber = aExcType;
+	info.iEventType = SEventInfo::EThreadException;
+
+	if (info.iExceptionNumber != EExcInvalidOpCode) 
+	{
+		// if its not an invalide opcode exception, check to see if we are debugging 
+		// the process.
+		TBool isDebugging = EFalse;	
+		for (TInt i = 0; i < iDebugProcessList.Count(); i++)
+		{
+			if (iDebugProcessList[i].iId == info.iProcessId)
+			{
+				isDebugging = ETrue;
+				break;
+			}
+		}
+		if (!isDebugging)
+			return EFalse;
+	}	
+
+	NThread nThread = currentThread->iNThread;
+	
+	if (nThread.iSuspendCount == 0)
+		Kern::ThreadSuspend(*currentThread, 1);
+	
+	HandleException(info, currentThread);
+	
+	return ETrue;
+}
+
+//
+// DMetroTrkChannel::HandleHwException
+//
+TBool DMetroTrkChannel::HandleHwException(TArmExcInfo* aExcInfo)
+{
+	LOG_MSG("DMetroTrkChannel::HandleHwException()");
+
+	SEventInfo info;
+	
+	DThread* currentThread = &Kern::CurrentThread();
+	
+	if (!currentThread)
+	{
+		LOG_MSG("Error getting current thread");
+		return EFalse;
+	}
+
+	//store the exception info as its needed to read the context for system threads
+	iExcInfoValid = ETrue;
+	iCurrentExcInfo = *aExcInfo;
+
+	info.iProcessId = currentThread->iOwningProcess->iId;
+	info.iThreadId = currentThread->iId;
+	info.iCurrentPC = aExcInfo->iR15;
+
+	switch (aExcInfo->iExcCode)
+	{
+		case 0:
+			info.iExceptionNumber = EExcCodeAbort;
+			break;
+		case 1:
+			info.iExceptionNumber = EExcDataAbort;
+			break;
+		case 2:
+			info.iExceptionNumber = EExcInvalidOpCode;
+			break;
+		default:
+			return EFalse;
+		
+	}	
+	info.iEventType = SEventInfo::EThreadException;
+	
+	if (info.iExceptionNumber != EExcInvalidOpCode) 
+	{
+		// if its not an invalide opcode exception, check to see if we are debugging 
+		// the process.
+		TBool isDebugging = EFalse;	
+		for (TInt i = 0; i < iDebugProcessList.Count(); i++)
+		{
+			if (iDebugProcessList[i].iId == info.iProcessId)
+			{
+				isDebugging = ETrue;
+				break;
+			}
+		}
+		if (!isDebugging)
+			return EFalse;
+	}	
+	
+	NThread nThread = currentThread->iNThread;	
+
+	if (nThread.iSuspendCount == 0) //don't suspend the thread if its already suspended.
+		Kern::ThreadSuspend(*currentThread, 1);
+	
+	HandleException(info, currentThread);
+	
+	return ETrue;
+}
+
+//
+// DMetroTrkChannel::HandleException
+//
+void DMetroTrkChannel::HandleException(SEventInfo& aEventInfo, DThread* aCurrentThread)
+{
+	TInt err = KErrNone;
+	// see if it was a breakpoint that stopped the thread
+	if (((TInt)2 == aEventInfo.iExceptionNumber) || ((TInt)EExcInvalidOpCode == aEventInfo.iExceptionNumber))
+	{
+		TUint32 inst = KArmBreakPoint;
+		TInt instSize = 4;
+
+		// change these for thumb mode
+		if (ReadRegister(aCurrentThread, STATUS_REGISTER) & ECpuThumb)
+		{
+			inst = KThumbBreakPoint;
+			instSize = 2;
+		}
+		
+		TUint32 instruction = 0;
+		err = Kern::ThreadRawRead(aCurrentThread, (TUint32 *)aEventInfo.iCurrentPC, (TUint8 *)&instruction, instSize);
+
+		if (KErrNone != err)
+			LOG_MSG2("Error reading instruction at currentpc: %d", err);
+		
+		if (!memcompare((TUint8 *)&inst, instSize, (TUint8 *)&instruction, instSize))
+		{
+			// the exception was a breakpoint instruction.  see if we have a breakpoint at that address
+			for (TInt i=0; i<iBreakPointList.Count(); i++)
+			{
+				TBreakEntry breakEntry = iBreakPointList[i];
+				
+				if (breakEntry.iAddress == aEventInfo.iCurrentPC)
+				{
+					LOG_MSG2("Breakpoint with Id %d has been hit", breakEntry.iId);
+
+					//change the event type to breakpoint type
+					aEventInfo.iEventType = SEventInfo::EThreadBreakPoint;
+					
+				
+					// enable any breakpoints we had to disable for this thread
+					err = DoEnableDisabledBreak(aEventInfo.iThreadId);
+					if (KErrNone != err)
+						LOG_MSG2("Error %d enabling disabled breakpoints", err);
+						
+					// see if this is a temp breakpoint
+					if (i < NUMBER_OF_TEMP_BREAKPOINTS)
+					{
+						// this was a temp breakpoint, so we need to clear it now
+						err = DoClearBreak(i);
+						if (KErrNone != err)
+							LOG_MSG2("Error %d clearing temp breakpoint", err);
+						
+						// if we're not out of range yet, go ahead and single step again
+						// if we are out of range, either continue or report the event depending
+						// on the iResumeOnceOutOfRange flag
+						if ((aEventInfo.iCurrentPC > breakEntry.iRangeStart) && (aEventInfo.iCurrentPC < breakEntry.iRangeEnd))
+						{
+							LOG_MSG("PC is still in range, stepping will continue");
+							err = DoStepRange(aCurrentThread, breakEntry.iRangeStart, breakEntry.iRangeEnd, breakEntry.iSteppingInto, breakEntry.iResumeOnceOutOfRange, breakEntry.iSteppingInto);
+							if (KErrNone != err)
+							{
+								LOG_MSG2("Error in DoStepRange: %d.  Resuming thread.", err);
+								err = DoResumeThread(aCurrentThread);
+								if (KErrNone != err)
+									LOG_MSG2("Error in DoResumeThread: %d", err);
+							}
+							return;												
+						}
+						else
+						{
+							if (breakEntry.iResumeOnceOutOfRange)
+							{
+								LOG_MSG("PC is out of range, continuing thread");
+								DoResumeThread(aCurrentThread);
+								
+								return;
+							}
+						}
+					}
+					
+					// if the breakpoint is thread specific, make sure it's the right thread
+					// if not, just continue the thread.  take special care if it's the debugger
+					// thread.  if it hits a regular breakpoint, we NEVER want to stop at it.  if
+					// it hits a temp breakpoint, we're probably just stepping past a real breakpoint
+					// and we do need to handle it.
+					if (((breakEntry.iThreadId != aEventInfo.iThreadId) && breakEntry.iThreadSpecific)/*(breakEntry.iThreadId != 0xFFFFFFFF))*/ ||
+						((aEventInfo.iProcessId == iClientThread->iOwningProcess->iId) && (breakEntry.iThreadId != aEventInfo.iThreadId)))
+					{
+						LOG_MSG("breakpoint does not match threadId, calling DoResumeThread");
+						err = DoResumeThread(aCurrentThread);
+						if (KErrNone != err)
+							LOG_MSG2("Error in DoResumeThread: %d", err);
+
+						return;					
+					}
+					
+					//normal user break point, just notify the event
+					break;
+				}
+			}
+
+		}
+	}
+	
+	NotifyEvent(aEventInfo);
+}
+
+//
+// DMetroTrkChannel::HandleUserTrace
+//
+TBool DMetroTrkChannel::HandleUserTrace(TText* aStr, TInt aLen)
+{
+	LOG_MSG("DMetroTrkChannel::HandleUserTrace()");
+
+// handle user trace events only for app trk.
+#ifndef __OEM_TRK__ 
+	// check to see if we are still debugging, otherwise just return
+	if (!iDebugging) 
+		return EFalse;
+	
+	DThread* currentThread = &Kern::CurrentThread();
+	
+	if (!currentThread)
+	{
+		LOG_MSG("Error getting current thread");
+		return EFalse;
+	}
+
+	if (currentThread->iOwningProcess->iId == iClientThread->iOwningProcess->iId)
+		return EFalse;
+
+	// only send traces for processes you are debugging	
+	TBool isDebugging = EFalse;	
+	for (TInt i = 0; i < iDebugProcessList.Count(); i++)
+	{
+		if (iDebugProcessList[i].iId == currentThread->iOwningProcess->iId)
+		{
+			isDebugging = ETrue;
+			break;
+		}
+	}
+	if (!isDebugging)
+		return EFalse;
+	
+	if (aLen > 0)
+	{
+		SEventInfo info;
+
+		// This is a temporary solution for grabbing the rdebug printfs.
+		// With the current TRK implementation, we don't have a mechanism for 
+		// using dynamically allocated buffers between the engine and the driver. 
+		// So for now we are limiting the printf strings to 256 bytes.		
+		TUint8 traceStr[260];
+		info.iTraceDataLen = aLen;
+		
+		if (info.iTraceDataLen > 256)
+			info.iTraceDataLen  = 256;
+			
+		XTRAPD(r, XT_DEFAULT, kumemget(traceStr, aStr, info.iTraceDataLen));
+		
+		if (r == KErrNone)
+		{
+			info.iEventType = SEventInfo::EUserTrace;			
+			traceStr[info.iTraceDataLen] = '\r';
+			traceStr[info.iTraceDataLen+1] = '\n';
+			info.iTraceDataLen += 2; // account for \r and \n.
+
+			info.iTraceData.Copy((TUint8*)traceStr, info.iTraceDataLen);
+			NotifyEvent(info, ETrue);										
+		}
+		else
+		{
+			return EFalse;
+		}
+	}
+#endif	
+
+	return ETrue;
+}
+
+
+//
+// DMetroTrkChannel::SetBreak
+//
+TInt DMetroTrkChannel::SetBreak(TUint32 aThreadId, TMetroTrkBreakInfo* aBreakInfo)
+{
+	LOG_MSG("DMetroTrkChannel::SetBreak()");
+
+	TInt err = KErrNone;
+	
+	if (!aBreakInfo)
+		return KErrArgument;
+	
+	//User side memory is not accessible directly
+	TMetroTrkBreakInfo info(0, 0, 0, 0);
+	err = Kern::ThreadRawRead(iClientThread, aBreakInfo, (TUint8*)&info, sizeof(TMetroTrkBreakInfo));
+	if (err != KErrNone)
+		return err;
+				
+	if (!info.iId) //first check if the iId address is valid
+		return KErrArgument;
+				
+	if (err == KErrNone) 
+	{
+		TInt32 iId;
+		
+		err = DoSetBreak(info.iProcessId, aThreadId, info.iAddress, info.iThumbMode, iId);
+		
+		if (err == KErrNone)
+		{
+			err = Kern::ThreadRawWrite(iClientThread, (TUint8 *)info.iId, &iId, sizeof(TInt32), iClientThread);
+		}
+	}
+	return err;
+}
+
+//
+// DMetroTrkChannel::StepRange
+//
+TInt DMetroTrkChannel::StepRange(DThread* aThread, TMetroTrkStepInfo* aStepInfo)
+{
+	LOG_MSG("DMetroTrkChannel::StepRange()");
+
+	TInt err = KErrNone;
+	
+	if (!aStepInfo)
+		return KErrArgument;
+	
+	TMetroTrkStepInfo info(0, 0, 0);
+	err = Kern::ThreadRawRead(iClientThread, aStepInfo, (TUint8*)&info, sizeof(TMetroTrkStepInfo));
+	
+	if (err != KErrNone)
+		return err;
+	
+	err = DoStepRange(aThread, info.iStartAddress, info.iStopAddress, info.iStepInto, EFalse, ETrue);
+	
+	return err;
+}
+
+//
+// DMetroTrkChannel::ReadMemory
+//
+TInt DMetroTrkChannel::ReadMemory(DThread* aThread, TMetroTrkMemoryInfo* aMemoryInfo)
+{
+	LOG_MSG("DMetroTrkChannel::ReadMemory()");
+
+	TInt err = KErrNone;
+	
+	if (!aMemoryInfo)
+		return KErrArgument;
+		
+#ifndef __OEM_TRK__
+	if (!IsBeingDebugged(aThread))
+		return KErrPermissionDenied;
+#endif
+		
+	TMetroTrkMemoryInfo info(0, 0, 0);
+	err = Kern::ThreadRawRead(iClientThread, aMemoryInfo, (TUint8*)&info, sizeof(TMetroTrkMemoryInfo));
+	if (err != KErrNone)
+		return err;
+	
+	if (!info.iData)
+		return KErrArgument;
+
+	TUint8 *data = (TUint8*)Kern::Alloc(info.iLength);
+	if (!data)
+		return KErrNoMemory;
+	
+	TPtr8 dataDes(data, info.iLength);
+		
+	err = DoReadMemory(aThread, info.iAddress, info.iLength, dataDes);
+	if (err != KErrNone)
+		return err;
+	
+	err = Kern::ThreadDesWrite(iClientThread, info.iData, dataDes, 0, KChunkShiftBy0, iClientThread);
+	
+	Kern::Free(data);
+	
+	return err;
+}
+
+//
+// DMetroTrkChannel::WriteMemory
+//
+TInt DMetroTrkChannel::WriteMemory(DThread* aThread, TMetroTrkMemoryInfo* aMemoryInfo)
+{
+	LOG_MSG("DMetroTrkChannel::WriteMemory()");
+
+	TInt err = KErrNone;
+	
+	if (!aMemoryInfo)
+		return KErrArgument;
+	
+#ifndef __OEM_TRK__
+	if (!IsBeingDebugged(aThread))
+		return KErrPermissionDenied;
+#endif	
+	
+	TMetroTrkMemoryInfo info(0, 0, 0);
+	err = Kern::ThreadRawRead(iClientThread, aMemoryInfo, (TUint8*)&info, sizeof(TMetroTrkMemoryInfo));
+	if (err != KErrNone)
+		return err;
+	
+	if (!info.iData)
+		return KErrArgument;
+	
+	TUint8 *data = (TUint8*)Kern::Alloc(info.iLength);
+	if (!data)
+		return KErrNoMemory;
+	
+	TPtr8 dataDes(data, info.iLength);
+	
+	err = Kern::ThreadDesRead(iClientThread, info.iData, dataDes, 0);
+	if (err != KErrNone)
+		return err;
+							
+	err = DoWriteMemory(aThread, info.iAddress, info.iLength, dataDes);
+	
+	Kern::Free(data);
+	
+	return err;
+}
+
+//
+// DMetroTrkChannel::ReadRegisters
+//
+TInt DMetroTrkChannel::ReadRegisters(DThread* aThread, TMetroTrkRegisterInfo* aRegisterInfo)
+{
+	LOG_MSG("DMetroTrkChannel::ReadRegisters()");
+
+	TInt err = KErrNone;
+	
+	if (!aRegisterInfo)
+		return KErrArgument;
+	
+#ifndef __OEM_TRK__	
+	if (!IsBeingDebugged(aThread))
+		return KErrPermissionDenied;
+#endif
+	
+	TMetroTrkRegisterInfo info(0, 0, 0);
+	err = Kern::ThreadRawRead(iClientThread, aRegisterInfo, (TUint8*)&info, sizeof(TMetroTrkRegisterInfo));
+	if (err != KErrNone)
+		return err;
+
+	if (!info.iValues)
+		return KErrArgument;
+	
+	TUint length = (info.iLastRegister - info.iFirstRegister + 1) * 4;
+	TUint8 *values = (TUint8*)Kern::Alloc(length);
+	if (!values)
+		return KErrNoMemory;
+
+	TPtr8 valuesDes(values, length);
+	
+	err = DoReadRegisters(aThread, info.iFirstRegister, info.iLastRegister, valuesDes);
+	if (err != KErrNone)
+		return err;
+	
+	err = Kern::ThreadDesWrite(iClientThread, info.iValues, valuesDes, 0, KChunkShiftBy0, iClientThread);
+
+	Kern::Free(values);
+	
+	return err;
+}
+
+//
+// DMetroTrkChannel::WriteRegisters
+//
+TInt DMetroTrkChannel::WriteRegisters(DThread* aThread, TMetroTrkRegisterInfo* aRegisterInfo)
+{
+	LOG_MSG("DMetroTrkChannel::WriteRegisters()");
+
+	TInt err = KErrNone;
+	
+	if (!aRegisterInfo)
+		return KErrArgument;
+
+#ifndef __OEM_TRK__
+	if (!IsBeingDebugged(aThread))
+		return KErrPermissionDenied;
+#endif
+
+	TMetroTrkRegisterInfo info(0, 0, 0);
+	err = Kern::ThreadRawRead(iClientThread, aRegisterInfo, (TUint8*)&info, sizeof(TMetroTrkRegisterInfo));
+	if (err != KErrNone)
+		return err;
+		
+	if (!info.iValues)
+		return KErrArgument;
+	
+	TUint length = (info.iLastRegister - info.iFirstRegister + 1) * 4;
+	
+	TUint8 *values = (TUint8*)Kern::Alloc(length);
+	if (!values)
+		return KErrNoMemory;
+	
+	TPtr8 valuesDes(values, length);
+	
+	err = Kern::ThreadDesRead(iClientThread, info.iValues, valuesDes, 0);
+	if (err != KErrNone)
+		return err;
+
+	err = DoWriteRegisters(aThread, info.iFirstRegister, info.iLastRegister, valuesDes);
+	
+	Kern::Free(values);
+	
+	return err;
+}
+
+//
+// DMetroTrkChannel::GetProcessInfo
+//
+TInt DMetroTrkChannel::GetProcessInfo(TInt aIndex, TMetroTrkTaskInfo* aTaskInfo)
+{
+	LOG_MSG("DMetroTrkChannel::GetProcessInfo()");
+
+	TInt err = KErrNone;
+	
+	if (!aTaskInfo)
+		return KErrArgument;
+
+	TMetroTrkTaskInfo info(0);
+	
+	err = DoGetProcessInfo(aIndex, &info);
+	
+	if (err != KErrNone)
+		return err;
+	
+	err = Kern::ThreadRawWrite(iClientThread, aTaskInfo, &info, sizeof(TMetroTrkTaskInfo), iClientThread);
+	
+	return err;
+}
+
+//
+// DMetroTrkChannel::GetThreadInfo
+//
+TInt DMetroTrkChannel::GetThreadInfo(TInt aIndex, TMetroTrkTaskInfo* aTaskInfo)
+{
+	LOG_MSG("DMetroTrkChannel::GetThreadInfo()");
+
+	TInt err = KErrNone;
+	
+	if (!aTaskInfo)
+		return KErrArgument;
+	
+	TMetroTrkTaskInfo info(0);
+	err = Kern::ThreadRawRead(iClientThread, aTaskInfo, (TUint8*)&info, sizeof(TMetroTrkTaskInfo));
+	if (err != KErrNone)
+		return err;
+	
+	err = DoGetThreadInfo(aIndex, &info);
+	
+	if (err != KErrNone)
+		return err;
+	
+	err = Kern::ThreadRawWrite(iClientThread, aTaskInfo, &info, sizeof(TMetroTrkTaskInfo), iClientThread);
+	
+	return err;
+}
+
+//
+// DMetroTrkChannel::GetProcessAddresses
+//
+TInt DMetroTrkChannel::GetProcessAddresses(DThread* aThread, TMetroTrkProcessInfo* aProcessInfo)
+{
+	LOG_MSG("DMetroTrkChannel::GetProcessAddresses()");
+
+	TInt err = KErrNone;
+
+	if  (!aProcessInfo)
+		return KErrArgument;
+	
+	TMetroTrkProcessInfo info(0, 0);
+	err = Kern::ThreadRawRead(iClientThread, aProcessInfo, (TUint8*)&info, sizeof(TMetroTrkProcessInfo));
+	
+	if (err != KErrNone)
+		return err;
+		
+	if (!info.iCodeAddress || !info.iDataAddress)
+		return KErrArgument;
+	
+	TUint32 codeAddress;
+	TUint32 dataAddress;
+	
+	err = DoGetProcessAddresses(aThread, codeAddress, dataAddress);
+	
+	if (err != KErrNone)
+		return err;
+		
+	err = Kern::ThreadRawWrite(iClientThread, info.iCodeAddress, (TUint8*)&codeAddress, sizeof(TUint32), iClientThread);
+	err = Kern::ThreadRawWrite(iClientThread, info.iDataAddress, (TUint8*)&dataAddress, sizeof(TUint32), iClientThread);
+
+	return err;
+}
+
+//
+// DMetroTrkChannel::GetStaticLibraryInfo
+//
+TInt DMetroTrkChannel::GetStaticLibraryInfo(TInt aIndex, SEventInfo* aEventInfo)
+{
+	LOG_MSG("DMetroTrkChannel::GetStaticLibraryInfo()");
+
+	TInt err = KErrNone;
+
+	if (!aEventInfo)
+		return KErrArgument;
+
+	SEventInfo info;
+
+	err = Kern::ThreadRawRead(iClientThread, aEventInfo, (TUint8*)&info, sizeof(SEventInfo));
+	
+	if (err != KErrNone)
+		return err;
+
+	err = DoGetStaticLibraryInfo(aIndex, &info);
+	
+	if (err != KErrNone)
+		return err;
+	
+	err = Kern::ThreadRawWrite(iClientThread, aEventInfo, &info, sizeof(SEventInfo), iClientThread);
+
+	return err;
+}
+
+//
+// DMetroTrkChannel::GetLibInfo
+//
+TInt DMetroTrkChannel::GetLibraryInfo(TMetroTrkLibInfo* aLibInfo)
+{
+	LOG_MSG("DMetroTrkChannel::GetLibraryInfo()");
+
+	TInt err = KErrNone;
+	
+	if (!aLibInfo)
+		return KErrArgument;
+
+	TMetroTrkLibInfo info(0, 0);
+
+	err = Kern::ThreadRawRead(iClientThread, aLibInfo, (TUint8*)&info, sizeof(TMetroTrkLibInfo));
+
+	if (err != KErrNone)
+		return err;
+
+	if (!info.iFileName)
+		return KErrArgument;
+	
+	TUint8 *dllName = (TUint8*)Kern::Alloc(info.iFileNameLength);
+	if (!dllName)
+		return KErrNoMemory;
+	
+	TPtr8 dllNameDes(dllName, info.iFileNameLength);
+	
+	err = Kern::ThreadDesRead(iClientThread, info.iFileName, dllNameDes, 0);
+	if (!err)
+	{
+		err = DoGetLibraryInfo(dllNameDes, &info);
+	
+		if (!err)		
+			err = Kern::ThreadRawWrite(iClientThread, aLibInfo, &info, sizeof(TMetroTrkLibInfo), iClientThread);
+		
+		// we couldn't find the library info, so add to our list to look for 
+		// when a library is loaded or a process is loaded.	
+		if (err != KErrNone)
+		{
+            for (TInt i=0; i<NUMBER_OF_LIBS_TO_REGISTER; i++)
+            {                
+                if (!iLibraryNotifyList[i].iName.Length() && iLibraryNotifyList[i].iEmptySlot)
+		        {
+                    iLibraryNotifyList[i].iName.Copy(dllNameDes);
+                    iLibraryNotifyList[i].iEmptySlot = EFalse;
+                    break;
+		        }
+		        else if (!iLibraryNotifyList[i].iEmptySlot && !_strnicmp(iLibraryNotifyList[i].iName.Ptr(), dllNameDes.Ptr(), dllNameDes.Length()))
+		        {
+		        	break;
+		        }
+            }
+		}		
+	}
+	
+	// now free the allocated memory
+	Kern::Free(dllName);	
+
+	return err;
+}
+
+//
+// DMetroTrkChannel::GetExeInfo
+//
+TInt DMetroTrkChannel::GetExeInfo(TMetroTrkExeInfo* aExeInfo)
+{
+	LOG_MSG("DMetroTrkChannel::GetExeInfo()");
+
+	TInt err = KErrNone;
+	
+	if (!aExeInfo)
+		return KErrArgument;
+
+	TMetroTrkExeInfo info(0, 0, 0);
+
+	err = Kern::ThreadRawRead(iClientThread, aExeInfo, (TUint8*)&info, sizeof(TMetroTrkExeInfo));
+
+	if (err != KErrNone)
+		return err;
+
+	if (!info.iFileName)
+		return KErrArgument;
+	
+	TUint8 *exeName = (TUint8*)Kern::Alloc(info.iFileNameLength);
+	if (!exeName)
+		return KErrNoMemory;
+	
+	TPtr8 exeNameDes(exeName, info.iFileNameLength);
+	
+	err = Kern::ThreadDesRead(iClientThread, info.iFileName, exeNameDes, 0);
+	if (KErrNone == err)
+	{
+			err = DoGetExeInfo(exeNameDes, &info);
+		if (KErrNone == err)
+		{		
+			err = Kern::ThreadRawWrite(iClientThread, aExeInfo, &info, sizeof(TMetroTrkExeInfo), iClientThread);
+		}
+	}
+	
+	Kern::Free(exeName);
+
+	return err;
+}
+
+//
+// DMetroTrkChannel::GetProcUidInfo
+//
+TInt DMetroTrkChannel::GetProcUidInfo(TMetroTrkProcUidInfo* aProcUidInfo)
+{
+	LOG_MSG("DMetroTrkChannel::GetProcUidInfo()");
+
+	TInt err = KErrNone;
+	
+	if (!aProcUidInfo)
+		return KErrArgument;
+
+	TMetroTrkProcUidInfo info(0);
+
+	err = Kern::ThreadRawRead(iClientThread, aProcUidInfo, (TUint8*)&info, sizeof(TMetroTrkProcUidInfo));
+
+	if (err != KErrNone)
+		return err;
+	
+	err = DoGetProcUidInfo(&info);
+	
+	if (err != KErrNone)
+		return err;
+	
+	err = Kern::ThreadRawWrite(iClientThread, aProcUidInfo, &info, sizeof(TMetroTrkProcUidInfo), iClientThread);
+
+	return err;
+}
+
+//
+//DMetroTrkChannel::DetachProcess
+//
+TInt DMetroTrkChannel::DetachProcess(DProcess *aProcess)
+{
+    LOG_MSG("DMetroTrkChannel::DetachProcess()");
+    // check to see if we are still debugging, otherwise just return
+    if (!iDebugging || !aProcess) 
+        return KErrArgument;
+
+    // This is called when a process has been detached.  
+    // We want to mark any breakpoints in this process space as clear.      
+    TUint32 codeAddress = 0;
+    TUint32 codeSize = 0;
+    
+    LOG_MSG2("Process being Detached, Name %S", aProcess->iName);    
+
+    // make sure there is not already a breakpoint at this address
+    for (TInt i = 0; i < iDebugProcessList.Count(); i++)
+    {
+        if (iDebugProcessList[i].iId == aProcess->iId)
+        {
+            codeAddress = iDebugProcessList[i].iCodeAddress;
+            codeSize = iDebugProcessList[i].iCodeSize;
+            //now remove from the list
+            iDebugProcessList.Remove(i);
+            break;
+        }
+	}
+
+    if (!codeAddress || !codeSize)
+        return KErrArgument;
+        
+    // first invalidate all breakpoints that were set in the library code
+    for (TInt i=0; i<iBreakPointList.Count(); i++)
+    {
+        if ((iBreakPointList[i].iAddress >= codeAddress) && (iBreakPointList[i].iAddress < (codeAddress + codeSize)))
+        {
+            LOG_MSG2("Clearing process breakpoint at address %x", iBreakPointList[i].iAddress);
+            // clear the break here
+            TInt32 err = KErrNone;
+            err = DoClearBreak(iBreakPointList[i].iId);
+            
+            //If not able to clear the break point host debugger  make obselete.
+            if (KErrNone != err)
+            {
+                LOG_MSG2("Clearing process breakpoint at address %x failed", iBreakPointList[i].iAddress);                
+            }
+        }
+	}
+
+    return KErrNone;
+}
+
+
+//
+// DMetroTrkChannel::DoSetBreak
+//
+TInt DMetroTrkChannel::DoSetBreak(const TUint32 aProcessId, const TUint32 aThreadId, const TUint32 aAddress, const TBool aThumbMode, TInt32 &aId)
+{
+	LOG_MSG("DMetroTrkChannel::DoSetBreak()");
+
+	// do not allow breakpoints in the excluded ROM region
+	//if ((aAddress >= iExcludedROMAddressStart) && (aAddress < iExcludedROMAddressEnd))
+	//{
+	//	return KErrNotSupported;
+	//}
+	
+	// make sure there is not already a breakpoint at this address
+	for (TInt i = NUMBER_OF_TEMP_BREAKPOINTS; i < iBreakPointList.Count(); i++)
+	{
+		if (iBreakPointList[i].iAddress == aAddress)
+		{
+			return KErrAlreadyExists;
+		}
+	}
+	
+	// increment the break id
+	aId = iNextBreakId++;	
+
+	// create the new breakpoint entry
+	TBreakEntry breakEntry(aId, aThreadId, aAddress, aThumbMode);
+
+	// IDE currently sends non-thread specific breakpoints (threadId == 0xffffffff)
+	// if this changes, we will get a real thread ID
+	// This check must be done before calling DoEnableBreak as it will replace the 
+	// the breakentry threadId with a real one
+	if (aThreadId == 0xFFFFFFFF)
+	{
+	    breakEntry.iThreadSpecific = EFalse;
+	    breakEntry.iThreadId = aProcessId+1; //process wide break, just use the main thread id for this process		
+	}
+	else
+	{
+		breakEntry.iThreadSpecific = ETrue;
+	}
+        
+	TInt err = DoEnableBreak(breakEntry, ETrue);
+	
+	if (KErrNone == err)
+	{
+		ReturnIfError(iBreakPointList.Append(breakEntry));
+	}
+	
+	return err;
+}
+
+
+//
+// DMetroTrkChannel::DoEnableBreak
+//
+TInt DMetroTrkChannel::DoEnableBreak(TBreakEntry &aEntry, TBool aSaveOldInstruction)
+{
+	LOG_MSG("DMetroTrkChannel::DoEnableBreak()");
+
+	// default to arm mode
+	TUint32 inst = KArmBreakPoint;
+	TInt instSize = 4;
+	
+	if (aEntry.iThumbMode)
+	{
+		LOG_MSG("Thumb Breakpoint");
+		inst = KThumbBreakPoint;
+		instSize = 2;
+	}
+
+	TInt err = KErrNone;
+  			
+	// Get thread id from the process that we are debugging
+	TProcessInfo * proc = NULL;
+	TUint32 threadId = NULL;
+	
+	threadId = aEntry.iThreadId;
+	
+	if (!threadId || threadId==0xFFFFFFFF) //threadId=0xFFFFFFFF is special case with CW debugger.
+	{
+		for (TInt i=0; i<iDebugProcessList.Count(); i++)
+		{
+			proc = &iDebugProcessList[i];
+			if ( proc && (proc->iCodeAddress <= aEntry.iAddress) && (aEntry.iAddress <= (proc->iCodeAddress + proc->iCodeSize)))
+			{
+				threadId = proc->iId+1;
+				break;
+			}
+		}
+	}
+	
+	DThread* threadObj = ThreadFromId(threadId);
+	//if we don't have the right thread id for the address, 
+	//then try with the thread id of the process that we are debugging 	
+	if (!threadObj && iDebugProcessList.Count())
+	{
+		proc = &iDebugProcessList[0];
+		if (proc)
+		{
+			threadId = proc->iId+1;	
+		}
+		threadObj = ThreadFromId(threadId);
+	}
+	
+	if (threadObj)
+	{		
+		if (aSaveOldInstruction)
+		{
+			TUint32 instruction;
+
+			// read the instruction at the address so we can store it in the break entry for when we clear this breakpoint
+			// trap exceptions in case the address is invalid
+			XTRAPD(r, XT_DEFAULT, err = TryToReadMemory(threadObj, (TAny *)aEntry.iAddress, (TAny *)&instruction, instSize));
+
+			ReturnIfError((KErrNone == r) ? err : r);
+
+			aEntry.iInstruction.Copy((TUint8 *)&instruction, instSize);
+		}
+
+		aEntry.iThreadId = threadId; //set the thread ID here 
+		XTRAPD(r, XT_DEFAULT, err = DebugSupport::ModifyCode(threadObj, aEntry.iAddress, instSize, inst, DebugSupport::EBreakpointGlobal));
+		err = (DebugSupport::EBreakpointGlobal == r) ? KErrNone : r;
+	}
+	else
+	{
+		err = KErrBadHandle;	
+	}
+
+
+	return err;
+}
+
+//
+// DMetroTrkChannel::DoClearBreak
+//
+TInt DMetroTrkChannel::DoClearBreak(const TInt32 aId)
+{
+	LOG_MSG("DMetroTrkChannel::DoClearBreak()");
+
+	// find the break entry matching this id.  note that the breakpoints are already sorted in ascending order by id
+	TBreakEntry entry;
+	entry.iId = aId;
+	TInt index = iBreakPointList.FindInSignedKeyOrder(entry);
+
+	TInt err = KErrNone;
+	if (index >= 0)
+	{
+		// if this breakpoint was set in a library and that library has already been unloaded, don't try to clear it
+		if (!iBreakPointList[index].iObsoleteLibraryBreakpoint)
+		{
+			LOG_MSG2("Clearing breakpoint at address %x", iBreakPointList[index].iAddress);
+
+			DThread* threadObj = ThreadFromId(iBreakPointList[index].iThreadId);
+			// In case of multiple memory model, if the thread doesn't exist any more, don't try to clear it.
+			// For example it might be in a static library which was unloaded when the thread exited,
+			// but we didn't get told so we didn't mark it as iObsoleteLibraryBreakpoint.
+			if (threadObj != NULL)
+			{
+				XTRAPD(r, XT_DEFAULT, err = DebugSupport::RestoreCode(threadObj, iBreakPointList[index].iAddress));
+				err = (KErrNone == r) ? err : r;
+
+			}
+			else
+			{
+				err = KErrBadHandle;
+			}
+		}
+		
+		if (KErrNone == err)
+		{
+			// if this is a temp breakpoint, just clear out the values, otherwise remove it from the list
+			if (index < NUMBER_OF_TEMP_BREAKPOINTS)
+			{
+				iBreakPointList[index].Reset();
+			}
+			else
+			{
+				iBreakPointList.Remove(index);
+			}
+		}
+		else
+		{
+			LOG_MSG2("Error clearing breakpoint %d", err);
+		}
+				
+		return err;
+	}
+
+	LOG_MSG2("Break Id %d not found", aId);
+
+	return KErrNotFound;
+}
+
+
+//
+// DMetroTrkChannel::DoChangeBreakThread
+//
+TInt DMetroTrkChannel::DoChangeBreakThread(TUint32 aThreadId, TInt32 aId)
+{
+	LOG_MSG("DMetroTrkChannel::DoChangeBreakThread()");
+
+	// find the break entry matching this id.  note that the breakpoints are already sorted in ascending order by id
+	TBreakEntry entry;
+	entry.iId = aId;
+	TInt index = iBreakPointList.FindInSignedKeyOrder(entry);
+	
+	if (index >=0)
+	{
+		// change the thread id for this breakpoint
+		iBreakPointList[index].iThreadId = aThreadId;
+		return KErrNone;
+	}
+
+	return KErrNotFound;
+}
+
+//
+// DMetroTrkChannel::DoSuspendThread
+//
+TInt DMetroTrkChannel::DoSuspendThread(DThread *aThread)
+{
+	LOG_MSG("DMetroTrkChannel::DoSuspendThread()");
+
+	if (!aThread)
+	{
+		LOG_MSG("Invalid dthread object");
+		return KErrArgument;
+	}
+	
+	NThread nThread = aThread->iNThread;
+	
+	if (nThread.iSuspendCount == 0)
+		Kern::ThreadSuspend(*aThread, 1); 
+
+	return KErrNone;
+}
+
+//
+// DMetroTrkChannel::DoResumeThread
+//
+TInt DMetroTrkChannel::DoResumeThread(DThread *aThread)
+{
+	LOG_MSG("DMetroTrkChannel::DoResumeThread()");
+
+	if (!aThread)
+		return KErrArgument;
+
+	// get the current PC
+	TUint32 currentPC = ReadRegister(aThread, PC_REGISTER);
+
+	// if there is a breakpoint at the current PC, we need to single step past it
+	for (TInt i=NUMBER_OF_TEMP_BREAKPOINTS; i<iBreakPointList.Count(); i++)
+	{
+		if (iBreakPointList[i].iAddress == currentPC)
+		{
+			return DoStepRange(aThread, currentPC, currentPC+1, ETrue, ETrue);
+		}
+	}
+
+	// PANIC_BACKPORT
+	// if frozen use semaphore
+	for(TInt i=0; i<iFrozenThreadSemaphores.Count(); i++)
+	{
+		if(iFrozenThreadSemaphores[i]->iOwningThread == &aThread->iNThread)
+		{
+			NKern::FSSignal(iFrozenThreadSemaphores[i]);
+			NKern::ThreadEnterCS();
+			delete iFrozenThreadSemaphores[i];
+			NKern::ThreadLeaveCS();
+			iFrozenThreadSemaphores.Remove(i);
+			return KErrNone;
+		}
+	}
+	// END PANIC_BACKPORT
+
+	// else use ThreadResume
+	Kern::ThreadResume(*aThread);
+	
+	return KErrNone;
+}
+
+//
+// DMetroTrkChannel::DoStepRange
+//
+TInt DMetroTrkChannel::DoStepRange(DThread *aThread, const TUint32 aStartAddress, const TUint32 aStopAddress, TBool aStepInto, TBool aResumeOnceOutOfRange, TBool aUserRequest)
+{
+	LOG_MSG("DMetroTrkChannel::DoStepRange()");
+
+	if (!aThread)
+		return KErrArgument;
+
+	TUint32 startAddress = (aStartAddress & 0x1) ? aStartAddress + 1 : aStartAddress;
+	TUint32 stopAddress = (aStopAddress & 0x1) ? aStopAddress + 1 : aStopAddress;
+
+	// don't allow the user to step in the excluded ROM region.  this could be called
+	// internally however.  for example, the the special breakpoints we set to handle
+	// panics, exceptions, and library loaded events are in the user library, and we
+	// will need to step past the breakpoint before continuing the thread.
+	//if (aUserRequest && (startAddress >= iExcludedROMAddressStart) && (startAddress < iExcludedROMAddressEnd))
+	//{
+	//	return KErrNotSupported;
+	//}
+
+	// set the temp breakpoint, and disable the breakpoint at the current PC if necessary
+	// if its not a user request, and we are just trying to resume from a breakpoint, 
+	// then we don't need to check for stubs. The last parameter aUserRequest tells 
+	// ModifyBreaksForStep to check for stubs or not. In some cases, the check for stubs 
+	// is true even if its not a user request.For example, this is true in cases where 
+	// we are doing a step range and the instruction in the range modified PC.
+	// in this case, DoStepRange will be called from the exception handler where 
+	// we need to check for the stubs for the valid behavior. So truly, we don't need to check 
+	// for stubs only when resuming from  a breakpoint.
+	ReturnIfError(ModifyBreaksForStep(aThread, startAddress, stopAddress, aStepInto, aResumeOnceOutOfRange, aUserRequest));
+	
+	// PANIC_BACKPORT
+	// if frozen use semaphore
+	for(TInt i=0; i<iFrozenThreadSemaphores.Count(); i++)
+		{
+		if(iFrozenThreadSemaphores[i]->iOwningThread == &aThread->iNThread)
+			{
+			NKern::FSSignal(iFrozenThreadSemaphores[i]);
+			NKern::ThreadEnterCS();
+			delete iFrozenThreadSemaphores[i];
+			NKern::ThreadLeaveCS();
+			iFrozenThreadSemaphores.Remove(i);
+			return KErrNone;
+			}
+		}
+
+	// END PANIC_BACKPORT
+	// else use ThreadResume
+	Kern::ThreadResume(*aThread);
+	
+	return KErrNone;
+}
+
+//
+// DMetroTrkChannel::DoReadMemory
+//
+TInt DMetroTrkChannel::DoReadMemory(DThread *aThread, const TUint32 aAddress, const TInt16 aLength, TDes8 &aData)
+{
+	LOG_MSG("DMetroTrkChannel::DoReadMemory()");
+
+	// make sure the parameters are valid
+	if (aLength > aData.MaxSize())
+		return KErrArgument;
+
+	TInt err = KErrNone;
+	
+	// trap exceptions in case the address is invalid
+	XTRAPD(r, XT_DEFAULT, err = TryToReadMemory(aThread, (TAny *)aAddress, (TAny *)aData.Ptr(), aLength));
+	
+	err = (KErrNone == r) ? err : r;
+	
+	if (KErrNone == err)
+	{
+		aData.SetLength(aLength);
+		
+		TPtr8 data((TUint8 *)aData.Ptr(), aLength, aLength);
+		
+		// if we have any breakpoints in this range, put the actual instruction in the buffer
+		for (TInt i = NUMBER_OF_TEMP_BREAKPOINTS; i < iBreakPointList.Count(); i++)
+		{
+			if ((iBreakPointList[i].iAddress >= aAddress) && (iBreakPointList[i].iAddress < (aAddress + aLength)))
+			{	
+				TInt instSize = (TInt)(iBreakPointList[i].iThumbMode ? 2 : 4);								
+				memcpy((TAny*)&data[iBreakPointList[i].iAddress - aAddress], (TAny *)iBreakPointList[i].iInstruction.Ptr(), instSize);
+			}
+		}
+	}
+
+	return err;
+}
+
+//
+// DMetroTrkChannel::DoWriteMemory
+//
+TInt DMetroTrkChannel::DoWriteMemory(DThread *aThread, const TUint32 aAddress, const TInt16 aLength, TDes8 &aData)
+{
+	LOG_MSG("DMetroTrkChannel::DoWriteMemory()");
+
+	// make sure the parameters are valid
+	if (aLength > aData.Length())
+		return KErrArgument;
+
+	TInt err = KErrNone;
+	
+	// trap exceptions in case the address is invalid
+	XTRAPD(r, XT_DEFAULT,  err = TryToWriteMemory(aThread, (TAny *)aAddress, (TAny *)aData.Ptr(), aLength));
+	
+	err = (KErrNone == r) ? err : r;
+
+	// reset any breakpoints we may have just overwritten
+	if (KErrNone == err)
+	{
+		TPtr8 data((TUint8 *)aData.Ptr(), aLength, aLength);
+		
+		for (TInt i = NUMBER_OF_TEMP_BREAKPOINTS; i < iBreakPointList.Count(); i++)
+		{
+			if ((iBreakPointList[i].iAddress >= aAddress) && (iBreakPointList[i].iAddress < (aAddress + aLength)))
+			{
+				// default to arm mode
+				TUint32 inst = KArmBreakPoint;
+				TInt instSize = 4;
+				
+				if (iBreakPointList[i].iThumbMode)
+				{
+					inst = KThumbBreakPoint;
+					instSize = 2;
+				}
+				
+				iBreakPointList[i].iInstruction.Copy(&data[iBreakPointList[i].iAddress - aAddress], instSize);
+				//memcpy((TAny*)iBreakPointList[i].iAddress, (TAny *)&inst, instSize);			
+				TryToWriteMemory(aThread, (TAny*)iBreakPointList[i].iAddress, (TAny *)&inst, instSize);			
+			}
+		}
+		
+	}
+	
+	return err;
+}
+
+//
+// DMetroTrkChannel::DoReadRegisters
+//
+TInt DMetroTrkChannel::DoReadRegisters(DThread *aThread, const TInt16 aFirstRegister, const TInt16 aLastRegister, TDes8 &aValues)
+{
+	LOG_MSG("DMetroTrkChannel::DoReadRegisters()");
+
+	// make sure the parameters are valid
+	if (!aThread || (aFirstRegister < 0) || (aLastRegister >= (TInt16)(sizeof(TArmRegSet)/sizeof(TArmReg))))
+		return KErrArgument;
+
+	// make sure the descriptor is big enough to hold the requested data
+	if ((TInt)((aLastRegister - aFirstRegister + 1) * sizeof(TArmReg)) > (aValues.MaxSize()))
+		return KErrArgument;
+	
+	TArmRegSet regSet;
+    TUint32 unused;
+
+#ifdef SUPPORT_KERNCONTEXT
+	NKern::Lock(); // lock the kernel before callin UserContextType as its required by this function
+	NThread nThread = aThread->iNThread;
+	NThread::TUserContextType userContextType = nThread.UserContextType();
+	NKern::Unlock(); //unlock the kernel now
+	
+	if (userContextType == NThread::EContextNone || userContextType == NThread::EContextKernel)
+	{
+		//NKern::ThreadGetSystemContext(&aThread->iNThread, &regSet, unused);
+		if (!GetSystemThreadRegisters(&regSet))
+			return KErrGeneral;
+	}
+	else
+#endif
+	{
+		NKern::ThreadGetUserContext(&aThread->iNThread, &regSet, unused);
+	}
+    
+    TArmReg *reg = &regSet.iR0;
+
+	if (!reg)
+		return KErrGeneral;
+			    
+    for (TInt16 i = aFirstRegister; i <= aLastRegister; i++)
+    	aValues.Append((TUint8 *)&reg[i], sizeof(TArmReg));
+
+	return KErrNone;
+}
+
+//
+// DMetroTrkChannel::DoWriteRegisters
+//
+TInt DMetroTrkChannel::DoWriteRegisters(DThread *aThread, const TInt16 aFirstRegister, const TInt16 aLastRegister, TDesC8 &aValues)
+{
+	LOG_MSG("DMetroTrkChannel::DoWriteRegisters()");
+
+	// make sure the parameters are valid
+	if (!aThread || (aFirstRegister < 0) || (aLastRegister >= (TInt16)(sizeof(TArmRegSet)/sizeof(TArmReg))))
+		return KErrArgument;
+
+	// make sure the descriptor is big enough to hold the data to write
+	if ((TInt)((aLastRegister - aFirstRegister + 1) * sizeof(TArmReg)) > (aValues.Length()))
+		return KErrArgument;
+
+    TArmRegSet regSet;
+    TUint32 unused;
+
+	NKern::ThreadGetUserContext(&aThread->iNThread, &regSet, unused);
+	
+    TArmReg *reg = &regSet.iR0;
+
+    for (TInt16 i = aFirstRegister; i <= aLastRegister; i++)
+    {
+    	#ifndef __OEM_TRK__	
+		if (IsRegisterSecure(i))
+			return KErrNotSupported;
+		#endif
+    	reg[i] = *(TUint32 *)&aValues[(i-aFirstRegister)*sizeof(TArmReg)];
+    }
+    	
+    	
+    NKern::ThreadSetUserContext(&aThread->iNThread, &regSet);
+
+	return KErrNone;
+}
+
+//
+// DMetroTrkChannel::DoGetProcessInfo
+//
+TInt DMetroTrkChannel::DoGetProcessInfo(const TInt aIndex, TMetroTrkTaskInfo *aInfo)
+{
+	LOG_MSG("DMetroTrkChannel::DoGetProcessInfo()");
+	
+	DObjectCon *processes = Kern::Containers()[EProcess];
+	if (!processes)
+		return KErrGeneral;
+	
+	TInt err = KErrNone;
+	
+	NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex
+	processes->Wait(); // Obtain the container mutex so the list does get changed under us
+		
+	// make sure the index is valid
+	if ((aIndex >= 0) && (aIndex < processes->Count())) // >= because the index is zero based
+	{
+		DProcess *process = (DProcess *)((*processes)[aIndex]);
+		
+		if (process)
+		{
+			process->Name(aInfo->iName);
+			aInfo->iId = process->iId;
+			aInfo->iPriority = (TUint32)process->iPriority;
+		}
+		else
+		{
+			LOG_MSG2("Process %d not found", aIndex);
+			err = KErrArgument;
+		}
+	}
+	else
+	{
+		err = KErrArgument;
+	}
+	
+	processes->Signal();
+	NKern::ThreadLeaveCS();
+	
+	return err;
+}
+
+//
+// DMetroTrkChannel::DoGetThreadInfo
+//
+TInt DMetroTrkChannel::DoGetThreadInfo(const TInt aIndex, TMetroTrkTaskInfo *aInfo)
+{
+	LOG_MSG("DMetroTrkChannel::DoGetThreadInfo()");
+		
+	DObjectCon *threads = Kern::Containers()[EThread];
+	if (!threads)
+		return KErrGeneral;	
+	
+	NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex
+	threads->Wait(); // Obtain the container mutex so the list does get changed under us
+	
+	TInt err = KErrNone;
+	if ((aIndex >= 0) && (aIndex < threads->Count()))
+	{
+		DThread *thread = NULL;
+		
+		TInt threadsForProcessCount = 0;
+		TBool found = EFalse;
+		
+		for (TInt i=0; i<threads->Count(); i++)
+		{
+			thread = (DThread *)((*threads)[i]);
+			
+			if (thread && (aInfo->iOtherId == thread->iOwningProcess->iId))
+			{
+				if (threadsForProcessCount == aIndex)
+				{
+					thread->Name(aInfo->iName);
+					aInfo->iId = thread->iId;
+					aInfo->iPriority = (TUint32)thread->iThreadPriority;
+					found = ETrue;				
+					break;
+				}
+				threadsForProcessCount++;
+			}
+		}
+		
+		if (!found)
+		{
+			LOG_MSG("Thread for process matching index not found");
+			err = KErrArgument;
+		}
+	
+	}
+	else
+	{		
+		err = KErrArgument;
+	}
+	
+	threads->Signal();
+	NKern::ThreadLeaveCS();
+
+	return err;
+}
+
+//
+// DMetroTrkChannel::DoGetProcessAddresses
+//
+TInt DMetroTrkChannel::DoGetProcessAddresses(DThread *aThread, TUint32 &aCodeAddress, TUint32 &aDataAddress)
+{
+	LOG_MSG("DMetroTrkChannel::DoGetProcessAddresses()");
+
+	if (!aThread)
+		return KErrArgument;
+	
+#ifndef __OEM_TRK__			
+	if (HasManufacturerCaps(aThread))
+		return KErrPermissionDenied;
+#endif
+	
+	DProcess *process = (DProcess *)aThread->iOwningProcess;
+	
+	if (!process)
+		return KErrArgument;
+	
+	DCodeSeg* codeSeg = process->iCodeSeg;
+	if (!codeSeg)
+		return KErrArgument;
+		
+	TModuleMemoryInfo processMemoryInfo;
+	TInt err = codeSeg->GetMemoryInfo(processMemoryInfo, process);
+	if (err != KErrNone)
+		return err;
+	
+	aCodeAddress = processMemoryInfo.iCodeBase;
+	aDataAddress = processMemoryInfo.iInitialisedDataBase;
+	
+	//add this process to the list of processes that we are debugging
+	TProcessInfo processInfo(process->iId, aCodeAddress, processMemoryInfo.iCodeSize, aDataAddress);
+	iDebugProcessList.Append(processInfo);
+		
+	return KErrNone;
+}
+
+//
+// DMetroTrkChannel::DoGetStaticLibraryInfo
+//
+
+TInt DMetroTrkChannel::DoGetStaticLibraryInfo(const TInt aIndex, SEventInfo *aInfo)
+{
+	LOG_MSG("DMetroTrkChannel::DoGetStaticLibraryInfo()");
+	
+	if (!aInfo)
+		return KErrArgument;
+		
+	DThread *thread = ThreadFromId(aInfo->iThreadId);
+
+	if (!thread)
+		return KErrArgument;
+	
+	DProcess *process = (DProcess *)thread->iOwningProcess;
+	
+
+	if (!process)
+		return KErrArgument;
+	
+	
+	DCodeSeg *processCodeSeg = process->iCodeSeg;
+	
+	if (!processCodeSeg)
+		return KErrArgument;
+	
+	int count = processCodeSeg->iDepCount;
+	LOG_MSG2("code segment count %d", count);
+
+	
+	if (aIndex < 0 || aIndex >= count)
+		return KErrArgument;
+	
+	DCodeSeg **codeSegList = processCodeSeg->iDeps;
+	if (!codeSegList)
+		return KErrArgument;
+	
+	DCodeSeg* codeSeg = codeSegList[aIndex];
+	if (!codeSeg)
+	{
+		return KErrArgument;
+	}
+	if (!codeSeg->IsDll())
+	{
+		LOG_MSG(" -- code segment is not for a dll");
+		return KErrArgument;		
+	}
+	TModuleMemoryInfo memoryInfo;
+	TInt err = codeSeg->GetMemoryInfo(memoryInfo, NULL); //NULL for DProcess should be ok;
+	if (err != KErrNone)
+	{
+		LOG_MSG2("Error in getting TModuleMemoryInfo info: %d", err);
+		return KErrArgument;
+	}
+
+	aInfo->iEventType = SEventInfo::ELibraryLoaded;	
+	aInfo->iFileName.Copy(*(codeSeg->iFileName)); //just the name, without uid info.		
+	aInfo->iCodeAddress = memoryInfo.iCodeBase;
+	aInfo->iDataAddress = memoryInfo.iInitialisedDataBase;
+	//this way, host debugger will not resume the thread, instead engine will resume
+	//after going through the list of all static libraries..
+	aInfo->iThreadId = 0xFFFFFFFF; 
+	
+	LOG_MSG2("library name: %S", codeSeg->iFileName);		
+	LOG_MSG2("code address: %x", aInfo->iCodeAddress);
+	LOG_MSG2("data address: %x", aInfo->iDataAddress);
+
+	return KErrNone;
+}
+
+
+//
+// DMetroTrkChannel::DoGetLibraryInfo
+//
+TInt DMetroTrkChannel::DoGetLibraryInfo(TDesC8 &aDllName, TMetroTrkLibInfo *aInfo)
+{
+	LOG_MSG("DMetroTrkChannel::DoGetLibraryInfo()");
+		
+	TInt err = KErrArgument;
+	
+	if (!aInfo)
+		return err;
+		
+	err = DoGetLibInfoFromCodeSegList(aDllName, aInfo);
+					
+	return err;
+}
+
+//
+// DMetroTrkChannel::DoGetExeInfo
+//
+TInt DMetroTrkChannel::DoGetExeInfo(TDesC8 &aExeName, TMetroTrkExeInfo* aExeInfo)
+{
+	LOG_MSG("DMetroTrkChannel::DoGetExeInfo()");
+	
+	DObjectCon *processes = Kern::Containers()[EProcess];
+	if (!processes)
+		return KErrGeneral;
+		
+	NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex
+	processes->Wait(); // Obtain the container mutex so the list does get changed under us
+			
+	TInt err = KErrNotFound; //set err to KErrNotFound
+	for (TInt i=0;  i < processes->Count(); i++) // >= because the index is zero based
+	{
+		DProcess *process = (DProcess *)((*processes)[i]);		
+		if (process && (0x0 != aExeInfo->iUid) && (aExeInfo->iUid == process->iUids.iUid[2].iUid))
+		{
+			DCodeSeg* codeSeg = process->iCodeSeg;
+			DThread* mainThread = process->FirstThread();
+			if (codeSeg && mainThread)
+			{
+				aExeInfo->iProcessID = process->iId;
+				aExeInfo->iThreadID = mainThread->iId;
+
+				TModuleMemoryInfo memoryInfo;
+				err = codeSeg->GetMemoryInfo(memoryInfo, NULL);
+				if (KErrNone == err)
+				{
+					aExeInfo->iCodeAddress = memoryInfo.iCodeBase;
+					aExeInfo->iDataAddress = memoryInfo.iInitialisedDataBase;					
+					break;
+				}								
+			}
+		}
+	}
+		
+	processes->Signal();
+	NKern::ThreadLeaveCS();
+					
+	return err;
+}
+
+
+//
+// DMetroTrkChannel::DoGetProcUidInfo
+//
+TInt DMetroTrkChannel::DoGetProcUidInfo(TMetroTrkProcUidInfo* aProcUidInfo)
+{
+	LOG_MSG("DMetroTrkChannel::DoGetProcUidInfo()");	
+	
+	TInt err = KErrNotFound;
+	DProcess* process = ProcessFromId(aProcUidInfo->iProcessID);	
+	if (process)
+	{
+		aProcUidInfo->iUid1 = process->iUids.iUid[0].iUid;
+		aProcUidInfo->iUid2 = process->iUids.iUid[1].iUid;
+		aProcUidInfo->iUid3 = process->iUids.iUid[2].iUid;
+		aProcUidInfo->iSecurID = process->iS.iSecureId;
+		aProcUidInfo->iVendorID = process->iS.iVendorId;
+		
+		err = KErrNone;
+	}								
+	return err;
+}
+
+//
+// DMetroTrkChannel::DoGetLibInfoFromCodeSegList
+//
+TInt DMetroTrkChannel::DoGetLibInfoFromCodeSegList(TDesC8 &aDllName, TMetroTrkLibInfo *aInfo)
+{
+	LOG_MSG("DMetroTrkChannel::DoGetLibInfoFromCodeSegList()");
+		
+	TInt err = KErrArgument;
+
+	//get global code seg list
+	SDblQue* codeSegList = Kern::CodeSegList();
+	if (!codeSegList)
+		return KErrBadHandle;		
+
+	//iterate through the list
+	for (SDblQueLink* codeSegPtr = codeSegList->First(); codeSegPtr!=(SDblQueLink*) (codeSegList); codeSegPtr=codeSegPtr->iNext)
+	{
+		DEpocCodeSeg* codeSeg = (DEpocCodeSeg*)_LOFF(codeSegPtr,DCodeSeg, iLink);	
+		if (codeSeg && codeSeg->IsDll())
+		{
+			if (codeSeg->iFileName) //If this is valid, the rootname will also be valid.
+			{
+				// some dll names from the code segment list have some characters towards the end.
+				// Not sure why.
+				// To account for this, we need to compare those strings that are 
+				// atleast as big as the dll we are looking for.
+				// Also the dll names in the code segment list don't have null terminator and so -1.
+				if (codeSeg->iRootName.Length() < aDllName.Length()-1)
+					continue;
+								
+				if (!_strnicmp(codeSeg->iRootName.Ptr(), aDllName.Ptr(), aDllName.Length()-1))
+				{
+					TModuleMemoryInfo memoryInfo;
+
+					TInt err = codeSeg->GetMemoryInfo(memoryInfo, NULL);
+					if (err != KErrNone)
+					{
+						//there's been an error so return it
+						return err;
+					}							
+					
+					aInfo->iCodeAddress = memoryInfo.iCodeBase;
+					aInfo->iDataAddress = memoryInfo.iInitialisedDataBase;
+					if (codeSeg->iAttachProcess) //not valid if dll is used by multiple processes, so not reliable.
+					{
+						aInfo->iAttachProcessId = codeSeg->iAttachProcess->iId;
+						if (codeSeg->iAttachProcess->FirstThread())
+							aInfo->iAttachThreadId = codeSeg->iAttachProcess->FirstThread()->iId;
+					}
+					
+					LOG_MSG2("Code segment found for lib: %s", aDllName.Ptr());
+					LOG_MSG2("code address: %x", aInfo->iCodeAddress);
+					LOG_MSG2("data address: %x", aInfo->iDataAddress);
+
+					return KErrNone;
+				}
+			}
+		}
+	}
+	
+	LOG_MSG2("Code segment not found for lib: %s", aDllName.Ptr());
+	return err;
+}
+
+//
+// DMetroTrkChannel::DoGetLibInfoFromKernLibContainer
+//
+TInt DMetroTrkChannel::DoGetLibInfoFromKernLibContainer(TDesC8 &aDllName, TMetroTrkLibInfo *aInfo)
+{
+	LOG_MSG("DMetroTrkChannel::DoGetLibInfoFromKernLibContainer()");
+		
+	TInt err = KErrNone;	
+		
+	DObjectCon *libraries = Kern::Containers()[ELibrary];
+	
+	if (!libraries)
+		return KErrGeneral;	
+
+	NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex
+	libraries->Wait(); // Obtain the container mutex so the list does get changed under us
+		
+	for (TInt i=0; i<libraries->Count(); i++)
+	{
+		DLibrary *library = (DLibrary *)((*libraries)[i]);
+		
+		if (library)
+		{
+			TBuf<KMaxPath> libName;
+			libName.Copy(*(library->iName)); //just copy the name without the UID info.
+						
+			if (libName.Length() < aDllName.Length()-1)
+				continue;
+								
+			if (!_strnicmp(libName.Ptr(), aDllName.Ptr(), aDllName.Length()-1))
+			{			
+				//get the code address
+				DCodeSeg* codeSeg = library->iCodeSeg;
+				if (codeSeg)
+				{
+					TModuleMemoryInfo memoryInfo;
+
+					TInt err = codeSeg->GetMemoryInfo(memoryInfo, NULL);
+					if (err == KErrNone)
+					{
+						// there's been an error so return it					
+						aInfo->iCodeAddress = memoryInfo.iCodeBase;
+						aInfo->iDataAddress = memoryInfo.iInitialisedDataBase;						
+						// process id and thread id are in DLibrary object.
+					}					
+				}
+				else
+				{
+					LOG_MSG2("Code segment not available for library %S", library->iName);
+					err = KErrNotFound;
+				}				
+				break;
+			}		
+		}										
+	}
+
+	libraries->Signal();
+	NKern::ThreadLeaveCS();
+	
+	return err;		
+}
+
+//
+// DMetroTrkChannel::DoSecurityCheck
+//
+TBool DMetroTrkChannel::DoSecurityCheck()
+{
+	DProcess* clientProcess = iClientThread->iOwningProcess;
+	if (clientProcess)
+	{
+		// now we also check to make sure that TRK app has ALLFILES capability as well.
+		if (!iClientThread->HasCapability(ECapabilityAllFiles))
+			return EFalse;
+		
+		SSecurityInfo secureInfo = clientProcess->iS;
+		if ((secureInfo.iSecureId == KTrkSrvSecurUid) || (secureInfo.iSecureId == KTrkAppSecurUid) || (secureInfo.iSecureId == KTrkExeSecurUid))
+		{
+			return ETrue;
+		}
+	}
+	return EFalse;
+}
+
+//
+// DMetroTrkChannel::TryToReadMemory
+//
+TInt DMetroTrkChannel::TryToReadMemory(DThread *aThread, TAny *aSrc, TAny *aDest, TInt16 aLength)
+{
+	LOG_MSG("DMetroTrkChannel::TryToReadMemory()");
+	
+	TInt err = KErrNone;
+	// on some targets reading from 0xFFFFFFFF address causes a kernel fault.
+	// avoid reading the last 4 bytes in the 32 bit address space.
+	TUint32 srcAddr = (TUint32)(aSrc);
+	if ((srcAddr >= 0xFFFFFFFC) || (aLength > (0xFFFFFFFC-srcAddr)))
+		return KErrAccessDenied;
+
+#ifndef __OEM_TRK__
+	if (IsAddressInRom((TUint32)(aSrc)) || IsAddressSecure((TUint32)(aSrc)))
+		return KErrNotSupported;
+#endif
+
+	//check if we have a valid thread object
+	if (!aThread)
+		return KErrBadHandle;
+
+	LOG_MSG2("Using Kern::ThreadRawRead to read memory at address %x", aSrc);
+	err = Kern::ThreadRawRead(aThread, aSrc, aDest, aLength);	
+
+	return err;
+}
+
+
+//
+// DMetroTrkChannel::TryToWriteMemory
+//
+TInt DMetroTrkChannel::TryToWriteMemory(DThread *aThread, TAny *aDest, TAny *aSrc, TInt16 aLength)
+{
+	LOG_MSG("DMetroTrkChannel::TryToWriteMemory()");
+
+	TInt err = KErrNone;
+	// on some targets writing to 0xFFFFFFFF address causes a kernel fault.
+	// avoid writing the last 4 bytes in the 32 bit address space.
+	TUint32 destAddr = (TUint32)(aDest);
+	if ((destAddr>=0xFFFFFFFC) || (aLength > (0xFFFFFFFC-destAddr)))
+		return KErrAccessDenied;
+
+#ifndef __OEM_TRK__
+	if (IsAddressInRom((TUint32)(aDest)) || IsAddressSecure((TUint32)(aDest)))
+		return KErrNotSupported;
+#endif
+
+	//check if we have a valid thread object
+	if (!aThread)
+		return KErrBadHandle;
+		
+	LOG_MSG2("Using Kern::ThreadRawWrite to write memory at address %x", (TUint32)aDest);
+	err = Kern::ThreadRawWrite(aThread, aDest, aSrc, aLength, iClientThread);		
+
+	return err;
+}
+
+//
+// DMetroTrkChannel::ReadRegister
+//
+TInt32 DMetroTrkChannel::ReadRegister(DThread *aThread, TInt aNum)
+{
+	LOG_MSG("DMetroTrkChannel::ReadRegister()");
+
+	if (!aThread || (aNum < 0) || (aNum >= (TInt16)(sizeof(TArmRegSet)/sizeof(TArmReg))))
+	{
+		LOG_MSG2("Invalid register number (%d) passed to ReadRegister", aNum);
+		return 0;
+	}
+	
+	TArmRegSet regSet;
+    TUint32 unused;
+
+#ifdef SUPPORT_KERNCONTEXT	
+  	NKern::Lock(); // lock the kernel before callin UserContextType as its required by this function
+	NThread nThread = aThread->iNThread;
+	NThread::TUserContextType userContextType = nThread.UserContextType();
+	NKern::Unlock(); // unlock the kernel now
+	
+	if (userContextType == NThread::EContextNone || userContextType == NThread::EContextKernel)
+	{
+		//NKern::ThreadGetSystemContext(&aThread->iNThread, &regSet, unused);
+		if (!GetSystemThreadRegisters(&regSet))
+			return KErrGeneral;
+	}
+	else
+#endif	
+	{
+		NKern::ThreadGetUserContext(&aThread->iNThread, &regSet, unused);
+	}
+    
+    TArmReg *reg = &regSet.iR0;
+	
+	return ((TUint32 *)reg)[aNum];
+}
+
+//
+// DMetroTrkChannel::ShiftedRegValue
+//
+TUint32 DMetroTrkChannel::ShiftedRegValue(DThread *aThread, TUint32 aInstruction, TUint32 aCurrentPC, TUint32 aStatusRegister)
+{
+	LOG_MSG("DMetroTrkChannel::ShiftedRegValue()");
+
+	TUint32 shift = 0;
+	if (aInstruction & 0x10)	// bit 4
+	{
+		shift = (ARM_RS(aInstruction) == PC_REGISTER ? aCurrentPC + 8 : aStatusRegister) & 0xFF;
+	}
+	else
+	{
+		shift = ARM_DATA_C(aInstruction);
+	}
+	
+	TInt rm = ARM_RM(aInstruction);
+	TUint32 res = (rm == PC_REGISTER ? (aCurrentPC + ((aInstruction & 0x10) ? 12 : 8)) : ReadRegister(aThread, rm));
+
+	switch(ARM_DATA_SHIFT(aInstruction))
+	{
+		case 0:			// LSL
+		{
+			res = shift >= 32 ? 0 : res << shift;
+			break;
+		}
+		case 1:			// LSR
+		{
+			res = shift >= 32 ? 0 : res >> shift;
+			break;
+		}
+		case 2:			// ASR
+		{
+			if (shift >= 32)
+			shift = 31;
+			res = ((res & 0x80000000L) ? ~((~res) >> shift) : res >> shift);
+			break;
+		}
+		case 3:			// ROR/RRX
+		{
+			shift &= 31;
+			if (shift == 0)
+			{
+				res = (res >> 1) | ((aStatusRegister & ARM_CARRY_BIT) ? 0x80000000L : 0);
+			}
+			else
+			{
+				res = (res >> shift) | (res << (32 - shift));
+			}
+			break;
+    	}
+    }
+
+  	return res & 0xFFFFFFFF;
+}
+
+
+//
+// DMetroTrkChannel::ModifyBreaksForStep
+//
+// Set a temporary breakpoint at the next instruction to be executed after the one at the current PC
+// Disable the breakpoint at the current PC if one exists
+//
+TInt DMetroTrkChannel::ModifyBreaksForStep(DThread *aThread, TUint32 aRangeStart, TUint32 aRangeEnd, TBool aStepInto, TBool aResumeOnceOutOfRange, TBool aCheckForStubs)
+{
+	LOG_MSG("DMetroTrkChannel::ModifyBreaksForStep()");
+	
+	if (!aThread)
+		return KErrArgument;
+
+	LOG_MSG2("Range Start: %x", aRangeStart);
+	LOG_MSG2("Range End: %x", aRangeEnd);
+
+	// get the current PC
+	TUint32 currentPC = ReadRegister(aThread, PC_REGISTER);
+	LOG_MSG2("Current PC: %x", currentPC);
+
+	// disable breakpoint at the current PC if necessary
+	ReturnIfError(DisableBreakAtAddress(currentPC));
+
+	// get the status register
+	TUint32 statusRegister = ReadRegister(aThread, STATUS_REGISTER);
+	LOG_MSG2("Current SR: %x", statusRegister);
+
+	TBool thumbMode = (statusRegister & ECpuThumb);
+	if (thumbMode)
+		LOG_MSG("Thumb Mode");
+
+	TInt instSize = thumbMode ? 2 : 4;
+
+	TBool changingModes = EFalse;
+	
+	TUint32 breakAddress = 0;
+
+	TInt rangeSize = aRangeEnd - currentPC;
+	
+	const TInt KMaxInstructionBuffer = 80;
+	
+	// scan the memory and see if any instruction might modify the PC.  if one does,
+	// stop scanning and just set a breakpoint at that instruction (with the range set accordingly).
+	// if none is found just set the breakpoint after the range.
+	// if there is only one instruction there is no need to parse the memory, just execute it
+	if ((rangeSize <= KMaxInstructionBuffer) && (rangeSize > instSize))
+	{
+		LOG_MSG("Scanning range for instructions that might modify the PC");
+		
+		// set it to the end of the range by default
+		breakAddress = aRangeEnd;
+
+		// get the instructions in range
+		// we really should be dynamically allocating this memory, but this could be
+		// called from another thread, so we can't
+		TBuf8<KMaxInstructionBuffer> instructions;
+			
+		ReturnIfError(DoReadMemory(aThread, currentPC, rangeSize, instructions));
+		
+		for (TInt i = 0; i < (TInt)rangeSize/instSize; i++)
+		{
+			if (InstructionModifiesPC(aThread, &instructions[i*instSize], thumbMode, aStepInto))
+			{
+				breakAddress = currentPC + i*instSize;
+				LOG_MSG2("Setting breakpoint at %x inside range", breakAddress);
+				break;
+			}
+		}
+	}
+	
+
+	TUint32 newRangeEnd = aRangeEnd;
+
+	if ((breakAddress == 0) || (breakAddress == currentPC))
+	{
+		// either the range consists of a single instruction, or the instruction at the currentPC may modify the PC
+		// decode the instruction and see where we need to set the breakpoint
+		breakAddress = PCAfterInstructionExecutes(aThread, currentPC, statusRegister, instSize, aStepInto, newRangeEnd, changingModes);
+				
+		// check to see if this is one of the stubs (found in stubs.s)
+		if (aStepInto && aCheckForStubs)
+		{
+			TBuf8<16> destination;
+			TInt err = DoReadMemory(aThread, breakAddress, 16, destination);
+
+			if (KErrNone == err)
+			{
+				TInt offset = 0;
+				
+				if (0 == destination.Find(KArm4Stub, sizeof(KArm4Stub)))
+				{
+					LOG_MSG("Arm4 stub found");
+					offset = 8;
+				}
+				else if ((0 == destination.Find(KArmIStub, sizeof(KArmIStub))) ||
+						 (0 == destination.Find(KFastArmIStub, sizeof(KFastArmIStub))))
+				{
+					LOG_MSG("ArmI stub found");
+					offset = 12;
+				}
+				else if ((0 == destination.Find(KThumbStub, sizeof(KThumbStub))) ||
+						 (0 == destination.Find(KFastThumbStub, sizeof(KFastThumbStub))))
+				{
+					LOG_MSG("Thumb stub found");
+					offset = 12;
+				}
+				else if ((0 == destination.Find(KThumbStub2, sizeof(KThumbStub2))) ||
+						 (0 == destination.Find(KFastThumbStub2, sizeof(KFastThumbStub2))))
+				{
+					LOG_MSG("Thumb stub found");
+					offset = 8;
+				}
+				//check to see if this is the stub generated with RVCT tools. 
+				//Look into genstubs.cpp for more details on this stub
+				else if(0 == destination.Find(KRvctArm4Stub, sizeof(KRvctArm4Stub)))
+				{
+					LOG_MSG("RVCT Arm4 stub found");
+					offset = 4;
+				}
+
+				
+				if (offset != 0)
+				{
+					if (offset == 4)
+					{
+						breakAddress = *(TUint32 *)&destination[offset];
+					}
+					else
+					{
+						err = DoReadMemory(aThread, *(TUint32 *)&destination[offset], 4, destination);
+						if (KErrNone == err)
+							breakAddress = *(TUint32 *)destination.Ptr();
+					}
+					
+					if (KErrNone == err)
+					{						
+						if (thumbMode)
+						{
+							if ((breakAddress & 0x00000001) == 1)
+								changingModes = EFalse;
+							else
+								changingModes = ETrue;
+						}
+						else
+						{
+							if ((breakAddress & 0x00000001) == 1)
+								changingModes = ETrue;
+							else
+								changingModes = EFalse;	
+						}
+						
+						breakAddress &= 0xFFFFFFFE;
+					}
+					else
+					{
+						LOG_MSG("Error reading destination of stub");
+					}
+				}
+			}
+			else
+			{
+				LOG_MSG("Error reading memory while decoding branch instruction");
+			}					
+		}
+		
+		// don't allow the user to step in a function in the excluded ROM region.
+		//if ((breakAddress >= iExcludedROMAddressStart) && (breakAddress < iExcludedROMAddressEnd))
+		//{
+		//	breakAddress = currentPC + instSize;
+		//	changingModes = EFalse;
+		//}
+	}
+	
+	// see if there is already a breakpoint at this address.  if there is, we do not need to set the temp breakpoint
+	for (TInt i=NUMBER_OF_TEMP_BREAKPOINTS; i<iBreakPointList.Count(); i++)
+	{
+		if (iBreakPointList[i].iAddress == breakAddress)
+		{
+			return KErrNone;
+		}
+	}
+	
+	for (TInt i=0; i<NUMBER_OF_TEMP_BREAKPOINTS; i++)
+	{
+		if (iBreakPointList[i].iAddress == 0)
+		{
+			iBreakPointList[i].iThreadId = aThread->iId;
+			iBreakPointList[i].iAddress = breakAddress;
+			iBreakPointList[i].iThumbMode = (thumbMode && !changingModes) || (!thumbMode && changingModes);
+			iBreakPointList[i].iResumeOnceOutOfRange = aResumeOnceOutOfRange;
+			iBreakPointList[i].iSteppingInto = aStepInto;
+			iBreakPointList[i].iRangeStart = aRangeStart;
+			iBreakPointList[i].iRangeEnd = newRangeEnd;
+			
+			// Temporary breakpoints are always thread specific
+			iBreakPointList[i].iThreadSpecific = ETrue;
+
+			LOG_MSG2("Adding temp breakpoint with id: %d", i);
+			LOG_MSG2("Adding temp breakpoint with thread id: %d", aThread->iId);
+
+			return DoEnableBreak(iBreakPointList[i], ETrue);			
+		}
+	}
+	
+	return KErrNoMemory;
+}
+
+//
+// DMetroTrkChannel::ClearAllBreakPoints
+//
+void DMetroTrkChannel::ClearAllBreakPoints()
+{
+	LOG_MSG("DMetroTrkChannel::ClearAllBreakPoints()");
+
+	TInt err = KErrNone;
+
+	for (TInt i=0; i<iBreakPointList.Count(); i++)
+	{		
+		if ((iBreakPointList[i].iAddress != 0) && !iBreakPointList[i].iObsoleteLibraryBreakpoint)
+		{
+			LOG_MSG2("Clearing breakpoint at address %x", iBreakPointList[i].iAddress);
+			
+			DThread* threadObj = ThreadFromId(iBreakPointList[i].iThreadId);
+		
+			if (threadObj != NULL)
+			{
+				XTRAPD(r, XT_DEFAULT, err = DebugSupport::RestoreCode(threadObj, iBreakPointList[i].iAddress));
+		
+				err = (KErrNone == r) ? err : r;
+			}
+			else
+			{
+				err = KErrBadHandle;
+			}
+				
+			if (KErrNone != err)
+			{
+				LOG_MSG2("Error %d while clearing breakpoint", err);
+			}		
+		}
+	}
+	
+	iBreakPointList.Reset();	
+}
+
+
+//
+// DMetroTrkChannel::DisableBreakAtAddress
+//
+TInt DMetroTrkChannel::DisableBreakAtAddress(TUint32 aAddress)
+{
+	LOG_MSG("DMetroTrkChannel::DisableBreakAtAddress()");
+
+	TInt err = KErrNone;
+	
+	for (TInt i = NUMBER_OF_TEMP_BREAKPOINTS; i < iBreakPointList.Count(); i++)
+	{
+		if (iBreakPointList[i].iAddress == aAddress)
+		{
+			iBreakPointList[i].iDisabledForStep = ETrue;
+			LOG_MSG2("Disabling breakpoint at address %x", iBreakPointList[i].iAddress);
+		
+			DThread* threadObj = ThreadFromId(iBreakPointList[i].iThreadId);
+
+			//clear the breakpoint with code modifier
+			//code modifier will restore the org instruction and also frees the shadow page if necessary
+			if (threadObj != NULL)
+			{
+				XTRAPD(r, XT_DEFAULT, err = DebugSupport::RestoreCode(threadObj, aAddress));
+		
+				err = (KErrNone == r) ? err : r;
+			}
+			else
+			{
+				err = KErrBadHandle;
+			}
+			break;
+		}
+	}
+	
+	return err;
+}
+
+//
+// DMetroTrkChannel::InstructionModifiesPC
+//
+TBool DMetroTrkChannel::InstructionModifiesPC(DThread *aThread, TUint8 *aInstruction, TBool aThumbMode, TBool aStepInto)
+{
+	LOG_MSG("DMetroTrkChannel::InstructionModifiesPC()");
+
+	if (aThumbMode)
+	{
+		TUint16 inst = *(TUint16 *)aInstruction;
+		
+		switch(THUMB_OPCODE(inst))
+		{
+			case 0x08:
+			{
+				if (aStepInto && (THUMB_INST_7_15(inst) == 0x08F))
+				{
+					// BLX(2)
+					return ETrue;				
+				}
+				else if (THUMB_INST_7_15(inst) == 0x08E)
+				{
+					// BX
+					return ETrue;				
+				}
+				else if (((THUMB_INST_8_15(inst) == 0x46) || (THUMB_INST_8_15(inst) == 0x44)) && ((inst & 0x87) == 0x87))
+				{
+					// ADD or MOV with PC as the destination
+					return ETrue;				
+				}
+				break;
+			}
+			case 0x13:
+			{
+				if (THUMB_INST_8_15(inst) == 0x9F)
+				{
+					// LDR(4) with the PC as the destination
+					return ETrue;				
+				}
+				break;
+			}
+			case 0x17:
+			{	
+				if (THUMB_INST_8_15(inst) == 0xBD)
+				{
+					// POP with the PC in the list
+					return ETrue;				
+				}
+				break;
+			}
+			case 0x1A:
+			case 0x1B:
+			{	
+				if (THUMB_INST_8_15(inst) < 0xDE)
+				{
+					// B(1) conditional branch
+					return ETrue;				
+				}
+				break;
+			}
+			case 0x1C:
+			{	
+				// B(2) unconditional branch
+				return ETrue;				
+			}
+			case 0x1D:
+			{
+				// NOTE: Only return true for the suffix since it's the second instruction that actually does the branch
+				if (aStepInto && !(inst & 0x00000001))
+				{
+					// BLX(1)
+					return ETrue;				
+				}
+				break;
+			}
+			case 0x1F:
+			{
+				// NOTE: Only return true for the suffix since it's the second instruction that actually does the branch
+				if (aStepInto)
+				{
+					// BL
+					return ETrue;				
+				}
+				break;
+			}
+		}
+	}
+	else
+	{
+		// Arm mode
+		TUint32 inst = *(TUint32 *)aInstruction;
+
+		switch(ARM_OPCODE(inst)) // bits 27-25
+		{
+			case 0:
+			{
+				switch((inst & 0x00000010) >> 4) // bit 4
+				{
+					case 0:
+					{
+						switch((inst & 0x01800000) >> 23) // bits 24-23
+						{
+							case 2:
+							{
+								// move to/from status register.  pc updates not allowed
+								// or TST, TEQ, CMP, CMN which don't modify the PC
+								break;
+							}
+							default:
+							{
+								// Data processing immediate shift
+								if (ARM_RD(inst) == PC_REGISTER)
+								{
+									// destination register is the PC
+									if (IsPreviousInstructionMovePCToLR(aThread))
+									{
+										return aStepInto;
+									}
+									else
+									{
+										return ETrue;
+									}										
+								}
+								break;
+							}
+						}
+						break;
+					}					
+					case 1:
+					{
+						switch((inst & 0x00000080) >> 7) // bit 7
+						{
+							case 0:
+							{
+								switch((inst & 0x01900000) >> 20) // bits 24-23 and bit 20
+								{
+									case 0x10:
+									{
+										// from figure 3-3
+										switch((inst & 0x000000F0) >> 4) // bits 7-4
+										{
+											case 1:
+											{
+												if (((inst & 0x00400000) >> 22) == 0) // bit 22
+												{
+													// BX
+													if (IsPreviousInstructionMovePCToLR(aThread))
+													{
+														return aStepInto;
+													}
+													else
+													{
+														return ETrue;
+													}										
+												}
+												break;
+											}
+											case 3:
+											{
+												// BLX
+												if (aStepInto)
+												{
+													return ETrue;
+												}
+												break;
+											}
+											default:
+											{
+												// either doesn't modify the PC or it is illegal to
+												break;
+											}
+										}
+										break;
+									}
+									default:
+									{
+										// Data processing register shift
+										if (((inst & 0x01800000) >> 23) == 2) // bits 24-23
+										{
+											// TST, TEQ, CMP, CMN don't modify the PC
+											return EFalse;
+										}
+										else if (ARM_RD(inst) == PC_REGISTER)
+										{
+											// destination register is the PC
+											if (IsPreviousInstructionMovePCToLR(aThread))
+											{
+												return aStepInto;
+											}
+											else
+											{
+												return ETrue;
+											}										
+										}
+										break;
+									}
+								}
+								break;
+							}
+							default:
+							{
+								// from figure 3-2, updates to the PC illegal
+								break;
+							}
+						}
+						break;
+					}
+				}
+				break;
+			}
+			case 1:
+			{
+				if (((inst & 0x01800000) >> 23) == 2) // bits 24-23
+				{
+					// cannot modify the PC
+					break;
+				}
+				else if (ARM_RD(inst) == PC_REGISTER)
+				{
+					// destination register is the PC
+					if (IsPreviousInstructionMovePCToLR(aThread))
+					{
+						return aStepInto;
+					}
+					else
+					{
+						return ETrue;
+					}										
+				}
+				break;
+			}
+			case 2:
+			{
+				// load/store immediate offset
+				if (ARM_LOAD(inst)) // bit 20
+				{
+					// loading a register from memory
+					if (ARM_RD(inst) == PC_REGISTER)
+					{
+						// loading the PC register
+						if (IsPreviousInstructionMovePCToLR(aThread))
+						{
+							return aStepInto;
+						}
+						else
+						{
+							return ETrue;
+						}										
+					}
+				}	
+				break;
+			}
+			case 3:
+			{
+				if (((inst & 0xF0000000) != 0xF) && ((inst & 0x00000010) == 0))
+				{
+					// load/store register offset
+					if (ARM_LOAD(inst)) // bit 20
+					{
+						// loading a register from memory
+						if (ARM_RD(inst) == PC_REGISTER)
+						{
+							// loading the PC register
+							if (IsPreviousInstructionMovePCToLR(aThread))
+							{
+								return aStepInto;
+							}
+							else
+							{
+								return ETrue;
+							}										
+						}
+					}	
+				}
+				break;
+			}
+			case 4:
+			{
+				if ((inst & 0xF0000000) != 0xF)
+				{
+					// load/store multiple
+					if (ARM_LOAD(inst)) // bit 20
+					{
+						// loading a register from memory
+						if (((inst & 0x00008000) >> 15))
+						{
+							// loading the PC register
+							return ETrue;
+						}
+					}					
+				}
+				break;
+			}
+			case 5:
+			{
+				if ((inst & 0xF0000000) == 0xF)
+				{
+					// BLX
+					if (aStepInto)
+					{
+						return ETrue;
+					}
+				}
+				else
+				{
+					if ((inst & 0x01000000)) // bit 24
+					{
+						// BL
+						if (aStepInto)
+						{
+							return ETrue;
+						}
+					}
+					else
+					{
+						// B
+						return ETrue;
+					}
+				}
+				break;
+			}
+		}	
+	}
+	
+	return EFalse;
+}
+
+//
+// DMetroTrkChannel::PCAfterInstructionExecutes
+//
+TUint32 DMetroTrkChannel::PCAfterInstructionExecutes(DThread *aThread, TUint32 aCurrentPC, TUint32 aStatusRegister, TInt aInstSize, TBool aStepInto, TUint32 &aNewRangeEnd, TBool &aChangingModes)
+{
+	LOG_MSG("DMetroTrkChannel::PCAfterInstructionExecutes()");
+
+	// by default we will set the breakpoint at the next instruction
+	TUint32 breakAddress = aCurrentPC + aInstSize;
+	
+	// get the instruction at the current PC
+	TBuf8<4> instruction;
+	TInt err = DoReadMemory(aThread, aCurrentPC, aInstSize, instruction); 
+
+	if (KErrNone != err)
+	{
+		return breakAddress;
+	}
+	
+	if (4 == aInstSize)
+	{
+		TUint32 inst = *(TUint32 *)instruction.Ptr();
+		LOG_MSG2("Current instruction: %x", inst);
+
+		// check the conditions to see if this will actually get executed
+		if (IsExecuted(((inst>>28) & 0x0000000F), aStatusRegister)) 
+		{
+			switch(ARM_OPCODE(inst)) // bits 27-25
+			{
+				case 0:
+				{
+					switch((inst & 0x00000010) >> 4) // bit 4
+					{
+						case 0:
+						{
+							switch((inst & 0x01800000) >> 23) // bits 24-23
+							{
+								case 2:
+								{
+									// move to/from status register.  pc updates not allowed
+									// or TST, TEQ, CMP, CMN which don't modify the PC
+									break;
+								}
+								default:
+								{
+									// Data processing immediate shift
+									if (ARM_RD(inst) == PC_REGISTER)
+									{
+										// destination register is the PC
+										if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
+										{
+											return breakAddress;
+										}
+
+										TUint32 rn = aCurrentPC + 8;
+										if (ARM_RN(inst) != PC_REGISTER) // bits 19-16
+										{
+											rn = ReadRegister(aThread, ARM_RN(inst));
+										}
+										
+										TUint32 shifter = ShiftedRegValue(aThread, inst, aCurrentPC, aStatusRegister);
+										
+										DecodeDataProcessingInstruction(((inst & 0x01E00000) >> 21), rn, shifter, aStatusRegister, breakAddress);
+									}
+									break;
+								}
+							}
+							break;
+						}					
+						case 1:
+						{
+							switch((inst & 0x00000080) >> 7) // bit 7
+							{
+								case 0:
+								{
+									switch((inst & 0x01900000) >> 20) // bits 24-23 and bit 20
+									{
+										case 0x10:
+										{
+											// from figure 3-3
+											switch((inst & 0x000000F0) >> 4) // bits 7-4
+											{
+												case 1:
+												{
+													if (((inst & 0x00400000) >> 22) == 0) // bit 22
+													{
+														// BX
+														// this is a strange case.  normally this is used in the epilogue to branch the the link
+														// register.  sometimes it is used to call a function, and the LR is stored in the previous
+														// instruction.  since what we want to do is different for the two cases when stepping over,
+														// we need to read the previous instruction to see what we should do
+														if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
+														{
+															return breakAddress;
+														}
+														
+														breakAddress = ReadRegister(aThread, (inst & 0x0000000F));
+														
+														if ((breakAddress & 0x00000001) == 1)
+														{
+															aChangingModes = ETrue;
+														}
+														
+														breakAddress &= 0xFFFFFFFE;
+													}
+													break;
+												}
+												case 3:
+												{
+													// BLX
+													if (aStepInto)
+													{
+														breakAddress = ReadRegister(aThread, (inst & 0x0000000F));
+
+														if ((breakAddress & 0x00000001) == 1)
+														{
+															aChangingModes = ETrue;
+														}
+														
+														breakAddress &= 0xFFFFFFFE;
+													}
+													break;
+												}
+												default:
+												{
+													// either doesn't modify the PC or it is illegal to
+													break;
+												}
+											}
+											break;
+										}
+										default:
+										{
+											// Data processing register shift
+											if (((inst & 0x01800000) >> 23) == 2) // bits 24-23
+											{
+												// TST, TEQ, CMP, CMN don't modify the PC
+											}
+											else if (ARM_RD(inst) == PC_REGISTER)
+											{
+												// destination register is the PC
+												if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
+												{
+													return breakAddress;
+												}
+
+												TUint32 rn = aCurrentPC + 8;
+												if (ARM_RN(inst) != PC_REGISTER) // bits 19-16
+												{
+													rn = ReadRegister(aThread, ARM_RN(inst));
+												}
+												
+												TUint32 shifter = ShiftedRegValue(aThread, inst, aCurrentPC, aStatusRegister);
+												
+												DecodeDataProcessingInstruction(((inst & 0x01E00000) >> 21), rn, shifter, aStatusRegister, breakAddress);
+											}
+											break;
+										}
+									}
+									break;
+								}
+								default:
+								{
+									// from figure 3-2, updates to the PC illegal
+									break;
+								}
+							}
+							break;
+						}
+					}
+					break;
+				}
+				case 1:
+				{
+					if (((inst & 0x01800000) >> 23) == 2) // bits 24-23
+					{
+						// cannot modify the PC
+						break;
+					}
+					else if (ARM_RD(inst) == PC_REGISTER)
+					{
+						// destination register is the PC
+						if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
+						{
+							return breakAddress;
+						}
+
+						TUint32 rn = ReadRegister(aThread, ARM_RN(inst)); // bits 19-16
+						TUint32 shifter = ((ARM_DATA_IMM(inst) >> ARM_DATA_ROT(inst)) | (ARM_DATA_IMM(inst) << (32 - ARM_DATA_ROT(inst)))) & 0xffffffff;
+
+						DecodeDataProcessingInstruction(((inst & 0x01E00000) >> 21), rn, shifter, aStatusRegister, breakAddress);
+					}
+					break;
+				}
+				case 2:
+				{
+					// load/store immediate offset
+					if (ARM_LOAD(inst)) // bit 20
+					{
+						// loading a register from memory
+						if (ARM_RD(inst) == PC_REGISTER)
+						{
+							// loading the PC register
+							if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
+							{
+								return breakAddress;
+							}
+
+					    	TUint32 base = ReadRegister(aThread, ARM_RN(inst));
+					    	TUint32 offset = 0;
+					    	
+					    	if (ARM_SINGLE_PRE(inst))
+					    	{
+					    		// Pre-indexing
+					    		offset = ARM_SINGLE_IMM(inst);
+							    
+							    if (ARM_SINGLE_U(inst))
+							    {
+							    	base += offset;
+							    }
+							    else
+							    {
+							    	base -= offset;
+								}
+							}
+
+							TBuf8<4> destination;
+							TInt err = DoReadMemory(aThread, base, 4, destination);
+							
+							if (KErrNone == err)
+							{
+								breakAddress = *(TUint32 *)destination.Ptr();
+							
+								if ((breakAddress & 0x00000001) == 1)
+								{
+									aChangingModes = ETrue;
+								}								
+								breakAddress &= 0xFFFFFFFE;
+							}
+							else
+							{
+								LOG_MSG("Error reading memory in decoding step instruction");
+							}
+						}
+					}	
+					break;
+				}
+				case 3:
+				{
+					if (((inst & 0xF0000000) != 0xF) && ((inst & 0x00000010) == 0))
+					{
+						// load/store register offset
+						if (ARM_LOAD(inst)) // bit 20
+						{
+							// loading a register from memory
+							if (ARM_RD(inst) == PC_REGISTER)
+							{
+								// loading the PC register
+								if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
+								{
+									return breakAddress;
+								}
+
+						    	TUint32 base = (ARM_RN(inst) == PC_REGISTER) ? aCurrentPC + 8 : ReadRegister(aThread, ARM_RN(inst));
+						    	TUint32 offset = 0;
+						    	
+						    	if (ARM_SINGLE_PRE(inst))
+						    	{
+							      	offset = ShiftedRegValue(aThread, inst, aCurrentPC, aStatusRegister);
+
+								    if (ARM_SINGLE_U(inst))
+								    {
+								    	base += offset;
+								    }
+								    else
+								    {
+								    	base -= offset;
+									}
+								}
+
+								TBuf8<4> destination;
+								TInt err = DoReadMemory(aThread, base, 4, destination);
+								
+								if (KErrNone == err)
+								{
+									breakAddress = *(TUint32 *)destination.Ptr();
+									
+									if ((breakAddress & 0x00000001) == 1)
+									{
+										aChangingModes = ETrue;
+									}								
+									breakAddress &= 0xFFFFFFFE;
+								}
+								else
+								{
+									LOG_MSG("Error reading memory in decoding step instruction");
+								}
+							}
+						}	
+					}
+					break;
+				}
+				case 4:
+				{
+					if ((inst & 0xF0000000) != 0xF)
+					{
+						// load/store multiple
+						if (ARM_LOAD(inst)) // bit 20
+						{
+							// loading a register from memory
+							if (((inst & 0x00008000) >> 15))
+							{
+								// loading the PC register
+								TInt offset = 0;	
+								if (ARM_BLOCK_U(inst))
+								{
+									TUint32 reglist = ARM_BLOCK_REGLIST(inst);
+									offset = Bitcount(reglist) * 4 - 4;
+									if (ARM_BLOCK_PRE(inst))
+										offset += 4;
+								}
+								else if (ARM_BLOCK_PRE(inst))
+								{
+									offset = -4;
+								}
+									
+						    	TUint32 temp = ReadRegister(aThread, ARM_RN(inst));
+								
+								temp += offset;
+
+								TBuf8<4> destination;
+								TInt err = DoReadMemory(aThread, temp, 4, destination);
+								
+								if (KErrNone == err)
+								{
+									breakAddress = *(TUint32 *)destination.Ptr();
+									if ((breakAddress & 0x00000001) == 1)
+									{
+										aChangingModes = ETrue;
+									}
+									breakAddress &= 0xFFFFFFFE;
+								}
+								else
+								{
+									LOG_MSG("Error reading memory in decoding step instruction");
+								}
+							}
+						}					
+					}
+					break;
+				}
+				case 5:
+				{
+					if ((inst & 0xF0000000) == 0xF)
+					{
+						// BLX
+						if (aStepInto)
+						{
+							breakAddress = (TUint32)ARM_INSTR_B_DEST(inst, aCurrentPC);
+
+							if ((breakAddress & 0x00000001) == 1)
+							{
+								aChangingModes = ETrue;
+							}
+							
+							breakAddress &= 0xFFFFFFFE;
+						}
+					}
+					else
+					{
+						if ((inst & 0x01000000)) // bit 24
+						{
+							// BL
+							if (aStepInto)
+							{
+								breakAddress = (TUint32)ARM_INSTR_B_DEST(inst, aCurrentPC);
+							}
+						}
+						else
+						{
+							// B
+							breakAddress = (TUint32)ARM_INSTR_B_DEST(inst, aCurrentPC);
+						}
+					}
+					break;
+				}
+			}	
+		}
+	}
+	else
+	{
+		// Thumb Mode
+		TUint16 inst = *(TUint16 *)instruction.Ptr();
+		LOG_MSG2("Current instruction: %x", inst);
+
+		switch(THUMB_OPCODE(inst))
+		{
+			case 0x08:
+			{
+				if (aStepInto && (THUMB_INST_7_15(inst) == 0x08F))
+				{
+					// BLX(2)
+					breakAddress = ReadRegister(aThread, ((inst & 0x0078) >> 3));
+
+					if ((breakAddress & 0x00000001) == 0)
+					{
+						aChangingModes = ETrue;
+					}
+					
+					breakAddress &= 0xFFFFFFFE;
+				}
+				else if (THUMB_INST_7_15(inst) == 0x08E)
+				{
+					// BX
+					breakAddress = ReadRegister(aThread, ((inst & 0x0078) >> 3));
+
+					if ((breakAddress & 0x00000001) == 0)
+					{
+						aChangingModes = ETrue;
+					}
+					
+					breakAddress &= 0xFFFFFFFE;
+				}
+				else if ((THUMB_INST_8_15(inst) == 0x46) && ((inst & 0x87) == 0x87))
+				{
+					// MOV with PC as the destination
+					breakAddress = ReadRegister(aThread, ((inst & 0x0078) >> 3));
+				}
+				else if ((THUMB_INST_8_15(inst) == 0x44) && ((inst & 0x87) == 0x87))
+				{
+					// ADD with PC as the destination
+					breakAddress = aCurrentPC + ReadRegister(aThread, ((inst & 0x0078) >> 3));
+				}
+				break;
+			}
+			case 0x13:
+			{
+				//This instruction doesn't modify the PC.
+
+				//if (THUMB_INST_8_15(inst) == 0x9F)
+				//{
+					// LDR(4) with the PC as the destination
+				//	breakAddress = ReadRegister(aThread, SP_REGISTER) + (4 * (inst & 0x00FF));
+				//}
+				break;
+			}
+			case 0x17:
+			{	
+				if (THUMB_INST_8_15(inst) == 0xBD)
+				{
+					// POP with the PC in the list
+					TUint32 regList = (inst & 0x00FF);
+					TInt offset = ReadRegister(aThread, SP_REGISTER) + (Bitcount(regList) * 4);
+
+					TBuf8<4> destination;
+					TInt err = DoReadMemory(aThread, offset, 4, destination);
+					
+					if (KErrNone == err)
+					{
+						breakAddress = *(TUint32 *)destination.Ptr();
+
+						if ((breakAddress & 0x00000001) == 0)
+						{
+							aChangingModes = ETrue;
+						}
+
+						breakAddress &= 0xFFFFFFFE;
+					}
+					else
+					{
+						LOG_MSG("Error reading memory in decoding step instruction");
+					}
+				}
+				break;
+			}
+			case 0x1A:
+			case 0x1B:
+			{	
+				if (THUMB_INST_8_15(inst) < 0xDE)
+				{
+					// B(1) conditional branch
+					if (IsExecuted(((inst & 0x0F00) >> 8), aStatusRegister))
+					{
+						TUint32 offset = ((inst & 0x000000FF) << 1);
+						if (offset & 0x00000100)
+						{
+							offset |= 0xFFFFFF00;
+						}
+						
+						breakAddress = aCurrentPC + 4 + offset;
+					}
+				}
+				break;
+			}
+			case 0x1C:
+			{	
+				// B(2) unconditional branch
+				TUint32 offset = (inst & 0x000007FF) << 1;
+				if (offset & 0x00000800)
+				{
+					offset |= 0xFFFFF800;
+				}
+				
+				breakAddress = aCurrentPC + 4 + offset;
+				break;
+			}
+			case 0x1D:
+			{
+				if (aStepInto && !(inst & 0x0001))
+				{
+					// BLX(1)
+					breakAddress = (ReadRegister(aThread, LINK_REGISTER) + ((inst & 0x07FF) << 1));
+					if ((breakAddress & 0x00000001) == 0)
+					{
+						aChangingModes = ETrue;
+					}
+					
+					breakAddress &= 0xFFFFFFFC;
+				}
+				break;
+			}
+			case 0x1E:
+			{
+				// BL/BLX prefix - destination is encoded in this and the next instruction
+				aNewRangeEnd += 2;
+                // BL Stepping Changes
+                if (aStepInto)
+                {
+                    TBuf8<2> nextInstruction;
+                    TInt err = DoReadMemory(aThread, aCurrentPC+2, aInstSize, nextInstruction);
+                    if (KErrNone == err)
+                    {
+                        TUint16 nextInst = *(TUint16*)nextInstruction.Ptr();
+                        LOG_MSG2("Next instruction: %x", nextInst);
+                        
+                        // base new LR from first instruction
+                        TUint32 newLR = inst & 0x07FF;
+                        newLR <<= 12;
+                        if (newLR & (TUint32)(0x0400 << 12))
+                        {
+                            // sign-extend it
+                            newLR |= 0xFF800000;
+                        }
+                        newLR += aCurrentPC + 4;        // pc is pointing to first instruction + 4
+                        TUint32 newPC = newLR + ((nextInst & 0x07FF) << 1);
+                        if (THUMB_OPCODE(nextInst) == 0x1D)         // H = 01 changing to ARM (BLX)
+                        {
+                            newPC &= 0xFFFFFFFC;
+                            aChangingModes = ETrue;
+                        }
+                        
+                        breakAddress = newPC;
+                    }
+                }
+                else    // step over
+                {
+                    breakAddress += 2;
+                }
+                // End of BL Stepping Changes
+				break;
+			}
+			case 0x1F:
+			{
+				if (aStepInto)
+				{
+					// BL
+					breakAddress = ReadRegister(aThread, LINK_REGISTER) + ((inst & 0x07FF) << 1);
+				}
+				break;
+			}
+		}
+	}
+	
+	return breakAddress;
+}
+
+
+//
+// DMetroTrkChannel::DecodeDataProcessingInstruction
+//
+void DMetroTrkChannel::DecodeDataProcessingInstruction(TUint8 aOpcode, TUint32 aOp1, TUint32 aOp2, TUint32 aStatusRegister, TUint32 &aBreakAddress)
+{
+	LOG_MSG("DMetroTrkChannel::DecodeDataProcessingInstruction()");
+
+	switch(aOpcode)
+	{
+		case 0:
+		{
+			// AND
+			aBreakAddress = aOp1 & aOp2;
+			break;
+		}
+		case 1:
+		{
+			// EOR
+			aBreakAddress = aOp1 ^ aOp2;
+			break;
+		}
+		case 2:
+		{
+			// SUB
+			aBreakAddress = aOp1 - aOp2;
+			break;
+		}
+		case 3:
+		{
+			// RSB
+			aBreakAddress = aOp2 - aOp1;
+			break;
+		}
+		case 4:
+		{
+			// ADD
+			aBreakAddress = aOp1 + aOp2;
+			break;
+		}
+		case 5:
+		{
+			// ADC
+			aBreakAddress = aOp1 + aOp2 + (aStatusRegister & ARM_CARRY_BIT) ? 1 : 0;
+			break;
+		}
+		case 6:
+		{
+			// SBC
+			aBreakAddress = aOp1 - aOp2 - (aStatusRegister & ARM_CARRY_BIT) ? 0 : 1;
+			break;
+		}
+		case 7:
+		{
+			// RSC
+			aBreakAddress = aOp2 - aOp1 - (aStatusRegister & ARM_CARRY_BIT) ? 0 : 1;
+			break;
+		}
+		case 12:
+		{
+			// ORR
+			aBreakAddress = aOp1 | aOp2;
+			break;
+		}
+		case 13:
+		{
+			// MOV
+			aBreakAddress = aOp2;
+			break;
+		}
+		case 14:
+		{
+			// BIC
+			aBreakAddress = aOp1 & ~aOp2;
+			break;
+		}
+		case 15:
+		{
+			// MVN
+			aBreakAddress = ~aOp2;
+			break;
+		}
+	}
+}
+
+//
+// DMetroTrkChannel::IsPreviousInstructionMovePCToLR
+//
+TBool DMetroTrkChannel::IsPreviousInstructionMovePCToLR(DThread *aThread)
+{
+	LOG_MSG("DMetroTrkChannel::IsPreviousInstructionMovePCToLR()");
+
+	// there are several types of instructions that modify the PC that aren't
+	// designated as linked or non linked branches.  the way gcc generates the
+	// code can tell us whether or not these instructions are to be treated as
+	// linked branches.  the main cases are bx and any type of mov or load or
+	// arithmatic operation that changes the PC.  if these are really just
+	// function calls that will return, gcc will generate a mov	lr, pc
+	// instruction as the previous instruction.  note that this is just for arm
+	// and armi
+	
+	// get the address of the previous instruction
+	TUint32 address = ReadRegister(aThread, PC_REGISTER) - 4;
+
+	TBuf8<4> previousInstruction;
+	TInt err = DoReadMemory(aThread, address, 4, previousInstruction);
+	if (KErrNone != err)
+	{
+		LOG_MSG2("Error %d reading memory at address %x", address);
+		return EFalse;
+	}
+
+	const TUint32 movePCToLRIgnoringCondition = 0x01A0E00F;
+
+	TUint32 inst = *(TUint32 *)previousInstruction.Ptr();
+	
+	if ((inst & 0x0FFFFFFF) == movePCToLRIgnoringCondition)
+	{
+		return ETrue;
+	}
+		
+	return EFalse;
+}
+
+//
+// DMetroTrkChannel::DoEnableDisabledBreak
+//
+// Restore the breakpoint that was disabled for stepping past it if necessary
+//
+TInt DMetroTrkChannel::DoEnableDisabledBreak(TUint32 aThreadId)
+{
+	LOG_MSG("DMetroTrkChannel::DoEnableDisabledBreak()");
+		
+	for (TInt i = NUMBER_OF_TEMP_BREAKPOINTS; i < iBreakPointList.Count(); i++)
+	{
+//	    if (iBreakPointList[i].iDisabledForStep && ((iBreakPointList[i].iThreadId == aThreadId) || (iBreakPointList[i].iThreadId == 0xFFFFFFFF)))
+	    //  Always re-enable non-Thread Specific breakpoints
+		if (iBreakPointList[i].iDisabledForStep && ((iBreakPointList[i].iThreadId == aThreadId) || (iBreakPointList[i].iThreadSpecific == EFalse)))
+		{
+			LOG_MSG2("Re-enabling breakpoint at address %x", iBreakPointList[i].iAddress);
+			iBreakPointList[i].iDisabledForStep = EFalse;
+			return DoEnableBreak(iBreakPointList[i], EFalse);
+		}		
+	}
+	
+	return KErrNone;
+}
+
+//
+// DMetroTrkChannel::IsExecuted
+//
+// Determines whether or not an instruction will be executed
+//
+TBool DMetroTrkChannel::IsExecuted(TUint8 aCondition ,TUint32 aStatusRegister)
+{
+	LOG_MSG("DMetroTrkChannel::IsExecuted()");
+
+	TBool N = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000008;
+	TBool Z = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000004;
+	TBool C = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000002;
+	TBool V = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000001;
+
+	switch(aCondition)
+	{
+		case 0:
+			return Z;
+		case 1:
+			return !Z;
+		case 2:
+			return C;
+		case 3:
+			return !C;
+		case 4:
+			return N;
+		case 5:
+			return !N;
+		case 6:
+			return V;
+		case 7:
+			return !V;
+		case 8:
+			return (C && !Z);
+		case 9:
+			return (!C || Z);
+		case 10:
+			return (N == V);
+		case 11:
+			return (N != V);
+		case 12:
+			return ((N == V) && !Z);
+		case 13:
+			return (Z || (N != V));
+		case 14:
+		case 15:
+			return ETrue;
+	}
+	
+	return EFalse;
+}
+
+
+TBool DMetroTrkChannel::IsAddressInRom(TUint32 aAddress)
+{
+	LOG_MSG("DMetroTrkChannel::IsAddressInRom()");
+	
+	TRomHeader romHeader = Epoc::RomHeader();
+	
+	if ((aAddress >= romHeader.iRomBase ) && (aAddress < (romHeader.iRomBase + romHeader.iRomSize)))
+		return ETrue;
+	
+	return EFalse;
+}
+
+TBool DMetroTrkChannel::IsAddressSecure(TUint32 aAddress)
+{
+	LOG_MSG("DMetroTrkChannel::IsAddressInRom()");
+	
+	// SHORT TERM FIX...
+	// For now, don't allow access to Kernel memory...
+	TLinAddr kernDataStartAddr =  iMultipleMemModel ? KSuperPageMultipleLinAddr: KSuperPageMovingLinAddr;
+	TLinAddr kernDataEndAddr = iMultipleMemModel ? KKernDataEndMultipleLinAddr: KKernDataEndMovingLinAddr;
+	
+	if ((aAddress >= kernDataStartAddr) && (aAddress <= kernDataEndAddr))
+		return ETrue;
+		
+	return EFalse;
+}
+
+TBool DMetroTrkChannel::IsRegisterSecure(TInt registerIndex)
+{	
+	LOG_MSG("DMetroTrkChannel::IsRegisterSecure()");
+		
+	if (registerIndex == SP_REGISTER || registerIndex == LINK_REGISTER || registerIndex == STATUS_REGISTER)
+		return ETrue;
+		
+	return EFalse;
+}
+
+//
+// DMetroTrkChannel::AllocateShadowPageIfNecessary
+//
+// Allocate a shadow page if the address is in ROM and no page has been allocated for that range yet
+//
+TInt DMetroTrkChannel::AllocateShadowPageIfNecessary(TUint32 aAddress, TUint32 &aPageAddress)
+{
+	LOG_MSG("DMetroTrkChannel::AllocateShadowPageIfNecessary()");
+
+	// if this is in ROM, we need to shadow memory
+	TBool inRom = EFalse;
+	
+	//find out if M::IsRomAddress is available from ekern or any other library
+	//ReturnIfError(inRom = M::IsRomAddress((TAny *)aAddress));
+	TRomHeader romHeader = Epoc::RomHeader();
+	
+	if ((aAddress >= romHeader.iRomBase ) && (aAddress < (romHeader.iRomBase + romHeader.iRomSize)))
+		inRom = ETrue;
+
+	TInt err = KErrNone;
+	
+	if (inRom) // && (TSuperPage().iRomConfig[0].iType != KBdbBankTypeRamAsRom))
+	{
+		// if a shadow page has not already been allocated for this address range, do so now
+		TUint32 pageAddress = (aAddress & ~(iPageSize-1));
+		
+		TBool found = EFalse;
+		for (TInt i=0; i<iBreakPointList.Count(); i++)
+		{
+			if (pageAddress == iBreakPointList[i].iPageAddress)
+			{
+				LOG_MSG2("Shadow page already allocated at address %x", pageAddress);
+				found = ETrue;
+			}
+		}
+
+		if (!found)
+		{
+			LOG_MSG2("Allocating shadow page starting at address %x", pageAddress);
+			err = Epoc::AllocShadowPage(pageAddress);
+			if (KErrNone != err)
+			{
+				LOG_MSG2("Error %d allocating shadow page", err);
+				return KErrGeneral;
+			}
+
+			//check to see if this is still necessary
+			//if ((ASSPID() & ASSP_ID_MASK) == XSCALE_ASSP_ID)
+				//FlushDataCache(); // workaround for cache flush problem on Lubbock/PXA255 base port
+		}
+		
+		// return the page address
+		aPageAddress = pageAddress;
+	}
+
+	return err;
+}
+
+//
+// DMetroTrkChannel::FreeShadowPageIfNecessary
+//
+// Free a shadow page if the address is in ROM and no no other breakpoints are set in that page range
+//
+TInt DMetroTrkChannel::FreeShadowPageIfNecessary(TUint32 aAddress, TUint32 aPageAddress)
+{
+	LOG_MSG("DMetroTrkChannel::FreeShadowPageIfNecessary()");
+
+	TInt err = KErrNone;
+	
+	TBool found = EFalse;
+
+	TBool inRom = EFalse;
+	
+	//find out if M::IsRomAddress is available from ekern or any other library
+	//ReturnIfError(inRom = M::IsRomAddress((TAny *)aAddress));
+	TRomHeader romHeader = Epoc::RomHeader();
+	
+	if ((aAddress >= romHeader.iRomBase ) && (aAddress < (romHeader.iRomBase + romHeader.iRomSize)))
+		inRom = ETrue;
+	
+	if (inRom)// && (TSuperPage().iRomConfig[0].iType != KBdbBankTypeRamAsRom))
+	{
+		// if there are no other breakpoints in this shadow page, we can free it now
+		for (TInt i = 0; i < iBreakPointList.Count(); i++)
+		{
+			if (aAddress != iBreakPointList[i].iAddress) // ignore the current entry
+			{
+				if ((iBreakPointList[i].iAddress >= aPageAddress) &&
+					(iBreakPointList[i].iAddress < (aPageAddress + iPageSize)))
+				{
+					LOG_MSG("Still a breakpoint in this shadow page range");
+					found = ETrue;
+					break;
+				}
+			}
+		}
+
+		if (!found)
+		{
+			LOG_MSG2("Freeing shadow page starting at address %x", aPageAddress);
+			err = Epoc::FreeShadowPage(aPageAddress);
+			if (KErrNone != err)
+			{
+				LOG_MSG2("Error %d freeing shadow page", err);
+				return KErrGeneral;
+			}
+		}
+	}
+
+	return err;
+}
+
+
+
+//
+// DMetroTrkChannel::NotifyEvent
+//
+void DMetroTrkChannel::NotifyEvent(SEventInfo aEventInfo, TBool isTraceEvent)
+{
+	LOG_MSG("DMetroTrkChannel::NotifyEvent()");
+	
+	if (iEventInfo)
+	{
+		LOG_MSG2("Completing event, type: %d", aEventInfo.iEventType);
+		
+		// iThread is the user side debugger thread, so use it to write the info to it memory
+		TInt err = Kern::ThreadRawWrite(iClientThread, iEventInfo, (TUint8 *)&aEventInfo, sizeof(SEventInfo), iClientThread);
+
+		if (KErrNone != err)
+			LOG_MSG2("Error writing event info: %d", err);
+
+		// clear this since we've completed the request
+		iEventInfo = NULL;
+		
+		// signal the debugger thread
+		Kern::RequestComplete(iClientThread, iRequestGetEventStatus, KErrNone);
+	}
+	else
+	{
+		if (isTraceEvent)
+		{
+			LOG_MSG("Queuing trace event\r\n");
+
+			for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
+			{
+				if (SEventInfo::EUnknown == iTraceEventQueue[i].iEventType)
+				{
+					iTraceEventQueue[i] = aEventInfo;
+					break;
+				}
+			}			
+		}
+		else
+		{
+			LOG_MSG2("Queuing event, type: %d", aEventInfo.iEventType);
+			
+			for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
+			{
+				if (SEventInfo::EUnknown == iEventQueue[i].iEventType)
+				{
+					iEventQueue[i] = aEventInfo;
+					break;
+				}
+			}			
+		}		
+	}
+}
+
+
+//
+// DMetroTrkChannel::ThreadFromId
+//
+DThread* DMetroTrkChannel::ThreadFromId(TUint32 aId)
+{
+	LOG_MSG("DMetroTrkChannel::ThreadFromId()");
+	
+	NKern::ThreadEnterCS();  // Prevent us from dying or suspending whilst holding a DMutex
+	DObjectCon& threads = *Kern::Containers()[EThread];  // Get containing holding threads
+	threads.Wait();  // Obtain the container mutex so the list does get changed under us
+	
+	DThread* thread = Kern::ThreadFromId(aId);
+	
+	threads.Signal();  // Release the container mutex
+	NKern::ThreadLeaveCS();  // End of critical section
+	
+	return thread;
+}
+
+//
+// DMetroTrkChannel::ProcessFromId
+//
+DProcess* DMetroTrkChannel::ProcessFromId(TUint32 aId)
+{
+	LOG_MSG("DMetroTrkChannel::ProcessFromId()");
+	
+	NKern::ThreadEnterCS();  // Prevent us from dying or suspending whilst holding a DMutex
+	DObjectCon& processes = *Kern::Containers()[EProcess];  // Get containing holding threads
+	processes.Wait();  // Obtain the container mutex so the list does get changed under us
+	
+	DProcess* process = Kern::ProcessFromId(aId);
+	
+	processes.Signal();  // Release the container mutex
+	NKern::ThreadLeaveCS();  // End of critical section
+	
+	return process;
+}
+
+//
+// DMetroTrkChannel::GetSystemThreadRegisters
+//
+TBool DMetroTrkChannel::GetSystemThreadRegisters(TArmRegSet* aArmRegSet)
+{
+	if (iExcInfoValid)
+	{
+		aArmRegSet->iR0 = iCurrentExcInfo.iR0;
+		aArmRegSet->iR1 = iCurrentExcInfo.iR1;
+		aArmRegSet->iR2 = iCurrentExcInfo.iR2;
+		aArmRegSet->iR3 = iCurrentExcInfo.iR3;
+		aArmRegSet->iR4 = iCurrentExcInfo.iR4;
+		aArmRegSet->iR5 = iCurrentExcInfo.iR5;
+		aArmRegSet->iR6 = iCurrentExcInfo.iR6;		
+		aArmRegSet->iR7 = iCurrentExcInfo.iR7;		
+		aArmRegSet->iR8 = iCurrentExcInfo.iR8;		
+		aArmRegSet->iR9 = iCurrentExcInfo.iR9;	
+		aArmRegSet->iR10 = iCurrentExcInfo.iR10;
+		aArmRegSet->iR11 = iCurrentExcInfo.iR11;
+		aArmRegSet->iR12 = iCurrentExcInfo.iR12;
+		aArmRegSet->iR13 = iCurrentExcInfo.iR13;		
+		aArmRegSet->iR14 = iCurrentExcInfo.iR14;		
+		aArmRegSet->iR15 = iCurrentExcInfo.iR15;		
+		aArmRegSet->iFlags = iCurrentExcInfo.iCpsr;
+		
+		return ETrue;				
+	}
+	
+	return EFalse;
+
+}
+
+TBool DMetroTrkChannel::HasManufacturerCaps(DThread* aThread)
+{
+	if (aThread && (aThread->HasCapability(ECapabilityTCB) || 
+		    		aThread->HasCapability(ECapabilityDRM) || 
+					aThread->HasCapability(ECapabilityAllFiles)))
+	{				
+		return ETrue;
+	}
+	return EFalse;
+}
+
+TBool DMetroTrkChannel::IsBeingDebugged(const DThread* aThread)
+{	
+	TBool isDebugging = EFalse;	
+	if (aThread)
+	{
+		for (TInt i = 0; i < iDebugProcessList.Count(); i++)
+		{
+			if (iDebugProcessList[i].iId == aThread->iOwningProcess->iId)
+			{
+				isDebugging = ETrue;
+				break;
+			}
+		}
+	}
+	return isDebugging;
+}
+
+void DMetroTrkChannel::CheckLibraryNotifyList(TUint32 aProcessId)
+{   
+	SDblQue* codeSegList = Kern::CodeSegList();
+
+	for (TInt i=0; i<iLibraryNotifyList.Count(); i++)
+	{	
+		if (!iLibraryNotifyList[i].iEmptySlot)
+		{
+			//iterate through the list
+			for (SDblQueLink* codeSegPtr = codeSegList->First(); codeSegPtr != (SDblQueLink*)(codeSegList); codeSegPtr = codeSegPtr->iNext)
+			{
+				DEpocCodeSeg* codeSeg = (DEpocCodeSeg*)_LOFF(codeSegPtr, DCodeSeg, iLink);   
+				if (codeSeg && codeSeg->IsDll())
+				{
+					SEventInfo info;						
+					if (!_strnicmp(iLibraryNotifyList[i].iName.Ptr(), codeSeg->iRootName.Ptr(), codeSeg->iRootName.Length()))
+					{
+						info.iFileName.Copy((codeSeg->iRootName.Ptr())); 
+						LOG_MSG2("library name match: %S", &info.iFileName);
+						TModuleMemoryInfo memoryInfo;
+						TInt err = codeSeg->GetMemoryInfo(memoryInfo, NULL);
+						if (err != KErrNone)
+				  		{
+				       		break;
+				   		}
+				   		// 
+				   		// check the process id from the DCodeSeg instead of using aProcessId
+				   		// if the iAttachProcess from DCodeSeg is null, then we should use aProcessId
+						info.iProcessId = aProcessId;
+						info.iEventType = SEventInfo::ELibraryLoaded; 
+						info.iCodeAddress = memoryInfo.iCodeBase;
+						info.iDataAddress = memoryInfo.iInitialisedDataBase;
+						info.iThreadId = 0xFFFFFFFF; 
+						LOG_MSG2("info.iCodeAddress: %x", info.iCodeAddress);
+						LOG_MSG2("info.iDataAddress: %x", info.iDataAddress);
+						LOG_MSG2("info.iProcessId: %d", info.iProcessId);
+						NotifyEvent(info);
+						
+						// now reset this entry					
+						iLibraryNotifyList[i].iEmptySlot = ETrue;
+						break;
+					}
+				}
+			}
+		}
+	}
+}
+
+DECLARE_STANDARD_LDD()
+{
+    return new DMetroTrkDriverFactory;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/TrkKernelDriver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,508 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKKERNELDRIVER_H__
+#define __TRKKERNELDRIVER_H__
+
+//
+// class TCapsMetroTrkDriver
+//
+class TCapsMetroTrkDriver
+{
+public:
+	TVersion	iVersion;
+};
+
+
+//
+// class SEventInfo
+//
+class SEventInfo
+{
+public:
+
+	enum TEventType
+	{
+		EUnknown = -1,
+	    EThreadBreakPoint,
+	    EThreadException,
+	    EThreadPanic,
+	    EProcessPanic,
+	    ELibraryLoaded,
+	    ELibraryUnloaded,
+	    EUserTrace,
+	    EProcessAdded
+	};
+
+	inline SEventInfo() { Reset(); };
+
+	inline void Reset() { iProcessId = 0;
+						  iThreadId = 0;
+						  iCurrentPC = 0;
+						  iExceptionNumber = 0;
+						  iFileName.FillZ();
+						  iPanicCategory.FillZ();
+						  iCodeAddress = 0;
+						  iDataAddress = 0;
+						  iEventType = EUnknown; 
+						  iTraceData.FillZ();
+						  iTraceDataLen = 0; 
+						  iPanicReason = 0; 
+						  iUid = 0; 
+						  };
+public:
+
+    TUint32 				iProcessId;
+    TUint32 				iThreadId;
+    TUint32					iCurrentPC;
+    TInt					iExceptionNumber; // from TExcType
+    TBuf8<KMaxName>			iFileName;
+    TBuf8<KMaxName>			iPanicCategory;
+	TUint32					iCodeAddress;
+	TUint32					iDataAddress;
+    TEventType				iEventType;
+    TBuf8<260>				iTraceData;
+    TInt					iTraceDataLen;
+    // START_PANIC
+    TInt					iPanicReason;
+    // END_PANIC
+    TUint32 				iUid;
+};
+
+
+//
+// class TMetroTrkBreakInfo
+//
+class TMetroTrkBreakInfo
+{
+public:
+
+	inline TMetroTrkBreakInfo(const TUint32 aAddress, const TBool aThumbMode, TInt32 *aId, const TUint32 aProcessId)
+				: iAddress(aAddress),
+				  iThumbMode(aThumbMode),
+				  iId(aId),
+				  iProcessId(aProcessId) {};
+
+public:
+
+	TUint32 iAddress;
+	TBool iThumbMode;
+	TInt32* iId;
+	TUint32 iProcessId;
+};
+
+
+//
+// class TMetroTrkMemoryInfo
+//
+class TMetroTrkMemoryInfo
+{
+public:
+
+	inline TMetroTrkMemoryInfo(const TUint32 aAddress, const TInt32 aLength, TDesC8 *aData)
+				: iAddress(aAddress),
+				  iLength(aLength),
+				  iData(aData) {};
+	
+public:
+
+	TUint32 iAddress;
+	TInt16	iLength;
+	TDesC8*	iData;
+};
+
+
+//
+// class TMetroTrkRegisterInfo
+//
+class TMetroTrkRegisterInfo
+{
+public:
+
+	inline TMetroTrkRegisterInfo(const TInt16 aFirstRegister, const TInt16 aLastRegister, TDesC8 *aValues)
+				: iFirstRegister(aFirstRegister),
+				  iLastRegister(aLastRegister),
+				  iValues(aValues) {};
+	
+public:
+
+	TInt16	iFirstRegister;
+	TInt16	iLastRegister;
+	TDesC8*	iValues;
+};
+
+
+//
+// class TMetroTrkTaskInfo
+//
+class TMetroTrkTaskInfo
+{
+public:
+
+	inline TMetroTrkTaskInfo(TUint32 aOtherId)
+				: iId(0),
+				  iOtherId(aOtherId),
+				  iPriority(0) { iName.FillZ(); };
+
+public:
+
+	TUint32 iId;
+	TUint32 iOtherId;
+	TUint32 iPriority;	
+	TBuf8<KMaxName> iName;
+};
+
+
+//
+// class TMetroTrkStepInfo
+//
+class TMetroTrkStepInfo
+{
+public:
+
+	inline TMetroTrkStepInfo(const TUint32 aStartAddress, const TUint32 aStopAddress, const TBool aStepInto)
+				: iStartAddress(aStartAddress),
+				  iStopAddress(aStopAddress),
+				  iStepInto(aStepInto) {};
+
+public:
+
+	TUint32 iStartAddress;
+	TUint32 iStopAddress;
+	TBool iStepInto;
+};
+
+
+//
+// class TMetroTrkDriverInfo
+//
+class TMetroTrkDriverInfo
+{
+public:
+
+	TUint32 iPanic1Address;
+	TUint32 iPanic2Address;
+	TUint32 iException1Address;
+	TUint32 iException2Address;
+	TUint32 iLibraryLoadedAddress;
+	TUint32 iUserLibraryEnd;
+};
+
+
+//
+// class TMetroTrkProcessInfo
+//
+class TMetroTrkProcessInfo
+{
+public:
+
+	inline TMetroTrkProcessInfo(TUint32 *aCodeAddress, TUint32 *aDataAddress)
+				: iCodeAddress(aCodeAddress),
+				  iDataAddress(aDataAddress) {};
+
+public:
+
+	TUint32* iCodeAddress;
+	TUint32* iDataAddress;
+};
+
+class TMetroTrkLibInfo
+{
+public:
+
+	inline TMetroTrkLibInfo(TUint32 aLength, TDesC8* aFileName)
+				: iCodeAddress(0xFFFFFFFF),
+				  iDataAddress(0xFFFFFFFF),
+				  iAttachProcessId(0),
+				  iAttachThreadId(0),
+				  iFileNameLength(aLength),
+				  iFileName(aFileName)
+				  {};
+	
+public:
+	//TBuf8<KMaxFileName> iFileName;
+	TUint32 iCodeAddress;
+	TUint32 iDataAddress;
+	TUint32 iAttachProcessId;
+	TUint32 iAttachThreadId;
+	TUint32 iFileNameLength;
+	TDesC8* iFileName;		
+};
+
+class TMetroTrkExeInfo
+{
+public:
+
+	inline TMetroTrkExeInfo(TUint32 aUid, TUint32 aLength, TDesC8* aFileName)
+				: iProcessID(0),
+				  iThreadID(0),
+				  iUid(aUid),
+				  iCodeAddress(0xFFFFFFFF),
+				  iDataAddress(0xFFFFFFFF),
+				  iFileNameLength(aLength),
+				  iFileName(aFileName)
+				  {};
+	
+public:
+	TUint32 iProcessID;
+	TUint32 iThreadID;
+	TUint32 iUid;
+	TUint32 iCodeAddress;
+	TUint32 iDataAddress;
+	TUint32 iFileNameLength;
+	TDesC8* iFileName;		
+};
+
+class TMetroTrkProcUidInfo
+{
+public:
+	inline TMetroTrkProcUidInfo(TUint32 aProcID)
+				: iProcessID(aProcID),				  
+				  iUid1(0),
+				  iUid2(0),
+				  iUid3(0),
+				  iSecurID(0),
+				  iVendorID(0)
+				  {};
+	
+public:
+	TUint32 iProcessID;
+	TUint32 iUid1;
+	TUint32 iUid2;
+	TUint32 iUid3;
+	TUint32 iSecurID;
+	TUint32 iVendorID;
+};
+
+class TTrkLibName
+{
+	public:
+		inline TTrkLibName() { iName.FillZ(); iEmptySlot = ETrue;};
+		inline TTrkLibName(TDesC8 aName) { iName.Copy(aName); iEmptySlot = EFalse; };
+
+		TBuf8<KMaxLibraryName> iName;
+		TBool iEmptySlot;
+};
+
+//
+// class RMetroTrkDriver
+//
+class RMetroTrkDriver : public RBusLogicalChannel
+{
+public:
+
+	enum TControl
+	{
+		EControlSetBreak = 0,
+		EControlClearBreak,
+		EControlChangeBreakThread,
+		EControlSuspendThread,
+		EControlResumeThread,
+		EControlStepRange,
+		EControlReadMemory,
+		EControlWriteMemory,
+		EControlReadRegisters,
+		EControlWriteRegisters,
+		EControlGetProcessInfo,
+		EControlGetThreadInfo,
+		EControlGetProcessAddresses,
+		EControlGetStaticLibraryInfo,
+		EControlEnableLibLoadedEvent,
+		EControlDisableLibLoadedEvent,
+		EControlGetLibraryInfo,
+		EControlGetExeInfo,
+		EControlGetProcUidInfo,
+		EControlDetachProcess
+	};
+	
+	enum TRequest
+	{
+		ERequestGetEvent=0x0, ERequestGetEventCancel=0x1
+	};	
+		
+public:
+
+	inline TInt Open(const TMetroTrkDriverInfo aDriverInfo);
+	inline TInt	SetBreak(const TUint32 aProcessId, const TUint32 aThreadId, const TUint32 aAddr, const TBool aThumbMode, TInt32 &aId);
+	inline TInt	ClearBreak(const TInt32 aId);
+	inline TInt	ChangeBreakThread(const TUint32 aThreadId, const TInt32 aId);
+	inline TInt	SuspendThread(const TUint32 aThreadId);
+	inline TInt	ResumeThread(const TUint32 aThreadId);
+	inline TInt	StepRange(const TUint32 aThreadId, const TUint32 aStartAddress, const TUint32 aStopAddress, TBool aStepInto);
+	inline TInt ReadMemory(const TUint32 aThreadId, const TUint32 aAddress, const TInt16 aLength, TDes8 &aData);
+	inline TInt WriteMemory(const TUint32 aThreadId, const TUint32 aAddress, const TInt16 aLength, TDesC8 &aData);
+	inline TInt ReadRegisters(const TUint32 aThreadId, const TInt32 aFirstRegister, const TInt32 aLastRegister, TDes8 &aValues);
+	inline TInt WriteRegisters(const TUint32 aThreadId, const TInt32 aFirstRegister, const TInt32 aLastRegister, TDesC8 &aValues);
+	inline void GetEvent(TRequestStatus &aStatus, SEventInfo &aEventInfo);
+	inline void CancelGetEvent();
+	inline TInt GetProcessInfo(const TInt aIndex, TMetroTrkTaskInfo &aInfo);
+	inline TInt GetThreadInfo(const TInt aIndex, TMetroTrkTaskInfo &aInfo);
+	inline TInt GetProcessAddresses(const TUint32 aThreadId, TUint32 &aCodeAddress, TUint32 &aDataAddress);
+	inline TInt GetStaticLibraryInfo(const TInt aIndex, SEventInfo &aInfo);
+	inline TInt EnableLibLoadedEvent();
+	inline TInt DisableLibLoadedEvent();
+	inline TInt GetLibraryInfo(TMetroTrkLibInfo &aInfo);
+	inline TInt GetExeInfo(TMetroTrkExeInfo &aInfo);
+	inline TInt GetProcUidInfo(TMetroTrkProcUidInfo &aInfo);
+	inline TInt DetachProcess(const TUint32 &aProcessId);
+
+};
+
+
+_LIT(KMetroTrkDriverName,"Trk Driver");
+
+// Version information
+const TInt KMajorVersionNumber=2;
+const TInt KMinorVersionNumber=0;
+const TInt KBuildVersionNumber=3;
+
+
+inline TInt RMetroTrkDriver::Open(const TMetroTrkDriverInfo aDriverInfo)
+{
+	TBuf8<32> buf;
+	buf.Append((TUint8*)&aDriverInfo.iPanic1Address, 4);
+	buf.Append((TUint8*)&aDriverInfo.iPanic2Address, 4);
+	buf.Append((TUint8*)&aDriverInfo.iException1Address, 4);
+	buf.Append((TUint8*)&aDriverInfo.iException2Address, 4);
+	buf.Append((TUint8*)&aDriverInfo.iLibraryLoadedAddress, 4);
+	buf.Append((TUint8*)&aDriverInfo.iUserLibraryEnd, 4);
+	
+	#ifdef EKA2
+	return DoCreate(KMetroTrkDriverName, TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber), KNullUnit, NULL, &buf);
+	#else
+	return DoCreate(KMetroTrkDriverName, TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber), NULL, KNullUnit, NULL, &buf);
+	#endif
+}
+
+inline TInt RMetroTrkDriver::SetBreak(const TUint32 aProcessId, const TUint32 aThreadId, const TUint32 aAddr, const TBool aThumbMode, TInt32 &aId)
+{
+	TMetroTrkBreakInfo info(aAddr, aThumbMode, &aId, aProcessId);
+	return DoSvControl(EControlSetBreak, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info);
+}
+
+inline TInt RMetroTrkDriver::ClearBreak(const TInt32 aId)
+{
+	return DoSvControl(EControlClearBreak, reinterpret_cast<TAny*>(aId));
+}
+
+inline TInt RMetroTrkDriver::ChangeBreakThread(const TUint32 aThreadId, const TInt32 aId)
+{
+	return DoControl(EControlChangeBreakThread, reinterpret_cast<TAny*>(aThreadId), reinterpret_cast<TAny*>(aId));
+}
+
+inline TInt RMetroTrkDriver::SuspendThread(const TUint32 aThreadId)
+{
+	return DoControl(EControlSuspendThread, reinterpret_cast<TAny*>(aThreadId));
+}
+
+inline TInt RMetroTrkDriver::ResumeThread(const TUint32 aThreadId)
+{
+	return DoSvControl(EControlResumeThread, reinterpret_cast<TAny*>(aThreadId));
+}
+
+inline TInt RMetroTrkDriver::StepRange(const TUint32 aThreadId, const TUint32 aStartAddress, const TUint32 aStopAddress, TBool aStepInto)
+{
+	TMetroTrkStepInfo info(aStartAddress, aStopAddress, aStepInto);
+	return DoSvControl(EControlStepRange, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info);
+}
+
+inline TInt RMetroTrkDriver::ReadMemory(const TUint32 aThreadId, const TUint32 aAddress, const TInt16 aLength, TDes8 &aData)
+{
+	TMetroTrkMemoryInfo info(aAddress, aLength, &aData);
+	return DoControl(EControlReadMemory, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info);
+}
+
+inline TInt RMetroTrkDriver::WriteMemory(const TUint32 aThreadId, const TUint32 aAddress, const TInt16 aLength, TDesC8 &aData)
+{
+	TMetroTrkMemoryInfo info(aAddress, aLength, &aData);
+	return DoControl(EControlWriteMemory, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info);
+}
+
+inline TInt RMetroTrkDriver::ReadRegisters(const TUint32 aThreadId, const TInt32 aFirstRegister, const TInt32 aLastRegister, TDes8 &aValues)
+{
+	TMetroTrkRegisterInfo info(aFirstRegister, aLastRegister, &aValues);
+	return DoControl(EControlReadRegisters, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info);
+}
+
+inline TInt RMetroTrkDriver::WriteRegisters(const TUint32 aThreadId, const TInt32 aFirstRegister, const TInt32 aLastRegister, TDesC8 &aValues)
+{
+	TMetroTrkRegisterInfo info(aFirstRegister, aLastRegister, &aValues);
+	return DoControl(EControlWriteRegisters, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info);
+}
+
+inline void RMetroTrkDriver::GetEvent(TRequestStatus &aStatus, SEventInfo &aEventInfo)
+{
+	DoRequest(ERequestGetEvent, aStatus, (TAny*)&aEventInfo);
+}
+
+inline void RMetroTrkDriver::CancelGetEvent()
+{
+	DoCancel(ERequestGetEventCancel);
+}
+
+inline TInt RMetroTrkDriver::GetProcessInfo(const TInt aIndex, TMetroTrkTaskInfo &aInfo)
+{
+	return DoControl(EControlGetProcessInfo, reinterpret_cast<TAny*>(aIndex), (TAny*)&aInfo);
+}
+
+inline TInt RMetroTrkDriver::GetThreadInfo(const TInt aIndex, TMetroTrkTaskInfo &aInfo)
+{
+	return DoControl(EControlGetThreadInfo, reinterpret_cast<TAny*>(aIndex), (TAny*)&aInfo);
+}
+
+inline TInt RMetroTrkDriver::GetProcessAddresses(const TUint32 aThreadId, TUint32 &aCodeAddress, TUint32 &aDataAddress)
+{
+	TMetroTrkProcessInfo info(&aCodeAddress, &aDataAddress);
+	return DoControl(EControlGetProcessAddresses, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info);
+}
+
+inline TInt RMetroTrkDriver::GetStaticLibraryInfo(const TInt aIndex, SEventInfo &aInfo)
+{
+	return DoControl(EControlGetStaticLibraryInfo, reinterpret_cast<TAny*>(aIndex), (TAny*)&aInfo);
+}
+
+inline TInt RMetroTrkDriver::EnableLibLoadedEvent()
+{
+	return DoControl(EControlEnableLibLoadedEvent);
+}
+
+inline TInt RMetroTrkDriver::DisableLibLoadedEvent()
+{
+	return DoControl(EControlDisableLibLoadedEvent);
+}
+
+inline TInt RMetroTrkDriver::GetLibraryInfo(TMetroTrkLibInfo &aInfo)
+{
+	return DoControl(EControlGetLibraryInfo, (TAny*)&aInfo);
+}
+
+inline TInt RMetroTrkDriver::GetExeInfo(TMetroTrkExeInfo &aInfo)
+{
+	return DoControl(EControlGetExeInfo, (TAny*)&aInfo);
+}
+
+inline TInt RMetroTrkDriver::GetProcUidInfo(TMetroTrkProcUidInfo &aInfo)
+{
+	return DoControl(EControlGetProcUidInfo, (TAny*)&aInfo);
+}
+
+inline TInt RMetroTrkDriver::DetachProcess(const TUint32 &aProcessId)
+{
+    return DoControl(EControlDetachProcess, (TAny*)&aProcessId);
+}
+#endif // __TRKKERNELDRIVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/TrkKernelDriver_s60.mmh	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+#include <kernel/kern_ext.mmh>
+
+macro 		__S60__
+
+TARGET			TrkDriver.ldd
+TARGETTYPE		LDD
+UID				0x100000AF 0x200159DA
+SOURCEPATH		.
+SOURCE			TrkKernelDriver.cpp TrkEventHandler.cpp
+//LIBRARY			ekern.lib
+
+NOSTRICTDEF
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+
+systeminclude		\epoc32\include 
+systeminclude		\epoc32\include\kernel 
+systeminclude		\epoc32\include\nkern
+
+systeminclude		\epoc32\include\kernel\arm
+systeminclude		\epoc32\include\nkern\arm
+
+systeminclude		\epoc32\include\memmodel\epoc
+systeminclude		\epoc32\include\memmodel\epoc\mmubase
+
+DEFFILE			..\eabi\trkkerneldriver.def
+
+#else
+
+OS_LAYER_KERNEL_SYSTEMINCLUDE
+DEFFILE			../eabi/trkkerneldriver.def
+
+#endif
+
+VENDORID VID_DEFAULT
+capability			all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/TrkKernelDriver_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+macro 	__OEM_TRK__
+
+#include "TrkKernelDriver_s60.mmh"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/TrkKernelDriver_tv.mmh	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+macro	__KERNEL_MODE__
+
+TARGET			TrkDriver.ldd
+TARGETTYPE		LDD
+UID				0x100000AF 0x200159DA
+SOURCEPATH		.
+SOURCE			TrkKernelDriver.cpp TrkEventHandler.cpp
+LIBRARY			ekern.lib
+
+NOSTRICTDEF
+
+
+systeminclude		/epoc32/include 
+systeminclude		/epoc32/include/kernel 
+systeminclude		/epoc32/include/nkern
+
+systeminclude		/epoc32/include/kernel/arm
+systeminclude		/epoc32/include/nkern/arm
+
+systeminclude		/epoc32/include/memmodel/epoc
+systeminclude		/epoc32/include/memmodel/epoc/mmubase
+
+DEFFILE			../eabi/trkkerneldriver.def
+
+
+
+VENDORID 0x101FB657
+capability			all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/TrkKernelDriver_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+macro 	__OEM_TRK__
+
+#include "trkkerneldriver_tv.mmh"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/isv_trkKerneldriver_uiq.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "trkKerneldriver_uiq.mmh"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/trkkerneldriver_uiq.mmh	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+macro	__KERNEL_MODE__
+
+TARGET			TrkDriver.ldd
+TARGETTYPE		LDD
+UID				0x100000AF 0x200159DA
+SOURCEPATH		.
+SOURCE			TrkKernelDriver.cpp TrkEventHandler.cpp
+LIBRARY			ekern.lib
+
+NOSTRICTDEF
+
+
+systeminclude		\epoc32\include 
+systeminclude		\epoc32\include\kernel 
+systeminclude		\epoc32\include\nkern
+
+systeminclude		\epoc32\include\kernel\arm
+systeminclude		\epoc32\include\nkern\arm
+
+systeminclude		\epoc32\include\memmodel\epoc
+systeminclude		\epoc32\include\memmodel\epoc\mmubase
+
+DEFFILE			..\eabi\trkkerneldriver.def
+
+VENDORID 0x101FB657
+capability			all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/eka2driver/trkkerneldriver_uiq.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+macro 	__OEM_TRK__
+
+#include "TrkKernelDriver_uiq.mmh"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/DateTimeConverter.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "DateTimeConverter.h"
+
+//
+//
+// TDateTimeConverter implementation
+//
+//
+
+//
+// TDateTimeConverter constructor
+//
+// Accepts Win32 date/time format and converts it to Symbian OS format
+//
+TDateTimeConverter::TDateTimeConverter(TUint32 aWinTimeDate)
+{
+	iWinTimeDate.winTimeDate = aWinTimeDate;
+	iEpocTimeDate.Set((TInt)(iWinTimeDate.t.year + 1980), (TMonth)(iWinTimeDate.t.month - 1),
+					  (TInt)(iWinTimeDate.t.day - 1), (TInt)iWinTimeDate.t.hour,
+					  (TInt)iWinTimeDate.t.minute, (TInt)(iWinTimeDate.t.second * 2), 0);
+}
+
+//
+// TDateTimeConverter constructor
+//
+// Accepts Win32 date/time format and converts it to Symbian OS format
+//
+TDateTimeConverter::TDateTimeConverter(TDateTime aEpocTimeDate)
+	: iEpocTimeDate(aEpocTimeDate)
+{
+	iWinTimeDate.t.hour = aEpocTimeDate.Hour();
+	iWinTimeDate.t.minute = aEpocTimeDate.Minute();
+	iWinTimeDate.t.second = (aEpocTimeDate.Second() / 2);
+	iWinTimeDate.t.year = aEpocTimeDate.Year() - 1980;
+	iWinTimeDate.t.month = aEpocTimeDate.Month() + 1;
+	iWinTimeDate.t.day = aEpocTimeDate.Day() + 1;
+}
+
+//
+// TDateTimeConverter::GetWinTimeDate
+//
+// Returns the date/time in Win32 format
+//
+TUint32 TDateTimeConverter::GetWinTimeDate()
+{
+	return iWinTimeDate.winTimeDate;
+}
+
+//
+// TDateTimeConverter::GetEpocTimeDate
+//
+// Returns the date/time in Symbian OS format
+//
+TDateTime TDateTimeConverter::GetEpocTimeDate()
+{
+	return iEpocTimeDate;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/DateTimeConverter.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __DATETIMECONVERTER_H__
+#define __DATETIMECONVERTER_H__
+
+#include <e32std.h>
+
+//
+// class TDateTimeConverter
+//
+// Converts between Win32 time and Symbian OS time
+//
+class TDateTimeConverter
+{
+public:
+
+	TDateTimeConverter(TUint32 aWinTimeDate);
+	TDateTimeConverter(TDateTime aEpocTimeDate);
+	
+	TUint32 GetWinTimeDate();
+	TDateTime GetEpocTimeDate();
+
+private:
+
+	union TWinTimeDate
+	{
+		struct
+		{
+			unsigned day:5;
+			unsigned month:4;
+			unsigned year:7;
+			unsigned second:5;
+			unsigned minute:6;
+			unsigned hour:5;
+		} t;
+		
+		TUint32 winTimeDate;
+
+	} iWinTimeDate;
+
+	TDateTime iEpocTimeDate;
+};
+
+#endif // __DATETIMECONVERTER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/Isv_TrkEngine_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+macro	__S60__
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+TARGET		TrkEngine.dll
+TARGETTYPE	dll
+UID		0x00000000 0x200159D9
+
+VENDORID VID_DEFAULT
+CAPABILITY ALL -TCB -DRM
+
+SOURCEPATH	.
+
+SOURCE		TrkEngine.cpp TrkDispatchLayer.cpp TrkFramingLayer.cpp
+SOURCE		TrkSerialCommPort.cpp TrkBtSocketCommPort.cpp DateTimeConverter.cpp
+SOURCE 		TrkEngineModel.cpp TrkUsbPortListener.cpp TrkDbgTrcCommPort.cpp
+SOURCE		TrkSwInstall.cpp TrkSwInstUIHandler.cpp
+
+
+LIBRARY	efsrv.lib euser.lib c32.lib sishelper.lib
+LIBRARY eikcoctl.lib
+LIBRARY	esock.lib
+LIBRARY bluetooth.lib
+LIBRARY btextnotifiers.lib
+LIBRARY btmanclient.lib
+LIBRARY sdpagent.lib
+LIBRARY sdpdatabase.lib 
+LIBRARY	charconv.lib
+LIBRARY	flogger.lib
+LIBRARY SWInstCli.lib
+LIBRARY usbman.lib
+LIBRARY usbostcomm.lib
+LIBRARY sysutil.lib 
+LIBRARY	etel3rdparty.lib 
+
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+  	SYSTEMINCLUDE	\epoc32\include
+  	USERINCLUDE	..\eka2driver
+	
+	#if defined(WINS)
+    deffile .\trkengU_win.def
+	#elif defined(EABI)
+	    deffile ..\eabi\isv_trkengine.def
+	#endif
+
+#else
+    MW_LAYER_SYSTEMINCLUDE
+	USERINCLUDE	../eka2driver
+	#if defined(WINS)
+    deffile ./trkengU_win.def
+	#elif defined(EABI)
+	    deffile ../eabi/isv_trkengine.def
+	#endif
+#endif
+nostrictdef
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/Isv_TrkEngine_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+TARGET		TrkEngine.dll
+TARGETTYPE	dll
+UID		0x00000000 0x200159D9
+
+VENDORID 0x101FB657
+CAPABILITY ALL -TCB -DRM
+
+SOURCEPATH	.
+SOURCE		TrkEngine.cpp TrkDispatchLayer.cpp TrkFramingLayer.cpp TrkEngineModel.cpp
+SOURCE		TrkSerialCommPort.cpp DateTimeConverter.cpp TrkUsbPortListener.cpp
+SOURCE		TrkSwInstall.cpp TrkSwInstUIHandler.cpp TrkBtSocketCommPort.cpp
+
+
+LIBRARY		efsrv.lib euser.lib c32.lib sishelper.lib usbman.lib
+LIBRARY		esock.lib bluetooth.lib btextnotifiers.lib btmanclient.lib sdpagent.lib sdpdatabase.lib 
+LIBRARY     sishelper.lib
+LIBRARY 	usbostcomm.lib
+LIBRARY 	sysutil.lib 
+LIBRARY		etel3rdparty.lib 
+
+SYSTEMINCLUDE	/epoc32/include
+SYSTEMINCLUDE	/epoc32/include\kernel
+USERINCLUDE	. 
+
+USERINCLUDE	../eka2driver
+
+
+#if defined(WINS)
+    deffile ./trkengU_win.def
+#elif defined(EABI)
+    deffile ../eabi/isv_trkengine.def
+#endif
+nostrictdef
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkBtSocketCommPort.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,575 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <e32cons.h>
+#include <f32file.h>
+// Notifier to select a device
+#include <btextnotifiers.h>
+
+#ifdef __UIQ_BUILD__
+#include <QBTselectdlg.h>
+#include <btsdp.h>          // CSdpAgent
+#endif
+
+#include "TrkBtSocketCommPort.h"
+#include "TrkFramingLayer.h"
+#include "TrkConnData.h"
+
+
+//
+// Static helper functions
+//
+
+//
+//
+// CTrkBtSocketCommPort implementation
+//
+//
+
+//
+// CTrkBtSocketCommPort constructor
+//
+CTrkBtSocketCommPort::CTrkBtSocketCommPort()
+	: CTrkCommPort(CActive::EPriorityStandard, ETrkNotConnected),
+	  iServerStarted(EFalse),
+	  iConnected(EFalse),
+	  iListening(EFalse),
+	  iCurrUUID(0),
+	  iPortValid(EFalse),
+	  iDiscovering(EFalse),
+	  iSearchPattern(NULL),
+	  iAgent(NULL),
+	  iConnectionListener(NULL)
+{
+   iAddr.Reset();
+}
+
+//
+// CTrkBtSocketCommPort::ConstructL
+//
+void CTrkBtSocketCommPort::ConstructL(TTrkConnData aTrkConnData, TDes& /*aErrorMessage*/, MTrkConnectionListener* aCallback)
+{
+	iUnitNumber = aTrkConnData.iPortNumber;
+	iUpdatedPort = iUnitNumber;
+
+	CActiveScheduler::Add(this);		
+	
+	iConnectionListener = aCallback;
+	
+}
+
+//
+// CTrkBtSocketCommPort destructor
+//
+CTrkBtSocketCommPort::~CTrkBtSocketCommPort()
+{
+	// make sure we cancel the request for data before shutting down
+	Cancel();
+	StopDiscovery();
+	
+	if (iConnected)
+	{
+		iSock.Close();
+		iConnected = EFalse;
+	}
+	
+	if (iServerStarted)
+	{
+		iSocketServ.Close();
+		iServerStarted = EFalse;
+	}	
+	
+
+}
+
+//
+// CTrkBtSocketCommPort::NewL
+//
+CTrkBtSocketCommPort* CTrkBtSocketCommPort::NewL(TTrkConnData aTrkConnData, TDes& aErrorMessage, MTrkConnectionListener* aCallback)
+{
+	CTrkBtSocketCommPort* self = new(ELeave) CTrkBtSocketCommPort;
+	CleanupStack::PushL(self);
+	self->ConstructL(aTrkConnData, aErrorMessage, aCallback);
+	CleanupStack::Pop(self);
+	return self;
+}
+
+//
+// CTrkBtSocketCommPort::OpenPortL
+//
+// Open the bluetooth selection dialog and connect to the selected device.
+//
+void CTrkBtSocketCommPort::OpenPortL()
+{
+	if (!iServerStarted)
+	{
+		StartC32();
+		ReportAndLeaveIfErrorL(iSocketServ.Connect(), _L("Failed to connect to socketserver."));
+		iServerStarted = ETrue;
+	}
+
+#ifdef __UIQ_BUILD__
+	CBTDeviceArray* aSelectedDeviceArray = new (ELeave) CArrayPtrFlat<CBTDevice>(4); 
+	CleanupStack::PushL(aSelectedDeviceArray); 
+	CQBTUISelectDialog* dialog = CQBTUISelectDialog::NewL(aSelectedDeviceArray); 
+	TInt err = dialog->RunDlgLD(KQBTUISelectDlgFlagNone);
+	if (err == KErrNone)
+	{ 
+		CBTDevice* ptrBTDev = aSelectedDeviceArray->operator[](0); 
+
+	  	TBTDeviceResponseParamsPckg devRespParamsPckg;
+		devRespParamsPckg().SetDeviceAddress(ptrBTDev->BDAddr()); 
+		devRespParamsPckg().SetDeviceName(ptrBTDev->FriendlyName()); 
+		devRespParamsPckg().SetDeviceClass(ptrBTDev->DeviceClass()); 
+
+		TBuf8<100> tmpName = ptrBTDev->DeviceName();
+		iName.Copy(tmpName);
+		iAddr = devRespParamsPckg().BDAddr();
+	}
+	else
+	{ 
+		ReportAndLeaveIfErrorL(err, _L("Failed to get device list."));
+	}
+	CleanupStack::Pop(aSelectedDeviceArray); 
+#else
+	// Try to open bluetooth selection dialog to get the name and address of the device
+	TBTDeviceResponseParamsPckg aResponse;
+    
+    RNotifier notifier;
+    User::LeaveIfError(notifier.Connect());
+  
+    TBTDeviceSelectionParamsPckg selectionFilter;
+
+    TRequestStatus status;
+    notifier.StartNotifierAndGetResponse(
+        status,
+        KDeviceSelectionNotifierUid,
+        selectionFilter,
+        aResponse
+    );
+
+    User::WaitForRequest(status);
+
+    if (status.Int() != KErrNone)
+    {
+        notifier.CancelNotifier(KDeviceSelectionNotifierUid);
+	    notifier.Close();
+	
+     	ReportAndLeaveIfErrorL(status.Int(), _L("Failed to get device list."));
+    }
+
+    notifier.CancelNotifier(KDeviceSelectionNotifierUid);
+    notifier.Close();
+    
+    iName = aResponse().DeviceName();
+    iAddr = aResponse().BDAddr();
+#endif
+
+	// load protocol, RFCOMM
+	TProtocolDesc pdesc;
+	ReportAndLeaveIfErrorL(iSocketServ.FindProtocol(_L("RFCOMM"), pdesc),_L("Unable to find protocol."));
+
+	// open socket
+	ReportAndLeaveIfErrorL(iSock.Open(iSocketServ, _L("RFCOMM")),_L("Unable to open socket."));
+	// set address and port
+    iState = EDiscovering;
+    DiscoverPortL();
+    iConnectionStatus = ETrkConnecting;
+}
+
+/*
+ * To connect to BT socket after getting appropriate port
+ * 
+ */
+void CTrkBtSocketCommPort::ConnectToPortL()
+{
+	TBTSockAddr addr;
+	addr.SetBTAddr(iAddr);
+    addr.SetPort(iUpdatedPort);
+
+	TRequestStatus cstatus;
+	iSock.Connect(addr, cstatus);
+	User::WaitForRequest(cstatus);
+
+    TInt err = cstatus.Int();    
+    if (err != KErrNone)
+    {
+        iErrorMessage.Format(_L("Error connecting socket\r\nError Code: %d\r\n"),err);
+        iConnectionStatus = ETrkConnectionError;
+        iConnectionListener->AsyncConnectionFailed();
+        return;
+	}
+		
+	iConnected = ETrue;
+    iConnectionMessage.Format(_L("BT Dev Name: %S\r\nBT Port number: %d\r\n"), &iName, iUpdatedPort);
+		
+    iConnectionStatus = ETrkConnected;
+    iConnectionListener->AsyncConnectionSuccessfulL();    
+}
+
+//
+// CTrkBtSocketCommPort::ClosePort
+//
+// Close the communications port
+//
+void CTrkBtSocketCommPort::ClosePort()
+{
+	Cancel();
+	
+	if (iConnected)
+	{
+		iSock.Close();
+		iConnected = EFalse;
+	}
+
+	if (iServerStarted)
+	{
+		iSocketServ.Close();
+		iServerStarted = EFalse;
+	}
+}
+
+//
+// CTrkBtSocketCommPort::SendDataL
+//
+// Write data to the serial type port
+//
+void CTrkBtSocketCommPort::SendDataL(const TDesC8& aBuffer)
+{
+	iSock.CancelRead();
+	iState = ESending;
+
+	iSock.Write(aBuffer, iStatus);
+	User::WaitForRequest(iStatus);
+	
+	if (iStatus!=KErrNone)
+	{
+		ReportAndLeaveIfErrorL(iStatus.Int(), _L("Error sending data."));
+	}	
+}
+
+//
+// CTrkBtSocketCommPort::Listen
+//
+// Start listening for data coming into the serial type communications port
+//
+void CTrkBtSocketCommPort::Listen(CTrkFramingLayer *aFramingLayer)
+{
+	iFramingLayer = aFramingLayer;
+	iListening = ETrue;
+}
+
+//
+// CTrkBtSocketCommPort::StopListening
+//
+// Stop listening for data coming into the serial type communications port
+//
+void CTrkBtSocketCommPort::StopListening()
+{
+	if (iListening)
+	{
+		iSock.CancelRead();
+		Cancel();
+		Deque();
+	}
+	
+	iListening = EFalse;
+}
+
+//
+// CTrkBtSocketCommPort::ReportAndLeaveIfErrorL
+//
+// If an error occurred, print the error information to the screen and bail out
+//
+void CTrkBtSocketCommPort::ReportAndLeaveIfErrorL(TInt aError, const TDesC& aDesc)
+{
+	if (KErrNone != aError)
+	{
+		iErrorMessage.Format(_L("%S\r\nError Code: %d\r\n"), &aDesc, aError);
+		User::Leave(aError);
+	}
+}
+
+
+//
+// CTrkBtSocketCommPort::IssueReadRequest
+//
+// Wait for data to come into the communications port
+//
+void CTrkBtSocketCommPort::IssueReadRequest()
+{
+	iSock.CancelRead();
+	iNextReadChar = 0;
+	iState = EWaiting;
+	iReceivedChars.Zero();
+	iSock.RecvOneOrMore(iReceivedChars, 0, iStatus, iLen);
+	SetActive();
+}
+
+//
+// CTrkBtSocketCommPort::DoCancel
+//
+// Cancel the request for data from the communications port
+//
+void CTrkBtSocketCommPort::DoCancel()
+{
+	//iSock.CancelRead();
+	//iPort.ReadCancel();
+}
+
+//
+// CTrkBtSocketCommPort::RunL
+//
+// Called when data comes into the communications port
+//
+void CTrkBtSocketCommPort::RunL()
+{
+	if (iStatus != KErrNone)
+	{
+		switch(iState)
+		{
+		   case EDiscovering:
+		   {
+		       iConnectionListener->AsyncConnectionFailed();
+		       break;	       
+		   }	       
+		   default:
+		 	  break;
+		}
+	}
+	else
+	{
+		switch (iState)
+		{
+	
+			case EWaiting:
+			{
+				if (iStatus.Int() == KErrNone)
+				{
+					while (iNextReadChar < iReceivedChars.Length())
+						iFramingLayer->HandleByte(iReceivedChars[iNextReadChar++]);
+				}
+				break;
+			}
+			case ESending:
+			{
+				break;
+			}
+			case EDiscovering:
+			{
+				ConnectToPortL();
+				break;
+			}
+			case EConnecting:
+			{
+				break;
+			}
+			default:
+				break;
+		}
+		IssueReadRequest();
+	}
+
+}
+
+//
+// CTrkBtSocketCommPort::DiscoverPortL
+//
+// Called to figure out the port number for serial profile
+//
+void CTrkBtSocketCommPort::DiscoverPortL()
+{
+    StopDiscovery(); // to avoid conflicts if called several times before the old discovery is finished
+   
+    const TInt BT_UUID_SPP_SP = 0x1101; // SPP (Serial Port) UUID
+    
+    // Init new service discovery agent
+    iAgent = CSdpAgent::NewL( *this, iAddr);
+    
+    // Set search properties for agent (use SPP service-UUID to filter the services discovered)
+    iSearchPattern = CSdpSearchPattern::NewL();
+    
+    iSearchPattern->AddL(BT_UUID_SPP_SP);
+    iAgent->SetRecordFilterL(*iSearchPattern);
+    iDiscovering = ETrue;
+   
+    // Initiate search, result will be received with call of NextRecordRequestComplete()
+    iAgent->NextRecordRequestL();
+    iStatus = KRequestPending;
+    SetActive();       
+}
+
+//
+//CTrkBtSocketCommPort::StopDiscovery()
+//
+//Called to stop the discovery services
+//
+void CTrkBtSocketCommPort::StopDiscovery()
+{
+    iDiscovering = EFalse;
+    
+    if (iAgent)
+    {
+        iAgent->Cancel();
+        delete iAgent;
+        iAgent = NULL;
+    }
+    
+    if (iSearchPattern)
+    {
+        iSearchPattern->Reset();
+        delete iSearchPattern;
+        iSearchPattern = NULL;
+    }
+}
+
+
+//
+// CTrkBtSocketCommPort::NextRecordRequestComplete
+//
+// called when the service discovery agent has completed discovering services on device (i.e. if next service found or not)
+//
+void CTrkBtSocketCommPort::NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount)
+{
+    if ( (KErrNone == aError) && (0 < aTotalRecordsCount) )
+    {
+        // We got next service record, request protocol descriptor to retrieve remote port
+        // (it calls later the AttributeRequestResult() when the answer is ready)
+        TRAPD(err, iAgent->AttributeRequestL(aHandle, KSdpAttrIdProtocolDescriptorList));
+        if( err )
+        {
+	        iErrorMessage.Format(_L("Error in finding the serial port record\r\nError Code: %d\r\n"),err);
+	        iConnectionStatus = ETrkConnectionError;
+	        StopDiscovery();
+	        TRequestStatus *status = &iStatus;
+	        User::RequestComplete(status, aError);
+        }
+    }
+    else
+    {
+	    // no any services found or error occures (probably the device is not present or SPP service is not present)
+	    iErrorMessage.Format(_L("Error in finding the serial port record\r\nError Code: %d\r\n"),aError);
+	    iConnectionStatus = ETrkConnectionError;
+	    StopDiscovery();
+	    TRequestStatus *status = &iStatus;
+	    User::RequestComplete(status, aError);  
+    }    
+
+}
+
+
+//
+//CTrkBtSocketCommPort::AttributeRequestResult
+//
+// Called when the service attributes for the service record have been retrieved.
+//
+void CTrkBtSocketCommPort::AttributeRequestResult(TSdpServRecordHandle, TSdpAttributeID, CSdpAttrValue* aAttrValue)
+{
+    // can't ignore the call of this function because we need take care about aAttrValue
+    // Parse attributes, it will return results by several calls of VisitAttributeValue()
+    TRAPD(err, aAttrValue->AcceptVisitorL(*this));
+    if( err )
+    {   
+	    iErrorMessage.Format(_L("Error in finding the serial port record \r\nError Code: %d"),err);
+	    iConnectionStatus = ETrkConnectionError;
+	    StopDiscovery();
+	    TRequestStatus *status = &iStatus;
+	    User::RequestComplete(status, err);
+    }
+    delete aAttrValue;
+}
+
+//
+// CTrkBtSocketCommPort::AttributeRequestComplete
+//
+// Called when the request to resolve the service attributes for the service record completes.
+//
+void CTrkBtSocketCommPort::AttributeRequestComplete(TSdpServRecordHandle, TInt aError)
+{
+    // if KErrNone ==aError and we need not just the first SPP service but check several services,
+    // can call for iAgent->NextRecordRequestL() here (and add corresponded processing in
+    // NextRecordRequestComplete() )
+    if (KErrNone != aError)
+    {
+        iErrorMessage.Format(_L("Error in finding the serial port record\r\nError Code: %d"),aError);
+        iConnectionStatus = ETrkConnectionError;
+        StopDiscovery();
+        TRequestStatus *status = &iStatus;
+        User::RequestComplete(status, aError);
+    }
+    else
+    {
+        StopDiscovery();
+        TRequestStatus *status = &iStatus;
+        User::RequestComplete(status, KErrNone);  
+    }
+}
+    
+//
+// CTrkBtSocketCommPort::VisitAttributeValueL
+//    
+// Called for processing of each service attribute.
+//
+void CTrkBtSocketCommPort::VisitAttributeValueL(CSdpAttrValue &aValue, TSdpElementType aType)
+{
+    if (!iDiscovering)
+    {
+        return; // ignore calls to that function if not discovering currently
+    }
+    
+    // Check for attributes of UUID type. 
+    // If the UUID is RFCOMM UUID, resolve the value for this attribute,
+    // which will be the channel number.
+    switch (aType)
+    {
+        case ETypeUUID: // UUID of attribute, store it 
+        {
+            TPtrC8 uuid(aValue.UUID().ShortestForm());
+            iCurrUUID.SetL(uuid);
+            break;
+        }
+        case ETypeUint: // uint value, check if the current attribute type is KRFCOMM, store the port value if "yes"
+        {
+            if (iCurrUUID == KRFCOMM)
+            {
+                iUpdatedPort = aValue.Uint();
+                iPortValid = TRUE;
+                iDiscovering = EFalse;
+            }
+            break;
+        }
+        default:
+            // other attributes are not interesting for processing...
+            break;
+    }   
+}
+
+/*
+ * This method should be overridden
+ */
+void CTrkBtSocketCommPort::StartListL(CSdpAttrValueList&)
+{
+}
+
+/*
+ * This method should be overridden 
+ * 
+ */
+void CTrkBtSocketCommPort::EndListL()
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkBtSocketCommPort.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKBTSOCKETCOMMPORT_H__
+#define __TRKBTSOCKETCOMMPORT_H__
+
+#include <e32base.h>
+#include <c32comm.h>
+#ifdef __UIQ_BUILD__
+#include <BTExtNotifiers.h>
+#include <BtSdp.h>
+#endif
+// Extra stuff for RFComm
+#include <es_sock.h>
+#include <btdevice.h>
+#include <bt_sock.h>
+
+#include <flogger.h>
+#include "TrkCommPort.h"
+#include "TrkConnectionListener.h"
+#include <btsdp.h> 
+
+#include <btextnotifiers.h>
+
+
+//
+// class CTrkBtSocketCommPort
+//
+// Defines an interface to a serial type communications port
+//
+class TTrkConnData;
+
+class MSdpAttributeValueVisitor;
+class MSdpAgentNotifier;
+class CTrkBtSocketCommPort : public CTrkCommPort,   public MSdpAgentNotifier, public MSdpAttributeValueVisitor
+{
+public:
+
+	static CTrkBtSocketCommPort* NewL(TTrkConnData aTrkConnData, TDes& aErrorMessage, MTrkConnectionListener* aCallback);
+	~CTrkBtSocketCommPort();
+
+	void OpenPortL();
+	void ClosePort();
+
+	void SendDataL(const TDesC8& aData);
+	void Listen(CTrkFramingLayer *aFramingLayer);
+	void StopListening();
+
+	void DiscoverPortL();
+	// stopes the discovery (aborts it and delete variables used for it) 
+	void StopDiscovery();
+protected:
+
+	void DoCancel();
+	void RunL();
+
+private:
+
+	CTrkBtSocketCommPort();
+	void ConstructL(TTrkConnData aTrkConnData, TDes& aErrorMessage,MTrkConnectionListener* aCallback);
+	void IssueReadRequest();
+	void ReportAndLeaveIfErrorL(TInt aError, const TDesC& aDesc);
+	// from MSdpAgentNotifier:
+	void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount);
+	void AttributeRequestResult(TSdpServRecordHandle aHandle, TSdpAttributeID aAttrID, CSdpAttrValue* aAttrValue);
+	void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError);
+
+	// from MSdpAttributeValueVisitor:
+	void VisitAttributeValueL(CSdpAttrValue &aValue, TSdpElementType aType); // Called for processing of each service attribute.
+	void StartListL(CSdpAttrValueList&);
+	void EndListL();
+	void ConnectToPortL();
+	
+private:
+
+    TUint  iUpdatedPort;
+	TUint  iUnitNumber;
+	TUint  iRate;
+
+	RCommServ iServer;
+	//RComm  iPort;
+
+	TBool iServerStarted;
+	TBool iConnected;
+	TBool iListening;
+
+	TBuf8<MAXMESSAGESIZE> iReceivedChars;
+	TInt iNextReadChar;
+
+	CTrkFramingLayer* iFramingLayer;
+ 
+ 	// name of the device connector connects
+	THostName iName;
+	// address of the device connector connects
+	TBTDevAddr iAddr;
+	TUUID iCurrUUID; // currently discovered attribute uuid in the service attributes
+	TBool iPortValid; // true if the Port was retrieved
+	TBool iDiscovering; // true if currently discovering the device (if interested on results of listener functions)
+	CSdpSearchPattern* iSearchPattern; // Service discovery search pattern
+	CSdpAgent* iAgent; // Service discovery agent      	
+	// connecting socket
+	RSocket iSock;
+
+	// socket server
+    RSocketServ iSocketServ;
+    // length of received data
+    TSockXfrLength iLen;
+	
+    MTrkConnectionListener* iConnectionListener;
+    
+    enum TState
+    {
+        ENone = 1,
+        EConnecting,
+		EWaiting,
+		ESending,
+		EDiscovering,
+    };
+    TState iState;
+};
+
+#endif // __TRKBTSOCKETCOMMPORT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkCommPort.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,151 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKCOMMPORT_H__
+#define __TRKCOMMPORT_H__
+
+#include <e32base.h>
+#include "TrkConnData.h"
+
+
+//
+// Macros
+//
+// these must be defined before including msgcmd.h
+#define DS_PROTOCOL	DS_PROTOCOL_RTOS
+#define DEBUG_MSGCMD 0
+
+#include "msgcmd.h"
+
+#define SafeDelete(x) { if (x) delete x; x = NULL; }
+
+
+//
+// class CInactivityTimerDisabler
+//
+// Active object used to avoid auto-switch off
+//
+class CInactivityTimerDisabler : public CActive
+{
+public:
+
+	CInactivityTimerDisabler();
+	void ConstructL();
+	~CInactivityTimerDisabler();
+	void Activate();
+
+protected:
+
+	void RunL();
+	void DoCancel();
+
+private:
+
+	enum { KPeriod = 5 * 1000000 };
+
+	RTimer iTimer;
+};
+
+//
+//
+// CInactivityTimerDisabler implementation
+//
+//
+
+inline CInactivityTimerDisabler::CInactivityTimerDisabler()
+	: CActive(EPriorityLow)
+{
+	CActiveScheduler::Add(this);
+}
+
+inline void CInactivityTimerDisabler::ConstructL()
+{
+	User::LeaveIfError(iTimer.CreateLocal());
+}
+
+inline CInactivityTimerDisabler::~CInactivityTimerDisabler()
+{
+	Cancel();
+	iTimer.Close();
+	Deque();
+}
+
+inline void CInactivityTimerDisabler::Activate()
+{
+	iTimer.After(iStatus, KPeriod);
+	SetActive();
+}
+
+inline void CInactivityTimerDisabler::RunL()
+{
+	User::ResetInactivityTime();
+	Activate();
+}
+
+inline void CInactivityTimerDisabler::DoCancel()
+{
+	iTimer.Cancel();
+}
+
+
+//
+// Forward declarations
+class CTrkFramingLayer;
+
+
+//
+// class CTrkCommPort
+//
+// Abstract base class for communications port
+//
+class CTrkCommPort : public CActive
+{
+public:
+	
+	virtual ~CTrkCommPort();
+
+	virtual void OpenPortL() = 0;
+	virtual void ClosePort() = 0;
+	virtual void SendDataL(const TDesC8& aData) = 0;
+	virtual void Listen(CTrkFramingLayer *aFramingLayer) = 0;
+	virtual void StopListening() = 0;
+	virtual TBool IsConnectionEstablished() { return iConnectionStatus == ETrkConnected; };
+	virtual void GetConnectionInfo(TDes& aMessage) { aMessage = iConnectionMessage; };
+	virtual void GetErrorInfo(TDes& aMessage) { aMessage = iErrorMessage; };
+	virtual TTrkConnStatus GetConnectionStatus() { return iConnectionStatus; };
+
+protected:
+
+	CTrkCommPort(TInt aPriority, TTrkConnStatus aConnectionStatus);
+
+	TBuf<KMaxPath> iConnectionMessage;
+	TBuf<KMaxPath> iErrorMessage;
+	TTrkConnStatus iConnectionStatus;
+};
+
+inline CTrkCommPort::CTrkCommPort(TInt aPriority,TTrkConnStatus aConnectionStatus=ETrkConnected)
+	: CActive(aPriority),
+	iConnectionStatus(aConnectionStatus)
+{
+}
+
+inline CTrkCommPort::~CTrkCommPort()
+{
+}
+
+#endif // __TRKCOMMPORT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkCommPortListener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKCOMMPORTLISTENER_H__
+#define __TRKCOMMPORTLISTENER_H__
+
+#include <e32base.h>
+
+#include "TrkUsbConnectionListener.h"
+
+
+//
+// class CTrkCommPortListener
+//
+// Abstract base class for communications port listener
+//
+class CTrkCommPortListener : public CActive
+{
+public:
+	
+	virtual ~CTrkCommPortListener();
+	
+	virtual void ListenL() = 0;
+	virtual void StopListening() = 0;
+
+protected:
+	
+	CTrkCommPortListener(MTrkUsbConnectionListener *aConnectionListener, TInt aPriority);
+	virtual TInt RunError( TInt aError );
+
+protected:
+	
+	MTrkUsbConnectionListener* iConnectionListener;
+};
+
+inline CTrkCommPortListener::CTrkCommPortListener(MTrkUsbConnectionListener *aConnectionListener, TInt aPriority)
+	: CActive(aPriority),
+	iConnectionListener(aConnectionListener)
+{
+}
+
+inline CTrkCommPortListener::~CTrkCommPortListener()
+{
+}
+
+inline TInt CTrkCommPortListener::RunError(TInt aError)
+{
+	User::Panic( _L("TRK"), aError );	
+	return aError;
+}
+
+#endif // __TRKCOMMPORTLISTENER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkConnData.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,154 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#ifndef __TRKCONNDATA_H__
+#define __TRKCONNDATA_H__
+
+
+_LIT8(KNewLine, "\r\n");
+_LIT8(KSpace, " ");
+
+_LIT8(KSerialComm,   "[SERIALCOMM]");
+_LIT8(KBtSocketComm, "[BTSOCKCOMM]");
+_LIT8(KDCCComm, 	 "[DCCIO_COMM]");
+_LIT8(KXTIComm, 	 "[XTIIO_COMM]");
+_LIT8(KDbgTrcComm,   "[DBGTRCCOMM]");
+
+_LIT8(KPDD, "PDD");
+_LIT8(KLDD, "LDD");
+_LIT8(KCSY, "CSY");
+_LIT8(KPort, "PORT");
+_LIT8(KRate, "RATE");
+_LIT8(KPlugPlay, "PlugPlay");
+
+//
+// Default comm values
+//
+#ifdef __WINS__
+	_LIT(KDefaultPDD, "ECDRV");
+#else
+	_LIT(KDefaultPDD, "EUART%d");
+#endif
+	_LIT(KDefaultLDD, "ECOMM");
+	_LIT(KDefaultCSY, "ECUART");
+
+_LIT(KPort0, "0");
+_LIT(KPort1, "1");
+
+#define KDefaultPortNumber		0
+#define KDefaultUsbPortNumber	1
+#define KDefaultRate			115200
+
+
+//default IR settings
+_LIT8(KDefaultSerialPDD, "EUART");
+_LIT8(KDefaultSerialLDD, "ECOMM");
+_LIT8(KDefaultSerialCSY, "ECUART");
+_LIT8(KDefaultSerialPort, "0");
+
+//default USB settings
+_LIT8(KDefaultUsbPDD, "NONE");
+_LIT8(KDefaultUsbLDD, "EUSBC");
+_LIT8(KDefaultUsbCSY, "ECACM");
+_LIT8(KDefaultUsbPort, "1");
+
+//default IR settings
+_LIT8(KDefaultIrPDD, "EUART");
+_LIT8(KDefaultIrLDD, "ECOMM");
+_LIT8(KDefaultIrCSY, "IRCOMM");
+_LIT8(KDefaultIrPort, "0");
+
+//default BT settings
+_LIT8(KDefaultBtPort, "1");
+
+//default DCC settings
+_LIT8(KTrkDCCLDD, "trkdccdriver");
+#define KDefaultDCCPort 42
+
+//default Xti settings
+_LIT8(KTrkXTILDD, "trkxtidriver");
+
+
+#ifdef __UIQ_BUILD__
+_LIT(KInitFilePath, "C:\\Media Files\\document\\");
+#else
+_LIT(KInitFilePath, "C:\\");
+#endif
+_LIT(KInitFileName, "trk.ini");
+
+_LIT(KStatusConnecting,"Status: Connecting ...");
+_LIT(KStatusConnected, "Status: Connected");
+_LIT(KStatusDisconnected, "Status: Not connected");
+_LIT(KStatusError, "Status: Not connected");
+
+_LIT(KCmdLineConnTypeUsb, "-usb");
+_LIT(KCmdLineConnTypeXti, "-xti");
+
+
+//This represents the underlying comms transport that is used for
+//accessing the actual connection.
+enum TTrkCommType
+{
+	ESerialComm = 0,
+	EDbgTrcComm,
+	EBtSocket,
+	ETcpSocket,
+	EUsb,
+	EDcc,
+	EXti,
+	ETrkCommInvalid
+};
+
+//This represents the actual connection type that is shown to the user through the GUI
+enum TTrkConnType
+{
+	ETrkUsbDbgTrc = 0,
+	ETrkBt,
+	ETrkXti,
+	ETrkDcc,
+	ETrkSerial,
+	ETrkUsb,
+	ETrkIr,
+	ETrkConnInvalid
+};
+
+enum TTrkConnStatus
+{
+    ETrkNotConnected = 1,
+    ETrkConnecting,
+    ETrkConnected,
+    ETrkConnectionError
+};
+//
+// Forward declarations
+//
+
+class TTrkConnData
+{
+public:
+	TTrkCommType iCommType;
+	TTrkConnType iConnType;
+	
+	TBuf<KMaxFileName> iPDD;
+	TBuf<KMaxFileName> iLDD;
+	TBuf<KMaxFileName> iCSY;
+	TUint  iPortNumber;
+	TUint  iRate;
+	TBool iDefault;
+	TUint iPlugPlay;
+};
+
+#endif //__TRKCONNDATA_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkConnectionListener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKCONNECTIONLISTENER_H__
+#define __TRKCONNECTIONLISTENER_H__
+
+/**
+*  Abstract callback interface for port listeners to call into the engine for certain situations.
+*/
+class MTrkConnectionListener
+{
+    public:
+        /*
+         * This is called when the BT socket has find the appropriate port/ 
+         * 
+        */
+        virtual void AsyncConnectionSuccessfulL() = 0;
+        
+        /*
+         * This is called to update the UI when the PC relinquishes the connection
+         * 
+        */
+        virtual void AsyncConnectionFailed() = 0;
+      
+};
+
+#endif //__TRKCONNECTIONLISTENER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkDbgTrcCommPort.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,239 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <e32cons.h>
+#include <f32file.h>
+
+#include "TrkConnData.h"
+#include "TrkDbgTrcCommPort.h"
+#include "TrkFramingLayer.h"
+
+_LIT(KSendErrMsg, "Failed to write to the DbgTrc channel");
+
+//
+// Default comm values
+//
+
+
+//
+// Static helper functions
+//
+
+//
+//
+// CTrkDbgTrcCommPort implementation
+//
+//
+
+//
+// CTrkDbgTrcCommPort constructor
+//
+CTrkDbgTrcCommPort::CTrkDbgTrcCommPort()
+	: CTrkCommPort(CActive::EPriorityStandard),
+	  iConnected(EFalse),
+	  iListening(EFalse),
+	  iLineNumber(0)
+{
+}
+
+//
+// CTrkDbgTrcCommPort::ConstructL
+//
+void CTrkDbgTrcCommPort::ConstructL(TTrkConnData aTrkConnData, TDes& aErrorMessage)
+{
+	iUnitNumber = aTrkConnData.iPortNumber;
+}
+
+//
+// CTrkDbgTrcCommPort destructor
+//
+CTrkDbgTrcCommPort::~CTrkDbgTrcCommPort()
+{
+	
+}
+
+//
+// CTrkDbgTrcCommPort::NewL
+//
+CTrkDbgTrcCommPort* CTrkDbgTrcCommPort::NewL(TTrkConnData aTrkConnData, TDes& aErrorMessage)
+{
+	CTrkDbgTrcCommPort* self = new(ELeave) CTrkDbgTrcCommPort;
+	CleanupStack::PushL(self);
+	self->ConstructL(aTrkConnData, aErrorMessage);
+	CleanupStack::Pop(self);
+	return self;
+}
+
+//
+// CTrkDbgTrcCommPort::OpenPortL
+//
+// Open the serial type communications port
+//
+void CTrkDbgTrcCommPort::OpenPortL()
+{
+	TInt error = KErrNone;
+
+	error = iDbgTrcPort.Connect();
+	if ((KErrAlreadyExists != error) && (KErrNone != error))
+		ReportAndLeaveIfErrorL(error, _L("Failed to connect to the debug trace comms server."));
+
+	TAcmConfig config;	
+	error = iDbgTrcPort.GetAcmConfig(config);
+
+	if (KErrNone != error)
+		ReportAndLeaveIfErrorL(error, _L("Failed to get the port configuration."));
+		
+	TAcmConfigV01 config1(*(TAcmConfigV01*)config.Ptr());
+	config1.iPortNumber = iUnitNumber;
+	
+	error = iDbgTrcPort.SetAcmConfig(config);
+	if (KErrNone != error && KErrInUse != error)
+		ReportAndLeaveIfErrorL(error, _L("Failed to set the port configuration."));
+
+	error = iDbgTrcPort.Open();
+	
+	if (KErrNone != error)
+		ReportAndLeaveIfErrorL(error, _L("Failed to open debug trace port."));
+	
+	iConnected = ETrue;
+	
+	// register the protocol id here
+	error = iDbgTrcPort.RegisterProtocolID(EOstProtTrk, EFalse);
+	if (KErrNone != error)
+		ReportAndLeaveIfErrorL(error, _L("Failed to register the protocol id."));
+
+		
+	iConnectionMessage.Format(_L("Connection: USB \r\nPort: %d\r\n"), iUnitNumber);
+}
+
+//
+// CTrkDbgTrcCommPort::ClosePort
+//
+// Close the communications port
+//
+void CTrkDbgTrcCommPort::ClosePort()
+{
+	Cancel();	
+	
+	if (iConnected)
+	{
+		iDbgTrcPort.UnRegisterProtocolID(EOstProtTrk);		
+		//iDbgTrcPort.Disconnect();
+		iDbgTrcPort.Close();
+		iConnected = EFalse;			
+	}	
+}
+
+//
+// CTrkDbgTrcCommPort::SendDataL
+//
+// Write data to the serial type port
+//
+void CTrkDbgTrcCommPort::SendDataL(const TDesC8& aBuffer)
+{
+	TRequestStatus status;
+	iDbgTrcPort.WriteMessage(status, aBuffer, EFalse);
+	User::WaitForRequest(status);
+	
+	TInt err = status.Int();	
+	ReportAndLeaveIfErrorL(err, KSendErrMsg);
+}
+
+//
+// CTrkDbgTrcCommPort::Listen
+//
+// Start listening for data coming into the serial type communications port
+//
+void CTrkDbgTrcCommPort::Listen(CTrkFramingLayer *aFramingLayer)
+{	
+	iFramingLayer = aFramingLayer;
+	CActiveScheduler::Add(this);
+	IssueReadRequest();
+	iListening = ETrue;
+}
+
+//
+// CTrkDbgTrcCommPort::StopListening
+//
+// Stop listening for data coming into the serial type communications port
+//
+void CTrkDbgTrcCommPort::StopListening()
+{
+	if (iListening)
+	{
+		Cancel();
+		Deque();
+	}
+	
+	iListening = EFalse;
+}
+
+//
+// CTrkDbgTrcCommPort::ReportAndLeaveIfErrorL
+//
+// If an error occurred, print the error information to the screen and bail out
+//
+void CTrkDbgTrcCommPort::ReportAndLeaveIfErrorL(TInt aError, const TDesC& aDesc)
+{
+	if (KErrNone != aError)
+	{
+		iErrorMessage.Format(_L("%S\r\nError Code: %d\r\n"), &aDesc, aError);
+		User::Leave(aError);
+	}
+}
+
+
+//
+// CTrkDbgTrcCommPort::IssueReadRequest
+//
+// Wait for data to come into the communications port
+//
+void CTrkDbgTrcCommPort::IssueReadRequest()
+{
+	iNextReadChar = 0;
+	iDbgTrcPort.ReadMessage(iStatus, iReceivedChars);
+	SetActive();
+}
+
+//
+// CTrkDbgTrcCommPort::DoCancel
+//
+// Cancel the request for data from the communications port
+//
+void CTrkDbgTrcCommPort::DoCancel()
+{
+	iDbgTrcPort.ReadCancel();
+}
+
+//
+// CTrkDbgTrcCommPort::RunL
+//
+// Called when data comes into the communications port
+//
+void CTrkDbgTrcCommPort::RunL()
+{
+	// pass the data onto the framing layer
+	if (iStatus.Int() == KErrNone)
+	{
+		while (iNextReadChar < iReceivedChars.Length())
+			iFramingLayer->HandleByte(iReceivedChars[iNextReadChar++]);
+	}
+	// continue waiting for data
+	IssueReadRequest();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkDbgTrcCommPort.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKDBGTRCCOMMPORT_H__
+#define __TRKDBGTRCCOMMPORT_H__
+
+#include "TrkCommPort.h"
+#include "dbgtrccomm.h"
+
+//
+// class CTrkDbgTrcCommPort
+//
+// Defines an interface to a serial type communications port
+//
+class CTrkDbgTrcCommPort : public CTrkCommPort
+{
+public:
+
+	static CTrkDbgTrcCommPort* NewL(TTrkConnData aTrkConnData, TDes& aErrorMessage);
+	~CTrkDbgTrcCommPort();
+
+	void OpenPortL();
+	void ClosePort();
+
+	void SendDataL(const TDesC8& aData);
+	void Listen(CTrkFramingLayer *aFramingLayer);
+	void StopListening();
+
+protected:
+
+	void DoCancel();
+	void RunL();
+
+private:
+
+	CTrkDbgTrcCommPort();
+	void ConstructL(TTrkConnData aTrkConnData, TDes& aErrorMessage);
+	void IssueReadRequest();
+	void ReportAndLeaveIfErrorL(TInt aError, const TDesC& aDesc);
+	
+private:
+	TUint  iUnitNumber;
+
+	TBool iConnected;
+	TBool iListening;
+
+	TBuf8<MAXMESSAGESIZE> iReceivedChars;
+	TInt iNextReadChar;
+
+	CTrkFramingLayer* iFramingLayer;
+		
+	TInt iLineNumber;
+	
+	RDbgTrcComm iDbgTrcPort;
+};
+
+#endif // __TRKDBGTRCCOMMPORT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkDccCommPort.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,252 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <e32cons.h>
+#include <f32file.h>
+
+#include "TrkConnData.h"
+#include "TrkDccCommPort.h"
+#include "TrkFramingLayer.h"
+
+_LIT(KSendErrMsg, "Failed to write to the DCC channel");
+
+//
+// Default comm values
+//
+
+
+//
+// Static helper functions
+//
+
+//
+//
+// CTrkDccCommPort implementation
+//
+//
+
+//
+// CTrkDccCommPort constructor
+//
+CTrkDccCommPort::CTrkDccCommPort()
+	: CTrkCommPort(CActive::EPriorityStandard),
+	  iConnected(EFalse),
+	  iListening(EFalse),
+	  iLineNumber(0),
+	  iLddLoaded(EFalse)
+{
+}
+
+//
+// CTrkDccCommPort::ConstructL
+//
+void CTrkDccCommPort::ConstructL(TTrkConnData& aTrkConnData, TDes& aErrorMessage)
+{
+
+	iLDD = aTrkConnData.iLDD;
+	iUnitNumber = aTrkConnData.iPortNumber;
+
+	if (!iLDD.Size())
+	{
+		aErrorMessage.Format(_L("LDD not specified in init file\r\n"));		
+		User::Leave(KErrCorrupt);
+	}
+
+	
+}
+
+//
+// CTrkDccCommPort destructor
+//
+CTrkDccCommPort::~CTrkDccCommPort()
+{
+	if (iLddLoaded)	
+	{
+		//cancel the read request
+		iDccDriver.ReadCancel();
+		iDccDriver.Close();
+		
+		TInt err = User::FreeLogicalDevice(iLDD);
+		if (KErrNone != err)
+			User::Panic(_L("FreeLogicalDevice failed"), err);
+			
+		iLddLoaded = EFalse;
+	}
+
+}
+
+//
+// CTrkDccCommPort::NewL
+//
+CTrkDccCommPort* CTrkDccCommPort::NewL(TTrkConnData& aTrkConnData, TDes& aErrorMessage)
+{
+	CTrkDccCommPort* self = new(ELeave) CTrkDccCommPort;
+	CleanupStack::PushL(self);
+	self->ConstructL(aTrkConnData, aErrorMessage);
+	CleanupStack::Pop(self);
+	return self;
+}
+
+//
+// CTrkDccCommPort::OpenPortL
+//
+// Open the serial type communications port
+//
+void CTrkDccCommPort::OpenPortL()
+{
+	TInt error = KErrNone;
+
+	// make sure the LDD is not already loaded
+	User::FreeLogicalDevice(iLDD);
+
+	error = User::LoadLogicalDevice(iLDD);
+	if ((KErrAlreadyExists != error) && (KErrNone != error))
+		ReportAndLeaveIfErrorL(error, _L("Failed to load dcc logical device."));
+
+	error = iDccDriver.Open();
+	if (KErrNone != error)
+		ReportAndLeaveIfErrorL(error, _L("Failed to open dcc logical device."));
+	
+	iLddLoaded = ETrue;
+	
+	
+	_LIT(KDCCMSG, "LDD: TrkDccDriver\r\nPort number: 42\r\n");
+	
+	iConnectionMessage = KDCCMSG;
+}
+
+//
+// CTrkDccCommPort::ClosePort
+//
+// Close the communications port
+//
+void CTrkDccCommPort::ClosePort()
+{
+	Cancel();
+	
+	if (iLddLoaded)
+	{
+		//cancel the read request
+		iDccDriver.ReadCancel();		
+		iDccDriver.Close();
+		
+		TInt err = User::FreeLogicalDevice(iLDD);
+		if (KErrNone != err)
+			User::Panic(_L("FreeLogicalDevice failed"), err);
+
+		iLddLoaded = EFalse;			
+	}
+
+}
+
+//
+// CTrkDccCommPort::SendDataL
+//
+// Write data to the serial type port
+//
+void CTrkDccCommPort::SendDataL(const TDesC8& aBuffer)
+{
+	TInt err = iDccDriver.Write(aBuffer);
+	
+	ReportAndLeaveIfErrorL(err, KSendErrMsg);
+}
+
+//
+// CTrkDccCommPort::Listen
+//
+// Start listening for data coming into the serial type communications port
+//
+void CTrkDccCommPort::Listen(CTrkFramingLayer *aFramingLayer)
+{
+	iFramingLayer = aFramingLayer;
+	CActiveScheduler::Add(this);
+	IssueReadRequest();
+	iListening = ETrue;
+}
+
+//
+// CTrkDccCommPort::StopListening
+//
+// Stop listening for data coming into the serial type communications port
+//
+void CTrkDccCommPort::StopListening()
+{
+	if (iListening)
+	{
+		Cancel();
+		Deque();
+	}
+	
+	iListening = EFalse;
+}
+
+//
+// CTrkDccCommPort::ReportAndLeaveIfErrorL
+//
+// If an error occurred, print the error information to the screen and bail out
+//
+void CTrkDccCommPort::ReportAndLeaveIfErrorL(TInt aError, const TDesC& aDesc)
+{
+	if (KErrNone != aError)
+	{
+		iErrorMessage.Format(_L("%S\r\nError Code: %d\r\n"), &aDesc, aError);
+		User::Leave(aError);
+	}
+}
+
+
+//
+// CTrkDccCommPort::IssueReadRequest
+//
+// Wait for data to come into the communications port
+//
+void CTrkDccCommPort::IssueReadRequest()
+{
+	iNextReadChar = 0;
+	iDccDriver.ReadOneOrMore(iStatus, iReceivedChars);
+	SetActive();
+}
+
+//
+// CTrkDccCommPort::DoCancel
+//
+// Cancel the request for data from the communications port
+//
+void CTrkDccCommPort::DoCancel()
+{
+	iDccDriver.ReadCancel();
+}
+
+//
+// CTrkDccCommPort::RunL
+//
+// Called when data comes into the communications port
+//
+void CTrkDccCommPort::RunL()
+{
+	// pass the data onto the framing layer
+	if (iStatus.Int() == KErrNone)
+	{
+		while (iNextReadChar < iReceivedChars.Length())
+			iFramingLayer->HandleByte(iReceivedChars[iNextReadChar++]);
+		//iDccDriver.Write(iReceivedChars);
+	}
+	// continue waiting for data
+	IssueReadRequest();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkDccCommPort.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKDCCCOMMPORT_H__
+#define __TRKDCCCOMMPORT_H__
+
+#include "TrkCommPort.h"
+#include "TrkDccComm.h"
+
+//
+// class CTrkDccCommPort
+//
+// Defines an interface to a serial type communications port
+//
+class CTrkDccCommPort : public CTrkCommPort
+{
+public:
+
+	static CTrkDccCommPort* NewL(TTrkConnData& aTrkConnData, TDes& aErrorMessage);
+	~CTrkDccCommPort();
+
+	void OpenPortL();
+	void ClosePort();
+
+	void SendDataL(const TDesC8& aData);
+	void Listen(CTrkFramingLayer *aFramingLayer);
+	void StopListening();
+
+protected:
+
+	void DoCancel();
+	void RunL();
+
+private:
+
+	CTrkDccCommPort();
+	void ConstructL(TTrkConnData& aTrkConnData, TDes& aErrorMessage);
+	void IssueReadRequest();
+	void ReportAndLeaveIfErrorL(TInt aError, const TDesC& aDesc);
+	
+private:
+
+	TBool iConnected;
+	TBool iListening;
+
+	TBuf8<MAXMESSAGESIZE> iReceivedChars;
+	TInt iNextReadChar;
+
+	CTrkFramingLayer* iFramingLayer;
+	
+	RTrkDccDriver iDccDriver;
+	
+	TBuf<32> iLDD;
+	TUint iUnitNumber;
+	
+	TInt iLineNumber;
+	
+	TBool iLddLoaded;
+};
+
+#endif // __TRKDCCCOMMPORT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkDispatchLayer.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,3577 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "TrkEngine.h"
+#include "TrkDispatchLayer.h"
+#include "DateTimeConverter.h"
+
+#ifndef __TEXT_SHELL__
+#include "TrkSwInstall.h"
+#endif
+
+//
+// Macros
+//
+
+//
+// Version Information
+//
+
+#define MAJOR_VERSION_NUMBER	3
+#define MINOR_VERSION_NUMBER	2
+#define BUILD_NUMBER			4
+
+
+//
+// Support Information
+//
+
+#define DS_SUPPORT_MASK_00_07	0x7E	// kDSConnect, kDSDisconnect, kDSReset, kDSVersions, kDSSupportMask, kDSCPUType */
+#define DS_SUPPORT_MASK_08_0F	0x00
+#define DS_SUPPORT_MASK_10_17	0x4f	// R/W Memory, R/W Registers, FlushCache
+#define DS_SUPPORT_MASK_18_1F	0x5f	// kDSContinue, kDSStep, kDSStop, kDSSetBreak, kDSClearBreak
+#define DS_SUPPORT_MASK_20_27	0x01	// kDSNotifyFileInput
+#define DS_SUPPORT_MASK_28_2F	0x00
+#define DS_SUPPORT_MASK_30_37	0x00
+#define DS_SUPPORT_MASK_38_3F	0x00
+#define DS_SUPPORT_MASK_40_47	0x0f	// OS Create/Delete Item, OS Read/Write Info
+#define DS_SUPPORT_MASK_48_4F	0x1f	// OS Read/Write/Open/Close/Position File
+#define DS_SUPPORT_MASK_50_57	0x00
+#define DS_SUPPORT_MASK_58_5F	0x00
+#define DS_SUPPORT_MASK_60_67	0x00
+#define DS_SUPPORT_MASK_68_6F	0x00
+#define DS_SUPPORT_MASK_70_77	0x00
+#define DS_SUPPORT_MASK_78_7F	0x00
+#define DS_SUPPORT_MASK_80_87	0x01	// kDSReplyACK
+#define DS_SUPPORT_MASK_88_8F	0x00
+#define DS_SUPPORT_MASK_90_97	0x11	// kDSNotifyStopped, kDSNotifyStopped2
+#define DS_SUPPORT_MASK_98_9F	0x00
+#define DS_SUPPORT_MASK_A0_A7	0x03	// kDSOSNotifyCreated, kDSOSNotifyDeleted
+#define DS_SUPPORT_MASK_A8_AF	0x00
+#define DS_SUPPORT_MASK_B0_B7	0x00
+#define DS_SUPPORT_MASK_B8_BF	0x00
+#define DS_SUPPORT_MASK_C0_C7	0x00
+#define DS_SUPPORT_MASK_C8_CF	0x00
+#define DS_SUPPORT_MASK_D0_D7	0x03	// kDSWriteFile, kDSReadFile
+#define DS_SUPPORT_MASK_D8_DF	0x00
+#define DS_SUPPORT_MASK_E0_E7	0x00
+#define DS_SUPPORT_MASK_E8_EF	0x00
+#define DS_SUPPORT_MASK_F0_F7	0x00
+#define DS_SUPPORT_MASK_F8_FF	0x80	// kDSReplyNAK
+
+#define KProcessKilled 0x4B696C6C // "Kill"
+
+#ifdef EKA2
+#define EUSER_LIBPATH _L("Z:\\Sys\\Bin\\euser.dll")
+#else
+#define EUSER_LIBPATH _L("Z:\\System\\Libs\\euser.dll")
+#endif
+
+#ifdef __OEM_TRK__
+#define TRK_TYPE_DESCRIPTION _L8("System TRK")
+#else
+#define TRK_TYPE_DESCRIPTION _L8("Application TRK")
+#endif
+
+
+//
+// Swap2
+//
+// Byte-swaps a 2-byte value.  Used to convert to/from little/big endian.
+//
+static TUint16 Swap2(TUint16 aSource)
+{
+	TUint16 dest = 0;
+	for (TInt i=0; i<2; i++)
+	{
+		dest <<= 8;
+		dest |= aSource & 0xFF;
+		aSource >>= 8;
+	}
+	
+	return dest;
+} 
+
+//
+// Swap4
+//
+// Byte-swaps a 4-byte value.  Used to convert to/from little/big endian.
+//
+static TUint32 Swap4(TUint32 aSource)
+{
+	TUint32 dest = 0;
+	for (TInt i=0; i<4; i++)
+	{
+		dest <<= 8;
+		dest |= aSource & 0xFF;
+		aSource >>= 8;
+	}
+	
+	return dest;
+} 
+
+//
+// Swap4xN
+//
+//	Byte-swaps N 4-byte values *in place*.  Used to convert to/from little/big endian.
+//
+void Swap4xN(TUint32 *aSource, TInt aCount)
+{
+	while (aCount--)
+	{
+		TUint32 temp = Swap4(*aSource);
+		*aSource++ = temp;
+	}
+} 
+
+
+//
+//
+// CExitTrapper implementation
+//
+//
+
+//
+// CExitTrapper constructor
+//
+// Accepts CTrkDispatchLayer interface and the process ID of the
+// process to watch
+//
+CExitTrapper::CExitTrapper(CTrkDispatchLayer *aDispatch, TUint32 aProcessId)
+	: CActive(EPriorityStandard),
+	  iProcessId(aProcessId),
+	  iDispatch(aDispatch)
+{
+	CActiveScheduler::Add(this);
+
+	TInt error = iProcess.Open(iProcessId);
+	if (KErrNone != error)
+		User::Panic(_L("Unable to open process"), __LINE__);
+}
+
+//
+// CExitTrapper destructor
+//
+CExitTrapper::~CExitTrapper()
+{
+	Cancel();
+	Deque();
+	iProcess.Close();
+}
+
+//
+// CExitTrapper::Watch
+//
+// Watch for the process to exit
+//
+void CExitTrapper::Watch()
+{
+	iProcess.Logon(iStatus);
+	SetActive();
+}
+
+//
+// CExitTrapper::RunL
+//
+// Called when the process exits
+//
+void CExitTrapper::RunL()
+{
+	// sometimes this is run when the process has yet to exit
+	if (iProcess.ExitType() == EExitPending)
+	{
+		iProcess.LogonCancel(iStatus);
+		Watch();
+	}
+	else
+	{
+		iDispatch->DoNotifyProcessDiedL(iProcessId, iProcess.ExitReason());
+	}
+}
+
+//
+// CExitTrapper::DoCancel
+//
+// Stop waiting for this process to exit
+//
+void CExitTrapper::DoCancel()
+{
+	iProcess.LogonCancel(iStatus);
+}
+
+
+//
+//
+// CEventTrapper implementation
+//
+//
+
+//
+// CEventTrapper constructor
+//
+// Accepts CTrkDispatchLayer interface
+//
+CEventTrapper::CEventTrapper(CTrkDispatchLayer *aDispatch)
+	: CActive(CActive::EPriorityStandard),
+	  iDispatch(aDispatch)
+{
+	CActiveScheduler::Add(this);
+}
+
+//
+// CEventTrapper destructor
+//
+CEventTrapper::~CEventTrapper()
+{
+	Cancel();
+	Deque();
+}
+
+//
+// CEventTrapper::Watch
+//
+// Start listening for events
+//
+void CEventTrapper::Watch()
+{
+	iDispatch->iKernelDriver.GetEvent(iStatus, iEventInfo);
+	SetActive();
+}
+
+//
+// CEventTrapper::RunL
+//
+// Called when an event occurs
+//
+void CEventTrapper::RunL()
+{
+	// determine the type of event and handle accordingly
+	switch (iEventInfo.iEventType)
+	{
+		case SEventInfo::EThreadBreakPoint:
+		{
+			iDispatch->DoNotifyStoppedL(iEventInfo.iProcessId, iEventInfo.iThreadId, iEventInfo.iCurrentPC, KNullDesC8);
+			break;
+		}
+		case SEventInfo::EThreadException:
+		{
+			TBuf8<100> buf;
+			
+			switch(iEventInfo.iExceptionNumber)
+			{
+				case EExcIntegerDivideByZero:
+				{
+					buf.Format(_L8("An integer divide by zero exception has occurred."));
+					break;
+				}
+				case EExcIntegerOverflow:
+				{
+					buf.Format(_L8("An integer overflow exception has occurred."));
+					break;
+				}
+				case EExcBoundsCheck:
+				{
+					buf.Format(_L8("An bounds check exception has occurred."));
+					break;
+				}
+				case EExcInvalidOpCode:
+				{
+					buf.Format(_L8("An invalid instruction exception has occurred."));
+					break;
+				}
+				case EExcDoubleFault:
+				{
+					buf.Format(_L8("A double fault exception has occurred."));
+					break;
+				}
+				case EExcStackFault:
+				{
+					buf.Format(_L8("A stack fault exception has occurred."));
+					break;
+				}
+				case EExcAccessViolation:
+				{
+					buf.Format(_L8("An access violation exception has occurred."));
+					break;
+				}
+				case EExcPrivInstruction:
+				{
+					buf.Format(_L8("A priveledged instruction exception has occurred."));
+					break;
+				}
+				case EExcAlignment:
+				{
+					buf.Format(_L8("An alignment exception has occurred."));
+					break;
+				}
+				case EExcPageFault:
+				{
+					buf.Format(_L8("A page fault exception has occurred."));
+					break;
+				}
+				case EExcFloatDenormal:
+				case EExcFloatDivideByZero:
+				case EExcFloatInexactResult:
+				case EExcFloatInvalidOperation:
+				case EExcFloatOverflow:
+				case EExcFloatStackCheck:
+				case EExcFloatUnderflow:
+				{
+					buf.Format(_L8("A floating point exception has occurred."));
+					break;
+				}
+				case EExcAbort:
+				{
+					buf.Format(_L8("An abort exception has occurred."));
+					break;
+				}
+				case EExcUserInterrupt:
+				{
+					buf.Format(_L8("A user interrupt exception has occurred."));
+					break;
+				}
+				case EExcDataAbort:
+				{
+					buf.Format(_L8("A data abort exception has occurred."));
+					break;
+				}
+				case EExcCodeAbort:
+				{
+					buf.Format(_L8("A code abort exception has occurred."));
+					break;
+				}				
+				case EExcGeneral:
+				case EExcSingleStep:
+				case EExcBreakPoint:
+				case EExcKill:
+				case EExcMaxNumber:
+				case EExcInvalidVector:
+				default:
+				{
+					buf.Format(_L8("An unknown exception (%d) has occurred."), iEventInfo.iExceptionNumber);
+					break;				
+				}
+			}
+			
+			iDispatch->DoNotifyStoppedL(iEventInfo.iProcessId, iEventInfo.iThreadId, iEventInfo.iCurrentPC, buf);
+			break;
+		}
+		case SEventInfo::EThreadPanic:
+		{
+			TBuf8<100> buf;
+//			buf.Format(_L8("Thread 0x%x has panicked.\nCategory: %S\nReason: %d"), iEventInfo.iThreadId, &iEventInfo.iPanicCategory, iEventInfo.iExceptionNumber);
+			buf.Format(_L8("Thread 0x%x has panicked. Category: %S; Reason: %d"), iEventInfo.iThreadId, &iEventInfo.iPanicCategory, iEventInfo.iPanicReason);
+			
+			iDispatch->DoNotifyStoppedL(iEventInfo.iProcessId, iEventInfo.iThreadId, iEventInfo.iCurrentPC, buf, true, iEventInfo.iExceptionNumber);
+			break;
+		}
+		case SEventInfo::EProcessPanic:
+		{
+			TBuf8<100> buf;
+			buf.Format(_L8("Process 0x%x has panicked.\nCategory: %S\nReason: %d"), iEventInfo.iProcessId, &iEventInfo.iPanicCategory, iEventInfo.iExceptionNumber);
+			
+			iDispatch->DoNotifyStoppedL(iEventInfo.iProcessId, iEventInfo.iThreadId, iEventInfo.iCurrentPC, buf);
+			break;
+		}
+		case SEventInfo::ELibraryLoaded:
+		{
+			// a library has been loaded.  we get statically linked library loaded notifications
+			// the very first time the process is created.  we want to ignore these because we
+			// handle static libs in another way.  if the process the library was loaded for is
+			// not being debugging, just resume the thread and ignore the event.  if the process
+			// is being debugged but it hasn't yet been created, then this must be a static lib
+			// and we ignore it.  note that we do not bother resuming the thread since it has not
+			// been started yet!
+
+			TBool created = EFalse;
+			TBool found = EFalse;
+					
+			for (TInt i=0; i<iDispatch->iDebugProcessList.Count(); i++)
+			{
+				if (iDispatch->iDebugProcessList[i]->ProcessId() == iEventInfo.iProcessId)
+				{
+					created = iDispatch->iDebugProcessList[i]->iReadyForLibraryLoadNotification;
+					found = ETrue;
+					break;
+				}
+			}
+
+		#ifndef EKA2
+			if (!iEventInfo.iCodeAddress)
+			{
+				TBuf<KMaxPath> libName;
+				libName.Copy(iEventInfo.iFileName);
+				
+				RLibrary lib;
+				TInt err = lib.LoadRomLibrary(libName, KNullDesC);
+				if (KErrNone == err)
+				{
+					iEventInfo.iCodeAddress = (TUint32)lib.EntryPoint();
+					lib.Close();
+				}
+			}
+		#endif
+
+			if (!created || !iEventInfo.iCodeAddress || !found)
+			{
+				iDispatch->iKernelDriver.ResumeThread(iEventInfo.iThreadId);
+			}
+			else
+			{
+				iDispatch->DoNotifyLibraryLoadedL(iEventInfo.iFileName, iEventInfo.iProcessId, iEventInfo.iThreadId, iEventInfo.iCodeAddress, iEventInfo.iDataAddress);
+			}
+			break;
+		}
+		case SEventInfo::ELibraryUnloaded:
+		{
+			TBool found = EFalse;
+			
+			for (TInt i=0; i<iDispatch->iDebugProcessList.Count(); i++)
+			{
+				if (iDispatch->iDebugProcessList[i]->ProcessId() == iEventInfo.iProcessId)
+				{
+					found = ETrue;
+					break;
+				}
+			}
+			
+			if (!found)
+			{
+				iDispatch->iKernelDriver.ResumeThread(iEventInfo.iThreadId);
+			}
+			else
+			{
+				iDispatch->DoNotifyLibraryUnloadedL(iEventInfo.iFileName, iEventInfo.iProcessId, iEventInfo.iThreadId);
+			}
+			
+			break;
+		}
+		case SEventInfo::EUserTrace:
+		{
+			iDispatch->DoNotifyUserTraceL(iEventInfo.iTraceData);
+			break;
+		}
+		case SEventInfo::EProcessAdded:
+		{
+			iDispatch->DoNotifyProcessAddedL(iEventInfo.iFileName, iEventInfo.iProcessId, 
+											 iEventInfo.iThreadId, iEventInfo.iUid, 
+											 iEventInfo.iCodeAddress, iEventInfo.iDataAddress);
+			break;
+		}
+		case SEventInfo::EUnknown:
+		default:
+			User::Panic(_L("Unknown event type"), __LINE__);
+			break;
+	}
+
+	// reset the values
+	iEventInfo.Reset();
+
+	// keep listening for more events
+	Watch();
+}
+
+//
+// CEventTrapper::DoCancel
+//
+// Stop listening for events
+//
+void CEventTrapper::DoCancel()
+{
+	iDispatch->iKernelDriver.CancelGetEvent();
+}
+
+
+//
+//
+// CDebugProcess implementation
+//
+//
+
+//
+// CDebugProcess::NewL
+//
+// Accepts CTrkDispatchLayer interface and the process ID and main
+// thread ID of a process being debugged
+//
+CDebugProcess* CDebugProcess::NewL(CTrkDispatchLayer *aDispatch, TUint32 aProcessId, TUint32 aMainThreadId)
+{
+	CDebugProcess* self = new(ELeave) CDebugProcess();
+	self->ConstructL(aDispatch, aProcessId, aMainThreadId);
+	return self;
+}
+
+//
+// CDebugProcess::ConstructL
+//
+// Accepts CTrkDispatchLayer interface and the process ID and main
+// thread ID of a process being debugged
+//
+void CDebugProcess::ConstructL(CTrkDispatchLayer *aDispatch, TUint32 aProcessId, TUint32 aMainThreadId)
+{
+	iProcessId = aProcessId;
+	iMainThreadId = aMainThreadId;
+	iReadyForLibraryLoadNotification = EFalse;
+	
+	// start waiting for this process to exit
+	iExitTrapper = new(ELeave) CExitTrapper(aDispatch, aProcessId);
+	iExitTrapper->Watch();
+}
+
+//
+// CDebugProcess destructor
+//
+CDebugProcess::~CDebugProcess()
+{
+	SafeDelete(iExitTrapper);
+}
+
+#ifndef __TEXT_SHELL__
+
+//
+// CPhoneInfo implementation
+//
+CPhoneInfo::CPhoneInfo():
+           CActive(EPriorityStandard),
+           iPhoneIdV1Pckg(iPhoneIdV1),
+           iDispatchLayer(NULL)
+{
+    CActiveScheduler::Add(this);
+}
+
+CPhoneInfo* CPhoneInfo::NewL()
+{
+    CPhoneInfo* self = new(ELeave) CPhoneInfo();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+}
+
+void CPhoneInfo::ConstructL()
+{
+    iTelephony = CTelephony::NewL();
+}
+
+CPhoneInfo::~CPhoneInfo() 
+{ 
+    Cancel();
+    Deque();
+    SafeDelete(iTelephony);
+}
+
+void CPhoneInfo::GetPhoneName(CTrkDispatchLayer* aDispatchLayer)
+{
+    iDispatchLayer = aDispatchLayer;
+    iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
+    SetActive();
+}
+
+void CPhoneInfo::RunL()
+{   
+    if(iStatus == KErrNone)
+	{          
+        iDispatchLayer->UpdatePhoneNameInfo(iPhoneIdV1.iModel);              
+    }
+}
+
+void CPhoneInfo::DoCancel()
+{
+	iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
+}
+#endif
+
+//
+//
+// CTrkDispatchLayer implementation
+//
+//
+
+//
+// CTrkDispatchLayer constructor
+//
+CTrkDispatchLayer::CTrkDispatchLayer()
+	: iEngine(NULL),
+	  iFramingLayer(NULL),
+#ifndef __TEXT_SHELL__
+	  iPhoneInfo(NULL),
+#endif
+	  iFileState(EFileUnknown),
+	  iDebugProcessList(1),
+	  iProcessList(1),
+	  iThreadList(1),
+	  iSuspendedThreadList(1),
+	  iEventTrapper(NULL),
+	  iIsConnected(EFalse),
+	  iPhoneNameInfoAvailable(EFalse)
+	  
+#ifdef __OEM_TRK__	  
+	  ,iUseTcbServer(EFalse)
+#endif	  
+{
+}
+
+//
+// CTrkDispatchLayer::NewL
+//
+CTrkDispatchLayer* CTrkDispatchLayer::NewL(CTrkCommPort *aPort, CTrkEngine* aEngine)
+{
+	CTrkDispatchLayer* self = new(ELeave) CTrkDispatchLayer();
+	self->ConstructL(aPort, aEngine);
+	return self;
+}
+
+//
+// CTrkDispatchLayer destructor
+//
+CTrkDispatchLayer::~CTrkDispatchLayer()
+{
+	SafeDelete(iFramingLayer);
+
+	SafeDelete(iInputBuffer);
+	SafeDelete(iReplyBuffer);
+#ifndef __TEXT_SHELL__
+	SafeDelete(iPhoneInfo);
+#endif
+	// just in case a disconnect never happened
+	SafeDelete(iEventTrapper);
+	
+#ifndef __WINS__
+	iKernelDriver.Close();
+#endif
+
+    CloseTcbServer();
+	iProcessList.Close();
+	iThreadList.Close();
+	iSuspendedThreadList.Close();
+	
+	iDebugProcessList.ResetAndDestroy();	
+	iDebugProcessList.Close();
+	//Notify the server that Debugging is ended
+    if (iEngine)
+        iEngine->DebuggingEnded();  
+        
+}
+//
+// CTrkDispathcLayer::CloseTcbServer()
+//
+void CTrkDispatchLayer::CloseTcbServer()
+{
+#ifdef __OEM_TRK__  
+    //Shutdown the tcb server.
+    if (iUseTcbServer)
+    {
+        iTrkTcbSession.ShutDownServer();
+        iTrkTcbSession.Close();
+        iUseTcbServer = EFalse;
+    }
+#endif  
+
+}
+
+//
+// CTrkDispatchLayer::ConstructL
+//
+void CTrkDispatchLayer::ConstructL(CTrkCommPort *aPort, CTrkEngine* aEngine)
+{
+	iEngine = aEngine;
+	
+	// create the framing layer interface
+	iFramingLayer = new CTrkFramingLayer(aPort);
+
+	// At a minimum, we assume that the host debugger supports 3.3 version of the protocol
+	// From 3.0 to 3.3, TRK is backwards compatible. Starting with version 3.4, TRK sends 
+	// process created notifications as part of notify created event. Unless the host 
+	// debugger sets the supported protocol version to 3.4, we are not going to send this 
+	// new notification. Going forward, we should check for the protocol version before 
+	// we send new notifications. 
+	iHostVersion.iMajor = DS_PROTOCOL_MAJOR_VERSION_3;
+	iHostVersion.iMinor = DS_PROTOCOL_MINOR_VERSION_3;
+	
+	//To find the sw version runnning in the phone
+	FindPhoneSWVersion();
+		
+	// On techview, this functionality is not available for some reason.
+	// This needs to be investigated further, but this functionality is not critical for techview platform right now.
+#ifdef __S60__
+	// To find the name of the phone.
+	TRAPD(err1, FindPhoneNameL());
+	if (err1 != KErrNone)
+#endif	   
+	{
+	    iPhoneNameInfoAvailable = EFalse;
+	}
+}
+
+//
+// CTrkDispathLayer::FindPhoneSWVersion()
+//
+// Finds out the software version of the phone
+//
+void CTrkDispatchLayer::FindPhoneSWVersion()
+{
+#ifndef __TEXT_SHELL__
+    TBuf<KSysUtilVersionTextLength> version;
+    if (SysUtil::GetSWVersion( version ) == KErrNone ) 
+	{
+        iPhoneVersion.Copy(version);
+	}                
+#endif
+}
+
+//
+// CTrkDispathLayer::FindPhoneName()
+//
+// Finds the name of the phone 
+//
+void CTrkDispatchLayer::FindPhoneNameL()
+{
+#ifndef __TEXT_SHELL__
+    iPhoneInfo = CPhoneInfo::NewL();
+    iPhoneInfo->GetPhoneName(this);
+#endif             
+}
+
+//
+// CTrkDispatchLayer::Listen
+//
+// Start listening to the communications port for messages from the host debugger
+//
+void CTrkDispatchLayer::Listen()
+{
+	iFramingLayer->Listen(this);
+}
+
+//
+// CTrkDispatchLayer::StopListening
+//
+// Stop listening to the communications port for messages from the host debugger
+//
+void CTrkDispatchLayer::StopListening()
+{
+	// just in case the user quit MetroTrk while something was being debugged.
+	RProcess process;
+	for (TInt i=0; i<iDebugProcessList.Count(); i++)
+	{
+		if (KErrNone == process.Open(iDebugProcessList[i]->ProcessId()))
+		{
+		#ifdef EKA2
+			process.Kill(KErrNone);
+		#else	
+			process.Kill(KProcessKilled);
+		#endif
+			process.Close();
+		}
+	}
+
+	iFramingLayer->StopListening();
+}
+
+//
+// CTrkDispatchLayer::GetVersionInfo
+//
+// Get the current version of MetroTrk
+//
+void CTrkDispatchLayer::GetVersionInfo(TInt &aMajorVersion, TInt &aMinorVersion, TInt &aMajorAPIVersion, TInt &aMinorAPIVersion, TInt &aBuildNumber)
+{
+	aMajorVersion = MAJOR_VERSION_NUMBER;
+	aMinorVersion = MINOR_VERSION_NUMBER;
+	aMajorAPIVersion = DS_PROTOCOL_MAJOR_VERSION;
+	aMinorAPIVersion = DS_PROTOCOL_MINOR_VERSION;
+	aBuildNumber = BUILD_NUMBER;
+}
+
+//
+// CTrkDispatchLayer::HandleMsg
+//
+// Handle a command sent by the host debugger
+//
+void CTrkDispatchLayer::HandleMsg(const TDesC8& aMsg)
+{
+	TInt error = KErrNone;
+
+	// reset the input buffer and set it to the new unframed message
+	SafeDelete(iInputBuffer);
+	iInputBuffer = aMsg.Alloc();
+
+	if (!iInputBuffer)
+		User::Panic(_L("Failed to allocate input buffer"), __LINE__);
+	
+	TRAP(error, DispatchMsgL());
+
+	if (error < 0)
+	{
+		// its a symbian os error
+		error = kDSReplyOsError;
+	}
+	
+	// handle errors raised during command execution
+	switch(error)
+	{
+		// no error and ack was sent by handler
+ 		case kDSReplyNoError:
+ 			break;
+
+		// there was a problem with the packet received
+		case kDSReplyPacketSizeError:
+		case kDSReplyEscapeError:
+		case kDSReplyBadFCS:
+		case kDSReplyOverflow:
+		case kDSReplySequenceMissing:
+			iFramingLayer->RespondErr(kDSReplyNAK, error);
+			break;
+			
+		// command and format were OK, but failed for some other reason
+ 		default:
+			iFramingLayer->RespondErr(kDSReplyACK, error);
+	}
+}
+
+//
+// CTrkDispatchLayer::DispatchMsgL
+//
+// Handle the command sent by the host debugger
+//
+void CTrkDispatchLayer::DispatchMsgL()
+{
+	// make sure the input buffer is setup
+	User::LeaveIfNull(iInputBuffer);
+
+	// iInputBuffer holds the unframed message from the host
+	switch (iInputBuffer->Ptr()[0])
+	{
+		case kDSPing:
+		{
+			// nothing to do
+			iFramingLayer->RespondOkL(KNullDesC8);
+			break;
+		}
+		case kDSConnect:
+		{
+			DoConnectL();
+			break;
+		}
+		case kDSDisconnect:
+		{
+			DoDisconnectL();
+			break;
+		}
+		case kDSVersions:
+		{
+			DoVersionsL();
+			break;
+		}
+		case kDSVersions2:
+		{
+			DoVersions2L();
+			break;
+		}
+		case kDSVersions3:
+		{
+			DoVersions3L();
+			break;
+		}
+		case kDSHostVersions:
+		{
+			DoHostVersionsL();
+			break;
+		}
+		case kDSSupportMask:
+		{
+			DoSupportMaskL();
+			break;
+		}
+		case kDSCPUType:
+		{
+			DoCPUTypeL();
+			break;
+		}
+		case kDSReadMemory:
+		{
+			DoReadMemoryL();
+			break;
+		}
+		case kDSWriteMemory:
+		{
+			DoWriteMemoryL();
+			break;
+		}
+		case kDSReadRegisters:
+		{
+			DoReadRegistersL();
+			break;
+		}
+		case kDSWriteRegisters:
+		{
+			DoWriteRegistersL();
+			break;
+		}
+		case kDSContinue:
+		{
+			DoContinueL();
+			break;
+		}
+		case kDSStep:
+		{
+			DoStepL();
+			break;
+		}
+		case kDSStop:
+		{
+			DoStopL();
+			break;
+		}
+		case kDSSetBreak:
+		{
+			DoSetBreakL();
+			break;
+		}
+		case kDSClearBreak:
+		{
+			DoClearBreakL();
+			break;
+		}
+		case kDSModifyBreakThread:
+		{
+			DoModifyBreakThreadL();
+			break;
+		}
+		case kDSOSCreateItem:
+		{
+			DoCreateItemL();
+			break;
+		}
+		case kDSOSDeleteItem:
+		{
+			DoDeleteItemL();
+			break;
+		}
+		case kDSOSReadInfo:
+		{
+			DoReadInfoL();
+			break;
+		}
+		case kDSOSWriteInfo:
+		{
+			DoWriteInfoL();
+			break;
+		}
+		case kDSOSWriteFile:
+		{
+			DoWriteFileL();
+			break;
+		}
+		case kDSOSReadFile:
+		{
+			DoReadFileL();
+			break;
+		}
+		case kDSOSOpenFile:
+		{
+			DoOpenFileL();
+			break;
+		}	
+		case kDSOSCloseFile:
+		{
+			DoCloseFileL();
+			break;
+		}
+		case kDSOSPositionFile:
+		{
+			DoPositionFileL();
+			break;
+		}
+		case kDSOSInstallFile:
+		{
+			DoInstallFileL();
+			break;
+		}
+		case kDSOSInstallFile2:
+		{
+			DoInstallFile2L();
+			break;
+		}
+		case kDSOSPhoneSWVersion:
+	    {		    
+		    DoGetPhoneSWVersionL();
+			break;
+		}
+		case kDSOSPhoneName:		    
+		{
+		    DoGetPhoneNameL();
+		    break;
+		}
+		
+		case kDSReplyACK:
+		case kDSReplyNAK:
+			break;
+
+		case kDSReset:
+		case kDSFillMemory:
+		case kDSCopyMemory:
+		case kDSFlushCache:
+		case kDSDownload:
+		case kDSNotifyFileInput:			
+		default:
+		{
+			// unsupported command
+			iFramingLayer->RespondErr(kDSReplyACK, kDSReplyUnsupportedCommandError);
+			break;
+		}
+	}
+}
+
+//
+// CTrkDispatchLayer::DoConnectL
+//
+// The host debugger is starting a new debug session
+//
+void CTrkDispatchLayer::DoConnectL()
+{	
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSConnect != command)
+		User::Leave(kDSReplyError);
+
+	// if we're already connected for some reason, we need to cleanup so we're ready
+	// for a new debug session
+	if (iIsConnected)
+	{
+		// reset the sequence ids for the next debug session
+		iFramingLayer->ResetSequenceIDs();
+
+		//stop listening for events
+		SafeDelete(iEventTrapper);
+
+		// let the kernel side driver cleanup
+		iKernelDriver.Close();
+
+		iIsConnected = EFalse;
+	}
+
+	// reset the lists so that they are ready for use
+	iProcessList.Reset();
+	iThreadList.Reset();
+	iSuspendedThreadList.Reset();
+	iDebugProcessList.ResetAndDestroy();
+
+	TMetroTrkDriverInfo info;
+#ifndef EKA2
+	RLibrary euser;
+	User::LeaveIfError(euser.Load(EUSER_LIBPATH));
+	CleanupClosePushL(euser);
+	
+	info.iPanic1Address = (TUint32)euser.Lookup(812);			// RThread::Panic
+	info.iPanic2Address = (TUint32)euser.Lookup(813);			// RProcess::Panic
+	info.iException1Address = (TUint32)euser.Lookup(868);		// RThread::RaiseException
+	info.iException2Address = (TUint32)euser.Lookup(520);		// User::HandleException
+	info.iLibraryLoadedAddress = (TUint32)euser.Lookup(636);	// UserSvr::LibraryLoaded
+
+	// calculate the end address of the user library.  breakpoints and stepping will not
+	// be allowed from the start of ROM to the end of the user library since stopping a
+	// kernel thread could end up freezing the target
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+
+	RFile file;
+	User::LeaveIfError(file.Open(fs, EUSER_LIBPATH, EFileStream|EFileRead|EFileShareReadersOnly));
+	CleanupClosePushL(file);
+
+	TInt size;
+	User::LeaveIfError(file.Size(size));
+	
+	info.iUserLibraryEnd = (TUint32)euser.EntryPoint() + size;
+
+	CleanupStack::PopAndDestroy(); // file
+	CleanupStack::PopAndDestroy(); // fs
+	CleanupStack::PopAndDestroy(); // euser
+#endif	
+	
+	// start the kernel side driver
+	User::LeaveIfError(iKernelDriver.Open(info));
+	
+	// start listening for events
+	iEventTrapper = new(ELeave) CEventTrapper(this);
+	iEventTrapper->Watch();
+
+	iIsConnected = ETrue;	
+#ifdef __S60__	
+	// now close close crash logger
+	CloseCrashLogger();
+#endif	
+	
+	if (iEngine)
+		iEngine->DebuggingStarted();
+	
+	iFramingLayer->RespondOkL(KNullDesC8);
+}
+
+//
+// CTrkDispatchLayer::DoDisconnectL
+//
+// The host debugger is stopping the current debug session
+//
+void CTrkDispatchLayer::DoDisconnectL()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSDisconnect != command)
+		User::Leave(kDSReplyError);
+
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrCouldNotDisconnect);
+	}
+
+	//stop listening for events
+	SafeDelete(iEventTrapper);
+
+	iIsConnected = EFalse;
+
+	iFramingLayer->RespondOkL(KNullDesC8);
+
+	// let the kernel side driver cleanup
+	iKernelDriver.Close();
+
+	//Shutdown the tcb server.
+	CloseTcbServer();
+	
+	// send the callback to the trk server
+	if (iEngine)
+		iEngine->DebuggingEnded();	
+        
+}
+
+//
+// CTrkDispatchLayer::DoVersionsL
+//
+// The host debugger is requesting MetroTrk version information
+//
+void CTrkDispatchLayer::DoVersionsL()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSVersions != command)
+		User::Leave(kDSReplyError);
+	
+	TUint8 kernelMajorVersion = MAJOR_VERSION_NUMBER;
+	TUint8 kernelMinorVersion = MINOR_VERSION_NUMBER;
+	TUint8 protocolMajorVersion = DS_PROTOCOL_MAJOR_VERSION;
+	TUint8 protocolMinorVersion = DS_PROTOCOL_MINOR_VERSION;
+
+	AddToReplyBufferL(kernelMajorVersion, true);
+	AddToReplyBufferL(kernelMinorVersion);
+	AddToReplyBufferL(protocolMajorVersion);
+	AddToReplyBufferL(protocolMinorVersion);
+
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::DoVersionsL
+//
+// The host debugger is requesting MetroTrk version information
+//
+void CTrkDispatchLayer::DoVersions2L()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSVersions2 != command)
+		User::Leave(kDSReplyError);
+	
+	TUint8 kernelMajorVersion = MAJOR_VERSION_NUMBER;
+	TUint8 kernelMinorVersion = MINOR_VERSION_NUMBER;
+	TUint8 protocolMajorVersion = DS_PROTOCOL_MAJOR_VERSION;
+	TUint8 protocolMinorVersion = DS_PROTOCOL_MINOR_VERSION;
+	TUint8 buildNumber = BUILD_NUMBER;
+
+	AddToReplyBufferL(kernelMajorVersion, true);
+	AddToReplyBufferL(kernelMinorVersion);
+	AddToReplyBufferL(protocolMajorVersion);
+	AddToReplyBufferL(protocolMinorVersion);
+	AddToReplyBufferL(buildNumber);
+
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::DoVersions3L
+//
+// The host debugger is requesting MetroTrk version information
+//
+void CTrkDispatchLayer::DoVersions3L()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSVersions3 != command)
+		User::Leave(kDSReplyError);
+	
+	TUint8 kernelMajorVersion = MAJOR_VERSION_NUMBER;
+	TUint8 kernelMinorVersion = MINOR_VERSION_NUMBER;
+	TUint8 protocolMajorVersion = DS_PROTOCOL_MAJOR_VERSION;
+	TUint8 protocolMinorVersion = DS_PROTOCOL_MINOR_VERSION;
+	TUint8 buildNumber = BUILD_NUMBER;
+
+	AddToReplyBufferL(kernelMajorVersion, true);
+	AddToReplyBufferL(kernelMinorVersion);
+	AddToReplyBufferL(protocolMajorVersion);
+	AddToReplyBufferL(protocolMinorVersion);
+	AddToReplyBufferL(buildNumber);
+	
+	TUint16 len = TRK_TYPE_DESCRIPTION.Length();
+	
+	AddToReplyBufferL(len);
+	AddToReplyBufferL(TRK_TYPE_DESCRIPTION);
+
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::DoHostVersionsL
+//
+// The host debugger is sending the supported protocol version
+//
+void CTrkDispatchLayer::DoHostVersionsL()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSHostVersions != command)
+		User::Leave(kDSReplyError);
+	
+	GetDataFromBufferL(&iHostVersion.iMajor, 1);
+	GetDataFromBufferL(&iHostVersion.iMinor, 1);
+	
+	iFramingLayer->RespondOkL(KNullDesC8);
+}
+
+//
+// CTrkDispatchLayer::DoSupportMaskL
+//
+// The host debugger is requesting MetroTrk capabilities
+//
+void CTrkDispatchLayer::DoSupportMaskL()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSSupportMask != command)
+		User::Leave(kDSReplyError);
+	
+	TBuf8<32> supportMask;
+	TUint8 level = DS_PROTOCOL_RTOS;
+	
+	supportMask.Zero();
+	supportMask.Append(DS_SUPPORT_MASK_00_07);
+	supportMask.Append(DS_SUPPORT_MASK_08_0F);
+	supportMask.Append(DS_SUPPORT_MASK_10_17);
+	supportMask.Append(DS_SUPPORT_MASK_18_1F);
+	supportMask.Append(DS_SUPPORT_MASK_20_27);
+	supportMask.Append(DS_SUPPORT_MASK_28_2F);
+	supportMask.Append(DS_SUPPORT_MASK_30_37);
+	supportMask.Append(DS_SUPPORT_MASK_38_3F);
+	supportMask.Append(DS_SUPPORT_MASK_40_47);
+	supportMask.Append(DS_SUPPORT_MASK_48_4F);
+	supportMask.Append(DS_SUPPORT_MASK_50_57);
+	supportMask.Append(DS_SUPPORT_MASK_58_5F);
+	supportMask.Append(DS_SUPPORT_MASK_60_67);
+	supportMask.Append(DS_SUPPORT_MASK_68_6F);
+	supportMask.Append(DS_SUPPORT_MASK_70_77);
+	supportMask.Append(DS_SUPPORT_MASK_78_7F);
+	supportMask.Append(DS_SUPPORT_MASK_80_87);
+	supportMask.Append(DS_SUPPORT_MASK_88_8F);
+	supportMask.Append(DS_SUPPORT_MASK_90_97);
+	supportMask.Append(DS_SUPPORT_MASK_98_9F);
+	supportMask.Append(DS_SUPPORT_MASK_A0_A7);
+	supportMask.Append(DS_SUPPORT_MASK_A8_AF);
+	supportMask.Append(DS_SUPPORT_MASK_B0_B7);
+	supportMask.Append(DS_SUPPORT_MASK_B8_BF);
+	supportMask.Append(DS_SUPPORT_MASK_C0_C7);
+	supportMask.Append(DS_SUPPORT_MASK_C8_CF);
+	supportMask.Append(DS_SUPPORT_MASK_D0_D7);
+	supportMask.Append(DS_SUPPORT_MASK_D8_DF);
+	supportMask.Append(DS_SUPPORT_MASK_E0_E7);
+	supportMask.Append(DS_SUPPORT_MASK_E8_EF);
+	supportMask.Append(DS_SUPPORT_MASK_F0_F7);
+	supportMask.Append(DS_SUPPORT_MASK_F8_FF);
+	
+	AddToReplyBufferL(supportMask, true);
+	AddToReplyBufferL(level);
+
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::DoCPUTypeL
+//
+// The host debugger is requesting cpu information
+//
+void CTrkDispatchLayer::DoCPUTypeL()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSCPUType != command)
+		User::Leave(kDSReplyError);
+
+	TUint8 cpuMajor = DS_CPU_MAJOR_ARM;
+	TUint8 cpuMinor = 0;
+	TUint8 bigEndian = iFramingLayer->IsBigEndian() ? 1 : 0;
+	TUint8 defaultTypeSize = 4;
+	TUint8 fpTypeSize = 0;
+	TUint8 extended1TypeSize = 0;
+	TUint8 extended2TypeSize = 0;
+
+	AddToReplyBufferL(cpuMajor, true);
+	AddToReplyBufferL(cpuMinor);
+	AddToReplyBufferL(bigEndian);
+	AddToReplyBufferL(defaultTypeSize);
+	AddToReplyBufferL(fpTypeSize);
+	AddToReplyBufferL(extended1TypeSize);
+	AddToReplyBufferL(extended2TypeSize);
+
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::DoReadMemoryL
+//
+// Read memory from the target device and return to the host
+//
+void CTrkDispatchLayer::DoReadMemoryL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSReadMemory != command)
+		User::Leave(kDSReplyError);
+
+ 	// get the options
+	TUint8 options = 0;
+	GetDataFromBufferL(&options, 1);
+
+	if ((options & DS_MSG_MEMORY_EXTENDED) != 0)
+		User::Leave(kDSReplyUnsupportedOptionError);
+
+	// get the length to read
+	TUint16 length = 0;
+	GetDataFromBufferL(&length, 2);
+
+	if (length > DS_MAXREADWRITELENGTH)
+		User::Leave(kDSReplyParameterError);
+	
+	// get the start address
+	TUint32 address = 0;
+	GetDataFromBufferL(&address, 4);
+
+	// get the process id
+	TUint32 processId = 0;
+	GetDataFromBufferL(&processId, 4);
+
+	// get the thread id
+	TUint32 threadId = 0;
+	GetDataFromBufferL(&threadId, 4);
+
+	// allocate enough room for the data
+	HBufC8 *data = HBufC8::NewLC(length);
+	TPtr8 ptr(data->Des());
+
+	TInt err = iKernelDriver.ReadMemory(threadId, address, length, ptr);
+	if (KErrNone != err)
+	{
+		CleanupStack::PopAndDestroy(data);
+		User::Leave(err);
+	}
+	
+	AddToReplyBufferL(length, true);
+	AddToReplyBufferL(ptr);
+
+	RespondOkL();
+
+	CleanupStack::PopAndDestroy(data);
+}
+
+//
+// CTrkDispatchLayer::DoWriteMemoryL
+//
+// Write memory from the host to the target device
+//
+void CTrkDispatchLayer::DoWriteMemoryL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSWriteMemory != command)
+		User::Leave(kDSReplyError);
+
+ 	// get the options
+	TUint8 options = 0;
+	GetDataFromBufferL(&options, 1);
+
+	if ((options & DS_MSG_MEMORY_EXTENDED) != 0)
+		User::Leave(kDSReplyUnsupportedOptionError);
+
+	// get the length to write
+	TUint16 length = 0;
+	GetDataFromBufferL(&length, 2);
+
+	if (length > DS_MAXREADWRITELENGTH)
+		User::Leave(kDSReplyParameterError);
+	
+	// get the start address
+	TUint32 address = 0;
+	GetDataFromBufferL(&address, 4);
+
+	// get the process id
+	TUint32 processId = 0;
+	GetDataFromBufferL(&processId, 4);
+
+	// get the thread id
+	TUint32 threadId = 0;
+	GetDataFromBufferL(&threadId, 4);
+
+	User::LeaveIfError(iKernelDriver.WriteMemory(threadId, address, length, *iInputBuffer));
+	
+	AddToReplyBufferL(length, true);
+
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::DoReadRegistersL
+//
+// Read registers from the target device and return to the host
+//
+void CTrkDispatchLayer::DoReadRegistersL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSReadRegisters != command)
+		User::Leave(kDSReplyError);
+
+	// get the options
+	TUint8 options = 0;
+	GetDataFromBufferL(&options, 1);
+
+	if (DS_MSG_REGISTERS_TYPE(options) != kDSRegistersDefault)
+		User::Leave(kDSReplyUnsupportedOptionError);
+		
+	// get the first register
+	TInt16 firstRegister = 0;
+	GetDataFromBufferL(&firstRegister, 2);
+
+	// get the last register
+	TInt16 lastRegister = 0;
+	GetDataFromBufferL(&lastRegister, 2);
+
+	if ((firstRegister < 0) || (lastRegister > 16))
+		User::Leave(kDSReplyInvalidRegisterRange);
+	
+	// get the process id
+	TUint32 processId = 0;
+	GetDataFromBufferL(&processId, 4);
+
+	// get the thread id
+	TUint32 threadId = 0;
+	GetDataFromBufferL(&threadId, 4);
+
+	// allocate enough space to hold the values
+	HBufC8 *values = HBufC8::NewLC((lastRegister - firstRegister + 1) * 4);
+	TPtr8 ptr(values->Des());
+	
+	TInt err = iKernelDriver.ReadRegisters(threadId, firstRegister, lastRegister, ptr);
+	if (KErrNone != err)
+	{
+		CleanupStack::PopAndDestroy(values);
+		User::Leave(err);
+	}
+	
+	for (int i=0; i<=lastRegister - firstRegister; i++)
+		AddToReplyBufferL(*(TUint32 *)&ptr.Ptr()[i*4], i==0 ? true : false);
+			
+	RespondOkL();
+
+	CleanupStack::PopAndDestroy(values);
+}
+
+//
+// CTrkDispatchLayer::DoWriteRegistersL
+//
+// Write registers from the host to the target device
+//
+void CTrkDispatchLayer::DoWriteRegistersL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSWriteRegisters != command)
+		User::Leave(kDSReplyError);
+
+	// get the options
+	TUint8 options = 0;
+	GetDataFromBufferL(&options, 1);
+
+	if (DS_MSG_REGISTERS_TYPE(options) != kDSRegistersDefault)
+		User::Leave(kDSReplyUnsupportedOptionError);
+
+	// get the first register
+	TInt16 firstRegister = 0;
+	GetDataFromBufferL(&firstRegister, 2);
+
+	// get the last register
+	TInt16 lastRegister = 0;
+	GetDataFromBufferL(&lastRegister, 2);
+
+	if ((firstRegister < 0) || (lastRegister > 16))
+		User::Leave(kDSReplyInvalidRegisterRange);
+
+	// get the process id
+	TUint32 processId = 0;
+	GetDataFromBufferL(&processId, 4);
+
+	// get the thread id
+	TUint32 threadId = 0;
+	GetDataFromBufferL(&threadId, 4);
+	
+	// MetroTrk register values come in as big endian so we may need to swap them
+	if (!iFramingLayer->IsBigEndian())
+	{
+		Swap4xN((TUint32 *)iInputBuffer->Ptr(), lastRegister-firstRegister + 1);
+	}
+	
+	User::LeaveIfError(iKernelDriver.WriteRegisters(threadId, firstRegister, lastRegister, *iInputBuffer));
+	
+	iFramingLayer->RespondOkL(KNullDesC8);
+}
+
+//
+// CTrkDispatchLayer::DoContinueL
+//
+// Resume thread execution
+//
+void CTrkDispatchLayer::DoContinueL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSContinue != command)
+		User::Leave(kDSReplyError);
+
+	// get the process id
+	TUint32 processId = 0;
+	GetDataFromBufferL(&processId, 4);
+
+	// get the thread id
+	TUint32 threadId = 0;
+	GetDataFromBufferL(&threadId, 4);
+	
+	// see if this thread is in the the suspended threads list
+	// if so, remove it and resume.  otherwise we need to handle
+	// the special case of the first time a thread is resumed
+	TInt index = iSuspendedThreadList.Find(threadId);
+	if (index >= 0)
+	{
+		iSuspendedThreadList.Remove(index);
+		User::LeaveIfError(iKernelDriver.ResumeThread(threadId));
+		iFramingLayer->RespondOkL(KNullDesC8);
+	}
+	else
+	{
+		// if it's not in the suspended list then this is the first time it has been
+		// resumed (the process has just been created).  see if there are statically
+		// linked libraries that we need to report to the host debugger.  if so, we
+		// don't really want to resume yet.  let the host debugger set any breakpoints
+		// in the libraries first.  it will call resume again once it's done.
+
+		// since we never mark it as suspended, we'll actually get here when the host
+		// debugger calls resume the second time.  we really don't want to mark it as
+		// suspended because then the host debugger will try to draw the thread window
+		TBool found = EFalse;
+		for (TInt i=0; i<iDebugProcessList.Count(); i++)
+		{
+			if (iDebugProcessList[i]->ProcessId() == processId)
+			{
+				found = ETrue;
+				// if we're already marked it as ready, just resume and return
+				if (iDebugProcessList[i]->iReadyForLibraryLoadNotification)
+				{
+					User::LeaveIfError(iKernelDriver.ResumeThread(threadId));
+					iFramingLayer->RespondOkL(KNullDesC8);		
+					return;
+				}
+
+				iDebugProcessList[i]->iReadyForLibraryLoadNotification = ETrue;
+				break;
+			}
+		}
+		// For RUN mode, we created the process but we didn't put it into the list
+		// therefore we do not want to notify the host debugger about static libraries
+		// so just resume and return  (see DoCreateExeL)
+		// The host debugger will soon disconnect in this mode
+		if (!found)
+		{
+			User::LeaveIfError(iKernelDriver.ResumeThread(threadId));
+			iFramingLayer->RespondOkL(KNullDesC8);		
+			return;
+		}
+
+		// the process has been created and the host debugger is listening for messages
+		// see if there are any statically linked libraries for this process.  if so, let
+		// the host debugger know about them now. note that the host debugger will send
+		// another resume command once it's handled the static libraries.  if there are
+		// not static libraries for this process, we really do need to resume the thread.
+		
+		TInt err = KErrNone;
+		TInt i = 0;
+		for (i=0; KErrNone==err; i++)
+		{
+			SEventInfo info;
+			info.iProcessId = processId;
+			info.iThreadId = threadId;
+			err = iKernelDriver.GetStaticLibraryInfo(i, info);
+			
+			if (KErrNone == err)
+			{
+				DoNotifyLibraryLoadedL(info.iFileName, info.iProcessId, 0xFFFFFFFF, info.iCodeAddress, info.iDataAddress);
+			}
+			//else if (0 == i)
+			//{
+				// there are no static libraries for this process
+				//User::LeaveIfError(iKernelDriver.ResumeThread(threadId));			
+			//}
+		}
+		//Always resume the thread instead of asking the host debugger to resume when sending the last static library notification.
+		User::LeaveIfError(iKernelDriver.ResumeThread(threadId));			
+		iFramingLayer->RespondOkL(KNullDesC8);		
+	}
+}
+
+//
+// CTrkDispatchLayer::DoStepL
+//
+// Execute one instruction in a thread
+//
+void CTrkDispatchLayer::DoStepL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSStep != command)
+		User::Leave(kDSReplyError);
+
+	// get the options
+	TUint8 options = 0;
+	GetDataFromBufferL(&options, 1);
+	
+	// we only support stepping out of a range of instructions
+	if ((kDSStepIntoRange != options) && (kDSStepOverRange != options))
+	{
+		User::Leave(kDSReplyUnsupportedOptionError);
+	}
+
+	// get the range start address
+	TUint32 startAddress = 0;
+	GetDataFromBufferL(&startAddress, 4);
+
+	// get the range stop address
+	TUint32 stopAddress = 0;
+	GetDataFromBufferL(&stopAddress, 4);
+		
+	// get the process id
+	TUint32 processId = 0;
+	GetDataFromBufferL(&processId, 4);
+
+	// get the thread id
+	TUint32 threadId = 0;
+	GetDataFromBufferL(&threadId, 4);
+
+	User::LeaveIfError(iKernelDriver.StepRange(threadId, startAddress, stopAddress, (kDSStepIntoRange == options)));
+
+	iFramingLayer->RespondOkL(KNullDesC8);
+}
+
+//
+// CTrkDispatchLayer::DoStopL
+//
+// Stop the execution of a thread
+//
+void CTrkDispatchLayer::DoStopL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSStop != command)
+		User::Leave(kDSReplyError);
+
+	// get the options
+	TUint8 options = 0;
+	GetDataFromBufferL(&options, 1);
+	
+	TUint32 processId = 0;
+	TUint32 threadId = 0;
+	
+	switch(options)
+	{
+		case kDSStopThread:
+		{
+			// get the process id
+			GetDataFromBufferL(&processId, 4);
+
+			// get the thread id
+			GetDataFromBufferL(&threadId, 4);
+			
+			User::LeaveIfError(iKernelDriver.SuspendThread(threadId));
+			
+			break;
+		}
+		case kDSStopSystem:
+		case kDSStopProcess:
+		default:
+		{
+			User::Leave(kDSReplyUnsupportedOptionError);
+			break;
+		}
+	}
+
+	iFramingLayer->RespondOkL(KNullDesC8);
+	
+	TBuf8<4> currentPC;
+	
+	User::LeaveIfError(iKernelDriver.ReadRegisters(threadId, 15, 15, currentPC));
+	
+	DoNotifyStoppedL(processId, threadId, *(TUint32 *)currentPC.Ptr(), KNullDesC8);
+}
+
+//
+// CTrkDispatchLayer::DoSetBreakL
+//
+// Set a breakpoint
+//
+void CTrkDispatchLayer::DoSetBreakL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSSetBreak != command)
+		User::Leave(kDSReplyError);
+
+	// get the options - unused
+	TUint8 options = 0;
+	GetDataFromBufferL(&options, 1);
+
+	// get the mode
+	TUint8 thumbMode = 0;
+	GetDataFromBufferL(&thumbMode, 1);
+
+	// get the address
+	TUint32 address = 0;
+	GetDataFromBufferL(&address, 4);
+
+	// get the length
+	TUint32 length = 0;
+	GetDataFromBufferL(&length, 4);
+
+	// get the count
+	TUint32 count = 0;
+	GetDataFromBufferL(&count, 4);
+
+	// get the process id
+	TUint32 processId = 0;
+	GetDataFromBufferL(&processId, 4);
+
+	// get the thread id
+	TUint32 threadId = 0;
+	GetDataFromBufferL(&threadId, 4);
+	
+	TInt32 breakId = 0;
+	User::LeaveIfError(iKernelDriver.SetBreak(processId, threadId, address, thumbMode, breakId));
+
+	// return the id of this breakpoint to the host debugger
+	AddToReplyBufferL((TUint32)breakId, true);
+	
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::DoClearBreakL
+//
+// Clear a breakpoint
+//
+void CTrkDispatchLayer::DoClearBreakL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+
+	if (kDSClearBreak != command)
+		User::Leave(kDSReplyError);
+
+	// get the breakpoint id
+	TUint32 breakId = 0;
+	GetDataFromBufferL(&breakId, 4);
+
+	User::LeaveIfError(iKernelDriver.ClearBreak(breakId));
+
+	iFramingLayer->RespondOkL(KNullDesC8);
+}
+
+//
+// CTrkDispatchLayer::DoModifyBreakThreadL
+//
+// Change the thread(s) that a breakpoint is associated with
+//
+void CTrkDispatchLayer::DoModifyBreakThreadL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+
+	if (kDSModifyBreakThread != command)
+		User::Leave(kDSReplyError);
+
+	// get the breakpoint id
+	TUint32 breakId = 0;
+	GetDataFromBufferL(&breakId, 4);
+
+	// get the thread id
+	TUint32 threadId = 0;
+	GetDataFromBufferL(&threadId, 4);
+
+	User::LeaveIfError(iKernelDriver.ChangeBreakThread(threadId, breakId));
+
+	iFramingLayer->RespondOkL(KNullDesC8);
+}
+
+//
+// CTrkDispatchLayer::DoCreateItemL
+//
+// Create a new OS item on the target device
+//
+void CTrkDispatchLayer::DoCreateItemL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSOSCreateItem != command)
+		User::Leave(kDSReplyError);
+
+	// get the item type
+	TUint16 type = 0;
+	GetDataFromBufferL(&type, 2);
+
+	switch(type)
+	{
+		case kDSOSProcessItem:
+		{
+			DoCreateProcessL();
+			break;
+		}
+		case kDSOSProcRunItem:
+		{
+			DoCreateProcessL(ETrue);
+			break;
+		}
+		case kDSOSProcAttachItem:
+		{
+			DoAttachProcessL(kDSOSProcAttachItem);
+			break;
+		}
+		case kDSOSProcAttach2Item:
+		{
+			DoAttachProcessL(kDSOSProcAttach2Item);
+			break;
+		}
+		case kDSOSProcAttach3Item:
+		{
+			DoAttachProcessL(kDSOSProcAttach3Item);
+			break;
+		}
+		case kDSOSThreadItem:
+		case kDSOSDLLItem:
+		case kDSOSAppItem:
+		case kDSOSMemBlockItem:
+		case kDSOSThreadAttachItem:
+		default:
+		{
+			User::Leave(kDSReplyUnsupportedOptionError);
+			break;
+		}
+	}
+}
+
+//
+// CTrkDispatchLayer::DoDeleteItemL
+//
+// Delete an OS item from the target device
+//
+void CTrkDispatchLayer::DoDeleteItemL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSOSDeleteItem != command)
+		User::Leave(kDSReplyError);
+
+	// get the item type
+	TUint16 type = 0;
+	GetDataFromBufferL(&type, 2);
+
+	switch(type)
+	{
+		case kDSOSProcessItem:
+		{
+			DoKillProcessL();
+			break;
+		}
+		case kDSOSProcAttachItem:
+		{
+		    DoDetachProcessL();
+			break;
+		}
+		case kDSOSThreadItem:
+		case kDSOSDLLItem:
+		case kDSOSAppItem:
+		case kDSOSMemBlockItem:
+		case kDSOSThreadAttachItem:
+		default:
+		{
+			User::Leave(kDSReplyUnsupportedOptionError);
+			break;
+		}
+	}
+}
+
+//
+// CTrkDispatchLayer::DoReadInfoL
+//
+// Read OS information from the target device
+//
+void CTrkDispatchLayer::DoReadInfoL()
+{	
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+
+	if (kDSOSReadInfo != command)
+		User::Leave(kDSReplyError);
+
+	// get the type of info requested
+	TUint16 type = 0;
+	GetDataFromBufferL(&type, 2);
+
+	// get the start index
+	TUint32 index = 0;
+	GetDataFromBufferL(&index, 4);	
+	
+	switch(type)
+	{
+		case kDSOSProcessList:
+		{
+			DoReadProcessListL(index);
+			break;
+		}
+		case kDSOSThreadList:
+		{
+			DoReadThreadListL(index);
+			break;
+		}
+		case kDSOSDLLInfo:
+		{
+			TUint16 nameLength = 0;
+			GetDataFromBufferL(&nameLength, 2);
+			
+			// make sure the length of the message is correct
+			if (iInputBuffer->Length() != nameLength)
+				User::Leave(kDSReplyPacketSizeError);
+			
+			TBuf8<KMaxFileName> fileName;
+			fileName.Copy(*iInputBuffer);
+			fileName.ZeroTerminate();
+
+			DoReadLibraryInfoL(fileName);
+			break;
+		}
+		case kDSOSProcessInfo:
+		{
+			TUint32 uid3 = 0;
+			GetDataFromBufferL(&uid3, 4);
+			TUint16 nameLength = 0;
+			GetDataFromBufferL(&nameLength, 2);
+			
+			// make sure the length of the message is correct
+			if (iInputBuffer->Length() != nameLength)
+				User::Leave(kDSReplyPacketSizeError);
+			
+			TBuf8<KMaxFileName> fileName;
+			fileName.Copy(*iInputBuffer);
+			fileName.ZeroTerminate();
+			
+			DoReadProcessInfoL(uid3, fileName);
+			break;
+		}
+		case kDSOSProcessState:
+		case kDSOSThreadState:
+		case kDSOSDLLList:
+		case kDSOSDLLState:
+		default:
+		{
+			User::Leave(kDSReplyUnsupportedOptionError);
+			break;
+		}
+	}
+}
+
+//
+// CTrkDispatchLayer::DoWriteInfoL
+//
+// Set options for the Trk
+//
+void CTrkDispatchLayer::DoWriteInfoL()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+
+	if (kDSOSWriteInfo != command)
+		User::Leave(kDSReplyError);
+
+	// get the type of info requested
+	TUint16 type = 0;
+	GetDataFromBufferL(&type, 2);
+
+	// get the start index
+	TUint32 index = 0;
+	GetDataFromBufferL(&index, 4);
+
+	// no options supported yet.  might add something for auto-target libraries later
+	User::Leave(kDSReplyUnsupportedOptionError);
+}
+
+//
+// CTrkDispatchLayer::DoOpenFileL
+//
+// Open or create a file on the target
+//
+void CTrkDispatchLayer::DoOpenFileL()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSOSOpenFile != command)
+		User::Leave(kDSReplyError);
+
+	// get the file mode(s)
+	TUint8 modes = 0;
+	GetDataFromBufferL(&modes, 1);
+
+	if ((modes & kDSFileOpenAppend) || (modes & kDSFileOpenCreate))
+		modes |= kDSFileOpenWrite;
+
+	TUint16 nameLength = 0;
+	GetDataFromBufferL(&nameLength, 2);
+	
+	// make sure the length of the message is correct
+	if (iInputBuffer->Length() != nameLength)
+		User::Leave(kDSReplyPacketSizeError);
+	
+	TBuf<KMaxPath> fullpath;
+	fullpath.Copy(*iInputBuffer);
+	fullpath.ZeroTerminate();
+		
+	TUint mode = EFileShareExclusive;
+
+	// get the file mode(s)
+	if (modes & kDSFileOpenRead)
+		mode |= EFileRead;
+
+	if (modes & kDSFileOpenWrite)
+		mode |= EFileWrite;
+
+	if (modes & kDSFileOpenAppend)
+		mode |= EFileWrite;
+
+	if (modes & kDSFileOpenCreate)
+		mode |= EFileWrite;
+	
+
+	//for getting the modification date
+	TTime time;
+	
+	OpenFileL(fullpath, mode, time);
+	
+	TDateTime dateTime = time.DateTime();
+
+	TDateTimeConverter winTime(dateTime);
+	
+	TUint32 timestamp = winTime.GetWinTimeDate();
+
+	TUint32 handle = 1;
+	TUint8 err = 0;
+
+	AddToReplyBufferL(err, true);
+	AddToReplyBufferL(handle);
+	AddToReplyBufferL(timestamp);
+	
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::OpenFileL
+//
+// Open a file on the target, if plat security is enabled, uses TrkTcbServer to open the file.
+//
+void CTrkDispatchLayer::OpenFileL(const TDesC& aFullPath, TUint aMode, TTime& aTime)
+{
+
+#ifdef __OEM_TRK__	
+	//Check to see if TCB capability is enforced, if so, connect to the tcb server as well.
+	if (!iUseTcbServer && PlatSec::IsCapabilityEnforced(ECapabilityTCB))
+	{
+		if (!iTrkTcbSession.Connect())
+		{
+			iUseTcbServer = ETrue;
+		}	
+	}
+
+	if (iUseTcbServer)
+	{
+		User::LeaveIfError(iTrkTcbSession.OpenFile(aFullPath, aMode, aTime));
+	}
+	else
+#endif	
+	{
+	#ifndef __OEM_TRK__
+		if (IsRestrictedFolder(aFullPath))
+			User::Leave(KErrAccessDenied);
+	#endif
+		// connect to the file server
+		User::LeaveIfError(iFs.Connect());
+
+		TInt error = iFs.MkDirAll(aFullPath);
+
+		if ((KErrNone != error) && (KErrAlreadyExists != error))
+		{
+			iFs.Close();
+			User::Leave(error);
+		}
+		
+		error = iFile.Open(iFs, aFullPath, aMode);
+		
+		if (KErrNone != error)
+			User::LeaveIfError(iFile.Replace(iFs, aFullPath, aMode));
+		
+		User::LeaveIfError(iFile.Modified(aTime));
+		iFileState = EFileOpened;
+	}
+}
+
+//
+// CTrkDispatchLayer::DoReadFileL
+//
+// Read data from a file on the target
+//
+void CTrkDispatchLayer::DoReadFileL()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSOSReadFile != command)
+		User::Leave(kDSReplyError);
+
+	// make sure the length of the message is correct
+	if (iInputBuffer->Length() != 6)
+		User::Leave(kDSReplyPacketSizeError);
+	
+	// remove the handle
+	iInputBuffer->Des().Delete(0, 4);
+
+	// get the length
+	TUint8 err = 0;
+	TUint16 length = 0;
+	GetDataFromBufferL(&length, 2);
+	
+	// allocate a buffer large enough for the data
+	HBufC8 *buffer = HBufC8::NewLC(length);
+	TPtr8 ptr(buffer->Des());
+	
+	//	CleanupStack::PushL(buffer);
+	
+	TInt error = ReadFileL(length, ptr);	
+	if (KErrNone != error)
+	{
+		CleanupStack::PopAndDestroy(buffer);	
+		User::Leave(error);
+	}
+	
+	length = buffer->Length();
+	
+	AddToReplyBufferL(err, true);
+	AddToReplyBufferL(length);
+//	AddToReplyBufferL(buffer[0], length);
+	AddToReplyBufferL(ptr);
+	RespondOkL();
+	
+	CleanupStack::PopAndDestroy(buffer);
+}
+
+//
+// CTrkDispatchLayer::ReadFileL
+//
+// Reads data from a file on the target
+//
+TInt CTrkDispatchLayer::ReadFileL(TUint16 aLength, TPtr8& aData)
+{
+	TInt error = KErrNone;
+
+#ifdef __OEM_TRK__
+	if (iUseTcbServer)
+	{
+		User::LeaveIfError(iTrkTcbSession.ReadFile(aLength, aData));
+	}
+	else
+#endif	
+	{
+		iFileState = EFileReading;
+		error = iFile.Read(aData);
+	}
+	return error;
+}
+
+//
+// CTrkDispatchLayer::DoWriteFileL
+//
+// Write data to a file on the target
+//
+void CTrkDispatchLayer::DoWriteFileL()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSOSWriteFile != command)
+		User::Leave(kDSReplyError);
+	
+	// get the length
+	TUint32 handle = 0;
+	GetDataFromBufferL(&handle, 4);
+	
+	if (handle != 1)
+		User::Leave(kDSReplyParameterError);
+
+	// get the length
+	TUint8 err = 0;
+	TUint16 length = 0;
+	GetDataFromBufferL(&length, 2);
+
+	// make sure the length of the message is correct
+	if (iInputBuffer->Length() != length)
+		User::Leave(kDSReplyPacketSizeError);
+		
+	WriteFileL(*iInputBuffer);
+	
+	length = iInputBuffer->Length();
+	
+	AddToReplyBufferL(err, true);
+	AddToReplyBufferL(length);
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::WriteFileL
+//
+// Write data to a file on the target. If plat sec is enabled, uses Trk Tcb Server.
+//
+void CTrkDispatchLayer::WriteFileL(TDesC8& aData)
+{
+#ifdef __OEM_TRK__
+	if (iUseTcbServer)
+	{
+		User::LeaveIfError(iTrkTcbSession.WriteFile(aData));
+	}
+	else
+#endif	
+	{	
+		if (iFileState == EFileOpened)
+		{
+			iFile.SetSize(0);
+			iFileState = EFileWriting;
+		}
+		User::LeaveIfError(iFile.Write(aData));
+		User::LeaveIfError(iFile.Flush());
+	}
+}
+
+//
+// CTrkDispatchLayer::DoPositionFileL
+//
+// Change the current file position of a file on the target
+//
+void CTrkDispatchLayer::DoPositionFileL()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSOSPositionFile != command)
+		User::Leave(kDSReplyError);
+
+	// make sure the length of the message is correct
+	if (iInputBuffer->Length() != 9)
+		User::Leave(kDSReplyPacketSizeError);
+	
+	// get the positioning mode
+	TUint8 mode = 0;
+	GetDataFromBufferL(&mode, 1);
+
+	// remove the handle
+	iInputBuffer->Des().Delete(0, 4);
+
+	TUint8 err = 0;
+	TUint32 offset = 0;
+	GetDataFromBufferL(&offset, 4);
+
+	TSeek seek;
+	
+	// convert mode to native parameter and set the position accordingly
+	switch(mode)
+	{
+		default:
+		case kDSFileSeekSet:
+		{
+			seek = ESeekStart;
+			break;
+		}
+		case kDSFileSeekCur:
+		{
+			seek = ESeekCurrent;
+			break;
+		}
+		case kDSFileSeekEnd:
+		{
+			seek = ESeekEnd;
+			break;
+		}
+	}
+
+	PositionFileL(seek, (TInt &)offset);
+
+	AddToReplyBufferL(err, true);
+	
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::PositionFileL
+//
+// Change the current file position of a file on the target. If plat sec is enabled,
+// uses Trk Tcb Server.
+//
+void CTrkDispatchLayer::PositionFileL(TSeek aSeek, TInt& aOffset)
+{
+#ifdef __OEM_TRK__
+	if (iUseTcbServer)
+	{
+		User::LeaveIfError(iTrkTcbSession.PositionFile(aSeek, aOffset));
+	}
+	else
+#endif	
+	{
+		User::LeaveIfError(iFile.Seek(aSeek, aOffset));
+	}
+}
+
+
+//
+// CTrkDispatchLayer::DoCloseFileL
+//
+// Close a file on the target
+//
+void CTrkDispatchLayer::DoCloseFileL()
+{
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSOSCloseFile != command)
+		User::Leave(kDSReplyError);
+
+	// make sure the length of the message is correct
+	if (iInputBuffer->Length() != 8)
+		User::Leave(kDSReplyPacketSizeError);
+
+	// remove the handle
+	iInputBuffer->Des().Delete(0, 4);
+	
+	TUint8 err = 0;
+	TUint32 timestamp = 0;
+	GetDataFromBufferL(&timestamp, 4);
+	
+	TDateTimeConverter epocTime(timestamp);
+	
+	CloseFileL(epocTime.GetEpocTimeDate());
+
+	AddToReplyBufferL(err, true);
+
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::CloseFileL
+//
+// Close a file on the target. If plat sec is enabled, uses Trk Tcb Server.
+//
+void CTrkDispatchLayer::CloseFileL(const TTime& aModifiedTime)
+{
+#ifdef __OEM_TRK__
+	if (iUseTcbServer)
+	{
+		User::LeaveIfError(iTrkTcbSession.CloseFile(aModifiedTime));
+	}
+	else
+#endif	
+	{
+		User::LeaveIfError(iFile.SetModified(aModifiedTime));
+		User::LeaveIfError(iFile.Flush());
+		
+		iFile.Close();
+		iFs.Close();
+		iFileState = EFileClosed;
+	}
+}
+
+//
+// CTrkDispatchLayer::DoInstallFileL
+//
+// Install the application, supplied as a SIS file.
+//
+void CTrkDispatchLayer::DoInstallFileL()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+#ifndef __TEXT_SHELL__
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSOSInstallFile != command)
+		User::Leave(kDSReplyError);
+
+	// get the installation drive
+	TUint8 drive = 'C';
+	GetDataFromBufferL(&drive, 1);
+	
+	TChar installDrive(drive);
+
+	TUint16 nameLength = 0;
+	GetDataFromBufferL(&nameLength, 2);
+	
+	// make sure the length of the message is correct
+	if (iInputBuffer->Length() != nameLength)
+		User::Leave(kDSReplyPacketSizeError);
+	
+	TBuf<KMaxPath> fullpath;
+	fullpath.Copy(*iInputBuffer);
+	fullpath.ZeroTerminate();
+			
+	TUint8 err = 0;
+	// Temporarily disable the lib loaded event before launching the SW Installer.
+	// This is necessary when launching the SIS installer since  launching the 
+	// installer causes several libraries to be loaded. The driver suspends the 
+	// thread thats loaded the library. This suspension might potentially cause 
+	// a deadlock as the event handling active object will never get a chance to 
+	// run as the Install function below blocks until the installation is completed.
+	User::LeaveIfError(iKernelDriver.DisableLibLoadedEvent());
+	
+	// now launch the installer
+	User::LeaveIfError(CTrkSwInstall::SilentInstallL(fullpath, installDrive));
+
+	// now enable the lib loaded event
+	iKernelDriver.EnableLibLoadedEvent();
+	
+	AddToReplyBufferL(err, true);
+	RespondOkL();
+#else 
+	User::LeaveIfError(-1); 
+#endif
+}
+
+//
+// CTrkDispatchLayer::DoInstallFileL
+//
+// Install the application, supplied as a SIS file.
+//
+void CTrkDispatchLayer::DoInstallFile2L()
+{
+	// make sure we're connected
+	if (!iIsConnected)
+	{
+		User::Leave(KErrGeneral);
+	}
+
+#ifndef __TEXT_SHELL__
+	// make sure we got here from DispatchMsgL
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+	
+	if (kDSOSInstallFile2 != command)
+		User::Leave(kDSReplyError);
+
+	TUint16 nameLength = 0;
+	GetDataFromBufferL(&nameLength, 2);
+	
+	// make sure the length of the message is correct
+	if (iInputBuffer->Length() != nameLength)
+		User::Leave(kDSReplyPacketSizeError);
+	
+	TBuf<KMaxPath> fullpath;
+	fullpath.Copy(*iInputBuffer);
+	fullpath.ZeroTerminate();
+			
+	TUint8 err = 0;
+	// Temporarily disable the lib loaded event before launching the SW Installer.
+	// This is necessary when launching the SIS installer since  launching the 
+	// installer causes several libraries to be loaded. The driver suspends the 
+	// thread thats loaded the library. This suspension might potentially cause 
+	// a deadlock as the event handling active object will never get a chance to 
+	// run as the Install function below blocks until the installation is completed.
+	User::LeaveIfError(iKernelDriver.DisableLibLoadedEvent());
+
+	// now launch the installer
+	User::LeaveIfError(CTrkSwInstall::Install(fullpath));
+
+	// now enable the lib loaded event
+	iKernelDriver.EnableLibLoadedEvent();
+	
+	AddToReplyBufferL(err);
+	RespondOkL();
+#else
+	User::LeaveIfError(-1);
+#endif
+}
+
+
+//
+// CTrkDispathLayer::DoGetPhoneSWVesionL()
+//
+// sends  the software version of the phone to reply buffer
+//
+void CTrkDispatchLayer::DoGetPhoneSWVersionL()
+{
+    // make sure we got here from DispatchMsgL
+    
+	TUint8 command = 0;
+	GetDataFromBufferL(&command, 1);
+
+	if (kDSOSPhoneSWVersion != command)
+	{
+		User::Leave(kDSReplyError);
+	}
+#ifndef __TEXT_SHELL__
+	if (iPhoneVersion.Size()>0 )
+	{
+		TUint16 versionNameLength = iPhoneVersion.Length();
+		AddToReplyBufferL(versionNameLength, ETrue); 
+		AddToReplyBufferL(iPhoneVersion);       
+		RespondOkL();
+	}
+	else
+#endif	    
+	{
+		User::Leave(KErrGeneral);
+	}    
+                
+}
+
+
+//
+//CTrkDispathLayer::DoGetPhoneNameL()
+//
+//sends the phone model name to the reply buffer
+//
+void CTrkDispatchLayer::DoGetPhoneNameL()
+{    
+    TUint8 command = 0;
+    GetDataFromBufferL(&command, 1);
+    
+    if (kDSOSPhoneName != command)
+    {
+    	User::Leave(kDSReplyError);
+	}
+
+#ifndef __TEXT_SHELL__
+    if (iPhoneNameInfoAvailable)
+    {
+     	TUint16 phoneModelLen = iPhoneModel.Length();
+     	AddToReplyBufferL(phoneModelLen, true);
+     	AddToReplyBufferL(iPhoneModel);
+        RespondOkL();
+    }    
+    else
+#endif
+    {
+        User::Leave(KErrGeneral);
+    }
+}
+//
+//To Update the phone model name 
+//
+//callback function from the CPhoneInfo
+//
+void CTrkDispatchLayer::UpdatePhoneNameInfo(TDesC16& aPhoneModel)
+{
+#ifndef __TEXT_SHELL__
+    iPhoneModel.Copy(aPhoneModel);
+    iPhoneNameInfoAvailable = ETrue;    
+#endif
+}
+
+//
+// CTrkDispatchLayer::DoCreateProcessL
+//
+// Create a new process on the target device
+//
+void CTrkDispatchLayer::DoCreateProcessL(TBool aRun)
+{
+	// remove the options - currently unused
+	iInputBuffer->Des().Delete(0, 1);
+
+	// get the length of the data
+	TUint16 length = 0;
+	GetDataFromBufferL(&length, 2);
+
+	// make sure the length of the message is correct
+	if (iInputBuffer->Length() != length)
+		User::Leave(kDSReplyPacketSizeError);
+
+	// extract the filename and path, command line args, and working directory
+	TPtrC8 exec8(iInputBuffer->Ptr());
+	TPtrC8 args8(exec8.Ptr() + exec8.Length() + 1);
+		
+	// convert the filename and args to unicode descriptors
+	HBufC* exec = HBufC::NewLC(exec8.Length());
+	exec->Des().Copy(exec8);
+
+	HBufC* args = HBufC::NewLC(args8.Length());
+	args->Des().Copy(args8);
+
+	// open the file and get the type (app, exe, etc.)
+	RFs fs;
+	
+	// connect to the file server
+	User::LeaveIfError(fs.Connect());
+	
+	TEntry entry;
+		
+	User::LeaveIfError(fs.Entry(*exec, entry));
+	
+	fs.Close();
+
+	TCreateProcessData data;
+		
+	switch(entry[0].iUid)
+	{
+		case 0x1000007a:
+		{
+			// EXE
+			DoCreateExeL(*exec, *args, data, aRun);
+			break;
+		}
+		default:
+			User::Leave(KErrGeneral);
+	}
+
+	CleanupStack::PopAndDestroy(args);
+	CleanupStack::PopAndDestroy(exec);
+
+	AddToReplyBufferL(data.iProcessId, true);
+	AddToReplyBufferL(data.iMainThreadId);
+	if (!aRun)
+	{
+		AddToReplyBufferL(data.iCodeAddr);
+		AddToReplyBufferL(data.iDataAddr);
+	}
+		
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::DoCreateExeL
+//
+// Create a new executable on the target device
+//
+void CTrkDispatchLayer::DoCreateExeL(const TDesC& aPath, const TDesC& aArgs, TCreateProcessData& aData, TBool aRun)
+{
+	RProcess process;
+	User::LeaveIfError(process.Create(aPath, aArgs));
+	CleanupClosePushL(process);
+
+	aData.iProcessId = process.Id();
+	
+	HBufC* threadName = HBufC::NewLC(KMaxFullName);
+
+	*threadName = process.Name();
+	_LIT(KMainThreadSuffix, "::Main");
+	threadName->Des().Append(KMainThreadSuffix);
+
+	// this function should be (indirectly) called when the debuggee
+	// has been created but not yet resumed.  So it should have a main
+	// thread whose name ends with "::Main", and so the following call
+	// should not fail.
+	RThread thread;
+	User::LeaveIfError(thread.Open(*threadName));
+		
+	aData.iMainThreadId = thread.Id();
+	thread.Close();
+
+	if (!aRun)
+	{
+		CDebugProcess *proc = CDebugProcess::NewL(this, aData.iProcessId, aData.iMainThreadId);
+		iDebugProcessList.Append(proc);
+
+		User::LeaveIfError(iKernelDriver.GetProcessAddresses(aData.iMainThreadId, aData.iCodeAddr, aData.iDataAddr));
+	}
+		
+	CleanupStack::PopAndDestroy(threadName);
+	CleanupStack::PopAndDestroy(); // process
+}
+
+//
+// CTrkDispatchLayer::DoKillProcessL
+//
+// Kill an existing process
+//
+void CTrkDispatchLayer::DoKillProcessL()
+{
+	// get the process id
+	TUint32 processId = 0;
+	GetDataFromBufferL(&processId, 4);
+	
+	RProcess process;
+	User::LeaveIfError(process.Open(processId));
+#ifdef EKA2
+	process.Kill(KErrNone);
+#else	
+	process.Kill(KProcessKilled);
+#endif
+	process.Close();
+
+	iFramingLayer->RespondOkL(KNullDesC8);	
+}
+
+//
+// CTrkDispatchLayer::DoAttachProcessL
+//
+// Create a new process on the target device
+//
+void CTrkDispatchLayer::DoAttachProcessL(DSOSItemTypes aAttachType)
+{
+	// remove the options - currently unused
+	iInputBuffer->Des().Delete(0, 1);
+
+	// get the length of the data
+	TUint32 processId = 0;
+	GetDataFromBufferL(&processId, 4);
+
+	RProcess process;
+	User::LeaveIfError(process.Open(processId));
+	CleanupClosePushL(process);
+	
+	// do not allow attaching to a system, protected, or the MetroTrk process because
+	// if the user were to stop the wrong thread, the whole system could stop
+#ifdef EKA2
+	if ((TUint)processId == RProcess().Id())
+#else
+	if (process.System() || process.Protected() || ((TUint)processId == RProcess().Id()))
+#endif
+	{
+		User::Leave(kDSReplyUnsupportedOptionError);
+	}
+
+	TMetroTrkTaskInfo threadInfo(processId);
+	User::LeaveIfError(iKernelDriver.GetThreadInfo(0, threadInfo));
+
+	
+	TUint32 codeAddr;
+	TUint32 dataAddr;
+	User::LeaveIfError(iKernelDriver.GetProcessAddresses(threadInfo.iId, codeAddr, dataAddr));	
+	//this is necessary to get the process died notifications and also any other event for this process
+	CDebugProcess *proc = CDebugProcess::NewL(this, processId, threadInfo.iId);
+	// For processes that we are attaching, we need to set this flag to true.
+	// otherwise library load notifications for this process will be ignored
+	proc->iReadyForLibraryLoadNotification = ETrue;
+	iDebugProcessList.Append(proc);	
+			
+	AddToReplyBufferL(threadInfo.iId, true);
+	if (aAttachType == kDSOSProcAttach3Item)
+	{
+		// now get the UID3 for this process
+		// and add it to the reply
+		TMetroTrkProcUidInfo procUidInfo(processId);
+		User::LeaveIfError(iKernelDriver.GetProcUidInfo(procUidInfo));
+		AddToReplyBufferL(procUidInfo.iUid3);
+	}
+	if (aAttachType == kDSOSProcAttach3Item || aAttachType == kDSOSProcAttach2Item)
+	{				
+		AddToReplyBufferL(codeAddr);
+		AddToReplyBufferL(dataAddr);
+		
+		TBuf8<KMaxFullName> procName;
+		procName.Copy(process.Name());
+		TUint16 nameLength = procName.Length();
+
+		AddToReplyBufferL(nameLength);
+		AddToReplyBufferL(procName);		
+	}
+
+	CleanupStack::PopAndDestroy(); // process
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::DoDetachProcessL
+//
+// To detach the process from the list of processes
+//
+void CTrkDispatchLayer::DoDetachProcessL()
+{
+    TUint32 processId = 0;
+    GetDataFromBufferL(&processId, 4);
+    
+    RProcess process;
+    User::LeaveIfError(process.Open(processId));
+    
+	for (TInt i=0 ; i<iDebugProcessList.Count(); i++)
+	{
+		if(iDebugProcessList[i]->ProcessId()== processId) 
+		{
+			SafeDelete(iDebugProcessList[i]);
+			iDebugProcessList.Remove(i);
+		}
+	}
+    User::LeaveIfError(iKernelDriver.DetachProcess(processId));    
+
+    iFramingLayer->RespondOkL(KNullDesC8);
+}
+
+
+//
+// CTrkDispatchLayer::DoReadProcessListL
+//
+// Return a list of the current processes to the host debugger
+//
+void CTrkDispatchLayer::DoReadProcessListL(TInt32 aIndex)
+{
+	// remove the options - unused
+	iInputBuffer->Des().Delete(0, 1);
+
+	// remove the filter - unused
+	iInputBuffer->Des().Delete(0, 4);
+
+	// an index of zero means we start fresh.  and index other than zero means
+	// we were not able to return all of the processes in the last round due to
+	// message size limitations, so we need to pick up where we left off
+	if (aIndex == 0)
+	{
+		DoReBuildProcessList();
+	}
+	
+	TInt32 totalCount = iProcessList.Count();
+	TInt32 returnedCount = 0;
+	TInt32 bytesRemaining = MAXMESSAGESIZE_V2 - 30; // minus the framing bytes
+	TInt32 restOfMsgSize = sizeof(TUint32) // process id
+						 + sizeof(TUint32) // priority
+						 + sizeof(TUint8); // NULL character
+	
+	for (TInt32 i=aIndex; i<totalCount; i++)
+	{
+		// make sure there is enough room left in the message
+		if (bytesRemaining >= (iProcessList[i].iName.Length() + restOfMsgSize))
+		{
+			returnedCount++;
+			bytesRemaining -= (iProcessList[i].iName.Length() + restOfMsgSize);
+		}
+		else
+			break;
+	}
+
+	// add values for returnedCount and totalCount
+	AddToReplyBufferL((TUint32)returnedCount, true);
+	AddToReplyBufferL((TUint32)totalCount);
+
+	for (TInt32 i=aIndex; i<(aIndex + returnedCount); i++)
+	{
+		// add this process info to the buffer
+		AddToReplyBufferL(iProcessList[i].iId);
+		AddToReplyBufferL(iProcessList[i].iPriority);
+		AddToReplyBufferL(iProcessList[i].iName);
+		
+		// host expects the name to be a null terminated string
+		AddToReplyBufferL((TUint8)0);
+	}
+	
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::DoReadThreadListL
+//
+// Return a list of the current threads for a process to the host debugger
+//
+void CTrkDispatchLayer::DoReadThreadListL(TInt32 aIndex)
+{
+	// remove the options - unused
+	iInputBuffer->Des().Delete(0, 1);
+
+	// get the process id
+	TUint32 processId = 0;
+	GetDataFromBufferL(&processId, 4);
+
+	// an index of zero means we start fresh.  and index other than zero means
+	// we were not able to return all of the threads in the last round due to
+	// message size limitations, so we need to pick up where we left off
+	if (aIndex == 0)
+	{
+		DoReBuildThreadList(processId);
+	}
+	
+	TInt32 totalCount = iThreadList.Count();
+	TInt32 returnedCount = 0;
+	TInt32 bytesRemaining = MAXMESSAGESIZE_V2 - 30; // minus the framing bytes
+	TInt32 restOfMsgSize = sizeof(TUint32) // process id
+						 + sizeof(TUint32) // priority
+						 + sizeof(TUint8)  // state
+						 + sizeof(TUint8); // NULL character
+	
+	
+	for (TInt32 i=aIndex; i<totalCount; i++)
+	{
+		// make sure there is enough room left in the message
+		if (bytesRemaining >= (iThreadList[i].iName.Length() + restOfMsgSize))
+		{
+			returnedCount++;
+			bytesRemaining -= (iThreadList[i].iName.Length() + restOfMsgSize);
+		}
+		else
+			break;
+	}
+
+	// add values for returnedCount and totalCount
+	AddToReplyBufferL((TUint32)returnedCount, true);
+	AddToReplyBufferL((TUint32)totalCount);
+
+	for (TInt32 i=aIndex; i<(aIndex + returnedCount); i++)
+	{
+		// add this thread info to the buffer
+		AddToReplyBufferL(iThreadList[i].iId);
+		AddToReplyBufferL(iThreadList[i].iPriority);
+		AddToReplyBufferL(IsThreadSuspended(iThreadList[i].iId));		
+		AddToReplyBufferL(iThreadList[i].iName);
+
+		// host expects the name to be a null terminated string
+		AddToReplyBufferL((TUint8)0);
+	}
+
+	RespondOkL();
+}
+
+//
+// CTrkDispatchLayer::DoReBuildProcessList
+//
+// Build a list of the current processes
+//
+void CTrkDispatchLayer::DoReBuildProcessList()
+{
+	TInt err = KErrNone;
+
+	// reset the process list
+	iProcessList.Reset();
+	
+	// fill up the process list
+	for (TInt i=0; KErrNone==err; i++)
+	{
+		TMetroTrkTaskInfo processInfo(0);
+		err = iKernelDriver.GetProcessInfo(i, processInfo);
+		
+		//Get a Handle to the process
+		RProcess proc;
+		if(KErrNone == err && KErrNone == proc.Open(TProcessId(processInfo.iId)))
+		{			
+			//Only display currently running processes
+			if(EExitPending == proc.ExitType())
+			{
+				iProcessList.Append(processInfo);
+			}
+			proc.Close();
+		}
+	}
+}
+
+//
+// CTrkDispatchLayer::DoReBuildThreadList
+//
+// Build a list of the current threads for a process
+//
+void CTrkDispatchLayer::DoReBuildThreadList(TUint32 aProcessId)
+{
+	TInt err = KErrNone;
+
+	// reset the thread list
+	iThreadList.Reset();
+	
+	// fill up the thread list
+	for (TInt i=0; KErrNone==err; i++)
+	{
+		TMetroTrkTaskInfo threadInfo(aProcessId);
+		err = iKernelDriver.GetThreadInfo(i, threadInfo);
+		
+		//Get a Handle to the thread
+		RThread thread;
+		if(KErrNone == err && KErrNone == thread.Open(TThreadId(threadInfo.iId)))
+		{			
+			//Only display currently running processes
+			if(EExitPending == thread.ExitType())
+			{
+				iThreadList.Append(threadInfo);
+			}
+			thread.Close();
+		}
+	}
+}
+
+// CTrkDispatchLayer::DoNotifyStoppedL
+//
+// Notify the host debugger that a thread has stopped
+//
+// START_PANIC
+//void CTrkDispatchLayer::DoNotifyStoppedL(TUint32 aProcessId, TUint32 aThreadId, TUint32 aCurrentPC, const TDesC8 &aDescription)
+void CTrkDispatchLayer::DoNotifyStoppedL(TUint32 aProcessId, TUint32 aThreadId, TUint32 aCurrentPC, const TDesC8 &aDescription, TBool aAddException, const TUint16 aExceptionNumber)
+// END_PANIC
+{	
+	// add this thread to the suspended threads list
+	iSuspendedThreadList.Append(aThreadId);
+
+//	TUint8 event = (aAddException==true) ? kDSNotifyStopped2 : kDSNotifyStopped;
+	TUint8 event = kDSNotifyStopped;
+	TUint16 descLength = aDescription.Length();
+	
+	AddToReplyBufferL(event, true);
+	AddToReplyBufferL(aCurrentPC);
+	AddToReplyBufferL(aProcessId);
+	AddToReplyBufferL(aThreadId);
+	AddToReplyBufferL(descLength);
+
+	if (descLength)
+	{
+		AddToReplyBufferL(aDescription);
+
+		// host expects the string to be a null terminated string
+		AddToReplyBufferL((TUint8)0);
+	}
+	// START_PANIC
+	if (aAddException)
+		AddToReplyBufferL(aExceptionNumber);
+	// END_PANIC
+	
+	InformEventL();
+}
+
+//
+// CTrkDispatchLayer::DoNotifyProcessDiedL
+//
+// Notify the host debugger that a process has exited
+//
+void CTrkDispatchLayer::DoNotifyProcessDiedL(TUint32 aProcessId, TInt aExitCode)
+{
+	// remove this process from our list
+	for (TInt i=0; i<iDebugProcessList.Count(); i++)
+	{
+		if (iDebugProcessList[i]->ProcessId() == aProcessId)
+		{
+			SafeDelete(iDebugProcessList[i]);
+			iDebugProcessList.Remove(i);
+		}
+	}
+
+	TUint8 event = kDSOSNotifyDeleted;
+	TUint16 type = kDSOSProcessItem;
+
+	AddToReplyBufferL(event, true);
+	AddToReplyBufferL(type);
+	AddToReplyBufferL((TUint32)aExitCode);
+	AddToReplyBufferL(aProcessId);
+
+	InformEventL();
+}
+
+//
+// CTrkDispatchLayer::DoNotifyLibraryLoadedL
+//
+// Notify the host debugger that a library in now loaded
+//
+void CTrkDispatchLayer::DoNotifyLibraryLoadedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId, TUint32 aCodeBaseAddress, TUint32 aDataBaseAddress)
+{
+	TUint8 event = kDSOSNotifyCreated;
+	TUint16 type = kDSOSDLLItem;
+
+	TUint16 nameLength = aName.Length();
+	
+	AddToReplyBufferL(event, true);
+	AddToReplyBufferL(type);
+	AddToReplyBufferL(aProcessId);
+	AddToReplyBufferL(aThreadId);
+	AddToReplyBufferL(aCodeBaseAddress);
+	AddToReplyBufferL(aDataBaseAddress);
+	AddToReplyBufferL(nameLength);
+	AddToReplyBufferL(aName);
+
+	InformEventL();
+}
+
+//
+// CTrkDispatchLayer::DoNotifyLibraryUnloadedL
+//
+// Notify the host debugger that a library has been unloaded
+//
+void CTrkDispatchLayer::DoNotifyLibraryUnloadedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId)
+{
+	TUint8 event = kDSOSNotifyDeleted;
+	TUint16 type = kDSOSDLLItem;
+	
+	TUint16 nameLength = aName.Length();
+	
+	AddToReplyBufferL(event, true);
+	AddToReplyBufferL(type);
+	AddToReplyBufferL(aProcessId);
+	AddToReplyBufferL(aThreadId);
+	AddToReplyBufferL(nameLength);
+	AddToReplyBufferL(aName);
+
+	InformEventL();
+}
+
+//
+// CTrkDispatchLayer::GetDataFromBufferL
+//
+// Notify the host debugger that trace data has been recieved
+//
+void CTrkDispatchLayer::DoNotifyUserTraceL(TDesC8 &aTrace)
+{
+	if (iIsConnected)
+		iFramingLayer->SendRawMsgL(aTrace);
+}
+
+void CTrkDispatchLayer::DoNotifyProcessAddedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId, TUint32 aUid, TUint32 aCodeBaseAddress, TUint32 aDataBaseAddress)
+{
+	// check to see if the host supported protocol handles this event, 
+	// otherwise just resume the thread. If not, this thread would get suspended indefinitely.
+	if (iHostVersion.iMajor < 3 || (iHostVersion.iMajor == 3  && iHostVersion.iMinor <= 3))
+	{
+		iKernelDriver.ResumeThread(aThreadId);				
+	}
+	else
+	{
+		TUint8 event = kDSOSNotifyCreated;
+		TUint16 type = kDSOSProcessItem;
+
+		TUint16 nameLength = aName.Length();
+		
+		AddToReplyBufferL(event, true);
+		AddToReplyBufferL(type);
+		AddToReplyBufferL(aProcessId);
+		AddToReplyBufferL(aThreadId);
+		AddToReplyBufferL(aUid);
+		AddToReplyBufferL(aCodeBaseAddress);
+		AddToReplyBufferL(aDataBaseAddress);
+		AddToReplyBufferL(nameLength);
+		AddToReplyBufferL(aName);
+
+		InformEventL();
+	}
+}
+
+//
+// CTrkDispatchLayer::DoReadLibraryInfoL()
+//
+void CTrkDispatchLayer::DoReadLibraryInfoL(TDesC8& aFileName)
+{
+	TMetroTrkLibInfo libInfo(aFileName.Length(), &aFileName);
+	
+	TInt err = iKernelDriver.GetLibraryInfo(libInfo);
+	
+	if (err == KErrNone)
+	{
+		AddToReplyBufferL(libInfo.iCodeAddress, true);
+		AddToReplyBufferL(libInfo.iDataAddress);
+		AddToReplyBufferL(libInfo.iAttachProcessId);
+		AddToReplyBufferL(libInfo.iAttachThreadId);
+		
+		RespondOkL();
+	}
+	else
+	{
+		User::Leave(err);
+	}			
+}
+
+//
+// CTrkDispatchLayer::DoReadProcessInfoL()
+//
+void CTrkDispatchLayer::DoReadProcessInfoL(TUint32 aUid, TDesC8& aFileName)
+{
+	TMetroTrkExeInfo exeInfo(aUid, aFileName.Length(), &aFileName);
+	
+	TInt err = iKernelDriver.GetExeInfo(exeInfo);
+	
+	if (err == KErrNone)
+	{
+		AddToReplyBufferL(exeInfo.iProcessID, true);
+		AddToReplyBufferL(exeInfo.iThreadID);
+		AddToReplyBufferL(exeInfo.iCodeAddress);
+		AddToReplyBufferL(exeInfo.iDataAddress);
+		
+		RespondOkL();
+	}
+	else
+	{
+		User::Leave(err);
+	}			
+}
+
+//
+// CTrkDispatchLayer::GetDataFromBufferL
+//
+// Get data from the input buffer
+//
+void CTrkDispatchLayer::GetDataFromBufferL(TAny* aData, TInt aLength)
+{
+	if (aLength > iInputBuffer->Length())
+		User::Leave(kDSReplyPacketSizeError);
+		
+	if (iFramingLayer->IsBigEndian())
+	{
+		Mem::Copy(aData, iInputBuffer->Ptr(), aLength);
+	}
+	else
+	{
+		TUint8 *p = (TUint8 *)aData;
+		for (int i=aLength-1, j=0; i>=0; i--, j++)
+			p[j] = iInputBuffer->Ptr()[i];
+	}
+	
+	// now remove it from the buffer
+	iInputBuffer->Des().Delete(0, aLength);
+}
+
+//
+// CTrkDispatchLayer::AddToReplyBufferL
+//
+// Add data to the buffer which will be sent back to the host as a reply
+//
+void CTrkDispatchLayer::AddToReplyBufferL(TUint8 aData, TBool aReset)
+{
+	if (aReset)
+	{
+		// free the memory associated with the old reply buffer and allocate a new one
+		SafeDelete(iReplyBuffer);
+		iReplyBuffer = HBufC8::New(sizeof(TUint8));
+	}
+	else
+	{
+		// reallocate to make enough room for the new data
+		iReplyBuffer = iReplyBuffer->ReAlloc(iReplyBuffer->Length() + sizeof(TUint8));
+	}
+	
+	// make sure the above worked
+	if (!iReplyBuffer)
+		User::Leave(KErrNoMemory);
+	
+	iReplyBuffer->Des().Append(aData);
+}
+
+//
+// CTrkDispatchLayer::AddToReplyBufferL
+//
+// Add data to the buffer which will be sent back to the host as a reply
+//
+void CTrkDispatchLayer::AddToReplyBufferL(TUint16 aData, TBool aReset)
+{
+	TUint16 temp = aData;
+	
+	if (aReset)
+	{
+		// free the memory associated with the old reply buffer and allocate a new one
+		SafeDelete(iReplyBuffer);
+		iReplyBuffer = HBufC8::New(sizeof(TUint16));
+	}
+	else
+	{
+		// reallocate to make enough room for the new data
+		iReplyBuffer = iReplyBuffer->ReAlloc(iReplyBuffer->Length() + sizeof(TUint16));
+	}
+	
+	// make sure the above worked
+	if (!iReplyBuffer)
+		User::Leave(KErrNoMemory);
+	
+	// the host expects all values except for raw data to be returned in big endian format
+	if (!iFramingLayer->IsBigEndian())
+	{
+		temp = Swap2(aData);
+	}
+
+	iReplyBuffer->Des().Append((TUint8 *)&temp, sizeof(TUint16));
+}
+
+//
+// CTrkDispatchLayer::AddToReplyBufferL
+//
+// Add data to the buffer which will be sent back to the host as a reply
+//
+void CTrkDispatchLayer::AddToReplyBufferL(TUint32 aData, TBool aReset)
+{
+	TUint32 temp = aData;
+	
+	if (aReset)
+	{
+		// free the memory associated with the old reply buffer and allocate a new one
+		SafeDelete(iReplyBuffer);
+		iReplyBuffer = HBufC8::New(sizeof(TUint32));
+	}
+	else
+	{
+		// reallocate to make enough room for the new data
+		iReplyBuffer = iReplyBuffer->ReAlloc(iReplyBuffer->Length() + sizeof(TUint32));
+	}
+	
+	// make sure the above worked
+	if (!iReplyBuffer)
+		User::Leave(KErrNoMemory);
+	
+	// the host expects all values except for raw data to be returned in big endian format
+	if (!iFramingLayer->IsBigEndian())
+	{
+		temp = Swap4(aData);
+	}
+
+	iReplyBuffer->Des().Append((TUint8 *)&temp, sizeof(TUint32));
+}
+
+//
+// CTrkDispatchLayer::AddToReplyBufferL
+//
+// Add data to the buffer which will be sent back to the host as a reply
+//
+void CTrkDispatchLayer::AddToReplyBufferL(const TDesC8 &aData, TBool aReset)
+{
+	if (aReset)
+	{
+		// free the memory associated with the old reply buffer and allocate a new one
+		SafeDelete(iReplyBuffer);
+		iReplyBuffer = HBufC8::New(aData.Length());
+	}
+	else
+	{
+		// reallocate to make enough room for the new data
+		iReplyBuffer = iReplyBuffer->ReAlloc(iReplyBuffer->Length() + aData.Length());
+	}
+	
+	// make sure the above worked
+	if (!iReplyBuffer)
+		User::Leave(KErrNoMemory);
+	
+	iReplyBuffer->Des().Append(aData);
+}
+
+//
+// CTrkDispatchLayer::IsThreadSuspended
+//
+// Determines whether or not a thread is suspended
+//
+TUint8 CTrkDispatchLayer::IsThreadSuspended(TUint32 aThreadId)
+{
+	if (iSuspendedThreadList.Find(aThreadId) >= 0)
+		return 1;
+	
+	return 0;
+}
+
+//
+// CTrkDispatchLayer::IsRestrictedFolder
+//
+// Check to see if the path is any of the data caged paths like \sys\ or \private\ or \resource\
+//
+TBool CTrkDispatchLayer::IsRestrictedFolder(const TDesC& aPath)
+{
+	_LIT(KSYS, "\\sys\\");
+	_LIT(KRESOURCE, "\\resource\\");
+	_LIT(KPRIVATE, "\\private\\");
+	
+	if ( (aPath.FindC(KSYS)>=0) || (aPath.FindC(KRESOURCE)>=0) || (aPath.FindC(KPRIVATE)>=0) )
+		return ETrue;
+	
+	return EFalse;
+}
+
+
+TInt CTrkDispatchLayer::CloseCrashLogger()
+{
+    TInt err = KErrNone;
+    
+    //The old mobile crash file name is "d_exc_mc.exe" and the new one is "mc_useragent.exe"    
+    //This is the string that needs to be passed to the RProcess::Open call to get a handle.
+    //The complete process name actually includes the UID info as well.
+    //Instead of hard coding the process name, its better to just 
+    //search for the process and find it that way.      
+    //_LIT16(KCrashLoggerName, "mc_useragent.exe[1020e519]0001");
+    _LIT16(KOldCrashLoggerName, "d_exc_mc*");
+    _LIT16(KCrashLoggerName, "mc_useragent*");
+    
+    err = TerminateProcess(KOldCrashLoggerName);
+    err = TerminateProcess(KCrashLoggerName);
+
+    return err;
+}
+
+TInt CTrkDispatchLayer::TerminateProcess(const TDesC& aProcessName)
+{
+    TFindProcess find(aProcessName);
+    TFullName name; 
+        
+    TInt err = find.Next(name);
+    if (KErrNone == err)
+    {   
+        RProcess process;
+        err = process.Open(find);
+    
+        if (KErrNone == err)
+        {
+            process.Kill(KErrNone);
+        }
+    }
+    return err;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkDispatchLayer.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,365 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKDISPATCHLAYER_H__
+#define __TRKDISPATCHLAYER_H__
+
+#include <f32file.h>
+#include "TrkFramingLayer.h"
+#include "TrkKernelDriver.h"
+
+
+#ifndef __TEXT_SHELL__
+#include <sysutil.h> 
+#include <etel3rdparty.h>
+#endif
+
+#ifdef __OEM_TRK__
+#include "TrkTcbCliSession.h"
+#endif
+
+
+
+//
+// Forward declarations
+//
+class CTrkDispatchLayer;
+class CTrkEngine;
+
+
+//
+// class CExitTrapper
+//
+// Watches to see when a process exists
+//
+class CExitTrapper : public CActive
+{
+public:
+
+	CExitTrapper(CTrkDispatchLayer *aDispatch, TUint32 aProcessId);
+	~CExitTrapper();
+
+	void Watch();
+
+protected:
+
+	void RunL();
+	void DoCancel();
+
+private:
+
+	RProcess iProcess;
+	TUint32 iProcessId;
+	CTrkDispatchLayer *iDispatch;
+};
+
+
+//
+// class CEventTrapper
+//
+// Listens for events like breakpoints, exceptions, panic, and library loads
+//
+class CEventTrapper : public CActive
+{
+public:
+
+	CEventTrapper(CTrkDispatchLayer *aDispatch);
+	~CEventTrapper();
+	void Watch();
+
+protected:
+
+	void RunL();
+	void DoCancel();
+
+private:
+
+	SEventInfo iEventInfo;
+	CTrkDispatchLayer *iDispatch;
+};
+
+
+//
+// class CDebugProcess
+//
+// Represents a process being debugged by the user
+//
+class CDebugProcess : public CBase
+{
+public:
+
+	static CDebugProcess* NewL(CTrkDispatchLayer *aDispatch, TUint32 aProcessId, TUint32 aMainThreadId);
+	~CDebugProcess();
+
+	void ConstructL(CTrkDispatchLayer *aDispatch, TUint32 aProcessId, TUint32 aMainThreadId);
+
+	TUint32 ProcessId() { return iProcessId; }
+
+public:
+	
+	TBool iReadyForLibraryLoadNotification;
+
+private:
+	
+	TUint32 iProcessId;
+	TUint32 iMainThreadId;
+	CExitTrapper *iExitTrapper;
+};
+
+#ifndef __TEXT_SHELL__
+//
+//class CPhoneInfo
+//
+//This class is used  to find the name of the Phone for eg: For Nokia 5800, the phone name is 5800 Music Express
+//
+class CPhoneInfo : public CActive
+{
+private:    
+    
+    CTelephony::TPhoneIdV1 iPhoneIdV1;
+    CTelephony::TPhoneIdV1Pckg iPhoneIdV1Pckg;
+    CTelephony* iTelephony;
+    CPhoneInfo();
+    void ConstructL();
+
+public:
+    static CPhoneInfo* NewL();    
+    void GetPhoneName(CTrkDispatchLayer* aDispatchLayer);
+    ~CPhoneInfo();
+
+private:
+    
+    void RunL();
+    void DoCancel();
+    
+private:
+    CTrkDispatchLayer* iDispatchLayer;
+ 
+};
+
+#endif
+
+//
+// class TCreateProcessData
+//
+// Container class for information related to the creation of a new process
+//
+class TCreateProcessData
+{
+public:
+
+	inline TCreateProcessData()
+				: iProcessId(0),
+				  iMainThreadId(0),
+				  iEntryAddr(0xFFFFFFFF),
+				  iCodeAddr(0xFFFFFFFF),
+				  iDataAddr(0xFFFFFFFF),
+				  iBssAddr(0xFFFFFFFF) {};
+	
+public:
+
+	TUint32 iProcessId;
+	TUint32 iMainThreadId;
+	TUint32 iEntryAddr;
+	TUint32 iCodeAddr;
+	TUint32 iDataAddr;
+	TUint32 iBssAddr;
+};
+
+//
+// class TProtocolVersion
+//
+// Container class for the protocol version
+//
+class TProtocolVersion
+{
+public:
+	inline TProtocolVersion() { };
+	inline TProtocolVersion(TUint8 aMajor, TUint8 aMinor)
+				: iMajor(aMajor), 
+				  iMinor(aMinor) { };
+public:
+	TUint8 iMajor;
+	TUint8 iMinor;	
+};
+
+//
+// class CTrkDispatchLayer
+//
+// Handles messages between the kernel side driver and the framing layer
+//
+class CTrkDispatchLayer : public CBase
+{
+public:
+
+	static CTrkDispatchLayer* NewL(CTrkCommPort *aPort, CTrkEngine* aEngine);
+	~CTrkDispatchLayer();
+
+	void Listen();
+	void StopListening();
+	static void GetVersionInfo(TInt &aMajorVersion, TInt &aMinorVersion, TInt &aMajorAPIVersion, TInt &aMinorAPIVersion, TInt &aBuildNumber);
+	void HandleMsg(const TDesC8& aMsg);
+	
+	TBool IsDebugging() { return iIsConnected; }
+	
+	void UpdatePhoneNameInfo(TDesC16& aPhoneModel);
+	
+private:
+
+	CTrkDispatchLayer();
+	void ConstructL(CTrkCommPort *aPort, CTrkEngine* aEngine);
+
+	void FindPhoneSWVersion();
+	void FindPhoneNameL();
+
+	void DispatchMsgL();
+	void DoConnectL();
+	void DoDisconnectL();
+	void DoVersionsL();
+	void DoVersions2L();
+	void DoVersions3L();
+	void DoHostVersionsL();
+	void DoSupportMaskL();
+	void DoCPUTypeL();
+	void DoReadMemoryL();
+	void DoWriteMemoryL();
+	void DoReadRegistersL();
+	void DoWriteRegistersL();
+	void DoContinueL();
+	void DoStepL();
+	void DoStopL();
+	void DoSetBreakL();
+	void DoClearBreakL();
+	void DoModifyBreakThreadL();
+	void DoCreateItemL();
+	void DoDeleteItemL();
+	void DoReadInfoL();
+	void DoWriteInfoL();
+
+	void DoOpenFileL();
+	void OpenFileL(const TDesC& aFullPath, TUint aMode, TTime& aTime);
+	void DoReadFileL();
+	TInt ReadFileL(TUint16 aLength, TPtr8& aData);
+
+	void DoWriteFileL();
+	void WriteFileL(TDesC8& aData);
+
+	void DoPositionFileL();
+	void PositionFileL(TSeek aSeek, TInt& aOffset);
+
+	void DoCloseFileL();
+	void CloseFileL(const TTime& aModifiedTime);
+
+	void DoInstallFileL();
+	void DoInstallFile2L();
+	
+	void DoGetPhoneSWVersionL();
+	void DoGetPhoneNameL();
+	
+	void DoCreateProcessL(TBool aRun=EFalse);
+	void DoCreateExeL(const TDesC& aPath, const TDesC& aArgs, TCreateProcessData& aData, TBool aRun=EFalse);
+	void DoKillProcessL();
+
+	void DoAttachProcessL(DSOSItemTypes aAttachType=kDSOSProcAttachItem);
+	void DoDetachProcessL();
+	
+	void DoReadProcessListL(TInt32 aIndex);
+	void DoReadThreadListL(TInt32 aIndex);
+	void DoReBuildProcessList();
+	void DoReBuildThreadList(TUint32 aProcessid);
+	
+	void DoNotifyStoppedL(TUint32 aProcessId, TUint32 aThreadId, TUint32 aCurrentPC, const TDesC8 &aDescription, TBool aAddException=false, const TUint16 aExceptionNumber=0);
+	void DoNotifyProcessDiedL(TUint32 aProcessId, TInt aExitCode);
+	void DoNotifyLibraryLoadedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId, TUint32 aCodeBaseAddress, TUint32 aDataBaseAddress);
+	void DoNotifyLibraryUnloadedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId);
+	void DoNotifyUserTraceL(TDesC8 &aTrace);
+	void DoNotifyProcessAddedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId, TUint32 aUid, TUint32 aCodeBaseAddress, TUint32 aDataBaseAddress);
+	void DoReadLibraryInfoL(TDesC8& aFileName);
+	void DoReadProcessInfoL(TUint32 aUid, TDesC8& aFileName);
+
+
+	void GetDataFromBufferL(TAny *aData, TInt aLength);
+	void AddToReplyBufferL(TUint8 aData, TBool aReset = false);
+	void AddToReplyBufferL(TUint16 aData, TBool aReset = false);
+	void AddToReplyBufferL(TUint32 aData, TBool aReset = false);
+	void AddToReplyBufferL(const TDesC8 &aData, TBool aReset = false);
+
+
+	void RespondOkL() 	{ if (iReplyBuffer) iFramingLayer->RespondOkL(*iReplyBuffer); };
+	void InformEventL() { if (iReplyBuffer) iFramingLayer->InformEventL(*iReplyBuffer); };
+	
+	
+	TUint8 IsThreadSuspended(TUint32 aThreadId);
+	TBool IsRestrictedFolder(const TDesC& aPath);
+	TInt CloseCrashLogger();
+	TInt TerminateProcess(const TDesC& aProcessName);
+	
+	void CloseTcbServer();
+private:
+
+	CTrkEngine* iEngine;
+	CTrkFramingLayer *iFramingLayer;
+#ifndef __TEXT_SHELL__
+	CPhoneInfo* iPhoneInfo;
+#endif
+
+	HBufC8 *iInputBuffer;
+	HBufC8 *iReplyBuffer;
+
+#ifndef __TEXT_SHELL__
+	TBuf8 <KSysUtilVersionTextLength> iPhoneVersion;
+    TBuf8 <CTelephony::KPhoneModelIdSize> iPhoneModel;
+#endif
+    
+    enum TFileState
+	{
+		EFileOpened = 0,
+		EFileReading = 1,
+		EFileWriting = 2,
+		EFileClosed = 3,
+		EFileUnknown = -1		
+	};
+	RFile iFile;
+	RFs iFs;
+	TFileState iFileState;
+
+	RPointerArray<CDebugProcess> iDebugProcessList;
+	
+	RArray<TMetroTrkTaskInfo> iProcessList;
+	RArray<TMetroTrkTaskInfo> iThreadList;
+	
+	RArray<TUint> iSuspendedThreadList;
+	
+	CEventTrapper *iEventTrapper;
+		
+	RMetroTrkDriver iKernelDriver;	
+	TBool iIsConnected;
+	
+	TBool iPhoneNameInfoAvailable; 
+
+#ifdef __OEM_TRK__	
+	RTrkTcbCliSession iTrkTcbSession;
+	TBool iUseTcbServer;
+#endif
+	TProtocolVersion iHostVersion;
+
+	friend class CEventTrapper;
+	friend class CExitTrapper;
+};
+
+#endif // __TRKDISPATCHLAYER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkEngine.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,439 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "TrkEngineModel.h"
+#include "TrkEngine.h"
+#ifdef __USE_NEW_DEBUG_API__
+#include "trkdispatchlayer2.h"
+#else
+#include "TrkDispatchLayer.h"
+#endif
+
+#ifndef __NOKIA_TEXT_SHELL__
+#include "TrkSerialCommPort.h"
+#endif
+
+#ifndef __TEXT_SHELL__
+#include "TrkBtSocketCommPort.h"
+#include "TrkUsbPortListener.h"
+#include "TrkDbgTrcCommPort.h"
+#endif //__TEXT_SHELL__
+
+#ifdef __OEM_TRK__	  
+#include "TrkDccCommPort.h"
+
+#ifdef __ENABLE_XTI__
+#include "TrkXtiCommPort.h"
+#endif
+#endif //__OEM_TRK__
+
+
+//
+//
+// CTrkEngine implementation
+//
+//
+
+//
+// CTrkEngine::NewL
+//
+EXPORT_C CTrkEngine* CTrkEngine::NewL()
+{
+	CTrkEngine* self = new(ELeave) CTrkEngine;
+	self->ConstructL();
+	return self;
+}
+
+//
+// CTrkEngine::NewLC
+//
+EXPORT_C CTrkEngine* CTrkEngine::NewLC()
+{
+	CTrkEngine* self = new(ELeave) CTrkEngine;
+	CleanupStack::PushL(self);
+	
+	self->ConstructL();
+	
+	return self;
+}
+
+
+EXPORT_C CTrkEngine* CTrkEngine::NewL(MTrkEngineCallback* aCallback)
+{
+	CTrkEngine* self = new(ELeave) CTrkEngine;
+	self->ConstructL(aCallback);
+	return self;
+}
+
+//
+// CTrkEngine::NewLC
+//
+EXPORT_C CTrkEngine* CTrkEngine::NewLC(MTrkEngineCallback* aCallback)
+{
+	CTrkEngine* self = new(ELeave) CTrkEngine;
+	CleanupStack::PushL(self);
+	
+	self->ConstructL(aCallback);
+	
+	return self;
+}
+
+//
+// CTrkEngine destructor
+//
+CTrkEngine::CTrkEngine()
+:iCommPort(NULL),
+ iDispatchLayer(NULL),
+ iModel(NULL),
+ iCommPortListener(NULL),
+ iInactivityTimerDisabler(NULL),
+ iCallback(NULL),
+ iCurrentConnType(ETrkBt)
+{
+}
+
+//
+// CTrkEngine::ConstructL
+//
+
+void CTrkEngine::ConstructL(MTrkEngineCallback* aCallback)
+{	
+    // make sure the kernel side device driver is not already loaded
+    User::FreeLogicalDevice(KMetroTrkDriverName);
+    // load the kernel side device driver
+#ifndef __WINS__
+    TInt err = User::LoadLogicalDevice(_L("TrkDriver.ldd"));
+    if ((KErrAlreadyExists != err) && (KErrNone != err))
+        User::Leave(err);       
+#endif
+
+	iModel = CTrkEngineModel::NewL();
+	iCallback = aCallback;
+}
+
+//
+// CTrkEngine destructor
+//
+EXPORT_C CTrkEngine::~CTrkEngine()
+{
+    #ifndef __TEXT_SHELL__
+    // if USB connection, then stop the cable listener as well.
+    if (iCurrentConnType == ETrkUsbDbgTrc)
+    {
+    	iCommPortListener->StopListening();
+    }
+	#endif
+    
+    //Unload the driver stuff
+#ifndef __WINS__
+    TInt err = User::FreeLogicalDevice(KMetroTrkDriverName);
+    if (KErrNone != err)
+        User::Panic(_L("FreeLogicalDevice failed"), err);
+#endif
+    
+	SafeDelete(iDispatchLayer);
+	SafeDelete(iModel);
+	SafeDelete(iCommPortListener);	
+	SafeDelete(iInactivityTimerDisabler);
+}
+
+//
+// CTrkEngine::Start
+//
+EXPORT_C void CTrkEngine::StartL()
+{
+	iModel->GetConnData(iCurrentConnData);
+	iCurrentConnType = iCurrentConnData.iConnType;
+	
+	DoStartL();
+}
+
+//
+// CTrkEngine::Start
+//
+EXPORT_C void CTrkEngine::StartL(TTrkConnType aConnType)
+{
+	iModel->GetDefaultConnData(aConnType, iCurrentConnData);
+	iCurrentConnType = iCurrentConnData.iConnType;
+	
+	DoStartL();
+}
+
+//
+// CTrkEngine::Stop
+//
+EXPORT_C void CTrkEngine::Stop()
+{
+	if (iDispatchLayer)
+	{
+		iDispatchLayer->StopListening();	
+		SafeDelete(iDispatchLayer);
+		iCommPort = NULL; //port is deleted by the framing layer
+	}
+}
+
+//
+// CTrkEngine::GetVersionInfo
+//
+EXPORT_C void CTrkEngine::GetVersionInfo(TInt &aMajorVersion, TInt &aMinorVersion, TInt &aMajorAPIVersion, TInt &aMinorAPIVersion, TInt &aBuildNumber)
+{
+	CTrkDispatchLayer::GetVersionInfo(aMajorVersion, aMinorVersion, aMajorAPIVersion, aMinorAPIVersion, aBuildNumber);
+}
+
+//
+// CTrkEngine::GetConnectionInfo
+//
+EXPORT_C void CTrkEngine::GetConnectionInfo(TDes& aMessage)
+{
+	aMessage = KNullDesC;
+	if (iCommPort)
+	{
+		iCommPort->GetConnectionInfo(aMessage);
+	}
+}
+//
+// CTrkEngine::GetConnectionInfo
+//
+EXPORT_C TTrkConnStatus CTrkEngine::GetConnectionStatus()
+{
+    if (iCommPort)
+    {
+        
+        return(iCommPort->GetConnectionStatus());
+    }
+    else
+        return ETrkConnectionError;
+        
+}
+//
+// CTrkEngine::GetErrorInfo
+//
+EXPORT_C void CTrkEngine::GetErrorInfo(TDes& aMessage)
+{
+	if (iCommPort)
+	{
+		iCommPort->GetErrorInfo(aMessage);
+	}
+	else
+	{
+		aMessage = iErrorMessage;
+	}
+}
+
+//
+// CTrkEngine::GetConnectionData
+//
+EXPORT_C void CTrkEngine::GetConnectionData(TTrkConnData& aConnData)
+{
+	iModel->GetConnData(aConnData);
+}
+
+//
+// CTrkEngine::SetConnectionData
+//
+EXPORT_C TInt CTrkEngine::SetConnectionData(TTrkConnData& aConnData)
+{
+	return iModel->SetConnData(aConnData);
+}
+
+//
+// CTrkEngine::IsDebugging
+//
+EXPORT_C TInt CTrkEngine::IsDebugging()
+{
+	if (iDispatchLayer)
+	{
+		return iDispatchLayer->IsDebugging();
+	}
+	return EFalse;
+}
+
+//
+// CTrkEngine::GetConnectionType
+//
+EXPORT_C TTrkConnType CTrkEngine::GetConnectionType()
+{
+    return iCurrentConnType;
+}
+//
+// CTrkEngine::GetPlugPlaySetting()
+//
+EXPORT_C TBool CTrkEngine::GetPlugPlaySetting()
+{
+    TBool PlugPLaySetting;
+    PlugPLaySetting = iModel->GetPlugPlaySettingValue();
+    return PlugPLaySetting;
+    
+}
+//
+// CTrkEngine::DoStartL
+//
+void CTrkEngine::DoStartL()
+{
+	CreateCommInterfaceL();
+
+	// ownership of the comm port is passed down to CTrkFramingLayer
+	iDispatchLayer = CTrkDispatchLayer::NewL(iCommPort, this);
+		
+#ifndef __TEXT_SHELL__		
+	// start listening for the cable connection.	
+	/* not required here as server starts listening
+	 
+	if (iCurrentConnType == ETrkUsbDbgTrc)
+	{
+		if (!iCommPortListener) // create the listener only once
+			iCommPortListener = new CTrkUsbPortListener(this);
+
+		iCommPortListener->ListenL();
+	}
+	*/
+#endif //__TEXT_SHELL__	
+
+	iCommPort->OpenPortL();
+	if (iCommPort->IsConnectionEstablished())
+	{	  
+		iDispatchLayer->Listen();
+	
+		if (iCurrentConnData.iConnType == ETrkBt || iCurrentConnData.iConnType == ETrkSerial)
+			iCommPort->SendDataL(_L8("Trk for Symbian OS started"));
+	}
+
+}
+
+//
+// CTrkEngine::CreateCommInterfaceL
+//
+void CTrkEngine::CreateCommInterfaceL()
+{
+	iCommPort = NULL;
+
+	switch (iCurrentConnData.iCommType)
+	{
+
+	#ifndef __NOKIA_TEXT_SHELL__		
+		case ESerialComm:
+		{
+			iCommPort = CTrkSerialCommPort::NewL(iCurrentConnData, iErrorMessage);
+			break;
+		}
+	#endif
+	
+	#ifndef __TEXT_SHELL__		
+		case EBtSocket:
+		{
+			iCommPort = CTrkBtSocketCommPort::NewL(iCurrentConnData, iErrorMessage, this);			
+			break;
+		}
+		case EDbgTrcComm:
+		{
+			iCommPort = CTrkDbgTrcCommPort::NewL(iCurrentConnData, iErrorMessage);
+			break;
+		}
+	#endif //__TEXT_SHELL__
+		
+	#ifdef __OEM_TRK__	  
+		case EDcc:
+		{
+			iCommPort = CTrkDccCommPort::NewL(iCurrentConnData, iErrorMessage);			
+			break;
+		}
+		
+		#ifdef __ENABLE_XTI__
+		case EXti:
+		{
+			iCommPort = CTrkXtiCommPort::NewL(iCurrentConnData, iErrorMessage);			
+			break;
+		}		
+		#endif
+	#endif //__OEM_TRK__
+	
+		default:
+		{
+			User::Leave(KErrNotFound);
+		}
+	}
+	}
+	
+/*
+ * This is called by when BT socket finds the port and started to listen  
+ * 
+ */
+void CTrkEngine::AsyncConnectionSuccessfulL()
+{
+    iDispatchLayer->Listen();    
+
+    if (iCurrentConnData.iConnType == ETrkBt || iCurrentConnData.iConnType == ETrkSerial)
+        iCommPort->SendDataL(_L8("Trk for Symbian OS started"));
+    
+    if (iCallback)
+			iCallback->OnConnection();
+	}
+
+/*
+ * This is called when PC rejects the connection
+ * 
+ */
+void CTrkEngine::AsyncConnectionFailed()
+{
+    iCallback->OnAsyncConnectionFailed();   
+}
+
+//
+// CTrkEngine::DebuggingStarted
+// Called from the dispatch layer to indicate the start of a debug session
+//
+void CTrkEngine::DebuggingStarted()
+{
+	//start the inactivity timer
+	StartInactivityTimerDisabler();
+	
+	if (iCallback)
+		iCallback->DebuggingStarted();
+}
+
+//
+// CTrkEngine::DebuggingEnded
+// Called from the dispatch layer when a debug session ends.
+//
+void CTrkEngine::DebuggingEnded()
+{	
+	if (iCallback)
+		iCallback->DebuggingEnded();
+	//deactivate inactivity timer
+	SafeDelete(iInactivityTimerDisabler);
+}
+
+// CTrkEngine::StartInactivityTimerDisabler 
+//
+void CTrkEngine::StartInactivityTimerDisabler()
+{	
+	iInactivityTimerDisabler = new(ELeave) CInactivityTimerDisabler;
+    iInactivityTimerDisabler->ConstructL();  
+    iInactivityTimerDisabler->Activate();
+}
+
+//
+// DLL Entry point
+//
+#ifndef EKA2
+TInt E32Dll(TDllReason)
+{
+	return KErrNone;
+}
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkEngine.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKENGINE_H__
+#define __TRKENGINE_H__
+
+#include <e32base.h>
+#include "TrkEngineCallback.h"
+#include "TrkConnectionListener.h"
+#include "TrkCommPortListener.h"
+#include "TrkConnData.h"
+#include "TrkCommPort.h"
+//
+// Forward declarations
+//
+class CTrkFramingLayer;
+class CTrkDispatchLayer;
+class CTrkCommPort;
+class CTrkEngineModel;
+class TTrkConnData;
+
+
+//
+// class CTrkEngine
+//
+// Provides the interface to the Trk engine
+//
+class CTrkEngine : public CBase, public MTrkConnectionListener
+{
+public:
+
+	IMPORT_C static CTrkEngine* NewL();
+	IMPORT_C static CTrkEngine* NewLC();
+	IMPORT_C static CTrkEngine* NewL(MTrkEngineCallback* aCallback);
+	IMPORT_C static CTrkEngine* NewLC(MTrkEngineCallback* aCallback);
+
+	IMPORT_C ~CTrkEngine();
+
+	IMPORT_C void StartL();
+	IMPORT_C void StartL(TTrkConnType aConnType);
+	IMPORT_C void Stop();
+	IMPORT_C void GetVersionInfo(TInt &aMajorVersion, TInt &aMinorVersion, TInt &aMajorAPIVersion, TInt &aMinorAPIVersion, TInt &aBuildNumber);
+	IMPORT_C void GetConnectionInfo(TDes& aMessage);
+	IMPORT_C void GetErrorInfo(TDes& aMessage);
+	IMPORT_C TTrkConnStatus GetConnectionStatus();
+	
+	IMPORT_C void GetConnectionData(TTrkConnData& aConnData);
+	IMPORT_C TInt SetConnectionData(TTrkConnData& aConnData);
+	IMPORT_C TBool IsDebugging();
+	IMPORT_C TTrkConnType GetConnectionType();
+	IMPORT_C TBool GetPlugPlaySetting();
+
+public:
+	// From MTrkConnectionListener
+	void AsyncConnectionSuccessfulL();
+	void AsyncConnectionFailed();
+	
+public:
+	// call backs to dispatch layer
+	void DebuggingStarted();
+	void DebuggingEnded();	
+
+
+private:
+
+private:
+	CTrkEngine();
+	void DoStartL();
+	void CreateCommInterfaceL();
+	void ConstructL(MTrkEngineCallback* aCallback=NULL);
+	void StartInactivityTimerDisabler();
+
+private:
+
+	CTrkCommPort* iCommPort;
+	CTrkDispatchLayer* iDispatchLayer;
+	CTrkEngineModel* iModel;
+	TBuf<KMaxPath> iErrorMessage;
+	
+	CTrkCommPortListener* iCommPortListener;
+	CInactivityTimerDisabler *iInactivityTimerDisabler;
+	MTrkEngineCallback* iCallback;
+	
+	TTrkConnData iCurrentConnData;
+	TTrkConnType iCurrentConnType;
+};
+
+
+#endif // __TRKENGINE_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkEngineCallback.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKENGINECALLBACK_H__
+#define __TRKENGINECALLBACK_H__
+
+/**
+*  Abstract callback interface for TRK engine to call into the app for certain situations.
+*  All callbacks into the app from TRK engine can be added here.
+*/
+class MTrkEngineCallback
+{
+    public:
+
+        /**
+        * Called by TRK engine when a connection is open
+        */
+        virtual void OnConnection() = 0;
+
+        /**
+        * This is called when a connection is closed, this can happen for different reasons.
+        * One of the reasons could be that the user has unplugged 
+        * the USB cable when using the USB connection
+        */
+        virtual void OnCloseConnection() = 0; 
+        
+        /**
+        * Called by TRK engine when a debug session is started
+        */
+        virtual void DebuggingStarted() = 0;
+
+        /**
+        * Called by TRK engine when a debug session ends
+        */
+        virtual void DebuggingEnded() = 0;
+        
+        /*
+         * called when the PC rejects the BT connection 
+         * 
+         */
+        virtual void OnAsyncConnectionFailed() = 0;
+      
+};
+
+#endif //__TRKENGINECALLBACK_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkEngineModel.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,552 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <f32file.h>
+
+#include "TrkEngineModel.h"
+
+
+//
+//
+// CTrkEngineModel implementation
+//
+//
+
+//
+// CTrkEngine::NewL
+//
+CTrkEngineModel* CTrkEngineModel::NewL()
+{
+	CTrkEngineModel* self = new(ELeave) CTrkEngineModel();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+
+}
+
+//
+// CTrkEngineModel::NewLC
+//
+CTrkEngineModel* CTrkEngineModel::NewLC()
+{
+	CTrkEngineModel* self = new(ELeave) CTrkEngineModel();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+}
+//
+// CTrkEngineModel::ConstructL()
+//
+// Second level constructor
+//
+void CTrkEngineModel::ConstructL()
+{ 
+ 
+    if (!iLoaded)
+    {
+        TRAP(iFileReadErr, LoadDataL());
+    
+        if (iFileReadErr != KErrNone)
+        {
+            //something went wrong in reading the ini file, just set the default values
+            iTrkConnData.iCommType = ESerialComm;
+            iTrkConnData.iConnType = ETrkSerial;
+            iTrkConnData.iPDD = KDefaultPDD;
+            iTrkConnData.iLDD = KDefaultLDD;
+            iTrkConnData.iCSY = KDefaultCSY;
+            iTrkConnData.iPortNumber = KDefaultPortNumber;
+            iTrkConnData.iRate = KDefaultRate;
+            iTrkConnData.iPlugPlay = ETrue;
+            
+            iTrkConnData.iDefault = ETrue;
+        }
+    }
+}
+
+//
+// CTrkEngineModel constructor
+//
+CTrkEngineModel::CTrkEngineModel()
+:iLineNumber(0),
+iLoaded(EFalse),
+iFileReadErr(0)
+{
+	iTrkConnData.iPortNumber = KDefaultUsbPortNumber;
+	iTrkConnData.iRate = KDefaultRate;
+}
+
+
+//
+// CTrkEngineModel destructor
+//
+CTrkEngineModel::~CTrkEngineModel()
+{
+
+}
+
+static TUint UintFromDecimalStringL(const TDesC8& aStr)
+{
+	TLex8 lexer(aStr);
+	TUint n;
+	if (lexer.Val(n, EDecimal) != KErrNone || !lexer.Eos())
+	{
+		User::Leave(KErrCorrupt);
+	}
+	return n;
+}
+
+//
+// CTrkEngineModel LoadDataL
+//
+void CTrkEngineModel::LoadDataL()
+{
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+
+	TFindFile findFile(fs);
+	
+	User::LeaveIfError(findFile.FindByDir(KInitFileName, KInitFilePath));
+
+	iInitFilePath = findFile.File();
+	
+	RFile file;
+	User::LeaveIfError(file.Open(fs, iInitFilePath, EFileStreamText|EFileRead));
+
+	iInitFilePath.ZeroTerminate();
+
+	CleanupClosePushL(file);
+
+	TInt size;
+	User::LeaveIfError(file.Size(size));
+	
+	HBufC8 *content = HBufC8::NewLC(size);
+	TPtr8 p(content->Des());
+	
+	User::LeaveIfError(file.Read(p));
+	
+	TLex8 lexer(*content);
+
+	iLineNumber = 1;
+	// skip any white space or blank lines
+	TChar ch = lexer.Peek();
+	while (!lexer.Eos() && (ch.IsSpace() || (ch == '\r') || (ch == '\n')))
+	{
+		lexer.Inc();
+		ch = lexer.Peek();
+	}
+	
+	if (lexer.Eos())
+	{
+		User::Leave(KErrCorrupt);
+	}
+	
+	// mark the token
+	lexer.Mark();
+	
+	lexer.Inc(KSerialComm().Length());
+
+	// the first thing in the init file has to be the comm type ([SERIALCOMM] or [SOCKETCOMM]) or [BTSOCKCOMM]
+	if (lexer.TokenLength() != KSerialComm().Length())
+	{
+		User::Leave(KErrCorrupt);
+	}
+
+	TPtrC8 commType = lexer.MarkedToken();
+
+	if (!commType.Compare(KSerialComm()))
+	{
+		iTrkConnData.iCommType = ESerialComm; //set to serial as the default comm type
+	}
+	else if (!commType.Compare(KDbgTrcComm()))
+	{
+		iTrkConnData.iCommType = EDbgTrcComm;
+		iTrkConnData.iConnType = ETrkUsbDbgTrc;	
+	}
+	else if (!commType.Compare(KBtSocketComm()))
+	{
+		iTrkConnData.iCommType = EBtSocket;
+		iTrkConnData.iConnType = ETrkBt;	
+	}
+	else if (!commType.Compare(KDCCComm()))
+	{
+		iTrkConnData.iCommType = EDcc;
+		iTrkConnData.iConnType = ETrkDcc;	
+	}
+	else if (!commType.Compare(KXTIComm()))
+	{
+		iTrkConnData.iCommType = EXti;
+		iTrkConnData.iConnType = ETrkXti;	
+	}	
+	else
+	{
+		User::Leave(KErrCorrupt);
+	}
+	
+	// skip white space and end of lines
+	ch = lexer.Peek();
+	while (!lexer.Eos() && (ch.IsSpace() || (ch == '\r') || (ch == '\n')))
+	{
+		if (ch == '\n')
+		{
+			iLineNumber++;
+		}
+
+		lexer.Inc();
+		ch = lexer.Peek();
+	}
+
+	// now read in the values
+	while (!lexer.Eos())
+	{
+		// mark the start of the token
+		lexer.Mark();
+
+		// read up to the next white space
+		ch = lexer.Peek();
+		while (!lexer.Eos() && !ch.IsSpace())
+		{
+			lexer.Inc();
+			ch = lexer.Peek();
+		}
+		
+		if (lexer.Eos())
+		{
+			User::Leave(KErrCorrupt);
+		}
+
+		// grab the token	
+		TPtrC8 token = lexer.MarkedToken();
+		
+		// mark the start of the value
+		lexer.SkipSpaceAndMark();
+
+		// read up to the next white space or end of line
+		ch = lexer.Peek();
+		while (!lexer.Eos() && !ch.IsSpace())
+		{			
+			if ((ch == '\r') || (ch == '\n'))
+			{
+				User::Leave(KErrCorrupt);
+			}
+			lexer.Inc();
+			ch = lexer.Peek();
+		}
+		
+		// grab the value
+		TPtrC8 value = lexer.MarkedToken();
+		
+		if (token == KPDD)
+		{
+			iTrkConnData.iPDD.Copy(value);
+		}
+		else if (token == KLDD)
+		{
+			iTrkConnData.iLDD.Copy(value);
+		}
+		else if (token == KCSY)
+		{
+			iTrkConnData.iCSY.Copy(value);
+		}
+		else if (token == KPort)
+		{
+			iTrkConnData.iPortNumber = UintFromDecimalStringL(value);
+		}
+		else if (token == KRate)
+		{
+			iTrkConnData.iRate = UintFromDecimalStringL(value);
+		}
+	    else if (token == KPlugPlay)
+	    {
+	    	iTrkConnData.iPlugPlay = UintFromDecimalStringL(value);
+		}
+		else
+		{
+			User::Leave(KErrCorrupt);
+		}
+
+		// skip white space and end of lines
+		ch = lexer.Peek();
+		while (!lexer.Eos() && (ch.IsSpace() || (ch == '\r') || (ch == '\n')))
+		{
+			if (ch == '\n')
+			{
+				iLineNumber++;
+			}
+
+			lexer.Inc();
+			ch = lexer.Peek();
+		}
+	}
+		
+	
+	//if the comm type is serial, the actual conn type could be USB or IR
+	if (iTrkConnData.iCommType == ESerialComm)
+	{		
+		TBuf8<32> csyModule;
+		csyModule.Copy(iTrkConnData.iCSY);
+		csyModule.UpperCase();
+		
+		if (csyModule == KDefaultUsbCSY)
+		{
+			iTrkConnData.iConnType = ETrkUsb;	
+		}
+		else if(csyModule == KDefaultIrCSY)
+		{
+			iTrkConnData.iConnType = ETrkIr;	
+		}
+		else
+		{
+			iTrkConnData.iConnType = ETrkSerial;	
+		}
+	}
+		
+	
+	iTrkConnData.iDefault = EFalse;
+	
+	iLoaded = ETrue; //read only once from the file system.
+	
+	CleanupStack::PopAndDestroy(content);
+	CleanupStack::PopAndDestroy(); // file
+	CleanupStack::PopAndDestroy(); // fs
+}
+
+//
+// CTrkEngineModel SaveDataL
+//
+void CTrkEngineModel::SaveDataL()
+{
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+
+//	RFile file;
+//	User::LeaveIfError(file.Open(fs, iInitFilePath, EFileStreamText|EFileRead|EFileWrite));
+//	CleanupClosePushL(file);
+	RFile file;
+	
+	if (!iInitFilePath.Size())
+	{
+		iInitFilePath = KInitFilePath;
+		iInitFilePath.Append(KInitFileName);
+	}
+	
+	//check to this if the file is in ROM, 
+	//If so, save it in C drive as Trk looks for the ini file in C drive first
+	if (iInitFilePath[0] == 'z' || iInitFilePath[0] == 'Z')
+	{
+		iInitFilePath[0] = 'C';
+	}
+
+	TInt err = file.Replace(fs, iInitFilePath, EFileStreamText|EFileWrite);
+	if (err != KErrNone)
+	{
+		User::LeaveIfError(file.Create(fs, iInitFilePath, EFileStreamText|EFileWrite));
+	}
+	CleanupClosePushL(file);
+
+	TBuf8<1024> fileBuf;
+	TBuf<25> buf;
+	if (iTrkConnData.iCommType == ESerialComm)
+	{	
+		fileBuf.Copy(KSerialComm);
+		fileBuf.Append(KNewLine);
+			
+		//write PDD info		
+		fileBuf.Append(KPDD);
+		fileBuf.Append(KSpace);
+		fileBuf.Append(iTrkConnData.iPDD);
+		fileBuf.Append(KNewLine);
+
+		//write LDD
+		fileBuf.Append(KLDD);
+		fileBuf.Append(KSpace);
+		fileBuf.Append(iTrkConnData.iLDD);
+		fileBuf.Append(KNewLine);
+				
+		//write CSY
+		fileBuf.Append(KCSY);
+		fileBuf.Append(KSpace);
+		fileBuf.Append(iTrkConnData.iCSY);
+		fileBuf.Append(KNewLine);
+
+		//write port number
+		_LIT(KPortSetting, "PORT %d\r\n");
+		buf.Format(KPortSetting, iTrkConnData.iPortNumber); 	
+		fileBuf.Append(buf);
+	
+		//write baud rate
+		_LIT(KRateSetting, "RATE %d");
+		buf.Format(KRateSetting, iTrkConnData.iRate); 	
+		fileBuf.Append(buf);
+		fileBuf.Append(KNewLine);
+		//fileData8.Copy(fileData16);
+	}
+	else if (iTrkConnData.iCommType == EDbgTrcComm)
+	{
+		fileBuf.Copy(KDbgTrcComm);
+		fileBuf.Append(KNewLine);
+
+		//write port number
+		_LIT(KPortSetting, "PORT %d\r\n");
+		buf.Format(KPortSetting, iTrkConnData.iPortNumber); 	
+		fileBuf.Append(buf);
+	
+		//write baud rate
+		_LIT(KRateSetting, "RATE %d");
+		buf.Format(KRateSetting, iTrkConnData.iRate); 	
+		fileBuf.Append(buf);
+		fileBuf.Append(KNewLine);
+	}
+	else if (iTrkConnData.iCommType == EBtSocket)
+	{
+		fileBuf.Copy(KBtSocketComm);
+		fileBuf.Append(KNewLine);
+
+		//write port number
+		_LIT(KPortSetting, "PORT %d\r\n");
+		buf.Format(KPortSetting, iTrkConnData.iPortNumber); 	
+		fileBuf.Append(buf);
+	
+		//write baud rate
+		_LIT(KRateSetting, "RATE %d");
+		buf.Format(KRateSetting, iTrkConnData.iRate); 	
+		fileBuf.Append(buf);
+		fileBuf.Append(KNewLine);		
+	}
+	else if(iTrkConnData.iCommType == EDcc)
+	{
+		fileBuf.Copy(KDCCComm);
+		fileBuf.Append(KNewLine);
+
+		//write LDD
+		fileBuf.Append(KLDD);
+		fileBuf.Append(KSpace);
+		fileBuf.Append(KTrkDCCLDD);	
+		fileBuf.Append(KNewLine);
+
+		//write port number
+		_LIT(KPortSetting, "PORT %d\r\n");
+		buf.Format(KPortSetting, KDefaultDCCPort); 	
+		fileBuf.Append(buf);
+		fileBuf.Append(KNewLine);		
+	}
+	else if(iTrkConnData.iCommType == EXti)
+	{
+		fileBuf.Copy(KXTIComm);
+		fileBuf.Append(KNewLine);
+
+		//write LDD
+		fileBuf.Append(KLDD);
+		fileBuf.Append(KSpace);
+		fileBuf.Append(KTrkXTILDD);	
+		fileBuf.Append(KNewLine);
+	}
+	else
+	{
+		User::Leave(KErrCorrupt);
+	}
+	
+    _LIT(KPlugPlaySetting, "PlugPlay %d");
+    buf.Format(KPlugPlaySetting, iTrkConnData.iPlugPlay);   
+    fileBuf.Append(buf);
+	
+	file.Write(fileBuf);
+	file.Flush();
+	
+	CleanupStack::PopAndDestroy(); // file
+	CleanupStack::PopAndDestroy(); // fs
+}
+
+//
+// CTrkEngineModel GetConnData
+//
+TInt CTrkEngineModel::GetConnData(TTrkConnData& aTrkConnData)
+{
+   
+	aTrkConnData = iTrkConnData;
+	return iFileReadErr;
+}
+
+//
+// CTrkEngineModel GetDefaultConnData
+//
+TInt CTrkEngineModel::GetDefaultConnData(TTrkConnType aConnType, TTrkConnData& aTrkConnData)
+{
+	switch (aConnType)
+	{
+		case ETrkUsbDbgTrc:
+		{		
+			aTrkConnData.iCommType = EDbgTrcComm;
+			aTrkConnData.iConnType = ETrkUsbDbgTrc;
+			aTrkConnData.iPDD.Copy(KDefaultUsbPDD);
+			aTrkConnData.iLDD.Copy(KDefaultUsbLDD);
+			aTrkConnData.iCSY.Copy(KDefaultUsbCSY);
+			aTrkConnData.iPortNumber = KDefaultUsbPortNumber;
+			aTrkConnData.iRate = KDefaultRate;		
+			aTrkConnData.iPlugPlay = iTrkConnData.iPlugPlay;
+			aTrkConnData.iDefault = ETrue;	
+		
+			return KErrNone;
+		}
+		case ETrkXti:
+		{
+            aTrkConnData.iCommType = EXti;
+            aTrkConnData.iConnType = ETrkXti;
+            aTrkConnData.iPDD.Copy(KNullDesC);
+	        aTrkConnData.iLDD.Copy(KTrkXTILDD);
+	        aTrkConnData.iCSY.Copy(KNullDesC);
+	       // aTrkConnData.iPortNumber = KDefaultUsbPortNumber;
+	       // aTrkConnData.iRate = KDefaultRate;      
+	        aTrkConnData.iPlugPlay = ETrue; 
+			aTrkConnData.iDefault = ETrue;	
+			aTrkConnData.iPlugPlay = iTrkConnData.iPlugPlay;
+		
+			return KErrNone;
+		}
+		default:
+		{
+			return KErrNotFound;	
+		}
+	}	
+}
+
+//
+// CTrkEngineModel SaveDataL
+//
+TInt CTrkEngineModel::SetConnData(TTrkConnData& aTrkConnData)
+{
+	iTrkConnData = aTrkConnData;
+	
+	TRAPD(err, SaveDataL());
+	
+	return err;
+}
+
+//
+// CTrkEngineModel::GetPlugPlaySettingValue()
+//
+
+TBool CTrkEngineModel::GetPlugPlaySettingValue()
+{
+    if(iTrkConnData.iPlugPlay)
+        return ETrue;
+    else
+        return EFalse;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkEngineModel.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKENGINEMODEL_H__
+#define __TRKENGINEMODEL_H__
+
+#include <e32base.h>
+#include "TrkConnData.h"
+
+//
+// class CTrkEngineModel
+//
+// Provides the interface to the Trk engine data
+//
+class CTrkEngineModel : public CBase
+{
+public:
+
+	static CTrkEngineModel* NewL();
+	static CTrkEngineModel* NewLC();
+	~CTrkEngineModel();
+	
+	void LoadDataL();
+	void SaveDataL();
+	
+	TInt GetDefaultConnData(TTrkConnType aConnType, TTrkConnData& aTrkConnData);
+	TInt GetConnData(TTrkConnData& aTrkConnData);
+	TInt SetConnData(TTrkConnData& aTrkConnData);
+	TBool GetPlugPlaySettingValue();
+		
+private:
+	TTrkConnData iTrkConnData;	
+	TBuf<KMaxFullName> iInitFilePath;
+	TInt iLineNumber;
+	TBool iLoaded;
+	TInt iFileReadErr;
+private:
+	CTrkEngineModel();
+	void    ConstructL();
+
+};
+
+#endif // __TRKENGINEMODEL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkEngine_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+macro 	__OEM_TRK__
+macro	__S60__
+macro   __ENABLE_XTI__
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+TARGET		TrkEngine.dll
+TARGETTYPE	dll
+UID		0x00000000 0x200159D9
+
+VENDORID VID_DEFAULT
+CAPABILITY ALL -TCB -DRM
+
+SOURCEPATH	.
+
+SOURCE		TrkEngine.cpp TrkDispatchLayer.cpp TrkFramingLayer.cpp
+SOURCE		TrkSerialCommPort.cpp TrkBtSocketCommPort.cpp TrkDccCommPort.cpp DateTimeConverter.cpp
+SOURCE 		TrkEngineModel.cpp TrkUsbPortListener.cpp TrkXtiCommPort.cpp TrkDbgTrcCommPort.cpp
+SOURCE		TrkSwInstall.cpp TrkSwInstUIHandler.cpp
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+SOURCEPATH	..\tcbclient
+#else
+SOURCEPATH	../tcbclient
+#endif
+SOURCE		TrkTcbCliSession.cpp TrkTcbClientUtils.cpp TrkTcbClientDefs.cpp
+
+
+LIBRARY	efsrv.lib euser.lib c32.lib sishelper.lib
+LIBRARY eikcoctl.lib
+LIBRARY	esock.lib
+LIBRARY bluetooth.lib
+LIBRARY btextnotifiers.lib
+LIBRARY btmanclient.lib
+LIBRARY sdpagent.lib
+LIBRARY sdpdatabase.lib 
+LIBRARY	charconv.lib
+LIBRARY	flogger.lib
+LIBRARY SWInstCli.lib
+LIBRARY usbman.lib
+LIBRARY usbostcomm.lib
+LIBRARY sysutil.lib 
+LIBRARY	etel3rdparty.lib 
+
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+  	SYSTEMINCLUDE	\epoc32\include
+  	USERINCLUDE	..\dccdriver
+	USERINCLUDE	..\eka2driver
+	USERINCLUDE	..\tcbclient
+	USERINCLUDE	..\tcbserver
+	USERINCLUDE	..\xtidriver
+	
+	#if defined(WINS)
+    deffile .\trkengU_win.def
+	#elif defined(EABI)
+	    deffile ..\eabi\trkengine_s60.def
+	#endif
+
+#else
+    MW_LAYER_SYSTEMINCLUDE
+    USERINCLUDE	../dccdriver
+	USERINCLUDE	../eka2driver
+	USERINCLUDE	../tcbclient
+	USERINCLUDE	../tcbserver
+	USERINCLUDE	../xtidriver
+	
+	#if defined(WINS)
+    deffile ./trkengU_win.def
+	#elif defined(EABI)
+	    deffile ../eabi/trkengine_s60.def
+	#endif
+
+#endif
+
+nostrictdef
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkEngine_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+macro 		__OEM_TRK__
+
+TARGET		TrkEngine.dll
+TARGETTYPE	dll
+UID		0x00000000 0x200159D9
+
+VENDORID 0x101FB657
+CAPABILITY ALL -TCB -DRM
+
+SOURCEPATH	.
+
+SOURCE		TrkEngine.cpp TrkDispatchLayer.cpp TrkFramingLayer.cpp TrkEngineModel.cpp
+SOURCE		TrkSerialCommPort.cpp TrkDccCommPort.cpp DateTimeConverter.cpp TrkUsbPortListener.cpp
+SOURCE		TrkBtSocketCommPort.cpp TrkDbgTrcCommPort.cpp
+SOURCE		TrkSwInstall.cpp TrkSwInstUIHandler.cpp
+
+SOURCEPATH	..\tcbclient
+SOURCE		TrkTcbCliSession.cpp TrkTcbClientUtils.cpp TrkTcbClientDefs.cpp
+
+LIBRARY		efsrv.lib euser.lib c32.lib usbman.lib sishelper.lib
+LIBRARY		esock.lib bluetooth.lib btextnotifiers.lib btmanclient.lib sdpagent.lib sdpdatabase.lib 
+LIBRARY 	usbostcomm.lib
+LIBRARY		sysutil.lib 
+LIBRARY		etel3rdparty.lib 
+
+SYSTEMINCLUDE	\epoc32\include
+
+
+USERINCLUDE	. 
+USERINCLUDE	..\dccdriver
+USERINCLUDE	..\eka2driver
+USERINCLUDE	..\tcbclient
+USERINCLUDE	..\tcbserver
+
+
+
+#if defined(WINS)
+    deffile .\trkengU_win.def
+#elif defined(EABI)
+    deffile ..\eabi\trkengine_tv.def
+#endif
+nostrictdef
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkFramingLayer.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,514 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "TrkFramingLayer.h"
+
+#ifdef __USE_NEW_DEBUG_API__
+#include "trkdispatchlayer2.h"
+#else
+#include "TrkDispatchLayer.h"
+#endif
+
+#include "serframe.h"
+
+_LIT8(kPPP_FLAG, "~");
+_LIT8(kPPP_ESCAPE, "}");
+
+
+//
+//
+// CTrkFramingLayer implementation
+//
+//
+
+//
+// CTrkFramingLayer constructor
+//
+CTrkFramingLayer::CTrkFramingLayer(CTrkCommPort* aPort)
+	: iPort(aPort),
+	  iFramingState(CTrkFramingLayer::eWaiting),
+	  iEscape(0),
+	  iFCS(0),
+	  iSequenceId(0),
+	  iOutSequenceId(1)
+{
+	// check the target endianness
+	TUint32	test;
+	TUint8 *byte_alias = (TUint8 *)&test;
+	
+	// Write a specific 4-byte sequence and then read it as
+	// a 32-bit word.  Big-endian systems yield one value and
+	// little-endian systems yield another.
+	
+	byte_alias[ 0 ] = 0x12;
+	byte_alias[ 1 ] = 0x34;
+	byte_alias[ 2 ] = 0x56;
+	byte_alias[ 3 ] = 0x78;
+	
+	if (test == 0x12345678)
+		iIsBigEndian = ETrue;
+	else
+		iIsBigEndian = EFalse;
+}
+
+//
+// CTrkFramingLayer destructor
+//
+CTrkFramingLayer::~CTrkFramingLayer()
+{
+	if (iPort)
+	{
+		iPort->ClosePort();
+		SafeDelete(iPort);
+	}
+	
+	SafeDelete(iLastReply);
+}
+
+//
+// CTrkFramingLayer::Listen
+//
+// Start listening for incoming messages from the host debugger
+//
+void CTrkFramingLayer::Listen(CTrkDispatchLayer *aDispatchLayer)
+{
+	// Start listening asynchronously for incoming messages
+	iDispatchLayer = aDispatchLayer;
+	
+	iPort->Listen(this);
+}
+
+//
+// CTrkFramingLayer::StopListening
+//
+// Stop listening for incoming messages from the host debugger
+//
+void CTrkFramingLayer::StopListening()
+{
+	iDispatchLayer = 0;
+	iPort->StopListening();
+}
+
+//
+// CTrkFramingLayer::HandleByte
+//
+// Handle a single incoming byte with a state machine 
+//
+void CTrkFramingLayer::HandleByte(TUint8 aByte)
+{
+	// discard existing escape if needed
+	if (iFramingState != eInFrame)
+		iEscape = EFalse;
+
+	// handle state machine
+	switch (iFramingState)
+	{
+		case eWaiting:
+		{
+			// Start of a new packet
+			if (PPP_FLAG == aByte)
+			{
+				iFCS = PPPINITFCS;
+				iFramingState = eFound;	// next state
+			}
+			break;
+		}
+			
+		case eFound:
+		{
+			if (PPP_FLAG == aByte)  // discard multiple flags
+				break;
+	
+			iFramingState = eInFrame;
+
+			// fall through to eInFrame, receive first char
+		}
+					
+		case eInFrame:
+		{
+			if (PPP_FLAG == aByte)
+			{
+				if (iEscape)
+				{
+					// [..., escape, flag] is bad frame; drop it
+					// send a NAK with the error.
+					RespondErr(kDSReplyNAK, kDSReplyEscapeError);
+					
+					// clear the buffer
+					DiscardFrame();
+				}
+				else
+				{
+					// normal case, good packet
+					if (ProcessFrame())
+					{
+						iDispatchLayer->HandleMsg(iBuffer);
+					}
+						
+					// now start all over again
+					DiscardFrame();
+				}
+				break;
+			}
+			else if (iEscape)
+			{
+				aByte ^= PPP_TRANS;		// change character to new code
+				iEscape = EFalse;		// no longer escaped character
+			}
+			else if (PPP_ESCAPE == aByte)
+			{
+				iEscape = ETrue;		// next character is escaped
+				break;
+			}
+
+			// make sure our buffer is not full
+			if (iBuffer.Length() == iBuffer.MaxLength())
+			{
+				// overflow.  send out a NAK immediately.  go into an overflow state
+				// which will wait for the end of the packet.
+				RespondErr(kDSReplyNAK, kDSReplyOverflow);
+
+				iFramingState = eFrameOverflow;
+				break;
+			}
+							
+			// append byte to buffer and compute running FCS (checksum)
+			iBuffer.Append(aByte);
+
+			iFCS = PPPFCS(iFCS, aByte);
+			break;
+		}
+		
+		case eFrameOverflow:
+		{
+			// overflow occurred.  throw away all characters and wait for a flag
+			if (PPP_FLAG == aByte)
+			{
+				DiscardFrame();
+			}
+			break;
+		}
+			
+		default:
+		{
+			User::Panic(_L("Invalid Framing State"), __LINE__);
+			break;
+		}
+	}
+}
+
+//
+// CTrkFramingLayer::RespondOkL
+//
+// Send an ACK to the host debugger
+//
+void CTrkFramingLayer::RespondOkL(const TDesC8& aMsg)
+{
+	// compose the standard ACK message
+	TBuf8<3> reply;
+	reply.Zero();
+	
+	reply.Append(kDSReplyACK);
+	reply.Append(iSequenceId);
+	reply.Append(kDSReplyNoError);
+
+	// now append the rest of the response if necessary
+	HBufC8 *ack = HBufC8::NewLC(aMsg.Length() + 3);
+	ack->Des().Copy(aMsg.Ptr(), aMsg.Length());
+
+	TPtr8 ptr(ack->Des());
+	ptr.Insert(0, reply);
+
+	// send it out
+	TUint ackTries = 3;
+	TInt leaveCode = KErrGeneral;
+	
+	do
+	{
+		TRAP(leaveCode, SendMsgL(*ack));
+		ackTries--;
+	} while ((leaveCode != KErrNone) && ackTries > 0);
+	
+	// now increment the sequence id
+	IncrementSequenceId();
+
+	// save this in case we need to resend it
+	SafeDelete(iLastReply);
+	iLastReply = ack->Des().AllocL();
+	
+	CleanupStack::PopAndDestroy(ack);
+}
+
+//
+// CTrkFramingLayer::RespondErr
+//
+// Send an NAK to the host debugger
+//
+void CTrkFramingLayer::RespondErr(TUint8 aType, TUint8 aErr)
+{
+	// compose the standard NAK message
+	TBuf8<3> ack;
+	TUint ackTries = 3;
+	TInt leaveCode = KErrGeneral;
+	
+	ack.Zero();
+	ack.Append(aType);	
+	ack.Append(iSequenceId);
+	ack.Append(aErr);
+
+	// send it out
+	do
+	{
+		TRAP(leaveCode, SendMsgL(ack));
+		ackTries--;
+	} while ((leaveCode != KErrNone) && ackTries > 0);
+
+	if (kDSReplySequenceMissing != aErr)
+	{
+		// now increment the sequence id
+		IncrementSequenceId();
+	}
+	
+	// save this in case we need to resend it
+	SafeDelete(iLastReply);
+	iLastReply = ack.Alloc();
+	
+	if (!iLastReply)
+		User::Panic(_L("Failed to allocate reply buffer"), __LINE__);
+}
+
+//
+// CTrkFramingLayer::InformEventL
+//
+// Queue up an event on the target
+//
+void CTrkFramingLayer::InformEventL(const TDesC8& aMsg)
+{
+	// compose the message
+	TBuf8<1> id;
+	id.Zero();
+	id.Append(iOutSequenceId);
+	IncrementOutSequenceId();
+
+	HBufC8 *msg = HBufC8::NewLC(aMsg.Length() + 1);
+	msg->Des().Copy(aMsg.Ptr(), aMsg.Length());
+
+	TPtr8 ptr(msg->Des());
+	ptr.Insert(1, id);
+
+	// now send it out
+	TUint ackTries = 3;
+	TInt leaveCode = KErrGeneral;
+
+	do
+	{
+		TRAP(leaveCode, SendMsgL(*msg));
+		ackTries--;
+	} while ((leaveCode != KErrNone) && ackTries > 0);
+
+	CleanupStack::PopAndDestroy(msg);
+	
+	if (leaveCode != KErrNone)
+		User::Leave(leaveCode);
+}
+
+//
+// CTrkFramingLayer::SendRawMsgL
+//
+// Frames a message and sends it back to the host debugger
+//
+void CTrkFramingLayer::SendRawMsgL(const TDesC8& aMsg)
+{
+	iPort->SendDataL(aMsg);
+}
+
+
+//
+// CTrkFramingLayer::SendMsgL
+//
+// Frames a message and sends it back to the host debugger
+//
+void CTrkFramingLayer::SendMsgL(const TDesC8& aMsg)
+{
+	FCSType fcs;
+	FCSType acc;
+
+	// allocate room for this message with ample space for escape sequences and framing
+	HBufC8 *msg = HBufC8::NewLC(aMsg.Length() + 100);
+
+	TPtr8 ptr(msg->Des());
+
+	// walk through buffer, computing frame check sequence
+	// (checksum).
+	
+	fcs = PPPINITFCS;
+	
+	for (TInt i=0; i<aMsg.Length(); i++)
+		fcs = PPPFCS(fcs, aMsg[i]);
+
+	fcs = fcs ^ PPPCOMPFCS;		// finish by complementing
+	
+	// send bytes out the comm channel:
+	//	[0x7E (frame flag)] [...data...] [FCS:8 or FCS:16 or FCS:32] [0x7E (frame flag)]
+	 
+	// FLAG
+	ptr.Append(kPPP_FLAG);
+					
+	// DATA
+	TBuf8<1> byte;
+	
+	for (TInt i=0; i<aMsg.Length(); i++)
+	{
+		byte.Zero();
+		byte.Append(aMsg[i]);
+		
+		// escape if necessary
+		if (byte[0] == PPP_FLAG || byte[0] == PPP_ESCAPE)
+		{
+			ptr.Append(kPPP_ESCAPE);
+			byte[0] ^= PPP_TRANS;
+		}
+		
+		ptr.Append(byte);
+	}
+	
+	// FCS always goes out in little endian (LSB, ... , MSB) order	
+	acc = fcs;		// accumulator
+	
+	TInt fcsSize = sizeof(FCSType);
+	
+	for (TInt i=0; i<fcsSize; i++)
+	{
+		byte.Zero();
+		byte.Append(acc & 0xFF);
+
+		acc >>= 8;
+
+		// escape if necessary
+		if (byte[0] == PPP_FLAG || byte[0] == PPP_ESCAPE)
+		{
+			ptr.Append(kPPP_ESCAPE);
+			byte[0] ^= PPP_TRANS;
+		}
+		
+		ptr.Append(byte);
+	}
+	
+	// FLAG	
+	ptr.Append(kPPP_FLAG);
+	
+	iPort->SendDataL(*msg);
+	
+	CleanupStack::PopAndDestroy(msg);
+}
+
+//
+// CTrkFramingLayer::DiscardFrame
+//
+// Trash the existing message and reset the state machine 
+//
+void CTrkFramingLayer::DiscardFrame()
+{
+	iBuffer.Zero();
+	iFramingState = eWaiting;
+}
+
+//
+// CTrkFramingLayer::ProcessFrame
+//
+// Checks a complete message for correct format
+//
+TBool CTrkFramingLayer::ProcessFrame()
+{
+	// the buffer contains data in the following form:
+	//		[data] [FCS8]
+	//	or:
+	//		[data] [FCS16]
+	//	or:
+	//		[data] [FCS32]
+	//	
+	//	where data is arbitrary length and FCSxx is 1, 2 or 4 bytes
+
+	TInt minSize = 2 + sizeof(FCSType);
+	
+	if (iBuffer.Length() < minSize)
+	{
+		// data received is too short
+		RespondErr(kDSReplyNAK, kDSReplyPacketSizeError);
+		DiscardFrame();
+		return EFalse;
+	}
+	
+	// check for FCS
+	if (PPPGOODFCS != iFCS)
+	{
+		// bad checksum (FCS)		
+		RespondErr(kDSReplyNAK, kDSReplyBadFCS);
+		DiscardFrame();
+		return EFalse;
+	}
+	
+	// make sure the sequence id is correct, then increment
+	if (iBuffer[TRK_MSG_SID_INDEX] == 0)
+	{
+		// special case - resets both sequence ids
+		iSequenceId = 0;
+		iOutSequenceId = 1;		
+	}
+	else
+	{
+		// see which id we're dealing with
+		if ((iBuffer[0] != kDSReplyACK) && (iBuffer[0] != kDSReplyNAK))
+		{
+			// a command from the host 
+			if (iBuffer[TRK_MSG_SID_INDEX] == iSequenceId)
+			{
+				// got the expected sequence id - do nothing
+			}
+			else if (iBuffer[TRK_MSG_SID_INDEX] == (iSequenceId - 1))
+			{
+				// we need to resend the last reply
+				TUint ackTries = 3;
+				TInt leaveCode = KErrGeneral;
+
+				do
+				{
+					TRAP(leaveCode, SendMsgL(*iLastReply));
+					ackTries--;
+				} while ((leaveCode != KErrNone) && ackTries > 0);
+
+				return EFalse;
+			}
+			else
+			{
+				// bad sequence id
+				RespondErr(kDSReplyNAK, kDSReplySequenceMissing);
+				DiscardFrame();
+				return EFalse;
+			}
+		}
+	}
+
+	// trim back packet, eliminating FCS
+	iBuffer.Delete(iBuffer.Length()-1, 1);
+
+	// remove sequence id
+	iBuffer.Delete(1, 1);
+	
+	return ETrue;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkFramingLayer.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKFRAMINGLAYER_H__
+#define __TRKFRAMINGLAYER_H__
+
+#include "TrkCommPort.h"
+
+//
+// Forward declarations
+//
+class CTrkDispatchLayer;
+
+
+//
+// class CTrkFramingLayer
+//
+// Frames outgoing messages to the host and unframes incoming messages
+// from the host
+//
+class CTrkFramingLayer : public CBase
+{
+public:
+
+	enum TFramingState
+	{
+		eWaiting,
+		eFound,
+		eInFrame,
+		eFrameOverflow
+	};
+
+	CTrkFramingLayer(CTrkCommPort* aPort);
+	~CTrkFramingLayer();
+
+	void Listen(CTrkDispatchLayer* aDispatchLayer);
+	void StopListening();
+
+	void HandleByte(TUint8 aByte);
+
+	void RespondOkL(const TDesC8& aMsg);
+	void RespondErr(TUint8 aType, TUint8 aErr);
+	void InformEventL(const TDesC8& aMsg);
+	void SendRawMsgL(const TDesC8& aMsg);
+	
+	TBool IsBigEndian() { return iIsBigEndian; };
+	void ResetSequenceIDs() { iSequenceId = 1; iOutSequenceId = 1; };
+
+private:
+
+	void SendMsgL(const TDesC8& aMsg);
+
+	void DiscardFrame();
+	TBool ProcessFrame();
+
+	void IncrementSequenceId() { if (iSequenceId == 0xFF) iSequenceId = 1; else iSequenceId++; };
+	void IncrementOutSequenceId() { if (iOutSequenceId == 0xFF) iOutSequenceId = 1; else iOutSequenceId++; };
+
+private:
+
+	CTrkCommPort* iPort;
+	CTrkDispatchLayer* iDispatchLayer;
+
+	TFramingState iFramingState;
+	TBool iEscape;
+	TUint8 iFCS;
+
+	TBuf8<MAXMESSAGESIZE> iBuffer;	// contains the incoming messages
+	TUint8 iSequenceId;
+	TUint8 iOutSequenceId;
+		
+	TBool iIsBigEndian;
+	
+	HBufC8* iLastReply;
+};
+
+#endif // __TRKFRAMINGLAYER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkSerialCommPort.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,444 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <e32cons.h>
+#include <f32file.h>
+
+#include "TrkEngineModel.h"
+#include "TrkSerialCommPort.h"
+#include "TrkFramingLayer.h"
+
+
+//
+// Static helper functions
+//
+static void BuildPortName(const TDesC& aModuleName, TUint aUnit, TDes& aCompleteName)
+{
+	aCompleteName.Zero();
+	aCompleteName.Append(aModuleName);
+	aCompleteName.AppendFill(':', 2);
+	aCompleteName.AppendNum(aUnit);
+}
+
+static TUint RateCapacityBitMaskFromRate(TUint aRate)
+{
+	switch (aRate)
+	{
+		case 50:      return KCapsBps50;
+		case 75:      return KCapsBps75;
+		case 110:     return KCapsBps110;
+		case 134:     return KCapsBps134;
+		case 150:     return KCapsBps150;
+		case 300:     return KCapsBps300;
+		case 600:     return KCapsBps600;
+		case 1200:    return KCapsBps1200;
+		case 1800:    return KCapsBps1800;
+		case 2000:    return KCapsBps2000;
+		case 2400:    return KCapsBps2400;
+		case 3600:    return KCapsBps3600;
+		case 4800:    return KCapsBps4800;
+		case 7200:    return KCapsBps7200;
+		case 9600:    return KCapsBps9600;
+		case 19200:   return KCapsBps19200;
+		case 38400:   return KCapsBps38400;
+		case 57600:   return KCapsBps57600;
+		case 115200:  return KCapsBps115200;
+		case 230400:  return KCapsBps230400;
+		case 460800:  return KCapsBps460800;
+		case 576000:  return KCapsBps576000;
+		case 1152000: return KCapsBps1152000;
+		case 4000000: return KCapsBps4000000;
+		default:      return 0;
+	}
+}
+
+static TBps TBpsRateFromRate(TUint aRate)
+{
+	switch (aRate)
+	{
+		case 50:      return EBps50;
+		case 75:      return EBps75;
+		case 110:     return EBps110;
+		case 134:     return EBps134;
+		case 150:     return EBps150;
+		case 300:     return EBps300;
+		case 600:     return EBps600;
+		case 1200:    return EBps1200;
+		case 1800:    return EBps1800;
+		case 2000:    return EBps2000;
+		case 2400:    return EBps2400;
+		case 3600:    return EBps3600;
+		case 4800:    return EBps4800;
+		case 7200:    return EBps7200;
+		case 9600:    return EBps9600;
+		case 19200:   return EBps19200;
+		case 38400:   return EBps38400;
+		case 57600:   return EBps57600;
+		case 115200:  return EBps115200;
+		case 230400:  return EBps230400;
+		case 460800:  return EBps460800;
+		case 576000:  return EBps576000;
+		case 1152000: return EBps1152000;
+		case 4000000: return EBps4000000;
+		default:      return EBpsAutobaud;
+	}
+}
+
+
+//
+//
+// CTrkSerialCommPort implementation
+//
+//
+
+//
+// CTrkSerialCommPort constructor
+//
+CTrkSerialCommPort::CTrkSerialCommPort()
+	: CTrkCommPort(CActive::EPriorityStandard),
+	  iPDD(NULL),
+	  iPDD2(NULL),
+	  iLDD(NULL),
+	  iCSY(NULL),
+	  iServerStarted(EFalse),
+	  iConnected(EFalse),
+	  iListening(EFalse),
+	  iLineNumber(0)
+{
+}
+
+//
+// CTrkSerialCommPort::ConstructL
+//
+void CTrkSerialCommPort::ConstructL(TTrkConnData& aTrkConnData , TDes& aErrorMessage)
+{
+	iPDD = aTrkConnData.iPDD;
+	iLDD = aTrkConnData.iLDD;
+	iCSY = aTrkConnData.iCSY;
+	iUnitNumber = aTrkConnData.iPortNumber;
+	iRate = aTrkConnData.iRate;
+	
+	
+	TBuf<KMaxPath> initFile(KInitFilePath);
+	initFile.Append(KInitFileName);
+	
+	if (!iPDD.Size())
+	{
+		aErrorMessage.Format(_L("PDD not specified in %S.\r\n"), &initFile);
+			User::Leave(KErrCorrupt);
+		}
+
+	if (!iLDD.Size())
+	{
+		aErrorMessage.Format(_L("LDD not specified in %S.\r\n"), &initFile);		
+			User::Leave(KErrCorrupt);
+		}
+
+	if (!iCSY.Size())
+	{
+		aErrorMessage.Format(_L("CSY not specified in %S.\r\n"), &initFile);		
+			User::Leave(KErrCorrupt);
+		}
+
+		if (!iRate)
+		{
+		aErrorMessage.Format(_L("RATE not specified in %S.\r\n"), &initFile);		
+			User::Leave(KErrCorrupt);
+		}
+	
+	iPDD2.Format(iPDD, iUnitNumber+1);
+		
+	iConnectionMessage.Format(_L("PDD: %S\r\nLDD: %S\r\nCSY: %S\r\nPort number: %d\r\nBaud rate: %d\r\n"), &iPDD2, &iLDD, &iCSY, iUnitNumber, iRate);
+
+	if (aTrkConnData.iDefault)
+	{
+		iConnectionMessage.Insert(0, _L("No init file found, using default values.\r\n"));
+	}
+}
+
+//
+// CTrkSerialCommPort destructor
+//
+CTrkSerialCommPort::~CTrkSerialCommPort()
+{
+	// make sure we cancel the request for data before shutting down
+	Cancel();
+
+	iPort.Close();
+	iConnected = EFalse;
+	iServer.Close();
+	iServerStarted = EFalse;	
+}
+
+//
+// CTrkSerialCommPort::NewL
+//
+CTrkSerialCommPort* CTrkSerialCommPort::NewL(TTrkConnData& aTrkConnData, TDes& aErrorMessage)
+{
+	CTrkSerialCommPort* self = new(ELeave) CTrkSerialCommPort;
+	CleanupStack::PushL(self);
+	self->ConstructL(aTrkConnData, aErrorMessage);
+	CleanupStack::Pop(self);
+	return self;
+}
+
+//
+// CTrkSerialCommPort::OpenPortL
+//
+// Open the serial type communications port
+//
+void CTrkSerialCommPort::OpenPortL()
+{
+	TInt error = KErrNone;
+
+	if (!iServerStarted)
+	{
+		StartC32();
+		ReportAndLeaveIfErrorL(iServer.Connect(),
+							  _L("Failed to connect to RCommServ."));
+		iServerStarted = ETrue;
+	}
+
+	// load the csy module
+	ReportAndLeaveIfErrorL(iServer.LoadCommModule(iCSY), _L("Failed to load CSY module."));
+
+	TInt ports = 0;
+	ReportAndLeaveIfErrorL(iServer.NumPorts(ports),
+						   _L("Unable to obtain information about port."));
+
+	// make sure the unit number is in range
+	TSerialInfo serialInfo;
+
+	error = KErrNotFound;
+	
+	TBuf<32> csyModule;
+	csyModule = iCSY;
+	csyModule.LowerCase();
+	for (TInt i=0; i<ports && error; i++)
+	{
+		TBuf<32> module;
+		ReportAndLeaveIfErrorL(iServer.GetPortInfo(i, module, serialInfo),
+							   _L("Unable to obtain information about port."));		
+		module.LowerCase();
+		if (module == csyModule)
+			error = KErrNone;
+	}
+
+	ReportAndLeaveIfErrorL(error, _L("Unable to obtain port information for comm module."));
+	
+	//If pdd is "NONE", don't try to load it.
+	//This is true incase of USB, where the USB pdd is a kernel extension on most of the phones
+	//and so can't be loaded.
+	TBuf<10> defaultUsbPdd;
+	defaultUsbPdd.Copy(KDefaultUsbPDD);	
+	if (iPDD2.Compare(defaultUsbPdd))
+	{
+		error = User::LoadPhysicalDevice(iPDD2);
+		if (error != KErrNone && error != KErrAlreadyExists)
+			ReportAndLeaveIfErrorL(error, _L("Failed to load physical device."));
+	}
+
+	error = User::LoadLogicalDevice(iLDD);
+	if (error != KErrNone && error != KErrAlreadyExists)
+		ReportAndLeaveIfErrorL(error, _L("Failed to load logical device."));
+
+	// Open port (try first in DTE mode and then if unsuccessful in
+	// DCE mode - necessary for cogent).
+
+	TBuf<KMaxPortName+4> portName;
+	BuildPortName(serialInfo.iName, iUnitNumber, portName);
+	error = iPort.Open(iServer, portName, ECommExclusive, ECommRoleDTE);
+	if (error != KErrNone)
+	{
+		ReportAndLeaveIfErrorL(iPort.Open(iServer, portName, ECommExclusive, ECommRoleDCE),
+							   _L("Failed to open port."));
+	}
+	iConnected = ETrue;
+
+	// Check Speed
+	TCommCaps caps;
+	iPort.Caps(caps);
+
+	TUint rateBitMask = RateCapacityBitMaskFromRate(iRate);
+	if (rateBitMask == 0 || (rateBitMask & caps().iRate) == 0)
+		ReportAndLeaveIfErrorL(KErrGeneral, _L("Unsupported baud rate."));
+
+	// Configure physical and logical characteristics
+	TCommConfig config;
+	iPort.Config(config);
+	config().iRate = TBpsRateFromRate(iRate);
+	config().iParity = EParityNone;
+	config().iDataBits = EData8;
+	config().iStopBits = EStop1;
+	config().iFifo = EFifoEnable;
+
+	config().iHandshake = 0;	// no flow control at all
+
+	ReportAndLeaveIfErrorL(iPort.SetConfig(config), _L("Failed to set port configuration."));
+
+	iPort.SetReceiveBufferLength(MAXMESSAGESIZE);
+
+	//reset the rx and tx buffers just in case 
+	//if there is any stale data lying around from the previous debug sessions
+	iPort.ResetBuffers(); 
+}
+
+//
+// CTrkSerialCommPort::ClosePort
+//
+// Close the communications port
+//
+void CTrkSerialCommPort::ClosePort()
+{
+	Cancel();
+	
+	if (iConnected)
+	{
+		iPort.Close();
+		iConnected = EFalse;
+	}
+
+	if (iServerStarted)
+	{
+		iServer.Close();
+		iServerStarted = EFalse;
+	}
+}
+
+//
+// CTrkSerialCommPort::SendDataL
+//
+// Write data to the serial type port
+//
+void CTrkSerialCommPort::SendDataL(const TDesC8& aBuffer)
+{
+	//_LIT8(KPrefix, "TrkToCarbide: ");
+	//PrintMessage(KPrefix(), aBuffer);
+	
+	TRequestStatus status;
+	iPort.Write(status, aBuffer);
+	User::WaitForRequest(status);
+	
+	User::LeaveIfError(status.Int());
+}
+
+//
+// CTrkSerialCommPort::Listen
+//
+// Start listening for data coming into the serial type communications port
+//
+void CTrkSerialCommPort::Listen(CTrkFramingLayer *aFramingLayer)
+{
+	iFramingLayer = aFramingLayer;
+	CActiveScheduler::Add(this);
+	IssueReadRequest();
+	iListening = ETrue;
+}
+
+//
+// CTrkSerialCommPort::StopListening
+//
+// Stop listening for data coming into the serial type communications port
+//
+void CTrkSerialCommPort::StopListening()
+{
+	if (iListening)
+	{
+		Cancel();
+		Deque();
+	}
+	
+	iListening = EFalse;
+}
+
+//
+// CTrkSerialCommPort::ReportAndLeaveIfErrorL
+//
+// If an error occurred, print the error information to the screen and bail out
+//
+void CTrkSerialCommPort::ReportAndLeaveIfErrorL(TInt aError, const TDesC& aDesc)
+{
+	if (KErrNone != aError)
+	{
+		iErrorMessage.Format(_L("%S\r\nError Code: %d\r\n"), &aDesc, aError);
+		User::Leave(aError);
+	}
+}
+
+//
+// CTrkSerialCommPort::IssueReadRequest
+//
+// Wait for data to come into the communications port
+//
+void CTrkSerialCommPort::IssueReadRequest()
+{
+	iNextReadChar = 0;
+	iReceivedChars.Zero();
+	iPort.ReadOneOrMore(iStatus, iReceivedChars);
+
+	SetActive();
+}
+
+//
+// CTrkSerialCommPort::DoCancel
+//
+// Cancel the request for data from the communications port
+//
+void CTrkSerialCommPort::DoCancel()
+{
+	iPort.ReadCancel();
+}
+
+//
+// CTrkSerialCommPort::RunL
+//
+// Called when data comes into the communications port
+//
+void CTrkSerialCommPort::RunL()
+{
+	//_LIT8(KPrefix, "CarbideToTrk: ");
+	//PrintMessage(KPrefix(), iReceivedChars);
+
+	// pass the data onto the framing layer
+	if (iStatus.Int() == KErrNone)
+		while (iNextReadChar < iReceivedChars.Length())
+			iFramingLayer->HandleByte(iReceivedChars[iNextReadChar++]);
+
+	// continue waiting for data
+	IssueReadRequest();
+}
+
+void CTrkSerialCommPort::PrintMessage(const TDesC8& aPrefix, const TDesC8& aBinaryData) const
+	{
+	TInt msgLength = aBinaryData.Length();
+	//RDebug::Printf("%S - start", &aPrefix);
+	for(TInt i=0; i<msgLength; i+=8)
+		{
+		TBuf8<30> tempBuf;
+		tempBuf.SetLength(0);
+		for(TInt j=i; (j<i+8) && (j<msgLength); j++)
+			{
+			TUint byte = (TUint)aBinaryData[j];
+			tempBuf.AppendNumFixedWidth(byte, EHex, 2);
+			tempBuf.Append(' ');
+			}
+		//RDebug::Printf("%S: [%S]", &aPrefix, &tempBuf);
+		}
+	//RDebug::Printf("%S - end", &aPrefix);
+
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkSerialCommPort.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKSERIALCOMMPORT_H__
+#define __TRKSERIALCOMMPORT_H__
+
+#include <c32comm.h>
+#include "TrkCommPort.h"
+
+
+//
+// class CTrkSerialCommPort
+//
+// Defines an interface to a serial type communications port
+//
+class CTrkSerialCommPort : public CTrkCommPort
+{
+public:
+
+	static CTrkSerialCommPort* NewL(TTrkConnData& aTrkConnData, TDes& aErrorMessage);
+	~CTrkSerialCommPort();
+
+	void OpenPortL();
+	void ClosePort();
+
+	void SendDataL(const TDesC8& aData);
+	void Listen(CTrkFramingLayer *aFramingLayer);
+	void StopListening();
+	
+protected:
+
+	void DoCancel();
+	void RunL();
+
+private:
+
+	CTrkSerialCommPort();
+	void ConstructL(TTrkConnData& aTrkConnData, TDes& aErrorMessage);
+	void IssueReadRequest();
+	void ReportAndLeaveIfErrorL(TInt aError, const TDesC& aDesc);
+	void PrintMessage(const TDesC8& aPrefix, const TDesC8& aBinaryData) const;
+	
+private:
+
+	TBuf<32> iPDD;
+	TBuf<32> iPDD2;
+	TBuf<32> iLDD;
+	TBuf<32> iCSY;
+	TUint iUnitNumber;
+	TUint iRate;
+
+	RCommServ iServer;
+	RComm  iPort;
+
+	TBool iServerStarted;
+	TBool iConnected;
+	TBool iListening;
+
+	TBuf8<MAXMESSAGESIZE> iReceivedChars;
+	TInt iNextReadChar;
+
+	CTrkFramingLayer* iFramingLayer;
+	
+	TInt iLineNumber;
+};
+
+#endif // __TRKSERIALCOMMPORT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkSocketCommPort.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,190 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#include "TrkSocketCommPort.h"
+#include "TrkFramingLayer.h"
+#include "TrkEngine.h"
+#include <e32cons.h>
+
+
+CTrkSocketCommPort::CTrkSocketCommPort()
+	: CTrkCommPort(CActive::EPriorityStandard),
+	  iConnected(EFalse)
+{
+}
+
+void CTrkSocketCommPort::ConstructL(const TDesC &/*aInitFilePath*/, TDes& /*aErrorMessage*/)
+{
+	CActiveScheduler::Add(this); 
+}
+
+void CTrkSocketCommPort::IssueReadRequest()
+{
+	iNextReadChar = 0;
+	TSockXfrLength len;
+	iSocket.RecvOneOrMore(iReceivedChars, 0, iStatus, len);
+
+	SetActive();
+}
+
+void CTrkSocketCommPort::DoCancel()
+{
+	iSocket.CancelRead();
+}
+
+void CTrkSocketCommPort::RunL()
+{
+	if (iStatus.Int() == KErrNone)
+		while (iNextReadChar < iReceivedChars.Length())
+			iFramingLayer->HandleByte(iReceivedChars[iNextReadChar++]);
+
+	IssueReadRequest();
+}
+
+
+CTrkSocketCommPort::~CTrkSocketCommPort()
+{
+	Cancel();
+//	iSocket.Close();
+	iConnected = EFalse;
+	iSocketServ.Close();
+}
+
+
+CTrkSocketCommPort* CTrkSocketCommPort::NewL(const TDesC& aInitFilePath, TDes& aErrorMessage)
+{
+	CTrkSocketCommPort* self = new(ELeave) CTrkSocketCommPort;
+	CleanupStack::PushL(self);
+	self->ConstructL(aInitFilePath, aErrorMessage);
+	CleanupStack::Pop(self);
+	return self;
+}
+
+
+void CTrkSocketCommPort::OpenPortL()
+{
+	TInt error = KErrNone;
+	
+	error = iSocketServ.Connect();
+	if (error != KErrNone)
+		User::Leave(100);
+
+	error = iSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp);
+	if (error != KErrNone)
+		User::Leave(101);
+
+	TUint protocols = 0;
+	
+	error = iSocketServ.NumProtocols(protocols);
+	
+	TProtocolDesc desc;
+	
+	for (TUint i=0; i<protocols; i++)
+	{
+		error = iSocketServ.GetProtocolInfo(i, desc);
+	}
+	
+}
+
+void CTrkSocketCommPort::ConnectL()
+{
+	TInetAddr address;
+	TInt err = KErrNone;
+	
+//	address.SetPort(10000);
+//	err = address.Input(_L("10.86.2.93"));
+//
+//	TRequestStatus stat;
+//	iSocket.Connect(address, stat);
+//	User::WaitForRequest(stat);
+
+//	iConnected = ETrue;
+
+//	TSockAddr test;
+//	iSocket.LocalName(test);
+//	TUint lp = iSocket.LocalPort();
+
+	
+	address.SetPort(6110);
+	err = address.Input(_L("127.0.0.1"));
+//	err = address.Input(_L("0.0.0.0"));
+
+	err = iSocket.Bind(address);
+	if (err != KErrNone)
+	{
+		User::Leave(err);
+	}
+
+	err = iSocket.Listen(1);
+	if (err != KErrNone)
+	{
+		User::Leave(err);
+	}
+
+	RSocket blankSocket;
+	err = blankSocket.Open(iSocketServ);
+
+	TRequestStatus stat;
+	iSocket.Accept(blankSocket, stat);
+//	SetActive();
+	User::WaitForRequest(stat);
+	User::Leave(5000);
+
+//	iSocket.Connect(address, iStatus);
+
+	iConnected = ETrue;
+}
+
+void CTrkSocketCommPort::ClosePort()
+{
+	Cancel();
+	
+	if (iConnected)
+	{
+		iSocket.Close();
+		iConnected = EFalse;
+	}
+
+	iSocketServ.Close();
+}
+
+void CTrkSocketCommPort::SendDataL(const TDesC8& aBuffer)
+{
+	TRequestStatus status;
+	iSocket.Write(aBuffer, status);
+	User::WaitForRequest(status);
+
+	User::LeaveIfError(status.Int());
+}
+
+void CTrkSocketCommPort::Listen(CTrkFramingLayer */*aFramingLayer*/)
+{
+//#warning - can leave
+//	if (!iConnected)
+//		ConnectL();
+//	iFramingLayer = aFramingLayer;
+//	CActiveScheduler::Add(this);
+//	IssueReadRequest();
+}
+
+void CTrkSocketCommPort::StopListening()
+{
+	Cancel();
+	Deque();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkSocketCommPort.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKSOCKETCOMMPORT_H__
+#define __TRKSOCKETCOMMPORT_H__
+
+#include <in_sock.h>
+#include "TrkCommPort.h"
+
+
+_LIT8(KSocketComm, "[SOCKETCOMM]");
+
+//
+// class CTrkSocketCommPort
+//
+// Defines an interface to a socket type communications port
+//
+
+class CTrkSocketCommPort : public CTrkCommPort
+{
+public:
+		
+	static CTrkSocketCommPort* NewL(const TDesC& aInitFilePath, TDes& aErrorMessage);
+	~CTrkSocketCommPort();
+
+	void OpenPortL();
+	void ClosePort();
+
+	void SendDataL(const TDesC8& aBuffer);
+	void Listen(CTrkFramingLayer *aFramingLayer);
+	void StopListening();
+
+protected:
+
+	void DoCancel();
+	void RunL();
+
+private:
+
+	CTrkSocketCommPort();
+	void ConstructL(const TDesC &aInitFilePath, TDes& aErrorMessage);
+	void ConnectL();
+	void IssueReadRequest();
+
+private:
+
+	RSocket iSocket;
+	RSocketServ iSocketServ;
+
+	TBool iConnected;
+	TBool iListening;
+
+	TBuf8<MAXMESSAGESIZE> iReceivedChars;
+	TInt iNextReadChar;
+
+	CTrkFramingLayer* iFramingLayer;
+	
+	TInt iLineNumber;
+};
+
+#endif // __TRKSOCKETCOMMPORT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkSwInstUIHandler.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,543 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "TrkSwInstUIHandler.h"
+
+/**
+ * Creates a new Instance of the CTrkSWInstUIHandler and calls the
+ * ConsturctL
+ * @param None
+ * @return CTrkSWInstUIHandler* 
+ * 
+ */
+CTrkSWInstUIHandler* CTrkSWInstUIHandler::NewL(const TChar aInstallDrive)
+{
+	CTrkSWInstUIHandler*	self=new(ELeave) CTrkSWInstUIHandler(aInstallDrive);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+}
+
+/**
+ * Creates a new Instance of the CTrkSWInstUIHandler and calls the
+ * ConsturctL
+ * @param None
+ * @return CTrkSWInstUIHandler* 
+ * 
+ */
+CTrkSWInstUIHandler* CTrkSWInstUIHandler::NewL()
+{
+	CTrkSWInstUIHandler*	self=new(ELeave) CTrkSWInstUIHandler();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+}
+
+
+/**
+ * Constructor for CTrkSWInstUIHandler
+ */	
+CTrkSWInstUIHandler::CTrkSWInstUIHandler()
+:	iDispInstall(TRUE),
+	iDispGrantCapabilities(TRUE),
+	iDispUnInstall(TRUE),
+	iDispLanguage(0),
+	iDispDialect(0),
+	iDispDrive('C'),
+	iDispUpgrade(TRUE),
+	iDispDependencyBreak(TRUE),
+	iDispQuestion(TRUE),
+	iDispSecurityWarning(TRUE),
+	iDispRevocationQuery(TRUE),
+	iDispApplicationInUse(TRUE),
+	iDispTextDialog(TRUE),
+	iDispOptions(0),
+	iAppUID(0),
+	iErrCode(KErrNothing)
+{
+}
+
+/**
+ * Constructor for CTrkSWInstUIHandler
+ */	
+CTrkSWInstUIHandler::CTrkSWInstUIHandler(const TChar aInstallDrive)
+:	iDispInstall(TRUE),
+	iDispGrantCapabilities(TRUE),
+	iDispUnInstall(TRUE),
+	iDispLanguage(0),
+	iDispDialect(0),
+	iDispDrive(aInstallDrive),
+	iDispUpgrade(TRUE),
+	iDispDependencyBreak(TRUE),
+	iDispQuestion(TRUE),
+	iDispSecurityWarning(TRUE),
+	iDispRevocationQuery(TRUE),
+	iDispApplicationInUse(TRUE),
+	iDispTextDialog(TRUE),
+	iDispOptions(0),
+	iAppUID(0),
+	iErrCode(KErrNothing)
+{
+}
+/**
+ * Second stage constructor for CTrkSWInstUIHandler
+ */	
+void CTrkSWInstUIHandler::ConstructL()
+{
+}
+
+/**
+ * Destructor for CTrkSWInstUIHandler
+ */	
+CTrkSWInstUIHandler::~CTrkSWInstUIHandler()
+{
+	iDispInstall = FALSE;
+	iDispGrantCapabilities = FALSE;
+	iDispUnInstall = FALSE;
+	iDispLanguage = 0;
+	iDispDialect = 0;
+	iDispDrive = 'C';
+	iDispUpgrade = FALSE;
+	iDispDependencyBreak = FALSE;
+	iDispQuestion = FALSE;
+	iDispSecurityWarning = FALSE;
+	iDispRevocationQuery = FALSE;
+	iDispApplicationInUse = FALSE;
+	iDispTextDialog = FALSE;
+	iDispOptions = 0;
+	iAppUID = 0;
+		
+	iErrCode = KErrNothing;
+}
+
+/**
+ * Displays a dialog at the beginning of an installation with details about the SISX package
+ * being installed. This dialog must be shown in TrustedUI mode.
+ *
+ * @param aAppInfo		Information about the application.
+ * @param aLogo			The logo data in the SISX file. If no logo is present it will be NULL.
+ * @param aCertificates An array of end entity certificates, one for each chain in the SISX file.
+ *						If the SISX file is unsigned this array will have zero length.
+ *
+ * @note 				Trusted UI
+ *
+ * @return				ETrue if the user pressed the Yes button to continue the install,
+ *						EFalse if the user pressed the No button, aborting the installation.
+ */
+TBool CTrkSWInstUIHandler::DisplayInstallL(const CAppInfo& aAppInfo, 
+			const CApaMaskedBitmap* aLogo, 
+			const RPointerArray< CCertificateInfo >& aCertificates)
+{
+	return iDispInstall;
+}
+
+/**
+ * Displays a dialog requesting that the user grants these capabilities to the SISX package 
+ * being installed. This dialog must be shown in TrustedUI mode.
+ *
+ * @param aAppInfo	 		Information about the application.
+ * @param aCapabilitySet 	The capabilities requested by the SISX package.
+ *
+ * @note 					Trusted UI
+ *
+ * @return					ETrue to continue the installation, or EFalse to abort the installation.
+ */
+TBool CTrkSWInstUIHandler::DisplayGrantCapabilitiesL(const CAppInfo& aAppInfo, 
+			const TCapabilitySet& aCapabilitySet)
+{
+	return iDispGrantCapabilities;
+}
+
+/**
+ * Requests preferred language and dialect information from the UI.
+ *
+ * @param aAppInfo		Information about the application.
+ * @param aLanguages	Array of languages supported by the SIS file. 
+ *
+ * @return				Must return index in the passed array that corresponds to the user's selected 
+ *						preferred language. If out-of-bounds value is returned, the engine will abort 
+ *						installation.
+ */
+TInt CTrkSWInstUIHandler::DisplayLanguageL(const CAppInfo& aAppInfo, 
+	      const RArray<TLanguage>& aLanguages)
+{
+	TInt languageCode = iDispLanguage;
+	TInt index;
+	
+	// Return the index value in the array which matches the language code 
+	// obtained from the ini file.
+	for (index=0; index<aLanguages.Count(); index++)
+	{
+		if (aLanguages[index] == (TLanguage)languageCode)
+		{
+			return index;
+		}
+	}
+	// Language Code did not match - ignore this error for now
+	// when doing silent install, we can ignore the mulilanguage support
+	iErrCode = KErrNothing;
+	
+	return languageCode;
+}
+	
+/**
+ * Requests the drive to install the package on, from the UI.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aSize		Total size of the files that will be installed on the configurable drive.
+ * @param aDriveLetters	Array of drive letters on which the package can be installed.
+ * @param aDriveSpaces	Array of space free (in bytes) on each of the drives in the aDriveLetters array. 
+ *
+ * @return		An index in the drive array. If the index is out of range the engine will abort
+ *                      the installation.
+ */
+TInt CTrkSWInstUIHandler::DisplayDriveL(const CAppInfo& aAppInfo, 
+		   TInt64 aSize,
+		   const RArray<TChar>& aDriveLetters,
+		   const RArray<TInt64>& aDriveSpaces)
+{
+	TInt index;
+	TInt driveIndex=0;
+	for (index=0; index < aDriveLetters.Count(); index++)
+	{
+		if (aDriveLetters[index] == iDispDrive)
+		{
+			driveIndex = index;
+			break;
+		}
+	}
+		
+	if (index == aDriveLetters.Count()) // Out of range error 
+	{
+		iErrCode = KErrDrive;
+		driveIndex = index;
+	}
+	return driveIndex;
+}
+	
+/**
+ * Displays a dialog asking whether we want to upgrade an application present on the device.
+ *
+ * @param aAppInfo	        Information about the application being installed.
+ * @param aExistingAppInfo	Information about the existing application.
+ *
+ * @return		ETrue if the user pressed the Yes button,
+ *			EFalse if the user pressed the No button.
+ */
+TBool CTrkSWInstUIHandler::DisplayUpgradeL(const CAppInfo& aAppInfo, 
+		      const CAppInfo& aExistingAppInfo)
+{
+	return iDispUpgrade;
+}
+	
+/**
+ * Displays a dialog box asking which options the user wishes to install.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aOptions	An array of option names.
+ * @param aSelections	An array of booleans, corresponding to the aOptions array.
+ *
+ * @return		ETrue on success, EFalse on error.
+ */
+TBool CTrkSWInstUIHandler::DisplayOptionsL(const CAppInfo& aAppInfo,
+		      const RPointerArray<TDesC>& aOptions,
+		      RArray<TBool>& aSelections)
+{
+	
+	TInt index;
+	TBool setFlag = EFalse;
+	
+	for (index=0; index<aOptions.Count();index++)
+	{
+		if (index == iDispOptions)
+		{
+			aSelections[index] = ETrue;
+			setFlag = ETrue;
+		}
+		else
+		{
+			aSelections[index] = EFalse;
+		}
+	}
+
+	if (setFlag == (TBool)ETrue)
+	{
+		return ETrue;
+	}
+	else
+	{
+		iErrCode = KErrOptions;
+		return EFalse;
+	}
+}
+	
+/**
+ * Informs the UI of events occurring during installation.  
+ *
+ * @param aEvent	The event which has occurred.
+ * @param aValue	The value associated with the event if applicable.
+ * @param aDes		A descriptor associated with the event if applicable.
+ * @return TBool	Always returns ETrue to indicate the Install Event is always handled
+ */
+TBool CTrkSWInstUIHandler::HandleInstallEventL(const CAppInfo& aAppInfo,
+			 TInstallEvent aEvent, 
+			 TInt aValue, 
+			 const TDesC& aDes)
+{
+	switch (aEvent)
+	{
+		case EEventSetProgressBarFinalValue:
+			break;
+		case EEventUpdateProgressBar:
+			break;
+		case EEventAbortedInstall:
+			iErrCode = KErrAbortInstall;
+			break;
+		case EEventCompletedInstall:
+			break;
+		case EEventCompletedUnInstall:
+			break;
+		case EEventAbortedUnInstall:
+			iErrCode = KErrAbortUnInstall;
+			break;
+		case EEventCompletedNoMessage:
+			break;
+		case EEventLeave:
+			iErrCode = KErrLeave;
+			break;
+		case EEventOcspCheckEnd:
+			break;
+		default:
+			break;
+	}
+	return ETrue;
+}
+	
+/**
+ * Informs the UI of cancellable events occurring during installation.  
+ *
+ * @param aEvent	 		The event which has occurred.
+ * @param aCancelHandler 	This mix-in is used to inform Software Install that the user has
+ *			 				pressed the cancel button on the dialog.
+ * @param aValue	 		The value associated with the event if applicable.
+ * @param aDes           	A descriptor associated with the event if applicable.
+ */
+void CTrkSWInstUIHandler::HandleCancellableInstallEventL(const CAppInfo& aAppInfo,
+			TInstallCancellableEvent aEvent, 
+		    MCancelHandler& aCancelHandler,
+		    TInt aValue, 
+		    const TDesC& aDes)
+{
+	switch (aEvent)
+	{
+		case EEventRemovingFiles:
+			break;
+		case EEventShuttingDownApps:
+			break;
+		case EEventCopyingFiles:
+			break;
+		case EEventOcspCheckStart:
+			break;
+		default:
+			break;
+	}
+}
+
+/**
+ * Displays a dialog indicating that the package is unsigned, or that signature validation has failed.
+ *
+ * @param aAppInfo              Information about the application.
+ * @param aSigValidationResult	The result of signature validation.
+ * @param aPkixResult           Results of a validation of the PKIX  certificate chain.
+ *                              Note that is can be NULL, in this case no validation results are available.
+ * @param aCertificates         An array containing information about the certificates in the chain.
+ * @param aInstallAnyway		ETrue if installation is allowed to continue.
+ *
+ * @return						ETrue to continue the installation, EFalse to abort.
+ */
+TBool CTrkSWInstUIHandler::DisplaySecurityWarningL(const CAppInfo& aAppInfo,
+						Swi::TSignatureValidationResult aSigValidationResult,
+						RPointerArray<CPKIXValidationResultBase>& aPkixResults,
+						RPointerArray<CCertificateInfo>& aCertificates,
+						TBool aInstallAnyway)
+{
+	return ETrue;
+}
+
+/**
+ * Displays a dialog indicating that there was an error carrying out online certificate status checking.
+ *
+ * @param aMessage		The error which occurred during online certificate status checking
+ * @param aOutcome		The outcome of the OCSP check. If no outcome can be given, it will be NULL.
+ * @param aWarningOnly	ETrue if the installation is allowed to continue after a warning, EFalse otherwise.
+ *
+ * @return				ETrue on success, EFalse on error.
+ */
+TBool CTrkSWInstUIHandler::DisplayOcspResultL(const CAppInfo& aAppInfo,
+						TRevocationDialogMessage aMessage, 
+						RPointerArray<TOCSPOutcome>& aOutcomes, 
+						RPointerArray<CCertificateInfo>& aCertificates,
+						TBool aWarningOnly)
+{
+	return aWarningOnly;
+}
+	
+/**
+ * Used to inform the user the installation they are attempting is trying to overwrite
+ * a file that does not belong to it. Following this message installation is aborted.
+ *
+ * @param aAppInfo	        Information about the application.
+ * @param aInstalledAppInfo	Information about the application that owns the file in question.
+ * @param aFileName			The filename of the file in question
+ */
+void CTrkSWInstUIHandler::DisplayCannotOverwriteFileL(const CAppInfo& /*aAppInfo*/,
+				 const CAppInfo& /*aInstalledAppInfo*/,
+				 const TDesC& /*aFileName*/)
+{
+	iErrCode = KErrCannotOverwriteFile;
+}
+	
+/**
+ * Displays a dialog at the start of the uninstallation with information about the application
+ * to be uninstalled. The user may cancel the uninstallation at this stage. This dialog must 
+ * be shown in TrustedUI mode.
+ *	
+ * @param aAppInfo	Information about the application.
+ *
+ * @note Trusted UI
+ *
+ * @return			ETrue to continue the uninstallation, or EFalse to abort the uninstallation.
+ */
+TBool CTrkSWInstUIHandler::DisplayUninstallL(const CAppInfo& aAppInfo)
+{
+	return iDispUnInstall;
+}
+
+/**
+ * Displays a dialog containing text. This dialog has only a Continue button if aOption is 
+ * EInstFileTextOptionContinue, or Yes and No buttons otherwise.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aOption	The type of dialog box to display.
+ * @param aText		The text to display
+ *
+ * @return		ETrue if the user wants to go forward, EFalse otherwise.
+ */
+TBool CTrkSWInstUIHandler::DisplayTextL(const CAppInfo& aAppInfo, 
+			    TFileTextOption aOption,
+			    const TDesC& aText)
+{
+	return iDispTextDialog;
+}
+	
+/**
+ * Displays a dialog showing an error message. 
+ *
+ * @param aAppInfo	    Information about the application.
+ * @param aType		    The error message to display.
+ * @param aParam	    An error specific parameter.
+ */
+void CTrkSWInstUIHandler::DisplayErrorL(const CAppInfo& aAppInfo,
+			   TErrorDialog aType,
+			   const TDesC& aParam)
+{
+	iErrCode = KErrError;
+}
+
+/**
+ * Displays a dialog indicating that a component which is being uninstalled is a dependency
+ * of another component installed.
+ *
+ * @param aAppInfo		Information about the application.
+ * @param aComponents	An array of components which depend on components of the application
+ *
+ * @return				ETrue to continue the uninstallation, EFalse to abort.
+ */
+TBool CTrkSWInstUIHandler::DisplayDependencyBreakL(const CAppInfo& aAppInfo,
+		      const RPointerArray<TDesC>& aComponents)
+{
+	return iDispDependencyBreak;
+}
+	
+/**
+ * Informs user that the applications are in use during an uninstallation.
+ * Return ETrue if the user wishes to continue the removal process and 
+ * close the applications anyway
+ *
+ * @param aAppNames		An array containing the name of the application in use.
+ *
+ * @return				ETrue if the user wishes to continue with removal.
+ */
+TBool CTrkSWInstUIHandler::DisplayApplicationsInUseL(const CAppInfo& aAppInfo, 
+			const RPointerArray<TDesC>& aAppNames)
+{
+	return iDispApplicationInUse;
+}
+	
+/**
+ * Displays a generic question dialog with a Yes/No answer.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aQuestion The question to ask.
+ * @param aDes		A descriptor associated with the question if applicable. 
+ *
+ * @return			ETrue if the user pressed the Yes button,
+ *					EFalse if the user pressed the No button.
+ */
+TBool CTrkSWInstUIHandler::DisplayQuestionL(const CAppInfo& aAppInfo, 
+			TQuestionDialog aQuestion, const TDesC& aDes)
+{
+	
+	switch(aQuestion)
+	{
+		case EQuestionIncompatible:
+			break;
+		default:
+			break;
+	}
+		
+	return iDispQuestion;
+}
+
+/**
+ * Used to inform the user of a missing dependency needed to install the 
+ * current package. It is up to the UI implementors and/or the user whether
+ * or not this warning can be overridden.
+ *
+ * @param aAppInfo           Info about the current application.
+ * @param aDependencyName    Name of the missing dependency.
+ * @param aWantedVersionFrom Starting suitable version number of the mising
+ *                           dependency. Can be all zeros, meaning it is 
+ *                           unknown.
+ * @param aWantedVersionFrom Ending suitable version number of the mising
+ *                           dependency. Can be all zeros, meaning it is 
+ *                           unknown.
+ * @param aInstalledVersion  The installed (unsuitable) version of the 
+ *                           missing dependency. Can be all zeros, meaning 
+ *                           the missing dependency is not installed.
+ *
+ * @return \e ETrue to continue installation, \e EFalse to abort.
+ */
+TBool CTrkSWInstUIHandler::DisplayMissingDependencyL(const CAppInfo& aAppInfo,
+	const TDesC& aDependencyName,TVersion aWantedVersionFrom,
+	TVersion aWantedVersionTo,TVersion aInstalledVersion)
+{
+	return ETrue;
+}
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkSwInstUIHandler.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,155 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TrkSWInstUIHandler_H__
+#define __TrkSWInstUIHandler_H__
+
+
+// Epoc Include
+#include <swi/msisuihandlers.h>
+
+//Macros
+#define KUserNameMaxLength	64
+#define KPassword			64
+
+
+enum KMyErrCode
+{
+	KErrNothing,
+	KErrLanguage,        
+	KErrDrive,
+	KErrOptions,        
+	KErrAbortInstall,
+	KErrAbortUnInstall,        
+	KErrLeave,
+	KErrCannotOverwriteFile,
+	KErrError        
+};
+	
+
+using namespace Swi;
+
+class CTrkSWInstUIHandler : public CBase, public Swi::MUiHandler
+{
+	public:
+		static CTrkSWInstUIHandler* NewL();
+
+		static CTrkSWInstUIHandler* NewL(const TChar);
+		
+		~CTrkSWInstUIHandler();
+
+		TBool  DisplayInstallL (const CAppInfo& aAppInfo, 
+			const CApaMaskedBitmap* aLogo, 
+			const RPointerArray <CCertificateInfo> & aCertificates);
+
+		TBool DisplayGrantCapabilitiesL(const CAppInfo& aAppInfo, 
+						const TCapabilitySet& aCapabilitySet);
+										
+		TInt DisplayLanguageL(const CAppInfo& aAppInfo, 
+				      const RArray<TLanguage>& aLanguages);
+	
+		TInt DisplayDriveL(const CAppInfo& aAppInfo, 
+				   TInt64 aSize,
+				   const RArray<TChar>& aDriveLetters,
+				   const RArray<TInt64>& aDriveSpaces);
+	
+		TBool DisplayUpgradeL(const CAppInfo& aAppInfo, 
+				      const CAppInfo& aExistingAppInfo);
+	
+		TBool DisplayOptionsL(const CAppInfo& aAppInfo,
+				      const RPointerArray<TDesC>& aOptions,
+				      RArray<TBool>& aSelections);
+	
+		TBool HandleInstallEventL(const CAppInfo& aAppInfo,
+						TInstallEvent aEvent, 
+						TInt aValue=0, 
+						const TDesC& aDes=KNullDesC);
+
+		void HandleCancellableInstallEventL(const CAppInfo& aAppInfo,
+						TInstallCancellableEvent aEvent, 
+						MCancelHandler& aCancelHandler,
+						TInt aValue=0, 
+						const TDesC& aDes=KNullDesC);
+
+		TBool DisplaySecurityWarningL(const CAppInfo& aAppInfo,
+						Swi::TSignatureValidationResult aSigValidationResult,
+						RPointerArray<CPKIXValidationResultBase>& aPkixResults,
+						RPointerArray<CCertificateInfo>& aCertificates,
+						TBool aInstallAnyway);
+	
+		TBool DisplayOcspResultL(const CAppInfo& aAppInfo,
+						TRevocationDialogMessage aMessage, 
+						RPointerArray<TOCSPOutcome>& aOutcomes, 
+						RPointerArray<CCertificateInfo>& aCertificates,
+						TBool aWarningOnly);
+	
+		void DisplayCannotOverwriteFileL(const CAppInfo& aAppInfo,
+						 const CAppInfo& aInstalledAppInfo,
+						 const TDesC& aFileName);
+						 
+		TBool DisplayUninstallL(const CAppInfo& aAppInfo);
+
+
+        TBool DisplayTextL(const CAppInfo& aAppInfo, 
+				    TFileTextOption aOption,
+				    const TDesC& aText);
+	 
+		void DisplayErrorL(const CAppInfo& aAppInfo,
+				   TErrorDialog aType, 
+				   const TDesC& aParam);
+
+		TBool DisplayDependencyBreakL(const CAppInfo& aAppInfo,
+					      const RPointerArray<TDesC>& aComponents);
+		
+		TBool DisplayApplicationsInUseL(const CAppInfo& aAppInfo, const RPointerArray<TDesC>& aAppNames);
+	
+		TBool DisplayQuestionL(const CAppInfo& aAppInfo, TQuestionDialog aQuestion, const TDesC& aDes=KNullDesC);
+
+		TBool DisplayMissingDependencyL(const CAppInfo& aAppInfo,
+										const TDesC& aDependencyName,
+										TVersion aWantedVersionFrom,
+										TVersion aWantedVersionTo,
+										TVersion aInstalledVersion);
+
+		TBool 	iDispInstall;
+		TBool	iDispGrantCapabilities;
+		TBool	iDispUnInstall;
+		TInt	iDispLanguage;
+		TInt	iDispDialect;
+		TChar	iDispDrive;
+		TBool	iDispUpgrade;
+		TBool	iDispDependencyBreak;
+		TBool	iDispQuestion;
+		TBool	iDispSecurityWarning;
+		TBool	iDispRevocationQuery;
+		TBool	iDispApplicationInUse;
+		TBool	iDispTextDialog;
+		TInt	iDispOptions;
+		TInt	iAppUID;
+		
+		KMyErrCode 	iErrCode;
+		
+	private:
+		CTrkSWInstUIHandler();
+		CTrkSWInstUIHandler(const TChar aInstallDrive);
+
+		void ConstructL();
+};
+
+#endif //__TrkSWInstUIHandler_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkSwInstall.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#include <e32base.h>
+#include <e32cons.h>
+#include <hal.h>
+#include <cinidata.h>
+
+// Epoc Includes
+#include <swi/launcher.h>
+// S60 specific headers
+#ifdef __S60__
+#include <SWInstApi.h>
+#endif
+
+#include "TrkSwInstall.h"
+#include "TrkSwInstUIHandler.h"
+
+#define SafeDelete(x) { if (x) delete x; x = NULL; }
+
+CTrkSwInstall::CTrkSwInstall()
+{
+}
+
+TInt CTrkSwInstall::Install(const TDesC& aFileName)
+{		
+#ifdef __S60__
+	TInt error = KErrNone;
+	
+	SwiUI::RSWInstLauncher swInstLauncher;
+	
+	error = swInstLauncher.Connect();
+	if (!error)
+	{
+		error = swInstLauncher.Install(aFileName);
+		
+		swInstLauncher.Close();
+	}
+	
+	return error;
+#else
+	return KErrNotSupported;	
+#endif	
+}
+
+TInt CTrkSwInstall::SilentInstallL(const TDesC& aFileName, const TChar aInstallDrive)
+{
+	TInt error = KErrNone;
+
+	TFileName fileName(aFileName);
+	
+	fileName.PtrZ();	
+	
+	Swi::CInstallPrefs* iInstallPrefs = Swi::CInstallPrefs::NewL();
+	
+	CTrkSWInstUIHandler* iUIHandler = CTrkSWInstUIHandler::NewL(aInstallDrive);
+	
+	error = Swi::Launcher::Install(*iUIHandler, fileName, *iInstallPrefs);
+
+	if ((KErrNone == error) && (KErrNothing != iUIHandler->iErrCode))
+		error = KErrGeneral;
+
+	SafeDelete(iUIHandler);
+	SafeDelete(iInstallPrefs);
+	
+	return error;
+}
+
+TInt CTrkSwInstall::UninstallL(const TDesC& aUid)
+{
+	
+	TInt error = KErrNone;
+
+	TLex conv(aUid);
+	
+	TUint32 id;
+	
+	error = conv.Val(id,EHex);
+	
+	if (error != KErrNone)
+	{
+		return error;
+	}
+		
+	TUid uid = TUid::Uid(id);
+		
+	
+	CTrkSWInstUIHandler* iUIHandler = CTrkSWInstUIHandler::NewL();
+
+	error = Swi::Launcher::Uninstall(*iUIHandler, uid);
+	
+	SafeDelete(iUIHandler);
+
+	return error;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkSwInstall.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#ifndef _TrkSwInstall_H__
+#define _TrkSwInstall_H__
+
+
+class CTrkSwInstall : public CBase
+
+{
+public:
+	CTrkSwInstall();
+
+	static TInt SilentInstallL(const TDesC&, const TChar);
+	static TInt Install(const TDesC&);
+
+	static TInt UninstallL(const TDesC&);	
+	
+protected:
+	
+private:
+};
+
+#endif // __TrkSwInstall_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkUsbConnectionListener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef TRKUSBCONNECTIONLISTENER_H_
+#define TRKUSBCONNECTIONLISTENER_H_
+
+/**
+*  Abstract callback interface for port listeners to call into the debug manager for certain situations.
+*/
+class MTrkUsbConnectionListener
+{
+    public:
+
+        /**
+        * Called by the port listeners when a connection is available
+        */
+        virtual void ConnectionAvailable() = 0;
+
+        /**
+        * This is called when a connection is closed, this can happen for different reasons.
+        * One of the reasons could be that the user has unplugged 
+        * the USB cable when using the USB connection
+        */
+        virtual void ConnectionUnAvailable() = 0; 
+            
+};
+#endif /* TRKUSBCONNECTIONLISTENER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkUsbPortListener.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,151 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// INCLUDE FILES
+#include <e32std.h>                      
+
+#include "TrkUsbPortListener.h" 
+                   
+// LOCAL FUNCTION PROTOTYPES
+
+// LOCAL CONSTANTS
+
+const TUint KTrkUsbDeviceStateMask				= 0x00ff;
+
+#if(defined __SERIES60_30__ || defined __SERIES60_31__ || defined __S60_32__)
+#define KPersonalityPCSuite               113
+#else
+#define KPersonalityPCSuite               5
+#endif
+
+
+
+
+//
+// CTrkUsbPortListener::CTrkUsbPortListener
+// Constructor
+//
+CTrkUsbPortListener::CTrkUsbPortListener (MTrkUsbConnectionListener *aConnectionListener) 
+		  	  :CTrkCommPortListener(aConnectionListener, CActive::EPriorityStandard)
+{
+	iConnected = EFalse;
+	iPersonalityId = 0;
+
+	iUsbDeviceState = EUsbDeviceStateUndefined;
+    
+    TInt err = iUsbServer.Connect();
+
+    err = iUsbServer.GetDeviceState( iUsbDeviceState );
+    if (!err)
+    	err = iUsbServer.GetCurrentPersonalityId( iPersonalityId );
+    
+    if (!err && iUsbDeviceState == EUsbDeviceStateConfigured
+    		 && iPersonalityId == KPersonalityPCSuite)
+    		 iConnected = ETrue;
+
+    CActiveScheduler::Add( this ); 
+}
+
+//
+// CTrkUsbPortListener::~CTrkUsbPortListener
+// Destructor
+//
+CTrkUsbPortListener::~CTrkUsbPortListener()
+{
+    Cancel();   // Ensure that any outstanding requests are cancelled
+    Deque();
+    iUsbServer.Close();
+}
+
+//
+// CTrkUsbPortListener::ListenL
+// Starts listening for usb connection status notifications..
+//
+void CTrkUsbPortListener::ListenL()
+{		
+	IssueRequestL();		
+}
+
+//
+// CTrkUsbPortListener::IssueRequestL
+//
+void CTrkUsbPortListener::IssueRequestL()
+{		
+	if (IsActive()) //already listening, just return...
+		return;
+		
+	if ( iUsbDeviceState == EUsbDeviceStateUndefined )
+	{
+		User::LeaveIfError( iUsbServer.GetDeviceState( iUsbDeviceState ) );
+		
+	}
+	
+	iUsbServer.DeviceStateNotification(KTrkUsbDeviceStateMask, iUsbDeviceState, iStatus);
+	SetActive();	
+}
+
+//
+// CTrkUsbPortListener::StopListening
+// Cancel any pending requests for connection status notifications.
+//
+void CTrkUsbPortListener::StopListening()
+{
+	Cancel();	
+}
+
+//
+// CTrkUsbPortListener::DoCancel
+// This method gets called from CActive::Cancel();
+//
+void CTrkUsbPortListener::DoCancel()
+{
+	iUsbServer.DeviceStateNotificationCancel();	
+	iUsbDeviceState = EUsbDeviceStateUndefined;
+}
+
+//
+// CTrkUsbPortListener::RunL
+// This method gets called whenever there is a change in the connection status.
+// Right now we are interested only when the cable is disconnected. 
+// For all the other notifications, just reissues the request.
+//
+void CTrkUsbPortListener::RunL()
+{
+	User::LeaveIfError( iStatus.Int() );
+
+	iUsbServer.GetCurrentPersonalityId( iPersonalityId );
+	
+  	if ( iUsbDeviceState == EUsbDeviceStateUndefined ||
+         (iUsbDeviceState == EUsbDeviceStateConfigured && iPersonalityId != KPersonalityPCSuite) ) 
+	{
+		iConnectionListener->ConnectionUnAvailable();
+		iConnected = EFalse;
+	}
+	// There is something wrong USB cable status notifications
+	// When the cable is disconnected, first you get a notification 
+	// with the device state as configured.
+	// So we need to work around using a local status flag
+	else if ( iUsbDeviceState == EUsbDeviceStateConfigured &&
+			  iPersonalityId == KPersonalityPCSuite  && 
+			  !iConnected) 
+	{
+		iConnected = ETrue;
+		iConnectionListener->ConnectionAvailable();;
+	}		
+		IssueRequestL();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkUsbPortListener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef     _TRK_USBPORTLISTENER_H_
+#define     _TRK_USBPORTLISTENER_H_
+
+//  INCLUDES
+#include <e32std.h>
+#include <c32comm.h>
+#include <usbman.h>
+
+#include "TrkCommPortListener.h"
+#include "TrkEngine.h"
+
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+class CTrkUsbPortListener: public CTrkCommPortListener
+{
+
+    public:  
+
+		CTrkUsbPortListener(MTrkUsbConnectionListener *aConnectionListener);	
+        ~CTrkUsbPortListener();
+
+		// From CTrkCommPortListener
+        void ListenL();
+        void StopListening();
+
+    protected: 
+    	// From CActive
+        void DoCancel();
+        void RunL();	    
+
+	private:
+	
+		void IssueRequestL();
+
+		
+    private:    
+
+        RUsb                        iUsbServer;
+		TUsbDeviceState				iUsbDeviceState;
+		
+		TBool iConnected;
+		TInt iPersonalityId;
+};
+
+
+#endif      //  _TRK_USBPORTLISTENER_H_
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkXtiCommPort.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,252 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <e32cons.h>
+#include <f32file.h>
+
+#include "TrkConnData.h"
+#include "TrkXtiCommPort.h"
+#include "TrkFramingLayer.h"
+
+_LIT(KSendErrMsg, "Failed to write to the XTI channel");
+
+//
+// Default comm values
+//
+
+
+//
+// Static helper functions
+//
+
+//
+//
+// CTrkXtiCommPort implementation
+//
+//
+
+//
+// CTrkXtiCommPort constructor
+//
+CTrkXtiCommPort::CTrkXtiCommPort()
+	: CTrkCommPort(CActive::EPriorityStandard),
+	  iConnected(EFalse),
+	  iListening(EFalse),
+	  iLineNumber(0),
+	  iLddLoaded(EFalse)
+{
+}
+
+//
+// CTrkXtiCommPort::ConstructL
+//
+void CTrkXtiCommPort::ConstructL(TTrkConnData aTrkConnData, TDes& aErrorMessage)
+{
+
+	iLDD = aTrkConnData.iLDD;
+	// We don't really need this
+	//iUnitNumber = aTrkConnData.iPortNumber;
+
+	if (!iLDD.Size())
+	{
+		aErrorMessage.Format(_L("LDD not specified in init file\r\n"));		
+		User::Leave(KErrCorrupt);
+	}
+	
+}
+
+//
+// CTrkXtiCommPort destructor
+//
+CTrkXtiCommPort::~CTrkXtiCommPort()
+{
+	if (iLddLoaded)	
+	{				
+		//cancel the read request
+		iXtiDriver.ReadCancel();		
+		iXtiDriver.Close();
+
+		TInt err = User::FreeLogicalDevice(iLDD);
+		if (KErrNone != err)
+			User::Panic(_L("FreeLogicalDevice failed"), err);
+			
+		iLddLoaded = EFalse;
+	}
+	
+}
+
+//
+// CTrkXtiCommPort::NewL
+//
+CTrkXtiCommPort* CTrkXtiCommPort::NewL(TTrkConnData aTrkConnData, TDes& aErrorMessage)
+{
+	CTrkXtiCommPort* self = new(ELeave) CTrkXtiCommPort;
+	CleanupStack::PushL(self);
+	self->ConstructL(aTrkConnData, aErrorMessage);
+	CleanupStack::Pop(self);
+	return self;
+}
+
+//
+// CTrkXtiCommPort::OpenPortL
+//
+// Open the serial type communications port
+//
+void CTrkXtiCommPort::OpenPortL()
+{
+	TInt error = KErrNone;
+	
+	// make sure the LDD is not already loaded
+	User::FreeLogicalDevice(iLDD);
+
+	error = User::LoadLogicalDevice(iLDD);
+	if ((KErrAlreadyExists != error) && (KErrNone != error))
+		ReportAndLeaveIfErrorL(error, _L("Failed to load xti logical device."));	
+
+	error = iXtiDriver.Open();
+	if (KErrNone != error)
+		ReportAndLeaveIfErrorL(error, _L("Failed to open xti logical device."));
+		
+	iLddLoaded = ETrue;
+	
+	
+	_LIT(KXTIMSG, "Connection: XTI\r\nLDD: TrkXtiDriver\r\n");
+	
+	iConnectionMessage = KXTIMSG;
+}
+
+//
+// CTrkXtiCommPort::ClosePort
+//
+// Close the communications port
+//
+void CTrkXtiCommPort::ClosePort()
+{
+	Cancel();
+	
+	if (iLddLoaded)
+	{
+		//cancel the read request
+		iXtiDriver.ReadCancel();		
+		iXtiDriver.Close();
+		
+		TInt err = User::FreeLogicalDevice(iLDD);
+		if (KErrNone != err)
+			User::Panic(_L("FreeLogicalDevice failed"), err);
+
+		iLddLoaded = EFalse;			
+	}
+
+}
+
+//
+// CTrkXtiCommPort::SendDataL
+//
+// Write data to the serial type port
+//
+void CTrkXtiCommPort::SendDataL(const TDesC8& aBuffer)
+{
+	TInt err = iXtiDriver.Write(aBuffer);
+	
+	ReportAndLeaveIfErrorL(err, KSendErrMsg);
+}
+
+//
+// CTrkXtiCommPort::Listen
+//
+// Start listening for data coming into the serial type communications port
+//
+void CTrkXtiCommPort::Listen(CTrkFramingLayer *aFramingLayer)
+{
+	iFramingLayer = aFramingLayer;
+	CActiveScheduler::Add(this);
+	IssueReadRequest();
+	iListening = ETrue;
+}
+
+//
+// CTrkXtiCommPort::StopListening
+//
+// Stop listening for data coming into the serial type communications port
+//
+void CTrkXtiCommPort::StopListening()
+{
+	if (iListening)
+	{
+		Cancel();
+		Deque();
+	}
+	
+	iListening = EFalse;
+}
+
+//
+// CTrkXtiCommPort::ReportAndLeaveIfErrorL
+//
+// If an error occurred, print the error information to the screen and bail out
+//
+void CTrkXtiCommPort::ReportAndLeaveIfErrorL(TInt aError, const TDesC& aDesc)
+{
+	if (KErrNone != aError)
+	{
+		iErrorMessage.Format(_L("%S\r\nError Code: %d\r\n"), &aDesc, aError);
+		User::Leave(aError);
+	}
+}
+
+
+//
+// CTrkXtiCommPort::IssueReadRequest
+//
+// Wait for data to come into the communications port
+//
+void CTrkXtiCommPort::IssueReadRequest()
+{
+	iNextReadChar = 0;
+	iXtiDriver.ReadOneOrMore(iStatus, iReceivedChars);
+	SetActive();
+}
+
+//
+// CTrkXtiCommPort::DoCancel
+//
+// Cancel the request for data from the communications port
+//
+void CTrkXtiCommPort::DoCancel()
+{
+	iXtiDriver.ReadCancel();
+}
+
+//
+// CTrkXtiCommPort::RunL
+//
+// Called when data comes into the communications port
+//
+void CTrkXtiCommPort::RunL()
+{
+	// pass the data onto the framing layer
+	if (iStatus.Int() == KErrNone)
+	{
+		while (iNextReadChar < iReceivedChars.Length())
+			iFramingLayer->HandleByte(iReceivedChars[iNextReadChar++]);
+		//iXtiDriver.Write(iReceivedChars);
+	}
+	// continue waiting for data
+	IssueReadRequest();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/TrkXtiCommPort.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKXTICOMMPORT_H__
+#define __TRKXTICOMMPORT_H__
+
+#include "TrkCommPort.h"
+#include "TrkXtiComm.h"
+
+//
+// class CTrkXtiCommPort
+//
+// Defines an interface to Trace Core 
+//
+class CTrkXtiCommPort : public CTrkCommPort
+{
+public:
+
+	static CTrkXtiCommPort* NewL(TTrkConnData aTrkConnData, TDes& aErrorMessage);
+	~CTrkXtiCommPort();
+
+	void OpenPortL();
+	void ClosePort();
+
+	void SendDataL(const TDesC8& aData);
+	void Listen(CTrkFramingLayer *aFramingLayer);
+	void StopListening();
+
+protected:
+
+	void DoCancel();
+	void RunL();
+
+private:
+
+	CTrkXtiCommPort();
+	void ConstructL(TTrkConnData aTrkConnData, TDes& aErrorMessage);
+	void IssueReadRequest();
+	void ReportAndLeaveIfErrorL(TInt aError, const TDesC& aDesc);
+	
+private:
+
+	TBool iConnected;
+	TBool iListening;
+
+	TBuf8<MAXMESSAGESIZE> iReceivedChars;
+	TInt iNextReadChar;
+
+	CTrkFramingLayer* iFramingLayer;
+	
+	RTrkXtiDriver iXtiDriver;
+	
+	TBuf<32> iLDD;
+//	TUint iUnitNumber;
+	
+	TInt iLineNumber;
+	
+	TBool iLddLoaded;
+};
+
+#endif // __TRKXTICOMMPORT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/dstypes.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef _DSTYPES_H_
+#define _DSTYPES_H_
+
+#ifndef ui8
+typedef unsigned char	ui8;
+#endif
+
+#ifndef ui16
+typedef unsigned short	ui16;
+#endif
+
+#ifndef ui32
+typedef unsigned long	ui32;
+#endif
+
+typedef struct {
+	ui16	hword_0;
+	ui16	hword_1;
+	ui16	hword_2;
+	ui16	hword_3;
+	ui16	hword_4;
+} ui80;
+
+typedef struct {
+	ui32	word_0;
+	ui32	word_1;
+	ui32	word_2;
+	ui32	word_3;
+} ui128;
+
+#if __MWERKS__
+  #if __option( longlong )
+	typedef unsigned long long ui64;
+  #else /* NOT __option( longlong ) */
+    typedef struct {
+		ui32	word_0;
+		ui32	word_1;
+  	} ui64;
+  #endif /* if/else __option( longlong ) */
+#else /* NOT __MWERKS__ */
+  #if __GNUC__
+	typedef unsigned long long ui64;
+  #else /* NOT __GNUC__ */
+    typedef struct { ui32 word_0, word_1; } ui64;
+  #endif /* if/else __GNUC__ */
+#endif /* if/else __MWERKS__ */
+
+
+
+#if defined( __CWDS__ ) || defined( __NEED_BOOL__ ) /* see __config.h */
+	typedef int bool;
+	#define false (0)
+	#define true (1)
+#endif
+
+#endif /* _DSTYPES_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/in_sock.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,353 @@
+/*
+* Copyright (c) 1997-2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#if !defined(__IN_SOCK_H__)
+#define __IN_SOCK_H__
+
+#if !defined(__ES_SOCK_H__)
+#include <es_sock.h>
+#endif
+
+// Address family ID
+const TUint KAfInet				= 0x0800;
+
+// IP Protocol IDs
+const TUint KProtocolInetIcmp	= 1;
+const TUint KProtocolInetTcp	= 6;
+const TUint KProtocolInetUdp	= 17;
+const TUint KProtocolInetIp		= 0x100;	// Psuedo protocol
+
+// Socket option/ioctl levels
+const TUint KSolInetIcmp		= 0x101;
+const TUint KSolInetTcp			= 0x106;
+const TUint KSolInetUdp			= 0x111;
+const TUint KSolInetIp			= 0x100;
+const TUint KSolInetIfCtrl		= 0x201;
+const TUint KSolInetRtCtrl		= 0x202;
+const TUint KSolInetDnsCtrl		= 0x204;
+// Security specific
+const TUint KSolInetSSL			= 0x205;  // SSL setopts/ioctls
+
+// Maximum IPv4 address
+const TInt KInetAddrMaxBits         = 32;
+
+// Port constants
+const TUint KInetPortAny			= 0x0000;
+const TUint KInetPortNone			= 0x0000;
+const TUint KInetMinAutoPort		= 1024;
+const TUint KInetMaxAutoPort		= 5000;
+
+// Address constants and utilities
+#define INET_ADDR(a,b,c,d) (TUint32)(((a)<<24)|((b)<<16)|((c)<<8)|(d))
+
+const TUint32 KInetAddrAny				= INET_ADDR(0,0,0,0);
+const TUint32 KInetAddrNone				= INET_ADDR(0,0,0,0);
+const TUint32 KInetAddrAll				= INET_ADDR(255,255,255,255);
+const TUint32 KInetAddrBroadcast		= INET_ADDR(255,255,255,255);
+const TUint32 KInetAddrLoop				= INET_ADDR(127,0,0,1);
+
+const TUint32 KInetAddrGroupUnspec		= INET_ADDR(224,0,0,0);
+const TUint32 KInetAddrGroupAllHosts	= INET_ADDR(224,0,0,1);
+
+const TUint32 KInetAddrMaskAll			= INET_ADDR(0,0,0,0);
+const TUint32 KInetAddrMaskHost			= INET_ADDR(255,255,255,255);
+
+const TUint32 KInetAddrNetMaskA			= INET_ADDR(255,0,0,0);
+const TUint32 KInetAddrHostMaskA		= ~KInetAddrNetMaskA;
+const TInt KInetAddrShiftA				= 24;
+const TUint32 KInetAddrNetMaskB 		= INET_ADDR(255,255,0,0);
+const TUint32 KInetAddrHostMaskB		= ~KInetAddrNetMaskB;
+const TInt KInetAddrShiftB				= 16;
+const TUint32 KInetAddrNetMaskC 		= INET_ADDR(255,255,255,0);
+const TUint32 KInetAddrHostMaskC		= ~KInetAddrNetMaskC;
+const TInt KInetAddrShiftC				= 8;
+
+const TUint32 KInetAddrIdMaskA			= 0x80000000;
+const TUint32 KInetAddrIdValA			= 0x00000000;
+const TUint32 KInetAddrIdMaskB			= 0xc0000000;
+const TUint32 KInetAddrIdValB			= 0x80000000;
+const TUint32 KInetAddrIdMaskC			= 0xe0000000;
+const TUint32 KInetAddrIdValC			= 0xc0000000;
+const TUint32 KInetAddrIdMaskD			= 0xf0000000;
+const TUint32 KInetAddrIdValD			= 0xe0000000;
+const TUint32 KInetAddrIdMaskE			= 0xf8000000;
+const TUint32 KInetAddrIdValE			= 0xf0000000;
+
+enum TInetAddrClass
+	{
+	EInetClassUnknown = 0,
+	EInetClassA,
+	EInetClassB,
+	EInetClassC,
+	EInetClassD,
+	EInetClassE,
+	EInetMulticast = EInetClassD,
+	EInetExperimental = EInetClassE
+	};
+
+struct SInetAddr
+	{ TUint32 iAddr; };
+
+class TInetAddr : public TSockAddr
+	{
+public:
+	IMPORT_C TInetAddr();
+	IMPORT_C TInetAddr(const TSockAddr& anAddr);
+	IMPORT_C TInetAddr(TUint aPort);
+	IMPORT_C TInetAddr(TUint32 anAddr, TUint aPort);
+	//
+	IMPORT_C void SetAddress(TUint32 anAddr);
+	IMPORT_C TUint32 Address() const;
+	//
+	IMPORT_C TBool CmpAddr(const TInetAddr& anAddr) const;
+	IMPORT_C TBool Match(const TInetAddr& aHost) const;
+	IMPORT_C TBool Match(const TInetAddr& aNet, const TInetAddr& aMask) const;
+	//
+	IMPORT_C void Output(TDes &aBuf) const;
+    IMPORT_C TInt Input(const TDesC &aBuf);	// Accepts a, a.b, a.b.c, a.b.c.d or 0xaabbccdd
+	//
+	IMPORT_C void NetMask(const TInetAddr& aAddr);
+	IMPORT_C void Net(const TInetAddr& aAddr);
+	IMPORT_C void NetBroadcast(const TInetAddr& aAddr);
+	IMPORT_C void SubNet(const TInetAddr& aAddr, const TInetAddr& aMask);
+	IMPORT_C void SubNetBroadcast(const TInetAddr& aAddr, const TInetAddr& aMask);
+	//
+	inline TBool IsClassA();
+	inline TBool IsClassB();
+	inline TBool IsClassC();
+	inline TBool IsMulticast();
+	inline TBool IsBroadcast();	// == 255.255.255.255
+	inline TBool IsWildAddr();	// == 0.0.0.0
+	inline TBool IsWildPort();	// == 0
+	//
+	inline static TInetAddr& Cast(const TSockAddr& anAddr);
+	inline static TInetAddr& Cast(const TSockAddr* anAddr);
+protected:
+	inline SInetAddr *Addr4Ptr() const;
+	inline static TInt AddrLen();
+	};
+
+// Send/Recv Flags (Datagram sockets only)
+const TUint KIpDontFragment		= 0x010000;
+const TUint KIpHeaderIncluded	= 0x020000;
+const TUint KIpDontRoute		= 0x040000;
+
+// Structure returned by KSoInetLastError/KIoctlInetLastError
+class TSoInetLastErr
+	{
+public:
+	TInt iStatus;			// ESock error code
+	TInt iErrType;			// ICMP type
+	TInt iErrCode;			// ICMP code
+	TInetAddr iSrcAddr;		// Src of failed datagram
+	TInetAddr iDstAddr;		// Dst of failed datagram
+	TInetAddr iErrAddr;		// Addr of host that generated the error
+	};
+
+// Enumerating & Configuring Interfaces TPckgBuf<TSoInetInterfaceInfo>
+// With a level of KSolInetIfCtrl
+const TInt KSoInetEnumInterfaces = 0x211;
+const TInt KSoInetNextInterface = 0x212;
+const TInt KSoInetConfigInterface = 0x213;
+
+enum TIfStatus
+	{
+	EIfPending,
+	EIfUp,
+	EIfBusy,
+	EIfDown,
+	};
+
+class TSoInetInterfaceInfo
+	{
+public:
+	TName iTag;				// Interface tag
+	TName iName;			// Interface name
+	TIfStatus iState;		// State
+	TInt iMtu;				// max transmition size
+	TInt iSpeedMetric;		// Metric - bigger is better
+	TUint iFeatures;		// Feature flags
+	TSockAddr iHwAddr;		// Hardware address (*)
+	TInetAddr iAddress;		// Interface IP Address (*)
+	TInetAddr iNetMask;		// IP netmask
+	TInetAddr iBrdAddr;		// IP broadcast address
+	TInetAddr iDefGate;		// IP default gateway or peer address (if known)
+	TInetAddr iNameSer1;	// IP Primary name server (if any)
+	TInetAddr iNameSer2;	// IP Secondary name server (if any)
+	};
+
+// Enumerating & Configuring Routes TPckgBuf<TSoInetRouteInfo>
+// With a level of KSolInetRtCtrl
+const TInt KSoInetEnumRoutes = 0x221;
+const TInt KSoInetNextRoute = 0x222;
+const TInt KSoInetAddRoute = 0x223;
+const TInt KSoInetDeleteRoute = 0x224;
+const TInt KSoInetChangeRoute = 0x225;
+
+enum TRouteState
+	{
+	ERtNone,
+	ERtPending,		// Interface has been started as a dialup, but no info available
+	ERtBusy,		// Interface is up but flowed off
+	ERtReady,		// Interface is up and ready
+	ERtDown		    // Route is down and most likely to stay that way
+	};
+
+enum TRouteType
+	{
+	ERtNormal,		// Created when interface was started
+	ERtUser,		// Created by user - ie via SetOpt()
+	ERtIcmpAdd,		// Added by ICMP redirect
+	ERtIcmpDel		// Replaced by an ICMP redirect
+	};
+
+class TSoInetRouteInfo
+	{
+public:
+	TRouteType iType;		// Type of route (normal/icmp generated etc)
+	TRouteState iState;		// State of route
+	TInt iMetric;			// Smaller is better (less hops and/or faster link)
+	TInetAddr iIfAddr;		// IP address of interface used for this route
+	TInetAddr iGateway;		// IP address of gateway (might be the interface)
+	TInetAddr iDstAddr;		// Destination network or host
+	TInetAddr iNetMask;		// Destination mask of network (or host if KInetMaskHost)
+	};
+
+// Access to route cache TPckgBuf<TSoInetCachedRouteInfo>, set iDstAddr for required address
+// With a level of KSolInetRtCtrl
+const TInt KSoInetCachedRouteByDest = 0x225;
+
+class TSoInetCachedRouteInfo : public TSoInetRouteInfo
+	{
+public:
+	TInt iPathMtu;			// Set if used by DF datagram (incl TCP SYN), else 0
+	TUint iPathRtt;			// Set if used by TCP, else 0
+	};
+
+// Flags returned from DNS records
+enum TNameRecordFlags
+	{
+	EDnsAlias=0x00000001,		// Name is an Alias
+	EDnsAuthoritive=0x00000002, // Answer is authoritive 
+	EDnsHostsFile=0x00000004,   // Answer is from hosts file
+	EDnsServer=0x00000008,      // Answer is from a DNS server
+	EDnsHostName=0x00000010,    // Answer is host name for this host
+	EDnsCache=0x00000020		// Answer is from the resolver cache
+	};
+const TUint KSoDnsCacheEnable = 0x600; // Get/Set
+const TUint KSoDnsCacheFlush = 0x601; //Set
+
+// TCP specific options and ioctls with a level of KSolInetTcp
+// Ioclt
+const TUint KIoctlTcpNotifyDataSent = 0x300;
+// Options
+const TUint KSoTcpSendWinSize = 0x301; // Get/Set before connect
+const TUint KSoTcpRecvWinSize = 0x302; // Get/Set before connect
+const TUint KSoTcpMaxSegSize = 0x303; // Get/Set before connect
+const TUint KSoTcpNoDelay = 0x304; // Get/Set
+const TUint KSoTcpKeepAlive = 0x305; // Get/Set
+const TUint KSoTcpAsync2MslWait = 0x306; // Get/Set
+const TUint KSoTcpSendBytesPending = 0x307; //Get
+const TUint KSoTcpReadBytesPending = 0x308; //Get
+const TUint KSoTcpListening = 0x309; //Get
+const TUint KSoTcpNumSockets = 0x310; //Get
+const TUint KSoTcpReadUrgentData = 0x311; //Get
+const TUint KSoTcpPeekUrgentData = 0x312; //Get
+const TUint KSoTcpRcvAtMark = 0x313; //Get
+const TUint KSoTcpNextSendUrgentData = 0x314; //Get/Set
+const TUint KSoTcpOobInline = 0x315; //Set
+const TUint KSOTcpDebugMode = 0x11110000;
+// SECURITY SPECIFIC STUFF
+// At level KSolInetSSL
+const TUint KSoSecureSocket = 0x400;          // set/clear secure socket
+const TUint KSoSSLUnloadTimeout = 0x401;      // set/get SSL dll unload timeout
+const TUint KSoCurrentCipherSuite = 0x402;    // set/get current cipher suite
+const TUint KSoSSLServerCert = 0x403;	      // get current server cert
+const TUint KSoDialogMode = 0x404;            // set/get current dialog mode
+const TUint KSoAvailableCipherSuites = 0x405; // set/get supported cipher suites
+
+// For KSoTcpSecureSocket
+const TUint KSSLClearSecureStatus = 0x00; // disconnect SSL session
+const TUint KSSLSetSecureStatus = 0x01;   // complete connect on SSL connect
+
+// For KSoDialogMode
+const TUint KSSLDialogUnattendedMode = 0x00; // dialogs
+const TUint KSSLDialogAttendedMode = 0x01;   // no dialogs
+
+// Generic with a level of KSolInetIp
+const TUint KSoIpOptions = 0x401; // Set/Get
+const TUint KSoRawMode = 0x402; // Set/Get
+const TUint KSoHeaderIncluded = 0x403; // Set/Get
+const TUint KSoIpTOS = 0x404; // Set/Get
+const TUint KSoIpTTL = 0x405; // Set/Get
+const TUint KSoReuseAddr = 0x406; //Set/Get
+const TUint KSoNoInterfaceError = 0x407; //Set/Get
+const TUint KSoInetLastError = 0x200; // Get Last ICMP error TPckgBuf<TSoInetLastErr>
+const TUint KIoctlInetLastError = 0x200; // Exactly the same a the GetOpt
+
+// UDP specific with a level of KSolInetUdp
+const TUint KSoUdpReceiveICMPError = 0x500; //Set/Get
+
+// Extended error codes
+const TInt KErrNetUnreach = -190;
+const TInt KErrHostUnreach = -191;
+const TInt KErrNoProtocolOpt = -192;
+const TInt KErrUrgentData = -193;
+
+inline SInetAddr* TInetAddr::Addr4Ptr() const
+	{ return (SInetAddr*)UserPtr(); }
+class TInetReserved0
+	{
+public:
+	union
+		{
+		TUint8  ixxx0[16];
+		TUint16 ixxx1[8];
+		TUint32 ixxx2[4];
+		} uxxx;
+	};
+struct TInetReserved1
+	{
+	TInetReserved0 ixxx0;
+	TUint32 ixxx1;
+	TUint32 ixxx2;
+	};
+
+inline TInt TInetAddr::AddrLen()
+	{ return sizeof(TInetReserved1); }
+
+inline TInetAddr& TInetAddr::Cast(const TSockAddr& anAddr)
+	{ return *((TInetAddr*)&anAddr); }
+inline TInetAddr& TInetAddr::Cast(const TSockAddr* anAddr)
+	{ return *((TInetAddr*)anAddr); }
+inline TBool TInetAddr::IsBroadcast()
+	{ return Address()==KInetAddrBroadcast; }
+inline TBool TInetAddr::IsWildPort()
+	{ return Port()==KInetPortNone; }
+inline TBool TInetAddr::IsWildAddr()
+	{ return Address()==KInetAddrNone; }
+inline TBool TInetAddr::IsClassA()
+	{ return (Address() & KInetAddrIdMaskA) == KInetAddrIdValA; }
+inline TBool TInetAddr::IsClassB()
+	{ return (Address() & KInetAddrIdMaskB) == KInetAddrIdValB; }
+inline TBool TInetAddr::IsClassC()
+	{ return (Address() & KInetAddrIdMaskC) == KInetAddrIdValC; }
+inline TBool TInetAddr::IsMulticast()
+	{ return (Address() & KInetAddrIdMaskD) == KInetAddrIdValD; }
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/isv_trkengine_uiq.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+TARGET		TrkEngine.dll
+TARGETTYPE	dll
+UID		0x00000000 0x200159D9
+
+VENDORID 0x101FB657
+CAPABILITY ALL -TCB -DRM
+
+macro __UIQ_BUILD__
+
+SOURCEPATH	.
+
+SOURCE		TrkEngine.cpp TrkDispatchLayer.cpp TrkFramingLayer.cpp
+SOURCE		TrkSerialCommPort.cpp TrkBtSocketCommPort.cpp DateTimeConverter.cpp
+SOURCE 		TrkEngineModel.cpp TrkUsbPortListener.cpp
+SOURCE		TrkSwInstall.cpp TrkSwInstUIHandler.cpp
+
+LIBRARY		efsrv.lib euser.lib c32.lib sishelper.lib btdevice.lib 
+LIBRARY     bluetooth.lib qbtsharedui.lib btextnotifiers.lib esock.lib
+LIBRARY     usbman.lib usbostcomm.lib
+
+SYSTEMINCLUDE	\epoc32\include
+SYSTEMINCLUDE	\epoc32\include\kernel
+USERINCLUDE	. 
+
+#if defined(EKA2)
+USERINCLUDE	..\eka2driver
+#else
+USERINCLUDE	..\driver
+#endif
+
+
+#if defined(WINS)
+    deffile .\trkengU_win.def
+#elif defined(EABI)
+    deffile ..\eabi\isv_trkengine.def
+#endif
+nostrictdef
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/msgcmd.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,3132 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __MSGCMD_H__
+#define __MSGCMD_H__
+
+
+#include "dstypes.h"
+
+/*
+** This is the maximum number of fields that will be encountered
+** in a message, including the header field(s).
+*/
+#define DS_MAXMESSAGEFIELDCOUNT	15
+
+/*
+** Some items are declared here only for debug purposes (e.g., 
+** string names for messages and fields).  The following macros
+** allow these items to be removed when debugging is disabled,
+** eliminating otherwise wasted data space.
+*/
+#ifndef DEBUG_MSGCMD
+	#error "DEBUG_MSGCMD must be defined to either 0 or 1"
+#endif
+
+#if DEBUG_MSGCMD
+	#define __debug_only_parm( x )		x,
+	#define __debug_only_field( x )		x;
+#else
+	#define __debug_only_parm( x )
+	#define	__debug_only_field( x )
+#endif
+
+/*
+** Descriptor for a message field.
+*/
+typedef struct TrkMsgFieldDesc
+{
+	__debug_only_field( char *name )	/* Field name - for debugging */
+	int length;							/* Length of the field in bytes */
+} TrkMsgFieldDesc;
+
+/*
+** Use this macro to initialize TrkMsgFieldDesc variables.
+*/
+#define __trk_msg_field( name, length )	{ __debug_only_parm( name ) length }
+
+/*
+** Descriptor for a message.  Each message consists of a header followed
+** by additional fields.  Note that length, count, and farray should
+** only account for the additional fields.  For example: if the header
+** has 1 field and the message has 3 additional fields (4 total), count
+** should be 3.
+**
+** Only fixed-length numeric fields should be included in the descriptor.
+** Variable-length portions of a message, such as memory data, are
+** typically handled by code that is specific to the message type.
+** They are outside the scope of the general-purpose routines which use
+** these descriptors.
+*/
+//#if __MWERKS__
+#if 0	/* SCM: MIPS compiler defect generates bad code in this case */
+	#define __TrkMsgFieldMax
+#else
+	#define __TrkMsgFieldMax	DS_MAXMESSAGEFIELDCOUNT
+#endif /* #if __MWERKS__ */
+
+typedef struct TrkMsgDesc
+{
+	__debug_only_field( char *name )	/* Message name - for debugging */
+	const struct TrkMsgDesc	*header;	/* Descriptor for header/previous fragment */
+	int 				length;			/* Length of the message in bytes */
+	unsigned int 		count;			/* Number of fields in the message */
+	TrkMsgFieldDesc 	farray[__TrkMsgFieldMax];/* Descriptors for the message fields */
+} TrkMsgDesc;
+
+
+#ifdef TRK_MSGCMD_INIT
+	#define DESCDECLNC			
+	#define DESCDECL			const
+#else
+	#define DESCDECLNC			extern
+	#define DESCDECL			extern const
+#endif
+
+/****************************************************************************/
+/*
+ *	Commands
+ *
+ *	constant definitions of commands sent from host to target
+ *
+ *	L1 = Level 1 CWDS (required)
+ *	L2 = Level 2 CWDS (extended board-level debugger)
+ *	L3 = Level 3 CWDS (OS-level debugger)
+ */
+/****************************************************************************/
+
+#define DS_PROTOCOL_MIN			1	/* L1 */
+#define DS_PROTOCOL_BOARD		2	/* L2 */
+#define DS_PROTOCOL_RTOS		3	/* L3 */
+
+#if (!defined( DS_PROTOCOL )) || (DS_PROTOCOL == 0)
+	#pragma error "Protocol level must be defined"
+#endif
+
+/*
+** The current protocol version.
+*/
+
+#define DS_PROTOCOL_MAJOR_VERSION_3	3
+#define DS_PROTOCOL_MINOR_VERSION_0 0
+
+#define DS_PROTOCOL_MINOR_VERSION_1 1
+#define DS_PROTOCOL_MINOR_VERSION_2 2
+#define DS_PROTOCOL_MINOR_VERSION_3 3
+#define DS_PROTOCOL_MINOR_VERSION_4 4
+#define DS_PROTOCOL_MINOR_VERSION_5 5
+#define DS_PROTOCOL_MINOR_VERSION_6 6
+
+
+#define DS_PROTOCOL_MAJOR_VERSION	DS_PROTOCOL_MAJOR_VERSION_3
+#define DS_PROTOCOL_MINOR_VERSION   DS_PROTOCOL_MINOR_VERSION_6
+#define DS_PROTOCOL_VERSION_STRING	version_str( DS_PROTOCOL_MAJOR_VERSION, \
+												 DS_PROTOCOL_MINOR_VERSION )
+
+/*
+** Named constants for significant protocol revisions can be added
+** here (the existing definitions should not be changed).
+*/
+
+/* Sequence IDs were introduced in version 2.0 */
+#define DS_PROTOCOL_MAJOR_VERSION_SEQUENCEIDS	2
+#define DS_PROTOCOL_MINOR_VERSION_SEQUENCEIDS	0
+
+/* Multi-channel communication, ethernet, & other comm enhancements in 3.0 */
+#define DS_PROTOCOL_MAJOR_VERSION_MULTICHANNEL	3
+#define DS_PROTOCOL_MINOR_VERSION_MULTICHANNEL	0
+
+
+#if __MWERKS__
+#pragma mark  MessageCommandID command value list
+#endif /* __MWERKS__ */
+
+/****************************************************************************/
+/*
+ *	MessageCommandID command value list
+ */
+/****************************************************************************/
+
+typedef enum MessageCommandID
+{
+	/* meta commands, minimum feature set */
+	
+	kDSPing						= 0x00,		/*					*/
+	kDSConnect					= 0x01,		/*	L1	L2	L3		*/
+	kDSDisconnect				= 0x02,		/*			L3		*/
+	kDSReset					= 0x03,		/*		L2	L3		*/
+	kDSVersions					= 0x04,		/*	L1	L2	L3		*/
+	kDSSupportMask              = 0x05,     /*  L1	L2	L3      */
+	kDSCPUType					= 0x06,		/*		L2	L3		*/
+	kDSConfigTransport			= 0x07,		/*		L2	L3		*/
+	kDSVersions2				= 0x08,		/*	L1	L2	L3		*/
+	kDSHostVersions				= 0x09,
+	
+	/* state commands */
+	
+	kDSReadMemory				= 0x10,		/*	L1	L2	L3		*/
+	kDSWriteMemory				= 0x11,		/*	L1	L2	L3		*/
+	kDSReadRegisters			= 0x12,		/*	L1	L2	L3		*/
+	kDSWriteRegisters			= 0x13,		/*	L1	L2	L3		*/
+	kDSFillMemory				= 0x14,		/*					*/
+	kDSCopyMemory				= 0x15,		/*					*/
+	kDSFlushCache				= 0x16,		/*					*/
+
+	/* execution commands */
+	
+	kDSContinue					= 0x18,		/*	L1	L2	L3		*/
+	kDSStep						= 0x19,		/*		L2	L3		*/
+	kDSStop						= 0x1a,		/*		L2	L3		*/
+	kDSSetBreak					= 0x1b,		/*		L2	L3		*/
+	kDSClearBreak				= 0x1c,		/*		L2	L3		*/
+	kDSDownload					= 0x1d,		/*					*/
+	kDSModifyBreakThread		= 0x1e,		/*			L3		*/
+	/* Note: kDSSetWatch & kDSClearWatch are obsolete and have been removed */
+	
+	/* host->target IO management */
+	kDSNotifyFileInput			= 0x20,		/*		L2	L3		*/
+	kDSBlockFileIo				= 0x21,		/*		L2	L3		*/
+	
+	/* host->target OS commands */
+	
+	kDSOSCreateItem				= 0x40,		/*			L3		*/
+	kDSOSDeleteItem				= 0x41,		/*			L3		*/
+	kDSOSReadInfo				= 0x42,		/*			L3		*/
+	kDSOSWriteInfo				= 0x43,		/*			L3		*/
+
+	kDSOSWriteFile				= 0x48,		/*			L3		*/
+	kDSOSReadFile				= 0x49,		/*			L3		*/
+	kDSOSOpenFile				= 0x4a,		/*			L3		*/
+	kDSOSCloseFile				= 0x4b,		/*			L3		*/
+	kDSOSPositionFile			= 0x4c,		/*			L3		*/
+	kDSOSInstallFile			= 0x4d,		/*			L3		*/
+	kDSOSInstallFile2			= 0x4e,		/*			L3		*/
+	
+	kDSOSPhoneSWVersion         = 0x4f,		/*			L3		*/
+	kDSOSPhoneName              = 0x50,		/*			L3		*/
+	kDSVersions3				= 0x51,		/*	L1	L2	L3		*/
+	/*
+	 * 0x70 - 0x7F reserved for host->target target-specific commands
+	 */
+
+	/* replies */
+	
+	kDSReplyACK					= 0x80,		/*	L1	L2	L3		*/
+	kDSReplyNAK					= 0xFF,		/*	L1	L2	L3		*/
+	
+	
+	/*
+	 * target->host notification
+	 */
+	
+	kDSNotifyStopped			= 0x90,		/*	L1	L2	L3		*/
+	kDSNotifyException			= 0x91,		/*  OBSOLETE!       */
+		/* kDSNotifyException (0x91) is included for historical */
+		/* reasons only; DON'T IMPLEMENT IN NEW DEBUG NUB CODE! */
+	kDSNotifyInternalError		= 0x92,		/*					*/
+//not used, remove?	kDSNotifyBreak				= 0x93,		/*		L2	L3		*/
+	kDSNotifyStopped2			= 0x94,		/*			L3		*/
+	
+	/*
+	 * target->host OS notification
+	 */
+	
+	kDSOSNotifyCreated			= 0xa0,		/*			L3		*/
+	kDSOSNotifyDeleted			= 0xa1,		/*			L3		*/
+	kDSOSNotifyProcessorStarted	= 0xa2,		/*          L3      */
+	kDSOSNotifyProcessorStandby	= 0xa6,		/*			L3		*/
+	kDSOSNotifyProcessorReset	= 0xa7,		/*			L3		*/
+	
+	/*
+	 * target->host support commands
+	 */
+
+	kDSWriteFile				= 0xD0,		/*		L2	L3		*/
+	kDSReadFile					= 0xD1,		/*		L2	L3		*/
+	kDSOpenFile					= 0xD2,		/*		L2	L3		*/
+	kDSCloseFile				= 0xD3,		/*		L2	L3		*/
+	kDSPositionFile				= 0xD4		/*		L2	L3		*/
+	
+	/*
+	 * 0xE0 - 0xEF reserved for target->host target-specific commands
+	 */
+} MessageCommandID;
+
+/****************************************************************************/
+/*
+ *
+ *	Formatted data for messages sent between host and target.
+ *
+ *	Primitive Scalar Types:
+ *
+ *		Only use hard data types with fixed sizes:
+ *		ui8		8-bit unsigned integer
+ *		ui16	16-bit unsigned integer
+ *		ui32	32-bit unsigned integer
+ *		ui8 []	array of bytes
+ *		char[]	array of characters (C string)
+ *		etc.
+ *	
+ *	Endian:
+ *
+ *		Messages are sent in big-endian format.
+ *
+ *		Example layouts:
+ *
+ *   Type Value                  Big Endian                    Little Endian
+ * -------------------- ---------------------------     ---------------------------
+ *    ui8 0x12          [0x12]                          [0x12]
+ *   ui16 0x1234        [0x12] [0x34]					[0x34] [0x12]
+ *   ui32 0x12345678    [0x12] [0x34] [0x56] [0x78]     [0x78] [0x56] [0x34] [0x12]
+ *  ui8[] 0x12 0x34     [0x12] [0x34]                   [0x12] [0x34]
+ * ui16[] 0x1234 0x5678 [0x12] [0x34] [0x56] [0x78]     [0x34] [0x12] [0x78] [0x56]
+ * ui32[] 0x12345678    [0x12] [0x34] [0x56] [0x78]     [0x78] [0x56] [0x34] [0x12]
+ *        0x9ABCDEF0    [0x9A] [0xBC] [0xDE] [0xF0]     [0xF0] [0xDE] [0xBC] [0x9A]
+ * char[] "Abcd 234"    [0x41] [0x62] [0x63] [0x64]     [0x41] [0x62] [0x63] [0x64]
+ *                      [0x20] [0x32] [0x33] [0x34]     [0x20] [0x32] [0x33] [0x34]
+ *
+ *	Alignment:
+ *		
+ *    Messages have no alignment restrictions.  For transmission efficiency,
+ *    alignment padding is not recommended in messages.
+ */
+/****************************************************************************/
+
+#if __MWERKS__
+#pragma mark  -
+#pragma mark Message Formats
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	M E S S A G E  F O R M A T S
+ */
+/****************************************************************************/
+
+#if __MWERKS__
+#pragma mark  Message Header (common)
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	Message Header (new format):
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		sequenceId			- (1) sequence ID of message
+ *									  <2> total
+ *	- OR - (old format):
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *									  <1> total
+ *
+ *	All messages, including replies begin with this header.  Some may consist
+ *	of nothing else (e.g., the Reset message).  Others contain additional
+ *	information following the header.
+ *
+ *	Currently MetroTRK only supports sending 1 message at a time, which
+ *	means that the sender must wait for a reply to each message before
+ *	sending the next message.  For this case, the sequence IDs follow
+ *	these rules:
+ *		- For non-reply messages, the sequence ID should be 1 larger
+ *		  than the sequence ID of the previous message from the same
+ *		  sender, or 0x01 if the previous value was 0xFF.  The host
+ *		  and target sequence ID's are independent.
+ *		  A sequence ID of 0 is a special case.  It is always valid
+ *		  and resets the sequence so that the next expected ID is 1
+ *        for both the host and target.
+ *		- For ACK reply messages, the sequence ID should equal the
+ *		  sequence ID of the message to which it is replying.
+ *		- For NAK reply messages, if the error code is 
+ *		  kDSReplySequenceMissing then the sequence ID should be the
+ *		  next value that was expected by the receiver.  For
+ *		  any other error code, the sequence ID is indeterminate.
+ *		- If a received, non-reply sequence ID is the same as the 
+ *		  previous received sequence ID, the receiver should re-send
+ *		  the reply to the previous message *without* re-processing
+ *		  the message.  It is important for certain messages (e.g., file
+ *		  writes) that duplicates not be re-processed.
+ *		- If a received, non-reply sequence ID is not equal to the
+ *		  previous received sequence ID, the next expected ID, or 0,
+ *		  the receiver should send a NAK reply with the
+ *		  kDSReplySequenceMissing error code and discard the
+ *		  received message.
+ *
+ *	The sequenceId field is new in version 2.0 of the protocol.  For
+ *	backwards compatibility, descriptors are included for both the new
+ *	and the old header formats.  The new format will be used by default,
+ *	but it can be changed at runtime.  The old format can also be forced
+ *	at build time by defining the following in target.h:
+ *		#define TRK_MSG_SEQUENCE_IDS		0
+ *
+ */
+/****************************************************************************/
+#define TRK_MSG_HEADER_LENGTH		(gTrkMsgHeader.length)
+#define TRK_MSG_HEADER_COUNT		2				/* 2 field in header */
+
+/*
+** For L1 and L2, sequence IDs are disabled by default.  For L3 they are
+** enabled by default.  Individual targets can override this setting by
+** defining TRK_MSG_SEQUENCE_IDS in target.h.
+*/
+
+#ifndef TRK_MSG_SEQUENCE_IDS
+	#if DS_PROTOCOL < DS_PROTOCOL_RTOS
+		#define TRK_MSG_SEQUENCE_IDS		0
+	#else
+		#define TRK_MSG_SEQUENCE_IDS		1
+	#endif
+#endif
+
+/* The current header descriptor as of protocol version 2.0 */
+#define TRK_MSG_HEADER_20_INIT \
+{ \
+	__debug_only_parm( "Header" ) \
+	NULL,										/* previous fragment/header */ \
+	2,											/* # of bytes */ \
+	TRK_MSG_HEADER_COUNT,						/* # of fields */ \
+	{						/* field descriptors: */ \
+		__trk_msg_field( "command", 1 ), \
+		__trk_msg_field( "sequence ID", 1 ) \
+	} \
+}
+
+DESCDECL TrkMsgDesc gTrkMsgHeader20
+#ifdef TRK_MSGCMD_INIT
+= TRK_MSG_HEADER_20_INIT
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* The old header descriptor prior to protocol version 2.0 */
+#define TRK_MSG_HEADER_PRE_20_INIT \
+{ \
+	__debug_only_parm( "Header" ) \
+	NULL,										/* previous fragment/header */ \
+	1,											/* # of bytes */ \
+	TRK_MSG_HEADER_COUNT,						/* # of fields */ \
+	{						/* field descriptors: */ \
+		__trk_msg_field( "command", 1 ), \
+		__trk_msg_field( "sequence ID (N/A)", 0 )		/* placeholder to make indices consistent */ \
+	} \
+}
+
+DESCDECL TrkMsgDesc gTrkMsgHeaderPre20
+#ifdef TRK_MSGCMD_INIT
+= TRK_MSG_HEADER_PRE_20_INIT
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* Use new header by default - can be changed at runtime. */
+DESCDECLNC TrkMsgDesc gTrkMsgHeader
+#ifdef TRK_MSGCMD_INIT
+	#if TRK_MSG_SEQUENCE_IDS
+		= TRK_MSG_HEADER_20_INIT;
+	#else
+		= TRK_MSG_HEADER_PRE_20_INIT
+	#endif
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields. */
+#define TRK_MSG_COMMAND_INDEX	0
+#define TRK_MSG_SID_INDEX		1
+
+#if __MWERKS__
+#pragma mark  Reply Header (common)
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	Reply Message Header
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui8		error				- (1) CWDS error value
+ *									  <1 + header> total
+ *
+ *	The command for a reply message must be either kDSReplyACK or kDSReplyNAK.
+ *
+ *	A NAK reply indicates that an invalid message or portion of a message
+ *  was received.  The error value will specify the problem.
+ *
+ *	An ACK with an error value other than kDSReplyNoError indicates that 
+ *	the message was valid but could not be processed for some reason (e.g.,
+ *	invalid memory ranges, bad parameters, etc.).  The error value will
+ *	specify the problem.
+ *
+ *	Some command replies include additional information that is specific to
+ *  the command.  This additional information is included ONLY if the 
+ *  reply is an ACK with kDSReplyNoError.
+ */
+/****************************************************************************/
+#define TRK_MSG_REPLY_HEADER_LENGTH	(1 + TRK_MSG_HEADER_LENGTH)	/* 1 addl bytes  */
+#define TRK_MSG_REPLY_HEADER_COUNT	(1 + TRK_MSG_HEADER_COUNT)	/* 1 addl fields */
+
+DESCDECL TrkMsgDesc gTrkMsgReplyHeader
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Reply Header" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	1,											/* # of addl bytes */
+	1,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "error", 1 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_REPLY_ERROR_INDEX			(0 + TRK_MSG_HEADER_COUNT)
+
+/* Retain these for compatibility with older code */
+#define DS_MIN_MSG_LENGTH					TRK_MSG_HEADER_LENGTH
+#define DS_MIN_REPLY_LENGTH					TRK_MSG_REPLY_HEADER_LENGTH
+
+/****************************************************************************/
+/*
+ *	Required Send and Reply Messsages
+ */
+/****************************************************************************/
+
+#if __MWERKS__
+#pragma mark  Ping
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSPing
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *	
+ *	Can be sent by the host at any time.  Simply replies with an
+ *	ACK.  Currently not supported.
+ */
+/****************************************************************************/
+ 
+#define DS_MIN_MSG_PING_LENGTH				DS_MIN_MSG_LENGTH
+#define DS_MIN_REPLY_PING_LENGTH			DS_MIN_REPLY_LENGTH
+ 
+
+#if __MWERKS__
+#pragma mark  Connect
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSConnect
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *
+ *	The host should send a connect message once at the beginning of
+ *	a debug session.
+ */
+/****************************************************************************/
+
+#define DS_MIN_MSG_CONNECT_LENGTH			DS_MIN_MSG_LENGTH
+#define DS_MIN_REPLY_CONNECT_LENGTH			DS_MIN_REPLY_LENGTH
+
+#if __MWERKS__
+#pragma mark  Disconnect
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSDisconnect
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *
+ *	The host should send a disconnect message once at the end of
+ *	a debug session.
+ */
+/****************************************************************************/
+
+#define DS_MIN_MSG_DISCONNECT_LENGTH		DS_MIN_MSG_LENGTH
+#define DS_MIN_REPLY_DISCONNECT_LENGTH		DS_MIN_REPLY_LENGTH
+
+#if __MWERKS__
+#pragma mark  Reset
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSReset
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *
+ *  Sent by the host.  Causes a soft reset on the target board.  The
+ *	ACK reply is sent before reset.  The host should also expect a 
+ *	welcome message after reset.
+ */
+/****************************************************************************/
+
+#define DS_MIN_MSG_RESET_LENGTH				DS_MIN_MSG_LENGTH
+#define DS_MIN_REPLY_RESET_LENGTH			DS_MIN_REPLY_LENGTH
+
+#if __MWERKS__
+#pragma mark  Versions
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSVersions
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui8		kernelMajor			- (1)
+ *		ui8		kernelMinor			- (1)
+ *		ui8		protocolMajor		- (1)
+ *		ui8		protocolMinor		- (1)
+ *									  <4 + header> total
+ *
+ *	Sent by the host, returns TRK version numbers.
+ */
+/****************************************************************************/
+#define DS_MIN_MSG_VERSIONS_LENGTH			DS_MIN_MSG_LENGTH
+
+DESCDECL TrkMsgDesc gTrkMsgVersionsReply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Versions Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	4,											/* # of addl bytes */
+	4,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "kernel major", 1 ),
+		__trk_msg_field( "kernel minor", 1 ),
+		__trk_msg_field( "protocol major", 1 ),
+		__trk_msg_field( "protocol minor", 1 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_VR_KMAJOR_INDEX		(0 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_VR_KMINOR_INDEX		(1 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_VR_PMAJOR_INDEX		(2 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_VR_PMINOR_INDEX		(3 + TRK_MSG_REPLY_HEADER_COUNT)
+
+#if __MWERKS__
+#pragma mark  CPUType
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSCPUType
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui8		CPU major type		- (1) DS_CPU_MAJOR_* (see below)
+ *		ui8		CPU minor type		- (1) DS_CPU_* (see below)
+ *		ui8		big_endian			- (1) 1 ==> big endian, 0 ==> little endian
+ *		ui8		default type size	- (1) size of DefaultType
+ *		ui8		FP type size 		- (1) size of FPType (0 if unsupported)
+ *		ui8		extended1 type size - (1) size of Extended1Type (0 if unsupported)
+ *		ui8		extended2 type size - (1) size of Extended2Type (0 if unsupported)
+ *									  <7 + header> total
+ *
+ *	Sent by the host, returns information indicating the CPU type and
+ *	CPU implementation details for the target system.
+ */
+/****************************************************************************/
+#define DS_MIN_MSG_CPUTYPE_LENGTH			DS_MIN_MSG_LENGTH
+
+DESCDECL TrkMsgDesc gTrkMsgCpuTypeReply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "CPU Type Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	7,											/* # of addl bytes */
+	7,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "CPU major", 1 ),
+		__trk_msg_field( "CPU minor", 1 ),
+		__trk_msg_field( "big endian", 1 ),
+		__trk_msg_field( "default type size", 1 ),
+		__trk_msg_field( "FP type size", 1 ),
+		__trk_msg_field( "extended1 type size", 1 ),
+		__trk_msg_field( "extended2 type size", 1 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_CTR_CMAJOR_INDEX			(0 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_CTR_CMINOR_INDEX			(1 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_CTR_BIGENDIAN_INDEX			(2 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_CTR_DEFAULT_SIZE_INDEX		(3 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_CTR_FP_SIZE_INDEX			(4 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_CTR_EXTENDED1_SIZE_INDEX	(5 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_CTR_EXTENDED2_SIZE_INDEX	(6 + TRK_MSG_REPLY_HEADER_COUNT)
+
+/*
+** CPU Major types.
+*/
+
+#define DS_CPU_MAJOR_PPC					0x00
+#define DS_CPU_MAJOR_MIPS					0x01
+#define DS_CPU_MAJOR_NEC_V8XX				0x02
+#define DS_CPU_MAJOR_MOT_DSP				0x03
+#define DS_CPU_MAJOR_ARM					0x04
+#define DS_CPU_MAJOR_X86					0x05
+#define DS_CPU_MAJOR_MCORE					0x06
+#define DS_CPU_MAJOR_M68K					0x07	/* includes ColdFire */
+#define DS_CPU_MAJOR_SUPERH					0x08
+#define DS_CPU_MAJOR_STARCORE				0x09
+
+/*
+** ARM CPU minor types.
+*/
+
+#define DS_CPU_ARM_920T					0x00
+
+/*
+** MIPS CPU minor types.
+*/
+
+#define DS_CPU_MIPS_R3000				0x00
+#define DS_CPU_MIPS_R3081E				0x01
+
+#define DS_CPU_MIPS_VR4100				0x20
+#define DS_CPU_MIPS_VR4300				0x21
+#define DS_CPU_MIPS_VR4500				0x22
+#define DS_CPU_MIPS_VR4111				0x23
+#define DS_CPU_MIPS_TR4101				0x24
+#define DS_CPU_MIPS_EZ4103				0x25
+#define DS_CPU_MIPS_RM7000				0x26
+#define DS_CPU_MIPS_MIPS32_4kc			0x27
+#define DS_CPU_MIPS_RM5231				0x28
+
+#define DS_CPU_MIPS_VR5000				0x40
+
+
+/*
+** PowerPC CPU minor types.
+*/
+
+#define	DS_CPU_PPC_403					0x00
+
+#define DS_CPU_PPC_5XX					0x20	/* used when not precisely known */
+#define DS_CPU_PPC_505					0x21
+#define DS_CPU_PPC_509					0x22
+#define DS_CPU_PPC_50X					0x27	/* used when not precisely known */
+#define DS_CPU_PPC_555					0x28
+
+#define DS_CPU_PPC_603E					0x40
+
+#define DS_CPU_PPC_7XX					0x50	/* used when not precisely known */
+#define DS_CPU_PPC_740					0x51
+#define DS_CPU_PPC_750					0x52
+#define DS_CPU_PPC_7400                 0x53
+#define DS_CPU_PPC_7410                 0x54
+
+#define DS_CPU_PPC_8260					0x61
+
+#define DS_CPU_PPC_8XX					0x80	/* used when not precisely known */
+#define DS_CPU_PPC_821					0x81
+#define DS_CPU_PPC_823					0x82
+#define DS_CPU_PPC_860					0x83
+
+
+/*
+** NEC V8xx CPU minor types.
+*/
+
+#define DS_CPU_NEC_V8XX_V810			0x00
+#define DS_CPU_NEC_V8XX_V821			0x01
+
+#define DS_CPU_NEC_V8XX_V830			0x10
+#define DS_CPU_NEC_V8XX_V831			0x11
+#define DS_CPU_NEC_V8XX_V832			0x12
+
+#define DS_CPU_NEC_V8XX_V850			0x20
+#define DS_CPU_NEC_V8XX_V853			0x21
+#define DS_CPU_NEC_V8XX_V850E			0x22
+#define DS_CPU_NEC_V8XX_V850_SA1		0x23
+
+/*
+** M68K/Coldfire CPU minor types.
+*/
+
+#define DS_CPU_M68K_68000				0x00
+#define DS_CPU_M68K_68020				0x02
+#define DS_CPU_M68K_68030				0x04
+#define DS_CPU_M68K_68040				0x06
+#define DS_CPU_M68K_68060				0x08
+
+#define DS_CPU_M68K_68302				0x20
+#define DS_CPU_M68K_68306				0x22
+#define DS_CPU_M68K_68307				0x24
+#define DS_CPU_M68K_68328				0x26
+#define DS_CPU_M68K_68EZ328				0x28
+#define DS_CPU_M68K_68VZ328				0x29
+#define DS_CPU_M68K_68340				0x2a
+#define DS_CPU_M68K_68360				0x2c
+
+#define DS_CPU_M68K_CF5102				0x80
+#define DS_CPU_M68K_CF5202				0x82
+#define DS_CPU_M68K_CF5204				0x84
+#define DS_CPU_M68K_CF5206				0x86
+#define DS_CPU_M68K_CF5206E				0x88
+#define DS_CPU_M68K_CF5307				0x8a
+
+/*
+** MCore CPU minor types.
+*/
+
+#define DS_CPU_MCORE_200				0x00
+#define DS_CPU_MCORE_340				0x20
+
+/*
+** STARCORE CPU minor types
+*/
+
+#define DS_CPU_STARCORE_8101			0x01
+#define	DS_CPU_STARCORE_8102			0x02
+
+#if __MWERKS__
+#pragma mark  SupportMask
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSSupportMask
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *
+ *	Reply:
+ *
+ *		ui8		command				- (1) ack/nak MessageCommandID
+ *		ui8		error				- (1) CWDS error value
+ *		ui8		mask[32]			- (32) DSSupportMask
+ *		ui8		protocolLevel		- (1) value of DS_PROTOCOL (1-3)
+ *									  <34>
+ *
+ *	Sent by the host, returns support mask indicating which commands are
+ *	supported by that particular TRK.
+ */
+/****************************************************************************/
+
+/*
+ * Meaning: (bit x == 1) <==> (command x is supported)
+ * where bit 0 is the least significant bit of mask[0] and
+ * bit 255 is the most significant bit of mask[31].
+ */
+typedef ui8	DSSupportMask[32];				/* 256 bits total */
+
+#define DS_MIN_MSG_SUPPORTMASK_LENGTH		DS_MIN_MSG_LENGTH
+#define DS_MIN_REPLY_SUPPORTMASK_LENGTH		(DS_MIN_REPLY_LENGTH + sizeof( DSSupportMask ) + 1)
+
+#if __MWERKS__
+#pragma mark  ConfigTransport
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSConfigTransport
+ *
+ *	Send: (if type == TRK_TRANSPORT_TYPE_ETHERNET)
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	general options		- (4) reserved (set to 0)
+ *		ui32	type				- (4) TRK_TRANSPORT_TYPE_ETHERNET (see below)
+ *		ui32	channel#			- (4) reserved (set to 0)
+ *		ui32	ethernet options	- (4) reserved (set to 0)
+ *		ui32	address				- (4) IP address of TRK
+ *		ui32	port				- (4) port used by TRK
+ *		ui32	gateway				- (4) gateway IP address (0 if none)
+ *		ui32	subnet mask			- (4) IP subnet mask (0 if none)
+ *									  <header + 32> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *
+ *	Sent by the host, configures a transport channel on the target with 
+ *	appropriate parameters.  The first 3 fields should be common to all
+ *	transport types.  The number and format of any remaining fields 
+ *	depend on the value of the "type" field.  Currently only ethernet
+ *	channels can be configured in this way.  Also, since the bare-board
+ *	TRK TCP/IP stack only supports a single hardware ethernet channel, the
+ *	"channel#" field should be set to 0 for now.
+ */
+/****************************************************************************/
+/* values to be used in the "type" field */
+#define TRK_MSG_TRANSPORT_TYPE_ETHERNET		0
+
+
+/* common segment of message */
+#define TRK_MSG_CT_HEADER_COUNT			(3 + TRK_MSG_HEADER_COUNT)
+DESCDECL TrkMsgDesc gTrkMsgConfigTransport
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Config Transport" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	12,											/* # of addl bytes */
+	3,											/* # of addl fields */
+	{											/* addl field descriptors: */
+		__trk_msg_field( "general options", 4 ),
+		__trk_msg_field( "type", 4 ),
+		__trk_msg_field( "channel#", 4 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_CT_GENOPT_INDEX				(0 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_CT_TYPE_INDEX				(1 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_CT_CHANNEL_INDEX			(2 + TRK_MSG_HEADER_COUNT)
+
+
+/* ethernet-specific segment of message */
+DESCDECL TrkMsgDesc gTrkMsgConfigTransportEthernet
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Config Transport (Ethernet)" )
+	&gTrkMsgConfigTransport,					/* previous fragment/header */
+	20,											/* # of addl bytes */
+	5,											/* # of addl fields */
+	{											/* addl field descriptors: */
+		__trk_msg_field( "ethernet options", 4 ),
+		__trk_msg_field( "address", 4 ),
+		__trk_msg_field( "port", 4 ),
+		__trk_msg_field( "gateway", 4 ),
+		__trk_msg_field( "netmask", 4 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_CTE_ETHOPT_INDEX			(0 + TRK_MSG_CT_HEADER_COUNT)
+#define TRK_MSG_CTE_ADDRESS_INDEX			(1 + TRK_MSG_CT_HEADER_COUNT)
+#define TRK_MSG_CTE_PORT_INDEX				(2 + TRK_MSG_CT_HEADER_COUNT)
+#define TRK_MSG_CTE_GATEWAY_INDEX			(3 + TRK_MSG_CT_HEADER_COUNT)
+#define TRK_MSG_CTE_NETMASK_INDEX			(4 + TRK_MSG_CT_HEADER_COUNT)
+
+#if __MWERKS__
+#pragma mark  Versions2
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSVersions
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui8		kernelMajor			- (1)
+ *		ui8		kernelMinor			- (1)
+ *		ui8		protocolMajor		- (1)
+ *		ui8		protocolMinor		- (1)
+ *									  <4 + header> total
+ *
+ *	Sent by the host, returns TRK version numbers.
+ */
+/****************************************************************************/
+#define DS_MIN_MSG_VERSIONS2_LENGTH			DS_MIN_MSG_LENGTH
+
+DESCDECL TrkMsgDesc gTrkMsgVersions2Reply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Versions2 Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	5,											/* # of addl bytes */
+	5,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "kernel major", 1 ),
+		__trk_msg_field( "kernel minor", 1 ),
+		__trk_msg_field( "protocol major", 1 ),
+		__trk_msg_field( "protocol minor", 1 ),
+		__trk_msg_field( "build number", 1 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_VR2_KMAJOR_INDEX		(0 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_VR2_KMINOR_INDEX		(1 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_VR2_PMAJOR_INDEX		(2 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_VR2_PMINOR_INDEX		(3 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_VR2_BUILDNUM_INDEX		(4 + TRK_MSG_REPLY_HEADER_COUNT)
+
+#if __MWERKS__
+#pragma mark  ReadMemory
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSReadMemory
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS &&
+ *			 (header.options & DS_MSG_MEMORYEXTENDED) == 0
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui16	length				- (2) memory data length
+ *		ui32	start				- (4) memory start address
+ *
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS &&
+ *			 (header.options & DS_MSG_MEMORYEXTENDED) != 0
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui16	length				- (2) memory data length
+ *		ui32	startHigh			- (4) memory start high-order address
+ *		ui32	startLow			- (4) memory start low-order address
+ *									  <12> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS &&
+ *			 (header.options & DS_MSG_MEMORYEXTENDED) == 0
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui16	length				- (2) memory data length
+ *		ui32	start				- (4) memory start address
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <16> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS &&
+ *			 (header.options & DS_MSG_MEMORYEXTENDED) != 0
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui16	length				- (2) memory data length
+ *		ui32	startHigh			- (4) memory start high-order address
+ *		ui32	startLow			- (4) memory start low-order address
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <20> total
+ *
+ *	Reply:
+ *
+ *		ui8		command				- (1) ack/nak MessageCommandID
+ *		ui8		error				- (1) CWDS error value
+ *		ui16	length				- (2) amount that was read
+ *		ui8		data[]				- (0 to 2048) data
+ *									  <4 + length> total
+ *		
+ *	Sent by the host, returns the requested memory contents.  The TRK
+ *	will attempt to catch and handle any memory access exceptions that
+ *	occur during this operation.
+ *
+ *	This command can only be used on a stopped system (protocol level 2)
+ *	or stopped thread (protocol level 3).
+ */
+/****************************************************************************/
+
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_READMEMORY_LENGTH		(DS_MIN_MSG_LENGTH + 15)
+#else
+	#define DS_MIN_MSG_READMEMORY_LENGTH		(DS_MIN_MSG_LENGTH + 7)
+#endif
+#define DS_MIN_REPLY_READMEMORY_LENGTH		(DS_MIN_REPLY_LENGTH + 2)
+
+#if __MWERKS__
+#pragma mark  WriteMemory
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSWriteMemory
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS &&
+ *			 (header.options & DS_MSG_MEMORYEXTENDED) == 0
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui16	length				- (2) memory data length in bytes
+ *		ui32	start				- (4) memory start address
+ *		ui8		data[]				- (0 to 2048) data
+ *									  <8 + length> total
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS &&
+ *			 (header.options & DS_MSG_MEMORYEXTENDED) != 0
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui16	length				- (2) memory data length in bytes
+ *		ui32	startHigh			- (4) memory start high-order address
+ *		ui32	startLow			- (4) memory start low-order address
+ *		ui8		data[]				- (0 to 2048) data
+ *									  <12 + length> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS &&
+ *			 (header.options & DS_MSG_MEMORYEXTENDED) == 0
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui16	length				- (2) memory data length in bytes
+ *		ui32	start				- (4) memory start address
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *		ui8		data[]				- (0 to 2048) data
+ *									  <16 + length> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS &&
+ *			 (header.options & DS_MSG_MEMORYEXTENDED) != 0
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui16	length				- (2) memory data length in bytes
+ *		ui32	startHigh			- (4) memory start high-order address
+ *		ui32	startLow			- (4) memory start low-order address
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *		ui8		data[]				- (0 to 2048) data
+ *									  <20 + length> total
+ *
+ *	Reply:
+ *
+ *		ui8		command				- (1) ack/nak MessageCommandID
+ *		ui8		error				- (1) CWDS error value
+ *		ui16	length				- (2) amount that was written in bytes
+ *									  <4> total
+ *		
+ *	Sent by the host, writes the specified values to target memory  The TRK
+ *	will attempt to catch and handle any memory access exceptions that
+ *	occur during this operation.
+ *
+ *	This command can only be used on a stopped system (protocol level 2)
+ *	or stopped thread (protocol level 3).
+ */
+/****************************************************************************/
+ 
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_WRITEMEMORY_LENGTH		(DS_MIN_MSG_LENGTH + 15)
+#else
+	#define DS_MIN_MSG_WRITEMEMORY_LENGTH		(DS_MIN_MSG_LENGTH + 7)
+#endif
+#define DS_MIN_REPLY_WRITEMEMORY_LENGTH		(DS_MIN_REPLY_LENGTH + 2)
+
+#if __MWERKS__
+#pragma mark  FillMemory
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSFillMemory
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui8		fillValue			- (1) value with which to fill memory
+ *		ui32	length				- (4) data length in bytes
+ *		ui32	start				- (4) memory start address
+ *									  <11> total
+ *
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui8		fillValue			- (1) value with which to fill memory
+ *		ui32	length				- (4) data length in bytes
+ *		ui32	start				- (4) memory start address
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <19> total
+ *
+ *	Reply - Basic Reply
+ *		
+ *	Sent by the host, fills the specified memory range with the given
+ *	fillValue.  The TRK	will attempt to catch and handle any memory
+ *	access exceptions that occur during this operation.
+ *
+ *	This command can only be used on a stopped system (protocol level 2)
+ *	or stopped thread (protocol level 3).
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_FILLMEMORY_LENGTH		(DS_MIN_MSG_LENGTH + 18)
+#else
+	#define DS_MIN_MSG_FILLMEMORY_LENGTH		(DS_MIN_MSG_LENGTH + 10)
+#endif
+#define DS_MIN_REPLY_FILLMEMORY_LENGTH		(DS_MIN_REPLY_LENGTH)
+
+#if __MWERKS__
+#pragma mark  CopyMemory
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSCopyMemory
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui32	length				- (4) data length in bytes
+ *		ui32	source				- (4) source memory start address
+ *		ui32	destination			- (4) destination memory start address
+ *									  <14> total
+ *
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) One of DS_MSG_MEMORY_* below
+ *		ui32	length				- (4) data length in bytes
+ *		ui32	source				- (4) source memory start address
+ *		ui32	destination			- (4) destination memory start address
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <22> total
+ *
+ *	Reply - Basic Reply
+ *
+ *	Sent by the host, copies a block of memory with the specified
+ *	size from the source address to the destination address.  This
+ *	operation will function correctly even if the source and
+ *	destination memory ranges overlap.  The TRK	will attempt to
+ *	catch and handle any memory access exceptions that occur during
+ *	this operation.
+ *
+ *	This command can only be used on a stopped system (protocol level 2)
+ *	or stopped thread (protocol level 3).
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_COPYMEMORY_LENGTH		(DS_MIN_MSG_LENGTH + 21)
+#else
+	#define DS_MIN_MSG_COPYMEMORY_LENGTH		(DS_MIN_MSG_LENGTH + 13)
+#endif
+#define DS_MIN_REPLY_COPYMEMORY_LENGTH		(DS_MIN_REPLY_LENGTH)
+
+											/* option flags in DSMessage.options */
+#define DS_MSG_MEMORY_SEGMENTED	0x01		/* non-flat addr space */
+#define DS_MSG_MEMORY_EXTENDED	0x02		/* > 32-bit data addr */
+#define DS_MSG_MEMORY_PROTECTED	0x04		/* non-user memory */
+#define DS_MSG_MEMORY_USERVIEW	0x08		/* breakpoints are invisible */
+
+/*
+** The desired memory space can be specified using one of
+** the following options.  It can be logically OR'ed with
+** the flags defined above.
+*/
+
+#define DS_MSG_MEMORY_SPACE_PROGRAM	0x00
+#define DS_MSG_MEMORY_SPACE_DATA	0x40
+#define DS_MSG_MEMORY_SPACE_IO		0x80
+
+/*
+** Use this mask to extract the memory space specifier
+** from the options field.  The specifier occupies the
+** 2 most significant bits.
+*/
+
+#define DS_MSG_MEMORY_SPACE_MASK	0xc0
+
+#define DS_MAXREADWRITELENGTH	0x0800	/* 2K data portion */
+#define DS_MAXMESSAGESIZE (DS_MAXREADWRITELENGTH + 0x80)
+											/* max size of all message including cmd hdr */
+#define MAXMESSAGESIZE	DS_MAXMESSAGESIZE
+
+#define DS_MAXREADWRITELENGTH_V2	0x0716	/* for some comms API, packet len needs bet less 2K */
+#define DS_MAXMESSAGESIZE_V2 (DS_MAXREADWRITELENGTH_V2 + 0x80)
+
+// With USB connection, transferring big chunks of data seems to be cause problems.
+// So reduce the size of each data transfer by almost half.
+#define DS_MAXFILEWRITELENGTH 0x0400 
+
+#define MAXMESSAGESIZE_V2	DS_MAXMESSAGESIZE_V2
+
+
+
+#if __MWERKS__
+#pragma mark  FlushCache
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSFlushCache
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DS_MSG_CACHE_* (see below)
+ *		ui32	start				- (4) start of mem region for which to clear cache
+ *		ui32	end					- (4) end of mem region for which to clear cache
+ *									  <10> total
+ *
+ *	Reply - Basic Reply
+ *
+ *	Sent by the host, flushes all cache entries corresponding to the
+ *	given memory range, at least.  Additional cache entries may
+ *	be flushed as well, depending on the target implementation.
+ *
+ *	This command can only be used on a stopped system.
+ */
+/****************************************************************************/
+
+#define DS_MIN_MSG_FLUSHCACHE_LENGTH	(DS_MIN_MSG_LENGTH + 9)
+#define DS_MIN_REPLY_FLUSHCACHE_LENGTH	(DS_MIN_REPLY_LENGTH)
+
+/*
+** The following values may be logically OR'ed together in the
+** options field of the kDSFlushCache command to specify
+** the cache types to be flushed.
+*/
+
+#define DS_MSG_CACHE_TYPE_INSTRUCTION	0x01
+#define DS_MSG_CACHE_TYPE_DATA			0x02
+#define DS_MSG_CACHE_TYPE_SECONDARY		0x04
+
+
+#if __MWERKS__
+#pragma mark  ReadRegisters
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSReadRegisters
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageRegisterOptions
+ *		ui16	firstRegister		- (2) first register ID
+ *		ui16	lastRegister		- (2) last register ID
+ *									  <6>
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageRegisterOptions
+ *		ui16	firstRegister		- (2) first register ID
+ *		ui16	lastRegister		- (2) last register ID
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <14>
+ *
+ *	Reply:
+ *
+ *		ui8		command				- (1) ack/nak MessageCommandID
+ *		ui8		error				- (1) CWDS error value
+ *				register data		- (0-2048) 
+ *									  <2 + register data>
+ *       
+ *	Sent by the host, reads the requested register contents.  The TRK
+ *	will attempt to catch and handle any access exceptions that
+ *	occur during this operation.
+ *
+ *	This command can only be used on a stopped system (protocol level 2)
+ *	or stopped thread (protocol level 3).
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_READREGISTERS_LENGTH		(DS_MIN_MSG_LENGTH + 13)
+#else
+	#define DS_MIN_MSG_READREGISTERS_LENGTH		(DS_MIN_MSG_LENGTH + 5)
+#endif
+#define DS_MIN_REPLY_READREGISTERS_LENGTH	DS_MIN_REPLY_LENGTH
+
+#if __MWERKS__
+#pragma mark  WriteRegisters
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSWriteRegisters
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageRegisterOptions
+ *		ui16	firstRegister		- (2) first register ID
+ *		ui16	lastRegister		- (2) last register ID
+ *				register data		- (0-2048) 
+ *									  <6 + register data>
+ * 
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageRegisterOptions
+ *		ui16	firstRegister		- (2) first register ID
+ *		ui16	lastRegister		- (2) last register ID
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *				register data		- (0-2048) 
+ *									  <14 + register data>
+ * 
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *       
+ *	Sent by the host, writes the specified values to target registers.
+ *	The TRK will attempt to catch and handle any access exceptions that
+ *	occur during this operation.
+ *
+ *	This command can only be used on a stopped system (protocol level 2)
+ *	or stopped thread (protocol level 3).
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_WRITEREGISTERS_LENGTH	(DS_MIN_MSG_LENGTH + 13)
+#else
+	#define DS_MIN_MSG_WRITEREGISTERS_LENGTH	(DS_MIN_MSG_LENGTH + 5)
+#endif
+#define DS_MIN_REPLY_WRITEREGISTERS_LENGTH	DS_MIN_REPLY_LENGTH
+
+											/* option flags for reading registers */
+
+#define DS_MSG_REGISTERS_TYPE_MASK	0x07	/* "register type" mask */
+#define DS_MSG_REGISTERS_TYPE_SHIFT	0		/* # bits to shift mask from lsb. */
+#define DS_MSG_REGISTERS_TYPE(_x_)	((_x_ & DS_MSG_REGISTERS_TYPE_MASK) << DS_MSG_REGISTERS_TYPE_SHIFT)
+
+/*
+ *	kDSReadRegisters & kDSWriteRegister options
+ */
+
+typedef enum DSMessageRegisterOptions {
+	kDSRegistersDefault = 0x0,			/* Default register block */
+	kDSRegistersFP = 0x1,				/* floating point registers */
+	kDSRegistersExtended1 = 0x2,		/* Extended register set 1 */
+	kDSRegistersExtended2 = 0x3			/* Extended register set 2 */
+} DSMessageRegisterOptions;
+
+
+#if __MWERKS__
+#pragma mark  Continue
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSContinue
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <header + 8> total
+ * 
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *       
+ *
+ *	Sent by the host.  Begins execution on the target at the current PC.
+ *
+ *	Replies with an ACK before execution starts.  Once execution begins,
+ *	most commands which access that process or thread will not be
+ *	accepted.  For DS_PROTOCOL values of 1 or 2, this means that it
+ *	will not respond to any of the state or execution commands 
+ *	except kDSStop.  It will respond to meta-commands.  For
+ *	a DS_PROTOCOL value of 3, it will not accept any commands
+ *	specifying that process or thread except kDSStop or 
+ *	kDSOSDeleteItem.
+ *
+ *	The host should wait for a NotifyStopped or NotifyException command
+ *	and reply with a corresponding ACK.  Once that process and thread
+ *	have stopped again, MetroTRK will once again accept other commands
+ *	which access them.
+ *
+ *	This command can only be used on a stopped system (protocol level 2)
+ *	or stopped thread (protocol level 3).
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_CONTINUE_LENGTH			(DS_MIN_MSG_LENGTH + 8)
+#else
+	#define DS_MIN_MSG_CONTINUE_LENGTH			DS_MIN_MSG_LENGTH
+#endif
+#define DS_MIN_REPLY_CONTINUE_LENGTH		DS_MIN_REPLY_LENGTH
+
+#if __MWERKS__
+#pragma mark  Step
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSStep
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS &&
+ *			 (options == kDSStepIntoCount || options == kDSStepOverCount)
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageStepOptions
+ *		ui8		count				- (1) # of instructions
+ *									  <3>
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS &&
+ *			 (options == kDSStepIntoCount || options == kDSStepOverCount)
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageStepOptions
+ *		ui8		count				- (1) # of instructions
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <11>
+ *
+ *	Sent by the host.  Steps over the specified number of instructions.
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS &&
+ *			 (options == kDSStepIntoRange || options == kDSStepOverRange)
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageStepOptions
+ *		ui32	rangeStart			- (4) Start address of memory range
+ *		ui32	rangeEnd			- (4) End address of memory range
+ *									  <10>
+ * 
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS &&
+ *			 (options == kDSStepIntoRange || options == kDSStepOverRange)
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageStepOptions
+ *		ui32	rangeStart			- (4) Start address of memory range
+ *		ui32	rangeEnd			- (4) End address of memory range
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <18>
+ * 
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *
+ *	Sent by the host.  Steps until the PC is outside of the specified
+ *	range.
+ *
+ *	Replies with an ACK before execution starts.  Once execution begins,
+ *	most commands which access that process or thread will not be
+ *	accepted.  For DS_PROTOCOL values of 1 or 2, this means that it
+ *	will not respond to any of the state or execution commands 
+ *	except kDSStop.  It will respond to meta-commands.  For
+ *	a DS_PROTOCOL value of 3, it will not accept any commands
+ *	specifying that process or thread except kDSStop or 
+ *	kDSOSDeleteItem.
+ *
+ *	The host should wait for a NotifyStopped or NotifyException command
+ *	and reply with a corresponding ACK.  Once that process and thread
+ *	have stopped again, MetroTRK will once again accept other commands
+ *	which access them.
+ *
+ *	This command can only be used on a stopped system (protocol level 2)
+ *	or stopped thread (protocol level 3).
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_STEP_COUNT_LENGTH	(DS_MIN_MSG_LENGTH + 10)
+	#define DS_MIN_MSG_STEP_RANGE_LENGTH	(DS_MIN_MSG_LENGTH + 17)
+#else
+	#define DS_MIN_MSG_STEP_COUNT_LENGTH	(DS_MIN_MSG_LENGTH + 2)
+	#define DS_MIN_MSG_STEP_RANGE_LENGTH	(DS_MIN_MSG_LENGTH + 9)
+#endif
+#define DS_MIN_MSG_STEP_LENGTH			(DS_MIN_MSG_STEP_COUNT_LENGTH)
+#define DS_MIN_REPLY_STEP_LENGTH		DS_MIN_REPLY_LENGTH
+
+/*
+** The following option values are predefined.  Desired
+** target-specific options can be added to the
+** DSTargMessageStepOptions enum (see msgtarg.h).
+*/
+
+typedef enum {
+	kDSStepIntoCount = 0x00,			/* Exec count instructions & stop */
+	kDSStepIntoRange = 0x01,			/* Exec until PC is out of specified range */
+	kDSStepOverCount = 0x10,			/* Step over 1*count instructions & stop */
+	kDSStepOverRange = 0x11				/* Step over until PC is out of specified range */
+} DSMessageStepOptions;
+
+
+#if __MWERKS__
+#pragma mark  Stop
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSStop
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS &&
+ *			 (options == kDSStopSystem)
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageStopOptions
+ *									  <2>
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS &&
+ *			 (options == kDSStopProcess)
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageStopOptions
+ *		ui32	processID			- (4) unique process ID
+ *									  <6>
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS &&
+ *			 (options == kDSStopThread)
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageStopOptions
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <10>
+ *
+ *	Sent by the host.  Forces the target system/process/thread to stop.
+ *  Replies	with an ACK.
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_STOP_LENGTH			(DS_MIN_MSG_LENGTH + 3)
+#else
+	#define DS_MIN_MSG_STOP_LENGTH			(DS_MIN_MSG_LENGTH + 2)
+#endif
+#define DS_MIN_REPLY_STOP_LENGTH		DS_MIN_REPLY_LENGTH
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+
+/*
+** The following option values are predefined.  Desired
+** target-specific options can be added to the
+** DSTargMessageStopOptions enum (see msgtarg.h).
+*/
+
+typedef enum {
+	kDSStopSystem	= 0x0,		/* Stop the entire system */
+	kDSStopProcess	= 0x1,		/* Stop all threads in a specific process */
+	kDSStopThread	= 0x2		/* Stop a specific thread in a specific process */
+} DSMessageStopOptions;
+
+#endif
+
+#if __MWERKS__
+#pragma mark  SetBreak
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSSetBreak
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui8		options				- (1) DSMessageBreakOptions
+ *		ui8		targetOptions		- (1) target-defined
+ *		ui32	address				- (4) Start of breakpoint memory range
+ *		ui32	length				- (4) Length of breakpoint memory range
+ *		ui32	count				- (4) Only stop after triggered this many times (currently not used, set to 0)
+ *									  <14 + header> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui8		options				- (1) DSMessageBreakOptions
+ *		ui8		targetOptions		- (1) target-defined
+ *		ui32	address				- (4) Start of breakpoint memory range
+ *		ui32	length				- (4) Length of breakpoint memory range
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *		ui32	count				- (4) Only stop after triggered this many times (currently not used, set to 0)
+ *									  <22 + header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui32	id					- (4) ID of the new breakpoint
+ *									  <4 + header> total
+ *	Sent by the host.  Sets a breakpoint at the specified location.
+ *	Replies with an ACK.
+ *
+ *  For software execution breakpoints, the length field should be 1.
+ *
+ *	Note: This command should not be implemented unless there is a
+ *	compelling reason to do so.  In most cases, both software and
+ *	hardware breakpoints can be implemented via memory and register reads
+ *	and writes.  
+ *	
+ *
+ */
+/****************************************************************************/
+#define TRK_MSG_REPLY_HEADER_LENGTH	(1 + TRK_MSG_HEADER_LENGTH)	/* 1 addl bytes  */
+#define TRK_MSG_REPLY_HEADER_COUNT	(1 + TRK_MSG_HEADER_COUNT)	/* 1 addl fields */
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+
+	DESCDECL TrkMsgDesc gTrkMsgSetBreak
+	#ifdef TRK_MSGCMD_INIT
+	= {
+		__debug_only_parm( "Set Breakpoint" )
+		&gTrkMsgHeader,								/* previous fragment/header */
+		22,											/* # of addl bytes */
+		7,											/* # of addl fields */
+		{						/* addl field descriptors: */
+			__trk_msg_field( "options", 1 ),
+			__trk_msg_field( "target options", 1 ),
+			__trk_msg_field( "address", 4 ),
+			__trk_msg_field( "length", 4 ),
+			__trk_msg_field( "count", 4 ),
+			__trk_msg_field( "process ID", 4 ),
+			__trk_msg_field( "thread ID", 4 ),
+		}
+	}
+	#endif /* #ifdef TRK_MSGCMD_INIT */
+	;
+
+#else /* #if DS_PROTOCOL == DS_PROTOCOL_RTOS */
+
+	DESCDECL TrkMsgDesc gTrkMsgSetBreak
+	#ifdef TRK_MSGCMD_INIT
+	= {
+		__debug_only_parm( "Set Breakpoint" )
+		&gTrkMsgHeader,								/* previous fragment/header */
+		14,											/* # of addl bytes */
+		5,											/* # of addl fields */
+		{						/* addl field descriptors: */
+			__trk_msg_field( "options", 1 ),
+			__trk_msg_field( "target options", 1 ),
+			__trk_msg_field( "address", 4 ),
+			__trk_msg_field( "length", 4 ),
+			__trk_msg_field( "count", 4 )
+		}
+	}
+	#endif /* #ifdef TRK_MSGCMD_INIT */
+	;
+
+#endif /* #if DS_PROTOCOL == DS_PROTOCOL_RTOS */
+
+/* field indices */
+#define TRK_MSG_SETBREAK_OPTIONS_INDEX	(0 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_SETBREAK_TOPTIONS_INDEX	(1 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_SETBREAK_ADDRESS_INDEX	(2 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_SETBREAK_LENGTH_INDEX	(3 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_SETBREAK_COUNT_INDEX	(4 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_SETBREAK_PID_INDEX		(5 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_SETBREAK_TID_INDEX		(6 + TRK_MSG_HEADER_COUNT)
+
+DESCDECL TrkMsgDesc gTrkMsgSetBreakReply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Set Breakpoint Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	4,											/* # of addl bytes */
+	1,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "breakpoint ID", 4 ),
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_SETBREAKREPLY_BID_INDEX	(0 + TRK_MSG_REPLY_HEADER_COUNT)
+
+#if __MWERKS__
+#pragma mark  ClearBreak
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSClearBreak
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	id					- (4) ID of the breakpoint to clear
+ *									  <4 + header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *
+ *	Sent by the host.  Clears the specified breakpoint.  If the specified
+ *	id is DS_MSG_BREAK_ID_ALL, clears all breakpoints.
+ *
+ */
+/****************************************************************************/
+DESCDECL TrkMsgDesc gTrkMsgClearBreak
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Clear Breakpoint" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	8,											/* # of addl bytes */
+	2,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "breakpoint ID", 4 ),
+		__trk_msg_field( "breakpoint Address", 4)	
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_CLEARBREAK_BID_INDEX	(0 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_CLEARBREAK_BADDR_INDEX	(1 + TRK_MSG_HEADER_COUNT)
+
+/*
+** The following values should be logically OR'ed with one
+** of the DSMessageBreakOptions values to specify the
+** type of access which will cause the target program to
+** stop.  More than one stop type can be specified.
+** the kDSSetBreak command will fail if one of the specified
+** conditions is not supported on the target, but there is
+** one exception:
+**
+** NOTE: If both the write and modify conditions are
+** specified, the kDSSetBreak command will succeed if
+** one of the two is supported.
+** 
+*/
+
+#define DS_MSG_BREAK_CONDITION_READ		0x10	/* stop on read access */
+#define DS_MSG_BREAK_CONDITION_WRITE	0x20	/* stop on write access */
+#define DS_MSG_BREAK_CONDITION_MODIFY	0x40	/* stop on modify access */
+#define DS_MSG_BREAK_CONDITION_EXECUTE	0x80	/* stop on execution */
+
+/*
+** Use the following mask to extract the breakpoint condition flags
+** from the options.
+*/
+
+#define DS_MSG_BREAK_CONDITION_MASK		0xf0
+
+/*
+** The following option values are predefined.  Desired
+** target-specific options can be added to the
+** DSTargMessageBreakOptions enum (see msgtarg.h).
+*/
+
+typedef enum {
+	kDSBreakSoftware	= 0x00,		/* Set a software breakpoint */
+	kDSBreakHardware	= 0x01,		/* Set a hardware breakpoint */
+	kDSBreakAuto		= 0x02		/* Set a SW BP if possible, otherwise HW */
+} DSMessageBreakOptions;
+
+/*
+** If the following is provided as the breakpoint ID in the kDSClearBreak
+** command, all breakpoints will be cleared.
+*/
+
+#define DS_MSG_BREAK_ID_ALL				0xffffffff
+
+/*
+** If the following is provided as the thread ID in the kDSSetBreak
+** command, the operation will apply to all threads in the process.
+*/
+
+#define DS_MSG_BREAK_THREAD_ID_ALL		0xffffffff
+
+#if __MWERKS__
+#pragma mark  ModifyBreakThread
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSModifyBreakThread
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	id					- (4) ID of the breakpoint to modify
+ *		ui32	threadID			- (4) new thread ID
+ *									  <8 + header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *
+ *	Sent by the host.  Associates an existing breakpoint with the
+ *	specified thread.  The thread ID can be for a specific thread or
+ *	it can be DS_MSG_BREAK_THREAD_ID_ALL.
+ *
+ *	This command is only valid if DS_PROTOCOL == DS_PROTOCOL_RTOS.
+ *
+ */
+/****************************************************************************/
+DESCDECL TrkMsgDesc gTrkMsgModifyBreakThread
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Modify Breakpoint Thread" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	8,											/* # of addl bytes */
+	2,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "breakpoint ID", 4 ),
+		__trk_msg_field( "thread ID", 4 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_MBT_BID_INDEX		(0 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_MBT_TID_INDEX		(1 + TRK_MSG_HEADER_COUNT)
+
+
+#if __MWERKS__
+#pragma mark  Download
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSDownload
+ *
+ *	Send: if (DSMessageDownloadOptions == kDSMessageDownloadTFTP)
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		options				- (1) DSMessageDownloadOptions (see below)
+ *		ui32	IP address			- (4) IP address of the target system
+ *		ui32	TFTP address		- (4) IP address of the TFTP server
+ *		ui32	length				- (4) file size in bytes
+ *		ui32	start address		- (4) load address of the file
+ *		ui16	name_length			- (2) length of file name in bytes
+ *		ui8[]	file name			  (0 - 2048) name of the file to download
+ *									  <20 + name_length>
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *
+ *	Sent by the host.  Downloads a file to the target system according
+ *	to the specified parameters.  This command is intended to allow
+ *	downloading via communication channels other than the TRK's command
+ *	channel.
+ *	Replies with an ACK.
+ *
+ */
+/****************************************************************************/
+
+#define DS_MIN_MSG_DOWNLOAD_LENGTH		(DS_MIN_MSG_LENGTH + 19)
+#define DS_MIN_REPLY_CLEARBREAK_LENGTH	DS_MIN_REPLY_LENGTH
+
+/*
+** The following option values are predefined.  Desired
+** target-specific options can be added to the
+** DSTargMessageDownloadOptions enum (see msgtarg.h).
+*/
+
+typedef enum {
+	kDSMessageDownloadTFTP		= 0x0
+} DSMessageDownloadOptions;
+
+#if __MWERKS__
+#pragma mark  NotifyStopped
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSNotifyStopped
+ *
+ *	Send:
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *				target-defined info (PC, instr @PC, exception word)
+ *									  <1 + target info> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *	
+ *	Sent by the target.  This message will only be sent when the target
+ *	is executing (after a kDSContinue or kDSStep command).  It indicates
+ *	that the target stopped running.  On a bare-board system (no OS), this 
+ *	typically means the target stopped due to an exception.  The
+ *  target-defind info should provide additional details about why
+ *	the target stopped.
+ *	Expects an ACK in response.
+ *
+ */
+/****************************************************************************/
+ 
+#define DS_MIN_MSG_NOTIFYSTOPPED_LENGTH		DS_MIN_MSG_LENGTH
+#define DS_MIN_REPLY_NOTIFYSTOPPED_LENGTH	DS_MIN_REPLY_LENGTH
+
+#if __MWERKS__
+#pragma mark  NotifyInternalError
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSNotifyInternalError
+ *
+ *	Send:
+ *
+ *		ui8		command				- (1) MessageCommandID
+ *		ui8		error code			- (1) DSInternalError
+ *									  <2> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *	
+ *	Sent by the target.  It indicates that an internal error occurred
+ *	in MetroTRK.
+ *	Expects an ACK in response.
+ *
+ */
+/****************************************************************************/
+ 
+#define DS_MIN_MSG_NOTIFYINTERNALERROR_LENGTH	(DS_MIN_MSG_LENGTH + 1)
+#define DS_MIN_REPLY_NOTIFYINTERNALERROR_LENGTH	DS_MIN_REPLY_LENGTH
+
+#if __MWERKS__
+#pragma mark  OSNotifyCreated / OSNotifyDeleted
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSOSNotifyCreated / kDSOSNotifyDeleted
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui16	itemType			- (2) DSOSItemTypes
+ *				target-defined info (e.g., process ID for kDSOSDLLItem)
+ *									  <2 + header + target info> total
+ *
+ *	Reply:
+ *	
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *				target-defined info (e.g., code & data offset for
+ *									 kDSOSProcessItem)
+ *									  <header + target info> total
+ *
+ *	Sent by the target.  This message indicates that an item of the 
+ *	given type has been created/deleted.
+ *	Expects an ACK in response.
+ *
+ */
+/****************************************************************************/
+ 
+#if __MWERKS__
+#pragma mark  OSCreateItem / OSDeleteItem Header
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSOSCreateItem / kDSOSDeleteItem
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui16	itemType			- (2) DSOSItemTypes
+ *				target-defined info (e.g., DLL name for kDSOSDLLItem)
+ *									  <2 + header + target info> total
+ *
+ *	Reply
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *				target-defined info (e.g., code & data offset for
+ *									 kDSOSProcessItem)
+ *									  <header + target info> total
+ *	
+ *	Sent by the host.  Creates/deletes an item of the specified type in
+ *	the system.  It allows the host to create/delete processes (load),
+ *	threads, DLL's, and any other system resources.  This command may
+ *	either operate synchronously or asynchronously.  The behavior may be
+ *	differ on an item-by-item basis.  The two scenarios:
+ *
+ *		synchronous: The host sends a OSCreateItem/OSDeleteItem command.
+ *			The target system creates the item and then replies with an
+ *			ACK containing specific information about the 
+ *			created/deleted item.
+ *
+ *		asynchronous: The host sends a OSCreateItem/OSDeleteItem command.
+ *			The target system queues the request and replies with
+ *			an ACK.  At some later time, when the item is
+ *			actually created/deleted, the target system sends an
+ *			OSNotifyCreated/OSNotifyDeleted message to the host
+ *			containing specific information about the created/deleted
+ *			item.
+ *
+ *	Expects an ACK in response.  The reply may contain specific
+ *	information about the created/deleted item, such as code and data 
+ *	offsets for relocatable processes (if the operation is
+ *	synchronous).
+ *
+ */
+/****************************************************************************/
+
+#define TRK_MSG_ITEM_HEADER_LENGTH	(2 + TRK_MSG_HEADER_LENGTH)	/* 2 addl bytes  */
+#define TRK_MSG_ITEM_HEADER_COUNT	(1 + TRK_MSG_HEADER_COUNT)	/* 1 addl fields */
+
+DESCDECL TrkMsgDesc gTrkMsgItemHeader
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Item Header" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	2,											/* # of addl bytes */
+	1,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "item type", 2 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+#define TRK_MSG_ITEM_HEADER_TYPE_INDEX		(0 + TRK_MSG_HEADER_COUNT)
+
+
+/*
+** The following option values are predefined.  Desired
+** target-specific options can be added to the
+** DSTargOSItemTypes enum (see msgtarg.h).
+*/
+
+typedef enum {
+	kDSOSProcessItem	= 0x0000,
+	kDSOSThreadItem		= 0x0001,
+	kDSOSDLLItem		= 0x0002,
+	kDSOSAppItem		= 0x0003,
+	kDSOSMemBlockItem	= 0x0004,
+	kDSOSProcAttachItem	= 0x0005,
+	kDSOSThreadAttachItem = 0x0006,
+	kDSOSProcAttach2Item	= 0x0007,
+	kDSOSProcRunItem	= 0x0008,
+	kDSOSProcAttach3Item = 0x0009
+	/* 0x0009 - 0x00ff reserved for general expansion */
+	/* 0x0100 - 0xffff available for target-specific use */
+} DSOSItemTypes;
+
+#if __MWERKS__
+#pragma mark  OSReadInfo / OSWriteInfo Header
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSOSReadInfo / KDSOSWriteInfo (Common Header)
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui16	infoType			- (2) DSOSInfoTypes
+ *				target-defined info (e.g., process ID for
+ *									 kDSOSProcessStateInfo)
+ *									  <2 + header + target info> total
+ *
+ *	Reply
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *				target-defined info (e.g., process state for
+ *									 kDSOSProcessStateInfo)
+ *									  <header + target info> total
+ *	
+ *	Sent by the host.  Reads/writes the requested info from/to the
+ *	target system.  It allows the host to get/set information about the
+ *	internal system state.  For ReadInfo, there are additional fields
+ *	specified in a secondary header (see below).
+ *
+ */
+/****************************************************************************/
+ 
+#define TRK_MSG_INFO_HEADER_LENGTH	(2 + TRK_MSG_HEADER_LENGTH)	/* 2 addl bytes  */
+#define TRK_MSG_INFO_HEADER_COUNT	(1 + TRK_MSG_HEADER_COUNT)	/* 1 addl fields */
+
+DESCDECL TrkMsgDesc gTrkMsgInfoHeader
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Info Header" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	2,											/* # of addl bytes */
+	1,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "info type", 2 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+#define TRK_MSG_INFO_HEADER_TYPE_INDEX		(0 + TRK_MSG_HEADER_COUNT)
+
+/*
+** The following option values are predefined.  Desired
+** target-specific options can be added to the
+** DSTargOSInfoTypes enum (see msgtarg.h).
+*/
+
+typedef enum {
+	kDSOSProcessList	= 0x0000,
+	kDSOSProcessState	= 0x0001,
+	kDSOSThreadList		= 0x0002,
+	kDSOSThreadState	= 0x0003,
+	kDSOSDLLList		= 0x0004,
+	kDSOSDLLState		= 0x0005,
+	kDSOSDLLInfo		= 0x0006,
+	kDSOSProcessInfo	= 0x0007,
+	/* 0x0008 - 0x00ff reserved for expansion */
+	/* 0x0100 - 0xffff available for target-specific use */
+} DSOSInfoTypes;
+
+#if __MWERKS__
+#pragma mark  OSReadInfo Header
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSOSReadInfo (header)
+ *
+ *	Send:
+ *
+ *		....	<Info Header>	      ... (see gTrkMsgInfoHeader)
+ *		ui32	startIndex			- (4) starting index of returned info
+ *				target-defined info (e.g., process ID for
+ *									 kDSOSProcessStateInfo)
+ *									  <4 + header + target info> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui32	returnedCount		- (4) # of items in this reply
+ *		ui32	totalCount			- (4) total # of items in complete response
+ *				target-defined info (e.g., process state for
+ *									 kDSOSProcessStateInfo)
+ *									  <8 + header + target info> total
+ *	
+ *
+ *	This is the header to be used by all kDSReadInfo requests.  The
+ *	complete info may not fit in a single MetroTRK message, so it is
+ *	possible to read the info in segments.  When reading the info, the
+ *	startIndex should be 0 the first time.  If, in the reply,
+ *	totalCount > (startIndex + returnedCount), then the next segment of
+ *	the info can be read by sending another request with the new
+ *	startIndex set to the previous (startIndex + returnedCount).  
+ *
+ *	startIndex, returnedCount, and totalCount all refer to the number of
+ *	"items" (the definition of which depends on the info type), not 
+ *	necessarily the number of bytes.
+ *
+ */
+/****************************************************************************/
+#define TRK_MSG_RI_HEADER_LENGTH	(4 + TRK_MSG_INFO_HEADER_LENGTH)	/* 4 addl bytes  */
+#define TRK_MSG_RI_HEADER_COUNT		(1 + TRK_MSG_INFO_HEADER_COUNT)		/* 1 addl fields */
+
+
+DESCDECL TrkMsgDesc gTrkMsgReadInfoHeader
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Read Info Header" )
+	&gTrkMsgInfoHeader,							/* previous fragment/header */
+	4,											/* # of addl bytes */
+	1,											/* # of addl fields */
+	{											/* addl field descriptors: */
+		__trk_msg_field( "start index", 4 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_RI_HEADER_START_INDEX	(0 + TRK_MSG_INFO_HEADER_COUNT)
+
+
+#define TRK_MSG_RIR_HEADER_LENGTH		(8 + TRK_MSG_REPLY_HEADER_LENGTH)	/* 4 addl bytes  */
+#define TRK_MSG_RIR_HEADER_COUNT		(2 + TRK_MSG_REPLY_HEADER_COUNT)	/* 1 addl fields */
+
+DESCDECL TrkMsgDesc gTrkMsgReadInfoReplyHeader
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Read Info Reply Header" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	8,											/* # of addl bytes */
+	2,											/* # of addl fields */
+	{											/* addl field descriptors: */
+		__trk_msg_field( "returned count", 4 ),
+		__trk_msg_field( "total count", 4 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_RIR_HEADER_RETURNED_INDEX	(0 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_RIR_HEADER_TOTAL_INDEX		(1 + TRK_MSG_REPLY_HEADER_COUNT)
+
+
+#if __MWERKS__
+#pragma mark  WriteFile
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSWriteFile
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	file_handle			- (4) DSFileHandles (see below)
+ *		ui16	length				- (2) file data length in bytes
+ *				file data			- (0 to 2048)
+ *									  <6 + length + header> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	file_handle			- (4) DSFileHandles (see below)
+ *		ui16	length				- (2) file data length in bytes
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *				file data			- (0 to 2048)
+ *									  <14 + length + header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui8		io_result			- (1) DSIOResult (see below)
+ *		ui16	length				- (2) amount that was written in bytes
+ *									  <3 + header> total
+ *	
+ *	kDSWriteFile: Sent by the target.  Instructs the host to write the
+ *	specified data to the file with the given handle.  Assumes that stdout
+ *	and stderr are always open for writing.
+ *	Expects a reply from the host in the above format.
+ *
+ *	Note: The startup welcome message is sent as a kDSWriteFile
+ *  message, but it is a special case and does not require a reply.
+ *
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_WRITEFILE_LENGTH		(DS_MIN_MSG_LENGTH + 14)
+#else
+	#define DS_MIN_MSG_WRITEFILE_LENGTH		(DS_MIN_MSG_LENGTH + 6)
+#endif
+#define DS_MIN_REPLY_WRITEFILE_LENGTH		(DS_MIN_REPLY_LENGTH + 3)
+  
+#if __MWERKS__
+#pragma mark  ReadFile
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSReadFile
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	file_handle			- (4) DSFileHandles (see below)
+ *		ui16	length				- (2) file data length in bytes
+ *									  <6 + header> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	file_handle			- (4) DSFileHandles (see below)
+ *		ui16	length				- (2) file data length in bytes
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <14 + header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui8		io_result			- (1) DSIOResult (see below)
+ *		ui16	length				- (2) amount that was read in bytes
+ *				file data			- (0 to 2048)
+ *									  <3 + length + header> total
+ *
+ *	Sent by the target.  Instructs the host to read the specified
+ *	amount of data from the file with the given handle.  Assumes
+ *	that stdin is always open for reading.
+ *	Expects a reply from the host in the above format.
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_READFILE_LENGTH		(DS_MIN_MSG_LENGTH + 14)
+#else
+	#define DS_MIN_MSG_READFILE_LENGTH		(DS_MIN_MSG_LENGTH + 6)
+#endif
+#define DS_MIN_REPLY_READFILE_LENGTH		(DS_MIN_REPLY_LENGTH + 3)
+
+#if __MWERKS__
+#pragma mark  NotifyFileInput
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSNotifyFileInput
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	file_handle			- (4) DSFileHandles (see below)
+ *									  <4 + header> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	file_handle			- (4) DSFileHandles (see below)
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <12 + header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *	
+ *	Sent by the host.  Notifies MetroTRK that new input is available for
+ *	the given file.  This is intended to be used for stdin, but can be
+ *	used for other files as well.
+ *
+ */
+/****************************************************************************/
+
+/*** kDSNotifyFileInput ***/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+
+	DESCDECL TrkMsgDesc gTrkMsgNotifyFileInput
+	#ifdef TRK_MSGCMD_INIT
+	= {
+		__debug_only_parm( "Notify File Input" )
+		&gTrkMsgHeader,								/* previous fragment/header */
+		12,											/* # of addl bytes */
+		3,											/* # of addl fields */
+		{											/* addl field descriptors: */
+			__trk_msg_field( "file handle", 4 ),
+			__trk_msg_field( "process ID", 4 ),
+			__trk_msg_field( "thread ID", 4 )
+		}
+	}
+	#endif /* #ifdef TRK_MSGCMD_INIT */
+	;
+
+#else /* #if DS_PROTOCOL == DS_PROTOCOL_RTOS */
+
+	DESCDECL TrkMsgDesc gTrkMsgNotifyFileInput
+	#ifdef TRK_MSGCMD_INIT
+	= {
+		__debug_only_parm( "Notify File Input" )
+		&gTrkMsgHeader,								/* previous fragment/header */
+		4,											/* # of addl bytes */
+		1,											/* # of addl fields */
+		{						/* addl field descriptors: */
+			__trk_msg_field( "file handle", 4 )
+		}
+	}
+	#endif /* #ifdef TRK_MSGCMD_INIT */
+	;
+
+#endif /* #if DS_PROTOCOL == DS_PROTOCOL_RTOS */
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_NFI_HANDLE_INDEX		(0 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_NFI_PID_INDEX			(1 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_NFI_TID_INDEX			(2 + TRK_MSG_HEADER_COUNT)
+
+
+#if __MWERKS__
+#pragma mark  BlockFileIo
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSBlockFileIo
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui8		block				- (1) if 0, OK to send file IO requests, otherwise no
+ *									  <1 + header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *									  <header> total
+ *	
+ *	Sent by the host.  Blocks/unblocks all file IO requests from the target.
+ *	If the host becomes overwhelmed with file IO processing, it can send this
+ *	message with a block value of 1.  When it is able to handle more file IO
+ *	requests it can send this message again with a block value of 0.  This
+ *	affects target->host IO requests from all files on all processes and threads.
+ *
+ */
+/****************************************************************************/
+
+/*** kDSBlockFileIo ***/
+
+DESCDECL TrkMsgDesc gTrkMsgBlockFileIo
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Block File IO" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	1,											/* # of addl bytes */
+	1,											/* # of addl fields */
+	{											/* addl field descriptors: */
+		__trk_msg_field( "block", 1 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_BFIO_BLOCK_INDEX		(0 + TRK_MSG_HEADER_COUNT)
+
+
+#if __MWERKS__
+#pragma mark  OpenFile
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSOpenFile
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui8		modes				- (1) DSFileOpenModes (see below)
+ *		ui16	name_length			- (2) file name length in bytes
+ *		ui8[]	file_name			- (0 to 2048) file name (no string
+ *												  terminator)
+ *									  <3 + name_length + header> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui8		modes				- (1) DSFileOpenModes (see below)
+ *		ui16	name_length			- (2) file name length in bytes
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *		ui8[]	file_name			- (0 to 2048) file name (no string
+ *												  terminator)
+ *									  <11 + name_length + header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui8		io_result			- (1) DSIOResult (see below)
+ *		ui32	file_handle			- (4) handle of the newly opened file
+ *		ui32	timestamp			- (4) timestamp of file on open (replyer-dependent format)
+ *									  <9 + header> total
+ *	
+ *	Sent by the target.  Instructs the host to open a file with the
+ *	given name and modes.  The resulting file_handle can then be
+ *	used by kDSWriteFile, kDSReadFile, kDSCloseFile, and kDSPositionFile.
+ *	Expects a reply from the host in the above format.
+ *
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_OPENFILE_LENGTH		(DS_MIN_MSG_LENGTH + 11)
+#else
+	#define DS_MIN_MSG_OPENFILE_LENGTH		(DS_MIN_MSG_LENGTH + 3)
+#endif
+#define DS_MIN_REPLY_OPENFILE_LENGTH		(DS_MIN_REPLY_LENGTH + 5)
+  
+#if __MWERKS__
+#pragma mark  CloseFile
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSCloseFile
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	file_handle			- (4) handle of the file to be closed
+ *		ui32	timestamp			- (4) new timestamp value to be set for the file (receiver-dependent format)
+ *									  <8 + header> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui32	file_handle			- (4) handle of the file to be closed
+ *		ui32	timestamp			- (4) new timestamp value to be set for the file (receiver-dependent format)
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <16 + header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui8		io_result			- (1) DSIOResult (see below)
+ *									  <1 + header> total
+ *	
+ *	Sent by the target.  Instructs the host to close the file with the
+ *	specified file_handle.  Note: the timestamp value will only affect
+ *	the file if it was opened in write mode.
+ *	Expects a reply from the host in the above format.
+ *
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_CLOSEFILE_LENGTH		(DS_MIN_MSG_LENGTH + 16)
+#else
+	#define DS_MIN_MSG_CLOSEFILE_LENGTH		(DS_MIN_MSG_LENGTH + 8)
+#endif
+#define DS_MIN_REPLY_CLOSEFILE_LENGTH		(DS_MIN_REPLY_LENGTH + 1)
+  
+#if __MWERKS__
+#pragma mark  PositionFile
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSPositionFile
+ *
+ *	Send: if DS_PROTOCOL < DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui8		mode				- (1) DSFilePositionModes (see below)
+ *		ui32	file_handle			- (4) handle of the file to be positioned
+ *		ui32	offset				- (4) position offset
+ *									  <9 + header> total
+ *
+ *	Send: if DS_PROTOCOL == DS_PROTOCOL_RTOS
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *		ui8		mode				- (1) DSFilePositionModes (see below)
+ *		ui32	file_handle			- (4) handle of the file to be positioned
+ *		ui32	offset				- (4) position offset
+ *		ui32	processID			- (4) unique process ID
+ *		ui32	threadID			- (4) unique thread ID
+ *									  <17 + header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui8		io_result			- (1) DSIOResult (see below)
+ *									  <1 + header> total
+ *	
+ *	Sent by the target.  Instructs the host to set the file position
+ *	of the specified file.  The new position will be at the specified
+ *	offset from one of three reference points in the file, as specified
+ *	by the mode.
+ *	Expects a reply from the host in the above format.
+ *
+ */
+/****************************************************************************/
+
+#if DS_PROTOCOL == DS_PROTOCOL_RTOS
+	#define DS_MIN_MSG_POSITIONFILE_LENGTH	(DS_MIN_MSG_LENGTH + 13)
+#else
+	#define DS_MIN_MSG_POSITIONFILE_LENGTH	(DS_MIN_MSG_LENGTH + 5)
+#endif
+#define DS_MIN_REPLY_POSITIONFILE_LENGTH	(DS_MIN_REPLY_LENGTH + 1)
+  
+/*
+** These are the predefined file handles.  Additional files may
+** be opened via the kDSOpenFile command.  New file handles 
+** returned by that command may be used in addition to the
+** ones defined here.
+*/
+
+typedef enum DSFileHandle
+{
+	kDSStdin  = 0x00,
+	kDSStdout = 0x01,
+	kDSStderr = 0x02
+} DSFileHandle;
+
+/*
+** The result of an I/O command can be any one of the following.
+*/
+
+typedef enum DSIOResult
+{
+	kDSIONoError	= 0x00,
+	kDSIOError		= 0x01,
+	kDSIOEOF		= 0x02
+} DSIOResult;
+
+/*
+** When opening a file, the following values can be OR'ed together
+** to specify the desired open modes.  The following table shows
+** the correlation between the various modes and the standard mode
+** option for fopen:
+**
+**	read	write	append	binary	create		fopen mode
+**	-------------------------------------------------------
+**	yes											"r"
+**			yes*					yes			"w"
+**			yes*	yes				yes			"a"
+**	yes		yes									"r+"
+**	yes		yes*					yes			"w+"
+**	yes		yes*	yes				yes			"a+"
+**	yes						yes					"rb"
+**			yes*			yes		yes			"wb"
+**			yes*	yes		yes		yes			"ab"
+**	yes		yes				yes					"r+b"
+**	yes		yes*			yes		yes			"w+b"
+**	yes		yes*	yes		yes		yes			"a+b"
+**
+**
+** * Note that when the append or create modes are specified,
+** the write mode is always assumed.
+**
+** If the exec mode is specified, the resulting file will
+** be created as an executable file (with execute permissions).
+** This is only meaningful if the create mode is also specified.
+*/
+
+typedef enum DSFileOpenModes
+{
+	kDSFileOpenRead		= 0x01,
+	kDSFileOpenWrite	= 0x02,
+	kDSFileOpenAppend	= 0x04,
+	kDSFileOpenBinary	= 0x08,
+	kDSFileOpenCreate	= 0x10,
+	kDSFileOpenExec		= 0x20
+} DSFileOpenModes;
+
+/*
+** Use one of the following values to specify a file positioning mode.
+*/
+
+typedef enum DSFilePositionModes
+{
+	kDSFileSeekSet		= 0x00,		/* Position is offset from file start */
+	kDSFileSeekCur		= 0x01,		/* Position is offset from current pos. */
+	kDSFileSeekEnd		= 0x02		/* Position is offset from file end */
+} DSFilePositionModes;
+
+#if __MWERKS__
+#pragma mark  OS File Operations
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	kDSOSWriteFile
+ *	kDSOSReadFile
+ *	kDSOSOpenFile
+ *	kDSOSCloseFile
+ *	kDSOSPositionFile
+ *	kDSOSInstallFile
+ *  kDSOSInstallFile2
+ *
+ *	The format and function of these commands is identical to
+ *	that of the kDSWriteFile, kDSReadFile, kDSOpenFile,
+ *	kDSCloseFile, and kDSPositionFile commands described above.  
+ *
+ *	The difference is that these commands are sent from the host to
+ *	the target, they operate on files on the target system, and they
+ *	do not include the processId and threadId fields (i.e., they are 
+ *	formatted as described above as if DS_PROTOCOL < DS_PROTOCOL_RTOS).
+ */
+/****************************************************************************/
+
+/*** kDSOSWriteFile ***/
+DESCDECL TrkMsgDesc gTrkMsgOsWriteFile
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Write File" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	6,											/* # of addl bytes */
+	2,											/* # of addl fields */
+	{						/* addl field descriptors (data handled separately): */
+		__trk_msg_field( "file handle", 4 ),
+		__trk_msg_field( "length", 2 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_OWF_HANDLE_INDEX		(0 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_OWF_LENGTH_INDEX		(1 + TRK_MSG_HEADER_COUNT)
+
+DESCDECL TrkMsgDesc gTrkMsgOsWriteFileReply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Write File Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	3,											/* # of addl bytes */
+	2,											/* # of addl fields */
+	{						/* addl field descriptors (data handled separately): */
+		__trk_msg_field( "io result", 1 ),
+		__trk_msg_field( "length", 2 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_OWFR_IORESULT_INDEX		(0 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_OWFR_LENGTH_INDEX		(1 + TRK_MSG_REPLY_HEADER_COUNT)
+
+
+/*** kDSOSReadFile ***/
+DESCDECL TrkMsgDesc gTrkMsgOsReadFile
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Read File" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	6,											/* # of addl bytes */
+	2,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "file handle", 4 ),
+		__trk_msg_field( "length", 2 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_ORF_HANDLE_INDEX		(0 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_ORF_LENGTH_INDEX		(1 + TRK_MSG_HEADER_COUNT)
+
+DESCDECL TrkMsgDesc gTrkMsgOsReadFileReply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Read File Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	3,											/* # of addl bytes */
+	2,											/* # of addl fields */
+	{						/* addl field descriptors (data handled separately): */
+		__trk_msg_field( "IO result", 1 ),
+		__trk_msg_field( "length", 2 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_ORFR_IORESULT_INDEX		(0 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_ORFR_LENGTH_INDEX		(1 + TRK_MSG_REPLY_HEADER_COUNT)
+
+
+/*** kDSOSOpenFile ***/
+DESCDECL TrkMsgDesc gTrkMsgOsOpenFile
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Open File" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	3,											/* # of addl bytes */
+	2,											/* # of addl fields */
+	{						/* addl field descriptors (file_name handled separately): */
+		__trk_msg_field( "modes", 1 ),
+		__trk_msg_field( "name length", 2 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_OOF_MODES_INDEX		(0 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_OOF_LENGTH_INDEX	(1 + TRK_MSG_HEADER_COUNT)
+
+DESCDECL TrkMsgDesc gTrkMsgOsOpenFileReply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Open File Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	9,											/* # of addl bytes */
+	3,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "IO result", 1 ),
+		__trk_msg_field( "file handle", 4 ),
+		__trk_msg_field( "timestamp", 4 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_OOFR_IORESULT_INDEX		(0 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_OOFR_HANDLE_INDEX		(1 + TRK_MSG_REPLY_HEADER_COUNT)
+#define TRK_MSG_OOFR_TIMESTAMP_INDEX	(2 + TRK_MSG_REPLY_HEADER_COUNT)
+
+
+/*** kDSOSCloseFile ***/
+DESCDECL TrkMsgDesc gTrkMsgOsCloseFile
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Close File" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	8,											/* # of addl bytes */
+	2,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "file handle", 4 ),
+		__trk_msg_field( "timestamp", 4 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_OCF_HANDLE_INDEX	(0 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_OCF_TIMESTAMP_INDEX	(1 + TRK_MSG_HEADER_COUNT)
+
+DESCDECL TrkMsgDesc gTrkMsgOsCloseFileReply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Close File Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	1,											/* # of addl bytes */
+	1,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "IO result", 1 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_OCFR_IORESULT_INDEX		(0 + TRK_MSG_REPLY_HEADER_COUNT)
+
+
+/*** kDSOSPositionFile ***/
+DESCDECL TrkMsgDesc gTrkMsgOsPositionFile
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Position File" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	9,											/* # of addl bytes */
+	3,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "modes", 1 ),
+		__trk_msg_field( "file handle", 4 ),
+		__trk_msg_field( "offset", 4 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_OPF_MODES_INDEX		(0 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_OPF_HANDLE_INDEX	(1 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_OPF_OFFSET_INDEX	(2 + TRK_MSG_HEADER_COUNT)
+
+DESCDECL TrkMsgDesc gTrkMsgOsPositionFileReply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Position File Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	1,											/* # of addl bytes */
+	1,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "IO result", 1 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_OPFR_IORESULT_INDEX		(0 + TRK_MSG_REPLY_HEADER_COUNT)
+
+
+/*** kDSOSInstallFile ***/
+DESCDECL TrkMsgDesc gTrkMsgOsInstallFile
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Install File" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	3,											/* # of addl bytes */
+	2,											/* # of addl fields */
+	{											/* addl field descriptors (file_name handled separately): */
+		__trk_msg_field( "drive", 1 ),
+		__trk_msg_field( "name length", 2 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_OIF_DRIVE_INDEX		(0 + TRK_MSG_HEADER_COUNT)
+#define TRK_MSG_OIF_LENGTH_INDEX	(1 + TRK_MSG_HEADER_COUNT)
+
+DESCDECL TrkMsgDesc gTrkMsgOsInstallFileReply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Install File Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	1,											/* # of addl bytes */
+	1,											/* # of addl fields */
+	{											/* addl field descriptors: */
+		__trk_msg_field( "IO result", 1 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/*** kDSOSInstallFile2 ***/
+DESCDECL TrkMsgDesc gTrkMsgOsInstallFile2
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Install File2" )
+	&gTrkMsgHeader,								/* previous fragment/header */
+	2,											/* # of addl bytes */
+	1,											/* # of addl fields */
+	{											/* addl field descriptors (file_name handled separately): */
+		__trk_msg_field( "name length", 2 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/* "Index" of fields.  Take # of header fields into account. */
+#define TRK_MSG_OIF2_LENGTH_INDEX	(0 + TRK_MSG_HEADER_COUNT)
+
+DESCDECL TrkMsgDesc gTrkMsgOsInstallFile2Reply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "OS Install File2 Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	1,											/* # of addl bytes */
+	1,											/* # of addl fields */
+	{											/* addl field descriptors: */
+		__trk_msg_field( "IO result", 1 )
+	}
+}
+#endif /* #ifdef TRK_MSGCMD_INIT */
+;
+
+/****************************************************************************/
+/*
+ *	kDSOSPhoneSWVersion
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui16	version string len	- (2)
+ *		string  sw version string 
+ *
+ *
+ */
+/****************************************************************************/
+#define DS_MIN_MSG_PHONESWVERSION_LENGTH			DS_MIN_MSG_LENGTH
+
+DESCDECL TrkMsgDesc gTrkMsgPhoneSWVersionReply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Phone SW Version Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	x,											/* # of addl bytes */
+	x,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "version string len", 2 ),
+		__trk_msg_field( "version string", x )
+	}
+}
+#endif 
+;
+/****************************************************************************/
+/*
+ *	kDSOSPhoneName
+ *
+ *	Send:
+ *
+ *		....	<Message Header>	  ... (see gTrkMsgHeader)
+ *									  <header> total
+ *
+ *	Reply:
+ *
+ *		....	<Reply Header>		  ... (see gTrkMsgReplyHeader)
+ *		ui16	phone name len	- (2)
+ *		string  phone name string 
+ *
+ *
+ */
+/****************************************************************************/
+#define DS_MIN_MSG_PHONENAME_LENGTH			DS_MIN_MSG_LENGTH
+
+DESCDECL TrkMsgDesc gTrkMsgPhoneNameReply
+#ifdef TRK_MSGCMD_INIT
+= {
+	__debug_only_parm( "Phone Name Reply" )
+	&gTrkMsgReplyHeader,						/* previous fragment/header */
+	x,											/* # of addl bytes */
+	x,											/* # of addl fields */
+	{						/* addl field descriptors: */
+		__trk_msg_field( "phone name string len", 2 ),
+		__trk_msg_field( "phone name string", x )
+	}
+}
+#endif 
+;
+
+#if __MWERKS__
+#pragma mark  Message Error Values
+#endif /* __MWERKS__ */
+/****************************************************************************/
+/*
+ *	Error values returned in ACK/NAK packets
+ */
+/****************************************************************************/
+ typedef enum {
+ 	kDSReplyNoError = 0x00,					/* no error */
+	kDSReplyError = 0x01,					/* generic error in CWDS message */
+	kDSReplyPacketSizeError = 0x02,			/* unexpected pkt size in send msg */
+	kDSReplyCWDSError = 0x03,				/* internal error occurred in CWDS */
+	kDSReplyEscapeError = 0x04,				/* escape followed by frame flag */
+	kDSReplyBadFCS = 0x05,					/* bad FCS in packet */
+	kDSReplyOverflow = 0x06,				/* packet too long */
+	kDSReplySequenceMissing = 0x07,			/* sequence ID != expected (gap in sequence) */
+
+	kDSReplyUnsupportedCommandError = 0x10,	/* command not supported */
+	kDSReplyParameterError = 0x11,			/* command param out of range */
+	kDSReplyUnsupportedOptionError = 0x12,	/* an option was not supported */
+	kDSReplyInvalidMemoryRange = 0x13,		/* read/write to invalid memory */
+	kDSReplyInvalidRegisterRange = 0x14,	/* read/write invalid registers */
+	kDSReplyCWDSException = 0x15,			/* exception occurred in CWDS */
+	kDSReplyNotStopped = 0x16,				/* targeted system or thread is running */
+	kDSReplyBreakpointsFull = 0x17,			/* bp resources (HW or SW) exhausted */
+	kDSReplyBreakpointConflict = 0x18,		/* requested bp conflicts w/existing bp */
+
+	kDSReplyOsError = 0x20,					/* general OS-related error */
+	kDSReplyInvalidProcessId = 0x21,		/* request specified invalid process */
+	kDSReplyInvalidThreadId = 0x22,			/* request specified invalid thread */
+	
+	kDSDebugSecurityError = 0x23			/* security error from DSS */
+	
+} DSReplyError;
+
+
+#endif /* __MSGCMD_H__ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/serframe.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,226 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*	Frame Check Sequence checksums (FCS) for 16 and 32 bits.
+*
+*	The 16-bit version uses a 512-byte table (2 bytes * 256 elements)
+*	and the 32-bit version uses a 1024-byte table (4 bytes * 256 elements)
+*
+*	Serial-based HDLC-like framing (RFC 1662) for use with the
+*	CWDS serial protocol.
+*	
+*	Serial data is transmitted using an HDLC-like framing convention.
+*	Byte-oriented streams are transmitted with a starting frame byte
+*	and also followed by an ending frame byte and a checksum (FCS).
+*	
+*	Errors can be detected with high probability using the FCS.
+*	While this is not intended to be used in an environment that
+*	generates a large number of errors, nevertheless it can be
+*	useful to help ensure that packets arrive with a high degree of
+*	certainty and to allow data to be dropped and still allow
+*	continuous data.
+*	
+*	Sender and receiver can be resynchronized with the receipt of a new
+*	framing byte.
+*	
+*	
+*	Frame Format
+*	
+*	The general frame format specified in RFC 1662 is described as:
+*
+*		+----------+----------+----------+
+*		|   Flag   | Address  | Control  |
+*		| 01111110 | 11111111 | 00000011 |
+*		+----------+----------+----------+
+*		+----------+-------------+---------+
+*		| Protocol | Information | Padding |
+*		| 8/16 bits|      *      |    *    |
+*		+----------+-------------+---------+
+*		+----------+----------+-----------------
+*		|   FCS    |   Flag   | Inter-frame Fill
+*		|16/32 bits| 01111110 | or next Address
+*		+----------+----------+-----------------
+*
+*	The routines in this file use a subset and are not negotiated;
+*	they are simply assumed. These are:
+*	
+*	Address and Control Field Compression is always ON.
+*	Protocol Field Compression is always ON.
+*	Protocol value is implied, but undefined.
+*	Padding is OFF.
+*	MRU is 1500 bytes.
+*	FCS is 32 bits.
+*	Trailing Flag is always transmitted.
+*	
+*	
+*	The resulting frame format is:
+*
+*		+----------+
+*		|   Flag   |
+*		| 01111110 |
+*		+----------+
+*		+-------------+
+*		| Information |
+*		|      *      |
+*		+-------------+
+*		+----------+----------+-----------------
+*		|   FCS    |   Flag   | Inter-frame Fill
+*		|16/32 bits| 01111110 | or next Address
+*		+----------+----------+-----------------
+*	
+*	Macros & Typedefs
+*		
+*		FCSBITSIZE
+*		
+*			This header file must first define FCSBITSIZE to be either one of:
+*			FCS16 or FCS32.  These control the definitions for the rest of the header
+*			file and the underlying tables.  Selecting FCS16 will cause the header
+*			file to define 16-bit types, table, and functions for calculating the
+*			16-bit FCS.  Selecting FCS32 is identical, except it uses 32-bit FCS values.
+*			
+*			FCS16 will use 512 bytes (2 bytes * 256 entries) of constant data space.
+*			FCS32 will use 1024 bytes.
+*	
+*		FCSType
+*		
+*			The 16- or 32-bit type used for the FCS register and datum.
+*
+*		PPPINITFCS
+*			
+*			Initialize the FCS register with this value.
+*		
+*		PPPGOODFCS
+*		
+*			On the receiver side, after the FCS compute function is applied
+*			to all data bytes plus the two or four FCS bytes, the correct FCS
+*			value will be PPPGOODFCS, a constant.
+*		
+*		PPPCOMPFCS
+*
+*
+*	REFERENCES
+*
+*	[RFC1662.94]	Simpson, W., Editor, "PPP in HDLC-like Framing,"
+*					STD 51, RFC 1662, Daydreamer, July 1994.
+*
+*/
+	
+	
+#ifndef TRK_SERFRAME_H
+#define TRK_SERFRAME_H
+
+#define FCS8  0					/* SCM: Added for simple 8-bit checksums */
+#define FCS16 1
+#define FCS32 2
+
+#define	FCSBITSIZE FCS8			/* define as either FCS8, FCS16 or FCS32 */
+
+
+#if FCSBITSIZE == FCS8
+
+	/*
+	 *	Definitions for 8-bit simple Frame Check Sequences
+	 */
+	 
+	typedef unsigned char FCSType;	/* 8-bit type */
+
+	#define PPPINITFCS8		0x00		/* Initial FCS value */
+	#define PPPGOODFCS8		0xFF		/* Good final FCS value */
+
+	#define PPPINITFCS		PPPINITFCS8
+	#define PPPGOODFCS		PPPGOODFCS8
+	#define PPPCOMPFCS		0xFF		/* complement FCS value */
+
+	#ifdef __cplusplus	
+		inline FCSType PPPFCS(FCSType fcs, unsigned char c)
+		{
+			return (fcs + c);
+		}
+
+	#else
+		#define PPPFCS(fcs, c)	(fcs + c)
+	#endif
+
+	
+#elif FCSBITSIZE == FCS16
+
+	/*
+	 *	Definitions for 16-bit Frame Check Sequences
+	 */
+	 
+	typedef unsigned short FCSType;	/* 16-bit type */
+/*	extern FCSType fcstab[]; */
+	extern const FCSType fcstab[256];
+
+	#define PPPINITFCS16	0xffff		/* Initial FCS value */
+	#define PPPGOODFCS16	0xf0b8		/* Good final FCS value */
+
+	#define PPPINITFCS		PPPINITFCS16
+	#define PPPGOODFCS		PPPGOODFCS16
+	#define PPPCOMPFCS		0xffff		/* complement FCS value */
+
+	#if __cplusplus	
+		inline FCSType PPPFCS(FCSType fcs, unsigned char c)
+		{
+			return (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]);
+		}
+
+	#else
+		#define PPPFCS(fcs, c)	(((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
+	#endif
+
+#elif FCSBITSIZE == FCS32
+
+	/*
+	 *	Definitions for 32-bit Frame Check Sequences
+	 */
+
+	typedef unsigned long FCSType;	/* 32-bit FCS */
+/*	extern FCSType fcstab_32[]; */
+	extern const FCSType fcstab_32[256];
+
+	#define PPPINITFCS32 	0xffffffff	/* Initial FCS value */
+	#define PPPGOODFCS32 	0xdebb20e3	/* Good final FCS value */
+
+	#define PPPINITFCS		PPPINITFCS32
+	#define PPPGOODFCS		PPPGOODFCS32
+	#define PPPCOMPFCS		0xffffffff	/* complement FCS value */
+	
+	#if __cplusplus
+		inline FCSType PPPFCS(FCSType fcs, unsigned char c)
+		{
+			return (((fcs) >> 8) ^ fcstab_32[((fcs) ^ (c)) & 0xff]);
+		}
+	#else
+		#define PPPFCS(fcs, c) (((fcs) >> 8) ^ fcstab_32[((fcs) ^ (c)) & 0xff])
+	#endif
+
+#endif
+
+
+/****************************************************************************/
+/*
+ *	Constants used for framing serial data
+ */
+/****************************************************************************/
+
+#define	PPP_UI			0x03	/* Unnumbered Information */
+#define	PPP_FLAG		0x7e	/* Flag Sequence */
+#define	PPP_ESCAPE		0x7d	/* Asynchronous Control Escape */
+#define	PPP_TRANS		0x20	/* Asynchronous transparency modifier */
+
+#define MAXFRAMESIZE	0x1000	/* maximum unframed/unescaped data size */
+
+#endif /* ndef TRK_SERFRAME_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/trkengine_nokia_tshell.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+macro 		__OEM_TRK__
+macro 		__TEXT_SHELL__
+macro 		__NOKIA_TEXT_SHELL__
+macro  		__ENABLE_XTI__
+
+TARGET		TrkEngine.dll
+TARGETTYPE	dll
+UID		0x00000000 0x200159D9
+
+VENDORID VID_DEFAULT
+CAPABILITY ALL -TCB -DRM
+
+SOURCEPATH	.
+
+SOURCE		TrkEngine.cpp TrkDispatchLayer.cpp TrkFramingLayer.cpp
+SOURCE		TrkDccCommPort.cpp DateTimeConverter.cpp
+SOURCE 		TrkEngineModel.cpp TrkXtiCommPort.cpp
+
+#if defined(EKA2)
+SOURCEPATH	../tcbclient
+SOURCE		TrkTcbCliSession.cpp TrkTcbClientUtils.cpp TrkTcbClientDefs.cpp
+#endif
+
+LIBRARY	efsrv.lib euser.lib
+
+
+SYSTEMINCLUDE	/epoc32/include
+USERINCLUDE	. 
+
+#if defined(EKA2)
+USERINCLUDE	../dccdriver
+USERINCLUDE	../eka2driver
+USERINCLUDE	../tcbclient
+USERINCLUDE	../tcbserver
+USERINCLUDE	../xtidriver
+#else
+USERINCLUDE	../driver
+#endif
+
+
+#if defined(WINS)
+    deffile ./trkengU_win.def
+#elif defined(EABI)
+    deffile ../eabi/trkengine_nokia_tshell.def
+#elif defined(ARM)
+    deffile ../bmarm/trkengine.def
+#endif
+nostrictdef
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/trkengine_tshell.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#if defined(EKA2) 
+macro 		__OEM_TRK__
+#endif
+macro 		__TEXT_SHELL__
+
+TARGET		TrkEngine.dll
+TARGETTYPE	dll
+UID		0x00000000 0x200159D9
+
+VENDORID 0x101FB657
+CAPABILITY ALL -TCB -DRM
+
+SOURCEPATH	.
+
+SOURCE		TrkEngine.cpp TrkDispatchLayer.cpp TrkFramingLayer.cpp
+SOURCE		TrkDccCommPort.cpp DateTimeConverter.cpp
+SOURCE 		TrkEngineModel.cpp TrkSerialCommPort.cpp
+
+#if defined(EKA2)
+SOURCEPATH	../tcbclient
+SOURCE		TrkTcbCliSession.cpp TrkTcbClientUtils.cpp TrkTcbClientDefs.cpp
+#endif
+
+LIBRARY	efsrv.lib euser.lib c32.lib
+
+
+SYSTEMINCLUDE	/epoc32/include
+USERINCLUDE	. 
+
+#if defined(EKA2)
+USERINCLUDE	../dccdriver
+USERINCLUDE	../eka2driver
+USERINCLUDE	../tcbclient
+USERINCLUDE	../tcbserver
+#else
+USERINCLUDE	../driver
+#endif
+
+
+#if defined(WINS)
+    deffile ./trkengU_win.def
+#elif defined(EABI)
+    deffile ../eabi/trkengine_tshell.def
+#endif
+nostrictdef
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/trkengine_uiq.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+macro 		__OEM_TRK__
+
+
+macro __UIQ_BUILD__
+
+TARGET		TrkEngine.dll
+TARGETTYPE	dll
+UID		0x00000000 0x200159D9
+
+VENDORID 0x101FB657    // NOKIA VID
+CAPABILITY ALL -TCB -DRM
+
+SOURCEPATH	.
+
+SOURCE		TrkEngine.cpp TrkDispatchLayer.cpp TrkFramingLayer.cpp
+SOURCE		TrkSerialCommPort.cpp TrkBtSocketCommPort.cpp TrkDccCommPort.cpp DateTimeConverter.cpp
+SOURCE 		TrkEngineModel.cpp TrkDbgTrcCommPort.cpp TrkUsbPortListener.cpp
+SOURCE		TrkSwInstall.cpp TrkSwInstUIHandler.cpp
+
+
+
+SOURCEPATH	..\tcbclient
+SOURCE		TrkTcbCliSession.cpp TrkTcbClientUtils.cpp TrkTcbClientDefs.cpp 
+
+LIBRARY		efsrv.lib euser.lib c32.lib sishelper.lib btdevice.lib 
+LIBRARY     bluetooth.lib qbtsharedui.lib btextnotifiers.lib esock.lib 
+LIBRARY     usbman.lib usbostcomm.lib
+
+SYSTEMINCLUDE	\epoc32\include
+SYSTEMINCLUDE	\epoc32\include\kernel
+USERINCLUDE	. 
+
+USERINCLUDE	..\eka2driver
+USERINCLUDE	..\tcbclient
+USERINCLUDE	..\tcbserver
+USERINCLUDE	..\dccdriver
+
+
+#if defined(WINS)
+    deffile .\trkengU_win.def
+#elif defined(EABI)
+    deffile ..\eabi\trkengine_uiq.def
+#endif
+nostrictdef
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/trkengu_win.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,16 @@
+EXPORTS
+	??1CTrkEngine@@UAE@XZ @ 1 NONAME ; CTrkEngine::~CTrkEngine(void)
+	?GetConnectionData@CTrkEngine@@QAEXAAVTTrkConnData@@@Z @ 2 NONAME ; void CTrkEngine::GetConnectionData(class TTrkConnData &)
+	?GetConnectionInfo@CTrkEngine@@QAEXAAVTDes16@@@Z @ 3 NONAME ; void CTrkEngine::GetConnectionInfo(class TDes16 &)
+	?GetErrorInfo@CTrkEngine@@QAEXAAVTDes16@@@Z @ 4 NONAME ; void CTrkEngine::GetErrorInfo(class TDes16 &)
+	?GetVersionInfo@CTrkEngine@@QAEXAAH0000@Z @ 5 NONAME ; void CTrkEngine::GetVersionInfo(int &, int &, int &, int &, int &)
+	?IsDebugging@CTrkEngine@@QAEHXZ @ 6 NONAME ; int CTrkEngine::IsDebugging(void)
+	?NewL@CTrkEngine@@SAPAV1@PAVMTrkEngineCallback@@@Z @ 7 NONAME ; class CTrkEngine * CTrkEngine::NewL(class MTrkEngineCallback *)
+	?NewL@CTrkEngine@@SAPAV1@XZ @ 8 NONAME ; class CTrkEngine * CTrkEngine::NewL(void)
+	?NewLC@CTrkEngine@@SAPAV1@PAVMTrkEngineCallback@@@Z @ 9 NONAME ; class CTrkEngine * CTrkEngine::NewLC(class MTrkEngineCallback *)
+	?NewLC@CTrkEngine@@SAPAV1@XZ @ 10 NONAME ; class CTrkEngine * CTrkEngine::NewLC(void)
+	?SetConnectionData@CTrkEngine@@QAEHVTTrkConnData@@@Z @ 11 NONAME ; int CTrkEngine::SetConnectionData(class TTrkConnData)
+	?StartL@CTrkEngine@@QAEXXZ @ 12 NONAME ; void CTrkEngine::StartL(void)
+	?Stop@CTrkEngine@@QAEXXZ @ 13 NONAME ; void CTrkEngine::Stop(void)
+	?StartL@CTrkEngine@@QAEXW4TTrkConnType@@@Z @ 14 NONAME ; void CTrkEngine::StartL(enum TTrkConnType)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/engine/trklogging.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#if defined(__TRKLOGGING__)
+
+    #include <e32debug.h>
+
+    #define LOG_MSG( a )              RDebug::Printf( a )
+    #define LOG_MSG2( a, b )          RDebug::Printf( a, b )
+    #define LOG_MSG3( a, b, c )       RDebug::Printf( a, b, c )
+    #define LOG_MSG4( a, b, c, d )    RDebug::Printf( a, b, c, d )
+    #define LOG_MSG5( a, b, c, d, e )    RDebug::Printf( a, b, c, d, e )
+	#define LOG_MSG6( a, b, c, d, e, f ) RDebug::Printf( a, b, c, d, e, f )
+
+#else
+
+  #define LOG_MSG( a )
+  #define LOG_MSG2( a, b )
+  #define LOG_MSG3( a, b, c )
+  #define LOG_MSG4( a, b, c, d )
+  #define LOG_MSG5( a, b, c, d, e )
+  #define LOG_MSG6( a, b, c, d, e, f )
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/Trk.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,7 @@
+[SERIALCOMM]
+PDD EUART%d
+LDD ECOMM
+CSY ECUART
+PORT 0
+RATE 115200
+PlugPlay 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#if(defined __SERIES60_30__ || defined __SERIES60_31__)
+#include ".\s60\bld.inf"
+#else
+#include "./s60/bld.inf"
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/nokia_tshell/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/nokia_tshell/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+trk_tshell.iby 		/epoc32/rom/include/trk.iby
+
+../trk.ini    		/epoc32/data/Z/trk/trk.ini
+../trk_bt.ini    	/epoc32/data/Z/trk/trk_bt.ini
+../trk_usb.ini    	/epoc32/data/Z/trk/trk_usb.ini
+../trk_dcc.ini    	/epoc32/data/Z/trk/trk_dcc.ini
+../s60/trk_xti.ini    	/epoc32/data/Z/trk/trk_xti.ini
+
+PRJ_MMPFILES
+
+#ifdef MARM
+../../dccdriver/trkdccdriver_tv
+../../eka2driver/trkkerneldriver_tv
+../../xtidriver/trkxtidriver
+../../engine/trkengine_nokia_tshell
+../../app/console/TrkConsole.mmp
+../../trkserver/trkserver_tv.mmp
+../../tcbserver/trktcbserver_tv
+../../trklauncher/trklauncher_tv
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/nokia_tshell/trk_tshell.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TRK_IBY__
+#define __TRK_IBY__
+
+// trk debugger stub
+
+//For disabling autostart of TRK, comment the line below
+ECOM_PLUGIN(trklauncher.dll, trklauncher.rsc)
+
+file=ABI_DIR\BUILD_DIR\trkengine.dll	System\Libs\trkengine.dll
+file=ABI_DIR\BUILD_DIR\trkconsole.exe	System\Programs\TRKConsole.exe
+
+
+device[VARID]=ABI_DIR\BUILD_DIR\trkdriver.ldd System\Libs\trkdriver.ldd
+device[VARID]=ABI_DIR\BUILD_DIR\trkdccdriver.ldd System\Libs\trkdccdriver.ldd
+device[VARID]=ABI_DIR\BUILD_DIR\trkxtidriver.ldd System\Libs\trkxtidriver.ldd
+file=ABI_DIR\BUILD_DIR\trktcbserver.exe	 sys\bin\TrkTcbServer.exe
+file=ABI_DIR\BUILD_DIR\trkserver.exe	 sys\bin\trkserver.exe
+
+// To use DCC, modify the line below to include the dcc ini file
+data=ZSYSTEM\..\trk\trk_xti.ini     \trk.ini
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+#if(defined __SERIES60_30__ || defined __SERIES60_31__)
+#include "..\..\dbgtrccomm\group\s60\bld.inf"
+#include "..\..\toolsstarter\bld.inf"
+#else
+#include "../../dbgtrccomm/group/s60/bld.inf"
+#include "../../toolsstarter/bld.inf"
+#endif
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+
+PRJ_EXPORTS
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+      ../../rom/trk.iby     	CORE_IBY_EXPORT_PATH(tools,trk.iby)
+      ../../rom/trk_rom.iby     CORE_IBY_EXPORT_PATH(tools/rom,trk_rom.iby)
+#endif
+
+#if(defined __SERIES60_30__ || defined __SERIES60_31__)
+..\trk.ini    	\epoc32\data\Z\trk\trk.ini
+..\trk_bt.ini    	\epoc32\data\Z\trk\trk_bt.ini
+..\trk_usb.ini    	\epoc32\data\Z\trk\trk_usb.ini
+..\trk_dcc.ini    	\epoc32\data\Z\trk\trk_dcc.ini
+trk_xti.ini    	\epoc32\data\Z\trk\trk_xti.ini
+#else
+../Trk.ini    		/epoc32/data/Z/trk/trk.ini
+../trk_bt.ini    	/epoc32/data/Z/trk/trk_bt.ini
+../trk_usb.ini    	/epoc32/data/Z/trk/trk_usb.ini
+../trk_dcc.ini    	/epoc32/data/Z/trk/trk_dcc.ini
+trk_xti.ini    	/epoc32/data/Z/trk/trk_xti.ini
+#endif
+
+PRJ_MMPFILES
+#ifndef SBSV2
+gnumakefile trk_aif_svg_icons_dc.mk
+#endif
+
+#ifdef MARM
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+..\..\dccdriver\trkdccdriver_s60
+// XTI driver requires some tracecore headers that are not available in some S60 releases.
+//..\..\xtidriver\trkxtidriver 
+..\..\eka2driver\trkkerneldriver_s60
+..\..\engine\trkengine_s60
+..\..\app\s60\trkconsole_s60
+..\..\app\s60\trkapp_s60
+..\..\tcbserver\trktcbserver_s60
+..\..\trklauncher\trklauncher_s60
+..\..\trkserver\trkserver_s60
+..\..\DebugNotifier\DebugNotifier_s60
+
+#else
+../../dccdriver/TrkDccDriver_s60
+../../xtidriver/TrkXtiDriver
+../../eka2driver/TrkKernelDriver_s60
+../../engine/TrkEngine_s60
+../../app/s60/TrkConsole_s60
+../../app/s60/TrkApp_s60
+../../tcbserver/TrkTcbServer_s60
+../../trklauncher/trklauncher_s60
+../../trkserver/trkserver_s60
+../../debugnotifier/DebugNotifier_s60
+#endif
+
+#endif
+
+PRJ_EXTENSIONS
+
+#ifdef SBSV2
+START EXTENSION s60/mifconv
+OPTION TARGETFILE trkapp_200170bb.mif
+OPTION SOURCES -c8,8 qgn_menu_trk
+END
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/isv_build/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/isv_build/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#if(defined __SERIES60_30__ || defined __SERIES60_31__)
+#include "..\..\..\dbgtrccomm\group\s60\bld.inf"
+#else
+#include "../../../dbgtrccomm/group/s60/bld.inf"
+#endif
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+..\..\trk_bt.ini    \epoc32\data\Z\trk\trk_bt.ini
+..\..\trk_usb.ini    \epoc32\data\Z\trk\trk_usb.ini
+#else
+../../trk_bt.ini    /epoc32/data/Z/trk/trk_bt.ini
+../../trk_usb.ini    /epoc32/data/Z/trk/trk_usb.ini
+#endif
+
+PRJ_MMPFILES
+gnumakefile ..\trk_aif_svg_icons_dc.mk
+
+#ifdef MARM
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+..\..\..\eka2driver\isv_trkkerneldriver_s60
+..\..\..\engine\isv_trkengine_s60
+..\..\..\app\s60\isv_trkapp_s60
+#else
+../../../eka2driver/isv_trkkerneldriver_s60
+../../../engine/isv_trkengine_s60
+../../../app/s60/isv_trkapp_s60
+#endif
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/isv_build/isv_trk.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TRK_IBY__
+#define __TRK_IBY__
+
+// trk debugger stub
+
+file=ABI_DIR\BUILD_DIR\trkengine.dll	System\Libs\trkengine.dll
+
+#ifdef __UI_FRAMEWORKS_V2__
+file=ABI_DIR\BUILD_DIR\trkapp_200170bb.exe	sys\bin\trkapp_200170bb.exe
+#else
+file=ABI_DIR\BUILD_DIR\trkapp_200170bb.app	System\Apps\Trk\trkapp_200170bb.app
+#endif
+
+#if defined(EKA2)
+device[VARID]=ABI_DIR\BUILD_DIR\trkdriver.ldd System\Libs\trkdriver.ldd
+#else
+file=ASSP_DIR\BUILD_DIR\trkkernelstub.dll	System\Libs\trkkernelstub.dll
+file=EPOCROOT##epoc32\release\ARM4\BUILD_DIR\trkkerneldriver.ldd System\Libs\trkkerneldriver.ldd
+#endif
+
+data=ZSYSTEM\..\trk\trk_bt.ini     \trk.ini
+
+#ifdef __UI_FRAMEWORKS_V2__
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb  resource\Apps\trkapp_200170bb)
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb_loc  resource\Apps\trkapp_200170bb_loc)
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\private\10003a3f\Apps\trkapp_200170bb_reg  private\10003a3f\Apps\trkapp_200170bb_reg)
+data=MULTI_LINGUIFY(MIF EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb  resource\Apps\trkapp_200170bb)
+#else
+data=MULTI_LINGUIFY(RSC ZSYSTEM\Apps\Trk\trkapp_200170bb  System\Apps\Trk\trkapp_200170bb)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/sis/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/sis/app_trk_s60.pkg	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,54 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+
+;Languages
+&EN
+
+;Header
+#{"App TRK"},(0x200170BB),3,20,4
+
+;Localised Vendor name
+%{"Nokia-EN"}
+
+;Unique Vendor name
+:"Nokia"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+"eula.txt"-"", FILETEXT, TEXTEXIT
+
+;Files to install
+"\epoc32\release\armv5\urel\trkengine.dll"			-"!:\sys\bin\trkengine.dll"
+"\epoc32\release\armv5\urel\trkapp_200170bb.exe"				-"!:\sys\bin\trkapp_200170bb.exe"
+"\epoc32\release\armv5\urel\trkdriver.ldd"			-"!:\sys\bin\trkdriver.ldd"
+"\epoc32\release\armv5\urel\usbostcomm.dll"				-"!:\sys\bin\usbostcomm.dll"
+"\epoc32\release\armv5\urel\usbostrouter.exe"			-"!:\sys\bin\usbostrouter.exe"
+
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb.rsc"			-"!:\resource\Apps\trkapp_200170bb.rsc"
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb_loc.rsc"			-"!:\resource\Apps\trkapp_200170bb_loc.rsc"
+"\epoc32\data\Z\private\10003a3f\apps\trkapp_200170bb_reg.rsc"		-"!:\private\10003a3f\import\apps\trkapp_200170bb_reg.rsc"
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb.mif"			-"!:\resource\Apps\trkapp_200170bb.mif"
+"\epoc32\data\Z\trk\trk_bt.ini"					-"!:\trk.ini"
+
+
+
+; Required files
+; None
+
+; Component .sis files
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/sis/app_trk_s60_5_0.pkg	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,54 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+
+;Languages
+&EN
+
+;Header
+#{"App TRK"},(0x200170BB),3,20,4
+
+;Localised Vendor name
+%{"Nokia-EN"}
+
+;Unique Vendor name
+:"Nokia"
+
+;Supports Series 60 v 3.0
+[0x1028315F], 0, 0, 0, {"Series60ProductID"}
+
+"eula.txt"-"", FILETEXT, TEXTEXIT
+
+;Files to install
+"\epoc32\release\armv5\urel\trkengine.dll"			-"!:\sys\bin\trkengine.dll"
+"\epoc32\release\armv5\urel\trkapp_200170bb.exe"				-"!:\sys\bin\trkapp_200170bb.exe"
+"\epoc32\release\armv5\urel\trkdriver.ldd"			-"!:\sys\bin\trkdriver.ldd"
+"\epoc32\release\armv5\urel\usbostcomm.dll"				-"!:\sys\bin\usbostcomm.dll"
+"\epoc32\release\armv5\urel\usbostrouter.exe"			-"!:\sys\bin\usbostrouter.exe"
+
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb.rsc"			-"!:\resource\Apps\trkapp_200170bb.rsc"
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb_loc.rsc"			-"!:\resource\Apps\trkapp_200170bb_loc.rsc"
+"\epoc32\data\Z\private\10003a3f\apps\trkapp_200170bb_reg.rsc"		-"!:\private\10003a3f\import\apps\trkapp_200170bb_reg.rsc"
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb.mif"			-"!:\resource\Apps\trkapp_200170bb.mif"
+"\epoc32\data\Z\trk\trk_bt.ini"					-"!:\trk.ini"
+
+
+
+; Required files
+; None
+
+; Component .sis files
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/sis/eula.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,2 @@
+By installing this software you accept the terms of the 
+Carbide.C++ End-User License Agreement. The license agreement can be found in your Carbide.c++ installation directory, under the "EULA" subfolder.
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/sis/mk_s60_app_sis.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,18 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+
+makesis app_trk_s60.pkg
+signsis app_trk_s60.sis s60_3_x_app_trk_3_1.sisx RDTest_02.der RDTest_02.key
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/sis/mk_s60_app_sis_5_0.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,18 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+
+makesis app_trk_s60_5_0.pkg
+signsis app_trk_s60_5_0.sis s60_5_x_app_trk_3_1.sisx RDTest_02.der RDTest_02.key
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/sis/mk_s60_sys_sis.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,18 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+
+makesis sys_trk_s60.pkg
+signsis sys_trk_s60.sis s60_3_x_sys_trk_3_2.sisx  RDTest_02.der RDTest_02.key
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/sis/mk_s60_sys_sis_5_0.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,18 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+
+makesis sys_trk_s60_5_0.pkg
+signsis sys_trk_s60_5_0.sis s60_5_x_sys_trk_3_2.sisx  RDTest_02.der RDTest_02.key
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/sis/sys_trk_s60.pkg	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+
+
+;Languages
+&EN
+
+;Header
+#{"System TRK"},(0x200170BB),3,20,4
+
+;Localised Vendor name
+%{"Nokia-EN"}
+
+;Unique Vendor name
+:"Nokia"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+"eula.txt"-"", FILETEXT, TEXTEXIT
+
+;Files to install
+"\epoc32\release\armv5\urel\trkengine.dll"				-"!:\sys\bin\trkengine.dll"
+"\epoc32\release\armv5\urel\trktcbserver.exe"			-"!:\sys\bin\trktcbserver.exe"
+"\epoc32\release\armv5\urel\trkapp_200170bb.exe"		-"!:\sys\bin\trkapp_200170bb.exe"
+"\epoc32\release\armv5\urel\trkdriver.ldd"				-"!:\sys\bin\trkdriver.ldd"
+"\epoc32\release\armv5\urel\trkdccdriver.ldd"			-"!:\sys\bin\trkdccdriver.ldd"
+;"\epoc32\release\armv5\urel\trkxtidriver.ldd"			-"!:\sys\bin\trkxtidriver.ldd"
+"\epoc32\release\armv5\urel\trkserver.exe"				-"!:\sys\bin\trkserver.exe"
+
+"\epoc32\release\armv5\urel\usbostcomm.dll"				-"!:\sys\bin\usbostcomm.dll"
+"\epoc32\release\armv5\urel\usbostrouter.exe"			-"!:\sys\bin\usbostrouter.exe"
+;"\epoc32\release\armv5\urel\usbosttest.exe"			-"!:\sys\bin\usbosttest.exe"
+
+"\epoc32\release\armv5\urel\toolsserverclient.dll"				-"!:\sys\bin\toolsserverclient.dll"
+"\epoc32\release\armv5\urel\DebugNotifier.dll"				-"!:\sys\bin\DebugNotifier.dll"
+
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb.rsc"				-"!:\resource\Apps\trkapp_200170bb.rsc"
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb_loc.rsc"			-"!:\resource\Apps\trkapp_200170bb_loc.rsc"
+"\epoc32\data\Z\private\10003a3f\apps\trkapp_200170bb_reg.rsc"	-"!:\private\10003a3f\import\apps\trkapp_200170bb_reg.rsc"
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb.mif"				-"!:\resource\Apps\trkapp_200170bb.mif"
+"\epoc32\data\Z\trk\trk_bt.ini"									-"!:\trk.ini"
+
+
+; Required files
+; None
+
+; Component .sis files
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/sis/sys_trk_s60_5_0.pkg	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+
+
+;Languages
+&EN
+
+;Header
+#{"System TRK"},(0x200170BB),3,20,4
+
+;Localised Vendor name
+%{"Nokia-EN"}
+
+;Unique Vendor name
+:"Nokia"
+
+;Supports Series 60 v 3.0
+[0x1028315F], 0, 0, 0, {"Series60ProductID"}
+
+"eula.txt"-"", FILETEXT, TEXTEXIT
+
+;Files to install
+"\epoc32\release\armv5\urel\trkengine.dll"				-"!:\sys\bin\trkengine.dll"
+"\epoc32\release\armv5\urel\trktcbserver.exe"				-"!:\sys\bin\trktcbserver.exe"
+"\epoc32\release\armv5\urel\trkapp_200170bb.exe"					-"!:\sys\bin\trkapp_200170bb.exe"
+"\epoc32\release\armv5\urel\trkdriver.ldd"				-"!:\sys\bin\trkdriver.ldd"
+"\epoc32\release\armv5\urel\trkdccdriver.ldd"			-"!:\sys\bin\trkdccdriver.ldd"
+;"\epoc32\release\armv5\urel\trkxtidriver.ldd"			-"!:\sys\bin\trkxtidriver.ldd"
+"\epoc32\release\armv5\urel\trkserver.exe"				-"!:\sys\bin\trkserver.exe"
+
+"\epoc32\release\armv5\urel\usbostcomm.dll"				-"!:\sys\bin\usbostcomm.dll"
+"\epoc32\release\armv5\urel\usbostrouter.exe"			-"!:\sys\bin\usbostrouter.exe"
+;"\epoc32\release\armv5\urel\usbosttest.exe"				-"!:\sys\bin\usbosttest.exe"
+
+"\epoc32\release\armv5\urel\toolsstarterclient.dll"				-"!:\sys\bin\toolsstarterclient.dll"
+"\epoc32\release\armv5\urel\DebugNotifier.dll"				-"!:\sys\bin\DebugNotifier.dll"
+
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb.rsc"				-"!:\resource\Apps\trkapp_200170bb.rsc"
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb_loc.rsc"				-"!:\resource\Apps\trkapp_200170bb_loc.rsc"
+"\epoc32\data\Z\private\10003a3f\apps\trkapp_200170bb_reg.rsc"			-"!:\private\10003a3f\import\apps\trkapp_200170bb_reg.rsc"
+"\epoc32\data\Z\Resource\Apps\trkapp_200170bb.mif"				-"!:\resource\Apps\trkapp_200170bb.mif"
+"\epoc32\data\Z\trk\trk_bt.ini"							-"!:\trk.ini"
+
+
+; Required files
+; None
+
+; Component .sis files
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/trk_aif_svg_icons_dc.mk	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\RESOURCE\APPS
+ICONTARGETFILENAME=$(TARGETDIR)\trkapp_200170bb.mif
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 qgn_menu_trk.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/s60/trk_xti.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,3 @@
+[XTIIO_COMM]
+LDD TrkXtiDriver
+PlugPlay 1
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/trk_bt.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,4 @@
+[BTSOCKCOMM]
+PORT 1
+RATE 115200
+PlugPlay 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/trk_dcc.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,4 @@
+[DCCIO_COMM]
+LDD TrkDccDriver
+PORT 42
+PlugPlay 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/trk_usb.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,7 @@
+[SERIALCOMM]
+PDD EUART
+LDD EUSBC
+CSY ECACM
+PORT 0
+RATE 115200
+PlugPlay 1
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/tshell/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/tshell/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+trk_tshell.iby 		/epoc32/rom/include/trk.iby
+
+../trk.ini    		/epoc32/data/Z/trk/trk.ini
+../tv/trk_om.ini    	/epoc32/data/Z/trk/trk_om.ini
+../tv/trk_h4hrp.ini  	/epoc32/data/Z/trk/trk_h4hrp.ini
+../trk_dcc.ini    	/epoc32/data/Z/trk/trk_dcc.ini
+
+
+PRJ_MMPFILES
+
+#if !defined(WINS)
+../../dccdriver/trkdccdriver_tv
+../../eka2driver/trkkerneldriver_tv
+../../engine/trkengine_tshell
+../../app/console/trkconsole
+../../trkserver/trkserver_tv.mmp
+../../tcbserver/trktcbserver_tv
+../../trklauncher/trklauncher_tv
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/tshell/trk_tshell.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TRK_IBY__
+#define __TRK_IBY__
+
+// trk debugger stub
+
+//For disabling autostart of TRK, comment the line below
+//ECOM_PLUGIN(trklauncher.dll, trklauncher.rsc)
+
+file=ABI_DIR\BUILD_DIR\trkengine.dll	System\Libs\trkengine.dll
+file=ABI_DIR\BUILD_DIR\trkconsole.exe	System\Programs\TRKConsole.exe
+
+
+device[VARID]=ABI_DIR\BUILD_DIR\trkdriver.ldd System\Libs\trkdriver.ldd
+device[VARID]=ABI_DIR\BUILD_DIR\trkdccdriver.ldd System\Libs\trkdccdriver.ldd
+file=ABI_DIR\BUILD_DIR\trktcbserver.exe	 sys\bin\TrkTcbServer.exe
+file=ABI_DIR\BUILD_DIR\trkserver.exe	 sys\bin\trkserver.exe
+
+// For using DCC, please uncomment the line and comment the next line.
+//data=ZSYSTEM\..\trk\trk_dcc.ini     \trk.ini
+data=ZSYSTEM\..\trk\trk_##VARIANT##.ini     \trk.ini
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/tv/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/tv/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "../../dbgtrccomm/group/tv/bld.inf"
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+trk.iby				/epoc32/rom/include/trk.iby
+../trk.ini    		/epoc32/data/Z/trk/trk.ini
+../trk_bt.ini   	/epoc32/data/Z/trk/trk_bt.ini
+../trk_usb.ini  	/epoc32/data/Z/trk/trk_usb.ini
+../trk_dcc.ini  	/epoc32/data/Z/trk/trk_dcc.ini
+trk_om.ini   		/epoc32/data/Z/trk/trk_om.ini
+trk_h4hrp.ini   	/epoc32/data/Z/trk/trk_h4hrp.ini
+
+PRJ_MMPFILES
+#ifdef MARM
+../../dccdriver/trkdccdriver_tv
+../../eka2driver/trkkerneldriver_tv
+../../engine/trkengine_tv
+../../app/console/trkconsole
+../../app/tv/trkapp_tv
+../../tcbserver/trktcbserver_tv
+../../trklauncher/trklauncher_tv
+../../trkserver/trkserver_tv
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/tv/isv_build/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/tv/isv_build/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+isv_trk.iby	/epoc32/rom/include/trk.iby
+../../trk.ini    	/epoc32/data/Z/trk/trk.ini
+../trk_om.ini    	/epoc32/data/Z/trk/trk_om.ini
+../trk_h4hrp.ini    	/epoc32/data/Z/trk/trk_h4hrp.ini
+../../trk_bt.ini    /epoc32/data/Z/trk/trk_bt.ini
+../../trk_usb.ini    /epoc32/data/Z/trk/trk_usb.ini
+
+PRJ_MMPFILES
+#ifdef MARM
+../../../eka2driver/isv_trkkerneldriver_tv
+../../../engine/isv_trkengine_tv
+../../../app/tv/trkapp_tv
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/tv/isv_build/isv_trk.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __ISV_TRK_IBY__
+#define __ISV_TRK_IBY__
+
+// trk debugger stub
+
+file=ABI_DIR\BUILD_DIR\trkengine.dll	System\Libs\trkengine.dll
+file=ABI_DIR\BUILD_DIR\trkconsole.exe	System\Programs\trkconsole.exe
+
+file=ABI_DIR\BUILD_DIR\trkapp_200170bb.exe	sys\bin\trkapp_200170bb.exe
+
+device[VARID]=ABI_DIR\BUILD_DIR\trkdriver.ldd System\Libs\trkdriver.ldd
+
+data=ZSYSTEM\..\trk\trk_##VARIANT##.ini     \trk.ini
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb  resource\Apps\trkapp_200170bb)
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb_loc  resource\Apps\trkapp_200170bb_loc)
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\private\10003a3f\Apps\trkapp_200170bb_reg  private\10003a3f\Apps\trkapp_200170bb_reg)
+data=MULTI_LINGUIFY(MBM EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb  resource\Apps\trkapp_200170bb)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/tv/trk.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TRK_IBY__
+#define __TRK_IBY__
+
+// trk debugger stub
+#include <dbgtrccomm.iby>
+
+//For autostarting TRK at boot time, please include the ecom launcher plugin below.
+//ECOM_PLUGIN(trklauncher.dll, trklauncher.rsc)
+
+file=ABI_DIR\BUILD_DIR\trkengine.dll	sys\bin\trkengine.dll
+file=ABI_DIR\BUILD_DIR\trkconsole.exe	sys\bin\trkconsole.exe
+file=ABI_DIR\BUILD_DIR\trkapp_200170bb.exe	sys\bin\trkapp_200170bb.exe
+file=ABI_DIR\BUILD_DIR\trkserver.exe	    sys\bin\trkserver.exe
+device[VARID]=ABI_DIR\BUILD_DIR\trkdccdriver.ldd System\Libs\trkdccdriver.ldd
+device[VARID]=ABI_DIR\BUILD_DIR\trkdriver.ldd System\Libs\trkdriver.ldd
+
+file=ABI_DIR\BUILD_DIR\trktcbserver.exe	 sys\bin\TrkTcbServer.exe
+// For using DCC, please uncomment the line and comment the next line.
+//data=ZSYSTEM\..\trk\trk_dcc.ini     \trk.ini
+data=ZSYSTEM\..\trk\trk_##VARIANT##.ini     \trk.ini
+
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb  resource\Apps\trkapp_200170bb)
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb_loc  resource\Apps\trkapp_200170bb_loc)
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\private\10003a3f\Apps\trkapp_200170bb_reg  private\10003a3f\Apps\trkapp_200170bb_reg)
+data=MULTI_LINGUIFY(MBM EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb  resource\Apps\trkapp_200170bb)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/tv/trk_h4hrp.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,6 @@
+[SERIALCOMM]
+PDD EUART1
+LDD ECOMM
+CSY ECUART
+PORT 3
+RATE 115200
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/group/tv/trk_om.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,6 @@
+[SERIALCOMM]
+PDD EUART1
+LDD ECOMM
+CSY ECUART
+PORT 3
+RATE 115200
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/internal/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+1
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/internal/Readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,30 @@
+//
+// Trk
+//
+
+Trk provides target side application level debug support for Carbide C++
+It comes preconfigured for certain reference platforms already supported by Symbian.
+It also comes preconfigured for S60 and UIQ platforms. 
+
+In order to build for different platforms, please follow the steps below:
+
+1) Choose the appropriate UI platform folder, for ex: if you are working techview, then choose tv folder.
+If you are working with S60, then choose s60 folder.
+If you are working a text shell environment, then choose tshell folder.
+
+2) Choose the type of TRK build, there are two options. One is OEM build which builds System TRK
+and the other one is isv build for building Application TRK. 
+For ex: If you want to build System TRK for S60 3.2 platform, 
+then goto trk\group\s60 and run 
+	bldmake bldfiles
+	abld build
+For Application TRK build, goto trk\group\s60\isv_build and run the same build commands as above.
+
+3) You can either include TRK in rom or package TRK in a sis file.
+For including trk in the rom image, please include trk.iby file 
+into one of the iby files that are used to build the rom.
+For packaging trk in a sis file, please goto the sis folder and run the appropriate batch file.
+
+
+NOTE: Please note that group2 folder is in development and use this only
+if you are working with TRK that uses new debug API
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/rom/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/rom/trk.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#ifndef __TRK_IBY__
+#define __TRK_IBY__
+
+#include <dbgtrccomm.iby>
+
+// trk debugger stub
+
+//For disabling autostart of TRK, comment the line below
+//ECOM_PLUGIN(trklauncher.dll, trklauncher.rsc)
+
+file=ABI_DIR\BUILD_DIR\trkengine.dll	System\Libs\trkengine.dll
+file=ABI_DIR\BUILD_DIR\trkconsole.exe	System\Programs\TRKConsole.exe
+
+file=ABI_DIR\BUILD_DIR\trkserver.exe	    System\Programs\trkserver.exe
+file=ABI_DIR\BUILD_DIR\DebugNotifier.dll	System\Libs\DebugNotifier.dll
+#ifdef __UI_FRAMEWORKS_V2__
+file=ABI_DIR\BUILD_DIR\trkapp_200170bb.exe	sys\bin\trkapp_200170bb.exe
+#else
+file=ABI_DIR\BUILD_DIR\trkapp_200170bb.app	System\Apps\Trk\trkapp_200170bb.app
+#endif
+
+file=ABI_DIR\BUILD_DIR\trktcbserver.exe	 sys\bin\TrkTcbServer.exe
+
+
+#ifdef FF_PLATFORM_SIMULATOR
+data=ZSYSTEM\..\trk\trk_xti.ini    \trk.ini
+#else
+data=ZSYSTEM\..\trk\trk_bt.ini     \trk.ini
+#endif // FF_PLATFORM_SIMULATOR
+
+
+#ifdef __UI_FRAMEWORKS_V2__
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb  resource\Apps\trkapp_200170bb)
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb_loc  resource\Apps\trkapp_200170bb_loc)
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\private\10003a3f\Apps\trkapp_200170bb_reg  private\10003a3f\Apps\trkapp_200170bb_reg)
+data=MULTI_LINGUIFY(MIF EPOCROOT##epoc32\data\Z\resource\Apps\trkapp_200170bb  resource\Apps\trkapp_200170bb)
+#else
+data=MULTI_LINGUIFY(RSC ZSYSTEM\Apps\Trk\trkapp_200170bb  System\Apps\Trk\trkapp_200170bb)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/rom/trk_rom.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#ifndef __TRK_ROM_IBY__
+#define __TRK_ROM_IBY__
+
+
+device[VARID]=ABI_DIR\BUILD_DIR\trkdriver.ldd System\Libs\trkdriver.ldd
+device[VARID]=ABI_DIR\BUILD_DIR\trkdccdriver.ldd System\Libs\trkdccdriver.ldd
+
+// Comment out the ifdef below to include the trk xti driver
+// By default, this is not included since tracecore is not included in the S60 clean environments.
+#ifdef FF_PLATFORM_SIMULATOR
+device[VARID]=ABI_DIR\BUILD_DIR\trkxtidriver.ldd System\Libs\trkxtidriver.ldd
+#endif
+
+
+#endif //__TRK_ROM_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbclient/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbclient/TrkTcbCliSession.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,174 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "TrkTcbCliSession.h"
+#include "TrkTcbClientDefs.h"
+
+// System includes
+
+// User includes
+#include "TrkTcbCmdCodes.h"
+#include "TrkTcbClientUtils.h"
+// Type definitions
+
+// Constants
+const TInt KNumberOfServerStartupAttempts = 2;
+
+// Enumerations
+
+//
+// RTrkTcbCliSession (source)
+//
+
+//
+// RTrkTcbCliSession::RTrkTcbCliSession
+//
+// Constructor
+//
+RTrkTcbCliSession::RTrkTcbCliSession()
+{
+}
+
+//
+//RTrkTcbCliSession::Connect()
+//
+// Connects the client process to the TrkTcb server, starting the server 
+// if it is not already running.
+// return KErrNone if successful, otherwise one of the system-wide errors.
+//
+TInt RTrkTcbCliSession::Connect()
+{
+	TInt startupAttempts = KNumberOfServerStartupAttempts;
+	for(;;)
+	{
+		TInt ret = CreateSession(TrkTcbClientDefs::ServerAndThreadName(), TrkTcbClientDefs::Version(), KTrkTcbServerAsynchronousSlotCount);
+		if (ret != KErrNotFound && ret != KErrServerTerminated)
+		{
+			return ret;
+		}
+		
+		if	(startupAttempts-- == 0)
+		{
+			return ret;
+		}
+		
+		ret = TrkTcbClientUtils::StartTrkTcbServer();
+		if	(ret != KErrNone && ret != KErrAlreadyExists)
+		{
+			return ret;
+		}
+	}
+}
+
+//
+// RTrkTcbCliSession::Version()
+//
+// Provides the version number of the TrkTcb server.
+// @return The version number. 
+//
+TVersion RTrkTcbCliSession::Version() const
+{
+	return TrkTcbClientDefs::Version();
+}
+
+//
+// RTrkTcbCliSession::OpenFile()
+//
+// Opens the specified file in the specified mode.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+TInt RTrkTcbCliSession::OpenFile(const TDesC& aFilePath, TUint aMode, TTime& aModifiedTime)
+{
+	TPckg<TTime> package(aModifiedTime);
+	TInt length = aFilePath.Length();
+	TIpcArgs args(length, &aFilePath, aMode, &package);
+	
+	return SendReceive(ETrkTcbCmdCodeOpenFile, args);
+}
+
+//
+// RTrkTcbCliSession::ReadFile()
+//
+// Reads data from the already opened file.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+TInt RTrkTcbCliSession::ReadFile(TUint16 aLength, TDes8& aFileData)
+{
+	TIpcArgs args(aLength, &aFileData);
+
+	return SendReceive(ETrkTcbCmdCodeReadFile, args);
+}
+
+//
+// RTrkTcbCliSession::WriteFile()
+//
+// Writes data into the already opened file.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+TInt RTrkTcbCliSession::WriteFile(const TDesC8& aFileData)
+{
+	TIpcArgs args(aFileData.Length(), &aFileData);
+	
+	return SendReceive(ETrkTcbCmdCodeWriteFile, args);
+}
+
+//
+// RTrkTcbCliSession::CloseFile()
+//
+// Closes data into the already opened file.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+TInt RTrkTcbCliSession::CloseFile(const TTime& aTime)
+{
+	TPckg<TTime> package(aTime);
+	TIpcArgs args(&package);
+	
+	return SendReceive(ETrkTcbCmdCodeCloseFile, args);
+}
+
+//
+// RTrkTcbCliSession::PositionFile()
+//
+// Changes the current postion in the already opened file
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+TInt RTrkTcbCliSession::PositionFile(TSeek aSeek, TInt& aOffset)
+{
+	TPckg<TSeek>  package(aSeek);
+	TIpcArgs args(&package, aOffset);
+	
+	return SendReceive(ETrkTcbCmdCodePositionFile, args);
+}
+
+//
+// RTrkTcbCliSession::ShutDownServer()
+//
+// Closes the server.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+TInt RTrkTcbCliSession::ShutDownServer()
+{
+	TIpcArgs args;
+	return SendReceive(ETrkTcbCmdCodeShutDownServer, args);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbclient/TrkTcbCliSession.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkTcbCliSession_h__
+#define __TrkTcbCliSession_h__
+
+// System includes
+#include <e32base.h>
+#include <f32file.h>
+// User includes
+
+// Classes referenced
+
+//The client-side interface to the MetroTrk Tcb server. 
+class RTrkTcbCliSession : public RSessionBase
+{
+	// CONNECT TO SERVER & VERSIONING
+	public:										
+		 			RTrkTcbCliSession();
+		TInt		Connect();
+		TVersion	Version() const;
+
+	// TCB CMD SPECIFIC FUNCTIONALITY
+	public:										
+		TInt	OpenFile(const TDesC& aFilePath, TUint aMode, TTime& aModifiedTime);
+		TInt	ReadFile(TUint16 aLength, TDes8& aFileData);
+		TInt	WriteFile(const TDesC8& aFileData);
+		TInt	CloseFile(const TTime& aTime);
+		TInt	PositionFile(TSeek aSeek, TInt& aOffset);
+		TInt	ShutDownServer();
+
+};
+
+#endif //__TrkTcbCliSession_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbclient/TrkTcbClientDefs.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "TrkTcbClientDefs.h"
+#include "TrkTcbCmdCodes.h"
+
+// System includes
+
+// User includes
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// TrkTcbClientDefs (source)
+//
+
+//
+// TrkTcbClientDefs::ServerAndThreadName()
+//
+// Returns the TrkTcb server's unique name.
+// @return Unique name of the TrkTcb server.
+//
+const TDesC& TrkTcbClientDefs::ServerAndThreadName()
+{
+	return KTrkTcbServerName;
+}
+
+//
+// TrkTcbClientDefs::ServerImageName()
+//
+// Return the name of the server image (Exe/Dll)
+//
+const TDesC& TrkTcbClientDefs::ServerImageName()
+{
+	return KTrkTcbServerImageName;
+}
+
+//
+// TrkTcbClientDefs::ServerUidType()
+//
+// Return the Uid associated with the server image
+//
+TUidType TrkTcbClientDefs::ServerUidType()
+{
+	return TUidType(KNullUid, KNullUid, KTrkTcbServerUid);
+}
+
+
+//
+// TrkTcbClientDefs::Version()
+//
+// Return the version number of the server/client
+//
+TVersion TrkTcbClientDefs::Version()
+{
+	return TVersion(KTrkTcbServerMajorVN, KTrkTcbServerMinorVN, KTrkTcbServerBuildVN);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbclient/TrkTcbClientDefs.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkTcbClientDefs_h__
+#define __TrkTcbClientDefs_h__
+
+// System includes
+#include <e32base.h>
+// User includes
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// TrkTcbClientDefs (header)
+//
+
+//This is a utility class that retrieves the name and version number of the TrkTcbServer 
+class TrkTcbClientDefs
+{
+	// STATIC ACCESS METHODS
+	public:										
+		static const TDesC&	ServerAndThreadName();
+
+		static const TDesC&	ServerImageName();
+
+		static TUidType		ServerUidType();
+
+		static TVersion		Version();
+
+};
+
+#endif //__TrkTcbClientDefs_h__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbclient/TrkTcbClientUtils.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "TrkTcbClientUtils.h"
+
+// System includes
+#include <e32std.h>
+
+// User includes
+#include "TrkTcbClientDefs.h"
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// TrkTcbClientUtils (source)
+//
+
+//
+// TrkTcbClientUtils::Panic()
+//
+// Panic the client
+//
+void TrkTcbClientUtils::Panic(TTrkTcbClientPanic aPanic)
+{
+	_LIT(KTrkTcbClientPanic, "TRKTCBCLI");
+	User::Panic(KTrkTcbClientPanic, aPanic);
+}
+
+//
+// TrkTcbClientUtils::Fault()
+//
+// Panic the client, indicating some form of logic error or terminal
+// fault.
+//
+void TrkTcbClientUtils::Fault(TTrkTcbClientFault aFault)
+{
+	_LIT(KTrkTcbClientFault, "TRKTCBCLIFAULT");
+	User::Panic(KTrkTcbClientFault, aFault);
+}
+
+//
+// TrkTcbClientUtils::StartTrkTcbServer()
+//
+// Starts the TrkTcb server.
+// @return KErrNone if successful, 
+//		   KErrAlreadyExists if the server is already running, otherwise a system-wide error.
+TInt TrkTcbClientUtils::StartTrkTcbServer()
+{
+
+	TInt ret = KErrNone;
+
+	//
+	// Create a new server process. Simultaneous launching
+	// of two such processes should be detected when the second one attempts to
+	// create the server object, failing with KErrAlreadyExists.
+	//
+	RProcess server;
+	ret = server.Create(TrkTcbClientDefs::ServerImageName(), KNullDesC, TrkTcbClientDefs::ServerUidType());
+
+	// Did we manage to create the thread/process?
+	if	(ret != KErrNone)
+		return ret;
+
+	// Wait to see if the thread/process died during construction
+	TRequestStatus serverDiedRequestStatus;
+#if defined(EKA2)
+	server.Rendezvous(serverDiedRequestStatus);
+#else
+	server.Logon(serverDiedRequestStatus);
+#endif
+	
+	if	(serverDiedRequestStatus != KRequestPending)
+	{
+		// Abort startup
+		server.Kill(KErrNone);
+	}
+	else
+	{
+		// Logon OK - start the server
+		server.Resume();
+	}
+	
+	User::WaitForRequest(serverDiedRequestStatus);
+
+	// we can't use the 'exit reason' if the server panicked as this
+	// is the panic 'reason' and may be '0' which cannot be distinguished
+	// from KErrNone
+	
+	ret = (server.ExitType() == EExitPanic) ? KErrGeneral : serverDiedRequestStatus.Int();
+	
+	server.Close();
+
+	return ret;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbclient/TrkTcbClientUtils.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkTcbClientUtils_H__
+#define __TrkTcbClientUtils_H__
+
+// System includes
+#include <e32base.h>
+
+
+//
+//  TrkTcbClientUtils (header)
+//
+class TrkTcbClientUtils
+{
+public:										// ENUMERATIONS
+	/** Panic numbers associated with the TRKTCBCLI panic category. */
+	enum TTrkTcbClientPanic
+	{
+		ETrkTcbClientPanicArgument			= 0,
+		ETrkTcbClientPanicCancel			= 1,
+		ETrkTcbClientPanicLast
+	};
+	/** Panic numbers associated with the TRKTCBCLIFAULT panic category. */
+	enum TTrkTcbClientFault
+	{
+		ETrkTcbClientFaultLogic					= 0,
+		ETrkTcbClientFaultData					= 1,
+		ETrkTcbClientFaultCouldNotLoadServer	= 2,
+		ETrkTcbClientFaultDebugFuncError		= 3,
+		ETrkTcbClientFaultLast
+	};
+
+public:
+
+	static void	Panic(TTrkTcbClientPanic aPanic);
+
+	static void	Fault(TTrkTcbClientFault aFault);
+
+	static TInt	StartTrkTcbServer();
+};
+
+#endif //__TrkTcbClientUtils_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbCmdCodes.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkTcbCmdCodes_H__
+#define __TrkTcbCmdCodes_H__
+
+// System includes
+#include <e32std.h>
+
+// Constants
+const TInt KTrkTcbServerMajorVN = 1;
+const TInt KTrkTcbServerMinorVN = 0;
+const TInt KTrkTcbServerBuildVN = 0;
+
+// asynchronous cmd slot count
+const TInt KTrkTcbServerAsynchronousSlotCount	= 0;
+
+//
+const TUid KTrkTcbServerUid = { 0x200159DB };
+const TUid KTrkAppUid = { 0x200170BB };
+const TUid KTrkExeUid = { 0x200159E2 };
+const TUid KTrkSrvUid = { 0x200170B7 };
+
+// Literal constants
+
+#if defined(EKA2)
+_LIT(KTrkTcbServerName, "!TrkTcbServer");
+#else
+_LIT(KTrkTcbServerName, "TrkTcbServer");
+#endif
+
+_LIT(KTrkTcbServerImageName, "TrkTcbServer");
+
+_LIT(KServerIntiatedSessionPanic, "TRKTCBSERVER");
+
+#define KCapabilityCustomCheck 0
+
+// Enumerations
+//
+// The cmd-codes used to communicate between the TrkTcb client and TrkTcb server.
+//
+enum TTrkTcbCmdCode
+{
+	//Custom check
+	ETrkTcbCmdCodeFirst = KCapabilityCustomCheck,				
+	ETrkTcbCmdCodeOpenFile,					
+	ETrkTcbCmdCodeReadFile,						
+	ETrkTcbCmdCodeWriteFile,
+	ETrkTcbCmdCodeCloseFile,
+	ETrkTcbCmdCodePositionFile,
+	ETrkTcbCmdCodeShutDownServer,
+	ETrkTcbCmdCodeLast								
+};
+
+// Identifies server-initiated panics relating to the client session.
+enum TTrkTcbServerInitiatedClientPanic
+{
+	//This panic occurs when the client requests a copy of any data attached to any 
+	//read request, but does not supply enough buffer space to contain the data. 
+	ETrkTcbServerInitiatedClientPanicInsufficientRoomForFileData = 1,
+
+	//This panic usually occurs when a client method tries to write to a descriptor 
+	//(sometimes asynchronously), and the client-supplied descriptor is not valid.
+	ETrkTcbServerInitiatedClientPanicBadDescriptor = 2,
+
+
+	//This panic occurs when a client tries to perform an invalid operation.
+	ETrkTcbServerInitiatedClientPanicInvalidOperation = 3,
+};
+
+#endif //__TrkTcbCmdCodes_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbServer.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,202 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "TrkTcbServer.h"
+
+static CMetroTrkIO* TrkIO = NULL;
+
+#define SafeDelete(x) { if (x) delete x; x = NULL; }
+
+
+//
+//
+// CKeyboardInput implementation
+//
+//
+
+//
+// CKeyboardInput constructor
+//
+CKeyboardInput::CKeyboardInput(CConsoleBase* aConsole)
+	: CActive(EPriorityUserInput),
+	  iConsole(aConsole)
+{
+	CActiveScheduler::Add(this);
+}
+
+//
+// CKeyboardInput destructor
+//
+CKeyboardInput::~CKeyboardInput()
+{
+	Cancel();
+	Deque();
+}
+
+//
+// CKeyboardInput::ListenToKeyboard
+//
+// Wait for a key to be pressed
+//
+void CKeyboardInput::ListenToKeyboard()
+{
+	iConsole->Read(iStatus);
+	SetActive();
+}
+
+//
+// CKeyboardInput::RunL
+//
+// Called when a key is pressed
+//
+void CKeyboardInput::RunL()
+{
+	TKeyCode key = iConsole->KeyCode();
+	if (key == 'q' || key == 'Q')
+		CActiveScheduler::Stop();
+	else
+		ListenToKeyboard();
+}
+
+//
+// CKeyboardInput::DoCancel
+//
+// Stop waiting for keyboard input
+//
+void CKeyboardInput::DoCancel()
+{
+	iConsole->ReadCancel();
+}
+
+
+//
+//
+// CMetroTrkIO implementation
+//
+//
+
+//
+// CMetroTrkIO constructor
+//
+CMetroTrkIO::CMetroTrkIO()
+	: iConsole(0),
+	  iKeyboardInput(0)
+{
+	TRAPD(error, iConsole = Console::NewL(_L("MetroTrk"), TSize(KConsFullScreen, KConsFullScreen)));
+	if (error != KErrNone)
+		User::Panic(_L("TrkTcbServer failed to allocate CConsoleBase"), __LINE__);
+
+	iKeyboardInput = new CKeyboardInput(iConsole);
+	if (iKeyboardInput == 0)
+		User::Panic(_L("TrkTcbServer failed to allocate CKeyboardInput"), __LINE__);
+
+	iKeyboardInput->ListenToKeyboard();
+}
+
+//
+// CMetroTrkIO destructor
+//
+CMetroTrkIO::~CMetroTrkIO()
+{
+	SafeDelete(iKeyboardInput);
+	SafeDelete(iConsole);
+}
+
+//
+// CMetroTrkIO::PrintToScreen
+//
+//	Print a message to the screen
+//
+void CMetroTrkIO::PrintToScreen(TRefByValue<const TDesC> aFmt, ...)
+{
+	VA_LIST(l);
+	VA_START(l, aFmt);
+	iBuffer.FormatList(aFmt, l);
+
+	iConsole->Printf(iBuffer);
+}
+
+//
+// CMetroTrkIO::Terminating
+//
+//	Notify user of termination
+//
+void CMetroTrkIO::Terminating()
+{
+	iConsole->Printf(_L("\r\nPress any key to exit."));
+	iKeyboardInput->Cancel();
+	iConsole->Getch();
+}
+
+//
+// MainL
+//
+// Create the engine and the communications interface and start the active scheduler
+//
+void MainL()
+{
+	RProcess().SetPriority(EPriorityHigh);
+	RThread().SetPriority(EPriorityAbsoluteHigh);
+	
+	TInt sid = RProcess().SecureId();
+		
+	//TrkIO->PrintToScreen(_L("Welcome to TrkTcbServer for MetroTrk\r\n"));
+	//TrkIO->PrintToScreen(_L("Press 'Q' to quit.\r\n\r\n"));
+
+	CActiveScheduler::Start();
+}
+
+//
+// EXE entrypoint
+//
+TInt E32Main()
+{	
+	__UHEAP_MARK;
+
+	CTrapCleanup* cleanupStack = CTrapCleanup::New();
+	if (cleanupStack == 0)
+		User::Panic(_L("MetroTrk failed to allocate CTrapCleanup"), __LINE__);
+	
+	CActiveScheduler* scheduler = new CActiveScheduler;
+	if (scheduler == 0)
+		User::Panic(_L("MetroTrk failed to allocate CActiveScheduler"), __LINE__);
+
+	CActiveScheduler::Install(scheduler);
+
+//	TrkIO = new CMetroTrkIO;
+	
+//	if (!TrkIO)
+//		User::Panic(_L("TrkTcbServer failed to allocate CMetroTrkIO"), __LINE__);
+	
+	TRAPD(error, MainL());
+
+//	if (error != KErrNone)
+//	{
+//		TrkIO->PrintToScreen(_L("\r\nUnexpected error %d"), error);
+//		TrkIO->Terminating();
+//	}
+	
+//	SafeDelete(TrkIO);
+	SafeDelete(scheduler);
+	SafeDelete(cleanupStack);
+
+	__UHEAP_MARKEND;
+
+	User::Exit(0);
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbServer.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKTCBSERVER_H__
+#define __TRKTCBSERVER_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include <e32cons.h>
+#include <hal.h>
+
+
+//
+// class CKeyboardInput
+//
+// Handles input from the keyboard
+//
+class CKeyboardInput : public CActive
+{
+public:
+
+	CKeyboardInput(CConsoleBase* aConsole);
+	~CKeyboardInput();
+
+	void ListenToKeyboard();
+
+protected:
+
+	void RunL();
+	void DoCancel();
+
+private:
+
+	CConsoleBase* iConsole;
+};
+
+
+//
+// class CMetroTrkIO
+//
+// Handles input and output from/to the console
+//
+class CMetroTrkIO : public CBase
+{
+public:
+
+	CMetroTrkIO();
+	~CMetroTrkIO();
+
+	void PrintToScreen(TRefByValue<const TDesC> aFmt, ...);
+	void Terminating();
+
+private:
+
+	CConsoleBase* iConsole;
+	CKeyboardInput* iKeyboardInput;
+	TBuf<50> iBuffer;
+};
+
+#endif // __TRKTCBSERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbServer_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+
+TARGET			TrkTcbServer.exe
+#ifdef EKA2
+TARGETTYPE		EXE
+#else
+TARGETTYPE		epocexe
+#endif
+
+UID			0x1000008C  0x200159DB 
+
+VENDORID VID_DEFAULT
+CAPABILITY ALL
+
+SOURCEPATH		.
+SOURCE			TrkTcbSrvMain.cpp  TrkTcbSrvScheduler.cpp
+SOURCE			TrkTcbSrvServer.cpp TrkTcbSrvSession.cpp TrkTcbSrvSessionEngine.cpp
+
+LIBRARY			euser.lib efsrv.lib
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+   	SYSTEMINCLUDE	\epoc32\include
+	SYSTEMINCLUDE	\epoc32\include\oem        
+#else
+    MW_LAYER_SYSTEMINCLUDE
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbServer_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+TARGET			TrkTcbServer.exe
+#ifdef EKA2
+TARGETTYPE		EXE
+#else
+TARGETTYPE		epocexe
+#endif
+
+UID			0x1000008C  0x200159DB  
+
+VENDORID 0x101FB657
+CAPABILITY ALL
+
+SOURCEPATH		.
+SOURCE			TrkTcbSrvMain.cpp  TrkTcbSrvScheduler.cpp
+SOURCE			TrkTcbSrvServer.cpp TrkTcbSrvSession.cpp TrkTcbSrvSessionEngine.cpp
+
+LIBRARY			euser.lib efsrv.lib
+
+SYSTEMINCLUDE  		/epoc32/include
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbSrvMain.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <e32std.h>
+#include <e32debug.h>
+#include <f32file.h>
+// User includes
+#include "TrkTcbCmdCodes.h"
+#include "TrkTcbSrvScheduler.h"
+#include "TrkTcbSrvServer.h"
+
+
+void RunServerL();
+
+//
+// RunServerL()
+// Creates tcb server, signals the client and starts the server
+//
+
+void RunServerL()
+{
+	// Create and install the active scheduler we need
+	CTrkTcbSrvScheduler* scheduler = CTrkTcbSrvScheduler::NewLC();
+	if (scheduler == 0)
+		User::Leave(KErrNoMemory);
+		
+	CActiveScheduler::Install(scheduler);
+
+	// Create server
+	CTrkTcbSrvServer::NewLC();
+
+	// Initialisation complete, now signal the client
+#ifdef EKA2
+	User::LeaveIfError(User::RenameThread(KTrkTcbServerName));
+#else
+	User::LeaveIfError(RThread().RenameMe(KTrkTcbServerName));
+#endif
+	RProcess::Rendezvous(KErrNone);
+
+	// Ready to run
+	CActiveScheduler::Start();
+
+	// Cleanup the server and scheduler
+	CleanupStack::PopAndDestroy(2, scheduler);
+}
+
+
+
+//
+// Main Entry Point
+//
+
+TInt E32Main()
+{
+	__UHEAP_MARK;
+	
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if (cleanup == 0)
+		User::Panic(_L("Trk Tcb Server failed to allocate CTrapCleanup"), __LINE__);
+	
+	TInt error = KErrNone;
+	
+	if (cleanup)
+	{
+		TRAP(error, RunServerL());
+		delete cleanup;
+	}
+	
+	if (error != KErrNone)
+	{
+		User::Panic(_L("Trk Tcb Server failed to start"), __LINE__);
+	}
+	
+	__UHEAP_MARKEND;
+
+	return error;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbSrvScheduler.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <e32base.h>
+
+// User includes
+#include "TrkTcbSrvScheduler.h"
+
+
+//
+// CTrkTcbSrvScheduler (source)
+//
+
+//
+// CTrkTcbSrvScheduler::CTrkTcbSrvScheduler()
+//
+// Constructor
+//
+CTrkTcbSrvScheduler::CTrkTcbSrvScheduler()
+{
+}
+
+
+//
+// CTrkTcbSrvScheduler::NewLC()
+//
+// Creates an instance of CTrkTcbSrvScheduler
+//
+CTrkTcbSrvScheduler* CTrkTcbSrvScheduler::NewLC()
+{
+	CTrkTcbSrvScheduler* self = new(ELeave) CTrkTcbSrvScheduler();
+	CleanupStack::PushL(self);
+	return self;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbSrvScheduler.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkTcbSrvActiveScheduler_H__
+#define __TrkTcbSrvActiveScheduler_H__
+
+// System includes
+#include <e32base.h>
+
+// User includes
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+// Classes referenced
+
+
+//
+// CTrkTcbSrvScheduler (header)
+//
+//
+// The Active Scheduler for the Trk TCB Server thread
+//
+class CTrkTcbSrvScheduler : public CActiveScheduler
+{
+	public:										
+		static CTrkTcbSrvScheduler* NewLC();
+
+	private:
+		CTrkTcbSrvScheduler();
+};
+
+#endif //__TrkTcbSrvActiveScheduler_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbSrvServer.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,202 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "TrkTcbSrvServer.h"
+
+// System includes
+#include <e32base.h>
+#include <e32debug.h>
+
+// User includes
+#include "TrkTcbSrvSession.h"
+//#include "TrkTcbSrvStaticUtils.h"
+
+
+// Type definitions
+
+// Constants
+#define TRK_SID 0x200170BB
+// Enumerations
+
+// Classes referenced
+
+#ifdef EKA2
+//Only include these in the secured platform 
+#include "TrkTcbCmdCodes.h"
+
+const TUint KRangeCount = 2; 
+
+const TInt KOpCodeRanges[KRangeCount] = 
+{	
+	KCapabilityCustomCheck, 
+	ETrkTcbCmdCodeLast,
+};
+
+
+const TUint8 KElementsIndex[KRangeCount] =
+{
+	CPolicyServer::ECustomCheck, 	//Custom check for the Trk SID 	 0 - ETrkTcbCmdCodeLast
+	CPolicyServer::ENotSupported, 	//Not Supported					 		 ETrkTcbCmdCodeLast-End
+};
+
+const CPolicyServer::TPolicy KTrkTcbServerPolicy =
+{
+	CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
+	KRangeCount,
+	KOpCodeRanges,
+	KElementsIndex, 	// what each range is compared to 
+	NULL, //KPolicyElements 	// what policies range is compared to
+};
+ 	
+#endif
+
+
+//
+// CTrkTcbSrvServer (source)
+//
+
+//
+// CTrkTcbSrvServer::CTrkTcbSrvServer()
+//
+// Constructor
+//
+CTrkTcbSrvServer::CTrkTcbSrvServer()
+#ifdef  EKA2
+ 	:CPolicyServer(CActive::EPriorityHigh, KTrkTcbServerPolicy)
+#else	
+   	:CServer2(CActive::EPriorityHigh) 
+#endif
+{
+}
+
+//
+// CTrkTcbSrvServer::~CTrkTcbSrvServer()
+//
+// Destructor
+//
+CTrkTcbSrvServer::~CTrkTcbSrvServer()
+{
+	// In order to prevent access violations as the server
+	// shuts down, we inform all sessions that the server is
+	// about to be destroyed
+	iSessionIter.SetToFirst();
+	//
+	CTrkTcbSrvSession* session = static_cast<CTrkTcbSrvSession*>(iSessionIter++);
+	while (session)
+	{
+		session->HandleServerDestruction();
+		session = static_cast<CTrkTcbSrvSession*>(iSessionIter++);
+	}
+	
+}
+
+//
+// CTrkTcbSrvServer::ConstructL()
+//
+// Second level construction
+//
+void CTrkTcbSrvServer::ConstructL()
+{
+	// Calling StartL here won't actually allow any connections
+	// to be created until the active scheduler has a chance to run. However, the 
+	// call below will leave should there already be a started TrkTcb server instance.
+	//
+	StartL(KTrkTcbServerName);
+}
+
+//
+// CTrkTcbSrvServer::NewLC()
+//
+// Creates an instance of CTrkTcbSrvServer.
+//
+CTrkTcbSrvServer* CTrkTcbSrvServer::NewLC()
+{
+	CTrkTcbSrvServer* self = new(ELeave) CTrkTcbSrvServer();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+}
+
+//
+// CTrkTcbSrvServer::NewSessionL()
+//
+// Creates a new session.
+// Called by the IPC framework everytime a client creates a new session.
+// Returns a CTrkTcbSrvSession object.
+//
+CSession2* CTrkTcbSrvServer::NewSessionL(const TVersion& aVersion,const RMessage2& /*aMessage*/) const
+{	
+	// Check client version is correct
+	const TVersion trkTcbServerVersion(KTrkTcbServerMajorVN, KTrkTcbServerMinorVN, KTrkTcbServerBuildVN);
+	if	(!User::QueryVersionSupported(trkTcbServerVersion, aVersion))
+		User::Leave(KErrNotSupported);
+	
+	// Create new session
+	CTrkTcbSrvSession* session = CTrkTcbSrvSession::NewL();
+	return session;
+}
+
+//
+// CTrkTcbSrvServer::RunError()
+//
+// Handles all the errors when handling a client request.
+// Called by the IPC framework whenever a leave occurs when handling a client request.
+// Returns KErrNone to complete the error handling.
+//
+TInt CTrkTcbSrvServer::RunError(TInt aError)
+{
+	// A bad descriptor error implies a badly programmed client, so panic it;
+	// otherwise report the error to the client
+	if	(aError == KErrBadDescriptor)
+	{
+		Message().Panic(KServerIntiatedSessionPanic, ETrkTcbServerInitiatedClientPanicBadDescriptor);
+	}
+	else
+	{
+		Message().Complete(aError);
+	}
+
+	// The leave will result in an early return from CServer2::RunL(), skipping
+	// the call to request another message. So do that now in order to keep the
+	// server running.
+	ReStart();
+
+	// Indicate that we've handled the error fully
+	return KErrNone;
+}
+	
+#ifdef EKA2	
+//
+// CTrkTcbSrvServer::CustomSecurityCheckL()
+//
+// The only security check that is done is to check for the cleint securid 
+// Returns EFail or EPass
+//
+CPolicyServer::TCustomResult CTrkTcbSrvServer::CustomSecurityCheckL(const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/)
+{
+	CPolicyServer::TCustomResult returnValue = CPolicyServer::EFail;	
+	
+	TSecureId ClientSID = aMsg.SecureId();
+	// We only permit Trk to use this server. So we check
+	// for Trk's SIDs. If its not Trk's SIDs, then the security check fails.
+	if ((KTrkSrvUid == ClientSID) || (KTrkAppUid == ClientSID) || (KTrkExeUid == ClientSID))
+	{
+		returnValue = CPolicyServer::EPass;
+	}			
+	return(returnValue);
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbSrvServer.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkTcbSrvServer_H__
+#define __TrkTcbSrvServer_H__
+
+// System includes
+#include <e32base.h>
+
+// User includes
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// CTrkTcbSrvServer (header)
+//
+//
+// The TrkTcb Server
+//
+#ifdef EKA2
+class CTrkTcbSrvServer : public CPolicyServer
+#else
+class CTrkTcbSrvServer : public CServer2
+#endif
+{
+	public:
+		static CTrkTcbSrvServer* NewLC();
+		~CTrkTcbSrvServer();
+
+	private:
+		CTrkTcbSrvServer();
+		void ConstructL();
+
+	public:
+		CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
+
+	private:
+		TInt RunError(TInt aError);
+
+	private:
+	#ifdef EKA2	
+		TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing);
+	#endif
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbSrvSession.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,288 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "TrkTcbSrvSession.h"
+
+// System includes
+
+//User Includes
+#include "TrkTcbCmdCodes.h"
+#include "TrkTcbSrvSessionEngine.h"
+// Type definitions
+
+// Constants
+const TInt KTrkTcbServerTransferBufferExpandSize = 100;
+const TInt KSlot0 = 0;
+const TInt KSlot1 = 1;
+//const TInt KSlot2 = 2;
+const TInt KSlot3 = 3;
+
+// Enumerations
+
+// Classes referenced
+
+
+//
+// CTrkTcbSrvSession (source)
+//
+
+//
+// CTrkTcbSrvServer::CTrkTcbSrvSession()
+//
+// Constructor
+//
+CTrkTcbSrvSession::CTrkTcbSrvSession()
+{
+}
+
+//
+// CTrkTcbSrvServer::~CTrkTcbSrvSession()
+//
+// Destructor
+//
+CTrkTcbSrvSession::~CTrkTcbSrvSession()
+{
+	HandleServerDestruction();
+	delete iTransferBuffer;
+}
+
+//
+// CTrkTcbSrvServer::ConstructL()
+//
+// Creates an instance of CTrkTcbSrvSession.
+//
+void CTrkTcbSrvSession::ConstructL()
+{
+	iTransferBuffer = CBufFlat::NewL(KTrkTcbServerTransferBufferExpandSize);
+	iSessionEngine = CTrkTcbSrvSessionEngine::NewL();
+}
+
+//
+// CTrkTcbSrvServer::NewL()
+//
+// Static self construction
+//
+CTrkTcbSrvSession* CTrkTcbSrvSession::NewL()
+{
+	CTrkTcbSrvSession* self = new(ELeave) CTrkTcbSrvSession();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+}
+
+//
+// CTrkTcbSrvServer::HandleServerDestruction()
+//
+// Called by the server's destructor. We need to be told that the server is
+// being destroyed.
+//
+void CTrkTcbSrvSession::HandleServerDestruction()
+{
+	delete iSessionEngine;
+	iSessionEngine = NULL;
+}
+
+//
+// CTrkTcbSrvServer::ServiceL()
+//
+// Services requests from a client.
+// Called by the IPC framework whenever a client sends a request to the server.
+//
+void CTrkTcbSrvSession::ServiceL(const RMessage2& aMessage)
+{
+	// Leave's are caught by CASSrvServer::RunError
+	iMessage = &aMessage;
+	
+	const TBool completeMessage = DoServiceL();
+	
+	//Right now there are no asynchronous message completion.
+	//So if the message is not completed, then there is an error and needs to be reported
+	//to the client.
+	if	(completeMessage)
+		aMessage.Complete(KErrNone);
+	else
+		aMessage.Complete(KErrGeneral);
+		
+	iMessage=NULL;
+}
+
+//
+// CTrkTcbSrvServer::ServiceL()
+//
+// Services the requests.
+//
+TBool CTrkTcbSrvSession::DoServiceL()
+{
+	TBool completeMessage = EFalse;
+	const TInt cmd = Message().Function();
+	//
+	switch(cmd)
+	{
+		case ETrkTcbCmdCodeOpenFile:
+			completeMessage = CmdOpenFileL();
+			break;
+		case ETrkTcbCmdCodeReadFile:
+			completeMessage = CmdReadFileL();
+			break;
+		case ETrkTcbCmdCodeWriteFile:
+			completeMessage = CmdWriteFileL();
+			break;
+		case ETrkTcbCmdCodeCloseFile:
+			completeMessage = CmdCloseFileL();
+			break;
+		case ETrkTcbCmdCodePositionFile:
+			completeMessage = CmdPositionFileL();
+			break;
+		case ETrkTcbCmdCodeShutDownServer:
+			completeMessage = CmdShutDownServer();			
+			break;
+	
+		default:
+			Message().Panic(KServerIntiatedSessionPanic, ETrkTcbServerInitiatedClientPanicInvalidOperation);
+			break;
+	}
+		
+	return completeMessage;
+}
+
+//
+// CTrkTcbSrvServer::CmdOpenFileL()
+//
+// Gets the data for open file request and calls the session engine open file method.
+//
+TBool CTrkTcbSrvSession::CmdOpenFileL()
+{
+	const TInt fileNameLength = static_cast<TInt>(Message().Int0());
+
+	if (fileNameLength > 0)
+	{
+		HBufC* filePath = HBufC::NewLC(fileNameLength);
+		TPtr pFilePath(filePath->Des());
+		Message().ReadL(KSlot1, pFilePath);
+	
+		const TUint mode = static_cast<TUint>(Message().Int2());
+		
+		TTime modifiedTime;
+		iSessionEngine->OpenFileL(filePath->Des(), mode, modifiedTime);
+		
+		TPckgC<TTime> package(modifiedTime);
+		Message().WriteL(KSlot3, package);
+
+		CleanupStack::PopAndDestroy(filePath);
+		
+		return ETrue;
+	}
+	return EFalse;
+}
+
+//
+// CTrkTcbSrvServer::CmdReadFileL()
+//
+// Gets the data for read file request and calls the session engine read file method.
+//
+TBool CTrkTcbSrvSession::CmdReadFileL()
+{
+	const TInt dataLength = static_cast<TInt>(Message().Int0());
+	
+	if (dataLength > 0)
+	{
+		HBufC8* fileData = HBufC8::NewLC(dataLength);
+		TPtr8 ptr(fileData->Des());
+		
+		iSessionEngine->ReadFileL(ptr);
+		
+		//write the file data into the client descriptor
+		Message().WriteL(KSlot1, ptr);
+	
+		CleanupStack::PopAndDestroy(fileData);
+	}
+
+	return ETrue;
+}
+
+//
+// CTrkTcbSrvServer::CmdWriteFileL()
+//
+// Gets the data for write file request and calls the session engine write file method.
+//
+TBool CTrkTcbSrvSession::CmdWriteFileL()
+{
+	const TInt fileDataLength = static_cast<TInt>(Message().Int0());
+	
+	if (fileDataLength > 0)
+	{
+		HBufC8* fileData = HBufC8::NewLC(fileDataLength);
+		TPtr8 pFileData(fileData->Des());
+		Message().ReadL(KSlot1, pFileData);
+		
+		iSessionEngine->WriteFileL(*fileData);
+
+		CleanupStack::PopAndDestroy(fileData);
+		
+		return ETrue;
+	}
+	return EFalse;
+}
+
+//
+// CTrkTcbSrvServer::CmdCloseFileL()
+//
+// Gets the data for close file request and calls the session engine close file method.
+//
+TBool CTrkTcbSrvSession::CmdCloseFileL()
+{
+	TTime modificationTime;
+	
+	TPckg<TTime> package(modificationTime);
+	Message().ReadL(KSlot0, package);
+	
+	iSessionEngine->CloseFileL(modificationTime);
+	
+	return ETrue;
+}
+
+//
+// CTrkTcbSrvServer::CmdPositionFileL()
+//
+// Gets the data for position file request and calls the session engine position file method.
+//
+TBool CTrkTcbSrvSession::CmdPositionFileL()
+{
+	TSeek seek;
+	
+	TPckg<TSeek> seekPckg(seek);
+	Message().ReadL(KSlot0, seekPckg);
+	
+	TInt offset = static_cast<TInt>(Message().Int1());;
+
+	iSessionEngine->PositionFileL(seek, offset);
+
+	return ETrue;
+}
+
+//
+// CTrkTcbSrvServer::CmdShutDownServer()
+//
+// Stops the active scheduler. This way, server process will run to completion.
+//
+TBool CTrkTcbSrvSession::CmdShutDownServer()
+{
+	CActiveScheduler::Stop();
+	
+	return ETrue;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbSrvSession.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkTcbSrvSession_h__
+#define __TrkTcbSrvSession_h__
+
+// System includes
+#include <e32base.h>
+
+// User includes
+// Constants
+
+// Classes referenced
+class CTrkTcbSrvSessionEngine;
+// Enumerations
+
+
+//
+// CTrkTcbSrvSession (header)
+//
+/**
+ * This class acts as a simple wrapper around the IPC client-server framework,
+ * and drives a real underlying engine, which is actually responsible for
+ * fulfulling all the client requests.
+ */
+ 
+class CTrkTcbSrvSession : public CSession2
+{
+	public:
+		static 	CTrkTcbSrvSession* NewL();
+				~CTrkTcbSrvSession();
+
+	private:
+				CTrkTcbSrvSession();
+		void 	ConstructL();
+
+	public:
+		void 	HandleServerDestruction();
+
+	private:
+
+
+
+	private:
+	//FROM CSession2
+		void 	ServiceL(const RMessage2& aMessage);
+
+	private:
+		TBool 	DoServiceL();
+		
+		inline const RMessage2&	Message() const { return *iMessage; }
+
+	private:
+	// CMD - TRKTCBSERVER SPECIFIC FUNCTIONALITY
+		TBool	CmdOpenFileL();
+		TBool	CmdReadFileL();
+		TBool	CmdWriteFileL();
+		TBool	CmdCloseFileL();
+		TBool	CmdPositionFileL();
+		TBool 	CmdShutDownServer();
+
+
+private:
+	/*
+	 * Used to transfer collections of objects between server and client.
+	 */
+	CBufBase*					iTransferBuffer;
+
+	CTrkTcbSrvSessionEngine*	iSessionEngine;
+
+	const RMessage2*			iMessage;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbSrvSessionEngine.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,168 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "TrkTcbSrvSessionEngine.h"
+
+// System includes
+#include <e32debug.h>
+
+// User includes
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+// Classes referenced
+
+
+//
+// CTrkTcbSrvSessionEngine (source)
+//
+
+//
+// CTrkTcbSrvScheduler::CTrkTcbSrvSessionEngine()
+//
+// Constructor
+//
+CTrkTcbSrvSessionEngine::CTrkTcbSrvSessionEngine() : iFileState(EFileUnknown)
+{
+}
+
+//
+// CTrkTcbSrvScheduler::~CTrkTcbSrvSessionEngine()
+//
+// Destructor
+//
+CTrkTcbSrvSessionEngine::~CTrkTcbSrvSessionEngine()
+{
+}
+
+//
+// CTrkTcbSrvScheduler::ConstructL()
+//
+// Second level constructor
+//
+void CTrkTcbSrvSessionEngine::ConstructL()
+{
+	//nothing right now
+}
+
+//
+// CTrkTcbSrvScheduler::NewL()
+//
+// Creates an instance of CTrkTcbSrvSessionEngine
+//
+CTrkTcbSrvSessionEngine* CTrkTcbSrvSessionEngine::NewL()
+{
+	CTrkTcbSrvSessionEngine* self = new(ELeave) CTrkTcbSrvSessionEngine();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+}
+
+//
+// CTrkTcbSrvScheduler::OpenFileL()
+//
+// Opens the specified file
+//
+void CTrkTcbSrvSessionEngine::OpenFileL(const TDesC& aFilePath, TUint aMode, TTime& aModifiedTime)
+{	
+	//just for testing
+	TBuf8<KMaxPath> fileName;
+	fileName.Copy(aFilePath);
+
+	iMode = aMode; //copy  the mode, for properly closing the file.
+	
+	User::LeaveIfError(iFs.Connect());
+
+	TInt error = iFs.MkDirAll(aFilePath);
+
+	if ((KErrNone != error) && (KErrAlreadyExists != error))
+	{
+		iFs.Close();
+		User::Leave(error);
+	}
+	
+	error = iFile.Open(iFs, aFilePath, aMode);
+	if (KErrNone != error)
+		User::LeaveIfError(iFile.Replace(iFs, aFilePath, aMode));
+
+	// get the modification date
+	User::LeaveIfError(iFile.Modified(aModifiedTime));
+	iFileState = EFileOpened;
+}
+
+//
+// CTrkTcbSrvScheduler::ReadFileL()
+//
+// Reads from the already opened file
+//
+void CTrkTcbSrvSessionEngine::ReadFileL(TDes8& aFileData)
+{
+	iFileState = EFileReading;
+	User::LeaveIfError(iFile.Read(aFileData));
+}
+
+//
+// CTrkTcbSrvScheduler::WriteFileL()
+//
+// Writes to an already opened file
+//
+void CTrkTcbSrvSessionEngine::WriteFileL(const TDesC8& aFileData)
+{
+	if (iFileState == EFileOpened)
+	{
+		iFile.SetSize(0);
+		iFileState = EFileWriting;
+	}
+	User::LeaveIfError(iFile.Write(aFileData));	
+	User::LeaveIfError(iFile.Flush());
+}
+
+//
+// CTrkTcbSrvScheduler::CloseFileL()
+//
+// Closes an already opened file
+//
+void CTrkTcbSrvSessionEngine::CloseFileL(const TTime& aModifiedTime)
+{
+	//set the modification time only if the file is opened in write mode
+	if (iMode & EFileWrite)
+	{
+		User::LeaveIfError(iFile.SetModified(aModifiedTime));
+		User::LeaveIfError(iFile.Flush());
+	}
+	
+	iFile.Close();
+	iFs.Close();
+	iFileState = EFileClosed;
+}
+
+//
+// CTrkTcbSrvScheduler::PositionFileL()
+//
+// Changes the positions in an already opened file
+//
+void CTrkTcbSrvSessionEngine::PositionFileL(TSeek aSeek, TInt& aOffset)
+{
+	User::LeaveIfError(iFile.Seek(aSeek, aOffset));
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/TrkTcbSrvSessionEngine.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkTcbSrvSessionEngine_h__
+#define __TrkTcbSrvSessionEngine_h__
+
+// System includes
+#include <e32base.h>
+#include <f32file.h>
+
+// User includes
+#include "TrkTcbCmdCodes.h"
+
+// Classes referenced
+
+
+//
+// CTrkTcbSrvSessionEngine (header)
+//
+//
+// The underlying engine used by each session. Manipulates the server-side objects.
+//
+class CTrkTcbSrvSessionEngine : public CBase
+{
+	//Static construct and destruct
+	public:
+		static 	CTrkTcbSrvSessionEngine*	NewL();
+				~CTrkTcbSrvSessionEngine();
+	
+	//private construct
+	private:
+				CTrkTcbSrvSessionEngine();
+		void	ConstructL();
+
+	//methods implementing the server cmds functionality
+	public:	
+		void	OpenFileL(const TDesC& aFilePath, TUint aMode, TTime& aModifiedTime);
+		void	ReadFileL(TDes8& aFileData);
+		void	WriteFileL(const TDesC8& aFileData);
+		void	CloseFileL(const TTime& aModifiedTime);
+		void    PositionFileL(TSeek aSeek, TInt& aOffset);
+
+	//date members
+	private:
+		enum TFileState
+		{
+			EFileOpened = 0,
+			EFileReading = 1,
+			EFileWriting = 2,
+			EFileClosed = 3,
+			EFileUnknown = -1		
+		};
+		RFile iFile;
+		RFs iFs;
+		TFileState iFileState;
+		TUint iMode;
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/tcbserver/trktcbserver_uiq.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+TARGET			TrkTcbServer.exe
+#ifdef EKA2
+TARGETTYPE		EXE
+#else
+TARGETTYPE		epocexe
+#endif
+
+UID			0x1000008C  0x200159DB 
+
+VENDORID 0x101FB657
+CAPABILITY ALL
+
+SOURCEPATH		.
+SOURCE			TrkTcbSrvMain.cpp  TrkTcbSrvScheduler.cpp
+SOURCE			TrkTcbSrvServer.cpp TrkTcbSrvSession.cpp TrkTcbSrvSessionEngine.cpp
+
+LIBRARY			euser.lib efsrv.lib
+
+SYSTEMINCLUDE  		\epoc32\include
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "./toolsstarterclient/group/bld.inf"
+#include "./toolsstarterserver/group/bld.inf"
+
+PRJ_EXPORTS
+./rom/toolsstarter.iby     CORE_IBY_EXPORT_PATH(tools, toolsstarter.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/common/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/common/ToolsCmdCodes.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __toolscmdcodes_H__
+#define __toolscmdcodes_H__
+
+// System includes
+#include <e32std.h>
+
+// Constants
+const TInt KToolsServerMajorVN = 1;
+const TInt KToolsServerMinorVN = 0;
+const TInt KToolsServerBuildVN = 0;
+
+// asynchronous cmd slot count
+const TInt KToolsServerAsynchronousSlotCount	= 16;
+
+// Uids for platform security
+
+const TUid KToolsClientUid = { 0x200170B4 };
+const TUid KToolsServerUid = { 0x200170B5 };
+const TUid KTraceServerUid = { 0x200170B6 };
+const TUid KTrkServerUid   = { 0x200170B7 };
+
+const TUid KMetroTrkAppUid = { 0x200170BB };
+const TUid KMetroTrkExeUid = { 0x200159E2 };
+
+
+
+// Literal constants
+
+
+
+#if defined(EKA2)
+_LIT(KToolsServerName, "!toolsstarterserver");
+#else
+_LIT(KToolsServerName, "toolsstarterserver");
+#endif
+
+_LIT(KToolsServerImageName, "toolsstarterserver");
+
+_LIT(KServerIntiatedSessionPanic, "toolsstarterserver");
+
+#define KCapabilityCustomCheck 0
+
+
+// Enumerations
+//
+// The cmd-codes used to communicate between the Tools client and Tools server.
+//
+enum TToolsCmdCode
+{
+	//Custom check
+	EToolsCmdCodeFirst = KCapabilityCustomCheck,				
+	EToolsCmdCodeGetUsbConnStatus,
+	EToolsCmdCodeConnNotify,
+	EToolCmdCodeConnNotifyCancel,
+	EToolsCmdCodeShutDownServer,
+	EToolsCmdCodeLast								
+};
+
+// Identifies server-initiated panics relating to the client session.
+enum TToolsServerInitiatedClientPanic
+{
+	//This panic occurs when the client requests a copy of any data attached to any 
+	//read request, but does not supply enough buffer space to contain the data. 
+	EToolsServerInitiatedClientPanicInsufficientRoomForFileData = 1,
+
+	//This panic usually occurs when a client method tries to write to a descriptor 
+	//(sometimes asynchronously), and the client-supplied descriptor is not valid.
+	EToolsServerInitiatedClientPanicBadDescriptor = 2,
+
+
+	//This panic occurs when a client tries to perform an invalid operation.
+	EToolsServerInitiatedClientPanicInvalidOperation = 3,
+};
+
+#endif //__toolscmdCodes_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/rom/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/rom/toolsstarter.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#ifndef __TOOLSSTARTER_IBY__
+#define __TOOLSSTARTER_IBY__
+
+file=ABI_DIR\BUILD_DIR\toolsstarterclient.dll	System\Libs\toolsstarterclient.dll
+file=ABI_DIR\BUILD_DIR\toolsstarterserver.exe	System\Programs\toolsstarterserver.exe
+ECOM_PLUGIN(toolsstarterautolaunch.dll, toolsstarterautolaunch.rsc)
+//data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\resource\Apps\0x200170B5.rsc  private\101f875a\import\[0x200170B5].rsc)
+
+#endif //__TOOLSSTARTER_IBY__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/eabi/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/eabi/toolsstarterclient.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,10 @@
+EXPORTS
+	_ZN19RToolsClientSession13GetConnStatusER17TConnectionStatus @ 1 NONAME
+	_ZN19RToolsClientSession13UsbConnNotifyER5TDes8R14TRequestStatus @ 2 NONAME
+	_ZN19RToolsClientSession14ShutDownServerEv @ 3 NONAME
+	_ZN19RToolsClientSession19UsbConnNotifyCancelEv @ 4 NONAME
+	_ZN19RToolsClientSession7ConnectEv @ 5 NONAME
+	_ZN19RToolsClientSessionC1Ev @ 6 NONAME
+	_ZN19RToolsClientSessionC2Ev @ 7 NONAME
+	_ZNK19RToolsClientSession7VersionEv @ 8 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/group/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../inc/toolsclientsession.h
+
+PRJ_MMPFILES
+#ifdef MARM
+toolsstarterclient.mmp
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/group/toolsstarterclient.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET		  toolsstarterclient.dll
+TARGETTYPE	  dll
+UID 0x1000008d 0x200170B4
+
+capability All -Tcb
+
+USERINCLUDE	 ../inc
+USERINCLUDE   ../../common
+USERINCLUDE ../../toolsstarterserver/inc
+//SYSTEMINCLUDE   \epoc32\include
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH	  ../src
+
+SOURCE		  toolsclientdefs.cpp toolsclientdllmain.cpp toolsclientutils.cpp toolsclientsession.cpp
+
+// In order to use .def files to freeze code you must use one or more DEFFILE lines;
+// see the ones commented out below for examples.
+// By default, the build tools look for the WINSCW def file in a BWINS directory
+// (at the same level as the directory containing the mmp file), 
+// the GCC ARM def file in a BMARM directory, and the ARMV5 def file in a EABI directory. 
+// If your .def files are stored in these default locations, you can simply specify the
+// .def filename(s) with no path. If you want to store .def files in non-default 
+// locations, you will need to specify the paths in the DEFFILE statement(s).
+
+//The following commented out code shows how the build system uses the implicit
+// location for defiles. To create the DEF files Choose Project > Freeze Exports from Carbide
+// or run 'abld freeze' from the command-line
+//#ifdef MARM
+DEFFILE ../eabi/toolsstarterclient.def
+//#endif
+
+nostrictdef
+
+LIBRARY		 euser.lib
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/toolsclient.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// This file defines the API for ToolsClient.dll
+
+#ifndef __ToolsCLIENT_H__
+#define __ToolsCLIENT_H__
+
+//  Include Files
+
+#include <e32base.h>	// CBase
+#include <e32std.h>	 // TBuf
+
+//  Constants
+
+const TInt KToolsClientBufferLength = 15;
+typedef TBuf<KToolsClientBufferLength> TToolsClientExampleString;
+
+//  Class Definitions
+
+class CToolsClient : public CBase
+    {
+public:
+    // new functions
+    IMPORT_C static CToolsClient* NewL();
+    IMPORT_C static CToolsClient* NewLC();
+    IMPORT_C ~CToolsClient();
+
+public:
+    // new functions, example API
+    IMPORT_C TVersion Version() const;
+    IMPORT_C void ExampleFuncAddCharL(const TChar& aChar);
+    IMPORT_C void ExampleFuncRemoveLast();
+    IMPORT_C const TPtrC ExampleFuncString() const;
+
+private:
+    // new functions
+    CToolsClient();
+    void ConstructL();
+
+private:
+    // data
+    TToolsClientExampleString* iString;
+    };
+
+#endif  // __ToolsCLIENT_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/toolsclient.pan	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __Toolsclient_pan__
+#define __Toolsclient_pan__
+
+//  Data Types
+
+enum TToolsClientPanic
+    {
+    EToolsClientNullPointer
+    };
+
+//  Function Prototypes
+
+GLREF_C void Panic(TToolsClientPanic aPanic);
+
+#endif  // __toolsclient_pan__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/toolsclientdefs.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __toolsclientdefs_h__
+#define __toolsclientdefs_h__
+
+// System includes
+#include <e32base.h>
+// User includes
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// ToolsClientDefs (header)
+//
+
+//This is a utility class that retrieves the name and version number of the ToolsServer 
+class ToolsClientDefs
+{
+	// STATIC ACCESS METHODS
+	public:										
+	    static const TDesC& ServerAndThreadName();
+
+	    static const TDesC& ServerImageName();
+
+	    static TUidType	 ServerUidType();
+
+	    static TVersion	 Version();
+
+};
+
+#endif //__ToolsClientDefs_h__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/toolsclientsession.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __toolsclientsession_h__
+#define __toolsclientsession_h__
+
+// System includes
+#include <e32base.h>
+
+enum TConnectionStatus
+{
+    EUsbNotConnected,
+    EUsbConnected
+    
+};
+typedef TPckg<TConnectionStatus> TConnPkg; 
+
+// User includes
+
+// Classes referenced
+
+//The client-side interface to the MetroTrk Tcb server. 
+class RToolsClientSession : public RSessionBase
+{
+	// CONNECT TO SERVER & VERSIONING
+	public:										
+	    IMPORT_C   RToolsClientSession();
+		IMPORT_C TInt Connect();
+		IMPORT_C TVersion	Version() const;
+
+	
+	public:										
+		
+		
+		IMPORT_C TInt   GetConnStatus(TConnectionStatus& aConnStatus);
+		IMPORT_C void   UsbConnNotify(TDes8 &aDes ,TRequestStatus& aStatus);
+		IMPORT_C TInt   UsbConnNotifyCancel();
+		IMPORT_C TInt   ShutDownServer();
+
+};
+
+#endif //__toolsclientsession_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/inc/toolsclientutils.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __toolsclientutils_h__
+#define __toolsclientutils_h__
+
+// System includes
+#include <e32base.h>
+
+
+//
+//  ToolsClientUtils (header)
+//
+class ToolsClientUtils
+{
+public:										// ENUMERATIONS
+	/** Panic numbers associated with the TRKTCBCLI panic category. */
+	enum TToolsClientPanic
+	{
+		EToolsClientPanicArgument			= 0,
+		EToolsClientPanicCancel			= 1,
+		EToolsClientPanicLast
+	};
+	/** Panic numbers associated with the TRKTCBCLIFAULT panic category. */
+	enum TToolsClientFault
+	{
+		EToolsClientFaultLogic					= 0,
+		EToolsClientFaultData					= 1,
+		EToolsClientFaultCouldNotLoadServer	= 2,
+		EToolsClientFaultDebugFuncError		= 3,
+		EToolsClientFaultLast
+	};
+
+public:
+
+	static void	Panic(TToolsClientPanic aPanic);
+
+	static void	Fault(TToolsClientFault aFault);
+
+	static TInt	StartToolsServer();
+};
+
+#endif //__toolsclientutils_h__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/src/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/src/toolsclientdefs.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "toolsclientdefs.h"
+#include "ToolsCmdCodes.h"
+
+// System includes
+
+// User includes
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// ToolsClientDefs (source)
+//
+
+//
+// ToolsClientDefs::ServerAndThreadName()
+//
+// Returns the Tools server's unique name.
+// @return Unique name of the Tools server.
+//
+const TDesC& ToolsClientDefs::ServerAndThreadName()
+{
+	return KToolsServerName;
+}
+
+//
+// ToolsClientDefs::ServerImageName()
+//
+// Return the name of the server image (Exe/Dll)
+//
+const TDesC& ToolsClientDefs::ServerImageName()
+{
+	return KToolsServerImageName;
+}
+
+//
+// ToolsClientDefs::ServerUidType()
+//
+// Return the Uid associated with the server image
+//
+TUidType ToolsClientDefs::ServerUidType()
+{
+	return TUidType(KNullUid, KNullUid, KToolsServerUid);
+}
+
+
+//
+// ToolsClientDefs::Version()
+//
+// Return the version number of the server/client
+//
+TVersion ToolsClientDefs::Version()
+{
+	return TVersion(KToolsServerMajorVN, KToolsServerMinorVN, KToolsServerBuildVN);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/src/toolsclientdllmain.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+//  Include Files  
+
+#include <e32std.h>		 // GLDEF_C
+#include "toolsclient.pan"		// panic codes
+
+//  Global Functions
+
+GLDEF_C void Panic(TToolsClientPanic aPanic)
+// Panics the thread with given panic code
+    {
+    User::Panic(_L("ToolsClient"), aPanic);
+    }
+
+//  Exported Functions
+
+#ifndef EKA2 // for EKA1 only
+EXPORT_C TInt E32Dll(TDllReason /*aReason*/)
+// Called when the DLL is loaded and unloaded. Note: have to define
+// epoccalldllentrypoints in MMP file to get this called in THUMB.
+    {
+    return KErrNone;
+    }
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/src/toolsclientsession.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "toolsclientsession.h"
+#include "toolsclientdefs.h"
+#include <f32file.h>
+#include "ToolsCmdCodes.h"
+
+// System includes
+
+// User includes
+
+#include "toolsclientutils.h"
+// Type definitions
+
+// Constants
+const TInt KNumberOfServerStartupAttempts = 2;
+
+// Enumerations
+
+//
+// RToolsClientSession (source)
+//
+
+//
+// RToolsClientSession::RToolsClientSession
+//
+// Constructor
+//
+EXPORT_C RToolsClientSession::RToolsClientSession()
+{
+
+}
+
+//
+//RToolsClientSession::Connect()
+//
+// Connects the client process to the Tools server, starting the server 
+// if it is not already running.
+// return KErrNone if successful, otherwise one of the system-wide errors.
+//
+EXPORT_C TInt RToolsClientSession::Connect()
+{
+	TInt startupAttempts = KNumberOfServerStartupAttempts;
+	for(;;)
+	{
+		TInt ret = CreateSession(ToolsClientDefs::ServerAndThreadName(), ToolsClientDefs::Version(), KToolsServerAsynchronousSlotCount);
+		if (ret != KErrNotFound && ret != KErrServerTerminated)
+		{
+			return ret;
+		}
+		
+		if	(startupAttempts-- == 0)
+		{
+			return ret;
+		}
+		/*
+		ret = ToolsClientUtils::StartToolsServer();
+		if	(ret != KErrNone && ret != KErrAlreadyExists)
+		{
+			return ret;
+		}
+		*/
+	}
+}
+
+//
+// RToolsClientSession::Version()
+//
+// Provides the version number of the Tools server.
+// @return The version number. 
+//
+EXPORT_C TVersion RToolsClientSession::Version() const
+{
+	return ToolsClientDefs::Version();
+}
+
+// 
+// RToolsClientSession::GetConnStatus()
+//
+// Provides the connection status
+//
+
+EXPORT_C TInt RToolsClientSession::GetConnStatus(TConnectionStatus& aConnStatus)
+{
+    
+    TPckg<TConnectionStatus> package(aConnStatus);
+    TIpcArgs args(&package);
+    return SendReceive(EToolsCmdCodeGetUsbConnStatus, args);
+}
+
+// 
+// RToolsClientSession::UsbConnNotify()
+//
+// Asynchronous method to register for USB connection notifications
+//
+EXPORT_C void RToolsClientSession::UsbConnNotify(TDes8& aDes, TRequestStatus& aStatus)
+{
+    TIpcArgs args(&aDes);
+    SendReceive(EToolsCmdCodeConnNotify, args,aStatus);
+}
+
+// 
+// RToolsClientSession::UsbConnNotifyCancel()
+//
+// To cancel the registration for USB connection notifications
+//
+EXPORT_C TInt RToolsClientSession::UsbConnNotifyCancel()
+{
+   TIpcArgs args;
+   return SendReceive(EToolsCmdCodeConnNotify, args);
+}
+
+
+//
+// RToolsClientSession::ShutDownServer()
+//
+// Closes the server.
+// @return KErrNone - if succesful
+//         Negative - if failed.
+//
+
+EXPORT_C TInt RToolsClientSession::ShutDownServer()
+{
+	TIpcArgs args;
+	return SendReceive(EToolsCmdCodeShutDownServer, args);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterclient/src/toolsclientutils.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "toolsclientutils.h"
+
+// System includes
+#include <e32std.h>
+
+// User includes
+#include "toolsclientdefs.h"
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// ToolsClientUtils (source)
+//
+
+//
+// ToolsClientUtils::Panic()
+//
+// Panic the client
+//
+void ToolsClientUtils::Panic(TToolsClientPanic aPanic)
+{
+	_LIT(KToolsClientPanic, "ToolsCLI");
+	User::Panic(KToolsClientPanic, aPanic);
+}
+
+//
+// ToolsClientUtils::Fault()
+//
+// Panic the client, indicating some form of logic error or terminal
+// fault.
+//
+void ToolsClientUtils::Fault(TToolsClientFault aFault)
+{
+	_LIT(KToolsClientFault, "ToolsCLIFAULT");
+	User::Panic(KToolsClientFault, aFault);
+}
+
+//
+// ToolsClientUtils::StartToolsServer()
+//
+// Starts the Tools server.
+// @return KErrNone if successful, 
+//		   KErrAlreadyExists if the server is already running, otherwise a system-wide error.
+TInt ToolsClientUtils::StartToolsServer()
+{
+
+	TInt ret = KErrNone;
+
+	//
+	// Create a new server process. Simultaneous launching
+	// of two such processes should be detected when the second one attempts to
+	// create the server object, failing with KErrAlreadyExists.
+	//
+	RProcess server;
+	ret = server.Create(ToolsClientDefs::ServerImageName(), KNullDesC, ToolsClientDefs::ServerUidType());
+
+	// Did we manage to create the thread/process?
+	if	(ret != KErrNone)
+		return ret;
+
+	// Wait to see if the thread/process died during construction
+	TRequestStatus serverDiedRequestStatus;
+#if defined(EKA2)
+	server.Rendezvous(serverDiedRequestStatus);
+#else
+	server.Logon(serverDiedRequestStatus);
+#endif
+	
+	if	(serverDiedRequestStatus != KRequestPending)
+	{
+		// Abort startup
+		server.Kill(KErrNone);
+	}
+	else
+	{
+		// Logon OK - start the server
+		server.Resume();
+	}
+	
+	User::WaitForRequest(serverDiedRequestStatus);
+
+	// we can't use the 'exit reason' if the server panicked as this
+	// is the panic 'reason' and may be '0' which cannot be distinguished
+	// from KErrNone
+	
+	ret = (server.ExitType() == EExitPanic) ? KErrGeneral : serverDiedRequestStatus.Int();
+	
+	server.Close();
+
+	return ret;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/data/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/data/toolsstarterautolaunch.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// INCLUDES
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO rInfo
+    {
+    // UID for the DLL 
+    dll_uid = 0x200170B8;
+    // Declare array of interface info
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = 0x101F7D87;  // const for all data recognisers
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x200170B9;
+                    version_no         = 1;
+                    display_name       = "ToolsStarter Launcher";
+                    default_data       = "";
+                    opaque_data        = "";
+                    }
+                };
+            }
+        };
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,22 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+PRJ_MMPFILES
+#ifdef MARM
+toolsstarterautolaunch.mmp
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/group/toolsstarterautolaunch.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <platform_paths.hrh>
+ 
+TARGET          toolsstarterautolaunch.dll
+TARGETTYPE      PLUGIN
+
+UID             0x10009D8D 0x200170B8
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../src
+SOURCE          toolsstarterautolaunch.cpp
+
+
+LANG            SC
+ 
+USERINCLUDE     ../inc
+MW_LAYER_SYSTEMINCLUDE
+
+START RESOURCE ../data/toolsstarterautolaunch.rss
+TARGET toolsstarterautolaunch.rsc
+END
+ 
+LIBRARY         euser.lib
+LIBRARY         apmime.lib
+LIBRARY         ecom.lib
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/inc/logging.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __LOGGING_H__
+#define __LOGGING_H__
+
+
+#define _LOGGING_
+
+
+#ifdef _LOGGING_
+#define LOG_MSG(x) RDebug::Printf(x)
+#define LOG_MSG2(x, y) RDebug::Printf(x, y)
+#define LOG_MSG3(x, y, z) RDebug::Printf(x, y, z)
+#else
+#define LOG_MSG(x)
+#define LOG_MSG2(x, y)
+#define LOG_MSG3(x, y, z)
+#endif
+
+
+#endif // __LOGGING_H__
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/inc/toolsstarterautolaunch.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TOOLSSTARTERAUTOLAUNCH_H
+#define __TOOLSSTARTERAUTOLAUNCH_H
+
+
+//  INCLUDES
+#include <apmrec.h>
+#include <e32std.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  Implements CToolsStarterAutoLaunch
+*/
+class CToolsStarterAutoLaunch : public CApaDataRecognizerType
+    {
+public: // new functions
+    static CApaDataRecognizerType* CreateRecognizerL();
+    CToolsStarterAutoLaunch();
+    static void CreateAutoStartThreadL();
+    static TInt StartAppThreadFunction( TAny* aParam );
+
+public: // from CApaDataRecognizerType
+    TUint PreferredBufSize();
+    TDataType SupportedDataTypeL( TInt aIndex ) const;
+
+private: // from CApaDataRecognizerType
+    void DoRecognizeL( const TDesC& aName, const TDesC8& aBuffer );
+    };
+
+
+class CToolsStarterLauncher : public CBase
+    {
+public:
+    static CToolsStarterLauncher* NewL();
+    ~CToolsStarterLauncher();
+
+private:
+    CToolsStarterLauncher();
+    void ConstructL();
+
+public:
+    void StartServer();
+    void WaitForUiServices();
+        
+    };
+
+#endif // __TOOLSSTARTERAUTOLAUNCH_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/inc/toolsstarteruiobserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TOOLSSTARTERIDLEOBSERVER_H__
+#define __TOOLSSTARTERIDLEOBSERVER_H__
+
+
+//  INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <e32property.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+class MToolsStarterIdleObserver
+    {
+public:
+    virtual void IdleStateActivated() = 0;
+    };
+
+// CLASS
+class CToolsStarterIdleObserver : public CActive
+    {
+public:
+    ~CToolsStarterIdleObserver();
+    static CToolsStarterIdleObserver* NewL(MToolsStarterIdleObserver* aObserver);
+
+public:
+    void StartL();
+
+private:
+    CToolsStarterIdleObserver(MToolsStarterIdleObserver* aObserver);
+    void ConstructL();
+
+private:
+    void RunL();
+    void DoCancel();
+    
+private:
+    MToolsStarterIdleObserver*     iObserver;
+    RProperty                   iProperty;
+    };
+
+#endif // __TOOLSSTARTERIDLEOBSERVER_H__
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/src/toolsstarterautolaunch.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,239 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// INCLUDE FILES
+#include <apmrec.h>
+#include <ecom/implementationproxy.h>
+#include <e32debug.h>
+#include <startupdomainpskeys.h>
+
+#include "toolsstarterautolaunch.h"
+#include "logging.h"
+
+#define KPSDelay 500000
+
+
+// CONSTANTS
+const static TUint KToolsStarterAutoLaunchImplUid = 0x200170B9;
+const static TUid KToolsStarterAutoLaunchUid = {0x200170B8};
+_LIT(KToolsStarterServerExe, "toolsstarterserver.exe");
+const TUid KToolsStarterServerExeUid = {0x200170B5};
+_LIT( KToolsStarterMatchPattern, "toolsstarterserver**" );
+
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( KToolsStarterAutoLaunchImplUid,
+    		CToolsStarterAutoLaunch::CreateRecognizerL )
+    };
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
+
+CApaDataRecognizerType* CToolsStarterAutoLaunch::CreateRecognizerL()
+    {
+	LOG_MSG("CToolsStarterAutoLaunch::CreateRecognizerL");
+
+	CApaDataRecognizerType* recognizer = new (ELeave) CToolsStarterAutoLaunch();
+	CToolsStarterAutoLaunch::CreateAutoStartThreadL();
+    return recognizer;
+    }
+
+
+CToolsStarterAutoLaunch::CToolsStarterAutoLaunch() :
+    CApaDataRecognizerType( KToolsStarterAutoLaunchUid, CApaDataRecognizerType::ENormal )
+    {
+    iCountDataTypes = 1;
+    }
+
+
+
+TUint CToolsStarterAutoLaunch::PreferredBufSize()
+    {
+    return 0;
+    }
+
+
+TDataType CToolsStarterAutoLaunch::SupportedDataTypeL( TInt /*aIndex*/ ) const
+    {
+    return TDataType();
+    }
+
+
+void CToolsStarterAutoLaunch::DoRecognizeL( const TDesC& /*aName*/, const TDesC8& /*aBuffer*/ )
+    {
+    }
+
+
+void CToolsStarterAutoLaunch::CreateAutoStartThreadL()
+    {
+    LOG_MSG("CToolsStarterAutoLaunch::CreateAutoStartThread");
+    
+    //create a new thread for starting our application
+    RThread startAppThread;
+
+    User::LeaveIfError( startAppThread.Create(
+        _L( "ToolsStarterAutoLaunch" ),
+        CToolsStarterAutoLaunch::StartAppThreadFunction,
+        KDefaultStackSize,
+        KMinHeapSize,
+        KMinHeapSize,
+        NULL,
+        EOwnerThread ) );
+
+    startAppThread.SetPriority( EPriorityNormal );
+    startAppThread.Resume();
+    startAppThread.Close();
+    }
+
+
+TInt CToolsStarterAutoLaunch::StartAppThreadFunction( TAny* /*aParam*/ )
+    {
+    LOG_MSG("CToolsStarterAutoLaunch::StartAppThreadFunction");
+    
+     // create a trap cleanup and active scheduler
+    CTrapCleanup* pC = CTrapCleanup::New();
+    
+    //CActiveScheduler* pS = new CActiveScheduler;
+    //CActiveScheduler::Install(pS);
+    
+    if (pC==NULL)// || pS==NULL)
+        LOG_MSG("Failed to create the trapcleanup and active scheduler");
+        
+            // create a server starter instance
+    CToolsStarterLauncher* serverStarter = NULL;
+    TRAPD(err, serverStarter = CToolsStarterLauncher::NewL());
+    
+    if (err == KErrNone)
+    	{
+	    // wait for UI to be up
+	   // serverStarter->WaitForUiServices();
+		// now start the toolsstarter server
+		serverStarter->StartServer();
+		delete serverStarter;	    
+	   	}    
+
+  	delete pC;
+  	//delete pS;
+  	
+    return KErrNone;
+    }
+
+
+CToolsStarterLauncher* CToolsStarterLauncher::NewL()
+    {
+    CToolsStarterLauncher* self = new(ELeave) CToolsStarterLauncher();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+
+CToolsStarterLauncher::CToolsStarterLauncher()
+    {
+    }
+
+
+    
+CToolsStarterLauncher::~CToolsStarterLauncher()
+    {
+
+    }
+
+
+ 
+void CToolsStarterLauncher::ConstructL()
+    {
+    }
+
+void CToolsStarterLauncher::StartServer()
+    {
+    LOG_MSG("CToolsStarterLauncher::StartServer");
+    
+    // check if toolsstarter is already running
+    TFullName processName;
+    TFindProcess finder( KToolsStarterMatchPattern );
+    TInt err = finder.Next( processName );
+    if ( err == KErrNone )
+        {
+        LOG_MSG("KToolsStarterMatchPattern server already running");
+        return;
+        }
+
+    // otherwise create a new process
+    RProcess pr;
+    err = pr.Create(KToolsStarterServerExe, TPtr(NULL, 0), TUidType(KNullUid, KNullUid, KToolsStarterServerExeUid));
+    if ( err == KErrNone )
+        {
+        LOG_MSG("CToolsStarterLauncher::StartServer process created");
+        pr.Resume();
+        pr.Close();
+        }
+    else
+        {
+        LOG_MSG2("CToolsStarterLauncher::StartServer Could not create process %d", err);
+        }
+    }
+
+
+void CToolsStarterLauncher::WaitForUiServices()
+    {
+    LOG_MSG("ToolsStarter Launcher: WaitForUiServices");
+    RProperty property;
+    TInt err = KErrNotReady;
+    while ( err != KErrNone )
+        {
+        User::After(KPSDelay); // Wait for the startup to define the key
+        err = property.Attach(KPSUidStartup, KPSGlobalSystemState);
+        LOG_MSG2("ToolsStarter Launcher: WaitForUiServices attach err %d \n", err);
+        }
+    // Wait for the correct startup state
+    TRequestStatus status;
+    property.Subscribe(status);
+    TInt state = 0;
+    err = property.Get(state);
+    LOG_MSG3("ToolsStarter Launcher: WaitForUiServices state %d err %d \n", state, err);
+    while ( err == KErrNone &&
+            !( state == ESwStateCriticalPhaseOK ||
+               state == ESwStateNormalRfOn ||
+               state == ESwStateNormalRfOff ||
+               state == ESwStateNormalBTSap ) )
+        {
+        state = 0; // Reset previous value
+        User::WaitForRequest(status);
+        err = status.Int();
+        if ( err == KErrNone )
+            {
+            property.Subscribe( status );
+            err = property.Get( state );
+            }
+        LOG_MSG3("ToolsStarter Launcher: WaitForUiServices state changed %d err %d", state, err);
+        }
+    property.Cancel();
+    property.Close();
+    LOG_MSG("ToolsStarter Launcher: WaitForUiServices end");
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/autolaunch/src/toolsstarteruiobserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,139 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// INCLUDE FILES
+#include <e32debug.h>
+#include <ActiveIdle2DomainPSKeys.h>
+#include <e32property.h>
+
+#include "logging.h"
+#include "toolsstarteruiobserver.h"
+
+// CONSTANTS
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CToolsStarterIdleObserver::CToolsStarterIdleObserver(MToolsStarterIdleObserver& aObserver) :
+    CActive(EPriorityStandard), // Standard priority
+    iObserver(aObserver)
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// Two-phased constructor
+// ----------------------------------------------------------------------------
+//
+CToolsStarterIdleObserver* CToolsStarterIdleObserver::NewL(MToolsStarterIdleObserver& aObserver)
+    {
+    CToolsStarterIdleObserver* self = new(ELeave) CToolsStarterIdleObserver(aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// 2nd phase construction
+// ----------------------------------------------------------------------------
+//
+void CToolsStarterIdleObserver::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    
+    // attach to the property which listens the idle state
+    User::LeaveIfError( iProperty.Attach( KPSUidAiInformation, KActiveIdleState ) );
+    
+    LOG_MSG("CToolsStarterIdleObserver::ConstructL succesfully attached to property");
+    }
+
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CToolsStarterIdleObserver::~CToolsStarterIdleObserver()
+    {
+    Cancel();
+    iProperty.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// Starts listening for events
+// ----------------------------------------------------------------------------
+//
+void CToolsStarterIdleObserver::StartL()
+    {
+    Cancel();
+    
+    // subscribe to the property
+    iProperty.Subscribe(iStatus);
+    SetActive();
+    }
+
+// ----------------------------------------------------------------------------
+// Implements cancellation of an outstanding request.
+// ----------------------------------------------------------------------------
+//
+void CToolsStarterIdleObserver::DoCancel()
+    {
+    iProperty.Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// Handles an active object's request completion event.
+// ----------------------------------------------------------------------------
+//
+void CToolsStarterIdleObserver::RunL()
+    {
+    // check the status
+    TInt idleStatus(KErrNotFound);
+    TInt err( iStatus.Int() );
+    
+    if (err == KErrNone)
+        {
+        // resubscribe before processing new value to prevent missing updates
+        StartL();
+        err = iProperty.Get( KPSUidAiInformation, KActiveIdleState, idleStatus );
+        
+        if (err == KErrNone && idleStatus == EPSAiForeground) 
+            {
+            LOG_MSG("CToolsStarterIdleObserver::RunL idle foreground state detected");
+
+            // idle state is active so notify the observer and no need to wait anymore
+            iObserver.IdleStateActivated();
+            Cancel();
+            }
+        else
+            {
+            LOG_MSG2("CToolsStarterIdleObserver::RunL unknown state %d", idleStatus);
+            }
+        }
+
+    else if (err != KErrCancel)
+        {
+        // try again..
+        StartL();
+        } 
+    }
+
+// ----------------------------------------------------------------------------
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/data/0x200170B5.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#include <StartupItem.rh>
+ 
+RESOURCE STARTUP_ITEM_INFO startexe
+{
+    executable_name = "\\sys\\bin\\toolsstarterserver.exe";
+    recovery = EStartupItemExPolicyNone;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/data/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/group/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "../autolaunch/group/bld.inf"
+
+#include <platform_paths.hrh>
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+#ifdef MARM
+toolsstarterserver.mmp
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/group/toolsstarterserver.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#if defined (FF_PLATFORM_SIMULATOR)
+macro __PLATSIM__
+#endif
+
+#include <platform_paths.hrh>
+
+TARGET		  toolsstarterserver.exe
+TARGETTYPE	  EXE
+UID 0x1000008C 0x200170B5
+
+USERINCLUDE	  ../inc
+USERINCLUDE   ../../common
+MW_LAYER_SYSTEMINCLUDE
+//SYSTEMINCLUDE   \epoc32\include
+//SYSTEMINCLUDE   \epoc32\include\middleware
+
+SOURCEPATH	  ../src
+SOURCE		    toolssrvmain.cpp toolssrvscheduler.cpp toolssrvserver.cpp toolssrvsession.cpp
+SOURCE        toolsusbportlistener.cpp toolslaunchmgr.cpp toolsprocess.cpp
+
+
+SOURCEPATH     ../data
+START RESOURCE 0x200170B5.rss
+HEADER
+targetpath	/resource/apps
+lang		sc
+END
+
+LIBRARY		 euser.lib usbman.lib
+
+CAPABILITY All -TCB -DRM -ALLFILES
+
+EPOCSTACKSIZE 0x12000
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/connectionvariables.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+ */
+
+
+#ifndef CONNECTIONVARIABLES_H_
+#define CONNECTIONVARIABLES_H_
+
+enum TConnectionStatus
+{
+    EUsbNotConnected,
+    EUsbConnected
+    
+};
+
+#endif /* CONNECTIONVARIABLES_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/launchmanagerinterface.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef LAUNCHMANAGERINTERFACE_H_
+#define LAUNCHMANAGERINTERFACE_H_
+
+#include "sessionmessgelistener.h"
+
+class ILaunchManagerInterface 
+{
+  public:
+
+    virtual void RegisterListener(MConnStateListener* aListener)=0;
+    virtual void UnregisterListener(MConnStateListener* aListener)=0;
+    virtual TConnectionStatus GetUsbConnStatus()=0;
+    virtual void Launch()=0;
+    
+     
+};
+
+#endif /* LAUNCHMANAGERINTERFACE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/logging.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __LOGGING_H__
+#define __LOGGING_H__
+
+#include <e32debug.h>
+
+
+//
+// Turn on this logging for debugging purposes when running with test code.  
+// If you turn on the logging either when tracing or while debugging, 
+// it won't work as the printf messages are handled both by trace core and debugger.
+//
+#define _LOGGING_
+
+
+#ifdef _LOGGING_
+#define LOG_MSG(x) RDebug::Printf(x)
+#define LOG_MSG2(x, y) RDebug::Printf(x, y)
+#define LOG_MSG3(x, y, z) RDebug::Printf(x, y, z)
+#else
+#define LOG_MSG(x)
+#define LOG_MSG2(x, y)
+#define LOG_MSG3(x, y, z)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/sessionmessgelistener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef SESSIONMESSGELISTENER_H_
+#define SESSIONMESSGELISTENER_H_
+
+#include "connectionvariables.h"
+
+class MConnStateListener
+    {
+public:
+    virtual void ConnStatusChanged(TConnectionStatus)=0;   
+    
+    };
+
+
+#endif /* SESSIONMESSGELISTENER_H_ */
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolscommportListener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TOOLSCOMMPORTLISTENER_H__
+#define __TOOLSCOMMPORTLISTENER_H__
+
+#include <e32base.h>
+
+#include "toolsconnectionlistener.h"
+
+
+//
+// class CToolsCommPortListener
+//
+// Abstract base class for communications port listener
+//
+class CToolsCommPortListener : public CActive
+{
+public:
+	
+	virtual ~CToolsCommPortListener();
+	
+	virtual void ListenL() = 0;
+	virtual void StopListening() = 0;
+
+protected:
+	
+	CToolsCommPortListener(MToolsConnectionListener *aConnectionListener, TInt aPriority);
+	virtual TInt RunError( TInt aError );
+
+protected:
+	
+	MToolsConnectionListener* iConnectionListener;
+};
+
+inline CToolsCommPortListener::CToolsCommPortListener(MToolsConnectionListener *aConnectionListener, TInt aPriority)
+	: CActive(aPriority),
+	iConnectionListener(aConnectionListener)
+{
+}
+
+inline CToolsCommPortListener::~CToolsCommPortListener()
+{
+}
+
+inline TInt CToolsCommPortListener::RunError(TInt aError)
+{
+	User::Panic( _L("TOOLSSTARTER"), aError );	
+	return aError;
+}
+
+#endif // __TOOLSCOMMPORTLISTENER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolsconnectionlistener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TOOLSCONNECTIONLISTENER_H__
+#define __TOOLSCONNECTIONLISTENER_H__
+
+/**
+*  Abstract callback interface for port listeners 
+*/
+class MToolsConnectionListener
+{
+    public:
+
+        /**
+        * Callback into the implementor when a connection is available
+        */
+        virtual void ConnectionAvailable() = 0;
+
+        /**
+        * This is called when a connection is closed, this can happen for different reasons.
+        * One of the reasons could be that the user has unplugged 
+        * the USB cable when using the USB connection
+        */
+        virtual void ConnectionUnAvailable() = 0; 
+      
+};
+
+#endif //__TOOLSCONNECTIONLISTENER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolslaunchmgr.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef     _TOOLSLAUNHCMGR_H_
+#define     _TOOLSLAUNHCMGR_H_
+
+//  INCLUDES
+#include <e32base.h>
+#include <e32std.h>
+#include "launchmanagerinterface.h"
+#include "toolsprocess.h"
+#include "toolsconnectionlistener.h"
+#include "toolsusbportlistener.h"
+#include "sessionmessgelistener.h"
+
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+class CToolsLaunchMgr: public CBase, public ILaunchManagerInterface, public MToolsConnectionListener
+{
+    public:  
+        static CToolsLaunchMgr* NewL();
+        static CToolsLaunchMgr* NewLC();
+        ~CToolsLaunchMgr();
+
+	private:
+	    
+		CToolsLaunchMgr();
+		void ConstructL();
+		void LaunchTools(TCmdLineConnType aConnType);
+		void StopTools();
+				        
+	public:        
+	    // from MConnectionListener
+	    void ConnectionAvailable();
+	    void ConnectionUnAvailable();
+
+         //From ILaunchManagerInterface 
+	    void RegisterListener(MConnStateListener* aListener);           
+	    void UnregisterListener(MConnStateListener* aListener);
+	    TConnectionStatus GetUsbConnStatus();
+	    void Launch();
+	    
+	public:
+	    
+	    TInt CloseCrashLogger();    
+	    TInt TerminateProcess(const TDesC& aProcessName);
+        
+    private:
+    	CToolsUsbPortListener* iUsbPortListener;    	
+    	RPointerArray<CToolsProcess> iToolsProcessList;
+    	RPointerArray<MConnStateListener> iToolListenerList;
+    
+};
+
+
+
+#endif      //  _TOOLSLAUNHCMGR_H_
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolsprocess.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef     _TOOLSPROCESS_H_
+#define     _TOOLSPROCESS_H_
+
+//  INCLUDES
+#include <e32base.h>
+#include <e32std.h>
+
+#define KMaxCmdLineConnArgsLen 10
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+class CToolsProcess;
+
+enum TCmdLineConnType
+{
+	EUsb = 0,
+	EXti,
+};
+
+//
+// class CProcessTracker
+//
+// Watches to see when a process exists
+//
+class CProcessTracker : public CActive
+{
+public:
+
+	CProcessTracker(CToolsProcess *aToolsProcess, TUint32 aProcessId);
+	~CProcessTracker();
+
+	void Watch();
+
+protected:
+
+	void RunL();
+	void DoCancel();
+
+private:
+
+	RProcess iProcess;
+	TUint32 iProcessId;
+	CToolsProcess *iToolsProcess;
+};
+
+
+class CToolsProcess: public CBase
+{
+    public:  
+
+		static CToolsProcess* NewL(const TDesC& aPath, const TDesC& aArgsUsb, const TDesC& aArgsXti);
+		static CToolsProcess* NewLC(const TDesC& aPath, const TDesC& aArgsUsb, const TDesC& aArgsXti);
+        ~CToolsProcess();
+        
+	public:
+		TInt Start(TCmdLineConnType aConnType);
+		void Stop();       
+		
+		void ProcessDied(TInt aExitReason);
+		TDesC GetProcessPath() { return iPath; }
+
+	private:
+		CToolsProcess();
+		void ConstructL(const TDesC& aPath, const TDesC& aArgsUsb, const TDesC& aArgsXti);		
+		        
+	private:
+		TBuf<KMaxPath> iPath;
+		TBuf<KMaxCmdLineConnArgsLen> iArgsUsb;
+		TBuf<KMaxCmdLineConnArgsLen> iArgsXti;
+		
+		TBool iRunning;            
+		
+		TUint32 iProcessId;
+		
+		CProcessTracker* iProcessTracker;
+		RProcess iProcess;
+		
+		static TBool iFirstTimeAfterBoot;
+};
+
+
+#endif      //  _TOOLSPROCESS_H_
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolsserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __toolsserver_h__
+#define __toolsserver_h__
+
+//  Include Files
+
+#include <e32base.h>
+
+//  Function Prototypes
+
+GLDEF_C TInt E32Main();
+
+#endif  // __toolsserver_h__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolssrvscheduler.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __ToolsSrvActiveScheduler_H__
+#define __ToolsSrvActiveScheduler_H__
+
+// System includes
+#include <e32base.h>
+
+
+
+//
+// CToolsSrvScheduler (header)
+//
+//
+// The Active Scheduler for the Trk TCB Server thread
+//
+class CToolsSrvScheduler : public CActiveScheduler
+{
+	public:										
+		static CToolsSrvScheduler* NewLC();
+
+	private:
+		CToolsSrvScheduler();
+};
+
+#endif //__ToolsSrvActiveScheduler_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolssrvserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __toolssrvserver_H__
+#define __toolssrvserver_H__
+
+// System includes
+#include <e32base.h>
+#include "toolslaunchmgr.h"
+//
+// CToolsSrvServer (header)
+// The Tools Server
+//
+#ifdef EKA2
+class CToolsSrvServer : public CPolicyServer
+#else
+class CToolsSrvServer : public CServer2
+#endif
+{
+	public:
+		static CToolsSrvServer* NewLC();
+		~CToolsSrvServer();
+
+	private:
+		CToolsSrvServer();
+		void ConstructL();
+
+	public:
+		CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
+        // called by the session objects
+		void SessionOpened();
+		void SessionClosed();
+	
+	public:
+	    TConnectionStatus GetUsbConnStatus();
+	    ILaunchManagerInterface* GetLaunchInterface();
+
+	private:
+		TInt RunError(TInt aError);
+
+	private:
+	    TInt iSessionCount;
+	    CToolsLaunchMgr* iLaunchManager;
+	#ifdef EKA2	
+		TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing);
+	#endif
+};
+
+//
+//                  inline implementations
+//
+/*
+ * To get the Launchmanger instance to be used for sessions
+ * 
+ */
+inline ILaunchManagerInterface* CToolsSrvServer::GetLaunchInterface()
+{
+    if(iLaunchManager)
+        return iLaunchManager;
+    return NULL;    
+    
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolssrvsession.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __toolssrvsession_h__
+#define __toolssrvsession_h__
+
+// System includes
+#include <e32base.h>
+#include "sessionmessgelistener.h"
+#include "launchmanagerinterface.h"
+
+//
+// CToolsSrvSession (header)
+//
+// This class acts as a simple wrapper around the IPC client-server framework,
+// and drives a real underlying engine, which is actually responsible for
+// fulfulling all the client requests.
+
+ 
+class CToolsSrvSession : public CSession2 ,public MConnStateListener
+{
+	public:
+		static 	CToolsSrvSession* NewL();
+				~CToolsSrvSession();
+
+	private:
+				CToolsSrvSession();
+		void 	ConstructL();
+
+	public:
+		void 	HandleServerDestruction();
+		void    CreateL();
+
+	private:
+
+
+
+	private:
+	//FROM CSession2
+		void 	ServiceL(const RMessage2& aMessage);
+
+	private:
+	// CMD - ToolsSERVER SPECIFIC FUNCTIONALITY
+		
+		void   CmdGetUsbConnStatus(const RMessage2& aMessage);
+		void   CmdConnNofify(const RMessage2& aMessage);
+		void   CmdConnNotifyCancel(const RMessage2& aMessage);
+		void   CmdShutDownServer();
+
+
+private:
+	/*
+	 * Used to transfer collections of objects between server and client.
+	 */
+	CBufBase*	 iTransferBuffer;
+	RMessagePtr2 iBlockedRead;
+	TBool     iPendingRead;
+	ILaunchManagerInterface* iLaunchManager;
+	
+	public:
+	    
+	void ConnStatusChanged(TConnectionStatus );
+	
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolsstarter.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __ToolsStarter_H__
+#define __ToolsStarter_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include <e32cons.h>
+#include <hal.h>
+
+
+//
+// class CKeyboardInput
+//
+// Handles input from the keyboard
+//
+class CKeyboardInput : public CActive
+{
+public:
+
+	CKeyboardInput(CConsoleBase* aConsole);
+	~CKeyboardInput();
+
+	void ListenToKeyboard();
+
+protected:
+
+	void RunL();
+	void DoCancel();
+
+private:
+
+	CConsoleBase* iConsole;
+};
+
+
+//
+// class CToolsStarterConsoleIO
+//
+// Handles input and output from/to the console
+//
+class CToolsStarterConsoleIO : public CBase
+{
+public:
+
+	CToolsStarterConsoleIO();
+	~CToolsStarterConsoleIO();
+
+	void PrintToScreen(TRefByValue<const TDesC> aFmt, ...);
+	void Terminating();
+
+private:
+
+	CConsoleBase* iConsole;
+	CKeyboardInput* iKeyboardInput;
+	TBuf<50> iBuffer;
+};
+
+#endif // __ToolsStarter_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/inc/toolsusbportlistener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef     _TOOLSUSBPORTLISTENER_H_
+#define     _TOOLSUSBPORTLISTENER_H_
+
+//  INCLUDES
+#include <e32std.h>
+#include <c32comm.h>
+#include <usbman.h>
+
+#include "toolscommportListener.h"
+#include "connectionvariables.h"
+
+
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+class CToolsUsbPortListener: public CToolsCommPortListener
+{
+
+    public:  
+
+		CToolsUsbPortListener(MToolsConnectionListener *aConnectionListener);	
+        ~CToolsUsbPortListener();
+
+		// From CCommPortListener
+        void ListenL();
+        void StopListening();
+        
+        TBool IsConnectionAvailable();
+        TConnectionStatus GetUsbConnStatus();
+
+    protected: 
+    	// From CActive
+        void DoCancel();
+        void RunL();	    
+
+	private:
+	
+		void IssueRequestL();
+
+		
+    private:    
+
+        RUsb                        iUsbServer;
+		TUsbDeviceState				iUsbDeviceState;
+		
+		TBool iConnected;
+		TInt iPersonalityId;
+};
+
+
+#endif      //  _TOOLSUSBPORTLISTENER_H_
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/sis/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/sis/eula.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,2 @@
+By installing this software you accept the terms of the 
+Carbide.C++ End-User License Agreement. The license agreement can be found in your Carbide.c++ installation directory, under the "EULA" subfolder.
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/sis/mk_s60_sys_sis_5_0.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,18 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+
+makesis toolsstarterserver_s60_5_0.pkg
+signsis toolsstarterserver_s60_5_0.sis s60_5_0_toolsstarterserver_1_0.sisx  ..\..\..\group\s60\sis\RDTest_02.der ..\..\..\group\s60\sis\RDTest_02.key
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/sis/toolsstarterserver_s60_5_0.pkg	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,60 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+
+;Languages
+&EN
+
+;Header
+#{"Toolsstarter server"},(0x200170B5),1,00,3
+
+;Localised Vendor name
+%{"Nokia-EN"}
+
+;Unique Vendor name
+:"Nokia"
+
+;Supports Series 60 v 5.0
+[0x1028315F], 0, 0, 0, {"Series60ProductID"}
+
+"eula.txt"-"", FILETEXT, TEXTEXIT
+
+
+;Embedded component
+;@"s60_5_x_sys_trk_3_2.sisx",(0x200170BB)
+
+
+;Embedded component
+;@"TraceSwitch.sisx",(0x20010231)
+
+
+
+
+;Files to install
+"\epoc32\release\armv5\urel\toolsstarterserver.exe"			-"!:\sys\bin\toolsstarterserver.exe", FILERUN, RUNINSTALL
+;"\epoc32\data\z\resource\apps\0x200170B5.rsc"			-"c:\private\101f875a\import\[200170B5].rsc"
+
+"\epoc32\release\armv5\urel\toolsstarterautolaunch.dll"			-"!:\sys\bin\toolsstarterautolaunch.dll"
+"\epoc32\data\z\resource\plugins\toolsstarterautolaunch.rsc"			-"c:\resource\plugins\toolsstarterautolaunch.rsc"
+
+
+
+
+; Required files
+; None
+
+; Component .sis files
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/src/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolslaunchmgr.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,272 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+// INCLUDE FILES
+#include <e32std.h> 
+#include <e32base.h>    
+#include "logging.h"
+#include "toolsusbportlistener.h"
+#include "toolslaunchmgr.h" 
+
+#define SafeDelete(x) { if (x) delete x; x = NULL; }
+
+_LIT(KTRKSERVER, "trkserver.exe");
+//_LIT(KTRACESERVER, "traceserver.exe");
+
+_LIT(KCMDLINECONNTYPEUSB, "-usb");
+_LIT(KCMDLINECONNTYPEXTI, "-xti");
+
+                   
+// LOCAL FUNCTION PROTOTYPES
+
+// LOCAL CONSTANTS
+
+
+
+//
+// CToolsLaunchMgr::NewL
+//
+CToolsLaunchMgr* CToolsLaunchMgr::NewL()
+{
+	CToolsLaunchMgr* self = new(ELeave) CToolsLaunchMgr;
+	self->ConstructL();
+	return self;
+}
+
+//
+// CTrkEngine::NewLC
+//
+CToolsLaunchMgr* CToolsLaunchMgr::NewLC()
+{
+	CToolsLaunchMgr* self = new(ELeave) CToolsLaunchMgr;
+	CleanupStack::PushL(self);
+	
+	self->ConstructL();
+	
+	return self;
+}
+
+
+//
+// CToolsLaunchMgr::ConstructL
+// Constructor
+//
+void CToolsLaunchMgr::ConstructL() 
+{
+	iUsbPortListener = new CToolsUsbPortListener(this);	
+	TRAPD(err, iUsbPortListener->ListenL());
+	if (err != KErrNone)
+	    LOG_MSG("Failed to start the USB port listener");
+	
+	// Adding TRKAPP to the launch list
+	CToolsProcess* toolsProcess = CToolsProcess::NewL(KTRKSERVER, KCMDLINECONNTYPEUSB, KCMDLINECONNTYPEXTI);
+	iToolsProcessList.Append(toolsProcess);
+
+	// Adding TRACESWITCH app
+	// For now, we are disabling the autostart of traceserver from toolsstarter
+	// When traceserver connects to the tracecore ost ldd at bootup time, 
+	// there is a problem for getting the data from the ldd.
+	// Until this problem is fixed, traceswitch needs to be started after the bootup
+	// for plug-n-play trace support.
+	//_LIT(KNOXTI, "");
+	
+	//toolsProcess = CToolsProcess::NewL(KTRACESERVER, KCMDLINECONNTYPEUSB, KNOXTI);
+	//iToolsProcessList.Append(toolsProcess);
+}
+
+//
+// CToolsLaunchMgr::CToolsLaunchMgr
+// Constructor
+//
+CToolsLaunchMgr::CToolsLaunchMgr()
+			: iUsbPortListener(NULL),
+			  iToolsProcessList(1),
+			  iToolListenerList(1)
+{
+	
+}
+
+//
+// CToolsLaunchMgr::~CToolsLaunchMgr
+// Destructor
+//
+CToolsLaunchMgr::~CToolsLaunchMgr()
+{
+	SafeDelete(iUsbPortListener);
+	iToolsProcessList.ResetAndDestroy();
+	iToolsProcessList.Close();
+	iToolListenerList.ResetAndDestroy();
+	iToolListenerList.Close();
+}
+
+//
+// CToolsLaunchMgr::Launch
+//
+void CToolsLaunchMgr::Launch() 
+{
+    if (iUsbPortListener->IsConnectionAvailable())
+	{
+		LaunchTools(EUsb);
+	}
+	else
+	{
+		LaunchTools(EXti);
+	}
+}
+
+//
+// CToolsLaunchMgr::ConnectionAvailable
+//
+void CToolsLaunchMgr::ConnectionAvailable() 
+{
+    
+    for (TInt i=0; i<iToolListenerList.Count(); i++)
+    {
+         iToolListenerList[i]->ConnStatusChanged(EUsbConnected);        
+        
+    }
+    
+}
+
+//
+// CToolsLaunchMgr::LaunchTools
+//
+void CToolsLaunchMgr::LaunchTools(TCmdLineConnType aConnType) 
+{ 
+    // remove this process from our list
+	for (TInt i=0; i<iToolsProcessList.Count(); i++)
+	{
+		TInt err = iToolsProcessList[i]->Start(aConnType);
+		
+		if (err != KErrNone)
+		{
+		   LOG_MSG2("Failed to start the process: %d", err);
+		}
+	}
+}
+
+//
+// CToolsLaunchMgr::ConnectionAvailable
+//
+void CToolsLaunchMgr::ConnectionUnAvailable() 
+{    
+    for (TInt i=0; i<iToolListenerList.Count(); i++)
+    {
+        iToolListenerList[i]->ConnStatusChanged(EUsbNotConnected);        
+       
+    }
+}
+
+//
+// CToolsLaunchMgr::StopTools
+//
+void CToolsLaunchMgr::StopTools() 
+{
+	// remove this process from our list
+	for (TInt i=0; i<iToolsProcessList.Count(); i++)
+	{
+		iToolsProcessList[i]->Stop();
+	} 
+}
+//
+//  CToolsLaunchMgr::GetUsbConnStatus()
+//
+//  To Find out the usb connection status  
+//
+TConnectionStatus CToolsLaunchMgr::GetUsbConnStatus()
+{
+    return (iUsbPortListener->GetUsbConnStatus());
+    
+}
+//
+//  CToolsLaunchMgr::RegisterListener()
+//
+//  To register the cable connection events  
+//
+
+void CToolsLaunchMgr::RegisterListener(MConnStateListener* aListener)
+{
+    iToolListenerList.Append(aListener);
+}
+
+//
+//  CToolsLaunchMgr::UnregisterListener()
+//
+//  To unregister the cable connection events  
+//
+void CToolsLaunchMgr::UnregisterListener(MConnStateListener* aListener)
+{
+    for (TInt i=0; i<iToolListenerList.Count(); i++)
+    {
+        if(iToolListenerList[i] == aListener)
+        {
+            iToolListenerList.Remove(i);
+        }        
+       
+    }
+            
+}
+//
+//  CToolsLaunchMgr::CloseCrashLogger()
+//
+//  To close the mobile crash logger
+//
+
+TInt CToolsLaunchMgr::CloseCrashLogger()
+{
+    TInt err = KErrNone;
+    
+    //The old mobile crash file name is "d_exc_mc.exe" and the new one is "mc_useragent.exe"    
+    //This is the string that needs to be passed to the RProcess::Open call to get a handle.
+    //The complete process name actually includes the UID info as well.
+    //Instead of hard coding the process name, its better to just 
+    //search for the process and find it that way.      
+    //_LIT16(KCrashLoggerName, "mc_useragent.exe[1020e519]0001");
+    _LIT16(KOldCrashLoggerName, "d_exc_mc*");
+    _LIT16(KCrashLoggerName, "mc_useragent*");
+    
+    err = TerminateProcess(KOldCrashLoggerName);
+    err = TerminateProcess(KCrashLoggerName);
+
+    return err;
+}
+
+//
+//  CToolsLaunchMgr::TerminateProcess
+//
+//  Terminates the given process 
+//
+TInt CToolsLaunchMgr::TerminateProcess(const TDesC& aProcessName)
+{
+    _LIT16(KCrashLoggerClMsg, "Closing crash logger");
+    
+    TFindProcess find(aProcessName);
+    TFullName name; 
+        
+    TInt err = find.Next(name);
+    if (KErrNone == err)
+    {   
+        RProcess process;
+        err = process.Open(find);
+    
+        if (KErrNone == err)
+        {
+            User::InfoPrint(KCrashLoggerClMsg);
+            process.Kill(KErrNone);
+        }
+    }
+    return err;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolsprocess.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,223 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+// INCLUDE FILES
+#include <e32std.h>                      
+
+#include "toolsprocess.h" 
+
+#define SafeDelete(x) { if (x) delete x; x = NULL; }
+                   
+// LOCAL FUNCTION PROTOTYPES
+
+// LOCAL CONSTANTS
+
+
+//
+// CProcessTracker constructor
+//
+// Accepts CTrkDispatchLayer interface and the process ID of the
+// process to watch
+//
+CProcessTracker::CProcessTracker(CToolsProcess *aToolsProcess, TUint32 aProcessId)
+    : CActive(EPriorityStandard),
+      iProcessId(aProcessId),
+      iToolsProcess(aToolsProcess)
+{
+    CActiveScheduler::Add(this);
+
+    TInt error = iProcess.Open(iProcessId);
+    if (KErrNone != error)
+        User::Panic(_L("Unable to open process"), __LINE__);
+}
+
+//
+// CProcessTracker destructor
+//
+CProcessTracker::~CProcessTracker()
+{
+    Cancel();
+    Deque();
+    iProcess.Close();
+}
+
+//
+// CProcessTracker::Watch
+//
+// Watch for the process to exit
+//
+void CProcessTracker::Watch()
+{
+    iProcess.Logon(iStatus);
+    SetActive();
+}
+
+//
+// CProcessTracker::RunL
+//
+// Called when the process exits
+//
+void CProcessTracker::RunL()
+{
+    // sometimes this is run when the process has yet to exit
+    if (iProcess.ExitType() == EExitPending)
+    {
+        iProcess.LogonCancel(iStatus);
+        Watch();
+    }
+    else
+    {
+        iToolsProcess->ProcessDied(iProcess.ExitReason());
+    }
+}
+
+//
+// CProcessTracker::DoCancel
+//
+// Stop waiting for this process to exit
+//
+void CProcessTracker::DoCancel()
+{
+    iProcess.LogonCancel(iStatus);
+}
+
+//
+// CToolsProcess implementation
+//
+
+TBool CToolsProcess::iFirstTimeAfterBoot = ETrue;
+//
+// CToolsProcess::NewL
+//
+CToolsProcess* CToolsProcess::NewL(const TDesC& aPath, const TDesC& aArgsUsb, const TDesC& aArgsXti)
+{
+    CToolsProcess* self = new(ELeave) CToolsProcess;
+    self->ConstructL(aPath, aArgsUsb, aArgsXti);
+    return self;
+}
+
+//
+// CTrkEngine::NewLC
+//
+CToolsProcess* CToolsProcess::NewLC(const TDesC& aPath, const TDesC& aArgsUsb, const TDesC& aArgsXti)
+{
+    CToolsProcess* self = new(ELeave) CToolsProcess;
+    CleanupStack::PushL(self);
+    
+    self->ConstructL(aPath, aArgsUsb, aArgsXti);
+    
+    return self;
+}
+
+//
+// CToolsProcess::ConstructL
+// Constructor
+//
+void CToolsProcess::ConstructL(const TDesC& aPath, const TDesC& aArgsUsb, const TDesC& aArgsXti) 
+{
+    iPath.Copy(aPath);
+    iArgsUsb.Copy(aArgsUsb);
+    iArgsXti.Copy(aArgsXti);
+}
+//
+// CToolsProcess::CToolsProcess
+// Constructor
+//
+CToolsProcess::CToolsProcess() 
+            : iRunning(EFalse),
+              iProcessTracker(NULL)
+{
+        
+}
+
+//
+// CToolsProcess::~CToolsProcess
+// Destructor
+//
+CToolsProcess::~CToolsProcess()
+{
+    SafeDelete(iProcessTracker);
+    iProcess.Close();
+}
+
+//
+// CToolsProcess::Start
+//
+TInt CToolsProcess::Start(TCmdLineConnType aConnType) 
+{
+    TBuf<KMaxCmdLineConnArgsLen> cmdConnArgs = _L("");
+    switch (aConnType)
+    {
+        case EUsb:
+            cmdConnArgs = iArgsUsb;
+            break;
+        case EXti:
+            cmdConnArgs = iArgsXti;
+            break;
+        default:
+            return KErrNotFound;
+    }
+  
+    TInt err = KErrNone;
+    // check to see if we have already launched or not.
+    // We only launch the first time and we track the process that we launched
+    // Also check to see if the process is already running or not.
+    // User could have manually launched the application in which case the user needs to 
+    // connect from the tool manually.
+    if (!iRunning)
+    {       
+        err = iProcess.Create(iPath, cmdConnArgs);  
+        if (!err)
+        {
+            iProcessId = iProcess.Id();     
+            iProcess.Resume();        
+          
+        }
+        if (!err)
+        {
+            iRunning = ETrue; //now the process is running..
+        }
+        
+        
+    }
+    
+    return err;
+}
+
+//
+// CToolsProcess::Stop
+//
+void CToolsProcess::Stop() 
+{
+    if (iRunning)
+    {
+        iRunning = EFalse;
+        iProcess.Kill(-1);
+        iProcess.Close();
+        SafeDelete(iProcessTracker);
+    }
+}
+
+//
+// CToolsProcess::Stop
+//
+void CToolsProcess::ProcessDied(TInt aExitReason) 
+{
+    iRunning = EFalse;
+    iProcess.Close();
+    SafeDelete(iProcessTracker);        
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolsserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+//  Include Files  
+
+#include "toolsserver.h"
+#include <e32base.h>
+#include <e32std.h>
+#include <e32cons.h>			// Console
+
+//  Constants
+
+_LIT(KTextConsoleTitle, "Console");
+_LIT(KTextFailed, " failed, leave code = %d");
+_LIT(KTextPressAnyKey, " [press any key]\n");
+
+//  Global Variables
+
+LOCAL_D CConsoleBase* console; // write all messages to this
+
+
+//  Local Functions
+
+LOCAL_C void MainL()
+    {
+    //
+    // add your program code here, example code below
+    //
+    console->Write(_L("Hello, world!\n"));
+    }
+
+LOCAL_C void DoStartL()
+    {
+    // Create active scheduler (to run active objects)
+    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
+    CleanupStack::PushL(scheduler);
+    CActiveScheduler::Install(scheduler);
+
+    MainL();
+
+    // Delete active scheduler
+    CleanupStack::PopAndDestroy(scheduler);
+    }
+
+//  Global Functions
+/*
+GLDEF_C TInt E32Main()
+    {
+    // Create cleanup stack
+    __UHEAP_MARK;
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+
+    // Create output console
+    TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(
+            KConsFullScreen, KConsFullScreen)));
+    if (createError)
+        return createError;
+
+    // Run application code inside TRAP harness, wait keypress when terminated
+    TRAPD(mainError, DoStartL());
+    if (mainError)
+        console->Printf(KTextFailed, mainError);
+    console->Printf(KTextPressAnyKey);
+    console->Getch();
+
+    delete console;
+    delete cleanup;
+    __UHEAP_MARKEND;
+    return KErrNone;
+    }
+
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolssrvmain.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <e32std.h>
+#include <e32debug.h>
+#include <f32file.h>
+// User includes
+
+#include "toolssrvscheduler.h"
+#include "toolssrvserver.h"
+
+
+#include "ToolsCmdCodes.h"
+
+void RunServerL();
+
+//
+// RunServerL()
+// Creates Tools server, signals the client and starts the server
+//
+
+void RunServerL()
+{
+	// Create and install the active scheduler we need
+	CToolsSrvScheduler* scheduler = CToolsSrvScheduler::NewLC();
+	if (scheduler == 0)
+		User::Leave(KErrNoMemory);
+		
+	CActiveScheduler::Install(scheduler);
+
+	// Create server
+	CToolsSrvServer::NewLC();
+
+	// Initialisation complete, now signal the client
+#ifdef EKA2
+	User::LeaveIfError(User::RenameThread(KToolsServerName));
+#else
+	User::LeaveIfError(RThread().RenameMe(KToolsServerName));
+#endif
+	RProcess::Rendezvous(KErrNone);
+	
+	// Ready to run
+	CActiveScheduler::Start();
+
+	// Cleanup the server and scheduler
+	CleanupStack::PopAndDestroy(2, scheduler);
+	
+}
+
+
+
+//
+// Main Entry Point
+//
+
+TInt E32Main()
+{
+	__UHEAP_MARK;
+	
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if (cleanup == 0)
+		User::Panic(_L("Tools Server failed to allocate CTrapCleanup"), __LINE__);
+	
+	TInt error = KErrNone;
+	
+	if (cleanup)
+	{
+		TRAP(error, RunServerL());
+		delete cleanup;
+	}
+	
+	if (error != KErrNone)
+	{
+		User::Panic(_L("Tools Server failed to start"), __LINE__);
+	}
+	
+	__UHEAP_MARKEND;
+
+	return error;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolssrvscheduler.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <e32base.h>
+
+// User includes
+#include "toolssrvscheduler.h"
+
+
+//
+// CToolsSrvScheduler (source)
+//
+
+//
+// CToolsSrvScheduler::CToolsSrvScheduler()
+//
+// Constructor
+//
+CToolsSrvScheduler::CToolsSrvScheduler()
+{
+}
+
+
+//
+// CToolsSrvScheduler::NewLC()
+//
+// Creates an instance of CToolsSrvScheduler
+//
+CToolsSrvScheduler* CToolsSrvScheduler::NewLC()
+{
+	CToolsSrvScheduler* self = new(ELeave) CToolsSrvScheduler();
+	CleanupStack::PushL(self);
+	return self;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolssrvserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,245 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "toolssrvserver.h"
+
+// System includes
+#include <e32base.h>
+
+// User includes
+#include "toolssrvsession.h"
+
+
+
+// Type definitions
+
+// Constants
+#define METROTRK_SID 0x200170BB
+// Enumerations
+
+// Classes referenced
+
+#ifdef EKA2
+//Only include these in the secured platform 
+#include "ToolsCmdCodes.h"
+
+const TUint KRangeCount = 2; 
+
+const TInt KOpCodeRanges[KRangeCount] = 
+{	
+	KCapabilityCustomCheck, 
+	EToolsCmdCodeLast,
+};
+
+
+const TUint8 KElementsIndex[KRangeCount] =
+{
+	CPolicyServer::ECustomCheck, 	//Custom check for the MetroTrk SID 	 0 - EToolsCmdCodeLast
+	CPolicyServer::ENotSupported, 	//Not Supported					 		 EToolsCmdCodeLast-End
+};
+
+const CPolicyServer::TPolicyElement KPolicyElements[] = 
+{ 
+	{_INIT_SECURITY_POLICY_S0(METROTRK_SID), CPolicyServer::EFailClient},
+};
+
+const CPolicyServer::TPolicy KToolsServerPolicy =
+{
+	CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
+	KRangeCount,
+	KOpCodeRanges,
+	KElementsIndex, 	// what each range is compared to 
+	KPolicyElements 	// what policies range is compared to
+};
+ 	
+#endif
+
+
+//
+// CToolsSrvServer (source)
+//
+
+//
+// CToolsSrvServer::CToolsSrvServer()
+//
+// Constructor
+//
+CToolsSrvServer::CToolsSrvServer()
+#ifdef  EKA2
+ 	:CPolicyServer(CActive::EPriorityHigh, KToolsServerPolicy),
+#else	
+   	:CServer2(CActive::EPriorityHigh),
+#endif
+iSessionCount(0)
+{
+}
+
+//
+// CToolsSrvServer::~CToolsSrvServer()
+//
+// Destructor
+//
+CToolsSrvServer::~CToolsSrvServer()
+{
+	// In order to prevent access violations as the server
+	// shuts down, we inform all sessions that the server is
+	// about to be destroyed
+	iSessionIter.SetToFirst();
+	//
+	CToolsSrvSession* session = static_cast<CToolsSrvSession*>(iSessionIter++);
+	while (session)
+	{
+		session->HandleServerDestruction();
+		session = static_cast<CToolsSrvSession*>(iSessionIter++);
+	}
+	if(iLaunchManager)
+	    delete iLaunchManager;
+	
+}
+
+//
+// CToolsSrvServer::ConstructL()
+//
+// Second level construction
+//
+void CToolsSrvServer::ConstructL()
+{
+	// Calling StartL here won't actually allow any connections
+	// to be created until the active scheduler has a chance to run. However, the 
+	// call below will leave should there already be a started Tools server instance.
+	//
+	StartL(KToolsServerName);
+	//Launching the tools
+	iLaunchManager = CToolsLaunchMgr::NewL();
+    if (iLaunchManager)
+        iLaunchManager->Launch();
+}
+
+//
+// CToolsSrvServer::NewLC()
+//
+// Creates an instance of CToolsSrvServer.
+//
+CToolsSrvServer* CToolsSrvServer::NewLC()
+{
+	CToolsSrvServer* self = new(ELeave) CToolsSrvServer();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+}
+
+//
+// CToolsSrvServer::NewSessionL()
+//
+// Creates a new session.
+// Called by the IPC framework everytime a client creates a new session.
+// Returns a CToolsSrvSession object.
+//
+CSession2* CToolsSrvServer::NewSessionL(const TVersion& aVersion,const RMessage2& /*aMessage*/) const
+{	
+	// Check client version is correct
+	const TVersion ToolsServerVersion(KToolsServerMajorVN, KToolsServerMinorVN, KToolsServerBuildVN);
+	if	(!User::QueryVersionSupported(ToolsServerVersion, aVersion))
+		User::Leave(KErrNotSupported);
+	
+	// Create new session
+	CToolsSrvSession* session = CToolsSrvSession::NewL();
+	return session;
+}
+
+//
+// CToolsSrvServer::RunError()
+//
+// Handles all the errors when handling a client request.
+// Called by the IPC framework whenever a leave occurs when handling a client request.
+// Returns KErrNone to complete the error handling.
+//
+TInt CToolsSrvServer::RunError(TInt aError)
+{
+	// A bad descriptor error implies a badly programmed client, so panic it;
+	// otherwise report the error to the client
+	if	(aError == KErrBadDescriptor)
+	{
+		Message().Panic(KServerIntiatedSessionPanic, EToolsServerInitiatedClientPanicBadDescriptor);
+	}
+	else
+	{
+		Message().Complete(aError);
+	}
+
+	// The leave will result in an early return from CServer2::RunL(), skipping
+	// the call to request another message. So do that now in order to keep the
+	// server running.
+	ReStart();
+
+	// Indicate that we've handled the error fully
+	return KErrNone;
+}
+	
+#ifdef EKA2	
+//
+// CToolsSrvServer::CustomSecurityCheckL()
+//
+// The only security check that is done is to check for the cleint securid 
+// Returns EFail or EPass
+//
+CPolicyServer::TCustomResult CToolsSrvServer::CustomSecurityCheckL(const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/)
+{
+	CPolicyServer::TCustomResult returnValue = CPolicyServer::EFail;	
+	
+	TSecureId ClientSID = aMsg.SecureId();
+	// We only permit MetroTrk to use this server. So we check
+	// for MetroTrk's SIDs. If its not MetroTrk's SIDs, then the security check fails.
+	if ((KTrkServerUid == ClientSID) || (KTraceServerUid == ClientSID) || (KToolsClientUid == ClientSID))
+	{
+		returnValue = CPolicyServer::EPass;
+	}			
+	return(returnValue);
+}
+#endif
+
+
+/**
+Decrements the server's count of how many sessions are connected to it and
+starts the shutdown timer if there are no sessions connected
+*/
+void CToolsSrvServer::SessionClosed()
+{
+    if(--iSessionCount < 1)
+    {
+        
+    }
+}
+
+/**
+Increments the servers count of how many sessions are connected to it and
+cancels the shutdown timer if it is running
+*/
+void CToolsSrvServer::SessionOpened()
+{
+    iSessionCount++;
+    
+}
+/*
+ * To get the USB connection status
+ * 
+ */
+TConnectionStatus CToolsSrvServer::GetUsbConnStatus()
+{
+   return(iLaunchManager->GetUsbConnStatus());
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolssrvsession.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,248 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "toolssrvsession.h"
+#include "toolssrvserver.h"
+// System includes
+
+//User Includes
+#include "ToolsCmdCodes.h"
+
+// Type definitions
+
+// Constants
+const TInt KToolsServerTransferBufferExpandSize = 100;
+const TInt KSlot0 = 0;
+
+// Enumerations
+
+// Classes referenced
+
+
+// Static functions
+//
+// Checks for a null'd handle before attempting complete. 
+// If handle is null'd then don't complete as this will panic server.
+//
+void SafeComplete(const RMessagePtr2& aMessage, TInt aCompletionCode)
+{
+    if(!aMessage.IsNull())
+    {
+        aMessage.Complete(aCompletionCode);
+    }
+}
+
+
+
+//
+// CToolsSrvSession (source)
+//
+
+//
+// CToolsSrvServer::CToolsSrvSession()
+//
+// Constructor
+//
+CToolsSrvSession::CToolsSrvSession()
+:   iPendingRead(EFalse),
+    iLaunchManager(NULL)
+{
+}
+
+//
+// CToolsSrvServer::~CToolsSrvSession()
+//
+// Destructor
+//
+CToolsSrvSession::~CToolsSrvSession()
+{
+	HandleServerDestruction();
+	delete iTransferBuffer;
+	//get a reference to the server
+	CToolsSrvServer* toolsserver = (CToolsSrvServer*)Server();
+	
+	//notify the server that the session has been opened
+	if (toolsserver != NULL)
+	    toolsserver->SessionClosed();
+	if(iLaunchManager)
+	    iLaunchManager->UnregisterListener(this);
+}
+
+//
+// CToolsSrvServer::ConstructL()
+//
+// Creates an instance of CToolsSrvSession.
+//
+void CToolsSrvSession::ConstructL()
+{
+    iTransferBuffer = CBufFlat::NewL(KToolsServerTransferBufferExpandSize);
+}
+
+//
+//  CToolsSrvSession::CreateL()
+//
+void CToolsSrvSession::CreateL()
+{
+    //get a reference to the server
+    CToolsSrvServer* toolsserver = (CToolsSrvServer*)Server();
+    
+    //notify the server that the session has been opened
+    if (toolsserver != NULL)
+    {
+        toolsserver->SessionOpened();
+        iLaunchManager = toolsserver->GetLaunchInterface();
+    }
+  
+}
+//
+// CToolsSrvServer::NewL()
+//
+// Static self construction
+//
+CToolsSrvSession* CToolsSrvSession::NewL()
+{
+	CToolsSrvSession* self = new(ELeave) CToolsSrvSession();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+}
+
+//
+// CToolsSrvServer::HandleServerDestruction()
+//
+// Called by the server's destructor. We need to be told that the server is
+// being destroyed.
+//
+void CToolsSrvSession::HandleServerDestruction()
+{
+}
+
+//
+// CToolsSrvServer::ServiceL()
+//
+// Services requests from a client.
+// Called by the IPC framework whenever a client sends a request to the server.
+//
+void CToolsSrvSession::ServiceL(const RMessage2& aMessage)
+{
+
+    const TInt cmd = aMessage.Function();
+
+	switch(cmd)
+	{
+		case EToolsCmdCodeGetUsbConnStatus:
+			 CmdGetUsbConnStatus(aMessage);
+			break;
+		case EToolsCmdCodeConnNotify:
+			CmdConnNofify(aMessage);
+			break;
+		case EToolCmdCodeConnNotifyCancel:
+			CmdConnNotifyCancel(aMessage);
+			break;		
+		case EToolsCmdCodeShutDownServer:
+			CmdShutDownServer();			
+			break;
+	
+		default:
+			aMessage.Panic(KServerIntiatedSessionPanic, EToolsServerInitiatedClientPanicInvalidOperation);
+			break;
+	}
+		
+}
+
+//
+//  CToolsSrvSession::CmdGetUsbConnStatus      
+//
+//  Command implementation to find out the usb connection status
+//
+void CToolsSrvSession::CmdGetUsbConnStatus(const RMessage2& aMessage)
+{
+    TConnectionStatus status = iLaunchManager->GetUsbConnStatus();
+    TPckg<TConnectionStatus> package(status);
+    TRAPD(err,aMessage.Write(KSlot0,package)); 
+    if (err != KErrNone)
+    {
+        aMessage.Panic(_L("ToolsServer"),2);
+    }
+    SafeComplete(aMessage,KErrNone);
+}
+//
+//  CToolsSrvSession::CmdConnNofify      
+//
+//  To register for usb cable connection notifications
+//
+void CToolsSrvSession::CmdConnNofify(const RMessage2& aMessage)
+{   
+    if (iPendingRead)
+    {   
+        SafeComplete(aMessage, KErrAlreadyExists);
+    }
+    else
+    {
+        iLaunchManager->RegisterListener(this);
+        iBlockedRead = aMessage;
+        iPendingRead = ETrue;     
+        
+    }   
+}
+//
+//  CToolsSrvSession::CmdConnNotifyCancel      
+//
+//  To unregister for usb cable connection notifications
+//
+void CToolsSrvSession::CmdConnNotifyCancel(const RMessage2& aMessage)
+{
+    if ( iPendingRead && iBlockedRead.Handle())
+    {
+        SafeComplete(iBlockedRead, KErrCancel);
+        iPendingRead = EFalse;
+        iLaunchManager->UnregisterListener(this);
+    }
+    SafeComplete(aMessage, KErrNone);
+}
+
+//
+//  CToolsSrvSession::ConnStatusChanged
+//
+//  Called when the usb cable connection changes
+//
+void CToolsSrvSession::ConnStatusChanged(TConnectionStatus aStatus)
+{
+    if(iPendingRead && iBlockedRead.Handle())
+    {
+        iPendingRead = EFalse;
+        TConnectionStatus status = aStatus;
+        TPckg<TConnectionStatus> package(status);
+        TRAPD(err, iBlockedRead.WriteL(KSlot0, package));  
+        if ( err != KErrNone )
+        {
+            iBlockedRead.Panic(_L("ToolsServer"),2);
+        }
+        SafeComplete(iBlockedRead,KErrNone);
+    }
+       
+}
+//
+// CToolsSrvServer::CmdShutDownServer()
+//
+// Stops the active scheduler. This way, server process will run to completion.
+//
+void CToolsSrvSession::CmdShutDownServer()
+{
+	CActiveScheduler::Stop();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/toolsstarter/toolsstarterserver/src/toolsusbportlistener.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,181 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+// INCLUDE FILES
+#include <e32std.h>                      
+#include "toolsusbportlistener.h" 
+                   
+// LOCAL FUNCTION PROTOTYPES
+
+// LOCAL CONSTANTS
+
+const TUint KUsbDeviceStateMask				= 0x00ff;
+#define KPersonalityPCSuite               113
+#define KPersonalityPCSuiteMTP            5
+
+//
+// CToolsUsbPortListener::CToolsUsbPortListener
+// Constructor
+//
+CToolsUsbPortListener::CToolsUsbPortListener (MToolsConnectionListener *aConnectionListener) 
+		  	  :CToolsCommPortListener(aConnectionListener, CActive::EPriorityStandard)
+{
+	iUsbDeviceState = EUsbDeviceStateUndefined;
+	iConnected = EFalse;
+	iPersonalityId = 0;
+    
+    // For platsim, getting the USB device state is not supported.
+    // Infact it panics the server, so don't bother with the USB state for platsim.
+#ifndef __PLATSIM__    
+    TInt err = iUsbServer.Connect();
+    
+    err = iUsbServer.GetDeviceState( iUsbDeviceState );
+    if (!err)
+    	err = iUsbServer.GetCurrentPersonalityId( iPersonalityId );
+    
+    if (!err && iUsbDeviceState == EUsbDeviceStateConfigured
+    		 && iPersonalityId == KPersonalityPCSuiteMTP)
+    		 iConnected = ETrue;
+
+    CActiveScheduler::Add( this ); 
+#endif
+
+}
+
+//
+// CToolsUsbPortListener::~CToolsUsbPortListener
+// Destructor
+//
+CToolsUsbPortListener::~CToolsUsbPortListener()
+{
+#ifndef __PLATSIM__
+    Cancel();   // Ensure that any outstanding requests are cancelled
+    Deque();
+    iUsbServer.Close();
+#endif    
+}
+
+//
+// CToolsUsbPortListener::ListenL
+// Starts listening for usb connection status notifications..
+//
+void CToolsUsbPortListener::ListenL()
+{		
+	IssueRequestL();		
+}
+
+//
+// CToolsUsbPortListener::IsConnectionAvailable
+//
+TBool CToolsUsbPortListener::IsConnectionAvailable()
+{		
+#ifndef __PLATSIM__		
+	TInt err = iUsbServer.GetDeviceState( iUsbDeviceState );
+    if (!err)
+    	err = iUsbServer.GetCurrentPersonalityId( iPersonalityId );
+    	
+    if (!err && iUsbDeviceState == EUsbDeviceStateConfigured
+    		 && iPersonalityId == KPersonalityPCSuiteMTP)
+    {
+		iConnected = ETrue;     
+		return ETrue;
+    }
+#endif      
+    return EFalse;
+}
+
+//
+// CToolsUsbPortListener::IssueRequestL
+//
+void CToolsUsbPortListener::IssueRequestL()
+{		
+#ifndef __PLATSIM__		
+	if ( iUsbDeviceState == EUsbDeviceStateUndefined )
+	{
+		User::LeaveIfError( iUsbServer.GetDeviceState( iUsbDeviceState ) );		
+	}
+	
+	iUsbServer.DeviceStateNotification(KUsbDeviceStateMask, iUsbDeviceState, iStatus);
+	SetActive();	
+#endif		
+}
+
+//
+// CToolsUsbPortListener::StopListening
+// Cancel any pending requests for connection status notifications.
+//
+void CToolsUsbPortListener::StopListening()
+{
+	Cancel();	
+}
+
+//
+// CToolsUsbPortListener::DoCancel
+// This method gets called from CActive::Cancel();
+//
+void CToolsUsbPortListener::DoCancel()
+{
+#ifndef __PLATSIM__		
+	iUsbServer.DeviceStateNotificationCancel();	
+#endif	
+	iUsbDeviceState = EUsbDeviceStateUndefined;
+}
+
+//
+// CToolsUsbPortListener::RunL
+// This method gets called whenever there is a change in the connection status.
+// Right now we are interested only when the cable is disconnected. 
+// For all the other notifications, just reissues the request.
+//
+void CToolsUsbPortListener::RunL()
+{
+#ifndef __PLATSIM__		
+	User::LeaveIfError( iStatus.Int() );
+
+	iUsbServer.GetCurrentPersonalityId( iPersonalityId );
+	
+    if ( iUsbDeviceState == EUsbDeviceStateUndefined ||
+         (iUsbDeviceState == EUsbDeviceStateConfigured && iPersonalityId != KPersonalityPCSuiteMTP) ) 
+	{
+		iConnectionListener->ConnectionUnAvailable();
+		iConnected = EFalse;
+	}
+	// There is something wrong with USB cable status notifications
+	// When the cable is disconnected, first you get a notification 
+	// with the device state as configured.
+	// So we need to work around using a local status flag
+	else if ( iUsbDeviceState == EUsbDeviceStateConfigured &&
+			  iPersonalityId == KPersonalityPCSuiteMTP  && 
+			  !iConnected) 
+	{
+		iConnected = ETrue;
+		iConnectionListener->ConnectionAvailable();;
+	}
+		
+	IssueRequestL();	
+#endif		
+}
+
+TConnectionStatus CToolsUsbPortListener::GetUsbConnStatus()
+{   
+    if(iConnected)
+        return EUsbConnected;
+    
+    return EUsbNotConnected;
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trklauncher/0x200159DC.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <registryinfo.rh>
+
+RESOURCE REGISTRY_INFO r_registry
+	{
+	dll_uid = 0x200159DC; //should match name of this file
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x101F7D87;
+			implementations =
+			 {
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x200159DC;
+					version_no = 1;
+					display_name = "TrkLauncher";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trklauncher/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trklauncher/trkdummyrecognizer.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+// trkdummyrecognizer.cpp
+//
+
+// system includes
+#include <apmrec.h>
+#include <apmstd.h>
+#include <eikenv.h>
+// local includes
+#include "trkdummyrecognizer.h"
+
+// constants
+const TInt KNumDataTypesSupported = 1;
+const TInt KMaxBufferLength = 4;
+const TInt KDummyRecognizerValue = 0x200159DC;
+const TUid KUidDummyRecognizer = {KDummyRecognizerValue};
+_LIT8(KDataTypeDummy, "text/vnd.nokia.trklauncherrec");
+
+//
+// CTrkDummyRecognizer
+//
+CTrkDummyRecognizer::CTrkDummyRecognizer()
+:CApaDataRecognizerType(KUidDummyRecognizer, CApaDataRecognizerType::ENormal)
+{
+	iCountDataTypes = KNumDataTypesSupported;
+}
+
+TUint CTrkDummyRecognizer::PerferredBufSize()
+{
+	return KMaxBufferLength;
+}
+
+TDataType CTrkDummyRecognizer::SupportedDataTypeL(TInt /*aIndex*/) const
+{
+	return TDataType(KDataTypeDummy);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trklauncher/trkdummyrecognizer.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+// trkdummyrecognizer.h
+//
+
+#ifndef TRKDUMMYRECOGNIZER_H
+#define TRKDUMMYRECOGNIZER_H
+
+#include <apmrec.h>
+
+class CTrkDummyRecognizer : public CApaDataRecognizerType
+{
+public:
+	CTrkDummyRecognizer();
+
+public:
+	// from CApaDataRecognizerType
+	TUint PerferredBufSize();
+	TDataType SupportedDataTypeL(TInt aIndex) const;
+	//swagata
+	#ifdef __UI_FRAMEWORKS_V2__
+	static CApaDataRecognizerType* NewL();
+	#endif //__UI_FRAMEWORKS_V2__
+
+};
+
+#endif // TRKDUMMYRECOGNIZER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trklauncher/trklauncher.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,144 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <e32debug.h>
+
+// system includes
+#include <e32std.h>
+#include <eikenv.h>
+
+// local includes
+#include "trkdummyrecognizer.h"
+#ifdef __UI_FRAMEWORKS_V2__
+#include <implementationproxy.h>
+#endif //__UI_FRAMEWORKS_V2__
+
+// constants
+_LIT(KTrkConsoleExe, "trkconsole.exe");
+
+const TUid KTrkConsoleExeUid={0x200159E2}; // 
+
+
+TBool IsAlreadyRunning()
+{
+	RDebug::Print(_L("TrkLauncher::IsAlreadyRunning()"));
+
+	_LIT(KTrkConsoleSearchPattern, "*TRKPROCESS*");
+	_LIT(KTrkConsoleProcessPattern, "*");
+	
+	TFindProcess finder;
+	TFullName fullName;
+	TBool found = EFalse;
+	finder.Find(KTrkConsoleProcessPattern);
+
+	while (!found && finder.Next(fullName) == KErrNone)
+	{
+		fullName.UpperCase();
+		
+		if (fullName.Match(KTrkConsoleSearchPattern) != KErrNotFound)
+		{
+			found = ETrue;
+			RDebug::Print(_L("process found Inside while"));
+			break;
+		}
+	}
+
+	if (found)
+	{
+		RDebug::Print(_L("TrkLauncher - Process found outside while"));
+	}
+	else
+	{
+		RDebug::Print(_L("TrkLauncher - Process was never found"));
+	}
+		
+	return found;
+}
+
+void HandleStart()
+{
+	RDebug::Print(_L("TrkLauncher::HandleStart()"));
+	
+	if (!IsAlreadyRunning())
+	{		
+		TInt result;		
+		RProcess p;
+		
+		//start TrkConsole	process
+		result = p.Create(KTrkConsoleExe, TPtr(NULL, 0), TUidType(KNullUid, KNullUid, KTrkConsoleExeUid));
+		if (result == KErrNone)
+		{
+			RDebug::Print(_L("TrkLauncher - Trk process resume"));
+			p.Resume();
+			RDebug::Print(_L("TrkLauncher - After Trk process resume"));
+			p.Close();
+			RDebug::Print(_L("TrkLauncher - After Trk process close"));
+		}
+		else
+		{
+			RDebug::Print(_L("TrkLauncher - Trk process not created with %d \n"),result);
+			RDebug::Print(_L("TrkLauncher - Returning without process creation"));
+		}
+			
+	}
+}
+	
+#ifdef __UI_FRAMEWORKS_V2__
+
+const TImplementationProxy ImplementationTable[]=
+{
+    IMPLEMENTATION_PROXY_ENTRY(0x1020814D, CTrkDummyRecognizer::NewL)
+};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+{
+    RDebug::Print(_L("TrkLauncher::ImplementationGroupProxy(aTableCount=%d)"), aTableCount);
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+}
+
+CApaDataRecognizerType* CTrkDummyRecognizer::NewL()
+{
+	RDebug::Print(_L("TrkLauncher::CTrkDummyRecognizer::NewL()"));
+    CApaDataRecognizerType *recog = new CTrkDummyRecognizer(); // no (ELeave) as return NULL is OK
+   
+    RDebug::Print(_L("TrkLauncher - Before HandleSart()"));
+    HandleStart(); 
+    
+    return recog;
+}
+
+#else
+	
+EXPORT_C CApaDataRecognizerType* CreateRecognizer()
+{
+	CApaDataRecognizerType* recog = new CTrkDummyRecognizer(); // no (ELeave) as return NULL is OK
+
+	HandleStart();
+
+	return recog;
+}
+#endif //__UI_FRAMEWORKS_V2__
+
+#ifndef EKA2
+
+GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
+{
+	RDebug::Print(_L("MCLauncher::E32Dll()"));
+	return KErrNone;
+}
+#endif // EKA2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trklauncher/trklauncher_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+// trklauncher.mmp
+//
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+OPTION CW   -w off
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+   	SYSTEMINCLUDE	\epoc32\include
+	SYSTEMINCLUDE	\epoc32\include\oem        
+#else
+    MW_LAYER_SYSTEMINCLUDE
+#endif
+
+
+TARGET trklauncher.dll
+TARGETTYPE plugin
+UID			0x10009D8D 0x200159DC
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+systeminclude   	\epoc32\include\ecom
+#else
+systeminclude   	/epoc32/include/ecom
+#endif
+
+start resource 0x200159DC.rss
+#ifdef SYMBIAN_SECURE_ECOM
+TARGET trklauncher.rsc
+#endif
+end
+
+
+VENDORID VID_DEFAULT
+
+CAPABILITY ALL -TCB -DRM
+
+SOURCE		trklauncher.cpp 
+SOURCE		trkdummyrecognizer.cpp
+
+LIBRARY		EUSER.LIB apmime.lib efile.lib efsrv.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trklauncher/trklauncher_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+// trklauncher.mmp
+//
+
+OPTION CW   -w off
+
+SYSTEMINCLUDE	/epoc32/include
+systeminclude   /epoc32/include/ecom
+
+USERINCLUDE	.
+
+
+TARGET trklauncher.dll
+TARGETTYPE plugin
+UID			0x10009D8D 0x200159DC
+
+start resource 0x200159DC.rss
+#ifdef SYMBIAN_SECURE_ECOM
+TARGET trklauncher.rsc
+#endif
+end
+
+
+
+VENDORID 0x101FB657
+
+CAPABILITY ALL -TCB -DRM
+
+SOURCE		trklauncher.cpp 
+SOURCE		trkdummyrecognizer.cpp
+
+LIBRARY		EUSER.LIB apmime.lib efile.lib efsrv.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/toolsconnectionlistener.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "toolsconnectionlistener.h"
+#include <e32debug.h>
+
+//
+//----------------------------------------------------
+// CToolsConnectionListener::NewL()
+// To create the instance
+//----------------------------------------------------
+//
+CToolsConnectionListener* CToolsConnectionListener :: NewL(MTrkUsbConnectionListener* aListener)
+{
+    CToolsConnectionListener* self = new (ELeave) CToolsConnectionListener();
+    CleanupStack::PushL(self);
+    self->ConstructL(aListener);
+    CleanupStack::Pop(self);
+    return self;   
+}
+//
+//----------------------------------------------------
+// CToolsConnectionListener::ConstructL()
+// 2nd phase constructor
+//----------------------------------------------------
+//
+void CToolsConnectionListener::ConstructL(MTrkUsbConnectionListener* aListener)
+{
+    User::LeaveIfError( iToolSession.Connect() );
+    iConnectionListener = aListener;
+}
+//
+//----------------------------------------------------
+// CToolsConnectionListener::CToolsConnectionListener()
+// 1st phase constructor
+//----------------------------------------------------
+//
+CToolsConnectionListener::CToolsConnectionListener()
+    : CActive(EPriorityStandard),
+    iPackage(iConnStatus),
+    iConnectionListener(NULL)
+   
+{   
+    CActiveScheduler::Add(this);
+}
+//
+//----------------------------------------------------
+// CToolsConnectionListener::~CToolsConnectionListener()
+// Desctructor
+//----------------------------------------------------
+//
+CToolsConnectionListener::~CToolsConnectionListener() 
+{   
+    Cancel();
+    iToolSession.Close();
+}
+//
+//----------------------------------------------------
+// CToolsConnectionListener::StartListening()
+// To issue the asynchronous request
+//----------------------------------------------------
+//
+
+void CToolsConnectionListener::StartListening()
+{
+    iToolSession.UsbConnNotify(iPackage, iStatus);    
+    SetActive();
+}
+//
+//----------------------------------------------------
+// CToolsConnectionListener::StartListening()
+// To stop the asynchronous request
+//----------------------------------------------------
+//
+void CToolsConnectionListener::StopListening()
+{
+    DoCancel();  
+    
+}
+//
+//----------------------------------------------------
+// CToolsConnectionListener::RunL()
+// RunL implementation
+//----------------------------------------------------
+//
+void CToolsConnectionListener::RunL()
+{
+    if(iStatus==KErrNone)
+    {
+        switch(iConnStatus)
+        {   
+            case EUsbConnected:
+            {  
+                if(iConnectionListener)
+                    iConnectionListener->ConnectionAvailable();
+                break;
+            }
+            case EUsbNotConnected:
+            {
+                if(iConnectionListener)
+                    iConnectionListener->ConnectionUnAvailable();
+                break;
+            }
+                
+            default:
+                break;
+            
+         }
+     }
+    
+    StartListening();
+       
+}
+
+//
+//----------------------------------------------------
+// CToolsConnectionListener::DoCancel()
+// 
+//----------------------------------------------------
+//
+
+void CToolsConnectionListener::DoCancel()
+{
+    iToolSession.UsbConnNotifyCancel();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/toolsconnectionlistener.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef TOOLSCONNECTIONLISTENER_H_
+#define TOOLSCONNECTIONLISTENER_H_
+
+#include <toolsclientsession.h>
+#include "TrkUsbConnectionListener.h"
+
+
+class CToolsConnectionListener:public CActive
+{
+    public:
+        
+        static CToolsConnectionListener* NewL(MTrkUsbConnectionListener* aListener);
+        void   ConstructL(MTrkUsbConnectionListener* aListener );
+        void   StartListening();
+        void   StopListening();
+        
+        ~CToolsConnectionListener();
+        
+        
+    private:
+        
+        CToolsConnectionListener();
+        
+    protected:
+        
+        void RunL();        
+        void DoCancel();
+        
+    private:
+        
+        RToolsClientSession iToolSession;
+        TConnectionStatus iConnStatus;
+        TConnPkg iPackage;      
+        MTrkUsbConnectionListener* iConnectionListener;
+    
+};
+
+
+
+
+
+#endif /* USBCONNECTIONLISTENER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trkdebugmanager.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,390 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "trkdebugmgrcallbacks.h"
+#include "trkdebugmanager.h"
+#ifndef __TEXT_SHELL__
+#include "DebugNotifier.h"
+#endif
+// System includes
+#include <e32debug.h>
+
+//Constants
+#ifndef __TEXT_SHELL__
+_LIT(KLibraryName, "DebugNotifier.dll");
+#endif
+
+#define SafeDelete(x) { if (x) delete x; x = NULL; }
+
+//
+// CTrkDebugManager (source)
+//
+
+//
+// CTrkDebugManager::CTrkDebugManager()
+//
+// Constructor
+//
+CTrkDebugManager::CTrkDebugManager() : iTrkEngine(NULL), iConnStatus(ETrkNotConnected), iDebugging(EFalse), iPlugAndPlay(ETrue),
+                                       iDebugMgrCallback(NULL)
+#ifndef __TEXT_SHELL__                                       
+, iToolsConnectionListener(NULL)
+#endif
+{
+    
+}
+
+//
+// CTrkDebugManager::~CTrkDebugManager()
+//
+// Destructor
+//
+CTrkDebugManager::~CTrkDebugManager()
+{
+    StopListening();
+#ifndef __TEXT_SHELL__
+    SafeDelete(iToolsConnectionListener);
+#endif
+    SafeDelete(iTrkEngine);
+}
+
+//
+// CTrkDebugManager::ConstructL()
+//
+// Second level constructor
+//
+void CTrkDebugManager::ConstructL()
+{	
+	iTrkEngine = CTrkEngine::NewL(this);
+#ifndef __TEXT_SHELL__
+	TRAPD(err,iToolsConnectionListener = CToolsConnectionListener::NewL(this));
+	if(!err)
+	iToolsConnectionListener->StartListening();
+#endif
+}
+
+//
+// CTrkDebugManager::NewL()
+//
+// Creates an instance of CTrkDebugManager
+//
+CTrkDebugManager* CTrkDebugManager::NewL()
+{
+	CTrkDebugManager* self = new(ELeave) CTrkDebugManager();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+}
+
+
+//
+// CTrkDebugManager::NewLC()
+//
+// Creates an instance of CTrkDebugManager
+//
+CTrkDebugManager* CTrkDebugManager::NewLC()
+{
+	CTrkDebugManager* self = new(ELeave) CTrkDebugManager();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	
+	return self;
+}
+//
+// CTrkDebugManager::StartDebugging()
+//
+// This method is to start debugging when the connection changes and also to handle command line arguments
+//
+void CTrkDebugManager::StartDebuggingL(TTrkConnType aConnType)
+{   
+    TRAPD(error, iTrkEngine->StartL(aConnType));
+    
+    if (error != KErrNone)
+    {
+        iTrkEngine->GetErrorInfo(iConnMsg);
+        iConnStatus = ETrkNotConnected;
+        iTrkEngine->Stop();
+    }
+    else
+    {
+        iTrkEngine->GetConnectionInfo(iConnMsg);
+        iConnStatus = ETrkConnected;
+    }
+    User::Leave(error);
+}
+//
+// CTrkSrvScheduler::StartDebuggingL()
+//
+// This method is to start debugging with the bluetooth connection
+//
+void CTrkDebugManager::StartDebuggingL()
+{	
+	TRAPD(error, iTrkEngine->StartL());
+
+	if (error != KErrNone)
+	{
+		iTrkEngine->GetErrorInfo(iConnMsg);
+		iConnStatus = ETrkNotConnected;
+		iTrkEngine->Stop();
+	}
+	else
+	{
+		iTrkEngine->GetConnectionInfo(iConnMsg);
+		iConnStatus = iTrkEngine->GetConnectionStatus();
+	}
+}
+//
+// CTrkSrvScheduler::StopDebugging()
+//
+// This method is to stop the debugging
+//
+void CTrkDebugManager::StopDebugging()
+{   
+	iTrkEngine->Stop();
+	iConnStatus = ETrkNotConnected;
+	iConnMsg = KNullDesC;
+}
+//
+// CTrkSrvScheduler::StopDebugging()
+//
+// To get the version info of TRK
+//
+void CTrkDebugManager::GetVersion(TTRKVersion& aVersion)
+{
+	iTrkEngine->GetVersionInfo(aVersion.iMajor, aVersion.iMinor, aVersion.iMajorAPI, aVersion.iMinorAPI, aVersion.iBuild);
+}
+//
+// CTrkSrvScheduler::GetConnectionMsg()
+//
+// To find out the connection msg 
+//
+void CTrkDebugManager::GetConnectionMsg(TDes& aConnStatusMsg)
+{
+    aConnStatusMsg = iConnMsg;        
+}
+
+//
+// CTrkDebugManager::ConnectToDebuggerL()
+//
+void CTrkDebugManager::ConnectToDebuggerL()
+{	
+    StartDebuggingL();
+}
+
+//
+// CTrkSrvScheduler::DisConnect()
+//
+void CTrkDebugManager::DisConnect()
+{
+    StopDebugging();
+}
+
+//
+// CTrkDebugManager::GetCurrentConnData()
+//
+void CTrkDebugManager::GetCurrentConnData(TTrkConnData& aConnData)
+{
+    iTrkEngine->GetConnectionData(aConnData);
+}
+
+//
+//CTrkDebugManager::SetCurrentConnData()
+//
+void CTrkDebugManager::SetCurrentConnData(TTrkConnData& aConnData)
+{
+    iTrkEngine->SetConnectionData(aConnData);
+}
+//
+// CTrkDebugManager::IsDebugging()
+// returns whether debugging started or not
+//
+TBool CTrkDebugManager::IsDebugging()
+{
+    iDebugging = iTrkEngine->IsDebugging();
+    return iDebugging;
+}
+//
+// CTrkDebugManager::GetPlugAndPlayOption()
+// returns whether the plug and play is set or not
+//
+TBool CTrkDebugManager::GetPlugAndPlayOption()
+{   
+    return iPlugAndPlay;
+    
+}
+//
+// CTrkDebugManager::SetPlugAndPlayOption()
+// To set the plug and play option 
+//
+void CTrkDebugManager::SetPlugAndPlayOption(TBool aPlugAndPlay)
+{
+    iPlugAndPlay = aPlugAndPlay;
+    
+}
+// ----------------------------------------------------
+// CTrkDebugManager::OnConnection
+// Called when a connection is opened, right now nothing is done
+// as connection is always established from the user side.
+// This call would be useful when we add for connecting automatically 
+// when a USB cable is plugged in while TRK is running.
+// ----------------------------------------------------
+//
+void CTrkDebugManager::OnConnection()
+{
+    iConnStatus = ETrkConnected;
+    iTrkEngine->GetConnectionInfo(iConnMsg);
+    if (iDebugMgrCallback)
+         iDebugMgrCallback->DebugConnStatusChanged(iConnStatus);
+}
+
+// ----------------------------------------------------
+// CTrkDebugManager::OnCloseConnection
+// Called when a connection is closed, update any of the UI clients.
+// ----------------------------------------------------
+//
+void CTrkDebugManager::OnCloseConnection()
+{   
+    iConnStatus = ETrkNotConnected;
+    if (iDebugMgrCallback)
+          iDebugMgrCallback->DebugConnStatusChanged(iConnStatus);
+}
+
+//
+// ----------------------------------------------------
+// CTrkDebugManager::DebuggingStarted
+// Called when a debug session is started.
+// ----------------------------------------------------
+//
+void CTrkDebugManager::DebuggingStarted()
+{
+    iDebugging = ETrue;
+    if (iDebugMgrCallback)
+        iDebugMgrCallback->DebuggingStatusChanged(iDebugging);
+}
+
+//
+// ----------------------------------------------------
+// CTrkDebugManager::DebuggingEnded
+// Called when a debug session is ended.
+// ----------------------------------------------------
+//
+void CTrkDebugManager::DebuggingEnded()
+{
+    iDebugging = EFalse;
+    if (iDebugMgrCallback)
+        iDebugMgrCallback->DebuggingStatusChanged(iDebugging);
+}
+
+//
+//----------------------------------------------------
+//CTrkDebugManager::OnAsyncConnectionFailed()
+//Called when bluetooth connection falied
+//----------------------------------------------------
+//
+void CTrkDebugManager::OnAsyncConnectionFailed()
+{
+    
+    iConnStatus = ETrkConnectionError;
+    iTrkEngine->GetErrorInfo(iConnMsg);
+    if (iDebugMgrCallback)
+          iDebugMgrCallback->DebugConnStatusChanged(iConnStatus);
+    
+}
+
+//
+//----------------------------------------------------
+// CTrkDebugManager::ConnectionAvailable()
+// Called when the usb connection available
+//----------------------------------------------------
+//
+void CTrkDebugManager::ConnectionAvailable()
+{   
+    iPlugAndPlay = iTrkEngine->GetPlugPlaySetting(); 
+  
+    if(!iDebugging && iPlugAndPlay)
+    {   
+       StopDebugging();
+       TRAPD(error, StartDebuggingL(ETrkUsbDbgTrc));
+        if (!error)
+        {   
+            TRAP(error, NotifyTheUserL());           
+        } 
+            if (iDebugMgrCallback)
+                iDebugMgrCallback->DebugConnStatusChanged(iConnStatus);
+        }       
+}
+
+//
+//----------------------------------------------------
+// CTrkDebugManager::ConnectionUnAvailable()
+// Called when the usb cable is disconnected
+//----------------------------------------------------
+//
+void CTrkDebugManager::ConnectionUnAvailable()
+{   
+    TTrkConnType connType = iTrkEngine->GetConnectionType();
+    if(connType == ETrkUsbDbgTrc)
+    {
+        StopDebugging();
+        TRAPD(error, StartDebuggingL(ETrkXti));
+        if (!error)
+        {   
+            // Nothing to do for now                       
+        }
+        if (iDebugMgrCallback)
+            iDebugMgrCallback->DebugConnStatusChanged(iConnStatus);
+    }    
+}
+
+//
+//----------------------------------------------------
+// CTrkDebugManager::NotifyTheUser()
+// To notify the user that debug services have started
+//----------------------------------------------------
+//
+void CTrkDebugManager::NotifyTheUserL()
+{
+#ifndef __TEXT_SHELL__
+    RLibrary library;
+    // Dynamically load DLL
+    TInt err = library.Load(KLibraryName);
+    if(!err)
+    {
+        TLibraryFunction entry=library.Lookup(1);
+        IDebugNotifier* notify =(IDebugNotifier*)entry();
+        CleanupStack::PushL(notify);
+        notify->NotifyTheUserL();
+        CleanupStack::PopAndDestroy();
+        // Finished with the DLL
+        library.Close();
+    }
+#endif    
+}
+//
+//----------------------------------------------------
+// CTrkDebugManager::StopListening()
+// To stop listening to cable connections
+//----------------------------------------------------
+//
+void CTrkDebugManager::StopListening()
+{    
+#ifndef __TEXT_SHELL__
+    if(iToolsConnectionListener)
+    iToolsConnectionListener->StopListening();
+#endif
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trkdebugmanager.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkDebugManager_h__
+#define __TrkDebugManager_h__
+
+// System includes
+#include <e32base.h>
+#include <f32file.h>
+
+// User includes
+#include "TrkEngine.h"
+#include "trksrvcmdcodes.h"
+#ifndef __TEXT_SHELL__
+#include "toolsconnectionlistener.h"
+#endif
+// Classes referenced
+class MTrkDebugMgrCallbacks;
+
+//
+// CTrkDebugManager (header)
+//
+// The underlying engine used by each session. Manipulates the server-side objects.
+//
+class CTrkDebugManager : public CBase, public MTrkEngineCallback , public MTrkUsbConnectionListener
+{
+	//Static construct and destruct
+	public:
+		static 	CTrkDebugManager*	NewLC();
+		static 	CTrkDebugManager*	NewL();
+				~CTrkDebugManager();
+	
+
+	//methods implementing the server cmds functionality
+	public:	
+		void 	StartDebuggingL();
+		void    StartDebuggingL(TTrkConnType aConnType);
+		void 	StopDebugging();
+		void	GetVersion(TTRKVersion& aVersion);
+		void    GetConnectionMsg(TDes& aConnStatusMsg);
+		void	ConnectToDebuggerL();
+		void	DisConnect();
+		void    GetCurrentConnData(TTrkConnData& aConnData);
+		void    SetCurrentConnData(TTrkConnData& aConnData);
+	    TBool   IsConnected() { return (iConnStatus == ETrkConnected); }
+		TTrkConnStatus GetConnectionStatus(){return iConnStatus;};
+	    TBool   IsDebugging();
+	    TBool   GetPlugAndPlayOption();
+	    void    SetPlugAndPlayOption(TBool aPlugAndPlay);
+	    
+	    void    SetDebugMgrCallback(MTrkDebugMgrCallbacks* aDebugMgrCallback) { iDebugMgrCallback = aDebugMgrCallback; }
+	    void    NotifyTheUserL();
+	    void    StopListening();
+	
+	public: // methods from MTrkEngineCallback
+	    void    OnConnection(); 
+	    void    OnCloseConnection();
+	    void    DebuggingStarted();
+	    void    DebuggingEnded();
+	    void    OnAsyncConnectionFailed();
+	    
+	public: //Methods from  public MTrkUsbConnectionListener
+	    void   ConnectionAvailable();
+	    void   ConnectionUnAvailable();
+	    	    
+    //private construct
+    private:
+                CTrkDebugManager();
+        void    ConstructL();
+
+	//date members
+	private:
+		CTrkEngine* iTrkEngine;
+		TTrkConnStatus iConnStatus;
+		TBool iDebugging;
+		TBuf<KMaxPath> iConnMsg;
+		TBool iPlugAndPlay;
+        MTrkDebugMgrCallbacks* iDebugMgrCallback;
+#ifndef __TEXT_SHELL__
+        CToolsConnectionListener* iToolsConnectionListener;
+#endif
+
+};
+
+#endif // __TrkDebugManager_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trkdebugmgrcallbacks.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKDEBUGMGRCALLBACKS_H__
+#define __TRKDEBUGMGRCALLBACKS_H__
+#include <e32std.h>
+#include "TrkConnData.h"
+
+/**
+*  Abstract callback interface for TRK engine to call into the app for certain situations.
+*  All callbacks into the app from TRK engine can be added here.
+*/
+class MTrkDebugMgrCallbacks
+{
+    public:
+
+        /**
+        * Called by TRK engine when a connection status is changed
+        */
+        virtual void DebugConnStatusChanged(TTrkConnStatus& aConnStatus) = 0;
+
+        /**
+        * Called by TRK engine when debugging is started or stopped.
+        */
+        virtual void DebuggingStatusChanged(TBool& aDebugging) = 0;
+        
+      
+};
+
+#endif //__TRKENGINECALLBACK_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trkserver_s60.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+TARGET			trkserver.exe
+#ifdef EKA2
+TARGETTYPE		EXE
+#else
+TARGETTYPE		epocexe
+#endif
+
+UID			0x1000008C  0x200170B7 
+
+VENDORID VID_DEFAULT
+CAPABILITY ALL -TCB -DRM
+
+USERINCLUDE   ../engine
+USERINCLUDE    ../debugnotifier
+
+SOURCEPATH		.
+SOURCE			trksrvmain.cpp trksrvserver.cpp trksrvsession.cpp trkdebugmanager.cpp toolsconnectionlistener.cpp
+
+LIBRARY			euser.lib efsrv.lib trkengine.lib toolsstarterclient.lib
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+SYSTEMINCLUDE	\epoc32\include
+SYSTEMINCLUDE	\epoc32\include\oem        
+#else
+MW_LAYER_SYSTEMINCLUDE
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trkserver_tv.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+macro 		__TEXT_SHELL__ 
+
+TARGET			trkserver.exe
+#ifdef EKA2
+TARGETTYPE		EXE
+#else
+TARGETTYPE		epocexe
+#endif
+
+UID			0x1000008C  0x200170B7  
+
+VENDORID 0x101FB657
+CAPABILITY ALL -TCB -DRM
+
+USERINCLUDE   ../engine
+
+SOURCEPATH		.
+SOURCE			trksrvmain.cpp  
+SOURCE			trksrvserver.cpp trksrvsession.cpp trkdebugmanager.cpp
+
+LIBRARY			euser.lib efsrv.lib trkengine.lib
+
+SYSTEMINCLUDE  		/epoc32/include
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trkserverconsole.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,202 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "trkserver.h"
+
+static CTrkIO* TrkIO = NULL;
+
+#define SafeDelete(x) { if (x) delete x; x = NULL; }
+
+
+//
+//
+// CKeyboardInput implementation
+//
+//
+
+//
+// CKeyboardInput constructor
+//
+CKeyboardInput::CKeyboardInput(CConsoleBase* aConsole)
+	: CActive(EPriorityUserInput),
+	  iConsole(aConsole)
+{
+	CActiveScheduler::Add(this);
+}
+
+//
+// CKeyboardInput destructor
+//
+CKeyboardInput::~CKeyboardInput()
+{
+	Cancel();
+	Deque();
+}
+
+//
+// CKeyboardInput::ListenToKeyboard
+//
+// Wait for a key to be pressed
+//
+void CKeyboardInput::ListenToKeyboard()
+{
+	iConsole->Read(iStatus);
+	SetActive();
+}
+
+//
+// CKeyboardInput::RunL
+//
+// Called when a key is pressed
+//
+void CKeyboardInput::RunL()
+{
+	TKeyCode key = iConsole->KeyCode();
+	if (key == 'q' || key == 'Q')
+		CActiveScheduler::Stop();
+	else
+		ListenToKeyboard();
+}
+
+//
+// CKeyboardInput::DoCancel
+//
+// Stop waiting for keyboard input
+//
+void CKeyboardInput::DoCancel()
+{
+	iConsole->ReadCancel();
+}
+
+
+//
+//
+// CTrkIO implementation
+//
+//
+
+//
+// CTrkIO constructor
+//
+CTrkIO::CTrkIO()
+	: iConsole(0),
+	  iKeyboardInput(0)
+{
+	TRAPD(error, iConsole = Console::NewL(_L("Trk"), TSize(KConsFullScreen, KConsFullScreen)));
+	if (error != KErrNone)
+		User::Panic(_L("TrkServer failed to allocate CConsoleBase"), __LINE__);
+
+	iKeyboardInput = new CKeyboardInput(iConsole);
+	if (iKeyboardInput == 0)
+		User::Panic(_L("TrkServer failed to allocate CKeyboardInput"), __LINE__);
+
+	iKeyboardInput->ListenToKeyboard();
+}
+
+//
+// CTrkIO destructor
+//
+CTrkIO::~CTrkIO()
+{
+	SafeDelete(iKeyboardInput);
+	SafeDelete(iConsole);
+}
+
+//
+// CTrkIO::PrintToScreen
+//
+//	Print a message to the screen
+//
+void CTrkIO::PrintToScreen(TRefByValue<const TDesC> aFmt, ...)
+{
+	VA_LIST(l);
+	VA_START(l, aFmt);
+	iBuffer.FormatList(aFmt, l);
+
+	iConsole->Printf(iBuffer);
+}
+
+//
+// CTrkIO::Terminating
+//
+//	Notify user of termination
+//
+void CTrkIO::Terminating()
+{
+	iConsole->Printf(_L("\r\nPress any key to exit."));
+	iKeyboardInput->Cancel();
+	iConsole->Getch();
+}
+
+//
+// MainL
+//
+// Create the engine and the communications interface and start the active scheduler
+//
+void MainL()
+{
+	RProcess().SetPriority(EPriorityHigh);
+	RThread().SetPriority(EPriorityAbsoluteHigh);
+	
+	TInt sid = RProcess().SecureId();
+		
+	//TrkIO->PrintToScreen(_L("Welcome to TrkServer for Trk\r\n"));
+	//TrkIO->PrintToScreen(_L("Press 'Q' to quit.\r\n\r\n"));
+
+	CActiveScheduler::Start();
+}
+
+//
+// EXE entrypoint
+//
+TInt E32Main()
+{	
+	__UHEAP_MARK;
+
+	CTrapCleanup* cleanupStack = CTrapCleanup::New();
+	if (cleanupStack == 0)
+		User::Panic(_L("Trk failed to allocate CTrapCleanup"), __LINE__);
+	
+	CActiveScheduler* scheduler = new CActiveScheduler;
+	if (scheduler == 0)
+		User::Panic(_L("Trk failed to allocate CActiveScheduler"), __LINE__);
+
+	CActiveScheduler::Install(scheduler);
+
+//	TrkIO = new CTrkIO;
+	
+//	if (!TrkIO)
+//		User::Panic(_L("TrkServer failed to allocate CTrkIO"), __LINE__);
+	
+	TRAPD(error, MainL());
+
+//	if (error != KErrNone)
+//	{
+//		TrkIO->PrintToScreen(_L("\r\nUnexpected error %d"), error);
+//		TrkIO->Terminating();
+//	}
+	
+//	SafeDelete(TrkIO);
+	SafeDelete(scheduler);
+	SafeDelete(cleanupStack);
+
+	__UHEAP_MARKEND;
+
+	User::Exit(0);
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trkserverconsole.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKSERVER_H__
+#define __TRKSERVER_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include <e32cons.h>
+#include <hal.h>
+
+
+//
+// class CKeyboardInput
+//
+// Handles input from the keyboard
+//
+class CKeyboardInput : public CActive
+{
+public:
+
+	CKeyboardInput(CConsoleBase* aConsole);
+	~CKeyboardInput();
+
+	void ListenToKeyboard();
+
+protected:
+
+	void RunL();
+	void DoCancel();
+
+private:
+
+	CConsoleBase* iConsole;
+};
+
+
+//
+// class CTrkIO
+//
+// Handles input and output from/to the console
+//
+class CTrkIO : public CBase
+{
+public:
+
+	CTrkIO();
+	~CTrkIO();
+
+	void PrintToScreen(TRefByValue<const TDesC> aFmt, ...);
+	void Terminating();
+
+private:
+
+	CConsoleBase* iConsole;
+	CKeyboardInput* iKeyboardInput;
+	TBuf<50> iBuffer;
+};
+
+#endif // __TRKSERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trksrvcmdcodes.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkCmdCodes_H__
+#define __TrkCmdCodes_H__
+
+// System includes
+#include <e32std.h>
+
+// Constants
+const TInt KTrkServerMajorVN = 1;
+const TInt KTrkServerMinorVN = 0;
+const TInt KTrkServerBuildVN = 0;
+
+// asynchronous cmd slot count
+const TInt KTrkServerAsynchronousSlotCount	= 8;
+
+//
+const TUid KTrkServerUid = { 0x200170B7 };
+const TUid KTrkAppUid = { 0x200170BB };
+const TUid KTrkExeUid = { 0x200159E2 };
+
+// Literal constants
+
+#if defined(EKA2)
+_LIT(KTrkServerName, "!TrkServer");
+#else
+_LIT(KTrkServerName, "TrkServer");
+#endif
+
+_LIT(KTrkServerImageName, "TrkServer");
+
+_LIT(KServerIntiatedSessionPanic, "TRKSERVER");
+
+#define KCapabilityCustomCheck 0
+
+// Enumerations
+//
+// The cmd-codes used to communicate between the Trk client and Trk server.
+//
+enum TTrkCmdCode
+{
+	//Custom check
+	ETrkSrvCmdCodeFirst = KCapabilityCustomCheck,
+	ETrkSrvGetVersion,
+	ETrkSrvCmdConnect,					
+	ETrkSrvCmdDisConnect,
+	ETrkSrvCmdGetCurrentConnData,
+	ETrkSrvCmdSetCurrentConnData,
+	ETrkSrvCmdGetDebugConnStatus,
+	ETrkSrvDebugConnStatus,
+	ETrkSrvDebugConnStatusCancel,
+	ETrkSrvCmdGetDebuggingStatus,
+	ETrkSrvDebuggingStatus,
+	ETrkSrvDebuggingStatusCancel,
+	ETrkGetPlugAndPlayType,
+	ETrkSetPlugAndPlayType,
+	ETrkSrvCmdCodeShutDownServer,
+	ETrkCmdCodeLast								
+};
+
+// Identifies server-initiated panics relating to the client session.
+enum TTrkServerInitiatedClientPanic
+{
+	//This panic occurs when the client requests a copy of any data attached to any 
+	//read request, but does not supply enough buffer space to contain the data. 
+	ETrkServerInitiatedClientPanicInsufficientRoomForFileData = 1,
+
+	//This panic usually occurs when a client method tries to write to a descriptor 
+	//(sometimes asynchronously), and the client-supplied descriptor is not valid.
+	ETrkServerInitiatedClientPanicBadDescriptor = 2,
+
+
+	//This panic occurs when a client tries to perform an invalid operation.
+	ETrkServerInitiatedClientPanicInvalidOperation = 3,
+};
+
+class TTRKVersion
+{
+public:
+	TInt iMajor;
+	TInt iMinor;
+	TInt iMajorAPI;
+	TInt iMinorAPI;
+	TInt iBuild;
+};
+
+#endif //__TrkCmdCodes_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trksrvmain.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <e32std.h>
+// User includes
+#include "trksrvcmdcodes.h"
+#include "trksrvserver.h"
+#include "trkdebugmanager.h"
+#include "TrkConnData.h"
+#include "TrkEngine.h"
+
+TTrkConnType GetCmdLineConnTypeL();
+void RunServerL();
+
+TTrkConnType GetCmdLineConnTypeL()
+{
+    TTrkConnType connType = ETrkConnInvalid;
+    
+    // Get command line argument
+    if (User::CommandLineLength() > 0)
+    {
+        TBuf<512> commandLineArguments;
+        User::CommandLine( commandLineArguments );
+
+        // Check command line argument
+        if (0 == commandLineArguments.Compare(KCmdLineConnTypeUsb))
+        {
+            connType = ETrkUsbDbgTrc;
+        }
+        else if (0 == commandLineArguments.Compare(KCmdLineConnTypeXti))
+        {
+            connType =  ETrkXti;
+        }
+    }
+    
+    return connType;  
+}
+
+//
+// RunServerL()
+// Creates trk server, signals the client and starts the server
+//
+
+void RunServerL()
+{
+	RProcess().SetPriority(EPriorityHigh);
+	RThread().SetPriority(EPriorityAbsoluteHigh);
+
+	// Create and install the active scheduler we need
+	CActiveScheduler* scheduler = new CActiveScheduler;
+	if (scheduler == 0)
+		User::Leave(KErrNoMemory);
+	// now push the scheduler onto the cleanup stack
+	CleanupStack::PushL(scheduler);
+		
+	CActiveScheduler::Install(scheduler);
+
+	CTrkDebugManager* trkDebugMgr = CTrkDebugManager::NewLC();
+	// Create server
+	CTrkSrvServer::NewLC(trkDebugMgr);
+	TTrkConnType connType = GetCmdLineConnTypeL();
+	if (connType != ETrkConnInvalid)
+    {
+        TRAPD(error, trkDebugMgr->StartDebuggingL(connType));
+        if (error != KErrNone)
+        {
+            // We just ignore the error here since the error is managed by the debug manager
+        }    
+    }
+	else
+    {
+        TRAPD(error, trkDebugMgr->StartDebuggingL());
+        if (error != KErrNone)
+        {
+            // We just ignore the error here since the error is managed by the debug manager
+        }
+    } 
+
+	// Initialisation complete, now signal the client
+#ifdef EKA2
+	User::LeaveIfError(User::RenameThread(KTrkServerName));
+#else
+	User::LeaveIfError(RThread().RenameMe(KTrkServerName));
+#endif
+	RProcess::Rendezvous(KErrNone);
+
+	// Ready to run
+	CActiveScheduler::Start();
+
+	trkDebugMgr->StopDebugging();
+	
+	// Cleanup the server and scheduler
+	CleanupStack::PopAndDestroy(3, scheduler);
+}
+
+
+
+//
+// Main Entry Point
+//
+
+TInt E32Main()
+{
+	__UHEAP_MARK;
+	
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if (cleanup == 0)
+		User::Panic(_L("Trk  Server failed to allocate CTrapCleanup"), __LINE__);
+	
+	TInt error = KErrNone;
+	
+	if (cleanup)
+	{
+		TRAP(error, RunServerL());
+		delete cleanup;
+	}
+	
+	if (error != KErrNone)
+	{
+		User::Panic(_L("Trk Server failed to start"), __LINE__);
+	}
+	
+	__UHEAP_MARKEND;
+
+	return error;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trksrvserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,199 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "trksrvserver.h"
+
+// System includes
+#include <e32base.h>
+#include <e32debug.h>
+
+// User includes
+#include "trksrvsession.h"
+
+
+// Type definitions
+
+// Constants
+#define METROTRK_SID 0x200170BB
+// Enumerations
+
+// Classes referenced
+
+//Only include these in the secured platform 
+#include "trksrvcmdcodes.h"
+
+const TUint KRangeCount = 2; 
+
+const TInt KOpCodeRanges[KRangeCount] = 
+{	
+	KCapabilityCustomCheck, 
+	ETrkCmdCodeLast,
+};
+
+
+const TUint8 KElementsIndex[KRangeCount] =
+{
+	CPolicyServer::ECustomCheck, 	//Custom check for the MetroTrk SID 	 0 - ETrkCmdCodeLast
+	CPolicyServer::ENotSupported, 	//Not Supported					 		 ETrkCmdCodeLast-End
+};
+
+const CPolicyServer::TPolicy KTrkServerPolicy =
+{
+	CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
+	KRangeCount,
+	KOpCodeRanges,
+	KElementsIndex, 	// what each range is compared to 
+	NULL 	// what policies range is compared to
+};
+
+
+
+//
+// CTrkSrvServer (source)
+//
+
+//
+// CTrkSrvServer::CTrkSrvServer()
+//
+// Constructor
+//
+CTrkSrvServer::CTrkSrvServer(CTrkDebugManager* aTrkDebugMgr)
+#ifdef  EKA2
+ 	:CPolicyServer(CActive::EPriorityHigh, KTrkServerPolicy),
+#else	
+   	:CServer2(CActive::EPriorityHigh), 
+#endif
+	iTrkDebugMgr(aTrkDebugMgr)
+{
+}
+
+//
+// CTrkSrvServer::~CTrkSrvServer()
+//
+// Destructor
+//
+CTrkSrvServer::~CTrkSrvServer()
+{
+	// In order to prevent access violations as the server
+	// shuts down, we inform all sessions that the server is
+	// about to be destroyed
+	iSessionIter.SetToFirst();
+	//
+	CTrkSrvSession* session = static_cast<CTrkSrvSession*>(iSessionIter++);
+	while (session)
+	{
+		session->HandleServerDestruction();
+		session = static_cast<CTrkSrvSession*>(iSessionIter++);
+	}	
+}
+
+//
+// CTrkSrvServer::ConstructL()
+//
+// Second level construction
+//
+void CTrkSrvServer::ConstructL()
+{
+	// Calling StartL here won't actually allow any connections
+	// to be created until the active scheduler has a chance to run. However, the 
+	// call below will leave should there already be a started Trk server instance.
+	//
+	StartL(KTrkServerName);
+}
+
+//
+// CTrkSrvServer::NewLC()
+//
+// Creates an instance of CTrkSrvServer.
+//
+CTrkSrvServer* CTrkSrvServer::NewLC(CTrkDebugManager* aTrkDebugMgr)
+{
+	CTrkSrvServer* self = new(ELeave) CTrkSrvServer(aTrkDebugMgr);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+}
+
+//
+// CTrkSrvServer::NewSessionL()
+//
+// Creates a new session.
+// Called by the IPC framework everytime a client creates a new session.
+// Returns a CTrkSrvSession object.
+//
+CSession2* CTrkSrvServer::NewSessionL(const TVersion& aVersion,const RMessage2& /*aMessage*/) const
+{	
+	// Check client version is correct
+	const TVersion trkServerVersion(KTrkServerMajorVN, KTrkServerMinorVN, KTrkServerBuildVN);
+	if	(!User::QueryVersionSupported(trkServerVersion, aVersion))
+		User::Leave(KErrNotSupported);
+	
+	// Create new session
+	CTrkSrvSession* session = CTrkSrvSession::NewL(iTrkDebugMgr);
+	return session;
+}
+
+//
+// CTrkSrvServer::RunError()
+//
+// Handles all the errors when handling a client request.
+// Called by the IPC framework whenever a leave occurs when handling a client request.
+// Returns KErrNone to complete the error handling.
+//
+TInt CTrkSrvServer::RunError(TInt aError)
+{
+	// A bad descriptor error implies a badly programmed client, so panic it;
+	// otherwise report the error to the client
+	if	(aError == KErrBadDescriptor)
+	{
+		Message().Panic(KServerIntiatedSessionPanic, ETrkServerInitiatedClientPanicBadDescriptor);
+	}
+	else
+	{
+		Message().Complete(aError);
+	}
+
+	// The leave will result in an early return from CServer2::RunL(), skipping
+	// the call to request another message. So do that now in order to keep the
+	// server running.
+	ReStart();
+
+	// Indicate that we've handled the error fully
+	return KErrNone;
+}
+	
+#ifdef EKA2	
+//
+// CTrkSrvServer::CustomSecurityCheckL()
+//
+// The only security check that is done is to check for the cleint securid 
+// Returns EFail or EPass
+//
+CPolicyServer::TCustomResult CTrkSrvServer::CustomSecurityCheckL(const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/)
+{
+	CPolicyServer::TCustomResult returnValue = CPolicyServer::EFail;	
+	
+	TSecureId ClientSID = aMsg.SecureId();
+	// We only permit MetroTrk to use this server. So we check
+	// for MetroTrk's SIDs. If its not MetroTrk's SIDs, then the security check fails.
+	if ((KTrkAppUid == ClientSID) || (KTrkExeUid == ClientSID))
+	{
+		returnValue = CPolicyServer::EPass;
+	}			
+	return(returnValue);
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trksrvserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkSrvServer_H__
+#define __TrkSrvServer_H__
+
+// System includes
+#include <e32base.h>
+
+// User includes
+#include "trkdebugmanager.h"
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// CTrkSrvServer (header)
+// The Trk Server
+//
+#ifdef EKA2
+class CTrkSrvServer : public CPolicyServer
+#else
+class CTrkSrvServer : public CServer2
+#endif
+{
+	public:
+		static CTrkSrvServer* NewLC(CTrkDebugManager* aTrkDebugMgr);
+		~CTrkSrvServer();
+
+	private:
+		CTrkSrvServer(CTrkDebugManager* aTrkDebugMgr);
+		void ConstructL();
+
+	public:
+		CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
+
+	private:
+		TInt RunError(TInt aError);
+
+	private:
+	#ifdef EKA2	
+		TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing);
+	#endif
+	
+	private:
+		CTrkDebugManager* iTrkDebugMgr;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trksrvsession.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,425 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "trksrvsession.h"
+
+// System includes
+
+//User Includes
+#include "trkdebugmgrcallbacks.h"
+#include "trksrvcmdcodes.h"
+
+// Type definitions
+
+// Constants
+const TInt KTrkServerTransferBufferExpandSize = 100;
+const TInt KSlot0 = 0;
+const TInt KSlot2 = 2;
+
+
+// Enumerations
+
+// Classes referenced
+
+// Static functions
+// Checks for a null'd handle before attempting complete. 
+// If handle is null'd then don't complete as this will panic server.
+//
+void SafeComplete(const RMessagePtr2& aMessage, TInt aCompletionCode)
+{
+    if(!aMessage.IsNull())
+    {
+        aMessage.Complete(aCompletionCode);
+    }
+}
+//
+// CTrkSrvSession (source)
+//
+
+//
+// CTrkSrvSession::CTrkSrvSession()
+//
+// Constructor
+//
+CTrkSrvSession::CTrkSrvSession(CTrkDebugManager* aTrkDebugMgr) : iTrkDebugMgr(aTrkDebugMgr)
+{
+}
+
+//
+// CTrkSrvSession::~CTrkSrvSession()
+//
+// Destructor
+//
+CTrkSrvSession::~CTrkSrvSession()
+{
+	HandleServerDestruction();
+	delete iTransferBuffer;
+}
+
+//
+// CTrkSrvSession::ConstructL()
+//
+// Creates an instance of CTrkSrvSession.
+//
+void CTrkSrvSession::ConstructL()
+{
+	iTransferBuffer = CBufFlat::NewL(KTrkServerTransferBufferExpandSize);
+	iTrkDebugMgr->SetDebugMgrCallback(this);
+}
+
+//
+// CTrkSrvServer::NewL()
+//
+// Static self construction
+//
+CTrkSrvSession* CTrkSrvSession::NewL(CTrkDebugManager* aTrkDebugMgr)
+{
+	CTrkSrvSession* self = new(ELeave) CTrkSrvSession(aTrkDebugMgr);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+}
+
+//
+// CTrkSrvSession::HandleServerDestruction()
+//
+// Called by the server's destructor. We need to be told that the server is
+// being destroyed.
+//
+void CTrkSrvSession::HandleServerDestruction()
+{
+
+}
+
+//
+// CTrkSrvSession::ServiceL()
+//
+// Services requests from a client.
+// Called by the IPC framework whenever a client sends a request to the server.
+//
+void CTrkSrvSession::ServiceL(const RMessage2& aMessage)
+{
+	const TInt cmd = aMessage.Function();
+	
+	switch (cmd)
+	{
+		case ETrkSrvGetVersion:
+			CmdGetVersionL(aMessage);
+			break;
+		case ETrkSrvCmdConnect:
+			CmdConnectL(aMessage);
+			break;
+		case ETrkSrvCmdDisConnect:
+			CmdDisConnectL(aMessage);
+			break;
+		case ETrkSrvCmdGetCurrentConnData:
+		    CmdGetCurrentConnDataL(aMessage);
+		    break;
+		case ETrkSrvCmdSetCurrentConnData:
+		    CmdSetCurrentConnDataL(aMessage);
+		    break;
+		case ETrkSrvCmdGetDebugConnStatus:
+			CmdGetDebugConnStatusL(aMessage);
+			break;
+		case ETrkSrvDebugConnStatus:
+			ConnStatusNotifyL(aMessage);
+			break;
+		case ETrkSrvDebugConnStatusCancel:
+		    ConnStatusNotifyCancel(aMessage);
+		    break;
+		case ETrkSrvCmdGetDebuggingStatus:
+			CmdGetDebugStatusL(aMessage);
+			break;
+		case ETrkSrvDebuggingStatus:
+			DebugStatusNotifyL(aMessage);				
+			break;
+		case ETrkSrvDebuggingStatusCancel:
+		    DebugStatusNotifyCancel(aMessage);
+		    break;
+		case ETrkGetPlugAndPlayType:
+		    GetPlugAndPlayTypeL(aMessage);
+		    break;
+		case ETrkSetPlugAndPlayType:
+		    SetPlugAndPlayTypeL(aMessage);
+		    break;
+		case ETrkSrvCmdCodeShutDownServer:
+		    CmdShutDownServer(aMessage);
+			break;
+		default:
+		    aMessage.Panic(KServerIntiatedSessionPanic, ETrkServerInitiatedClientPanicInvalidOperation);
+			break;
+	}
+}
+
+//
+// CTrkSrvSession::CmdGetVersionL()
+//
+// Gets the TRK version information
+//
+void CTrkSrvSession::CmdGetVersionL(const RMessage2& aMessage)
+{
+	TTRKVersion version;
+	iTrkDebugMgr->GetVersion(version);
+	
+	TPckgC<TTRKVersion> package(version);
+	TRAPD(err, aMessage.WriteL(KSlot0, package));
+	if (err != KErrNone)
+	{
+        aMessage.Panic(_L("TrkServer"), 2);
+	}
+	aMessage.Complete(KErrNone);
+}
+
+//
+// CTrkSrvSession::CmdConnectL()
+//
+void CTrkSrvSession::CmdConnectL(const RMessage2& aMessage)
+{
+	TRAPD(err,iTrkDebugMgr->ConnectToDebuggerL());
+	if (err != KErrNone)
+	{
+        aMessage.Panic(_L("TrkServer"), 3);
+	}
+	aMessage.Complete(KErrNone);
+}
+
+//
+// CTrkSrvSession::CmdDisconnectL()
+//
+void CTrkSrvSession::CmdDisConnectL(const RMessage2& aMessage)
+{
+	iTrkDebugMgr->DisConnect();	
+	aMessage.Complete(KErrNone);
+}
+
+//
+// CTrkSrvSession::CmdGetConnStatusL()
+//
+void CTrkSrvSession::CmdGetCurrentConnDataL(const RMessage2& aMessage)
+{
+    TTrkConnData connData;  
+    iTrkDebugMgr->GetCurrentConnData(connData);
+    
+    TPckgC<TTrkConnData> package(connData);      
+    TRAPD(err, aMessage.WriteL(KSlot0, package));    
+    if (err != KErrNone)
+    {
+        aMessage.Panic(_L("TrkServer"), 2);
+    }
+    aMessage.Complete(KErrNone);
+}
+
+//
+// CTrkSrvSession::CmdGetConnStatusL()
+//
+void CTrkSrvSession::CmdSetCurrentConnDataL(const RMessage2& aMessage)
+{   
+    TTrkConnData connData;
+
+    TPckg<TTrkConnData> package(connData);
+    TRAPD(err, aMessage.ReadL(KSlot0, package));
+    if (err != KErrNone)
+    {
+        aMessage.Panic(_L("TrkServer"), 2);
+    }
+    TPckgBuf<TBool> connected(iTrkDebugMgr->IsConnected());
+    TBuf<KMaxPath> connStatus;
+    iTrkDebugMgr->SetCurrentConnData(connData);       
+    
+    aMessage.Complete(KErrNone);
+}
+
+//
+// CTrkSrvSession::CmdGetConnStatusL()
+//
+void CTrkSrvSession::CmdGetDebugConnStatusL(const RMessage2& aMessage)
+{	
+    TPckgBuf<TTrkConnStatus> package(iTrkDebugMgr->GetConnectionStatus());
+    TBuf<KMaxPath> connMsg;
+	iTrkDebugMgr->GetConnectionMsg(connMsg);
+		
+	TRAPD(err, aMessage.WriteL(KSlot0, package));
+	TRAPD(err1, aMessage.WriteL(KSlot2, connMsg));
+	if (err || err1)
+	{
+        aMessage.Panic(_L("TrkServer"), 2);
+	 }
+	aMessage.Complete(KErrNone);   
+}
+
+//
+// CTrkSrvSession::ConnStatusNotifyL()
+//
+void CTrkSrvSession::ConnStatusNotifyL(const RMessage2& aMessage)
+{
+    if (!iPendingConnState)
+    {
+        iBlockedConnState = aMessage;       
+        iPendingConnState = ETrue;
+    }
+    else
+    {
+        aMessage.Complete(KErrAlreadyExists);
+    }
+}
+
+//
+//CTrkSrvSession::ConnStatusNotifyCancel()
+//
+void CTrkSrvSession::ConnStatusNotifyCancel(const RMessage2& aMessage)
+{
+    if (iPendingConnState && iBlockedConnState.Handle())
+    {
+       SafeComplete(iBlockedConnState, KErrCancel);
+       iPendingConnState = EFalse;        
+    }
+    SafeComplete(aMessage, KErrNone);
+    iTrkDebugMgr->SetDebugMgrCallback(NULL);
+}
+
+//
+// CTrkSrvSession::CmdGetDebugStatusL()
+//
+void CTrkSrvSession::CmdGetDebugStatusL(const RMessage2& aMessage)
+{
+    TPckgBuf<TBool> debugging(iTrkDebugMgr->IsDebugging());        
+    TRAPD(err, aMessage.WriteL(KSlot0, debugging));
+    
+    if (err != KErrNone)
+    {
+        aMessage.Panic(_L("TrkServer"), 2);
+    }
+    aMessage.Complete(KErrNone);
+}
+
+//
+// CTrkSrvSession::DebugStatusNotifyL()
+//
+void CTrkSrvSession::DebugStatusNotifyL(const RMessage2& aMessage)
+{	
+    if (!iPendingDebugState)
+    {
+        iBlockedDebugState = aMessage;       
+        iPendingDebugState = ETrue;
+    }
+    else
+    {
+        aMessage.Complete(KErrAlreadyExists);
+    }
+}
+
+//
+// CTrkSrvSession::DebugStatusNotifyCancel()
+//
+void CTrkSrvSession::DebugStatusNotifyCancel(const RMessage2& aMessage)
+{
+    if (iPendingDebugState && iBlockedDebugState.Handle())
+    {
+       SafeComplete(iBlockedDebugState, KErrCancel);
+       iPendingDebugState = EFalse;        
+    }
+    SafeComplete(aMessage, KErrNone);
+}
+//
+// CTrkSrvSession::CmdShutDownServer()
+//
+// Stops the active scheduler. This way, server process will run to completion.
+//
+void CTrkSrvSession::CmdShutDownServer(const RMessage2& aMessage)
+{
+    CActiveScheduler::Stop();
+    aMessage.Complete(KErrNone);
+}
+
+//
+// CTrkSrvSession::DebugConnStatusChanged()
+//
+// It is called when the debug connection status has been found changed
+//
+void CTrkSrvSession::DebugConnStatusChanged(TTrkConnStatus& aConnStatus)
+{
+    if (iPendingConnState && iBlockedConnState.Handle())
+    {
+        TPckg<TTrkConnStatus> package(aConnStatus);
+        //write the file data into the client descriptor
+        TRAPD(err, iBlockedConnState.WriteL(KSlot0, package));                      
+        if (err != KErrNone)
+        {
+            iBlockedConnState.Panic(_L("TrkServer"), 2);
+        }
+        SafeComplete(iBlockedConnState, err);    
+    }
+    iPendingConnState = EFalse;
+}
+
+//
+// CTrkSrvSession::DebugConnStatusChanged()
+//
+// Called when the debugging status is changed
+//
+void CTrkSrvSession::DebuggingStatusChanged(TBool& aDebugging)
+{
+    if (iPendingDebugState && iBlockedDebugState.Handle())
+    {
+        TPckg<TBool> package(aDebugging);
+        //write the file data into the client descriptor
+        TRAPD(err, iBlockedDebugState.WriteL(KSlot0, package));                      
+        if (err != KErrNone)
+        {
+            iBlockedDebugState.Panic(_L("TrkServer"), 2);
+        }
+        SafeComplete(iBlockedDebugState, err);    
+    }
+    iPendingDebugState = EFalse;
+}
+
+//
+// CTrkSrvSession::GetPlugAndPlayType()
+//
+// To know whether plug and play is set or not
+//
+void CTrkSrvSession::GetPlugAndPlayTypeL(const RMessage2& aMessage)
+{
+    TPckg<TBool> plugandPlay(iTrkDebugMgr->GetPlugAndPlayOption());
+        
+    TRAPD(err, aMessage.WriteL(KSlot0, plugandPlay));
+    if (err!= KErrNone)
+    {
+        aMessage.Panic(_L("TrkServer"), 2);
+    }
+    aMessage.Complete(KErrNone);  
+}
+
+//
+// CTrkSrvSession::SetPlugAndPlayType()
+//
+// To set the plug and play 
+//
+void CTrkSrvSession::SetPlugAndPlayTypeL(const RMessage2& aMessage)
+{   
+    TBool plugandPlay;
+    TPckg<TBool> package(plugandPlay);
+    TRAPD(err, aMessage.ReadL(KSlot0, package));
+    if (err!= KErrNone)
+    {
+        aMessage.Panic(_L("TrkServer"), 2);
+    }
+    iTrkDebugMgr->SetPlugAndPlayOption(plugandPlay);
+    aMessage.Complete(KErrNone);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trkserver/trksrvsession.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkSrvSession_h__
+#define __TrkSrvSession_h__
+
+// System includes
+#include <e32base.h>
+
+// User includes
+
+#include "trkdebugmanager.h"
+#include "trkdebugmgrcallbacks.h"
+
+// Constants
+
+// Classes referenced
+class CTrkSrvSessionEngine;
+// Enumerations
+
+
+//
+// CTrkSrvSession (header)
+//
+/**
+ * This class acts as a simple wrapper around the IPC client-server framework,
+ * and drives a real underlying engine, which is actually responsible for
+ * fulfulling all the client requests.
+ */
+ 
+class CTrkSrvSession : public CSession2, public MTrkDebugMgrCallbacks
+{
+	public:
+		static 	CTrkSrvSession* NewL(CTrkDebugManager* aTrkDebugMgr);
+				~CTrkSrvSession();
+    
+	public:
+        void    HandleServerDestruction();
+
+	public:
+	//FROM CSession2
+	    void DebugConnStatusChanged(TTrkConnStatus& aConnStatus);
+	    void DebuggingStatusChanged(TBool& aDebugging);
+	    
+	private:
+    //FROM CSession2
+        void    ServiceL(const RMessage2& aMessage);
+    
+	
+	private:
+                CTrkSrvSession(CTrkDebugManager* aTrkDebugMgr);
+        void    ConstructL();
+
+	private:	
+	// CMD - TRKSERVER SPECIFIC FUNCTIONALITY
+		void	CmdGetVersionL(const RMessage2& aMessage);
+		void	CmdConnectL(const RMessage2& aMessage);
+		void	CmdDisConnectL(const RMessage2& aMessage);
+		void    CmdGetCurrentConnDataL(const RMessage2& aMessage);
+		void    CmdSetCurrentConnDataL(const RMessage2& aMessage);
+		void	CmdGetDebugConnStatusL(const RMessage2& aMessage);
+		void	ConnStatusNotifyL(const RMessage2& aMessage);
+		void 	CmdGetDebugStatusL(const RMessage2& aMessage);
+		void 	DebugStatusNotifyL(const RMessage2& aMessage);
+		void    CmdShutDownServer(const RMessage2& aMessage);
+		void    ConnStatusNotifyCancel(const RMessage2& aMessage);
+		void    DebugStatusNotifyCancel(const RMessage2& aMessage);
+		void    GetPlugAndPlayTypeL(const RMessage2& aMessage);
+		void    SetPlugAndPlayTypeL(const RMessage2& aMessage);
+
+private:
+	/*
+	 * Used to transfer collections of objects between server and client.
+	 */
+	CBufBase*				iTransferBuffer;
+
+	CTrkDebugManager* 		iTrkDebugMgr;
+	
+    RMessagePtr2            iBlockedDebugState;   
+    RMessagePtr2            iBlockedConnState;
+    TBool                   iPendingDebugState;
+    TBool                   iPendingConnState;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trksrvclient/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trksrvclient/trksrvclientdefs.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "trksrvclientdefs.h"
+#include "trksrvcmdcodes.h"
+
+// System includes
+
+// User includes
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// TrkSrvClientDefs (source)
+//
+
+//
+// TrkSrvClientDefs::ServerAndThreadName()
+//
+// Returns the Trk server's unique name.
+// @return Unique name of the Trk server.
+//
+const TDesC& TrkSrvClientDefs::ServerAndThreadName()
+{
+	return KTrkServerName;
+}
+
+//
+// TrkSrvClientDefs::ServerImageName()
+//
+// Return the name of the server image (Exe/Dll)
+//
+const TDesC& TrkSrvClientDefs::ServerImageName()
+{
+	return KTrkServerImageName;
+}
+
+//
+// TrkSrvClientDefs::ServerUidType()
+//
+// Return the Uid associated with the server image
+//
+TUidType TrkSrvClientDefs::ServerUidType()
+{
+	return TUidType(KNullUid, KNullUid, KTrkServerUid);
+}
+
+
+//
+// TrkSrvClientDefs::Version()
+//
+// Return the version number of the server/client
+//
+TVersion TrkSrvClientDefs::Version()
+{
+	return TVersion(KTrkServerMajorVN, KTrkServerMinorVN, KTrkServerBuildVN);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trksrvclient/trksrvclientdefs.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkSrvClientDefs_h__
+#define __TrkSrvClientDefs_h__
+
+// System includes
+#include <e32base.h>
+// User includes
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// TrkSrvClientDefs (header)
+//
+
+//This is a utility class that retrieves the name and version number of the TrkServer 
+class TrkSrvClientDefs
+{
+	// STATIC ACCESS METHODS
+	public:										
+		static const TDesC&	ServerAndThreadName();
+
+		static const TDesC&	ServerImageName();
+
+		static TUidType		ServerUidType();
+
+		static TVersion		Version();
+
+};
+
+#endif //__TrkSrvClientDefs_h__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trksrvclient/trksrvclientutils.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <e32std.h>
+
+// User includes
+#include "trksrvclientdefs.h"
+#include "trksrvclientutils.h"
+
+// Type definitions
+
+// Constants
+
+// Enumerations
+
+
+//
+// TrkSrvClientUtils (source)
+//
+
+//
+// TrkSrvClientUtils::Panic()
+//
+// Panic the client
+//
+void TrkSrvClientUtils::Panic(TTrkSrvClientPanic aPanic)
+{
+	_LIT(KTrkSrvClientPanic, "TRKSRVCLI");
+	User::Panic(KTrkSrvClientPanic, aPanic);
+}
+
+//
+// TrkSrvClientUtils::Fault()
+//
+// Panic the client, indicating some form of logic error or terminal
+// fault.
+//
+void TrkSrvClientUtils::Fault(TTrkSrvClientFault aFault)
+{
+	_LIT(KTrkSrvClientFault, "TRKSRVCLIFAULT");
+	User::Panic(KTrkSrvClientFault, aFault);
+}
+
+//
+// TrkSrvClientUtils::StartTrkSrvServer()
+//
+// Starts the TrkSrv server.
+// @return KErrNone if successful, 
+//		   KErrAlreadyExists if the server is already running, otherwise a system-wide error.
+TInt TrkSrvClientUtils::StartTrkServer()
+{
+
+	TInt ret = KErrNone;
+
+	//
+	// Create a new server process. Simultaneous launching
+	// of two such processes should be detected when the second one attempts to
+	// create the server object, failing with KErrAlreadyExists.
+	//
+	RProcess server;
+	ret = server.Create(TrkSrvClientDefs::ServerImageName(), KNullDesC, TrkSrvClientDefs::ServerUidType());
+
+	// Did we manage to create the thread/process?
+	if	(ret != KErrNone)
+		return ret;
+
+	// Wait to see if the thread/process died during construction
+	TRequestStatus serverDiedRequestStatus;
+#if defined(EKA2)
+	server.Rendezvous(serverDiedRequestStatus);
+#else
+	server.Logon(serverDiedRequestStatus);
+#endif
+	
+	if	(serverDiedRequestStatus != KRequestPending)
+	{
+		// Abort startup
+		server.Kill(KErrNone);
+	}
+	else
+	{
+		// Logon OK - start the server
+		server.Resume();
+	}
+	
+	User::WaitForRequest(serverDiedRequestStatus);
+
+	// we can't use the 'exit reason' if the server panicked as this
+	// is the panic 'reason' and may be '0' which cannot be distinguished
+	// from KErrNone
+	
+	ret = (server.ExitType() == EExitPanic) ? KErrGeneral : serverDiedRequestStatus.Int();
+	
+	server.Close();
+
+	return ret;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trksrvclient/trksrvclientutils.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkSrvClientUtils_H__
+#define __TrkSrvClientUtils_H__
+
+// System includes
+#include <e32base.h>
+
+
+//
+//  TrkSrvClientUtils (header)
+//
+class TrkSrvClientUtils
+{
+public:										// ENUMERATIONS
+	/** Panic numbers associated with the TRKSRVCLI panic category. */
+	enum TTrkSrvClientPanic
+	{
+		ETrkSrvClientPanicArgument			= 0,
+		ETrkSrvClientPanicCancel			= 1,
+		ETrkSrvClientPanicLast
+	};
+	/** Panic numbers associated with the TRKSRVCLIFAULT panic category. */
+	enum TTrkSrvClientFault
+	{
+		ETrkSrvClientFaultLogic					= 0,
+		ETrkSrvClientFaultData					= 1,
+		ETrkSrvClientFaultCouldNotLoadServer	= 2,
+		ETrkSrvClientFaultDebugFuncError		= 3,
+		ETrkSrvClientFaultLast
+	};
+
+public:
+
+	static void	Panic(TTrkSrvClientPanic aPanic);
+
+	static void	Fault(TTrkSrvClientFault aFault);
+
+	static TInt	StartTrkServer();
+};
+
+#endif //__TrkTcbClientUtils_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trksrvclient/trksrvclisession.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,211 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "trksrvcmdcodes.h"
+#include "trksrvclientutils.h"
+#include "trksrvclientdefs.h"
+#include "trksrvclisession.h"
+
+// Type definitions
+
+// Constants
+const TInt KNumberOfServerStartupAttempts = 4;
+
+// Enumerations
+
+//
+// RTrkSrvCliSession (source)
+//
+
+//
+// RTrkSrvCliSession::RTrkSrvCliSession
+//
+// Constructor
+//
+RTrkSrvCliSession::RTrkSrvCliSession()
+{
+}
+
+//
+//RTrkSrvCliSession::ConnectToServer()
+//
+// Connects the client process to the TrkSrv server, starting the server 
+// if it is not already running.
+// return KErrNone if successful, otherwise one of the system-wide errors.
+//
+TInt RTrkSrvCliSession::ConnectToServer()
+{
+	TInt startupAttempts = KNumberOfServerStartupAttempts;
+	for(;;)
+	{
+		TInt ret = CreateSession(TrkSrvClientDefs::ServerAndThreadName(), TrkSrvClientDefs::Version(), KTrkServerAsynchronousSlotCount);
+		if (ret != KErrNotFound && ret != KErrServerTerminated)
+		{
+			return ret;
+		}
+		
+		if	(startupAttempts-- == 0)
+		{
+			return ret;
+		}
+		
+		ret = TrkSrvClientUtils::StartTrkServer();
+		if	(ret != KErrNone && ret != KErrAlreadyExists)
+		{
+			return ret;
+		}
+		
+	}
+}
+
+//
+// RTrkSrvCliSession::GetTrkVersion()
+//
+// Provides the version number of the Trk server.
+// @return The version number. 
+//
+TInt RTrkSrvCliSession::GetTrkVersion(TInt& aMajorVersion, TInt& aMinorVersion, TInt& aMajorAPIVersion, TInt& aMinorAPIVersion, TInt& aBuildNumber)
+{
+    TTRKVersion trkVersion; 
+    TPckg<TTRKVersion> trkVersionPkg(trkVersion);
+	TInt err = SendReceive(ETrkSrvGetVersion, TIpcArgs(&trkVersionPkg));
+	if (KErrNone == err)
+	{
+        aMajorVersion = trkVersion.iMajor;
+        aMinorVersion = trkVersion.iMinor;
+        aMajorAPIVersion = trkVersion.iMajorAPI;
+        aMinorAPIVersion = trkVersion.iMinorAPI;
+        aBuildNumber = trkVersion.iBuild;
+	}
+
+	return err;
+}
+
+//
+// RTrkSrvCliSession::Connect()
+//
+//
+TInt RTrkSrvCliSession::Connect()
+{	
+	return SendReceive(ETrkSrvCmdConnect);
+}
+
+//
+// RTrkSrvCliSession::ReadFile()
+//
+TInt RTrkSrvCliSession::DisConnect()
+{
+	return SendReceive(ETrkSrvCmdDisConnect);
+}
+
+//
+// RTrkSrvCliSession::GetCurrentConnData()
+//
+TInt RTrkSrvCliSession::GetCurrentConnData(TTrkConnData& aConnData)
+{
+    TPckg<TTrkConnData> package(aConnData);
+    TIpcArgs args(&package);
+    return SendReceive(ETrkSrvCmdGetCurrentConnData, args);
+}
+
+//
+// RTrkSrvCliSession::SetCurrentConnData()
+//
+TInt RTrkSrvCliSession::SetCurrentConnData(TTrkConnData& aConnData)
+{
+    TPckg<TTrkConnData> package(aConnData);
+    TIpcArgs args(&package);
+    return SendReceive(ETrkSrvCmdSetCurrentConnData, args);
+}
+
+//
+// RTrkSrvCliSession::GetDebugConnStatus()
+//
+TInt RTrkSrvCliSession::GetDebugConnStatus(TTrkConnStatus& aConnStatus, TDes& aConnMsg)
+{    
+    TPckg<TTrkConnStatus> package(aConnStatus);
+	TIpcArgs args(&package, aConnMsg.Length(), &aConnMsg);
+	
+	return SendReceive(ETrkSrvCmdGetDebugConnStatus, args);
+}
+
+//
+// RTrkSrvCliSession::DebugConnStatusNotify()
+//
+void RTrkSrvCliSession::DebugConnStatusNotify(TDes8& aConnStatus, TDes& aConnMsg, TRequestStatus& aStatus)
+{
+    SendReceive(ETrkSrvDebugConnStatus, TIpcArgs(&aConnStatus, &aConnMsg), aStatus);
+}
+
+//
+// RTrkSrvCliSession::DebugConnStatusNotifyCancel()
+//
+TInt RTrkSrvCliSession::DebugConnStatusNotifyCancel()
+{
+    return SendReceive(ETrkSrvDebugConnStatusCancel);
+}
+
+//
+// RTrkSrvCliSession::GetDebugStatus()
+//
+TInt RTrkSrvCliSession::GetDebuggingStatus(TBool& aDebugging)
+{
+	TPckg<TBool> isDebugging(aDebugging);
+	return SendReceive(ETrkSrvCmdGetDebuggingStatus, TIpcArgs(&isDebugging));
+}
+
+//
+// RTrkSrvCliSession::DebuggingStatusNotify()
+//
+void RTrkSrvCliSession::DebuggingStatusNotify(TDes8& aDebugging, TRequestStatus& aStatus)
+{
+    SendReceive(ETrkSrvDebuggingStatus, TIpcArgs(&aDebugging), aStatus);   
+}
+
+//
+// RTrkSrvCliSession::DebuggingStatusNotifyCancel()
+//
+TInt RTrkSrvCliSession::DebuggingStatusNotifyCancel()
+{
+    return SendReceive(ETrkSrvDebuggingStatusCancel);
+}
+
+TInt RTrkSrvCliSession::GetPlugAndPlayType(TBool& aPlugandPlay)
+{
+    TPckg<TBool> package(aPlugandPlay);
+    return SendReceive(ETrkGetPlugAndPlayType, TIpcArgs(&package));
+    
+}
+
+TInt RTrkSrvCliSession::SetPlugAndPlayType(TBool aPlugandPlay)
+{   
+    TPckg<TBool> package(aPlugandPlay);
+    return SendReceive(ETrkSetPlugAndPlayType, TIpcArgs(&package));
+}
+
+//
+// RTrkSrvCliSession::ShutDownServer()
+//
+// Closes the server.
+// @return KErrNone - if succesful
+//		   Negative - if failed.
+//
+TInt RTrkSrvCliSession::ShutDownServer()
+{
+	return SendReceive(ETrkSrvCmdCodeShutDownServer);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/trksrvclient/trksrvclisession.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TrkSrvCliSession_h__
+#define __TrkSrvCliSession_h__
+
+// System includes
+#include <e32base.h>
+#include <f32file.h>
+#include "TrkConnData.h"
+// User includes
+
+// Classes referenced
+typedef TPckg<TBool> TDebugState;
+typedef TPckg<TTrkConnStatus> TConnState;
+
+//class TTrkConnData;
+
+
+//The client-side interface to the Trk server. 
+class RTrkSrvCliSession : public RSessionBase
+{
+	// CONNECT TO SERVER & VERSIONING
+	public:										
+		 			RTrkSrvCliSession();
+		TInt		ConnectToServer();
+
+	// TRK server CMD SPECIFIC FUNCTIONALITY
+	public:										
+		TInt	GetTrkVersion(TInt& aMajorVersion, TInt& aMinorVersion, TInt& aMajorAPIVersion, TInt& aMinorAPIVersion, TInt& aBuildNumber);
+		TInt	Connect();
+		TInt	DisConnect();
+		TInt    GetCurrentConnData(TTrkConnData& aConnData);
+		TInt    SetCurrentConnData(TTrkConnData& aConnData);
+		TInt	GetDebugConnStatus(TTrkConnStatus& aConnStatus, TDes& aConnMsg);
+		void    DebugConnStatusNotify(TDes8& aConnStatus, TDes& aConnMsg, TRequestStatus& aStatus);
+        TInt    DebugConnStatusNotifyCancel();
+		TInt	GetDebuggingStatus(TBool& aDebugging);
+		void    DebuggingStatusNotify(TDes8& aDebugging, TRequestStatus& aStatus);
+		TInt    DebuggingStatusNotifyCancel();
+		TInt    GetPlugAndPlayType(TBool& aPlugandPlay);
+		TInt    SetPlugAndPlayType(TBool aPlugandPlay);
+		TInt	ShutDownServer();
+};
+
+#endif //__TrkSrvCliSession_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/xtidriver/Distribution.Policy.S60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+0
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/xtidriver/TrkXtiComm.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,135 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKXTICOMM_H__
+#define __TRKXTICOMM_H__
+
+//
+// class TCapsTrkXtiDriver
+//
+class TCapsTrkXtiDriver
+{
+public:
+	TVersion	iVersion;
+};
+
+
+
+
+//
+// class RTrkXtiDriver
+//
+class RTrkXtiDriver : public RBusLogicalChannel
+{
+public:
+
+	enum TControl
+	{
+		EControlWrite = 0,
+	};
+	
+	enum TRequest
+	{
+		ERequestRead=0x0, ERequestReadCancel=0x1,
+		ERequestWrite=0x1,ERequestWriteCancel=0x2,
+	};	
+		
+public:
+
+	inline TInt Open();
+	inline void Read(TRequestStatus &aStatus, TDes8 &aDes);
+	inline void Read(TRequestStatus &aStatus, TDes8 &aDes, TInt aLength);
+	inline void ReadOneOrMore(TRequestStatus &aStatus, TDes8 &aDes);
+	inline void ReadCancel();
+	inline void Write(TRequestStatus &aStatus, const TDesC8 &aDes);
+	inline void Write(TRequestStatus &aStatus, const TDesC8 &aDes, TInt aLength);
+	inline TInt Write(const TDesC8 &aDes);
+	inline TInt Write(const TDesC8 &aDes, TInt aLength);
+	inline void WriteCancel();
+
+};
+
+
+_LIT(KTrkXtiDriverName,"TrkXti Driver");
+
+// Version information
+const TInt KMajorXtiVersionNumber=1;
+const TInt KMinorXtiVersionNumber=0;
+const TInt KBuildXtiVersionNumber=0;
+
+
+inline TInt RTrkXtiDriver::Open()
+{
+	#ifdef EKA2
+	return DoCreate(KTrkXtiDriverName, TVersion(KMajorXtiVersionNumber, KMinorXtiVersionNumber, KBuildXtiVersionNumber), KNullUnit, NULL, NULL);
+	#else
+	return DoCreate(KTrkXtiDriverName, TVersion(KMajorXtiVersionNumber, KMinorXtiVersionNumber, KBuildXtiVersionNumber), NULL, KNullUnit, NULL, NULL);
+	#endif
+}
+
+inline void RTrkXtiDriver::Read(TRequestStatus &aStatus, TDes8 &aDes)
+{
+	TInt len = aDes.MaxLength();
+	DoRequest(ERequestRead, aStatus, &aDes, &len);
+}
+
+inline void RTrkXtiDriver::Read(TRequestStatus &aStatus, TDes8 &aDes, TInt aLength)
+{
+	DoRequest(ERequestRead, aStatus, &aDes, &aLength);
+}
+
+inline void RTrkXtiDriver::ReadOneOrMore(TRequestStatus &aStatus, TDes8 &aDes)
+{
+	TInt len = (-aDes.MaxLength());
+	DoRequest(ERequestRead, aStatus, &aDes, &len);
+}
+
+inline void RTrkXtiDriver::ReadCancel()
+{
+	DoCancel(ERequestReadCancel);
+}
+
+inline void RTrkXtiDriver::Write(TRequestStatus &aStatus, const TDesC8 &aDes)
+{ 
+	TInt len=aDes.Length();
+	DoRequest(ERequestWrite, aStatus, (TAny *)&aDes, &len);
+}
+
+inline void RTrkXtiDriver::Write(TRequestStatus &aStatus, const TDesC8 &aDes, TInt aLength)
+{
+	DoRequest(ERequestWrite, aStatus, (TAny *)&aDes, &aLength);
+}
+
+inline TInt RTrkXtiDriver::Write(const TDesC8 &aDes)
+{ 
+	TInt len=aDes.Length();
+	return DoControl(EControlWrite, reinterpret_cast<TAny*>(len), (TAny*)&aDes);
+}
+
+inline TInt RTrkXtiDriver::Write(const TDesC8 &aDes, TInt aLength)
+{
+	return DoControl(EControlWrite, reinterpret_cast<TAny*>(aLength), (TAny*)&aDes);
+}
+
+inline void RTrkXtiDriver::WriteCancel()
+{
+	DoCancel(ERequestWriteCancel);
+}
+
+
+#endif // __TRKXTICOMM_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/xtidriver/TrkXtiDriver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,364 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifdef __WINS__
+#error - this driver cannot be built for emulation
+#endif
+
+#include <e32def.h>
+#include <e32cmn.h>
+#include <kernel.h>
+#include <kern_priv.h>
+#include <arm.h>
+
+#include "TrkXtiComm.h"
+#include "TrkXtiDriver.h"
+
+#define KTrkAppSecurUid 0x200170BB
+#define KTrkExeSecurUid 0x200159E2
+
+//
+// Static function definitions
+//
+
+
+//
+//
+// DTrkXtiDriverFactory implementation
+//
+//
+
+//
+// DTrkXtiDriverFactory constructor
+//
+DTrkXtiDriverFactory::DTrkXtiDriverFactory()
+{
+    iVersion = TVersion(KMajorXtiVersionNumber, KMinorXtiVersionNumber, KBuildXtiVersionNumber);    
+}
+
+//
+// DTrkXtiDriverFactory::Create
+//
+TInt DTrkXtiDriverFactory::Create(DLogicalChannelBase*& aChannel)
+{
+	if (iOpenChannels != 0)
+		return KErrInUse; // a channel is already open
+	
+	aChannel = new DTrkXtiChannel(this);
+	
+	return aChannel ? KErrNone : KErrNoMemory;
+}
+
+//
+// DTrkXtiDriverFactory::Install
+//
+TInt DTrkXtiDriverFactory::Install()
+{
+    return(SetName(&KTrkXtiDriverName));
+}
+
+//
+// DTrkXtiDriverFactory::Install
+//
+void DTrkXtiDriverFactory::GetCaps(TDes8& aDes) const
+{
+    TCapsTrkXtiDriver b;
+    b.iVersion = TVersion(KMajorXtiVersionNumber, KMinorXtiVersionNumber, KBuildXtiVersionNumber);
+    
+    Kern::InfoCopy(aDes,(TUint8*)&b, sizeof(b));
+}
+
+
+//
+//
+// DTrkXtiChannel implementation
+//
+//
+
+//
+// DTrkXtiChannel constructor
+//
+DTrkXtiChannel::DTrkXtiChannel(DLogicalDevice* aLogicalDevice)
+					: iRxPendingMsg(EFalse),
+					  iInterruptId(76)
+{
+	
+	LOG_MSG("DTrkXtiChannel::DTrkXtiChannel()");
+
+	iDevice = aLogicalDevice;
+	
+	iClientThread = &Kern::CurrentThread();
+	TInt err = iClientThread->Open();	
+	
+	
+	LOG_MSG("DTrkXtiChannel::DTrkXtiChannel() End"); 
+}
+
+//
+// DTrkXtiChannel destructor
+//
+DTrkXtiChannel::~DTrkXtiChannel()
+{
+	LOG_MSG("DTrkXtiChannel::~DTrkXtiChannel()");
+	
+	Kern::SafeClose((DObject*&)iClientThread, NULL);
+	
+	if (iLock)
+		iLock->Close(NULL);	
+}
+
+//
+// DTrkXtiChannel::DoCreate
+//
+TInt DTrkXtiChannel::DoCreate(TInt /*aUnit*/, const TDesC* /*anInfo*/, const TVersion& aVer)
+{
+	LOG_MSG("DTrkXtiChannel::DoCreate()");
+
+  	if (!Kern::QueryVersionSupported(TVersion(KMajorXtiVersionNumber, KMinorXtiVersionNumber, KBuildXtiVersionNumber), aVer))
+		return KErrNotSupported; 
+
+	//Setup the driver for receiving client messages
+	iDFCQue = NULL;
+	TBuf8<KMaxInfoName> xtiDFC = _L8("XTI DFC");;
+	
+	TInt err = Kern::DfcQCreate(iDFCQue, 27, &xtiDFC);
+	if (err == KErrNone)
+	{
+		SetDfcQ(iDFCQue);
+	}
+	else
+	{
+		SetDfcQ(Kern::DfcQue0());
+	}
+
+	iMsgQ.Receive();  	
+	
+	// create subscriber and subscribe to receive trk messages from TraceCore
+	iTrkXtiSubscriber = new DTrkXtiSubscriber;
+ 	if (!iTrkXtiSubscriber)
+		return KErrNoMemory;
+ 	
+	err = iTrkXtiSubscriber->Create(this, iClientThread);
+	if (err != KErrNone)
+		return err;
+	
+	err = Kern::SemaphoreCreate(iLock, _L("TrkXtiDriverWriteLock"), 1 /* Initial count */);
+	if (err != KErrNone)
+		return err;
+
+	return KErrNone;
+}
+
+//
+// DTrkXtiChannel::DoCancel
+//
+void DTrkXtiChannel::DoCancel(TInt aReqNo)
+{
+	LOG_MSG("DTrkXtiChannel::DoCancel()");
+	
+	switch(aReqNo)
+	{
+		case RTrkXtiDriver::ERequestReadCancel:
+		{
+			Kern::RequestComplete(iClientThread, iRxRequestStatus, KErrCancel);
+			iRxClientBuffer = NULL;
+			iRxRequestStatus = NULL;
+			iRxClientBufferLength = 0;
+		}
+		break;
+	}
+
+}
+
+//
+// DTrkXtiChannel::DoRequest
+//
+void DTrkXtiChannel::DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2)
+{
+	LOG_MSG("DTrkXtiChannel::DoRequest()");
+		
+	switch(aReqNo)
+	{
+		case RTrkXtiDriver::ERequestRead:
+		{
+			iRxRequestStatus = aStatus;
+			iRxClientBuffer = a1;
+			iRxClientBufferLength = (TUint32)a2;
+			
+			if (iRxPendingMsg)
+			{
+				TInt err = Kern::ThreadDesWrite(iClientThread, iRxClientBuffer, iRxPendingMsgBuffer, 0, KChunkShiftBy0, iClientThread);
+				Kern::RequestComplete(iClientThread, iRxRequestStatus, err);
+		
+				iRxRequestStatus = NULL;
+				iRxPendingMsg = EFalse;
+			}
+
+			break;
+		}		
+		default:
+			Kern::RequestComplete(iClientThread, aStatus, KErrNotSupported);
+	}
+}
+
+//
+// DTrkXtiChannel::DoControl
+//
+TInt DTrkXtiChannel::DoControl(TInt aFunction, TAny* a1, TAny* a2)
+{
+	LOG_MSG("DTrkXtiChannel::DoControl()");
+	
+	TInt err = KErrNone;
+	
+	switch(aFunction)
+	{
+		case RTrkXtiDriver::EControlWrite:
+		{
+			//lock the Semaphore so that write doesn't happen when a write is already in progress.
+			Kern::SemaphoreWait(*iLock);
+			err = DoWrite((TUint32)a1, a2);			
+			Kern::SemaphoreSignal(*iLock);			
+			break;
+		}
+		default:
+		{
+			return KErrGeneral;
+		}
+
+	}
+	if (KErrNone != err)
+	{
+		LOG_MSG2("Error %d from control function", err);
+	}
+	return err;
+}
+
+//
+// DTrkXtiChannel::HandleMsg
+//
+void DTrkXtiChannel::HandleMsg(TMessageBase* aMsg)
+{
+	LOG_MSG("DTrkXtiChannel::HandleMsg()");
+	
+	TThreadMessage& m = *(TThreadMessage*)aMsg;
+	TInt id = m.iValue;
+
+
+	if (id == (TInt)ECloseMsg)
+	{
+        if (iTrkXtiSubscriber)
+        {
+            Kern::SemaphoreWait(*iLock);
+            delete iTrkXtiSubscriber;
+            iTrkXtiSubscriber = NULL;   
+            Kern::SemaphoreSignal(*iLock);              
+        }
+		m.Complete(KErrNone, EFalse);
+		return;
+	}
+
+	if (id == KMaxTInt)
+	{
+		// DoCancel
+		DoCancel(m.Int0());
+		m.Complete(KErrNone, ETrue); 
+		return;
+	}
+
+	if (id < 0)
+	{
+		// DoRequest
+		TRequestStatus* pStatus = (TRequestStatus*)m.Ptr0();
+		DoRequest(~id, pStatus, m.Ptr1(), m.Ptr2());
+		m.Complete(KErrNone, ETrue);
+	}
+	else
+	{
+		// DoControl
+		TInt err = DoControl(id, m.Ptr0(), m.Ptr1());
+		m.Complete(err, ETrue);
+	}
+}
+
+//
+// DTrkXtiChannel::DoWrite
+//
+TInt DTrkXtiChannel::DoWrite(TUint32 aLength, TAny* a2)
+{
+	LOG_MSG("DTrkXtiChannel::DoWrite()");
+
+	TInt err = KErrNone;
+
+	err = Kern::ThreadDesRead(iClientThread, a2, iTxBuffer, 0, KChunkShiftBy0);
+
+	if (err == KErrNone)
+	{	
+		err = WriteXtiChannel(iTxBuffer);
+	}
+	return err;
+}
+
+//
+// DTrkXtiChannel::WriteXtiChannel
+//
+// This function writes all the data in the descriptor in one message
+TInt DTrkXtiChannel::WriteXtiChannel(TDesC8& aDes)
+{
+	TInt err = KErrNone;
+		err = iTrkXtiSubscriber->Send(aDes);
+
+	return err;
+}
+
+
+
+
+
+//
+// DTrkXtiChannel::DoCompleteRx
+//
+void DTrkXtiChannel::DoCompleteRx(const TDesC8& aMessage)
+{
+	LOG_MSG("DTrkXtiChannel::DoCompleteRx()");
+
+	// If there is a pending read request, complete the request with this message.
+	// Otherwise store the message, ideally we should queue the messages, but having 
+	// a large buffer is failing to initialize at the startup.
+	// For now, we will just store only one message
+	// If for some reason, TRK is waiting on something and doesn't read for a while, 
+	// then its possible that we will loose messages. 
+	Kern::SemaphoreWait(*iLock);
+	if (iRxRequestStatus)
+	{
+		TInt err = Kern::ThreadDesWrite(iClientThread, iRxClientBuffer, aMessage, 0, KChunkShiftBy0, iClientThread);
+		Kern::RequestComplete(iClientThread, iRxRequestStatus, err);
+		
+		iRxRequestStatus = NULL;
+	}
+	else if (!iRxPendingMsg)
+	{
+		iRxPendingMsgBuffer.Copy(aMessage);
+		iRxPendingMsg = ETrue;
+	}
+	Kern::SemaphoreSignal(*iLock);
+}
+
+DECLARE_STANDARD_LDD()
+{
+    return new DTrkXtiDriverFactory;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/xtidriver/TrkXtiDriver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,108 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKXTIDRIVER_H__
+#define __TRKXTIDRIVER_H__
+
+#include "TrkXtiSubscriber.h"
+
+// Debug messages
+#ifdef _DEBUG
+#define LOG_MSG(x) Kern::Printf(x)
+#define LOG_MSG2(x, y) Kern::Printf(x, y)
+#else
+#define LOG_MSG(x)
+#define LOG_MSG2(x, y)
+#endif
+
+//class DTrkXtiSubscriber;
+//
+// Macros
+//
+#define MAXMESSAGESIZE	0x0900
+#define KTRKXTIDRIVERREQ 0x44;
+const TInt kIntTrkMessageId = 0x44;
+
+//
+// class DTrkXtiDriverFactory
+//
+class DTrkXtiDriverFactory : public DLogicalDevice
+{
+public:
+
+	DTrkXtiDriverFactory();
+	virtual TInt Install();
+	virtual void GetCaps(TDes8& aDes) const;
+	virtual TInt Create(DLogicalChannelBase*& aChannel);
+};
+
+//
+// DTrkXtiChannel
+//
+class DTrkXtiChannel : public DLogicalChannel					  								
+{
+public:
+
+	DTrkXtiChannel(DLogicalDevice* aLogicalDevice);
+	~DTrkXtiChannel();
+
+	virtual TInt DoCreate(TInt aUnit, const TDesC* anInfo, const TVersion& aVer);	
+	virtual void HandleMsg(TMessageBase* aMsg);
+    
+    void DoCompleteRx(const TDesC8& aMessage);	
+	
+	
+protected: // from DLogicalChannel
+	virtual void DoCancel(TInt aReqNo);
+	virtual void DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
+	virtual TInt DoControl(TInt aFunction, TAny *a1, TAny *a2);
+	
+	
+private:
+	TInt DoWrite(TUint32 aLength, TAny* a2);
+	TInt DoRead();
+
+	TInt WriteXtiChannel(TDesC8& aDes);
+	void ReadXtiChannel();
+
+		
+private:
+		
+	DThread* iClientThread;
+	
+	TRequestStatus* iRequestGetEventStatus;
+	
+	TAny* iRxClientBuffer;
+	TUint32 iRxClientBufferLength;
+
+	TBuf8<MAXMESSAGESIZE> iTxBuffer;
+	TBuf8<MAXMESSAGESIZE> iRxPendingMsgBuffer;
+	TBool iRxPendingMsg;
+	
+	TRequestStatus* iRxRequestStatus;
+	
+	TInt iInterruptId;
+	
+	DSemaphore* iLock;
+	
+	TDfcQue* iDFCQue;
+	
+	DTrkXtiSubscriber *iTrkXtiSubscriber;
+};
+
+#endif //__TRKXTIDRIVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/xtidriver/TrkXtiDriver.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include <platform_paths.hrh>
+#endif
+
+#include <kernel/kern_ext.mmh>
+
+// For including the XTI driver in the build, please uncomment the line below
+// and also uncomment the same in trk.iby file in ..\..\rom folder.
+//#define _ENABLE_XTI_DRIVER_
+
+#if defined (_ENABLE_XTI_DRIVER_) || defined (FF_PLATFORM_SIMULATOR)
+
+
+macro 	__OEM_TRK__
+
+TARGET			TrkXtiDriver.ldd
+TARGETTYPE		LDD
+UID				0x100000AF 0x200159DD
+SOURCEPATH		.
+SOURCE			TrkXtiDriver.cpp
+SOURCE			TrkXtiSubscriber.cpp
+
+LIBRARY			tracecore.lib
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+
+systeminclude		\epoc32\include
+systeminclude		\epoc32\include\nkern 
+systeminclude 		\epoc32\include\kernel
+systeminclude		\epoc32\include\internal
+systeminclude		\epoc32\include\kernel\arm
+systeminclude		\epoc32\include\nkern\arm
+systeminclude		\epoc32\include\memmodel\epoc
+systeminclude		\epoc32\include\memmodel\epoc\mmubase
+
+DEFFILE			..\eabi\trkxtidriver.def
+
+#else
+
+OS_LAYER_KERNEL_SYSTEMINCLUDE
+systeminclude		/epoc32/include/internal
+
+DEFFILE			../eabi/trkxtidriver.def
+
+#endif
+
+NOSTRICTDEF
+
+
+VENDORID VID_DEFAULT
+capability			all
+
+#else
+
+TARGETTYPE NONE
+
+#endif // _ENABLE_XTI_DRIVER_ || FF_PLATFORM_SIMULATOR
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/xtidriver/TrkXtiSubscriber.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,143 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <e32def.h>
+#include <e32cmn.h>
+#include <arm.h>
+#include <kernel.h>
+#include <kern_priv.h>
+#include <nk_trace.h>
+
+#include "TrkXtiComm.h"
+
+#include "TrkXtiDriver.h"
+#include "TrkXtiSubscriber.h"
+
+/**
+ * Constructor
+ */
+DTrkXtiSubscriber::DTrkXtiSubscriber() : 
+					iTraceMessageInitialized(FALSE),
+					iHeaderBuf(NULL)
+{
+	LOG_MSG("DTrkXtiSubscriber::DTrkXtiSubscriber()");
+}
+
+DTrkXtiSubscriber::~DTrkXtiSubscriber() 
+{
+	LOG_MSG("DTrkXtiSubscriber::~DTrkXtiSubscriber()");
+	// Unsubscribe here
+	Unsubscribe(kIntTrkMessageId);
+	if (iHeaderBuf)
+	{
+		delete iHeaderBuf;
+		iHeaderBuf = NULL;
+	}
+	
+}
+
+TInt DTrkXtiSubscriber::Create(DTrkXtiChannel* aChannel, DThread* aClient)
+{
+	LOG_MSG("DTrkXtiSubscriber::Create()");
+	
+	iChannel = aChannel; //Don't add ref the channel, since channel closes the event handler before it ever gets destroyed.
+
+	TInt err = aClient->Open();
+	
+	if (err != KErrNone)
+	{
+		LOG_MSG("DTrkXtiSubscriber::Create() - Thread Opened, error");
+		return err;
+	}
+		
+	iClientThread = aClient;
+
+	// subscribe to receive trk messages from TraceCore
+	err = Subscribe( kIntTrkMessageId ); //  To do: replace with SOS_MON_TRK_SEND_MESSAGE_REQ 
+
+	if (err != KErrNone)
+
+		return err;
+		
+	return KErrNone;	
+
+}
+
+void DTrkXtiSubscriber::MessageReceived(TTraceMessage& aMessage)
+
+{ 
+	LOG_MSG("DTrkXtiSubscriber::MessageReceived()");
+
+	if (!iTraceMessageInitialized)
+	{ 
+
+		iTraceMessage.iHeader = NULL;
+
+		iTraceMessageInitialized = TRUE; 
+
+	}
+	
+	StoreMessage (aMessage);
+	// iTraceMessage.iMessageId = 0x45;  
+	LOG_MSG2("iTraceMessage.iHeader->Length() = %d", iTraceMessage.iHeader->Length());
+  	LOG_MSG2("aMessage.iHeader->Length() = %d", aMessage.iHeader->Length());
+  	LOG_MSG2("aMessage.iData->Length() = %d", aMessage.iData->Length());
+
+	iChannel->DoCompleteRx(*aMessage.iData);
+
+}
+
+TInt DTrkXtiSubscriber::Send(TDesC8& aMessage)
+{
+	LOG_MSG("DTrkXtiSubscriber::Send()");
+	
+	if (!iTraceMessageInitialized)
+	{
+		LOG_MSG("Trace message header not initialized");
+		return KErrNotReady;
+	}
+		
+	
+	iTraceMessage.iData = &aMessage;
+	// Replace this with SOS_MON_TRK_SEND_MESSAGE_RESP when get the new tracecore header
+	iTraceMessage.iMessageId = 0x45;
+	
+	TInt err = KErrNone;
+	
+	err = iMessageSender->SendMessage(iTraceMessage);
+	LOG_MSG2("iMessageSender->SendMessage, error = %d", err);
+	LOG_MSG2("iTraceMessage.iHeader->Length() = %d", iTraceMessage.iHeader->Length());
+	LOG_MSG2("iTraceMessage.iData->Length() = %d", iTraceMessage.iData->Length());
+	
+	return err;
+}
+
+/**
+ * Stores the header from the incoming message
+ */
+void DTrkXtiSubscriber::StoreMessage( const TTraceMessage& aMessage )
+{
+    LOG_MSG("DTrkXtiSubscriber::StoreMessage()");
+    if (iHeaderBuf == NULL)
+    {
+        iHeaderBuf = HBuf8::New(aMessage.iHeader->Length( ));
+    }
+    iHeaderBuf->Copy( *aMessage.iHeader );
+    iTraceMessage = aMessage; // Copy message
+    iTraceMessage.iHeader = iHeaderBuf; // Assign copy of header
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgagents/trkagent/xtidriver/TrkXtiSubscriber.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __TRKXTISUBSCRIBER_H__
+#define __TRKXTISUBSCRIBER_H__
+
+#include <TraceCoreSubscriber.h>
+#include <TraceCoreMessageSender.h>
+
+class DTrkXtiChannel;
+
+class DTrkXtiSubscriber : public DTraceCoreSubscriber
+{
+public:
+	DTrkXtiSubscriber();
+	~DTrkXtiSubscriber();
+	
+	TInt Create(DTrkXtiChannel* aChannel, DThread* aClient);
+
+	TInt Send(TDesC8& aMessage);
+    void MessageReceived(TTraceMessage& aMessage);
+    
+    void StoreMessage(const TTraceMessage& aMessage);
+    
+private:
+    
+    TTraceMessage iTraceMessage;
+	TBool		  iTraceMessageInitialized;
+    
+   	DThread* iClientThread;
+	DTrkXtiChannel* iChannel;
+	HBuf8* iHeaderBuf;
+};
+
+#endif //__TRKXTISUBSCRIBER_H__
Binary file dbgguides/dbgsolutionsguide/com.nokia.debug_0.1.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgguides/dbgsolutionsguide/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,3 @@
+
+PRJ_EXPORTS
+../com.nokia.debug_0.1.jar /plugins/com.nokia.debug_0.1.jar
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgguides/dbgsolutionsguide/group/dbgsolutionsguide.mrp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,9 @@
+component	dev_devicedbgsrvs_dbgguides_dbgsolutionsguide
+
+source /src/tools/dev/devicedbgsrvs/dbgguides/dbgsolutionsguide/com.nokia.debug_0.1.jar
+source /src/tools/dev/devicedbgsrvs/dbgguides/dbgsolutionsguide/group/dbgsolutionsguide.mrp
+source /src/tools/dev/devicedbgsrvs/dbgguides/dbgsolutionsguide/group/bld.inf
+
+exports /src/tools/dev/devicedbgsrvs/dbgguides/dbgsolutionsguide/group
+
+notes_source	\component_defs\release.src
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/bwins/cdssupportu.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,117 @@
+EXPORTS
+	?SvcStackAddr@CThreadInfo@@QBEIXZ @ 1 NONAME ; unsigned int CThreadInfo::SvcStackAddr(void) const
+	?PassivelyDebugged@CExecutableInfo@@QBEHXZ @ 2 NONAME ; int CExecutableInfo::PassivelyDebugged(void) const
+	?NewL@CExecutableInfo@@SAPAV1@ABVTDesC8@@@Z @ 3 NONAME ; class CExecutableInfo * CExecutableInfo::NewL(class TDesC8 const &)
+	?GetContent8@TRegisterData@@QBEEXZ @ 4 NONAME ; unsigned char TRegisterData::GetContent8(void) const
+	?SetContent8@TRegisterData@@QAEXE@Z @ 5 NONAME ; void TRegisterData::SetContent8(unsigned char)
+	?Prompt@COptionConfig@@QBEABVTDesC16@@XZ @ 6 NONAME ; class TDesC16 const & COptionConfig::Prompt(void) const
+	?ExternalizeL@TCrashInfo@@QAEXAAVRWriteStream@@PAVCBufFlat@@@Z @ 7 NONAME ; void TCrashInfo::ExternalizeL(class RWriteStream &, class CBufFlat *)
+	?Instance@COptionConfig@@QAEXJ@Z @ 8 NONAME ; void COptionConfig::Instance(long)
+	?Pair@CPluginInfo@@QBEIXZ @ 9 NONAME ; unsigned int CPluginInfo::Pair(void) const
+	?SetContent32@TRegisterData@@QAEXK@Z @ 10 NONAME ; void TRegisterData::SetContent32(unsigned long)
+	?Name@CExecutableInfo@@QBEABVTDesC16@@XZ @ 11 NONAME ; class TDesC16 const & CExecutableInfo::Name(void) const
+	?Observed@CThreadInfo@@QBEHXZ @ 12 NONAME ; int CThreadInfo::Observed(void) const
+	?Type@CPluginInfo@@QBE?AW4TPluginType@TPluginRequest@@XZ @ 13 NONAME ; enum TPluginRequest::TPluginType CPluginInfo::Type(void) const
+	?Pair@CPluginInfo@@QAEXI@Z @ 14 NONAME ; void CPluginInfo::Pair(unsigned int)
+	?MaxSize@CExecutableInfo@@SAHXZ @ 15 NONAME ; int CExecutableInfo::MaxSize(void)
+	?Name@CThreadInfo@@QBEABVTDesC16@@XZ @ 16 NONAME ; class TDesC16 const & CThreadInfo::Name(void) const
+	??1COptionConfig@@UAE@XZ @ 17 NONAME ; COptionConfig::~COptionConfig(void)
+	?SvcStackSize@CThreadInfo@@QBEIXZ @ 18 NONAME ; unsigned int CThreadInfo::SvcStackSize(void) const
+	?NewL@COptionConfig@@SAPAV1@ABVTDesC8@@@Z @ 19 NONAME ; class COptionConfig * COptionConfig::NewL(class TDesC8 const &)
+	?MaxSize@CThreadInfo@@SAHXZ @ 20 NONAME ; int CThreadInfo::MaxSize(void)
+	?Version@CPluginInfo@@QAEXI@Z @ 21 NONAME ; void CPluginInfo::Version(unsigned int)
+	?NameL@CPluginInfo@@QAEXABVTDesC16@@@Z @ 22 NONAME ; void CPluginInfo::NameL(class TDesC16 const &)
+	??1CPluginInfo@@UAE@XZ @ 23 NONAME ; CPluginInfo::~CPluginInfo(void)
+	?Value@COptionConfig@@QAEXJ@Z @ 24 NONAME ; void COptionConfig::Value(long)
+	??1CThreadInfo@@UAE@XZ @ 25 NONAME ; CThreadInfo::~CThreadInfo(void)
+	?MarshalDataL@CStreamElementBase@@QAEPAVHBufC8@@XZ @ 26 NONAME ; class HBufC8 * CStreamElementBase::MarshalDataL(void)
+	?ActivelyDebugged@CExecutableInfo@@QBEHXZ @ 27 NONAME ; int CExecutableInfo::ActivelyDebugged(void) const
+	?InternalizeL@CExecutableInfo@@UAEXAAVRReadStream@@@Z @ 28 NONAME ; void CExecutableInfo::InternalizeL(class RReadStream &)
+	?Uid@CPluginInfo@@QBEHXZ @ 29 NONAME ; int CPluginInfo::Uid(void) const
+	??0COptionConfig@@AAE@XZ @ 30 NONAME ; COptionConfig::COptionConfig(void)
+	?ExternalizeL@COptionConfig@@UAEXAAVRWriteStream@@PAVCBufFlat@@@Z @ 31 NONAME ; void COptionConfig::ExternalizeL(class RWriteStream &, class CBufFlat *)
+	?ValueAsDesc@COptionConfig@@QBEABVTDesC16@@XZ @ 32 NONAME ; class TDesC16 const & COptionConfig::ValueAsDesc(void) const
+	?SetContent16@TRegisterData@@QAEXG@Z @ 33 NONAME ; void TRegisterData::SetContent16(unsigned short)
+	?ExternalizeL@CPluginInfo@@UAEXAAVRWriteStream@@PAVCBufFlat@@@Z @ 34 NONAME ; void CPluginInfo::ExternalizeL(class RWriteStream &, class CBufFlat *)
+	?Uid@CPluginInfo@@QAEXH@Z @ 35 NONAME ; void CPluginInfo::Uid(int)
+	?Available@TRegisterData@@QBEHXZ @ 36 NONAME ; int TRegisterData::Available(void) const
+	?PassivelyDebugged@CExecutableInfo@@QAEXH@Z @ 37 NONAME ; void CExecutableInfo::PassivelyDebugged(int)
+	?Options@COptionConfig@@QBEABVTDesC16@@XZ @ 38 NONAME ; class TDesC16 const & COptionConfig::Options(void) const
+	?MaxSize@CProcessInfo@@SAHXZ @ 39 NONAME ; int CProcessInfo::MaxSize(void)
+	?Name@CPluginInfo@@QBEABVTDesC16@@XZ @ 40 NONAME ; class TDesC16 const & CPluginInfo::Name(void) const
+	?ActivelyDebugged@CExecutableInfo@@QAEXH@Z @ 41 NONAME ; void CExecutableInfo::ActivelyDebugged(int)
+	?GetSubId@TRegisterData@@QBEGXZ @ 42 NONAME ; unsigned short TRegisterData::GetSubId(void) const
+	?MaxSize@TCrashInfo@@SAHXZ @ 43 NONAME ; int TCrashInfo::MaxSize(void)
+	?Index@COptionConfig@@QBEKXZ @ 44 NONAME ; unsigned long COptionConfig::Index(void) const
+	?Size@CProcessInfo@@UBEHXZ @ 45 NONAME ; int CProcessInfo::Size(void) const
+	?NameL@CExecutableInfo@@QAEXABVTDesC16@@@Z @ 46 NONAME ; void CExecutableInfo::NameL(class TDesC16 const &)
+	?NewL@CPluginInfo@@SAPAV1@ABVTDesC8@@@Z @ 47 NONAME ; class CPluginInfo * CPluginInfo::NewL(class TDesC8 const &)
+	?Observed@CProcessInfo@@QBEHXZ @ 48 NONAME ; int CProcessInfo::Observed(void) const
+	?Instance@COptionConfig@@QBEKXZ @ 49 NONAME ; unsigned long COptionConfig::Instance(void) const
+	?ValueL@COptionConfig@@QAEXABVTDesC16@@@Z @ 50 NONAME ; void COptionConfig::ValueL(class TDesC16 const &)
+	?Size@CPluginInfo@@UBEHXZ @ 51 NONAME ; int CPluginInfo::Size(void) const
+	?GetClass@TRegisterData@@QBEEXZ @ 52 NONAME ; unsigned char TRegisterData::GetClass(void) const
+	?Id@CThreadInfo@@QBEAB_KXZ @ 53 NONAME ; unsigned long long const & CThreadInfo::Id(void) const
+	?NumOptions@COptionConfig@@QBEKXZ @ 54 NONAME ; unsigned long COptionConfig::NumOptions(void) const
+	?NewL@CExecutableInfo@@SAPAV1@ABVTDesC16@@HH@Z @ 55 NONAME ; class CExecutableInfo * CExecutableInfo::NewL(class TDesC16 const &, int, int)
+	?Size@CThreadInfo@@UBEHXZ @ 56 NONAME ; int CThreadInfo::Size(void) const
+	?InternalizeL@COptionConfig@@UAEXAAVRReadStream@@@Z @ 57 NONAME ; void COptionConfig::InternalizeL(class RReadStream &)
+	?NameL@CProcessInfo@@QAEXABVTDesC16@@@Z @ 58 NONAME ; void CProcessInfo::NameL(class TDesC16 const &)
+	?SetContent@TRegisterData@@QAEXI@Z @ 59 NONAME ; void TRegisterData::SetContent(unsigned int)
+	?ValueAsBool@COptionConfig@@QBEHXZ @ 60 NONAME ; int COptionConfig::ValueAsBool(void) const
+	?Priority@CThreadInfo@@QBEIXZ @ 61 NONAME ; unsigned int CThreadInfo::Priority(void) const
+	?NewL@CPluginInfo@@SAPAV1@ABVTDesC16@@HIW4TPluginType@TPluginRequest@@@Z @ 62 NONAME ; class CPluginInfo * CPluginInfo::NewL(class TDesC16 const &, int, unsigned int, enum TPluginRequest::TPluginType)
+	??0TCrashInfo@@QAE@XZ @ 63 NONAME ; TCrashInfo::TCrashInfo(void)
+	?NameL@CThreadInfo@@QAEXABVTDesC16@@@Z @ 64 NONAME ; void CThreadInfo::NameL(class TDesC16 const &)
+	?GetContent32@TRegisterData@@QBEKXZ @ 65 NONAME ; unsigned long TRegisterData::GetContent32(void) const
+	?NewL@CProcessInfo@@SAPAV1@ABVTDesC8@@@Z @ 66 NONAME ; class CProcessInfo * CProcessInfo::NewL(class TDesC8 const &)
+	?NewL@CThreadInfo@@SAPAV1@AB_KABVTDesC16@@0ABIABK3232@Z @ 67 NONAME ; class CThreadInfo * CThreadInfo::NewL(unsigned long long const &, class TDesC16 const &, unsigned long long const &, unsigned int const &, unsigned long const &, unsigned long const &, unsigned int const &, unsigned long const &, unsigned int const &)
+	?NewL@TCrashInfo@@SAPAV1@ABVTCrashInfoHeader@Debug@@@Z @ 68 NONAME ; class TCrashInfo * TCrashInfo::NewL(class Debug::TCrashInfoHeader const &)
+	?Value@COptionConfig@@QBEJXZ @ 69 NONAME ; long COptionConfig::Value(void) const
+	?SameRegister@TRegisterData@@QBEHABV1@@Z @ 70 NONAME ; int TRegisterData::SameRegister(class TRegisterData const &) const
+	?GetContent64@TRegisterData@@QBE_KXZ @ 71 NONAME ; unsigned long long TRegisterData::GetContent64(void) const
+	?GetSize@TRegisterData@@QBEEXZ @ 72 NONAME ; unsigned char TRegisterData::GetSize(void) const
+	?SetContent64@TRegisterData@@QAEX_K@Z @ 73 NONAME ; void TRegisterData::SetContent64(unsigned long long)
+	?Version@CPluginInfo@@QBEIXZ @ 74 NONAME ; unsigned int CPluginInfo::Version(void) const
+	?GetId@TRegisterData@@QBEGXZ @ 75 NONAME ; unsigned short TRegisterData::GetId(void) const
+	?SetContent@TRegisterData@@QAEXABV1@@Z @ 76 NONAME ; void TRegisterData::SetContent(class TRegisterData const &)
+	?InternalizeL@TCrashInfo@@QAEXAAVRReadStream@@@Z @ 77 NONAME ; void TCrashInfo::InternalizeL(class RReadStream &)
+	?ExternalizeL@CThreadInfo@@UAEXAAVRWriteStream@@PAVCBufFlat@@@Z @ 78 NONAME ; void CThreadInfo::ExternalizeL(class RWriteStream &, class CBufFlat *)
+	?Type@CPluginInfo@@QAEXW4TPluginType@TPluginRequest@@@Z @ 79 NONAME ; void CPluginInfo::Type(enum TPluginRequest::TPluginType)
+	?ExternalizeL@CProcessInfo@@UAEXAAVRWriteStream@@PAVCBufFlat@@@Z @ 80 NONAME ; void CProcessInfo::ExternalizeL(class RWriteStream &, class CBufFlat *)
+	?Id@CProcessInfo@@QBEAB_KXZ @ 81 NONAME ; unsigned long long const & CProcessInfo::Id(void) const
+	?NewL@CThreadInfo@@SAPAV1@ABVTDesC8@@@Z @ 82 NONAME ; class CThreadInfo * CThreadInfo::NewL(class TDesC8 const &)
+	?NewL@CProcessInfo@@SAPAV1@_KABVTDesC16@@@Z @ 83 NONAME ; class CProcessInfo * CProcessInfo::NewL(unsigned long long, class TDesC16 const &)
+	?Source@COptionConfig@@QBE?AW4TParameterSource@1@XZ @ 84 NONAME ; enum COptionConfig::TParameterSource COptionConfig::Source(void) const
+	?MaxSize@CPluginInfo@@SAHXZ @ 85 NONAME ; int CPluginInfo::MaxSize(void)
+	?Observed@CExecutableInfo@@QAEXH@Z @ 86 NONAME ; void CExecutableInfo::Observed(int)
+	?NewL@COptionConfig@@SAPAV1@ABK0ABW4TParameterSource@1@ABW4TOptionType@1@ABVTDesC16@@03ABJ3@Z @ 87 NONAME ; class COptionConfig * COptionConfig::NewL(unsigned long const &, unsigned long const &, enum COptionConfig::TParameterSource const &, enum COptionConfig::TOptionType const &, class TDesC16 const &, unsigned long const &, class TDesC16 const &, long const &, class TDesC16 const &)
+	??1CExecutableInfo@@UAE@XZ @ 88 NONAME ; CExecutableInfo::~CExecutableInfo(void)
+	?ExternalizeL@CExecutableInfo@@UAEXAAVRWriteStream@@PAVCBufFlat@@@Z @ 89 NONAME ; void CExecutableInfo::ExternalizeL(class RWriteStream &, class CBufFlat *)
+	?Type@COptionConfig@@QBE?AW4TOptionType@1@XZ @ 90 NONAME ; enum COptionConfig::TOptionType COptionConfig::Type(void) const
+	?MaxSize@COptionConfig@@SAHXZ @ 91 NONAME ; int COptionConfig::MaxSize(void)
+	?UsrStackAddr@CThreadInfo@@QBEIXZ @ 92 NONAME ; unsigned int CThreadInfo::UsrStackAddr(void) const
+	?Observed@CProcessInfo@@QAEXH@Z @ 93 NONAME ; void CProcessInfo::Observed(int)
+	??1CProcessInfo@@UAE@XZ @ 94 NONAME ; CProcessInfo::~CProcessInfo(void)
+	?InternalizeL@CPluginInfo@@UAEXAAVRReadStream@@@Z @ 95 NONAME ; void CPluginInfo::InternalizeL(class RReadStream &)
+	?Uid@COptionConfig@@QBEKXZ @ 96 NONAME ; unsigned long COptionConfig::Uid(void) const
+	?GetContent16@TRegisterData@@QBEGXZ @ 97 NONAME ; unsigned short TRegisterData::GetContent16(void) const
+	?Observed@CThreadInfo@@QAEXH@Z @ 98 NONAME ; void CThreadInfo::Observed(int)
+	?Size@COptionConfig@@UBEHXZ @ 99 NONAME ; int COptionConfig::Size(void) const
+	?Size@CExecutableInfo@@UBEHXZ @ 100 NONAME ; int CExecutableInfo::Size(void) const
+	?Observed@CExecutableInfo@@QBEHXZ @ 101 NONAME ; int CExecutableInfo::Observed(void) const
+	?ProcessId@CThreadInfo@@QBEAB_KXZ @ 102 NONAME ; unsigned long long const & CThreadInfo::ProcessId(void) const
+	?InternalizeL@CProcessInfo@@UAEXAAVRReadStream@@@Z @ 103 NONAME ; void CProcessInfo::InternalizeL(class RReadStream &)
+	?NewL@TCrashInfo@@SAPAV1@ABVTDesC8@@@Z @ 104 NONAME ; class TCrashInfo * TCrashInfo::NewL(class TDesC8 const &)
+	?SvcStackPtr@CThreadInfo@@QBEIXZ @ 105 NONAME ; unsigned int CThreadInfo::SvcStackPtr(void) const
+	?Name@CProcessInfo@@QBEABVTDesC16@@XZ @ 106 NONAME ; class TDesC16 const & CProcessInfo::Name(void) const
+	?UsrStackSize@CThreadInfo@@QBEIXZ @ 107 NONAME ; unsigned int CThreadInfo::UsrStackSize(void) const
+	?SetAvailable@TRegisterData@@QAEXH@Z @ 108 NONAME ; void TRegisterData::SetAvailable(int)
+	?InternalizeL@CThreadInfo@@UAEXAAVRReadStream@@@Z @ 109 NONAME ; void CThreadInfo::InternalizeL(class RReadStream &)
+	?SetHeapSize@CThreadInfo@@QAEXK@Z @ 110 NONAME ; void CThreadInfo::SetHeapSize(unsigned long)
+	?SetHeapBase@CThreadInfo@@QAEXK@Z @ 111 NONAME ; void CThreadInfo::SetHeapBase(unsigned long)
+	?LastCpuId@CThreadInfo@@QBEJXZ @ 112 NONAME ; long CThreadInfo::LastCpuId(void) const
+	?SetLastCpuId@CThreadInfo@@QAEXJ@Z @ 113 NONAME ; void CThreadInfo::SetLastCpuId(long)
+	?HeapBase@CThreadInfo@@QBEKXZ @ 114 NONAME ; unsigned long CThreadInfo::HeapBase(void) const
+	?HeapSize@CThreadInfo@@QBEKXZ @ 115 NONAME ; unsigned long CThreadInfo::HeapSize(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/bwins/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/eabi/cdssupportu.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,139 @@
+EXPORTS
+	_ZN11CThreadInfo12ExternalizeLER12RWriteStreamP8CBufFlat @ 1 NONAME
+	_ZN11CThreadInfo12InternalizeLER11RReadStream @ 2 NONAME
+	_ZN11CThreadInfo4NewLERK6TDesC8 @ 3 NONAME
+	_ZN11CThreadInfo4NewLERKyRK7TDesC16S1_RKjRKmS8_S6_S8_S6_ @ 4 NONAME
+	_ZN11CThreadInfo5NameLERK7TDesC16 @ 5 NONAME
+	_ZN11CThreadInfo7MaxSizeEv @ 6 NONAME
+	_ZN11CThreadInfo8ObservedEi @ 7 NONAME
+	_ZN11CThreadInfoD0Ev @ 8 NONAME
+	_ZN11CThreadInfoD1Ev @ 9 NONAME
+	_ZN11CThreadInfoD2Ev @ 10 NONAME
+	_ZN12CProcessInfo12ExternalizeLER12RWriteStreamP8CBufFlat @ 11 NONAME
+	_ZN12CProcessInfo12InternalizeLER11RReadStream @ 12 NONAME
+	_ZN12CProcessInfo4NewLERK6TDesC8 @ 13 NONAME
+	_ZN12CProcessInfo4NewLEyRK7TDesC16 @ 14 NONAME
+	_ZN12CProcessInfo5NameLERK7TDesC16 @ 15 NONAME
+	_ZN12CProcessInfo7MaxSizeEv @ 16 NONAME
+	_ZN12CProcessInfo8ObservedEi @ 17 NONAME
+	_ZN12CProcessInfoD0Ev @ 18 NONAME
+	_ZN12CProcessInfoD1Ev @ 19 NONAME
+	_ZN12CProcessInfoD2Ev @ 20 NONAME
+	_ZN13COptionConfig12ExternalizeLER12RWriteStreamP8CBufFlat @ 21 NONAME
+	_ZN13COptionConfig12InternalizeLER11RReadStream @ 22 NONAME
+	_ZN13COptionConfig4NewLERK6TDesC8 @ 23 NONAME
+	_ZN13COptionConfig4NewLERKmS1_RKNS_16TParameterSourceERKNS_11TOptionTypeERK7TDesC16S1_SA_RKlSA_ @ 24 NONAME
+	_ZN13COptionConfig5ValueEl @ 25 NONAME
+	_ZN13COptionConfig6ValueLERK7TDesC16 @ 26 NONAME
+	_ZN13COptionConfig7MaxSizeEv @ 27 NONAME
+	_ZN13COptionConfigC1Ev @ 28 NONAME
+	_ZN13COptionConfigC2Ev @ 29 NONAME
+	_ZN13COptionConfigD0Ev @ 30 NONAME
+	_ZN13COptionConfigD1Ev @ 31 NONAME
+	_ZN13COptionConfigD2Ev @ 32 NONAME
+	_ZN13TRegisterData10SetContentERKS_ @ 33 NONAME
+	_ZN13TRegisterData10SetContentEj @ 34 NONAME
+	_ZN13TRegisterData11SetContent8Eh @ 35 NONAME
+	_ZN13TRegisterData12SetAvailableEi @ 36 NONAME
+	_ZN13TRegisterData12SetContent16Et @ 37 NONAME
+	_ZN13TRegisterData12SetContent32Em @ 38 NONAME
+	_ZN13TRegisterData12SetContent64Ey @ 39 NONAME
+	_ZN15CExecutableInfo12ExternalizeLER12RWriteStreamP8CBufFlat @ 40 NONAME
+	_ZN15CExecutableInfo12InternalizeLER11RReadStream @ 41 NONAME
+	_ZN15CExecutableInfo16ActivelyDebuggedEi @ 42 NONAME
+	_ZN15CExecutableInfo17PassivelyDebuggedEi @ 43 NONAME
+	_ZN15CExecutableInfo4NewLERK6TDesC8 @ 44 NONAME
+	_ZN15CExecutableInfo4NewLERK7TDesC16ii @ 45 NONAME
+	_ZN15CExecutableInfo5NameLERK7TDesC16 @ 46 NONAME
+	_ZN15CExecutableInfo7MaxSizeEv @ 47 NONAME
+	_ZN15CExecutableInfo8ObservedEi @ 48 NONAME
+	_ZN15CExecutableInfoD0Ev @ 49 NONAME
+	_ZN15CExecutableInfoD1Ev @ 50 NONAME
+	_ZN15CExecutableInfoD2Ev @ 51 NONAME
+	_ZN18CStreamElementBase12MarshalDataLEv @ 52 NONAME
+	_ZNK11CThreadInfo11SvcStackPtrEv @ 53 NONAME
+	_ZNK11CThreadInfo12SvcStackAddrEv @ 54 NONAME
+	_ZNK11CThreadInfo12SvcStackSizeEv @ 55 NONAME
+	_ZNK11CThreadInfo12UsrStackAddrEv @ 56 NONAME
+	_ZNK11CThreadInfo12UsrStackSizeEv @ 57 NONAME
+	_ZNK11CThreadInfo2IdEv @ 58 NONAME
+	_ZNK11CThreadInfo4NameEv @ 59 NONAME
+	_ZNK11CThreadInfo4SizeEv @ 60 NONAME
+	_ZNK11CThreadInfo8ObservedEv @ 61 NONAME
+	_ZNK11CThreadInfo8PriorityEv @ 62 NONAME
+	_ZNK11CThreadInfo9ProcessIdEv @ 63 NONAME
+	_ZNK12CProcessInfo2IdEv @ 64 NONAME
+	_ZNK12CProcessInfo4NameEv @ 65 NONAME
+	_ZNK12CProcessInfo4SizeEv @ 66 NONAME
+	_ZNK12CProcessInfo8ObservedEv @ 67 NONAME
+	_ZNK13COptionConfig10NumOptionsEv @ 68 NONAME
+	_ZNK13COptionConfig11ValueAsBoolEv @ 69 NONAME
+	_ZNK13COptionConfig11ValueAsDescEv @ 70 NONAME
+	_ZNK13COptionConfig3UidEv @ 71 NONAME
+	_ZNK13COptionConfig4SizeEv @ 72 NONAME
+	_ZNK13COptionConfig4TypeEv @ 73 NONAME
+	_ZNK13COptionConfig5IndexEv @ 74 NONAME
+	_ZNK13COptionConfig5ValueEv @ 75 NONAME
+	_ZNK13COptionConfig6PromptEv @ 76 NONAME
+	_ZNK13COptionConfig6SourceEv @ 77 NONAME
+	_ZNK13COptionConfig7OptionsEv @ 78 NONAME
+	_ZNK13TRegisterData11GetContent8Ev @ 79 NONAME
+	_ZNK13TRegisterData12GetContent16Ev @ 80 NONAME
+	_ZNK13TRegisterData12GetContent32Ev @ 81 NONAME
+	_ZNK13TRegisterData12GetContent64Ev @ 82 NONAME
+	_ZNK13TRegisterData12SameRegisterERKS_ @ 83 NONAME
+	_ZNK13TRegisterData5GetIdEv @ 84 NONAME
+	_ZNK13TRegisterData7GetSizeEv @ 85 NONAME
+	_ZNK13TRegisterData8GetClassEv @ 86 NONAME
+	_ZNK13TRegisterData8GetSubIdEv @ 87 NONAME
+	_ZNK13TRegisterData9AvailableEv @ 88 NONAME
+	_ZNK15CExecutableInfo16ActivelyDebuggedEv @ 89 NONAME
+	_ZNK15CExecutableInfo17PassivelyDebuggedEv @ 90 NONAME
+	_ZNK15CExecutableInfo4NameEv @ 91 NONAME
+	_ZNK15CExecutableInfo4SizeEv @ 92 NONAME
+	_ZNK15CExecutableInfo8ObservedEv @ 93 NONAME
+	_ZTI11CThreadInfo @ 94 NONAME
+	_ZTI12CProcessInfo @ 95 NONAME
+	_ZTI13COptionConfig @ 96 NONAME
+	_ZTI15CExecutableInfo @ 97 NONAME
+	_ZTV11CThreadInfo @ 98 NONAME
+	_ZTV12CProcessInfo @ 99 NONAME
+	_ZTV13COptionConfig @ 100 NONAME
+	_ZTV15CExecutableInfo @ 101 NONAME
+	_ZN10TCrashInfo12ExternalizeLER12RWriteStreamP8CBufFlat @ 102 NONAME
+	_ZN10TCrashInfo12InternalizeLER11RReadStream @ 103 NONAME
+	_ZN10TCrashInfo4NewLERK6TDesC8 @ 104 NONAME
+	_ZN10TCrashInfo4NewLERKN5Debug16TCrashInfoHeaderE @ 105 NONAME
+	_ZN10TCrashInfo7MaxSizeEv @ 106 NONAME
+	_ZN10TCrashInfoC1Ev @ 107 NONAME
+	_ZN10TCrashInfoC2Ev @ 108 NONAME
+	_ZN11CPluginInfo12ExternalizeLER12RWriteStreamP8CBufFlat @ 109 NONAME
+	_ZN11CPluginInfo12InternalizeLER11RReadStream @ 110 NONAME
+	_ZN11CPluginInfo3UidEi @ 111 NONAME
+	_ZN11CPluginInfo4NewLERK6TDesC8 @ 112 NONAME
+	_ZN11CPluginInfo4NewLERK7TDesC16ijN14TPluginRequest11TPluginTypeE @ 113 NONAME
+	_ZN11CPluginInfo4PairEj @ 114 NONAME
+	_ZN11CPluginInfo4TypeEN14TPluginRequest11TPluginTypeE @ 115 NONAME
+	_ZN11CPluginInfo5NameLERK7TDesC16 @ 116 NONAME
+	_ZN11CPluginInfo7MaxSizeEv @ 117 NONAME
+	_ZN11CPluginInfo7VersionEj @ 118 NONAME
+	_ZN11CPluginInfoD0Ev @ 119 NONAME
+	_ZN11CPluginInfoD1Ev @ 120 NONAME
+	_ZN11CPluginInfoD2Ev @ 121 NONAME
+	_ZN13COptionConfig8InstanceEl @ 122 NONAME
+	_ZNK11CPluginInfo3UidEv @ 123 NONAME
+	_ZNK11CPluginInfo4NameEv @ 124 NONAME
+	_ZNK11CPluginInfo4PairEv @ 125 NONAME
+	_ZNK11CPluginInfo4SizeEv @ 126 NONAME
+	_ZNK11CPluginInfo4TypeEv @ 127 NONAME
+	_ZNK11CPluginInfo7VersionEv @ 128 NONAME
+	_ZNK13COptionConfig8InstanceEv @ 129 NONAME
+	_ZTI11CPluginInfo @ 130 NONAME
+	_ZTV11CPluginInfo @ 131 NONAME
+	_ZN11CThreadInfo11SetHeapBaseEm @ 132 NONAME
+	_ZN11CThreadInfo11SetHeapSizeEm @ 133 NONAME
+	_ZN11CThreadInfo12SetLastCpuIdEl @ 134 NONAME
+	_ZNK11CThreadInfo8HeapBaseEv @ 135 NONAME
+	_ZNK11CThreadInfo8HeapSizeEv @ 136 NONAME
+	_ZNK11CThreadInfo9LastCpuIdEv @ 137 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/eabi/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/group/cdssupport.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,40 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET        cdssupport.dll
+TARGETTYPE    dll
+UID           0x1000008d 0x102836B5
+VENDORID      0x70000001
+
+
+SYSTEMINCLUDE	\epoc32\include
+SYSTEMINCLUDE	\epoc32\include\drivers
+SYSTEMINCLUDE	\epoc32\include\tools\coredump
+
+SOURCEPATH	..\src
+SOURCE			crashdata.cpp
+SOURCE			plugindata.cpp
+SOURCE			executabledata.cpp
+SOURCE			optionconfig.cpp
+SOURCE			processdata.cpp
+SOURCE			threaddata.cpp
+SOURCE			streamelement.cpp
+
+
+LIBRARY       euser.lib
+LIBRARY       estor.lib
+
+CAPABILITY ALL -TCB
+//MACRO CDSDEBUG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/group/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,4 @@
+Directory for:
+  coredump\cdssupport\group
+
+Implement core dump server support library
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/src/crashdata.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,384 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implemetation of class TRegisterData methods. 
+//
+
+
+
+/**
+ @file
+ @see TRegisterData
+*/
+
+#include <e32std.h>
+#include <e32const.h>
+#include <rm_debug_api.h>
+#include <s32mem.h>
+#include <crashdata.h>
+#include <debuglogging.h> 
+
+using namespace Debug;
+
+/** Return the register identifier. 
+@see Sym32_reginfod::rd_id
+*/
+EXPORT_C TUint16 TRegisterData::GetId() const
+	{
+	return iId;
+	}
+
+
+/** Return the register sub-identifier. 
+@see Sym32_reginfod::rd_repre
+*/
+EXPORT_C TUint16 TRegisterData::GetSubId() const
+	{
+	return iSubId;
+	}
+
+/** Return the register size in number of bits.
+@see Sym32_reginfod::rd_repre
+*/
+EXPORT_C TUint8  TRegisterData::GetSize() const
+	{
+	return iSize;
+	}
+
+/** Return the register class
+@see Sym32_reginfod::rid_class
+*/
+EXPORT_C TUint8  TRegisterData::GetClass() const
+	{
+	return iRegClass;
+	}
+
+
+/** Return the register value as 8 bits */	
+EXPORT_C TUint8  TRegisterData::GetContent8()  const
+	{
+	return iValue8;
+	}
+
+/** Return the register value as 16 bits */	
+EXPORT_C TUint16 TRegisterData::GetContent16() const
+	{
+	return iValue16;
+	}
+
+/** Return the register value as 32 bits */	
+EXPORT_C TUint32 TRegisterData::GetContent32() const
+	{
+	return iValue32;
+	}
+
+/** Return the register value as 64 bits */	
+EXPORT_C TUint64 TRegisterData::GetContent64() const
+	{
+	return iValue64;
+	}
+
+
+/** 
+Returns ETrue if all the register's attributes are the same, exclugin the contents 
+@param other The register to compare the attributes against
+*/	
+EXPORT_C TBool TRegisterData::SameRegister( const TRegisterData & other ) const
+	{
+
+	if( other.iRegClass != iRegClass )
+		{
+		return EFalse;
+		}
+
+	if( other.iId != iId )
+		{
+		return EFalse;
+		}
+
+	if( other.iSubId != iSubId )
+		{
+		return EFalse;
+		}
+
+	if( other.iSize != iSize )
+		{
+		// Not sure this is a valid check, but should be same
+		return EFalse;
+		}
+
+	return ETrue;
+
+	}
+
+
+/** 
+Takes the content from another TRegisterData
+@param other The register to copy the contents from
+*/	
+EXPORT_C void	TRegisterData::SetContent( const TRegisterData & other )
+	{
+	switch( iSize )
+		{
+		case ERegRepr8:
+			iValue8 = other.GetContent8();
+			break;
+		case ERegRepr16:
+			iValue16 = other.GetContent16();
+			break;
+		case ERegRepr32:
+			iValue32 = other.GetContent32();
+			break;
+		case ERegRepr64:
+			iValue64 = other.GetContent64();
+			break;
+		default:
+			// Best leave untouched
+			break;
+		}
+	}
+
+/** 
+Set the register value as 8 bits 
+@param aVal The value to set the register contents to
+*/	
+EXPORT_C void	TRegisterData::SetContent8( const TUint8 aVal )
+	{
+	iValue8 = aVal;
+	}
+
+/** 
+Set the register value as 16 bits 
+@param aVal The value to set the register contents to
+*/	
+EXPORT_C void	TRegisterData::SetContent16( const TUint16 aVal )
+	{
+	iValue16 = aVal;
+	}
+
+/** 
+Set the register value as 32 bits
+@param aVal The value to set the register contents to
+*/	
+EXPORT_C void	TRegisterData::SetContent32( const TUint32 aVal )
+	{
+	iValue32 = aVal;
+	}
+
+/** 
+Set the register value as 64 bits
+@param aVal The value to set the register contents to
+*/	
+EXPORT_C void	TRegisterData::SetContent64( const TUint64 aVal )
+	{
+	iValue64 = aVal;
+	}
+
+/** 
+Set the register value, casting it to the correct size.
+@param aVal The value to set the register contents to.
+*/
+EXPORT_C void	TRegisterData::SetContent( const TUint aVal )
+	{
+	switch( GetSize() )
+		{
+		case ERegRepr8:
+			iValue8 = (TUint8) aVal;
+			break;
+		case ERegRepr16:
+			iValue16 = (TUint16) aVal;
+			break;
+		case ERegRepr32:
+			iValue32 = (TUint32) aVal;
+			break;
+		case ERegRepr64:
+			iValue64 = (TUint64) aVal;
+			break;
+		default:
+			// Best leave untouched
+			break;
+		}
+	}
+
+
+/** Return ETrue if the register content was obtained correctly */
+EXPORT_C TBool TRegisterData::Available( ) const
+	{
+	return iAvailable;
+	}
+
+
+/** Set the register content availability */
+EXPORT_C void TRegisterData::SetAvailable( const TBool aAvailable )
+	{
+	iAvailable = aAvailable;
+	}
+
+EXPORT_C TCrashInfo* TCrashInfo::NewL(const TDesC8 & aStreamData)
+	{	
+	TCrashInfo* self = new (ELeave) TCrashInfo();	
+	CleanupStack::PushL(self);
+	
+	RDesReadStream stream(aStreamData);
+	CleanupClosePushL(stream);
+
+	self->InternalizeL(stream);
+	CleanupStack::PopAndDestroy(&stream); // finished with the stream
+
+	CleanupStack::Pop(self);
+
+	return self;
+	}
+
+EXPORT_C TCrashInfo* TCrashInfo::NewL(const TCrashInfoHeader& aCrashHeader)
+	{	
+	TCrashInfo* self = new (ELeave) TCrashInfo(aCrashHeader);	
+	CleanupStack::PushL(self);
+	
+	self->ConstructL(aCrashHeader);
+	
+	CleanupStack::Pop(self);
+
+	return self;
+	}
+
+EXPORT_C TCrashInfo::TCrashInfo()
+	{	
+	}
+
+TCrashInfo::TCrashInfo(const TCrashInfoHeader& aCrashHeader) :
+	iType(ECrashException), 
+	iExcNumber(aCrashHeader.iExcCode), 
+	iReason(aCrashHeader.iExitReason), 
+	iTid(aCrashHeader.iTid), 
+	iPid(aCrashHeader.iPid),
+	iTime(aCrashHeader.iCrashTime), 
+	iCrashId(aCrashHeader.iCrashId), 
+	iSize(aCrashHeader.iLogSize),
+	iCrashSource(ELast)
+	{
+
+	}
+
+void TCrashInfo::ConstructL(const TCrashInfoHeader& aCrashHeader)
+	{
+	RBuf inter;
+	inter.Create(aCrashHeader.iCategorySize * 2);
+	inter.CleanupClosePushL();
+	inter.Copy(aCrashHeader.iCategory);	
+	
+	iCategory.SetLength(0);	
+	TInt lengthToCopy = (aCrashHeader.iCategorySize >= iCategory.MaxLength()) ? iCategory.MaxLength() : aCrashHeader.iCategorySize;
+	iCategory.Copy(inter.Ptr(), lengthToCopy);
+	
+	CleanupStack::PopAndDestroy(&inter);
+	}
+
+/**
+Initialise this object with the contents of RReadStream aStream.
+The descriptor contains an externalised version of an object.
+This method is typically used to obtain a TCrashInfo object from 
+the core dump server. 
+Also note that the methods used from RReadStream (>> or ReadUint32L) 
+can behave differently, especially for descriptors.
+@param aStream Stream with streamed object
+@see ExternalizeL
+@see RReadStream
+*/
+EXPORT_C void TCrashInfo::InternalizeL(RReadStream & aStream)
+	{	
+	iType = static_cast<TCrashInfo::TCrashType>(aStream.ReadUint32L());	
+	iExcNumber = aStream.ReadUint32L();		
+	iReason = aStream.ReadInt32L();
+	
+	TUint32 nameLength = aStream.ReadUint32L();
+	aStream.ReadL(iCategory, nameLength);	
+	
+	iTid = MAKE_TUINT64(aStream.ReadUint32L(), aStream.ReadUint32L());
+	iPid = MAKE_TUINT64(aStream.ReadUint32L(), aStream.ReadUint32L());
+	iTime = MAKE_TUINT64(aStream.ReadUint32L(), aStream.ReadUint32L());
+	
+	aStream.ReadL((TUint8*)(&iContext), sizeof(TRmdArmExcInfo));
+	iCrashId = aStream.ReadUint32L();
+	iCrashSource = static_cast<TCrashInfo::TCrashSource>(aStream.ReadUint32L());
+	
+	iSize = aStream.ReadUint32L();
+	}
+
+/**
+Make a streamed representation of this object to a RWriteStream.
+
+This method is typically by the core dump server when contructing a list of 
+CPluginInfo for a client.
+Any modifications to this method should be synchronised with InternalizeL().
+Also note that the methods used from RWriteStream (>> or WriteUint32L) can behave differently,
+especially for descriptors.
+@param aStream Stream to stream object onto
+@param buf Buffer onto the same stream, used to obtain the correct size of the externalised object
+@see InternalizeL
+@see RReadStream
+@see RWriteStream
+@post The stream contains an externalised version of this object.
+*/
+EXPORT_C void TCrashInfo::ExternalizeL(RWriteStream & aStream, CBufFlat* aBuf)
+	{
+	LOG_MSG("TCrashInfo::ExternalizeL()");
+	
+	// Take the size of the buffer before we add anything to it.
+	TUint startBufSize = aBuf->Size();
+	
+	aStream.WriteUint32L( static_cast<TCrashInfo::TCrashType>(iType) );
+	aStream.WriteUint32L( static_cast<TUint32>(iExcNumber) );
+	aStream.WriteInt32L( static_cast<TUint32>(iReason) );
+	
+	//write the category name
+	TUint nameLength = iCategory.Length();
+	aStream.WriteUint32L(nameLength);
+	
+	if(nameLength > 0)
+		{		
+		aStream.WriteL(iCategory);
+		}
+	
+	aStream.WriteUint32L(static_cast<TUint32>I64HIGH(iTid));
+	aStream.WriteUint32L(static_cast<TUint32>I64LOW(iTid));
+	
+	aStream.WriteUint32L(static_cast<TUint32>I64HIGH(iPid));
+	aStream.WriteUint32L(static_cast<TUint32>I64LOW(iPid));
+	
+	aStream.WriteUint32L(static_cast<TUint32>I64HIGH(iTime));
+	aStream.WriteUint32L(static_cast<TUint32>I64LOW(iTime));
+	
+	aStream.WriteL((TUint8*)(&iContext), sizeof(TRmdArmExcInfo) );
+	aStream.WriteUint32L(static_cast<TUint32>(iCrashId));
+	aStream.WriteUint32L(static_cast<TCrashInfo::TCrashSource>(iCrashSource));
+	
+	// The real exteranlized size is the size of the buffer up to here plus the 
+	// 4 bytes for the size itself
+	iSize = aBuf->Size() - startBufSize + 4;
+	aStream.WriteUint32L( iSize );
+	}
+
+/** 
+ * Get the maximum size allowed for this object. This is needed as the object is passed
+ * across the Client Server interface.
+ * @return maxSize
+ */
+EXPORT_C TInt TCrashInfo::MaxSize()
+	{
+	const TInt maxSize = 256;
+	return maxSize;
+	}
+
+//eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/src/executabledata.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,389 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implemetation of class CExecutableInfo
+//
+
+
+
+/**
+ @file
+ @see CExecutableInfo
+*/
+
+#include <e32debug.h>
+
+#include <debuglogging.h>
+#include <executabledata.h>
+
+
+/**
+Allocates and constructs a CExecutableInfo object.
+@param aName Name of target executable.
+@param aActivelyDebugged True if executable if being actively debugged by Debug Security Server.
+@param aPassivelyDebugged True if executable if being passively debugged by Debug Security Server.
+
+@see CExecutableInfo::CExecutableInfo
+*/
+EXPORT_C CExecutableInfo* CExecutableInfo::NewL( const TDesC		& aName,
+												const TBool  	  aActivelyDebugged,
+												const TBool  	  aPassivelyDebugged )
+	{
+
+
+	const TUint size = 
+		+ sizeof( TUint32 )		// When externalized, we send the name length, so must include this
+		+ 2						// When externalized, the << operator writes 2 bytes for the descriptor size
+		+ aName.Size()			// iName Size, in bytes.
+		+ sizeof( TUint32 ) 	// aActivelyDebugged
+		+ sizeof( TUint32 ) 	// aPassivelyDebugged
+		+ sizeof( TUint32 ) 	// Observed
+		+ sizeof( TUint32 );	// iSize itself
+
+
+
+	if( size >= MaxSize() )
+		{
+		LOG_MSG3( "CExecutableInfo::NewL() : Descriptorized object = 0x%X bytes would exceed the maximum of 0x%X\n", 
+			size, MaxSize() );
+
+		User::Leave( KErrTooBig );
+		}
+
+	CExecutableInfo * data = new (ELeave) CExecutableInfo( aActivelyDebugged, aPassivelyDebugged );
+
+	CleanupStack::PushL( data );
+	
+	data->ConstructL( aName );
+
+	CleanupStack::Pop(data);
+
+	return (data);
+
+	}
+
+
+/**
+Allocates and constructs a CExecutableInfo object from a descriptor. 
+The descriptor contains an externalised version of a CExecutableInfo object.
+This method is typically used to obtain a CExecutableInfo object from a 
+descriptor returned by the core dump server.
+
+@param aStreamData Descriptor with externalised/streamed object to initialize from.
+@see InternalizeL
+@see ExternalizeL
+*/
+EXPORT_C CExecutableInfo* CExecutableInfo::NewL( const TDesC8 & aStreamData )
+	{
+
+	CExecutableInfo* self = new (ELeave) CExecutableInfo();
+	
+	CleanupStack::PushL( self );
+	
+	// Open a read stream for the descriptor
+	RDesReadStream stream( aStreamData );
+
+	CleanupClosePushL( stream );
+
+	self->InternalizeL( stream );
+
+	CleanupStack::PopAndDestroy( &stream ); // finished with the stream
+
+	CleanupStack::Pop( self );
+
+	return ( self );
+
+	}
+
+
+/**
+Destructor. Deletes name if allocated.
+*/
+EXPORT_C CExecutableInfo::~CExecutableInfo()
+	{
+
+	if( NULL != iName )
+		{
+		delete iName;
+		}
+	}
+
+/**
+First phase contructor. Sets the size to 0, name to NULL.
+
+@param aActivelyDebugged Whether this executable is being actively 
+debugged according to the Debug Security Server.
+@param aPassivelyDebugged Whether this executable is being passively 
+debugged according to the Debug Security Server.
+
+@see CExecutableInfo::NewL().
+*/
+CExecutableInfo::CExecutableInfo( const TBool aActivelyDebugged,
+									const TBool aPassivelyDebugged ) :
+    iActivelyDebugged    ( aActivelyDebugged ),
+    iPassivelyDebugged   ( aPassivelyDebugged ),
+    iObserved    ( EFalse ),
+	iSize        ( 0 )
+	{
+	iName = NULL;
+	}
+
+
+/**
+Second phase constructor initialises the name of the executable.
+@param aName Executable name
+@see NameL()
+*/
+void CExecutableInfo::ConstructL(  const TDesC & aName )
+	{
+	NameL( aName );
+	}
+
+
+/**
+Initialise this object with the contents of RReadStream aStream.
+The descriptor contains an externalised version of an object.
+This method is typically used to obtain a CExecutableInfo object from 
+the core dump server.
+Any modifications to this method should be synchronised with ExternalizeL(). 
+Also note that the methods used from RReadStream (>> or ReadUint32L) 
+can behave differently, especially for descriptors.
+@param aStream Stream with streamed object
+@see ExternalizeL
+@see RReadStream
+@pre Call Externalise to obtain the stream containing an externalised 
+version of this object.
+*/
+EXPORT_C void CExecutableInfo::InternalizeL( RReadStream & aStream )
+	{
+
+
+	// Read the number of character elements in the name. 
+	TUint32 nameLength = aStream.ReadUint32L(); 
+
+	if( NULL != iName )
+		{
+		delete iName;
+		iName = NULL;
+		}
+
+	if ( nameLength > 0 )
+		{
+		iName  = HBufC::NewL( aStream, nameLength ); 
+		}
+	else
+		{
+		iName  = NULL;
+		}
+
+	iActivelyDebugged = static_cast<TBool>(aStream.ReadUint32L());
+	iPassivelyDebugged = static_cast<TBool>(aStream.ReadUint32L());
+
+	iObserved = static_cast<TBool>(aStream.ReadUint32L());
+
+	iSize = aStream.ReadUint32L() ;
+	}
+
+
+/**
+Make a streamed representation of this object to a RWriteStream.
+
+This method is typically by the core dump server when contructing a list of 
+CExecutableInfo for a client.
+Any modifications to this method should be synchronised with InternalizeL().
+Also note that the methods used from RWriteStream (>> or WriteUint32L) can behave differently,
+especially for descriptors.
+@param aStream Stream to stream object onto
+@param buf Buffer onto the same stream, used to obtain the correct size of the externalised object
+@see InternalizeL
+@see RReadStream
+@see RWriteStream
+@post The stream contains an externalised version of this object.
+*/
+EXPORT_C void CExecutableInfo::ExternalizeL( RWriteStream & aStream, CBufFlat* buf )
+	{
+
+	// Take the size of the buffer before we add anything to it.
+	TUint startBufSize = buf->Size();
+
+	TUint nameLength = 0;
+
+	if ( ( NULL != iName ) && ( iName->Des().Length() > 0 ) )
+		{
+
+		nameLength = iName->Des().Length();
+
+		if( nameLength > 0 )
+			{
+			// Write the number of character elements in the name. 
+			aStream.WriteUint32L( nameLength ); 
+			aStream << iName->Des();
+			}
+		}
+
+	if( nameLength == 0 )
+		{
+		aStream.WriteUint32L( 0 ); 
+		}
+
+	aStream.WriteUint32L( static_cast<TUint32>(iActivelyDebugged) );
+	aStream.WriteUint32L( static_cast<TUint32>(iPassivelyDebugged) );
+
+	aStream.WriteUint32L( static_cast<TUint32>(iObserved) );
+
+	iSize = buf->Size() - startBufSize + 4;
+
+	aStream.WriteUint32L( iSize );
+
+	}
+
+/** 
+Return ETrue if the executable if being actively debugged by a client of the Debug Security Server.
+*/
+EXPORT_C TBool CExecutableInfo::ActivelyDebugged() const 
+	 { 
+	 return ( iActivelyDebugged ); 
+	 }
+
+
+/** 
+Return ETrue if the executable if being passively debugged by a client of the Debug Security Server.
+*/
+EXPORT_C TBool CExecutableInfo::PassivelyDebugged() const 
+	 { 
+	 return ( iPassivelyDebugged ); 
+	 }
+
+
+/** 
+Set whether the executable is being actively debugged by a client of the Debug Security Server.
+*/
+EXPORT_C void CExecutableInfo::ActivelyDebugged( TBool aActivelyDebugged ) 
+	 { 
+	 iActivelyDebugged = aActivelyDebugged; 
+	 }
+
+
+/** 
+Set whether the executable is being passively debugged by a client of the Debug Security Server.
+*/
+EXPORT_C void  CExecutableInfo::PassivelyDebugged( TBool aPassivelyDebugged ) 
+	 { 
+	 iPassivelyDebugged = aPassivelyDebugged; 
+	 }
+
+
+/**
+Returns ETrue if the the Core Dump Server is observing this executable.
+*/
+EXPORT_C TBool CExecutableInfo::Observed() const 
+	 { 
+	 return ( iObserved ); 
+	 }
+
+
+/**
+Set whether the the Core Dump Server is observing this executable.
+*/
+EXPORT_C void CExecutableInfo::Observed( TBool aFlag ) 
+	 { 
+	 iObserved = aFlag; 
+	 }
+
+
+/**
+Set the name of the executable by deleting, allocating and then copying the parameter.
+@param aName Name of the executable to set to
+@see ConstructL()
+*/
+EXPORT_C void CExecutableInfo::NameL( const TDesC & aName )
+	{
+
+	if( aName.Length() > 0 )
+		{
+		TUint toCopy = aName.Length();
+		iName = HBufC::NewL( toCopy );
+		TPtr nameDes = iName->Des();
+
+		nameDes.Copy( aName.Ptr(), toCopy );
+		nameDes.SetLength( toCopy );
+		}
+	else
+		{
+		iName = NULL;
+		}
+	}
+
+
+/**
+Obtain the kernel executable name.
+*/
+EXPORT_C const TDesC & CExecutableInfo::Name() const 
+	{ 
+	return ( *iName ); 
+	}
+
+
+CExecutableInfo::CExecutableInfo()
+	{
+	}
+
+
+/** 
+Get the maximum size allowed for this object. This is needed as the object is passed  
+across the Client Server interface.
+*/
+EXPORT_C TInt CExecutableInfo::MaxSize()
+	{
+	
+	const TInt maxSize = 256;
+	return maxSize;
+	}
+
+
+/**
+Gets the size of the object when externalized. The sizeofs used to calculate this 
+must match the operators used in ExternalizeL and InternalizeL.
+Special attention must be paid to the name. If the object has not been 
+externalized yet then this method returns the maximum that it could take.
+The name descriptor is compressed when externalized, so it is not its Size().
+Furthermore the << operator adds two bytes to the stream when externalizing 
+a descriptor.
+*/
+EXPORT_C TInt CExecutableInfo::Size() const
+	{
+
+	if( iSize != 0 )
+		{
+		return iSize;
+		}
+
+	TUint extNameSize = 0;
+	if( iName )
+		{
+		extNameSize = 2					// When externalized, the << operator writes 2 bytes for the descriptor size
+					+ iName->Size();	// iName itself, in bytes.
+		}
+
+	const TUint size = 
+		+ sizeof( TUint32 )		// When externalized, we send the name length, so must include this
+		+ extNameSize
+		+ sizeof( TUint32 ) 	// iActivelyDebugged
+		+ sizeof( TUint32 ) 	// iPassivelyDebugged
+		+ sizeof( TUint32 ) 	// iObserved
+		+ sizeof( TUint32 );	// iSize When externalized, we send the real externalized size of the buffer
+
+	return size;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/src/optionconfig.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,675 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implementation of class COptionConfig configuration parameter interface 
+//
+
+
+
+/**
+ @file
+ @see COptionConfig
+*/
+
+#include <debuglogging.h>
+
+#include <optionconfig.h>
+
+
+/**
+Allocates and constructs a COptionConfig object.
+@param aIndex Internal index to the component that owns the object
+@param aUID UID of the component that owns the object
+@param aSource Type of component that owns the object
+@param aType Type of parameter
+@param aPrompt Prompt to present to user 
+@param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
+@param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool.
+@param aVal Integer value. Applies to ETInt, ETUInt, ETBool.
+@param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool.
+*/
+EXPORT_C COptionConfig* COptionConfig::NewL( 
+										const TUint32          & aIndex, 
+										const TUint32          & aUID, 
+										const TParameterSource & aSource, 
+										const TOptionType      & aType, 
+										const TDesC            & aPrompt, 
+										const TUint32          & aNumOptions,
+										const TDesC            & aOptions,
+										const TInt32           & aVal, 
+										const TDesC            & aStrValue)
+                                        
+	{
+
+
+	const TInt size = 
+		  sizeof( TUint32 )	// iType
+		+ sizeof( TUint32 )	// iSource
+		+ sizeof( TUint32 )	// iIndex
+		+ sizeof( TUint32 )	// iInstance
+		+ sizeof( TUint32 )	// iUID
+
+		+ sizeof( TUint32 )	// When externalized, we send the name length, so must include this
+		+ 2					// When externalized, the << operator writes 2 bytes for the descriptor size
+		+ aPrompt.Size()	// iPrompt
+
+		+ sizeof( TUint32 )	// iNumOptions
+
+		+ sizeof( TUint32 )	// When externalized, we send the name length, so must include this
+		+ 2					// When externalized, the << operator writes 2 bytes for the descriptor size
+		+ aOptions.Size()	// iOptions
+
+		+ sizeof ( TInt32 )	// iValue
+
+		+ sizeof( TUint32 )	// When externalized, we send the name length, so must include this
+		+ 2					// When externalized, the << operator writes 2 bytes for the descriptor size
+		+ aStrValue.Size()	// iStrValue
+
+		+ sizeof( TUint32 );// iSize itself
+
+	if( size >= MaxSize() )
+		{
+		LOG_MSG3( "COptionConfig::NewL() : Attempting to allocate %d bytes but maximum is %d\n", 
+			size, MaxSize() );
+
+		User::Leave( KErrTooBig );
+		}
+
+	COptionConfig * data = new (ELeave) COptionConfig( aType, aSource, aIndex, aUID, aNumOptions, aVal );
+	CleanupStack::PushL( data );
+
+	data->ConstructL( aPrompt, aOptions, aStrValue );
+	CleanupStack::Pop(data);
+	return (data);
+
+	}
+
+
+/**
+Allocates and constructs a COptionConfig object from a descriptor. 
+The descriptor contains an externalised version of a COptionConfig object.
+This method is typically used to obtain a COptionConfig object from a 
+descriptor returned by the core dump server.
+
+@param aStreamData Descriptor with externalised/streamed object
+@see InternalizeL
+@see ExternalizeL
+*/
+EXPORT_C COptionConfig* COptionConfig::NewL( const TDesC8 & aStreamData )
+	{
+
+	COptionConfig* data = new (ELeave) COptionConfig();
+
+	CleanupStack::PushL( data );
+	
+	// Open a read stream for the descriptor
+	RDesReadStream stream( aStreamData );
+
+	CleanupClosePushL( stream );
+
+	data->InternalizeL( stream );
+
+	CleanupStack::PopAndDestroy( &stream ); // finished with the stream
+
+	CleanupStack::Pop( data );
+
+	return (data);
+
+	}
+
+
+/**
+Destructor. Deletes descriptors.
+*/
+EXPORT_C COptionConfig::~COptionConfig()
+	{
+
+
+	if( iPrompt )
+		{
+		delete iPrompt;
+		}
+
+	if( iOptions )
+		{
+		delete iOptions;
+		}
+
+	if( iStrValue )
+		{
+		delete iStrValue;
+		}
+	}
+
+
+/**
+First phase contructor. Sets the size to 0, descriptors to NULL.
+@see COptionConfig::NewL()
+*/
+COptionConfig::COptionConfig(const TOptionType				& aType,  
+									const TParameterSource	& aSource, 
+									const TUint32			& aIndex, 
+									const TUint32			& aUID,
+									const TUint32			& aNumOptions,
+									const TInt32			& aValue ) :
+	iType			( aType ),
+	iSource			( aSource ),
+	iIndex			( aIndex ), 
+	iUID			( aUID ), 
+	iPrompt			( NULL ),
+	iNumOptions		( aNumOptions ),
+	iOptions		( NULL ),
+	iValue			( aValue ),
+	iStrValue		( NULL ),
+	iSize			( 0 ),
+	iInstance		( 0 ) 
+
+	{
+
+	
+	/*
+	LOG_MSG2( "COptionConfig::COptionConfig() : iSize=%d\n", iSize );
+	LOG_MSG4( "  iType=%d, iSource=%d, iIndex=%d", iType, iSource, iIndex );
+	LOG_MSG4( "  iUID=0x%X, iNumOpts=%d, iValue=%d\n", iUID, iNumOptions, iValue );
+	*/
+	
+	}
+
+
+
+void COptionConfig::ConstructStringL( const TDesC & aSource, HBufC ** aDest )
+	{
+
+	TInt sourceLength = aSource.Length();
+
+	if( sourceLength > 0 )
+		{
+
+		TInt newMaxLength = Align4( KCDSMaxConfigParamStr );
+		if( *aDest )
+			{
+			delete *aDest;
+			}
+
+		*aDest = HBufC::NewL( newMaxLength );
+		CleanupStack::PushL( *aDest );
+
+		TPtr destDes = (*aDest)->Des();
+
+		destDes.FillZ( newMaxLength );
+
+		if( sourceLength >= KCDSMaxConfigParamStr )
+			{
+			sourceLength = KCDSMaxConfigParamStr - 1; // We want to leave the null at the end always
+			}
+
+		destDes.Copy( aSource.Ptr(), sourceLength );
+
+		destDes.SetLength( sourceLength );
+		CleanupStack::Pop( *aDest );
+
+		}
+	else
+		{
+		*aDest = NULL;
+		}
+	 }
+
+
+
+/**
+Second phase constructor initialises the descriptors
+*/
+void COptionConfig::ConstructL( const TDesC & aPrompt, 
+								const TDesC & aOptions,
+								const TDesC & aStrValue )
+	{
+
+	ConstructStringL( aPrompt, &iPrompt );
+	ConstructStringL( aOptions, &iOptions );
+	ConstructStringL( aStrValue, &iStrValue );
+
+	}
+
+
+/**
+Initialise this object with the contents of RReadStream aStream.
+The descriptor contains an externalised version of an object.
+This method is typically used to obtain a COptionConfig object from 
+the core dump server.
+Any modifications to this method should be synchronised with ExternalizeL(). 
+Also note that the methods used from RReadStream (>> or ReadUint32L) 
+can behave differently, especially for descriptors.
+@param aStream Stream with streamed object
+@see ExternalizeL
+@see RReadStream
+@pre Call ExternaliseL to obtain the stream containing an externalised 
+version of this object.
+*/
+EXPORT_C void COptionConfig::InternalizeL( RReadStream & aStream )
+	{
+
+
+	iType = (TOptionType) aStream.ReadUint32L(); 
+
+	iSource = (TParameterSource) aStream.ReadUint32L(); 
+
+	iIndex = aStream.ReadUint32L(); 
+
+	iInstance = aStream.ReadUint32L(); 
+
+	iUID = aStream.ReadUint32L(); 
+
+	if( NULL != iPrompt )
+		{
+		delete iPrompt;
+		iPrompt = NULL;
+		}
+
+	TUint32 promptSize = aStream.ReadUint32L(); 
+
+	if ( promptSize > 0 )
+		{
+		//iPrompt = HBufC::NewL( aStream, KCDSMaxConfigParamStr ); 
+		iPrompt = HBufC::NewL( aStream, promptSize ); 
+		}
+	else
+		{
+		iPrompt  = NULL;
+		}
+
+	iNumOptions = aStream.ReadUint32L(); 
+
+	if( NULL != iOptions )
+		{
+		delete iOptions;
+		iOptions = NULL;
+		}
+
+	TUint32 optionSize = aStream.ReadUint32L(); 
+
+	if ( optionSize > 0 )
+		{
+		//iOptions = HBufC::NewL( aStream, KCDSMaxConfigParamStr ); 
+		iOptions = HBufC::NewL( aStream, optionSize ); 
+		}
+	else
+		{
+		iOptions = NULL;
+		}
+
+
+	iValue = aStream.ReadInt32L();
+
+	if( NULL != iStrValue )
+		{
+		delete iStrValue;
+		iStrValue = NULL;
+		}
+
+	TUint32 strValueSize = aStream.ReadUint32L(); 
+
+	if ( strValueSize > 0 )
+		{
+		//iStrValue = HBufC::NewL( aStream, KCDSMaxConfigParamStr ); 
+		iStrValue = HBufC::NewL( aStream, strValueSize ); 
+		}
+	else
+		{
+		iStrValue = NULL;
+		}
+
+	iSize = aStream.ReadUint32L() ;
+
+	}
+
+
+/**
+Make a streamed representation of this object to a RWriteStream.
+
+This method is typically by the core dump server when contructing a list of 
+COptionConfig for a client.
+Any modifications to this method should be synchronised with InternalizeL(). 
+Also note that the methods used from RWriteStream (>> or WriteUint32L) can behave differently,
+especially for descriptors.
+@param aStream Stream to stream object onto
+@param buf Buffer onto the same stream, used to obtain correct size of externalised object
+@see InternalizeL
+@see RReadStream
+@see RWriteStream
+@post The stream contains an externalised version of this object.
+*/
+EXPORT_C void COptionConfig::ExternalizeL( RWriteStream & aStream, CBufFlat* buf )
+	{
+
+
+	// Take the size of the buffer before we add anything to it.
+	TUint startBufSize = buf->Size();
+
+	aStream.WriteUint32L( iType ); 
+
+	aStream.WriteUint32L( iSource ); 
+
+	aStream.WriteUint32L( iIndex );
+
+	aStream.WriteUint32L( iInstance );
+
+	aStream.WriteUint32L( iUID );
+
+	TInt promptSize = 0;
+	if ( iPrompt != NULL )
+		{
+		promptSize = iPrompt->Des().Length();
+		if( promptSize > 0 )
+			{
+			aStream.WriteUint32L( promptSize ); 
+			aStream << iPrompt->Des();
+			}
+		}
+
+	if( promptSize == 0 )
+		{
+		aStream.WriteUint32L( 0 ); 
+		}
+
+	aStream.WriteUint32L( iNumOptions );
+
+	TInt optionSize = 0;
+	if ( iOptions != NULL )
+		{
+		optionSize = iOptions->Des().Length();
+		if( optionSize > 0 )
+			{
+			aStream.WriteUint32L( optionSize ); 
+			aStream << iOptions->Des();
+			}
+		}
+
+	if( optionSize == 0 )
+		{
+		aStream.WriteUint32L( 0 ); 
+		}
+
+	aStream.WriteInt32L( iValue );
+
+	TInt valueSize = 0;
+	if ( iStrValue != NULL )
+		{
+		valueSize = iStrValue->Des().Length();
+		if( valueSize > 0 )
+			{
+			aStream.WriteUint32L( valueSize ); 
+			aStream << iStrValue->Des();
+			}
+		}
+
+	if( valueSize == 0 )
+		{
+		aStream.WriteUint32L( 0 ); 
+		}
+
+	// The real exteranlized size is the size of the buffer up to here plus the 
+	// 4 bytes for the size itself
+	iSize = buf->Size() - startBufSize + 4;
+	aStream.WriteUint32L( iSize );
+
+	}
+
+
+
+/**
+Obtain the type of parameter.
+@see TOptionType
+*/
+EXPORT_C COptionConfig::TOptionType COptionConfig::Type() const 
+	 { 
+	 return ( iType ); 
+	 }
+
+/**
+Obtain the source component type of the parameter.
+@see TParameterSource
+*/
+EXPORT_C COptionConfig::TParameterSource COptionConfig::Source() const 
+	 { 
+	 return ( iSource ); 
+	 }
+
+/**
+Obtain the internal index to the component that owns the object.
+*/
+EXPORT_C TUint32 COptionConfig::Index() const 
+	 { 
+	 return ( iIndex ); 
+	 }
+
+/**
+Obtain the internal index to the component that owns the object.
+*/
+EXPORT_C TUint32 COptionConfig::Instance() const 
+	 { 
+	 return ( iInstance ); 
+	 }
+
+/**
+Set the internal index to the component that owns the object.
+*/
+EXPORT_C void COptionConfig::Instance(TInt32 aInstance)
+	 { 
+	 iInstance = aInstance; 
+	 }
+
+/**
+Obtain the UID of the component that owns the object.
+*/
+EXPORT_C TUint32 COptionConfig::Uid( ) const 
+	{ 
+	return iUID; 
+	}
+
+
+/**
+Obtain the prompt to present to the user.
+*/
+EXPORT_C const TDesC & COptionConfig::Prompt() const 
+	{ 
+	if( iPrompt )
+		{
+		return ( *iPrompt ); 
+		}
+	else
+		{
+		return KNullDesC;
+		}
+	}
+
+
+/**
+Obtain the number of options that the parameter can be set to. 
+Only applies if type is ETMultiEntryEnum.
+*/
+EXPORT_C TUint32 COptionConfig::NumOptions( ) const 
+	{ 
+	return iNumOptions; 
+	}
+
+
+/**
+Obtain the comma separated list of options. Applies to ETMultiEntryEnum and ETBool.
+*/
+EXPORT_C const TDesC & COptionConfig::Options() const 
+	{ 
+	if( iOptions )
+		{
+		return ( *iOptions ); 
+		}
+	else
+		{
+		return KNullDesC;
+		}
+	}
+
+
+/** Obtain the integer value of the parameter. */
+EXPORT_C TInt32 COptionConfig::Value() const 
+	 { 
+	 return ( iValue ); 
+	 }
+
+
+/** Obtain the value of the parameter as a Boolean. */
+EXPORT_C TBool COptionConfig::ValueAsBool() const
+	{
+	if( 0 == iValue )
+		{
+		return EFalse;
+		}
+	else
+		{
+		return ETrue;
+		}
+	}
+
+
+/** Obtain the value of the parameter as a descriptor. Does not apply to ETInt or ETUInt. */
+EXPORT_C const TDesC & COptionConfig::ValueAsDesc() const 
+	{ 
+
+	if( iStrValue )
+		{
+		return ( *iStrValue ); 
+		}
+	else
+		{
+		return KNullDesC;
+		}
+	 }
+
+/** Set the integer value of the parameter. */
+EXPORT_C void COptionConfig::Value( const TInt32 aValue ) 
+	{ 
+	iValue = aValue; 
+	}
+
+/** Set the descriptor value of the parameter. */
+EXPORT_C void COptionConfig::ValueL( const TDesC & aValue ) 
+	{ 
+
+	TInt valSize = aValue.Size();
+
+	TInt newSize = Size() + valSize ;
+
+	if( iStrValue )
+		{
+		newSize -= iStrValue->Size();
+		}
+
+	if( aValue.Length() > KCDSMaxConfigParamStr )
+		{
+		LOG_MSG( "if( aValue.Length() > KCDSMaxConfigParamStr ) -> User::Leave( KErrTooBig )\n" );
+		User::Leave( KErrTooBig );
+		}
+
+	if( newSize >= MaxSize() )
+		{
+		LOG_MSG( "if( newSize >= MaxSize() ) -> User::Leave( KErrTooBig )\n" );
+		User::Leave( KErrTooBig );
+		}
+
+
+	if( valSize == 0 )
+		{
+		iStrValue = NULL;
+		}
+	else
+		{
+		ConstructStringL( aValue, & iStrValue );
+		}
+
+	iSize = newSize;
+
+	}
+
+
+
+EXPORT_C COptionConfig::COptionConfig()
+	{
+	}
+
+
+/**
+Gets the size of the object when externalized. The sizeofs used to calculate this 
+must match the operators used in ExternalizeL and InternalizeL.
+Special attention must be paid to the name. If the object has not been 
+externalized yet then this method returns the maximum that it could take.
+The name descriptor is compressed when externalized, so it is not its Size().
+Furthermore the << operator adds two bytes to the stream when externalizing 
+a descriptor.
+*/
+EXPORT_C TInt COptionConfig::Size() const
+	{
+
+	if( iSize != 0 )
+		{
+		return iSize;
+		}
+
+	TUint extDecSize = 0;
+	if( iPrompt )
+		{
+		extDecSize += 2					// When externalized, the << operator writes 2 bytes for the descriptor size
+					+ iPrompt->Size();	// iPrompt itself, in bytes. Worst case
+		}
+
+	if( iOptions )
+		{
+		extDecSize += 2					// When externalized, the << operator writes 2 bytes for the descriptor size
+					+ iOptions->Size();	// iOptions itself, in bytes. Worst case
+		}
+
+	if( iStrValue )
+		{
+		extDecSize += 2					// When externalized, the << operator writes 2 bytes for the descriptor size
+					+ iStrValue->Size();	// iStrValue itself, in bytes. Worst case
+		}
+
+
+	const TInt size = 
+		  sizeof( TUint32 )	// iType
+		+ sizeof( TUint32 )	// iSource
+		+ sizeof( TUint32 )	// iIndex
+		+ sizeof( TUint32 )	// iInstance
+		+ sizeof( TUint32 )	// iUID
+		+ sizeof( TUint32 )	// iPrompt size
+		+ extDecSize		// all the descriptors and their 2 bytes due to <<
+		+ sizeof( TUint32 )	// iNumOptions
+		+ sizeof( TUint32 )	// iOptions size
+		+ sizeof( TInt32 )	// iValue 
+		+ sizeof( TUint32 )	// iStrValue size
+		+ sizeof( TUint32 );	// iSize itself
+
+	return size;
+	}
+
+
+ /**
+ Get the maximum size allowed for this object. This is needed as the object is passed  
+ across the Client Server interface.
+ */
+ EXPORT_C TInt COptionConfig::MaxSize()
+	{
+	
+	const TInt maxSize = 1024;
+	return maxSize;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/src/plugindata.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,388 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implemetation of class CPluginInfo
+//
+
+
+
+/**
+ @file
+ @see CPluginInfo
+*/
+
+#include <e32debug.h>
+
+#include <debuglogging.h>
+#include <plugindata.h>
+
+
+/**
+Allocates and constructs a CPluginInfo object.
+
+@see CPlguinInfo::CPluginInfo
+*/
+EXPORT_C CPluginInfo* CPluginInfo::NewL(const TDesC &aName,
+									    const TInt aUid,
+                                        const TUint aVersion,
+									    const TPluginRequest::TPluginType aType)
+	{
+	const TUint size = 
+		+ sizeof( TUint32 )		// When externalized, we send the name length, so must include this
+		+ 2						// When externalized, the << operator writes 2 bytes for the descriptor size
+		+ aName.Size()			// iName Size, in bytes.
+		+ sizeof( TInt32 ) 	    // aUid
+		+ sizeof( TUint32 ) 	// aVersion
+		+ sizeof( TUint32 ) 	// aType
+		+ sizeof( TUint32 ) 	// aPair
+		+ sizeof( TUint32 );	// iSize itself
+
+
+	if( size >= MaxSize() )
+		{
+		LOG_MSG3( "CPluginInfo::NewL() : Descriptorized object = 0x%X bytes would exceed the maximum of 0x%X\n", 
+			size, MaxSize() );
+
+		User::Leave( KErrTooBig );
+		}
+
+	CPluginInfo * data = new (ELeave) CPluginInfo( aUid, aVersion, aType );
+
+	CleanupStack::PushL( data );
+	
+	data->ConstructL( aName );
+
+	CleanupStack::Pop(data);
+
+	return (data);
+	}
+
+
+/**
+Allocates and constructs a CPluginInfo object from a descriptor. 
+The descriptor contains an externalised version of a CPluginInfo object.
+This method is typically used to obtain a CPluginInfo object from a 
+descriptor returned by the core dump server.
+
+@param aStreamData Descriptor with externalised/streamed object to initialize from.
+@see InternalizeL
+@see ExternalizeL
+*/
+EXPORT_C CPluginInfo* CPluginInfo::NewL( const TDesC8 & aStreamData )
+	{
+	CPluginInfo* self = new (ELeave) CPluginInfo();
+	
+	CleanupStack::PushL( self );
+	
+	RDesReadStream stream( aStreamData );
+
+	CleanupClosePushL( stream );
+
+	self->InternalizeL( stream );
+
+	CleanupStack::PopAndDestroy( &stream ); // finished with the stream
+
+	CleanupStack::Pop( self );
+
+	return ( self );
+	}
+
+
+/**
+Destructor. Deletes name if allocated.
+*/
+EXPORT_C CPluginInfo::~CPluginInfo()
+	{
+
+	if(iName)
+		{
+		delete iName;
+		}
+	}
+
+/**
+First phase contructor. Sets the size to 0, name to NULL.
+
+@see CPluginInfo::NewL().
+*/
+CPluginInfo::CPluginInfo(const TInt aUid,
+			const TUint aVersion,
+            const TPluginRequest::TPluginType aType):
+
+	iName(NULL),
+    iUid(aUid ),
+    iVersion(aVersion),
+    iType(aType),
+    iPair(KMaxTUint32),
+	iSize(0)
+	{
+	}
+
+
+/**
+Second phase constructor initialises the name of the executable.
+@param aName Plugin name
+@see NameL()
+*/
+void CPluginInfo::ConstructL(const TDesC &aName)
+	{
+	NameL(aName);
+	}
+
+
+/**
+Initialise this object with the contents of RReadStream aStream.
+The descriptor contains an externalised version of an object.
+This method is typically used to obtain a CPluginInfo object from 
+the core dump server.
+Any modifications to this method should be synchronised with ExternalizeL(). 
+Also note that the methods used from RReadStream (>> or ReadUint32L) 
+can behave differently, especially for descriptors.
+@param aStream Stream with streamed object
+@see ExternalizeL
+@see RReadStream
+@pre Call Externalise to obtain the stream containing an externalised 
+version of this object.
+*/
+EXPORT_C void CPluginInfo::InternalizeL( RReadStream & aStream )
+	{
+	// Read the number of character elements in the name. 
+	TUint32 nameLength = aStream.ReadUint32L(); 
+
+	if( NULL != iName )
+		{
+		delete iName;
+		iName = NULL;
+		}
+
+	if ( nameLength > 0 )
+		{
+		iName  = HBufC::NewL( aStream, nameLength ); 
+		}
+	else
+		{
+		iName  = NULL;
+		}
+
+	iUid = static_cast<TInt>(aStream.ReadInt32L());
+	iVersion = static_cast<TUint>(aStream.ReadUint32L());
+	iType = static_cast<TPluginRequest::TPluginType>(aStream.ReadUint32L());
+	iPair = static_cast<TUint>(aStream.ReadUint32L());
+	
+	iSize = aStream.ReadUint32L() ;
+	}
+
+
+/**
+Make a streamed representation of this object to a RWriteStream.
+
+This method is typically by the core dump server when contructing a list of 
+CPluginInfo for a client.
+Any modifications to this method should be synchronised with InternalizeL().
+Also note that the methods used from RWriteStream (>> or WriteUint32L) can behave differently,
+especially for descriptors.
+@param aStream Stream to stream object onto
+@param buf Buffer onto the same stream, used to obtain the correct size of the externalised object
+@see InternalizeL
+@see RReadStream
+@see RWriteStream
+@post The stream contains an externalised version of this object.
+*/
+EXPORT_C void CPluginInfo::ExternalizeL( RWriteStream & aStream, CBufFlat* buf )
+	{
+
+	// Take the size of the buffer before we add anything to it.
+	TUint startBufSize = buf->Size();
+
+	TUint nameLength = 0;
+
+	if ( ( NULL != iName ) && ( iName->Des().Length() > 0 ) )
+		{
+
+		nameLength = iName->Des().Length();
+
+		if( nameLength > 0 )
+			{
+			// Write the number of character elements in the name. 
+			aStream.WriteUint32L( nameLength ); 
+			aStream << iName->Des();
+			}
+		}
+
+	if( nameLength == 0 )
+		{
+		aStream.WriteUint32L( 0 ); 
+		}
+
+	aStream.WriteInt32L( static_cast<TInt32>(iUid) );
+	aStream.WriteUint32L( static_cast<TUint32>(iVersion) );
+
+	aStream.WriteUint32L( static_cast<TUint32>(iType) );
+	aStream.WriteUint32L( static_cast<TUint32>(iPair) );
+	
+	iSize = buf->Size() - startBufSize + 4;
+
+	aStream.WriteUint32L( iSize );
+
+	}
+
+/** 
+*/
+EXPORT_C TInt CPluginInfo::Uid() const 
+	 { 
+	 return ( iUid ); 
+	 }
+
+/** 
+*/
+EXPORT_C void CPluginInfo::Uid( TInt aUid ) 
+	 { 
+	 iUid = aUid; 
+	 }
+
+/** 
+*/
+EXPORT_C TUint CPluginInfo::Version() const 
+	 { 
+	 return ( iVersion ); 
+	 }
+
+
+/** 
+*/
+EXPORT_C void CPluginInfo::Version(TUint aVersion )
+	 { 
+	 iVersion = aVersion; 
+	 }
+
+/**
+*/
+EXPORT_C TPluginRequest::TPluginType CPluginInfo::Type() const 
+	 { 
+	 return ( iType ); 
+	 }
+
+
+/**
+*/
+EXPORT_C void CPluginInfo::Type( TPluginRequest::TPluginType aType ) 
+	 { 
+	 iType = aType; 
+	 }
+/** 
+*/
+EXPORT_C TUint CPluginInfo::Pair() const 
+	 { 
+	 return ( iPair ); 
+	 }
+
+
+/** 
+*/
+EXPORT_C void CPluginInfo::Pair(TUint aIndex )
+	 { 
+	 iPair = aIndex; 
+	 }
+
+
+/**
+Set the name of the plugin by deleting, allocating and then copying the parameter.
+@param aName Name of the executable to set to
+@see ConstructL()
+*/
+EXPORT_C void CPluginInfo::NameL(const TDesC &aName)
+	{
+
+    if(iName)
+        {
+        delete iName; //missing in all other data files - leak?!?
+        }
+
+	if( aName.Length() > 0 )
+		{
+		TUint toCopy = aName.Length();
+		iName = HBufC::NewL( toCopy );
+		TPtr nameDes = iName->Des();
+
+		nameDes.Copy( aName.Ptr(), toCopy );
+		nameDes.SetLength( toCopy );
+		}
+	else
+		{
+		iName = NULL;
+		}
+	}
+
+
+/**
+Obtain the kernel executable name.
+*/
+EXPORT_C const TDesC & CPluginInfo::Name() const 
+	{ 
+	return ( *iName ); 
+	}
+
+
+CPluginInfo::CPluginInfo()
+	{
+	}
+
+
+/** 
+Get the maximum size allowed for this object. This is needed as the object is passed  
+across the Client Server interface.
+*/
+EXPORT_C TInt CPluginInfo::MaxSize()
+	{
+	const TInt maxSize = 256;
+	return maxSize;
+	}
+
+
+/**
+Gets the size of the object when externalized. The sizeofs used to calculate this 
+must match the operators used in ExternalizeL and InternalizeL.
+Special attention must be paid to the name. If the object has not been 
+externalized yet then this method returns the maximum that it could take.
+The name descriptor is compressed when externalized, so it is not its Size().
+Furthermore the << operator adds two bytes to the stream when externalizing 
+a descriptor.
+*/
+EXPORT_C TInt CPluginInfo::Size() const
+	{
+
+	if( iSize != 0 )
+		{
+		return iSize;
+		}
+
+	TUint extNameSize = 0;
+	if( iName )
+		{
+		extNameSize = 2					// When externalized, the << operator writes 2 bytes for the descriptor size
+					+ iName->Size();	// iName itself, in bytes.
+		}
+
+	const TUint size = 
+		+ sizeof( TUint32 )		// When externalized, we send the name length, so must include this
+		+ extNameSize
+		+ sizeof( TInt32 ) 	    // aUid
+		+ sizeof( TUint32 ) 	// aVersion
+		+ sizeof( TUint32 ) 	// aType
+		+ sizeof( TUint32 ) 	// aPair
+		+ sizeof( TUint32 );	// iSize When externalized, we send the real externalized size of the buffer
+
+	return size;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/src/processdata.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,358 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implemetation of class CProcessInfo
+//
+
+
+
+/**
+ @file
+ @see CProcessInfo
+*/
+
+#include <e32debug.h>
+#include <debuglogging.h>
+
+#include <processdata.h>
+
+/**
+Allocates and constructs a CProcessInfo object.
+@param aId Kernel process id
+@param aName Kernel process name
+@see CProcessInfo::CProcessInfo
+*/
+EXPORT_C CProcessInfo* CProcessInfo::NewL( 
+										const TUint64	  aId,
+										const TDesC		& aName )
+	{
+
+	const TUint size = 
+		  sizeof( TUint32 )		// iId Low
+		+ sizeof( TUint32 )		// iId High
+		+ sizeof( TUint32 )		// When externalized, we send the name length, so must include this
+		+ 2						// When externalized, the << operator writes 2 bytes for the descriptor size
+		+ aName.Size()			// iName Size, in bytes.
+		+ sizeof( TUint32 ) 	// Observed
+		+ sizeof( TUint32 );	// iSize itself
+
+	if( size >= MaxSize() )
+		{
+		LOG_MSG3( "CProcessInfo::NewL() : Descriptorized object = 0x%X bytes would exceed the maximum of 0x%X\n", 
+			size, MaxSize() );
+
+		User::Leave( KErrTooBig );
+		}
+
+	CProcessInfo * data = new (ELeave) CProcessInfo( aId );
+
+	CleanupStack::PushL( data );
+	
+	data->ConstructL( aName );
+
+	CleanupStack::Pop(data);
+
+	return (data);
+
+	}
+
+
+/**
+Allocates and constructs a CProcessInfo object from a descriptor. 
+The descriptor contains an externalised version of a CProcessInfo object.
+This method is typically used to obtain a CProcessInfo object from a 
+descriptor returned by the core dump server.
+
+@param aStreamData Descriptor with externalised/streamed object
+@see InternalizeL
+@see ExternalizeL
+*/
+EXPORT_C CProcessInfo* CProcessInfo::NewL( const TDesC8 & aStreamData )
+	{
+
+	CProcessInfo* self = new (ELeave) CProcessInfo();
+	
+	CleanupStack::PushL( self );
+	
+	// Open a read stream for the descriptor
+	RDesReadStream stream( aStreamData );
+
+	CleanupClosePushL( stream );
+
+	self->InternalizeL( stream );
+
+	CleanupStack::PopAndDestroy( &stream ); // finished with the stream
+
+	CleanupStack::Pop( self );
+
+	return ( self );
+
+	}
+
+
+/**
+Destructor. Deletes name if allocated.
+*/
+EXPORT_C CProcessInfo::~CProcessInfo()
+	{
+
+	if( NULL != iName )
+		{
+		delete iName;
+		}
+	}
+
+
+/**
+First phase contructor. Sets the size to 0, name to NULL.
+@see CProcessInfo::NewL()
+*/
+CProcessInfo::CProcessInfo(	const TUint64	  aId ) :
+	iId			 ( aId ),
+    iObserved    ( EFalse ),
+	iSize        ( 0 )
+	{
+	iName = NULL;
+	}
+
+
+/**
+Second phase constructor initialises the name of the process.
+@param aName Process name
+@see NameL()
+*/
+void CProcessInfo::ConstructL(  const TDesC & aName )
+	{
+	NameL( aName );
+	}
+
+
+/**
+Initialise this object with the contents of RReadStream aStream
+The descriptor contains an externalised version of an object.
+This method is typically used to obtain a CProcessInfo object from 
+the core dump server.
+Any modifications to this method should be synchronised with ExternalizeL().
+Also note that the methods used from RReadStream (>> or ReadUint32L) 
+can behave differently, especially for descriptors.
+@param aStream Stream with streamed object
+@see ExternalizeL
+@see RReadStream
+@pre Call Externalise to obtain the stream containing an externalised 
+version of this object.
+*/
+EXPORT_C void CProcessInfo::InternalizeL( RReadStream & aStream )
+	{
+
+	TUint32 idLow = aStream.ReadUint32L(); 
+
+	TUint32 idHigh = aStream.ReadUint32L(); 
+	iId = MAKE_TUINT64( idHigh, idLow );
+
+	// Read the number of character elements in the name. 
+	TUint32 nameLength = aStream.ReadUint32L(); 
+
+	if( NULL != iName )
+		{
+		LOG_MSG( " iName != NULL\n" );
+		delete iName;
+		iName = NULL;
+		}
+
+	if ( nameLength > 0 )
+		{
+		iName  = HBufC::NewL( aStream, nameLength ); 
+		}
+	else
+		{
+		iName  = NULL;
+		}
+
+	iObserved = static_cast<TBool>(aStream.ReadUint32L());
+
+	iSize = aStream.ReadUint32L() ;
+	}
+
+
+
+/**
+Make a streamed representation of this object to RWriteStream aStream.
+
+This method is typically by the core dump server when contructing a list of 
+CProcessInfo for a client.
+Any modifications to this method should be synchronised with InternalizeL(). 
+Also note that the methods used from RWriteStream (>> or WriteUint32L) can behave differently,
+especially for descriptors.
+@param aStream Stream to stream object onto
+@param buf Buffer onto the same stream, used to obtain the correct size of the externalised object
+@see InternalizeL
+@see RReadStream
+@see RWriteStream
+@post The stream contains an externalised version of this object.
+*/
+EXPORT_C void CProcessInfo::ExternalizeL( RWriteStream & aStream, CBufFlat* buf )
+	{
+
+	const TUint32 idLow = I64LOW( iId ); 
+	const TUint32 idHigh = I64HIGH( iId ); 
+
+	// Take the size of the buffer before we add anything to it.
+	TUint startBufSize = buf->Size();
+
+	aStream.WriteUint32L( idLow ); 
+	aStream.WriteUint32L( idHigh ); 
+
+	TUint nameLength = 0;
+
+	if ( ( NULL != iName ) && ( iName->Des().Length() > 0 ) )
+		{
+
+		nameLength = iName->Des().Length();
+
+		if( nameLength > 0 )
+			{
+			// Write the number of character elements in the name. 
+			aStream.WriteUint32L( nameLength ); 
+			aStream << iName->Des();
+			}
+		}
+
+	if( nameLength == 0 )
+		{
+		aStream.WriteUint32L( 0 ); 
+		}
+
+	aStream.WriteUint32L( static_cast<TUint32>(iObserved) );
+
+	iSize = buf->Size() - startBufSize + 4;
+
+	aStream.WriteUint32L( iSize );
+
+	}
+
+
+/**
+Obtain the kernel process id.
+*/
+EXPORT_C const TUint64 & CProcessInfo::Id() const 
+	 { 
+	 return ( iId ); 
+	 }
+
+
+/**
+Set the name of the process by deleting, allocating and then copying the parameter.
+@param aName Name of the process to set to
+@see ConstructL()
+*/
+EXPORT_C void CProcessInfo::NameL( const TDesC & aName )
+	{
+
+	if( aName.Length() > 0 )
+		{
+		TUint toCopy = aName.Length();
+		iName = HBufC::NewL( toCopy );
+		TPtr nameDes = iName->Des();
+
+		nameDes.Copy( aName.Ptr(), toCopy );
+		nameDes.SetLength( toCopy );
+		}
+	else
+		{
+		iName = NULL;
+		}
+	}
+
+
+/**
+Obtain the kernel process name.
+*/
+EXPORT_C const TDesC & CProcessInfo::Name() const 
+	{ 
+	if(!iName)
+		{
+		return KNoThreadName;
+		}
+	
+	return ( *iName ); 
+	}
+
+/**
+Returns ETrue if the process is being observed for crashes by the Core Dump Server.
+*/
+EXPORT_C TBool CProcessInfo::Observed() const 
+	 { 
+	 return ( iObserved ); 
+	 }
+
+/**
+Set whether this process is being observed for crashes by the Core Dump Server.
+*/
+EXPORT_C void CProcessInfo::Observed( TBool aFlag ) 
+	 { 
+	 iObserved = aFlag; 
+	 }
+
+CProcessInfo::CProcessInfo()
+	{
+	}
+
+
+ /* 
+ Get the maximum size allowed for this object. This is needed as the object is passed  
+ across the Client Server interface.
+ */
+ EXPORT_C TInt CProcessInfo::MaxSize()
+	{
+	
+	const TInt maxSize = 256;
+	return maxSize;
+	}
+
+
+/**
+Gets the size of the object when externalized. The sizeofs used to calculate this 
+must match the operators used in ExternalizeL and InternalizeL.
+Special attention must be paid to the name. If the object has not been 
+externalized yet then this method returns the maximum that it could take.
+The name descriptor is compressed when externalized, so it is not its Size().
+Furthermore the << operator adds two bytes to the stream when externalizing 
+a descriptor.
+*/
+ EXPORT_C TInt CProcessInfo::Size() const
+	{
+
+	if( iSize != 0 )
+		{
+		return iSize;
+		}
+
+	TUint extNameSize = 0;
+	if( iName )
+		{
+		extNameSize = 2					// When externalized, the << operator writes 2 bytes for the descriptor size
+					+ iName->Size();	// iName itself, in bytes.
+		}
+
+	const TUint size = 
+		  sizeof( TUint32 )		// iId Low
+		+ sizeof( TUint32 )		// iId High
+		+ sizeof( TUint32 )		// When externalized, we send the name length, so must include this
+		+ extNameSize
+		+ sizeof( TUint32 ) 	// iObserved
+		+ sizeof( TUint32 );	// iSize When externalized, we send the real externalized size of the buffer
+
+	return size;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/src/streamelement.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,57 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// streamelement.h
+// Implemetation of class CStreamElementBase
+//
+
+
+
+/**
+ @file
+ @see CStreamElementBase
+*/
+
+#include <streamelement.h>
+
+
+EXPORT_C HBufC8* CStreamElementBase::MarshalDataL()
+	{
+		const TInt KExpandSize = 128; // "Granularity" of dynamic buffer	
+
+		/*
+		Create a dynamic flat buffer to hold this object's member data	
+		Can only use CBufFlat due to Store supporting CBufFlat and CBufSeg
+		See Symbian OS guide » System libraries » Using Store » Streaming » Templated stream operators
+		*/
+		CBufFlat* buf = CBufFlat::NewL( KExpandSize );
+
+		CleanupStack::PushL( buf );
+
+		RBufWriteStream stream( *buf ); // Stream over the buffer
+
+		CleanupClosePushL( stream );
+
+		ExternalizeL( stream, buf );
+
+		CleanupStack::PopAndDestroy( &stream );
+		
+		// Create a heap descriptor from the buffer
+		HBufC8 * des = HBufC8::NewL( buf->Size() );
+		TPtr8 ptr( des->Des() );
+
+		buf->Read( 0, ptr, buf->Size() );
+		
+		CleanupStack::PopAndDestroy( buf ); // Finished with the buffer
+		return ( des );
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/cdssupport/src/threaddata.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,532 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implemetation of CThreadInfo class 
+//
+
+
+
+/**
+ @file
+ @see CThreadInfo
+*/
+
+
+#include <rm_debug_api.h>
+#include <debuglogging.h> 
+#include <threaddata.h>
+
+/**
+Allocates and constructs a CThreadInfo object.
+@param aId Kernel thread id
+@param aName Kernel thread name
+@param aProcessId Kernel id of owning process
+@param aPriority Kernel thread priority TThreadPriority
+@param aSvcStackPtr Thread supervisor stack pointer
+@param aSvcStackAddr Thread supervisor mode stack base address
+@param aSvcStackSize Thread supervisor mode stack size in bytes
+@param aUsrStackAddr Thread user mode stack base address
+@param aUsrStackSize Thread user mode stack base size in bytes
+
+@see CThreadInfo::CThreadInfo
+*/
+EXPORT_C CThreadInfo* CThreadInfo::NewL( 
+										const TUint64	& aId,
+										const TDesC		& aName, 
+										const TUint64	& aProcessId,
+										const TUint		& aPriority,
+										const TLinAddr	& aSvcStackPtr,
+										const TLinAddr	& aSvcStackAddr,
+										const TUint		& aSvcStackSize,
+										const TLinAddr	& aUsrStackAddr,
+										const TUint		& aUsrStackSize )
+	{
+
+	// Add up the potential maximum size of the externalized object
+	const TUint size = 
+		  sizeof( TUint32 )		// iId Low
+		+ sizeof( TUint32 )		// iId High
+
+		+ sizeof( TUint32 )		// When externalized, we send the name length, so must include this
+		+ 2						// When externalized, the << operator writes 2 bytes for the descriptor size
+		+ aName.Size()			// iName Size, in bytes.
+
+		+ sizeof( TUint32 )		// iProcessId Low
+		+ sizeof( TUint32 )		// iProcessId High
+		+ sizeof( TUint32 )		// iPriority
+		+ sizeof( TUint32 )		// iSvcStackPtr
+		+ sizeof( TUint32 )		// iSvcStackAddr
+		+ sizeof( TUint32 )		// iSvcStackSize
+		+ sizeof( TUint32 )		// iUsrStackAddr
+		+ sizeof( TUint32 )		// iUsrStackSize
+		+ sizeof( TUint32 )		// iObserved
+
+		+ sizeof( TUint32 );	// iSize itself
+
+	if( size >= MaxSize() )
+		{
+		LOG_MSG3( "CThreadInfo::NewL() : Descriptorized object = 0x%X bytes would exceed the maximum of 0x%X\n", 
+			size, MaxSize() );
+
+		User::Leave( KErrTooBig );
+		}
+
+	CThreadInfo * data = new (ELeave) CThreadInfo(	aId, 
+													aProcessId, 
+													aPriority, 
+													aSvcStackPtr,
+													aSvcStackAddr,
+													aSvcStackSize,
+													aUsrStackAddr,
+													aUsrStackSize );
+	CleanupStack::PushL( data );
+	
+	data->ConstructL( aName );
+
+	CleanupStack::Pop(data);
+
+	return (data);
+
+	}
+
+
+/**
+Allocates and constructs a CThreadInfo object from a descriptor. 
+The descriptor contains an externalised version of a CThreadInfo object.
+This method is typically used to obtain a CThreadInfo object from a 
+descriptor returned by the core dump server.
+
+@param aStreamData Descriptor with externalised/streamed object
+@see InternalizeL
+@see ExternalizeL
+*/
+EXPORT_C CThreadInfo* CThreadInfo::NewL( const TDesC8 & aStreamData )
+	{
+
+	CThreadInfo* self = new (ELeave) CThreadInfo();
+	
+	CleanupStack::PushL( self );
+	
+	// Open a read stream for the descriptor
+	RDesReadStream stream( aStreamData );
+
+	CleanupClosePushL( stream );
+
+	self->InternalizeL( stream );
+
+	CleanupStack::PopAndDestroy( &stream ); // finished with the stream
+
+	CleanupStack::Pop( self );
+
+	return ( self );
+
+	}
+
+
+/**
+Destructor. Deletes name if allocated.
+*/
+EXPORT_C CThreadInfo::~CThreadInfo()
+	{
+
+	if( NULL != iName )
+		{
+		delete iName;
+		}
+	}
+
+/**
+Set the name of the thread by deleting, allocating and then copying the parameter.
+@param aName Name of the thread to set to 
+@see ConstructL()
+*/
+EXPORT_C void CThreadInfo::NameL( const TDesC & aName )
+	{
+
+	if( aName.Length() > 0 )
+		{
+		TUint toCopy = aName.Length();
+		iName = HBufC::NewL( toCopy );
+		TPtr nameDes = iName->Des();
+
+		nameDes.Copy( aName.Ptr(), toCopy );
+		nameDes.SetLength( toCopy );
+		}
+	else
+		{
+		iName = NULL;
+		}
+	}
+
+
+/**
+First phase contructor. Sets the size to 0, name to NULL.
+@see CThreadInfo::NewL()
+*/
+CThreadInfo::CThreadInfo(	const TUint64	& aId,
+							const TUint64	& aProcessId,
+							const TUint		& aPriority,
+							const TLinAddr	& aSvcStackPtr,
+							const TLinAddr	& aSvcStackAddr,
+							const TUint		& aSvcStackSize,
+							const TLinAddr	& aUsrStackAddr,
+							const TUint		& aUsrStackSize ) :
+	iId			 ( aId ),
+	iName		 ( NULL ),
+	iProcessId	 ( aProcessId ),
+	iPriority	 ( aPriority ), 
+	iSvcStackPtr ( aSvcStackPtr ),
+	iSvcStackAddr( aSvcStackAddr ),
+	iSvcStackSize( aSvcStackSize ),
+	iUsrStackAddr( aUsrStackAddr ),
+	iUsrStackSize( aUsrStackSize ),
+	iObserved    ( EFalse ),
+	iSize        ( 0 ), 
+	iLastCpuId	 ( -1 )
+	{
+	
+	}
+
+
+/**
+Second phase constructor initialises the name of the thread.
+@param aName Thread name
+@see NameL()
+*/
+void CThreadInfo::ConstructL(  const TDesC & aName )
+	{
+	NameL( aName );
+	}
+
+
+
+/**
+Initialise this object with the contents of RReadStream aStream.
+The descriptor contains an externalised version of an object.
+This method is typically used to obtain a CThreadInfo object from 
+the core dump server.
+Any modifications to this method should be synchronised with ExternalizeL().
+Also note that the methods used from RReadStream (>> or ReadUint32L) 
+can behave differently, especially for descriptors.
+@param aStream Stream with streamed object
+@see ExternalizeL
+@see RReadStream
+@pre Call Externalise to obtain the stream containing an externalised 
+version of this object.
+*/
+EXPORT_C void CThreadInfo::InternalizeL( RReadStream & aStream )
+	{
+
+	TUint32 idLow = aStream.ReadUint32L(); 
+
+	TUint32 idHigh = aStream.ReadUint32L(); 
+	iId = MAKE_TUINT64( idHigh, idLow );
+
+	if( NULL != iName )
+		{
+		//LOG_MSG( " iName != NULL\n" );
+		delete iName;
+		iName = NULL;
+		}	
+
+	TUint32 nameLength = aStream.ReadUint32L(); 
+
+	if ( nameLength > 0 )
+		{
+		iName = HBufC::NewL( aStream, nameLength ); 
+		}
+	else
+		{
+		iName  = NULL;
+		}
+
+	TUint32 pidLow = aStream.ReadUint32L(); 
+	TUint32 pidHigh = aStream.ReadUint32L(); 
+	iProcessId = MAKE_TUINT64( pidHigh, pidLow );
+
+	iPriority     = aStream.ReadUint32L(); 
+	iSvcStackPtr  = aStream.ReadUint32L() ;
+	iSvcStackAddr = aStream.ReadUint32L() ;
+	iSvcStackSize = aStream.ReadUint32L() ;
+	iUsrStackAddr = aStream.ReadUint32L() ;
+	iUsrStackSize = aStream.ReadUint32L() ;
+	iObserved     = static_cast<TBool>(aStream.ReadUint32L());
+	iLastCpuId = aStream.ReadUint32L();
+	iHeapBase = aStream.ReadUint32L();
+	iHeapSize = aStream.ReadUint32L();
+	iSize = aStream.ReadUint32L() ;
+	}
+
+
+
+
+
+/**
+Make a streamed representation of this object to RWriteStream aStream.
+
+This method is typically by the core dump server when contructing a list of 
+CThreadInfo for a client.
+Any modifications to this method should be synchronised with InternalizeL(). 
+Also note that the methods used from RWriteStream (>> or WriteUint32L) can behave differently,
+especially for descriptors.
+@param aStream Stream to stream object onto
+@param buf Buffer onto the same stream, used to obtain correct size of externalised object
+@see InternalizeL
+@see RReadStream
+@see RWriteStream
+@post The stream contains an externalised version of this object.
+*/
+EXPORT_C void CThreadInfo::ExternalizeL( RWriteStream & aStream, CBufFlat* buf )
+	{
+
+	const TUint32 idLow = I64LOW( iId ); 
+	const TUint32 idHigh = I64HIGH( iId ); 
+
+	// Take the size of the buffer before we add anything to it.
+	TUint startBufSize = buf->Size();
+
+	aStream.WriteUint32L( idLow ); 
+	aStream.WriteUint32L( idHigh ); 
+
+	TUint nameLength = 0;
+
+	if ( NULL != iName )
+		{
+		nameLength = iName->Des().Length();
+		if( nameLength > 0 )
+			{
+			// Write the number of character elements in the name. 
+			aStream.WriteUint32L( nameLength ); 
+			aStream << iName->Des();
+			}
+		}
+
+	if( nameLength == 0 )
+		{
+		aStream.WriteUint32L( 0 ); 
+		}
+
+	const TUint32 pIdLow = I64LOW( iProcessId ); 
+	const TUint32 pIdHigh = I64HIGH( iProcessId ); 
+	aStream.WriteUint32L( pIdLow ); 
+	aStream.WriteUint32L( pIdHigh );
+	
+	aStream.WriteUint32L( iPriority     ); 
+
+	aStream.WriteUint32L( iSvcStackPtr  ) ;
+	aStream.WriteUint32L( iSvcStackAddr ) ;
+	aStream.WriteUint32L( iSvcStackSize ) ;
+	aStream.WriteUint32L( iUsrStackAddr );
+	aStream.WriteUint32L( iUsrStackSize );
+	aStream.WriteUint32L( static_cast<TUint32>(iObserved) );
+	aStream.WriteInt32L(iLastCpuId);
+	aStream.WriteUint32L( iHeapBase );
+	aStream.WriteUint32L( iHeapSize );
+
+	// The real exteranlized size is the size of the buffer up to here plus the 
+	// 4 bytes for the size itself
+	iSize = buf->Size() - startBufSize + 4;
+	aStream.WriteUint32L( iSize );
+
+	}
+
+/**
+Obtain the kernel thread id.
+*/
+EXPORT_C const TUint64 & CThreadInfo::Id() const 
+	 { 
+	 return ( iId ); 
+	 }
+
+/**
+Obtain the kernel thread name.
+*/
+EXPORT_C const TDesC & CThreadInfo::Name() const 
+	{ 
+	return ( *iName ); 
+	}
+
+/**
+Obtain the kernel owning process id.
+*/
+EXPORT_C const TUint64 & CThreadInfo::ProcessId() const 
+	 { 
+	 return ( iProcessId );
+	 }
+
+/**
+Obtain the kernel priority.
+*/
+EXPORT_C TUint CThreadInfo::Priority() const 
+	 { 
+	 return ( iPriority ); 
+	 }
+
+/**
+Obtain the kernel supervisor mode stack pointer.
+*/
+EXPORT_C TUint CThreadInfo::SvcStackPtr() const 
+	 { 
+	 return ( iSvcStackPtr ); 
+	 }
+
+/**
+Obtain the kernel supervisor mode stack base address.
+*/
+EXPORT_C TUint CThreadInfo::SvcStackAddr() const 
+	 { 
+	 return ( iSvcStackAddr ); 
+	 }
+
+/**
+Obtain the kernel supervisor mode stack size in bytes.
+*/
+EXPORT_C TUint CThreadInfo::SvcStackSize() const 
+	 { 
+	 return ( iSvcStackSize ); 
+	 }
+
+/**
+Obtain the kernel user mode stack base address.
+*/
+EXPORT_C TUint CThreadInfo::UsrStackAddr() const 
+	 { 
+	 return ( iUsrStackAddr ); 
+	 }
+
+/**
+Obtain the kernel user mode stack size in bytes.
+*/
+EXPORT_C TUint CThreadInfo::UsrStackSize() const 
+	 { 
+	 return ( iUsrStackSize ); 
+	 }
+
+
+/**
+Returns ETrue if the thread is being explicitly observed for crashes by the Core Dump Server.
+If only the owning process is being observed, this method returns EFalse.
+*/
+EXPORT_C TBool CThreadInfo::Observed() const 
+	 { 
+	 return ( iObserved ); 
+	 }
+
+/**
+Set whether this thread is being observed for crashes by the Core Dump Server.
+*/
+EXPORT_C void CThreadInfo::Observed(TBool aFlag) 
+	 { 
+	 iObserved = aFlag; 
+	 }
+
+CThreadInfo::CThreadInfo()
+	{
+	}
+
+
+/**
+Get the maximum size allowed for this object. This is needed as the object is passed  
+across the Client Server interface.
+*/
+EXPORT_C TInt CThreadInfo::MaxSize()
+	{
+	
+	const TInt maxSize = 512;
+	return maxSize;
+	}
+
+
+/**
+Gets the size of the object when externalized. The sizeofs used to calculate this 
+must match the operators used in ExternalizeL and InternalizeL.
+Special attention must be paid to the name. If the object has not been 
+externalized yet then this method returns the maximum that it could take.
+The name descriptor is compressed when externalized, so it is not its Size().
+Furthermore the << operator adds two bytes to the stream when externalizing 
+a descriptor
+*/
+EXPORT_C TInt CThreadInfo::Size() const
+	{
+
+	if( iSize != 0 )
+		{
+		return iSize;
+		}
+
+	// This is the maximum size of the object when externalized.
+	// It is a maximum since externalizing 16 bit descriptors compresses the data,
+	// and thus the real externalized size is only known at the end of the Externalize() call.
+	// The difference is the iName->Size()
+
+
+	TUint extNameSize = 0;
+	if( iName )
+		{
+		extNameSize = 2					// When externalized, the << operator writes 2 bytes for the descriptor size
+					+ iName->Size();	// iName itself, in bytes. Worst case
+		}
+
+	const TUint size = 
+		  sizeof( TUint32 )		// iId Low
+		+ sizeof( TUint32 )		// iId High
+		+ sizeof( TUint32 )		// When externalized, we send the name length, so must include this
+		+ extNameSize
+		+ sizeof( TUint32 )		// iProcessId Low
+		+ sizeof( TUint32 )		// iProcessId High
+		+ sizeof( TUint32 )		// iPriority
+		+ sizeof( TUint32 )		// iSvcStackPtr
+		+ sizeof( TUint32 )		// iSvcStackAddr
+		+ sizeof( TUint32 )		// iSvcStackSize
+		+ sizeof( TUint32 )		// iUsrStackAddr
+		+ sizeof( TUint32 )  	// iUsrStackSize
+		+ sizeof( TUint32 )  	// iObserved
+		+ sizeof( TInt32 )  	// iLastCpuId
+		+ sizeof( TUint32 )  	// iHeapBase
+		+ sizeof( TUint32 )  	// iHeapSize
+		+ sizeof( TUint32 );	// iSize When externalized, we send the real externalized size of the buffer
+	
+	return size;
+	}
+
+
+EXPORT_C void  CThreadInfo::SetLastCpuId(TInt32 aLastCpuId)
+	{
+	iLastCpuId = aLastCpuId;
+	}
+
+EXPORT_C TInt32  CThreadInfo::LastCpuId() const
+	{
+	return iLastCpuId;
+	}
+
+EXPORT_C void  CThreadInfo::SetHeapBase(TUint32 aHeapBase)
+	{
+	iHeapBase = aHeapBase;
+	}
+
+EXPORT_C TUint32  CThreadInfo::HeapBase() const
+	{
+	return iHeapBase;
+	}
+
+EXPORT_C void  CThreadInfo::SetHeapSize(TUint32 aHeapSize)
+	{
+	iHeapSize = aHeapSize;
+	}
+
+EXPORT_C TUint32  CThreadInfo::HeapSize() const
+	{
+	return iHeapSize;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/config/bwins/coredumpinterfaceu.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,24 @@
+EXPORTS
+	?PluginRequestL@RCoreDumpSession@@QBEXABVTPluginRequest@@@Z @ 1 NONAME ; void RCoreDumpSession::PluginRequestL(class TPluginRequest const &) const
+	?ObservationRequestL@RCoreDumpSession@@QBEXABVTDesC16@@0H@Z @ 2 NONAME ; void RCoreDumpSession::ObservationRequestL(class TDesC16 const &, class TDesC16 const &, int) const
+	?GetWritersL@RCoreDumpSession@@QBEXAAV?$RPointerArray@VCPluginInfo@@@@@Z @ 3 NONAME ; void RCoreDumpSession::GetWritersL(class RPointerArray<class CPluginInfo> &) const
+	?GetFormattersL@RCoreDumpSession@@QBEXAAV?$RPointerArray@VCPluginInfo@@@@@Z @ 4 NONAME ; void RCoreDumpSession::GetFormattersL(class RPointerArray<class CPluginInfo> &) const
+	??0RCoreDumpSession@@QAE@XZ @ 5 NONAME ; RCoreDumpSession::RCoreDumpSession(void)
+	?GetThreadsL@RCoreDumpSession@@QBEXAAV?$RPointerArray@VCThreadInfo@@@@_K@Z @ 6 NONAME ; void RCoreDumpSession::GetThreadsL(class RPointerArray<class CThreadInfo> &, unsigned long long) const
+	?Connect@RCoreDumpSession@@QAEHXZ @ 7 NONAME ; int RCoreDumpSession::Connect(void)
+	?ProcessCrashLogL@RCoreDumpSession@@QAEXH@Z @ 8 NONAME ; void RCoreDumpSession::ProcessCrashLogL(int)
+	?DeleteCrashLogL@RCoreDumpSession@@QBEXH@Z @ 9 NONAME ; void RCoreDumpSession::DeleteCrashLogL(int) const
+	?SetConfigParameterL@RCoreDumpSession@@QBEXABVCOptionConfig@@@Z @ 10 NONAME ; void RCoreDumpSession::SetConfigParameterL(class COptionConfig const &) const
+	?ListCrashesInFlashL@RCoreDumpSession@@QBEXAAV?$RPointerArray@VTCrashInfo@@@@@Z @ 11 NONAME ; void RCoreDumpSession::ListCrashesInFlashL(class RPointerArray<class TCrashInfo> &) const
+	?Disconnect@RCoreDumpSession@@QAEXXZ @ 12 NONAME ; void RCoreDumpSession::Disconnect(void)
+	?SaveConfigL@RCoreDumpSession@@QBEXABVTDesC16@@@Z @ 13 NONAME ; void RCoreDumpSession::SaveConfigL(class TDesC16 const &) const
+	?GetExecutablesL@RCoreDumpSession@@QBEXAAV?$RPointerArray@VCExecutableInfo@@@@@Z @ 14 NONAME ; void RCoreDumpSession::GetExecutablesL(class RPointerArray<class CExecutableInfo> &) const
+	?GetConfigParameterL@RCoreDumpSession@@QBEPAVCOptionConfig@@H@Z @ 15 NONAME ; class COptionConfig * RCoreDumpSession::GetConfigParameterL(int) const
+	?GetNumberConfigParametersL@RCoreDumpSession@@QBEHXZ @ 16 NONAME ; int RCoreDumpSession::GetNumberConfigParametersL(void) const
+	?GetProcessesL@RCoreDumpSession@@QBEXAAV?$RPointerArray@VCProcessInfo@@@@@Z @ 17 NONAME ; void RCoreDumpSession::GetProcessesL(class RPointerArray<class CProcessInfo> &) const
+	?LoadConfigL@RCoreDumpSession@@QBEXABVTDesC16@@@Z @ 18 NONAME ; void RCoreDumpSession::LoadConfigL(class TDesC16 const &) const
+	?GetPluginListL@RCoreDumpSession@@QBEXAAV?$RArray@VTPluginInfo@@@@@Z @ 19 NONAME ; void RCoreDumpSession::GetPluginListL(class RArray<class TPluginInfo> &) const
+	?DeleteCrashPartitionL@RCoreDumpSession@@QBEXXZ @ 20 NONAME ; void RCoreDumpSession::DeleteCrashPartitionL(void) const
+	?ProcessCrashLog@RCoreDumpSession@@QAEXHAAVTRequestStatus@@@Z @ 21 NONAME ; void RCoreDumpSession::ProcessCrashLog(int, class TRequestStatus &)
+	?CancelProcessCrashLog@RCoreDumpSession@@QAEHH@Z @ 22 NONAME ; int RCoreDumpSession::CancelProcessCrashLog(int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/config/bwins/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/config/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/config/eabi/coredumpinterfaceu.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,25 @@
+EXPORTS
+	_ZN16RCoreDumpSession10DisconnectEv @ 1 NONAME
+	_ZN16RCoreDumpSession7ConnectEv @ 2 NONAME
+	_ZN16RCoreDumpSessionC1Ev @ 3 NONAME
+	_ZN16RCoreDumpSessionC2Ev @ 4 NONAME
+	_ZNK16RCoreDumpSession11GetThreadsLER13RPointerArrayI11CThreadInfoEy @ 5 NONAME
+	_ZNK16RCoreDumpSession11LoadConfigLERK7TDesC16 @ 6 NONAME
+	_ZNK16RCoreDumpSession11SaveConfigLERK7TDesC16 @ 7 NONAME
+	_ZNK16RCoreDumpSession13GetProcessesLER13RPointerArrayI12CProcessInfoE @ 8 NONAME
+	_ZNK16RCoreDumpSession14GetPluginListLER6RArrayI11TPluginInfoE @ 9 NONAME
+	_ZNK16RCoreDumpSession14PluginRequestLERK14TPluginRequest @ 10 NONAME
+	_ZNK16RCoreDumpSession15GetExecutablesLER13RPointerArrayI15CExecutableInfoE @ 11 NONAME
+	_ZNK16RCoreDumpSession19GetConfigParameterLEi @ 12 NONAME
+	_ZNK16RCoreDumpSession19ObservationRequestLERK7TDesC16S2_i @ 13 NONAME
+	_ZNK16RCoreDumpSession19SetConfigParameterLERK13COptionConfig @ 14 NONAME
+	_ZNK16RCoreDumpSession26GetNumberConfigParametersLEv @ 15 NONAME
+	_ZNK16RCoreDumpSession11GetWritersLER13RPointerArrayI11CPluginInfoE @ 16 NONAME
+	_ZNK16RCoreDumpSession14GetFormattersLER13RPointerArrayI11CPluginInfoE @ 17 NONAME
+	_ZN16RCoreDumpSession16ProcessCrashLogLEi @ 18 NONAME
+	_ZNK16RCoreDumpSession15DeleteCrashLogLEi @ 19 NONAME
+	_ZNK16RCoreDumpSession19ListCrashesInFlashLER13RPointerArrayI10TCrashInfoE @ 20 NONAME
+	_ZNK16RCoreDumpSession21DeleteCrashPartitionLEv @ 21 NONAME
+	_ZN16RCoreDumpSession15ProcessCrashLogEiR14TRequestStatus @ 22 NONAME
+	_ZN16RCoreDumpSession21CancelProcessCrashLogEi @ 23 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/config/eabi/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/config/src/coredumpinterface.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,736 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implement the interface to the Core Dump Server
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+ @see RCoreDumpSession
+*/
+
+
+// Project includes
+#include <coredumpinterface.h>
+
+/**
+    Called to start the server (by the RCoreDumpSession::Connect())
+    The function is only called if the server is not running.
+@return KErrNone if server was successfully started, or one of the other
+system wide error codes
+*/	
+TInt RCoreDumpSession::StartServer()
+	{
+    LOG_MSG("->RCoreDumpSession::StartServer()\n");
+    TInt err;
+	// Create the server process
+	const TUidType serverUid( KNullUid, KNullUid, KCoreDumpServUid );
+
+	RProcess server;
+    _LIT(KServerCommand, "");
+	LOG_MSG("RCoreDumpSession::StartServer -> Create()\n");
+	err = server.Create( KCoreDumpServerName, KServerCommand, serverUid );
+	
+    if(err != KErrNone)
+        {
+        LOG_MSG2("RCoreDumpSession::StartServer - creating server failed! err:%d\n", err);
+        return err;
+        }
+
+	//Set up Rendezvous so that server thread can signal correct startup
+	TRequestStatus serverDiedRequestStatus;
+	server.Rendezvous( serverDiedRequestStatus );
+	
+	// Status flag should still be pending as we haven't resumed the server yet!
+	if( serverDiedRequestStatus != KRequestPending )
+		{
+		LOG_MSG2("RCoreDumpSession::StartServer - rendezvous failed! err:%d\n", serverDiedRequestStatus.Int());
+		server.Kill(KErrAbort); 
+        server.Close();
+        return serverDiedRequestStatus.Int();
+		}
+	server.Resume();
+
+	LOG_MSG("RCoreDumpSession::StartServer -> User::WaitForRequest()\n");
+
+	// Will block here until server signals starts
+    User::WaitForRequest( serverDiedRequestStatus );
+
+    LOG_MSG("RCoreDumpSession::StartServer -> Close()\n");
+
+    // we can't use the 'exit reason' if the server panicked as this
+    // is the panic 'reason' and may be '0' which cannot be distinguished from KErrNone
+    err = ( server.ExitType()==EExitPanic ) ? KErrGeneral : serverDiedRequestStatus.Int();
+	server.Close();
+	return err;
+	}
+
+    
+/**
+    Constructor. It initializes the member variables to zero.
+*/
+EXPORT_C RCoreDumpSession::RCoreDumpSession()
+    : iConnected(EFalse), iMaxConfigParamSize(0)
+	{
+	}
+
+
+/**
+First call that a client must make to use the Core Dump server. This call
+starts the server if not already running, and then connects to it.
+@return KErrNone if connection was successfully created, or one of the other
+system wide error codes
+*/
+EXPORT_C TInt RCoreDumpSession::Connect()
+	{
+	LOG_MSG("->RCoreDumpSession::Connect()\n");
+
+    if(iConnected != EFalse)
+        {
+        LOG_MSG("RCoreDumpSession::Connect - already connected\n"); 
+        return KErrNone;
+        }
+
+    TInt err;
+
+    for(TInt i = 0; i < KConnectionRetries; i++)
+        {
+        LOG_MSG("RCoreDumpSession::Connect -> StartServer()\n");
+        err = StartServer();
+        if( (KErrNone != err) && (KErrAlreadyExists != err) )
+            {
+            return err;
+            }
+
+        LOG_MSG("RCoreDumpSession::Connect - CreateSession()\n");
+        err = CreateSession( KCoreDumpServerName, Version(), KTTDefaultMessageSlots );
+
+        if(KErrNone == err)
+            {
+            LOG_MSG("RCoreDumpSession::Connect - session created successfully\n");
+            iConnected = ETrue;
+            return KErrNone;
+            }
+        }
+    LOG_MSG("RCoreDumpSession::Connect - too many retries!\n");
+	return err;
+    }
+
+/**
+    Required to be called to close the session with the CoreDumpServer.
+    It automatically closes this session handle.
+*/
+EXPORT_C void RCoreDumpSession::Disconnect()
+	{
+	iConnected = EFalse;
+    RSessionBase::Close();
+	}
+
+/**
+Provides the version number of the server we require for this API.
+@return TVersion object representing the version of the server
+*/
+TVersion RCoreDumpSession::Version () const
+	{
+	return TVersion(KCoreDumpServMajorVersionNumber,
+					KCoreDumpServMinorVersionNumber,
+					KCoreDumpServBuildVersionNumber);
+	}
+
+/**
+Provides the caller with a list of the currently running processes.
+@param aProcessList Reference to the pointer list that is going to be filled
+with CProcessInfo objects. The caller takes ownership of the content.
+@see RProcessPointerList
+*/
+EXPORT_C void RCoreDumpSession::GetProcessesL( RProcessPointerList & aProcessList ) const
+	{
+    LOG_MSG("->RCoreDumpSession::GetProcessesL()\n");
+
+    aProcessList.ResetAndDestroy();
+
+	TListRequest request;
+	request.iListType = TListRequest::EProcessList;
+	request.iSubId1 = 0;
+	request.iSubId2 = 0;
+	request.iRequiredDescriptorSize = 0;
+
+	const TUint8 * bufStart = GetListLC(request).Ptr();
+	TUint nextObjOffset = 0;
+	for(TInt i = 0 ; i < request.iRemaining; i++)
+		{
+        TPtrC8 nextObj( (bufStart + nextObjOffset), CProcessInfo::MaxSize() );
+        CProcessInfo * processInfoPtr = CProcessInfo::NewL( nextObj ); 
+
+        TInt err = aProcessList.Append(processInfoPtr);
+        if(err != KErrNone)
+            {
+            LOG_MSG2("RCoreDumpSession::GetProcessesL - unable to append process info object! err:%d\n", err);
+            delete processInfoPtr;
+            User::Leave(err);
+            }
+        nextObjOffset += processInfoPtr->Size();
+        }
+	CleanupStack::PopAndDestroy(); //GetListLC
+    }
+
+
+/**
+    Provides the caller with a list of executables.
+@param aExecutableList reference to the pointer list that is going to be filled
+with CExecutableInfo objects. The caller takes ownership of the content.
+@see RExecutablePointerList
+*/
+EXPORT_C void RCoreDumpSession::GetExecutablesL( RExecutablePointerList & aExecutableList ) const
+	{
+    LOG_MSG("->RCoreDumpSession::GetExecutablesL()\n");
+
+    aExecutableList.ResetAndDestroy();
+
+	TListRequest request;
+	request.iListType = TListRequest::EExecutableList;
+	request.iSubId1 = 0;
+	request.iSubId2 = 0;
+	request.iRequiredDescriptorSize = 0;
+
+	const TUint8 * bufStart = GetListLC(request).Ptr();
+	TUint nextObjOffset = 0;
+	for(TInt i = 0 ; i < request.iRemaining; i++)
+		{
+        TPtrC8 nextObj( (bufStart + nextObjOffset), CExecutableInfo::MaxSize() );
+        CExecutableInfo * executableInfoPtr = CExecutableInfo::NewL( nextObj ); 
+
+        TInt err = aExecutableList.Append( executableInfoPtr );
+        if(err != KErrNone)
+            {
+            LOG_MSG2("RCoreDumpSession::GetExecutablesL - unable to append Executable info object! err:%d\n", err);
+            delete executableInfoPtr;
+            User::Leave(err);
+            }
+        nextObjOffset += executableInfoPtr->Size();
+        }
+	CleanupStack::PopAndDestroy(); //GetListLC
+    }
+
+/**
+Provides the caller with a list of currently running threads.
+@param aThreadList reference to the pointer list that is going to be filled
+with CThreadInfo objects. The caller takes ownership of the content.
+@param aPid Specify this to narrow the list of threads to a particular process.
+@see RThreadPointerList
+*/
+EXPORT_C void RCoreDumpSession::GetThreadsL( RThreadPointerList & aThreadList, const TUint64 aPid ) const
+	{
+    LOG_MSG("->RCoreDumpSession::GetThreadsL()\n");
+
+    aThreadList.ResetAndDestroy();
+
+	TListRequest request;
+	request.iListType = TListRequest::EThreadList;
+	request.iSubId1 = aPid;
+	request.iSubId2 = 0;
+	request.iRequiredDescriptorSize = 0;
+
+	const TUint8 * bufStart = GetListLC(request).Ptr();
+	TUint nextObjOffset = 0;
+
+	for(TInt i = 0 ; i < request.iRemaining; i++)
+		{
+        TPtrC8 nextObj( (bufStart + nextObjOffset), CThreadInfo::MaxSize() );
+        CThreadInfo * threadInfoPtr = CThreadInfo::NewL( nextObj ); 
+        TInt err = aThreadList.Append(threadInfoPtr);
+        if(err != KErrNone)
+            {
+            LOG_MSG2("RCoreDumpSession::GetThreads - unable to append thread info object! err:%d\n", err);
+            delete threadInfoPtr;
+            User::Leave(err);
+            }
+        nextObjOffset += threadInfoPtr->Size();
+        }
+
+	CleanupStack::PopAndDestroy(); //GetListLC
+    }
+
+/**
+@param aFormatterList Reference to the pointer list that is going to be filled
+with CPluginInfo objects. The caller takes ownership of the content.
+@see RPluginPointerList
+*/
+EXPORT_C void RCoreDumpSession::GetFormattersL( RPluginPointerList &aFormatterList ) const
+	{
+    LOG_MSG("->RCoreDumpSession::GetFormattersL()\n");
+
+    aFormatterList.ResetAndDestroy();
+
+	TListRequest request;
+	request.iListType = TListRequest::EFormatterList;
+	request.iSubId1 = 0;
+	request.iSubId2 = 0;
+	request.iRequiredDescriptorSize = 0;
+
+	const TUint8 * bufStart = GetListLC(request).Ptr();
+	TUint nextObjOffset = 0;
+	for(TInt i = 0 ; i < request.iRemaining; i++)
+		{
+        TPtrC8 nextObj( (bufStart + nextObjOffset), CPluginInfo::MaxSize() );
+        CPluginInfo * pluginInfoPtr = CPluginInfo::NewL( nextObj ); 
+
+        TInt err = aFormatterList.Append(pluginInfoPtr);
+        if(err != KErrNone)
+            {
+            LOG_MSG2("RCoreDumpSession::GetPluginsL - unable to append plugin info object! err:%d\n", err);
+            delete pluginInfoPtr;
+            User::Leave(err);
+            }
+        nextObjOffset += pluginInfoPtr->Size();
+        }
+	CleanupStack::PopAndDestroy(); //GetListLC
+    }
+
+/**
+ * Lists the crashes in the flash partition
+ * @param aCrashes Array in which to store the list of crashes
+ * @leave one of the OS wide codes
+ */
+EXPORT_C void RCoreDumpSession::ListCrashesInFlashL(RCrashInfoPointerList& aCrashes) const
+	{
+	LOG_MSG("->RCoreDumpSession::ListCrashesInFlash()\n");
+
+	aCrashes.ResetAndDestroy();
+
+	TListRequest request;
+	request.iListType = TListRequest::ECrashList;
+	request.iSubId1 = 0;
+	request.iSubId2 = 0;
+	request.iRequiredDescriptorSize = 0;
+
+	const TUint8 * bufStart = GetListLC(request).Ptr();
+	TUint nextObjOffset = 0;
+	for(TInt i = 0 ; i < request.iRemaining; i++)
+		{
+        TPtrC8 nextObj( (bufStart + nextObjOffset), TCrashInfo::MaxSize() );
+        TCrashInfo* crashInf = TCrashInfo::NewL( nextObj ); 
+
+        TInt err = aCrashes.Append(crashInf);
+        if(err != KErrNone)
+            {
+            LOG_MSG2("RCoreDumpSession::ListCrashesInFlash - unable to append plugin info object! err:%d\n", err);
+            delete crashInf;
+            User::Leave(err);
+            }
+        nextObjOffset += crashInf->iSize;
+        }
+	CleanupStack::PopAndDestroy(); //GetListLC
+	}
+
+/**
+ * Deletes crash log specified from the flash partition
+ * @param aCrashId Identifier of crash to delete
+ * @leave One of the OS wide codes
+ */
+EXPORT_C void RCoreDumpSession::DeleteCrashLogL(const TInt aCrashId) const
+	{
+    LOG_MSG2("->RCoreDumpSession::DeleteCrashLogL(ID = [%d])\n", aCrashId);
+    TIpcArgs args(aCrashId);
+
+    TInt err = SendReceive(ECoreDumpDeleteLogRequest, args);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("->RCoreDumpSession::DeleteCrashLogL() - unable to delete log -> err:%d\n", err);
+        User::Leave(err);
+        }
+	}
+
+/**
+ * Deletes crash partition from the flash partition
+ * @param aCrashId Identifier of crash to delete
+ * @leave One of the OS wide codes
+ */
+EXPORT_C void RCoreDumpSession::DeleteCrashPartitionL() const
+	{
+    LOG_MSG("->RCoreDumpSession::DeleteCrashPartitionL");
+
+    TInt err = SendReceive(ECoreDumpDeleteCrashPartitionRequest);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("->RCoreDumpSession::DeleteCrashPartitionL() - unable to delete log -> err:%d\n", err);
+        User::Leave(err);
+        }
+	}
+
+/**
+ * Processes the crash log in the flash partition corrosponding to the crash ID of this 
+ * TCrashInfo object. If this doesnt match a crash in the partition, or the flash cannot be read
+ * this will leave with KErrCorrupted
+ * @param aCrash The crash to be processed
+ * @leave One of the OS wide codes
+ */
+EXPORT_C void RCoreDumpSession::ProcessCrashLogL(TInt aCrashId)
+	{
+	LOG_MSG2("->RCoreDumpSession::ProcessCrashLogL(ID = [%d])\n", aCrashId);
+	
+/*    TPckgBuf<TCrashInfo> requestPckg(aCrashInfo);
+    TIpcArgs args(&requestPckg);*/
+	TIpcArgs args(aCrashId);
+
+    TInt err = SendReceive(ECoreDumpProcessFlashCrash, args);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("->RCoreDumpSession::ProcessCrashLogL() - unable to process crash log -> err:%d\n", err);
+        User::Leave(err);
+        }
+	}
+
+/**
+ * Processes the crash log Asynchronously in the flash partition corresponding to the crash ID of this 
+ * TCrashInfo object.
+ * @param aCrashId The crash to be processed
+ * @param aStatus asynchronous request status object 
+ */
+EXPORT_C void RCoreDumpSession::ProcessCrashLog(const TInt aCrashId, TRequestStatus &aStatus)
+	{
+	LOG_MSG2("->RCoreDumpSession::ProcessCrashLog async (ID = [%d])\n", aCrashId);
+	
+	TIpcArgs args(aCrashId);
+    SendReceive(ECoreDumpProcessCrashAsync, args, aStatus);
+
+	}
+
+/**
+ * Cancel a previously issued asynchronous RCoreDumpSession::ProcessCrashLog call 
+ * @param aCrash The crash to be processed
+ * @return Any error which may be returned by RSessionBase::SendReceive()
+ */
+EXPORT_C TInt RCoreDumpSession::CancelProcessCrashLog(TInt aCrashId)
+	{
+	LOG_MSG2("->RCoreDumpSession::CancelProcessCrashLog async (ID = [%d])\n", aCrashId);
+	
+	TIpcArgs args(aCrashId);
+    return SendReceive(ECoreDumpCancelProcessCrashAsync, args);
+
+	}
+
+
+/**
+@param aFormatterList Reference to the pointer list that is going to be filled
+with CPluginInfo objects. The caller takes ownership of the content.
+@see RPluginPointerList
+*/
+EXPORT_C void RCoreDumpSession::GetWritersL( RPluginPointerList &aWriterList ) const
+	{
+    LOG_MSG("->RCoreDumpSession::GetWritersL()\n");
+
+    aWriterList.ResetAndDestroy();
+
+	TListRequest request;
+	request.iListType = TListRequest::EWriterList;
+	request.iSubId1 = 0;
+	request.iSubId2 = 0;
+	request.iRequiredDescriptorSize = 0;
+
+	const TUint8 * bufStart = GetListLC(request).Ptr();
+	TUint nextObjOffset = 0;
+	for(TInt i = 0 ; i < request.iRemaining; i++)
+		{
+        TPtrC8 nextObj( (bufStart + nextObjOffset), CPluginInfo::MaxSize() );
+        CPluginInfo * pluginInfoPtr = CPluginInfo::NewL( nextObj ); 
+
+        TInt err = aWriterList.Append(pluginInfoPtr);
+        if(err != KErrNone)
+            {
+            LOG_MSG2("RCoreDumpSession::GetPluginsL - unable to append plugin info object! err:%d\n", err);
+            delete pluginInfoPtr;
+            User::Leave(err);
+            }
+        nextObjOffset += pluginInfoPtr->Size();
+        }
+	CleanupStack::PopAndDestroy(); //GetListLC
+    }
+
+/**
+    Called by GetProcessesL and GetThreadsL methods to get list information from the CoreDumpServer.
+@param aRequest structure defining list request
+@return descriptor holding serialized list content or null descriptor if unable to get any data.
+*/
+const TDesC8 &RCoreDumpSession::GetListLC(const TListRequest &aRequest) const
+    {
+    LOG_MSG2("->RCoreDumpSession::GetListLC(iType=%d)\n", aRequest.iListType);
+	TPckg<TListRequest> requestPckgPtr( aRequest );
+	TIpcArgs reqArgs( &requestPckgPtr );
+
+	TInt err = SendReceive( ECoreDumpGetListInfo, reqArgs );
+
+    if(err != KErrNone)
+		{
+		LOG_MSG2( "RCoreDumpSession::GetListL() - unable to get list info! err:%d\n", err );
+		User::Leave(err);
+	    }
+
+	HBufC8 *buf = HBufC8::NewMaxL( aRequest.iRequiredDescriptorSize );
+	CleanupStack::PushL( buf );
+
+	if( ( aRequest.iRemaining == 0) || ( aRequest.iRequiredDescriptorSize == 0 ) )
+		{
+		LOG_MSG("RCoreDumpSession::GetListL() - no data to transfer\n");
+		return *buf;
+        }
+
+    TPtr8 ptr(buf->Des());
+	TIpcArgs listArgs( &requestPckgPtr, &ptr );
+	err = SendReceive( ECoreDumpGetListData, listArgs );
+
+	if(err != KErrNone) 
+		{
+		LOG_MSG2("RCoreDumpSession::GetListL() - unable to get list data! err:%d\n", err);
+		User::Leave(err);
+		}
+
+    return *buf;
+    }
+
+/**
+    Provides the caller with a list of currently available formatter and 
+	writer plugins.
+@param aPluginList reference to list to be filled with TPluginInfo structs.
+    The caller takes ownership of the content.
+@see RPluginList
+*/
+EXPORT_C void RCoreDumpSession::GetPluginListL(RPluginList &aPluginList) const
+    {
+    LOG_MSG("RCoreDumpSession::GetPluginListL()\n");
+    aPluginList.Reset();
+
+    TPluginInfoBlock *pluginArr = new(ELeave) TPluginInfoBlock;
+    CleanupStack::PushL(pluginArr);
+	TPtr8 pluginArrPtr( (TUint8*)pluginArr, sizeof(TPluginInfoBlock) );
+
+	TListRequest request;
+	request.iIndex = 0; //the one that really matters on the server side
+    do
+        {
+        TPckgBuf<TListRequest> requestPckg(request);
+        TIpcArgs reqArgs( &requestPckg , &pluginArrPtr );
+        TInt err = SendReceive( ECoreDumpServGetPluginList, reqArgs );
+        
+        if(err != KErrNone)
+            {
+            LOG_MSG2("RCoreDumpSession::GetPluginListL - unable to get plugin list! err:%d\n", err);
+            User::Leave(err);
+            }
+
+        request = requestPckg();
+		if(request.iIndex == 0)
+			{
+			LOG_MSG3("RCoreDumpSession::GetPluginListL - first call got:%d from %d\n",
+                    request.iSupplied, request.iSupplied + request.iRemaining);
+			request.iIndex = request.iSupplied;
+			}
+		else
+			{
+			LOG_MSG3("RCoreDumpSession::GetPluginListL - following call got:%d from %d\n",
+                    request.iSupplied, request.iSupplied + request.iRemaining);
+			request.iIndex += request.iSupplied;
+			}
+
+		for(TInt i = 0; i < request.iSupplied; i++)
+			{
+	            TPluginInfo pluginData;
+				pluginData.iVersion		= pluginArr->plugins[i].iVersion;
+				pluginData.iName		= pluginArr->plugins[i].iName;
+				pluginData.iUid			= pluginArr->plugins[i].iUid;
+				pluginData.iType		= pluginArr->plugins[i].iType;
+				pluginData.iDescription = pluginArr->plugins[i].iDescription;
+				pluginData.iLoaded		= pluginArr->plugins[i].iLoaded;
+				aPluginList.AppendL( pluginData );
+			}
+        }
+    while(request.iRemaining > 0);
+    CleanupStack::PopAndDestroy(pluginArr);
+    }
+
+/**
+Make a request to load/unload a plugin.
+@param aPluginRequest Structure defining the plugin request
+@see TPluginRequest
+*/
+EXPORT_C void RCoreDumpSession::PluginRequestL(const TPluginRequest &aPluginRequest ) const
+{
+    LOG_MSG("->RCoreDumpSession::PluginRequestL()\n");
+
+	TPckgBuf<TPluginRequest> requestPckg(aPluginRequest);
+	TIpcArgs reqArgs( &requestPckg );
+
+	LOG_MSG4("RCoreDumpSession::PluginRequestL(): iPluginType=%d, iIndex=%d, iUid=0x%X\n", 
+            aPluginRequest.iPluginType, aPluginRequest.iIndex, aPluginRequest.iUid ); 
+
+	TInt err = SendReceive( ECoreDumpPluginRequest, reqArgs );
+    if(err != KErrNone)
+        {
+        LOG_MSG2("->RCoreDumpSession::PluginRequestL() - unable to load plugin! err:%d\n", err);
+        User::Leave(err);
+        }
+}
+
+/**
+Request the observation of a thread or process. To observe a process, aTargetName and 
+aTargetOwnerName must be the same and be the name of the process.
+To observe a thread, aTargetOwnerName is the name of the process and aTargetName is the name
+To observe an executable, aTargetOwnerName is the full path to the exe and aTargetName is also the full path to the exe
+of the thread. 
+@param aTargetName Name of process or thread
+@param aTargetOwnerName Name of process 
+@param aObserve Set to ETrue to request the observation of the target. EFalse to stop observing the target.
+@see GetProcessesL
+@see GetThreadsL
+*/
+EXPORT_C void RCoreDumpSession::ObservationRequestL(const TDesC &aTargetName, const TDesC &aTargetOwnerName, TBool aObserve) const
+{
+    LOG_MSG("->RCoreDumpSession::ObservationRequestL()\n");
+    TIpcArgs args(&aTargetName, &aTargetOwnerName, static_cast<TInt>(aObserve));
+
+    TInt err = SendReceive(ECoreDumpObservationRequest, args);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("->RCoreDumpSession::ObservationRequestL() - unable to [un]observe target! err:%d\n", err);
+        User::Leave(err);
+        }
+}
+
+
+/**
+Return the total list of configuration parameters currently available. 
+The list is made up of the parameters from the Core Dump Server and any loaded plugins.
+@see COptionConfig
+*/
+EXPORT_C TInt RCoreDumpSession::GetNumberConfigParametersL() const
+	{
+	LOG_MSG("->RCoreDumpSession::GetNumberConfigParameters()\n" );
+    TInt numParams;
+	TPtr8 numParamPtr( (TUint8*) &numParams, sizeof(TInt) );
+
+	TPtr8 maxConfigParamSizePtr( (TUint8*) &iMaxConfigParamSize, sizeof(TInt) );
+	TIpcArgs reqArgs( &numParamPtr, &maxConfigParamSizePtr );
+
+	TInt err = SendReceive( ECoreDumpGetNumberConfigParams, reqArgs );
+
+    if(err != KErrNone)
+        {
+	    LOG_MSG2( "RCoreDumpSession::GetNumberConfigParams() - unable to get params number! err:%d \n", err);
+        User::Leave(err); 
+        }
+
+	return numParams;
+	}
+										
+
+/**
+Obtain the configuration parameter indexed by aIndex. 
+@param aIndex This must be less than the value returned by GetNumberConfigParametersL().
+@see COptionConfig
+*/
+EXPORT_C COptionConfig * RCoreDumpSession::GetConfigParameterL( const TInt aIndex ) const
+	{
+	LOG_MSG("->RCoreDumpSession::GetConfigParameterL()\n" );
+	
+	// Allocate the max, rounded up, plus 4 bytes for safety
+	HBufC8 *buf = HBufC8::NewMaxL( Align4(iMaxConfigParamSize) );
+    CleanupStack::PushL(buf);
+    TPtr8 ptr( buf->Des() );
+	ptr.FillZ();
+
+	TIpcArgs configArgs( aIndex, &ptr );
+
+	TInt err = SendReceive( ECoreDumpGetConfigParam, configArgs );
+
+	if(err != KErrNone) 
+		{
+		LOG_MSG3("RCoreDumpSession::GetConfigParameter() - unable to get parameter:%d! err:%d\n", aIndex, err );
+        User::Leave(err);
+		}
+
+    COptionConfig *option = COptionConfig::NewL(*buf);
+    CleanupStack::PopAndDestroy(buf);
+    return option;
+	}
+
+
+/**
+Change a configuration parameter. 
+@param aConfig The modified parameter that will be changed. The index and source are 
+checked against those held by the server.
+*/
+EXPORT_C void RCoreDumpSession::SetConfigParameterL( const COptionConfig &aConfig) const
+	{
+	LOG_MSG4("->RCoreDumpSession::SetConfigParameterL( aSource=%d, aIndex=%d, aInstance=%d)\n",
+             aConfig.Source(), aConfig.Index(), aConfig.Index() );
+
+    TConfigRequest request;
+    request.iSource = aConfig.Source();
+    request.iIndex = aConfig.Index();
+    request.iInstance = aConfig.Instance();
+
+	TPckg<TConfigRequest> requestPckgPtr( request );
+
+	TIpcArgs configArgs( &requestPckgPtr, aConfig.Value(), &aConfig.ValueAsDesc() );
+	TInt err = SendReceive( ECoreDumpSetConfigParam, configArgs );
+
+    if(err != KErrNone)
+        {
+	    LOG_MSG3("RCoreDumpSession::SetConfigParameterL() - unable to set parameter:%d! err:%d\n", aConfig.Index(), err );
+        User::Leave(err);
+        }
+	}
+
+
+/**
+Restore a configuration. Configuration files are created by the Core dump server
+when it exits and when the call SaveConfigL is made. The format is private and should be
+considered binary. When the Core dump server exits it stores the current configuration 
+in its private directory with the name coredumpserver.ini.
+@param aLoadPath File that will be read and restored
+*/
+EXPORT_C void RCoreDumpSession::LoadConfigL( const TDesC & aLoadPath ) const
+    {
+	LOG_MSG("->RCoreDumpSession::LoadConfig()\n" );
+
+	TIpcArgs configArgs( &aLoadPath );
+	TInt err = SendReceive( ECoreDumpLoadConfig, configArgs );
+    if(err != KErrNone)
+        {
+	    LOG_MSG2("RCoreDumpSession::LoadConfigL() - unable to load config! err:%d\n", err );
+        User::Leave(err);
+        }
+    }
+
+
+/**
+Save the current configuration to file. 
+@param aSavePath File that will be saved
+*/
+EXPORT_C void RCoreDumpSession::SaveConfigL( const TDesC & aSavePath ) const
+    {
+	LOG_MSG("->RCoreDumpSession::SaveConfig()\n" );
+	TIpcArgs configArgs( &aSavePath );
+
+	TInt err = SendReceive( ECoreDumpSaveConfig, configArgs );
+    if(err != KErrNone)
+        {
+	    LOG_MSG2("RCoreDumpSession::SaveConfigL() - unable to save config! err:%d\n", err );
+        User::Leave(err);
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/config/src/coredumpinterface.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,35 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET        coredumpinterface.dll
+TARGETTYPE    dll
+UID           0x1000008d 0x102836b4
+
+SYSTEMINCLUDE	\epoc32\include
+SYSTEMINCLUDE	\epoc32\include\drivers
+SYSTEMINCLUDE	\epoc32\include\tools\coredump
+
+SOURCEPATH	.
+SOURCE		coredumpinterface.cpp
+
+
+LIBRARY       euser.lib
+LIBRARY       estor.lib
+LIBRARY       cdssupport.lib
+
+
+
+CAPABILITY ALL -TCB
+//MACRO CDSDEBUG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/config/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/config/src/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,5 @@
+Directory for:
+  coredump\server\session
+
+All the source, including subdirectories, to implement Core Dump server Config UI sessions.
+A session interfaces to the UI client and carries out requests.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/group/all.mbc	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,66 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+// Description:
+// Meta Build (metabld) script for the CDS
+//Followng targets built:
+// - udeb
+// - urel
+// - armv5
+
+
+SECTION_COMMANDS
+bldmake bldfiles
+abld -k export
+abld -k makefile armv5
+abld -k library armv5
+abld -k target armv5
+abld -k test export
+abld -k test makefile armv5
+abld -k test library armv5
+abld -k test target armv5
+abld -k makefile winscw
+abld -k library winscw
+abld -k target winscw
+abld -k test makefile winscw
+abld -k test library winscw
+abld -k test target winscw
+
+SECTION_DIRS
+
+//Production code
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\plugins\formatters\dexc\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\plugins\formatters\dexc\test
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\plugins\formatters\symbianelf\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\plugins\formatters\utrace\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\plugins\writers\file\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\plugins\writers\file\test
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\ui\coredumpui\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\ui\scriptconfig
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\ui\text
+
+// test code
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\automatictests\tcds_kernel\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\automatictests\tcds_kernel\testtoken
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\automatictests\tcds_unit\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\automatictests\tcds_app\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\crashapps\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\elfdump
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\flashdump\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\oeelfdump
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\oemtoken
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\plugins\testplugin\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\rundump\group
+\dp_team_sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\testclient
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,58 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+//coredumpserver.iby has Core Dump Server itself and coredumpinterface.iby and cdssupport.iby
+..\server\src\coredumpserver.iby				\epoc32\rom\include\coredumpserver.iby
+..\server\src\coredumpserverstub.iby			\epoc32\rom\include\coredumpserverstub.iby
+
+..\interface\common\crashdata.h					tools\coredump\crashdata.h
+..\interface\common\debuglogging.h				tools\coredump\debuglogging.h
+..\interface\common\executabledata.h			tools\coredump\executabledata.h
+..\interface\common\plugindata.h				tools\coredump\plugindata.h
+..\interface\common\processdata.h				tools\coredump\processdata.h
+..\interface\common\streamelement.h				tools\coredump\streamelement.h
+..\interface\common\threaddata.h				tools\coredump\threaddata.h
+..\interface\config\optionconfig.h				tools\coredump\optionconfig.h
+..\interface\datasave\crashdatasave.h			tools\coredump\crashdatasave.h
+..\interface\datasave\crashdatasave.inl			tools\coredump\crashdatasave.inl
+..\interface\datasource\crashdatasource.h		tools\coredump\crashdatasource.h
+..\interface\formatter\formatterapi.h			tools\coredump\formatterapi.h
+..\interface\formatter\formatterapi.inl			tools\coredump\formatterapi.inl
+..\interface\server\coredumpinterface.h			tools\coredump\coredumpinterface.h
+..\interface\server\coredumpserverapi.h			tools\coredump\coredumpserverapi.h
+
+
+
+// Default allowed plugins
+..\server\plugins\pluginList1.plugin   \epoc32\data\Z\private\10282FE5\pluginList1.plugin
+
+// Stub SIS file for installing core dump server and plugins after rom build
+..\server\plugins\coredumpserverstub.SIS   \epoc32\data\Z\system\install\coredumpserverstub.SIS
+
+PRJ_TESTEXPORTS
+t_core_dump_all.iby						\epoc32\rom\include\t_core_dump_all.iby
+
+
+PRJ_MMPFILES
+..\cdssupport\group\cdssupport.mmp
+..\config\src\coredumpinterface.mmp
+#if defined(MARM_ARMV5) || defined(MARM_ARMV4)
+..\server\src\coredumpserver.mmp
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/group/coredumpserver.mrp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	dev_devicedbgsrvs_dbgsrv_coredumpserver
+
+source	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver
+
+# Core Dump Server
+binary	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/group armv5
+exports	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/group
+
+# User interfaces
+binary	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/ui/coredumpui/group armv5
+binary	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/ui/scriptconfig armv5
+exports	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/ui/coredumpui/group
+exports	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/ui/scriptconfig
+
+# Plugins
+binary	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/plugins/formatters/dexc/group armv5
+binary	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/plugins/formatters/symbianelf/group armv5
+binary	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/plugins/formatters/utrace/group armv5
+binary	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/plugins/writers/file/group armv5
+binary	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/plugins/formatters/symbianelf/group winscw
+exports	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/plugins/formatters/dexc/group
+exports	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/plugins/formatters/symbianelf/group
+exports	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/plugins/formatters/utrace/group
+exports	/src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/plugins/writers/file/group
+
+notes_source	/component_defs/release.src
+#touch to force CBR re-release
+
+ipr E 
+ipr T /src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/test
+ipr T /src/tools/dev/devicedbgsrvs/dbgsrv/coredumpserver/ui
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/group/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,4 @@
+Directory for:
+  coredump\group
+
+Used for build files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/group/t_core_dump_all.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#ifndef _T_CORE_DUMP_ALL_IBY_
+#define _T_CORE_DUMP_ALL_IBY_
+
+#include "coredumpui.iby"
+#include "coredumpserver.iby"
+#include "textcrashconfig.iby"
+#include "dexcformatter.iby"
+#include "symbianelfformatter.iby"
+#include "filewriter.iby"
+#include "crashapp.iby"
+#include "coredumpscriptconfig.iby"
+#include "tdexcformatter.iby"
+#include "tsymbianelfformatter.iby"
+#include "coredumptestplugin.iby"
+#include "oeelfdump.iby"
+#include "utraceformatter.iby"
+#include "flashdump.iby"
+#include "crashdriver.iby"
+
+#endif //_T_CORE_DUMP_ALL_IBY_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/common/crashdata.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,389 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Common Crash Data definitions used between the core dump server, 
+// formatters and user interfaces
+//
+
+
+
+/**
+ @file
+ @publishedPartner 
+ @released
+ @see CCrashDataSource
+ @see RCoreDumpSession
+*/
+
+#ifndef CRASH_DATA_H
+#define CRASH_DATA_H
+
+#include <e32std.h>
+#include <e32const.h>
+#include <rm_debug_api.h>
+#include <s32strm.h>
+#include <scmdatatypes.h>
+
+using namespace Debug;
+
+/**
+Crash event information. This is given to a formatter when a crash occurs.
+@see CCoreDumpFormatter::CrashEventL()
+*/
+class TCrashInfo
+{
+
+	public:
+		/** 
+		 * Constructs object from stream
+		 */
+		IMPORT_C static TCrashInfo* TCrashInfo::NewL(const TDesC8 & aStreamData);
+			
+		/**
+		 * Constructs from structure
+		 */
+		IMPORT_C static TCrashInfo* TCrashInfo::NewL(const TCrashInfoHeader& aCrashHeader);
+		
+		/**
+		 * Initializes ’this’ from stream
+		 */
+		IMPORT_C void InternalizeL(RReadStream & aStream);
+	
+		IMPORT_C TCrashInfo();
+		
+		IMPORT_C void ExternalizeL(RWriteStream & aStream, CBufFlat* buf);
+		
+		IMPORT_C static TInt MaxSize();
+	
+	private:		
+		
+		TCrashInfo(const TCrashInfoHeader& aCrashHeader);
+		void ConstructL(const TCrashInfoHeader& aCrashHeader);			
+	
+	public:
+	
+	/** 
+	Type of crash event
+	*/
+	enum TCrashType 
+		{ 
+		/** ECrashException is raised when a hardware exception occurs */
+		ECrashException, 
+	
+		/** ECrashKill is raised when a thread is killed or panicked */
+		ECrashKill,
+	
+	    /** 
+		@internalTechnology
+		Guard
+		*/
+	    ECrashLast
+		};
+	
+	/**
+	 * Tells us where the crash event came from. ie is it a system crash or a live crash
+	 */
+	enum TCrashSource
+		{
+		ESystemCrash,		    //!< System Crash - Data in flash
+		ELiveCrash,			//!< Live System - Data to be got from DSS
+		
+	    /** 
+		@internalTechnology
+		Guard
+		*/
+		ELast       //!< ELast
+		};	
+    /** Type of crash
+	@see  TCrashType 
+	*/
+	TCrashType		iType; 
+
+	/** Exception type or exit type. 
+	If crash type iType is ECrashException, this is set to e32const.h::TExcType 
+	If crash type iType is ECrashKill, this is set to e32const.h::TExitType.
+	*/
+    TUint32			iExcNumber;
+
+	/** This is only set when iType is ECrashKill. Kernel panic code. */
+	TInt			iReason; 
+
+	/** Crash category description. Valid when crash type is ECrashKill */
+    TBuf<KMaxExitCategoryName> iCategory; 
+
+	/** Crashed thread id */
+	TUint64			iTid;
+
+	/** Crashed process id */
+	TUint64			iPid;
+
+	/** Crash time */
+    TUint64			iTime; 
+
+	/** Register context at time of crash. 
+	@see TRmdArmExcInfo
+	@see Debug::TRmdArmExcInfo
+	*/
+    TRmdArmExcInfo  iContext;
+
+    /** Id for crash in flash - only relevant for system crash */
+    TUint32 iCrashId;
+    
+	/** Externalized size */
+	TUint iSize;
+    
+	/** Source of crash
+	 *	@see TCrashSource
+	 */
+	TCrashSource iCrashSource;
+		
+};
+
+/**
+Pointer array of TCodeSegInfo objects.
+@see TCrashInfo
+*/
+typedef RPointerArray<TCrashInfo> RCrashInfoPointerList;
+
+/**
+Code segment information. 
+@see CServerCrashDataSource::GetCodeSegmentsL()
+*/
+struct TCodeSegInfo
+{
+
+	/**
+	Name of code segment. 
+	*/
+    TBufC<KMaxPath> iName;
+
+	/**
+	Set to trie to indicates that this executable is executing in place.
+	*/
+    TBool		iXIP;
+
+
+	/**
+	Type of the code segment. 
+	@see Debug::TCodeSegType
+	@see TCodeSegType
+	*/
+    TCodeSegType iType;
+
+	/**	Code size in bytes	*/
+    TUint32		iCodeSize;
+
+	/**	Code segment run address. If code segment is XIP then 
+	this is the same as iCodeLoadAddr */
+    TLinAddr	iCodeRunAddr;
+
+	/**	Address where code segement was loaded from */
+    TLinAddr	iCodeLoadAddr;
+
+	/**	Size on bytes of the read only data */
+    TUint32		iRoDataSize;
+
+	/**	Address of read only data at run time. If code segment is XIP then 
+	this is the same as iRoDataLoadAddr */
+    TLinAddr	iRoDataRunAddr;
+
+	/**	Address where read only data was loaded from */
+    TLinAddr	iRoDataLoadAddr;
+
+	/** Writable data size in bytes. Combined .bss and .data sections  */
+    TUint32		iDataSize;
+
+	/** Address of writable data at run time */
+    TLinAddr	iDataRunAddr;
+
+	/** Build time address of initialised writable data */
+    TLinAddr	iDataLoadAddr;
+
+    /** reserved for future 
+	@internalTechnology */
+    TUint32 iSpare1;
+	/** @internalTechnology */
+    TUint32 iSpare2;
+	/** @internalTechnology */
+    TUint32 iSpare3;
+};
+
+/**
+Pointer array of TCodeSegInfo objects.
+@see TCodeSegInfo
+*/
+typedef RPointerArray<TCodeSegInfo> RCodeSegPointerList;
+
+
+/**
+Detailed information about a register. 
+The Symbian ELF format defines the register identification format.
+The Debug Security Server implements this format.
+@see CCrashDataSource::ReadRegistersL()
+*/
+class TRegisterData
+{
+
+public: 
+
+	IMPORT_C    TUint16		GetId()   const;
+	IMPORT_C    TUint16		GetSubId() const;
+	IMPORT_C    TUint8		GetSize() const;
+	IMPORT_C    TUint8		GetClass() const;
+	IMPORT_C    TBool		SameRegister( const TRegisterData & other ) const;
+	
+	IMPORT_C    TUint8		GetContent8()  const;
+	IMPORT_C    TUint16		GetContent16() const;
+	IMPORT_C    TUint32		GetContent32() const;
+	IMPORT_C    TUint64		GetContent64() const;
+
+	IMPORT_C    void		SetContent8(  const TUint8 aVal );
+	IMPORT_C    void		SetContent16( const TUint16 aVal );
+	IMPORT_C    void		SetContent32( const TUint32 aVal );
+	IMPORT_C    void		SetContent64( const TUint64 aVal );
+	IMPORT_C    void		SetContent( const TUint aVal );
+
+	IMPORT_C    void		SetContent( const TRegisterData & other );
+
+	IMPORT_C    TBool		Available( ) const;
+	IMPORT_C    void		SetAvailable( const TBool aAvailable );
+
+
+	/**
+	This is the same as symbianelfdefs.h ESYM_REGREP. 
+	@see ESYM_REGREP
+	*/
+	typedef enum TRegisterRepresentation
+		{
+		/** 8 Bit register */
+		ERegRepr8	= 0,	
+		/** 16 Bit register */
+		ERegRepr16	= 1,
+		/** 32 Bit register */
+		ERegRepr32	= 2,
+		/** 64 Bit register */
+		ERegRepr64	= 3,
+		/** 
+		@internalTechnology
+		*/
+		ERegReprLast
+		};
+    
+	/**
+	This is the same as symbianelfdefs.h ESYM_REGCLASS. 
+	@see ESYM_REGCLASS
+	*/
+	typedef enum TRegisterClass
+		{
+		/** A Core register */
+		ERegClassCore	= 0,	
+		/** A Co Processor register */
+		ERegClassCoPro	= 1, 
+		/** 
+		@internalTechnology
+		*/
+		ERegClassLast
+		};
+
+
+	/**
+	Register identifier
+	*/
+	union 
+        {
+	    /** Used when calling the Debug Security Server */
+        TRegisterInfo regInfo;
+
+        /** Same as Sym32_reginfod::rd_id
+	    if rid_class == ESYM_REG_CORE 
+	      rd_id is one of rm_debug_api.h::TFunctionalityRegister
+	    else 
+	      rd_id is CoProcessor number, eg 15 for ARM CP15 
+
+		@see Sym32_reginfod::rd_id
+		*/
+		TUint16		iId;
+        };
+
+	/** Same as Sym32_reginfod::rid_class
+		Type of register ESYM_REG_CLASS :{ ESYM_REG_CORE = 0, ESYM_REG_COPRO = 1 } 
+	@see Sym32_reginfod::rid_class
+	*/
+	TUint8		iRegClass;
+
+	/** Same as Sym32_reginfod::rd_sub_id		
+		Only used if rid_clas == ESYM_REG_COPRO
+
+  	   Bitfield is made up of the following fields:
+         bits 13 to 11  : OpCode2
+         bits 10 to 8   : OpCode1
+         bits 7  to 4   : CRn
+         bits 3  to 0   : CRm 
+
+	@see Sym32_reginfod::rd_sub_id		
+	*/
+	TUint16		iSubId;
+
+	/** Same as Sym32_reginfod::rd_repre
+		{ ESYM_REG_8 == 0, ESYM_REG_16 == 1, ESYM_REG_32 == 2, ESYM_REG_64 == 3 }
+		Determines which version of GetContent*() to use 
+	@see Sym32_reginfod::rd_repre
+	*/
+	TUint8		iSize;
+
+
+	/** True if the content of this register was succesfully obtained from 
+	the target */
+	TBool       iAvailable;
+
+	/** Register value */
+	union
+	{
+		/** Value of an 8 bit register */
+		TUint8		iValue8;
+
+		/** Value of a 16 bit register */
+		TUint16		iValue16;
+
+		/** Value of a 32 bit register */
+		TUint32		iValue32;
+
+		/** Value of a 64 bit register */
+		TUint64		iValue64;
+	};
+
+	/** Reserved for future use
+	@internalTechnology */
+	TUint32 iSpare1;
+
+	/** @internalTechnology */
+	TUint32 iSpare2;
+
+	/** @internalTechnology */
+	TUint32 iSpare3;
+};
+
+
+/**
+@publishedPartner 
+@released
+
+List of TRegisterData objects.
+@see TRegisterData
+@see RArray
+*/
+typedef RArray<TRegisterData> RRegisterList;
+
+#endif // CRASH_DATA_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/common/debuglogging.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,56 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Logging macros for use in debug subsystem
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef DEBUG_LOGGING_H
+#define DEBUG_LOGGING_H
+
+/*
+ * Debug messages are only generated for debug builds.
+ */
+
+#ifdef CDSDEBUG
+
+    #include <e32debug.h>
+    #define LOG_DES(des) {if(des.Length() > 0) {RBuf buf; buf.CreateL(des); char *ptr = (char*)buf.Collapse().PtrZ(); LOG_MSG2("\n(%s)\n", ptr); buf.Close();} }
+
+    #define LOG_MSG( a )				RDebug::Printf( a )
+    #define LOG_MSG2( a, b )			RDebug::Printf( a, b )
+    #define LOG_MSG3( a, b, c )			RDebug::Printf( a, b, c )
+    #define LOG_MSG4( a, b, c, d )		RDebug::Printf( a, b, c, d )
+    #define LOG_MSG5( a, b, c, d, e )	RDebug::Printf( a, b, c, d, e )
+	#define LOG_ENTRY()					RDebug::Printf("Entering [%s] ", __PRETTY_FUNCTION__);
+	#define LOG_EXIT()					RDebug::Printf("Exiting [%s] ", __PRETTY_FUNCTION__);
+
+#else
+
+    #define LOG_DES(des)
+    #define LOG_MSG( a )
+    #define LOG_MSG2( a, b )
+    #define LOG_MSG3( a, b, c )
+    #define LOG_MSG4( a, b, c, d )
+    #define LOG_MSG5( a, b, c, d, e )
+	#define LOG_ENTRY()
+	#define LOG_EXIT()
+
+#endif
+
+#endif //DEBUG_LOGGING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/common/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/common/executabledata.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,125 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Defines target-executable classes used across the Core Dump client/server interface 
+//
+
+
+
+/**
+ @file
+ @publishedPartner 
+ @released
+*/
+
+#ifndef EXECUTABLEDATA_H
+#define EXECUTABLEDATA_H
+
+#include <streamelement.h>
+
+
+/**
+@publishedPartner 
+@released
+
+Class that represents a target executable file from which a process can launched. 
+It is based on CStreamElementBase so it can be streamed between client and server.
+@see CServerCrashDataSource::GetExecutableListL
+*/
+class CExecutableInfo : public CStreamElementBase
+{
+
+public:
+
+	IMPORT_C static CExecutableInfo* NewL( const TDesC		& aName,
+										   const TBool  	  aActivelyDebugged,
+										   const TBool  	  aPassivelyDebugged );
+
+	IMPORT_C static CExecutableInfo* NewL( const TDesC8 & aStreamData );
+
+	IMPORT_C ~CExecutableInfo();
+
+public:
+	// Methods specific to CExecutableInfo
+
+	IMPORT_C void NameL( const TDesC & aName );
+	IMPORT_C const TDesC & Name() const;
+
+	IMPORT_C TBool ActivelyDebugged( ) const;
+	IMPORT_C void  ActivelyDebugged( TBool aActivelyDebugged );
+
+	IMPORT_C TBool PassivelyDebugged( ) const;
+	IMPORT_C void PassivelyDebugged( TBool aPassivelyDebugged );
+
+	IMPORT_C TBool Observed( ) const;
+	IMPORT_C void  Observed( TBool aFlag );
+
+
+public:
+	// Methods required by streaming interface 
+
+	IMPORT_C TInt static MaxSize();
+
+	IMPORT_C TInt Size() const;
+
+	// Initializes ’this’ from stream
+	IMPORT_C void InternalizeL( RReadStream & aStream );
+
+	// Writes ’this’ to the stream
+	IMPORT_C void ExternalizeL( RWriteStream & aStream, CBufFlat* buf );
+
+
+private:
+
+	CExecutableInfo( const TBool aActivelyDebugged,
+					 const TBool aPassivelyDebugged );
+
+	CExecutableInfo();
+
+	void ConstructL( const TDesC & aName );
+
+private:
+
+	/** Symbian kernel executable name */
+	HBufC  *			iName;
+
+    /** Actively debugged by client of Debug Security Server */
+	TBool				iActivelyDebugged;
+
+    /** Passively debugged by client of Debug Security Server */
+	TBool				iPassivelyDebugged;
+
+    /** Observed by core dump server */
+	TBool				iObserved;
+
+	/** Externalized size */
+	TUint				iSize;
+
+	// These are not internalised/externalised since they are spare
+	TUint32				iSpare1;
+	TUint32				iSpare2;
+	TUint32				iSpare3;
+	};
+
+
+/**
+@publishedPartner 
+@released
+
+List of CExecutableInfo object pointers
+@see CExecutableInfo
+@see RPointerArray
+*/
+typedef RPointerArray<CExecutableInfo>	RExecutablePointerList;
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/common/plugindata.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,242 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Defines ECOM-plugin related classes used accross the Core Dump client/server interface 
+//
+
+
+
+/**
+ @file
+ @publishedPartner 
+ @released
+*/
+
+#ifndef PLUGINDATA_H
+#define PLUGINDATA_H
+
+/**
+@publishedPartner 
+@released
+
+Class used between Core Dump Server and its clients to request 
+the server to carry out actions on plugins, such as load/unload.
+@see CCrashConfig::LoadPlugin()
+*/
+class TPluginRequest
+{
+public:
+
+	
+	inline TPluginRequest(){ iIndex = 0; }
+	
+	/** 
+	Type of plugin to request
+	*/
+	enum TPluginType
+		{
+		/** A formatter plugin */
+		EFormatter,
+		/** A writer plugin */
+		EWriter
+		};
+
+
+	/* Whether to load or unload the plugin */
+	TBool						iLoad; 
+
+	/** Type of plugin */
+	TPluginType					iPluginType;
+
+    /** Index of the plugin that requires action */
+	TUint						iIndex;
+
+	/** Plugin UID, used to check correct plugin */
+	TUid						iUid;
+
+    /** Index of the pair plugin */
+	TUint                       iPair;
+
+	/** @internalTechnology */
+	TUint32 iSpare2;
+};
+
+
+/** Maximum length allowed for a plugin's name */
+#define KPluginNameLength (50)
+
+/** Maximum length allowed for a plugin's description */
+#define KPluginDescriptionLength (250)
+
+/**
+@publishedPartner 
+@released
+
+Detailed information about a plugin.
+@see RPluginList
+@see TPluginInfoBlock
+*/
+class TPluginInfo
+{
+public:
+
+	/** Plugin's own version.
+	From rss file::IMPLEMENTATION_INFO::version_no */
+	TUint					iVersion;
+
+	/** Plugin's unique UID. 
+	From rss file::IMPLEMENTATION_INFO::implementation_uid */
+	TUid					iUid;
+
+	/** Plugin's own name.
+	From rss file::IMPLEMENTATION_INFO::display_name */
+	TBufC<KPluginNameLength>			iName;
+
+	/** Plugin's own description obtained from 
+	CCoreDumpFormatter->GetDescription()
+	@see CCoreDumpFormatter */
+	TBufC<KPluginDescriptionLength>	iDescription;
+
+	/** Plugin type : from TPluginRequest::TPluginType */
+	TPluginRequest::TPluginType	iType;
+
+	/** Plugin loaded state. */
+	TBool					iLoaded;
+
+	/** Reserved for future use
+	@internalTechnology */
+	TUint32 iSpare1;
+
+	/** @internalTechnology */
+	TUint32 iSpare2;
+};
+
+
+/**
+@publishedPartner 
+@released
+
+List of TPluginInfo objects.
+@see TPluginInfo
+@see RArray
+*/
+typedef RArray<TPluginInfo>	RPluginList;
+
+
+#include <streamelement.h>
+
+/**
+@publishedPartner 
+@released
+
+Class that represents a ECOM plugin instance. 
+It is based on CStreamElementBase so it can be streamed between client and server.
+@see CServerCrashDataSource::GetPluginListL
+*/
+class CPluginInfo : public CStreamElementBase
+{
+
+public:
+
+	IMPORT_C static CPluginInfo* NewL( const TDesC &aName,
+									   const TInt aUid,
+                                       const TUint aVersion,
+									   const TPluginRequest::TPluginType aType); 
+
+	IMPORT_C static CPluginInfo* NewL( const TDesC8 & aStreamData );
+
+	IMPORT_C ~CPluginInfo();
+
+public:
+
+	IMPORT_C void NameL( const TDesC & aName );
+	IMPORT_C const TDesC & Name() const;
+
+    IMPORT_C void Uid(const TInt aUid);
+    IMPORT_C TInt Uid() const;
+
+    IMPORT_C void Version(TUint aVersion);
+    IMPORT_C TUint Version() const;
+
+    IMPORT_C void Pair(TUint aIndex);
+    IMPORT_C TUint Pair() const;
+
+    IMPORT_C void Type(TPluginRequest::TPluginType aType);
+    IMPORT_C TPluginRequest::TPluginType Type() const;
+
+public:
+	// Methods required by streaming interface 
+
+	IMPORT_C TInt static MaxSize();
+
+	IMPORT_C TInt Size() const;
+
+	// Initializes ’this’ from stream
+	IMPORT_C void InternalizeL( RReadStream & aStream );
+
+	// Writes ’this’ to the stream
+	IMPORT_C void ExternalizeL( RWriteStream & aStream, CBufFlat* buf );
+
+
+private:
+
+	CPluginInfo( const TInt aUid,
+				 const TUint aVersion,
+                 const TPluginRequest::TPluginType aType);
+
+	CPluginInfo();
+
+	void ConstructL( const TDesC & aName );
+
+private:
+
+    /** Plugin name */
+	HBufC *iName;
+
+    /** Plugin UID */
+	TInt iUid;
+
+    /** Plugin version */
+	TUint iVersion;
+
+	/** Plugin type : from TPluginRequest::TPluginType */
+	TPluginRequest::TPluginType	iType;
+
+    /** Index to paired plugin */
+    TUint iPair;
+
+	/** Externalized size */
+	TUint				iSize;
+
+	/** Reserved for future use
+	@internalTechnology */
+	TUint32 iSpare1;
+
+	/** @internalTechnology */
+	TUint32 iSpare2;
+
+	};
+
+
+/**
+@publishedPartner 
+@released
+
+List of CPluginInfo object pointers
+@see CPluginInfo
+@see RPointerArray
+*/
+typedef RPointerArray<CPluginInfo>	RPluginPointerList;
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/common/processdata.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,116 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @publishedPartner 
+ @released
+*/
+
+#ifndef PROCESSDATA_H
+#define PROCESSDATA_H
+
+#include <streamelement.h>
+
+_LIT(KNoThreadName, "No Thread Name Available");
+
+/**
+@publishedPartner 
+@released
+
+Class that represents a process on the target. It is based on CStreamElementBase so
+it can be streamed between client and server.
+It is used by the Core Dump server, its clients and the plugins.
+@see CServerCrashDataSource::GetProcessListL()
+*/
+class CProcessInfo : public CStreamElementBase
+{
+
+public:
+
+	IMPORT_C static CProcessInfo* NewL( const TUint64	  aId,
+										const TDesC		& aName );
+
+	IMPORT_C static CProcessInfo* NewL( const TDesC8 & aStreamData );
+
+	IMPORT_C ~CProcessInfo();
+
+public:
+	// Methods specific to CProcessInfo
+
+	IMPORT_C const TUint64 & Id( ) const;
+
+	IMPORT_C void NameL( const TDesC & aName );
+	IMPORT_C const TDesC & Name() const;
+
+	IMPORT_C TBool Observed( ) const;
+	IMPORT_C void  Observed( TBool aFlag );
+
+public:
+	// Methods required by streaming interface 
+
+	IMPORT_C TInt static MaxSize();
+
+	IMPORT_C TInt Size() const;
+
+	// Initializes ’this’ from stream
+	IMPORT_C void InternalizeL( RReadStream & aStream );
+
+	// Writes ’this’ to the stream
+	IMPORT_C void ExternalizeL( RWriteStream & aStream, CBufFlat* buf );
+
+
+private:
+
+	CProcessInfo(	const TUint64	  aId );
+
+	CProcessInfo();
+
+	void ConstructL( const TDesC & aName );
+
+private:
+
+	/** Symbian kernel process id */
+	TUint64				iId;
+
+	/** Symbian kernel process name */
+	HBufC  *			iName;
+
+    /** Observed by core dump server */
+	TBool				iObserved;
+
+	/** Externalized size */
+	TUint				iSize;
+
+	// These are not internalised/externalised since they are spare
+	TUint32				iSpare0;
+	TUint32				iSpare1;
+	TUint32				iSpare2;
+	};
+
+
+/**
+@publishedPartner 
+@released
+
+List of CProcessInfo object pointers
+@see CProcessInfo
+@see RPointerArray
+*/
+typedef RPointerArray<CProcessInfo>	RProcessPointerList;
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/common/streamelement.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#ifndef STREAMELEMENT_H
+#define STREAMELEMENT_H
+
+#include <e32base.h>
+#include <s32mem.h>
+
+#include <rm_debug_api.h>
+#include <debuglogging.h>
+
+/**
+@internalTechnology 
+@released
+
+Pure virtual base class for streamable classes. 
+Used when a class must be passed accross a client server interface
+*/
+class CStreamElementBase : public CBase
+{
+
+public:
+	
+	virtual ~CStreamElementBase()
+		{
+		}
+
+	/** 
+	Creates HBufC8 with a representation of ’this’ object
+	*/
+	IMPORT_C  HBufC8* MarshalDataL();
+
+
+	TInt static MaxSize()
+		{
+		return 0;
+		}
+
+	virtual TInt Size() const = 0;
+
+	// Initializes ’this’ from stream
+	virtual void InternalizeL( RReadStream & aStream ) = 0;
+
+	// Writes ’this’ to the stream
+	virtual void ExternalizeL( RWriteStream & aStream, CBufFlat* buf ) = 0;
+
+	TUint32 iSpare1;
+	TUint32 iSpare2;
+};
+
+#endif // STREAMELEMENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/common/threaddata.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,177 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @publishedPartner 
+ @released
+*/
+
+#ifndef THREADDATA_H
+#define THREADDATA_H
+
+#include <streamelement.h>
+
+
+/**
+@publishedPartner 
+@released
+
+Class that represents a thread on the target. It is based on CStreamElementBase, so
+it can be streamed between client and server.
+It is used by the Core Dump server, its clients and the plugins.
+*/
+class CThreadInfo : public CStreamElementBase
+{
+
+public:
+
+	IMPORT_C static CThreadInfo* NewL(  const TUint64	& aId,
+										const TDesC		& aName, 
+										const TUint64	& aProcessId,
+										const TUint		& aPriority,
+										const TLinAddr	& aSvcStackPtr,
+										const TLinAddr	& aSvcStackAddr,
+										const TUint		& aSvcStackSize,
+										const TLinAddr	& aUsrStackAddr,
+										const TUint		& aUsrStackSize);
+
+	IMPORT_C static CThreadInfo* NewL( const TDesC8 & aStreamData );
+
+	IMPORT_C ~CThreadInfo();
+
+public:
+
+	// Methods specific to CThreadInfo
+
+	IMPORT_C const TUint64 & Id( ) const;
+
+	IMPORT_C void NameL( const TDesC & aName );
+	IMPORT_C const TDesC & Name() const;
+	
+	IMPORT_C const TUint64 & ProcessId( ) const;
+
+	IMPORT_C TUint Priority( ) const;
+	IMPORT_C TUint SvcStackPtr( ) const;
+	IMPORT_C TUint SvcStackAddr( ) const;
+	IMPORT_C TUint SvcStackSize( ) const;
+	IMPORT_C TUint UsrStackAddr( ) const;
+	IMPORT_C TUint UsrStackSize( ) const;
+
+	IMPORT_C TBool Observed( ) const;
+	IMPORT_C void Observed( TBool aFlag );
+	
+	IMPORT_C void SetLastCpuId(TInt32 aLastCpu); 
+	IMPORT_C TInt32 LastCpuId() const;
+	
+	IMPORT_C void SetHeapBase(TUint32 aHeapSize); 
+	IMPORT_C TUint32 HeapBase() const;
+	
+	IMPORT_C void SetHeapSize(TUint32 lastCpu); 
+	IMPORT_C TUint32 HeapSize() const;
+	
+public:
+	// Methods required by streaming interface 
+
+	IMPORT_C TInt static MaxSize();
+
+	IMPORT_C TInt Size() const;
+
+	IMPORT_C void InternalizeL( RReadStream & aStream );
+
+	IMPORT_C void ExternalizeL( RWriteStream & aStream, CBufFlat* buf );
+	
+private:
+
+	CThreadInfo(	const TUint64	& aId,
+					const TUint64	& aProcessId,
+					const TUint		& aPriority,
+					const TLinAddr	& aSvcStackPtr,
+					const TLinAddr	& aSvcStackAddr,
+					const TUint		& aSvcStackSize,
+					const TLinAddr	& aUsrStackAddr,
+					const TUint		& aUsrStackSize);
+
+	CThreadInfo();
+
+	void ConstructL( const TDesC & aName );
+
+private:
+
+	/** Symbian kernel thread id */
+	TUint64				iId;
+
+	/** Symbian kernel thread name */
+	HBufC  *			iName;
+
+	/** Symbian kernel process id of owning process */
+	TUint64				iProcessId;
+
+	/** Symbian kernel thread priority TThreadPriority */
+	TUint				iPriority;
+
+	/** Thread supervisor stack pointer */
+	TLinAddr			iSvcStackPtr;
+
+	/** Thread supervisor mode stack base address */
+	TLinAddr			iSvcStackAddr;
+
+	/** Thread supervisor mode stack size in bytes */
+	TUint				iSvcStackSize;
+
+	/** Thread user mode stack base address */
+	TLinAddr			iUsrStackAddr;
+
+	/** Thread user mode stack base size in bytes */
+	TUint				iUsrStackSize;
+
+	/** Set to ETrue if the thread is being explicitly observed for crashes 
+	by the Core Dump Server. If only the owning process is being observed, 
+	this should be EFalse. */
+	TBool				iObserved;
+
+	/** Externalized size */
+	TUint				iSize;
+
+	/** last cpu in use when crash occurred */
+	TInt32 			iLastCpuId;  
+	
+	/** threads heap base */
+	TInt32				iHeapBase;
+	
+	/** thread heap size  */
+	TUint32				iHeapSize;
+
+	// These are not internalised/externalised since they are spare
+	TUint32 iSpare1;
+	TUint32 iSpare2;
+
+	};
+
+
+/**
+@publishedPartner 
+@released
+
+List of CThreadInfo object pointers.
+@see CThreadInfo
+@see RPointerArray
+*/
+typedef RPointerArray<CThreadInfo>	RThreadPointerList;
+
+
+#endif // THREADDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/config/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/config/optionconfig.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,205 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Define the Option Configuration interface class COptionConfig.
+//
+
+
+
+/**
+ @file
+ @publishedPartner 
+ @released
+ @see COptionConfig
+*/
+
+
+#ifndef OPTION_CONFIG_H
+#define OPTION_CONFIG_H
+
+
+
+#include <streamelement.h>
+
+/** 
+Maximum number of characters allowed for the descriptors of a COptionConfig object.
+@see COptionConfig* NewL().
+*/
+#define KCDSMaxConfigParamStr 128
+
+
+/**
+@publishedPartner 
+@released
+
+Class that represents a configuration parameter. It is based on CStreamElementBase so
+it can be streamed between client and server.
+*/
+class COptionConfig : public CStreamElementBase
+{
+
+public:
+
+	/**
+	Type of parameter
+	*/
+	enum TOptionType
+		{
+		/** Signed integer */
+		ETInt,
+		/** Unsigned integer */
+		ETUInt,
+		/** String */
+		ETString,
+		/** Filename */
+		ETFileName,
+
+        /** Unused */
+		ETSingleEntryEnum,	
+
+		/** Set string values allowed. */
+		ETMultiEntryEnum,
+
+		/** True/False */
+		ETBool	
+
+		};
+
+	/**
+	Owning component type
+	*/
+	enum TParameterSource
+		{
+		/** Core Dump Server is owner of the parameter */
+		ECoreDumpServer,
+
+		/** Formatter plugin is owner of the parameter */
+		EFormatterPlugin,
+
+		/** Writer plugin is owner of the parameter */
+		EWriterPlugin,
+		
+		/* SCM config option */
+		ESCMConfig
+		};
+
+	IMPORT_C static COptionConfig* NewL( const TUint32	       & aIndex, 
+										const TUint32	       & aUID, 
+										const TParameterSource & aSource, 
+										const TOptionType	   & aType, 
+										const TDesC            & aPrompt, 
+										const TUint32	       & aNumOptions,
+										const TDesC            & aOptions,
+										const TInt32	       & aVal, 
+										const TDesC            & aStrValue );
+
+	IMPORT_C static COptionConfig* NewL( const TDesC8 & aStreamData );
+
+	IMPORT_C ~COptionConfig();
+
+public:
+	// Methods specific to COptionConfig
+	
+	IMPORT_C TOptionType Type() const;
+	IMPORT_C TParameterSource Source() const;
+	IMPORT_C TUint32 Index() const;
+	IMPORT_C TUint32 Uid( ) const;
+
+	IMPORT_C const TDesC & Prompt() const;
+
+	IMPORT_C TUint32 NumOptions( ) const;
+	IMPORT_C const TDesC & Options() const;
+
+	IMPORT_C TInt32 Value() const;
+	IMPORT_C TBool ValueAsBool() const;
+	IMPORT_C const TDesC & ValueAsDesc() const;
+
+	IMPORT_C void Value( const TInt32 aValue );
+	IMPORT_C void ValueL( const TDesC & aValue );
+
+public:
+	// Methods required by streaming interface 
+
+	IMPORT_C static TInt MaxSize();
+	IMPORT_C TInt Size() const;
+	
+	// Initializes ’this’ from stream
+	IMPORT_C void InternalizeL( RReadStream & aStream );
+
+	// Writes ’this’ to the stream
+	IMPORT_C void ExternalizeL( RWriteStream & aStream, CBufFlat* buf );
+
+
+private:
+
+	COptionConfig(  const TOptionType		& aType, 
+					const TParameterSource	& aSource, 
+					const TUint32			& aIndex, 
+					const TUint32			& aUID,
+					const TUint32			& aNumOptions,
+					const TInt32			& aValue );
+
+	void ConstructStringL( const TDesC & aSource, HBufC ** aDest );
+
+	COptionConfig();
+
+	void ConstructL( const TDesC & aPrompt, 
+					const TDesC & aOptions,
+					const TDesC & aStrValue );
+
+public:
+	IMPORT_C TUint32 Instance() const;
+    IMPORT_C void Instance( const TInt32 aInstance );
+
+    TAny* Tag() const { return  iTag; }
+    void SetTag(TAny* aTag) { iTag = aTag; }
+    
+private:
+
+	// Since this is passed accross the Client Server interface, we should keep the type native.
+	TOptionType iType;
+
+	TParameterSource iSource;
+
+	// This index is not globally unique. It is valid within a group of parameters only. 
+	// For example the params from the formatter are say 0 to 3, then for the writer they are 0 to 2.
+	TUint32 iIndex;
+
+	TUint32 iUID;
+
+	HBufC * iPrompt;
+
+	TUint32 iNumOptions;
+
+	HBufC * iOptions;
+
+	TInt32  iValue;
+
+	HBufC * iStrValue;
+
+	/** 
+	Externalized size
+	*/
+	TUint	iSize;
+
+	TUint32 iInstance;
+
+	TAny* iTag;
+	TUint32 iSpare2;
+	
+	
+	};
+
+typedef RPointerArray<COptionConfig>	RConfigParameterList;
+	
+#endif // OPTION_CONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/config/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,6 @@
+Directory for:
+  coredump\interface\config
+
+
+Interface to the configuration parameters used accross the Core dump Client-server interface 
+  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/datasave/crashdatasave.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,226 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Defines the ECOM Core Dump Writer interface.
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CRASH_DATA_SAVE_H
+#define CRASH_DATA_SAVE_H
+
+#include <e32std.h>
+#include <ecom.h>
+
+#include <ImplementationInformation.h>
+
+/**
+This is the ECOM interface UID that all Writer ECOM plugins supporting this interface
+must implement. This must match with the implementation_uid field of the rss file.
+*/
+const TUid KCCrashDataSaveUid = {0x102831e3};
+
+class COptionConfig;
+
+/**
+Class that defines the ECOM interface of a Core Dump Writer ECOM plugin.
+The responsibility of a writer plugin is to be a repository or channel for a
+formatter's crash data.
+The class is intended for derivation by implementations of the interface.
+*/
+class CCrashDataSave : public CBase
+{
+public:
+
+    /** Interface for passing initialisation parameters
+    to the derived class constructor. Standard ECOM implementation.
+	*/
+    struct TExampleInterfaceInitParams
+        {
+		/** Integer cue */
+        TInt integer;
+		/** Descriptor cue */
+        const TDesC* descriptor;
+        };
+
+	// mandatory ECOM functions
+	static CCrashDataSave* NewL();
+	static CCrashDataSave* NewL( const TDesC8 & aCue );
+	static CCrashDataSave* NewL(const TUid& aUid);
+	static void ListAllImplementationsL( RImplInfoPtrArray & aImplInfoArray );
+
+	/**
+	Obtain a description of the plugin.
+	*/
+	virtual void GetDescription( TDes & aPluginDescription ) = 0;
+
+    /**
+	Return the number of configuration parameters implemented by the plugin.
+	*/
+	virtual TInt GetNumberConfigParametersL( ) = 0;
+
+	/**
+	Return the configuration parameter with ordinal aIndex.
+	@param  aIndex Parameter ordinal
+	*/
+	virtual COptionConfig * GetConfigParameterL( const TInt aIndex ) = 0;
+
+	/**
+	Change the configuration parameter with ordinal aIndex to the given values.
+	The plugin interprets and validates the values. Depending on the type of
+	parameter, the plugin may use the integer parameter aValue or the
+	descriptor parameter aDescValue
+	@param  aIndex Parameter ordinal
+	@param  aValue Integer value
+	@param  aDescValue Descriptor value
+	*/
+	virtual void SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue ) = 0;
+
+	// Writer interface
+
+	/**
+	Used to start the saving of data.
+	@param aParam The interpretation of aParam is specific to the plugin.
+	*/
+	virtual void OpenL( const TDesC& aParam ) = 0;
+
+	/**
+	Used to start the saving of data.
+	@param aParam The interpretation of aParam is specific to the plugin.
+	*/
+	virtual TInt Open( const TDesC& aParam ) = 0;
+
+	/**
+	End the data save operation.
+	@pre Must have called Open or OpenL
+	*/
+	virtual void CloseL() = 0;
+
+	/**
+	End the data save operation.
+	@pre Must have called Open or OpenL
+	*/
+	virtual TInt Close() = 0;
+
+	/**
+	Save data.
+	@param aData TDesC8 with data to be saved.
+	@pre Must have called Open or OpenL
+	*/
+	virtual void WriteL( const TDesC8& aData ) = 0;
+
+	/**
+	Save data.
+	@param aData TDesC8 with data to be saved.
+	@pre Must have called Open or OpenL
+	*/
+	virtual TInt Write( const TDesC8& aData ) = 0;
+
+	/**
+	Save data from a pointer given the data size.
+	@param aData Pointer to data to be saved.
+	@param aSize Length of data to be saved in bytes
+	@pre Must have called Open or OpenL
+	*/
+	virtual void WriteL( TAny* aData, TUint aSize ) = 0;
+
+	/**
+	Save data from a pointer given the data size.
+	@param aData Pointer to data to be saved.
+	@param aSize Length of data to be saved in bytes
+	@pre Must have called Open or OpenL
+	*/
+	virtual TInt Write( TAny* aData, TUint aSize ) = 0;
+
+	/**
+	Save aData at the specific position.
+	@param aPos The interpretation of aPos is specific to the plugin.
+	@param aData TDesC8 with data to be saved.
+	@pre Must have called Open or OpenL
+	*/
+	virtual void WriteL( TInt aPos, const TDesC8& aData ) = 0;
+
+	/**
+	Save aData at the specific position.
+	@param aPos The interpretation of aPos is specific to the plugin.
+	@param aData TDesC8 with data to be saved.
+	@pre Must have called Open or OpenL
+	*/
+	virtual TInt Write( TInt aPos, const TDesC8& aData ) = 0;
+
+	/**
+	Save aData at the specific position.
+	@param aPos The interpretation of aPos is specific to the plugin.
+	@param aData Pointer to data to be saved.
+	@param aSize Length of data to be saved in bytes
+	@pre Must have called Open or OpenL
+	*/
+	virtual void WriteL( TInt aPos, TAny* aData, TUint aSize ) = 0;
+
+	/**
+	Save aData at the specific position.
+	@param aPos The interpretation of aPos is specific to the plugin.
+	@param aData Pointer to data to be saved.
+	@param aSize Length of data to be saved in bytes
+	@pre Must have called Open or OpenL
+	*/
+	virtual TInt Write( TInt aPos, TAny* aData, TUint aSize ) = 0;
+
+	/**
+	Returns the media specific name that will be used to save this object
+    @return const reference to a descriptor describing the media name
+	*/
+	virtual const TDesC& GetMediaName() = 0;
+
+    //dtor
+public:
+    virtual ~CCrashDataSave();
+
+    /**
+	Writer plugin base configuration parameter identifiers.
+	Identifiers for derived interfaces should start where this enum ends.
+	*/
+	enum TDataSaveParams
+		{
+		/** This parameter is a root identifier for core dumps. Its use depends on the
+		writer plugin and potentially the formatters. For example for an email data save
+		plugin this parameter could be an the email address. For a file writer it could be
+		a file name or a directory path. */
+		ECoreFilePath,
+		EDataSaveLastParam
+		};
+
+protected:
+
+	/** Define the container for the plugin's configuration parameters */
+	typedef RPointerArray<COptionConfig>	RConfigParameterList;
+
+	/**
+	List of COptionConfig configuration parameters implemented by the plugin.
+	*/
+	RConfigParameterList	 iConfigList;
+
+private:
+	TUid iDtor_ID_Key;
+
+	TUint32 iSpare1;
+	TUint32 iSpare2;
+};
+
+#include <crashdatasave.inl>
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/datasave/crashdatasave.inl	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,78 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implements some of the ECOM Core Dump Writer interface.
+// The rest is implemented by the inheritors.
+//
+
+
+
+/**
+ @file
+ @publishedPartner 
+ @released
+ @see CCrashDataSave
+*/
+
+// Set default to be first implementation found by resolver
+_LIT8(KDefaultImpl, "*");
+
+inline CCrashDataSave::~CCrashDataSave()
+    {
+    // Destroy any instance variables and then
+    // inform the framework that this specific
+    // instance of the interface has been destroyed.
+    REComSession::DestroyedImplementation(iDtor_ID_Key);
+    }
+
+inline CCrashDataSave* CCrashDataSave::NewL()
+    {
+    // Set up the interface find for the default resolver.
+    TEComResolverParams resolverParams;
+    resolverParams.SetDataType(KDefaultImpl());
+    resolverParams.SetGenericMatch(ETrue);     // Allow wildcard matching
+
+    // Set up some empty initialisation parameters
+    TExampleInterfaceInitParams initParams;
+    initParams.integer      = 0;
+    initParams.descriptor   = NULL;
+
+    return reinterpret_cast<CCrashDataSave*>(
+                            REComSession::CreateImplementationL(KCCrashDataSaveUid,
+                                                             _FOFF(CCrashDataSave, iDtor_ID_Key),
+                                                             &initParams,
+                                                             resolverParams));
+    }
+
+inline CCrashDataSave* CCrashDataSave::NewL(const TDesC8& aCue)
+	{
+	TEComResolverParams resolverParams;
+	resolverParams.SetDataType(aCue);
+	resolverParams.SetGenericMatch(ETrue);
+	TAny* fileWriter = REComSession::CreateImplementationL(KCCrashDataSaveUid, _FOFF(CCrashDataSave, iDtor_ID_Key),
+		resolverParams);
+	return reinterpret_cast<CCrashDataSave*>(fileWriter);
+	}
+
+inline CCrashDataSave* CCrashDataSave::NewL(const TUid& aUid)
+	{
+	TAny* fileWriter = REComSession::CreateImplementationL(aUid, _FOFF(CCrashDataSave, iDtor_ID_Key));
+	return reinterpret_cast<CCrashDataSave*>(fileWriter);
+	}
+
+inline void CCrashDataSave::ListAllImplementationsL(RImplInfoPtrArray& aImplInfoArray)
+	{
+	REComSession::ListImplementationsL(KCCrashDataSaveUid, aImplInfoArray);
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/datasave/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/datasave/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,5 @@
+Directory for:
+  coredump\interface\data_save
+
+Data save API implemented Writer plugins. Instantiated by Core Dump Server and used by formatters to save crash data.
+  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/datasource/crashdatasource.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,397 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Definition of Data Source API that supplies crash information.
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef CRASH_DATA_SOURCE_H
+#define CRASH_DATA_SOURCE_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <scmdatatypes.h>
+#include <crashdata.h>
+#include <processdata.h>
+#include <executabledata.h>
+#include <threaddata.h>
+
+#ifdef __MARM__
+#include <rm_debug_api.h>
+#endif
+
+/**
+Definition of the Data Source API. This API is used by formatters to obtain crash data from
+the Core Dump Server. The Core Dump Server derives and implements this API.
+*/
+class CCrashDataSource : public CBase
+{
+protected:
+
+	/** Standard second-phase constructor. */
+	virtual void ConstructL() = 0;
+
+public:
+
+	/**
+	This call returns information on all available registers. It does not
+	return the register contents. This is used to establish which registers
+	a caller could ask for, in particular for Co Processor registers.
+	The callee (not the caller) allocates aRegisterList.
+	This method is used by a formatter to establish which registers it can ask for,
+	and thus need only be called once per session.
+
+    @param aRegisterList Returned register list with available registers.
+
+    @see TRegisterData.
+	@see RRegisterList.
+	*/
+	virtual void GetRegisterListL( RRegisterList  &	aRegisterList ) = 0;
+
+	/**
+	Ask the Core Dump server for some register data. The caller allocates
+	the array and fills in the details of the registers for which it would like
+	the contents.
+	@param aThreadId Thread to read registers from.
+	@param aRegisterList Returned register list with current values.
+
+    @see TRegisterData.
+	@see GetRegisterListL().
+	@see RRegisterList.
+	*/
+	virtual void ReadRegistersL( const TUint64 aThreadId, RRegisterList &aRegisterList ) = 0;
+
+	/**
+ 	Read data from target relative to a particular thread.
+	The caller assumes ownership of the resulting data descriptor.
+
+ 	@param aThreadId Memory read is relative to this thread parameter
+	@param aAddress Virtual address to read from
+    @param aLength Number of bytes to read
+	@param aData Descriptor for read data
+	*/
+	virtual void ReadMemoryL(
+                   const TUint64    aThreadId,
+                   const TUint32    aAddress,
+                   const TUint32    aLength,
+                   TDes8          & aData ) = 0;
+
+	/**
+ 	Read the current process list.
+	The caller assumes ownership of resulting data.
+	@param aData Array of currently running processes .
+
+	@see RProcessPointerList.
+	@see CProcessInfo.
+	*/
+	virtual void GetProcessListL( RProcessPointerList & aData )
+		{
+		TUint totalProcessListDescSize;
+		GetProcessListL( aData, totalProcessListDescSize );
+		};
+
+	/**
+ 	Read the current process list.
+	The caller assumes ownership of the resulting data.
+	This call is only useful if the total descriptor size required for
+	transferring across the client-server boundary must be known.
+
+ 	@param aData	Array of currently running processes.
+	@param aTotalProcessListDescSize Total descriptor size required
+	to transfer the list across the client-server interface.
+	@leave One of the OS wide codes
+    @see RProcessPointerList.
+	@see CProcessInfo.
+	*/
+	virtual void GetProcessListL( RProcessPointerList & aData,
+						         TUint & aTotalProcessListDescSize ) = 0;
+
+	/**
+ 	Read the current executable list. The caller assumes ownership of the resulting data.
+	@param aData Array of current executables.
+ 	@leave One of the OS wide codes
+	@see RExecutablePointerList.
+	@see CExecutableInfo
+	*/
+	virtual void GetExecutableListL( RExecutablePointerList & aData )
+		{
+		TUint totalExecutableListDescSize;
+		GetExecutableListL( aData, totalExecutableListDescSize );
+		};
+
+	/**
+ 	Read the current executable list.
+	The caller assumes ownership of the resulting data.
+	This call is only useful if the total descriptor size required for
+	transferring across the client-server boundary must be known.
+
+ 	@param aData	Array of current executables.
+	@param aTotalExecutableListDescSize	Total descriptor size required
+	to transfer the list across the client-server interface.
+	@leave One of the OS wide codes
+	@see RExecutablePointerList.
+	@see CExecutableInfo
+	*/
+	virtual void GetExecutableListL( RExecutablePointerList & aData,
+						         TUint & aTotalExecutableListDescSize ) = 0;
+
+ 	/**
+	Read the current thread list.
+	This call is only useful if the total descriptor size required for
+	transferring across the client-server boundary must be known.
+
+	@param aProcessId If this argument is -1, all the threads in the
+	system are returned. Otherwise the threads under the process with the id
+	aProcessId are returned.
+ 	@param aThreadList Array of currently running threads.
+	@param aTotalThreadListDescSize Size in bytes of the descriptor
+	required to transfer the data over the client server interface.
+ 	@leave One of the OS wide codes
+  	@see CThreadInfo
+    @see RThreadPointerList.
+	@see GetThreadListL
+	*/
+	virtual void GetThreadListL( const TUint64 aProcessId,
+						RThreadPointerList & aThreadList,
+						TUint & aTotalThreadListDescSize ) = 0;
+
+	/**
+ 	Read the current thread list.
+	The caller assumes ownership of the resulting data.
+
+	@param aProcessId If this argument is -1, all the threads in the
+	system are returned. Otherwise the threads under the process with the id
+	aProcessId are returned.
+ 	@param aThreadList	Array of currently running threads.
+	@leave One of the OS wide codes
+	@see CThreadInfo
+	@see RThreadPointerList
+	*/
+  	virtual void GetThreadListL( const TUint64 aProcessId,
+								 RThreadPointerList & aThreadList )
+		{
+		TUint totalThreadListDescSize;
+		GetThreadListL(	aProcessId, aThreadList, totalThreadListDescSize );
+		};
+
+    /**
+	Obtain a list of the code segments for a process.
+
+	@param aTid Thread identifier to obtain code segments for.
+	@param aCodeSegs Array of code segments.
+	@param aTotalCodeSegListDescSize Size in bytes of the descriptor
+	required to transfer the data over the client server interface.
+ 	@leave One of the OS wide codes
+	@see RCodeSegPointerList
+	@see TSegmentInfo
+	*/
+    virtual void GetCodeSegmentsL(const TUint64 aTid,
+									RCodeSegPointerList &aCodeSegs,
+									TUint &aTotalCodeSegListDescSize ) = 0;
+
+    /**
+	Obtain a list of the code segments for a process.
+
+	@param aTid Thread identifier to obtain code segments for.
+	@param aCodeSegs Array of code segments.
+    @leave One of the OS wide codes
+	@see RCodeSegPointerList
+	@see TSegmentInfo
+	*/
+    virtual void GetCodeSegmentsL(const TUint64 aTid, RCodeSegPointerList &aCodeSegs)
+        {
+        TUint totalThreadListDescSize;
+        GetCodeSegmentsL(aTid, aCodeSegs, totalThreadListDescSize);
+        };
+
+    /**
+     * Returns the size of the trace buffer that is available. Should be used in conjunction with ReadTraceBufferL to
+     * determine the size of the buffer you need to pass in.
+     * @return Trace Buffer Size
+     * @leave One of the OS wide codes
+     * @see ReadTraceBufferL
+     */
+    virtual TUint GetAvailableTraceSizeL() {User::Leave(KErrNotSupported); return 0;};
+
+	/**
+	 * Reads trace data from trace buffer at time of crash. If the resulting
+	 * descriptor is of size zero then no trace data is available. Use GetAvailableTraceSizeL to see what size buffer to supply.
+	 * @param aTraceData Descriptor to store trace data
+	 * @param aPos Position in the trace buffer from which to read. It will read to the end or until the supplied descriptor is full, whichever happens first.
+	 * @leave One of the OS wide codes
+	 * @see GetAvailableTraceSizeL
+	 */
+	virtual void ReadTraceBufferL(TDes8 &aTraceData, TUint aPos = 0 ) {User::Leave(KErrNotSupported); };
+
+	/**
+	 * Reads locks data
+	 * @param aLockData Descriptor to store trace data
+	 * @leave One of the OS wide codes
+	 * @see TSCMLockData
+	 */
+	virtual void GetLocksL(TSCMLockData& aLockData) {User::Leave(KErrNotSupported); };
+
+	/**
+	 * Reads the ROM Build Info
+	 * @param aRomHeader Contains the ROM header info after the call if succesful
+	 * @leave One of the OS wide codes
+	 * @see TRomHeaderData
+	 */
+	virtual void GetROMBuildInfoL(TRomHeaderData& aRomHeader) {User::Leave(KErrNotSupported); };
+
+	/**
+	 * Gets the size of any variant specific information that might be available. Should
+	 * be used in conjunction with GetVariantSpecificDataL to determine the size of descriptor
+	 * required to be passed in	 *
+	 * @return One of the system wide error codes
+	 * @param aDataSize Stores the datasize after the call
+	 * @see GetVariantSpecificData
+	 */
+	virtual TInt GetVariantSpecificDataSize(TUint& aDataSize) = 0;
+
+	/**
+	 * Gets any variant specific data that might be available
+	 * @return One of the system wide error codes
+	 * @param aVarSpecData Reference to descriptor to store data. Must be large enough
+	 *			to store the data. If this returns size zero, no data was available
+	 * @see GetVariantSpecificDataSize
+	 */
+	virtual TInt GetVariantSpecificData(TDes8& aVarSpecData) = 0;
+
+#ifdef __MARM__
+
+	/**
+	 * If the stack for the given mode is available, this will return the size of it
+	 * @return The size of the stack
+	 * @param aMode Processer mode of interest
+	 * @leave One of the OS wide codes
+	 * @see Debug::TArmProcessorModes
+	 * @see GetExceptionStackL
+	 */
+	virtual TUint GetExceptionStackSizeL(const Debug::TArmProcessorModes aMode) {User::Leave(KErrNotSupported); };
+
+	/**
+	 * Reads the exception stack for a given exception mode into the descriptor. Will start reading
+	 * aStartReadPoint bytes into the stack and will fill up the descriptor as much as possible. The intention
+	 * is to make multiple calls of this so you don't have to allocate a large buffer at the start.
+	 * @param aMode Processer mode of interest
+	 * @param aStack Descriptor to put stack into
+	 * @param aStartReadPoint Will start reading aStartReadPoint bytes into the stack
+	 * @see GetExceptionStackSizeL
+	 */
+	virtual void GetExceptionStackL(const Debug::TArmProcessorModes aMode, TDes8& aStack, TUint aStartReadPoint) {User::Leave(KErrNotSupported); };
+#endif   //MARM_ARMV5
+
+	/**
+	 * Returns the version of this implementation of the data source
+	 * @return TVersion Data Source version
+	 */
+	virtual TVersion GetVersion() const  { return TVersion(1,0,0);};
+
+	/**
+	 * Returns the buffer size that will be required to read the Data Source
+	 * functionality block
+	 * @param aBufSize Size of the buffer required
+	 * @return One of the OS wide codes
+	 * @see GetDataSourceFunctionality
+	 */
+	virtual TInt GetDataSourceFunctionalityBufSize(TUint& aBufSize)   {return 0;};
+
+	/**
+	 * Returns the Data Source Functionality block. Should be used in conjunction with
+	 * GetDataSourceFunctionalityBufSize to determine how big a buffer should be passed through.
+	 *
+	 * Information in the debug functionality block is represented as a concatenation
+	 * of TTag objects and a TTagHeader.
+	 *
+	 * @param aBuffer Contains the functionality block
+	 * @return One of the OS wide codes
+	 * @see GetDataSourceFunctionalityBufSize
+	 * @see Debug::TTag
+	 * @see Debug::TTagType
+	 * @see Debug::TTagHeader
+	 */
+	virtual TInt GetDataSourceFunctionality(TDes8& aFuncBuffer)   { return 0;};
+
+	/** For future expansion
+	@internalTechnology */
+	TUint32 iSpare1;
+
+	/** @internalTechnology */
+	TUint32 iSpare2;
+
+public:
+
+	/**
+	 * These tags define what kinds of core functionality is supported by a given implementation of
+	 * the data source. TTag structures associated with the ETagHeaderIdCore sub-block will have iTagId values from this enumeration.
+	 * See each enumerator for an explanation of how a TTag with that iTagId should be interpreted.
+	 */
+	enum TDataSourceFunctionalityCore
+	{
+		ECodeSegments = 0,        /**< Indicates whether getting code segments is supported */
+		EExecutableList = 1,     /**< Indicates whether getting the executable list is supported */
+		EProcessList = 2,        /**< Indicates whether getting the process list is supported */
+		ERegisterList = 3,      /**< Indicates whether getting the register list is supported */
+		EThreadList = 4,    /**< Indicates whether getting the thread list */
+		EReadMemory = 5,      /**< Indicates whether reading memory is supported. */
+		EReadRegisters = 6,         /**< Indicates whether reading registers is supported. */
+		EReadTraceBuffer = 7,       /**< Indicates whether reading the trace buffer is supported. */
+		ERomBuildInfo = 8,      /**< Indicates whether obtaining the ROM build info is supported */
+		ESystemLocks = 9,  /**< Indicates whether obtaining the System Locks info is supported */
+		EExceptionStacks = 10,  /**< Indicates whether obtaining the exception stacks is supported */
+		/**
+		  @internalTechnology
+		  A debug agent should find the number of core tags from the DFBlock rather than this enumerator.
+		  */
+		ECoreLast
+	};
+
+	/**
+	 * Information in the Data Source functionality block is represented as a concatenation
+	 * of pairs of TDataSourceTagHeader structures and arrays of TTag objects.
+	 * @see Debug::TTag
+	 * @see GetDataSourceFunctionality
+	  */
+	struct TDataSourceTagHeader
+	{
+		/** Value identifying the contents of this TTagHeader, should be interpreted as an enumerator from TTagHeaderId.
+		  @see TTagHeaderId
+		  */
+		TUint16	iTagHdrId;
+		/** The number of TTag elements in the array associated with this TTagHeader. */
+		TUint16 iNumTags;
+	};
+
+	/**
+	 * Enumeration used to identify TDataSourceTagHeader structures, TDataSourceTagHeader::iTagHdrId elements take
+	 * these enumerators as values.
+	 * @see TDataSourceTagHeader
+	 */
+	enum TDataSourceTagHeaderId
+	{
+		ETagHeaderIdCore = 0,            /**< Identifies a TTagHeader with associated TTag elements with iTagId values from TDataSourceFunctionalityCore. */
+		/**
+		 * @internalTechnology
+		 */
+		ELast
+	};
+
+};
+
+#endif // CRASH_DATA_SOURCE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/datasource/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/datasource/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,5 @@
+Directory for:
+  coredump\interface\data_source
+
+Data source API implemented by agent and used by formatter to obtain crash data
+  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/formatter/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/formatter/formatterapi.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,157 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef FORMATTER_API_H
+#define FORMATTER_API_H
+
+/**
+@file
+@publishedPartner
+@released
+
+Defines the ECOM Core Dump Formatting interface. 
+
+*/
+
+#include <e32base.h>
+#include <badesca.h>
+#include <ecom.h>
+#include <ImplementationInformation.h>
+#include <crashdata.h>
+
+/**
+This is the ECOM interface UID that all Formatter ECOM plugins supporting this interface
+must implement. This must match with the implementation_uid field of the rss file.
+*/
+const TUid KCCoreDumpFormatterUid = {0x10282fe2};
+
+class CCrashDataSource;
+class CCrashDataSave;
+class COptionConfig;
+
+/**
+@publishedPartner
+@released
+
+Definition of the ECOM Core Dump Formatting interface. 
+The interface is pure virtual. Formatters must implement this interface for the 
+core dump server to be able to load them.
+*/
+class CCoreDumpFormatter : public CBase
+{
+
+public:
+
+    /** Interface for passing initialisation parameters
+    to the derived class constructor. Standard ECOM implementation. 
+	*/
+    struct TExampleInterfaceInitParams
+        {
+		/** Integer cue */
+        TInt integer;
+		/** Descriptor cue */
+        const TDesC* descriptor;
+        };
+
+	// mandatory ECOM functions
+
+	static CCoreDumpFormatter* NewL();
+	static CCoreDumpFormatter* NewL( const TDesC8 & aCue );
+	static CCoreDumpFormatter* NewL(const TUid& aUid);
+
+	virtual ~CCoreDumpFormatter();
+	static void ListAllImplementationsL( RImplInfoPtrArray & aImplInfoArray );
+
+public:
+	// The formatter interface
+
+
+	/**
+	Core dump server makes this call to supply the formatter with the 
+	data save object. The formatter can then use this object to store 
+	its crash data. The formatter does not own the object.
+	@param aDataSave Data save object to save crash data to.
+	@see CCrashDataSave 
+	*/
+	virtual void ConfigureDataSaveL( CCrashDataSave * aDataSave ) = 0;
+
+	/**
+	Core dump server makes this call to supply the formatter with the 
+	data source object. The formatter can then use this object to obtain
+	crash data. The formatter does not own the object.
+	@param aDataSource Data source object to obtain crash data from.
+	@see CCrashDataSource
+	*/
+	virtual void ConfigureDataSourceL( CCrashDataSource * aDataSource ) = 0;
+
+	/**
+	Call used to obtain a text description of the formatter. Can be used by
+	UIs to present a description to the user.
+	@param aPluginDescription Descriptor with formatter descriptor.
+	*/
+	virtual void GetDescription( TDes & aPluginDescription ) = 0;
+
+	/** 
+	This method informs the formatter that a crash event has occured. 
+	Called by Core Dump Server, which owns the TCrashInfo object.
+	@param aCrashInfo Crash event information with crash data. 
+	Object is owned by caller.
+	@see TCrashInfo
+	*/
+    virtual void CrashEventL(TCrashInfo* aCrashInfo) = 0;
+
+	/** 
+	Used to obtain the number of configuration parameters implemented by the 
+	formatter. Use this call in conjunction with GetConfigParameterL().
+	@return Number of configuration parameters implemented by formatter.
+	@see COptionConfig
+	*/
+	virtual TInt GetNumberConfigParametersL( ) = 0;
+
+	/** 
+	Return the configuration parameter indexed by aIndex. aIndex should be less
+	than the value returned by GetNumberConfigParametersL().
+	@param aIndex Parameter ordinal to retrieve.
+	@return Pointer to a COptionConfig object that is then owned by the caller.
+	@see COptionConfig.
+	@see GetNumberConfigParametersL().
+	*/
+	virtual COptionConfig * GetConfigParameterL( const TInt aIndex ) = 0;
+
+	/** 
+	Set the value of a configuration parameters indexed by aIndex. 
+	@param  aIndex Parameter ordinal to change.
+	@param  aValue Integer value.
+	@param  aDescValue Descriptor value.
+	@see COptionConfig
+	*/
+	virtual void SetConfigParameterL( const TInt aIndex, 
+									const TInt32 & aValue, 
+									const TDesC & aDescValue ) = 0;
+	
+protected:
+	CCoreDumpFormatter();
+
+private:
+	
+	TUid iDtor_ID_Key;
+
+	TUint32 iSpare1;
+	TUint32 iSpare2;
+};
+
+#include <formatterapi.inl>
+
+#endif // FORMATTER_API_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/formatter/formatterapi.inl	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,94 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implement some of the ECOM Core Dump Formatter interface.
+//
+
+
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+// Set default to be first implementation found by resolver
+_LIT8(KDefaultImplementation,"*");
+
+#include <debuglogging.h>
+
+inline CCoreDumpFormatter::CCoreDumpFormatter()
+    {
+	LOG_MSG( "CCoreDumpFormatter::CCoreDumpFormatter()\n" );
+    }
+
+inline CCoreDumpFormatter::~CCoreDumpFormatter()
+    {
+	LOG_MSG2( "CCoreDumpFormatter::~CCoreDumpFormatter() with iDtor_ID_Key=0x%X\n", iDtor_ID_Key );
+    // Destroy any instance variables and then
+    // inform the framework that this specific
+    // instance of the interface has been destroyed.
+    REComSession::DestroyedImplementation( iDtor_ID_Key );
+    }
+
+inline CCoreDumpFormatter* CCoreDumpFormatter::NewL()
+    {
+	LOG_MSG( "CCoreDumpFormatter::NewL()\n" );
+    // Set up the interface find for the default resolver.
+    TEComResolverParams resolverParams;
+    resolverParams.SetDataType(KDefaultImplementation());
+    //resolverParams.SetGenericMatch(ETrue);     // Allow wildcard matching
+	resolverParams.SetWildcardMatch(ETrue);     // Allow wildcard matching
+
+    // Set up some empty initialisation parameters
+    TExampleInterfaceInitParams initParams;
+    initParams.integer      = 0;
+    initParams.descriptor   = NULL;
+
+    return reinterpret_cast<CCoreDumpFormatter*>(
+                            REComSession::CreateImplementationL(KCCoreDumpFormatterUid,
+                                                             _FOFF(CCoreDumpFormatter,iDtor_ID_Key),
+                                                             &initParams,
+                                                             resolverParams));
+    }
+
+inline CCoreDumpFormatter* CCoreDumpFormatter::NewL(const TDesC8& aCue)
+	{
+	LOG_MSG( "CCoreDumpFormatter::NewL(const TDesC8& aCue)\n" );
+
+	TEComResolverParams resolverParams;
+	resolverParams.SetDataType(aCue);
+	resolverParams.SetGenericMatch(ETrue);
+	TAny* symbianElf = REComSession::CreateImplementationL(KCCoreDumpFormatterUid, _FOFF(CCoreDumpFormatter, iDtor_ID_Key),
+		resolverParams);
+	return reinterpret_cast<CCoreDumpFormatter*>(symbianElf);
+	}
+
+
+inline CCoreDumpFormatter* CCoreDumpFormatter::NewL(const TUid& aUid)
+	{
+	LOG_MSG( "CCoreDumpFormatter::NewL(const TUid& aUid)\n" );
+
+	LOG_MSG2( "->REComSession::CreateImplementationL(aUid=0x%X)\n", (aUid) );
+	
+	TAny* symbianElf = REComSession::CreateImplementationL( aUid, _FOFF(CCoreDumpFormatter, iDtor_ID_Key) );
+	LOG_MSG2( "<-REComSession::CreateImplementationL() iDtor_ID_Key=0x%X\n", _FOFF(CCoreDumpFormatter, iDtor_ID_Key) );
+		
+	return reinterpret_cast<CCoreDumpFormatter*>(symbianElf);
+	}
+
+
+inline void CCoreDumpFormatter::ListAllImplementationsL(RImplInfoPtrArray& aImplInfoArray)
+	{
+	REComSession::ListImplementationsL(KCCoreDumpFormatterUid, aImplInfoArray);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/formatter/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,8 @@
+Directory for:
+  coredump\interface\formatter
+
+interface files
+
+This is the definition of the ECOM formatter interface. 
+Plugins implement this interface.
+The interface is needed by the coredump agent, since it uses the interface.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,11 @@
+Directory for:
+  coredump\interface
+
+top level system interface files
+
+ - /common	Common definitions
+ - /config 	parameter configuration interface
+ - /formatter 	ECOM formatter plugin interface
+ - /datasave 	ECOM writer plugin interface
+ - /datasource  Data source API implemented by Core Dump Server and used by formatters to obtain crash data
+ - /server 	client-server interface to the Core Dump Server
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/server/coredumpinterface.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,105 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Define the interface to the Core Dump Server
+//
+
+
+
+/**
+ @file
+ @publishedPartner 
+ @released
+*/
+
+#ifndef CORE_DUMP_API_H
+#define CORE_DUMP_API_H
+
+#include <e32base.h>
+
+
+#include <processdata.h>
+#include <executabledata.h>
+#include <threaddata.h>
+#include <coredumpserverapi.h>
+#include <optionconfig.h>
+
+#include <debuglogging.h>
+#include <crashdata.h>
+
+/**
+@publishedPartner
+@released
+
+Definition of the Core Dump Server interface.
+This is used by clients to interact with the server.
+
+*/
+class RCoreDumpSession	: public RSessionBase
+	{
+        static TInt StartServer();
+
+	public:		// Construction
+		IMPORT_C RCoreDumpSession();
+		
+	public:
+		IMPORT_C TInt Connect();
+		IMPORT_C void Disconnect();
+
+		IMPORT_C void GetPluginListL( RPluginList &aPluginList ) const;
+		IMPORT_C void PluginRequestL(const TPluginRequest &aPluginRequest ) const;
+
+        IMPORT_C void GetProcessesL( RProcessPointerList &aProcessList ) const;
+        IMPORT_C void GetThreadsL( RThreadPointerList &aThreadsList, const TUint64 aPid = (TUint64)-1 ) const;
+		IMPORT_C void GetExecutablesL( RExecutablePointerList &aExecutableList ) const;
+
+        IMPORT_C void ObservationRequestL( const TDesC &aTargetName, const TDesC &aTargetOwnerName, TBool aObserve) const;
+
+		IMPORT_C TInt GetNumberConfigParametersL() const;
+		IMPORT_C COptionConfig * GetConfigParameterL( const TInt aIndex ) const;
+	    IMPORT_C void SetConfigParameterL( const COptionConfig &aConfig ) const;
+
+		IMPORT_C void LoadConfigL( const TDesC & aLoadPath ) const;
+		IMPORT_C void SaveConfigL( const TDesC & aSavePath ) const;
+
+        IMPORT_C void GetFormattersL( RPluginPointerList &aFormatterList ) const;
+        IMPORT_C void GetWritersL( RPluginPointerList &aWriterList ) const;
+
+        IMPORT_C void ListCrashesInFlashL(RCrashInfoPointerList& aCrashes) const;
+        IMPORT_C void DeleteCrashLogL(TInt aCrashId) const;
+        IMPORT_C void DeleteCrashPartitionL() const;
+        IMPORT_C void ProcessCrashLogL(const TInt aCrashId);
+        
+        IMPORT_C void ProcessCrashLog(TInt aCrashId, TRequestStatus &aStatus);
+        IMPORT_C TInt CancelProcessCrashLog(TInt aCrashId);
+        
+	private:	
+        const TDesC8 &GetListLC(const TListRequest &aRequest) const;
+		TVersion Version() const;
+
+	private:	// Data members
+
+        enum {KConnectionRetries = 3};
+
+		TBool iConnected;
+
+		TInt iMaxConfigParamSize;
+
+		TUint32 iSpare0;
+		TUint32 iSpare1;
+		TUint32 iSpare2;
+		TUint32 iSpare3;
+	};
+
+
+#endif // CORE_DUMP_API_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/server/coredumpserverapi.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,340 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Definitions used between the Core Dump Server interface library and the server.
+//
+
+
+
+/**
+ @file
+ @publishedPartner 
+ @released
+*/
+
+#ifndef CORE_DUMP_SERVER_API_H
+#define CORE_DUMP_SERVER_API_H
+
+#include <plugindata.h>
+#include <optionconfig.h>
+
+/** Core Dump Server executable name */
+_LIT(KCoreDumpServerName, "coredump_svr");
+
+/** Core Dump Server UID */
+const TUid KCoreDumpServUid = { 0x10282FE5 };
+
+/** Core Dump Server major version */
+const TUint KCoreDumpServMajorVersionNumber=1;
+
+/** Core Dump Server minor version */
+const TUint KCoreDumpServMinorVersionNumber=1;
+
+/** Core Dump Server build number */
+const TUint KCoreDumpServBuildVersionNumber=2;
+
+/** @see ECrashMediaName 
+ * Length of each entry in the property ECrashMediaName 
+ */
+const TInt KMaxEntryLength = 160;
+
+/** @see ECrashMediaName 
+ * Number of entries in the property ECrashMediaName 
+ */
+const TInt KNumofEntries = 5;
+
+/** @see ECrashMediaName
+ * Size of Media Name in the property ECrashMediaName 
+ */
+const TInt KMaxMediaLength = 148;
+
+/** @see ECrashMediaName
+ * Length of UID in the property ECrashMediaName 
+ */
+const TInt KMaxUIDLength = 10;
+
+/** @see ECrashMediaName
+ * Length of the status in the property ECrashMediaName 
+ */
+const TInt KMaxStatusLength = 1;
+
+/** @see ECrashMediaName
+ * Length of the end character in the property ECrashMediaName 
+ */
+const TInt KMaxEndLength = 1;
+
+/** @see ECrashMediaName
+ * Length of the crash progress buffer ECrashProgress 
+ */
+const TInt KMaxCrashProgressBuffer = 50;
+
+enum TCoreDumpConfigParameters
+	{
+	ECrashEventTypes,
+	EPreCrashEventAction,
+	EPostCrashEventAction,
+	ELastParam
+	};		
+
+/** 
+Core Dump Server client-server requests 
+@internalTechnology 
+*/
+enum TCoreDumpServRqst
+	{
+	/** Obtain a plugin list. 
+	@see RCoreDumpSession::GetPluginListL(). */
+	ECoreDumpServGetPluginList,
+	
+	/** Generic call to obtain data about a list from the Core Dump Server. 
+	@see RCoreDumpSession::GetListLC(). */
+	ECoreDumpGetListInfo,
+
+	/** Generic call to obtain the list from the Core Dump Server. 
+	@see RCoreDumpSession::GetListLC(). */
+	ECoreDumpGetListData,
+
+	/** Request the loading or unloading of a plugin. 
+	@see RCoreDumpSession::PluginRequestL(). */
+	ECoreDumpPluginRequest,
+
+	/** Obtain the current number of configuration parameters. 
+	@see RCoreDumpSession::GetNumberConfigParametersL(). */
+	ECoreDumpGetNumberConfigParams,
+
+	/**  Obtain a configuration parameter.
+	@see RCoreDumpSession::GetConfigParameterL(). */
+	ECoreDumpGetConfigParam,
+
+	/**  Change a configuration parameter.
+	@see RCoreDumpSession::SetConfigParameterL(). */
+	ECoreDumpSetConfigParam,
+
+
+	/** Unused */
+    ECoreDumpAttachThread,
+
+	/** Unused */
+    ECoreDumpDetachThread,
+
+	/** Unused */
+    ECoreDumpAttachProcess,
+
+	/** Unused */
+    ECoreDumpDetachProcess,
+
+	/** Request the observation of a target or the cancellation of an observation.
+	@see RCoreDumpSession::ObservationRequestL(). */
+    ECoreDumpObservationRequest,
+
+	/** Request the restoration of a configuration.
+	@see RCoreDumpSession::LoadConfigL(). */
+	ECoreDumpLoadConfig,
+
+	/** Request the saving of a configuration.
+	@see RCoreDumpSession::SaveConfigL(). */
+	ECoreDumpSaveConfig,
+	
+	/** Deletes a crash in the flash partition */
+	ECoreDumpDeleteLogRequest,
+	
+	/** Deletes entire flash partition */
+	ECoreDumpDeleteCrashPartitionRequest,	
+	
+	/** Processes a crash in the flash partition */
+	ECoreDumpProcessFlashCrash,
+	
+	/** Asynchronously processes a crash */
+	ECoreDumpProcessCrashAsync,
+	
+	/** Cancel asynchronous processesing a crash */
+	ECoreDumpCancelProcessCrashAsync,
+	
+	/**	Guard	*/
+	ECoreDumpServEndMarker
+	
+	};
+
+/** Number of asynchronous requests */
+#define KTTMaxAsyncRequests		(4)
+
+/** Default number of message slots per session
+Same as KTTMaxAsyncRequests as synchronous requests provided
+by framework */
+#define KTTDefaultMessageSlots	(KTTMaxAsyncRequests)
+
+
+/**
+@internalTechnology
+Number of plugin details in a plugin transfer block. 
+Used between server library and cds
+*/
+#define KNumPluginDetails 5
+
+
+/**
+@internalTechnology
+Class used for transfering fixed sized blocks of plugin information 
+between the Core Dump Server and its clients. This makes it easier
+accross the client/server interface.
+@see TPluginInfo
+*/
+class TPluginInfoBlock
+{
+public:
+
+	/**	
+	A simple array is used as the transfer block across the 
+	process boundary.
+	*/
+	TPluginInfo plugins[ KNumPluginDetails ];
+};
+
+
+/**
+Enumerations that identify the RProperty objects shared between various parts 
+of the core dump server system, plugins and clients.
+
+The properties are defined by the Core Dump Session at startup. 
+These properties have the uid of the Core Dump Server.
+
+@publishedPartner 
+@released
+@see CCoreDumpSession::ConstructL().
+*/
+enum TCrashProgress 
+	{ 
+	/** Current crash status. Updated by formatters during a crash. 
+	RProperty of type RProperty::EText. */
+	ECrashProgress, 
+
+	/** Cancels the generation of a crash when set to non-zero.
+	RProperty of type RProperty::EInt. */
+	ECancelCrash,
+
+	/** Number of crashes served by this session of the Core Dump Server.
+	RProperty of type RProperty::EInt. */
+	ECrashCount,
+	
+	/** Name of the Crash Media Dump created. Updated by the CDS/Formatter
+	RProperty of type RProperty::EText. */
+	ECrashMediaName
+	};
+
+
+
+/**
+@publishedPartner 
+@released
+
+Class for requesting lists from the Core Dump Server. 
+The requestor appends the results of each request to obtain an entire list.
+Uses "T<type>InfoBlock" classes to transfer data accross the process boundary.
+*/
+class TListRequest
+{
+public:
+
+	/** Type of data to supply for this request */
+	enum TListRequestType
+		{
+		/** This request is for the formatter plugin list */
+		EFormatterList,
+
+		/** This request is for the writer plugin list */
+		EWriterList,
+
+		/** This request is for the thread list */
+		EThreadList,
+
+		/** This request is for the process list */
+		EProcessList,
+
+		/** This request is for the executable list */
+		EExecutableList,
+		
+		/** This request is for the crashes in flash */
+		ECrashList,
+
+		/** 
+		@internalTechnology
+		Last marker 
+		*/
+		EUnknownRequest
+
+		};
+
+	/** Type of data to supply for this request */
+	TListRequestType	iListType;
+
+	/** Sub identifiers for the request. These are auxiliary ids that 
+	can be used to refine the request. */
+	TUint32				iSubId1;
+	TUint32				iSubId2;
+
+	/** Requestor sets iIndex. iIndex==0 means the supplier should refresh the 
+	list and supply from index 0. iIndex > 0 means supply element 
+	[iIndex-1] and onwards. Requestor should thus increase iIndex 
+	by how many elements were supplied on each call. */
+	TUint				iIndex;
+
+	/** Supplier writes iSupplied according to how many items 
+	it copied into the buffer on this call */
+	TUint				iSupplied;
+
+	/** Supplier writes iRemaining to indicate how many items it 
+	has yet to supply. */
+	TUint				iRemaining;
+
+	/** Number of bytes required to hold the resulting data */
+	TUint				iRequiredDescriptorSize;
+
+	/** 
+	Spare variables for future expansion.
+	@internalTechnology */
+	TUint32				iSpare0;
+	/** @internalTechnology */
+	TUint32				iSpare1;
+	/** @internalTechnology */
+	TUint32				iSpare2;
+	/** @internalTechnology */
+	TUint32				iSpare3;
+
+};
+
+/**
+@publishedPartner 
+@released
+
+Class for requesting change in configuration parameter from the CDS and loaded plugins. 
+*/
+class TConfigRequest
+{
+public:
+	/** Type of data to supply for this request */
+    COptionConfig::TParameterSource iSource;
+
+	/** Sub identifiers for the request. These are auxiliary ids that 
+	can be used to refine the request. */
+	TUint32				iIndex;
+	TUint32				iInstance;
+
+	/** 
+	Spare variables for future expansion.
+	@internalTechnology */
+	TUint32				iSpare0;
+	/** @internalTechnology */
+	TUint32				iSpare1;
+};
+
+#endif // CORE_DUMP_SERVER_API_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/interface/server/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/data/dexcformatter.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,54 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Registry file for the Core Dump D_EXC Formatter
+// ECOM RSS file for D_EXC Core dump formatter
+//
+
+
+
+/**
+ @file 
+*/
+
+#include "RegistryInfo.rh"
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+	{
+	// UID for the DLL
+	dll_uid = 0x102832c4;
+
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of formatter interface
+			interface_uid = 0x10282fe2;
+			implementations = 
+				{
+				// Info for CImplementation1
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102832c5;
+					version_no = 1;
+					display_name = "D_EXC Formatter plugin v1.0.0";
+					default_data = "D_EXC V1.0.0";
+					opaque_data = "cds dexc";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/data/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,30 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file bld.inf Build information file
+//
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+dexcformatter.iby         /epoc32/rom/include/dexcformatter.iby
+
+PRJ_MMPFILES
+dexcformatter.mmp
+
+PRJ_TESTMMPFILES
+../test/tdexcformatter.mmp
+
+PRJ_TESTEXPORTS
+../test/tdexcformatter.iby /epoc32/rom/include/tdexcformatter.iby
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/group/dexcformatter.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file dexcformatter.iby ROM build file for symbian elf formatter
+//
+
+#ifndef D_EXC_FORMATTER_IBY__
+#define D_EXC_FORMATTER_IBY__
+
+ECOM_PLUGIN(dexcformatter.dll,dexcformatter.rsc)
+
+#endif // D_EXC_FORMATTER_IBY__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/group/dexcformatter.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,57 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// D_EXC formatter MMP file
+// dexcformatter.dll A process dump formatter implemented as an ECOM plugin
+//
+
+
+
+/**
+ @file 
+*/
+
+TARGET      dexcformatter.dll
+TARGETTYPE  plugin
+UID         0x10009D8D 0x102832c4 //second uid=ecom uid, third UID d_exc_formatter
+
+VENDORID    0x70000001
+
+CAPABILITY 	PowerMgmt
+
+SOURCEPATH  ../src
+SOURCE      dexcformatter.cpp
+SOURCE		dexcproxy.cpp
+
+USERINCLUDE ../inc
+USERINCLUDE ../../test
+
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/drivers
+SYSTEMINCLUDE   /epoc32/include/tools/coredump
+
+//
+// ECOM plugin resource file
+//
+start resource ../data/dexcformatter.rss
+target dexcformatter.rsc
+end
+
+LIBRARY		ecom.lib
+LIBRARY		euser.lib
+LIBRARY     estor.lib
+LIBRARY     cdssupport.lib
+
+//MACRO CDSDEBUG
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/inc/dexcformatter.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,127 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Defines D_EXC formatter plugin class
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef D_EXC_FORMATTER_H
+#define D_EXC_FORMATTER_H
+
+#include <e32std.h>
+#include <e32property.h>
+#include <rm_debug_api.h> //registers info
+
+#include <formatterapi.h>
+#include <optionconfig.h>
+#include <crashdatasource.h>
+#include <crashdatasave.h>
+#include "tdexcformatter.h" //test friendship
+#include <coredumpserverapi.h> //property - UID
+
+
+
+const TUint32 KDEXCFormatterUid = { 0x102832C5 };
+
+const TInt KMaxLineLength = KMaxFullName + 32; //compatibility with legacy D_EXC implementation
+_LIT(KPluginDescription, "D_EXC formatter plugin description");
+
+class COptionConfig;
+class CThreadInfo;
+
+/**
+@internalTechnology 
+@released 
+DEXC formatter plugin is loaded by the core dump server and notified about the crash event.
+Then it dupms crash data in the same format as the legacy d_exc crash dump utility.
+@see CCrashDataSave
+*/
+class CDexcFormatter : public CCoreDumpFormatter
+{
+        static void CleanupThreadList(TAny *aArray);
+        static void CleanupCodeSegList(TAny *aArray);
+        friend void CDexcFormatterTest::TestSuiteL(TSuite aSuite) const; //test harness
+        enum { KBufSize = 1024 }; //mem read buf size
+        enum { KDexcFileNameLength = 26 }; //d_exc_<tid>.[stk|txt]
+
+	public:
+		static CDexcFormatter* NewL();
+		static CDexcFormatter* NewLC();
+        ~CDexcFormatter();
+
+	public:
+		virtual TInt GetNumberConfigParametersL( );
+		virtual COptionConfig * GetConfigParameterL( const TInt aIndex );
+		virtual void SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue );
+
+	    virtual void ConfigureDataSaveL(CCrashDataSave* aDataSave);
+	    virtual void ConfigureDataSourceL(CCrashDataSource* aDataSource);
+	    virtual void GetDescription(TDes& aPluginDescription);
+        virtual void CrashEventL(TCrashInfo* aCrashInfo);
+ 
+    private:
+        void ConstructL();
+        void DumpLogL(const CThreadInfo& aThread);
+        void DumpPanicInfoL(const TCrashInfo& aInfo);
+        void DumpExcInfoL(const TCrashInfo& aCrash);
+        void DumpRegistersL(const TUint64 aTid);
+        void DumpCodeSegsL(const TUint64 aPid) ;
+        void DumpStackL(const TUint64 aTid, const CThreadInfo& aInfo);
+        void UpdateCrashProgressL(const TDesC &aProgress) const;
+        TInt PickRegisters(const RRegisterList& aAllRegs, RRegisterList& aReqRegs,
+                           const TFunctionalityRegister* const aReqIds) const;
+        const CThreadInfo& GetCrashedThreadInfoLC(const TCrashInfo &aCrashInfo) const;
+
+        const TDesC& DumpFileNameLC(TUint64 aTid, const TDesC &aExtension);
+
+    private:
+        /** Buffer holding each dump line */
+	    TBuf8<KMaxLineLength> iLine;
+
+        /** reserved for the future */
+        TInt iSpare;
+
+        /** Pointer to writer plugin created and managed by core dump server, provides API to store the dump information*/
+        CCrashDataSave* iDataSave;
+
+        /** Pointer to data source object created and managed by core dump server, provides API to gather necessary info about the crash */ 
+        CCrashDataSource* iDataSource; 
+
+        /** Dump stack information flag, updated on parameter change */
+        TBool iDumpStack; 
+
+        /** Dump stack in ASCII format flag, updated on parameter change */
+        TBool iAsciiStack;
+
+        /** Available values of DEXC formatter plugin parameter index */
+		enum TDexcParams
+		    {
+            /** dump stack */
+            EDumpStack,
+            /** dump stack in ASCII */
+            EAsciiStack,
+            /** guard */
+            EDexcParamsLast
+            };
+
+        /** DEXC formatter configuration parameter list */
+		RConfigParameterList iConfigList;
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/inc/tdexcformatter.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,73 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef T_D_EXC_FORMATTER_H
+#define T_D_EXC_FORMATTER_H
+#include <e32std.h>
+#include <e32test.h>
+#include <crashdata.h>
+#include "testcrashdatasource.h"
+#include "testcrashdatasave.h"
+
+const TUid KDexcFormatterUid = { 0x102832c5 };
+class CDexcFormatter;
+
+const TUint MaxCrashDataSize = 4096;
+const TUint MaxPluginDescription = 63;
+
+_LIT(KTestTitle, "D_EXC_FORMATTER_TEST");
+_LIT(KTestName, "test suite: ");
+
+class CDexcFormatterTest : public CBase
+{
+public:
+        enum TSuite {
+                    ENone,
+                    EConfigData,
+                    EFindImplementation,
+                    EConfigParams,
+                    EGetDescription,
+                    EDumpLog,
+                    EDumpPanicInfo,
+                    EDumpExcInfo,
+                    EDumpRegisters,
+                    EDumpCodeSegs,
+                    EDumpStack,
+                    ECrash
+                    };
+
+        static CDexcFormatterTest * NewL(RTest &aTest);
+        static CDexcFormatterTest * NewLC(RTest &aTest);
+        void ConstructL();
+        CDexcFormatterTest(RTest &aTest);
+        ~CDexcFormatterTest();
+        void TestSuiteL(TSuite aSuite) const;
+private:
+        static void CleanupEComArray(TAny* aArray);
+        RTest &itest;
+        CDexcFormatter *formatter;
+        CTestCrashDataSource *server;
+        CTestDataSave *writer;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/src/dexcformatter.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,736 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "dexcformatter.h"
+//
+// there is a line limit but what if file name is longer?
+//
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CDexcFormatter* CDexcFormatter::NewL()
+{
+    LOG_MSG("->CDexcFormatter::NewL()\n");
+	CDexcFormatter* self = CDexcFormatter::NewLC();
+	CleanupStack::Pop(self);
+    return self;
+}
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CDexcFormatter* CDexcFormatter::NewLC()
+{
+    LOG_MSG("->CDexcFormatter::NewLC()\n");
+	CDexcFormatter* self = new(ELeave) CDexcFormatter();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+}
+
+/**
+2nd stage construction
+Reserves config parameter list, creates config parameter objects and sets them to default values.
+*/
+void CDexcFormatter::ConstructL()
+{
+    LOG_MSG("->CDexcFormatter::ConstructL()\n");
+    TInt err;
+	COptionConfig * config;
+
+	iConfigList.ReserveL( (TInt)EDexcParamsLast );
+
+	_LIT( KTrueFalseOpt, "True,False" );
+	_LIT( KTrueOpt, "True" );
+	_LIT( KFalseOpt, "False" );
+
+	_LIT( KDumpStackPrompt, "Dump stack memory?" );
+	config = COptionConfig::NewL(  (TInt)EDumpStack,
+									KDEXCFormatterUid,
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool, 
+									KDumpStackPrompt, 
+                                    1,
+									KTrueFalseOpt,
+									1,
+									KTrueOpt );
+
+	err = iConfigList.Append( config );
+
+    if(err != KErrNone)
+    {
+        delete config;
+	    LOG_MSG("CDexcFormatter::ConstructL - unable to append dump stack config option!\n" );
+        User::Leave(err);
+    }
+	iDumpStack = ETrue;
+
+	_LIT( KDumpAsciiPrompt, "Stack contents in ASCII?" );
+	config = COptionConfig::NewL(  (TInt)EAsciiStack,
+									KDEXCFormatterUid,
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool, 
+									KDumpAsciiPrompt, 
+                                    1,
+									KTrueFalseOpt,
+									0,
+									KFalseOpt );
+
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+	    LOG_MSG("CDexcFormatter::ConstructL - unable to append dump ascii config option!\n" );
+        User::Leave(err);
+    }
+	iAsciiStack = EFalse;
+}
+
+/**
+dtor frees config parameter list
+*/
+CDexcFormatter::~CDexcFormatter()
+{
+    LOG_MSG("->~CDexcFormatter()\n");
+    iConfigList.ResetAndDestroy();
+}
+
+/**
+   Sets pointer to the writer plugin.
+  Configures formatter's dump data save plugin.
+
+@param aDataSave pointer to writer plugin object.
+@leave KErrNoMemory if aDataSave is NULL 
+*/
+void CDexcFormatter::ConfigureDataSaveL(CCrashDataSave* aDataSave)
+{
+    LOG_MSG2("->ConfigureDataSaveL(%d)\n", aDataSave);
+    User::LeaveIfNull(aDataSave);
+    iDataSave = aDataSave;
+}
+
+/**
+   Sets pointer to the crash data server.
+  Configures formatter's crash data source plugin.
+
+@param aDataSource pointer to core dump server object.
+@leave KErrNoMemory if aDataSource is NULL 
+*/
+void CDexcFormatter::ConfigureDataSourceL(CCrashDataSource* aDataSource)
+{
+    LOG_MSG2("->ConfigureDataSourceL(%d)\n", aDataSource);
+    User::LeaveIfNull(aDataSource);
+    iDataSource = aDataSource;
+}
+
+/**
+   Returns a short formatter description.
+@param aPluginDescription Descriptor capable of storing a short plugin description. 
+*/
+void CDexcFormatter::GetDescription(TDes& aPluginDescription)
+{
+    LOG_MSG("->CDexcFormatter::GetDescription()\n");
+	aPluginDescription.Copy(KPluginDescription());
+}
+
+
+/**
+Called by CDS to ask for the configuration parameters that the writer needs (see Plugin Configuration) 
+@return actual number of implemented config parameters
+*/
+TInt CDexcFormatter::GetNumberConfigParametersL( )
+{
+	TInt count = iConfigList.Count();
+	LOG_MSG2("->CDexcFormatter::GetNumberConfigParametersL() : returns:%d\n", count );
+	return count;
+}
+
+
+/**
+Called by CDS to ask for configuration parameter prompt (see Plugin Configuration) 
+
+@param aIndex indicates which parameter to return
+@return pointer to COptionConfig object representing the requested config parameter. Caller doesn't take ownership of the object!
+@leave KErrBadHandle if index is out of bounds
+@see COptionConfig
+*/
+COptionConfig * CDexcFormatter::GetConfigParameterL( const TInt aIndex )
+{
+	// return the config identified by aIndex
+	if( ( aIndex < 0 ) || ( aIndex >= iConfigList.Count() ) )
+		{
+		User::Leave( KErrBadHandle );
+		}
+
+	return iConfigList[aIndex];
+}
+
+/**
+Change a configuration parameter.
+@param aIndex Index of parameter to change
+@param aValue Unused 
+@param aDescValue Path and filename to use
+@leave KErrBadHandle if index is out of bounds or one of the other system wide error codes
+*/
+void CDexcFormatter::SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue )
+{
+	if( ( aIndex < 0 ) || ( aIndex >= iConfigList.Count() ) )
+	{
+		User::Leave( KErrBadHandle );
+	}
+
+	COptionConfig & config = *(iConfigList[aIndex]);
+
+	if( ( aIndex != (TInt)EDumpStack ) && ( aIndex != (TInt)EAsciiStack ) )
+	{
+		LOG_MSG( "  Leaving : aIndex != EDumpStack && aIndex != EAsciiStack" );
+		User::Leave( KErrArgument );
+	}
+
+	TBool setTo = ETrue;
+
+	if( aDescValue.Length() )
+	{
+		if( 0 == aDescValue.CompareF(_L("True") ) )
+		{
+			setTo = ETrue;
+			//LOG_MSG( " 0 == aDescValue.CompareF(_L(True" );
+		}
+		else if( 0 == aDescValue.CompareF(_L("False") ) )
+		{
+			//LOG_MSG( " 0 == aDescValue.CompareF(_L(False" );
+			setTo = EFalse;
+		}
+		else
+		{
+			LOG_MSG( " ERROR !* : CDexcFormatter::SetConfigParameterL : Invalid string for boolean" );
+			User::Leave( KErrArgument );
+		}
+	}
+	else
+	{
+		if( 1 == aValue )
+		{
+			//LOG_MSG( " 1 == aValue" );
+			setTo = ETrue;
+		}
+		else if ( 0 == aValue )
+		{
+			//LOG_MSG( " 0 == aValue " );
+			setTo = EFalse;
+		}
+		else
+		{
+			LOG_MSG( "  Value of %d not valid. Must be 0 or 1\n" );
+			User::Leave( KErrArgument );
+		}
+	}
+
+
+	if( setTo )
+	{
+		config.Value( 1 );
+		config.ValueL( _L("True") );
+	}
+	else
+	{
+		config.Value( 0 );
+		config.ValueL( _L("False") );
+	}
+
+	if( aIndex == (TInt)EDumpStack )
+	{
+		iDumpStack = config.ValueAsBool();
+	}
+	else if( aIndex == (TInt)EAsciiStack )
+	{
+		iAsciiStack = config.ValueAsBool();
+	}
+}
+
+/**
+   Dumps basic information about the thread that crashed.
+@param aThread TThreadInfo data structure holding information about the crashed thread.
+@leave err one of the system wide error codes
+*/
+void CDexcFormatter::DumpLogL(const CThreadInfo& aThread)
+{
+    LOG_MSG("->DumpLogL()\n");
+	iLine.Fill('-', 76);
+	iDataSave->WriteL(iLine);
+
+	_LIT8(KHdr, "\r\nEKA2 USER CRASH LOG\r\n");
+	iLine = KHdr;
+	iDataSave->WriteL(iLine);
+
+    RBuf8 filename;
+    filename.CreateL(KMaxFileName);
+    filename.Copy(aThread.Name());
+	_LIT8(KName, "Thread Name: %S\r\n");
+	iLine.Format(KName, &filename);
+    filename.Close();
+	iDataSave->WriteL(iLine);
+
+	_LIT8(KFmtTid, "Thread ID: %u\r\n");
+	iLine.Format(KFmtTid, aThread.Id());
+	iDataSave->WriteL(iLine);
+	
+	_LIT8(KFmtStack, "User Stack %08X-%08X\r\n");
+	iLine.Format(KFmtStack, aThread.UsrStackAddr(), aThread.UsrStackAddr() + aThread.UsrStackSize());
+	iDataSave->WriteL(iLine);
+}
+/**
+   Dumps panic details.
+@param aCrash TCrashInfo data structure holding information about the crash.
+@leave err one of the system wide error codes
+*/
+void CDexcFormatter::DumpPanicInfoL(const TCrashInfo& aCrash)
+{
+    LOG_MSG("->DumpPanicInfoL()\n");
+	//_LIT8(KFmtPanic, "\r\nPanic: %S-%d\r\n");
+	_LIT8(KFmtPanic, "Panic: %S-%d\r\n");
+    RBuf8 buf;
+    buf.CreateL(aCrash.iCategory.Length());
+    buf.Copy(aCrash.iCategory);
+    iLine.Format(KFmtPanic, &buf, aCrash.iReason);
+    buf.Close();
+	iDataSave->WriteL(iLine);
+}
+
+/**
+   Picks registers from available register list and puts them in the required register list.
+   Order of the output list is determined by the order of aReqIds.
+
+@param aAllRegs input RRegisterList of all available registers.
+@param aReqRegs output RRegisterList for the required registers.
+@param aReqIds EDF_Register_Last terminated array of IDs of required registers.
+@return KErrNone if successful, otherwise one of the other system-wide error codes.
+*/
+TInt CDexcFormatter::PickRegisters(const RRegisterList& aAllRegs, RRegisterList& aReqRegs,
+                                   const TFunctionalityRegister* const aReqIds) const
+{
+    LOG_MSG("->CDexcFormatter::PickRegistersL()\n");
+    if(aReqIds == NULL)
+    {
+        return KErrArgument;
+    }
+        
+    TInt regsCount = aAllRegs.Count();
+    const TFunctionalityRegister* reg;
+    for(reg = aReqIds; *reg != ERegisterLast; ++reg)
+    {
+        for(TInt i = 0; i < regsCount; ++i)
+        {
+            if(aAllRegs[i].GetId() == *reg)
+            {
+                aReqRegs.Append(aAllRegs[i]);
+                break;
+            }
+        }
+    }
+
+    if(aReqRegs.Count() != (reg - aReqIds)) 
+    {
+	    LOG_MSG3("CDExcFormatter::PickRegisters - found only %d out of %d registers!\n", aReqRegs.Count(), (reg - aReqIds));
+        return KErrNotFound;
+    }
+    return KErrNone;
+}
+
+/**
+   Dumps exception details. Valid on ARM platform only!
+
+@param aCrash TCrashInfo data structure holding information about the crash event.
+@leave err one of the system wide error codes
+*/
+void CDexcFormatter::DumpExcInfoL(const TCrashInfo& aCrash)
+{
+    LOG_MSG("-> CDexcFormatter::DumpExcInfoL()\n");
+
+	_LIT8(KHdr, "\r\nUNHANDLED EXCEPTION:\r\n");
+	iLine = KHdr;
+	iDataSave->WriteL(iLine);
+
+	_LIT8(KFmt1, "code=%d PC=%08x FAR=%08x FSR=%08x\r\n");
+	iLine.Format(KFmt1, aCrash.iContext.iExcCode,
+                        aCrash.iContext.iR15,
+                        aCrash.iContext.iFaultAddress,
+                        aCrash.iContext.iFaultStatus);   
+	iDataSave->WriteL(iLine);
+
+	_LIT8(KFmt2, "R13svc=%08x R14svc=%08x SPSRsvc=%08x\r\n");
+	iLine.Format(KFmt2, aCrash.iContext.iR13Svc,
+                        aCrash.iContext.iR14Svc,
+                        aCrash.iContext.iSpsrSvc);
+	iDataSave->WriteL(iLine);
+
+    LOG_MSG("<- CDexcFormatter::DumpExcInfoL()\n");
+} 
+
+/**
+   Dumps register values of the crashed thread. Valid on ARM platform only!
+@param aTid ID of the crashed thread
+@leave err one of the system wide error codes
+*/
+void CDexcFormatter::DumpRegistersL(const TUint64 aTid)
+{
+    LOG_MSG2("-> CDexcFormatter::DumpRegistersL(%Lu)\n", aTid);
+
+    TFunctionalityRegister ids[] = {ERegisterR0,
+                                    ERegisterR1,
+                                    ERegisterR2,
+                                    ERegisterR3,
+                                    ERegisterR4,
+                                    ERegisterR5,
+                                    ERegisterR6,
+                                    ERegisterR7,
+                                    ERegisterR8,
+                                    ERegisterR9,
+                                    ERegisterR10,
+                                    ERegisterR11,
+                                    ERegisterR12,
+                                    ERegisterR13,
+                                    ERegisterR14,
+                                    ERegisterR15,
+                                    ERegisterCpsr,
+                                    ERegisterLast};
+
+    RRegisterList allRegs;
+    CleanupClosePushL(allRegs);
+    RRegisterList reqRegs;
+    CleanupClosePushL(reqRegs);
+
+	_LIT8(KHdr, "\r\nUSER REGISTERS:\r\n");
+	iLine = KHdr;
+	iDataSave->WriteL(iLine);
+
+    LOG_MSG("CDexcFormatter::DumpRegistersL - getting list of avaliable registers\n");
+    iDataSource->GetRegisterListL(allRegs);
+
+    LOG_MSG("CDexcFormatter::DumpRegistersL - picking required registers\n");
+    User::LeaveIfError(PickRegisters(allRegs, reqRegs, ids)); 
+
+    LOG_MSG("CDexcFormatter::DumpRegistersL - reading data of required registers\n");
+    iDataSource->ReadRegistersL(aTid, reqRegs); 
+
+    //display zeros when register is not available
+    //use AppendFormat to get rid of this macro
+#define REG_VAL(i) reqRegs[i].iAvailable ? reqRegs[i].GetContent32() : 0
+	_LIT8(KFmtCpsr, "CPSR=%08x\r\n");
+    TInt regsCount = reqRegs.Count();
+	iLine.Format(KFmtCpsr, REG_VAL(regsCount - 1)); 
+	iDataSave->WriteL(iLine);
+
+    regsCount -= 4;
+	for(TInt i = 0; i < regsCount; i+=4)
+	{
+		_LIT8(KFmtReg, "r%02d=%08x %08x %08x %08x\r\n");
+        iLine.Format(KFmtReg, i, REG_VAL(i), REG_VAL(i+1), REG_VAL(i+2), REG_VAL(i+3));
+		iDataSave->WriteL(iLine);
+	}
+#undef REG_VAL
+    CleanupStack::PopAndDestroy(2, &allRegs);
+}
+
+/**
+Cleanup item implementation for code segment list in DumpCodeSegsL() method.
+@param aArray pointer to the list that is supposed to be freed
+*/
+void CDexcFormatter::CleanupCodeSegList(TAny *aArray)
+{
+    LOG_MSG("->CDexcFormatter::CleanupCodeSegList()\n");
+	RCodeSegPointerList *codeSegList = static_cast<RCodeSegPointerList*> (aArray);
+    codeSegList->ResetAndDestroy();
+    codeSegList->Close();
+}
+
+/**
+   Dumps code segments of the process that owned the crashed thread.
+@param aTid ID of the crashed thread
+@leave err one of the system wide error codes
+*/
+void CDexcFormatter::DumpCodeSegsL(const TUint64 aTid)
+{
+    LOG_MSG2("-> CDexcFormatter::DumpCodeSegsL(%Lu)\n", aTid);
+	_LIT8(KHdr, "\r\nCODE SEGMENTS:\r\n");
+	_LIT8(KFmtSegs, "%08X-%08X %S\r\n");
+
+	iLine = KHdr;
+	iDataSave->WriteL(iLine);
+
+    RCodeSegPointerList segs;
+    TCleanupItem cleanup(CDexcFormatter::CleanupCodeSegList, (TAny*)&segs);
+    CleanupStack::PushL(cleanup);
+
+    //User::LeaveIfError(iDataSource->GetCodeSegments(aPid, segs));
+    LOG_MSG("CDexcFormatter::DumpCodeSegsL() - getting code segments data\n");
+    iDataSource->GetCodeSegmentsL(aTid, segs);
+
+    RBuf8 filename;
+    CleanupClosePushL(filename);
+    filename.CreateL(KMaxFileName);
+	for (TInt i=0; i < segs.Count(); i++)
+	{
+        filename.Copy(segs[i]->iName); //conversion
+        iLine.Format(KFmtSegs, segs[i]->iCodeRunAddr, segs[i]->iCodeRunAddr + segs[i]->iCodeSize, &filename);
+        iDataSave->WriteL(iLine);
+	}
+    LOG_MSG2("CDexcFormatter::DumpCodeSegsL - code segments count:%d\n", segs.Count());
+    CleanupStack::PopAndDestroy(2);
+
+    //compatibility with legacy D_EXC implementation
+    iLine.Zero();
+    iLine.Append(_L8("\r\n"));
+    iDataSave->WriteL(iLine);
+}
+
+/**
+   Dumps thread stack information and content. 
+@param aTid ID of the crashed thread
+@param aInfo CThreadInfo data structure holding information about the crashed thread
+@leave err one of the system wide error codes
+*/
+void CDexcFormatter::DumpStackL(const TUint64 aTid, const CThreadInfo& aInfo)
+{
+    LOG_MSG2("-> CDexcFormatter::DumpStackL(%Lu)\n", aTid);
+
+    TInt length = KBufSize < aInfo.UsrStackSize() ? KBufSize : aInfo.UsrStackSize(); 
+
+	RBuf8 buf;
+    buf.CreateL(length);
+    CleanupClosePushL(buf);
+
+	TUint top = aInfo.UsrStackAddr() + aInfo.UsrStackSize();
+	for(TUint base = aInfo.UsrStackAddr(); base < top; base += KBufSize)
+	{
+        LOG_MSG3("CDexcFormatter::DumpStackL - reading %d bytes of memory from:0x%X\n", length, base);
+		iDataSource->ReadMemoryL(aTid, base, length, buf); 
+
+        //6571de54: 07 00 00 10 14 04 17 f8 00 00 00 00 d4 4e 40 00 .............N@.
+        //<-addr-------------------------memory----------------------representation>
+		if(iAsciiStack)
+		{
+			TBuf8<80> out; //74 used
+			TBuf8<20> ascii; //16 usd
+			TInt len = buf.Length();
+            for(TUint offset = 0; offset < len; offset += 16) 
+			{
+				out.Zero();
+				ascii.Zero();
+				out.AppendNumFixedWidth(base + offset, EHex, 8); //addr
+				out.Append(_L(": "));
+
+				for(TUint byte = 0; byte < 16; ++byte)
+				{
+					TUint8 c = *(buf.Ptr() + offset + byte);
+					out.AppendNumFixedWidth(c, EHex, 2); //each memory byte
+					out.Append(' ');
+
+					if(c < 0x20 || c >= 0x7f) //something writable
+						c = 0x2e; //.
+					ascii.Append(TChar(c)); //byte representation
+				}
+				out.Append(ascii);
+                out.Append(_L("\r\n"));
+				iDataSave->WriteL(out);
+			} 
+		}
+		else //binary dump
+			iDataSave->WriteL(buf);
+	}
+    CleanupStack::PopAndDestroy(&buf); 
+}
+
+/**
+    Retrives the 'cancel crash' property value and checks if required to abort the crash dump. Updates 'crash progress' property. 
+
+@param aProgress descriptor with the crash progress value.
+@leave KErrAbort if crash cancel property has been set
+ */
+void CDexcFormatter::UpdateCrashProgressL(const TDesC &aProgress) const
+    {
+    LOG_MSG("->CDexcFormatter::UpdateCrashProgress()\n");
+    TInt cancelCrash = EFalse;
+    TInt err = RProperty::Get(KCoreDumpServUid, ECancelCrash, cancelCrash);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CDexcFormatter::UpdateCrashProgress - unable to retrive 'cancel crash' value! err:%d\n", err);
+        }
+
+    if(cancelCrash)
+        {
+        LOG_MSG("CDexcFormatter::UpdateCrashProgress - aborting dump in progress\n");
+        User::Leave(KErrAbort);
+        }
+
+    err = RProperty::Set(KCoreDumpServUid, ECrashProgress, aProgress);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CDexcFormatter::UpdateCrashProgress - unable to retrive 'crash progress' value! err:%d\n", err);
+        }
+#ifdef DEBUG 
+    User::After(1000000);
+#endif
+  }
+
+/**
+    Gets information about the threads of the crashed process and finds the one that caused the crash. 
+@return reference to the CThreadInfo data structure holding information about the crashed thread
+@leave err one of the system wide error codes
+*/
+const CThreadInfo& CDexcFormatter::GetCrashedThreadInfoLC(const TCrashInfo &aCrashInfo) const
+    {
+    LOG_MSG("->CDexcFormatter::GetCrashedThreadInfoLC()\n");
+
+	RThreadPointerList *threadList = new(ELeave)RThreadPointerList;
+    TCleanupItem cleanup(CDexcFormatter::CleanupThreadList, (TAny*)threadList);
+    CleanupStack::PushL(cleanup);
+
+	CThreadInfo *threadInfo = NULL;
+	TUint totalThreadListDescSize;
+	iDataSource->GetThreadListL((TUint64)aCrashInfo.iPid, *threadList, totalThreadListDescSize); //for crashed process
+
+	for(TInt i = 0; i < threadList->Count(); i++)
+		{
+		if(aCrashInfo.iTid == (*threadList)[i]->Id())
+			{
+			threadInfo = (*threadList)[i]; //crashed thread
+			break;
+			}
+		}
+
+	if(NULL == threadInfo)
+		{
+        LOG_MSG("CDexcFormatter::CrashEventL - crashed thread not found!\n");
+        User::Leave( KErrNotFound ); 
+		}
+
+    return *threadInfo;
+    }
+
+/**
+    Prepares the name of the dump file. Checks DataSave filename option, if it is provided by the user
+    it appends crashed thread ID and extension, if not it uses default name appended with thread ID and extension. 
+@param aTid ID of the crashed thread
+@param aExtension descriptor holding the file extension
+@return descriptor holding the final dump file name, caller is responsible to pop it from the cleanup stack
+@leave err one of the system wide error codes
+ */
+const TDesC& CDexcFormatter::DumpFileNameLC(TUint64 aTid, const TDesC &aExtension)
+{
+    COptionConfig *option = iDataSave->GetConfigParameterL(CCrashDataSave::ECoreFilePath);
+	const TDesC &userFileName = option->ValueAsDesc();
+	HBufC *filename = HBufC::NewLC(userFileName.Length() + KDexcFileNameLength);
+    if(userFileName.Length() > 0)
+        {
+	    *filename = userFileName;
+        _LIT(KTidFormat, "%Lu");
+        filename->Des().AppendFormat(KTidFormat, aTid);
+        }
+    else
+        {
+        _LIT(KTxtFileFormat, "c:\\d_exc_%Lu");
+        filename->Des().Format(KTxtFileFormat, aTid);
+        }
+    filename->Des().Append(aExtension);
+    return *filename;
+}
+
+
+/**
+   Main formatter method. Handles crash event notification and drives dump process.
+
+@param aCrashInfo pointer to the TCrashInfo data structure holding information about the crash. 
+@leave err one of the system wide error codes
+*/
+void CDexcFormatter::CrashEventL(TCrashInfo *aCrashInfo)
+{
+    LOG_MSG("-> CrashEventL()\n");
+
+    User::LeaveIfNull(aCrashInfo);
+    LOG_MSG("CDexcFormatter::CrashEvenL - crash info is sane\n");
+    User::LeaveIfNull(iDataSource);
+    LOG_MSG("CDexcFormatter::CrashEvenL - data source is sane\n");
+    User::LeaveIfNull(iDataSave);
+    LOG_MSG("CDexcFormatter::CrashEvenL - data save is sane\n");
+
+    _LIT(KProgressStart, "crash dump started");
+    UpdateCrashProgressL(KProgressStart);
+
+    const CThreadInfo &threadInfo = GetCrashedThreadInfoLC(*aCrashInfo);
+    _LIT(KProgressText, "dumping text file");
+    UpdateCrashProgressL(KProgressText);
+
+    LOG_MSG("CDexcFormatter::CrashEventL - opening text file\n");
+    _LIT(KTxtFileExt, ".txt");
+    iDataSave->OpenL(DumpFileNameLC(aCrashInfo->iTid, KTxtFileExt));
+    CleanupStack::PopAndDestroy(); //filename
+    DumpLogL(threadInfo);
+
+    if(aCrashInfo->iType == TCrashInfo::ECrashKill)
+    {
+        LOG_MSG("CDexcFormatter::CrashEventL - dumping panic info\n");
+        DumpPanicInfoL(*aCrashInfo);
+    }
+#ifdef __MARM__
+    else //ECrashException
+    {
+        LOG_MSG("CDexcFormatter::CrashEventL - dumping exeception info\n");
+        DumpExcInfoL(*aCrashInfo);
+    }
+    LOG_MSG("CDexcFormatter::CrashEventL - dumping registers info\n");
+    DumpRegistersL(aCrashInfo->iTid);
+#endif
+    LOG_MSG("CDexcFormatter::CrashEventL - dumping code segments info\n");
+    DumpCodeSegsL(aCrashInfo->iTid);
+
+    LOG_MSG("CDexcFormatter::CrashEventL - closing text file\n");
+    iDataSave->CloseL();
+
+    if(iDumpStack)
+    {
+        _LIT(KProgressStack, "dumping stack file");
+        UpdateCrashProgressL(KProgressStack);
+        LOG_MSG("CDexcFormatter::CrashEventL - opening stack file\n");
+        _LIT(KStkFileExt, ".stk");
+        iDataSave->OpenL(DumpFileNameLC(aCrashInfo->iTid, KStkFileExt));
+        CleanupStack::PopAndDestroy();//filename
+        LOG_MSG("CDexcFormatter::CrashEventL - dumping stack\n");
+        DumpStackL(aCrashInfo->iTid, threadInfo);
+        LOG_MSG("CDexcFormatter::CrashEventL - closing stack file\n");
+        iDataSave->CloseL();
+    }
+    _LIT(KProgressCompleted, "crash dump completed");
+    UpdateCrashProgressL(KProgressCompleted);
+    CleanupStack::PopAndDestroy(); //GetCrashedThreadInfoLC()::threadList , results in a call to CleanupThreadList 
+    LOG_MSG("CDexcFormatter::CrashEventL - crash finished\n");
+}
+
+/**
+Cleanup item implementation for thread list in CrashEventL() method.
+@param aArray pointer to the list that is supposed to be freed
+*/
+void CDexcFormatter::CleanupThreadList(TAny *aArray)
+{
+    LOG_MSG("->CDexcFormatter::CleanupThreadList()\n");
+	RThreadPointerList *threadList = static_cast<RThreadPointerList*> (aArray);
+    threadList->ResetAndDestroy();
+    threadList->Close();
+    delete threadList;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/src/dexcproxy.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,30 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <implementationproxy.h>
+
+#include "dexcformatter.h"
+
+// ECom boiler template code
+const TImplementationProxy ImplementationTable[] =
+{
+	IMPLEMENTATION_PROXY_ENTRY(0x102832c5, CDexcFormatter::NewL),
+};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+	return ImplementationTable;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/src/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,12 @@
+Directory for:
+  coredump\plugins\formatters\d_exc\src
+
+All the source, including subdirectories, to implement the D_EXC formatter
+Files here are not visible to others. They are just implementation.
+
+Implements the ECOM interface in coredump\interface\formatter.
+
+Uses the data source interface in coredump\interface\data_source.
+
+Uses the data save interface in coredump\interface\writer.
+  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/test/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+PRJ_PLATFORMS
+ARMV5
+
+
+prj_testmmpfiles
+tdexcformatter.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/test/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/test/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,5 @@
+Directory for:
+  coredump\plugins\formatters\d_exc\
+test files
+
+The tests at this level should be unit tests
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/test/tdexcformatter.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,522 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32std.h>
+#include <e32base.h>
+#include "tdexcformatter.h"
+#include "dexcformatter.h"
+
+CDexcFormatterTest * CDexcFormatterTest::NewL(RTest &itest)
+{
+    CDexcFormatterTest *self = CDexcFormatterTest::NewLC(itest);
+    CleanupStack::Pop();
+    return self;
+}
+
+CDexcFormatterTest * CDexcFormatterTest::NewLC(RTest &itest)
+{
+    CDexcFormatterTest *self = new(ELeave) CDexcFormatterTest(itest);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+}
+
+void CDexcFormatterTest::ConstructL()
+{
+    server = new(ELeave) CTestCrashDataSource;
+    formatter = CDexcFormatter::NewL();
+    writer = CTestDataSave::NewL();
+    formatter->ConfigureDataSourceL(server);
+    formatter->ConfigureDataSaveL(writer);
+}
+
+CDexcFormatterTest::CDexcFormatterTest(RTest &aTest) : itest(aTest) { }
+
+CDexcFormatterTest::~CDexcFormatterTest()
+{
+    delete server;
+    delete writer;
+    delete formatter;
+}
+
+void CDexcFormatterTest::CleanupEComArray(TAny* aArray)
+{
+	(static_cast<RImplInfoPtrArray*> (aArray))->ResetAndDestroy();
+    REComSession::FinalClose();
+}
+
+void CDexcFormatterTest::TestSuiteL(TSuite aSuite) const
+{
+    RDebug::Print(_L("-> TestSuite(%d)\n"), aSuite);
+    TInt err;
+    TBuf<23> name(KTestName); 
+    name.AppendNum(aSuite);
+    itest.Next(name);
+
+    switch(aSuite)
+    {
+        case EConfigData:
+        {
+            RDebug::Print(_L("EConfigData starting...\n"));
+            TRAP(err, formatter->ConfigureDataSourceL(server));
+            itest(err == KErrNone);
+            itest(server == formatter->iDataSource);
+
+            TRAP(err, formatter->ConfigureDataSaveL(writer));
+            itest(err == KErrNone);
+            itest(writer == formatter->iDataSave);
+
+            TRAP(err, formatter->ConfigureDataSourceL(NULL)); 
+            itest(err == KErrNoMemory);
+
+            TRAP(err, formatter->ConfigureDataSaveL(NULL));
+            itest(err == KErrNoMemory);
+            RDebug::Print(_L("EConfigData passed!\n"));
+            break;
+        }
+
+        case EFindImplementation:
+        {
+		
+            RDebug::Print(_L("EFindImplementation starting...\n"));
+            RImplInfoPtrArray infoArray;
+            TCleanupItem cleanup(CDexcFormatterTest::CleanupEComArray, (TAny*)&infoArray);
+            CleanupStack::PushL(cleanup);
+            
+            TRAPD(err, CDexcFormatter::ListAllImplementationsL(infoArray));
+            itest(err == KErrNone);
+
+			CCoreDumpFormatter* findImpFormatter = 0;            
+            RBuf description;
+            description.CreateL(MaxPluginDescription);
+            CleanupClosePushL(description);
+
+            err = KErrNotFound;
+            for (TInt i = 0; i < infoArray.Count(); i++)
+            {
+                TUid uid = infoArray[i]->ImplementationUid();
+                findImpFormatter  = CCoreDumpFormatter::NewL(uid);
+				findImpFormatter->GetDescription(description);
+                delete findImpFormatter;
+                RDebug::Print(_L("found plugin[%d]: (%S)\n"), i, &description);
+                if(description == KPluginDescription())
+                {
+                    itest(uid == KDexcFormatterUid);
+                    err = KErrNone;
+                    break;
+                }
+                description.Zero();
+            }
+            CleanupStack::PopAndDestroy();
+            itest(err == KErrNone);
+            CleanupStack::PopAndDestroy(); // infoArray, results in a call to CleanupEComArray
+            break;
+
+        }
+
+        case EConfigParams:
+        {
+			RDebug::Print(_L("EConfigParams starting\n"));
+
+			_LIT( KTrueFalseOpt, "True,False" );
+			_LIT( KFalseOpt, "False" );
+			_LIT( KTrueOpt, "True" );
+
+            TInt err;
+            COptionConfig * param = NULL;
+		    TInt paramsCount = formatter->GetNumberConfigParametersL(); //it should be non leaving call
+            itest(paramsCount == formatter->iConfigList.Count());
+
+            TRAP(err, param = formatter->GetConfigParameterL(0));
+            itest(param->Index() == CDexcFormatter::EDumpStack);
+			itest(param->Uid() == KDEXCFormatterUid );
+            itest(param->Source() == COptionConfig::EFormatterPlugin);
+            itest(param->Type() == COptionConfig::ETBool);
+            itest(param->Options() == KTrueFalseOpt);
+            itest(param->ValueAsBool() == 1);
+			param = NULL;
+
+            TRAP(err, param = formatter->GetConfigParameterL(1));
+            itest(param->Index() == CDexcFormatter::EAsciiStack);
+			itest(param->Uid() == KDEXCFormatterUid );
+            itest(param->Source() == COptionConfig::EFormatterPlugin);
+            itest(param->Type() == COptionConfig::ETBool);
+            itest(param->Options() == KTrueFalseOpt);
+            itest(param->ValueAsBool() == 0);
+			param = NULL;
+
+			RDebug::Printf("->TRAP(err, param = formatter->GetConfigParameterL(paramsCount))\n");
+            TRAP(err, param = formatter->GetConfigParameterL(paramsCount));
+            itest(err == KErrBadHandle);
+			param = NULL;
+
+			RDebug::Printf("formatter->SetConfigParameterL( 0, (TInt)EFalse, KFalseOpt );\n");
+		    TRAP(err, formatter->SetConfigParameterL( 0, (TInt)EFalse, KFalseOpt ));
+			itest(err == KErrNone);
+			itest(formatter->iConfigList[0]->ValueAsBool() == EFalse);
+			TRAP(err, param = formatter->GetConfigParameterL(0));
+            itest(formatter->iConfigList[0]->ValueAsBool() == EFalse);
+            itest(param->ValueAsDesc() == KFalseOpt);
+
+			RDebug::Printf("formatter->SetConfigParameterL( 0, (TInt)ETrue, KTrueOpt );\n");
+		    TRAP(err, formatter->SetConfigParameterL( 0, (TInt)ETrue, KNullDesC ));
+			itest(err == KErrNone);
+			TRAP(err, param = formatter->GetConfigParameterL(0));
+			itest(formatter->iConfigList[0]->ValueAsBool());
+            itest(param->ValueAsDesc() == KTrueOpt);
+            
+			RDebug::Print(_L("EConfigParams finished\n"));
+
+            break;
+        }
+
+        case EDumpLog:
+        {           
+			RDebug::Print(_L("EDumpLog starting.... \n"));
+            //            0123456789012345678901234567890123456789012345678901234567890123456789012345
+            _LIT8(KLine, "----------------------------------------------------------------------------");
+            //                  0 12345678901234567890 1 23456789012345   6 78901234567890 1 2345678901234?
+            _LIT8(KLogDump, "%S\r\nEKA2 USER CRASH LOG\r\nThread Name: %S\r\nThread ID: %u\r\nUser Stack %08X-%08X\r\n");
+            TBuf8<65+76+KMaxName+11+16> reference; //line, thread name, id and 2x 8-digits
+
+            //add newLC
+            CThreadInfo *thread = CThreadInfo::NewL(KCrashTid,
+                                                    KCrashThreadName,
+                                                    KCrashPid,
+                                                    KCrashThreadPriority,
+                                                    KCrashSvcStackPtr,
+                                                    KCrashSvcStackAddr,
+                                                    KCrashSvcStackSize,
+                                                    KCrashUsrStackAddr,
+                                                    KCrashUsrStackSize);
+            
+			RDebug::Print(_L("  -> writer->OpenL(_L(\"\"), handle)\n"));
+            writer->OpenL(_L("")); //clear writer buffer
+            formatter->DumpLogL(*thread);
+            delete thread;
+            itest(writer->iData != KLogDump());
+            reference.Format(KLogDump, &KLine, &KCrashThreadName8, KCrashTid, KCrashUsrStackAddr, KCrashUsrStackAddr + KCrashUsrStackSize);
+            itest(writer->iData == reference);
+			RDebug::Print(_L("EDumpLog finished\n"));
+            break;
+        }
+
+        case EDumpPanicInfo:
+        {
+			RDebug::Print(_L("EDumpPanicInfo starting.... \n"));
+            //                 0123456  7 8 9 0
+			_LIT8(KPanicDump, "Panic: %S-%d\r\n");
+            RBuf8 reference; 
+            reference.CreateL(KPanicDump().Length() + 11 + KMaxExitCategoryName);
+            CleanupClosePushL(reference);
+
+            TCrashInfo crash;
+            crash.iReason = KCrashReason;
+            crash.iCategory = KCrashCategory;
+
+            writer->OpenL(_L("")); //clear writer buffer
+            formatter->DumpPanicInfoL(crash);
+            itest(writer->iData != KPanicDump());
+
+    		reference.Format(KPanicDump, &KCrashCategory8, KCrashReason);
+
+            itest(writer->iData == reference);
+
+            CleanupStack::PopAndDestroy(); //reference
+			RDebug::Print(_L("EDumpPanicInfo finished\n"));
+            break;
+        }
+
+        case EDumpExcInfo:
+        {
+			RDebug::Print(_L("EDumpExcInfo starting.... \n"));
+
+            _LIT8(KExcDump, "\r\nUNHANDLED EXCEPTION:\r\ncode=%d PC=%08x FAR=%08x FSR=%08x\r\nR13svc=%08x R14svc=%08x SPSRsvc=%08x\r\n");
+            //     012345 6 7890123456789012345678901234567890123 4 5
+            RBuf8 reference;
+            reference.CreateL(KExcDump().Length() + 11 + 6*4);
+            CleanupClosePushL(reference);
+
+            TCrashInfo crash;
+			crash.iType = TCrashInfo::ECrashException;
+			crash.iContext.iExcCode = KCrashExcCode;
+
+            crash.iContext.iFaultAddress = KCrashFaultAddress;
+            crash.iContext.iFaultStatus = KCrashFaultStatus;
+
+			crash.iContext.iR15 = KRegValue32 + KCrashTid;
+			crash.iContext.iR13Svc = crash.iContext.iR15 + 1;
+			crash.iContext.iR14Svc = crash.iContext.iR15 + 2;
+			crash.iContext.iSpsrSvc = crash.iContext.iR15 + 3;
+
+            writer->Open(_L("")); //clear writer buffer
+            formatter->DumpExcInfoL(crash);
+
+			RDebug::Print( _L("-> itest(writer->iData != KExcDump())\n") );
+            itest(writer->iData != KExcDump());
+
+            TInt32 code = KCrashExcCode;
+            TInt32 pc = KRegValue32 + KCrashTid; //index of r15
+            TInt32 far = KCrashFaultAddress; 
+            TInt32 fsr = KCrashFaultStatus;
+            TInt32 r13svc = KRegValue32 + KCrashTid + 1; //index of r13svc
+            TInt32 r14svc = KRegValue32 + KCrashTid + 2; //index of r14svc
+            TInt32 spsr = KRegValue32 + KCrashTid + 3; //index of spsr 
+
+            reference.Format(KExcDump, code, pc, far, fsr, r13svc, r14svc, spsr);
+
+			/*
+			RBuf8 referencePrint;
+		    referencePrint.CreateL(256);
+			referencePrint.Copy( reference );
+			char *tonp = (char*) referencePrint.PtrZ();
+			LOG_MSG2("  KExcDump=%s\n", tonp);
+			referencePrint.Close();
+			writer->Print();
+			*/
+			RDebug::Print( _L("-> itest(writer->iData == reference)\n") );
+			itest(writer->iData == reference);
+
+            CleanupStack::PopAndDestroy(); //reference
+			RDebug::Print(_L("EDumpExcInfo finished\n"));
+
+            break;
+        }
+
+        case EDumpRegisters:
+        {
+			RDebug::Print(_L("EDumpRegisters starting.... \n"));
+
+            _LIT8(KCpsrDump, "\r\nUSER REGISTERS:\r\nCPSR=%08x\r\n");
+            _LIT8(KRegsDump, "r%02d=%08x %08x %08x %08x\r\n");
+            RBuf8 reference;
+            reference.CreateL(KCpsrDump().Length() + 4 + KCoreRegsCount * (KRegsDump().Length() + 4*4));
+            CleanupClosePushL(reference);
+
+            writer->Open(_L("")); //clear writer buffer
+            TRAP(err, formatter->DumpRegistersL(KCrashTid));
+            itest(err == KErrNone);
+            itest(writer->iData != KRegsDump());
+
+            TInt32 cpsr = KRegValue32 + KCrashTid + 16; //index of cpsr 
+
+            reference.Format(KCpsrDump, cpsr); 
+            TBuf8<41> line;
+            #define REG_VAL(i) ( KRegValue32 + KCrashTid + i )
+            for(TInt i = 0; i < KCoreRegsCount; i+=4)
+            {
+                TInt reg0 = REG_VAL(i);
+                TInt reg1 = REG_VAL(i+1);
+                TInt reg2 = REG_VAL(i+2);
+                TInt reg3 = REG_VAL(i+3);
+                line.Format(KRegsDump, i, reg0, reg1, reg2, reg3);
+                reference.Append(line);
+            }
+            #undef REG_VAL
+            itest(writer->iData == reference);
+            CleanupStack::PopAndDestroy(); //reference
+			RDebug::Print(_L("EDumpRegisters finished\n"));
+
+            break;
+        }
+
+        case EDumpCodeSegs:
+        {
+			RDebug::Print(_L("EDumpCodeSegs starting.... \n"));
+
+            _LIT8(KSegsLine, "%08X-%08X %S\r\n");
+            RBuf8 line;
+            CleanupClosePushL(line);
+            line.CreateL(KSegsLine().Length() + 2*4 + KMaxFileName);
+            //               0123456789012345679012
+	        _LIT8(KSegsDump, "\r\nCODE SEGMENTS:\r\n");
+            RBuf8 reference;
+            CleanupClosePushL(reference);
+            reference.CreateL(KSegsDump().Length() + KCodeSegsCount * (line.MaxLength()) + 76);
+
+            writer->Open(_L("")); //clear writer buffer
+            formatter->DumpCodeSegsL(KCrashPid);
+			//writer->Print();
+
+            itest(writer->iData != KSegsDump());
+			RDebug::Print( _L(" writer->iData.Length() = %d\n"), writer->iData.Length() );
+
+            reference = KSegsDump();
+            TUint base;
+            TUint size;
+
+			// See CTestCrashDataSource::GetCodeSegmentsL()
+            
+			base = KCrashCodeRunAddr + KCrashPid;
+			size= KCrashCodeSize + KCrashPid;
+            line.Format(KSegsLine, base, base + size, &KCrashProcessName8);
+            reference.Append(line);
+
+			base = KCrashCodeRunAddr + KCrashPid + 1;
+			size= KCrashCodeSize + KCrashPid + 1;
+            line.Format(KSegsLine, base, base + size, &KLibName1_8);
+            reference.Append(line);
+
+			base = KCrashCodeRunAddr + KCrashPid + 2;
+			size= KCrashCodeSize + KCrashPid + 2;
+            line.Format(KSegsLine, base, base + size, &KLibName2_8);
+            reference.Append(line);
+           
+            reference.Append(_L8("\r\n"));
+
+			/*
+			RBuf8 referencePrint;
+		    referencePrint.CreateL(256);
+			referencePrint.Copy( reference );
+			char *tonp = (char*) referencePrint.PtrZ();
+			LOG_MSG2("  KCodeSeg=%s\n", tonp);
+			referencePrint.Close();
+			writer->Print();
+			*/
+
+			itest(writer->iData == reference);
+            CleanupStack::PopAndDestroy(2);
+			RDebug::Print(_L("EDumpCodeSegs finished\n"));
+            break;
+        }
+
+        case EDumpStack:
+        {
+			RDebug::Print(_L("EDumpStack starting.... \n"));
+			_LIT( KFalseOpt, "False" );
+
+            CThreadInfo *thread = CThreadInfo::NewL(KCrashTid,
+                                                    KCrashThreadName,
+                                                    KCrashPid,
+                                                    KCrashThreadPriority,
+                                                    KCrashSvcStackPtr,
+                                                    KCrashSvcStackAddr,
+                                                    KCrashSvcStackSize,
+                                                    KCrashUsrStackAddr,
+                                                    KCrashUsrStackSize);
+
+			CleanupStack::PushL(thread);
+
+            RBuf8 stack;
+            stack.CreateL(KCrashUsrStackSize*5);
+            CleanupClosePushL(stack);
+            
+            writer->Open(_L("")); //clear writer buffer
+		    formatter->SetConfigParameterL( 1, (TInt32)EFalse, KFalseOpt ); //binary dump
+            formatter->DumpStackL(KCrashTid, *thread); 
+
+            for( TInt i = 0; i < KCrashUsrStackSize; i++ )
+		    {
+                stack.Append((TUint8*)&i, 1);
+            }
+
+			RDebug::Printf("itest(writer->iData == stack);");
+            itest(writer->iData == stack);
+            itest(writer->iData != _L8(""));
+            stack.Zero();
+
+            for(TInt i = 0; i < KCrashUsrStackSize; i+=16)
+            {
+                stack.AppendNumFixedWidth(KCrashUsrStackAddr + i, EHex, 8);
+                stack.Append(_L8(": "));
+                for(TInt j = 0; j < 16; ++j)
+                {
+                    stack.AppendNumFixedWidth(i+j, EHex, 2); 
+                    stack.Append(' ');
+                }
+                for(TInt j = 0; j < 16; ++j)
+                {
+                    TInt c = i+j;
+                    if(c < 0x20 || c >= 0x7f) //something writable
+						c = 0x2e; //.
+                    stack.Append(TChar(c));
+                }
+                stack.AppendFormat(_L8("\r\n"));
+            }
+
+            writer->OpenL(_L("")); //clear writer buffer
+			RDebug::Printf("formatter->SetConfigParameterL( 1, (TInt)ETrue, KNullDesC );");
+		    formatter->SetConfigParameterL( 1, (TInt)ETrue, KNullDesC ); //ascii dump
+
+			RDebug::Printf("formatter->DumpStackL(KCrashTid, *thread);");
+            formatter->DumpStackL(KCrashTid, *thread); 
+
+			RDebug::Printf("itest(writer->iData == stack);");
+            itest(writer->iData == stack);
+            itest(writer->iData != _L8(""));
+            CleanupStack::PopAndDestroy();
+			CleanupStack::PopAndDestroy(thread);
+			RDebug::Print(_L("EDumpStack finished\n"));
+            break;
+        }
+        
+        default:
+            break;
+    }
+    RDebug::Print(_L("<- TestSuite(%d)\n"), aSuite);
+}
+
+void RunTestsL()
+{
+    RDebug::Print(_L("-> RunTestsL()\n"));
+
+    CDexcFormatterTest::TSuite suite[] = {
+                                         CDexcFormatterTest::ENone,
+                                         CDexcFormatterTest::EConfigData,
+                                         CDexcFormatterTest::EFindImplementation,
+                                         CDexcFormatterTest::EConfigParams,
+                                         CDexcFormatterTest::EGetDescription,
+                                         CDexcFormatterTest::EDumpLog,
+                                         CDexcFormatterTest::EDumpPanicInfo,
+                                         CDexcFormatterTest::EDumpExcInfo,
+                                         CDexcFormatterTest::EDumpRegisters,
+										 CDexcFormatterTest::EDumpCodeSegs,
+										 CDexcFormatterTest::EDumpStack,
+                                         CDexcFormatterTest::ECrash
+                                         };
+
+    RTest rtest(KTestTitle);
+    rtest.Title(); 
+    rtest.Start(_L(""));
+    CDexcFormatterTest::TSuite *test = suite; 
+
+    while(*test != CDexcFormatterTest::ECrash)
+    {
+        CDexcFormatterTest *itester = CDexcFormatterTest::NewLC(rtest);
+        itester->TestSuiteL(*test++);
+        CleanupStack::PopAndDestroy();
+    }
+
+    rtest.End();
+    rtest.Close();
+    RDebug::Print(_L("<- RunTestsL()\n"));
+}
+
+TInt E32Main()
+{
+    RDebug::Print(_L("-> E32Main()\n"));
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+    __ASSERT_ALWAYS(cleanup, User::Panic(_L("D_EXC_TEST-NO_CLEANUP"), KErrNoMemory));
+
+    TRAPD(err, RunTestsL());
+	__ASSERT_ALWAYS(!err, User::Panic(_L("D_EXC_TEST-RunTestsL trapped with error: "), err));
+
+	delete cleanup;
+	__UHEAP_MARKEND;
+    RDebug::Print(_L("<- E32Main()\n"));
+    return err;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/test/tdexcformatter.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef T_D_EXC_FORMATTER_IBY
+#define T_D_EXC_FORMATTER_IBY
+
+#include <header.iby>
+
+file=ABI_DIR\BUILD_DIR\tdexcformatter.exe  \sys\bin\tdexcformatter.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/dexc/test/tdexcformatter.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,44 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+target tdexcformatter.exe
+targettype	exe
+uid 				0xE8000077
+VENDORID    0x70000001
+
+sourcepath .
+source tdexcformatter.cpp
+sourcepath ../../test
+source testcrashdatasource.cpp
+source testcrashdatasave.cpp
+
+sourcepath ../src
+source dexcformatter.cpp
+
+userinclude		../inc
+userinclude		../../test/
+
+systeminclude /epoc32/include
+systeminclude /epoc32/include/ecom
+systeminclude /epoc32/include/drivers
+systeminclude /epoc32/include/tools/coredump
+
+library euser.lib ecom.lib estor.lib
+library cdssupport.lib
+
+CAPABILITY 	PowerMgmt
+
+
+OPTION CW -w nounused -w noempty
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/bwins/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/bwins/selflibu.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,7 @@
+EXPORTS
+	?NewL@CSELFEditor@@SAPAV1@ABVTDesC16@@@Z @ 1 NONAME ; class CSELFEditor * CSELFEditor::NewL(class TDesC16 const &)
+	?InsertVariantSpecificDataL@CSELFEditor@@QAEXABVTDesC8@@@Z @ 2 NONAME ; void CSELFEditor::InsertVariantSpecificDataL(class TDesC8 const &)
+	?NewLC@CSELFEditor@@SAPAV1@ABVTDesC16@@@Z @ 3 NONAME ; class CSELFEditor * CSELFEditor::NewLC(class TDesC16 const &)
+	?GetELFHeader@CSELFEditor@@QAEXAAUElf32_Ehdr@@@Z @ 4 NONAME ; void CSELFEditor::GetELFHeader(struct Elf32_Ehdr &)
+	?WriteELFUpdatesL@CSELFEditor@@QAEXXZ @ 5 NONAME ; void CSELFEditor::WriteELFUpdatesL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/data/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/data/symbianelfformatter.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Registry file for the Core Dump Symbian ELF Formatter
+// ECOM RSS file for Symbian ELF Core dump formatter
+//
+
+
+
+/**
+ @file 
+*/
+
+#include "RegistryInfo.rh"
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+	{
+	// UID for the DLL
+	dll_uid = 0x10282fe1;
+
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of formatter interface 
+			interface_uid = 0x10282fe2;
+
+			implementations = 
+				{
+				// Info for CImplementation1
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10282fe3;
+					version_no = 1;
+					display_name = "Symbian ELF Core Dump Formatter plugin v1.0.0";
+					default_data = "ELF V1.0.0";
+					opaque_data = "cds elf";
+					},				
+
+				// Info for Implementation2
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102836bb;
+					version_no = 2;
+					display_name = "Symbian ELF Core Dump Formatter plugin v2.0.0";
+					default_data = "ELF V2.0.0";
+					opaque_data = "cds elf v2";
+					}								 
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/documentation/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
Binary file dbgsrv/coredumpserver/plugins/formatters/symbianelf/documentation/sgl_ts0028_027_symbian_core_dump_file_format_1.6.doc has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/eabi/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/eabi/selflibu.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,11 @@
+EXPORTS
+	_ZN11CSELFEditor12GetELFHeaderER10Elf32_Ehdr @ 1 NONAME
+	_ZN11CSELFEditor16WriteELFUpdatesLEv @ 2 NONAME
+	_ZN11CSELFEditor26InsertVariantSpecificDataLERK6TDesC8 @ 3 NONAME
+	_ZN11CSELFEditor4NewLERK7TDesC16 @ 4 NONAME
+	_ZN11CSELFEditor5NewLCERK7TDesC16 @ 5 NONAME
+	_ZTI11CSELFEditor @ 6 NONAME
+	_ZTV11CSELFEditor @ 7 NONAME
+	_ZTI18CStringInfoTableV2 @ 8 NONAME
+	_ZTV18CStringInfoTableV2 @ 9 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,41 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file bld.inf Build information file
+//
+
+PRJ_PLATFORMS
+ARMV5 WINSCW
+
+PRJ_EXPORTS
+
+symbianelfformatter.iby		/epoc32/rom/include/symbianelfformatter.iby
+../inc/symbianelfdefs.h		/epoc32/include/tools/coredump/symbianelfdefs.h
+../selflib/selflib.h		/epoc32/include/tools/coredump/selflib.h
+
+PRJ_MMPFILES
+
+#if defined(MARM)
+symbianelfformatter.mmp
+#endif
+selflib.mmp
+
+PRJ_TESTMMPFILES
+
+#if defined(MARM)
+../test/tsymbianelfformatter.mmp
+../test/tsymbianelfstringinfo.mmp
+#endif
+
+PRJ_TESTEXPORTS
+../test/tsymbianelfformatter.iby		/epoc32/rom/include/tsymbianelfformatter.iby
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/group/selflib.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,40 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  MMP file for utility symbian elf file that allows editing of an existing file
+
+TARGET        selflib.dll
+TARGETTYPE    dll
+UID           0x1000008d 0x102836B5
+VENDORID      0x70000001
+
+SYSTEMINCLUDE	/epoc32/include
+SYSTEMINCLUDE	/epoc32/include/tools
+SYSTEMINCLUDE	/epoc32/include/tools/coredump
+
+USERINCLUDE		../../../../interface/common
+USERINCLUDE		../inc
+USERINCLUDE		../incv2
+
+SOURCEPATH		../selflib
+SOURCE			selflib.cpp
+
+SOURCEPATH		../srcv2
+SOURCE			symbianelfstringinfov2.cpp
+
+LIBRARY			euser.lib
+LIBRARY			efsrv.lib
+LIBRARY			bafl.lib
+
+MACRO CDSDEBUG
+CAPABILITY	NONE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/group/symbianelfformatter.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,24 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file symbianelfformatter.iby ROM build file for symbian elf formatter
+//
+
+#ifndef SYMBIAN_ELF_FORMATTER_IBY__
+#define SYMBIAN_ELF_FORMATTER_IBY__
+
+ECOM_PLUGIN(symbianelfformatter.dll,symbianelfformatter.rsc)
+file=ABI_DIR/BUILD_DIR/selflib.dll			sys/bin/selflib.dll
+
+#endif // SYMBIAN_ELF_FORMATTER_IBY__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/group/symbianelfformatter.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,75 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// symbianelfformatterv2.mmp
+// Symbian ELF formatter MMP file (v2)
+// symbianelfformatter.dll A process core dump formatter implemented as an ECOM plugin
+//
+
+
+
+/**
+ @file 
+*/
+
+TARGET      symbianelfformatter.dll
+TARGETTYPE  plugin
+UID         0x10009D8D 0x10282fe1 //second uid=ecom uid, third UID symbian_elf_formatter
+
+VENDORID    0x70000001
+
+CAPABILITY 	PowerMgmt
+
+
+SOURCEPATH  ../src
+SOURCE      symbianelfformatter.cpp
+source		symbianelfproxy.cpp
+source		symbianelfstringinfo.cpp
+source		symbianelfoptions.cpp
+
+SOURCEPATH  ../srcv2
+SOURCE      symbianelfformatterv2.cpp
+source		symbianelfstringinfov2.cpp
+source		symbianelfoptionsv2.cpp
+
+
+USERINCLUDE ../inc
+USERINCLUDE ../incv2
+USERINCLUDE ../../test
+
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE	/epoc32/include/drivers
+SYSTEMINCLUDE	/epoc32/include/tools
+SYSTEMINCLUDE	/epoc32/include/tools/coredump
+
+//
+// ECOM plugin resource file
+//
+start resource ../data/symbianelfformatter.rss
+target symbianelfformatter.rsc
+end
+
+LIBRARY		ecom.lib
+LIBRARY		euser.lib
+LIBRARY		efsrv.lib
+LIBRARY     estor.lib
+LIBRARY     cdssupport.lib
+LIBRARY     btracec.lib
+
+#ifdef MARM_ARMV5
+STATICLIBRARY scmusr_lib.lib
+#endif
+
+
+MACRO CDSDEBUG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/symbianelfdefs.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,452 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __SYMBIANELFDEFS_H__
+#define __SYMBIANELFDEFS_H__
+
+#include <elfdefs.h>
+
+/**
+@file
+@publishedPartner
+@released
+
+Symbian Core Dump specific ELF definitions.
+
+The definitions in this file implement the interface described in document
+SGL_TS0028_027_symbian_core_dump_file_format.doc.
+
+@see CSymbianElfFormatter
+*/
+
+/** Definition of 64 bit memory */
+typedef unsigned long long Elf64_Word;
+
+/** Definition of 8 bit memory */
+typedef unsigned char Elf32_Byte;
+
+/**
+Value of the d_type field of the standard descriptor header.
+*/
+typedef enum
+{
+	/**  Value to identify Sym32_syminfod */
+	ESYM_NOTE_SYM	= 0x00000000,
+
+	/**  Value to identify Sym32_thrdinfod */
+	ESYM_NOTE_THRD	= 0x00000010,
+
+	/** Value to identify Sym32_procinfod */
+	ESYM_NOTE_PROC	= 0x00000020,
+
+	/** Value to identify Sym32_execinfod */
+	ESYM_NOTE_EXEC	= 0x00000040,
+
+	/** Value to identify Sym32_reginfod */
+	ESYM_NOTE_REG	= 0x00000080,
+
+	/** Value to identify string information */
+	ESYM_NOTE_STR	= 0x00000100,
+
+	/** Value to identify trace info */
+	ESYM_NOTE_TRACE = 0x00000200,
+
+	/** Value to identify lock data info */
+	ESYM_NOTE_LOCKDATA = 0x00000400,
+
+	/** Value to identify rom build info */
+	ESYM_NOTE_ROMBUILD = 0x00000800,
+
+	/** Value to identify variant specific data */
+	ESYM_NOTE_VARIANT_DATA = 0x00010000
+
+} ESYM_NOTE_TYPE;
+
+/**
+To uniquely identify executables associated with the crashed process an executable
+identifier is required, this identifier is defined as follows
+*/
+typedef struct
+{
+	/** ID of the executable to match symbolic debug information to executable binary
+	[Currently crash time iTimeLo (LSW) and iTimeHi (MSW)] */
+	Elf64_Word		exec_id;
+
+	/** CCITT CRC-32 Checksum of up to the first 1Kbytes of code segment. */
+	Elf32_Word		exec_crc;
+
+	/** @internalTechnology */
+    Elf32_Word		exec_spare;
+} Sym32_execid;
+
+/** Size of Sym32_execid in bytes. @see Sym32_execid */
+#define SYM32_EXECID_SIZE	16
+
+/**
+The Symbian Info segment contains generic crash information.
+It is defined as a program segment with type PT_NOTE which
+references the segment descriptor Sym32_dhdr.
+The d_name field of the standard descriptor header is "CORE.SYMBIAN".
+The d_type field of the standard descriptor header is ESYM_NOTE_SYM.
+*/
+typedef struct
+{
+	/** Date and time of the crash */
+	Elf64_Word		sd_date_time;
+
+	/** The ID of the crashed process as defined by Sym32_execid */
+	Sym32_execid	sd_execid;
+
+	/** The id of the thread causing the crash */
+	Elf64_Word		sd_thread_id;
+
+	/** The crashing threads owning process */
+	Elf64_Word		sd_proc_id;
+
+	/** Identifies whether the crash was caused by a Hardware Exception (set to 0)
+	or Thread Kill (set to 1) */
+	Elf32_Word		sd_exit_type;
+
+	/** If sd_exit_type is Hardware Exception then set to e32const.h::TExcType
+	if is Thread Kill then set to e32const.h::TExitType */
+	Elf32_Word		sd_exit_reason;
+
+	/** Only set if sd_exit_type is Thread Kill. Index into the CORE.SYMBIAN.STR
+	note segment identifying the reason for the crash or ESYM_STR_UNDEF */
+	Elf32_Word		sd_exit_cat;
+
+	/** @internalTechnology */
+    Elf32_Word		sd_spare;
+} Sym32_syminfod;
+
+/** Size of Sym32_syminfod in bytes. @see Sym32_syminfod */
+#define SYM32_SYMINFO_SIZE	56
+
+/**
+ The descriptor contents immediately follow the header.
+ To obtain the nth segment: nth segment offset =
+ (Elf32_Phdr) element -> p_offset + sizeof(Sym32_dhdr) + n * d_descrsz
+ */
+typedef struct {
+	/** Index into the CORE.SYMBIAN.STR note segment defining the name of
+	the descriptor or ESYM_STR_UNDEF */
+	Elf32_Word	d_name;
+
+	/** Size of a single descriptor element */
+	Elf32_Word	d_descrsz;
+
+	/** Type of the descriptor defined */
+	Elf32_Word	d_type;
+
+	/** Index into the CORE.SYMBIAN.STR note segment defining the version
+	of the following segment descriptor */
+	Elf32_Word	d_version;
+
+	/** Number of descriptor elements */
+	Elf32_Word	d_elemnum;
+} Sym32_dhdr;
+
+/** Size of Sym32_dhdr in bytes. @see Sym32_dhdr */
+#define SYM32_DESCHDR_SIZE	20
+
+/**
+The Thread Info segment contains thread related information for one or more
+threads of the owning process.
+It is defined as a program segment with type PT_NOTE referencing the segment
+descriptor defined below.
+The d_name field of the standard descriptor header is "CORE.SYMBIAN.THREAD".
+The d_type field of the standard descriptor header is ESYM_NOTE_THRD.
+*/
+typedef struct {
+	/** Id of the thread */
+	Elf64_Word	td_id;
+
+	/** Id of the owning process */
+	Elf64_Word	td_owning_process;
+
+	/** Index into the CORE.SYMBIAN.STR note segment defining the name of the
+	thread or ESYM_STR_UNDEF */
+	Elf32_Word	td_name;
+
+	/** Priority of thread */
+	Elf32_Word	td_priority;
+	/** Supervisor stack pointer */
+	Elf32_Word	td_svc_sp;
+
+	/** Address of the supervisor stack */
+	Elf32_Word	td_svc_stack;
+
+	/** Size of the supervisor stack */
+	Elf32_Word	td_svc_stacksz;
+
+	/** Address of the user stack */
+	Elf32_Word	td_usr_stack;
+
+	/** Size of the user stack */
+	Elf32_Word	td_usr_stacksz;
+
+	/** id of the last cpu used */
+	Elf32_Word	td_last_cpu_id;
+
+	/** Address of threads heap */
+	Elf32_Word	td_heap_add;
+
+	/** Size of threads heap */
+	Elf32_Word	td_heap_sz;
+
+} Sym32_thrdinfod;
+
+/** Size of Sym32_thrdinfod in bytes. @see Sym32_thrdinfod */
+#define SYM32_THRINFO_SIZE	56
+
+/**
+The Process Info segment contains process related information for the
+crashed threads owning process. It is defined as a program segment with
+type PT_NOTE referencing the segment descriptor defined below.
+The d_name field of the standard descriptor header is "CORE.SYMBIAN.PROCESS".
+The d_type field of the standard descriptor header is ESYM_NOTE_PROC.
+*/
+typedef struct {
+	/** ID of the process */
+	Elf64_Word	pd_id;
+
+	/** Index into the CORE.SYMBIAN.STR note segment defining the
+	name of the Process or ESYM_STR_UNDEF */
+	Elf32_Word	pd_name;
+
+	/** Priority of the process */
+	Elf32_Word	pd_priority;
+
+} Sym32_procinfod;
+
+/** Size of Sym32_procinfod in bytes. @see Sym32_procinfod */
+#define SYM32_PROCINFO_SIZE	16
+
+/**
+The Executable Info segment contains information defining the location of the given executables image segments in the processes address space; this includes statically and dynamically linked executables also. It is defined as a program segment with type PT_NOTE referencing the segment descriptor defined below.
+The d_name field of the standard descriptor header is "CORE.SYMBIAN.EXECUTABLE".
+The d_type field of the standard descriptor header is ESYM_NOTE_EXEC.
+*/
+typedef struct {
+	/** The ID of the executable as defined by Sym32_execid */
+	Sym32_execid	ed_execid;
+
+	/** Index into the CORE.SYMBIAN.STR note segment defining the name of
+	the executable or ESYM_STR_UNDEF */
+	Elf32_Word		ed_name;
+
+	/** Execute in place TRUE (1) for XIP ROM code FALSE (0) otherwise */
+	Elf32_Word		ed_XIP;
+
+	/** Size of the executables code segment */
+	Elf32_Word		ed_codesize;
+
+	/** Execution address of the code segment */
+	Elf32_Word		ed_coderunaddr;
+
+	/** Build address of the code section (Non XIP only) */
+	Elf32_Word		ed_codeloadaddr;
+
+	/** Size of the executable rodata segment */
+	Elf32_Word		ed_rodatasize;
+
+	/** Execution address of the rodata segment */
+	Elf32_Word		ed_rodatarunaddr;
+
+	/** Build address of the rodata section (Non XIP only) */
+	Elf32_Word		ed_rodataloadaddr;
+
+	/** Size of the executable data segment */
+	Elf32_Word		ed_datasize;
+
+	/** Execution address of the data segment */
+	Elf32_Word		ed_datarunaddr;
+
+	/** Build address of the data section (Non XIP only) */
+	Elf32_Word		ed_dataloadaddr;
+
+	/** @internalTechnology */
+	Elf32_Word		ed_spare;
+} Sym32_execinfod;
+
+/** Size of Sym32_execinfod in bytes. @see Sym32_execinfod */
+#define SYM32_EXECINFO_SIZE	64
+
+/**
+The register descriptor member Sym32_reginfod::rid_class is defined by this enumeration.
+@see Sym32_reginfod.
+*/
+typedef enum
+{
+	/** Core processor register */
+	ESYM_REG_CORE = 0,
+	/** Coprocessor register */
+	ESYM_REG_COPRO = 1
+} ESYM_REGCLASS;
+
+/**
+The register descriptor member Sym32_reginfod::rid_repre is defined by this enumeration.
+@see Sym32_reginfod
+*/
+typedef enum
+{
+	/** 8 Bit register contents */
+	ESYM_REG_8	= 0,
+	/** 16 Bit register contents */
+	ESYM_REG_16	= 1,
+	/** 32 Bit register contents */
+	ESYM_REG_32	= 2,
+	/** 64 Bit register contents */
+	ESYM_REG_64	= 3
+} ESYM_REGREP;
+
+/**
+The Register Info segment contains a register context for a given thread. The core dump file may include zero or more register contexts for one or more threads within the owning process. It is defined as a program segment with type PT_NOTE referencing the segment descriptor defined below.
+The d_name field of the standard descriptor header is "CORE.SYMBIAN.REGISTER.<THREADID>".
+The d_type field of the standard descriptor header is ESYM_NOTE_REG.
+*/
+typedef struct {
+	/** Thread which context relates to */
+	Elf64_Word	rid_thread_id;
+
+	/** Index into the CORE.SYMBIAN.STR note segment defining the version of
+	the Register Data Info descriptor */
+	Elf32_Word	rid_version;
+
+	/** Number of registers this descriptor defines */
+	Elf32_Half	rid_num_registers;
+
+	/** Register class defined by ESYM_REGCLASS */
+	Elf32_Byte	rid_class;
+
+	/** Register representation defined by ESYM_REGREP */
+	Elf32_Byte	rid_repre;
+
+} Sym32_reginfod;
+
+/** Size of Sym32_reginfod in bytes. @see Sym32_reginfod */
+#define SYM32_REGINFO_SIZE	16
+
+/**
+Immediately following the Register Info descriptor header is the information describing
+the individual registers. See document for register identifiers.
+The register identification scheme is the same as that used by the run mode debug interface.
+*/
+typedef struct {
+	/** Register ID */
+	Elf32_Half	rd_id;
+
+	/**  Sub register ID */
+	Elf32_Half	rd_sub_id;
+
+	/** Offset in bytes from the beginning of the file to the register data */
+	Elf32_Word	rd_data;
+} Sym32_regdatad;
+
+/** Size of Sym32_regdatad in bytes. @see Sym32_regdatad */
+#define SYM32_REGDATA_SIZE	8
+
+/**
+Trace Data
+*/
+typedef struct {
+
+	/** Trace version of the data */
+	Elf32_Word	tr_version;
+
+	/** Offset in bytes from the beginning of the file to the register data */
+	Elf32_Word	tr_data;
+
+	/** Size of trace data */
+	Elf32_Word	tr_size;
+} Sym32_tracedata;
+
+#define SYM32_TRACEDATA_SIZE 12
+
+typedef struct {
+
+	/** Number of holds on the mutex from current thread see Kern::CodeSegLock() */
+	Elf32_Word	lk_mutex_held_count;
+
+	/** Number of threads waiting on the mutex see Kern::CodeSegLock() */
+	Elf32_Word	lk_mutex_thread_wait_count;
+
+	/** Number of kernel locks held see NKern::KernelLocked() */
+	Elf32_Word	lk_lock_count;
+} Sym32_lockdata;
+
+#define SYM32_LOCKDATA_SIZE 12
+
+typedef struct {
+
+	/** Which mode the stack belongs to */
+	Elf32_Word	es_type;
+
+	/** Location of the data */
+	Elf32_Word	es_data;
+
+	/** Size of the data */
+	Elf32_Word	es_size;
+} Sym32_cpu_exception_stk;
+
+#define SYM32_CPU_EXCEPTION_STK_SIZE 12
+
+typedef struct {
+
+	/** Location of the data */
+	Elf32_Word	es_data;
+
+	/** Size of the data */
+	Elf32_Word	es_size;
+} Sym32_variant_spec_data;
+
+#define SYM32_VARIANT_SPEC_DATA_SIZE 8
+
+typedef struct {
+
+	/** Time of ROM build in miliseconds */
+	Elf64_Word rom_time;
+
+	/** Build number of ROM */
+	Elf32_Half rom_build;
+
+	/** Major version number of ROM built */
+	Elf32_Byte rom_major_version;
+
+	/** Minor version number of ROM built */
+	Elf32_Byte rom_minor_version;
+
+	/** Spare */
+	Elf32_Word spare1;
+
+} Sym32_rombuild;
+
+#define SYM32_ROMBUILD_SIZE 16
+
+/** Program header member p_flags indicating that the segment may be executed. */
+#define PF_X 1
+
+/** Program header member p_flags indicating that the segment may be written to. */
+#define PF_W 2
+
+/** Program header member p_flags indicating that the segment may be read from. */
+#define PF_R 4
+
+/**
+Index to the NULL string, ie string is not defined.
+*/
+#define ESYM_STR_UNDEF 0
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/symbianelfformatter.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,167 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implements two examples of the ECOM Symbian Elf Core Dump API
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef __SYMBIAN_ELF_FORMATTER_H__
+#define __SYMBIAN_ELF_FORMATTER_H__
+
+// Abstract ECOM API definition
+#include <formatterapi.h>
+#include <symbianelfdefs.h>
+#include <crashdatasource.h>
+
+#include "symbianelfoptions.h"
+#include <crashdatasave.h>
+#include "tsymbianelfformatter.h"
+#include "symbianelfstringinfo.h"
+
+const TUint32 KSymbianELFFormatterUid = { 0x10282fe3 };
+_LIT(KPluginDescription, "Symbian Elf Core Dump formatter");
+
+/**
+@internalTechnology
+@released
+Symbian ELF formatter plugin is loaded by the core dump server and notified about the crash event.
+Then it dupms crash data in the ELF file format.
+@see CCrashDataSave
+*/
+class CSymbianElfFormatter : public CCoreDumpFormatter
+{
+    friend void CSymbianElfFormatterTest::TestSuiteL(TSuite aSuite); //test harness
+    enum { KElfDumpFileLength = 23 };
+public:
+	static CSymbianElfFormatter* NewL();
+	static CSymbianElfFormatter* NewLC();
+	virtual ~CSymbianElfFormatter();
+
+public:
+
+	virtual void ConfigureDataSaveL( CCrashDataSave * aDataSave );
+
+	virtual void ConfigureDataSourceL( CCrashDataSource * aDataSource );
+
+	virtual void GetDescription( TDes & aPluginDescription );
+
+	virtual void CrashEventL( TCrashInfo* aCrashInfo );
+
+	virtual TInt GetNumberConfigParametersL( );
+
+	virtual COptionConfig * GetConfigParameterL( const TInt aIndex );
+
+	virtual void SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue );
+
+public:
+
+private:
+
+    /** Helper structure for creating data segs for stacks and .rodata/.bss/.data sections */
+	struct TSegmentInfo
+	{
+        /** base memory address of the segment */
+		TUint32 iSegBase;
+        /** size of the segment data */
+		TUint32 iSegSize;
+        /** access rights to the segment data */
+		TUint32 iFlags;
+
+        /** reserved for future */
+		TUint32 iSpare1;
+        /** reserved for future */
+		TUint32 iSpare2;
+	};
+
+    /**
+     @publishedPartner
+     @released
+     List of TSegmentInfo structures
+    @see TSegmentInfo
+    @see RArray
+    */
+	typedef RArray<TSegmentInfo> RSegmentList;
+
+	void ConstructL();
+	CSymbianElfFormatter();
+	void FindAllOfSameClassRepresentation( RRegisterList &aRegs,
+											RRegisterList &aRegsOfSameClassRepr,
+											ESYM_REGCLASS aClass,
+											ESYM_REGREP aRepr );
+
+	TUint WriteSymbianInfoL(const TCrashInfo &aCrashInfo, const TUint32 aCrc32);
+
+	TUint WriteDataSegmentsL( const TUint64 & aThreadId,
+							  const TUint64 & aPid,
+							  const RThreadPointerList &aThreadList,
+							  const RCodeSegPointerList &aCodeSegs,
+							  RSegmentList &aDataSegs,
+							  RArray<TUint> &aDataSegOffsets );
+
+	TUint WriteCodeSegmentsL( const TUint64 & aThreadId,
+							  const RCodeSegPointerList &aCodeSegs,
+							  RArray<TUint> &aCodeSegOffsets );
+
+	TUint WriteThreadInfoL(const TUint64 & aPid, const RThreadPointerList &aThreadList);
+
+	TUint WriteProcessInfoL(const TUint64 & aPid, const RProcessPointerList &aProcessList);
+	TUint WriteExecutableInfoL(const RCodeSegPointerList &aCodeSegs, const TUint64 &aTime, const TUint64 &aTid);
+
+	void  WriteRegisterInfoL( const TUint64 & aTid,
+							  const TUint64 & aPid,
+							  RArray<TUint>& aOffsets,
+							  RRegisterList &aArmExcRegs,
+							  const RThreadPointerList &aThreadList);
+	TUint WriteStringInfoL();
+
+	void SetArmRegsFromCrashDataL(const TCrashInfo &aCrashInfo, RRegisterList &aArmExcRegs);
+
+	TBool GetArmExcReg(const TCrashInfo &aCrashInfo, const TRegisterData & aReg, TRegisterValue32 & aVal);
+
+	void UpdateCrashProgressL( const TDesC &aProgress );
+	TUint32 CalcExecCrcL(const TUint64 &aTid, const TCodeSegInfo &aExecInfo );
+
+	void PrepareFileNameL(TUint64 aStamp);
+    TUint WriteTraceBufferL();
+
+	static void CleanupCodeSegList(TAny *aArray);
+	static void CleanupProcessList(TAny *aArray);
+	static void CleanupThreadList(TAny *aArray);
+
+private:
+
+    /** Pointer to data source object created and managed by core dump server, provides API to gather necessary info about the crash */
+	CCrashDataSource * iDataSource;
+
+    /** Pointer to writer plugin created and managed by core dump server, provides API to store the dump information*/
+	CCrashDataSave	 * iDataSave;
+
+    /** Keep track of the current media-position indicator */
+	TUint			   iOffset;
+
+    /** Responsible for holding all the strings required to be stored in ELF string info segment */
+	CStringInfoTable * iStrInfoTbl;
+
+    /** Symbian ELF formatter configuration parameter list */
+	CElfOptions		 * iElfOptions;
+
+	/** Dump file Name */
+	RBuf iElfFileName;
+};
+
+#endif // __SYMBIAN_ELF_FORMATTER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/symbianelfoptions.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,121 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Class holds all user configuration data
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef __ELFOPTIONS_H__
+#define __ELFOPTIONS_H__
+
+#include <e32def.h>
+#include <optionconfig.h>
+
+/**
+@internalTechnology
+@released
+
+It is used by symbian ELF formatter to manage its configuration parameters.
+*/
+class CElfOptions : public CBase
+{
+
+public:
+	static CElfOptions* NewL( TUint32 aUID = 0 );
+	static CElfOptions* NewLC( TUint32 aUID = 0 );
+	~CElfOptions();
+
+	TBool CreateProcessData() const;
+
+	TBool CreateDataSegments() const;
+	TBool CreateCodeSegments() const;
+	TBool CreateThreadSegments() const;
+	TBool CreateRegisterSegments() const;
+	TBool CreateExecSegments() const;
+	TBool CreateProcessSegments() const;
+	TBool CreateSystemCrashInfo() const;
+	TBool CreateSystemWideOnly() const;
+	TInt TraceDataToCapture() const;
+	TBool CreateLockDataSegments() const;
+	TBool CreateRomBuildInfo() const;
+	
+	
+	TInt GetNumberConfigParametersL( );
+	COptionConfig * GetConfigParameterL( const TInt aIndex );
+	TInt SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue );
+	
+private:
+	CElfOptions();
+	void ConstructL( TUint32 aUID = 0 );
+	
+private:
+
+    /** Available values of symbian ELF parameter index */
+	enum TElfOptions
+		{
+        /** dump system wide info */
+		ECreateSystemCrashInfo,
+        /** dump whole crashed process info */
+		ECreateProcessData,
+        /** dump data segments */
+		ECreateDataSegments,
+        /** dump code segments */
+		ECreateCodeSegments,
+        /** dump thread info segments */
+		ECreateThreadSegments,
+        /** dump register data segments */
+		ECreateRegisterSegments,
+        /** dump executable info segments */
+		ECreateExecSegments,
+        /** dump process info segments */
+		ECreateProcessSegments,
+		/** dump trace data */
+		ECreateTraceData,
+		/** dump lock data */
+		ECreateLockSegments,
+		/** dump ROM build info */
+		ECreateRomInfo,		
+        /** guard */
+		EElfOptionsLast
+		};	
+
+    /** Symbian ELF formatter configuration parameter list */
+	RConfigParameterList	 iConfigList;
+
+    /** Available values of system crash parameter */
+	enum TSystemCrashOption
+		{
+		/**
+		Generate crash data for system, not for crashed process
+		*/
+		ESystemWideOnly = 0,			
+		/**
+		Generate crash data for crashed process only
+		*/
+		ECrashedProcessOnly = 1,
+		/**
+		Generate crash data for crashed process and system wide
+		*/
+		ESystemWideAndCrashedProc = 2
+		};
+};
+
+
+#endif // __ELFOPTIONS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/symbianelfstringinfo.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,92 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implements handling of the string info segment in Elf core dump
+// Definition of the string info table.
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef __SYMBIAN_STRING_INFO_H__
+#define __SYMBIAN_STRING_INFO_H__
+
+_LIT8(KEmpty, "");
+_LIT8(KSymbian, "CORE.SYMBIAN");
+_LIT8(KThread, "CORE.SYMBIAN.THREAD");
+_LIT8(KProcess, "CORE.SYMBIAN.PROCESS");
+_LIT8(KExecutable, "CORE.SYMBIAN.EXECUTABLE");
+_LIT8(KStr, "CORE.SYMBIAN.STR");
+_LIT8(KSymbianElfCoreDumpVersion, "1.0.0");
+_LIT8(KSymbianTraceVersion, "1.0.0");
+
+/**
+@internalTechnology
+@released
+
+String info table is used by symbian elf formatter to manage the string segment data.
+*/
+class CStringInfoTable : public CBase
+{
+public:
+	static CStringInfoTable *NewL();
+	static CStringInfoTable *NewLC();
+	~CStringInfoTable();
+
+public:
+	TUint GetIndex(const TDesC8 &aItem);
+	TUint AddStringL(const TDesC8 &aItem);
+	TText8* GetAllStrings();
+	TUint GetSize();
+
+private:
+	void ConstructL();
+	CStringInfoTable();
+    /** internal buffer holding the content of the string table */
+	RBuf8 iBuffer;
+};
+
+/**
+Called when willing to locate the index of the specified text in the internal buffer
+@param aItem descriptor holding the text to locate
+@return index of the located text in the internall buffer
+*/
+inline TUint CStringInfoTable::GetIndex(const TDesC8 &aItem)
+{
+	return iBuffer.Find(aItem);
+}
+
+/**
+Called when required to get the raw content of the string table
+@return pointer to the content of the internal buffer
+*/
+inline TText8* CStringInfoTable::GetAllStrings()
+{
+	return (TText8*)iBuffer.Ptr();
+}
+
+/**
+Called when required to get the size of the string table
+@return size of the internal buffer
+*/
+inline TUint CStringInfoTable::GetSize()
+{
+	return iBuffer.Length();
+}
+
+#endif // __SYMBIAN_STRING_INFO_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/tsymbianelfformatter.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,78 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef T_SYMBIAN_ELF_FORMATTER_H__
+#define T_SYMBIAN_ELF_FORMATTER_H__
+#include <e32std.h>
+#include <e32test.h>
+#include <crashdata.h>
+#include "testcrashdatasource.h"
+#include "testcrashdatasave.h"
+#include "symbianelfstringinfo.h"
+
+class CSymbianElfFormatter;
+
+const TUid KSymbianElfFormatterUid = { 0x10282fe3 };
+const TUint MaxCrashDataSize = 4096;
+const TUint MaxPluginDescription = 63;
+
+_LIT(KTestTitle, "SYMBIAN_ELF_FORMATTER_TEST");
+_LIT(KTestName, "test suite: ");
+
+class CSymbianElfFormatterTest : public CBase
+{
+public:
+       enum TSuite {
+                    ENone,
+                    EConfigData,
+                    EFindImplementation,
+                    EConfigParams,
+                    EGetDescription,
+                    EWriteSymbianInfo,
+                    EWriteCodeSegments,
+                    EWriteDataSegments,
+                    EWriteThreadsInfo,
+                    EWriteProcessInfo,
+                    EWriteExecutableInfo,
+                    EWriteRegistersInfo,
+                    ECrash
+                    };
+
+	static CSymbianElfFormatterTest* NewL(RTest &aTest);
+	static CSymbianElfFormatterTest* NewLC(RTest &aTest);
+    void ConstructL();
+	CSymbianElfFormatterTest(RTest &aTest);
+	~CSymbianElfFormatterTest();
+    void TestSuiteL(TSuite aSuite);
+
+private:
+    static void CleanupEComArray(TAny* aArray);
+	RTest &itest;
+    CTestCrashDataSource	* server;
+    CSymbianElfFormatter	* formatter;
+	CStringInfoTable		* iStrInfoTbl;
+    CTestDataSave			* writer;
+	TCrashInfo				iCrashInfo;
+};
+
+#endif // T_SYMBIAN_ELF_FORMATTER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/inc/tsymbianelfstringinfo.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,41 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef __T_SYMBIAN_STRING_INFO_H__
+#define __T_SYMBIAN_STRING_INFO_H__
+
+#include <e32test.h>
+
+class CSymbianStringInfoTest : public CBase
+{
+public:
+	static CSymbianStringInfoTest* NewL(const TDesC& aTitle);
+	~CSymbianStringInfoTest();
+	void TestSymbianStringInfoL();
+	
+private:
+	CSymbianStringInfoTest(const TDesC& aTitle);
+	RTest iTest;
+};
+
+#endif // __T_SYMBIAN_STRING_INFO_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/incv2/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/incv2/symbianelfformatterv2.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,207 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implements two examples of the ECOM Symbian Elf Core Dump API
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef __SYMBIAN_ELF_FORMATTERV2_H__
+#define __SYMBIAN_ELF_FORMATTERV2_H__
+
+#include <e32property.h>
+
+// Abstract ECOM API definition
+#include <formatterapi.h>
+#include <symbianelfdefs.h>
+#include <crashdatasource.h>
+#include <crashdatasave.h>
+
+#include "symbianelfoptionsv2.h"
+#include "tsymbianelfformatter.h"
+#include "symbianelfstringinfov2.h"
+
+const TUint32 KSymbianELFFormatterV2Uid = { 0x102836bb };
+const TUint32 KCPSRUsrMode = 0x10;
+
+_LIT(KPluginDescriptionV2, "Symbian Elf Core Dump formatter V2");
+
+/**
+@internalTechnology 
+@released 
+Symbian ELF formatter plugin is loaded by the core dump server and notified about the crash event.
+Then it dupms crash data in the ELF file format.
+@see CCrashDataSave
+*/
+class CSymbianElfFormatterV2 : public CCoreDumpFormatter
+{
+    friend void CSymbianElfFormatterTest::TestSuiteL(TSuite aSuite); //test harness
+    enum { KElfDumpFileLength = 23 };
+public:
+	static CSymbianElfFormatterV2* NewL();
+	static CSymbianElfFormatterV2* NewLC();
+	virtual ~CSymbianElfFormatterV2();
+
+public:
+
+	virtual void ConfigureDataSaveL( CCrashDataSave * aDataSave );
+	virtual void ConfigureDataSourceL( CCrashDataSource * aDataSource );	
+	virtual void GetDescription( TDes & aPluginDescription );
+	virtual void CrashEventL( TCrashInfo* aCrashInfo );
+	virtual TInt GetNumberConfigParametersL( );
+	virtual COptionConfig * GetConfigParameterL( const TInt aIndex );
+	virtual void SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue );
+
+public:
+
+private:
+
+    /** Helper structure for creating data segs for stacks and .rodata/.bss/.data sections */
+	struct TSegmentInfo
+	{
+        /** base memory address of the segment */
+		TUint32 iSegBase;
+        /** size of the segment data */
+		TUint32 iSegSize;
+        /** access rights to the segment data */
+		TUint32 iFlags;
+
+        /** reserved for future */
+		TUint32 iSpare1;
+        /** reserved for future */
+		TUint32 iSpare2;
+	};
+
+    /**
+     * @publishedPartner
+     * @released
+     * List of TSegmentInfo structures
+     * @see TSegmentInfo
+     * @see RArray
+     */
+	typedef RArray<TSegmentInfo> RSegmentList;
+
+	void ConstructL();
+	CSymbianElfFormatterV2();
+	void FindAllOfSameClassRepresentation( RRegisterList &aRegs, 
+											RRegisterList &aRegsOfSameClassRepr, 
+											ESYM_REGCLASS aClass, 
+											ESYM_REGREP aRepr );
+											
+	TUint WriteSymbianInfoL(const TCrashInfo &aCrashInfo, const TUint32 aCrc32);
+
+	TUint WriteDataSegmentsL( const TUint64 & aThreadId, 
+							  const TUint64 & aPid, 
+							  const RThreadPointerList &aThreadList, 
+							  const RCodeSegPointerList &aCodeSegs,
+							  RSegmentList &aDataSegs, 
+							  RArray<TUint> &aDataSegOffsets );
+
+	TUint WriteCodeSegmentsL( const TUint64 & aThreadId, 
+							  const RCodeSegPointerList &aCodeSegs, 
+							  RArray<TUint> &aCodeSegOffsets );
+
+	TUint WriteThreadInfoL(const TUint64 & aPid, const RThreadPointerList &aThreadList);
+
+	TUint WriteProcessInfoL(const TUint64 & aPid, const RProcessPointerList &aProcessList);
+	TUint WriteExecutableInfoL(const RCodeSegPointerList &aCodeSegs, const TUint64 &aTime, const TUint64 &aTid);
+
+	void  WriteRegisterInfoL( const TUint64 & aTid, 
+							  const TUint64 & aPid, 
+							  RArray<TUint>& aOffsets, 
+							  RRegisterList &aArmExcRegs, 
+							  const RThreadPointerList &aThreadList);
+	TUint WriteStringInfoL();
+
+	void SetArmRegsFromCrashDataL(const TCrashInfo &aCrashInfo, RRegisterList &aArmExcRegs);
+
+	TBool GetArmExcReg(const TCrashInfo &aCrashInfo, const TRegisterData & aReg, TRegisterValue32 & aVal);
+
+	void UpdateCrashProgressL( const TDesC &aProgress );
+	void UpdateMediaNameL(const TDesC &aMediaFileName, const TDesC &aStatus);
+
+	TUint32 CalcExecCrcL(const TUint64 &aTid, const TCodeSegInfo &aExecInfo );
+
+    void PrepareFileNameL(TUint64 aStamp);
+
+    TUint WriteTraceBufferL();
+    TUint WriteLockDataL();
+    TUint WriteRomBuildInfoL();
+	TUint WriteVariantSpecificDataL();
+
+    void WriteRawMemoryToFileL(const TUint64 aThreadId, const TUint32 aAddress, const TUint32 aLength);
+    void HelpWriteRawMemoryToFileL(const TUint64 aThreadId, const TUint32 aAddress, const TUint32 aLength);
+    
+    TBool IsSystemCrash();
+    
+	static void CleanupCodeSegList(TAny *aArray);
+	static void CleanupProcessList(TAny *aArray);
+	static void CleanupThreadList(TAny *aArray);
+	
+private:
+
+    /** Pointer to data source object created and managed by core dump server, provides API to gather necessary info about the crash */
+	CCrashDataSource* iDataSource;
+
+    /** Pointer to writer plugin created and managed by core dump server, provides API to store the dump information*/
+	CCrashDataSave* iDataSave;
+
+    /** Keep track of the current media-position indicator */
+	TUint iOffset;
+
+    /** Responsible for holding all the strings required to be stored in ELF string info segment */
+	CStringInfoTableV2* iStrInfoTbl;
+
+    /** Symbian ELF formatter configuration parameter list */
+	CElfOptionsV2* iElfOptions;
+	
+	/** Records the CPSR */
+	TUint32 iCPSR;
+	
+	/** Dump file Name */
+	RBuf iElfFileName;
+	
+	/** Crash UID lower 32 bits of crash time uniquely identifies the crash*/
+	TUid iCrashUID;
+
+	/** Crash UID Property Buffer */
+	RBuf iCrashIDBuffer;
+
+	/** @see ECrashprogress
+	 * Crash Progress Buffer
+	 */
+	RBuf iCrashProgressBuffer;
+
+	/** RProperty for reporting crash processing progress */
+	RProperty iCrashProgress;
+
+	/** RProperty for canceling crash processing */
+	RProperty iCancelCrash;
+
+	/** @see ECrashMediaName
+	 * RProperty for reporting the crash media name
+	 */
+	RProperty iCrashMediaName;
+
+private:
+	
+	void HandleCrashEventL(TCrashInfo* aCrashInfo);
+	TUint HelpWriteTraceBufferL(TUint aTraceAvailable, TUint aTraceWanted, TUint aOffset);
+	TUint HelpWriteTraceBufferWithTraceFrameWorkL(TUint aTraceWanted, TUint aOffset);
+};
+
+#endif // __SYMBIAN_ELF_FORMATTERV2_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/incv2/symbianelfoptionsv2.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,100 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Class holds all user configuration data
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef __ELFOPTIONSV2_H__
+#define __ELFOPTIONSV2_H__
+
+#include <e32def.h>
+#include <optionconfig.h>
+
+/**
+@internalTechnology
+@released
+
+It is used by symbian ELF formatter to manage its configuration parameters.
+*/
+class CElfOptionsV2 : public CBase
+{
+
+public:
+	static CElfOptionsV2* NewL( TUint32 aUID = 0 );
+	static CElfOptionsV2* NewLC( TUint32 aUID = 0 );
+	~CElfOptionsV2();
+
+	TBool CreateProcessData() const;
+
+	TBool CreateDataSegments() const;
+	TBool CreateCodeSegments() const;
+	TBool CreateThreadSegments() const;
+	TBool CreateRegisterSegments() const;
+	TBool CreateExecSegments() const;
+	TBool CreateProcessSegments() const;
+	TBool CreateSystemCrashInfo() const;
+	TBool CreateSystemWideOnly() const;
+	TInt TraceDataToCapture() const;
+	TBool CreateLockDataSegments() const;
+	TBool CreateRomBuildInfo() const;
+	TBool CreateHeapData() const;
+	TBool CreateVariantSpecificData() const;
+
+	TInt GetNumberConfigParametersL( );
+	COptionConfig * GetConfigParameterL( const TInt aIndex );
+	TInt SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue );
+
+private:
+	CElfOptionsV2();
+	void ConstructL( TUint32 aUID = 0 );
+
+private:
+
+    /** Available values of symbian ELF parameter index */
+	enum TElfOptions
+		{
+		ECreateSystemCrashInfo,		/**< Dump system wide info */
+		ECreateProcessData,			/**< Dump whole crashed process info */
+		ECreateDataSegments,		/**< Dump data segments */
+		ECreateCodeSegments,        /**< Dump code segments */
+		ECreateThreadSegments,		/**< Dump thread info segments */
+		ECreateRegisterSegments,	/**< Dump register data segments */
+		ECreateExecSegments,		/**< Dump executable info segments */
+		ECreateProcessSegments,		/**< Dump process info segments */
+		ECreateTraceData,			/**< Dump trace data */
+		ECreateLockSegments,		/**< Dump lock data */
+		ECreateRomInfo,				/**< Dump ROM build info */
+		ECreateHeapInfo,			/**< Dump heap info */
+		ECreateVariantInfo,			/**< Dump variant specific info */
+		EElfOptionsLast				/** Guard */
+		};
+
+    /** Symbian ELF formatter configuration parameter list */
+	RConfigParameterList	 iConfigList;
+
+    /** Available values of system crash parameter */
+	enum TSystemCrashOption
+		{
+		ESystemWideOnly = 0,			/**< Generate crash data for system, not for crashed process */
+		ECrashedProcessOnly = 1,		/**< Generate crash data for crashed process only */
+		ESystemWideAndCrashedProc = 2	/**< Generate crash data for crashed process and system wide */
+		};
+};
+
+#endif // __ELFOPTIONSV2_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/incv2/symbianelfstringinfov2.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,89 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implements handling of the string info segment in Elf core dump
+// Definition of the string info table.
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef __SYMBIAN_STRING_INFOV2_H__
+#define __SYMBIAN_STRING_INFOV2_H__
+
+_LIT8(KSymbianElfCoreDumpVersionV2, "2.0.0");
+
+/**
+@internalTechnology
+@released
+
+String info table is used by symbian elf formatter to manage the string segment data.
+*/
+class CStringInfoTableV2 : public CBase
+{
+public:
+	static CStringInfoTableV2* NewL();
+	static CStringInfoTableV2* NewLC();
+
+	static CStringInfoTableV2* NewL(const TDesC8& aStrings);
+	static CStringInfoTableV2* NewLC(const TDesC8& aStrings);
+
+	~CStringInfoTableV2();
+
+public:
+	TUint GetIndex(const TDesC8 &aItem);
+	TUint AddStringL(const TDesC8 &aItem);
+	TText8* GetAllStrings();
+	TUint GetSize();
+
+private:
+	void ConstructL();
+	void ConstructL(const TDesC8& aStrings);
+
+	CStringInfoTableV2();
+    /** internal buffer holding the content of the string table */
+	RBuf8 iBuffer;
+};
+
+/**
+Called when willing to locate the index of the specified text in the internal buffer
+@param aItem descriptor holding the text to locate
+@return index of the located text in the internall buffer
+*/
+inline TUint CStringInfoTableV2::GetIndex(const TDesC8 &aItem)
+{
+	return iBuffer.Find(aItem);
+}
+
+/**
+Called when required to get the raw content of the string table
+@return pointer to the content of the internal buffer
+*/
+inline TText8* CStringInfoTableV2::GetAllStrings()
+{
+	return (TText8*)iBuffer.Ptr();
+}
+
+/**
+Called when required to get the size of the string table
+@return size of the internal buffer
+*/
+inline TUint CStringInfoTableV2::GetSize()
+{
+	return iBuffer.Length();
+}
+
+#endif // __SYMBIAN_STRING_INFOV2_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/selflib/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/selflib/selflib.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,734 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//	Classes that allow the editing and creation of Symbian ELF files
+//
+
+/**
+ * @file selflib.cpp
+ * @prototype
+ */
+
+#include <f32file.h>
+
+#include "selflib.h"
+#include "debuglogging.h"
+#include "symbianelfstringinfov2.h"
+#include "symbianelfstringinfo.h"
+
+/**
+ * First stage construction
+ * @return Pointer to new CSELFEditor object
+ * @leave One of the System Wide Error Codes
+ */
+EXPORT_C CSELFEditor* CSELFEditor::NewL(const TDesC& aFilename)
+	{
+	LOG_ENTRY();
+
+	CSELFEditor* self = CSELFEditor::NewLC(aFilename);
+	CleanupStack::Pop();
+
+	return self;
+	}
+
+/**
+ * First stage construction. Object is left upon cleanup stack
+ * @return Pointer to new CSELFEditor object
+ * @leave One of the System Wide Error Codes
+ */
+EXPORT_C CSELFEditor* CSELFEditor::NewLC(const TDesC& aFilename)
+	{
+	LOG_ENTRY();
+
+	CSELFEditor* self = new(ELeave)CSELFEditor();
+	CleanupStack::PushL(self);
+	self->ConstructL(aFilename);
+
+	return self;
+	}
+
+/**
+ * CSELFEditor Desctructor
+ */
+CSELFEditor::~CSELFEditor()
+	{
+	LOG_ENTRY();
+
+	delete iRawData;
+	delete iStringTable;
+
+	iELFFile.Close();
+	iFsSession.Close();
+	iNewSegments.Close();
+	iProgramHeaders.Close();
+	}
+
+/**
+ * Second stage safe construction
+ * @leave One of the System Wide Error Codes
+ */
+void CSELFEditor::ConstructL(const TDesC& aFilename)
+	{
+	LOG_ENTRY();
+
+	User::LeaveIfError(iFsSession.Connect());
+	User::LeaveIfError(iELFFile.Open(iFsSession, aFilename, EFileWrite));
+
+	TInt fileSize;
+	User::LeaveIfError(iELFFile.Size(fileSize));
+
+	//Check its big enough to at least read the header
+	if(fileSize < sizeof(Elf32_Ehdr))
+		{
+		LOG_MSG("\tCSELFEditor::ConstructL --> File is not big enough to be an ELF file");
+		User::Leave(KErrCorrupt);
+		}
+
+	CacheELFHeaderL();
+
+	//Validate the ELF file
+	if(!IsValidELFFile())
+		User::Leave(KErrCorrupt);
+
+	if(!IsELFFileSupported())
+		User::Leave(KErrNotSupported);
+
+	iRawData = new(ELeave) CDesC8ArrayFlat(1);
+
+	CacheProgramHeadersL();
+	CacheStringTableL();
+	}
+
+/**
+ * Caches ELF File internally in this object
+ * @see GetELFHeader
+ * @leave One of the system wide error codes
+ */
+void CSELFEditor::CacheELFHeaderL()
+	{
+	//Read the ELF header
+	TUint fileLocation = 0;
+	TPtr8 hdrDes((TUint8*)&iELFHeader, sizeof(Elf32_Ehdr));
+	User::LeaveIfError(iELFFile.Read(fileLocation, hdrDes));
+	}
+
+/**
+ * CSELFEditor Constructor
+ */
+CSELFEditor::CSELFEditor()
+	{}
+
+/**
+ * This ELF library currently only supports a specific subset of the ELF standard.
+ * This function makes sure the ELF file supplied is part of that subset. These are the things
+ * we do not currently support:
+ * 1. 64 Bit ELF
+ * 2. ELFDATA2MSB File class (Big Endian)
+ * 3. Any sections
+ * 4. Any type other than ET_CORE
+ *
+ * @return TBool indicating if the file is OK to continue with
+ */
+TBool CSELFEditor::IsELFFileSupported()
+	{
+	LOG_ENTRY();
+
+	TBool supported = ETrue;
+	if(iELFHeader.e_ident[EI_CLASS] != ELFCLASS32)
+		{
+		LOG_MSG("\tCSELFEditor::IsElfFileSupported() --> Non 32 bit files are not supported");
+		supported = EFalse;
+		}
+
+	if(iELFHeader.e_ident[EI_DATA] != ELFDATA2LSB)
+		{
+		LOG_MSG("\tCSELFEditor::IsElfFileSupported() --> Only support Little Endian");
+		supported = EFalse;
+		}
+
+	if(iELFHeader.e_type != ET_CORE)
+		{
+		LOG_MSG("\tCSELFEditor::IsElfFileSupported() --> Only support Core Files");
+		supported = EFalse;
+		}
+
+	if(iELFHeader.e_shoff != 0 || iELFHeader.e_shnum != 0)
+		{
+		LOG_MSG("\tCSELFEditor::IsElfFileSupported() --> Do not support Sections");
+		supported = EFalse;
+		}
+
+	return supported;
+	}
+
+/**
+ * Validates the ELF file by looking at the signature
+ * @return Boolean indicating whether or not the file is valid ELF
+ */
+TBool CSELFEditor::IsValidELFFile()
+	{
+	LOG_ENTRY();
+
+	//Check signature
+	return iELFHeader.e_ident[EI_MAG0] == ELFMAG0 &&
+		iELFHeader.e_ident[EI_MAG1] == ELFMAG1 &&
+		iELFHeader.e_ident[EI_MAG2] == ELFMAG2 &&
+		iELFHeader.e_ident[EI_MAG3] == ELFMAG3;
+	}
+
+/**
+ * Provides the ELF header of this file
+ * @param aELFHeader Holds the ELF header after the call
+ */
+EXPORT_C void CSELFEditor::GetELFHeader(Elf32_Ehdr& aELFHeader)
+	{
+	LOG_ENTRY();
+	aELFHeader = iELFHeader;
+	}
+
+/**
+ * Caches the program headers from the file into this object
+ * @leave One of the system wide codes
+ */
+void CSELFEditor::CacheProgramHeadersL()
+	{
+	LOG_ENTRY();
+
+	Elf32_Phdr progHeader;
+	TPtr8 phdrPtr((TUint8*)&progHeader, sizeof(Elf32_Phdr));
+
+	TUint nextPh = iELFHeader.e_phoff;
+	for(TUint i = 0; i < iELFHeader.e_phnum; i++)
+		{
+		User::LeaveIfError(iELFFile.Read(nextPh, phdrPtr));
+		iProgramHeaders.AppendL(progHeader);
+		nextPh += sizeof(Elf32_Phdr);
+		}
+	}
+
+/**
+ * Inserts variant specific data into the ELF file
+ * @param aVarData The binary data to be inserted into the ELF file
+ * @leave One of the system wide codes
+ */
+EXPORT_C void CSELFEditor::InsertVariantSpecificDataL(const TDesC8& aVarData)
+	{
+	LOG_ENTRY();
+
+	//Store the data in the raw data array, and record its position to associate with the new section
+	iRawData->AppendL(aVarData);
+	TUint position = iRawData->Count() - 1;
+
+	//Now create the variant sepcific data dhdr and structure
+	TSELFSegment newSegment;
+
+	newSegment.iPhdr.p_type = PT_NOTE;
+	newSegment.iPhdr.p_offset = 0;    //Fill in when we write the file
+	newSegment.iPhdr.p_vaddr = 0;
+	newSegment.iPhdr.p_paddr = 0;
+	newSegment.iPhdr.p_filesz =0;
+	newSegment.iPhdr.p_memsz = 0;
+	newSegment.iPhdr.p_flags = 0;
+	newSegment.iPhdr.p_align = sizeof(TUint);
+
+	newSegment.iDhdr.d_name = 0;		//Fill in when we write the file (we need the string table)
+	newSegment.iDhdr.d_type = ESYM_NOTE_VARIANT_DATA;
+	newSegment.iDhdr.d_version = 0;	//Fill in when we write the file (we need the string table)
+	newSegment.iDhdr.d_elemnum = 1;
+	newSegment.iDhdr.d_descrsz = sizeof(Sym32_variant_spec_data);
+
+	Sym32_variant_spec_data* variantData = (Sym32_variant_spec_data*)(&newSegment.iType);
+	variantData->es_data = position;			//This data is in the iRawData until the write
+	variantData->es_size = aVarData.Size();
+
+	iNewSegments.AppendL(newSegment);
+	++iELFHeader.e_phnum;
+	}
+
+/**
+ * Commits any changes made in the CSELFEditor to the ELF file
+ * @leave One of the system wide codes
+ */
+EXPORT_C void CSELFEditor::WriteELFUpdatesL()
+	{
+	LOG_ENTRY();
+
+	//There may be nothing to do
+	if(iNewSegments.Count() == 0)
+		return;
+
+	//Create tmp file
+	TBuf<KMaxFileName> tmpFilename;
+	RFile tmpFile;
+	User::LeaveIfError(tmpFile.Temp(iFsSession, KTempFileLocation, tmpFilename, EFileWrite));
+	CleanupClosePushL(tmpFile);
+
+	//Log file name
+	TPtr8 smallName((TUint8*)tmpFilename.Ptr(), 2*tmpFilename.Length(), 2*tmpFilename.Length());
+	LOG_MSG2("\tWriteELFUpdatesL() --> Writing new temporary updates to [%S]", &smallName);
+
+	TUint numberofPhdrs = 0;
+
+	//Leave space for elf header plus program header table at start
+	TUint spaceToLeave =+ sizeof(Elf32_Ehdr) + (iNewSegments.Count() + iProgramHeaders.Count() ) * sizeof(Elf32_Phdr);
+	PutEmptySpaceAtEndOfFileL(tmpFile, spaceToLeave);
+
+	TUint phdrLoc = sizeof(Elf32_Ehdr); //phdr table starts just after ELF header
+	TUint dataLoc = spaceToLeave;
+
+	LOG_MSG("WriteELFUpdatesL --> Copying existing program headers to the tmp file");
+
+	//Store new program headers as we go
+	RArray<Elf32_Phdr> newProgramHeaders;
+
+	{
+	Elf32_Phdr phdr;
+	TPtr8 phdrPtr((TUint8*)&phdr, sizeof(Elf32_Phdr), sizeof(Elf32_Phdr));
+
+	for(TUint i = 0; i < iProgramHeaders.Count(); i++)
+		{
+		phdr = iProgramHeaders[i];
+
+		//Now we put the neccesary data after the phdr table
+		if(phdr.p_type == PT_LOAD && phdr.p_filesz != 0 && phdr.p_offset != 0)
+			{
+			phdr.p_offset = CopyFromELFFileL(phdr.p_offset, phdr.p_filesz, tmpFile, dataLoc);
+			dataLoc += phdr.p_filesz;
+			}
+		else if(phdr.p_type == PT_NOTE)
+			{
+			//Read the symbian descriptor
+			READ_STRUCTL(Sym32_dhdr, symd, iELFFile, phdr.p_offset);
+
+			//TODO: The fact that we need this *MAY* indicate flaws in SELF format. It would be nice
+			//to be able to copy a bit that was completely described by the dhdr
+			if(symd.d_type == ESYM_NOTE_REG)
+				{
+				//registers cant just be blindly copied as they contain offsets that need updating
+				TUint sizeWritten = 0;
+				phdr.p_offset = CopyRegistersL(tmpFile, phdr.p_offset, dataLoc, sizeWritten);
+				dataLoc += sizeWritten;
+				}
+			else if(symd.d_type == ESYM_NOTE_VARIANT_DATA)
+				{
+				//Variant data cant be blindly copied either as they have offsets too
+				TUint sizeWritten = 0;
+				phdr.p_offset = CopyVariantDataL(tmpFile, phdr.p_offset, dataLoc, sizeWritten);
+				dataLoc += sizeWritten;
+				}
+			//special case - needs updating so do after everything else
+			else if(symd.d_type == ESYM_NOTE_STR)
+				{
+				continue;
+				}
+			else
+				{
+				TUint sizetoCopy = sizeof(Sym32_dhdr) + symd.d_descrsz * symd.d_elemnum;
+				phdr.p_offset = CopyFromELFFileL(phdr.p_offset, sizetoCopy, tmpFile, dataLoc);
+				dataLoc += sizetoCopy;
+				}
+
+			}
+
+		//Write the updated program header
+ 		User::LeaveIfError(tmpFile.Write(phdrLoc, phdrPtr));
+		phdrLoc += sizeof(Elf32_Phdr);
+		newProgramHeaders.AppendL(phdr);
+		++numberofPhdrs;
+		}
+	LOG_MSG2("WriteELFUpdatesL --> Copied [%d] existing program headers (minus string table)", numberofPhdrs);
+	}
+
+	//Now we add the new segments
+	
+	//This is for the string table
+	TBuf8<KMaxFileName> varDataBuf;
+	varDataBuf.Format(_L8("CORE.SYMBIAN.VARDATA"));
+	TUint versionIndex = iStringTable->GetIndex(KSymbianElfCoreDumpVersionV2);
+
+	for(TUint i = 0; i < iNewSegments.Count(); i++)
+		{
+		TSELFSegment segment = iNewSegments[i];
+
+		//Update the program header and the d_hdr
+		segment.iPhdr.p_offset = dataLoc;
+
+
+		TInt index = iStringTable->AddStringL(varDataBuf);
+		segment.iDhdr.d_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+		segment.iDhdr.d_version = versionIndex;
+
+		Sym32_variant_spec_data* variantData = (Sym32_variant_spec_data*)(&segment.iType);
+		TUint dataIndex = variantData->es_data;
+		variantData->es_data = dataLoc + sizeof(Sym32_variant_spec_data) + sizeof(Sym32_dhdr);
+
+		//Write the phdr
+		TPtr8 nphdrPtr((TUint8*)&segment.iPhdr, sizeof(Elf32_Phdr), sizeof(Elf32_Phdr));
+		User::LeaveIfError(tmpFile.Write(phdrLoc, nphdrPtr));
+		newProgramHeaders.AppendL(segment.iPhdr);
+		phdrLoc += sizeof(Elf32_Phdr);
+		++numberofPhdrs;
+
+		//Write the dhdr
+		TPtr8 ndhdrPtr((TUint8*)&segment.iDhdr, sizeof(Sym32_dhdr), sizeof(Sym32_dhdr));
+		User::LeaveIfError(tmpFile.Write(dataLoc, ndhdrPtr));
+		dataLoc += sizeof(Sym32_dhdr);
+
+		//Write the var struct
+		TPtr8 nvarHdr((TUint8*)&segment.iType, sizeof(Sym32_variant_spec_data), sizeof(Sym32_variant_spec_data));
+		User::LeaveIfError(tmpFile.Write(dataLoc, nvarHdr));
+		dataLoc += sizeof(Sym32_variant_spec_data);
+
+		//Write the data
+		User::LeaveIfError(tmpFile.Write(dataLoc, (*iRawData)[dataIndex]));
+		dataLoc += variantData->es_size;
+		}
+
+	//Write the string info
+	Elf32_Phdr sphdr;
+	TPtr8 sphdrPtr((TUint8*)&sphdr, sizeof(Elf32_Phdr), sizeof(Elf32_Phdr));
+
+	sphdr.p_type = PT_NOTE;
+	sphdr.p_offset = WriteStringInfoL(tmpFile, dataLoc);
+	sphdr.p_vaddr = 0;
+	sphdr.p_paddr = 0;
+	sphdr.p_filesz = 0;
+	sphdr.p_memsz = 0;
+	sphdr.p_flags = 0;
+	sphdr.p_align = 4;
+
+	User::LeaveIfError(tmpFile.Write(phdrLoc, sphdrPtr));
+	newProgramHeaders.Append(sphdr);
+	phdrLoc += sizeof(Elf32_Phdr);
+	++numberofPhdrs;
+
+	//Last thing, is to finally update the ELF header and write it
+	iELFHeader.e_phoff = sizeof(Elf32_Ehdr);
+	iELFHeader.e_phnum = numberofPhdrs;
+
+	LOG_MSG("\tWriting final ELF Header");
+	TPtr8 hdrPtr((TUint8*)&iELFHeader, sizeof(Elf32_Ehdr), sizeof(Elf32_Ehdr));
+	User::LeaveIfError(tmpFile.Write(0, hdrPtr));
+
+	tmpFile.Flush();
+	CleanupStack::PopAndDestroy(&tmpFile);
+
+	TBuf<KMaxFileName> origFilename;
+	iELFFile.FullName(origFilename);
+	iELFFile.Close();
+
+	SwapFilesL(tmpFilename, origFilename);
+
+	//Open the file again for further use and reset data structs
+	User::LeaveIfError(iELFFile.Open(iFsSession, origFilename, EFileWrite));
+
+	iNewSegments.Reset();
+	iProgramHeaders.Close();
+	iProgramHeaders = newProgramHeaders;  //Update with latest p hdrs
+	}
+
+/**
+ * Writes the string info at specified offset
+ * This writes the Sym32_dhdr and the string info
+ * @param aFile File to write to
+ * @param aOffset Position in file to write to. This is updated and finishes at the next free point to
+ * write to in this file
+ * @leave One of the system wide codes
+ * @return Offset in the file where this was written to (the initial value of aOffset)
+ */
+TUint CSELFEditor::WriteStringInfoL(RFile aFile, TUint& aOffset)
+	{
+	LOG_ENTRY();
+
+	TUint writeStart = aOffset;
+
+	Sym32_dhdr dhdr;
+	TPtr8 dhdrPtr((TUint8*)&dhdr, sizeof(Sym32_dhdr), sizeof(Sym32_dhdr));
+
+	TInt index = iStringTable->GetIndex(KStr);
+	dhdr.d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+	dhdr.d_descrsz	= iStringTable->GetSize();
+	dhdr.d_type		= ESYM_NOTE_STR;
+	dhdr.d_version	= iStringTable->GetIndex(KSymbianElfCoreDumpVersionV2);
+    dhdr.d_elemnum	= 1;
+
+	//Write the dhdr
+	User::LeaveIfError(aFile.Write(aOffset, dhdrPtr));
+	aOffset += sizeof(Sym32_dhdr);
+
+	//Write the string info
+	TText8* buf = iStringTable->GetAllStrings();
+	TUint size = iStringTable->GetSize();
+
+	TPtr8 data((TUint8*)buf, size, size);
+	User::LeaveIfError(aFile.Write(aOffset, data));
+	aOffset += size;
+
+	return writeStart;
+	}
+
+/**
+ * Copies the registers to aFile sensibly, updating the offsets accordingly
+ * @param aFile Destination file
+ * @param aSrcRead Place in src file where d_hdr starts
+ * @param aDestWrite Destination to write to
+ * @leave One of the system wide codes
+ */
+TUint CSELFEditor::CopyRegistersL(RFile aFile, TUint aSrcRead, TUint aDestWrite, TUint& aSizeWritten)
+	{
+	LOG_ENTRY();
+
+	aSizeWritten = 0;
+	TUint srcpos = aSrcRead;
+	TUint destpos = aDestWrite;
+
+	//Write the dhdr, it wont change
+	READ_STRUCTL(Sym32_dhdr, dhdr, iELFFile, srcpos);
+	CopyFromELFFileL(srcpos, sizeof(Sym32_dhdr), aFile, destpos);
+	srcpos += sizeof(Sym32_dhdr);
+	destpos += sizeof(Sym32_dhdr);
+
+	//And the reginfod struct
+	READ_STRUCTL(Sym32_reginfod, reginfo, iELFFile, srcpos);
+	CopyFromELFFileL(srcpos, sizeof(Sym32_reginfod), aFile, destpos);
+	srcpos += sizeof(Sym32_reginfod);
+	destpos += sizeof(Sym32_reginfod);
+
+	RBuf8 regVals;
+	regVals.CreateL(reginfo.rid_num_registers * sizeof(TUint64));
+	regVals.CleanupClosePushL();
+
+	//Now we need to go through the individual register values. They are offset to somewhere and
+	//we need to figure out where we will be putting them first
+	TUint regoffset = destpos + (reginfo.rid_num_registers * sizeof(Sym32_regdatad) );
+	for(TUint i = 0; i < reginfo.rid_num_registers; i++)
+		{
+		READ_STRUCTL(Sym32_regdatad, regdata, iELFFile, srcpos);
+		srcpos += sizeof(Sym32_regdatad);
+
+		//update the offset
+		TUint srcOffset = regdata.rd_data;
+		regdata.rd_data = regoffset;
+		regoffset += sizeof(TUint64);
+
+		//Write it to the file
+		TPtr8 dataPtr((TUint8*)&regdata, sizeof(Sym32_regdatad), sizeof(Sym32_regdatad));
+		User::LeaveIfError(aFile.Write(destpos, dataPtr));
+		destpos += sizeof(Sym32_regdatad);
+
+		//Read the appropriate value
+		TUint32 regValue = 0;
+		TPtr8 regValuePtr((TUint8*)&regValue, sizeof(TUint64), sizeof(TUint64));
+
+		switch(reginfo.rid_repre)
+			{
+			case ESYM_REG_8:
+				User::LeaveIfError(iELFFile.Read(srcOffset, regValuePtr, sizeof(TUint8)));
+				break;
+			case ESYM_REG_16:
+				User::LeaveIfError(iELFFile.Read(srcOffset, regValuePtr, sizeof(TUint16)));
+				break;
+			case ESYM_REG_32:
+				User::LeaveIfError(iELFFile.Read(srcOffset, regValuePtr, sizeof(TUint32)));
+				break;
+			case ESYM_REG_64:
+				User::LeaveIfError(iELFFile.Read(srcOffset, regValuePtr, sizeof(TUint64)));
+				break;
+			default:
+				regValue = 0;
+				break;
+			}
+
+		regValuePtr.SetLength(sizeof(TUint64));
+		regVals.Append(regValuePtr);
+		}
+
+	//Now write the values
+	User::LeaveIfError(aFile.Write(destpos, regVals));
+	destpos += regVals.Size();
+
+	CleanupStack::PopAndDestroy(&regVals);
+
+	aSizeWritten = destpos - aDestWrite;
+	return aDestWrite;
+	}
+
+/**
+ * Copies the variant data to aFile sensibly, updating the offsets accordingly
+ * @param aFile Destination file
+ * @param aSrcRead Place in src file where d_hdr starts
+ * @param aDestWrite Destination to write to
+ * @leave One of the system wide codes
+ */
+TUint CSELFEditor::CopyVariantDataL(RFile aFile, TUint aSrcRead, TUint aDestWrite, TUint& aSizeWritten)
+	{
+	LOG_ENTRY();
+
+	aSizeWritten = 0;
+	TUint srcpos = aSrcRead;
+	TUint destpos = aDestWrite;
+
+	//Write the dhdr, it wont change
+	READ_STRUCTL(Sym32_dhdr, dhdr, iELFFile, srcpos);
+	CopyFromELFFileL(srcpos, sizeof(Sym32_dhdr), aFile, destpos);
+	srcpos += sizeof(Sym32_dhdr);
+	destpos += sizeof(Sym32_dhdr);
+
+	//And the var data struct
+	READ_STRUCTL(Sym32_variant_spec_data, varData, iELFFile, srcpos);
+	varData.es_data = destpos + sizeof(Sym32_variant_spec_data);
+
+	TPtr8 varDataPtr((TUint8*)&varData, sizeof(Sym32_variant_spec_data), sizeof(Sym32_variant_spec_data));
+	User::LeaveIfError(aFile.Write(destpos, varDataPtr));
+	srcpos += sizeof(Sym32_variant_spec_data);
+	destpos += sizeof(Sym32_variant_spec_data);
+
+	//And the data
+	CopyFromELFFileL(srcpos, varData.es_size, aFile, destpos);
+	srcpos += varData.es_size;
+	destpos += varData.es_size;
+
+	aSizeWritten = destpos - aDestWrite;
+	return aDestWrite;
+	}
+
+/**
+ * Copies a part of the ELF file into a destination file
+ * @param aStartPoint Point in file to start copying
+ * @param aSize Amount to copy
+ * @param aDestinationFile Destination file to copy to
+ * @param aDestWrite Position in destination to write to
+ * @return Place in file where this has been written
+ * @leave One of the System wide codes
+ */
+TUint CSELFEditor::CopyFromELFFileL(TUint aStartPoint, TUint aSize, RFile aDestinationFile, TUint aDestWrite)
+	{
+	TUint readpos = aStartPoint;
+	TUint endpoint = aStartPoint + aSize;
+	TUint destpos = aDestWrite;
+
+	//Use free memory/10 for our buffering
+	TInt block = 0;
+	TInt freemem = User::Available(block);
+	TInt maxfilecopysize = freemem/10;
+
+	RBuf8 copybuf;
+	copybuf.CreateL(maxfilecopysize);
+	copybuf.CleanupClosePushL();
+
+	while(readpos < endpoint)
+		{
+		TUint readsize = maxfilecopysize;
+		if(readpos + readsize > endpoint)
+			readsize = endpoint - readpos;
+
+		if(readsize != copybuf.MaxLength())
+			copybuf.ReAllocL(readsize);
+
+		User::LeaveIfError(iELFFile.Read(readpos, copybuf, readsize));
+		User::LeaveIfError(aDestinationFile.Write(destpos, copybuf));
+
+		copybuf.Zero();
+
+		destpos += readsize;
+		readpos += readsize;
+		}
+
+	CleanupStack::PopAndDestroy(&copybuf);
+
+	return aDestWrite;
+	}
+
+/**
+ * Caches the string table in source ELF file into our string info table object
+ * @leaves One of the system wide codes
+ */
+void CSELFEditor::CacheStringTableL()
+	{
+	LOG_ENTRY();
+
+	for(TUint i = 0; i < iProgramHeaders.Count(); i++)
+		{
+		Elf32_Phdr phdr = iProgramHeaders[i];
+
+		READ_STRUCTL(Sym32_dhdr, dhdr, iELFFile, phdr.p_offset);
+		if(dhdr.d_type == ESYM_NOTE_STR)
+			{
+			iStringTableDhdr = dhdr;
+
+			RBuf8 stringData;
+			stringData.CreateL(dhdr.d_descrsz);
+			stringData.CleanupClosePushL();
+
+			User::LeaveIfError(iELFFile.Read(phdr.p_offset + sizeof(Sym32_dhdr), stringData));
+			iStringTable = CStringInfoTableV2::NewL(stringData);
+
+			CleanupStack::PopAndDestroy(&stringData);
+			return;
+			}
+		}
+	}
+
+/**
+ * Utility function to leave space in the file
+ * @param aFile
+ * @param aSize
+ */
+void CSELFEditor::PutEmptySpaceAtEndOfFileL(RFile aFile, TUint aSize)
+	{
+	LOG_ENTRY();
+
+	RBuf8 empty;
+	empty.CreateL(aSize);
+	empty.CleanupClosePushL();
+	empty.SetLength(aSize);
+
+	LOG_MSG2("\tPutEmptySpaceAtEndOfFileL --> Leaving [0x%X] bytes", aSize);
+	User::LeaveIfError(aFile.Write(empty));
+
+	CleanupStack::PopAndDestroy(&empty);
+	}
+
+/**
+ * Swaps 2 files and deletes the original destination
+ * @leave One of the system wide codes
+ */
+void CSELFEditor::SwapFilesL(const TDesC& aSrc, const TDesC& aDest)
+	{
+	LOG_ENTRY();
+
+	//1. Back up the destination file in case anything fails
+	TBuf<KMaxFileName> backupName;
+	backupName.Copy(aDest);
+	backupName.Append(_L(".bak"));
+
+	CFileMan* fmanager = CFileMan::NewL(iFsSession);
+	CleanupStack::PushL(fmanager);
+	
+	User::LeaveIfError(fmanager->Rename(aDest, backupName));
+	
+	//2. Rename the src file to the dest file
+	TInt err = fmanager->Move(aSrc, aDest);
+	if(KErrNone != err)
+		{
+		//rename failed so restore original file
+		TPtr8 dest8((TUint8*)aDest.Ptr(), 2*aDest.Length(), 2*aDest.Length());
+		RDebug::Printf("\nFailed to move the tmp file so restoring original file [%S]", &dest8);
+		User::LeaveIfError(fmanager->Rename(backupName, aDest));
+		User::Leave(err);
+		}
+
+	//3. Delete the backup file file
+	User::LeaveIfError(fmanager->Delete(backupName));
+	CleanupStack::PopAndDestroy(fmanager);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/selflib/selflib.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,117 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//	Classes that allow the editing and creation of Symbian ELF files
+//
+
+/**
+ * @file
+ * @publishedAll
+ * @prototype
+ */
+
+#ifndef __SELF_LIB_H__
+#define __SELF_LIB_H__
+
+#include <e32base.h>
+#include <e32debug.h>
+#include <f32file.h>
+#include <elfdefs.h>
+#include <badesca.h>
+#include <symbianelfdefs.h>
+
+_LIT(KTempFileLocation, "C:\\"); //TODO: Investigate system drive
+
+/** Reads a struct from a file
+ *	@param t Type to read
+ *	@param s the structure
+ *	@param f RFile to read from
+ *	@param r Point in the file from which to read
+ * */
+#define READ_STRUCTL(t, s, f, r)\
+	t s;\
+	{\
+	TPtr8 ptr((TUint8*)&s, sizeof(s), sizeof(s));\
+	User::LeaveIfError(f.Read(r, ptr));\
+	}
+
+/**
+ * This represents a Symbian Note segment in an ELF file
+ * It consits of a program header, descriptor header and
+ * the Note specific segment.
+ */
+struct TSELFSegment
+	{
+	Elf32_Phdr iPhdr;
+	Sym32_dhdr iDhdr;
+
+	union TSegmentType
+		{
+		Sym32_variant_spec_data iVarData;
+		//Other section types can live here - currently only support variant specific data
+		};
+
+	TSegmentType iType;
+	};
+
+class CStringInfoTableV2;
+
+/**
+ * This class is the interface to allow editing of SELF files
+ */
+class CSELFEditor : public CBase
+	{
+	public:
+		IMPORT_C static CSELFEditor* NewL(const TDesC& aFilename);
+		IMPORT_C static CSELFEditor* NewLC(const TDesC& aFilename);
+
+		IMPORT_C void GetELFHeader(Elf32_Ehdr& aELFHeader);
+		IMPORT_C void InsertVariantSpecificDataL(const TDesC8& aVarData);
+		IMPORT_C void WriteELFUpdatesL();
+
+		virtual ~CSELFEditor();
+
+	private:
+		CSELFEditor();
+		void ConstructL(const TDesC& aFilename);
+		TBool IsValidELFFile();
+		TBool IsELFFileSupported();
+
+		TUint CopyFromELFFileL(TUint aStartPoint, TUint aSize, RFile aDestinationFile, TUint aDestWrite = 0);
+		TUint CopyRegistersL(RFile aFile, TUint aSrcRead, TUint aDestWrite, TUint& aSizeWritten);
+		TUint CopyVariantDataL(RFile aFile, TUint aSrcRead, TUint aDestWrite, TUint& aSizeWritten);
+		void PutEmptySpaceAtEndOfFileL(RFile aFile, TUint aSize);
+
+		void CacheStringTableL();
+		void CacheProgramHeadersL();
+		void CacheELFHeaderL();
+
+		TUint WriteStringInfoL(RFile aFile, TUint& aOffset);
+		void SwapFilesL(const TDesC& aSrc, const TDesC& aDest);
+
+	private:
+		RFs iFsSession;
+		RFile iELFFile;
+		RArray<TSELFSegment> iNewSegments;
+		RArray<Elf32_Phdr> iProgramHeaders;
+
+		Elf32_Ehdr iELFHeader;
+		Sym32_dhdr iStringTableDhdr;
+		CStringInfoTableV2* iStringTable;
+
+		//Flat array of descriptors for data to be inserted to ELF
+		CDesC8Array* iRawData;
+
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,11 @@
+Directory for:
+  coredump\plugins\formatters\symbian_elf\src
+
+All the source, including subdirectories, to implement the Symbian ELF formatter.
+
+  
+Implements the ECOM interface in coredump\interface\formatter.
+
+Uses the data source interface in coredump\interface\data_source.
+
+Uses the data save interface in coredump\interface\writer
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/symbianelfformatter.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1843 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implementation of CSymbianElfFormatter class
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+ @see CCoreDumpFormatter
+*/
+
+#include <e32base.h>
+#include <e32property.h>
+#include <e32debug.h>
+
+#include <coredumpserverapi.h>
+#include "symbianelfformatter.h"
+#include "symbianelfstringinfo.h"
+
+#define KMaxCrc32Size 1000
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CSymbianElfFormatter* CSymbianElfFormatter::NewL()
+{
+	LOG_MSG("->CSymbianElfFormatter::NewL()->\n");
+	CSymbianElfFormatter* self = CSymbianElfFormatter::NewLC();
+	CleanupStack::Pop();
+	return self;
+}
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CSymbianElfFormatter* CSymbianElfFormatter::NewLC()
+{
+	LOG_MSG("->CSymbianElfFormatter::NewLC()->\n");
+	CSymbianElfFormatter* self = new(ELeave)CSymbianElfFormatter();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+}
+
+/**
+ctor nothing really
+*/
+CSymbianElfFormatter::CSymbianElfFormatter()
+{
+	LOG_MSG("->CSymbianElfFormatter::CSymbianElfFormatter()\n");
+}
+
+/**
+2nd stage construction
+Creates elf options object
+*/
+void CSymbianElfFormatter::ConstructL()
+{
+	iElfOptions = CElfOptions::NewL( (TUint32)KSymbianELFFormatterUid );
+	iElfFileName.CreateL(KMaxFileName);
+}
+
+/**
+dtor frees elf options object
+*/
+CSymbianElfFormatter::~CSymbianElfFormatter()
+{
+	LOG_MSG( "CSymbianElfFormatter::~CSymbianElfFormatter()\n" );
+
+	iElfFileName.Close();
+
+    if(iElfOptions)
+    {
+	    delete iElfOptions;
+        iElfOptions = NULL;
+    }
+}
+
+/**
+Sets pointer to the writer plugin.  Configures formatter's dump data save plugin.
+@param aDataSave Pointer to writer plugin
+@leave KErrNoMemory if aDataSave is NULL
+*/
+void CSymbianElfFormatter::ConfigureDataSaveL( CCrashDataSave * aDataSave )
+{
+	LOG_MSG("->CSymbianElfFormatter::ConfigureDataSave()\n");
+    User::LeaveIfNull(aDataSave);
+	iDataSave  = aDataSave;
+}
+
+/**
+Sets pointer to the crash data server. Configures formatter's crash data source plugin
+@param aDataSource Pointer to Crash Data Source
+@leave KErrNoMemory if aDataSource is NULL
+*/
+void CSymbianElfFormatter::ConfigureDataSourceL( CCrashDataSource * aDataSource )
+{
+	LOG_MSG("->CSymbianElfFormatter::ConfigureDataSource()\n");
+    User::LeaveIfNull(aDataSource);
+	iDataSource = aDataSource;
+}
+
+/**
+Returns a description of the plugin.
+@param aPluginDescription Output parameter that contains the plugin description.
+*/
+void CSymbianElfFormatter::GetDescription( TDes & aPluginDescription )
+{
+	LOG_MSG("CSymbianElfFormatter::GetDescription()\n");
+	aPluginDescription.Copy(KPluginDescription());
+}
+
+/**
+Called by CDS to ask for the configuration parameters that the writer needs (see Plugin Configuration)
+@return actual number of implemented config parameters
+*/
+TInt CSymbianElfFormatter::GetNumberConfigParametersL( )
+	{
+	TInt numberConfigParameters = iElfOptions->GetNumberConfigParametersL( );
+	LOG_MSG2("->CSymbianElfFormatter::GetNumberConfigParametersL() will return %d \n",
+		numberConfigParameters );
+	return ( numberConfigParameters );
+	}
+
+/**
+Called by CDS to ask for configuration parameter prompt (see Plugin Configuration)
+
+@param aIndex indicates which parameter to return
+@return pointer to COptionConfig object representing the requested config parameter. Caller doesn't take ownership of the object!
+@leave KErrBadHandle if index is out of bounds
+@see COptionConfig
+*/
+COptionConfig * CSymbianElfFormatter::GetConfigParameterL( const TInt aIndex )
+	{
+	return ( iElfOptions->GetConfigParameterL( aIndex ) );
+	}
+
+/**
+Change a configuration parameter.
+@param aIndex Index of the configuration parameter.
+@param aValue Value of the configuration parameter as an int
+@param aDescValue Value of the configuration parameter as a string
+@leave err one of the system wide error codes
+@see COptionConfig
+@see CElfOptions
+*/
+void CSymbianElfFormatter::SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue )
+	{
+	LOG_MSG3("->CSymbianElfFormatter::SetConfigParameterL(index=%d, val=%d)\n", aIndex, aValue );
+	iElfOptions->SetConfigParameterL( aIndex, aValue, aDescValue );
+	}
+
+/**
+Create and save Sym32_syminfod segment.
+@param aCrashInfo TCrashInfo data structure holding information about the crash.
+@param aCrc32 CRC calculated for the crashed executable
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+@see Sym32_syminfod
+*/
+TUint CSymbianElfFormatter::WriteSymbianInfoL(const TCrashInfo &aCrashInfo, const TUint32 aCrc32 )
+{
+	LOG_MSG2( "CSymbianElfFormatter::WriteSymbianInfoL( pid=0x%X)\n", I64LOW(aCrashInfo.iPid) );
+
+	TUint offset = iOffset;
+	LOG_MSG2( " iOffset at start of WriteSymbianInfoL->%d", iOffset );
+
+	Sym32_dhdr *symInfo_descriptor = new(ELeave) Sym32_dhdr();
+	CleanupStack::PushL(symInfo_descriptor);
+
+	TInt32 index = iStrInfoTbl->GetIndex(KSymbian);
+	symInfo_descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+	symInfo_descriptor->d_descrsz	= sizeof(Sym32_syminfod);
+	LOG_MSG2( " symInfo_descriptor->d_descrsz = 0x%X", symInfo_descriptor->d_descrsz);
+	symInfo_descriptor->d_type		= ESYM_NOTE_SYM;
+	symInfo_descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+    symInfo_descriptor->d_elemnum	= 1;
+
+	LOG_MSG3( "  iDataSave->WriteL( iOffset=%d, symInfo_descriptor, sizeof(Sym32_dhdr)=%d)", iOffset, sizeof(Sym32_dhdr) );
+	iDataSave->WriteL( iOffset, symInfo_descriptor, sizeof(Sym32_dhdr));
+
+	LOG_MSG( "  CleanupStack::PopAndDestroy(symInfo_descriptor);" );
+	CleanupStack::PopAndDestroy(symInfo_descriptor); // symInfo_descriptor
+
+	iOffset += sizeof(Sym32_dhdr);
+
+	// get Symbian Info from iDataSource
+	Sym32_syminfod *symInfo = new(ELeave) Sym32_syminfod();
+	CleanupStack::PushL(symInfo);
+
+	symInfo->sd_exit_type = aCrashInfo.iType; // ECrashException or EEventsKillThread
+	LOG_MSG2( " Sym32_syminfod->sd_exit_type = 0x%X", symInfo->sd_exit_type );
+
+	index = KErrNotFound;
+
+	if( TCrashInfo::ECrashException == aCrashInfo.iType )
+		{
+		LOG_MSG2( " symInfo->sd_exit_reason = aCrashInfo->iExcNumber = 0x%X", aCrashInfo.iExcNumber );
+		symInfo->sd_exit_reason = aCrashInfo.iExcNumber;
+		}
+	else if( TCrashInfo::ECrashKill == aCrashInfo.iType )
+		{
+		LOG_MSG2( " symInfo->sd_exit_reason = aCrashInfo.iReason = 0x%X", aCrashInfo.iReason );
+		symInfo->sd_exit_reason = aCrashInfo.iReason;
+
+		TBuf8<KMaxExitCategoryName> buf;
+		LOG_MSG( "  buf.Copy(aCrashInfo.iCategory)" );
+		buf.Copy(aCrashInfo.iCategory);
+		if (buf.Length() > 0)
+			{
+			index = iStrInfoTbl->AddStringL(buf);
+			}
+		LOG_MSG2( "  Added Crash Category at index %d", index );
+		}
+
+	symInfo->sd_thread_id = aCrashInfo.iTid;
+	symInfo->sd_proc_id = aCrashInfo.iPid;
+	symInfo->sd_date_time = aCrashInfo.iTime;
+	LOG_MSG2( " sizeof(Sym32_syminfod->symInfo->sd_date_time) = 0x%X", sizeof(symInfo->sd_date_time)  );
+	LOG_MSG3( " time high low = 0x%X%X", I64HIGH(symInfo->sd_date_time), I64LOW(symInfo->sd_date_time) );
+
+	symInfo->sd_execid.exec_id = aCrashInfo.iTime;
+	symInfo->sd_execid.exec_crc = aCrc32;
+	symInfo->sd_exit_cat = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+
+	// Write the Symbian specifics to file
+	LOG_MSG3( "  iDataSave->WriteL( iOffset=%d, symInfo, sizeof(Sym32_syminfod)=%d)",
+		iOffset, sizeof(Sym32_syminfod) );
+	iDataSave->WriteL( iOffset, symInfo, sizeof(Sym32_syminfod));
+	CleanupStack::PopAndDestroy(symInfo);
+
+	iOffset += sizeof(Sym32_syminfod);
+	return offset;
+}
+
+/**
+Creates TDataSegment segments by checking the .rodata and .bss/.data sections of the code segments provided by data source.
+It may also create data segments for the user stacks of threads in the crashed process, depending on user configuration.
+@param aThreadId The id of the crashed thread.
+@param aPid ID of the process that owned the crashed thread
+@param aThreadList list of the threads in the crashed process or the whole system, depending on user configuration
+@param aCodeSegList list of all code segments loaded into process that crashed
+@param aDataSegs output list of created data segments
+@param aDataSegOffsets output list of media-location offsets where segment data was stored
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+@see TDataSegment
+*/
+TUint CSymbianElfFormatter::WriteDataSegmentsL( const TUint64 & aThreadId,
+											    const TUint64 & aPid,
+                                                const RThreadPointerList &aThreadList,
+                                                const RCodeSegPointerList &aCodeSegList,
+                                                RSegmentList &aDataSegs,
+                                                RArray<TUint> &aDataSegOffsets )
+	{
+
+	LOG_MSG2( "CSymbianElfFormatter::WriteDataSegmentsL(aThreadId=0x%X)\n", I64LOW(aThreadId) );
+	TUint offset = iOffset;
+
+	if(!iElfOptions->CreateDataSegments())
+        {
+        LOG_MSG("CSymbianElfFormatter::WriteDataSegmentsL - not configured to dump data segs");
+        return offset;
+        }
+
+    LOG_MSG("CSymbianElfFormatter::WriteDataSegmentsL - generating data segments\n");
+    TSegmentInfo segInfo;
+    // Create data segments for the threads' stacks in this process
+    for( TInt i = 0; i < aThreadList.Count(); i++ )
+        {
+
+		if( aThreadList[i]->ProcessId() != aPid )
+			{
+			// Thread not in crashed process
+			continue;
+			}
+
+        CThreadInfo &threadInfo = *aThreadList[i];
+
+        LOG_MSG2( "  Generating stack data segment for thread 0x%X\n", I64LOW(threadInfo.Id()) );
+
+        segInfo.iSegBase = threadInfo.UsrStackAddr();
+        segInfo.iSegSize = threadInfo.UsrStackSize();
+        segInfo.iFlags = PF_W | PF_R;
+
+        LOG_MSG3( "CSymbianElfFormatter::WriteDataSegmentsL - .stack base=0x%X, size=%d)", segInfo.iSegBase, segInfo.iSegSize );
+        aDataSegs.AppendL( segInfo );
+        }
+
+    LOG_MSG2( "  Found %d .stack data segments for crashed thread", aDataSegs.Count() );
+
+    // Create data segments for the .rodata .data .bss sections of the exe and dlls in this proc
+    for(TInt i = 0;  i < aCodeSegList.Count(); i++)
+        {
+        TCodeSegInfo &codeSeg = *aCodeSegList[i];
+        if(codeSeg.iRoDataSize != 0)
+            {
+            segInfo.iSegBase = codeSeg.iRoDataRunAddr;
+            segInfo.iSegSize = codeSeg.iRoDataSize;
+            segInfo.iFlags = PF_R;
+            LOG_MSG3( "CSymbianElfFormatter::WriteDataSegmentsL - .rodata base=0x%X, size=%d)", segInfo.iSegBase, segInfo.iSegSize );
+            aDataSegs.AppendL(segInfo);
+            }
+
+        if(codeSeg.iDataSize != 0)
+            {
+            segInfo.iSegBase = codeSeg.iDataRunAddr;
+            segInfo.iSegSize = codeSeg.iDataSize;
+            segInfo.iFlags = PF_W | PF_R;
+            LOG_MSG3( "CSymbianElfFormatter::WriteDataSegmentsL - .data base=0x%X, size=%d)", segInfo.iSegBase, segInfo.iSegSize );
+            aDataSegs.AppendL(segInfo);
+            }
+        }
+
+    LOG_MSG2( "  Total %d Data Segments for crashed thread", aDataSegs.Count() );
+
+    // Dumping memory content of the identified data segments
+    for (TInt i = 0; i < aDataSegs.Count(); i++)
+        {
+        RBuf8 memData;
+        CleanupClosePushL(memData);
+
+        memData.CreateL( aDataSegs[i].iSegSize );
+
+        LOG_MSG4( "iDataSource->ReadMemory(ThreadId=0x%X, at=0x%X, size=0x%X)\n",
+                I64LOW(aThreadId), aDataSegs[i].iSegBase, aDataSegs[i].iSegSize );
+
+        TRAPD( memReadErr, iDataSource->ReadMemoryL(aThreadId, aDataSegs[i].iSegBase, aDataSegs[i].iSegSize, memData ) );
+        if( KErrNone != memReadErr )
+            {
+            LOG_MSG2( "  ERROR %d from ReadMemory(). Will generate empty segment\n", memReadErr );
+            // This means that there will be a data segment that points to no data
+            aDataSegOffsets.AppendL( 0 );
+            CleanupStack::PopAndDestroy(&memData);
+            continue;
+            }
+
+        // save memData to core dump
+        LOG_MSG3( "  iDataSave->WriteL( at iOffset=%d, size=0x%X )", iOffset, aDataSegs[i].iSegSize );
+        iDataSave->WriteL( iOffset, const_cast<TUint8*>(memData.Ptr()), aDataSegs[i].iSegSize );
+        aDataSegOffsets.AppendL( iOffset );
+        iOffset += aDataSegs[i].iSegSize;
+        CleanupStack::PopAndDestroy(&memData);
+        }
+
+	return offset;
+	}
+
+/**
+Calculate the CRC of the executable code text section up to 1kbytes. We only leave if there is a terminal
+error. If we cannot generate the CRC.
+@param aTid ID of the crashed thread
+@param aExecInfo code segment structure holding iformation required to calculate crc
+@return calculated CRC value
+@leave err one of the system wide error codes
+@see TCodeSegInfo
+*/
+TUint32 CSymbianElfFormatter::CalcExecCrcL(const TUint64 &aTid, const TCodeSegInfo &aExecInfo )
+	{
+	TUint32 crc32 = 0xDEADDEAD;
+
+    TInt crcSize = aExecInfo.iCodeSize > KMaxCrc32Size ? KMaxCrc32Size : aExecInfo.iCodeSize;
+
+	RBuf8 crcData;
+	crcData.CreateL( crcSize );
+    crcData.CleanupClosePushL();
+
+    iDataSource->ReadMemoryL(aTid, aExecInfo.iCodeRunAddr, crcSize, crcData);
+
+	Mem::Crc32(crc32, crcData.Ptr(), crcData.Length());
+
+    CleanupStack::PopAndDestroy( &crcData );
+
+    return crc32;
+	}
+
+/**
+Goes through all codes segments and saves empty code segments structures as the code .text section is going to be available on the host.
+@param aThreadId The id of the crashed thread.
+@param aCodeSegs list of all code segments loaded into process that crashed
+@param aCodeSegOffsets output list of media-location offsets where segment data was stored
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+*/
+TUint CSymbianElfFormatter::WriteCodeSegmentsL( const TUint64 & aThreadId, const RCodeSegPointerList &aCodeSegs, RArray<TUint> &aCodeSegOffsets )
+{
+
+	LOG_MSG2( "CSymbianElfFormatter::WriteCodeSegmentsL(aThreadId=0x%X)\n", I64LOW(aThreadId) );
+
+	TUint offset = iOffset;
+
+	if(!iElfOptions->CreateCodeSegments())
+    {
+        LOG_MSG("CSymbianElfFormatter::WriteCodeSegmentsL - not configured to dump code segs");
+        return iOffset;
+    }
+
+    for (TInt i = 0, count = aCodeSegs.Count(); i < count; i++)
+    {
+        aCodeSegOffsets.AppendL(0); //not dumping .text section, as it will be present on the host
+	}
+
+	return offset;
+}
+
+/**
+Creates and saves Sym32_thrdinfod structures for all threads provided.
+@param aPid The id of the process of the crashed thread.
+@param aThreadList list of the threads in the crashed process or the whole system, depending on user configuration
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+@see Sym32_thrdinfod
+*/
+TUint CSymbianElfFormatter::WriteThreadInfoL( const TUint64 & aPid, const RThreadPointerList &aThreadList )
+{
+
+	LOG_MSG2("->CSymbianElfFormatter::WriteThreadInfoL(aPid=0x%X)\n", I64LOW(aPid) );
+
+	TUint offset = iOffset;
+
+	if( !iElfOptions->CreateThreadSegments() )
+	{
+        LOG_MSG("CSymbianElfFormatter::WriteThreadInfoL - not configured to dump thread info");
+        return iOffset;
+    }
+
+    Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+    CleanupStack::PushL(descriptor);
+
+    TInt index = iStrInfoTbl->GetIndex(KThread);
+    descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+    descriptor->d_descrsz	= sizeof(Sym32_thrdinfod);
+    descriptor->d_type		= ESYM_NOTE_THRD;
+    descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+    descriptor->d_elemnum	= aThreadList.Count();
+
+    iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+    iOffset += sizeof(Sym32_dhdr);
+    CleanupStack::PopAndDestroy(descriptor);
+
+    Sym32_thrdinfod *thrInfo = new(ELeave) Sym32_thrdinfod();
+    CleanupStack::PushL(thrInfo);
+
+    RBuf8 buf;
+    buf.CreateL( KMaxFullName );
+    CleanupClosePushL(buf);
+
+    for( TInt i = 0; i < aThreadList.Count(); i++ )
+    {
+        //LOG_MSG3( "  Creating Sym32_thrdinfod for Thread[%d].Id()=0x%X", i, I64LOW( aThreadList[i]->Id()) );
+        CThreadInfo &threadInfo = *aThreadList[i];
+
+        buf.Copy( threadInfo.Name() );
+
+        TInt index = KErrNotFound;
+        if (buf.Length() > 0)
+        {
+            index = iStrInfoTbl->AddStringL(buf);
+        }
+
+        thrInfo->td_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+        thrInfo->td_id = threadInfo.Id();
+        thrInfo->td_owning_process = threadInfo.ProcessId();
+        thrInfo->td_priority = threadInfo.Priority();
+        thrInfo->td_svc_sp = threadInfo.SvcStackPtr();
+        thrInfo->td_svc_stack = threadInfo.SvcStackAddr();
+        thrInfo->td_svc_stacksz = threadInfo.SvcStackSize();
+        thrInfo->td_usr_stack = threadInfo.UsrStackAddr();
+        thrInfo->td_usr_stacksz = threadInfo.UsrStackSize();
+
+        iDataSave->WriteL( iOffset, thrInfo, sizeof(Sym32_thrdinfod));
+
+        iOffset += sizeof(Sym32_thrdinfod);
+    }
+
+    CleanupStack::PopAndDestroy(2, thrInfo);
+	return offset;
+}
+
+/**
+Creates and saves Sym32_procinfod for all processes provided.
+@param aPid The id of the process of the crashed thread.
+@param aProcessList list of the processes holding the crashed process or the whole system, depending on user configuration
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+@see Sym32_procinfod
+*/
+TUint CSymbianElfFormatter::WriteProcessInfoL( const TUint64 & aPid, const RProcessPointerList &aProcessList )
+{
+
+	LOG_MSG2("->CSymbianElfFormatter::WriteProcessInfoL(aPid=0x%X)\n", I64LOW(aPid) );
+
+	TUint offset = iOffset;
+
+	if (!iElfOptions->CreateProcessSegments())
+		{
+        LOG_MSG("CSymbianElfFormatter::WriteProcessInfoL - not configured to dump process info");
+        return iOffset;
+        }
+
+    Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+    CleanupStack::PushL(descriptor);
+    descriptor->d_elemnum = aProcessList.Count();
+
+    TInt32 index = iStrInfoTbl->GetIndex(KProcess);
+    descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+    descriptor->d_descrsz	= sizeof(Sym32_procinfod);
+    descriptor->d_type		= ESYM_NOTE_PROC;
+    descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+
+    iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+    iOffset += sizeof(Sym32_dhdr);
+
+    Sym32_procinfod *symProcInfo = new(ELeave) Sym32_procinfod();
+    CleanupStack::PushL(symProcInfo );
+
+    RBuf8 buf;
+    buf.CreateL( KMaxFullName );
+    CleanupClosePushL(buf);
+
+    //LOG_MSG2( "  Will create %d Sym32_procinfod structures\n", descriptor->d_elemnum );
+    for(TInt i = 0; i < aProcessList.Count(); i++ )
+        {
+        CProcessInfo &procInfo = *aProcessList[i];
+
+        //LOG_MSG3( "  Creating Sym32_procinfod for Proc[%d].Id()=0x%X", i, I64LOW( procInfo->Id() ) );
+
+        symProcInfo->pd_id = procInfo.Id();
+
+		RProcess proc;
+		if( KErrNone == proc.Open( symProcInfo->pd_id ) )
+			{
+			symProcInfo->pd_priority = proc.Priority();
+			proc.Close();
+			}
+		else
+			{
+			symProcInfo->pd_priority = 0;
+			}
+
+        buf.Copy( procInfo.Name() );
+
+        index = KErrNotFound;
+        if (buf.Length() > 0)
+            {
+            index = iStrInfoTbl->AddStringL(buf);
+            }
+        symProcInfo->pd_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+
+        iDataSave->WriteL( iOffset, symProcInfo, sizeof(Sym32_procinfod));
+
+        iOffset += sizeof(Sym32_procinfod);
+        }
+
+	CleanupStack::PopAndDestroy(3, descriptor);
+
+	return offset;
+}
+
+/**
+Creates and saves Sym32_execinfod structures for all the code segments provided
+@param aCodeSegs list of all code segments loaded into process that crashed
+@param aTime time of the crash.
+@param aTid ID of the crashed thread
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+@see Sym32_execinfod
+*/
+TUint CSymbianElfFormatter::WriteExecutableInfoL( const RCodeSegPointerList &aCodeSegs, const TUint64 &aTime, const TUint64 &aTid )
+{
+	LOG_MSG("CSymbianElfFormatter::WriteExecutableInfoL()\n");
+
+	TUint offset = iOffset;
+
+	if(!iElfOptions->CreateExecSegments())
+        {
+        LOG_MSG("CSymbianElfFormatter::WriteExecutableInfoL - not configured to dump executable info");
+        return iOffset;
+        }
+
+    // Get Executable Info
+    Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+    CleanupStack::PushL(descriptor);
+
+    TInt32 index = iStrInfoTbl->GetIndex(KExecutable);
+    descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+    descriptor->d_descrsz	= sizeof(Sym32_execinfod);
+    descriptor->d_type		= ESYM_NOTE_EXEC;
+    descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+    descriptor->d_elemnum	= aCodeSegs.Count();
+
+    //LOG_MSG3( "   Write ESYM_NOTE_EXEC size =%d at iOffset->%d\n", sizeof(Sym32_dhdr), iOffset );
+    iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+    CleanupStack::PopAndDestroy(descriptor); // descriptor
+
+    iOffset += sizeof(Sym32_dhdr);
+
+    Sym32_execinfod *execInfo = new(ELeave) Sym32_execinfod();
+    CleanupStack::PushL(execInfo);
+
+    RBuf8 name;
+    name.CreateL(KMaxFullName);
+    CleanupClosePushL(name);
+
+    for(TInt i = 0, count = aCodeSegs.Count(); i < count; i++)
+        {
+        TCodeSegInfo &segInfo = *aCodeSegs[i];
+        name.Copy(segInfo.iName);
+        index = KErrNotFound;
+
+        if (name.Length() > 0)
+        {
+            index = iStrInfoTbl->AddStringL(name);
+        }
+
+        execInfo->ed_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+        //LOG_MSG2( "   execInfo->ed_name = %d\n", execInfo->ed_name );
+
+        execInfo->ed_XIP = segInfo.iXIP;
+        //LOG_MSG2( "   execInfo->ed_XIP = %d\n", execInfo->ed_XIP );
+
+        execInfo->ed_execid.exec_id = aTime;
+        execInfo->ed_execid.exec_crc = CalcExecCrcL(aTid, segInfo);
+
+        execInfo->ed_codesize = segInfo.iCodeSize;
+        //LOG_MSG2( "   execInfo->ed_codesize = 0x%x\n", execInfo->ed_codesize );
+        execInfo->ed_coderunaddr = segInfo.iCodeRunAddr;
+        //LOG_MSG2( "   execInfo->ed_coderunaddr = 0x%x\n", execInfo->ed_coderunaddr );
+        execInfo->ed_codeloadaddr = segInfo.iCodeLoadAddr;
+        //LOG_MSG2( "   execInfo->ed_codeloadaddr = 0x%x\n", execInfo->ed_codeloadaddr );
+        execInfo->ed_rodatasize = segInfo.iRoDataSize;
+        execInfo->ed_rodatarunaddr = segInfo.iRoDataRunAddr;
+        execInfo->ed_rodataloadaddr = segInfo.iRoDataLoadAddr;
+        execInfo->ed_datasize = segInfo.iDataSize;
+        execInfo->ed_datarunaddr = segInfo.iDataRunAddr;
+        //LOG_MSG2( "   execInfo->ed_datarunaddr = 0x%x\n", execInfo->ed_datarunaddr );
+        execInfo->ed_dataloadaddr = segInfo.iDataLoadAddr;
+        //LOG_MSG2( "   execInfo->ed_dataloadaddr = 0x%x\n", execInfo->ed_dataloadaddr );
+
+        //LOG_MSG3( "   Write execInfo size =%d at iOffset->%d\n", sizeof(Sym32_execinfod), iOffset );
+        iDataSave->WriteL( iOffset, execInfo, sizeof(Sym32_execinfod));
+
+        iOffset += sizeof(Sym32_execinfod);
+        }
+
+    CleanupStack::PopAndDestroy(2, execInfo);
+
+	return offset;
+}
+
+/**
+The method finds all registers of a specific class (core register or coprocessor register)
+and of a specific represenation (8-bit, 16-bit, 32-bit, 64-bit etc).
+
+@param aRegs Input : all registers of all classes and representations.
+@param aRegsOfSameClassRepr Output : All registers of the same class and representaion.
+@param aClass Input : Which class to use as filter
+@param aRepr INput : Which representation to use as filter.
+*/
+void CSymbianElfFormatter::FindAllOfSameClassRepresentation(RRegisterList &aRegs, RRegisterList &aRegsOfSameClassRepr, ESYM_REGCLASS aClass, ESYM_REGREP aRepr)
+{
+	for (TUint j = 0; j < aRegs.Count(); j++)
+	{
+		if ( aRegs[j].Available() &&
+			(aRegs[j].GetClass() == aClass) &&
+			(aRegs[j].GetSize() == aRepr) )
+		{
+			aRegsOfSameClassRepr.Append(aRegs[j]);
+		}
+	}
+}
+
+/**
+ Write registers for threads. For non-crashed threads we save a thread's registers
+ if the user setting CreateRegisterSegmentForAllThreadsInProcess() is true.
+ For the crashed thread we save the thread's registers if the user setting
+ CreateRegisterSegmentForCrashedThread() is true.
+ We can only save register information for threads within the crashed process.
+ The threads in the thread list may contain all threads in the system or only the
+ threads in the crashed process, depending on user choice CreateSystemCrashInfo().
+@param aTid The id of the crashed thread.
+@param aPid The id of the process of the crashed thread.
+@param aOffsets output array of offsets to each threads register information segment.
+@param aArmExcRegs register context of the crashed thread
+@param aThreadList list of the threads in the crashed process or the whole system, depending on user configuration
+@leave err one of the system wide error codes
+*/
+void CSymbianElfFormatter::WriteRegisterInfoL( const TUint64 &aTid,
+											   const TUint64 &aPid,
+											   RArray<TUint>& aOffsets,
+											   RRegisterList &aArmExcRegs,
+                                               const RThreadPointerList &aThreadList )
+{
+
+	LOG_MSG2( "CSymbianElfFormatter::WriteRegisterInfoL(aTid=0x%X)\n", I64LOW(aTid) );
+
+    if(!iElfOptions->CreateRegisterSegments())
+	    {
+        LOG_MSG("CSymbianElfFormatter::WriteRegisterInfoL - not configured to dump register info");
+        return;
+        }
+
+    Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+    CleanupStack::PushL(descriptor);
+
+    Sym32_reginfod *regInfo = new(ELeave) Sym32_reginfod();
+    CleanupStack::PushL(regInfo);
+    // For each thread, Get register info using ReadRegisters( threadId ...)
+    for (TUint i = 0; i<aThreadList.Count(); i++)
+    {
+
+        if( aThreadList[i]->ProcessId() != aPid )
+            {
+            // Thread not in crashed process
+            continue;
+            }
+
+        RRegisterList *regListPtr;
+        RRegisterList regList;
+        CleanupClosePushL(regList);
+
+        if( aThreadList[i]->Id() == aTid )
+            {
+            // Use the registers at the time of the crash: aArmExcRegs
+            regListPtr = &aArmExcRegs;
+            }
+        else
+            {
+            iDataSource->ReadRegistersL(aThreadList[i]->Id(), regList);
+            regListPtr = &regList;
+            }
+
+        /*
+        LOG_MSG3( "  Register list for thread 0x%X has %d entries",
+            I64LOW(aThreadList[i]->Id()), regListPtr->Count() );
+        */
+
+        RRegisterList tmpRegList;
+        CleanupClosePushL(tmpRegList);
+
+        TBuf8<255> buf;
+        buf.Format(_L8("CORE.SYMBIAN.REGISTER.0x%X%X"), I64HIGH(aThreadList[i]->Id()), I64LOW(aThreadList[i]->Id()));
+        TInt32 index = iStrInfoTbl->AddStringL(buf);
+        descriptor->d_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+        descriptor->d_type = ESYM_NOTE_REG;
+        descriptor->d_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+        descriptor->d_elemnum = 1;
+
+        TUint dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_CORE, ESYM_REG_8);
+
+        LOG_MSG2( "  aOffsets.Count()=%d", aOffsets.Count() );
+
+        if (tmpRegList.Count() > 0)
+        {
+            //LOG_MSG2( "  found %d ESYM_REG_8 registers", tmpRegList.Count() );
+            // Writereg8data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint8 content = tmpRegList[j].GetContent8();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint8));
+                iOffset += sizeof(TUint8);
+            }
+
+            // writedescr
+            aOffsets.Append((TUint)iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod) + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            regInfo->rid_class = ESYM_REG_CORE;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_8;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod8
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint8);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_CORE, ESYM_REG_16);
+        if (tmpRegList.Count() > 0)
+        {
+            //LOG_MSG2( "  found %d ESYM_REG_16 registers", tmpRegList.Count() );
+            // Writereg16data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint16 content = tmpRegList[j].GetContent16();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint16));
+                iOffset += sizeof(TUint16);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod) + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            // writereginfod16
+            regInfo->rid_class = ESYM_REG_CORE;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_16;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod8
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint16);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        //LOG_MSG2( "  Write reg 32. dataOffset = iOffset = %d", iOffset );
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_CORE, ESYM_REG_32);
+        if (tmpRegList.Count() > 0)
+        {
+            //LOG_MSG2( "  found %d ESYM_REG_32 registers", tmpRegList.Count() );
+
+            // WriteReg32data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                /*
+                LOG_MSG3( "  Saving register Id=0x%X, val=0x%X",
+                    tmpRegList[j].GetId(), tmpRegList[j].GetContent32() );
+                */
+                TUint32 content = tmpRegList[j].GetContent32();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint32));
+                iOffset += sizeof(TUint32);
+            }
+
+            //LOG_MSG2( "  ->aOffsets.Append(iOffset=%d)", iOffset );
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod) + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            //LOG_MSG2( "  ->iDataSave->WriteL( iOffset=%d, descriptor, sizeof(Sym32_dhdr))", iOffset );
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+            //LOG_MSG2( "  iOffset += sizeof(Sym32_dhdr) = %d", iOffset );
+
+            // writereginfod32
+            regInfo->rid_class = ESYM_REG_CORE;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_32;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+
+            //LOG_MSG2( "  iDataSave->WriteL( iOffset = %d, regInfo, sizeof(Sym32_reginfod))", iOffset );
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+            //LOG_MSG2( "  iOffset += sizeof(Sym32_reginfod) = %d", iOffset );
+
+            // writereginfod32
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint32);
+                //LOG_MSG2( "  regData.rd_data = %d", regData.rd_data  );
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_CORE, ESYM_REG_64);
+        if (tmpRegList.Count() > 0)
+        {
+            // WriteReg64data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint64 content = tmpRegList[j].GetContent64();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint64));
+                iOffset += sizeof(TUint64);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod)  + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            // writereginfod64
+            regInfo->rid_class = ESYM_REG_CORE;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_64;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod64
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint64);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_COPRO, ESYM_REG_8);
+
+        if (tmpRegList.Count() > 0)
+        {
+            // Writereg8data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint8 content = tmpRegList[j].GetContent8();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint8));
+                iOffset += sizeof(TUint8);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod)  + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            regInfo->rid_class = ESYM_REG_COPRO;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_8;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod8
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint8);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_COPRO, ESYM_REG_16);
+        if (tmpRegList.Count() > 0)
+        {
+            // Writereg16data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint16 content = tmpRegList[j].GetContent16();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint16));
+                iOffset += sizeof(TUint16);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod)  + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            // writereginfod16
+            regInfo->rid_class = ESYM_REG_COPRO;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_16;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod8
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint16);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_COPRO, ESYM_REG_32);
+        if (tmpRegList.Count() > 0)
+        {
+            //LOG_MSG2( "  found %d ESYM_REG_32 CoPro registers", tmpRegList.Count() );
+
+            // WriteReg32data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                /*
+                LOG_MSG4( "  Saving CoPro register Id=0x%X, SubId=0x%X, val=0x%X",
+                    tmpRegList[j].GetId(), tmpRegList[j].GetSubId(), tmpRegList[j].GetContent32() );
+                */
+                TUint32 content = tmpRegList[j].GetContent32();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint32));
+                iOffset += sizeof(TUint32);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod)  + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            // writereginfod32
+            regInfo->rid_class = ESYM_REG_COPRO;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_32;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod32
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint32);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_COPRO, ESYM_REG_64);
+        if (tmpRegList.Count() > 0)
+        {
+            // WriteReg64data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint64 content = tmpRegList[j].GetContent64();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint64));
+                iOffset += sizeof(TUint64);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod)  + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            // writereginfod64
+            regInfo->rid_class = ESYM_REG_COPRO;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_64;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod64
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint64);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+
+        //LOG_MSG( "  CleanupStack::PopAndDestroy( tmpRegList )" );
+        CleanupStack::PopAndDestroy(&tmpRegList); // tmpRegList. Will call Close().
+
+        //LOG_MSG( "  CleanupStack::PopAndDestroy(regList)" );
+        CleanupStack::PopAndDestroy(&regList); // regList. Will call Close().
+    }
+    //LOG_MSG( "  CleanupStack::PopAndDestroy(descriptor)" );
+    CleanupStack::PopAndDestroy(2, descriptor);
+
+	//LOG_MSG2( "  Final aOffsets.Count()=%d", aOffsets.Count() );
+}
+
+/**
+Saves content of the string info segment.
+@return value of the media-position indicator at which the call started storing its data
+*/
+TUint CSymbianElfFormatter::WriteStringInfoL()
+{
+	TUint offset = iOffset;
+
+	Sym32_dhdr *strInfo_descriptor = new(ELeave) Sym32_dhdr();
+	CleanupStack::PushL(strInfo_descriptor);
+	TInt32 index = iStrInfoTbl->GetIndex(KStr);
+	strInfo_descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+	strInfo_descriptor->d_descrsz	= iStrInfoTbl->GetSize();
+	strInfo_descriptor->d_type		= ESYM_NOTE_STR;
+	strInfo_descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+    strInfo_descriptor->d_elemnum	= 1;
+	LOG_MSG2( "   Writing Sym32_dhdr strInfo_descriptor at iOffset -> %d\n", iOffset );
+	iDataSave->WriteL( iOffset, strInfo_descriptor, sizeof(Sym32_dhdr));
+	CleanupStack::PopAndDestroy(strInfo_descriptor); // strInfo_descriptor
+	iOffset += sizeof(Sym32_dhdr);
+
+	// Write all strings
+	TText8* buf = iStrInfoTbl->GetAllStrings();
+	TUint size = iStrInfoTbl->GetSize();
+
+	LOG_MSG2( "   Writing strings at iOffset -> %d\n", iOffset );
+	iDataSave->WriteL( iOffset, buf, size);
+	LOG_MSG2( "   Strings size=%d\n", size);
+	iOffset += size;
+
+	return offset;
+}
+
+/**
+Returns requested register value.
+@param aCrashInfo TCrashInfo data structure holding information about the crash.
+@param aReg structure holding the information about the register caller wants the value of
+@param aVal output parameter where the register value is being stored
+@return ETrue if was able to get register value, EFalse otherwise
+*/
+TBool CSymbianElfFormatter::GetArmExcReg(const TCrashInfo &aCrashInfo, const TRegisterData & aReg, TRegisterValue32 & aVal)
+	{
+
+	if( ESYM_REG_CORE != aReg.GetClass() )
+		{
+		return EFalse;
+		}
+
+	switch( aReg.GetId() )
+		{
+		case ERegisterR0:
+			aVal = aCrashInfo.iContext.iR0;
+			break;
+		case ERegisterR1:
+			aVal = aCrashInfo.iContext.iR1;
+			break;
+		case ERegisterR2:
+			aVal = aCrashInfo.iContext.iR2;
+			break;
+		case ERegisterR3:
+			aVal = aCrashInfo.iContext.iR3;
+			break;
+		case ERegisterR4:
+			aVal = aCrashInfo.iContext.iR4;
+			break;
+		case ERegisterR5:
+			aVal = aCrashInfo.iContext.iR5;
+			break;
+		case ERegisterR6:
+			aVal = aCrashInfo.iContext.iR6;
+			break;
+		case ERegisterR7:
+			aVal = aCrashInfo.iContext.iR7;
+			break;
+		case ERegisterR8:
+			aVal = aCrashInfo.iContext.iR8;
+			break;
+		case ERegisterR9:
+			aVal = aCrashInfo.iContext.iR9;
+			break;
+		case ERegisterR10:
+			aVal = aCrashInfo.iContext.iR10;
+			break;
+		case ERegisterR11:
+			aVal = aCrashInfo.iContext.iR11;
+			break;
+		case ERegisterR12:
+			aVal = aCrashInfo.iContext.iR12;
+			break;
+		case ERegisterR13:
+			aVal = aCrashInfo.iContext.iR13;
+			break;
+		case ERegisterR14:
+			aVal = aCrashInfo.iContext.iR14;
+			break;
+		case ERegisterR15:
+			aVal = aCrashInfo.iContext.iR15;
+			break;
+		case ERegisterCpsr:
+			aVal = aCrashInfo.iContext.iCpsr;
+			break;
+		case ERegisterR13Svc:
+			aVal = aCrashInfo.iContext.iR13Svc;
+			break;
+		case ERegisterR14Svc:
+			aVal = aCrashInfo.iContext.iR14Svc;
+			break;
+		case ERegisterSpsrSvc:
+			aVal = aCrashInfo.iContext.iSpsrSvc;
+			break;
+		default:
+			return EFalse;
+		}
+
+	return ETrue;
+	}
+
+/**
+ This method is responsible for creating a member variable that is a list of the
+ registers available at the time of the crash for the crashed thread.
+ The registers not passed to the formatter at the time of the crash are
+ obtained from the data source API.
+@param aCrashInfo TCrashInfo data structure holding information about the crash.
+@param aArmExcRegs output list of registers
+@leave err one of the system wide error codes
+ */
+void CSymbianElfFormatter::SetArmRegsFromCrashDataL(const TCrashInfo &aCrashInfo, RRegisterList &aArmExcRegs)
+	{
+	LOG_MSG("->CSymbianElfFormatter::SetArmRegsFromCrashDataL()\n");
+
+//    aArmExcRegs.Reset();
+	// Read all registers first, then overwrite values with what we get
+	// from crash data, if available
+	iDataSource->ReadRegistersL( aCrashInfo.iTid, aArmExcRegs );
+
+	if( TCrashInfo::ECrashException != aCrashInfo.iType )
+		{
+		// The registers for the crashed thread are only available for exceptions.
+		// When not an exception, use the registers are returned by the ReadRegisters call
+		// This is not an error
+		return;
+		}
+
+	TRegisterValue32 val;
+
+	for(TInt numRegs=0; numRegs < aArmExcRegs.Count(); numRegs ++ )
+		{
+		if( GetArmExcReg( aCrashInfo, aArmExcRegs[numRegs], val ) )
+			{
+			//LOG_MSG3( "  Setting reg[%d] to =0x%X", numRegs, val );
+			aArmExcRegs[numRegs].SetContent( (TUint) val );
+			aArmExcRegs[numRegs].SetAvailable( ETrue );
+			}
+		}
+
+	// Now add the FSR and FAR to the available registers for the crashed thread
+	// These are Co-Pro registers
+	TRegisterData reg;
+	reg.iId			= 15; // Co-Pro 15
+	reg.iSize		= ESYM_REG_32;
+	reg.iRegClass	= ESYM_REG_COPRO;
+	reg.iAvailable	= ETrue;
+
+	/*
+	Create two Co-Processor registers to represent the fault status FSR and
+	fault address FAR values. The fault status and address values depend on
+	the type of exception. See /e32/nkern/arm/vectors.cia
+
+	The sub id of the register is based on the ARM instruction used to access the reg:
+
+                             Op1 CRn CRm Op2=0. Op1 bits 10-8, CRn bits 7-4
+      fault address  mrc p15, 0, c6, c0  =>          0       ,    6
+      fault status   mrc p15, 0, c5, c0  =>          0       ,    5
+    */
+
+	reg.iSubId = 6;
+	reg.iSubId <<= 4;
+	reg.SetContent( aCrashInfo.iContext.iFaultAddress );
+	reg.SetAvailable( ETrue );
+	aArmExcRegs.AppendL( reg );
+
+	reg.iSubId = 5;
+	reg.iSubId <<= 4;
+	reg.SetContent( aCrashInfo.iContext.iFaultStatus );
+	reg.SetAvailable( ETrue );
+	aArmExcRegs.AppendL( reg );
+	}
+
+/**
+ * Prepares the name of the dump file. Checks DataSave filename option, if it is provided by the user
+ * it appends the time stamp, if not it uses default name appended with the time stamp.
+ * @param aStamp lower 32 bits of the time stamp
+ * @leave err one of system wide error codes
+ */
+void CSymbianElfFormatter::PrepareFileNameL(TUint64 aStamp)
+{
+	LOG_MSG("->CSymbianElfFormatterV2::PrepareFileNameL()\n");
+
+	COptionConfig *option = iDataSave->GetConfigParameterL(CCrashDataSave::ECoreFilePath);
+	const TDesC &userFileName = option->ValueAsDesc();
+
+	if(userFileName.Length() == 0)
+		{
+		_LIT(KTxtFileFormat, "E:\\core%u.elf");
+		iElfFileName.Format(KTxtFileFormat, aStamp);
+		}
+	else
+		{
+		iElfFileName = userFileName;
+		}
+}
+
+/**
+    Cleanup item implementation for thread list in CrashEventL() method.
+@param aArray pointer to the list that is supposed to be freed
+*/
+void CSymbianElfFormatter::CleanupCodeSegList(TAny *aArray)
+{
+    LOG_MSG("->CSymbianElfFormatter::CleanupCodeSegList()\n");
+	RCodeSegPointerList *codeSegList = static_cast<RCodeSegPointerList*> (aArray);
+    codeSegList->ResetAndDestroy();
+    codeSegList->Close();
+    delete codeSegList;
+}
+
+/**
+    Cleanup item implementation for thread list in CrashEventL() method.
+@param aArray pointer to the list that is supposed to be freed
+*/
+void CSymbianElfFormatter::CleanupProcessList(TAny *aArray)
+{
+    LOG_MSG("->CSymbianElfFormatter::CleanupProcessList()\n");
+	RProcessPointerList *processList = static_cast<RProcessPointerList*> (aArray);
+    processList->ResetAndDestroy();
+    processList->Close();
+    delete processList;
+}
+
+/**
+    Cleanup item implementation for thread list in CrashEventL() method.
+@param aArray pointer to the list that is supposed to be freed
+*/
+void CSymbianElfFormatter::CleanupThreadList(TAny *aArray)
+{
+    LOG_MSG("->CSymbianElfFormatter::CleanupThreadList()\n");
+	RThreadPointerList *threadList = static_cast<RThreadPointerList*> (aArray);
+    threadList->ResetAndDestroy();
+    threadList->Close();
+    delete threadList;
+}
+
+/**
+ Handle a crash event and generate Symbian ELF formatted crash data. Write the data using the
+ provided data save interface.
+@param aCrashInfo Crash Data @see TCrashInfo.
+@leave err one of the system wide error codes
+*/
+void CSymbianElfFormatter::CrashEventL( TCrashInfo* aCrashInfo )
+{
+	LOG_MSG("->CSymbianElfFormatter::CrashEvent (SELF V1)\n");
+
+    //LOG_MSG("CSymbiaElfFormatter::CrashEvenL - checking if crash info is sane\n");
+    User::LeaveIfNull(aCrashInfo);
+    //LOG_MSG("CSymbianElfFormatter::CrashEvenL - checking if data source is sane\n");
+    User::LeaveIfNull(iDataSource);
+    //LOG_MSG("CSymbianElfFormatter::CrashEvenL - checking if data save is sane\n");
+    User::LeaveIfNull(iDataSave);
+
+    _LIT(KProgressStart, "-");
+    UpdateCrashProgressL( KProgressStart );
+
+    RRegisterList armExcRegs;
+    CleanupClosePushL(armExcRegs);
+    SetArmRegsFromCrashDataL(*aCrashInfo, armExcRegs);
+
+	iStrInfoTbl = CStringInfoTable::NewLC();
+	PrepareFileNameL(aCrashInfo->iTime);
+	iDataSave->OpenL(iElfFileName);
+
+	// This is a workaround for fole media, since it does not support
+	// saving beyond the current file size. At the start this is 0, so we
+	// must save this data even with dummy values.
+	Elf32_Ehdr *elfHdr = new(ELeave) Elf32_Ehdr();
+	CleanupStack::PushL(elfHdr);
+	iDataSave->WriteL( 0, elfHdr, sizeof(Elf32_Ehdr));
+
+	// Move file pointer to skip Elf Header as the info in that struct isn't known
+	// until everything has been written.
+	iOffset = sizeof(Elf32_Ehdr);
+	//LOG_MSG2( " iOffset start ->%d", iOffset );
+
+    RProcessPointerList *processList = new(ELeave)RProcessPointerList;
+    TCleanupItem processCleanup(CSymbianElfFormatter::CleanupProcessList, (TAny*)processList);
+    CleanupStack::PushL(processCleanup);
+
+    //LOG_MSG("CSymbianElfFormatter::CrashEvenL - getting process list\n");
+	iDataSource->GetProcessListL( *processList );
+	// Search processList for the crashed process, then get its details
+    CProcessInfo *crashedProc = NULL;
+    TInt i = 0;
+	for (i = 0; i < processList->Count(); i++ )
+		{
+		if( (*processList)[i]->Id() == aCrashInfo->iPid )
+			{
+            LOG_MSG("CSymbianElfFormatter::CrashEventL - found crashed process on the process list\n");
+			crashedProc = (*processList)[i];
+			break;
+			}
+		}
+
+	if( !crashedProc )
+		{
+		LOG_MSG( "  ERROR CProcessInfo == NULL. Crashed proc not found in process list" );
+		User::Leave( KErrBadHandle );
+		return; // Here for Coverity reasons
+		}
+
+    if(!iElfOptions->CreateSystemCrashInfo())
+        {
+		LOG_MSG3( "  Not generating SystemCrashInfo, only keeping crashed proc i=%d, 0x%X in proc list",
+			i, I64LOW(crashedProc->Id()));
+        processList->Remove(i);
+        processList->ResetAndDestroy();
+        processList->AppendL(crashedProc);
+        }
+
+	LOG_MSG2( " processList->Count()=%d", processList->Count() );
+
+	TUint64 threadRequestPid;
+	if( iElfOptions->CreateSystemCrashInfo() )
+		{
+		// All threads in the system
+		threadRequestPid = (TUint64)-1;
+		//LOG_MSG( "  iElfOptions->CreateSystemCrashInfo() is True => Get All System Threads" );
+		}
+	else
+		{
+		// This should only return the threads under the crashed process
+		//LOG_MSG( "  iElfOptions->CreateSystemCrashInfo() is False => Get Process Specific Threads" );
+		threadRequestPid = aCrashInfo->iPid;
+		}
+
+    RThreadPointerList *threadList = new(ELeave) RThreadPointerList;
+    TCleanupItem threadCleanup(CSymbianElfFormatter::CleanupThreadList, (TAny*)threadList);
+    CleanupStack::PushL(threadCleanup);
+
+    //LOG_MSG("CSymbianElfFormatter::CrashEvenL - getting thread list\n");
+	iDataSource->GetThreadListL( threadRequestPid, *threadList );
+
+ 	if(!iElfOptions->CreateProcessData())
+        {
+
+		LOG_MSG2( " threadList->Count()=%d before removal of non-crashed threads in process", threadList->Count() );
+		// User does not want threads from the crashed process. So remove these threads from the
+		// threads list. We still want the crashed thread and any other threads not belonging to
+		// this process.
+		TBool found;
+		do
+			{
+
+			found = EFalse;
+			for(TInt i =0; i < threadList->Count(); i++)
+				{
+				if( ((*threadList)[i]->ProcessId() == aCrashInfo->iPid) &&
+					((*threadList)[i]->Id() != aCrashInfo->iTid) )
+					{
+					LOG_MSG2("  removing thread 0x%X\n", I64LOW((*threadList)[i]->Id()) );
+					CThreadInfo *someThread = (*threadList)[i];
+					threadList->Remove(i);
+					delete someThread;
+					found = ETrue;
+					break;
+					}
+				}
+
+			} while( found );
+
+		}
+
+	LOG_MSG2( " threadList->Count()=%d", threadList->Count() );
+
+    RCodeSegPointerList *codeSegList = new(ELeave) RCodeSegPointerList;
+    TCleanupItem codeSegCleanup(CSymbianElfFormatter::CleanupCodeSegList, (TAny*)codeSegList);
+    CleanupStack::PushL(codeSegCleanup);
+
+    iDataSource->GetCodeSegmentsL(aCrashInfo->iTid, *codeSegList);
+
+    TCodeSegInfo *execInfo = NULL;
+    for(TInt i = 0; i < codeSegList->Count(); i++)
+        {
+        if((*codeSegList)[i]->iType == EExeCodeSegType)
+            {
+            LOG_MSG("CSymbianElfFormatter::CrashEventL - found exe code seg list\n");
+            execInfo = (*codeSegList)[i];
+            break;
+            }
+        }
+
+    if(!execInfo)
+		{
+		LOG_MSG( "  ERROR TCodeSegInfo == NULL. Crashed exec not found in code seg list" );
+		User::Leave( KErrBadHandle );
+		return; // Here for Coverity reasons
+		}
+
+	TUint32 crc32 = CalcExecCrcL(aCrashInfo->iTid, *execInfo);
+
+    _LIT(KWriteSymbianInfoProgress, "Write Symbian Info");
+    UpdateCrashProgressL( KWriteSymbianInfoProgress );
+	TUint symbianInfoOffset = WriteSymbianInfoL(*aCrashInfo, crc32);
+
+    RSegmentList dataSegs;
+    CleanupClosePushL(dataSegs);
+    RArray<TUint> dataSegOffsets;
+    CleanupClosePushL(dataSegOffsets);
+
+    _LIT( KWriteDataSegProgress, "Write Data Segments" );
+    UpdateCrashProgressL( KWriteDataSegProgress );
+	TUint dataSegmentsOffset = WriteDataSegmentsL( aCrashInfo->iTid, aCrashInfo->iPid, *threadList, *codeSegList, dataSegs, dataSegOffsets );
+
+    RArray<TUint> codeSegOffsets;
+    CleanupClosePushL(codeSegOffsets);
+
+    _LIT( KWriteCodeSegProgress, "Write Code Segments" );
+    UpdateCrashProgressL( KWriteCodeSegProgress );
+	TUint codeSegmentsOffset = WriteCodeSegmentsL( aCrashInfo->iTid, *codeSegList, codeSegOffsets );
+
+	//LOG_MSG2( "   iOffset before WriteThreadInfoL-> %d\n", iOffset );
+    _LIT( KWriteThreadProgress, "Write Thread Data" );
+    UpdateCrashProgressL( KWriteThreadProgress );
+	TUint threadInfoOffset = WriteThreadInfoL( aCrashInfo->iPid, *threadList );
+
+	//LOG_MSG2( "   iOffset before WriteProcessInfoL-> %d\n", iOffset );
+    _LIT( KWriteProcessProgress, "Write Process Data" );
+    UpdateCrashProgressL( KWriteProcessProgress );
+	TUint processInfoOffset = WriteProcessInfoL( aCrashInfo->iPid, *processList );
+
+	//LOG_MSG2( "   iOffset before WriteExecutableInfoL-> %d\n", iOffset );
+    _LIT( KWriteExeProgress, "Write Executable Data" );
+    UpdateCrashProgressL( KWriteExeProgress );
+	TUint executableInfoOffset = WriteExecutableInfoL( *codeSegList, aCrashInfo->iTime, aCrashInfo->iTid );
+	//LOG_MSG2( "   iOffset after WriteExecutableInfoL-> %d\n", iOffset );
+
+	RArray<TUint> registerInfoOffsets;
+	CleanupClosePushL(registerInfoOffsets);
+
+    _LIT( KWriteRegProgress, "Write Register Data" );
+    UpdateCrashProgressL( KWriteRegProgress );
+	//LOG_MSG( "  -> WriteRegisterInfoL()\n" );
+	WriteRegisterInfoL(aCrashInfo->iTid, aCrashInfo->iPid, registerInfoOffsets, armExcRegs, *threadList);
+	//LOG_MSG( "  <- WriteRegisterInfoL()\n" );
+	TUint stringInfoOffset = WriteStringInfoL();
+
+	LOG_MSG2( "   programTableOffset set to -> %d\n", iOffset );
+	TUint programTableOffset = iOffset;
+
+	// Create program header table 2.3 by collecting and assembling all bits and pieces needed
+
+	TUint noProgramTblEntries = 0;
+
+    _LIT( KCreatePHdrProgress, "Write ELF Headers" );
+    UpdateCrashProgressL( KCreatePHdrProgress );
+
+	Elf32_Phdr *header = new(ELeave) Elf32_Phdr();
+	CleanupStack::PushL(header);
+
+	// create program header with p_type=PT_NOTE and p_offset pointing to Symbian Info
+	header->p_type = PT_NOTE;
+	header->p_offset = symbianInfoOffset;
+	//LOG_MSG2( "   Symbian Info Elf32_Phdr.p_offset points to -> %d\n", header->p_offset );
+	header->p_vaddr = 0;
+	header->p_paddr = 0;
+	header->p_filesz = 0;
+	header->p_memsz = 0;
+	header->p_flags = 0; //no flags for note segments
+	header->p_align = 4;
+	//LOG_MSG2( "   Writing 1st Elf32_Phdr (Symbian Info ) at offset %d\n", iOffset );
+	iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+
+	iOffset += sizeof(Elf32_Phdr);
+	noProgramTblEntries++;
+
+	if( iElfOptions->CreateDataSegments() )
+	{
+        LOG_MSG2("SymbianElfFormatter:: dataSegs.Count90 = %d", dataSegs.Count());
+		for (TInt i=0; i < dataSegs.Count(); i++) // each segment in segs
+		{
+
+			header->p_type = PT_LOAD;
+			header->p_offset =  dataSegOffsets[i];
+			LOG_MSG2( "   header->p_offset = dataSegmentsOffset ->=%d\n", header->p_offset );
+			header->p_vaddr = dataSegs[i].iSegBase;
+			header->p_paddr = 0;
+			header->p_filesz = dataSegs[i].iSegSize;
+			header->p_memsz = dataSegs[i].iSegSize;
+			header->p_flags = dataSegs[i].iFlags;
+			header->p_align = 4;
+			LOG_MSG2( "   Writing this Data Seg PT_LOAD at offset %d\n", iOffset );
+			iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+			iOffset += sizeof(Elf32_Phdr);
+			noProgramTblEntries++;
+		}
+	}
+
+	if( iElfOptions->CreateCodeSegments() )
+	{
+		for (TInt i=0; i < codeSegList->Count(); i++) // each segment in segs
+		{
+			header->p_type = PT_LOAD;
+			header->p_offset =  codeSegOffsets[i];
+			//LOG_MSG2( "   header->p_offset = codeSegmentsOffset ->=%d\n", header->p_offset );
+			header->p_vaddr = (*codeSegList)[i]->iCodeRunAddr;
+			header->p_paddr = 0;
+			header->p_filesz = 0; //not dumping the code text section
+			header->p_memsz = (*codeSegList)[i]->iCodeSize;
+			header->p_flags = PF_R | PF_X; // Code segment
+			header->p_align = 4;
+			//LOG_MSG2( "   Writing this Code Seg PT_LOAD at offset %d\n", iOffset );
+			iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+			iOffset += sizeof(Elf32_Phdr);
+			noProgramTblEntries++;
+		}
+	}
+
+	if( iElfOptions->CreateThreadSegments() )
+	{
+
+		LOG_MSG( "  iElfOptions->CreateThreadSegments is True => creating P Hdr thread\n" );
+
+		// create program header for crashed thread segment
+		header->p_type = PT_NOTE;
+		header->p_offset =  threadInfoOffset;
+		LOG_MSG2( "   header->p_offset = threadInfoOffset=%d\n", threadInfoOffset );
+		header->p_vaddr = 0;
+		header->p_paddr = 0;
+		header->p_filesz = 0;
+		header->p_memsz = 0;
+		header->p_flags = 0; //no flags for note segments
+		header->p_align = 4;
+		LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+		iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+		iOffset += sizeof(Elf32_Phdr);
+		noProgramTblEntries++;
+	}
+
+	if (iElfOptions->CreateProcessSegments())
+	{
+		LOG_MSG( "  iElfOptions->CreateProcessSegmentInfo is True => creating P Hdr Proc\n" );
+
+		// create program header with p_type=PT_NOTE and p_offset pointing to...
+		header->p_type = PT_NOTE;
+		header->p_offset = processInfoOffset;
+		LOG_MSG2( "   header->p_offset = processInfoOffset=%d\n", processInfoOffset );
+		header->p_vaddr = 0;
+		header->p_paddr = 0;
+		header->p_filesz = 0;
+		header->p_memsz = 0;
+		header->p_flags = 0; //no flags for note segments
+		header->p_align = 4;
+		LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+		iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+		iOffset += sizeof(Elf32_Phdr);
+		noProgramTblEntries++;
+	}
+
+	if( iElfOptions->CreateExecSegments() )
+	{
+		LOG_MSG2( "  iElfOptions->CreateExecInfo is True => creating P Hdr Proc at offset %d\n",
+			executableInfoOffset );
+
+		// create program header with p_type=PT_NOTE and p_offset pointing to...
+		header->p_type = PT_NOTE;
+		header->p_offset = executableInfoOffset;
+		LOG_MSG2( "   header->p_offset = executableInfoOffset=%d\n", executableInfoOffset );
+		header->p_vaddr = 0;
+		header->p_paddr = 0;
+		header->p_filesz = 0;
+		header->p_memsz = 0;
+		header->p_flags = 0; //no flags for note segments
+		header->p_align = 4;
+		LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+		iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+		iOffset += sizeof(Elf32_Phdr);
+		noProgramTblEntries++;
+	}
+
+	if( registerInfoOffsets.Count() )
+	{
+		// create program header with p_type=PT_NOTE and p_offset pointing to Register info
+
+		for (TUint i = 0; i<registerInfoOffsets.Count(); i++)
+		{
+			header->p_type = PT_NOTE;
+			header->p_offset = registerInfoOffsets[i];
+			LOG_MSG2( "    => header->p_offset Register Seg P Hdr offset ->%d\n", header->p_offset );
+			header->p_vaddr = 0;
+			header->p_paddr = 0;
+			header->p_filesz = 0;
+			header->p_memsz = 0;
+			header->p_flags = 0; //no flags for note segments
+			header->p_align = 4;
+			LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+			iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+			iOffset += sizeof(Elf32_Phdr);
+			noProgramTblEntries++;
+		}
+	}
+
+	//LOG_MSG( "   Writing String PT_NOTE\n" );
+	header->p_type = PT_NOTE;
+	header->p_offset = stringInfoOffset;
+	LOG_MSG2( "   Creating String table at offset->%d\n", header->p_offset );
+	LOG_MSG2( "   header->p_offset = stringInfoOffset=%d\n", stringInfoOffset );
+	header->p_vaddr = 0;
+	header->p_paddr = 0;
+	header->p_filesz = 0;
+	header->p_memsz = 0;
+	header->p_flags = 0; //no flags for string segment
+	header->p_align = 4;
+	LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+	iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+	noProgramTblEntries++;
+
+	CleanupStack::PopAndDestroy(header);
+
+	// update the Elf32 header and write it at the beginning of the file
+	elfHdr->e_ident[EI_MAG0] = ELFMAG0;
+	elfHdr->e_ident[EI_MAG1] = ELFMAG1;
+	elfHdr->e_ident[EI_MAG2] = ELFMAG2;
+	elfHdr->e_ident[EI_MAG3] = ELFMAG3;
+	elfHdr->e_ident[EI_CLASS] = ELFCLASS32;
+	elfHdr->e_ident[EI_DATA] = ELFDATA2LSB;
+	elfHdr->e_ident[EI_VERSION] = 0;
+	elfHdr->e_ident[EI_PAD] = 0;
+	elfHdr->e_type = ET_CORE;
+	elfHdr->e_machine = EM_ARM;
+	elfHdr->e_version = EV_CURRENT;
+	elfHdr->e_entry = 0;
+	elfHdr->e_phoff = programTableOffset;
+	LOG_MSG2( "   Program header offset elfHdr->e_phoff = programTableOffset=%d\n", programTableOffset );
+	elfHdr->e_shoff = 0;
+	elfHdr->e_flags = 0;
+	LOG_MSG2( "   elfHdr->e_ehsize = %d\n", sizeof(Elf32_Ehdr) );
+	elfHdr->e_ehsize = sizeof(Elf32_Ehdr);
+	LOG_MSG2( "   elfHdr->e_phentsize = %d\n", sizeof(Elf32_Phdr) );
+	elfHdr->e_phentsize = sizeof(Elf32_Phdr);
+	elfHdr->e_phnum = noProgramTblEntries;
+	LOG_MSG2( "   Program header entries elfHdr->e_phnum = noProgramTblEntries=%d\n", noProgramTblEntries );
+	elfHdr->e_shentsize = 0;
+	elfHdr->e_shnum = 0;
+	elfHdr->e_shstrndx = 0;
+
+	//LOG_MSG( "   Writing ELF header at offset 0\n" );
+	iDataSave->WriteL( 0, elfHdr, sizeof(Elf32_Ehdr));
+
+    CleanupStack::PopAndDestroy(&registerInfoOffsets);
+
+    CleanupStack::PopAndDestroy(&codeSegOffsets);
+    CleanupStack::PopAndDestroy(&dataSegOffsets);
+    CleanupStack::PopAndDestroy(&dataSegs);
+
+    CleanupStack::PopAndDestroy();//&codeSegCleanup);
+    CleanupStack::PopAndDestroy();//&threadCleanup);
+    CleanupStack::PopAndDestroy();//&processCleanup);
+
+	CleanupStack::PopAndDestroy(elfHdr);
+    CleanupStack::PopAndDestroy(iStrInfoTbl);
+    CleanupStack::PopAndDestroy(&armExcRegs);
+
+	LOG_MSG("  iDataSave->CloseL();\n");
+	iDataSave->CloseL();
+}
+
+/**
+Checks the value of the crash cancel property. If set to cancel, it closes the
+data save and then leaves with KErrAbort.
+Otherwise it updates the crash progress with the argument value.
+
+@param aProgress Progress description.
+@leave KErrAbort if crash cancel property has been set
+*/
+void CSymbianElfFormatter::UpdateCrashProgressL( const TDesC &aProgress )
+    {
+
+    LOG_MSG("CSymbianElfFormatter::UpdateCrashProgress()\n");
+    TInt cancelCrash;
+    _LIT(KNoProgress, "");
+    RProperty::Get( KCoreDumpServUid, ECancelCrash, cancelCrash );
+
+    if( cancelCrash )
+        {
+        RProperty::Set( KCoreDumpServUid, ECrashProgress, KNoProgress );
+
+		LOG_MSG("  iDataSave->CloseL();\n");
+		iDataSave->CloseL();
+
+		LOG_MSG("  UpdateCrashProgress() -> User::Leave( KErrAbort )\n");
+        User::Leave( KErrAbort );
+        }
+
+    RProperty::Set( KCoreDumpServUid, ECrashProgress, aProgress );
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/symbianelfoptions.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,453 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implementation of the symbian elf options class.
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#include <e32base.h>
+#include <e32debug.h>
+
+#include "symbianelfoptions.h"
+#include <debuglogging.h>
+
+/**
+1st stage construction 
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CElfOptions* CElfOptions::NewL( TUint32 aUID )
+{
+	//LOG_MSG( "CElfOptions::NewL()\n" );
+	CElfOptions* self = CElfOptions::NewLC( aUID );
+	CleanupStack::Pop();
+	return self;
+}
+
+/**
+1st stage construction 
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CElfOptions* CElfOptions::NewLC( TUint32 aUID )
+{
+	//LOG_MSG( "CElfOptions::NewLC()\n" );
+
+	CElfOptions* self = new(ELeave) CElfOptions();
+
+	CleanupStack::PushL(self);
+
+	self->ConstructL( aUID );
+	return self;
+}
+
+/**
+2nd stage construction
+Reserves config parameter list, creates config parameter objects and sets them to default values.
+@leave err one of the system wide error codes
+*/
+void CElfOptions::ConstructL( TUint32 aUID )
+{
+	//LOG_MSG("->CElfOptions::ConstructL()\n");
+    TInt err;
+
+	iConfigList.ReserveL( (TInt)EElfOptionsLast );
+
+	COptionConfig * config;
+	TInt index = 0; // Index of config params that we create
+
+	_LIT( KTrueFalseOpt, "True,False" );
+	_LIT( KTrueOpt, "True" );
+	
+	_LIT( KCreateSystemInfo, "System-Wide Crash Data Option:\n  0-System-Wide Data,\n  1-Crashed Process Only,\n  2-Both" );
+	config = COptionConfig::NewL(  (TInt)ECreateSystemCrashInfo,
+									aUID,						
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETUInt, 
+									KCreateSystemInfo, 
+                                    1,
+									KNullDesC, 
+									ESystemWideAndCrashedProc,						
+									KNullDesC );
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	
+	index ++;
+
+
+	_LIT( KCreateProcessDataPrompt, 
+		"Create Data for all Threads in Crashed Process?" );
+//      0        1         2         3         4         5
+//      12345678901234567890123456789012345678901234657890
+
+	config = COptionConfig::NewL(  (TInt)ECreateProcessData,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool, 
+									KCreateProcessDataPrompt, 
+                                    1,
+									KTrueFalseOpt, 
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KDataSegmentPrompt, "Create Data Segments?" );
+	config = COptionConfig::NewL(  (TInt)ECreateDataSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool, 
+									KDataSegmentPrompt, 
+									1,						// Number of options
+									KTrueFalseOpt,				// Option string
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KCodeSegmentPrompt, "Create Code Segments?" );
+	config = COptionConfig::NewL(  (TInt)ECreateCodeSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool, 
+									KCodeSegmentPrompt, 
+									1,
+									KTrueFalseOpt, 
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KThreadSegmentPrompt, "Create Thread Segments?" );
+	config = COptionConfig::NewL(  (TInt)ECreateThreadSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool, 
+									KThreadSegmentPrompt, 
+                                    1, 
+									KTrueFalseOpt, 
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KRegisterSegmentPrompt, "Create Register Segments?" );
+	config = COptionConfig::NewL(  (TInt)ECreateRegisterSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool, 
+									KRegisterSegmentPrompt, 
+                                    1,
+									KTrueFalseOpt, 
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KCreateExecInfoPrompt, "Create Exec Info?" );
+	config = COptionConfig::NewL(  (TInt)ECreateExecSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool, 
+									KCreateExecInfoPrompt, 
+                                    1,
+									KTrueFalseOpt, 
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KCreateProcessSegmentInfo, "Create Process Info?" );
+	config = COptionConfig::NewL(  (TInt)ECreateProcessSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool, 
+									KCreateProcessSegmentInfo, 
+                                    1,
+									KTrueFalseOpt, 
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+}
+
+/**
+ctor nothing really
+*/
+
+CElfOptions::CElfOptions()
+{
+	
+}
+
+/**
+dtor frees config parameter list
+*/
+CElfOptions::~CElfOptions()
+{
+    iConfigList.ResetAndDestroy();
+}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptions::CreateProcessData() const
+	{
+	return iConfigList[ (TInt)ECreateProcessData ]->ValueAsBool();
+	}
+	
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptions::CreateDataSegments() const
+	{
+	if( CreateSystemWideOnly() )
+		return EFalse;
+
+	return iConfigList[ (TInt)ECreateDataSegments ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptions::CreateCodeSegments() const
+	{
+	if( CreateSystemWideOnly() )
+		return EFalse;
+
+	return iConfigList[ (TInt)ECreateCodeSegments ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptions::CreateThreadSegments() const
+	{
+	return iConfigList[ (TInt)ECreateThreadSegments ]->ValueAsBool();
+	}
+	
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptions::CreateRegisterSegments() const
+	{
+	if( CreateSystemWideOnly() )
+		return EFalse;
+
+	return iConfigList[ (TInt)ECreateRegisterSegments ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptions::CreateExecSegments() const
+	{
+	if( CreateSystemWideOnly() )
+		return EFalse;
+
+	return iConfigList[ (TInt)ECreateExecSegments ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptions::CreateProcessSegments() const
+	{
+    return iConfigList[ (TInt)ECreateProcessSegments ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptions::CreateSystemWideOnly() const
+	{
+	return ( ESystemWideOnly == iConfigList[ (TInt)ECreateSystemCrashInfo ]->Value() );
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptions::CreateSystemCrashInfo() const
+	{
+
+	switch( iConfigList[ (TInt)ECreateSystemCrashInfo ]->Value() )
+		{
+		case ESystemWideOnly:
+		case ESystemWideAndCrashedProc:
+			return ETrue;
+		case ECrashedProcessOnly:
+		default:
+			return EFalse;
+		}
+	}
+
+/**
+Called by CDS to ask for the configuration parameters that the formatter implements.
+@return actual number of implemented config parameters
+*/
+TInt CElfOptions::GetNumberConfigParametersL( )
+	{
+	//LOG_MSG("->CElfOptions::GetNumberConfigParametersL() : returning %d", iConfigList.Count() );
+	return iConfigList.Count();
+	}
+
+/**
+Called by CDS to ask for configuration parameter.
+@param aIndex indicates which parameter to return
+@return pointer to COptionConfig object representing the requested config parameter. Caller doesn't take ownership of the object!
+@leave KErrBadHandle if index is out of bounds
+@see COptionConfig
+*/
+COptionConfig * CElfOptions::GetConfigParameterL( const TInt aIndex )
+	{
+
+	if( ( aIndex < 0 ) || ( aIndex >= iConfigList.Count() ) )
+		{
+		User::Leave( KErrBadHandle );
+		}
+
+    return iConfigList[aIndex];
+
+	}
+
+/**
+Called by CDS with response to prompt from user. Plugin interprets 
+the response (eg create file, check permissions, pre-allocate memory etc).
+
+@param aIndex Index of parameter to change
+@param aValue Unused 
+@param aDescValue Path and filename to use
+@return KErrNone
+@leave KErrBadHandle if index is out of bounds or one of the other system wide error codes
+*/
+TInt CElfOptions::SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue )
+	{
+	//LOG_MSG2("->CElfOptions::SetConfigParameterL()\n");
+    
+	// Make the changes to our internal structures, and reflect such changes in our behaviour
+
+	if( ( aIndex < 0 ) || ( aIndex > iConfigList.Count() ) )
+		{
+		LOG_MSG2( "CElfOptions::SetConfigParameterL(): ERROR !* : aIndex=%d is out of bounds\n", aIndex );
+		User::Leave( KErrBadHandle );
+		}
+
+	COptionConfig * config = iConfigList[aIndex];
+
+	switch( config->Index() )
+		{
+		case ECreateProcessData:
+		case ECreateDataSegments:
+		case ECreateCodeSegments:
+		case ECreateThreadSegments:
+		case ECreateRegisterSegments:
+		case ECreateExecSegments:
+		case ECreateProcessSegments:
+			if( 0 == aValue )
+				{
+				config->Value( EFalse );
+				}
+			else if( 1 == aValue )
+				{
+				config->Value( ETrue );
+				}
+			else
+				{
+				User::Leave( KErrArgument );
+				}
+			break;
+
+		case ECreateSystemCrashInfo:
+			{
+			if( ESystemWideOnly == aValue )
+				{
+				config->Value( ESystemWideOnly );
+				}
+			else if( ECrashedProcessOnly == aValue )
+				{
+				config->Value( ECrashedProcessOnly );
+				}
+			else if( ESystemWideAndCrashedProc == aValue )
+				{
+				config->Value( ESystemWideAndCrashedProc );
+				}
+			else
+				{
+				User::Leave( KErrArgument );
+				}
+			}
+		}//switch
+
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/symbianelfproxy.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,33 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <implementationproxy.h>
+
+#include "symbianelfformatter.h"
+#include "symbianelfformatterv2.h"
+
+// ECom boiler template code
+const TImplementationProxy ImplementationTable[] =
+{
+	IMPLEMENTATION_PROXY_ENTRY(0x10282fe3, CSymbianElfFormatter::NewL),
+	IMPLEMENTATION_PROXY_ENTRY(0x102836bb, CSymbianElfFormatterV2::NewL)
+};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+	return ImplementationTable;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/src/symbianelfstringinfo.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,112 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#include <e32base.h>
+#include "symbianelfstringinfo.h"
+
+#include <e32debug.h>
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CStringInfoTable *CStringInfoTable::NewLC()
+{
+	CStringInfoTable *self = new(ELeave) CStringInfoTable();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+}
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CStringInfoTable *CStringInfoTable::NewL()
+{
+	CStringInfoTable *self = CStringInfoTable::NewLC();
+	CleanupStack::Pop(self);
+	return self;
+}
+/**
+dtor closes string buffer
+*/
+CStringInfoTable::~CStringInfoTable()
+{
+	iBuffer.Close();
+}
+
+/**
+ctor nothing really
+*/
+CStringInfoTable::CStringInfoTable()
+{
+}
+
+/**
+2nd stage construction.
+Creates string buffer and populates it with strings present in every ELF dump file.
+@leave one of the system wide error codes
+*/
+void CStringInfoTable::ConstructL()
+    {
+    //LOG_MSG("->CStringInfoTable::ConstructL()\n");
+	iBuffer.CreateL(KEmpty, KEmpty().Length()+1);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KSymbian().Length()+1);
+	iBuffer.Append(KSymbian);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KThread().Length()+1);
+	iBuffer.Append(KThread);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KProcess().Length()+1);
+	iBuffer.Append(KProcess);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KExecutable().Length()+1);	
+	iBuffer.Append(KExecutable);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KStr().Length()+1);
+	iBuffer.Append(KStr);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KSymbianElfCoreDumpVersion().Length()+1);
+	iBuffer.Append(KSymbianElfCoreDumpVersion);
+	iBuffer.AppendFill((TChar)0, 1);
+	
+    }
+
+/**
+
+@param aItem: The string to be added to internal buffer
+@return offset at which the aItem was added to internal buffer
+@leave one of the system wide error codes
+*/
+TUint CStringInfoTable::AddStringL(const TDesC8 &aItem)
+    {
+    //LOG_MSG("->CStringInfoTable::AddStringL()\n");
+	TUint index = iBuffer.Length();
+	iBuffer.ReAllocL(iBuffer.Length() + aItem.Length() + 1);
+	iBuffer.Append(aItem);
+	iBuffer.AppendFill((TChar)0, 1);
+	return index;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/srcv2/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/srcv2/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,11 @@
+Directory for:
+  coredump\plugins\formatters\symbian_elf\src
+
+All the source, including subdirectories, to implement the Symbian ELF formatter.
+
+  
+Implements the ECOM interface in coredump\interface\formatter.
+
+Uses the data source interface in coredump\interface\data_source.
+
+Uses the data save interface in coredump\interface\writer
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/srcv2/symbianelfformatterv2.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,2720 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// symbianelfformatter.cpp
+// Implementation of CSymbianElfFormatterV2 class
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+ @see CCoreDumpFormatter
+*/
+
+#include <e32base.h>
+#include <e32property.h>
+#include <e32debug.h>
+#include <d32btrace.h>
+
+#include <coredumpserverapi.h>
+#include "symbianelfformatterv2.h"
+#include "symbianelfstringinfov2.h"
+
+#define KMaxCrc32Size 1000
+
+/** Updates to the RProperty ECrashProgress */
+_LIT(KProgressStart, "Start");
+_LIT(KWriteSymbianInfoProgress, "Write Symbian Info");
+_LIT(KWriteDataSegProgress, "Write Data Segments" );
+_LIT(KWriteCodeSegProgress, "Write Code Segments" );
+_LIT(KWriteThreadProgress, "Write Thread Data" );
+_LIT(KWriteProcessProgress, "Write Process Data" );
+_LIT(KWriteExeProgress, "Write Executable Data" );
+_LIT(KWriteRegProgress, "Write Register Data" );
+_LIT(KCreatePHdrProgress, "Write ELF Headers" );
+_LIT(KNoProgress, "Cancel");
+_LIT(KProgressDone, "Done");
+
+/** @see ECrashMediaName
+ * status bit in the crash media name entries
+ * D - Done
+ * I - In progress
+ * C - Cancelled
+ */
+_LIT(KMediaStatusDone, "D");
+_LIT(KMediaStatusInprogress, "I");
+_LIT(KMediaStatusCancelled, "C");
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CSymbianElfFormatterV2* CSymbianElfFormatterV2::NewL()
+{
+	LOG_MSG("->CSymbianElfFormatterV2::NewL()->\n");
+	CSymbianElfFormatterV2* self = CSymbianElfFormatterV2::NewLC();
+	CleanupStack::Pop();
+	return self;
+}
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CSymbianElfFormatterV2* CSymbianElfFormatterV2::NewLC()
+{
+	LOG_MSG("->CSymbianElfFormatterV2::NewLC()->\n");
+	CSymbianElfFormatterV2* self = new(ELeave)CSymbianElfFormatterV2();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+}
+
+/**
+ctor nothing really
+*/
+CSymbianElfFormatterV2::CSymbianElfFormatterV2():
+iCPSR(0)
+{
+	LOG_MSG("->CSymbianElfFormatterV2::CSymbianElfFormatterV2()\n");
+}
+
+/**
+2nd stage construction
+Creates elf options object
+*/
+void CSymbianElfFormatterV2::ConstructL()
+{
+	iElfOptions = CElfOptionsV2::NewL( (TUint32)KSymbianELFFormatterV2Uid );
+	iElfFileName.CreateL(KMaxFileName);
+	//attach to the property
+	User::LeaveIfError(iCrashProgress.Attach(KCoreDumpServUid, ECrashProgress));
+	User::LeaveIfError(iCancelCrash.Attach(KCoreDumpServUid, ECancelCrash));
+	User::LeaveIfError(iCrashMediaName.Attach(KCoreDumpServUid, ECrashMediaName));
+	// Crash UID Buffer
+	iCrashIDBuffer.CreateL(KMaxUIDLength);
+	// Crash Progress Buffer
+	iCrashProgressBuffer.CreateL(KMaxCrashProgressBuffer);
+}
+
+/**
+dtor frees elf options object
+*/
+CSymbianElfFormatterV2::~CSymbianElfFormatterV2()
+{
+	LOG_MSG( "CSymbianElfFormatterV2::~CSymbianElfFormatterV2()\n" );
+
+	iElfFileName.Close();
+	iCrashIDBuffer.Close();
+	iCrashProgressBuffer.Close();
+
+	iCrashProgress.Close();
+	iCancelCrash.Close();
+	iCrashMediaName.Close();
+
+    if(iElfOptions)
+    {
+	    delete iElfOptions;
+        iElfOptions = NULL;
+    }
+}
+
+/**
+Sets pointer to the writer plugin.  Configures formatter's dump data save plugin.
+@param aDataSave Pointer to writer plugin
+@leave KErrNoMemory if aDataSave is NULL
+*/
+void CSymbianElfFormatterV2::ConfigureDataSaveL( CCrashDataSave * aDataSave )
+{
+	LOG_MSG("->CSymbianElfFormatterV2::ConfigureDataSave()\n");
+    User::LeaveIfNull(aDataSave);
+	iDataSave  = aDataSave;
+}
+
+/**
+Sets pointer to the crash data server. Configures formatter's crash data source plugin
+@param aDataSource Pointer to Crash Data Source
+@leave KErrNoMemory if aDataSource is NULL
+*/
+void CSymbianElfFormatterV2::ConfigureDataSourceL( CCrashDataSource * aDataSource )
+{
+	LOG_MSG("->CSymbianElfFormatterV2::ConfigureDataSource()\n");
+    User::LeaveIfNull(aDataSource);
+	iDataSource = aDataSource;
+}
+
+/**
+Returns a description of the plugin.
+@param aPluginDescription Output parameter that contains the plugin description.
+*/
+void CSymbianElfFormatterV2::GetDescription( TDes & aPluginDescription )
+{
+	LOG_MSG("CSymbianElfFormatterV2::GetDescription()\n");
+	aPluginDescription.Copy(KPluginDescriptionV2());
+}
+
+/**
+Called by CDS to ask for the configuration parameters that the writer needs (see Plugin Configuration)
+@return actual number of implemented config parameters
+*/
+TInt CSymbianElfFormatterV2::GetNumberConfigParametersL( )
+	{
+	TInt numberConfigParameters = iElfOptions->GetNumberConfigParametersL( );
+	LOG_MSG2("->CSymbianElfFormatterV2::GetNumberConfigParametersL() will return %d \n",
+		numberConfigParameters );
+	return ( numberConfigParameters );
+	}
+
+/**
+Called by CDS to ask for configuration parameter prompt (see Plugin Configuration)
+
+@param aIndex indicates which parameter to return
+@return pointer to COptionConfig object representing the requested config parameter. Caller doesn't take ownership of the object!
+@leave KErrBadHandle if index is out of bounds
+@see COptionConfig
+*/
+COptionConfig * CSymbianElfFormatterV2::GetConfigParameterL( const TInt aIndex )
+	{
+	return ( iElfOptions->GetConfigParameterL( aIndex ) );
+	}
+
+/**
+Change a configuration parameter.
+@param aIndex Index of the configuration parameter.
+@param aValue Value of the configuration parameter as an int
+@param aDescValue Value of the configuration parameter as a string
+@leave err one of the system wide error codes
+@see COptionConfig
+@see CElfOptions
+*/
+void CSymbianElfFormatterV2::SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue )
+	{
+	LOG_MSG3("->CSymbianElfFormatterV2::SetConfigParameterL(index=%d, val=%d)\n", aIndex, aValue );
+	iElfOptions->SetConfigParameterL( aIndex, aValue, aDescValue );
+	}
+
+/**
+Create and save Sym32_syminfod segment.
+@param aCrashInfo TCrashInfo data structure holding information about the crash.
+@param aCrc32 CRC calculated for the crashed executable
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+@see Sym32_syminfod
+*/
+TUint CSymbianElfFormatterV2::WriteSymbianInfoL(const TCrashInfo &aCrashInfo, const TUint32 aCrc32 )
+{
+	LOG_MSG2( "CSymbianElfFormatterV2::WriteSymbianInfoL( pid=0x%X)\n", I64LOW(aCrashInfo.iPid) );
+
+	TUint offset = iOffset;
+	LOG_MSG2( " iOffset at start of WriteSymbianInfoL->%d", iOffset );
+
+	Sym32_dhdr *symInfo_descriptor = new(ELeave) Sym32_dhdr();
+	CleanupStack::PushL(symInfo_descriptor);
+
+	TInt32 index = iStrInfoTbl->GetIndex(KSymbian);
+	symInfo_descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+	symInfo_descriptor->d_descrsz	= sizeof(Sym32_syminfod);
+	LOG_MSG2( " symInfo_descriptor->d_descrsz = 0x%X", symInfo_descriptor->d_descrsz);
+	symInfo_descriptor->d_type		= ESYM_NOTE_SYM;
+	symInfo_descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+    symInfo_descriptor->d_elemnum	= 1;
+
+	LOG_MSG3( "  iDataSave->WriteL( iOffset=%d, symInfo_descriptor, sizeof(Sym32_dhdr)=%d)", iOffset, sizeof(Sym32_dhdr) );
+	iDataSave->WriteL( iOffset, symInfo_descriptor, sizeof(Sym32_dhdr));
+
+	LOG_MSG( "  CleanupStack::PopAndDestroy(symInfo_descriptor);" );
+	CleanupStack::PopAndDestroy(symInfo_descriptor); // symInfo_descriptor
+
+	iOffset += sizeof(Sym32_dhdr);
+
+	// get Symbian Info from iDataSource
+	Sym32_syminfod *symInfo = new(ELeave) Sym32_syminfod();
+	CleanupStack::PushL(symInfo);
+
+	symInfo->sd_exit_type = aCrashInfo.iType; // ECrashException or EEventsKillThread
+	LOG_MSG2( " Sym32_syminfod->sd_exit_type = 0x%X", symInfo->sd_exit_type );
+
+	index = KErrNotFound;
+
+	if( TCrashInfo::ECrashException == aCrashInfo.iType )
+		{
+		LOG_MSG2( " symInfo->sd_exit_reason = aCrashInfo->iExcNumber = 0x%X", aCrashInfo.iExcNumber );
+		symInfo->sd_exit_reason = aCrashInfo.iExcNumber;
+		}
+	else if( TCrashInfo::ECrashKill == aCrashInfo.iType )
+		{
+		LOG_MSG2( " symInfo->sd_exit_reason = aCrashInfo.iReason = 0x%X", aCrashInfo.iReason );
+		symInfo->sd_exit_reason = aCrashInfo.iReason;
+
+		TBuf8<KMaxExitCategoryName> buf;
+		LOG_MSG( "  buf.Copy(aCrashInfo.iCategory)" );
+		buf.Copy(aCrashInfo.iCategory);
+		if (buf.Length() > 0)
+			{
+			index = iStrInfoTbl->AddStringL(buf);
+			}
+		LOG_MSG2( "  Added Crash Category at index %d", index );
+		}
+
+	symInfo->sd_thread_id = aCrashInfo.iTid;
+	symInfo->sd_proc_id = aCrashInfo.iPid;
+	symInfo->sd_date_time = aCrashInfo.iTime;
+	LOG_MSG2( " sizeof(Sym32_syminfod->symInfo->sd_date_time) = 0x%X", sizeof(symInfo->sd_date_time)  );
+	LOG_MSG3( " time high low = 0x%X%X", I64HIGH(symInfo->sd_date_time), I64LOW(symInfo->sd_date_time) );
+
+	symInfo->sd_execid.exec_id = aCrashInfo.iTime;
+	symInfo->sd_execid.exec_crc = aCrc32;
+	symInfo->sd_exit_cat = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+
+	// Write the Symbian specifics to file
+	LOG_MSG3( "  iDataSave->WriteL( iOffset=%d, symInfo, sizeof(Sym32_syminfod)=%d)",
+		iOffset, sizeof(Sym32_syminfod) );
+	iDataSave->WriteL( iOffset, symInfo, sizeof(Sym32_syminfod));
+	CleanupStack::PopAndDestroy(symInfo);
+
+	iOffset += sizeof(Sym32_syminfod);
+	return offset;
+}
+
+/**
+Creates TDataSegment segments by checking the .rodata and .bss/.data sections of the code segments provided by data source.
+It may also create data segments for the user stacks of threads in the crashed process, depending on user configuration.
+@param aThreadId The id of the crashed thread.
+@param aPid ID of the process that owned the crashed thread
+@param aThreadList list of the threads in the crashed process or the whole system, depending on user configuration
+@param aCodeSegList list of all code segments loaded into process that crashed
+@param aDataSegs output list of created data segments
+@param aDataSegOffsets output list of media-location offsets where segment data was stored
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+@see TDataSegment
+*/
+TUint CSymbianElfFormatterV2::WriteDataSegmentsL( const TUint64 & aThreadId,
+											    const TUint64 & aPid,
+                                                const RThreadPointerList &aThreadList,
+                                                const RCodeSegPointerList &aCodeSegList,
+                                                RSegmentList &aDataSegs,
+                                                RArray<TUint> &aDataSegOffsets )
+	{
+	LOG_MSG2( "CSymbianElfFormatterV2::WriteDataSegmentsL(aThreadId=0x%X)\n", I64LOW(aThreadId) );
+	TUint offset = iOffset;
+
+	if(!iElfOptions->CreateDataSegments())
+        {
+        LOG_MSG("CSymbianElfFormatterV2::WriteDataSegmentsL - not configured to dump data segs");
+        return offset;
+        }
+
+    LOG_MSG("CSymbianElfFormatterV2::WriteDataSegmentsL - generating data segments\n");
+    TSegmentInfo segInfoUsrStack;
+    TSegmentInfo segInfoSvrStack;
+    TSegmentInfo segInfoHeap;
+
+    // Create data segments for the threads' stacks in this process
+    for( TInt i = 0; i < aThreadList.Count(); i++ )
+        {
+        CThreadInfo &threadInfo = *aThreadList[i];
+		if( aThreadList[i]->ProcessId() != aPid )
+			{
+			// Thread not in crashed process
+			continue;
+			}
+
+        //CThreadInfo &threadInfo = *aThreadList[i];
+
+        LOG_MSG2("\tGenerating stack data segment for thread 0x%X\n", I64LOW(threadInfo.Id()));
+
+        segInfoUsrStack.iSegBase = threadInfo.UsrStackAddr();
+        segInfoUsrStack.iSegSize = threadInfo.UsrStackSize();
+        segInfoUsrStack.iFlags = PF_W | PF_R;
+
+        segInfoSvrStack.iSegBase = threadInfo.SvcStackAddr();
+        segInfoSvrStack.iSegSize = threadInfo.SvcStackSize();
+
+        LOG_MSG4("CSymbianElfFormatterV2::WriteDataSegmentsL - user .stack base=0x%X, size=%d   for TID = 0x%X)", segInfoUsrStack.iSegBase, segInfoUsrStack.iSegSize, threadInfo.Id() );
+        LOG_MSG4("CSymbianElfFormatterV2::WriteDataSegmentsL - svr .stack base=0x%X, size=%d)", segInfoSvrStack.iSegBase, segInfoSvrStack.iSegSize, threadInfo.Id() );
+
+        if(iElfOptions->CreateHeapData())
+        	{
+        	segInfoHeap.iSegBase = threadInfo.HeapBase();
+        	segInfoHeap.iSegSize = threadInfo.HeapSize();
+        	}
+        else
+        	{
+        	segInfoHeap.iSegBase = 0;
+        	segInfoHeap.iSegSize = 0;
+        	}
+
+        LOG_MSG4("CSymbianElfFormatterV2::WriteDataSegmentsL - heap base=0x%X, size=%d)", segInfoHeap.iSegBase, segInfoHeap.iSegSize, threadInfo.Id() );
+
+        if(segInfoUsrStack.iSegSize > 0)
+        	{
+        	aDataSegs.AppendL(segInfoUsrStack);
+        	}
+
+        if(segInfoSvrStack.iSegSize > 0 && IsSystemCrash())
+        	{
+        	aDataSegs.AppendL(segInfoSvrStack);
+        	}
+        if(segInfoHeap.iSegSize > 0 && IsSystemCrash())
+        	{
+        	aDataSegs.AppendL(segInfoHeap);
+        	}
+        }
+
+    LOG_MSG2( "  Found %d .stack data segments for crashed process", aDataSegs.Count() );
+
+
+    // Create data segments for the .rodata .data .bss sections of the exe and dlls in this proc
+    for(TInt i = 0;  i < aCodeSegList.Count(); i++)
+        {
+        TSegmentInfo segInfo;
+        TCodeSegInfo &codeSeg = *aCodeSegList[i];
+        if(codeSeg.iRoDataSize != 0)
+            {
+            segInfo.iSegBase = codeSeg.iRoDataRunAddr;
+            segInfo.iSegSize = codeSeg.iRoDataSize;
+            segInfo.iFlags = PF_R;
+            LOG_MSG3( "CSymbianElfFormatterV2::WriteDataSegmentsL - .rodata base=0x%X, size=%d)", segInfo.iSegBase, segInfo.iSegSize );
+            aDataSegs.AppendL(segInfo);
+            }
+
+        if(codeSeg.iDataSize != 0)
+            {
+            segInfo.iSegBase = codeSeg.iDataRunAddr;
+            segInfo.iSegSize = codeSeg.iDataSize;
+            segInfo.iFlags = PF_W | PF_R;
+            LOG_MSG3( "CSymbianElfFormatterV2::WriteDataSegmentsL - .data base=0x%X, size=%d)", segInfo.iSegBase, segInfo.iSegSize );
+            aDataSegs.AppendL(segInfo);
+
+            }
+        }
+
+    LOG_MSG2( "  Total %d Data Segments for crashed thread", aDataSegs.Count() );
+
+    // Dumping memory content of the identified data segments
+    for (TInt i = 0; i < aDataSegs.Count(); i++)
+        {
+        TUint startPoint = iOffset;
+        TRAPD(memError, WriteRawMemoryToFileL(aThreadId, aDataSegs[i].iSegBase, aDataSegs[i].iSegSize));
+        if(memError != KErrNone)
+        	{
+        	//This means that there will be a data segment that points to no data
+            LOG_MSG2("ERROR %d from WriteRawMemoryToFileL(). Will generate empty segment\n", memError );
+            aDataSegOffsets.AppendL(0);
+            continue;
+        	}
+
+        aDataSegOffsets.AppendL(startPoint);
+        }
+
+	return offset;
+	}
+
+/**
+ * This takes a memory address and length and writes that raw memory to the file. This is safe against a large
+ * aLength causing an allocation failure.
+ * @param aThreadId Thread ID of memory to read
+ * @param aAddress Address of memory to read
+ * @param aLength Length of memory to read
+ * @param aReadSize How many bytes at a time to read. A large number here will cause memory failures and slow things down
+ * @leave One of the System wide codes
+ * @see HelpWriteRawMemoryToFileL
+ */
+
+void CSymbianElfFormatterV2::WriteRawMemoryToFileL(const TUint64 aThreadId, const TUint32 aAddress, const TUint32 aLength)
+	{
+	//First thing to do is to find a valid read size that wont cause a KErrNoMemory
+	TUint writeSize = aLength;
+	TUint remaining = aLength;
+
+	//Keep trying until we find a read size that doesnt cause a memory error
+	while(ETrue)
+		{
+		TRAPD(err, HelpWriteRawMemoryToFileL(aThreadId, aAddress, writeSize));
+		if(err != KErrNone)
+			{
+			if(err == KErrNoMemory)
+				{
+				if(writeSize == 0)
+					{
+					User::LeaveNoMemory();
+					}
+
+				//Try a smaller write size next time
+				writeSize = writeSize/4;
+
+				LOG_MSG("CSymbianElfFormatterV2::WriteRawMemoryToFileL !!! Try a smaller write size next time !!!");
+				continue;
+				}
+			else
+				{
+				User::Leave(err);
+				}
+			}
+
+		//The write was succesful
+		remaining -= writeSize;
+		break;
+		}
+
+	TUint32 position = aAddress + writeSize;
+	while(remaining > 0)
+		{
+
+		writeSize = (remaining >= writeSize) ? writeSize : remaining;
+
+		//This call shouldnt leave - if it does we are finished anyway to pass it back
+		WriteRawMemoryToFileL(aThreadId, position, writeSize);
+		position+=writeSize;
+		remaining-=writeSize;
+		}
+
+	}
+
+/**
+ * This takes a memory address and length and writes that raw memory to the file. A large aLength may cause a KErrNoMemory
+ * @param aThreadId Thread ID of memory to read
+ * @param aAddress Address of memory to read
+ * @param aLength Length of memory to read
+ * @param aReadSize How many bytes at a time to read. A large number here will cause memory failures and slow things down
+ * @leave KErrNoMemory if the read size is too big or one of the other System Wide Codes
+ * @see WriteRawMemoryToFileL
+ */
+void CSymbianElfFormatterV2::HelpWriteRawMemoryToFileL(const TUint64 aThreadId, const TUint32 aAddress, const TUint32 aLength)
+	{
+	LOG_MSG4("HelpWriteRawMemoryToFileL Writing memory to file:   aThreadId = [%ld]    aAddress = [0x%X]    aLength = [0x%X]", aThreadId, aAddress, aLength);
+
+    RBuf8 memData;
+    CleanupClosePushL(memData);
+
+    memData.CreateL(aLength);
+
+    iDataSource->ReadMemoryL(aThreadId, aAddress, aLength, memData );
+
+	iDataSave->WriteL( iOffset, const_cast<TUint8*>(memData.Ptr()), aLength );
+	iOffset+=aLength;
+
+    CleanupStack::PopAndDestroy(&memData);
+	}
+
+/**
+Calculate the CRC of the executable code text section up to 1kbytes. We only leave if there is a terminal
+error. If we cannot generate the CRC.
+@param aTid ID of the crashed thread
+@param aExecInfo code segment structure holding iformation required to calculate crc
+@return calculated CRC value
+@leave err one of the system wide error codes
+@see TCodeSegInfo
+*/
+TUint32 CSymbianElfFormatterV2::CalcExecCrcL(const TUint64 &aTid, const TCodeSegInfo &aExecInfo )
+	{
+	TUint32 crc32 = 0xDEADDEAD;
+
+	if(IsSystemCrash())
+		{
+		return crc32;
+		}
+
+    TInt crcSize = aExecInfo.iCodeSize > KMaxCrc32Size ? KMaxCrc32Size : aExecInfo.iCodeSize;
+
+	RBuf8 crcData;
+	crcData.CreateL( crcSize );
+    crcData.CleanupClosePushL();
+
+    iDataSource->ReadMemoryL(aTid, aExecInfo.iCodeRunAddr, crcSize, crcData);
+
+	Mem::Crc32(crc32, crcData.Ptr(), crcData.Length());
+
+    CleanupStack::PopAndDestroy( &crcData );
+
+    return crc32;
+	}
+
+/**
+Goes through all codes segments and saves empty code segments structures as the code .text section is going to be available on the host.
+@param aThreadId The id of the crashed thread.
+@param aCodeSegs list of all code segments loaded into process that crashed
+@param aCodeSegOffsets output list of media-location offsets where segment data was stored
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+*/
+TUint CSymbianElfFormatterV2::WriteCodeSegmentsL( const TUint64 & aThreadId, const RCodeSegPointerList &aCodeSegs, RArray<TUint> &aCodeSegOffsets )
+{
+
+	LOG_MSG2( "CSymbianElfFormatterV2::WriteCodeSegmentsL(aThreadId=0x%X)\n", I64LOW(aThreadId) );
+
+	TUint offset = iOffset;
+
+	if(!iElfOptions->CreateCodeSegments())
+    {
+        LOG_MSG("CSymbianElfFormatterV2::WriteCodeSegmentsL - not configured to dump code segs");
+        return iOffset;
+    }
+
+    for (TInt i = 0, count = aCodeSegs.Count(); i < count; i++)
+    {
+        aCodeSegOffsets.AppendL(0); //not dumping .text section, as it will be present on the host
+	}
+
+	return offset;
+}
+
+/**
+Creates and saves Sym32_thrdinfod structures for all threads provided.
+@param aPid The id of the process of the crashed thread.
+@param aThreadList list of the threads in the crashed process or the whole system, depending on user configuration
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+@see Sym32_thrdinfod
+*/
+TUint CSymbianElfFormatterV2::WriteThreadInfoL( const TUint64 & aPid, const RThreadPointerList &aThreadList )
+{
+
+	LOG_MSG2("->CSymbianElfFormatterV2::WriteThreadInfoL(aPid=0x%X)\n", I64LOW(aPid) );
+
+	TUint offset = iOffset;
+
+	if( !iElfOptions->CreateThreadSegments() )
+	{
+        LOG_MSG("CSymbianElfFormatterV2::WriteThreadInfoL - not configured to dump thread info");
+        return iOffset;
+    }
+
+    Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+    CleanupStack::PushL(descriptor);
+
+    TInt index = iStrInfoTbl->GetIndex(KThread);
+    descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+    descriptor->d_descrsz	= sizeof(Sym32_thrdinfod);
+    descriptor->d_type		= ESYM_NOTE_THRD;
+    descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+    descriptor->d_elemnum	= aThreadList.Count();
+
+    iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+    iOffset += sizeof(Sym32_dhdr);
+    CleanupStack::PopAndDestroy(descriptor);
+
+    Sym32_thrdinfod *thrInfo = new(ELeave) Sym32_thrdinfod();
+    CleanupStack::PushL(thrInfo);
+
+    RBuf8 buf;
+    buf.CreateL( KMaxFullName );
+    CleanupClosePushL(buf);
+
+    for( TInt i = 0; i < aThreadList.Count(); i++ )
+    {
+        //LOG_MSG3( "  Creating Sym32_thrdinfod for Thread[%d].Id()=0x%X", i, I64LOW( aThreadList[i]->Id()) );
+        CThreadInfo &threadInfo = *aThreadList[i];
+
+        buf.Copy( threadInfo.Name() );
+
+        TInt index = KErrNotFound;
+        if (buf.Length() > 0)
+        {
+            index = iStrInfoTbl->AddStringL(buf);
+        }
+
+        thrInfo->td_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+        thrInfo->td_id = threadInfo.Id();
+        thrInfo->td_owning_process = threadInfo.ProcessId();
+        thrInfo->td_priority = threadInfo.Priority();
+        thrInfo->td_svc_sp = threadInfo.SvcStackPtr();
+        thrInfo->td_svc_stack = threadInfo.SvcStackAddr();
+        thrInfo->td_svc_stacksz = threadInfo.SvcStackSize();
+        thrInfo->td_usr_stack = threadInfo.UsrStackAddr();
+        thrInfo->td_usr_stacksz = threadInfo.UsrStackSize();
+        thrInfo->td_last_cpu_id = threadInfo.LastCpuId();
+        thrInfo->td_heap_add = threadInfo.HeapBase();
+        thrInfo->td_heap_sz = threadInfo.HeapSize();
+
+        iDataSave->WriteL( iOffset, thrInfo, sizeof(Sym32_thrdinfod));
+
+        iOffset += sizeof(Sym32_thrdinfod);
+    }
+
+    CleanupStack::PopAndDestroy(2, thrInfo);
+	return offset;
+}
+
+/**
+Creates and saves Sym32_procinfod for all processes provided.
+@param aPid The id of the process of the crashed thread.
+@param aProcessList list of the processes holding the crashed process or the whole system, depending on user configuration
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+@see Sym32_procinfod
+*/
+TUint CSymbianElfFormatterV2::WriteProcessInfoL( const TUint64 & aPid, const RProcessPointerList &aProcessList )
+{
+
+	LOG_MSG2("->CSymbianElfFormatterV2::WriteProcessInfoL(aPid=0x%X)\n", I64LOW(aPid) );
+
+	TUint offset = iOffset;
+
+	if (!iElfOptions->CreateProcessSegments())
+		{
+        LOG_MSG("CSymbianElfFormatterV2::WriteProcessInfoL - not configured to dump process info");
+        return iOffset;
+        }
+
+    Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+    CleanupStack::PushL(descriptor);
+    descriptor->d_elemnum = aProcessList.Count();
+
+    TInt32 index = iStrInfoTbl->GetIndex(KProcess);
+    descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+    descriptor->d_descrsz	= sizeof(Sym32_procinfod);
+    descriptor->d_type		= ESYM_NOTE_PROC;
+    descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+
+    iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+    iOffset += sizeof(Sym32_dhdr);
+
+    Sym32_procinfod *symProcInfo = new(ELeave) Sym32_procinfod();
+    CleanupStack::PushL(symProcInfo );
+
+    RBuf8 buf;
+    buf.CreateL( KMaxFullName );
+    CleanupClosePushL(buf);
+
+    //LOG_MSG2( "  Will create %d Sym32_procinfod structures\n", descriptor->d_elemnum );
+    for(TInt i = 0; i < aProcessList.Count(); i++ )
+        {
+        CProcessInfo &procInfo = *aProcessList[i];
+
+        //LOG_MSG3( "  Creating Sym32_procinfod for Proc[%d].Id()=0x%X", i, I64LOW( procInfo->Id() ) );
+
+        symProcInfo->pd_id = procInfo.Id();
+
+		RProcess proc;
+		if( KErrNone == proc.Open( symProcInfo->pd_id ) )
+			{
+			symProcInfo->pd_priority = proc.Priority();
+			proc.Close();
+			}
+		else
+			{
+			symProcInfo->pd_priority = 0;
+			}
+
+        buf.Copy( procInfo.Name() );
+
+        index = KErrNotFound;
+        if (buf.Length() > 0)
+            {
+            index = iStrInfoTbl->AddStringL(buf);
+            }
+        symProcInfo->pd_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+
+        iDataSave->WriteL( iOffset, symProcInfo, sizeof(Sym32_procinfod));
+
+        iOffset += sizeof(Sym32_procinfod);
+        }
+
+	CleanupStack::PopAndDestroy(3, descriptor);
+
+	return offset;
+}
+
+/**
+Creates and saves Sym32_execinfod structures for all the code segments provided
+@param aCodeSegs list of all code segments loaded into process that crashed
+@param aTime time of the crash.
+@param aTid ID of the crashed thread
+@return value of the media-position indicator at which the call started storing its data
+@leave err one of the system wide error codes
+@see Sym32_execinfod
+*/
+TUint CSymbianElfFormatterV2::WriteExecutableInfoL( const RCodeSegPointerList &aCodeSegs, const TUint64 &aTime, const TUint64 &aTid )
+{
+	LOG_MSG("CSymbianElfFormatterV2::WriteExecutableInfoL()\n");
+
+	TUint offset = iOffset;
+
+	if(!iElfOptions->CreateExecSegments())
+        {
+        LOG_MSG("CSymbianElfFormatterV2::WriteExecutableInfoL - not configured to dump executable info");
+        return iOffset;
+        }
+
+    // Get Executable Info
+    Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+    CleanupStack::PushL(descriptor);
+
+    TInt32 index = iStrInfoTbl->GetIndex(KExecutable);
+    descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+    descriptor->d_descrsz	= sizeof(Sym32_execinfod);
+    descriptor->d_type		= ESYM_NOTE_EXEC;
+    descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+    descriptor->d_elemnum	= aCodeSegs.Count();
+
+    //LOG_MSG3( "   Write ESYM_NOTE_EXEC size =%d at iOffset->%d\n", sizeof(Sym32_dhdr), iOffset );
+    iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+    CleanupStack::PopAndDestroy(descriptor); // descriptor
+
+    iOffset += sizeof(Sym32_dhdr);
+
+    Sym32_execinfod *execInfo = new(ELeave) Sym32_execinfod();
+    CleanupStack::PushL(execInfo);
+
+    RBuf8 name;
+    name.CreateL(KMaxFullName);
+    CleanupClosePushL(name);
+
+    for(TInt i = 0, count = aCodeSegs.Count(); i < count; i++)
+        {
+        TCodeSegInfo &segInfo = *aCodeSegs[i];
+        name.Copy(segInfo.iName);
+        index = KErrNotFound;
+
+        if (name.Length() > 0)
+        {
+            index = iStrInfoTbl->AddStringL(name);
+        }
+
+        execInfo->ed_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+        //LOG_MSG2( "   execInfo->ed_name = %d\n", execInfo->ed_name );
+
+        execInfo->ed_XIP = segInfo.iXIP;
+        //LOG_MSG2( "   execInfo->ed_XIP = %d\n", execInfo->ed_XIP );
+
+        execInfo->ed_execid.exec_id = aTime;
+        execInfo->ed_execid.exec_crc = CalcExecCrcL(aTid, segInfo);
+
+        execInfo->ed_codesize = segInfo.iCodeSize;
+        //LOG_MSG2( "   execInfo->ed_codesize = 0x%x\n", execInfo->ed_codesize );
+        execInfo->ed_coderunaddr = segInfo.iCodeRunAddr;
+        //LOG_MSG2( "   execInfo->ed_coderunaddr = 0x%x\n", execInfo->ed_coderunaddr );
+        execInfo->ed_codeloadaddr = segInfo.iCodeLoadAddr;
+        //LOG_MSG2( "   execInfo->ed_codeloadaddr = 0x%x\n", execInfo->ed_codeloadaddr );
+        execInfo->ed_rodatasize = segInfo.iRoDataSize;
+        execInfo->ed_rodatarunaddr = segInfo.iRoDataRunAddr;
+        execInfo->ed_rodataloadaddr = segInfo.iRoDataLoadAddr;
+        execInfo->ed_datasize = segInfo.iDataSize;
+        execInfo->ed_datarunaddr = segInfo.iDataRunAddr;
+        //LOG_MSG2( "   execInfo->ed_datarunaddr = 0x%x\n", execInfo->ed_datarunaddr );
+        execInfo->ed_dataloadaddr = segInfo.iDataLoadAddr;
+        //LOG_MSG2( "   execInfo->ed_dataloadaddr = 0x%x\n", execInfo->ed_dataloadaddr );
+
+        //LOG_MSG3( "   Write execInfo size =%d at iOffset->%d\n", sizeof(Sym32_execinfod), iOffset );
+        iDataSave->WriteL( iOffset, execInfo, sizeof(Sym32_execinfod));
+
+        iOffset += sizeof(Sym32_execinfod);
+        }
+
+    CleanupStack::PopAndDestroy(2, execInfo);
+
+	return offset;
+}
+
+/**
+The method finds all registers of a specific class (core register or coprocessor register)
+and of a specific represenation (8-bit, 16-bit, 32-bit, 64-bit etc).
+
+@param aRegs Input : all registers of all classes and representations.
+@param aRegsOfSameClassRepr Output : All registers of the same class and representaion.
+@param aClass Input : Which class to use as filter
+@param aRepr INput : Which representation to use as filter.
+*/
+void CSymbianElfFormatterV2::FindAllOfSameClassRepresentation(RRegisterList &aRegs, RRegisterList &aRegsOfSameClassRepr, ESYM_REGCLASS aClass, ESYM_REGREP aRepr)
+{
+	for (TUint j = 0; j < aRegs.Count(); j++)
+	{
+		if ( aRegs[j].Available() &&
+			(aRegs[j].GetClass() == aClass) &&
+			(aRegs[j].GetSize() == aRepr) )
+		{
+			aRegsOfSameClassRepr.Append(aRegs[j]);
+		}
+	}
+}
+
+/**
+ Write registers for threads. For non-crashed threads we save a thread's registers
+ if the user setting CreateRegisterSegmentForAllThreadsInProcess() is true.
+ For the crashed thread we save the thread's registers if the user setting
+ CreateRegisterSegmentForCrashedThread() is true.
+ We can only save register information for threads within the crashed process.
+ The threads in the thread list may contain all threads in the system or only the
+ threads in the crashed process, depending on user choice CreateSystemCrashInfo().
+@param aTid The id of the crashed thread.
+@param aPid The id of the process of the crashed thread.
+@param aOffsets output array of offsets to each threads register information segment.
+@param aArmExcRegs register context of the crashed thread
+@param aThreadList list of the threads in the crashed process or the whole system, depending on user configuration
+@leave err one of the system wide error codes
+*/
+void CSymbianElfFormatterV2::WriteRegisterInfoL( const TUint64 &aTid,
+											   const TUint64 &aPid,
+											   RArray<TUint>& aOffsets,
+											   RRegisterList &aArmExcRegs,
+                                               const RThreadPointerList &aThreadList )
+{
+
+	LOG_MSG2( "CSymbianElfFormatterV2::WriteRegisterInfoL(aTid=0x%X)\n", I64LOW(aTid) );
+
+    if(!iElfOptions->CreateRegisterSegments())
+	    {
+        LOG_MSG("CSymbianElfFormatterV2::WriteRegisterInfoL - not configured to dump register info");
+        return;
+        }
+
+    Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+    CleanupStack::PushL(descriptor);
+
+    Sym32_reginfod *regInfo = new(ELeave) Sym32_reginfod();
+    CleanupStack::PushL(regInfo);
+    // For each thread, Get register info using ReadRegisters( threadId ...)
+    for (TUint i = 0; i<aThreadList.Count(); i++)
+    {
+		CThreadInfo* inf = aThreadList[i];
+
+        if( aThreadList[i]->ProcessId() != aPid )
+            {
+            // Thread not in crashed process
+            continue;
+            }
+
+        LOG_MSG3("Found registers for Process ID = [%ld] and Thread ID = [%d]", inf->ProcessId(), inf->Id());
+        RRegisterList *regListPtr;
+        RRegisterList regList;
+        CleanupClosePushL(regList);
+
+        if( aThreadList[i]->Id() == aTid )
+            {
+            // Use the registers at the time of the crash: aArmExcRegs
+            regListPtr = &aArmExcRegs;
+            }
+        else
+            {
+            TRAPD(err, iDataSource->ReadRegistersL(aThreadList[i]->Id(), regList));
+            if(err != KErrNone)
+            	{
+            	LOG_MSG2("CSymbianElfFormatterV2::WriteRegisterInfoL ReadRegisters failed with err [%d]", err);
+            	}
+
+            regListPtr = &regList;
+            }
+
+        /*
+        LOG_MSG3( "  Register list for thread 0x%X has %d entries",
+            I64LOW(aThreadList[i]->Id()), regListPtr->Count() );
+        */
+
+        RRegisterList tmpRegList;
+        CleanupClosePushL(tmpRegList);
+
+        TBuf8<255> buf;
+        buf.Format(_L8("CORE.SYMBIAN.REGISTER.0x%X%X"), I64HIGH(aThreadList[i]->Id()), I64LOW(aThreadList[i]->Id()));
+        TInt32 index = iStrInfoTbl->AddStringL(buf);
+        descriptor->d_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+        descriptor->d_type = ESYM_NOTE_REG;
+        descriptor->d_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+        descriptor->d_elemnum = 1;
+
+        TUint dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_CORE, ESYM_REG_8);
+
+        LOG_MSG2( "  aOffsets.Count()=%d", aOffsets.Count() );
+
+        if (tmpRegList.Count() > 0)
+        {
+            // Writereg8data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint8 content = tmpRegList[j].GetContent8();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint8));
+                iOffset += sizeof(TUint8);
+            }
+
+            // writedescr
+            aOffsets.Append((TUint)iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod) + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            regInfo->rid_class = ESYM_REG_CORE;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_8;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod8
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint8);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_CORE, ESYM_REG_16);
+        if (tmpRegList.Count() > 0)
+        {
+            // Writereg16data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint16 content = tmpRegList[j].GetContent16();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint16));
+                iOffset += sizeof(TUint16);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod) + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            // writereginfod16
+            regInfo->rid_class = ESYM_REG_CORE;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_16;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod8
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint16);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        //LOG_MSG2( "  Write reg 32. dataOffset = iOffset = %d", iOffset );
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_CORE, ESYM_REG_32);
+        if (tmpRegList.Count() > 0)
+        {
+            LOG_MSG2( "  found %d ESYM_REG_32 registers", tmpRegList.Count() );
+
+            // WriteReg32data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint32 content = tmpRegList[j].GetContent32();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint32));
+                iOffset += sizeof(TUint32);
+            }
+
+            //LOG_MSG2( "  ->aOffsets.Append(iOffset=%d)", iOffset );
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod) + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            //LOG_MSG2( "  ->iDataSave->WriteL( iOffset=%d, descriptor, sizeof(Sym32_dhdr))", iOffset );
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+            //LOG_MSG2( "  iOffset += sizeof(Sym32_dhdr) = %d", iOffset );
+
+            // writereginfod32
+            regInfo->rid_class = ESYM_REG_CORE;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_32;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+
+            //LOG_MSG2( "  iDataSave->WriteL( iOffset = %d, regInfo, sizeof(Sym32_reginfod))", iOffset );
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+            //LOG_MSG2( "  iOffset += sizeof(Sym32_reginfod) = %d", iOffset );
+
+            // writereginfod32
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint32);
+                //LOG_MSG2( "  regData.rd_data = %d", regData.rd_data  );
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_CORE, ESYM_REG_64);
+
+        if (tmpRegList.Count() > 0)
+        {
+            // WriteReg64data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint64 content = tmpRegList[j].GetContent64();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint64));
+                iOffset += sizeof(TUint64);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod)  + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            // writereginfod64
+            regInfo->rid_class = ESYM_REG_CORE;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_64;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod64
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint64);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_COPRO, ESYM_REG_8);
+
+        if (tmpRegList.Count() > 0)
+        {
+
+            // Writereg8data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint8 content = tmpRegList[j].GetContent8();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint8));
+                iOffset += sizeof(TUint8);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod)  + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            regInfo->rid_class = ESYM_REG_COPRO;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_8;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod8
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint8);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_COPRO, ESYM_REG_16);
+        if (tmpRegList.Count() > 0)
+        {
+            // Writereg16data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint16 content = tmpRegList[j].GetContent16();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint16));
+                iOffset += sizeof(TUint16);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod)  + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            // writereginfod16
+            regInfo->rid_class = ESYM_REG_COPRO;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_16;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod8
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint16);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_COPRO, ESYM_REG_32);
+        if (tmpRegList.Count() > 0)
+        {
+            //LOG_MSG2( "  found %d ESYM_REG_32 CoPro registers", tmpRegList.Count() );
+
+            // WriteReg32data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                /*
+                LOG_MSG4( "  Saving CoPro register Id=0x%X, SubId=0x%X, val=0x%X",
+                    tmpRegList[j].GetId(), tmpRegList[j].GetSubId(), tmpRegList[j].GetContent32() );
+                */
+                TUint32 content = tmpRegList[j].GetContent32();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint32));
+                iOffset += sizeof(TUint32);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod)  + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            // writereginfod32
+            regInfo->rid_class = ESYM_REG_COPRO;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_32;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod32
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint32);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+        tmpRegList.Reset();
+
+        dataOffset = iOffset;
+        FindAllOfSameClassRepresentation(*regListPtr, tmpRegList, ESYM_REG_COPRO, ESYM_REG_64);
+        if (tmpRegList.Count() > 0)
+        {
+            // WriteReg64data
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                TUint64 content = tmpRegList[j].GetContent64();
+                iDataSave->WriteL( iOffset, &content, sizeof(TUint64));
+                iOffset += sizeof(TUint64);
+            }
+
+            // writedescr
+            aOffsets.Append(iOffset);
+            descriptor->d_descrsz   = sizeof(Sym32_reginfod)  + tmpRegList.Count()*sizeof(Sym32_regdatad);
+            iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+            iOffset += sizeof(Sym32_dhdr);
+
+            // writereginfod64
+            regInfo->rid_class = ESYM_REG_COPRO;
+            regInfo->rid_num_registers = tmpRegList.Count();
+            regInfo->rid_repre = ESYM_REG_64;
+            regInfo->rid_thread_id = aThreadList[i]->Id();
+            regInfo->rid_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+
+            iDataSave->WriteL( iOffset, regInfo, sizeof(Sym32_reginfod));
+            iOffset += sizeof(Sym32_reginfod);
+
+            // writereginfod64
+            Sym32_regdatad regData;
+
+            for (TUint j = 0; j < tmpRegList.Count(); j++)
+            {
+                regData.rd_id = tmpRegList[j].GetId();
+                regData.rd_sub_id = tmpRegList[j].GetSubId();
+                regData.rd_data = dataOffset + j*sizeof(TUint64);
+
+                iDataSave->WriteL( iOffset, &regData, sizeof(Sym32_regdatad));
+                iOffset += sizeof(Sym32_regdatad);
+            }
+        }
+
+        //LOG_MSG( "  CleanupStack::PopAndDestroy( tmpRegList )" );
+        CleanupStack::PopAndDestroy(&tmpRegList); // tmpRegList. Will call Close().
+
+        //LOG_MSG( "  CleanupStack::PopAndDestroy(regList)" );
+        CleanupStack::PopAndDestroy(&regList); // regList. Will call Close().
+    }
+    //LOG_MSG( "  CleanupStack::PopAndDestroy(descriptor)" );
+    CleanupStack::PopAndDestroy(2, descriptor);
+
+	//LOG_MSG2( "  Final aOffsets.Count()=%d", aOffsets.Count() );
+}
+
+/**
+Saves content of the string info segment.
+@return value of the media-position indicator at which the call started storing its data
+*/
+TUint CSymbianElfFormatterV2::WriteStringInfoL()
+{
+	TUint offset = iOffset;
+
+	Sym32_dhdr *strInfo_descriptor = new(ELeave) Sym32_dhdr();
+	CleanupStack::PushL(strInfo_descriptor);
+	TInt32 index = iStrInfoTbl->GetIndex(KStr);
+	strInfo_descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+	strInfo_descriptor->d_descrsz	= iStrInfoTbl->GetSize();
+	strInfo_descriptor->d_type		= ESYM_NOTE_STR;
+	strInfo_descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+    strInfo_descriptor->d_elemnum	= 1;
+	LOG_MSG2( "   Writing Sym32_dhdr strInfo_descriptor at iOffset -> %d\n", iOffset );
+	iDataSave->WriteL( iOffset, strInfo_descriptor, sizeof(Sym32_dhdr));
+	CleanupStack::PopAndDestroy(strInfo_descriptor); // strInfo_descriptor
+	iOffset += sizeof(Sym32_dhdr);
+
+	// Write all strings
+	TText8* buf = iStrInfoTbl->GetAllStrings();
+	TUint size = iStrInfoTbl->GetSize();
+
+	LOG_MSG2( "   Writing strings at iOffset -> %d\n", iOffset );
+	iDataSave->WriteL( iOffset, buf, size);
+	LOG_MSG2( "   Strings size=%d\n", size);
+	iOffset += size;
+
+	return offset;
+}
+
+/**
+Returns requested register value.
+@param aCrashInfo TCrashInfo data structure holding information about the crash.
+@param aReg structure holding the information about the register caller wants the value of
+@param aVal output parameter where the register value is being stored
+@return ETrue if was able to get register value, EFalse otherwise
+*/
+TBool CSymbianElfFormatterV2::GetArmExcReg(const TCrashInfo &aCrashInfo, const TRegisterData & aReg, TRegisterValue32 & aVal)
+	{
+
+	if( ESYM_REG_CORE != aReg.GetClass() )
+		{
+		return EFalse;
+		}
+
+	switch( aReg.GetId() )
+		{
+		case ERegisterR0:
+			aVal = aCrashInfo.iContext.iR0;
+			break;
+		case ERegisterR1:
+			aVal = aCrashInfo.iContext.iR1;
+			break;
+		case ERegisterR2:
+			aVal = aCrashInfo.iContext.iR2;
+			break;
+		case ERegisterR3:
+			aVal = aCrashInfo.iContext.iR3;
+			break;
+		case ERegisterR4:
+			aVal = aCrashInfo.iContext.iR4;
+			break;
+		case ERegisterR5:
+			aVal = aCrashInfo.iContext.iR5;
+			break;
+		case ERegisterR6:
+			aVal = aCrashInfo.iContext.iR6;
+			break;
+		case ERegisterR7:
+			aVal = aCrashInfo.iContext.iR7;
+			break;
+		case ERegisterR8:
+			aVal = aCrashInfo.iContext.iR8;
+			break;
+		case ERegisterR9:
+			aVal = aCrashInfo.iContext.iR9;
+			break;
+		case ERegisterR10:
+			aVal = aCrashInfo.iContext.iR10;
+			break;
+		case ERegisterR11:
+			aVal = aCrashInfo.iContext.iR11;
+			break;
+		case ERegisterR12:
+			aVal = aCrashInfo.iContext.iR12;
+			break;
+		case ERegisterR13:
+			aVal = aCrashInfo.iContext.iR13;
+			break;
+		case ERegisterR14:
+			aVal = aCrashInfo.iContext.iR14;
+			break;
+		case ERegisterR15:
+			aVal = aCrashInfo.iContext.iR15;
+			break;
+		case ERegisterCpsr:
+			aVal = aCrashInfo.iContext.iCpsr;
+			break;
+		case ERegisterR13Svc:
+			aVal = aCrashInfo.iContext.iR13Svc;
+			break;
+		case ERegisterR14Svc:
+			aVal = aCrashInfo.iContext.iR14Svc;
+			break;
+		case ERegisterSpsrSvc:
+			aVal = aCrashInfo.iContext.iSpsrSvc;
+			break;
+		default:
+			return EFalse;
+		}
+
+	return ETrue;
+	}
+
+/**
+ This method is responsible for creating a member variable that is a list of the
+ registers available at the time of the crash for the crashed thread.
+ The registers not passed to the formatter at the time of the crash are
+ obtained from the data source API.
+@param aCrashInfo TCrashInfo data structure holding information about the crash.
+@param aArmExcRegs output list of registers
+@leave err one of the system wide error codes
+ */
+void CSymbianElfFormatterV2::SetArmRegsFromCrashDataL(const TCrashInfo &aCrashInfo, RRegisterList &aArmExcRegs)
+	{
+	LOG_MSG("->CSymbianElfFormatterV2::SetArmRegsFromCrashDataL()\n");
+
+//    aArmExcRegs.Reset();
+	// Read all registers first, then overwrite values with what we get
+	// from crash data, if available
+	iDataSource->ReadRegistersL( aCrashInfo.iTid, aArmExcRegs );
+
+	//Set the CPSR if we can
+	for(TInt cnt = 0; cnt < aArmExcRegs.Count(); cnt++)
+		{
+		TRegisterData reg = aArmExcRegs[cnt];
+		if(reg.GetId() == ERegisterCpsr)
+			{
+			iCPSR = reg.GetContent32();
+			break;
+			}
+		}
+
+	if( !IsSystemCrash() && TCrashInfo::ECrashException != aCrashInfo.iType )
+		{
+		// The registers for the crashed thread are only available for exceptions.
+		// When not an exception, use the registers are returned by the ReadRegisters call
+		// This is not an error
+		return;
+		}
+
+	TRegisterValue32 val;
+
+	for(TInt numRegs=0; numRegs < aArmExcRegs.Count(); numRegs ++ )
+		{
+		if( GetArmExcReg( aCrashInfo, aArmExcRegs[numRegs], val ) )
+			{
+			LOG_MSG3( "  Setting reg[%d] to =0x%X", numRegs, val );
+			aArmExcRegs[numRegs].SetContent( (TUint) val );
+			aArmExcRegs[numRegs].SetAvailable( ETrue );
+			}
+		}
+
+	// Now add the FSR and FAR to the available registers for the crashed thread
+	// These are Co-Pro registers
+	TRegisterData reg;
+	reg.iId			= 15; // Co-Pro 15
+	reg.iSize		= ESYM_REG_32;
+	reg.iRegClass	= ESYM_REG_COPRO;
+	reg.iAvailable	= ETrue;
+
+	/*
+	Create two Co-Processor registers to represent the fault status FSR and
+	fault address FAR values. The fault status and address values depend on
+	the type of exception. See /e32/nkern/arm/vectors.cia
+
+	The sub id of the register is based on the ARM instruction used to access the reg:
+
+                             Op1 CRn CRm Op2=0. Op1 bits 10-8, CRn bits 7-4
+      fault address  mrc p15, 0, c6, c0  =>          0       ,    6
+      fault status   mrc p15, 0, c5, c0  =>          0       ,    5
+    */
+
+	reg.iSubId = 6;
+	reg.iSubId <<= 4;
+	reg.SetContent( aCrashInfo.iContext.iFaultAddress );
+	reg.SetAvailable( ETrue );
+	aArmExcRegs.AppendL( reg );
+
+	reg.iSubId = 5;
+	reg.iSubId <<= 4;
+	reg.SetContent( aCrashInfo.iContext.iFaultStatus );
+	reg.SetAvailable( ETrue );
+	aArmExcRegs.AppendL( reg );
+	}
+
+/**
+ This reads the trace data from the buffer and writes it to the file, returning the offset
+ at which the data starts. This is zero if the trace read should fail for some reason
+ @leave err one of the system wide error codes
+ @return offset Offset at which trace data has been written. zero if it didnt write anything
+ */
+TUint CSymbianElfFormatterV2::WriteTraceBufferL()
+	{
+	LOG_MSG("->CSymbianElfFormatterV2::WriteTraceBufferL()\n");
+
+	TInt traceDataToCapture = iElfOptions->TraceDataToCapture();
+
+	if(traceDataToCapture == 0)
+		{
+		LOG_MSG("\tCSymbianElfFormatterV2::WriteTraceBufferL - not configured to dump trace data");
+		return 0;
+		}
+
+	TUint offset = iOffset;
+
+	//write the descriptor
+    Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+    CleanupStack::PushL(descriptor);
+
+	TBuf8<255> buf;
+    buf.Format(_L8("CORE.SYMBIAN.TRACE"));
+    TInt32 index = iStrInfoTbl->AddStringL(buf);
+    descriptor->d_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+	descriptor->d_type = ESYM_NOTE_TRACE;
+	descriptor->d_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+	descriptor->d_elemnum = 1;
+	descriptor->d_descrsz = sizeof(Sym32_tracedata);
+
+    LOG_MSG2("\tWriting trace note descriptor at %d", iOffset);
+	iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+	iOffset += sizeof(Sym32_dhdr);
+	CleanupStack::PopAndDestroy(descriptor);
+
+	//Write the info hdr
+	Sym32_tracedata *traceInfo = new(ELeave) Sym32_tracedata();
+	CleanupStack::PushL(traceInfo);
+	traceInfo->tr_version = iStrInfoTbl->GetIndex(KSymbianTraceVersion);
+
+	//If there is no trace data in the buffer, its just a null pointer
+	traceInfo->tr_data = iOffset + sizeof(Sym32_tracedata);
+
+	TUint traceAvailable = 0;
+	TRAPD(err, traceAvailable = iDataSource->GetAvailableTraceSizeL());
+	if(err != KErrNone)
+		{
+		LOG_MSG2("CSymbianElfFormatterV2::WriteTraceBufferL() Unable to get available trace size. Err = [%d] ", err);
+		LOG_MSG2("CSymbianElfFormatterV2::WriteTraceBufferL() traceAvailable will be = [%d] ", traceAvailable);
+		}
+
+	traceInfo->tr_size = traceAvailable;
+
+	//Write trace info
+	LOG_MSG3("\tWriting Trace Info: iDataSave->WriteL() at offset = %d, size =%d bytes", iOffset, sizeof(Sym32_tracedata));
+	iDataSave->WriteL(iOffset, traceInfo, sizeof(Sym32_tracedata));
+	iOffset += sizeof(Sym32_tracedata);
+
+	//Size is zero due to error and there is no data to write
+	if(err != KErrNone)
+		{
+		LOG_MSG("CSymbianElfFormatterV2::WriteTraceBufferL() 0 size returning");
+		CleanupStack::Check(traceInfo);
+		CleanupStack::PopAndDestroy(traceInfo);
+		return offset;
+		}
+
+	//Write the data to the file
+	LOG_MSG3("\tWriting Trace data: iDataSave->WriteL() at Offset =%d, size =%d bytes", iOffset, traceAvailable);
+	TUint size = 0;
+
+	if(IsSystemCrash())
+		{
+		TRAP(err, size = HelpWriteTraceBufferL(traceAvailable, traceDataToCapture * 1024, iOffset));
+		}
+	else
+		{
+		TRAP(err, size = HelpWriteTraceBufferWithTraceFrameWorkL(traceDataToCapture * 1024, iOffset));
+		}
+
+	if(err != KErrNone)
+		{
+		//This error is not fatal but worth logging
+		LOG_MSG2("Trace writing didnt succeed. Error = [%d]", err);
+		}
+	else
+		{
+		LOG_MSG("Trace data and info succesfully written");
+		}
+
+	iOffset += size;
+	CleanupStack::PopAndDestroy(traceInfo);
+
+	return offset;
+	}
+
+/**
+ * This gets trace from the data source. This is for use when you dont want trace from the live system and want
+ * the data source to decide how we obtain the trace. The data source may not support this, and leaving with
+ * KErrNotSupported will mean that you should be using the live trace system to get the data
+ * @param aTraceAvailable The amount of availbale trace data
+ * @param aTraceWanted The amount of trace data we wish to dump
+ * @param aOffset The position in the file to write the trace
+ * @see HelpWriteTraceBufferWithTraceFrameWorkL
+ */
+TUint CSymbianElfFormatterV2::HelpWriteTraceBufferL(TUint aTraceAvailable, TUint aTraceWanted, TUint aOffset)
+	{
+	LOG_MSG4("CSymbianElfFormatterV2::HelpWriteTraceBufferL aTraceAvailable = [%d] aTraceWanted = [%d] aOffset = [%d]", aTraceAvailable, aTraceWanted, aOffset);
+
+	TUint dataReq = (aTraceAvailable >= aTraceWanted) ? aTraceWanted : aTraceAvailable;
+	TUint bufferSize = dataReq;
+	RBuf8 theTraceData;
+	TBool bufferCreated = EFalse;
+
+	//Try and allocate the buffer
+	while(!bufferCreated)
+		{
+		LOG_MSG2("Trying to create a buffer of size [%d] bytes", bufferSize);
+
+		if(bufferSize == 0)
+			{
+			User::LeaveNoMemory();
+			}
+
+		TInt err = theTraceData.Create(bufferSize);
+		if(KErrNone == err)
+			{
+			bufferCreated = ETrue;
+			theTraceData.CleanupClosePushL();
+			}
+		else
+			{
+			bufferSize = bufferSize/4;
+			}
+		}
+
+	//Now we read the trace data bit by bit
+	TUint sizeWritten = 0;
+	while(sizeWritten < dataReq)
+		{
+		iDataSource->ReadTraceBufferL(theTraceData, sizeWritten);
+
+		LOG_MSG3("Writing [%d] bytes of raw trace data at [%d]", theTraceData.Size(), aOffset);
+		iDataSave->WriteL( aOffset, const_cast<TUint8*>(theTraceData.Ptr()), theTraceData.Size());
+
+		sizeWritten += theTraceData.Length();
+		aOffset += theTraceData.Length();
+		}
+
+	CleanupStack::PopAndDestroy(&theTraceData);
+
+	return sizeWritten;
+	}
+
+/**
+ * Writes trace to the file using the trace framework. This is to use when you want trace from the live system.
+ * @param aTraceWanted The amount of trace data we wish to dump
+ * @param aOffset The position in the file to write the trace
+ * @see HelpWriteTraceBufferL
+ */
+TUint CSymbianElfFormatterV2::HelpWriteTraceBufferWithTraceFrameWorkL(TUint aTraceWanted, TUint aOffset)
+	{
+	LOG_MSG3("CSymbianElfFormatterV2::HelpWriteTraceBufferWithTraceFrameWorkL aTraceWanted = [%d] aOffset = [%d]", aTraceWanted, aOffset);
+
+    RBTrace trace;
+    User::LeaveIfError(trace.Open());
+    CleanupClosePushL(trace);
+
+    TUint8 *data = NULL;
+    TInt size = trace.GetData(data);
+
+    if(!data)
+    	{
+    	User::Leave(KErrNotFound);
+    	}
+
+    TUint sizeToDump = (aTraceWanted >= size) ? size : aTraceWanted;
+
+    LOG_MSG2("Adding [%d] bytes to the file", sizeToDump);
+    iDataSave->WriteL( aOffset, data, sizeToDump);
+
+    CleanupStack::PopAndDestroy(&trace);
+
+	return size;
+	}
+
+/**
+Writes ROM build info
+@leave err one of the system wide error codes
+@return offset at which data has been written
+*/
+TUint CSymbianElfFormatterV2::WriteRomBuildInfoL()
+	{
+	LOG_MSG2("->CSymbianElfFormatterV2::WriteROMBuildInfo() starting at iOffset = [%d]\n", iOffset);
+
+	TUint offset = iOffset;
+
+#ifdef __MARM_ARMV5__
+	if( !iElfOptions->CreateRomBuildInfo() )
+		{
+        LOG_MSG("CSymbianElfFormatterV2::WriteROMBuildInfo - not configured to dumprom info data");
+        return 0;
+		}
+
+	//This may leave with KErrNotFound - or anything for that matter, so do it before
+	//we write anything in
+	TRomHeaderData romHdr;
+	iDataSource->GetROMBuildInfoL(romHdr);
+
+	// write the descriptor
+    Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+    CleanupStack::PushL(descriptor);
+
+    TBuf8<255> buf;
+    buf.Format(_L8("CORE.SYMBIAN.ROMBUILD"));
+    TInt32 index = iStrInfoTbl->AddStringL(buf);
+    descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+    descriptor->d_descrsz	= sizeof(Sym32_lockdata);
+    descriptor->d_type		= ESYM_NOTE_ROMBUILD;
+    descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+    descriptor->d_elemnum	= 1;
+
+    iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+    iOffset += sizeof(Sym32_dhdr);
+    CleanupStack::PopAndDestroy(descriptor);
+
+    Sym32_rombuild *romInfo = new(ELeave) Sym32_rombuild();
+    CleanupStack::PushL(romInfo);
+
+    romInfo->rom_major_version = romHdr.iMajorVersion;
+    romInfo->rom_minor_version = romHdr.iMinorVersion;
+    romInfo->rom_build = romHdr.iBuildNumber;
+    romInfo->rom_time = romHdr.iTime;
+
+    iDataSave->WriteL( iOffset, romInfo, sizeof(Sym32_rombuild));
+    iOffset += sizeof(Sym32_rombuild);
+
+    CleanupStack::PopAndDestroy(romInfo);
+#else
+    return 0;
+#endif
+
+	return offset;
+	}
+
+/**
+Writes variant specific info
+@leave err one of the system wide error codes
+@return offset at which data has been written
+*/
+TUint CSymbianElfFormatterV2::WriteVariantSpecificDataL()
+	{
+	LOG_MSG("->CSymbianElfFormatterV2::WriteVariantSpecificDataL()\n");
+
+	if(!iElfOptions->CreateVariantSpecificData())
+		{
+		LOG_MSG("\tCSymbianElfFormatterV2::WriteVariantSpecificDataL - not configured to variant specific data");
+		return 0;
+		}
+
+	TUint offset = iOffset;
+
+	//write the descriptor
+	Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+	CleanupStack::PushL(descriptor);
+
+	TBuf8<255> buf;
+	buf.Format(_L8("CORE.SYMBIAN.VARDATA"));
+	TInt32 index = iStrInfoTbl->AddStringL(buf);
+	descriptor->d_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+	descriptor->d_type = ESYM_NOTE_VARIANT_DATA;
+	descriptor->d_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+	descriptor->d_elemnum = 1;
+	descriptor->d_descrsz = sizeof(Sym32_variant_spec_data);
+
+	LOG_MSG2("\tWriting variant specific data note descriptor at %d", iOffset);
+	iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+	CleanupStack::PopAndDestroy(descriptor);
+
+	iOffset += sizeof(Sym32_dhdr);
+
+	//Write the info hdr
+	Sym32_variant_spec_data *variantData = new(ELeave) Sym32_variant_spec_data();
+	CleanupStack::PushL(variantData);
+	variantData->es_data = iOffset + sizeof(Sym32_variant_spec_data);
+	variantData->es_size = 0;
+
+	TUint availableVarData = 0;
+	TInt err = iDataSource->GetVariantSpecificDataSize(availableVarData);
+	if(KErrNone != err)
+		{
+		LOG_MSG2("CSymbianElfFormatterV2::WriteVariantSpecificDataL() Unable to get variant data size. Err = [%d] ", err);
+		//No return as we still need to write the note for a valid elf file
+		}
+
+	variantData->es_size = availableVarData;
+
+	//Write variant info
+	LOG_MSG3("\tWriting Variant Specific Info note: iDataSave->WriteL() at offset = %d, size =%d bytes", iOffset, sizeof(Sym32_variant_spec_data));
+	err = iDataSave->Write(iOffset, variantData, sizeof(Sym32_variant_spec_data));
+	iOffset += sizeof(Sym32_variant_spec_data);
+	CleanupStack::PopAndDestroy(variantData);
+
+	if(err != KErrNone || availableVarData == 0)
+		{
+		LOG_MSG("CSymbianElfFormatterV2::WriteVariantSpecificDataL() 0 size returning");
+		return offset;
+		}
+
+	//Write the data to the file
+	LOG_MSG3("\tWriting variant data: iDataSave->WriteL() at Offset =%d, size =%d bytes", iOffset, availableVarData);
+	RBuf8 rawData;
+	rawData.CreateL(availableVarData);
+
+	err = iDataSource->GetVariantSpecificData(rawData);
+	if(KErrNone != err)
+		{
+		LOG_MSG2("CSymbianElfFormatterV2::WriteVariantSpecificDataL() Unable to get variant info from data source [%d]", err);
+		rawData.Close();
+		return offset;
+		}
+
+	LOG_MSG3("Writing [%d] bytes of raw variant specific data at [%d]", rawData.Size(), iOffset);
+	err = iDataSave->Write(iOffset, const_cast<TUint8*>(rawData.Ptr()), rawData.Size()); //The Write(TDes&) method doesn't seem to work
+	if(KErrNone == err)
+		iOffset += rawData.Size();
+	else
+		LOG_MSG2("CSymbianElfFormatterV2::WriteVariantSpecificDataL() Unable to log variant specific data: [%d]", err);
+
+	rawData.Close();
+	return offset;
+	}
+
+/**
+Description
+@leave err one of the system wide error codes
+@return offset at which data has been written
+*/
+TUint CSymbianElfFormatterV2::WriteLockDataL()
+	{
+	LOG_MSG2("->CSymbianElfFormatterV2::WriteLockDataL() at iOffset = [%d]\n", iOffset);
+
+	TUint offset = iOffset;
+#ifdef __MARM_ARMV5__
+
+	if( !iElfOptions->CreateLockDataSegments() )
+		{
+        LOG_MSG("CSymbianElfFormatterV2::WriteLockDataL - not configured to dump system lock data");
+        return 0;
+		}
+
+	//This may leave with KErrNotFound - or anything for that matter, so do it before
+	//we write anything in
+	TSCMLockData lockdata;
+	iDataSource->GetLocksL(lockdata);
+
+	// write the descriptor
+    Sym32_dhdr *descriptor = new(ELeave) Sym32_dhdr();
+    CleanupStack::PushL(descriptor);
+
+    TBuf8<255> buf;
+    buf.Format(_L8("CORE.SYMBIAN.LOCKDATA"));
+    TInt32 index = iStrInfoTbl->AddStringL(buf);
+    descriptor->d_name		= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+    descriptor->d_descrsz	= sizeof(Sym32_lockdata);
+    descriptor->d_type		= ESYM_NOTE_LOCKDATA;
+    descriptor->d_version	= iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersionV2);
+    descriptor->d_elemnum	= 1;
+
+    iDataSave->WriteL( iOffset, descriptor, sizeof(Sym32_dhdr));
+    iOffset += sizeof(Sym32_dhdr);
+    CleanupStack::PopAndDestroy(descriptor);
+
+    Sym32_lockdata *lockDataInfo = new(ELeave) Sym32_lockdata();
+    CleanupStack::PushL(lockDataInfo);
+
+    lockDataInfo->lk_lock_count = lockdata.LockCount();
+    lockDataInfo->lk_mutex_held_count = lockdata.MutexHoldCount();
+    lockDataInfo->lk_mutex_thread_wait_count = lockdata.MutexThreadWaitCount();
+
+    iDataSave->WriteL( iOffset, lockDataInfo, sizeof(Sym32_lockdata));
+    iOffset += sizeof(Sym32_lockdata);
+
+    CleanupStack::PopAndDestroy(lockDataInfo);
+#else
+    return 0;
+#endif
+
+	return offset;
+	}
+
+/**
+ * Prepares the name of the dump file. Checks DataSave filename option, if it is provided by the user
+ * it appends the time stamp, if not it uses default name appended with the time stamp.
+ * @param aStamp lower 32 bits of the time stamp
+ * @leave err one of system wide error codes
+ */
+void CSymbianElfFormatterV2::PrepareFileNameL(TUint64 aStamp)
+{
+	LOG_MSG("->CSymbianElfFormatterV2::PrepareFileNameL()\n");
+
+	COptionConfig *option = iDataSave->GetConfigParameterL(CCrashDataSave::ECoreFilePath);
+	const TDesC &userFileName = option->ValueAsDesc();
+
+	if(userFileName.Length() == 0)
+		{
+		_LIT(KTxtFileFormat, "E:\\core%u.elf");
+		iElfFileName.Format(KTxtFileFormat, aStamp);
+		}
+	else
+		{
+		iElfFileName = userFileName;
+		}
+}
+
+/**
+    Cleanup item implementation for thread list in CrashEventL() method.
+@param aArray pointer to the list that is supposed to be freed
+*/
+void CSymbianElfFormatterV2::CleanupCodeSegList(TAny *aArray)
+{
+    LOG_MSG("->CSymbianElfFormatterV2::CleanupCodeSegList()\n");
+	RCodeSegPointerList *codeSegList = static_cast<RCodeSegPointerList*> (aArray);
+    codeSegList->ResetAndDestroy();
+    codeSegList->Close();
+    delete codeSegList;
+}
+
+/**
+    Cleanup item implementation for thread list in CrashEventL() method.
+@param aArray pointer to the list that is supposed to be freed
+*/
+void CSymbianElfFormatterV2::CleanupProcessList(TAny *aArray)
+	{
+    LOG_MSG("->CSymbianElfFormatterV2::CleanupProcessList()");
+	RProcessPointerList *processList = static_cast<RProcessPointerList*> (aArray);
+    processList->ResetAndDestroy();
+    processList->Close();
+    delete processList;
+	}
+
+/**
+    Cleanup item implementation for thread list in CrashEventL() method.
+@param aArray pointer to the list that is supposed to be freed
+*/
+void CSymbianElfFormatterV2::CleanupThreadList(TAny *aArray)
+	{
+    LOG_MSG("->CSymbianElfFormatterV2::CleanupThreadList()\n");
+	RThreadPointerList *threadList = static_cast<RThreadPointerList*> (aArray);
+    threadList->ResetAndDestroy();
+    threadList->Close();
+    delete threadList;
+	}
+
+/**
+ Starts a crash event and generates Symbian ELF formatted crash data. Write the data using the
+ provided data save interface.
+@param aCrashInfo Crash Data @see TCrashInfo.
+@leave err one of the system wide error codes
+*/
+void CSymbianElfFormatterV2::CrashEventL( TCrashInfo* aCrashInfo )
+	{
+	//PRepare file for the dumping
+    LOG_MSG("CSymbianElfFormatterV2::CrashEventL SELF V2\n");
+    User::LeaveIfNull(iDataSave);
+
+    // unique ID identifying the crash lower 32 bits of the crash time
+    iCrashUID.iUid = I64LOW(aCrashInfo->iTime);
+
+    // descriptorize the crash UID
+    iCrashIDBuffer.Zero();
+    iCrashIDBuffer.AppendNumFixedWidth(iCrashUID.iUid, EDecimal, KMaxUIDLength);
+
+	TTime currentTime;
+	currentTime.HomeTime();
+	PrepareFileNameL(currentTime.Int64());
+	iDataSave->OpenL(iElfFileName);
+
+	iElfFileName = iDataSave->GetMediaName();
+
+    //Update the crash media name and to be in progress
+    TRAPD(err,UpdateMediaNameL(iElfFileName, KMediaStatusInprogress));
+    if(err != KErrNone && iDataSave)
+        {
+        LOG_MSG2("->CSymbianElfFormatterV2::UpdateMediaNameL Failed with [%d]\n", err);
+        iDataSave->CloseL();
+        User::Leave(err);
+        }
+	//now do the crash event
+	TRAP(err, HandleCrashEventL(aCrashInfo));
+	if(err != KErrNone && iDataSave)
+		{
+		LOG_MSG2("->CSymbianElfFormatterV2::CrashEvent Failed with [%d]\n", err);
+		iDataSave->CloseL();
+		User::Leave(err);
+		}
+
+	// Update the crash media name and to be done
+	UpdateCrashProgressL(KProgressDone);
+	TRAP(err,UpdateMediaNameL(iElfFileName, KMediaStatusDone));
+	if(err != KErrNone && iDataSave)
+		{
+		LOG_MSG2("->CSymbianElfFormatterV2::UpdateMediaNameL Failed with [%d]\n", err);
+		iDataSave->CloseL();
+		User::Leave(err);
+		}
+	}
+
+/**
+ Handle a crash event and generate Symbian ELF formatted crash data. Write the data using the
+ provided data save interface.
+@param aCrashInfo Crash Data @see TCrashInfo.
+@leave err one of the system wide error codes
+*/
+void CSymbianElfFormatterV2::HandleCrashEventL( TCrashInfo* aCrashInfo )
+{
+	LOG_MSG("CSymbianElfFormatterV2::HandleCrashEventL started");
+
+    //LOG_MSG("CSymbiaElfFormatter::CrashEventL - checking if crash info is sane\n");
+    User::LeaveIfNull(aCrashInfo);
+    //LOG_MSG("CSymbianElfFormatterV2::CrashEventL - checking if data source is sane\n");
+    User::LeaveIfNull(iDataSource);
+
+    UpdateCrashProgressL( KProgressStart );
+
+    RRegisterList armExcRegs;
+    CleanupClosePushL(armExcRegs);
+    SetArmRegsFromCrashDataL(*aCrashInfo, armExcRegs);
+
+	iStrInfoTbl = CStringInfoTableV2::NewLC();
+
+	// This is a workaround for fole media, since it does not support
+	// saving beyond the current file size. At the start this is 0, so we
+	// must save this data even with dummy values.
+	Elf32_Ehdr *elfHdr = new(ELeave) Elf32_Ehdr();
+	CleanupStack::PushL(elfHdr);
+	iDataSave->WriteL( 0, elfHdr, sizeof(Elf32_Ehdr));
+
+	// Move file pointer to skip Elf Header as the info in that struct isn't known
+	// until everything has been written.
+	iOffset = sizeof(Elf32_Ehdr);
+
+    RProcessPointerList *processList = new(ELeave)RProcessPointerList;
+    TCleanupItem processCleanup(CSymbianElfFormatterV2::CleanupProcessList, (TAny*)processList);
+    CleanupStack::PushL(processCleanup);
+
+    LOG_MSG("CSymbianElfFormatterV2::HandleCrashEventL - getting process list\n");
+
+    iDataSource->GetProcessListL( *processList );
+
+	// Search processList for the crashed process, then get its details
+    CProcessInfo *crashedProc = NULL;
+    TInt i = 0;
+	for (i = 0; i < processList->Count(); i++ )
+		{
+		if( (*processList)[i]->Id() == aCrashInfo->iPid )
+			{
+            LOG_MSG2("CSymbianElfFormatterV2::CrashEventL - found crashed process on the process list index[%d]"
+            		, i);
+			crashedProc = (*processList)[i];
+			break;
+			}
+		}
+
+	if( !crashedProc )
+		{
+		LOG_MSG( "  ERROR CProcessInfo == NULL. Crashed proc not found in process list" );
+		User::Leave( KErrBadHandle );
+		return; // Here for Coverity reasons
+		}
+
+    if(!iElfOptions->CreateSystemCrashInfo())
+        {
+		LOG_MSG3( "  Not generating SystemCrashInfo, only keeping crashed proc i=%d, 0x%X in proc list",
+			i, I64LOW(crashedProc->Id()));
+        processList->Remove(i);
+        processList->ResetAndDestroy();
+        processList->AppendL(crashedProc);
+        }
+
+	LOG_MSG2( " processList->Count()=%d", processList->Count() );
+
+	TUint64 threadRequestPid;
+	if( iElfOptions->CreateSystemCrashInfo() )
+		{
+		// All threads in the system
+		threadRequestPid = (TUint64)-1;
+		//LOG_MSG( "  iElfOptions->CreateSystemCrashInfo() is True => Get All System Threads" );
+		}
+	else
+		{
+		// This should only return the threads under the crashed process
+		//LOG_MSG( "  iElfOptions->CreateSystemCrashInfo() is False => Get Process Specific Threads" );
+		threadRequestPid = aCrashInfo->iPid;
+		}
+
+    RThreadPointerList *threadList = new(ELeave) RThreadPointerList;
+    TCleanupItem threadCleanup(CSymbianElfFormatterV2::CleanupThreadList, (TAny*)threadList);
+    CleanupStack::PushL(threadCleanup);
+
+	iDataSource->GetThreadListL( threadRequestPid, *threadList );
+
+ 	if(!iElfOptions->CreateProcessData())
+        {
+
+		LOG_MSG2( " threadList->Count()=%d before removal of non-crashed threads in process", threadList->Count() );
+		// User does not want threads from the crashed process. So remove these threads from the
+		// threads list. We still want the crashed thread and any other threads not belonging to
+		// this process.
+		TBool found;
+		do
+			{
+
+			found = EFalse;
+			for(TInt i =0; i < threadList->Count(); i++)
+				{
+				if( ((*threadList)[i]->ProcessId() == aCrashInfo->iPid) &&
+					((*threadList)[i]->Id() != aCrashInfo->iTid) )
+					{
+					LOG_MSG2("  removing thread 0x%X\n", I64LOW((*threadList)[i]->Id()) );
+					CThreadInfo *someThread = (*threadList)[i];
+					threadList->Remove(i);
+					delete someThread;
+					found = ETrue;
+					break;
+					}
+				}
+
+			} while( found );
+
+		}
+
+	LOG_MSG2( " threadList->Count()=%d", threadList->Count() );
+
+    RCodeSegPointerList *codeSegList = new(ELeave) RCodeSegPointerList;
+    TCleanupItem codeSegCleanup(CSymbianElfFormatterV2::CleanupCodeSegList, (TAny*)codeSegList);
+    CleanupStack::PushL(codeSegCleanup);
+
+    iDataSource->GetCodeSegmentsL(aCrashInfo->iTid, *codeSegList);
+
+
+
+    TCodeSegInfo *execInfo = NULL;
+    for(TInt i = 0; i < codeSegList->Count(); i++)
+        {
+        if((*codeSegList)[i]->iType == EExeCodeSegType)
+            {
+            LOG_MSG("CSymbianElfFormatterV2::CrashEventL - found exe code seg list\n");
+            execInfo = (*codeSegList)[i];
+            break;
+            }
+        }
+
+    if(!execInfo)
+		{
+		LOG_MSG( "  ERROR TCodeSegInfo == NULL. Crashed exec not found in code seg list" );
+		User::Leave( KErrBadHandle );
+		return; // Here for Coverity reasons
+		}
+
+	TUint32 crc32 = CalcExecCrcL(aCrashInfo->iTid, *execInfo);
+
+    UpdateCrashProgressL( KWriteSymbianInfoProgress );
+	TUint symbianInfoOffset = WriteSymbianInfoL(*aCrashInfo, crc32);
+
+    RSegmentList dataSegs;
+    CleanupClosePushL(dataSegs);
+    RArray<TUint> dataSegOffsets;
+    CleanupClosePushL(dataSegOffsets);
+
+    UpdateCrashProgressL( KWriteDataSegProgress );
+	TUint dataSegmentsOffset = WriteDataSegmentsL( aCrashInfo->iTid, aCrashInfo->iPid, *threadList, *codeSegList, dataSegs, dataSegOffsets );
+
+    RArray<TUint> codeSegOffsets;
+    CleanupClosePushL(codeSegOffsets);
+
+    UpdateCrashProgressL( KWriteCodeSegProgress );
+	TUint codeSegmentsOffset = WriteCodeSegmentsL( aCrashInfo->iTid, *codeSegList, codeSegOffsets );
+
+	//LOG_MSG2( "   iOffset before WriteThreadInfoL-> %d\n", iOffset );
+    UpdateCrashProgressL( KWriteThreadProgress );
+	TUint threadInfoOffset = WriteThreadInfoL( aCrashInfo->iPid, *threadList );
+
+	//LOG_MSG2( "   iOffset before WriteProcessInfoL-> %d\n", iOffset );
+    UpdateCrashProgressL( KWriteProcessProgress );
+	TUint processInfoOffset = WriteProcessInfoL( aCrashInfo->iPid, *processList );
+
+	//LOG_MSG2( "   iOffset before WriteExecutableInfoL-> %d\n", iOffset );
+    UpdateCrashProgressL( KWriteExeProgress );
+	TUint executableInfoOffset = WriteExecutableInfoL( *codeSegList, aCrashInfo->iTime, aCrashInfo->iTid );
+	//LOG_MSG2( "   iOffset after WriteExecutableInfoL-> %d\n", iOffset );
+
+	TUint traceInfoOffset = 0;
+
+	TRAPD(err, traceInfoOffset = WriteTraceBufferL());
+	if(KErrNone != err)
+		{
+		LOG_MSG2("Unable to dump trace data - [%d]", err);
+		}
+
+	//Do the System Lock data if we can
+	TUint systemLocksOffset = 0;
+	TRAP(err, systemLocksOffset = WriteLockDataL());
+	if(KErrNone != err)
+		{
+		LOG_MSG2("Not dumping System locks - [%d]", err);
+		}
+
+	//ROM Build info if we can
+	TUint romBuildOffset = 0;
+	TRAP(err, romBuildOffset = WriteRomBuildInfoL());
+	if(KErrNone != err)
+		{
+		LOG_MSG2("Not dumping ROM build info - [%d]", err);
+		}
+
+	TUint variantOffset = 0;
+	TRAP(err, variantOffset = WriteVariantSpecificDataL());
+	if(KErrNone != err)
+		{
+		LOG_MSG2("Not dumping variant specific info - [%d]", err);
+		}
+
+	RArray<TUint> registerInfoOffsets;
+	CleanupClosePushL(registerInfoOffsets);
+
+    UpdateCrashProgressL( KWriteRegProgress );
+	LOG_MSG( "  -> WriteRegisterInfoL()\n" );
+	WriteRegisterInfoL(aCrashInfo->iTid, aCrashInfo->iPid, registerInfoOffsets, armExcRegs, *threadList);
+	LOG_MSG( "  <- WriteRegisterInfoL()\n" );
+	TUint stringInfoOffset = WriteStringInfoL();
+
+	LOG_MSG2( "   programTableOffset set to -> %d\n", iOffset );
+	TUint programTableOffset = iOffset;
+
+	// Create program header table 2.3 by collecting and assembling all bits and pieces needed
+
+	TUint noProgramTblEntries = 0;
+
+    UpdateCrashProgressL( KCreatePHdrProgress );
+
+	Elf32_Phdr *header = new(ELeave) Elf32_Phdr();
+	CleanupStack::PushL(header);
+
+	// create program header with p_type=PT_NOTE and p_offset pointing to Symbian Info
+	header->p_type = PT_NOTE;
+	header->p_offset = symbianInfoOffset;
+	//LOG_MSG2( "   Symbian Info Elf32_Phdr.p_offset points to -> %d\n", header->p_offset );
+	header->p_vaddr = 0;
+	header->p_paddr = 0;
+	header->p_filesz = 0;
+	header->p_memsz = 0;
+	header->p_flags = 0; //no flags for note segments
+	header->p_align = 4;
+	//LOG_MSG2( "   Writing 1st Elf32_Phdr (Symbian Info ) at offset %d\n", iOffset );
+	iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+
+	iOffset += sizeof(Elf32_Phdr);
+	noProgramTblEntries++;
+
+	if( iElfOptions->CreateDataSegments() )
+	{
+        LOG_MSG2("SymbianElfFormatter:: dataSegs.Count90 = %d", dataSegs.Count());
+		for (TInt i=0; i < dataSegs.Count(); i++) // each segment in segs
+		{
+
+			header->p_type = PT_LOAD;
+			header->p_offset =  dataSegOffsets[i];
+			LOG_MSG2( "   header->p_offset = dataSegmentsOffset ->=%d\n", header->p_offset );
+			header->p_vaddr = dataSegs[i].iSegBase;
+			header->p_paddr = 0;
+
+			if(header->p_offset == 0)
+				header->p_filesz = 0;
+			else
+				header->p_filesz = dataSegs[i].iSegSize;
+
+			header->p_memsz = dataSegs[i].iSegSize;
+			header->p_flags = dataSegs[i].iFlags;
+			header->p_align = 4;
+			LOG_MSG2( "   Writing this Data Seg PT_LOAD at offset %d\n", iOffset );
+			iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+			iOffset += sizeof(Elf32_Phdr);
+			noProgramTblEntries++;
+		}
+	}
+
+	if( iElfOptions->CreateCodeSegments() )
+	{
+		for (TInt i=0; i < codeSegList->Count(); i++) // each segment in segs
+		{
+			header->p_type = PT_LOAD;
+			header->p_offset =  codeSegOffsets[i];
+			//LOG_MSG2( "   header->p_offset = codeSegmentsOffset ->=%d\n", header->p_offset );
+			header->p_vaddr = (*codeSegList)[i]->iCodeRunAddr;
+			header->p_paddr = 0;
+			header->p_filesz = 0; //not dumping the code text section
+			header->p_memsz = (*codeSegList)[i]->iCodeSize;
+			header->p_flags = PF_R | PF_X; // Code segment
+			header->p_align = 4;
+			//LOG_MSG2( "   Writing this Code Seg PT_LOAD at offset %d\n", iOffset );
+			iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+			iOffset += sizeof(Elf32_Phdr);
+			noProgramTblEntries++;
+		}
+	}
+
+	if( iElfOptions->CreateThreadSegments() )
+	{
+
+		LOG_MSG( "  iElfOptions->CreateThreadSegments is True => creating P Hdr thread\n" );
+
+		// create program header for crashed thread segment
+		header->p_type = PT_NOTE;
+		header->p_offset =  threadInfoOffset;
+		LOG_MSG2( "   header->p_offset = threadInfoOffset=%d\n", threadInfoOffset );
+		header->p_vaddr = 0;
+		header->p_paddr = 0;
+		header->p_filesz = 0;
+		header->p_memsz = 0;
+		header->p_flags = 0; //no flags for note segments
+		header->p_align = 4;
+		LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+		iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+		iOffset += sizeof(Elf32_Phdr);
+		noProgramTblEntries++;
+	}
+
+	if (iElfOptions->CreateProcessSegments())
+	{
+		LOG_MSG( "  iElfOptions->CreateProcessSegmentInfo is True => creating P Hdr Proc\n" );
+
+		// create program header with p_type=PT_NOTE and p_offset pointing to...
+		header->p_type = PT_NOTE;
+		header->p_offset = processInfoOffset;
+		LOG_MSG2( "   header->p_offset = processInfoOffset=%d\n", processInfoOffset );
+		header->p_vaddr = 0;
+		header->p_paddr = 0;
+		header->p_filesz = 0;
+		header->p_memsz = 0;
+		header->p_flags = 0; //no flags for note segments
+		header->p_align = 4;
+		LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+		iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+		iOffset += sizeof(Elf32_Phdr);
+		noProgramTblEntries++;
+	}
+
+	if( iElfOptions->CreateExecSegments() )
+	{
+		LOG_MSG2( "  iElfOptions->CreateExecInfo is True => creating P Hdr Proc at offset %d\n",
+			executableInfoOffset );
+
+		// create program header with p_type=PT_NOTE and p_offset pointing to...
+		header->p_type = PT_NOTE;
+		header->p_offset = executableInfoOffset;
+		LOG_MSG2( "   header->p_offset = executableInfoOffset=%d\n", executableInfoOffset );
+		header->p_vaddr = 0;
+		header->p_paddr = 0;
+		header->p_filesz = 0;
+		header->p_memsz = 0;
+		header->p_flags = 0; //no flags for note segments
+		header->p_align = 4;
+		LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+		iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+		iOffset += sizeof(Elf32_Phdr);
+		noProgramTblEntries++;
+	}
+
+	if( registerInfoOffsets.Count() )
+	{
+		// create program header with p_type=PT_NOTE and p_offset pointing to Register info
+
+		for (TUint i = 0; i<registerInfoOffsets.Count(); i++)
+		{
+			header->p_type = PT_NOTE;
+			header->p_offset = registerInfoOffsets[i];
+			LOG_MSG2( "    => header->p_offset Register Seg P Hdr offset ->%d\n", header->p_offset );
+			header->p_vaddr = 0;
+			header->p_paddr = 0;
+			header->p_filesz = 0;
+			header->p_memsz = 0;
+			header->p_flags = 0; //no flags for note segments
+			header->p_align = 4;
+			LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+			iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+			iOffset += sizeof(Elf32_Phdr);
+			noProgramTblEntries++;
+		}
+	}
+
+	if(iElfOptions->TraceDataToCapture() > 0 && traceInfoOffset >0)
+		{
+		LOG_MSG("Writing trace program header");
+		//create program header with p_type=PT_NOTE and p_offset pointing to trace info
+		header->p_type = PT_NOTE;
+		header->p_offset = traceInfoOffset;
+		LOG_MSG2( "    => header->p_offset Trace Seg P Hdr offset ->%d\n", header->p_offset );
+		header->p_vaddr = 0;
+		header->p_paddr = 0;
+		header->p_filesz = 0;
+		header->p_memsz = 0;
+		header->p_flags = 0; //no flags for note segments
+		header->p_align = 4;
+		LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+		iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+		iOffset += sizeof(Elf32_Phdr);
+		noProgramTblEntries++;
+		}
+
+	if(iElfOptions->CreateLockDataSegments() && systemLocksOffset > 0)
+		{
+		LOG_MSG("Writing system locks program header");
+		//create program header with p_type=PT_NOTE and p_offset pointing to trace info
+		header->p_type = PT_NOTE;
+		header->p_offset = systemLocksOffset;
+		LOG_MSG2( "    => header->p_offset Locks Seg P Hdr offset ->%d\n", header->p_offset );
+		header->p_vaddr = 0;
+		header->p_paddr = 0;
+		header->p_filesz = 0;
+		header->p_memsz = 0;
+		header->p_flags = 0; //no flags for note segments
+		header->p_align = 4;
+		LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+		iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+		iOffset += sizeof(Elf32_Phdr);
+		noProgramTblEntries++;
+		}
+
+	if(iElfOptions->CreateRomBuildInfo() && romBuildOffset > 0)
+		{
+		LOG_MSG("Writing rom info program header");
+		//create program header with p_type=PT_NOTE and p_offset pointing to trace info
+		header->p_type = PT_NOTE;
+		header->p_offset = romBuildOffset;
+		LOG_MSG2( "    => header->p_offset ROM Info Seg P Hdr offset ->%d\n", header->p_offset );
+		header->p_vaddr = 0;
+		header->p_paddr = 0;
+		header->p_filesz = 0;
+		header->p_memsz = 0;
+		header->p_flags = 0; //no flags for note segments
+		header->p_align = 4;
+		LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+		iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+		iOffset += sizeof(Elf32_Phdr);
+		noProgramTblEntries++;
+		}
+
+	if(iElfOptions->CreateVariantSpecificData() && variantOffset > 0)
+		{
+		LOG_MSG("Writing variant specific data program header");
+		header->p_type = PT_NOTE;
+		header->p_offset = variantOffset;
+		header->p_vaddr = 0;
+		header->p_filesz = 0;
+		header->p_memsz = 0;
+		header->p_flags = 0;
+		header->p_align = 4;
+		LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+		iDataSave->WriteL(iOffset, header, sizeof(Elf32_Phdr));
+		iOffset += sizeof(Elf32_Phdr);
+		++noProgramTblEntries;
+		}
+
+	//LOG_MSG( "   Writing String PT_NOTE\n" );
+	header->p_type = PT_NOTE;
+	header->p_offset = stringInfoOffset;
+	LOG_MSG2( "   Creating String table at offset->%d\n", header->p_offset );
+	LOG_MSG2( "   header->p_offset = stringInfoOffset=%d\n", stringInfoOffset );
+	header->p_vaddr = 0;
+	header->p_paddr = 0;
+	header->p_filesz = 0;
+	header->p_memsz = 0;
+	header->p_flags = 0; //no flags for string segment
+	header->p_align = 4;
+	LOG_MSG2( "   Writing this PT_NOTE at offset %d\n", iOffset );
+	iDataSave->WriteL( iOffset, header, sizeof(Elf32_Phdr));
+	noProgramTblEntries++;
+
+	CleanupStack::PopAndDestroy(header);
+
+	// update the Elf32 header and write it at the beginning of the file
+	elfHdr->e_ident[EI_MAG0] = ELFMAG0;
+	elfHdr->e_ident[EI_MAG1] = ELFMAG1;
+	elfHdr->e_ident[EI_MAG2] = ELFMAG2;
+	elfHdr->e_ident[EI_MAG3] = ELFMAG3;
+	elfHdr->e_ident[EI_CLASS] = ELFCLASS32;
+	elfHdr->e_ident[EI_DATA] = ELFDATA2LSB;
+	elfHdr->e_ident[EI_VERSION] = 0;
+	elfHdr->e_ident[EI_PAD] = 0;
+	elfHdr->e_type = ET_CORE;
+	elfHdr->e_machine = EM_ARM;
+	elfHdr->e_version = EV_CURRENT;
+	elfHdr->e_entry = 0;
+	elfHdr->e_phoff = programTableOffset;
+	LOG_MSG2( "   Program header offset elfHdr->e_phoff = programTableOffset=%d\n", programTableOffset );
+	elfHdr->e_shoff = 0;
+	elfHdr->e_flags = 0;
+	LOG_MSG2( "   elfHdr->e_ehsize = %d\n", sizeof(Elf32_Ehdr) );
+	elfHdr->e_ehsize = sizeof(Elf32_Ehdr);
+	LOG_MSG2( "   elfHdr->e_phentsize = %d\n", sizeof(Elf32_Phdr) );
+	elfHdr->e_phentsize = sizeof(Elf32_Phdr);
+	elfHdr->e_phnum = noProgramTblEntries;
+	LOG_MSG2( "   Program header entries elfHdr->e_phnum = noProgramTblEntries=%d\n", noProgramTblEntries );
+	elfHdr->e_shentsize = 0;
+	elfHdr->e_shnum = 0;
+	elfHdr->e_shstrndx = 0;
+
+	LOG_MSG( "   Writing ELF header at offset 0\n" );
+	iDataSave->WriteL( 0, elfHdr, sizeof(Elf32_Ehdr));
+
+    CleanupStack::PopAndDestroy(&registerInfoOffsets);
+    CleanupStack::PopAndDestroy(&codeSegOffsets);
+    CleanupStack::PopAndDestroy(&dataSegOffsets);
+    CleanupStack::PopAndDestroy(&dataSegs);
+    CleanupStack::PopAndDestroy();//&codeSegCleanup);
+    CleanupStack::PopAndDestroy();//&threadCleanup);
+    CleanupStack::PopAndDestroy();//&processCleanup);
+	CleanupStack::PopAndDestroy(elfHdr);
+    CleanupStack::PopAndDestroy(iStrInfoTbl);
+    CleanupStack::PopAndDestroy(&armExcRegs);
+
+	LOG_MSG("  iDataSave->CloseL();\n");
+	iDataSave->CloseL();
+}
+
+/**
+Checks the value of the crash cancel property. If set to cancel, it closes the
+data save and then leaves with KErrAbort.
+Otherwise it updates the crash progress with the argument value.
+
+@param aProgress Progress description.
+@leave KErrAbort if crash cancel property has been set
+*/
+void CSymbianElfFormatterV2::UpdateCrashProgressL( const TDesC &aProgress )
+    {
+
+    LOG_MSG("CSymbianElfFormatterV2::UpdateCrashProgress()\n");
+    TInt cancelCrash;
+    User::LeaveIfError(iCancelCrash.Get(cancelCrash));
+
+    if( cancelCrash )
+        {
+        User::LeaveIfError(iCrashProgress.Set(KNoProgress));
+
+		LOG_MSG("Canceling crash and closing media iDataSave->CloseL();\n");
+		iDataSave->CloseL();
+
+        // cancel the crash processing
+		// no media name required
+		UpdateMediaNameL(_L("Cancelled"), KMediaStatusCancelled);
+		LOG_MSG("  UpdateCrashProgress() -> User::Leave( KErrAbort )\n");
+        User::Leave( KErrAbort );
+        }
+
+    // checking the length of crash progress messages
+    if(aProgress.Length() > (KMaxCrashProgressBuffer - KMaxUIDLength))
+    	{
+    	LOG_MSG3(" UpdateCrashProgress() Progress Message %S Length() is bigger than %d\n", &aProgress, (KMaxCrashProgressBuffer - KMaxUIDLength));
+    	User::Leave( KErrTooBig );
+    	}
+    //Apppending the UID in every ECrashProgress property update
+    iCrashProgressBuffer.Copy(iCrashIDBuffer);
+    iCrashProgressBuffer.Append(aProgress);
+
+    User::LeaveIfError(iCrashProgress.Set(iCrashProgressBuffer));
+    }
+
+/**
+ * Updates the RPoperty ECrashMediaName buffer with the entries which
+ * contains the crash media name and some status information about the crash processing.
+ * Adds a new crash information if it is not in the list of entries
+ * otherwise just updates the status of the crash information.
+ * Each entry is of size KMaxEntryLength and there are KNumofEntries entries.
+ * Each crash processing has a entry in the ECrashMediaName buffer.
+ * The last entry always has the latest crash information.
+ *
+ *    structure of each entry in ECrashMediaName buffer
+ *    ____________________________________________
+ *    |Status|         MediaName         |UID |END|
+ *      1              128 + 20           10   1   number of characters = KMaxEntryLength = 160
+ *
+ *    Status:      D stands for Done
+ *                 I stands for In progress
+ *                 C stands for Cancel
+ *    UID:         lower 32 bit of crash time
+ *    MediaName:   medianame + 64 bit time appended to it
+ *    END:         end character \
+ *
+ * @param aMediaFileName Crash Media Name
+ * @param aStatus status of the crash process
+ * @leave one of the other system wide error codes
+*/
+void CSymbianElfFormatterV2::UpdateMediaNameL(const TDesC &aMediaFileName, const TDesC &aStatus)
+    {
+    LOG_MSG3("CSymbianElfFormatterV2::UpdateMediaName()\n aMediaFileName %S aStatus %S", &aMediaFileName, &aStatus);
+
+    TBool matchfound = EFalse;
+    TInt matchedentry = 0;
+    TUint uid = 0;
+    RBuf newbuffer;
+    RBuf crashMediaName;
+
+    // KNumofEntries entries each of length KMaxEntryLength
+    User::LeaveIfError(crashMediaName.Create(KMaxEntryLength * KNumofEntries));
+    crashMediaName.CleanupClosePushL();
+    // read the crash media name buffer property
+    User::LeaveIfError(iCrashMediaName.Get(crashMediaName));
+
+    // run through all the crashes present
+    TInt numofEntries = crashMediaName.Length() / KMaxEntryLength ;
+
+    // check buffer corruption
+    if( ((crashMediaName.Length() % KMaxEntryLength) != 0) || (numofEntries > KNumofEntries) )
+        User::Leave(KErrCorrupt);
+
+    if (numofEntries == 0)
+        {
+        // first entry
+        //construct the crash media buffer
+        User::LeaveIfError(newbuffer.Create(KMaxEntryLength));
+        newbuffer.Append(aStatus); //status bit
+        newbuffer.Append(iCrashIDBuffer); //crash uid
+        newbuffer.AppendJustify(aMediaFileName, KMaxMediaLength, ELeft, TChar('0')); //crash media name
+        newbuffer.Append(_L("\\")); //terminating character
+        crashMediaName.Copy(newbuffer);
+        newbuffer.Close();
+        }
+    else
+        {
+        // run through the list of entries
+        for(TInt i = 0; i < numofEntries; i++ )
+            {
+            //read the status bit used a validity bit as well
+            TPtrC ptr = crashMediaName.Mid((i * KMaxEntryLength), KMaxStatusLength);
+
+            if ((ptr.CompareF(_L("D")) == 0) || (ptr.CompareF(_L("I")) == 0) || (ptr.CompareF(_L("C")) == 0) )
+                {
+                // read the crash uid for the entry
+                TPtrC uidptr = crashMediaName.Mid(((i * KMaxEntryLength) + KMaxStatusLength), KMaxUIDLength);
+
+                TLex lexuid(uidptr);
+                User::LeaveIfError(lexuid.Val(uid));
+
+                if (uid == iCrashUID.iUid)
+                    {
+                    // match found
+                    matchfound = ETrue;
+                    matchedentry = i;
+                    break;
+                    }
+                }
+            else
+                {
+                // entry present and not a valid one
+                LOG_MSG2("CSymbianElfFormatterV2::UpdateMediaName() Status bit %S not a valid entry", &ptr);
+                User::Leave(KErrCorrupt);
+                }
+            }
+
+            if(matchfound)
+                {
+                // matching crash UID found so update the status bit
+                matchfound = EFalse;
+
+                TPtr statusptr = crashMediaName.MidTPtr((matchedentry * KMaxEntryLength), KMaxStatusLength);
+                matchedentry = 0;
+                statusptr.Copy(aStatus);
+                }
+            else
+                {
+                //add a new entry as no match found
+                newbuffer.Create(KMaxEntryLength);
+                newbuffer.Append(aStatus);
+                newbuffer.Append(iCrashIDBuffer);
+                newbuffer.AppendJustify(aMediaFileName, KMaxMediaLength, ELeft, TChar('0'));
+                newbuffer.Append(_L("\\"));
+
+                // no space left
+                if( crashMediaName.Length() == (KMaxEntryLength * KNumofEntries) )
+                    {
+                    // append the new crash at the end
+                    TPtrC withoutfirstcrashptr = crashMediaName.Mid(KMaxEntryLength, KMaxEntryLength * (KNumofEntries - 1));
+                    // erasing the final buffer
+                    crashMediaName.Zero();
+                    crashMediaName.Append(withoutfirstcrashptr);
+                    crashMediaName.Append(newbuffer);
+                    }
+                else
+                    {
+                    // we have space for one more entry
+                    crashMediaName.Append(newbuffer);
+                    }
+
+                newbuffer.Close();
+                }
+
+        }
+
+    //finally writing back the property value
+    LOG_MSG2("Final crash media buffer before setting %S", &crashMediaName);
+    User::LeaveIfError(iCrashMediaName.Set(crashMediaName));
+
+    CleanupStack::PopAndDestroy(); //crashMediaName
+    }
+/**
+ * Determines if we are dealing with a system crash or not
+ * @return TBool
+ */
+TBool CSymbianElfFormatterV2::IsSystemCrash()
+	{
+	//Here we must look at the CPSR to determine if we were in usr mode. If not then its a system crash
+	//The CPSR Mode is defined by bits M[4:0) so anding with 0x1F will tell us
+
+	return !(KCPSRUsrMode == (iCPSR & 0x1F));
+	}
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/srcv2/symbianelfoptionsv2.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,604 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// symbianelfoptions.cpp
+// Implementation of the symbian elf options class.
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#include <e32base.h>
+#include <e32debug.h>
+
+#include "symbianelfoptionsv2.h"
+#include <debuglogging.h>
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CElfOptionsV2* CElfOptionsV2::NewL( TUint32 aUID )
+{
+	//LOG_MSG( "CElfOptionsV2::NewL()\n" );
+	CElfOptionsV2* self = CElfOptionsV2::NewLC( aUID );
+	CleanupStack::Pop();
+	return self;
+}
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CElfOptionsV2* CElfOptionsV2::NewLC( TUint32 aUID )
+{
+	//LOG_MSG( "CElfOptionsV2::NewLC()\n" );
+
+	CElfOptionsV2* self = new(ELeave) CElfOptionsV2();
+
+	CleanupStack::PushL(self);
+
+	self->ConstructL( aUID );
+	return self;
+}
+
+/**
+2nd stage construction
+Reserves config parameter list, creates config parameter objects and sets them to default values.
+@leave err one of the system wide error codes
+*/
+void CElfOptionsV2::ConstructL( TUint32 aUID )
+{
+	//LOG_MSG("->CElfOptionsV2::ConstructL()\n");
+    TInt err;
+
+	iConfigList.ReserveL( (TInt)EElfOptionsLast );
+
+	COptionConfig * config;
+	TInt index = 0; // Index of config params that we create
+
+	_LIT( KTrueFalseOpt, "True,False" );
+	_LIT( KTrueOpt, "True" );
+
+	_LIT( KCreateSystemInfo, "System-Wide Crash Data Option:\n  0-System-Wide Data,\n  1-Crashed Process Only,\n  2-Both" );
+	config = COptionConfig::NewL(  (TInt)ECreateSystemCrashInfo,
+									aUID,
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETUInt,
+									KCreateSystemInfo,
+                                    1,
+									KNullDesC,
+									ESystemWideAndCrashedProc,
+									KNullDesC );
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KCreateProcessDataPrompt,
+		"Create Data for all Threads in Crashed Process?" );
+//      0        1         2         3         4         5
+//      12345678901234567890123456789012345678901234657890
+
+	config = COptionConfig::NewL(  (TInt)ECreateProcessData,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool,
+									KCreateProcessDataPrompt,
+                                    1,
+									KTrueFalseOpt,
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KDataSegmentPrompt, "Create Data Segments?" );
+	config = COptionConfig::NewL(  (TInt)ECreateDataSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool,
+									KDataSegmentPrompt,
+									1,						// Number of options
+									KTrueFalseOpt,				// Option string
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KCodeSegmentPrompt, "Create Code Segments?" );
+	config = COptionConfig::NewL(  (TInt)ECreateCodeSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool,
+									KCodeSegmentPrompt,
+									1,
+									KTrueFalseOpt,
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KThreadSegmentPrompt, "Create Thread Segments?" );
+	config = COptionConfig::NewL(  (TInt)ECreateThreadSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool,
+									KThreadSegmentPrompt,
+                                    1,
+									KTrueFalseOpt,
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KRegisterSegmentPrompt, "Create Register Segments?" );
+	config = COptionConfig::NewL(  (TInt)ECreateRegisterSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool,
+									KRegisterSegmentPrompt,
+                                    1,
+									KTrueFalseOpt,
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KCreateExecInfoPrompt, "Create Exec Info?" );
+	config = COptionConfig::NewL(  (TInt)ECreateExecSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool,
+									KCreateExecInfoPrompt,
+                                    1,
+									KTrueFalseOpt,
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+	_LIT( KCreateProcessSegmentInfo, "Create Process Info?" );
+	config = COptionConfig::NewL(  (TInt)ECreateProcessSegments,
+									aUID,						// UID
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETBool,
+									KCreateProcessSegmentInfo,
+                                    1,
+									KTrueFalseOpt,
+									1,						// Default Value = 1 == True
+									KTrueOpt );				// Default Option String = True
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+    index++;
+
+    _LIT( KCreateTraceData, "How much Trace data to capture (Kb)" );
+    config = COptionConfig::NewL( (TInt)ECreateTraceData,
+    							   aUID,
+    							   COptionConfig::EFormatterPlugin,
+								   COptionConfig::ETInt,
+								   KCreateTraceData,
+								   1,
+								   KNullDesC,
+								   100,
+								   KNullDesC );
+    err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+	index ++;
+
+    _LIT( KCreateLockData, "Capture System Lock Data ?" );
+    config = COptionConfig::NewL( (TInt)ECreateLockSegments,
+    							   aUID,
+    							   COptionConfig::EFormatterPlugin,
+    							   COptionConfig::ETBool,
+								   KCreateLockData,
+								   1,
+								   KTrueFalseOpt,
+								   1,
+								   KTrueOpt );
+    err = iConfigList.Append( config );
+    if(err != KErrNone)
+    	{
+        delete config;
+        User::Leave(err);
+    	}
+
+    index ++;
+
+    _LIT( KCreateRomBuildInfo, "Capture ROM build data ?" );
+    config = COptionConfig::NewL( (TInt)ECreateRomInfo,
+    							   aUID,
+    							   COptionConfig::EFormatterPlugin,
+								   COptionConfig::ETInt,
+								   KCreateRomBuildInfo,
+								   1,
+								   KNullDesC,
+								   100,
+								   KNullDesC );
+    err = iConfigList.Append( config );
+    if(err != KErrNone)
+    {
+        delete config;
+        User::Leave(err);
+    }
+
+    index ++;
+
+    _LIT( KCreateHeapData, "Capture Heap Data ?" );
+    config = COptionConfig::NewL( (TInt)ECreateHeapInfo,
+    							   aUID,
+    							   COptionConfig::EFormatterPlugin,
+    							   COptionConfig::ETBool,
+    							   KCreateHeapData,
+								   1,
+								   KTrueFalseOpt,
+								   1,
+								   KTrueOpt );
+    err = iConfigList.Append( config );
+    if(err != KErrNone)
+    	{
+        delete config;
+        User::Leave(err);
+    	}
+
+    index ++;
+
+ 	_LIT( KCreateVariantData, "Create Variant Specific Data ?" );
+    config = COptionConfig::NewL( (TInt)ECreateVariantInfo,
+    							   aUID,
+    							   COptionConfig::EFormatterPlugin,
+    							   COptionConfig::ETBool,
+    							   KCreateVariantData,
+								   1,
+								   KTrueFalseOpt,
+								   1,
+								   KTrueOpt );
+    err = iConfigList.Append( config );
+    if(err != KErrNone)
+    	{
+        delete config;
+        User::Leave(err);
+    	}
+
+    index ++;
+}
+
+/**
+ctor nothing really
+*/
+
+CElfOptionsV2::CElfOptionsV2()
+{
+
+}
+
+/**
+dtor frees config parameter list
+*/
+CElfOptionsV2::~CElfOptionsV2()
+{
+    iConfigList.ResetAndDestroy();
+}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptionsV2::CreateProcessData() const
+	{
+	return iConfigList[ (TInt)ECreateProcessData ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptionsV2::CreateDataSegments() const
+	{
+	if( CreateSystemWideOnly() )
+		return EFalse;
+
+	return iConfigList[ (TInt)ECreateDataSegments ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptionsV2::CreateCodeSegments() const
+	{
+	if( CreateSystemWideOnly() )
+		return EFalse;
+
+	return iConfigList[ (TInt)ECreateCodeSegments ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptionsV2::CreateThreadSegments() const
+	{
+	return iConfigList[ (TInt)ECreateThreadSegments ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptionsV2::CreateRegisterSegments() const
+	{
+	if( CreateSystemWideOnly() )
+		return EFalse;
+
+	return iConfigList[ (TInt)ECreateRegisterSegments ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptionsV2::CreateExecSegments() const
+	{
+	if( CreateSystemWideOnly() )
+		return EFalse;
+
+	return iConfigList[ (TInt)ECreateExecSegments ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptionsV2::CreateProcessSegments() const
+	{
+    return iConfigList[ (TInt)ECreateProcessSegments ]->ValueAsBool();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptionsV2::CreateSystemWideOnly() const
+	{
+	return ( ESystemWideOnly == iConfigList[ (TInt)ECreateSystemCrashInfo ]->Value() );
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptionsV2::CreateSystemCrashInfo() const
+	{
+
+	switch( iConfigList[ (TInt)ECreateSystemCrashInfo ]->Value() )
+		{
+		case ESystemWideOnly:
+		case ESystemWideAndCrashedProc:
+			return ETrue;
+		case ECrashedProcessOnly:
+		default:
+			return EFalse;
+		}
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TInt CElfOptionsV2::TraceDataToCapture() const
+	{
+	return iConfigList[ (TInt)ECreateTraceData ]->Value();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptionsV2::CreateLockDataSegments() const
+	{
+	return iConfigList[ (TInt)ECreateLockSegments ]->Value();
+	}
+
+/**
+Called to obtain the value of the parameter
+@return actual value of the parameter
+*/
+TBool CElfOptionsV2::CreateRomBuildInfo() const
+	{
+	return iConfigList[ (TInt)ECreateRomInfo ]->Value();
+	}
+
+/**
+Called to obtain the value of the heap data option
+@return Whether or not to dump heap data
+*/
+TBool CElfOptionsV2::CreateHeapData() const
+	{
+	LOG_MSG2("CElfOptionsV2::CreateHeapData ret %d", iConfigList[(TInt)ECreateHeapInfo]->Value());
+	return iConfigList[(TInt)ECreateHeapInfo]->Value();
+	}
+
+/**
+Called to obtain the value of the variant specific data option
+@return Whether or not to dump variant data
+*/
+TBool CElfOptionsV2::CreateVariantSpecificData() const
+	{
+	LOG_MSG2("CElfOptionsV2::CreateVariantSpecificData ret %d", iConfigList[(TInt)ECreateVariantInfo]->Value());
+	return iConfigList[(TInt)ECreateVariantInfo]->Value();
+	}
+
+/**
+Called by CDS to ask for the configuration parameters that the formatter implements.
+@return actual number of implemented config parameters
+*/
+TInt CElfOptionsV2::GetNumberConfigParametersL( )
+	{
+	//LOG_MSG("->CElfOptionsV2::GetNumberConfigParametersL() : returning %d", iConfigList.Count() );
+	return iConfigList.Count();
+	}
+
+/**
+Called by CDS to ask for configuration parameter.
+@param aIndex indicates which parameter to return
+@return pointer to COptionConfig object representing the requested config parameter. Caller doesn't take ownership of the object!
+@leave KErrBadHandle if index is out of bounds
+@see COptionConfig
+*/
+COptionConfig * CElfOptionsV2::GetConfigParameterL( const TInt aIndex )
+	{
+	LOG_MSG2("CElfOptionsV2::GetConfigParameterL Getting index = %d", aIndex);
+	if( ( aIndex < 0 ) || ( aIndex >= iConfigList.Count() ) )
+		{
+		User::Leave( KErrBadHandle );
+		}
+
+    return iConfigList[aIndex];
+
+	}
+
+/**
+Called by CDS with response to prompt from user. Plugin interprets
+the response (eg create file, check permissions, pre-allocate memory etc).
+
+@param aIndex Index of parameter to change
+@param aValue Unused
+@param aDescValue Path and filename to use
+@return KErrNone
+@leave KErrBadHandle if index is out of bounds or one of the other system wide error codes
+*/
+TInt CElfOptionsV2::SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue )
+	{
+	LOG_MSG3("->CElfOptionsV2::SetConfigParameterL()\n  DesC = %S aIndex = %d", &aDescValue, aIndex);
+
+	// Make the changes to our internal structures, and reflect such changes in our behaviour
+
+	if( ( aIndex < 0 ) || ( aIndex > iConfigList.Count() ) )
+		{
+		LOG_MSG2( "CElfOptionsV2::SetConfigParameterL(): ERROR !* : aIndex=%d is out of bounds\n", aIndex );
+		User::Leave( KErrBadHandle );
+		}
+
+	COptionConfig * config = iConfigList[aIndex];
+
+	switch( config->Index() )
+		{
+		case ECreateProcessData:
+		case ECreateDataSegments:
+		case ECreateCodeSegments:
+		case ECreateThreadSegments:
+		case ECreateRegisterSegments:
+		case ECreateExecSegments:
+		case ECreateProcessSegments:
+		case ECreateHeapInfo:
+		case ECreateVariantInfo:
+			if( 0 == aValue )
+				{
+				config->Value( EFalse );
+				}
+			else if( 1 == aValue )
+				{
+				config->Value( ETrue );
+				}
+			else
+				{
+				LOG_MSG2( "CElfOptionsV2::SetConfigParameterL(): ERROR !* : invalid value %d\n", aValue );
+				User::Leave( KErrArgument );
+				}
+			break;
+
+		case ECreateSystemCrashInfo:
+			{
+			if( ESystemWideOnly == aValue )
+				{
+				config->Value( ESystemWideOnly );
+				}
+			else if( ECrashedProcessOnly == aValue )
+				{
+				config->Value( ECrashedProcessOnly );
+				}
+			else if( ESystemWideAndCrashedProc == aValue )
+				{
+				config->Value( ESystemWideAndCrashedProc );
+				}
+			else
+				{
+				User::Leave( KErrArgument );
+				}
+			}
+			break;
+		case ECreateTraceData:
+			{
+			config->Value(aValue);
+			}
+			break;
+		default:
+			break;
+		}//switch
+
+	LOG_MSG("CElfOptionsV2::SetConfigParameterL finished");
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/srcv2/symbianelfstringinfov2.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,148 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#include <e32base.h>
+#include <e32debug.h>
+
+#include "symbianelfstringinfo.h"
+#include "symbianelfstringinfov2.h"
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CStringInfoTableV2 *CStringInfoTableV2::NewLC()
+{
+	CStringInfoTableV2 *self = new(ELeave) CStringInfoTableV2();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+}
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CStringInfoTableV2 *CStringInfoTableV2::NewL()
+{
+	CStringInfoTableV2 *self = CStringInfoTableV2::NewLC();
+	CleanupStack::Pop(self);
+	return self;
+}
+
+/**
+1st stage construction
+@return pointer to new object
+@param aStrings Buffer containing existing set of NULL terminated strings
+@leave One of the system wide codes
+*/
+CStringInfoTableV2* CStringInfoTableV2::NewL(const TDesC8& aStrings)
+{
+	CStringInfoTableV2 *self = CStringInfoTableV2::NewLC(aStrings);
+	CleanupStack::Pop(self);
+	return self;
+}
+
+/**
+1st stage construction
+@return pointer to new object
+@param aStrings Buffer containing existing set of NULL terminated strings
+@leave One of the system wide codes
+*/
+CStringInfoTableV2* CStringInfoTableV2::NewLC(const TDesC8& aStrings)
+{
+	CStringInfoTableV2 *self = new(ELeave) CStringInfoTableV2();
+	CleanupStack::PushL(self);
+	self->ConstructL(aStrings);
+	return self;
+}
+
+/**
+dtor closes string buffer
+*/
+CStringInfoTableV2::~CStringInfoTableV2()
+{
+	iBuffer.Close();
+}
+
+/**
+ctor nothing really
+*/
+CStringInfoTableV2::CStringInfoTableV2()
+{
+}
+
+/**
+2nd stage construction.
+Creates string buffer and populates it with strings present in every ELF dump file.
+@leave one of the system wide error codes
+*/
+void CStringInfoTableV2::ConstructL()
+    {
+    //LOG_MSG("->CStringInfoTable::ConstructL()\n");
+	iBuffer.CreateL(KEmpty, KEmpty().Length()+1);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KSymbian().Length()+1);
+	iBuffer.Append(KSymbian);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KThread().Length()+1);
+	iBuffer.Append(KThread);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KProcess().Length()+1);
+	iBuffer.Append(KProcess);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KExecutable().Length()+1);
+	iBuffer.Append(KExecutable);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KStr().Length()+1);
+	iBuffer.Append(KStr);
+	iBuffer.AppendFill((TChar)0, 1);
+	iBuffer.ReAllocL(iBuffer.Length()+KSymbianElfCoreDumpVersion().Length()+1);
+	iBuffer.Append(KSymbianElfCoreDumpVersion);
+	iBuffer.AppendFill((TChar)0, 1);
+	}
+
+/**
+2nd stage construction.
+Creates string buffer and populates it with param
+@param aStrings initial buffer
+@leave one of the system wide error codes
+*/
+void CStringInfoTableV2::ConstructL(const TDesC8& aStrings)
+	{
+	iBuffer.CreateL(aStrings);
+	}
+
+/**
+
+@param aItem: The string to be added to internal buffer
+@return offset at which the aItem was added to internal buffer
+@leave one of the system wide error codes
+*/
+TUint CStringInfoTableV2::AddStringL(const TDesC8 &aItem)
+    {
+    //LOG_MSG("->CStringInfoTable::AddStringL()\n");
+	TUint index = iBuffer.Length();
+	iBuffer.ReAllocL(iBuffer.Length() + aItem.Length() + 1);
+	iBuffer.Append(aItem);
+	iBuffer.AppendFill((TChar)0, 1);
+	return index;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,45 @@
+Directory for:
+  coredump\plugins\formatters\symbian_elf\
+test files
+
+The tests at this level should be unit tests and should be run whenever the plugin is changed.
+
+- test_crashdatasource is a dll called test_crashdatasource.dll. 
+
+This dll's export creates a CTestCrashDataSource object (CTestCrashDataSource isa CCrashDataSource). 
+CTestCrashDataSource supplies simulated, fixed crash data.
+
+
+- t_symbian_elf_formatter is the unit test program. 
+
+It creates a data source from the dll test_crashdatasource.dll.
+It then lists the available Symbian ELF formatting plugins.
+Then it instanciates each formatter, configures the CTestCrashDataSource as their data source, 
+and then calls CrashEvent(). The formatter plugin will then call whatever it needs from the the
+data source object to generate an elf dump.
+
+
+- To build, 
+
+At \coredump\plugins\formatters\symbian_elf\group> 
+  abld build ARMV5 UDEB
+
+At \epoc32\rom\tools> 
+  buildrom h2 techview symbian_elf_formatter.iby t_symbian_el_formatter.iby test_crashdatasource.iby -D_FULL_DEBUG
+
+It is advisable to have the serial output connected, for logging.
+
+Then from e_shell, run
+  t_symbian_elf_formatter.exe
+
+
+
+
+Note: 
+The reason for the dll, as opposed to a static library, is that at run 
+time there is a check that fails when loading the formatter plugin at 
+base\e32\memmodel\epoc\pcodeseg.cpp::DEpocCodeSeg::DoCreate() :: 
+
+  if ( (DLL.RomInfo().iFlags & (KRomImageFlagExeInTree|KRomImageFlagDll)) == (KRomImageFlagExeInTree|KRomImageFlagDll))
+    ....
+    if ( NOT( Process->iXIP ) || ( &Process->RomInfo() != DLL.RomInfo().Dll Reference table[0].RomInfo() ))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/tsymbianelfformatter.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,771 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32base.h>
+
+#include "symbianelfformatter.h"
+#include "tsymbianelfformatter.h"
+
+
+CSymbianElfFormatterTest * CSymbianElfFormatterTest::NewL(RTest &itest)
+{
+    CSymbianElfFormatterTest *self = CSymbianElfFormatterTest::NewLC(itest);
+    CleanupStack::Pop();
+    return self;
+}
+
+CSymbianElfFormatterTest * CSymbianElfFormatterTest::NewLC(RTest &itest)
+{
+    CSymbianElfFormatterTest *self = new(ELeave) CSymbianElfFormatterTest(itest);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+}
+
+void CSymbianElfFormatterTest::ConstructL()
+{
+    server = new(ELeave) CTestCrashDataSource;
+    formatter = CSymbianElfFormatter::NewL();
+	iStrInfoTbl = CStringInfoTable::NewL();
+    writer = CTestDataSave::NewL();
+    formatter->ConfigureDataSaveL(writer);
+    formatter->ConfigureDataSourceL(server);
+}
+
+CSymbianElfFormatterTest::CSymbianElfFormatterTest(RTest &aTest) : itest(aTest) { }
+
+CSymbianElfFormatterTest::~CSymbianElfFormatterTest()
+{
+    delete server;
+    delete writer;
+    delete iStrInfoTbl;
+    delete formatter;
+}
+
+void CSymbianElfFormatterTest::CleanupEComArray(TAny* aArray)
+{
+	(static_cast<RImplInfoPtrArray*> (aArray))->ResetAndDestroy();
+    REComSession::FinalClose();
+}
+
+void CSymbianElfFormatterTest::TestSuiteL(TSuite aSuite)
+{
+    RDebug::Print(_L("-> TestSuite(%d)\n"), aSuite);
+    TInt err;
+    //TInt handle;
+    //           123456789012345678901
+    TBuf<23> name(KTestName); 
+    name.AppendNum(aSuite);
+    itest.Next(name);
+
+	iCrashInfo.iType = TCrashInfo::ECrashException;
+	iCrashInfo.iExcNumber = KCrashExcCode;
+	iCrashInfo.iTime = KCrashTime;
+	iCrashInfo.iPid = KCrashPid;
+	iCrashInfo.iTid = KCrashTid;
+
+	iCrashInfo.iContext.iFaultAddress = KCrashFaultAddress;
+	iCrashInfo.iContext.iFaultStatus = KCrashFaultStatus;
+	
+
+	iCrashInfo.iContext.iR15 = KRegValue32 + KCrashTid;
+	iCrashInfo.iContext.iR13Svc = iCrashInfo.iContext.iR15 + 1;
+	iCrashInfo.iContext.iR14Svc = iCrashInfo.iContext.iR15 + 2;
+	iCrashInfo.iContext.iSpsrSvc = iCrashInfo.iContext.iR15 + 3;
+
+	if( iStrInfoTbl )
+		delete iStrInfoTbl;
+
+	iStrInfoTbl = CStringInfoTable::NewLC();
+	formatter->iStrInfoTbl = iStrInfoTbl;
+
+    RBuf8 reference;
+    switch(aSuite)
+    {
+        case EConfigData:
+        {
+            RDebug::Print(_L("EConfigData starting...\n"));
+            TRAP(err, formatter->ConfigureDataSourceL(server));
+            itest(err == KErrNone);
+            itest(server == formatter->iDataSource);
+
+            TRAP(err, formatter->ConfigureDataSaveL(writer));
+            itest(err == KErrNone);
+            itest(writer == formatter->iDataSave);
+
+            TRAP(err, formatter->ConfigureDataSourceL(NULL)); 
+            itest(err == KErrNoMemory);
+
+            TRAP(err, formatter->ConfigureDataSaveL(NULL));
+            itest(err == KErrNoMemory);
+            RDebug::Print(_L("EConfigData passed!\n"));
+            break;
+        }
+
+        case EFindImplementation:
+        {
+            RDebug::Print(_L("EFindImplementation starting...\n"));
+            RImplInfoPtrArray infoArray;
+            TCleanupItem cleanup(CSymbianElfFormatterTest::CleanupEComArray, (TAny*)&infoArray);
+            CleanupStack::PushL(cleanup);
+            
+            TRAPD(err, CSymbianElfFormatter::ListAllImplementationsL(infoArray));
+            itest(err == KErrNone);
+            
+            CCoreDumpFormatter* formatter = 0;
+            RBuf description;
+            description.CreateL(MaxPluginDescription);
+            CleanupClosePushL(description);
+
+            err = KErrNotFound;
+            for (TInt i = 0; i < infoArray.Count(); i++)
+            {
+                TUid uid = infoArray[i]->ImplementationUid();
+                formatter = CCoreDumpFormatter::NewL(uid);
+                formatter->GetDescription(description);
+                delete formatter;
+                RDebug::Print(_L("found plugin[%d]: (%S)\n"), i, &description);
+                if(description == KPluginDescription())
+                {
+                    itest(uid == KSymbianElfFormatterUid);
+                    err = KErrNone;
+                    break;
+                }
+                description.Zero();
+            }
+            CleanupStack::PopAndDestroy();
+            description.Close();
+            itest(err == KErrNone);
+            CleanupStack::PopAndDestroy(); // infoArray, results in a call to CleanupEComArray
+            break;
+        }
+        case EWriteSymbianInfo:
+        {
+
+			RDebug::Print(_L("EWriteSymbianInfo starting...\n"));
+            TRAP(err, formatter->ConfigureDataSourceL(server));
+            itest(err == KErrNone);
+            itest(server == formatter->iDataSource);
+
+            TRAP(err, formatter->ConfigureDataSaveL(writer));
+            itest(err == KErrNone);
+            itest(writer == formatter->iDataSave);
+
+            reference.CreateL( sizeof(Sym32_dhdr) + sizeof(Sym32_syminfod) );
+            CleanupClosePushL(reference);
+
+            TPtrC8 ptr;
+            Sym32_dhdr dhdr;
+            ptr.Set(reinterpret_cast<TUint8*>(&dhdr), sizeof(Sym32_dhdr));
+            TInt32 index = iStrInfoTbl->GetIndex(KSymbian);
+            dhdr.d_name	= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+            dhdr.d_descrsz	= sizeof(Sym32_syminfod);
+            dhdr.d_type	= ESYM_NOTE_SYM;
+            dhdr.d_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+            dhdr.d_elemnum = 1;
+            reference.Append(ptr);
+
+            Sym32_syminfod seg;
+            ptr.Set(reinterpret_cast<TUint8*>(&seg), sizeof(Sym32_syminfod));
+            
+            seg.sd_date_time = (Elf64_Word)KCrashTime;
+            seg.sd_exit_type = KCrashType;
+            seg.sd_exit_reason = KCrashReason;
+            seg.sd_thread_id = KCrashTid;
+            seg.sd_proc_id = KCrashPid;
+        
+            TBuf8<KMaxExitCategoryName> buf;
+            buf.Copy(KCrashCategory);
+            if (buf.Length() > 0)
+            {
+                iStrInfoTbl->AddStringL(buf);
+            }
+            index = iStrInfoTbl->GetIndex(buf);
+            seg.sd_exit_cat = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+
+            Sym32_execid id = {I64LOW(KCrashTime), KCrc32};            
+            seg.sd_execid = id;
+            
+            reference.Append(ptr);
+
+            writer->OpenL(_L("") ); //clear writer buffer
+
+			formatter->iOffset = 0;
+            TInt offset = 0;
+            
+			RDebug::Print(_L("->formatter->WriteSymbianInfoL( )\n"));
+
+			formatter->WriteSymbianInfoL( iCrashInfo, KCrc32 );
+
+			RDebug::Print(_L("<-formatter->WriteSymbianInfoL( )\n"));
+            itest(offset + sizeof(Sym32_dhdr) + sizeof(Sym32_syminfod) == formatter->iOffset);
+			itest(offset != formatter->iOffset);
+			
+			//RDebug::Print(_L("itest3\n"));
+            //itest(reference == writer->iData);
+			//writer->Print();						
+
+            itest(reference != _L8(""));
+
+            CleanupStack::PopAndDestroy(&reference);
+            break;
+        }
+        case EWriteCodeSegments:
+        {
+
+			RDebug::Print(_L("EWriteCodeSegments starting...\n"));
+            TRAP(err, formatter->ConfigureDataSourceL(server));
+            itest(err == KErrNone);
+            itest(server == formatter->iDataSource);
+
+            TRAP(err, formatter->ConfigureDataSaveL(writer));
+            itest(err == KErrNone);
+            itest(writer == formatter->iDataSave);
+
+			RCodeSegPointerList codeSegs;
+			RArray<TUint> codeSegOffsets;
+			CleanupClosePushL(codeSegOffsets);
+			TUint totalCodeSegListDescSize;
+
+			RDebug::Print(_L("server->GetCodeSegmentsL( KCrashTid, codeSegs );\n"));
+			server->GetCodeSegmentsL( KCrashTid, codeSegs, totalCodeSegListDescSize );
+
+			formatter->iOffset = 0;
+
+			writer->OpenL(_L("") ); //clear writer buffer
+
+			RDebug::Print(_L("formatter->WriteCodeSegmentsL( KCrashTid, codeSegs, codeSegOffsets );\n"));
+            formatter->WriteCodeSegmentsL( KCrashTid, codeSegs, codeSegOffsets );
+
+			RDebug::Print(_L("itest(codeSegOffsets.Count() == KCodeSegsCount );\n"));
+			itest(codeSegOffsets.Count() == KCodeSegsCount );
+
+			for(TInt i = 0; i < KCodeSegsCount; i++)
+            {
+				RDebug::Printf( "itest( codeSegs[i] = %d );\n", codeSegOffsets[i] );
+                itest( codeSegOffsets[i] == 0 );
+            }
+
+			RDebug::Printf( "itest(0 == formatter->iOffset);" );
+            itest(0 == formatter->iOffset);
+			
+			RDebug::Printf( "CleanupStack::PopAndDestroy(&codeSegOffsets);" );
+			CleanupStack::PopAndDestroy(&codeSegOffsets);
+			RDebug::Printf( "CleanupStack::PopAndDestroy(&codeSegs);" );
+            codeSegs.ResetAndDestroy();
+
+            break;
+        }
+        case EWriteDataSegments:
+        {
+			RDebug::Print(_L("EWriteDataSegments starting...\n"));
+            TRAP(err, formatter->ConfigureDataSourceL(server));
+            itest(err == KErrNone);
+            itest(server == formatter->iDataSource);
+
+            TRAP(err, formatter->ConfigureDataSaveL(writer));
+            itest(err == KErrNone);
+            itest(writer == formatter->iDataSave);
+
+            reference.CreateL(KDataSegsCount * (KDataSegSize + KCrashPid + KDataSegsCount*(KDataSegsCount+1)/2) ); 
+            CleanupClosePushL(reference);
+
+            RBuf8 buf;
+            buf.CreateL((KDataSegSize + KCrashPid + KDataSegsCount));
+            for(TInt i = 0; i < KDataSegSize + KCrashPid + KDataSegsCount; ++i)
+                    buf.Append((TUint8*)&i, 1);
+
+            for(TInt i = 0; i < KDataSegsCount; ++i)
+            {
+                reference.Append(buf.Ptr(), KDataSegSize + KCrashPid + i);
+            }
+            buf.Close();
+
+			formatter->iOffset = 0;
+            TInt offset = formatter->iOffset;
+
+			RThreadPointerList *threadList = new(ELeave)RThreadPointerList ;
+			formatter->iDataSource->GetThreadListL((TUint64)KCrashPid, *threadList);
+
+			RCodeSegPointerList codeSegs;
+			CleanupClosePushL(codeSegs);
+			CSymbianElfFormatter::RSegmentList dataSegs;
+			CleanupClosePushL(dataSegs);
+			RArray<TUint> dataSegOffsets;
+			CleanupClosePushL(dataSegOffsets);
+
+			writer->OpenL(_L("") ); //clear writer buffer
+
+            formatter->WriteDataSegmentsL( 
+				KCrashTid, 
+				KCrashPid, 
+				*threadList, 
+				codeSegs, 
+				dataSegs, 
+				dataSegOffsets );
+
+			//RDebug::Print(_L("itest1\n"));
+            //itest(offset + reference.Length() == formatter->iOffset);
+
+			RDebug::Print(_L("itest2\n"));
+            itest(offset != formatter->iOffset);
+
+			//RDebug::Print(_L("itest3\n"));
+            //itest(reference == writer->iData);
+
+			// Note that the number of sements is not the same as KDataSegsCount, 
+			//since we also create thread stack segments
+
+			RDebug::Print(_L("itest4\n"));
+            itest(reference != _L8(""));
+
+			threadList->ResetAndDestroy();
+			threadList->Close();
+			delete threadList;
+
+			CleanupStack::PopAndDestroy(&dataSegOffsets);
+			CleanupStack::PopAndDestroy(&dataSegs);
+			CleanupStack::PopAndDestroy(&codeSegs);
+
+            CleanupStack::PopAndDestroy(); //reference
+
+            break;
+        }
+        case EWriteThreadsInfo:
+        {
+
+			RDebug::Print(_L("EWriteThreadsInfo  starting...\n"));
+            TRAP(err, formatter->ConfigureDataSourceL(server));
+            itest(err == KErrNone);
+            itest(server == formatter->iDataSource);
+
+            TRAP(err, formatter->ConfigureDataSaveL(writer));
+            itest(err == KErrNone);
+            itest(writer == formatter->iDataSave);
+
+            reference.CreateL( sizeof(Sym32_dhdr) + sizeof(Sym32_thrdinfod)*KCrashThreadsCount );
+            CleanupClosePushL(reference);
+
+            TPtrC8 ptr;
+            Sym32_dhdr dhdr;
+            ptr.Set(reinterpret_cast<TUint8*>(&dhdr), sizeof(Sym32_dhdr));
+            TInt32 index = iStrInfoTbl->GetIndex(KThread);
+            dhdr.d_name	= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+            dhdr.d_descrsz	= sizeof(Sym32_thrdinfod);
+            dhdr.d_type	= ESYM_NOTE_THRD;
+            dhdr.d_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+            dhdr.d_elemnum = KCrashThreadsCount;
+            reference.Append(ptr);
+
+			RThreadPointerList *threadList = new(ELeave) RThreadPointerList;
+			formatter->iDataSource->GetThreadListL(KCrashPid, *threadList);
+
+            Sym32_thrdinfod seg;
+            ptr.Set(reinterpret_cast<TUint8*>(&seg), sizeof(Sym32_thrdinfod));
+
+            for(TInt i = 0; i < KCrashThreadsCount; ++i)
+				{
+				seg.td_id = KCrashTid + i;
+				seg.td_owning_process = KCrashPid;
+				seg.td_priority = KCrashThreadPriority + i;
+				seg.td_svc_sp = KCrashSvcStackPtr + i;
+				seg.td_svc_stack = KCrashSvcStackAddr + i;
+				seg.td_svc_stacksz = KCrashSvcStackSize + i;
+				seg.td_usr_stack = KCrashUsrStackAddr + i;
+				seg.td_usr_stacksz = KCrashUsrStackSize + i;
+
+				TBuf8<KMaxProcessName> buf;
+				buf.Copy(KCrashThreadName);
+				if (buf.Length() > 0)
+				{
+					iStrInfoTbl->AddStringL(buf);
+				}
+
+				index = iStrInfoTbl->GetIndex(buf);
+				seg.td_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+
+				reference.Append(ptr);
+
+				}
+
+            writer->OpenL(_L("") ); //clear writer buffer
+
+			formatter->iOffset = 0;
+            TInt offset = 0;
+
+            formatter->WriteThreadInfoL(KCrashPid, *threadList);
+
+			RDebug::Print(_L("itest1\n"));
+            itest(offset + reference.Length() == formatter->iOffset);
+			RDebug::Print(_L("itest2\n"));
+            itest(offset != formatter->iOffset);
+
+			//RDebug::Print(_L("itest3\n"));
+            //itest(reference == writer->iData);
+
+			RDebug::Print(_L("itest4\n"));
+            itest(reference != _L8(""));
+
+			threadList->ResetAndDestroy();
+			threadList->Close();
+			delete threadList;
+
+            CleanupStack::PopAndDestroy(); //reference
+
+            break;
+        }
+        case EWriteProcessInfo:
+        {
+			RDebug::Print(_L("EWriteProcessInfo starting...\n"));
+            TRAP(err, formatter->ConfigureDataSourceL(server));
+            itest(err == KErrNone);
+            itest(server == formatter->iDataSource);
+
+            TRAP(err, formatter->ConfigureDataSaveL(writer));
+            itest(err == KErrNone);
+            itest(writer == formatter->iDataSave);
+
+            reference.CreateL( sizeof(Sym32_dhdr) + sizeof(Sym32_procinfod) );
+            CleanupClosePushL(reference);
+
+			RProcessPointerList *processList = new(ELeave)RProcessPointerList;
+			formatter->iDataSource->GetProcessListL( *processList );
+
+            TPtrC8 ptr;
+            Sym32_dhdr dhdr;
+            ptr.Set(reinterpret_cast<TUint8*>(&dhdr), sizeof(Sym32_dhdr));
+            TInt32 index = iStrInfoTbl->GetIndex(KProcess);
+            dhdr.d_name	= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+            dhdr.d_descrsz	= sizeof(Sym32_procinfod);
+            dhdr.d_type	= ESYM_NOTE_PROC;
+            dhdr.d_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+            dhdr.d_elemnum = 1;
+            reference.Append(ptr);
+
+            Sym32_procinfod seg;
+            ptr.Set(reinterpret_cast<TUint8*>(&seg), sizeof(Sym32_procinfod));
+            
+            seg.pd_id = KCrashPid;
+
+            TBuf8<KMaxProcessName> buf;
+            buf.Copy(KCrashProcessName);
+            if (buf.Length() > 0)
+            {
+                iStrInfoTbl->AddStringL(buf);
+            }
+            index = iStrInfoTbl->GetIndex(buf);
+            seg.pd_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+            reference.Append(ptr);
+
+            writer->OpenL(_L("") ); //clear writer buffer
+
+			formatter->iOffset = 0;
+            TInt offset = 0;
+
+            formatter->WriteProcessInfoL(KCrashPid, *processList );
+
+			RDebug::Print(_L("itest1\n"));
+            itest(offset + reference.Length() == formatter->iOffset);
+
+			RDebug::Print(_L("itest2\n"));
+            itest(offset != formatter->iOffset);
+
+			//RDebug::Print(_L("itest3\n"));
+            //itest(reference == writer->iData);
+
+			RDebug::Print(_L("itest4\n"));
+            itest(reference != _L8(""));
+
+			processList->ResetAndDestroy();
+			processList->Close();
+			delete processList;
+
+            CleanupStack::PopAndDestroy(&reference); //reference
+
+            break;
+        }
+
+        case EWriteExecutableInfo:
+        {
+			RDebug::Print(_L("EWriteExecutableInfo starting...\n"));
+            TRAP(err, formatter->ConfigureDataSourceL(server));
+            itest(err == KErrNone);
+            itest(server == formatter->iDataSource);
+
+            TRAP(err, formatter->ConfigureDataSaveL(writer));
+            itest(err == KErrNone);
+            itest(writer == formatter->iDataSave);
+
+            reference.CreateL(sizeof(Sym32_dhdr) + KCodeSegsCount * sizeof(Sym32_execinfod) );
+            CleanupClosePushL(reference);
+
+            TPtrC8 ptr;
+            Sym32_dhdr dhdr;
+            ptr.Set(reinterpret_cast<TUint8*>(&dhdr), sizeof(Sym32_dhdr));
+            TInt32 index = iStrInfoTbl->GetIndex(KExecutable);
+            dhdr.d_name	= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+            dhdr.d_descrsz	= sizeof(Sym32_execinfod);
+            dhdr.d_type	= ESYM_NOTE_EXEC;
+            dhdr.d_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+            dhdr.d_elemnum = KCodeSegsCount;
+            reference.Append(ptr);
+
+            Sym32_execinfod seg;
+            ptr.Set(reinterpret_cast<TUint8*>(&seg), sizeof(Sym32_execinfod));
+
+            Sym32_execid id = {I64LOW(KCrashTime), KCrc32};
+            
+            seg.ed_execid = id;
+            seg.ed_XIP = KCrashXIP;
+
+            for(TInt i = 0; i < KCodeSegsCount; i++)
+            {
+                if(i == 2)
+                    seg.ed_XIP = !KCrashXIP;
+
+                seg.ed_codesize = KCrashCodeSize + KCrashPid + i;
+                seg.ed_coderunaddr = KCrashCodeRunAddr + KCrashPid + i;
+                seg.ed_codeloadaddr = KCrashCodeLoadAddr + KCrashPid + i;
+                seg.ed_rodatasize = KCrashRODataSize + KCrashPid + i;
+                seg.ed_rodatarunaddr = KCrashRODataRunAddr + KCrashPid + i;
+                seg.ed_rodataloadaddr = KCrashRODataLoadAddr + KCrashPid + i;
+                seg.ed_datasize = KCrashDataSize + KCrashPid + i;
+                seg.ed_datarunaddr = KCrashDataRunAddr + KCrashPid + i;
+                seg.ed_dataloadaddr = KCrashDataLoadAddr + KCrashPid + i;
+                TBuf8<KMaxFileName> buf;
+                switch(i)
+                {
+                    case 0:    
+                        buf.Copy(KCrashFileName);
+                        break;
+                    case 1:
+                        buf.Copy(KLibName1);
+                        break;
+                    case 2:
+                        buf.Copy(KLibName2);
+                        break;
+
+                }
+                if (buf.Length() > 0)
+                {
+                    iStrInfoTbl->AddStringL(buf);
+                }
+                index = iStrInfoTbl->GetIndex(buf);
+                seg.ed_name = (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+                reference.Append(ptr);
+            }
+            
+
+            writer->OpenL(_L("") ); //clear writer buffer
+			formatter->iOffset = 0;
+            TInt offset = 0;
+
+			RCodeSegPointerList segList;
+
+            formatter->iDataSource->GetCodeSegmentsL(KCrashTid, segList);
+
+			formatter->WriteExecutableInfoL( segList, KCrashTime, KCrashTid );
+
+            segList.ResetAndDestroy();
+
+			RDebug::Print(_L("itest1\n"));
+            itest(offset + reference.Length() == formatter->iOffset);
+
+			RDebug::Print(_L("itest2\n"));
+            itest(offset != formatter->iOffset);
+
+			//RDebug::Print(_L("itest3\n"));
+            //itest(reference == writer->iData);
+
+			RDebug::Print(_L("itest4\n"));
+            itest(reference != _L8(""));
+
+            CleanupStack::PopAndDestroy(&reference); //reference
+			
+            break;
+        }
+
+        case EWriteRegistersInfo:
+        {
+
+			RDebug::Print(_L("EWriteRegistersInfo starting...\n"));
+            TRAP(err, formatter->ConfigureDataSourceL(server));
+            itest(err == KErrNone);
+            itest(server == formatter->iDataSource);
+
+            TRAP(err, formatter->ConfigureDataSaveL(writer));
+            itest(err == KErrNone);
+            itest(writer == formatter->iDataSave);
+
+            reference.CreateL( sizeof(Sym32_dhdr) + sizeof(Sym32_reginfod) * (1 + KCoProRegsCount/4) 
+                                                  + sizeof(Sym32_regdatad) * (KCoreRegsCount+KCoProRegsCount/2) );
+            CleanupClosePushL(reference);
+
+            TPtrC8 ptr;
+            Sym32_dhdr dhdr;
+            //Sym32_reginfod seg;
+            //Sym32_regdatad reg;
+            for(TInt i =0; i < KCrashThreadsCount; ++i)
+            {
+                TBuf8<255> buf;
+                buf.Format(_L8("CORE.SYMBIAN.REGISTER.%u"), KCrashTid + i);
+                iStrInfoTbl->AddStringL(buf);
+                TInt32 index = iStrInfoTbl->GetIndex(buf);
+                dhdr.d_name	= (index == KErrNotFound) ? ESYM_STR_UNDEF : index;
+                dhdr.d_descrsz	= (sizeof(Sym32_reginfod) + sizeof(Sym32_regdatad)) * KCoreRegsCount; 
+                dhdr.d_type	= ESYM_NOTE_REG;
+                dhdr.d_version = iStrInfoTbl->GetIndex(KSymbianElfCoreDumpVersion);
+                dhdr.d_elemnum = KCoreRegsCount + KCoProRegsCount/4; //core regs plus one for each copro reg size
+                ptr.Set(reinterpret_cast<TUint8*>(&dhdr), sizeof(Sym32_dhdr));
+                reference.Append(ptr);
+
+                /*
+                 defect in formatter code needs to be fixed, so not sure how is it going to be implemented
+                 but it should match the code below
+                //all core regs are 32-bit and available
+                seg.rid_class = ESYM_CORE;
+                seg.rid_num_registers = KCoreRegsCount;
+                seg.rid_repre = ESYM_REG_32;
+                seg.rid_thread_id = KCrashTid + i;
+                seg.rid_version = iStrInfoTbl->Getindex(KSymbianElfCoreDumpVersion);
+                ptr.Set(reinterpret_cast<TUint8*>(&seg), sizeof(Sym32_reginfod));
+                reference.Append(ptr);
+
+                for(TInt j = 0; j < KCoreRegsCount; ++j)
+                {
+                    reg.rd_id = regid; //r0...r15 
+                    reg.rd_sub_id = 0; //not important for core
+                    reg.rd_data = 0; //good question??
+                    ptr.Set(reinterpret_cast<TUint8*>(&reg), sizeof(Sym32_regdatad));
+                    reference.Append(ptr);
+                }
+
+                //done with core regs now four types of copro regs
+                seg.rid_class = ESYM_COPRO;
+                seg.rid_num_registers = KCoProRegsCount/4;
+                seg.rid_num_registers /=2; //half of them is not available
+                seg.rid_repre = ESYM_REG_8;
+                seg.rid_thread_id = KCrashTid + i;
+                seg.rid_version = iStrInfoTbl->Getindex(KSymbianElfCoreDumpVersion);
+                ptr.Set(reinterpret_cast<TUint8*>(&seg), sizeof(Sym32_reginfod));
+                reference.Append(ptr);
+                
+                for(TInt j = 0; j < KCoProRegsCount/2; ++j) //half of them is available
+                {
+                    if(i%4 == 0)
+                    {
+                        reg.rd_id = j;
+                        reg.rd_sub_id = KRegSubId + i;
+                        reg.rd_data = 0; //what about that?
+                        ptr.Set(reinterpret_cast<TUint8*>(&reg), sizeof(Sym32_regdatad));
+                        reference.Append(ptr);
+                    }
+                }
+                */
+            }
+
+            writer->OpenL(_L("") ); //clear writer buffer
+
+            CleanupStack::PopAndDestroy(&reference); //reference
+            break;    
+        }
+
+        default:
+            break;
+    }
+
+	RDebug::Print(_L("-> CleanupStack::PopAndDestroy( iStrInfoTbl );\n"));
+	CleanupStack::PopAndDestroy( iStrInfoTbl );
+	iStrInfoTbl = NULL;
+	RDebug::Print(_L("<- TestSuiteL()\n"));
+}
+
+void RunTestsL()
+{
+    RDebug::Print(_L("-> RunTestsL()0\n"));
+
+	RArray<TUint> pt;
+	CleanupStack::PushL(&pt);
+	CleanupStack::Check(&pt);
+		
+    CSymbianElfFormatterTest::TSuite suite[] = {
+                                         CSymbianElfFormatterTest::ENone,
+                                         CSymbianElfFormatterTest::EConfigData,
+                                         //CSymbianElfFormatterTest::EFindImplementation,
+                                         CSymbianElfFormatterTest::EConfigParams,
+                                         CSymbianElfFormatterTest::EGetDescription,
+                                         CSymbianElfFormatterTest::EWriteSymbianInfo,
+                                         CSymbianElfFormatterTest::EWriteCodeSegments,
+                                         CSymbianElfFormatterTest::EWriteDataSegments,
+                                         CSymbianElfFormatterTest::EWriteThreadsInfo,
+                                         CSymbianElfFormatterTest::EWriteProcessInfo,
+                                         CSymbianElfFormatterTest::EWriteExecutableInfo,
+                                         //CSymbianElfFormatterTest::EWriteRegistersInfo,
+                                         CSymbianElfFormatterTest::ECrash
+                                         };
+	RDebug::Print(_L("-> RunTestsL()2\n"));
+
+    RTest rtest(KTestTitle);
+    rtest.Title(); 
+    rtest.Start(_L(""));
+    CSymbianElfFormatterTest::TSuite *test = suite; 
+
+	CleanupStack::Check(&pt);
+	RDebug::Print(_L("-> RunTestsL()3\n"));
+
+    while(*test != CSymbianElfFormatterTest::ECrash)
+    {
+		RDebug::Print(_L("-> CleanupStack::Check(&pt);\n"));
+		CleanupStack::Check(&pt);
+
+        CSymbianElfFormatterTest *itester = CSymbianElfFormatterTest::NewLC(rtest);
+        itester->TestSuiteL(*test++);
+
+		RDebug::Print(_L("-> CleanupStack::PopAndDestroy( itester );\n"));
+        CleanupStack::PopAndDestroy( itester );
+		RDebug::Print(_L("<- CleanupStack::PopAndDestroy( itester );\n"));
+	}
+
+
+    rtest.End();
+    rtest.Close();
+    RDebug::Print(_L("<- RunTestsL()\n"));
+	CleanupStack::Check(&pt);
+
+	pt.Close();
+	CleanupStack::Pop(&pt);
+}
+
+	
+TInt E32Main()
+{
+    RDebug::Print(_L("-> E32Main()\n"));
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+
+    __ASSERT_ALWAYS(cleanup, User::Panic(_L("SYMBIAN_ELF_TEST-NO_CLEANUP"), KErrNoMemory));
+
+	TRAPD(err, RunTestsL());
+
+	RDebug::Print(_L("E32Main() after TRAPD(err=%d, RunTestsL());\n"), err);
+	__ASSERT_ALWAYS(!err, User::Panic(_L("SYMBIAN_ELF_TEST-RunTestsL trapped with error: "), err));
+
+	RDebug::Print(_L("delete cleanup;\n"));
+	delete cleanup;
+	__UHEAP_MARKEND;
+    RDebug::Print(_L("<- E32Main()\n"));
+	return err;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/tsymbianelfformatter.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef T_SYMBIAN_ELF_FORMATTER_IBY
+#define T_SYMBIAN_ELF_FORMATTER_IBY
+
+file=ABI_DIR\BUILD_DIR\tsymbianelfformatter.exe  sys\bin\tsymbianelfformatter.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/tsymbianelfformatter.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,53 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET		tsymbianelfformatter.exe
+
+TARGETTYPE	EXE
+
+UID			0xE8000077
+
+VENDORID    0x70000001
+
+
+sourcepath .
+source tsymbianelfformatter.cpp
+sourcepath ../../test
+source testcrashdatasource.cpp
+source testcrashdatasave.cpp
+sourcepath ../src
+source symbianelfformatter.cpp
+source	symbianelfstringinfo.cpp
+source symbianelfoptions.cpp
+
+userinclude		../inc
+userinclude		../../test
+
+systeminclude /epoc32/include
+systeminclude /epoc32/include/ecom
+systeminclude /epoc32/include/drivers
+systeminclude /epoc32/include/tools
+systeminclude /epoc32/include/tools/coredump
+
+
+LIBRARY euser.lib
+LIBRARY efsrv.lib 
+LIBRARY ecom.lib
+LIBRARY estor.lib
+LIBRARY cdssupport.lib
+
+CAPABILITY 	PowerMgmt
+
+OPTION CW -w nounused -w noempty
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/tsymbianelfstringinfo.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,102 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32base.h>
+#include <e32cons.h>
+#include <ecom.h>
+#include "symbianelfstringinfo.h"
+#include "tsymbianelfstringinfo.h"
+
+CSymbianStringInfoTest::CSymbianStringInfoTest(const TDesC& aTitle) : iTest(aTitle)
+{
+	iTest.SetLogged(ETrue);
+	iTest.Title();
+	iTest.Start(_L("SymbianStringInfo - start environment"));
+}
+
+CSymbianStringInfoTest* CSymbianStringInfoTest::NewL(const TDesC& aTitle)
+{
+	CSymbianStringInfoTest* self = new(ELeave) CSymbianStringInfoTest(aTitle);
+	return self;
+}
+
+CSymbianStringInfoTest::~CSymbianStringInfoTest()
+{
+	iTest.Close();
+}
+
+void CSymbianStringInfoTest::TestSymbianStringInfoL()
+{
+	CStringInfoTable *strTbl = CStringInfoTable::NewL();
+	CleanupStack::PushL(strTbl);
+	iTest.Next(_L("GetSize"));
+	TUint size = strTbl->GetSize();
+	iTest(size>0, __LINE__);
+	
+	iTest.Next(_L("GetIndex on predefined string \"CORE.SYMBIAN.PROCESS\""));
+	TUint index = strTbl->GetIndex(_L8("CORE.SYMBIAN.PROCESS"));
+	iTest(index == 34, __LINE__);
+
+	iTest.Next(_L("GetIndex on empty string"));
+	index = strTbl->GetIndex(_L8(""));
+	iTest(index == 0, __LINE__);
+
+	iTest.Next(_L("AddStringL \"TEST.STRING\""));
+	_LIT8(KTestString, "TEST.STRING");
+	TRAPD(err, strTbl->AddStringL(KTestString));
+	iTest(err == KErrNone, __LINE__);
+	
+	iTest.Next(_L("GetIndex on newly added string"));
+	index = strTbl->GetIndex(KTestString);
+	iTest(index > 0, __LINE__);
+
+	iTest.Next(_L("GetAllStrings: Check that first position is 0"));
+	TText8* ptr = strTbl->GetAllStrings();
+	iTest(ptr[0] == 0, __LINE__);
+	
+	iTest.Next(_L("GetAllStrings: Check that last position is 0"));
+	size = strTbl->GetSize();
+	iTest(ptr[size-1] == 0, __LINE__);
+	
+	iTest.Next(_L("GetAllStrings: Check that next last position is 'G'"));
+	iTest(ptr[size-2] == 'G', __LINE__);
+	
+	iTest.End();
+	CleanupStack::PopAndDestroy(strTbl);
+}
+
+static void RunTestsL()
+{
+	CSymbianStringInfoTest* test = CSymbianStringInfoTest::NewL(_L("SymbianStringInfo - basic tests"));
+	CleanupStack::PushL(test);
+
+	test->TestSymbianStringInfoL();
+
+	CleanupStack::PopAndDestroy(test);
+}
+
+TInt E32Main()
+{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanupStack = CTrapCleanup::New();
+	
+	TRAPD(error, RunTestsL());
+	
+	__ASSERT_ALWAYS(!error, User::Panic(_L("RunTestsL was trapped with error: "), error));
+	delete cleanupStack;
+	__UHEAP_MARKEND;
+	return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/symbianelf/test/tsymbianelfstringinfo.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,35 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// tsymbianstringinfo.mmp
+//
+
+target tsymbianstringinfo.exe
+targettype	exe
+uid 				0xE8000077
+VENDORID    0x70000001
+
+sourcepath .
+source tsymbianelfstringinfo.cpp
+source ../src/symbianelfstringinfo.cpp
+
+userinclude		../inc
+
+systeminclude /epoc32/include /epoc32/include/ecom
+systeminclude /epoc32/include/tools/coredump
+
+library euser.lib ecom.lib
+library cdssupport.lib
+
+CAPABILITY 	PowerMgmt
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/test/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/test/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,6 @@
+Directory for:
+  coredump\plugins\formatters\test\
+test files
+
+test_crashdatasource implements a data source that provides fixed, simulated crash data.
+This data source can thus be used by the unit test formatter programs.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/test/testcrashdatasave.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,96 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32base.h>
+#include "testcrashdatasave.h"
+
+CTestDataSave::~CTestDataSave()
+{
+    iData.Close();
+}
+
+CTestDataSave* CTestDataSave::NewL()
+{
+    CTestDataSave* self = new(ELeave) CTestDataSave();
+    CleanupStack::PushL(self);
+    //self->ConstructL();
+    self->iData.CreateL(0);
+    CleanupStack::Pop(self);
+    return self;
+}
+
+TInt CTestDataSave::Open(const TDesC& aParam )
+{
+    iData.Zero();
+	return KErrNone;
+}
+
+TInt CTestDataSave::Close()
+{
+     iData.ZeroTerminate();
+	 return KErrNone;
+}
+
+TInt CTestDataSave::Write( const TDesC8& aData)
+{
+    iData.ReAlloc(iData.Length() + aData.Length());
+    iData.Append(aData);
+	//Print();
+	return KErrNone;
+}
+
+TInt CTestDataSave::Write( TAny* aData, TUint aSize)
+{
+    TPtrC8 data(static_cast<TUint8*>(aData), aSize);
+    return ( Write(data) );
+}
+
+TInt CTestDataSave::Write( TInt aPos, const TDesC8& aData )
+{
+	if( 0 == iData.Length() )
+		{
+		iData.CreateMax( aPos + aData.Length() );
+		}
+	else if( aPos >= iData.Length() )
+		{
+		iData.ReAlloc( aPos + aData.Length() );
+		iData.SetMax();
+
+		}
+	else if( (aPos + aData.Length()) > iData.Length() )
+		{
+		iData.ReAlloc( aPos - iData.Length() + aData.Length() );
+		}
+
+	iData.Replace( aPos, aData.Length(), aData );
+
+	return KErrNone;
+}
+
+
+TInt CTestDataSave::Write( TInt aPos, TAny* aData, TUint aSize )
+	{
+    TPtrC8 data(static_cast<TUint8*>(aData), aSize);
+    return ( Write(aPos, data) );
+	}
+
+void CTestDataSave::Print() const
+	{
+	RBuf8 printBuf;
+	printBuf.Create( iData, iData.Length()+1 );
+	char* clPrompt = (char*) printBuf.PtrZ();
+	RDebug::Printf("  CTestDataSave::Print() length=%d, iData=>>>%s<<<\n", iData.Length(), clPrompt );
+	printBuf.Close();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/test/testcrashdatasave.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,81 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef TEST_DATA_SAVE_H
+#define TEST_DATA_SAVE_H
+#include <e32std.h>
+#include <crashdatasave.h>
+
+class CTestDataSave : public CCrashDataSave
+{
+    public:
+        void OpenL( const TDesC& aParam ){ Open( aParam ); };
+        TInt Open( const TDesC& aParam );
+        void CloseL( ){ Close(); };
+        TInt Close( );
+
+		// Save aData - binary
+		void WriteL( const TDesC8& aData ){ Write( aData ); };
+		TInt Write( const TDesC8& aData );
+
+		// Save aData - raw
+		void WriteL( TAny* aData, TUint aSize ) { Write( aData, aSize ); };
+		TInt Write( TAny* aData, TUint aSize );
+
+		// Save aData at the specific position - binary
+		// need implementation
+		void WriteL( TInt aPos, const TDesC8& aData ){ Write( aPos, aData); };
+		TInt Write( TInt aPos, const TDesC8& aData );
+
+		// Save aData at the specific position - raw
+		void WriteL( TInt aPos, TAny* aData, TUint aSize ){ Write( aPos, aData, aSize ); };
+		TInt Write( TInt aPos, TAny* aData, TUint aSize );
+
+        void GetDescription( TDes & aPluginDescription )
+        	{
+			(void)aPluginDescription;
+        	};
+
+        TInt GetNumberConfigParametersL( ) {return 0;};
+        COptionConfig * GetConfigParameterL( const TInt aIndex )
+        	{
+			(void)aIndex;
+			return NULL;
+			};
+	    void SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue )
+			{
+			(void)aIndex;
+			(void)aValue;
+			(void)aDescValue;
+			};
+
+		 const TDesC& GetMediaName() { return KNullDesC; };
+
+    public:
+        static CTestDataSave* NewL();
+        virtual ~CTestDataSave();
+
+        RBuf8 iData;
+
+		void Print() const;
+
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/test/testcrashdatasource.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,462 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32debug.h>
+
+#include <rm_debug_api.h>
+#include "testcrashdatasource.h"
+#include <debuglogging.h>
+
+CTestCrashDataSource::CTestCrashDataSource( )
+    {
+	RDebug::Printf( "test_crashdatasource.cpp::CTestCrashDataSource::CTestCrashDataSource()\n" );
+    }
+
+
+// second-phase constructor
+void CTestCrashDataSource::ConstructL()
+    {
+	RDebug::Printf( "test_crashdatasource.cpp::CTestCrashDataSource::ConstructL()\n" );
+    }
+
+
+// destructor
+CTestCrashDataSource::~CTestCrashDataSource()
+    {
+	RDebug::Printf( "test_crashdatasource.cpp::CTestCrashDataSource::~CTestCrashDataSource()\n" );
+    }
+
+
+
+TInt CTestCrashDataSource::SetSimRegValues(  const TUint32    aThreadId,
+						RRegisterList & aRegisterList )
+	{
+
+	RDebug::Print( _L("CTestCrashDataSource::SetSimRegValues()\n") );
+
+	if( aRegisterList.Count() > 0 )
+		{
+
+		TUint8  val8  = (TUint8)(KRegValue8 + aThreadId);
+		TUint16 val16 = (TUint16)(KRegValue16 + aThreadId); 
+		TUint32 val32 = (TUint32)(KRegValue32 + aThreadId); 
+		TUint64 val64 = (TUint64)(MAKE_TUINT64(0xFEDCBA98u,0x76543210u) + aThreadId); 
+
+		for( TInt i = 0; i < aRegisterList.Count(); i ++ )
+			{
+			
+			TRegisterData & reg = aRegisterList[i];
+
+			switch ( reg.iSize )
+				{
+				case 0:
+					reg.iValue8  =  val8 + i;
+					RDebug::Printf( " Setting reg[%d] iValue8=0x%X\n", i, reg.iValue8 ); 
+					break;
+				case 1:
+					reg.iValue16 =  val16+ i;
+					RDebug::Printf( " Setting reg[%d] iValue16=0x%X\n", i, reg.iValue16 ); 
+					break;
+				case 2:
+					reg.iValue32 =  val32+ i;
+					RDebug::Printf( " Setting reg[%d] iValue32=0x%X\n", i, reg.iValue32 ); 
+					break;
+				case 3:
+					reg.iValue64 =  val64+ i;
+					RDebug::Printf( " Setting reg[%d]=0x%X%X\n", i,
+						I64HIGH(reg.iValue64), I64LOW(reg.iValue64) ); 
+					break;
+				}
+
+            //reg.iAvailable = i%8 ? ETrue : EFalse;
+            /*
+			if ( 0 == ((i+1) % 8) )
+				{
+				RDebug::Printf( "   setting reg[%d] as not available\n", i );
+				reg.iAvailable = EFalse;
+				}
+            */
+			}
+
+		return KErrNone;
+
+		}
+
+	return KErrBadHandle;
+
+	}
+
+
+void CTestCrashDataSource::PrintRegs( RRegisterList & aRegisterList )
+	{
+	RDebug::Printf( "CTestCrashDataSource::PrintRegs()\n" );
+
+	if( aRegisterList.Count() > 0 )
+		{
+		for( TInt i = 0; i < aRegisterList.Count(); i ++ )
+			{			
+			TRegisterData & reg = aRegisterList[i];
+
+			RDebug::Printf( " reg[%d] iRegClass=%d, iId=%d, iSubId=%d, iSize=%d, iAvailable=", 
+				i, reg.iRegClass, reg.iId, reg.iSubId, reg.iSize );
+            if(reg.iAvailable)
+                RDebug::Printf( "ETrue\n" );
+            else
+                RDebug::Printf( "EFalse\n" );
+
+			switch ( reg.iSize )
+				{
+				case 0:
+					RDebug::Printf( "  iValue8=0x%X\n", reg.iValue8 ); break;
+				case 1:
+					RDebug::Printf( "  iValue16=0x%X\n", reg.iValue16 ); break;
+				case 2:
+					RDebug::Printf( "  iValue32=0x%X\n", reg.iValue32 ); break;
+				case 3:
+					RDebug::Printf( "  iValue64=0x%X%X\n", 
+						I64HIGH(reg.iValue64), I64LOW(reg.iValue64) ); 
+					break;
+				}
+			}
+		}
+	else
+		{
+		RDebug::Printf( " No registers to print\n" );
+		}
+	}
+
+
+void CTestCrashDataSource::GetRegisterListL( RRegisterList & aRegisterList )
+{
+
+	LOG_MSG("CTestCrashDataSource::GetRegisterListL()\n");
+
+    TFunctionalityRegister ids[] = {ERegisterR0,
+                                    ERegisterR1,
+                                    ERegisterR2,
+                                    ERegisterR3,
+                                    ERegisterR4,
+                                    ERegisterR5,
+                                    ERegisterR6,
+                                    ERegisterR7,
+                                    ERegisterR8,
+                                    ERegisterR9,
+                                    ERegisterR10,
+                                    ERegisterR11,
+                                    ERegisterR12,
+                                    ERegisterR13,
+                                    ERegisterR14,
+                                    ERegisterR15,
+                                    ERegisterCpsr,
+                                    ERegisterR13Svc,
+                                    ERegisterR14Svc,
+                                    ERegisterSpsrSvc,
+                                    ERegisterR13Abt,
+                                    ERegisterR14Abt,
+                                    ERegisterSpsrAbt,
+                                    ERegisterR13Und,
+                                    ERegisterR14Und,
+                                    ERegisterSpsrUnd,
+                                    ERegisterR13Irq,
+                                    ERegisterR14Irq,
+                                    ERegisterSpsrIrq,
+                                    ERegisterR8Fiq,
+                                    ERegisterR9Fiq,
+                                    ERegisterR10Fiq,
+                                    ERegisterR11Fiq,
+                                    ERegisterR12Fiq,
+                                    ERegisterR13Fiq,
+                                    ERegisterR14Fiq,
+                                    ERegisterSpsrFiq,
+                                    ERegisterLast
+                                                    };
+
+    aRegisterList.Reset();
+
+    TRegisterData reg;
+    //core regs
+    const TFunctionalityRegister* r;
+    for(r = ids; *r != ERegisterLast; ++r)
+    {
+        reg.iRegClass  = 0; //Core
+        reg.iId        = *r; // R0, ...  
+        reg.iSubId     = 0; // not used for Core Regs
+        reg.iSize      = 2;
+        reg.iAvailable = ETrue;
+        aRegisterList.AppendL( reg );
+
+    }
+
+    //copro regs
+    for(TInt i = 0; i < KCoProRegsCount; ++i)
+    {
+        reg.iRegClass  = 1; //CoPro
+        reg.iId        = i; // R0, ...  
+        reg.iSubId     = KRegSubId + i; 
+        reg.iSize      = i%4;
+        reg.iAvailable = i < KCoProRegsCount/2 ? ETrue : EFalse; //half not available
+        aRegisterList.AppendL( reg );
+    }
+}
+
+void CTestCrashDataSource::ReadRegistersL( const TUint64 aThreadId, RRegisterList &aRegisterList )
+	{
+
+	//RDebug::Print( _L("CTestCrashDataSource::ReadRegisters( threadId=0x%X)\n"), I64LOW(aThreadId) );
+
+	if( aRegisterList.Count() )
+		{
+		RDebug::Printf( "Register list already supplied\n" );
+        User::LeaveIfError(SetSimRegValues( aThreadId, aRegisterList ));
+		}
+	else
+		{
+		RDebug::Printf( "Creating register list\n" );
+	    GetRegisterListL( aRegisterList );
+        User::LeaveIfError(SetSimRegValues( aThreadId, aRegisterList ));
+		}
+
+	PrintRegs( aRegisterList );
+
+	}
+
+
+
+void CTestCrashDataSource::ReadMemoryL(
+                   const TUint64    aThreadId,
+                   const TUint32    aAddress,
+                   const TUint32    aLength,
+                   TDes8          & aData )
+	{
+
+	RDebug::Print( _L("CCrashDataSource::ReadMemory( tId=0x%X, addr=0x%X, len=0x%X)\n"), 
+		aThreadId, aAddress, aLength );
+
+	for( TUint32 i = 0; i < aLength; i++ )
+		{
+        aData.Append((TUint8*)&i, 1);
+		RDebug::Printf( " Memory[%d]=0x%X\n", i, aData[i] );
+		}
+	}
+
+
+
+
+void CTestCrashDataSource::GetProcessListL( RProcessPointerList & aProcList, 
+									        TUint & aTotalProcessListDescSize )
+	{
+
+	RDebug::Print( _L("CTestCrashDataSource::GetProcessList( )\n") );
+
+    CProcessInfo *processInfo = CProcessInfo::NewL(KCrashPid, KCrashFileName );
+
+    TInt err = aProcList.Append( processInfo ); 
+    if(err != KErrNone)
+        {
+        delete processInfo;
+        User::Leave(err);
+        }
+    }
+
+void CTestCrashDataSource::GetExecutableListL( RExecutablePointerList & aExecutableList, 
+									        TUint & aTotalExecutableListDescSize )
+	{
+
+	RDebug::Print( _L("CTestCrashDataSource::GetExecutableList( )\n") );
+
+    CExecutableInfo *executableInfo = CExecutableInfo::NewL(KCrashFileName, EFalse, EFalse );
+
+    TInt err = aExecutableList.Append( executableInfo ); 
+    if(err != KErrNone)
+        {
+        delete executableInfo;
+        User::Leave(err);
+        }
+    }
+
+void CTestCrashDataSource::GetThreadListL(	const TUint64 aProcessId, 
+									RThreadPointerList & aThreadList,
+									TUint & aTotalThreadListDescSize )
+	{
+	GetThreadListL( I64LOW( aProcessId ), aThreadList, aTotalThreadListDescSize );
+	}
+
+
+void CTestCrashDataSource::GetThreadListL( const TUint32 aProcessId, 
+									RThreadPointerList & aThreadList,
+									TUint & aTotalThreadListDescSize )
+	{
+
+	RDebug::Print( _L("CTestCrashDataSource::GetThreadList( pId=0x%X)\n"), aProcessId );
+
+
+
+	LOG_MSG2( "CTestCrashDataSource::GetThreadListL( pId=0x%X)\n", aProcessId );
+
+	aThreadList.ResetAndDestroy();
+	aTotalThreadListDescSize = 0;
+
+        for(TInt i =0; i < KCrashThreadsCount; ++i)
+        {
+            CThreadInfo *thread = CThreadInfo::NewL( KCrashTid + i,
+                                        KCrashThreadName,
+                                        KCrashPid,
+                                        KCrashThreadPriority + i,
+                                        KCrashSvcStackPtr + i,
+                                        KCrashSvcStackAddr + i,
+                                        KCrashSvcStackSize + i,
+                                        KCrashUsrStackAddr + i,
+                                        KCrashUsrStackSize + i);
+            aThreadList.Append(thread);
+            //delete thread;
+        }
+
+	}
+
+void CTestCrashDataSource::GetCodeSegmentsL( const TUint64 aTid, RCodeSegPointerList &aCodeSegs, TUint &aTotalCodeSegListDescSize )
+	{
+
+	RDebug::Printf( "CTestCrashDataSource::GetExecutableInfo(pId=0x%X)\n", aTid );
+	TInt err;
+    
+    TCodeSegInfo *segInfo;
+
+    if(KCrashXIP)
+        RDebug::Printf( " Exec info XIP == ETrue\n" );
+    else
+        RDebug::Printf( " Exec info XIP == EFalse\n" );
+
+    
+	segInfo = new(ELeave) TCodeSegInfo;
+	segInfo->iName			 = KCrashFileName;
+    segInfo->iXIP			 = ETrue;
+    segInfo->iCodeSize       = KCrashCodeSize + aTid;
+    segInfo->iCodeRunAddr    = KCrashCodeRunAddr + aTid;
+    segInfo->iCodeLoadAddr   = KCrashCodeLoadAddr + aTid;
+    segInfo->iRoDataSize     = KCrashRODataSize + aTid;
+    segInfo->iRoDataRunAddr  = KCrashRODataRunAddr + aTid;
+    segInfo->iRoDataLoadAddr = KCrashRODataLoadAddr + aTid;
+    segInfo->iDataSize       = KCrashDataSize + aTid;
+    segInfo->iDataRunAddr    = KCrashDataRunAddr + aTid;
+    segInfo->iDataLoadAddr   = KCrashDataLoadAddr + aTid;
+	segInfo->iType			 = EExeCodeSegType;
+    err = aCodeSegs.Append(segInfo);
+	if(err != KErrNone)
+		{
+        delete segInfo;
+        User::Leave(err);
+        }
+	aTotalCodeSegListDescSize += sizeof(TCodeSegInfo);
+
+	segInfo = new(ELeave) TCodeSegInfo;
+	segInfo->iName			 = KLibName1;
+    segInfo->iXIP			 = ETrue;
+    segInfo->iCodeSize       = KCrashCodeSize + aTid + 1;
+    segInfo->iCodeRunAddr    = KCrashCodeRunAddr + aTid + 1;
+    segInfo->iCodeLoadAddr   = KCrashCodeLoadAddr + aTid + 1;
+    segInfo->iRoDataSize     = KCrashRODataSize + aTid + 1;
+    segInfo->iRoDataRunAddr  = KCrashRODataRunAddr + aTid + 1;
+    segInfo->iRoDataLoadAddr = KCrashRODataLoadAddr + aTid + 1;
+    segInfo->iDataSize       = KCrashDataSize + aTid + 1;
+    segInfo->iDataRunAddr    = KCrashDataRunAddr + aTid + 1;
+    segInfo->iDataLoadAddr   = KCrashDataLoadAddr + aTid + 1;
+	segInfo->iType			 = EDllCodeSegType;
+    err = aCodeSegs.Append(segInfo);
+	if(err != KErrNone)
+		{
+        delete segInfo;
+        User::Leave(err);
+        }
+	aTotalCodeSegListDescSize += sizeof(TCodeSegInfo);
+
+	segInfo = new(ELeave) TCodeSegInfo;
+	segInfo->iName			 = KLibName2;
+    segInfo->iXIP			 = EFalse;
+    segInfo->iCodeSize       = KCrashCodeSize + aTid + 2;
+    segInfo->iCodeRunAddr    = KCrashCodeRunAddr + aTid + 2;
+    segInfo->iCodeLoadAddr   = KCrashCodeLoadAddr + aTid + 2;
+    segInfo->iRoDataSize     = KCrashRODataSize + aTid + 2;
+    segInfo->iRoDataRunAddr  = KCrashRODataRunAddr + aTid + 2;
+    segInfo->iRoDataLoadAddr = KCrashRODataLoadAddr + aTid + 2;
+    segInfo->iDataSize       = KCrashDataSize + aTid + 2;
+    segInfo->iDataRunAddr    = KCrashDataRunAddr + aTid + 2;
+    segInfo->iDataLoadAddr   = KCrashDataLoadAddr + aTid + 2;
+	segInfo->iType			 = EDllCodeSegType;
+    err = aCodeSegs.Append(segInfo);
+	if(err != KErrNone)
+		{
+        delete segInfo;
+        User::Leave(err);
+        }
+	aTotalCodeSegListDescSize += sizeof(TCodeSegInfo);
+
+	}
+
+void CTestCrashDataSource::ReadTraceBufferL(TDes8 &aTraceData )
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+void CTestCrashDataSource::GetLocksL(TSCMLockData& aLockData)
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+void CTestCrashDataSource::GetROMBuildInfoL(TRomHeaderData& aRomHeader)
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+TUint CTestCrashDataSource::GetExceptionStackSizeL(const Debug::TArmProcessorModes aMode)
+	{
+	User::Leave(KErrNotSupported);
+	return 0;
+	}
+
+void CTestCrashDataSource::GetExceptionStackL(const Debug::TArmProcessorModes aMode, TDes8& aStack, TUint aStartReadPoint)
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+TInt CTestCrashDataSource::GetDataSourceFunctionality(TDes8& aFuncBuffer)
+	{
+	return KErrNotSupported;
+	}
+
+TInt CTestCrashDataSource::GetDataSourceFunctionalityBufSize(TUint& aBufSize)
+	{
+	return KErrNotSupported;
+	}
+
+TVersion CTestCrashDataSource::GetVersion() const
+	{
+	TVersion ver(2,0,0);
+	return ver;
+	}
+
+TInt CTestCrashDataSource::GetVariantSpecificDataSize(TUint& aDataSize)
+	{
+	aDataSize = 0;
+	return KErrNotSupported;
+	}
+
+TInt CTestCrashDataSource::GetVariantSpecificData(TDes8& aVarSpecData)
+	{
+	(void)aVarSpecData;
+	return KErrNotSupported;
+	}
+
+//eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/test/testcrashdatasource.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,224 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Simulated Data Source API that supplies crash information 
+// by implementing the data source API CCrashDataSource 
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef TEST_CRASH_DATA_SOURCE_H
+#define TEST_CRASH_DATA_SOURCE_H
+
+#include <e32std.h>
+#include <e32base.h>
+
+
+#include <crashdatasource.h>
+#include <scmdatatypes.h>
+//
+// CTestCrashDataSource 
+//
+class CTestCrashDataSource : public CCrashDataSource 
+{
+public:
+
+	CTestCrashDataSource();
+
+	virtual ~CTestCrashDataSource();
+protected:
+	virtual void ConstructL();
+
+public:
+	
+	/** This call returns information on all available registers. It does not
+	return the register contents. This is used to establish which registers 
+	a formatter could ask for, in particular for Co Processor registers. 
+	The callee (not the caller) allocates aRegisterList. 
+	This method is used by a formatter to establish which registers it can ask for, 
+	and thus need only be called once per session. */
+	virtual void GetRegisterListL( RRegisterList  &	aRegisterList );
+
+	/** Ask the Core Dump server for some register data. The caller allocates
+	the array and fills in the details of the registers that it would like 
+	the contents for */
+	virtual void ReadRegistersL( const TUint64 aThreadId, RRegisterList &aRegisterList );
+
+	//
+	// Argument aLength must be a multiple of aAccessSize
+    // Argument aAddress is aAccessSize aligned
+    // The existence of argument aEndianess is not published, 
+	// allowing for future implementation
+	//
+	virtual void ReadMemoryL(
+                   const TUint64    aThreadId,
+                   const TUint32    aAddress,
+                   const TUint32    aLength,
+                   TDes8          & aData );
+
+
+	//
+	// Get process list 
+	// 
+	virtual void GetProcessListL( RProcessPointerList & aData,
+							      TUint & aTotalProcessListDescSize );
+
+	//
+	// Get executable list 
+	// 
+	virtual void GetExecutableListL( RExecutablePointerList & aData,
+							      TUint & aTotalExecutableListDescSize );
+
+
+    //
+  	// Get the thread list for a given process
+  	// 
+  	//virtual TInt GetThreadList( const TUint32 aProcessId, RThreadList& aThreadList );
+	virtual void GetThreadListL(	const TUint64 aProcessId, 
+									RThreadPointerList & aThreadList,
+									TUint & aTotalThreadListDescSize );
+
+
+  	virtual void GetThreadListL(	const TUint32 aProcessId, 
+									RThreadPointerList & aThreadList,
+									TUint & aTotalThreadListDescSize );
+
+    //
+    // API calls below come from the prototype
+    //
+    virtual void GetCodeSegmentsL(const TUint64 aTid, RCodeSegPointerList &aCodeSegs, TUint &aTotalCodeSegListDescSize);
+    
+    virtual void ReadTraceBufferL(TDes8 &aTraceData );
+    
+    virtual void GetLocksL(TSCMLockData& aLockData);
+    
+    virtual void GetROMBuildInfoL(TRomHeaderData& aRomHeader);
+    
+	virtual TUint GetExceptionStackSizeL(const Debug::TArmProcessorModes aMode);
+
+	virtual void GetExceptionStackL(const Debug::TArmProcessorModes aMode, TDes8& aStack, TUint aStartReadPoint);
+	
+	virtual TInt GetDataSourceFunctionality(TDes8& aFuncBuffer);
+
+	virtual TInt GetDataSourceFunctionalityBufSize(TUint& aBufSize);
+
+	virtual TInt GetVariantSpecificDataSize(TUint& aDataSize);
+
+	virtual TInt GetVariantSpecificData(TDes8& aVarSpecData);
+
+	virtual TVersion GetVersion() const;
+
+private:
+
+	TInt SetSimRegInfo( RRegisterList  &	aRegisterList );
+
+	TInt SetSimRegValues( const TUint32    aThreadId,
+		                  RRegisterList  &	aRegisterList );
+
+	void PrintRegs( RRegisterList  &	aRegisterList );
+
+};
+
+//test consts defines
+enum TTestExcCode 
+	{ 
+	EPrefetchAbort=0, 
+	EDataAbort=1, 
+	EUndefinedOpcode=2
+	};
+enum TTestExitType 
+	{ 
+	EException, 
+	EPanic, 
+	ETerminate, 
+	EPending 
+	}; 
+
+enum TTestExitReason 
+	{ 
+	EUser, 
+	EKernel, 
+	ENone 
+	};
+
+const TInt KCrashFaultAddress = 0x01020304;
+const TInt KCrashFaultStatus = 0x00011000;
+const TInt32 KCrc32 = 0x1234FEDC;
+const TCrashInfo::TCrashType KCrashType = TCrashInfo::ECrashKill;
+const TTestExitReason KCrashReason = EKernel;
+const TRmdArmExcInfo::TExceptionType KCrashExcCode = TRmdArmExcInfo::EPrefetchAbort;
+
+
+const TBool KCrashXIP = EFalse;
+_LIT( KCrashCategory, "crash_category" );
+_LIT8( KCrashCategory8, "crash_category" );
+_LIT( KCrashFileName, "crash_application.exe");
+_LIT8( KCrashFileName8, "crash_application.exe");
+const TUint64 KCrashTid = 0x0123;
+const TUint64 KCrashPid = 0x0789;
+const TUint64 KCrashTime = MAKE_TUINT64(0xFEDCBA98u,0x76543210u);
+_LIT( KCrashThreadName, "crash-thread");
+_LIT8( KCrashThreadName8, "crash-thread");
+const TUint KCrashThreadsCount = 4;
+const TUint KCrashThreadPriority = 42;
+const TUint KCrashUsrStackAddr = 0x44332211;
+const TUint KCrashUsrStackSize = 0x20;
+const TUint KCrashSvcStackPtr = 0x11223344;
+const TUint KCrashSvcStackAddr = 0x22334455;
+const TUint KCrashSvcStackSize = 0x20;
+
+const TUint KCrashCodeSize = 0x10;
+const TUint KCrashCodeRunAddr = 0x01010101;
+const TUint KCrashCodeLoadAddr = 0x02020202;
+const TUint KCrashRODataSize = 0x20;
+const TUint KCrashRODataRunAddr = 0x03030303;
+const TUint KCrashRODataLoadAddr = 0x04040404;
+const TUint KCrashDataSize = 0x30;
+const TUint KCrashDataRunAddr = 0x05050505;
+const TUint KCrashDataLoadAddr = 0x60606006;
+
+
+_LIT( KCrashProcessName, "crash_application.exe");
+_LIT( KLibName1, "application1.dll");
+_LIT( KLibName2, "application2.dll");
+
+_LIT8( KCrashProcessName8, "crash_application.exe");
+_LIT8( KLibName1_8, "application1.dll");
+_LIT8( KLibName2_8, "application2.dll");
+
+
+const TUint KCoreRegsCount = 16;
+const TUint KCoProRegsCount = 16;
+const TUint KRegSubId = 0x11;
+const TUint8 KRegValue8 = 0x10;
+const TUint16 KRegValue16 = 0x3210;
+const TUint32 KRegValue32 = 0x76543210;
+const TUint64 KRegValue64 = MAKE_TUINT64(0xFEDCBA98u,0x76543210u);
+
+const TUint KCodeSegsCount = 3;
+const TUint KCodeSegBase = 0x01020304;
+const TUint KCodeSegSize = 0x20;
+
+const TUint KDataSegsCount = 7;
+const TUint KDataSegBase = 0x09080706;
+const TUint KDataSegSize = 0x40;
+
+#endif // TEST_CRASH_DATA_SOURCE_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/data/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/data/utraceformatter.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,58 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Registry file for the Core Dump UTRACE Formatter
+// ECOM RSS file for UTRACE Core dump formatter
+//
+
+
+
+/**
+ @file 
+*/
+
+#include "RegistryInfo.rh"
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+	{
+
+
+	// UID for the DLL
+	dll_uid = 0x102836B9;
+
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of formatter interface 
+			interface_uid = 0x10282fe2;
+
+			implementations = 
+				{
+
+				// Info for CImplementation1
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102836BA;
+					version_no = 1;
+					display_name = "UTRACE Core Dump Formatter plugin v1.0.0";
+					default_data = "UTRACE";
+					opaque_data = "cds utrace";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,25 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file bld.inf Build information file
+//
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+utraceformatter.iby         /epoc32/rom/include/utraceformatter.iby
+
+PRJ_MMPFILES
+utraceformatter.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/group/utraceformatter.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,22 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file utraceformatter.iby ROM build file for symbian elf formatter
+//
+
+#ifndef UTRACE_FORMATTER_IBY__
+#define UTRACE_FORMATTER_IBY__
+
+ECOM_PLUGIN(utraceformatter.dll,utraceformatter.rsc)
+
+#endif // UTRACE_FORMATTER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/group/utraceformatter.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,59 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// UTRACE formatter MMP file
+// utraceformatter.dll A process dump formatter implemented as an ECOM plugin
+//
+
+
+
+/**
+ @file 
+*/
+
+TARGET      utraceformatter.dll
+TARGETTYPE  plugin
+UID         0x10009D8D 0x102836B9 //second uid=ecom uid, third UID d_exc_formatter
+
+VENDORID    0x70000001
+
+CAPABILITY 	PowerMgmt
+
+SOURCEPATH  ../src
+SOURCE      utraceformatter.cpp
+SOURCE		utraceproxy.cpp
+
+USERINCLUDE ../inc
+USERINCLUDE ../../test
+
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/drivers
+SYSTEMINCLUDE   /epoc32/include/tools/coredump
+
+
+//
+// ECOM plugin resource file
+//
+start resource ../data/utraceformatter.rss
+target utraceformatter.rsc
+end
+
+LIBRARY		ecom.lib
+LIBRARY		euser.lib
+LIBRARY     estor.lib
+LIBRARY     cdssupport.lib
+LIBRARY     btracec.lib
+
+MACRO CDSDEBUG
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/group/utraceformatter.mrp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component	utraceformatter
+
+source	\src\tools\debug\coredump\plugins\formatters\utrace\group
+binary	\src\tools\debug\coredump\plugins\formatters\utrace\group all
+exports	\src\tools\debug\coredump\plugins\formatters\utrace\group
+
+notes_source	\component_defs\release.src
+#touch to force CBR re-release
+
+ipr E
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/inc/utraceformatter.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,104 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Defines UTRACE formatter plugin class
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef UTRACE_FORMATTER_H
+#define UTRACE_FORMATTER_H
+
+#include <e32std.h>
+#include <e32property.h>
+#include <rm_debug_api.h> //registers info
+
+#include <formatterapi.h>
+#include <optionconfig.h>
+#include <crashdatasource.h>
+#include <crashdatasave.h>
+#include <coredumpserverapi.h> //property - UID
+
+const TUint32 KUtraceFormatterUID = { 0x102836BA   };
+
+_LIT(KPluginDescription, "UTrace formatter plugin");
+_LIT(KUTraceCrashStart, "started utrace formatting");
+_LIT(KUTraceCrashFinish, "done");
+
+/**
+@internalTechnology 
+@released 
+DEXC formatter plugin is loaded by the core dump server and notified about the crash event.
+Then it dupms crash data in the same format as the legacy d_exc crash dump utility.
+@see CCrashDataSave
+*/
+class CUtraceFormatter : public CCoreDumpFormatter
+{
+	enum { KUTraceDumpFileLength = 23 };
+
+	public:
+		static CUtraceFormatter* NewL();
+		static CUtraceFormatter* NewLC();
+		~CUtraceFormatter();
+		
+	public:
+		virtual TInt GetNumberConfigParametersL( );
+		virtual COptionConfig * GetConfigParameterL( const TInt aIndex );
+		virtual void SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue );
+	
+	    virtual void ConfigureDataSaveL(CCrashDataSave* aDataSave);
+	    virtual void ConfigureDataSourceL(CCrashDataSource* aDataSource);
+	    virtual void GetDescription(TDes& aPluginDescription);
+	    virtual void CrashEventL(TCrashInfo* aCrashInfo);
+	    
+    private:
+    	void ConstructL();
+    	TUint HelpWriteTraceBufferL(TUint aTraceAvailable, TUint aTraceWanted, TUint aOffset);
+    	TUint HelpWriteTraceBufferWithTraceFrameWorkL(TUint aTraceWanted, TUint aOffset);    	
+    	
+    private:
+    	
+	    /** Pointer to writer plugin created and managed by core dump server, provides API to store the dump information*/
+	    CCrashDataSave* iDataSave;
+	    
+	    /** Pointer to data source object created and managed by core dump server, provides API to gather necessary info about the crash */ 
+        CCrashDataSource* iDataSource; 
+        
+        /** Values for utrace configuration */
+        enum TUTraceParams
+        {
+        /** Amount of trace to dump */
+        ETraceSize,
+        
+        /** Gaurd */
+        ETraceGuard
+        };
+        
+        const TDesC& DumpFileNameLC(TUint64 aStamp);
+         
+        void UpdateCrashProgressL( const TDesC &aProgress );
+        
+     public:
+     
+        /** UTRACE formatter configuration parameter list */
+		RConfigParameterList iConfigList;   
+    
+
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/src/utraceformatter.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,383 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <d32btrace.h>
+
+#include "utraceformatter.h"
+
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CUtraceFormatter* CUtraceFormatter::NewL()
+	{
+    LOG_MSG("->CUtraceFormatter::NewL()\n");
+    CUtraceFormatter* self = CUtraceFormatter::NewLC();
+	CleanupStack::Pop(self);
+    return self;
+	}
+
+/**
+1st stage construction
+@return pointer to the newly created object, caller takes ownership of the object.
+*/
+CUtraceFormatter* CUtraceFormatter::NewLC()
+	{
+    LOG_MSG("->CUtraceFormatter::NewLC()\n");
+    CUtraceFormatter* self = new(ELeave) CUtraceFormatter();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+/**
+dtor
+*/
+CUtraceFormatter::~CUtraceFormatter()
+	{
+    LOG_MSG("->~CDexcFormatter()\n");
+    iConfigList.ResetAndDestroy();
+	}
+
+/**
+2nd stage construction
+*/
+void CUtraceFormatter::ConstructL()
+	{
+	LOG_MSG("->CDexcFormatter::ConstructL()\n");
+	
+	//Configure the plugin
+	COptionConfig * config = NULL;
+	
+	iConfigList.ReserveL( (TInt) ETraceGuard );
+	
+	_LIT(KTraceSize, "How much trace data to dump? (Kb)");
+	
+	config = COptionConfig::NewL(   (TInt) ETraceSize,    
+									KUtraceFormatterUID,
+									COptionConfig::EFormatterPlugin,
+									COptionConfig::ETInt,
+									KTraceSize,
+									1,
+									KNullDesC,
+									100,
+									KNullDesC);
+	
+	TInt error = iConfigList.Append(config);
+	
+	if(error != KErrNone)
+		{
+		delete config;
+		LOG_MSG2("\tCDexcFormatter::ConstructL() - unable to store COptionConfig object in param list: %d", error);
+		}
+
+	}
+
+/**
+Called by CDS to ask for the configuration parameters that the writer needs (see Plugin Configuration) 
+@return actual number of implemented config parameters
+*/
+TInt CUtraceFormatter::GetNumberConfigParametersL()
+	{
+	TInt count = iConfigList.Count();
+	LOG_MSG2("->CUtraceFormatter::GetNumberConfigParametersL() : returns:%d\n", count );
+	return count;
+	}
+
+/**
+Called by CDS to ask for configuration parameter prompt (see Plugin Configuration) 
+
+@param aIndex indicates which parameter to return
+@return pointer to COptionConfig object representing the requested config parameter. Caller doesn't take ownership of the object!
+@leave KErrBadHandle if index is out of bounds
+@see COptionConfig
+*/
+COptionConfig* CUtraceFormatter::GetConfigParameterL(const TInt aIndex)
+	{
+	// return the config identified by aIndex
+	if( ( aIndex < 0 ) || ( aIndex >= iConfigList.Count() ) )
+		{
+		User::Leave( KErrBadHandle );
+		}
+	
+	return iConfigList[aIndex];
+	}
+
+/**
+Change a configuration parameter.
+@param aIndex Index of parameter to change
+@param aValue Unused 
+@param aDescValue Path and filename to use
+@leave KErrBadHandle if index is out of bounds or one of the other system wide error codes
+*/
+void CUtraceFormatter::SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue )
+	{
+	
+	if( ( aIndex < 0 ) || ( aIndex >= iConfigList.Count() ) )
+		{
+			User::Leave( KErrBadHandle );
+		}
+	
+	COptionConfig & config = *(iConfigList[aIndex]);
+
+	if( ( aIndex != (TInt)ETraceSize ) )
+		{
+			LOG_MSG( "\tLeaving : aIndex != ETraceSize " );
+			User::Leave( KErrArgument );
+		}
+	
+	//For the moment, we care not for the aDescValue
+	if(aValue > 0)
+		{
+		config.Value(aValue);
+		config.ValueL(KNullDesC);
+		}
+	
+	}
+
+/**
+Sets pointer to the writer plugin.
+Configures formatter's dump data save plugin.
+
+@param aDataSave pointer to writer plugin object.
+@leave KErrNoMemory if aDataSave is NULL 
+*/
+void CUtraceFormatter::ConfigureDataSaveL(CCrashDataSave* aDataSave)
+	{
+    LOG_MSG2("\tConfigureDataSaveL(%d)", aDataSave);
+    User::LeaveIfNull(aDataSave);
+    iDataSave = aDataSave;
+	}
+
+/**
+Sets pointer to the crash data server.
+Configures formatter's crash data source plugin.
+
+@param aDataSource pointer to core dump server object.
+@leave KErrNoMemory if aDataSource is NULL 
+*/
+void CUtraceFormatter::ConfigureDataSourceL(CCrashDataSource* aDataSource)
+	{
+    LOG_MSG2("\tConfigureDataSourceL(%d)", aDataSource);
+    User::LeaveIfNull(aDataSource);
+    iDataSource = aDataSource;
+	}
+
+void CUtraceFormatter::GetDescription(TDes& aPluginDescription)
+	{
+    LOG_MSG("\tCDexcFormatter::GetDescription()");
+	aPluginDescription.Copy(KPluginDescription());
+	}
+
+void CUtraceFormatter::CrashEventL(TCrashInfo* aCrashInfo)
+	{
+	LOG_MSG("->CUtraceFormatter::CrashEventL\n");
+	
+	User::LeaveIfNull(aCrashInfo);
+    User::LeaveIfNull(iDataSource);
+    User::LeaveIfNull(iDataSave);
+    
+    TInt traceDataToCapture = iConfigList[ (TInt)ETraceSize ]->Value();
+	if(traceDataToCapture == 0)
+		{
+		LOG_MSG("CUtraceFormatter::WriteTraceBufferL - not configured to dump trace data");
+		return;
+		}
+    
+    //update notifier
+    UpdateCrashProgressL( KUTraceCrashStart );
+    
+    iDataSave->OpenL( DumpFileNameLC(aCrashInfo->iTime ));
+    CleanupStack::PopAndDestroy(); //filename
+    
+	TUint traceAvailable = 0;	
+	TRAPD(err, traceAvailable = iDataSource->GetAvailableTraceSizeL());
+	if(err != KErrNone)
+		{
+		LOG_MSG2("Unable to get available trace size. Err = [%d] ", err);
+		User::Leave(err);
+		}
+	
+	//Write the data to the file
+	LOG_MSG2("\tWriting Trace data: iDataSave->WriteL() at Offset =0, size =%d bytes", traceAvailable);
+	TUint size = 0;
+	
+	TRAP(err, size = HelpWriteTraceBufferL(traceAvailable, traceDataToCapture * 1024, 0));
+	if(err == KErrNotSupported)
+		{
+		LOG_MSG("Unable to use data source to dump trace so reverting to the live trace framework");
+		TRAP(err, size = HelpWriteTraceBufferWithTraceFrameWorkL(traceDataToCapture * 1024, 0));
+		}
+	
+	if(err != KErrNone)
+		{
+		//This error is not fatal but worth logging
+		LOG_MSG2("Trace writing didnt succeed. Error = [%d]", err);
+		}	
+
+	LOG_MSG2("\tTrace data and info succesfully written - [%d] bytes", size);
+	
+	iDataSave->CloseL();
+	}
+
+/**
+ * This gets trace from the data source. This is for use when you dont want trace from the live system and want 
+ * the data source to decide how we obtain the trace. The data source may not support this, and leaving with
+ * KErrNotSupported will mean that you should be using the live trace system to get the data
+ * @param aTraceAvailable The amount of availbale trace data
+ * @param aTraceWanted The amount of trace data we wish to dump
+ * @param aOffset The position in the file to write the trace
+ * @see HelpWriteTraceBufferWithTraceFrameWorkL
+ */
+TUint CUtraceFormatter::HelpWriteTraceBufferL(TUint aTraceAvailable, TUint aTraceWanted, TUint aOffset)
+	{
+	LOG_MSG4("CUtraceFormatter::HelpWriteTraceBufferL aTraceAvailable = [%d] aTraceWanted = [%d] aOffset = [%d]", aTraceAvailable, aTraceWanted, aOffset);
+	
+	TUint dataReq = (aTraceAvailable >= aTraceWanted) ? aTraceWanted : aTraceAvailable;
+	TUint bufferSize = dataReq;
+	RBuf8 theTraceData;	
+	TBool bufferCreated = EFalse;
+	
+	//Try and allocate the buffer
+	while(!bufferCreated)
+		{
+		LOG_MSG2("Trying to create a buffer of size [%d] bytes", bufferSize);
+		
+		if(bufferSize == 0)
+			{
+			User::LeaveNoMemory();
+			}
+		
+		TInt err = theTraceData.Create(bufferSize);
+		if(KErrNone == err)
+			{
+			bufferCreated = ETrue;
+			theTraceData.CleanupClosePushL();
+			}
+		else
+			{
+			bufferSize = bufferSize/4;
+			}
+		}
+	
+	//Now we read the trace data bit by bit
+	TUint sizeWritten = 0;
+	while(sizeWritten < dataReq)
+		{		
+		iDataSource->ReadTraceBufferL(theTraceData, sizeWritten);
+		
+		LOG_MSG3("Writing [%d] bytes of raw trace data at [%d]", theTraceData.Size(), aOffset);
+		iDataSave->WriteL( aOffset, const_cast<TUint8*>(theTraceData.Ptr()), theTraceData.Size());
+		
+		sizeWritten += theTraceData.Length();
+		aOffset += theTraceData.Length();
+		}
+	
+	CleanupStack::PopAndDestroy(&theTraceData);
+	
+	return sizeWritten;
+	}
+
+/**
+ * Writes trace to the file using the trace framework. This is to use when you want trace from the live system.
+ * @param aTraceWanted The amount of trace data we wish to dump
+ * @param aOffset The position in the file to write the trace
+ * @see HelpWriteTraceBufferL
+ */
+TUint CUtraceFormatter::HelpWriteTraceBufferWithTraceFrameWorkL(TUint aTraceWanted, TUint aOffset)
+	{
+	LOG_MSG3("CUtraceFormatter::HelpWriteTraceBufferWithTraceFrameWorkL aTraceWanted = [%d] aOffset = [%d]", aTraceWanted, aOffset);
+    
+    RBTrace trace;
+    User::LeaveIfError(trace.Open());
+    CleanupClosePushL(trace);
+    
+    TUint8 *data = NULL;
+    TInt size = trace.GetData(data);
+    
+    if(!data)
+    	{
+    	User::Leave(KErrNotFound);
+    	}
+    
+    TUint sizeToDump = (aTraceWanted >= size) ? size : aTraceWanted;
+    
+    LOG_MSG2("Adding [%d] bytes to the file", sizeToDump);
+    iDataSave->WriteL( aOffset, data, sizeToDump);
+    
+    CleanupStack::PopAndDestroy(&trace);	
+	
+	return size;
+	}
+
+/**
+Prepares the name of the dump file. Checks DataSave filename option, if it is provided by the user
+it appends the time stamp, if not it uses default name appended with the time stamp. 
+@param aStamp lower 32 bits of the time stamp
+@return descriptor holding the final dump file name, caller is responsible to pop it from the cleanup stack
+@leave err one of system wide error codes
+ */
+const TDesC& CUtraceFormatter::DumpFileNameLC(TUint64 aStamp)
+{
+    LOG_MSG("->CUtraceFormatter::DumpFileNameLC()\n");
+    COptionConfig *option = iDataSave->GetConfigParameterL(CCrashDataSave::ECoreFilePath);
+	const TDesC &userFileName = option->ValueAsDesc();
+	HBufC *filename = HBufC::NewLC(userFileName.Length() + KUTraceDumpFileLength);
+    if(userFileName.Length() > 0)
+        {
+	    *filename = userFileName;
+        _LIT(KStampFormat, "%u");
+        filename->Des().AppendFormat(KStampFormat, I64LOW(aStamp));
+        }
+    else
+        {
+        _LIT(KTxtFileFormat, "e:\\trace%u");
+        filename->Des().Format(KTxtFileFormat, aStamp);
+        }
+    return *filename;
+}
+
+/**
+Checks the value of the crash cancel property. If set to cancel, it closes the 
+data save and then leaves with KErrAbort.
+Otherwise it updates the crash progress with the argument value.
+
+@param aProgress Progress description.
+@leave KErrAbort if crash cancel property has been set
+*/
+void CUtraceFormatter::UpdateCrashProgressL( const TDesC &aProgress )
+    {
+    
+    LOG_MSG("->CUtraceFormatter::UpdateCrashProgress()\n");
+    TInt cancelCrash;
+    _LIT(KNoProgress, "");
+    RProperty::Get( KCoreDumpServUid, ECancelCrash, cancelCrash );
+
+    if( cancelCrash )
+        {
+        RProperty::Set( KCoreDumpServUid, ECrashProgress, KNoProgress );
+
+		
+		LOG_MSG("  iDataSave->CloseL();\n");
+		iDataSave->CloseL();
+
+		LOG_MSG("  UpdateCrashProgress() -> User::Leave( KErrAbort )\n");
+        User::Leave( KErrAbort );
+        }
+
+    RProperty::Set( KCoreDumpServUid, ECrashProgress, aProgress );
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/formatters/utrace/src/utraceproxy.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,30 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <implementationproxy.h>
+
+#include "utraceformatter.h"
+
+// ECom boiler template code
+const TImplementationProxy ImplementationTable[] =
+{
+	IMPLEMENTATION_PROXY_ENTRY(0x102836BA, CUtraceFormatter::NewL),
+};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+	return ImplementationTable;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/data/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/data/filewriter.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,53 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Registry file for the core dump writer
+// ECOM RSS file for File Writer 
+//
+
+
+
+/**
+ @file 
+*/
+
+#include "RegistryInfo.rh"
+
+// Declares info for one implementation
+RESOURCE REGISTRY_INFO theInfo
+	{
+	// UID for the DLL
+	dll_uid = 0x102831e2;
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of file writer interface
+			interface_uid = 0x102831e3;
+			implementations = 
+				{
+				// Info for CFileWriter
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102831e4;
+					version_no = 1;
+					display_name = "Symbian File Writer plugin v1.0.0";
+					default_data = "File Writer V1.0.0";
+					opaque_data = "cds filewriter";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file bld.inf Build information file
+//
+
+#include "../test/bld.inf"
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+filewriter.iby		/epoc32/rom/include/filewriter.iby
+
+PRJ_MMPFILES
+filewriter.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/group/filewriter.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file filewriter.iby ROM build file for symbian elf formatter
+//
+
+#ifndef __FILE_WRITER_IBY__
+#define __FILE_WRITER_IBY__
+
+ECOM_PLUGIN(filewriter.dll,102831e2.rsc)
+
+#endif // __FILE_WRITER_IBY__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/group/filewriter.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,55 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// File Writer MMP file
+// filewriter.dll A process core dump writer implemented as an ECOM plugin
+//
+
+/**
+ @file
+*/
+
+TARGET      filewriter.dll
+TARGETTYPE  plugin
+UID         0x10009D8D 0x102831e2 //second uid=ecom uid, third UID file_writer
+
+VENDORID    0x70000001
+
+CAPABILITY 	PowerMgmt
+
+SOURCEPATH  ../src
+SOURCE    	filewriter.cpp
+source		filewriterproxy.cpp
+
+USERINCLUDE ../inc
+
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/drivers
+SYSTEMINCLUDE   /epoc32/include/tools/coredump
+
+//
+// ECOM plugin resource file
+//
+sourcepath		../src
+start resource ../data/filewriter.rss
+end
+
+library		ecom.lib
+library		euser.lib
+library		efsrv.lib
+library		estor.lib
+library		cdssupport.lib
+library		bafl.lib
+
+MACRO CDSDEBUG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/inc/filewriter.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,88 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implements file writer plugin
+// Definition of the file writer plugin.
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef __FILE_WRITER_H__
+#define __FILE_WRITER_H__
+
+#include <e32hashtab.h>
+#include <crashdatasave.h>
+
+const TUint32 KFileWriterUid = { 0x102831e4 };
+
+/**
+@internalTechnology
+@released
+
+File writer plugin is loaded by the core dump server and used by formatter plugin to write dump data to a file.
+*/
+class CFileWriter : public CCrashDataSave
+{
+public:
+	static CFileWriter* NewL();
+	static CFileWriter* NewLC();
+	~CFileWriter();
+
+public:
+
+	virtual void GetDescription( TDes & aPluginDescription );
+	virtual TInt GetNumberConfigParametersL( );
+	virtual COptionConfig * GetConfigParameterL( const TInt aIndex );
+	virtual void SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue );
+	virtual const TDesC& GetMediaName();
+
+	// Called by formatter to start the creation of a dump. Can be called several times to create several dumps
+	void OpenL( const TDesC& aFileName );
+	TInt Open( const TDesC& aFileName );
+
+	// Called by formatter to end the creation of a dump. Open() and Close() must be paired calls
+	void CloseL();
+	TInt Close();
+
+	// Save aData - binary
+	void WriteL( const TDesC8& aData );
+	TInt Write( const TDesC8& aData );
+
+	// Save aData - raw
+	void WriteL( TAny* aData, TUint aSize );
+	TInt Write( TAny* aData, TUint aSize );
+
+    // Save aData at the specific position - binary - need implementation
+	void WriteL( TInt aPos, const TDesC8& aData );
+	TInt Write( TInt aPos, const TDesC8& aData );
+
+    // Save aData at the specific position - raw
+	void WriteL( TInt aPos, TAny* aData, TUint aSize );
+	TInt Write( TInt aPos, TAny* aData, TUint aSize );
+
+private:
+	void ConstructL();
+	CFileWriter();
+
+private:
+	HBufC* iDescription;			/** plugin description string */
+	RFs	iFs;						/** file server session handle */
+	RFile iFile;					/** dump file handle */
+	TBuf<KMaxFileName> iFileName;	/** filename to be used */
+};
+
+#endif // __FILE_WRITER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/src/filewriter.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,480 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file filewriter.cpp
+// Implementation of the file writer plugin.
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#include <e32base.h>
+#include <e32debug.h>
+#include <optionconfig.h>
+#include <bautils.h>
+#include "filewriter.h"
+
+/**
+1st stage construction
+@return pointer to the newly created object, user takes ownership of the object.
+*/
+CFileWriter* CFileWriter::NewL()
+    {
+	//LOG_MSG("->CFileWriter::NewL()\n");
+	CFileWriter* self = CFileWriter::NewLC();
+	CleanupStack::Pop();
+	return self;
+    }
+
+/**
+1st stage construction
+@return pointer to the newly created object, user takes ownership of the object.
+*/
+CFileWriter* CFileWriter::NewLC()
+    {
+	//LOG_MSG("->CFileWriter::NewLC()\n");
+	CFileWriter* self = new(ELeave) CFileWriter();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+    }
+
+/**
+ctor defaults plugin description descriptor to zero
+*/
+CFileWriter::CFileWriter() :
+	iDescription(0)
+{ }
+
+/**
+2nd stage construction.
+Connects to the file server, reserves config parameter list,
+creates config parameter objects and sets them to default values.
+*/
+void CFileWriter::ConstructL()
+    {
+	//LOG_MSG("->CFileWriter::ConstructL()\n");
+    TInt err;
+
+	_LIT(KPluginDescription, "Symbian Elf Core Dump Writer");
+	iDescription = KPluginDescription().AllocL();
+    iFs.Connect();
+    iFs.ShareAuto(); //share the session with the crash processing thread
+
+	iConfigList.ReserveL( (TInt)EDataSaveLastParam );
+
+	COptionConfig *config;
+
+	_LIT( KFilePathPrompt, "Please supply Full Core Dump Filepath (eg \"C:\\coredump.core\")" );
+	config = COptionConfig::NewL(  (TInt)ECoreFilePath,
+									KFileWriterUid,								// UID, unused
+									COptionConfig::EWriterPlugin,
+									COptionConfig::ETFileName,
+									KFilePathPrompt,
+                                    1,
+									KNullDesC,
+									0,
+									KNullDesC );
+
+	err = iConfigList.Append( config );
+    if(err != KErrNone)
+        {
+	    LOG_MSG2("CFileWriter::ConstructL - unable to append the param! err:%d\n", err);
+        delete config;
+        User::Leave(err);
+        }
+    }
+
+/**
+dtor frees config parameter list, plugin description descriptor and closes file server session.
+*/
+CFileWriter::~CFileWriter()
+    {
+    iConfigList.ResetAndDestroy();
+	delete iDescription;
+	iFs.Close();
+    }
+
+/**
+Returns a description of the plugin.
+@param aPluginDescription Output parameter that contains the plugin description.
+*/
+void CFileWriter::GetDescription( TDes & aPluginDescription )
+    {
+	aPluginDescription = *iDescription;
+    }
+
+/**
+Called by CDS to ask for the configuration parameters that the writer implements.
+@return actual number of implemented config parameters
+*/
+TInt CFileWriter::GetNumberConfigParametersL()
+	{
+	//LOG_MSG2("CFileWriter::GetNumberConfigParametersL()\n", iConfigList.Count() );
+	return iConfigList.Count();
+	}
+
+/**
+Called by CDS to ask for configuration parameter.
+@param aIndex indicates which parameter to return
+@return pointer to COptionConfig object representing the requested config parameter. Caller doesn't take ownership of the object!
+@leave KErrBadHandle if index is out of bounds
+@see COptionConfig
+*/
+COptionConfig * CFileWriter::GetConfigParameterL( const TInt aIndex )
+	{
+	// return the config identified by aIndex
+	if( ( aIndex < 0 ) || ( aIndex >= iConfigList.Count() ) )
+		{
+		User::Leave( KErrBadHandle );
+		}
+
+    return iConfigList[aIndex];
+	}
+
+/**
+Change a configuration parameter.
+@param aIndex Index of parameter to change
+@param aValue Unused
+@param aDescValue Path and filename to use
+@leave KErrBadHandle if index is out of bounds, KErrBadName if file name parameter is not a valid file name or one of the other system wide error codes
+*/
+void CFileWriter::SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue )
+    {
+	// Make the changes to our internal structures, and reflect such changes in our behaviour
+	if( ( aIndex < 0 ) || ( aIndex > iConfigList.Count() ) )
+		{
+		LOG_MSG2("CFileWriter::SetConfigParameterL - bad param request %d", aIndex );
+		User::Leave( KErrBadHandle );
+		}
+
+	COptionConfig & config = *(iConfigList[aIndex]);
+	if( aIndex == (TInt)ECoreFilePath )
+		{
+		if( iFs.IsValidName( aDescValue ) || aDescValue == KNullDesC )
+			{
+			config.ValueL( aDescValue );
+			}
+		else
+			{
+			_LIT( KInvalidFileErrorMsg ,"File Writer Error : Filepath Not Valid");
+			User::InfoPrint( KInvalidFileErrorMsg );
+			LOG_MSG(" CFileWriter::SetConfigParameterL() : ERROR  from RFs.IsValidName( )" );
+			User::Leave( KErrBadName );
+			}
+		}
+	else
+		{
+		LOG_MSG2("CFileWriter::SetConfigParameterL - invalid aIndex:%d\n", aIndex );
+		User::Leave( KErrBadHandle );
+		}
+
+	//If the descriptor is not null ensure it is a valid path
+	if(aDescValue != KNullDesC)
+		{
+		TParse parseName;
+		TInt err = parseName.Set( aDescValue, NULL, NULL );
+		if( KErrNone != err )
+			{
+			_LIT( KParseFileErrorMsg ,"File Writer Error : Could not Parse Filepath");
+			User::InfoPrint( KParseFileErrorMsg );
+			LOG_MSG(" CFileWriter::SetConfigParameterL() : ERROR  from TParse.Set( )" );
+			User::Leave( err );
+			}
+
+		TPtrC drvpath = parseName.DriveAndPath();
+		RDir rDir;
+		TInt dirErr = rDir.Open( iFs, drvpath, EFileWrite );
+		rDir.Close();
+		if( KErrNone != dirErr )
+			{
+			_LIT( KInvalidDirErrorMsg ,"File Writer Error : Directory Does Not Exist");
+			User::InfoPrint( KInvalidDirErrorMsg );
+			LOG_MSG2(" CFileWriter::SetConfigParameterL() : ERROR  from RDir.Open() returned %d", dirErr );
+			User::Leave( KErrBadName );
+			}
+		}
+
+	//This is initially the filename we intend to, and will try to use
+	iFileName = aDescValue;
+    }
+
+/**
+Called by formatter to start the creation of a dump file.
+Can be called several times to create several files.
+Note that if the file specified either in the parameter here
+or the configuration already exists, the file writer will not 
+overwrite it, and instead just append a number in brackets to 
+the stem of the filename. e.g. e:\file(1).elf if e:\file.elf
+already exists. To determine the actual name used, call GetMediaName
+
+@see GetMediaName()
+@param aFileName Formatters can supply a file name to use
+@return one of the system error codes
+@leave err one of the system wide error codes
+*/
+void CFileWriter::OpenL( const TDesC& aFileName )
+    {
+    User::LeaveIfError(Open(aFileName));
+    }
+
+/**
+Called by formatter to start the creation of a dump file.
+Can be called several times to create several files.
+Note that if the file specified either in the parameter here
+or the configuration already exists, the file writer will not 
+overwrite it, and instead just append a number in brackets to 
+the stem of the filename. e.g. e:\file(1).elf if e:\file.elf
+already exists. To determine the actual name used, call GetMediaName
+
+@see GetMediaName()
+@param aFileName Formatters can supply a file name to use
+@return one of the system error codes
+*/
+TInt CFileWriter::Open( const TDesC& aFileName )
+	{
+    if(aFileName.Length() > 0)
+        {
+		iFileName = aFileName;
+        }
+    else
+        {
+		COptionConfig & config = *(iConfigList[ (TInt)ECoreFilePath ]);
+		iFileName = config.ValueAsDesc();
+	    }
+
+	LOG_MSG2("->CFileWriter::Open([%S])\n", &TPtr8((TUint8*)iFileName.Ptr(), 2*iFileName.Length(),	2*iFileName.Length() ));
+
+	//If the file exists already, we want to preserve it, and append a (%d) to the name of the new file
+	const TUint startAppend = 1;
+	TUint currentAppend = startAppend;
+	TBuf<KMaxFileName> formatString;
+
+	_LIT(KFormatString, "(%d)");
+	_LIT(KFileBackSlash, "\\");
+
+	for(;;)
+		{
+		//If file doesn't exist, we can use this name
+		if(!BaflUtils::FileExists(iFs, iFileName))
+			break;
+
+		//otherwise, we sort out the filename
+		if(currentAppend == startAppend)
+			{
+			//first time so it needs the (%d) at the end of the name
+			TParse p;
+			p.Set(iFileName, NULL, NULL);
+
+			formatString.Append(p.Drive());
+			formatString.Append(KFileBackSlash);
+			formatString.Append(p.Name());
+			formatString.Append(KFormatString);
+			formatString.Append(p.Ext());
+			}
+
+		iFileName.Format(formatString, currentAppend);
+		++currentAppend;
+		}
+
+	return iFile.Create(iFs, iFileName, EFileWrite);
+    }
+
+/**
+This returns a reference to a descriptor containing the name
+of the file that the filewriter intends to use at any point 
+in time. Note that the filewriter will not determine what file
+to use until the last moment and so this is not gauranteed to 
+be the actual filename used until one of the Open() methods are
+called
+
+@see Open(const TDesC& aFileName)
+@see OpenL(const TDesC& aFileName)
+@return TDesC& reference to filename
+*/
+const TDesC& CFileWriter::GetMediaName()
+	{
+	return iFileName;	
+	}
+
+/**
+Called by formatter at the end of the creation of a dump.
+Open() and Close() must be paired calls
+@pre Must have called Open() or OpenL()
+@leave err one of the system wide error codes
+*/
+void CFileWriter::CloseL()
+    {
+	User::LeaveIfError(Close());
+    }
+
+/**
+Called by formatter at the end of the creation of a dump.
+Open() and Close() must be paired calls
+@return one of the system wide error codes
+*/
+TInt CFileWriter::Close()
+    {
+    TInt err = iFile.Flush();
+    //LOG_MSG2("->CFileWriter::Close() : returns:%d\n", err);
+    iFile.Close();
+	return err;
+    }
+
+/**
+Save binary aData
+
+@param aData Binary data to save
+@leave err one of the system wide error codes
+*/
+void CFileWriter::WriteL( const TDesC8& aData )
+    {
+    User::LeaveIfError(Write(aData));
+    }
+
+/**
+Save binary aData
+
+@param aData Binary data to save
+@return one of the system wide error codes
+*/
+TInt CFileWriter::Write( const TDesC8& aData )
+    {
+    TInt err = iFile.Write(aData);
+    if( KErrNone != err )
+		{
+		LOG_MSG2("CFileWriter::Write() : iFile.Write(aData) returned :%d\n", err);
+		}
+    return err;
+    }
+
+/**
+Save aSize bytes of binary data.
+
+@param aData Binary data to save
+@param aSize Number of bytes to save
+@leave err one of the system wide error codes
+*/
+void CFileWriter::WriteL( TAny* aData, TUint aSize )
+    {
+    User::LeaveIfError(Write(aData, aSize));
+    }
+
+/**
+Save aSize bytes of binary data
+
+@param aData Binary data to save
+@param aSize Number of bytes to save
+@return one of the system wide error codes
+*/
+TInt CFileWriter::Write( TAny* aData, TUint aSize )
+    {
+    //LOG_MSG2("->CFileWriter::Writer(size=%d)\n", aSize);
+    if(aData == NULL)
+		{
+		LOG_MSG2("CFileWriter::Writer(size=%d), aData == NULL\n", aSize);
+        return KErrBadHandle;
+		}
+
+    TPtrC8 data(static_cast<TUint8*>(aData), aSize);
+    return( Write(data) );
+    }
+
+/**
+Save all of aData to file. Leaves if error.
+
+@param aPos Input : Position to write to, in bytes.
+@param aData Input : Data to write to file
+@leave err one of the system wide error codes
+@see RFile
+*/
+void CFileWriter::WriteL( TInt aPos, const TDesC8& aData )
+    {
+    User::LeaveIfError(Write(aPos, aData));
+    }
+
+/**
+Save all of aData to file.
+Note that if a position beyond the end of the file is specified,
+then the write operation begins at the end of the file.
+Thus aPos must be within the file written so far. For example
+writing at position 10 when that position has no data yet will
+result in the data being written at the end of the current file.
+This is a limitation of RFile.
+
+@param aPos Input : Position to write to, in bytes.
+@param aData Input : Data to write to file
+@return Returns error from RFile::Write()
+@see RFile
+*/
+TInt CFileWriter::Write( TInt aPos, const TDesC8& aData )
+    {
+//	LOG_MSG2("  iFile.Write(aPos=%d, aData)\n", aPos );
+    TInt err = iFile.Write(aPos, aData);
+    if( KErrNone != err )
+		{
+ 		LOG_MSG3("CFileWriter::Write() : iFile.Write(aPos=%d, aData) returned :%d\n", aPos, err );
+		}
+
+    return err;
+    }
+
+/**
+Save aSize bytes of aData at file position aPos.
+Note that if a position beyond the end of the file is specified,
+then the write operation begins at the end of the file.
+Thus aPos must be within the file written so far. For example
+writing at position 10 when that position has no data yet will
+result in the data being written at the end of the current file.
+This is a limitation of RFile.
+
+@param aPos Input : Position to write to, in bytes.
+@param aData Input : Data to write to file
+@param aSize Input : Number of bytes to write
+@leave err one of the system wide error codes
+@see RFile
+*/
+void CFileWriter::WriteL( TInt aPos, TAny* aData, TUint aSize )
+    {
+    User::LeaveIfError(Write(aPos, aData, aSize));
+    }
+
+/**
+Save aSize bytes of aData at file position aPos.
+Note that if a position beyond the end of the file is specified,
+then the write operation begins at the end of the file.
+Thus aPos must be within the file written so far. For example
+writing at position 10 when that position has no data yet will
+result in the data being written at the end of the current file.
+This is a limitation of RFile.
+
+@param aPos Input : Position to write to, in bytes.
+@param aData Input : Data to write to file
+@param aSize Input : Number of bytes to write
+@return one of the system wide error codes
+@see RFile
+*/
+TInt CFileWriter::Write( TInt aPos, TAny* aData, TUint aSize )
+    {
+    if(aData == NULL)
+        {
+		LOG_MSG3("CFileWriter::Writer(pos=%d, size=%d), aData == NULL\n", aPos, aSize);
+        return KErrNoMemory;
+        }
+
+    TPtrC8 data(static_cast<TUint8*>(aData), aSize);
+    return( Write(aPos, data) );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/src/filewriterproxy.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,30 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <implementationproxy.h>
+
+#include "filewriter.h"
+
+// ECom boiler template code
+const TImplementationProxy ImplementationTable[] =
+{
+	IMPLEMENTATION_PROXY_ENTRY(0x102831e4, CFileWriter::NewL)
+};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+	return ImplementationTable;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/src/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,9 @@
+Directory for:
+  coredump\plugins\writers\file\src
+
+All the source, including subdirectories, to implement the file writer.
+Files here are not visible to others. They are just implementation.
+  
+Implements the ECOM interface in coredump\interface\writer.
+
+Implements the data save interface in coredump\interface\writer
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/test/autoexec.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,16 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/test/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,27 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file bld.inf Build information file
+//
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_TESTMMPFILES
+
+../test/filewritertestserver.mmp
+
+PRJ_TESTEXPORTS
+../test/filewritertestserver.iby	/epoc32/rom/include/filewritertestserver.iby
+../test/filewritertest.script	/epoc32/winscw/c/file_writer/filewritertest.script
+../test/autoexec.bat	/epoc32/winscw/c/autoexec.bat
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/test/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/test/filewritertest.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,33 @@
+//
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+//
+PRINT Run all Sample Tests 
+//
+LOAD_SUITE filewritertestserver -SharedData
+//
+
+#
+RUN_TEST_STEP 100 filewritertestserver FileWriterTestStep1
+RUN_TEST_STEP 100 filewritertestserver FileWriterTestStep2
+
+// Open (create) 11 files in c:\dumpfiles
+PREFIX RUN_UTILS
+MkDir c:\dumpfiles
+REMOVE_PREFIX
+
+RUN_TEST_STEP 100 filewritertestserver FileWriterTestStep3
+RUN_TEST_STEP 100 filewritertestserver FileWriterTestStep4
+RUN_TEST_STEP 100 filewritertestserver FileWriterTestStep5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/test/filewritertestserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,141 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
+// in the process of the client. The client initialises the server by calling the
+// one and only ordinal.
+//
+
+
+
+/**
+ @file filewritertestserver.cpp
+*/
+#include "filewritertestserver.h"
+#include "filewriterteststeps.h"
+
+// __EDIT_ME__ - Substitute the name of your test server 
+_LIT(KServerName,"filewritertestserver");
+// __EDIT_ME__ - Use your own server class name
+CFileWriterTestServer* CFileWriterTestServer::NewL()
+/**
+ * @return - Instance of the test server
+ * Called inside the MainL() function to create and start the
+ * CTestServer derived server.
+ */
+	{
+	// __EDIT_ME__ new your server class here
+	CFileWriterTestServer * server = new (ELeave) CFileWriterTestServer ();
+	CleanupStack::PushL(server);
+	
+	// Either use a StartL or ConstructL, the latter will permit
+	// Server Logging.
+
+	//server->StartL(KServerName); 
+	server->ConstructL(KServerName);
+	CleanupStack::Pop(server);
+	return server;
+	}
+
+// EKA2 much simpler
+// Just an E32Main and a MainL()
+LOCAL_C void MainL()
+/**
+ * Much simpler, uses the new Rendezvous() call to sync with the client
+ */
+	{
+	// Leave the hooks in for platform security
+#if (defined __DATA_CAGING__)
+	RProcess().DataCaging(RProcess::EDataCagingOn);
+	RProcess().SecureApi(RProcess::ESecureApiOn);
+#endif
+	CActiveScheduler* sched=NULL;
+	sched=new(ELeave) CActiveScheduler;
+	CActiveScheduler::Install(sched);
+	// __EDIT_ME__ Your server name
+	CFileWriterTestServer * server = NULL;
+	// Create the CTestServer derived server
+	// __EDIT_ME__ Your server name
+	TRAPD(err,server = CFileWriterTestServer::NewL());
+	if(!err)
+		{
+		// Sync with the client and enter the active scheduler
+		RProcess::Rendezvous(KErrNone);
+		sched->Start();
+		}
+	delete server;
+	delete sched;
+	}
+
+// Only a DLL on emulator for typhoon and earlier
+
+GLDEF_C TInt E32Main()
+/**
+ * @return - Standard Epoc error code on exit
+ */
+	{
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if(cleanup == NULL)
+		{
+		return KErrNoMemory;
+		}
+	TRAP_IGNORE(MainL());
+	delete cleanup;
+	return KErrNone;
+    }
+
+// Create a thread in the calling process
+// Emulator typhoon and earlier
+
+// __EDIT_ME__ - Use your own server class name
+CTestStep* CFileWriterTestServer::CreateTestStep(const TDesC& aStepName)
+/**
+ * @return - A CTestStep derived instance
+ * Implementation of CTestServer pure virtual
+ */
+	{
+	CTestStep* testStep = NULL;
+	// __EDIT_ME__ - Create your own test steps here
+	// This server creates just one step but create as many as you want
+	// They are created "just in time" when the worker thread is created
+	TInt err = KErrNone;
+
+	if(aStepName == KFileWriterTestStep1)
+		{
+		TRAP(err, testStep = new(ELeave) CFileWriterTestStep1());
+		}
+	else if(aStepName == KFileWriterTestStep2)
+		{
+		TRAP(err, testStep = new(ELeave) CFileWriterTestStep2());
+		}
+	else if(aStepName == KFileWriterTestStep3)
+		{
+		TRAP(err, testStep = new(ELeave) CFileWriterTestStep3());
+		}
+	else if(aStepName == KFileWriterTestStep4)
+		{
+		TRAP(err, testStep = new(ELeave) CFileWriterTestStep4());
+		}
+	else if(aStepName == KFileWriterTestStep5)
+		{
+		TRAP(err, testStep = new(ELeave) CFileWriterTestStep5());
+		}
+
+	if(err != KErrNone)
+		{
+		return NULL;
+		}
+	
+	return testStep;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/test/filewritertestserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,46 @@
+/**
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file filewritertestserver.h
+ @file
+ @internalTechnology
+ @released
+*/
+
+// __EDIT_ME__ Create your own class definition based on this
+#ifndef __FILE_WRITER_TEST_SERVER_H__
+#define __FILE_WRITER_TEST_SERVER_H__
+
+#include <TestExecuteServerBase.h>
+
+class CFileWriterTestServer  : public CTestServer
+	{
+public:
+	static CFileWriterTestServer* NewL();
+	virtual CTestStep* CreateTestStep(const TDesC& aStepName);
+	RFs& Fs(){return iFs;};
+
+private:
+	RFs iFs;
+	};
+
+#endif // __FILE_WRITER_TEST_SERVER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/test/filewritertestserver.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#ifndef __FILE_WRITER_TEST_SERVER_IBY__
+#define __FILE_WRITER_TEST_SERVER_IBY__
+
+#include <testexecute.iby>
+
+file=ABI_DIR\BUILD_DIR\filewritertestserver.exe		sys\bin\filewritertestserver.exe
+
+data=EPOCROOT##epoc32/winscw/c/filewriter/filewritertest.script filewritertest\filewritertest.script
+
+#endif // __FILE_WRITER_TEST_SERVER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/test/filewritertestserver.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,40 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file filewritertestserver.mmp
+// Using relative paths for sourcepath and user includes
+//
+
+TARGET      filewritertestserver.exe
+TARGETTYPE  exe
+UID 0
+VENDORID 0x70000001
+
+SOURCEPATH  ../test
+SOURCE		filewritertestserver.cpp
+SOURCE		filewriterteststeps.cpp	
+
+USERINCLUDE   ../test
+userinclude		../inc
+
+SYSTEMINCLUDE /epoc32/include
+SYSTEMINCLUDE /epoc32/include/ecom
+SYSTEMINCLUDE /epoc32/include/test
+SYSTEMINCLUDE /epoc32/include/tools/coredump
+
+LIBRARY		euser.lib
+LIBRARY		testexecuteutils.lib
+LIBRARY		efsrv.lib
+LIBRARY		testexecutelogclient.lib
+library		ecom.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/test/filewriterteststeps.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,410 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example CTestStep derived implementation
+//
+
+
+
+/**
+ @file filewriterteststeps.cpp
+*/
+
+#include "filewriterteststeps.h"
+#include <crashdatasave.h>
+
+TInt getFileWriter(CTestStep* logger, CCrashDataSave **dataSave)
+{
+	TUid dataSaveUid = { 0x102831e4 };
+	TRAPD(err, *dataSave = CCrashDataSave::NewL(dataSaveUid));
+	switch(err)
+	{
+		case KErrNoMemory:
+		logger->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (_L("KErrNoMemory\n")));
+		RDebug::Print(_L("KErrNoMemory\n"));
+		break;
+ 
+		case KErrNotFound:
+		logger->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (_L("KErrNotFound\n")));
+		RDebug::Print(_L("KErrNotFound\n"));
+		break;
+ 		
+		case KErrArgument:
+		logger->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (_L("KErrArgument\n")));
+ 		RDebug::Print(_L("KErrArgument\n"));
+ 		break;
+	
+		case KErrPermissionDenied:
+		logger->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (_L("KErrPermissionDenied\n")));
+		RDebug::Print(_L("KErrPermissionDenied\n"));
+ 		break;
+	}
+	
+	return err;
+}
+
+CFileWriterTestStep1::~CFileWriterTestStep1()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CFileWriterTestStep1::CFileWriterTestStep1()
+/**
+ * Constructor
+ */
+	{
+	// Call base class method to set up the human readable name for logging
+	SetTestStepName(KFileWriterTestStep1);
+	SetTestStepResult(EPass);
+	}
+
+TVerdict CFileWriterTestStep1::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	return TestStepResult();
+	}
+
+TVerdict CFileWriterTestStep1::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ */
+	{
+    /*
+	INFO_PRINTF1(_L("Testing GetFormattingPromptL"));
+	RBuf format;
+	CleanupClosePushL(format);
+
+	format.Create(255);
+	
+	CCrashDataSave *writer = 0;
+	testBooleanTrueL(getFileWriter(this, &writer) == KErrNone, (TText8*)__FILE__, __LINE__);
+	CleanupStack::PushL(writer);
+	INFO_PRINTF1(_L("File writer created"));
+	
+	TRAPD(err, writer->GetFormattingPromptL(format));
+	
+	testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+	
+	INFO_PRINTF1(_L("Got the format from GetFormattingPromptL"));
+	INFO_PRINTF2(_L("The format is: %S"), &format);
+	
+	_LIT(KPluginDescription, "Symbian Elf Core Dump Writer");
+	testBooleanTrue(format == KPluginDescription, (TText8*)__FILE__, __LINE__);
+	
+	CleanupStack::PopAndDestroy(writer);
+	INFO_PRINTF1(_L("File writer destroyed and popped"));
+
+	CleanupStack::PopAndDestroy();
+	
+    */
+	return TestStepResult();
+	}
+
+TVerdict CFileWriterTestStep1::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	return TestStepResult();
+	}
+
+//
+
+CFileWriterTestStep2::~CFileWriterTestStep2()
+/**
+ * Destructor
+ */
+	{
+	}
+CFileWriterTestStep2::CFileWriterTestStep2()
+/**
+ * Constructor
+ */
+	{
+	// Call base class method to set up the human readable name for logging
+	SetTestStepName(KFileWriterTestStep2);
+	SetTestStepResult(EPass);
+	}
+
+TVerdict CFileWriterTestStep2::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	return TestStepResult();
+	}
+
+TVerdict CFileWriterTestStep2::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ */
+	{
+    /*
+	INFO_PRINTF1(_L("Testing FormatL"));
+
+	CCrashDataSave *writer = 0;
+	testBooleanTrueL(getFileWriter(this, &writer) == KErrNone, (TText8*)__FILE__, __LINE__);
+	CleanupStack::PushL(writer);
+	INFO_PRINTF1(_L("File writer created"));
+	
+	_LIT(KNewFormat, "New format");
+	
+	TRAPD(err, writer->FormatL(KNewFormat));
+	INFO_PRINTF1(_L("Set new format"));
+	testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+	
+	RBuf format;
+	format.Create(255);
+	CleanupClosePushL(format);
+	
+	TRAP(err, writer->GetFormattingPromptL(format));
+	testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+	testBooleanTrue(format.Compare(KNewFormat) == 0, (TText8*)__FILE__, __LINE__);
+	
+	CleanupStack::PopAndDestroy();
+	CleanupStack::PopAndDestroy(writer);
+	
+    */
+	return TestStepResult();
+	}
+
+TVerdict CFileWriterTestStep2::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	return TestStepResult();
+	}
+//
+
+CFileWriterTestStep3::~CFileWriterTestStep3()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CFileWriterTestStep3::CFileWriterTestStep3()
+/**
+ * Constructor
+ */
+	{
+	// Call base class method to set up the human readable name for logging
+	SetTestStepName(KFileWriterTestStep3);
+	SetTestStepResult(EPass);
+	}
+
+TVerdict CFileWriterTestStep3::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	return TestStepResult();
+	}
+
+TVerdict CFileWriterTestStep3::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ */
+	{
+	INFO_PRINTF1(_L("Testing OpenL"));
+	CCrashDataSave *writer = 0;
+	testBooleanTrueL(getFileWriter(this, &writer) == KErrNone, (TText8*)__FILE__, __LINE__);
+	CleanupStack::PushL(writer);
+	INFO_PRINTF1(_L("File writer created"));
+	
+	TRAPD(err, writer->OpenL(_L("c:\\dumpfiles\\file1")));
+	INFO_PRINTF2(_L("Opened file c:\\dumpfiles\\file1 and the error code back was (should be 0): %d"), err);
+	testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+	TRAP(err, writer->CloseL());
+
+	User::After(500000);
+	INFO_PRINTF1(_L("Create 10 more files"));
+
+	for (TInt i = 0; i < 10; i++)
+	{
+		TBuf<255> filename;
+		filename.Format(_L("C:\\dumpfiles\\file%d"), i);
+		TRAP(err, writer->OpenL(filename));
+		testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+		INFO_PRINTF2(_L("Opened file %d"), i );
+
+		TRAP(err, writer->CloseL() );
+		testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+		INFO_PRINTF2(_L("Closed file %d"), i);
+	}
+	
+	CleanupStack::PopAndDestroy(writer);
+	return TestStepResult();
+	}
+
+TVerdict CFileWriterTestStep3::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	return TestStepResult();
+	}
+
+
+CFileWriterTestStep4::~CFileWriterTestStep4()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CFileWriterTestStep4::CFileWriterTestStep4()
+/**
+ * Constructor
+ */
+	{
+	// Call base class method to set up the human readable name for logging
+	SetTestStepName(KFileWriterTestStep4);
+	}
+
+TVerdict CFileWriterTestStep4::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	return TestStepResult();
+	}
+
+TVerdict CFileWriterTestStep4::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ */
+	{
+	INFO_PRINTF1(_L("Testing CloseL"));
+	CCrashDataSave *writer = 0;
+	testBooleanTrueL(getFileWriter(this, &writer) == KErrNone, (TText8*)__FILE__, __LINE__);
+	CleanupStack::PushL(writer);
+	INFO_PRINTF1(_L("File writer created"));
+	
+	
+	TRAPD(err, writer->OpenL(_L("c:\\dumpfiles\\file1")));
+	INFO_PRINTF2(_L("Opened file file 1 and the error code back was (should be 0): %d"), err);
+	testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+	
+
+	TRAP(err, writer->CloseL());
+	testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+	INFO_PRINTF1(_L("Closed file"));
+
+	CleanupStack::PopAndDestroy(writer);
+	return TestStepResult();
+	}
+
+TVerdict CFileWriterTestStep4::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	return TestStepResult();
+	}
+
+
+CFileWriterTestStep5::~CFileWriterTestStep5()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CFileWriterTestStep5::CFileWriterTestStep5()
+/**
+ * Constructor
+ */
+	{
+	// Call base class method to set up the human readable name for logging
+	SetTestStepName(KFileWriterTestStep5);
+	}
+
+TVerdict CFileWriterTestStep5::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	return TestStepResult();
+	}
+
+TVerdict CFileWriterTestStep5::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ */
+	{
+	INFO_PRINTF1(_L("Testing WriteL"));
+	CCrashDataSave *writer = 0;
+	testBooleanTrueL(getFileWriter(this, &writer) == KErrNone, (TText8*)__FILE__, __LINE__);
+	CleanupStack::PushL(writer);
+	INFO_PRINTF1(_L("File writer created"));
+
+	TRAPD(err, writer->OpenL(_L("c:\\dumpfiles\\file1") ));
+	INFO_PRINTF2(_L("Opened file file 1 and the error code back was (should be 0): %d"), err);
+	testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+
+	RBuf8 buf;
+	CleanupClosePushL(buf);
+	buf.Create(100);
+	buf = _L8("1234567890123456789012345678901234567890123456789012345678901234567890");
+	
+    TAny* ptr = static_cast<TAny*>(const_cast<TUint8*>(buf.Ptr()));
+
+	TRAP(err, writer->WriteL( 0, ptr, buf.Length()));
+	testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+	INFO_PRINTF1(_L("Wrote 70 bytes"));
+	
+	TRAP(err, writer->WriteL( 0x100, ptr, buf.Length()));
+	testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+	INFO_PRINTF1(_L("Wrote 70 bytes start at pos 100"));
+	
+	TRAP(err, writer->WriteL( -1, ptr, buf.Length()));
+	testBooleanTrue(err != KErrNone, (TText8*)__FILE__, __LINE__);
+	INFO_PRINTF2(_L("Negative test: Tried to write 70 bytes start at -1, leave code %d"), err);
+	
+	TRAP(err, writer->CloseL());
+	testBooleanTrue(err == KErrNone, (TText8*)__FILE__, __LINE__);
+	INFO_PRINTF1(_L("Closed file"));
+	
+	CleanupStack::PopAndDestroy(); // buf
+	CleanupStack::PopAndDestroy(writer);
+	return TestStepResult();
+	}
+
+TVerdict CFileWriterTestStep5::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	return TestStepResult();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/test/filewriterteststeps.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,104 @@
+/**
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file filewriterteststeps.h
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef __FILE_WRITER_TEST_STEPS_H__
+#define __FILE_WRITER_TEST_STEPS_H__
+#include <TestExecuteStepBase.h>
+#include "filewritertestserver.h"
+
+// __EDIT_ME__ - Create your own test step definitions
+class CFileWriterTestStep1 : public CTestStep
+	{
+public:
+	CFileWriterTestStep1();
+	~CFileWriterTestStep1();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepPostambleL();
+	virtual TVerdict doTestStepL();
+private:
+	};
+
+class CFileWriterTestStep2 : public CTestStep
+	{
+public:
+	CFileWriterTestStep2();
+	~CFileWriterTestStep2();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepPostambleL();
+	virtual TVerdict doTestStepL();
+private:
+
+	};
+
+
+class CFileWriterTestStep3 : public CTestStep
+	{
+public:
+	CFileWriterTestStep3( );
+	~CFileWriterTestStep3();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepPostambleL();
+	virtual TVerdict doTestStepL();
+private:
+
+	};
+
+
+class CFileWriterTestStep4 : public CTestStep
+	{
+public:
+	CFileWriterTestStep4();
+	~CFileWriterTestStep4();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepPostambleL();
+	virtual TVerdict doTestStepL();
+private:
+
+	};
+
+
+class CFileWriterTestStep5 : public CTestStep
+	{
+public:
+	CFileWriterTestStep5();
+	~CFileWriterTestStep5();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepPostambleL();
+	virtual TVerdict doTestStepL();
+private:
+
+	};
+
+
+_LIT(KFileWriterTestStep1,"FileWriterTestStep1");
+_LIT(KFileWriterTestStep2,"FileWriterTestStep2");
+_LIT(KFileWriterTestStep3,"FileWriterTestStep3");
+_LIT(KFileWriterTestStep4,"FileWriterTestStep4");
+_LIT(KFileWriterTestStep5,"FileWriterTestStep5");
+
+
+#endif // __FILE_WRITER_TEST_STEPS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/plugins/writers/file/test/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,7 @@
+Directory for:
+  coredump\plugins\writers\file\
+test files
+
+The tests at this level should be unit tests
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,151 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+//
+
+Implement Core Dump Server and ECOM plugins.
+
+
+- Component Summary
+
+-- Core Dump Server : Server that manages the connection to the Debug Security Server (DSS), 
+loading plugins and controlling the creation of core dumps. 
+
+A stub SIS file is also provided to allow installations after ROM build.
+
+Two libraries are also provided, coredumpinterface and cdssupport.
+The coredumpinterface library is a standard Symbian interface to the Core Dump Server.
+The cdssupport library contains common code used by UI clients, the server and the ECOM plugins.
+
+
+-- Plugins : ECOM plugins that implement the creation of core dumps in differen formats (formatters) 
+and the saving of core dumps to different medium/media (writers). 
+
+By default there are two formatters (Symbian ELF, D_EXC) and one writer (File Writer).
+
+-- User Interfaces : User interfaces to the Core Dump Server (CDS). 
+By default there are two: TechView GUI and core dump script.
+
+
+- External Requirements
+
+-- Debug Security Server
+The Core Dump Server uses the DSS, which is available in the MCL from M04250. 
+
+-- Target Hardware
+Since the DSS does not run on the emulator, the CDS cannot run on the emulator either. 
+It has been tested on H2 and H4 boards.
+
+
+- Components Details
+
+-- Core Dump Server 
+IBY : server\src\coredumpserver.iby
+Source : server
+
+-- Core Dump Server STUB SIS file
+IBY : server\src\coredumpserverstub.iby
+Source : server\plugins
+
+
+-- Plugins
+
+--- Symbian ELF
+
+Source : plugins/formatters/symbianelf/group/symbianelfformatter.iby
+
+IBY : plugins\formatters\symbianelf\group\symbianelfformatter.iby
+
+Symbian ELF V1 : plugins/formatters/symbianelf/src/
+Symbian ELF V2 : plugins/formatters/symbianelf/srcv2/
+
+--- D_EXC
+
+IBY : plugins\formatters\dexc\group\dexcformatter.iby
+Source : plugins\formatters\dexc
+
+--- File Writer
+IBY : plugins\writers\file\group\filewriter.iby
+Source : plugins\writers\file
+
+--- UTrace
+IBY : plugins\formatters\utrace\group\utraceformatter.iby
+Source : plugins\formatters\utrace
+
+
+-- User Interfaces
+
+--- TechView UI
+IBY : ui\coredumpui\group\coredumpui.iby
+Source : \ui\coredumpui
+
+--- Core Dump Script UI
+IBY : ui\scriptconfig\coredumpscriptconfig.iby
+Source : ui\scriptconfig
+
+
+
+- Component Build Options
+
+Each of the abovementioned components can be built separately, and thus a ROM can contain a mixture of 
+components. To obtain the default set of components without the STUB SIS file:
+ \epoc32\rom>buildrom h2 techview coredumpserver.iby symbianelfformatter.iby filewriter.iby dexcformatter.iby coredumpui.iby
+
+The STUB SIS file is required to upgrade and/or add plugins after ROM build. 
+
+Both the plugins and the server can be installed after ROM build.
+
+
+- Basic Usage
+
+-- The TechView UI 
+
+The TechView UI allows the user to:
+ . Display a list of running processes and threads and choose which ones to observe for crashes 
+ . Display a list of plugins and choose which ones to load
+ . Configure the CDS options:
+    - Core dump trigger : Hardware Exception and/or Kill Event 
+    - Actions to carry out upon crash event 
+    - Actions to carry out after core dump is complete
+
+
+-- D_EXC Output
+The D_EXC formatter will, by default, generate the same output in the same location (C: drive) as the original D_EXC tool. 
+
+
+-- Symbian ELF Output
+The Symbian ELF output is documented in 
+  plugins\formatters\symbianelf\documentation\sgl_ts0028_027_symbian_core_dump_file_format
+
+The Symbian ELF formatter will, by default, generate all the optional output. 
+By default the core dump location is the E: drive. 
+The name of the file contains an optional user supplied string, followed by the lower 32 
+bits of the crash timestamp. If the user does not supply a file name to the file writer plugin, the
+default base name of the core dump file is "core<LSW time of crash>".
+
+Version 1.01.002
+=================
+Made by Stephen Roberts (17/11/2009)
+
+1.	DPDEF142882: Updated so crash files don't overwrite old ones if configured to use the same name.
+2.	DPDEF142849: Memory Leak Found when CDS exits after processing System Crash.
+
+
+Version 1.01.001
+=================
+Made by Sakhya Ghosh (22/10/2009)
+
+1. 	Updated Core Dump Server and SELF Formatter V2 with the new RProperty Signaling mechanism. A new RProperty added to 
+notify the clients of Core Dump Server about the core dump ELF media name. 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/eabi/coredump_svru.def	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+EXPORTS
+	_ZN16CCoreDumpSession4NewLERN5Debug19RSecuritySvrSessionE @ 1 NONAME
+	_ZN16CCoreDumpSession8ServiceLERK9RMessage2 @ 2 NONAME
+	_ZN16CCoreDumpSessionC1ERN5Debug19RSecuritySvrSessionE @ 3 NONAME
+	_ZN16CCoreDumpSessionC2ERN5Debug19RSecuritySvrSessionE @ 4 NONAME
+	_ZN16CCoreDumpSessionD0Ev @ 5 NONAME
+	_ZN16CCoreDumpSessionD1Ev @ 6 NONAME
+	_ZN16CCoreDumpSessionD2Ev @ 7 NONAME
+	_ZTI13CCrashHandler @ 8 NONAME
+	_ZTI15CCoreDumpServer @ 9 NONAME
+	_ZTI15CTargetObserver @ 10 NONAME
+	_ZTI16CCoreDumpSession @ 11 NONAME
+	_ZTI16CFlashDataSource @ 12 NONAME
+	_ZTI22CServerCrashDataSource @ 13 NONAME
+	_ZTIN5Debug10TTraceDumpE @ 14 NONAME
+	_ZTIN5Debug11TConfigItemE @ 15 NONAME
+	_ZTIN5Debug11TMemoryDumpE @ 16 NONAME
+	_ZTIN5Debug11TThreadDataE @ 17 NONAME
+	_ZTIN5Debug12TCodeSegmentE @ 18 NONAME
+	_ZTIN5Debug12TProcessDataE @ 19 NONAME
+	_ZTIN5Debug12TRegisterSetE @ 20 NONAME
+	_ZTIN5Debug12TSCMLockDataE @ 21 NONAME
+	_ZTIN5Debug12TScmChecksumE @ 22 NONAME
+	_ZTIN5Debug12TThreadStackE @ 23 NONAME
+	_ZTIN5Debug14TRegisterValueE @ 24 NONAME
+	_ZTIN5Debug14TRomHeaderDataE @ 25 NONAME
+	_ZTIN5Debug15TByteStreamBaseE @ 26 NONAME
+	_ZTIN5Debug15TCodeSegmentSetE @ 27 NONAME
+	_ZTIN5Debug16SCMConfigurationE @ 28 NONAME
+	_ZTIN5Debug16TCrashInfoHeaderE @ 29 NONAME
+	_ZTIN5Debug17TByteStreamWriterE @ 30 NONAME
+	_ZTIN5Debug19TCrashOffsetsHeaderE @ 31 NONAME
+	_ZTIN5Debug20TVariantSpecificDataE @ 32 NONAME
+	_ZTIN5Debug23TCachedByteStreamWriterE @ 33 NONAME
+	_ZTIN5Debug8TRawDataE @ 34 NONAME
+	_ZTV13CCrashHandler @ 35 NONAME
+	_ZTV15CCoreDumpServer @ 36 NONAME
+	_ZTV15CTargetObserver @ 37 NONAME
+	_ZTV16CCoreDumpSession @ 38 NONAME
+	_ZTV16CFlashDataSource @ 39 NONAME
+	_ZTV22CServerCrashDataSource @ 40 NONAME
+	_ZTVN5Debug10TTraceDumpE @ 41 NONAME
+	_ZTVN5Debug11TConfigItemE @ 42 NONAME
+	_ZTVN5Debug11TMemoryDumpE @ 43 NONAME
+	_ZTVN5Debug11TThreadDataE @ 44 NONAME
+	_ZTVN5Debug12TCodeSegmentE @ 45 NONAME
+	_ZTVN5Debug12TProcessDataE @ 46 NONAME
+	_ZTVN5Debug12TRegisterSetE @ 47 NONAME
+	_ZTVN5Debug12TSCMLockDataE @ 48 NONAME
+	_ZTVN5Debug12TScmChecksumE @ 49 NONAME
+	_ZTVN5Debug12TThreadStackE @ 50 NONAME
+	_ZTVN5Debug14TRegisterValueE @ 51 NONAME
+	_ZTVN5Debug14TRomHeaderDataE @ 52 NONAME
+	_ZTVN5Debug15TByteStreamBaseE @ 53 NONAME
+	_ZTVN5Debug15TCodeSegmentSetE @ 54 NONAME
+	_ZTVN5Debug16SCMConfigurationE @ 55 NONAME
+	_ZTVN5Debug16TCrashInfoHeaderE @ 56 NONAME
+	_ZTVN5Debug17TByteStreamWriterE @ 57 NONAME
+	_ZTVN5Debug19TCrashOffsetsHeaderE @ 58 NONAME
+	_ZTVN5Debug20TVariantSpecificDataE @ 59 NONAME
+	_ZTVN5Debug23TCachedByteStreamWriterE @ 60 NONAME
+	_ZTVN5Debug8TRawDataE @ 61 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/eabi/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/inc/corecrashhandler.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,116 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef CORE_CRASH_HANDLER_H
+#define CORE_CRASH_HANDLER_H
+
+#include <e32base.h>
+#include <e32debug.h>
+#include <formatterapi.h>
+#include <debuglogging.h>
+
+class CCoreDumpSession;
+
+const TUid KUidSELFFormatterV1 = TUid::Uid(0x10282fe3);
+
+//Identifier for SELF v1
+_LIT(KSelfV1, "Symbian Elf Core Dump formatter");
+_LIT(KDexcV1, "D_EXC formatter plugin description");
+
+typedef struct GCCCrashEventInfo : TEventInfo
+{
+    TTime iEventTime; 
+} TCrashEventInfo;
+
+_LIT(KCrashProcessingThread, "core_dump_processor"); //crash processing thread name
+
+/**
+Active object class that creates the thread that handles the crash generation
+@see CCoreDumpSession
+@see CTargetObserver
+@see CCoreDumpFormatter
+*/
+class CCrashHandler : public CActive
+{
+    static TInt Processing(TAny* aParam); //crash processing thread entry point
+
+    struct TCrashThreadParams //crash processing thread params
+	    {
+	    CCoreDumpFormatter *iFormatter;
+	    TCrashInfo iCrashInfo;
+	    };
+
+    enum {EEventsQueueDefaultLength = 1};    
+
+public:
+	
+	/**
+	 * Defines the type of crash we are processing and so what DS to use
+	 */
+	enum TCrashType
+		{
+		ELiveCrash,  //!< Live Application Crash
+		ESystemCrash,//!< System Crash (ie. Flash)
+		ELast        //!< ELast
+		};
+	
+    static CCrashHandler* NewL(CCoreDumpSession &aCoreSess);
+    static CCrashHandler* NewLC(CCoreDumpSession &aCoreSess);
+    ~CCrashHandler();
+
+    TBool CrashInProgress() const {return iThreadsRun > 0 ? ETrue : EFalse;};
+    void HandleCrashEventL(const TCrashEventInfo &aEventInfo);
+    void HandleCrashFromFlashL(const TCrashInfo& aCrashInf);
+    void HandleCrashFromFlashL(const TCrashInfo& aCrashInf, const RMessage2& aMessage);
+    void CancelHandleCrashFromFlash(const TCrashInfo& aCrashInf);
+
+protected:
+   	CCrashHandler(CCoreDumpSession &aCoreSess);
+	void ConstructL();
+
+	virtual void RunL();
+	virtual void DoCancel();
+	virtual TInt RunError(TInt aError);
+
+private:
+	void ProcessCrashL(const TCrashInfo::TCrashSource& aType);
+	void ProcessLiveCrashL();
+	void ProcessSystemCrashL();
+	
+    void StartThreadL();
+    void ResetProperties(const TDesC &aProgress);
+    void PostProcessL();
+ 
+private:
+    TUint iThreadsRun; // number of running threads
+    RThread iThread; //thread processing the crash
+    RArray<TCrashEventInfo> iRemainingEvents; //copy of structures provided by target observer
+    RArray<TCrashInfo> iRemainingFlashCrashEvents;
+    RArray<TUint64> iTids;
+    TCrashThreadParams iParams;
+    CCoreDumpSession &iCoreSess;
+	TUint iCrashCount;
+	RMessagePtr2 iMessage;
+};
+
+#endif //CORE_CRASH_HANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/inc/coredumpserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,95 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+
+#ifndef CORE_DUMP_SERVER_H
+#define CORE_DUMP_SERVER_H
+
+
+// INCLUDES
+
+#include <e32cons.h>
+#include <s32file.h>
+#include <rm_debug_api.h>
+
+#include <coredumpserverapi.h>
+
+
+using namespace Debug;
+
+// CONSTANTS
+
+// Default heap size for server thread.
+const TUint KCoreDumpServerDefaultHeapSize=0x10000;
+
+// ENUMS
+
+// Server panic codes
+enum TCoreDumpServerPanic
+{
+	ESvrCreateServer,
+	ESvrStartServer,
+	ESvrFileServer,
+	EMainSchedulerError,
+	EBadRequest,
+};
+
+// CLASS DECLARATIONS
+
+
+/**
+Define core dump server class. 
+@see RCoreDumpSession
+@see RSecuritySvrSession
+*/
+class CCoreDumpServer : public CServer2
+{
+	public:
+		static CCoreDumpServer* NewLC();
+		static CCoreDumpServer* NewL();
+		static void RunServerL();
+		static void PanicServer(TCoreDumpServerPanic aPanic);	
+
+	public:
+		virtual CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage) const;
+		~CCoreDumpServer();
+
+		void SessionOpened();
+		void SessionClosed();
+		TInt RunError(TInt aError);
+
+	private:	// Construction
+		CCoreDumpServer(TInt aPriority = EPriorityHigh);
+
+    protected:
+		void ConstructL();
+
+	private:	// Data members
+
+		TInt	iNumSessions;
+
+	RSecuritySvrSession	iSecSess;
+};
+
+#endif	// CORE_DUMP_SERVER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/inc/coredumpsession.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,284 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef CORE_DUMP_SESSION_H
+#define CORE_DUMP_SESSION_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <s32file.h>
+#include <e32property.h>
+#include <bsul\inifile.h>
+#include <scmdatatypes.h>
+
+#include <rm_debug_api.h>
+
+// Project inclues
+#include <crashdata.h>
+#include "coredumpserver.h"
+#include <coredumpserverapi.h>
+#include <optionconfig.h>
+#include <crashdatasave.h>
+#include "servercrashdatasource.h"
+#include "flashdatasource.h"
+#include "coretargetobserver.h"
+
+using namespace Debug;
+using namespace BSUL;
+
+        enum TPreProcessingActionType {ENoPreAction = 0, ESuspendThread = 0x1, ESuspendProcess = 0x2};
+        enum TPostProcessingActionType {ENoPostAction = 0, EResumeThread = 0x1, EResumeProcess = 0x2, EKillProcess = 0x4, EDeleteCrashLog = 0x5};
+
+/**
+Core dump server session that handles messages from core dump clients.
+@see CCoreDumpServer
+@see RCoreDumpSession
+*/
+class CCoreDumpSession : public CSession2
+	{	
+	public:		// Construction
+		IMPORT_C static CCoreDumpSession* NewL( RSecuritySvrSession &aSecSess );
+
+	public:		// Destruction
+		IMPORT_C ~CCoreDumpSession();
+		
+	public:		// CCoreDumpSession
+		IMPORT_C virtual void ServiceL (const RMessage2& aMessage);
+
+	private:
+		CCoreDumpSession( RSecuritySvrSession &aSecSess );
+
+    protected:
+		void ConstructL();
+		
+	private:	// CCoreDumpSession
+		void PanicClient(const RMessage2& aMessage, TInt aPanic);
+		void DispatchMessageL(const RMessage2& aMessage);
+
+		HBufC8 * MarshalListL( TListRequest & req, TAny * list );
+		void GetListL( const RMessage2& aMessage );
+		void ListInfoL( const RMessage2& aMessage );
+
+        //make sure that those calls leave
+		void GetPluginListL(const RMessage2& aMessage);
+		void PluginRequestL(const RMessage2& aMessage);
+
+	//	TInt StartDebugSessionL(const RMessage2& aMessage);
+
+		void RefreshPluginListL();
+
+        void ObservationRequestL( const RMessage2 &aMessage );
+        void AttachTargetL( const TDesC &aTargetName, const TDesC &aTargetOwnerName );
+        void DetachTargetL( const TDesC &aTargetName, const TDesC &aTargetOwnerName );
+
+		TInt GetByPId( const TUint aPid );
+
+		void CreateFormatterL( const TUid loadRequestUid );
+		void CreateWriterL( const TUid loadRequestUid );
+        void DeleteFormatterL( const TUid freeRequestUid, const TUint index );
+        void DeleteWriterL( const TUid freeRequestUid, const TUint index );
+
+        void BindPluginsL(const TUint aIndex, TUint aPair);
+		void SetPluginsL( const TUid aFormatterUID, 
+							const TUid aWriterUID, 
+							const TBool aLoad );
+
+		void GetNumberConfigParametersL( const RMessage2& aMessage );
+		void GetConfigParameterL( const RMessage2& aMessage );
+		void SetConfigParameterL( const RMessage2& aMessage );
+		void SetConfigParameterL( const TInt aIndex, 
+								 const TInt32 & aValue, 
+								 const TDesC & aDescValue );
+
+		void UpdateConfigParametersL( );
+
+
+		void LoadConfigFileL( const RMessage2* aMessage = NULL );
+		void SaveConfigFileL( const RMessage2* aMessage = NULL );
+
+		
+		enum TCoreDumpIniKey
+			{
+			EIniKeyType,
+			EIniKeyIndex,
+			EIniKeyValue
+			};
+
+		HBufC * GenerateKeyStringLC( TUint aIndex, 
+									 TCoreDumpIniKey aKey );
+
+		void RecreateConfigurationL( BSUL::CIniDocument16 * aPersistConfigData );
+
+		void ChangeConfigParamsL( const COptionConfig::TParameterSource aSource,
+								  BSUL::CIniDocument16	*	aPersistConfigData,
+                                  const TInt aIndex = -1);
+
+		void SaveConfigParamL(  const COptionConfig	 *	aParam, 
+								const TPtrC			 &	aSectName,
+								const TInt				aSaveIndex,
+								BSUL::CIniDocument16 *	aPersistConfigData );
+
+		void OpenIniFileLC( const RMessage2		  *	aMessage, 
+							const TBool				aSaving,
+							RFs					  & aFsSession,
+							HBufC				 *&	aFileName,
+							BSUL::CIniDocument16 *&	aPersistConfigData );
+
+		void OpenIniFileLC( const TBool				aSaving,
+							RFs					  & aFsSession,
+							HBufC				 *&	aFileName,
+							BSUL::CIniDocument16 *&	aPersistConfigData );
+
+		void ReadPluginUidFilesL( );
+		
+//		void ReadSCMConfigListL();
+//		void WriteSCMConfigListL();
+		//void UpdateSCMConfigParameterL( TConfigItem::TSCMDataType aDataType, const TInt32 & aPriority );
+		
+		void ValidatePluginL( const TUid aPluginUid ) const;
+        void SetCrashEventsL(CTargetObserver &aObserver, TKernelEventAction aAction);
+        
+        void RefreshCrashListFromFlashL();
+        void GetCrashInfoL(TInt aCrashId, TCrashInfo& aCrashInfo);
+        void DeleteCrashLogL(const RMessage2& aMessage);
+        void DeleteCrashPartitionL();
+        void ProcessCrashLogL(const RMessage2& aMessage);
+        void ProcessCrashLogAsyncL(const RMessage2& aMessage);
+        void CancelProcessCrashLogAsync(const RMessage2& aMessage);
+        void UpdateProgressL(const TDesC &aProgress) const;
+
+    public:
+        CCrashDataSource* DataSource() const {return iDataSource;};
+        CFlashDataSource* FlashDataSource() const {return iFlashDataSource;};
+        CCoreDumpFormatter* GetValidFormatter(const TUint aCount);
+        TInt32 PreProcessingAction() const;
+        TInt32 PostProcessingAction() const;
+        void SuspendProcessL(TUint64 aPid);
+        void KillProcessL(TUint64 aPid);
+        void ResumeProcessL(TUint64 aPid);
+        void ResumeThreadL(TUint64 aTid);
+        CCoreDumpServer& Server() const;
+        virtual void CreateL();
+
+	private:	// Data members
+        RSecuritySvrSession &iSecSess;
+		
+		TUint					iKeyEvent;
+		
+        /** keeps list of ECOM plugin types */
+		RPluginList				iPluginList;
+
+		TUint					iTotalThreadListDescSize;
+		RThreadPointerList      iThreadPointerList; 
+		HBufC8*					iMarshalledThreadList;
+        
+		TUint					iTotalProcessListDescSize;
+		RProcessPointerList		iProcessPointerList;
+		HBufC8*					iMarshalledProcessList;
+
+		TUint					iTotalExecutableListDescSize;
+		RExecutablePointerList	iExecutablePointerList;
+		HBufC8*					iMarshalledExecutableList;
+		
+		//this stores the crashes that are in the flash partition
+		TUint					iTotalCrashInfoDescSize;
+		RCrashInfoPointerList	iCrashList;
+		HBufC8*					iMarshalledCrashList;
+		
+        typedef RPointerArray<CCoreDumpFormatter> RFormatterPointerList;
+        
+        /** list of formatter plugin instances */
+		RFormatterPointerList	iFormatterPlugins;
+		
+        /** list of formatter plugin info objects coresponding to actual instances*/
+        RPluginPointerList      iFormatterInfos;
+		HBufC8*					iMarshalledFormatterList;
+		TUint					iTotalFormatterListDescSize;
+
+        typedef RPointerArray<CCrashDataSave> RWriterPointerList;
+        
+        /** list of writer plugin instances */
+		RWriterPointerList		iWriterPlugins;
+		
+        /** list of writer plugin info objects coresponding to actual instances*/
+        RPluginPointerList      iWriterInfos;
+		HBufC8*					iMarshalledWriterList;
+		TUint					iTotalWriterListDescSize;
+
+		CServerCrashDataSource* iDataSource;
+		CFlashDataSource* iFlashDataSource;
+        CCrashHandler*			iCrashHandler;
+
+        enum TCrashEventTypes 
+			{
+			ECrashHwExc = 0x1, 
+			ECrashKillThread = 0x2, 
+			ECrashHwExcAndKillThread = 0x3
+			};
+
+		typedef RPointerArray<CTargetObserver>		RObservationList;
+		
+		RObservationList iObservationList;
+
+    private:
+        TInt32 iPreCrashEventAction;
+        TInt32 iPostCrashEventAction;
+        TInt32 iCrashEventTypes;
+
+
+		// Configuration parameters for current system. It is the collection
+		// of config params from CDS and currently loaded plugins
+		typedef RPointerArray<COptionConfig>	RConfigParameterList;
+		RConfigParameterList	  iTotalConfigList; //no need to destroy the content
+
+		/** The maximum size of the configuration parameter that was found 
+		when the entire list iTotalConfigList was last updated. It is useful
+		when allocating descriptor for client/server transfer */
+		TInt					iMaxConfigParamSize;
+
+		/** Configuration parameters for CDS. */
+		RConfigParameterList     iConfigList;
+		
+		/** configuration parameters for SCM configuration */
+		RConfigParameterList	 iScmConfigList;
+		
+		
+
+		TUid					iOurSecureID;
+		RArray<TUid>			iAllowedPlugins;
+
+		TUint32					iSpare0;
+		TUint32					iSpare1;
+		TUint32					iSpare2;
+		TUint32					iSpare3;
+		TUint32					iSpare4;
+		TUint32					iSpare5;
+		
+    private:
+    	void PrintScmConfigL();
+    	
+    	static void CleanupSCMConfiguration(TAny* );
+};
+
+#endif	// CORE_DUMP_SESSION_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/inc/coretargetobserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,75 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+
+#ifndef CORE_TARGET_OBSERVER_H
+#define CORE_TARGET_OBSERVER_H
+
+#include <e32base.h>
+#include <e32debug.h>
+#include <rm_debug_api.h> //RSecuritySvrSession
+#include "corecrashhandler.h"
+
+using namespace Debug;
+
+/** 
+Class that tracks the observation of targets, bot processes and threads within
+@internalComponent
+*/
+class CTargetObserver : public CActive
+{
+public:
+    static CTargetObserver* NewL(RSecuritySvrSession &aSession, CCrashHandler &aHandler, const TDesC& aProcessName);
+    static CTargetObserver* NewLC(RSecuritySvrSession &aSession, CCrashHandler &aHandler, const TDesC& aProcessName);
+    ~CTargetObserver();
+
+	void Observe();
+    void SetCrashEventL(TEventType aType, TKernelEventAction aAction);
+
+    const TDesC& TargetName() const;
+
+    TInt ThreadCount() const;
+    void AddThreadL(const TDesC &aThreadName);
+    void DelThreadL(const TDesC &aThreadName);
+    void ClearThreads();
+    TBool HasThread(const TDesC &aThreadName) const;
+    const TDesC& Thread(TInt aIndex) const;
+
+protected:
+   	CTargetObserver(RSecuritySvrSession &aSession, CCrashHandler &iHandler);
+	void ConstructL(const TDesC& aProcessName);
+
+	virtual void RunL();
+	virtual void DoCancel();
+	virtual TInt RunError(TInt aError);
+ 
+private:
+    RSecuritySvrSession &iSecSess; 
+    CCrashHandler &iHandler; 
+    RBuf iTargetName; //process name
+    RPointerArray<HBufC> iThreadList; //threads name array 
+    TCrashEventInfo iCrashEventInfo; //crash event info struct
+    TTime iEventTime; //crash event time
+    TPtr8 iEventInfoPtr; //descriptor wrapper for crash event info
+};
+#endif //CORE_TARGET_OBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/inc/flashdatasource.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,280 @@
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef FLASH_CRASH_DATA_SOURCE_H
+#define FLASH_CRASH_DATA_SOURCE_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <rm_debug_api.h>
+#include <scmconfig.h>
+#include <scmdatatypes.h>
+#include <crashdatasource.h>
+#include <crashlogwalker.h>
+#include <optionconfig.h>
+
+using namespace Debug;
+
+const TInt KMaxBufferSize = 5000; //max size we will store in the buffer reading from crash flash
+const TInt KInitialBufferSize = 0; //Size with which we shall initialise buffer
+
+const TVersion KFlashCrashDataSourceVersion(1,2,0);
+
+/**
+ * Implementation of the CCrashDataSource interface by the core dump server, which is used by
+ * formatters to gather crash data. The data is obtained from the flash partition via the Debug Security
+ * Server.
+ * @see CCrashDataSource
+ *
+ */
+class CFlashDataSource : public CCrashDataSource
+	{
+	public:
+	    static CFlashDataSource *NewL(RSecuritySvrSession &aSource);
+		virtual ~CFlashDataSource();
+		Debug::SCMConfiguration& SCMConfiguration();
+		TInt ReadCrashLog(const TInt aPos, const TUint aSize);
+
+		static const TInt READ_SIZE = 0x6000; // Can be Tuned
+
+	protected:
+		virtual void ConstructL();
+
+	private:
+		CFlashDataSource(RSecuritySvrSession &aSource);
+
+	public:
+		//Inherited from CCrashDataSource
+
+		/**
+		 * @see CCrashDataSource::GetRegisterListL
+		 */
+		virtual void GetRegisterListL( RRegisterList &aRegisterList );
+
+		/**
+		 * @see CCrashDataSource::ReadRegistersL
+		 */
+		virtual void ReadRegistersL( const TUint64 aThreadId, RRegisterList &aRegisterList );
+
+		/**
+		 * @see CCrashDataSource::ReadMemoryL
+		 */
+		virtual void ReadMemoryL(const TUint64 aThreadId,
+	                   			const TUint32 aAddress,
+	                   			const TUint32 aLength,
+	                   			TDes8& aData );
+
+		/**
+		 * @see CCrashDataSource::GetProcessListL
+		 */
+		virtual void GetProcessListL(	RProcessPointerList & aData,
+										TUint & aTotalProcessListDescSize );
+
+		/**
+		 * @see CCrashDataSource::GetExecutableListL
+		 */
+		virtual void GetExecutableListL(	RExecutablePointerList & aData,
+										TUint & aTotalExecutableListDescSize );
+
+		/**
+		 * @see CCrashDataSource::GetThreadListL
+		 */
+		virtual void GetThreadListL(	const TUint64 aProcessId,
+										RThreadPointerList & aThreadList,
+										TUint & aTotalThreadListDescSize );
+
+		/**
+		 * @see CCrashDataSource::GetCodeSegmentsL
+		 */
+	    virtual void GetCodeSegmentsL(const TUint64 aTid, RCodeSegPointerList &aCodeSegs, TUint &aTotalCodeSegListDescSize);
+
+		/**
+		 * @see CCrashDataSource::GetCodeSegmentsFromPIDL
+		 */
+	    void GetCodeSegmentsFromPIDL( const TUint64 aPid, RCodeSegPointerList &aCodeSegList, TUint & aTotalCodeSegListDescSize );
+
+	    /**
+		 * @see CCrashDataSource::GetAvailableTraceSizeL
+		 */
+	    virtual TUint GetAvailableTraceSizeL();
+
+		/**
+		 * @see CCrashDataSource::ReadTraceBufferL
+		 */
+	    virtual void ReadTraceBufferL(TDes8 &aTraceData, TUint aPos = 0);
+
+		/**
+		 * @see CCrashDataSource::GetLocksL
+		 */
+		virtual void GetLocksL(TSCMLockData& aLockData);
+
+		/**
+		 * @see CCrashDataSource::GetROMBuildInfoL
+		 */
+		virtual void GetROMBuildInfoL(TRomHeaderData& aRomHeader);
+
+		/**
+		 * @see CCrashDataSource::GetExceptionStackSizeL
+		 */
+		virtual TUint GetExceptionStackSizeL(const Debug::TArmProcessorModes aMode);
+
+		/**
+		 * @see CCrashDataSource::GetExceptionStackL
+		 */
+		virtual void GetExceptionStackL(const Debug::TArmProcessorModes aMode, TDes8& aStack, TUint aStartReadPoint);
+
+		/**
+		 * @see CCrashDataSource::GetVersion
+		 */
+		virtual TVersion GetVersion() const;
+
+		/**
+		 * @see CCrashDataSource::GetDataSourceFunctionalityBufSize
+		 */
+		virtual TInt GetDataSourceFunctionalityBufSize(TUint& aBufSize);
+
+		/**
+		 * @see CCrashDataSource::GetDataSourceFunctionality
+		 */
+		virtual TInt GetDataSourceFunctionality(TDes8& aFuncBuffer);
+
+		/**
+		 * @see CCrashDataSource::GetVariantSpecificDataSizeL
+		 */
+		virtual TInt GetVariantSpecificDataSize(TUint& aDataSize);
+
+		/**
+		 * @see CCrashDataSource::GetVariantSepcificDataL
+		 */
+		virtual TInt GetVariantSpecificData(TDes8 &aVarSpecData);
+
+	public:
+
+		TInt ProcessCrashHeaderL(TInt aCrashStart);
+		void AnalyseCrashL(TInt aCrashStart);
+
+		void CalculateChecksumL(TInt aStart, TInt aLength, TScmChecksum& aChecksum);
+
+	    TInt GetCrashLogSize() const {return iHdr.iLogSize;}
+	    TInt GetFlashAlignment() const {return iHdr.iFlashAlign;}
+	    TInt GetFlashBlockSize() const {return iHdr.iFlashBlockSize;}
+	    TInt GetFlashPartitionSize() const {return iHdr.iFlashPartitionSize;}
+	    TThreadId GetCrashedThreadId() const {return iHdr.iTid;}
+
+	    void AssignOwner(TInt64 aOwningProcessId, TInt64 aThreadId);
+	    inline TDes8& GetFlashBuffer(){return iFlashBuf; }
+	    TInt GetCrashStartFromCrashIDL(TInt aCrashId);
+
+	    Debug::SCMConfiguration* GetSCMConfigFromFlashL();
+	    void ReadSCMConfigL(RConfigParameterList& aScmConfigList);
+
+	    void ModifySCMConfigItemL(TUint32 aDataType, TInt32 aPriority);
+	    void WriteSCMConfigL();
+	    void PrintFlashBuf();
+	    void ReleaseFirstBlockBuf();
+
+		inline const TRmdArmExcInfo& GetCrashContext() const {return  iWalker.GetCrashContext();};
+		inline const TCrashInfoHeader& GetCrashHeader() const {return  iWalker.GetCrashHeader();};
+		inline const TCrashOffsetsHeader& GetOffsetsHeader() const {return  iWalker.GetOffsetsHeader();};
+
+	private:
+
+	    void SetRegValuesL(	const TUint64 aThreadId, RRegisterList & aRegisterList );
+		void HelpReadRegistersL(TInt aRegStartPoint, TInt aMaxReadPointconst, TUint64 aThreadId, RRegisterList& aRegList);
+		void ConvertFlashFormatRegL(TRegisterData& aData, const TRegisterValue& aOriginalVal);
+		void ReadRawFlashL(TDes8& aDestinationBuffer, TUint aReadPos, TUint aReadSize);
+	    void HelpAnalyseCrashL(const MByteStreamSerializable* aData, TInt aStructId, TInt aPosFound);
+	    TUint64 GetThreadOwnerL(TUint64 aThreadId);
+	    TInt ReallocFlashBuf(const TUint aSize);
+
+	private:
+
+		/** Session to the debug security server */
+	    RSecuritySvrSession	&iSecSess;
+
+	    /** This buffer contains a given amount of a data from the crash log at any one time */
+	    RBuf8 iFlashBuf;
+
+	    /** Tells us if the header is present */
+	    TBool iOffsetsPresent;
+
+	    /** This stores the crash offsets log header (if available)*/
+	    TCrashOffsetsHeader iOffsetsHdr;
+
+	    /** Stores the core crash header */
+	    TCrashInfoHeader iHdr;
+
+	    /** These are structs we wish to cache */
+	    TCodeSegmentSet* iCurrentCodeSegSet;
+	    TSCMLockData* iLockData;
+	    TRomHeaderData* iRomBuildInfo;
+	    TTraceDump* iTraceDump;
+		TVariantSpecificData* iVarSpecData;
+
+	    /** This struct contains the offset in the flash for a given object (thread/process)  */
+	    struct TObjectLocation
+		    {
+		    TInt64 iObjectId;
+		    TInt32 iOffset;
+		    };
+
+	    //This is an array of all the memory we have dumped in a given crash
+	    RArray<TObjectLocation> iCrashMemoryMap;
+
+	    //This array stores the code segments we have stored
+	    RArray<TObjectLocation> iCodeSegMap;
+
+	    TCrashLogWalker iWalker;
+
+	    TInt iHeaderStart;
+
+	    struct TChildOwnerPair
+	    	{
+	    	TUint64 iOwnerId;
+	    	TUint64 iChildId;
+
+	    	TChildOwnerPair(TUint64 aOwner, TUint64 aChild)
+	    		{
+	    		iOwnerId = aOwner;
+	    		iChildId = aChild;
+	    		}
+	    	};
+
+	    RArray<TChildOwnerPair> iThreadOwners;
+
+	    /** Boolean to mark if we have processed the crash header or not */
+	    TBool iHdrProcd;
+
+	    /** Scm checksum calculator */
+	    TScmChecksum iScmCheckSum;
+
+	    Debug::SCMConfiguration* iScmConfig;
+
+	    RBuf8	iFirstBlockBuf;
+	    TBool iCrashFound;
+
+	public:
+		static void CleanupCodeSegList(TAny *aArray);
+		static void CleanupProcessList(TAny *aArray);
+		static void CleanupThreadList(TAny *aArray);
+
+	};
+
+#endif // FLASH_CRASH_DATA_SOURCE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/inc/servercrashdatasource.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,194 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef SERVER_CRASH_DATA_SOURCE_H
+#define SERVER_CRASH_DATA_SOURCE_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <rm_debug_api.h>
+#include <crashdatasource.h>
+
+using namespace Debug;
+
+const TVersion KServerCrashDataSourceVersion(2,1,0);
+
+/**
+Implementation of the CCrashDataSource interface by the core dump server, which is used by
+formatters to gather crash data. The data is obtained from the Debug Security Server.
+@see CCrashDataSource
+
+*/
+class CServerCrashDataSource : public CCrashDataSource
+{
+public:
+    static CServerCrashDataSource *NewL(RSecuritySvrSession &aSource);
+	virtual ~CServerCrashDataSource();
+
+protected:
+	virtual void ConstructL();
+
+private:
+    CServerCrashDataSource(RSecuritySvrSession &aSource);
+
+public:
+
+	/**
+	See CCrashDataSource::GetRegisterListL()
+	*/
+	virtual void GetRegisterListL( RRegisterList &aRegisterList );//const
+
+	/**
+	See CCrashDataSource::ReadRegistersL()
+	*/
+	virtual void ReadRegistersL( const TUint64 aThreadId, RRegisterList &aRegisterList );
+
+	/**
+	See CCrashDataSource::ReadMemoryL()
+	*/
+	virtual void ReadMemoryL(
+                   const TUint64    aThreadId,
+                   const TUint32    aAddress,
+                   const TUint32    aLength,
+                   TDes8          & aData );
+
+	/**
+	See CCrashDataSource::GetProcessListL()
+	*/
+	virtual void GetProcessListL(	RProcessPointerList & aData,
+									TUint & aTotalProcessListDescSize );
+
+	/**
+	See CCrashDataSource::GetExecutableListL()
+	*/
+	virtual void GetExecutableListL(	RExecutablePointerList & aData,
+									TUint & aTotalExecutableListDescSize );
+
+	/**
+	See CCrashDataSource::GetThreadListL()
+	*/
+	virtual void GetThreadListL(	const TUint64 aProcessId,
+									RThreadPointerList & aThreadList,
+									TUint & aTotalThreadListDescSize );
+
+	/**
+	See CCrashDataSource::GetCodeSegmentsL()
+	*/
+    virtual void GetCodeSegmentsL(const TUint64 aTid, RCodeSegPointerList &aCodeSegs, TUint &aTotalCodeSegListDescSize);
+
+    /**
+	 * @see CCrashDataSource::ReadTraceBufferL
+     */
+    virtual void ReadTraceBufferL(TDes8 &aTraceData, TUint aPos = 0);
+
+    /**
+	 * @see CCrashDataSource::GetAvailableTraceSizeL
+	 */
+    virtual TUint GetAvailableTraceSizeL();
+
+	/**
+	 * @see CCrashDataSource::GetLocksL
+	 */
+	virtual void GetLocksL(TSCMLockData& aLockData);
+
+	/**
+	 * @see CCrashDataSource::GetROMBuildInfoL
+	 */
+	virtual void GetROMBuildInfoL(TRomHeaderData& aRomHeader);
+
+	/**
+	 * @see CCrashDataSource::GetExceptionStackSizeL
+	 */
+	virtual TUint GetExceptionStackSizeL(const Debug::TArmProcessorModes aMode);
+
+	/**
+	 * @see CCrashDataSource::GetExceptionStackL
+	 */
+	virtual void GetExceptionStackL(const Debug::TArmProcessorModes aMode, TDes8& aStack, TUint aStartReadPoint);
+
+	/**
+	 * @see CCrashDataSource::GetVersion
+	 */
+	virtual TVersion GetVersion() const;
+
+	/**
+	 * @see CCrashDataSource::GetDataSourceFunctionalityBufSize
+	 */
+	virtual TInt GetDataSourceFunctionalityBufSize(TUint& aBufSize);
+
+	/**
+	 * @see CCrashDataSource::GetDataSourceFunctionality
+	 */
+	virtual TInt GetDataSourceFunctionality(TDes8& aFuncBuffer);
+
+	/**
+	 * @see CCrashDataSource::GetVariantSpecificDataSizeL
+	 */
+	virtual TInt GetVariantSpecificDataSize(TUint& aDataSize);
+
+	/**
+	 * @see CCrashDataSource::GetVariantSepcificDataL
+	 */
+	virtual TInt GetVariantSpecificData(TDes8 &aVarSpecData);
+
+private:
+    void SetRegValuesL(	const TUint64 aThreadId, RRegisterList & aRegisterList );
+
+	void PrintRegs( RRegisterList  &	aRegisterList );
+
+	enum TListLevel
+		{
+		EListGlobal,
+		EListThread,
+		EListProcess
+		};
+
+	void DoGetListL( const TListId aListId,
+				    const TThreadId aThreadId,
+					const TProcessId aProcessId,
+					RBuf8 & aBuffer,
+					TUint32 & aSize );
+
+	TTagHeader * GetDebugHeader( const TTagHeaderId aTagHdrId, const TDesC8 &aDFBlock );
+	TTag* GetTag(const TTagHeader* aTagHdr, const TInt aElement);
+
+private:
+    RSecuritySvrSession	&iSecSess;
+
+	RRegisterList iRegisterList;
+	RBuf8 iThreadListBuffer;
+	RBuf8 iProcListBuffer;
+	RBuf8 iExecutableListBuffer;
+
+	TUint32 iLastThreadListSize;
+	TUint32 iLastProcListSize;
+	TUint32 iLastExecutableListSize;
+	TUint32 iLastRegListSize;
+	TUint32 iMaxMemReadSize;
+
+	TUint32 iSpare0;
+	TUint32 iSpare1;
+	TUint32 iSpare2;
+	TUint32 iSpare3;
+
+};
+
+#endif // TEST_CRASH_DATA_SOURCE_H
Binary file dbgsrv/coredumpserver/server/plugins/coredumpserverstub.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/plugins/coredumpserverstub.pkg	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+; List of languages supported
+&EN
+; List of localised vendor names
+%{"Symbian Software Ltd."}
+; Single, non-localised (global) vendor name
+:"Symbian Software Ltd."
+; Installation header.
+#{"Core Dump Server Stub SIS"},(0x2000B26E),1,0,0
+;
+"" - "z:\sys\bin\coredump_svr.exe"
+"" - "z:\private\10282FE5\additionalPluginList.plugin"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/plugins/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/plugins/pluginList1.plugin	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,5 @@
+10282FE3
+102831E4
+102832C5
+102836BA
+102836BB
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/corecrashhandler.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,497 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#include "corecrashhandler.h"
+#include "coredumpsession.h"
+
+CCrashHandler::CCrashHandler(CCoreDumpSession &aCoreSess)
+    : CActive(CActive::EPriorityStandard),
+    iThreadsRun(0),
+    iCoreSess(aCoreSess)
+	{
+	CActiveScheduler::Add(this); 
+	}
+
+CCrashHandler* CCrashHandler::NewL(CCoreDumpSession &aCoreSess)
+{
+    //LOG_MSG("->CCrashHandler::NewL()");
+	CCrashHandler* self = CCrashHandler::NewLC(aCoreSess);;
+	CleanupStack::Pop(self);
+    return self;
+}
+
+CCrashHandler* CCrashHandler::NewLC(CCoreDumpSession &aCoreSess) 
+	{
+    //LOG_MSG("->CCrashHandler::NewLC()");
+	CCrashHandler *self = new (ELeave) CCrashHandler(aCoreSess);;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+void CCrashHandler::ConstructL()
+	{
+    //LOG_MSG("->CCrashHandler::ConstructL()");
+	iCrashCount = 0;
+    iRemainingEvents.ReserveL(EEventsQueueDefaultLength); 
+	}
+
+CCrashHandler::~CCrashHandler()
+	{
+    //LOG_MSG("->CCrashHandler::~CCrashHandler()");
+	Cancel();
+    iRemainingEvents.Reset();
+    iRemainingFlashCrashEvents.Reset();
+    iTids.Reset();
+	LOG_MSG("<-CCrashHandler::~CCrashHandler()");
+	}
+
+void CCrashHandler::DoCancel()
+	{
+	LOG_MSG("CCrashHandler::DoCancel()");
+    iThread.LogonCancel(iStatus);
+    iThread.Close();
+	}
+
+void CCrashHandler::ResetProperties(const TDesC &aProgress)
+{
+    LOG_MSG("->CCrashHandler::DefaultProperties\n");
+    //restore properties to default values
+    TInt err = RProperty::Set(KCoreDumpServUid, ECrashProgress, aProgress);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CCrashHandler::DefaultProperties - unable to reset 'crash progress'! err:%d\n", err);
+        }
+    err = RProperty::Set(KCoreDumpServUid, ECancelCrash, EFalse);  
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CCrashHandler::DefaultProperties - unable to reset 'cancel crash'! err:%d\n", err);
+        }
+
+    err = RProperty::Set(KCoreDumpServUid, ECrashCount, iCrashCount);  
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CCrashHandler::DefaultProperties - unable to reset 'crash count'! err:%d\n", err);
+        }
+}
+
+void CCrashHandler::PostProcessL()
+{
+    TInt32 action = iCoreSess.PostProcessingAction();
+    LOG_MSG2("->CCrashHandler::PostProcessL - action:%d", action);
+    switch(action)
+        {
+        case ENoPostAction:
+        	{
+            //no action
+            break;
+        	}
+        case EResumeThread:
+            {            
+            if(iParams.iCrashInfo.iCrashSource == TCrashInfo::ELiveCrash)
+            	{
+	            LOG_MSG2("CCrashHandler::PostProcessL() - resuming crashed thread:%Ld\n", iParams.iCrashInfo.iTid);
+	            iCoreSess.ResumeThreadL(iParams.iCrashInfo.iTid);
+            	}
+            break;
+            }
+
+        case EResumeProcess:
+            {
+            if(iParams.iCrashInfo.iCrashSource == TCrashInfo::ELiveCrash)
+            	{            
+	            LOG_MSG2("CCrashHandler::PostProcessL() - resuming crashed process:%Ld\n", iParams.iCrashInfo.iPid);
+	            iCoreSess.ResumeProcessL(iParams.iCrashInfo.iPid);
+            	}
+            break;
+            }
+
+        case EKillProcess:
+            {       
+            if(iParams.iCrashInfo.iCrashSource == TCrashInfo::ELiveCrash)
+            	{
+				LOG_MSG2("CCrashHandler::PostProcessL() - killing crashed process:%Ld\n", iParams.iCrashInfo.iPid);
+	            iCoreSess.KillProcessL(iParams.iCrashInfo.iPid);
+            	}
+            
+            break;
+            }
+        case EDeleteCrashLog:
+	        {
+            if(iParams.iCrashInfo.iCrashSource == TCrashInfo::ESystemCrash)
+            	{	        
+            	LOG_MSG2("CCrashHandler::PostProcessL() - deleting crashed process:%Ld\n", iParams.iCrashInfo.iPid);
+            	}
+            
+            break;
+	        }
+        default:
+        	{
+            LOG_MSG("CCrashHandler::PostProcessL() - unknown action!\n");
+            User::Leave(KErrArgument);
+        	}
+        }
+}
+/**
+ RunL() completes a previously issued ProcessCrashL call and 
+ carry out user specified post processing actions. We trap the calls to 
+ resume the thread, resume the process and kill the process since the thread
+ or process may no longer be alive, and we would leave without finishing the
+ core dump. 
+ */
+void CCrashHandler::RunL()
+	{
+    LOG_MSG2("->CCrashHandler::RunL(status:%d)", iStatus.Int());
+
+    if(CrashInProgress())
+    {
+        LOG_MSG2("CCrashHandler::RunL - thread no:%d finished processing\n", iThreadsRun);
+        iThread.Close();
+        ResetProperties(_L("clear"));
+
+        if(!(iMessage.IsNull()) && (iParams.iCrashInfo.iCrashSource == TCrashInfo::ESystemCrash) )
+        	{
+        	LOG_MSG("CCrashHandler::RunL - Completing the Async request After the Thread is Killed\n");
+            //we have done with the processing and complete the async request
+            iMessage.Complete(iStatus.Int());
+        	}
+
+        StartThreadL();
+        return;
+    }
+
+    //multiple crash event case
+    if(iParams.iCrashInfo.iType == TCrashInfo::ECrashException && iParams.iCrashInfo.iCrashSource == TCrashInfo::ELiveCrash)
+        {
+        //LOG_MSG2("CCrashHandler::RunL - marking thread:%Lu\n", iParams.iCrashInfo.iTid);
+        iTids.AppendL(iParams.iCrashInfo.iTid);
+        }
+
+
+    PostProcessL();
+    ResetProperties(_L("idle"));
+
+    iCrashCount++;
+      
+    if(!CrashInProgress() && (iParams.iCrashInfo.iCrashSource == TCrashInfo::ESystemCrash))
+    	{
+    	if(!iMessage.IsNull())
+    		{
+        	//When there are no plugins
+        	LOG_MSG("CCrashHandler::RunL - Completing the request when there are no plugins\n");
+    		iMessage.Complete(iStatus.Int());
+    		}
+    	}
+
+    if(iRemainingEvents.Count() > 0) 
+        {
+        ProcessCrashL(TCrashInfo::ELiveCrash);
+        }
+    
+    if(iRemainingFlashCrashEvents.Count() > 0)
+    	{
+    	ProcessCrashL(TCrashInfo::ESystemCrash);
+    	}
+
+	}
+
+// Report any leave to the client if possible.
+TInt CCrashHandler::RunError(TInt aError)
+	{
+	LOG_MSG2("CCrashHandler::RunError(TInt aError=%d)", aError);
+    TBuf<63> errorMsg;
+    errorMsg.Format(_L("Processing core dump finished abnormally! err:%d"), aError);
+    User::InfoPrint(errorMsg);
+    
+    if(!(iMessage.IsNull()) && (iParams.iCrashInfo.iCrashSource == TCrashInfo::ESystemCrash) )
+    	{
+    	LOG_MSG("CCrashHandler::RunError - Completing the Async request \n");
+        iMessage.Complete(aError);
+    	}    
+	return KErrNone;
+	}
+
+
+void CCrashHandler::HandleCrashFromFlashL(const TCrashInfo& aCrashInf)
+	{
+	LOG_MSG("-> CCrashHandler::HandleCrashFromFlashL()");
+	
+	iRemainingFlashCrashEvents.AppendL(aCrashInf);
+	
+    if(!CrashInProgress())
+        {
+	    LOG_MSG("CCrashHandler::HandleCrashFromFlashL() -> ProcessCrashL\n");
+        ProcessCrashL(aCrashInf.iCrashSource);
+        }
+	
+	}
+
+void CCrashHandler::HandleCrashFromFlashL(const TCrashInfo& aCrashInf, const RMessage2& aMessage)
+	{
+	LOG_MSG("-> CCrashHandler::HandleCrashFromFlashL() using the async mechanism");
+	
+	if(aMessage.IsNull())
+		User::Leave(KErrArgument);
+	
+	iMessage = aMessage;
+	
+	iRemainingFlashCrashEvents.AppendL(aCrashInf);
+	
+    if(!CrashInProgress())
+        {
+	    LOG_MSG("CCrashHandler::HandleCrashFromFlashL() -> ProcessCrashL\n");
+        ProcessCrashL(aCrashInf.iCrashSource);
+        }
+    else
+    	{
+    	LOG_MSG("CCrashHandler::HandleCrashFromFlashL() -> Crash already in progress\n");
+    	}
+	
+	} 
+
+void CCrashHandler::CancelHandleCrashFromFlash(const TCrashInfo& aCrashInf)
+	{
+	LOG_MSG("-> CCrashHandler::CancelHandleCrashFromFlashL() using the async mechanism");
+	
+    //if this request is pending remove the request from the queue
+	for(TInt i =0; i<iRemainingFlashCrashEvents.Count(); i++)
+		{
+		if( (iRemainingFlashCrashEvents[i].iCrashId) == (aCrashInf.iCrashId))
+			{
+			LOG_MSG("CCrashHandler::CancelHandleCrashFromFlashL() -> Removed Pending Event from the queue\n");
+			iRemainingFlashCrashEvents.Remove(i);
+			}
+		}
+	
+	}
+
+
+void CCrashHandler::HandleCrashEventL(const TCrashEventInfo &aCrashEventInfo)
+    {    
+    LOG_MSG3("CCrashHandler::HandleCrashEventL - type:%d, thread:%Lu\n", aCrashEventInfo.iEventType, aCrashEventInfo.iThreadId);
+    //multiple crash events case
+    if(aCrashEventInfo.iEventType == EEventsKillThread)
+        {
+        TInt index = iTids.Find(aCrashEventInfo.iThreadId);
+        if(index != KErrNotFound)
+            {
+            LOG_MSG2("CCrashHandler::HandleCrashEventL - multiple kill event, not handling thread:%Lu\n", aCrashEventInfo.iThreadId);
+            iTids.Remove(index);
+			iCoreSess.ResumeThreadL(aCrashEventInfo.iThreadId);
+            return;
+            }
+        }
+
+
+	LOG_MSG2("CCrashHandler::HandleCrashEvent() - preprocessing action:%d\n", iCoreSess.PreProcessingAction());
+    if(iCoreSess.PreProcessingAction() == ESuspendProcess)
+        {
+        LOG_MSG2("CCrashHandler::HandleCrashEventL - suspending crashed process:%Lu\n", aCrashEventInfo.iProcessId);
+        iCoreSess.SuspendProcessL(aCrashEventInfo.iProcessId);
+        }
+
+    iRemainingEvents.AppendL(aCrashEventInfo); //fifo order, coping the data
+
+    if(!CrashInProgress())
+        {
+	    LOG_MSG("CCrashHandler::HandleCrashEvent() -> ProcessCrashL\n");
+        ProcessCrashL(TCrashInfo::ELiveCrash);
+        }
+    }
+
+void CCrashHandler::ProcessCrashL(const TCrashInfo::TCrashSource& aType) 
+	{	
+	switch (aType)
+		{
+		case TCrashInfo::ELiveCrash :
+			{			
+			ProcessLiveCrashL();
+			break;
+			}
+		case TCrashInfo::ESystemCrash :
+			{
+			ProcessSystemCrashL();
+			break;
+			}
+		default:
+			{
+			LOG_MSG( " CCrashHandler::ProcessCrashL()  --->  ERROR: Unknown crash type" );
+			}
+		}
+	}
+
+/**
+ * Handles a crash stored in the system flash
+ * @leave
+ */
+void CCrashHandler::ProcessSystemCrashL()
+	{
+	LOG_MSG( "->CCrashHandler::ProcessSystemCrashL()\n" );
+	//set the crash paramaters
+	iParams.iCrashInfo = iRemainingFlashCrashEvents[0];
+		
+	iRemainingFlashCrashEvents.Remove(0); //remove in fifo order				
+	
+	iCoreSess.FlashDataSource()->AnalyseCrashL(iParams.iCrashInfo.iCrashId);	
+	
+	StartThreadL();
+	}
+	
+/**
+ * Handles a live crash event
+ * @leave
+ */
+void CCrashHandler::ProcessLiveCrashL()
+	{
+    LOG_MSG( "->CCrashHandler::ProcessLiveCrashL()\n" );
+
+    TCrashEventInfo &event = iRemainingEvents[0]; //serve in fifo order
+
+    TCrashInfo &crashInfo = iParams.iCrashInfo;
+
+	if( !event.iThreadIdValid )
+		{
+		LOG_MSG( " ERROR *! - CCrashHandler::ProcessCrashL() - ThreadId marked as invalid\n" );
+		User::Leave( KErrCorrupt );
+		}
+
+	if( !event.iProcessIdValid )
+		{
+		LOG_MSG( " ERROR *! - CCrashHandler::ProcessCrashL() - ProcessId marked as invalid\n" );
+		User::Leave( KErrCorrupt );
+		}
+
+    crashInfo.iTid = event.iThreadId;
+    crashInfo.iPid = event.iProcessId;
+    crashInfo.iCrashSource = TCrashInfo::ELiveCrash;
+
+    if(event.iEventType == EEventsHwExc)
+		{
+		crashInfo.iType = TCrashInfo::ECrashException;
+		crashInfo.iContext = event.iThreadHwExceptionInfo.iRmdArmExcInfo; //only valid for HwExc
+		LOG_MSG2( "  crashInfo.iContext.iFaultAddress=0x%X", crashInfo.iContext.iFaultAddress );
+		LOG_MSG2( "  crashInfo.iContext.iFaultStatus=0x%X", crashInfo.iContext.iFaultStatus );
+		LOG_MSG2( "  iThreadHwExceptionInfo.iExceptionNumber=0x%X", event.iThreadHwExceptionInfo.iExceptionNumber );
+		crashInfo.iExcNumber = (TUint32)event.iThreadHwExceptionInfo.iExceptionNumber; // e32const.h :: TExcType
+		}
+    else if(event.iEventType == EEventsKillThread)
+		{
+		crashInfo.iType = TCrashInfo::ECrashKill;
+		crashInfo.iReason = event.iThreadKillInfo.iExitReason; //only valid for KillThread
+		crashInfo.iExcNumber = (TUint32)event.iThreadKillInfo.iExitType; // e32const.h :: TExitType
+		TPtrC8 category( event.iThreadKillInfo.iPanicCategory, event.iThreadKillInfo.iPanicCategoryLength); //only valid for KillThread
+		crashInfo.iCategory.Copy(category);
+		}
+	else
+		{
+		LOG_MSG2( " ERROR *! - CCrashHandler::ProcessCrashL() - TEventType=%d not supported", event.iEventType );
+		User::Leave( KErrNotSupported );
+		}
+    
+    crashInfo.iTime = event.iEventTime.Int64();
+    
+    iRemainingEvents.Remove(0); //remove in fifo order
+
+    StartThreadL();
+    }
+
+void CCrashHandler::StartThreadL()
+{
+    LOG_MSG2("->CCrashHandler::StartThreadL() iThreadsRun %d\n", iThreadsRun);
+    iParams.iFormatter = iCoreSess.GetValidFormatter(iThreadsRun);      
+
+    if(!iParams.iFormatter)
+    	{
+    	LOG_MSG("->CCrashHandler::StartThreadL() no formatters found\n");
+        iThreadsRun = 0;
+        RunL();
+        return;
+    	}
+    
+    //SELF v1 and DEXC v1 arent supported for system crash
+	TBuf<KMaxFileName> pluginDesc;
+	iParams.iFormatter->GetDescription(pluginDesc);
+	
+	if(iParams.iCrashInfo.iCrashSource == TCrashInfo::ESystemCrash && (pluginDesc.Compare(KSelfV1) == 0 || pluginDesc.Compare(KDexcV1) == 0))
+		{
+		User::Leave(KErrNotSupported);
+		}  
+
+    if(iParams.iCrashInfo.iCrashSource == TCrashInfo::ELiveCrash)
+    	{
+    	iParams.iFormatter->ConfigureDataSourceL(iCoreSess.DataSource());
+    	}
+    else if(iParams.iCrashInfo.iCrashSource == TCrashInfo::ESystemCrash)
+    	{
+    	iParams.iFormatter->ConfigureDataSourceL(iCoreSess.FlashDataSource());
+    	}
+    else
+    	{
+    	//If we dont know the crash type we cant continue - programming error (dont tell user that though!)
+    	__ASSERT_ALWAYS(ETrue, User::Panic(_L("Unknown crash type"), KErrUnknown));
+    	}
+    
+
+    LOG_MSG("CCrashHandler::StartThreadL - creating the processing thread\n");
+
+    TInt err = iThread.Create(KCrashProcessingThread, CCrashHandler::Processing, KDefaultStackSize, NULL, (TAny*)&iParams);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CCrashHandler::StartThreadL - unable to create thread! err:%d\n", err);
+        User::Leave(err);
+        }
+
+    ++iThreadsRun;
+    
+    iThread.Rendezvous(iStatus);    
+    iThread.Resume();
+    User::WaitForRequest(iStatus);
+
+    User::LeaveIfError(iStatus.Int()); //something bad happened
+
+    iThread.Logon(iStatus);
+    //LOG_MSG("CCrashHandler::ProcessCrash() -> waiting for processing thread to finish\n");
+    SetActive(); //wait for thread termination event
+}
+
+TInt CCrashHandler::Processing(TAny* aParams)
+    {
+    //LOG_MSG("-> CCrashHandler::CrashProcessing()");
+    RThread::Rendezvous(KErrNone);
+//    __UHEAP_MARK;
+	TInt err = KErrNoMemory;
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+	if(cleanup)
+		{
+	    TCrashThreadParams *params = static_cast<TCrashThreadParams*>(aParams);
+        LOG_MSG("CCrashHandler::CrashProcessing() -> formatter.CrashEventL");
+        TRAP(err, params->iFormatter->CrashEventL(&params->iCrashInfo)); 
+		delete cleanup;
+		}
+//    __UHEAP_MARKEND;
+    LOG_MSG2("CCrashHandler::CrashProcessing - processing thread returns: %d\n", err);
+    return err;
+    }
+
+//eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/coredumpmain.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,124 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32base.h>
+#include "coredumpserver.h"
+#include <debuglogging.h>
+
+_LIT(KWildCard, "*");
+
+/**
+Checks whether another instance of the CDS exists in the system. It is checked
+that:
+    * the secure id of another process is KSecurityServerSecureID??
+    * the PID is different to this process
+    * the FileName of the other process contains KCoreDumpServerName
+
+The final check is only made for the benefit of hardware boards, in a 
+production device, the first two checks would be sufficient.
+
+@return ETrue if the CDS is judged to be already running, EFalse otherwise
+*/
+TBool CDSAlreadyExists()
+	{
+	//find PID of this process
+	RProcess process;
+	TProcessId thisProcessId = process.Id();
+
+	TFindProcess find(KWildCard);
+	TFullName name;
+
+	//try and find another CDS based on SecureID value??, which has a different PID
+	while(find.Next(name)==KErrNone)
+		{
+		if (process.Open(find) == KErrNone)
+			{
+			//if(process.SecureId() == KSecurityServerSecureID) //does CDS have something like that
+				{
+				if(process.Id() != thisProcessId)
+					{
+					if(process.FileName().Find(KCoreDumpServerName) != KErrNotFound)
+						{
+	                    LOG_MSG( "core_dump_main.cpp::CDSAlreadyExists() returning: true" );
+						process.Close();
+						return ETrue;
+						}
+					}
+				}
+			}
+		process.Close();
+		}
+
+	LOG_MSG( "core_dump_main.cpp::CDSAlreadyExists() returning: false\n" );
+	return EFalse;
+	}
+
+
+/**
+Perform all server initialisation, in particular creation of the
+scheduler and server and then run the scheduler
+*/
+
+void CCoreDumpServer::RunServerL()
+	{
+
+	LOG_MSG( "CCoreDumpServer::RunServerL() -> new (ELeave) CActiveScheduler\n" );
+	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
+
+	LOG_MSG( "CCoreDumpServer::RunServerL() -> PushL(scheduler)\n" );
+	CleanupStack::PushL(scheduler);
+
+	LOG_MSG( "CCoreDumpServer::RunServerL() -> Install(scheduler)\n" );
+	CActiveScheduler::Install(scheduler);
+    
+	LOG_MSG( "CCoreDumpServer::RunServerL() -> CCoreDumpServer::NewLC()\n" );
+	CCoreDumpServer::NewLC();
+	
+	LOG_MSG( "CCoreDumpServer::RunServerL() -> Rendezvous(KErrNone)\n" );
+	RProcess::Rendezvous(KErrNone);
+
+	LOG_MSG( "CCoreDumpServer::RunServerL() -> CActiveScheduler::Start()\n" );
+	CActiveScheduler::Start();
+	
+	// Free the server and active scheduler.
+    CleanupStack::PopAndDestroy(2, scheduler);
+	}
+
+/**
+   Entry point for Core Dump Server
+*/
+TInt E32Main()
+	{
+	__UHEAP_MARK;
+
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	
+	TInt err = KErrNoMemory;
+	if	(cleanup)
+		{
+        if(!CDSAlreadyExists())
+            {
+		    TRAP(err, CCoreDumpServer::RunServerL());
+            }
+        else
+            err = KErrAlreadyExists; 
+		delete cleanup;
+		}
+
+	LOG_MSG2( "<- core_dump_main.cpp::E32Main() returning: %d\n", err );
+	__UHEAP_MARKEND;
+	return KErrNone;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/coredumpserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,188 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// core_dump_server.cpp
+//
+
+// System includes
+#include <e32cmn.h>
+#include <e32std.h>
+#include <e32svr.h>
+
+// Project includes
+#include "coredumpserver.h"
+#include "coredumpsession.h"
+#include "flashdatasource.h"
+
+/**
+This is the version of the security server that we have developed our code against
+and it comes from the interface definition of the DSS at the time of compilation.
+*/
+const TVersion securityServerVersion( 
+				KDebugServMajorVersionNumber, 
+				KDebugServMinorVersionNumber, 
+				KDebugServPatchVersionNumber );
+
+/*
+* Called to panic the server (in event of partial construction or serious error)
+*/
+void CCoreDumpServer::PanicServer(TCoreDumpServerPanic aPanic)
+	{
+        //are we using this??
+	User::Panic(KCoreDumpServerName, aPanic);
+	}
+	
+CCoreDumpServer* CCoreDumpServer::NewL()
+{
+	CCoreDumpServer* self = CCoreDumpServer::NewLC();
+    CleanupStack::Pop();
+    return self;
+}
+	
+/*
+* Symbian OS 1st stage construction
+*/
+CCoreDumpServer* CCoreDumpServer::NewLC()
+	{
+	//RDebug::Print( _L("CCoreDumpServer* CCoreDumpServer::NewLC()\n"));
+	CCoreDumpServer* self = new (ELeave) CCoreDumpServer();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+	
+/*
+* Destructor
+*/
+CCoreDumpServer::~CCoreDumpServer()
+	{
+    //LOG_MSG("->CCoreDumpServer::~CCoreDumpServer\n");
+    iSecSess.Close();
+	}
+
+/*
+* Called when a new session is to be created
+*/
+CSession2* CCoreDumpServer::NewSessionL( const TVersion& aVersion, 
+									   const RMessage2& /*aMessage*/ ) const
+	{
+
+	//RDebug::Printf( "->CCoreDumpServer::NewSessionL()\n" );
+    
+    RSecuritySvrSession &session = const_cast<RSecuritySvrSession&>(iSecSess);
+    
+	THandleInfo dssSessionInfo;
+	session.HandleInfo( & dssSessionInfo );
+
+	if( dssSessionInfo.iNumOpenInProcess > 1 )
+		{
+        //if there is already a session with DSS this means that we started it already for someone else
+		RDebug::Print( _L("CCoreDumpServer::NewSessionL() : Error : Session to DSS already in use by CDS\n"));
+		User::Leave( KErrAlreadyExists );
+		}
+
+	// Check the client-side API version number against the server version number.
+	TVersion serverVersion(	KCoreDumpServMajorVersionNumber,
+							KCoreDumpServMinorVersionNumber,
+							KCoreDumpServBuildVersionNumber);
+
+	LOG_MSG4( "CCoreDumpServer::NewSessionL() : Server version: major=%d,minor=%d,build=%d\n",
+		KCoreDumpServMajorVersionNumber, KCoreDumpServMinorVersionNumber, KCoreDumpServBuildVersionNumber );
+
+	LOG_MSG4( "  Client API built against : major=%d,minor=%d,build=%d\n", 
+		aVersion.iBuild, aVersion.iMajor, aVersion.iMinor );
+
+	if( !User::QueryVersionSupported( serverVersion, aVersion ) )
+		{
+		// This server version is incompatible with the version of the server the 
+		// client-side API was built against
+		RDebug::Printf( "CCoreDumpServer::NewSessionL() : Leaving due to incompatible versions\n" );
+		User::Leave( KErrNotSupported );
+		}
+
+	//LOG_MSG("CCoreDumpServer::NewSessionL - creating new core dump session\n");
+	return CCoreDumpSession::NewL(session);
+	}
+
+/*
+* Called when a session is opened
+*/
+void CCoreDumpServer::SessionOpened()
+	{
+	//LOG_MSG("->CCoreDumpServer::SessionOpened()\n");
+	++iNumSessions;
+	}
+
+
+/*
+* Called when a session is closed 
+*/
+void CCoreDumpServer::SessionClosed()
+	{
+	//LOG_MSG("->CCoreDumpServer::SessionClosed()\n");
+	if(--iNumSessions < 1) // No more sessions connected to the server, shut down the server
+		{
+	    //LOG_MSG("CCoreDumpServer::SessionClosed() -> CActiveScheduler::Stop()\n");
+		CActiveScheduler::Stop();
+		}
+	}
+   
+
+/*
+* Called when the server active object's RunL() leaves
+*/
+TInt CCoreDumpServer::RunError(TInt aError)
+	{
+	Message().Complete(aError);
+    
+	// Call Restart(), as RunL() left before server got chance to re-issue its request
+	ReStart();
+
+	return KErrNone;
+	}
+
+// PRIVATE MEMBER FUNCTIONS
+
+/*
+* C++ Constructor
+*/
+CCoreDumpServer::CCoreDumpServer( TInt aPriority )
+	: CServer2( aPriority ), 
+	  iNumSessions( 0 )
+	{
+	// No implementation required
+	}
+	
+
+/*
+* Symbian OS 2nd stage construction. Called from CCoreDumpServer::NewLC()
+*/	
+void CCoreDumpServer::ConstructL()
+	{
+	//LOG_MSG("->CCoreDumpServer::ConstructL()\n" );
+
+	TInt err = iSecSess.Connect( securityServerVersion );
+
+	if( KErrNone != err )
+		{
+		_LIT( KDssStartErrorMsg ,"Core Dump Server: Unable to Start/Connect to Debug Security Server");
+		User::InfoPrint( KDssStartErrorMsg );
+
+		LOG_MSG2("CCoreDumpServer::ConstructL() - unable to open security server session! err:%d\n", err);
+		User::Leave(err);
+		}
+
+    err = iSecSess.ShareAuto();
+    
+	StartL( KCoreDumpServerName );
+	} 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/coredumpserver.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef CORE_DUMP_SERVER_IBY
+#define CORE_DUMP_SERVER_IBY
+
+file=ABI_DIR\BUILD_DIR\coredump_svr.exe			sys\bin\coredump_svr.exe
+file=ABI_DIR\BUILD_DIR\coredumpinterface.dll	sys\bin\coredumpinterface.dll
+file=ABI_DIR\BUILD_DIR\cdssupport.dll			sys\bin\cdssupport.dll
+
+data=EPOCROOT##epoc32\data\Z\private\10282FE5\pluginList1.plugin  \private\10282FE5\pluginList1.plugin
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/coredumpserver.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,53 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET		coredump_svr.exe
+TARGETTYPE	EXEXP
+UID			0x1000008C 0x10282FE5
+
+USERINCLUDE	  ..\inc
+
+SYSTEMINCLUDE \epoc32\include 
+SYSTEMINCLUDE \epoc32\include\drivers
+SYSTEMINCLUDE \epoc32\include\ecom
+SYSTEMINCLUDE \epoc32\include\tools\coredump
+
+
+SOURCEPATH	.
+SOURCE		coredumpmain.cpp
+SOURCE		coredumpserver.cpp
+SOURCE		coredumpsession.cpp
+SOURCE		coredumpsessioncalls.cpp
+SOURCE		servercrashdatasource.cpp
+SOURCE      coretargetobserver.cpp
+SOURCE      corecrashhandler.cpp
+SOURCE		flashdatasource.cpp
+
+LIBRARY		euser.lib
+LIBRARY		ecom.lib
+LIBRARY		efsrv.lib
+LIBRARY     estor.lib
+LIBRARY     bsulinifile.lib
+LIBRARY     cdssupport.lib
+LIBRARY     btracec.lib
+
+STATICLIBRARY scmusr_lib.lib
+
+// This is required to kill debugged applications when a crash occurs.
+CAPABILITY 	PowerMgmt
+
+
+OPTION CW -w noempty
+MACRO CDSDEBUG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/coredumpserverstub.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef CORE_DUMP_SERVER_STUB_IBY
+#define CORE_DUMP_SERVER_STUB_IBY
+
+data=\epoc32\data\Z\system\install\coredumpserverstub.SIS \system\install\coredumpserverstub.SIS
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/coredumpsession.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,487 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implements the session functinality of the Core Dump Server
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+#include <scmconfigitem.h>
+
+#include "coredumpsession.h"
+
+/**
+C++ constructor
+@param aSession RSecuritySvrSession session parameter
+*/
+EXPORT_C CCoreDumpSession::CCoreDumpSession( RSecuritySvrSession &aSession )
+	: iSecSess( aSession )
+	{
+	LOG_MSG("->CCoreDumpSession::CCoreDumpSession()\n");
+	// No implementation required
+	}
+
+/**
+C++ Destructor. Saves the current configuration to the standard configuration file
+Calls REComSession::FinalClose() to finish the ECOM session.
+Disconnect from the Core Dump Server by calling its SessionClosed() method.
+*/
+EXPORT_C CCoreDumpSession::~CCoreDumpSession()
+	{
+
+	LOG_MSG("CCoreDumpSession::~CCoreDumpSession()\n" );
+
+	TRAPD( err, SaveConfigFileL() );
+	if( KErrNone != err )
+		{
+		_LIT(KSaveConfigFileErrorMsg ,"Warning :Core Dump Server Could Not Save Configuration File.");
+		User::InfoPrint( KSaveConfigFileErrorMsg );
+		}
+
+	iPluginList.Reset();
+	LOG_MSG("<-iPluginList.Reset()" );
+
+	iThreadPointerList.ResetAndDestroy();
+	LOG_MSG("<-iThreadPointerList.ResetAndDestroy()" );
+
+	iProcessPointerList.ResetAndDestroy();
+	LOG_MSG("<-iProcessPointerList.ResetAndDestroy()" );
+
+	iExecutablePointerList.ResetAndDestroy();
+	LOG_MSG("<-iProcessPointerList.ResetAndDestroy()" );
+
+	iObservationList.ResetAndDestroy();
+	LOG_MSG("<-iObservationList.ResetAndDestroy()" );
+
+    iConfigList.ResetAndDestroy();
+	LOG_MSG("<-iConfigList.ResetAndDestroy()" );
+	
+	
+	iScmConfigList.ResetAndDestroy();
+
+    iTotalConfigList.Reset();
+
+    iAllowedPlugins.Reset();
+
+    if(iDataSource)
+        {
+		LOG_MSG("->delete iDataSource" );
+        delete iDataSource;
+        iDataSource = NULL;
+        }
+    
+    if(iFlashDataSource)
+    	{
+		LOG_MSG("->delete iFlashDataSource" );
+        delete iFlashDataSource;
+        iFlashDataSource = NULL;    	
+    	}
+
+    if( iCrashHandler )
+        {
+		LOG_MSG("->delete iCrashHandler" );
+        delete iCrashHandler;
+        iCrashHandler = NULL;
+        }
+
+    iFormatterPlugins.ResetAndDestroy();
+    iFormatterInfos.ResetAndDestroy();
+    if(iMarshalledFormatterList)
+    {
+        delete iMarshalledFormatterList;
+    }
+
+    iWriterPlugins.ResetAndDestroy();
+    iWriterInfos.ResetAndDestroy();
+    if(iMarshalledWriterList)
+    {
+        delete iMarshalledWriterList;
+    }
+
+
+	LOG_MSG( "->RProperty::Delete(KCoreDumpServUid, ECancelCrash)" );
+    err = RProperty::Delete(KCoreDumpServUid, ECancelCrash);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CCoreDumpSession::~CCoreDumpSession - unable to delete 'cancel crash' property! err:%d\n", err);
+        }
+
+	LOG_MSG("->RProperty::Delete(KCoreDumpServUid, ECrashProgress)" );
+    err = RProperty::Delete(KCoreDumpServUid, ECrashProgress);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CCoreDumpSession::~CCoreDumpSession - unable to delete 'crash progress' property! err:%d\n", err);
+        }
+
+	
+    err = RProperty::Delete(KCoreDumpServUid, ECrashCount);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CCoreDumpSession::~CCoreDumpSession - unable to delete 'crash count' property! err:%d\n", err);
+        }
+    
+    err = RProperty::Delete(KCoreDumpServUid, ECrashMediaName);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CCoreDumpSession::~CCoreDumpSession - unable to delete 'crash media name' property! err:%d\n", err);
+        }
+
+    if(iMarshalledProcessList != NULL)
+        {
+		LOG_MSG("->delete iMarshalledProcessList;\n" );
+        delete iMarshalledProcessList;
+        }
+
+    if(iMarshalledExecutableList != NULL)
+        {
+		LOG_MSG("->delete iMarshalledExecutableList;\n" );
+        delete iMarshalledExecutableList;
+        }
+
+    if(iMarshalledThreadList != NULL)
+        {
+		LOG_MSG( "->delete iMarshalledThreadList;\n" );
+        delete iMarshalledThreadList;
+        }
+    
+    iCrashList.ResetAndDestroy();
+    if(iMarshalledCrashList != NULL)
+    	{
+		LOG_MSG( "->delete iMarshalledCrashList;\n" );
+        delete iMarshalledCrashList;   	
+    	}
+    
+	LOG_MSG("REComSession::FinalClose()" );
+    REComSession::FinalClose();
+
+	Server().SessionClosed();
+
+	LOG_MSG("<-CCoreDumpSession::~CCoreDumpSession()" );
+
+	}
+
+#define KObservationListGranularity (20)
+
+/**
+* Symbian OS 2nd stage construction
+*/
+void CCoreDumpSession::ConstructL()
+	{
+	LOG_MSG( "CCoreDumpSession::ConstructL()\n" );
+
+    iMarshalledThreadList = NULL;
+	iTotalThreadListDescSize = 0;
+    iMarshalledProcessList = NULL;
+	iTotalProcessListDescSize = 0;
+    iMarshalledExecutableList = NULL;
+	iTotalExecutableListDescSize = 0;
+    iMarshalledFormatterList = NULL;
+	iTotalFormatterListDescSize = 0;
+    iMarshalledWriterList = NULL;
+	iTotalWriterListDescSize = 0;
+
+	iObservationList.ReserveL(KObservationListGranularity);
+
+    static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); //do we want to limit it?? DOS attack via CancelCrash
+
+    //UI sets to ETrue, formatter gets, crash handler resets
+    TInt err = RProperty::Define(KCoreDumpServUid, ECancelCrash, RProperty::EInt, KAllowAllPolicy, KAllowAllPolicy);
+    if( (err != KErrAlreadyExists) && (err != KErrNone) )
+        { 
+        LOG_MSG2("CCoreDumpSession::ConstrucL - unable to create 'cancel crash' property! err:%d\n", err);
+        User::LeaveIfError(err);
+        }
+
+    //UI gets and displays, formatter sets to update the progress, crash handler resets
+    err = RProperty::Define(KCoreDumpServUid, ECrashProgress, RProperty::EText, KAllowAllPolicy, KAllowAllPolicy);
+    if( (err != KErrAlreadyExists) && (err != KErrNone) )
+        {
+        LOG_MSG2("CCoreDumpSession::ConstrucL - unable to create 'crash progress' property! err:%d\n", err);
+        User::LeaveIfError(err);
+        }
+
+    //UI gets crash count
+    err = RProperty::Define(KCoreDumpServUid, ECrashCount, RProperty::EInt, KAllowAllPolicy, KAllowAllPolicy);
+    if( (err != KErrAlreadyExists) && (err != KErrNone) )
+        {
+        LOG_MSG2("CCoreDumpSession::ConstrucL - unable to create 'crash count' property! err:%d\n", err);
+        User::LeaveIfError(err);
+        }
+    
+    //UI gets the crash media name
+    err = RProperty::Define(KCoreDumpServUid, ECrashMediaName, RProperty::ELargeByteArray, KAllowAllPolicy, KAllowAllPolicy, RProperty::KMaxLargePropertySize);
+    if( (err != KErrAlreadyExists) && (err != KErrNone) )
+        {
+        LOG_MSG2("CCoreDumpSession::ConstrucL - unable to create 'crash media name' property! err:%d\n", err);
+        User::LeaveIfError(err);
+        }
+
+    
+    iCrashHandler = CCrashHandler::NewL(*this);
+
+	iConfigList.ReserveL( (TInt)ELastParam );
+	
+	iScmConfigList.ReserveL((TInt)Debug::TConfigItem::ELast);
+	
+	
+
+	// This list will contain all the configuration parameters for the entire system,
+	// but we do not know how many there are. At least hold our own params.
+
+	//LOG_MSG( "  -> new (ELeave) RConfigParameterList()\n" );
+
+	iTotalConfigList.ReserveL( (TInt)ELastParam );
+
+	COptionConfig * config;
+
+	//LOG_MSG( "  -> NewL KSuspendOwningProcsPrompt\n" );
+
+	RProcess thisProc;
+	iOurSecureID = thisProc.SecureId();
+	TUint32 ourSecureID = iOurSecureID.iUid;
+	//LOG_MSG2( "  thisProc.SecureId()=0x%X\n", ourSecureID );
+
+    
+	// This is stored as a bitfield
+	_LIT( KCrashedEventTypePrompt, "Select Crash Trigger:\n  1-HW Exception,\n  2-Thread Kill,\n  3-Both" );
+	iCrashEventTypes = ECrashHwExcAndKillThread;
+	config = COptionConfig::NewL(  (TInt)ECrashEventTypes,
+									ourSecureID,
+									COptionConfig::ECoreDumpServer,
+									COptionConfig::ETUInt, 
+									KCrashedEventTypePrompt, 
+									1,
+									KNullDesC,
+									iCrashEventTypes,
+									KNullDesC );
+    
+	iConfigList.AppendL( config );
+
+
+	_LIT( KPreCrashEventActionPrompt, "Action On Crash:\n  0-None,\n  1-Suspend Thread,\n  2-Suspend Process" );
+	iPreCrashEventAction = ESuspendThread;
+	config = COptionConfig::NewL(  (TInt)EPreCrashEventAction,
+									ourSecureID,
+									COptionConfig::ECoreDumpServer,
+									COptionConfig::ETUInt, 
+									KPreCrashEventActionPrompt, 
+									1,
+									KNullDesC,
+									iPreCrashEventAction,
+									KNullDesC );
+	iConfigList.AppendL( config );
+    
+
+	_LIT( KPostCrashEventActionPrompt, "Action After Crash:\n  0-None,\n  1-Resume Thread,\n  2-Resume Process,\n  4-Kill Process" );
+	iPostCrashEventAction = EResumeThread;
+	config = COptionConfig::NewL(  (TInt)EPostCrashEventAction,
+									ourSecureID,
+									COptionConfig::ECoreDumpServer,
+									COptionConfig::ETUInt, 
+									KPostCrashEventActionPrompt, 
+									1,
+									KNullDesC,
+									iPostCrashEventAction,
+									KNullDesC );
+
+	iConfigList.AppendL( config );
+
+	iDataSource = CServerCrashDataSource::NewL(iSecSess);
+	iFlashDataSource = CFlashDataSource::NewL(iSecSess);
+
+	ReadPluginUidFilesL();	
+    }
+
+void CCoreDumpSession::CreateL()
+{
+    LOG_MSG("->CCoreDumpSession::CreateL()\n");
+	Server().SessionOpened();
+}
+
+/**
+* Symbian OS 1st stage construction called by CCoreDumpServer::NewSessionL()
+*/
+EXPORT_C CCoreDumpSession* CCoreDumpSession::NewL( RSecuritySvrSession &aSession )
+	{
+	LOG_MSG( "CCoreDumpSession::NewL()\n" );
+	CCoreDumpSession* self = new (ELeave) CCoreDumpSession( aSession );
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+CCoreDumpServer& CCoreDumpSession::Server() const
+{
+    LOG_MSG("->CCoreDumpServer::Server()\n");
+    return *static_cast<CCoreDumpServer*>(const_cast<CServer2*>(CSession2::Server()));
+}
+
+/*
+* Called each time a client request message is received
+*/
+EXPORT_C void CCoreDumpSession::ServiceL(const RMessage2& aMessage)
+	{
+	// Any security checks on a connected client can be made here using the aMessage parameter.
+	// aMessage is the service request message from the client thread.
+    TInt err = KErrNone;
+
+	TRAP(err, DispatchMessageL(aMessage));
+
+	if ((aMessage.Function()) != ECoreDumpProcessCrashAsync)
+		{//ECoreDumpProcessFlashCrashAsync is an async request so we complete the request when we are done
+		aMessage.Complete(err);
+		}
+    	
+	}
+
+//
+_LIT(KSessionPanic,"CCoreDumpSession panic");
+/*
+* Called when the client should be panicked
+*/
+void CCoreDumpSession::PanicClient(const RMessage2& aMessage, TInt aPanic)
+	{
+	aMessage.Panic(KSessionPanic, aPanic);
+	}
+
+
+/*
+* Called by ServiceL() when a request message is received, calls the appropriate service
+*/
+void CCoreDumpSession::DispatchMessageL(const RMessage2& aMessage)
+	{
+	// Call the required service given by the request message's function number
+	switch(aMessage.Function())
+		{
+		case ECoreDumpServGetPluginList:
+			{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpServerGetPluginList\n" );
+			GetPluginListL(aMessage);
+			break;
+			}
+		case ECoreDumpPluginRequest:
+			{
+			LOG_MSG("CCoreDumpSession::DispatchMessageL() ECoreDumpPluginRequest\n");
+            if(iCrashHandler->CrashInProgress())
+                {
+                LOG_MSG( "CCoreDumpSession::DispatchMessageL - unable to handle because of crash in progress\n" );
+                User::Leave(KErrServerBusy);
+                }
+            else	
+            	{
+			    PluginRequestL( aMessage );
+            	}
+			break;
+			}
+		case ECoreDumpGetListInfo:
+			{
+			LOG_MSG("CCoreDumpSession::DispatchMessageL() ECoreDumpListInfo\n");
+			ListInfoL( aMessage );
+			break;
+			}
+		case ECoreDumpGetListData:
+			{
+			LOG_MSG("CCoreDumpSession::DispatchMessageL() ECoreDumpGetList\n");
+			GetListL( aMessage );
+			break;
+			}
+		case ECoreDumpGetNumberConfigParams :
+			{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpGetNumberConfigParams\n" );
+			GetNumberConfigParametersL( aMessage );
+			break;
+			}
+		case ECoreDumpGetConfigParam :
+			{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpGetConfigParam\n" );
+			GetConfigParameterL( aMessage );
+			break;
+			}
+		case ECoreDumpSetConfigParam :
+			{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpSetConfigParam\n" );
+            if(iCrashHandler->CrashInProgress())
+                {
+                LOG_MSG( "CCoreDumpSession::DispatchMessageL - unable to handle because of crash in progress\n");
+                User::Leave(KErrServerBusy);
+                }
+            else	
+            	{
+			    SetConfigParameterL( aMessage );
+            	}
+			break;
+			}
+        case ECoreDumpObservationRequest:
+        	{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpObservationRequest\n" );
+            ObservationRequestL( aMessage );
+            break;
+        	}
+		case ECoreDumpLoadConfig :
+			{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpLoadConfig\n" );
+			LoadConfigFileL( &aMessage );
+			break;
+			}
+		case ECoreDumpSaveConfig :
+			{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpSaveConfig\n" );
+			SaveConfigFileL( &aMessage );
+			break;
+			}
+		case ECoreDumpDeleteCrashPartitionRequest:
+			{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpDeleteCrashPartitionRequest\n" );
+			DeleteCrashPartitionL();
+			break;
+			}
+		case ECoreDumpDeleteLogRequest:
+			{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpDeleteLogRequest\n" );
+			//DeleteCrashLogL(aMessage);
+			User::Leave(KErrNotSupported);
+			break;
+			}
+		case ECoreDumpProcessFlashCrash:
+			{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpProcessFlashCrash\n" );
+			ProcessCrashLogL(aMessage);
+			break;
+			}
+		case ECoreDumpProcessCrashAsync:
+			{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpProcessFlashCrashAsync\n" );
+			ProcessCrashLogAsyncL(aMessage);
+			break;			
+			}
+		case ECoreDumpCancelProcessCrashAsync:
+			{
+			LOG_MSG( "CCoreDumpSession::DispatchMessageL() ECoreDumpCancelProcessFlashCrashAsync\n" );
+			CancelProcessCrashLogAsync(aMessage);
+			break;			
+			}
+		default:
+			{
+			// Unknown function number - panic the client
+			PanicClient(aMessage, EBadRequest);
+			}
+		}
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/coredumpsessioncalls.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,2851 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// core_dump_session_calls.cpp
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#include <crashlogwalker.h>
+#include <scmconfigitem.h>
+#include "coredumpsession.h"
+
+using namespace Debug;
+
+// Creates and returns a heap descriptor which holds contents of list
+HBufC8* CCoreDumpSession::MarshalListL( TListRequest & req, TAny * list )
+	{
+
+	LOG_MSG("->CCoreDumpSession::MarshalListL()\n" );
+
+	// Create a dynamic flat buffer to hold this object's member data	
+	// Can only use CBufFlat due to Store supporting CBufFlat and CBufSeg
+	// See Symbian OS guide » System libraries » Using Store » Streaming » Templated stream operators
+
+	const TInt KExpandSize = 128; // "Granularity" of dynamic buffer
+
+	CBufFlat* buf = CBufFlat::NewL( KExpandSize );
+	CleanupStack::PushL( buf );
+
+	RBufWriteStream stream( *buf ); // Stream over the buffer
+	CleanupClosePushL( stream );
+
+	for( TInt i = 0; i < req.iRemaining; i ++ )
+		{		
+		switch( req.iListType )
+			{
+			case TListRequest::EThreadList:
+				{
+				//LOG_MSG2( "  -> ((*threadPointerList)[%d])->ExternalizeL( )\n", i );
+				iThreadPointerList[i]->ExternalizeL( stream, buf );
+				//LOG_MSG2( "  buf->Size()=%d\n", buf->Size() );
+				break;
+				}
+			case TListRequest::EProcessList:
+				{
+				//LOG_MSG2( "  -> ((*processPointerList)[%d])->ExternalizeL( )\n", i );
+				iProcessPointerList[i]->ExternalizeL( stream, buf );
+				//LOG_MSG2( "  buf->Size()=%d\n", buf->Size() );
+				break;
+				}
+
+			case TListRequest::EExecutableList:
+				{
+				//LOG_MSG2( "  -> ((*processPointerList)[%d])->ExternalizeL( )\n", i );
+				iExecutablePointerList[i]->ExternalizeL( stream, buf );
+				//LOG_MSG2( "  buf->Size()=%d\n", buf->Size() );
+				break;
+				}
+            case TListRequest::EFormatterList:
+                {
+				LOG_MSG2( "  -> ((*formatterInfos)[%d])->ExternalizeL( )\n", i );
+				iFormatterInfos[i]->ExternalizeL( stream, buf );
+				//LOG_MSG2( "  buf->Size()=%d\n", buf->Size() );
+				break;
+                }
+            case TListRequest::EWriterList:
+                {
+				LOG_MSG2( "  -> ((*writerInfos)[%d])->ExternalizeL( )\n", i );
+				iWriterInfos[i]->ExternalizeL( stream, buf );
+				//LOG_MSG2( "  buf->Size()=%d\n", buf->Size() );
+				break;
+                }
+            case TListRequest::ECrashList:
+            	{
+            	LOG_MSG2( "  -> ((*iCrashList)[%d])->ExternalizeL( )\n", i );
+            	iCrashList[i]->ExternalizeL(stream, buf);
+            	//LOG_MSG2( "  buf->Size()=%d\n", buf->Size() );
+            	break;
+            	}
+			default:
+				{
+				LOG_MSG("CCoreDumpSession::MarshalListL : Received unknown list type");				
+				User::Leave( KErrNotSupported );
+				}
+			}
+		}
+
+	stream.CommitL();
+
+	TInt bufSize = buf->Size();
+
+	// Create a heap descriptor from the buffer
+	HBufC8* des = HBufC8::NewL( buf->Size() );
+	TPtr8 ptr( des->Des() );
+
+	buf->Read( 0, ptr, buf->Size() );
+	
+	CleanupStack::PopAndDestroy( &stream );
+	CleanupStack::PopAndDestroy( buf ); 
+	
+	return des;
+	}
+
+
+void CCoreDumpSession::GetListL( const RMessage2& aMessage )
+	{
+	LOG_MSG( "CCoreDumpSession::GetListL()\n" );
+
+	TListRequest listRequest; 
+	HBufC8 *listDes = NULL;
+
+	TPtr8 listReqPtr( (TUint8 *)&listRequest, sizeof(TListRequest) );
+
+	aMessage.ReadL( 0, listReqPtr );
+
+	switch( listRequest.iListType )
+		{
+		case TListRequest::EThreadList :
+			{
+			if( listRequest.iRequiredDescriptorSize != iTotalThreadListDescSize )
+				{
+				LOG_MSG( "  ERROR !* listReq.iRequiredDescriptorSize != iTotalThreadListDescSize\n" );
+				User::Leave( KErrBadDescriptor );
+				}
+			listDes = iMarshalledThreadList;
+			break;
+			}
+		case TListRequest::EProcessList :
+			{
+			if( listRequest.iRequiredDescriptorSize != iTotalProcessListDescSize )
+				{
+				LOG_MSG( "  ERROR !* listReq.iRequiredDescriptorSize != iTotalProcessListDescSize\n" );
+				User::Leave( KErrBadDescriptor );
+				}
+			listDes = iMarshalledProcessList;
+			break;
+			}
+		case TListRequest::EExecutableList :
+			{
+			if( listRequest.iRequiredDescriptorSize != iTotalExecutableListDescSize )
+				{
+				LOG_MSG( "  ERROR !* listReq.iRequiredDescriptorSize != iTotalExecutableListDescSize\n" );
+				User::Leave( KErrBadDescriptor );
+				}
+			listDes = iMarshalledExecutableList;
+			break;
+			}
+		case TListRequest::EFormatterList :
+			{
+			if( listRequest.iRequiredDescriptorSize != iTotalFormatterListDescSize )
+				{
+				LOG_MSG( "  ERROR !* listReq.iRequiredDescriptorSize != iTotalFormatterListDescSize\n" );
+				User::Leave( KErrBadDescriptor );
+				}
+			listDes = iMarshalledFormatterList;
+			break;
+			}
+		case TListRequest::EWriterList :
+			{
+			if( listRequest.iRequiredDescriptorSize != iTotalWriterListDescSize )
+				{
+				LOG_MSG( "  ERROR !* listReq.iRequiredDescriptorSize != iTotalWriterListDescSize\n" );
+				User::Leave( KErrBadDescriptor );
+				}
+			listDes = iMarshalledWriterList;
+			break;
+			}
+		case TListRequest::ECrashList :
+			{
+			if( listRequest.iRequiredDescriptorSize != iTotalCrashInfoDescSize )
+				{
+				LOG_MSG( "  ERROR !* listReq.iRequiredDescriptorSize != iTotalWriterListDescSize\n" );
+				User::Leave( KErrBadDescriptor );
+				}
+			listDes = iMarshalledCrashList;
+			break;
+			}
+		default :
+			{
+			LOG_MSG2( " ERROR !* : CCoreDumpSession::ListInfoL() : invalid TListRequestType %d\n", 	listRequest.iListType );
+			User::Leave( KErrArgument );
+			}
+		}
+
+	if ( listDes == NULL )
+		{
+
+		LOG_MSG( "  ERROR !* MarshalData returned null buf\n" );
+		User::Leave( KErrBadDescriptor );
+
+		}
+	else
+		{
+
+		//LOG_MSG( "  -> TPtr8 lsitPtr( listDes->Des() )\n" );
+		TPtr8 listPtr( listDes->Des() );
+		//LOG_MSG2( "  listPtr->Size()=%d\n", listPtr.Size() );
+
+		if( listPtr.Size() == 0 )
+			{
+			LOG_MSG( "  ERROR !* : if( lsitPtr.Size() == 0 )\n" );
+			User::Leave( KErrBadDescriptor );
+			}
+
+		//LOG_MSG( "  -> WriteL( 1, listPtr )\n" );
+		aMessage.WriteL( 1, listPtr );
+
+		}
+
+	}
+
+
+void CCoreDumpSession::ListInfoL( const RMessage2& aMessage )
+	{
+    LOG_MSG( "CCoreDumpSession::ListInfoL()\n" );
+
+	TListRequest listRequest; 
+	TUint64 procId;
+	
+	TPtr8 listReqPtr( (TUint8 *)&listRequest, sizeof(TListRequest) );
+
+	aMessage.ReadL( 0, listReqPtr );
+
+	switch( listRequest.iListType )
+		{
+		    case TListRequest::EThreadList :
+				{
+				procId = MAKE_TUINT64( listRequest.iSubId2, listRequest.iSubId1 );				
+				iDataSource->GetThreadListL( procId, iThreadPointerList, iTotalThreadListDescSize );
+	
+				listRequest.iRemaining = iThreadPointerList.Count();
+	
+	            //mark those that we observe
+	            for(TInt i = 0; i < iObservationList.Count(); i++)
+	                {
+	                for(TInt j = 0; j < iThreadPointerList.Count(); j++)
+	                    {
+	                    if(iObservationList[i]->HasThread(iThreadPointerList[j]->Name()))
+	                        {
+	                        iThreadPointerList[j]->Observed(ETrue); 
+	                        }
+	                    }
+	                }
+	
+				if( NULL != iMarshalledThreadList )
+					{
+					delete iMarshalledThreadList;
+					}
+	
+				//LOG_MSG( " EThreadList -> MarshalDataL()\n" );
+				iMarshalledThreadList = MarshalListL( listRequest, (TAny*) &iThreadPointerList );
+				listRequest.iRequiredDescriptorSize = iMarshalledThreadList->Des().Size();
+				iTotalThreadListDescSize = listRequest.iRequiredDescriptorSize;
+								
+				break;
+				}
+		case TListRequest::EProcessList :
+            {
+			iDataSource->GetProcessListL( iProcessPointerList, iTotalProcessListDescSize );
+
+			listRequest.iRemaining = iProcessPointerList.Count();
+
+            //mark those that we observe
+            for(TInt i = 0; i < iObservationList.Count(); i++)
+                {
+                for(TInt j = 0; j < iProcessPointerList.Count(); j++)
+                    {
+                    if( (iObservationList[i]->TargetName() == iProcessPointerList[j]->Name()) && //attached to it
+                        (iObservationList[i]->ThreadCount() == 0) ) //and no threads on the list 
+                        {
+                        iProcessPointerList[j]->Observed(ETrue); 
+                        }
+                    }
+                }
+
+			if( NULL != iMarshalledProcessList )
+				{
+				delete iMarshalledProcessList;
+				}
+
+			//LOG_MSG( " EProcessList -> MarshalDataL()\n" );
+			iMarshalledProcessList = MarshalListL( listRequest, (TAny*) &iProcessPointerList );
+			listRequest.iRequiredDescriptorSize = iMarshalledProcessList->Des().Size();
+			iTotalProcessListDescSize = listRequest.iRequiredDescriptorSize;
+						
+			break;
+			}			
+		case TListRequest::EExecutableList :
+            {
+			iDataSource->GetExecutableListL( iExecutablePointerList, iTotalExecutableListDescSize );
+
+			listRequest.iRemaining = iExecutablePointerList.Count();
+			//LOG_MSG2( "  listRequest.iRemaining=%d\n", listRequest.iRemaining );
+
+            //mark those that we observe
+            for(TInt i = 0; i < iObservationList.Count(); i++)
+                {
+                for(TInt j = 0; j < iExecutablePointerList.Count(); j++)
+                    {
+                    if( iObservationList[i]->TargetName() == iExecutablePointerList[j]->Name() )//attached to it
+                        {
+                        iExecutablePointerList[j]->Observed(ETrue); 
+                        }
+                    }
+                }
+
+			if( NULL != iMarshalledExecutableList )
+				{
+				delete iMarshalledExecutableList;
+				}
+
+			//LOG_MSG( " EExecutableList -> MarshalDataL()\n" );
+			iMarshalledExecutableList = MarshalListL( listRequest, (TAny*) &iExecutablePointerList );
+			listRequest.iRequiredDescriptorSize = iMarshalledExecutableList->Des().Size();
+			iTotalExecutableListDescSize = listRequest.iRequiredDescriptorSize;
+			
+			break;
+			}		
+		case TListRequest::EFormatterList :
+            {
+			listRequest.iRemaining = iFormatterInfos.Count();
+
+            if(iMarshalledFormatterList)
+                {
+                delete iMarshalledFormatterList;
+                }
+
+            iMarshalledFormatterList = MarshalListL( listRequest, (TAny*) &iFormatterInfos );
+			listRequest.iRequiredDescriptorSize = iMarshalledFormatterList->Des().Size();
+			iTotalFormatterListDescSize = listRequest.iRequiredDescriptorSize;
+			
+            break;
+            }
+		case TListRequest::EWriterList :
+            {
+			listRequest.iRemaining = iWriterInfos.Count();
+
+            if(iMarshalledWriterList)
+                {
+                delete iMarshalledWriterList;
+                }
+
+            iMarshalledWriterList = MarshalListL( listRequest, (TAny*) &iWriterInfos );
+			listRequest.iRequiredDescriptorSize = iMarshalledWriterList->Des().Size();
+			iTotalWriterListDescSize = listRequest.iRequiredDescriptorSize;
+			
+            break;
+            }
+		case TListRequest::ECrashList :
+			{
+			//Dealing with listing crashes from flash. Refresh the list and then
+			//serialise the list onto iMarshalledCrashList
+			
+			RefreshCrashListFromFlashL();			
+			listRequest.iRemaining = iCrashList.Count();
+			
+			if(iMarshalledCrashList)
+				{
+				delete iMarshalledCrashList;
+				iMarshalledCrashList = NULL;
+				}
+			
+			iMarshalledCrashList = MarshalListL(listRequest, (TAny*)&iCrashList);
+			listRequest.iRequiredDescriptorSize = iMarshalledCrashList->Des().Size();
+			iTotalCrashInfoDescSize = listRequest.iRequiredDescriptorSize;
+			
+			break;
+			}
+		default :
+			{
+			LOG_MSG2( " ERROR !* : CCoreDumpSession::ListInfoL() : invalid TListRequestType %d\n", listRequest.iListType );			
+			User::Leave( KErrArgument );
+			}
+		}
+
+	aMessage.WriteL( 0, listReqPtr );
+
+	}
+
+/**
+ * This method looks at the crash logs in the flash partition
+ * and caches them
+ */
+void CCoreDumpSession::RefreshCrashListFromFlashL()
+	{	
+	LOG_MSG("CCoreDumpSession::RefreshCrashListFromFlashL()");
+	
+	TBuf8<Debug::KMaxCoreHeaderSize> buf;	
+	iCrashList.ResetAndDestroy();
+	
+	//Start looking where the config ends if it exists
+	TInt crashLogPos = 0;
+	SCMConfiguration* config = FlashDataSource()->GetSCMConfigFromFlashL();
+	if(config)
+		{
+		crashLogPos = config->GetSize();
+		}
+	
+	delete config;
+	
+	do
+		{
+		LOG_MSG3("Looking for crash at [%d]   [0x%X]", crashLogPos, crashLogPos);
+
+		//Read in the 2 headers and the context, while we are in the crash log		
+		TInt err = iSecSess.ReadCrashLog(crashLogPos, buf, Debug::KMaxCoreHeaderSize);
+		if(err != KErrNone)
+			{
+			if(err == KErrPermissionDenied)
+				{
+				User::Leave(err);
+				}
+			
+			//We have reached the end of the crash partition
+			return;
+			}
+		
+		TCrashLogWalker wlk(buf);
+					
+		if(KErrNone == wlk.ReadLogHeader(0))
+			{
+			LOG_MSG("Found a valid crash");
+			const TCrashInfoHeader hdr = wlk.GetCrashHeader();
+			TCrashInfo* inf = TCrashInfo::NewL(hdr);
+			inf->iCrashSource = TCrashInfo::ESystemCrash;
+			inf->iContext = wlk.GetCrashContext();
+			
+			iCrashList.Append(inf);
+			
+			//Increment this so it goes up by the log size AND then enough to align it to a flash block
+			TUint32 flashPadding = 0x20000 - (crashLogPos + hdr.iLogSize)%0x20000;
+			crashLogPos += (hdr.iLogSize + flashPadding);
+			}
+		else
+			{			
+			//otherwise we dont have any more crashes			
+			return;
+			}
+		
+		}
+	while(true);		
+	
+	}
+
+
+/**
+ * Processes the crash log in the flash partition corrosponding to the crash ID of the parameter 
+ * passed through. If this doesnt match a crash in the partition, or the flash cannot be read 
+ * this will leave with KErrCorrupted
+ * @param aMessage
+ * @leave one of the OS wide codes
+ */
+void CCoreDumpSession::ProcessCrashLogL(const RMessage2& aMessage)
+	{
+	TInt crashId = aMessage.Int0();	
+	LOG_MSG2("->CCoreDumpSession::ProcessCrashLogL(ID = [%d])\n",  crashId);
+	
+	RefreshCrashListFromFlashL();
+	
+	for(TInt cnt = 0; cnt < iCrashList.Count(); cnt++)
+		{
+		if(iCrashList[cnt]->iCrashId == crashId)
+			{
+			RDebug::Printf("Going to the crash handler");
+			iCrashHandler->HandleCrashFromFlashL(*(iCrashList[cnt]));
+			}
+		}
+	}
+
+/**
+ * Processes the crash log in the flash partition Asynchronously corrosponding to the crash ID of the parameter 
+ * passed through. It refreshes the crash list and then calls the crash handler. Leaves with standard leave codes 
+ * when the underlying methods leave.  
+ * @param aMessage
+ * @leave one of the OS wide codes
+ */
+void CCoreDumpSession::ProcessCrashLogAsyncL(const RMessage2& aMessage)
+	{
+	TInt crashId = aMessage.Int0();	
+	LOG_MSG2("->CCoreDumpSession::ProcessCrashLogAsyncL(ID = [%d])\n",  crashId);
+	
+	RefreshCrashListFromFlashL();
+	
+	for(TInt cnt = 0; cnt < iCrashList.Count(); cnt++)
+		{
+		if(iCrashList[cnt]->iCrashId == crashId)
+			{
+			LOG_MSG("Going to the crash handler using the async mechanism");
+			iCrashHandler->HandleCrashFromFlashL(*(iCrashList[cnt]), aMessage);
+			}
+		}
+	}
+
+/**
+ * Cancels asynchronous processing of the crash log in the flash partition  
+ * @param aMessage
+ */
+void CCoreDumpSession::CancelProcessCrashLogAsync(const RMessage2& aMessage)
+	{
+	TInt crashId = aMessage.Int0();	
+	LOG_MSG2("->CCoreDumpSession::CancelProcessCrashLogAsyncL(ID = [%d])\n",  crashId);
+	
+	for(TInt cnt = 0; cnt < iCrashList.Count(); cnt++)
+		{
+		if(iCrashList[cnt]->iCrashId == crashId)
+			{
+			LOG_MSG("Going to the cancel async crash handler processing");
+			iCrashHandler->CancelHandleCrashFromFlash(*(iCrashList[cnt]));
+			}
+		}
+	}
+
+/**
+ * From a crash ID gets a TCrashInfo
+ * @param aCrashId crash ID to search for
+ * @param aCrashInfo the crash info for supplied crash ID
+ * @leave one of the OS wide codes
+ */
+void CCoreDumpSession::GetCrashInfoL(TInt aCrashId, TCrashInfo& aCrashInfo)
+	{
+	for(TInt i = 0; i<iCrashList.Count(); i++)
+		{
+		if(iCrashList[i]->iCrashId == aCrashId)
+			{
+			aCrashInfo = *(iCrashList[i]);
+			return;
+			}
+		}
+	
+	User::Leave(KErrNotFound);
+	}
+
+/**
+    Retrives the 'cancel crash' property value and checks if required to abort the crash dump. Updates 'crash progress' property. 
+
+@param aProgress descriptor with the crash progress value.
+@leave KErrAbort if crash cancel property has been set
+ */
+void CCoreDumpSession::UpdateProgressL(const TDesC &aProgress) const
+    {
+    LOG_MSG("->CCoreDumpSession::UpdateProgressL()\n");
+    TInt cancelCrash = EFalse;
+    TInt err = RProperty::Get(KCoreDumpServUid, ECrashProgress, cancelCrash);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CCoreDumpSession::UpdateProgressL - unable to retrive 'ECrashProgress' value! err:%d\n", err);
+        }
+
+    if(cancelCrash)
+        {
+        LOG_MSG("CCoreDumpSession::UpdateProgressL - aborting dump in progress\n");
+        User::Leave(KErrNotReady);
+        }
+
+    err = RProperty::Set(KCoreDumpServUid, ECrashProgress, aProgress);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CCoreDumpSession::UpdateProgressL - unable to retrive 'crash progress' value! err:%d\n", err);
+        }
+#ifdef DEBUG 
+    User::After(1000000);
+#endif
+  }
+
+/**
+ * This method removes a crash log from the flash partition
+ * @param aMessage
+ * @leave one of the OS wide codes
+ */
+void CCoreDumpSession::DeleteCrashLogL(const RMessage2& aMessage) 
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+void CCoreDumpSession::DeleteCrashPartitionL()
+	{
+	LOG_MSG("CCoreDumpSession::DeleteCrashPartitionL()");
+	
+	UpdateProgressL(_L("Erasing Entire Log"));
+
+	//Read in config first
+	SCMConfiguration* config = FlashDataSource()->GetSCMConfigFromFlashL();
+	TCleanupItem scmCleanup(CCoreDumpSession::CleanupSCMConfiguration, (TAny*)config);
+	if(config)
+		CleanupStack::PushL(scmCleanup);
+	
+	TInt err = iSecSess.EraseCrashFlashPartition();	
+	User::LeaveIfError(err);	
+	
+	if(config)
+		{
+		//Now we rewrite the config
+		RBuf8 data;	
+		data.CreateL(config->GetSize());
+		data.SetLength(config->GetSize());
+		data.CleanupClosePushL();
+			
+		TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);	
+		config->Serialize(writer);
+			
+		TUint32 written = 0;
+		User::LeaveIfError(iSecSess.WriteCrashConfig(0, data, written));
+		
+		CleanupStack::PopAndDestroy(2);//data and scmCleanup
+		}
+	
+	RefreshCrashListFromFlashL();	
+
+	UpdateProgressL(_L("Idle"));
+	}
+
+void CCoreDumpSession::CreateWriterL( const TUid loadRequestUid )
+	{
+	LOG_MSG("->CCoreDumpSession::CreateWriterL()\n" );
+
+	ValidatePluginL( loadRequestUid );
+
+    if(iPluginList.Count() == 0)
+        {
+        RefreshPluginListL();
+        }
+
+    CPluginInfo *info = NULL;
+    for(TInt i = 0; i < iPluginList.Count(); i++)
+        {
+        if(iPluginList[i].iUid == loadRequestUid)
+            {
+                info = CPluginInfo::NewL(iPluginList[i].iName,
+                                         loadRequestUid.iUid,
+                                         iPluginList[i].iVersion,
+                                         TPluginRequest::EWriter);        
+                CleanupStack::PushL(info);
+                break;
+            }
+        }
+
+    if(!info)
+        {
+        LOG_MSG2("CCoreDumpSession::CreateWriterL - unable to find writer uid:%d on plugin type list!\n", loadRequestUid);
+        User::Leave(KErrArgument); 
+        }
+
+    iWriterInfos.AppendL(info);
+    CleanupStack::Pop(info);
+    
+	CCrashDataSave *writer = CCrashDataSave::NewL( (TUid)( loadRequestUid ) );
+
+    CleanupStack::PushL(writer);
+    iWriterPlugins.AppendL(writer);
+    CleanupStack::Pop(writer);
+
+    LOG_MSG3("CCoreDumpSession::CreateFormatter fmt:%d, wrt:%d\n", iFormatterPlugins.Count(), iWriterPlugins.Count());
+    //for compatibility, first pair is bound by default
+    if( (iFormatterPlugins.Count() == 1) && (iWriterPlugins.Count() == 1) )
+        {
+	        LOG_MSG("CCoreDumpSession::CreateFormatter binding default plugin pair\n" );
+            iFormatterInfos[0]->Pair(0);
+            iFormatterPlugins[0]->ConfigureDataSaveL(iWriterPlugins[0]);
+        }
+	}
+
+void CCoreDumpSession::CreateFormatterL( const TUid loadRequestUid )
+	{	
+	LOG_MSG( "->CCoreDumpSession::CreateFormatter()\n" );
+
+	ValidatePluginL( loadRequestUid );
+	
+	if(iPluginList.Count() == 0)
+		{		
+		RefreshPluginListL();
+		}
+
+    CPluginInfo *info = NULL;
+    for(TInt i = 0; i < iPluginList.Count(); i++)
+        {    	
+        if(iPluginList[i].iUid == loadRequestUid)
+            {
+                info = CPluginInfo::NewL(iPluginList[i].iName,
+                                         loadRequestUid.iUid,
+                                         iPluginList[i].iVersion,
+                                         TPluginRequest::EFormatter);        
+                CleanupStack::PushL(info);
+                break;
+            }
+        }
+
+    if(!info)
+        {
+        LOG_MSG2("CCoreDumpSession::CreateFormatterL - unable to find formatter uid:%X on plugin type list!\n", loadRequestUid);
+        User::Leave(KErrArgument);
+        }
+
+    iFormatterInfos.AppendL(info);
+    CleanupStack::Pop(info);
+
+	CCoreDumpFormatter *formatter = CCoreDumpFormatter::NewL( (TUid)( loadRequestUid ) );
+
+    CleanupStack::PushL(formatter);
+    iFormatterPlugins.AppendL(formatter);
+    CleanupStack::Pop(formatter);
+
+    LOG_MSG3("CCoreDumpSession::CreateFormatter fmt:%d, wrt:%d\n", iFormatterPlugins.Count(), iWriterPlugins.Count());
+    //for compatibility, first pair is bound by default
+    if( (iFormatterPlugins.Count() == 1) && (iWriterPlugins.Count() == 1) )
+        {
+	        LOG_MSG("CCoreDumpSession::CreateFormatter binding default plugin pair\n" );
+            iFormatterInfos[0]->Pair(0);
+            iFormatterPlugins[0]->ConfigureDataSaveL(iWriterPlugins[0]);
+        }
+	}
+
+void CCoreDumpSession::DeleteFormatterL( const TUid aFreeRequestUid, const TUint aIndex )
+{
+    LOG_MSG("->CCoreDumpSession::DeleteFormatterL()\n");
+    if( (iFormatterInfos.Count() > aIndex) && (iFormatterInfos[aIndex]->Uid() == aFreeRequestUid.iUid) )
+    {
+        delete iFormatterPlugins[aIndex];
+        iFormatterPlugins.Remove(aIndex);
+
+        delete iFormatterInfos[aIndex];
+        iFormatterInfos.Remove(aIndex);
+    }
+    else
+    {
+        User::Leave(KErrArgument);
+    }
+}
+
+void CCoreDumpSession::DeleteWriterL( const TUid aFreeRequestUid, const TUint aIndex )
+{
+    LOG_MSG("->CCoreDumpSession::DeleteWriterL()\n");
+    if( (iWriterInfos.Count() > aIndex) && (iWriterInfos[aIndex]->Uid() == aFreeRequestUid.iUid) )
+    {
+        for(TInt i = 0; i < iFormatterInfos.Count(); i++)
+        {
+            if(iFormatterInfos[i]->Pair() == aIndex)
+            {
+                iFormatterInfos[i]->Pair(KMaxTUint32);
+            }
+        }
+
+        delete iWriterPlugins[aIndex];
+        iWriterPlugins.Remove(aIndex);
+
+        delete iWriterInfos[aIndex];
+        iWriterInfos.Remove(aIndex);
+    }
+    else
+    {
+        User::Leave(KErrArgument);
+    }
+}
+
+void CCoreDumpSession::PluginRequestL(const RMessage2& aMessage)
+{
+	LOG_MSG("->CCoreDumpSession::PluginRequestL()\n");
+
+	TPluginRequest request;
+	TPtr8 pluginReqPtr((TUint8 *)&request, sizeof(TPluginRequest));
+	aMessage.ReadL(0, pluginReqPtr);
+	
+    if(request.iUid.iUid != 0) //(un)load a plugin
+    { 
+        if(request.iPluginType == TPluginRequest::EFormatter)
+        {
+            if(request.iLoad)
+            {
+                CreateFormatterL(request.iUid);
+            }
+            else
+            {
+                //index mapping compatibility  - one plugin at a time case
+                TUint index = (request.iIndex == request.iPair) ? request.iIndex : 0;
+                DeleteFormatterL(request.iUid, index);
+            }
+        }
+        else if(request.iPluginType == TPluginRequest::EWriter)
+        {
+            if(request.iLoad)
+            {
+                CreateWriterL(request.iUid);
+            }
+            else
+            {
+                //index mapping compatibility - one plugin at a time case
+                TUint index = (request.iIndex == request.iPair) ? request.iIndex : 0;
+                DeleteWriterL(request.iUid, index);
+            }
+        }
+        else
+        {
+            LOG_MSG2("CCoreDumpSession::PluginRequestL() - invalid plugin type:%d!\n", request.iPluginType);
+            User::Leave(KErrNotSupported);
+        }
+	    UpdateConfigParametersL();
+    }
+    else //bind a plugin pair
+    {
+        BindPluginsL(request.iIndex, request.iPair);
+    }
+}
+
+void CCoreDumpSession::BindPluginsL(const TUint aFormatterIndex, const TUint aWriterIndex)
+{
+   LOG_MSG3("->CCoreDumpSession::BindPluginsL(fmt=%d, wrt=%d)\n", aFormatterIndex, aWriterIndex);
+   if( (aFormatterIndex < iFormatterInfos.Count()) && (aWriterIndex < iWriterInfos.Count()) )
+   {
+        iFormatterInfos[aFormatterIndex]->Pair(aWriterIndex);
+        iFormatterPlugins[aFormatterIndex]->ConfigureDataSaveL(iWriterPlugins[aWriterIndex]);
+   }
+   else
+   {
+        LOG_MSG5("CCoreDumpSession::BindPluginsL -> fmtIndex:%d/%d wrtIndex:%d/%d\n", aFormatterIndex, iFormatterInfos.Count(),
+                                                                                     aWriterIndex, iWriterInfos.Count());
+        User::Leave(KErrNotFound);
+   }
+}
+
+CCoreDumpFormatter* CCoreDumpSession::GetValidFormatter(const TUint aCount)
+{
+    LOG_MSG2("->CCoreDumpSession::ValidFormatter(aCount=%d)", aCount);
+    TUint counter = 0;
+
+    for(TInt i = 0; i < iFormatterInfos.Count(); i++)
+    {
+        LOG_MSG3("CCoreDumpSession::ValidFormatter() - fmt[%d]->pair=%d", i, iFormatterInfos[i]->Pair());
+        if( (iFormatterInfos[i]->Pair() < iWriterInfos.Count()) && ( counter++ == aCount))
+        {
+            LOG_MSG2("CCoreDumpSession::ValidFormatter() - found valid formatter=%d", iFormatterPlugins[i]);
+            return iFormatterPlugins[i];
+        }
+    }
+    return NULL;
+}
+
+static void CleanupEComArray(TAny* aArray)
+{
+	(static_cast<RImplInfoPtrArray*> (aArray))->ResetAndDestroy();
+	(static_cast<RImplInfoPtrArray*> (aArray))->Close();
+}
+
+void CCoreDumpSession::RefreshPluginListL()
+{
+	LOG_MSG("->CCoreDumpSession::RefreshPluginList()\n");
+
+	iPluginList.Close();
+	TPluginInfo ref;
+
+	RImplInfoPtrArray infoArray;
+	TCleanupItem cleanup(CleanupEComArray, &infoArray);
+	CleanupStack::PushL(cleanup);
+    
+	CCoreDumpFormatter::ListAllImplementationsL( infoArray );
+
+	for ( TInt i = 0; i < infoArray.Count(); i++ )
+		{
+		ref.iVersion = infoArray[i]->Version();
+		ref.iName = infoArray[i]->DisplayName();
+		ref.iUid = infoArray[i]->ImplementationUid();
+		ref.iType = TPluginRequest::EFormatter;
+
+        ref.iLoaded = EFalse; //iLoaded on this list means we have an instance of that plugin
+        for(TInt j = 0; j < iFormatterInfos.Count(); j++)
+        {
+            if(iFormatterInfos[j]->Uid() == ref.iUid.iUid)
+            {
+                ref.iLoaded = ETrue;
+                break;
+            }
+        }
+
+		iPluginList.AppendL(ref);
+		}
+	
+	infoArray.ResetAndDestroy();
+
+	CCrashDataSave::ListAllImplementationsL( infoArray );
+
+	for ( TInt i = 0; i < infoArray.Count(); i++ )
+		{
+		ref.iVersion = infoArray[i]->Version();
+		ref.iName = infoArray[i]->DisplayName();
+		ref.iUid = infoArray[i]->ImplementationUid();
+		ref.iType = TPluginRequest::EWriter;
+
+        ref.iLoaded = EFalse; //iLoaded on this list means we have an instance of that plugin
+        for(TInt j = 0; j < iWriterInfos.Count(); j++)
+        {
+            if(iWriterInfos[j]->Uid() == ref.iUid.iUid)
+            {
+                ref.iLoaded = ETrue;
+                break;
+            }
+        }
+
+		iPluginList.AppendL(ref);
+		}
+
+	CleanupStack::PopAndDestroy();
+}
+
+void CCoreDumpSession::GetPluginListL(const RMessage2& aMessage)
+	{
+	//LOG_MSG("->CCoreDumpSession::GetPluginList()\n");
+
+	TListRequest listRequest; 
+
+	TPtr8 pluginReqPtr((TUint8 *)&listRequest, sizeof(TListRequest));
+
+	//read target debug app address and size from debug agent
+	aMessage.ReadL(0, pluginReqPtr);
+
+	TPluginInfoBlock * plugins = new (ELeave) TPluginInfoBlock;
+    CleanupStack::PushL(plugins);
+
+	if( 0 == listRequest.iIndex )
+		{
+		iPluginList.Reset();
+		RefreshPluginListL();
+		}
+
+	TUint toSupply = iPluginList.Count() - listRequest.iIndex;
+	if ( toSupply > KNumPluginDetails )
+		{
+		toSupply = KNumPluginDetails;
+		}
+
+	for( TUint index = 0; index < toSupply; index ++ )
+		{
+		plugins->plugins[index].iVersion		= iPluginList[index+listRequest.iIndex].iVersion;
+		plugins->plugins[index].iName			= iPluginList[index+listRequest.iIndex].iName;
+		plugins->plugins[index].iDescription	= iPluginList[index+listRequest.iIndex].iDescription;
+		plugins->plugins[index].iUid			= iPluginList[index+listRequest.iIndex].iUid;
+		plugins->plugins[index].iType			= iPluginList[index+listRequest.iIndex].iType;
+		plugins->plugins[index].iLoaded			= iPluginList[index+listRequest.iIndex].iLoaded;
+		//RDebug::Print( _L("  loaded[%d]=%d\n"), index, plugins->plugins[index].iLoaded );
+		}
+
+	listRequest.iSupplied = toSupply;
+	listRequest.iRemaining = iPluginList.Count() - (listRequest.iIndex + listRequest.iSupplied);
+
+	//RDebug::Print( _L("  supplying=%d, remaining=%d\n"), toSupply, listRequest.iRemaining );
+
+	aMessage.WriteL(0, pluginReqPtr);
+	TPtr8 pluginArrPtr( (TUint8 *)plugins, sizeof(TPluginInfoBlock) );
+	pluginArrPtr.Set( (TUint8 *)plugins, sizeof(TPluginInfoBlock), sizeof(TPluginInfoBlock) );
+
+	aMessage.WriteL(1, pluginArrPtr);
+    CleanupStack::PopAndDestroy(plugins);
+	}
+
+void CCoreDumpSession::ObservationRequestL( const RMessage2& aMessage )
+    {
+	//RDebug::Print(_L("->CCoreDumpSession::ObservationRequestL()\n"));
+    TInt deslen;
+    deslen = aMessage.GetDesLengthL(0);
+	if (deslen == 0)
+		{
+		// Zero-length target name supplied
+		User::Leave(KErrArgument);
+		}
+
+	RBuf targetName;
+	targetName.CleanupClosePushL();
+	targetName.CreateL(deslen);
+	// Read the target name into targetName
+	aMessage.ReadL(0, targetName);
+
+    deslen = aMessage.GetDesLengthL(1);
+	if (deslen == 0)
+		{
+		// Zero-length target owner name supplied
+		User::Leave(KErrArgument);
+		}
+
+	RBuf targetOwnerName;
+	targetOwnerName.CleanupClosePushL();
+	targetOwnerName.CreateL(deslen);
+	// Read the target owner name into targetOwnerName
+	aMessage.ReadL(1, targetOwnerName);
+
+    TBool observe = static_cast<TBool>(aMessage.Int2());
+    if(observe)
+        {
+        LOG_MSG("CCoreDumpSession::ObservationRequestL - KAttach\n" );
+        AttachTargetL(targetName, targetOwnerName);
+        }
+    else
+        {
+        LOG_MSG("CCoreDumpSession::ObservationRequestL - KDetach\n");
+        DetachTargetL(targetName, targetOwnerName);
+        }
+
+    CleanupStack::PopAndDestroy(&targetOwnerName);
+    CleanupStack::PopAndDestroy(&targetName);
+    }
+
+void CCoreDumpSession::AttachTargetL( const TDesC &aTargetName, const TDesC &aTargetOwnerName )
+    {
+	//LOG_MSG("->CoreDumpSession::AttachTargetL()\n");
+    TBool found = EFalse;
+
+    for(TInt i = 0; i < iObservationList.Count(); ++i)
+        {
+        if(iObservationList[i]->TargetName() == aTargetOwnerName)
+            {
+            if(aTargetName != aTargetOwnerName) //attach thread
+                {
+                iObservationList[i]->AddThreadL(aTargetName);
+                //LOG_MSG("CoreDumpSession::AttachTargetL - thread added\n");
+                }
+            else
+                {
+                LOG_MSG("CoreDumpSession::AttachTargetL - process added\n");
+                iObservationList[i]->ClearThreads();
+                } 
+            found = ETrue;
+            break;
+            }
+        }
+
+    if(!found)
+        {
+        //RDebug::Printf( "CoreDumpSession::AttachTargetL - creating new observer", &aTargetOwnerName );
+        CTargetObserver *observer = CTargetObserver::NewLC( iSecSess, *iCrashHandler, aTargetOwnerName ); 
+        User::LeaveIfError( iObservationList.Insert(observer, 0) );
+        
+        if(aTargetName != aTargetOwnerName) //attach thread
+            {
+            observer->AddThreadL(aTargetName);
+            //LOG_MSG("CoreDumpSession::AttachTargetL - thread added\n");
+            }
+
+        if( (iPreCrashEventAction & ESuspendThread) || 
+			(iPreCrashEventAction & ESuspendProcess) )
+			{
+			LOG_MSG("CCoreDumpSession::AttachTargetL() ->SetCrashEventsL(EActionSuspend)\n" );
+            SetCrashEventsL(*observer, EActionSuspend);
+			}
+        else
+			{
+			LOG_MSG("CCoreDumpSession::AttachTargetL() ->SetCrashEventsL(EActionContinue)\n" );
+            SetCrashEventsL(*observer, EActionContinue);
+			}
+
+        observer->Observe();
+
+	    //LOG_MSG("CoreDumpSession::AttachTargetL - observer started\n");
+        CleanupStack::Pop(); //observer is now in the iObservationList 
+        }
+    }
+
+void CCoreDumpSession::SetCrashEventsL(CTargetObserver &aObserver, TKernelEventAction aAction)
+{
+	LOG_MSG2("CCoreDumpSession::SetCrashEventsL(aAction=%d)\n", aAction);
+
+    if(iCrashEventTypes & ECrashHwExc)
+		{
+		LOG_MSG2("  aObserver.SetCrashEventL(EEventsHwExc, aAction=%d)\n", aAction);
+        aObserver.SetCrashEventL(EEventsHwExc, aAction);
+		}
+    else
+		{
+		LOG_MSG("  aObserver.SetCrashEventL(EEventsHwExc, EActionIgnore)\n");
+        aObserver.SetCrashEventL(EEventsHwExc, EActionIgnore);
+		}
+
+    if(iCrashEventTypes & ECrashKillThread)
+		{
+		LOG_MSG2("  aObserver.SetCrashEventL(EEventsKillThread, aAction=%d)\n", aAction);
+        aObserver.SetCrashEventL(EEventsKillThread, aAction);
+		}
+    else
+		{
+		LOG_MSG("  aObserver.SetCrashEventL(EEventsKillThread, EActionIgnore)\n");
+        aObserver.SetCrashEventL(EEventsKillThread, EActionIgnore);
+		}
+}
+
+void CCoreDumpSession::DetachTargetL( const TDesC &aTargetName, const TDesC &aTargetOwnerName )
+    {
+	//LOG_MSG("->CoreDumpSession::DetachTargetL()\n");
+    TBool found = EFalse;
+
+    RBuf ton;
+    ton.CreateL(aTargetName);
+    char *tonp = (char*) ton.Collapse().PtrZ();
+    LOG_MSG2("CCoreDumpSession::DetachTargetL(%s)\n", tonp);
+    ton.Close();
+
+    RBuf otn;
+    TInt count = iObservationList.Count();
+    for(TInt i = 0; i < count; ++i)
+        {
+        otn.CreateL(iObservationList[i]->TargetName());
+        char* otnp = (char*) otn.Collapse().PtrZ();
+        LOG_MSG3("CCoreDumpSession::DetachTargetL - iObservationList[%d]->TargetName=%s\n", i, otnp);
+        otn.Close();
+        if (iObservationList[i]->TargetName() == aTargetOwnerName)
+            {
+            if(aTargetName != aTargetOwnerName) //detach thread
+                {
+                iObservationList[i]->DelThreadL(aTargetName);
+                LOG_MSG("CoreDumpSession::DetachTargetL - thread removed\n");
+                }
+            if(iObservationList[i]->ThreadCount() == 0) //no more threads to observe or detach process
+                {
+                LOG_MSG("CoreDumpSession::DetachTargetL - destroying observer\n");
+                delete iObservationList[i]; 
+                iObservationList.Remove(i);
+                }
+            found = ETrue;
+            break;
+            }
+        }
+
+    if(!found)
+        {
+        LOG_MSG("CoreDumpSession::DetachTargetL - target not found\n");
+        User::Leave(KErrNotFound);
+        }
+    }
+
+void CCoreDumpSession::UpdateConfigParametersL()
+{
+	LOG_MSG( "->CCoreDumpSession::UpdateConfigParametersL()\n" );
+
+    COptionConfig *config = NULL;
+    iTotalConfigList.Reset();
+    TUint configParamSize;
+    
+    TInt paramNum = iConfigList.Count();
+	for(TInt i = 0; i < paramNum; i++ )
+		{
+        config = iConfigList[i];
+        
+        if(!config)
+            {
+            User::Leave(KErrBadHandle);
+            }
+
+        configParamSize = config->Size();
+        if(configParamSize > iMaxConfigParamSize)
+            {
+            iMaxConfigParamSize = configParamSize ;
+            }
+        iTotalConfigList.AppendL(config);
+		}
+
+
+    for(TInt i = 0; i < iFormatterPlugins.Count(); i++)
+        {
+        paramNum = iFormatterPlugins[i]->GetNumberConfigParametersL();
+        for(TInt index = 0; index < paramNum; index++)
+            {
+            config = iFormatterPlugins[i]->GetConfigParameterL(index);
+            if(!config)
+                {
+                User::Leave(KErrBadHandle);
+                }
+
+            configParamSize = config->Size();
+            if(configParamSize > iMaxConfigParamSize)
+                {
+                iMaxConfigParamSize = configParamSize ;
+                }
+
+            config->Instance(i); 
+            iTotalConfigList.AppendL(config);
+            }
+        }
+
+    for(TInt i = 0; i < iWriterPlugins.Count(); i++)
+        {
+        paramNum = iWriterPlugins[i]->GetNumberConfigParametersL();
+        for(TInt index = 0; index < paramNum; index++)
+            {
+            config = iWriterPlugins[i]->GetConfigParameterL(index);
+            if(!config)
+                {
+                User::Leave(KErrBadHandle);
+                }
+
+            configParamSize = config->Size();
+            if(configParamSize > iMaxConfigParamSize)
+                {
+                iMaxConfigParamSize = configParamSize ;
+                }
+
+            config->Instance(i); 
+            iTotalConfigList.AppendL(config);
+            }
+        }
+    
+    
+	TRAPD(err, iFlashDataSource->ReadSCMConfigL(iScmConfigList));
+	if(err != KErrNone)
+		{
+		LOG_MSG("Unable to retrieve config params for the SCM: [%d]");
+		return;
+		}
+	
+    for(TInt i=0;i<iScmConfigList.Count();i++)
+    	{
+    	iTotalConfigList.AppendL(iScmConfigList[i]);
+    	} 
+	}
+
+/**
+ * This logs the current SCM Config to serial 
+ */
+void CCoreDumpSession::PrintScmConfigL()
+	{	
+    for(TInt i=0;i<iScmConfigList.Count();i++)
+    	{
+    	COptionConfig* optCon = iScmConfigList[i];
+    	LOG_DES(optCon->Prompt());
+    	LOG_MSG2("\t\tHas a value of %d", optCon->Value());
+    	} 
+	}
+
+// Gather all conifg params from CDS, formatter and iWriter, 
+// collent into an array and set num to the number of configs avaliable
+void CCoreDumpSession::GetNumberConfigParametersL( const RMessage2& aMessage )
+	{
+	//LOG_MSG( "->CCoreDumpSession::GetNumberConfigParametersL()\n" );
+	 UpdateConfigParametersL( );
+
+	TInt numConfigParams = iTotalConfigList.Count();
+	//LOG_MSG2( "  numConfigParams=%d", numConfigParams );
+
+	TPtr8 numParamPtr( (TUint8 *) & numConfigParams, sizeof(TInt) );
+	// Else it does not get passed back
+	numParamPtr.Set( (TUint8 *)& numConfigParams, sizeof(TInt), sizeof(TInt) ); 
+
+	TPtr8 maxParamSizePtr( (TUint8 *) & iMaxConfigParamSize, sizeof(TInt) );
+	// Else it does not get passed back
+	maxParamSizePtr.Set( (TUint8 *)& iMaxConfigParamSize, sizeof(TInt), sizeof(TInt) ); 
+
+	/*
+	RDebug::Printf( " CCoreDumpSession::GetNumberConfigParameters(): iConfigList.Count()=%d, passing back nParams=%d, iMaxConfigParamSize=%d \n", 
+		iConfigList.Count(), numConfigParams, iMaxConfigParamSize );
+	*/
+
+	aMessage.WriteL( 0, numParamPtr );
+
+	aMessage.WriteL( 1, maxParamSizePtr );
+	}
+
+void CCoreDumpSession::GetConfigParameterL( const RMessage2& aMessage )
+	{
+//	LOG_MSG( "->CCoreDumpSession::GetConfigParameterL()\n" );
+
+
+	if(	iTotalConfigList.Count() == 0 )
+		{
+		// The user has never called GetNumberConfigParametersL(), 
+		// so update the parameters first.
+		UpdateConfigParametersL( );
+		}
+
+	if( iTotalConfigList.Count() == 0 )
+		{
+		RDebug::Printf( "  ERROR !* : Have not gathered the configuration parameters\n" );
+		User::Leave( KErrBadHandle );
+		}
+
+	TInt configIndex = aMessage.Int0();
+	//RDebug::Printf( "  configIndex=%d\n", configIndex );
+
+	if ( ( configIndex < 0 ) || ( configIndex >= iTotalConfigList.Count() ) )
+		{
+		RDebug::Printf( "  ERROR !* : config Index out of bounds\n" );
+		User::Leave( KErrBadHandle );
+		}
+
+	COptionConfig * config = iTotalConfigList[configIndex];
+	
+	HBufC8 * configDes = config->MarshalDataL();
+	CleanupStack::PushL( configDes );
+	
+	if ( configDes == NULL )
+		{
+		RDebug::Printf( "  ERROR !* MarshalData returned null buf\n" );
+		User::Leave( KErrBadDescriptor );
+		}
+	else
+		{
+		TPtr8 configPtr( configDes->Des() );
+		if( configPtr.Size() == 0 )
+			{
+			RDebug::Printf( "  ERROR !* : if( configPtr.Size() == 0 )\n" );
+			User::Leave( KErrBadDescriptor );
+			}
+
+		aMessage.WriteL( 1, configPtr );
+		}
+
+	CleanupStack::PopAndDestroy( configDes );
+	}
+
+void CCoreDumpSession::SetConfigParameterL( const RMessage2& aMessage )
+	{
+	LOG_MSG( "->CCoreDumpSession::SetConfigParameterL()\n" );
+
+	TConfigRequest configRequest; 
+	
+	TPtr8 configReqPtr( (TUint8 *)&configRequest, sizeof(TConfigRequest) );
+	aMessage.ReadL( 0, configReqPtr );
+
+	TInt32 value = aMessage.Int1();
+
+	HBufC *valueDesc = NULL;
+	TInt valueDesLen = aMessage.GetDesLength( 2 );
+	if( valueDesLen > 0 )
+		{
+		valueDesc = HBufC::NewL( valueDesLen );
+		CleanupStack::PushL( valueDesc );
+		TPtr ptr( valueDesc->Des() );
+		aMessage.ReadL( 2, ptr );
+		}
+	else
+		{
+		valueDesc = KNullDesC().AllocL();
+		CleanupStack::PushL( valueDesc );
+		}
+
+	switch(configRequest.iSource)
+		{
+		case COptionConfig::ECoreDumpServer:
+
+			SetConfigParameterL( configRequest.iIndex, value, *valueDesc );
+			break;
+
+		case COptionConfig::EFormatterPlugin:
+            {
+                if(configRequest.iInstance < iFormatterPlugins.Count())
+                    {
+                    iFormatterPlugins[configRequest.iInstance]->SetConfigParameterL(configRequest.iIndex, value, *valueDesc); 
+                    break;
+                    }
+			break;
+            }
+		case COptionConfig::EWriterPlugin:
+            {	
+                if(configRequest.iInstance < iWriterPlugins.Count())
+                    {
+                    iWriterPlugins[configRequest.iInstance]->SetConfigParameterL(configRequest.iIndex, value, *valueDesc); 
+                    break;
+                    }
+			break;
+            }
+		case COptionConfig::ESCMConfig:
+			{
+							
+    		LOG_MSG4("(CCoreDumpSession::SetConfigParameterL) Updating config param instance %d  value %d index =%d"
+    				, configRequest.iInstance , value, configRequest.iIndex);
+    		iFlashDataSource->ModifySCMConfigItemL(configRequest.iInstance, value);
+            break;
+            }
+            
+		default:
+            User::Leave(KErrArgument);
+		}
+
+	    CleanupStack::PopAndDestroy( valueDesc );
+	}
+
+
+TInt32 CCoreDumpSession::PreProcessingAction() const
+	{
+    return iConfigList[EPreCrashEventAction]->Value();
+	}
+
+TInt32 CCoreDumpSession::PostProcessingAction() const
+	{
+    return iConfigList[EPostCrashEventAction]->Value();
+	}
+
+void CCoreDumpSession::SetConfigParameterL( const TInt aIndex, 
+										 const TInt32 & aValue, 
+										 const TDesC & aDescValue )
+	{
+	LOG_MSG3( "->CCoreDumpSession::SetConfigParameterL( aIndex=%d, aValue=0x%X )\n", aIndex, aValue );
+
+	if ( ( aIndex < 0 ) || ( aIndex >= iConfigList.Count() ) )
+		{
+		LOG_MSG2( "  ERROR !* : config Index out of bounds, max=%d\n", iConfigList.Count() - 1 );
+		User::Leave( KErrBadHandle );
+		}
+
+	//Match the parameter passed in to one of our own parameters via the index
+	COptionConfig &config = *iConfigList[aIndex];
+
+	if( config.Index() != aIndex )
+		{
+		RDebug::Printf( "  ERROR !* : config Index %d does not match internal index %d\n", aIndex, config.Index() );
+		User::Leave( KErrBadHandle );
+		}
+
+	if( aIndex == (TInt)EPreCrashEventAction )
+	    {
+		switch( aValue )
+			{
+			case ENoPreAction:
+			case ESuspendThread:
+			case ESuspendProcess:
+
+				LOG_MSG2("  Changing EPreCrashEventAction to =%d\n", aValue );
+
+				iPreCrashEventAction = aValue;
+
+                for(TInt i = 0; i < iObservationList.Count(); i++)
+                    {
+                    if( (iPreCrashEventAction & ESuspendThread) || 
+						(iPreCrashEventAction & ESuspendProcess) )
+						{
+						LOG_MSG2("  SetCrashEventsL(*iObservationList[%d], EActionSuspend)\n", i );
+                        SetCrashEventsL(*iObservationList[i], EActionSuspend);
+						}
+                    else
+						{
+						LOG_MSG2("  SetCrashEventsL(*iObservationList[%d], EActionContinue);\n", i );
+                        SetCrashEventsL(*iObservationList[i], EActionContinue);
+						}
+                    }
+                
+				break;
+			default:
+				RDebug::Printf(" ERROR !* EPreCrashEventAction cannot be %d\n", aValue );
+				User::Leave(KErrArgument);
+			}
+	    }
+	else if( aIndex == (TInt)EPostCrashEventAction )
+	    {
+		switch( aValue )
+			{
+			case ENoPostAction:
+			case EResumeThread:
+			case EResumeProcess:
+			case EKillProcess:
+				iPostCrashEventAction = aValue;
+				break;
+			default:
+				RDebug::Printf(" ERROR !* EPostCrashEventAction cannot be %d\n", aValue );
+				User::Leave(KErrArgument);
+			}
+	    }
+    else if( aIndex == (TInt)ECrashEventTypes )
+        {
+		switch( aValue )
+			{
+			case ECrashHwExc:
+			case ECrashKillThread:
+			case ECrashHwExcAndKillThread:
+
+				LOG_MSG2("  Changing trigger ECrashEventTypes to =%d\n", aValue );
+				iCrashEventTypes = aValue;
+
+				for(TInt i = 0; i < iObservationList.Count(); i++)
+                    {
+                    if( (iPreCrashEventAction & ESuspendThread) || 
+						(iPreCrashEventAction & ESuspendProcess) )
+                        SetCrashEventsL(*iObservationList[i], EActionSuspend);
+                    else
+                        SetCrashEventsL(*iObservationList[i], EActionContinue);
+                    }
+
+				break;
+			default:
+				RDebug::Printf( " ERROR !* ECrashEventTypes  cannot be %d\n", aValue );
+				User::Leave(KErrArgument);
+			}
+        }
+	else
+		{
+		RDebug::Printf(
+			"CCoreDumpSession::SetConfigParameterL() : parameter with index %d does is not valid\n", 
+				aIndex );
+		User::Leave(KErrArgument);
+		}
+
+	// Change our internal values
+	config.Value( aValue );
+	//LOG_MSG( "  config->ValueL( aDescValue )\n" );
+	config.ValueL( aDescValue );
+
+	}
+
+
+
+/**
+Save one parameter for a specific section. 
+@param aParam COptionConfig pointer to save
+@param aSectName Section name in the file to save this parameter to
+@param aSaveIndex This parameter is only used to create key strings that are unique.
+@param aPersistConfigData Object used to save the configuration to. 
+*/
+void CCoreDumpSession::SaveConfigParamL( const COptionConfig * aParam, 
+									   const TPtrC	&	aSectName,
+									   const TInt		aSaveIndex,
+									   CIniDocument16 * aPersistConfigData )
+	{
+
+	LOG_MSG2( "CCoreDumpSession::SaveConfigParamL( aSaveIndex=%d )\n", aSaveIndex );
+
+	HBufC * iniStringKey;
+	TInt err;
+
+	// Save the Configuration Parameter Value
+		{
+		iniStringKey = GenerateKeyStringLC( aSaveIndex, EIniKeyValue );
+		TInt keyIntValue = aParam->Value();
+
+		// Size of character buffer required to represent a 32bit 
+		// interger as decimal should be 10.
+		TBuf<16> intValueBuf; 
+				
+		switch( aParam->Type() )
+			{
+			case COptionConfig::ETInt:
+			case COptionConfig::ETUInt:
+			case COptionConfig::ETBool:
+
+				LOG_MSG2( "  -> SetKey( int value=%d)\n", keyIntValue );
+				intValueBuf.AppendNum( keyIntValue );
+				err = aPersistConfigData->SetKey( aSectName, iniStringKey->Des(), intValueBuf );
+				
+                /*
+				const TDesC & paramV = intValueBuf;
+				RBuf valueV;
+				valueV.Create( paramV );
+				char* cl = (char*) valueV.Collapse().PtrZ();
+				RDebug::Printf("  saving integer value=%s\n", cl );
+                */
+
+				break;
+
+			case COptionConfig::ETString:
+			case COptionConfig::ETFileName:
+			case COptionConfig::ETMultiEntryEnum:
+			case COptionConfig::ETSingleEntryEnum:
+				{
+				const TDesC & paramValue = aParam->ValueAsDesc();
+
+				if( paramValue == KNullDesC )
+					{
+					LOG_MSG( "  Cannot save parameter value that is NULL\n" );	
+					CleanupStack::PopAndDestroy( iniStringKey );
+					return;
+					}
+                /*
+				RBuf value;
+				value.Create( paramValue );
+				char* cl = (char*) value.Collapse().PtrZ();
+				RDebug::Printf("  saving string value=%s\n", cl );
+                */
+
+				LOG_MSG( "  -> SetKey( string value )\n" );
+				err = aPersistConfigData->SetKey( aSectName, iniStringKey->Des(), paramValue );
+				}
+				break;
+			default:
+				{
+				// unknown type, Leave since the file could be corrupt or malformed
+				LOG_MSG2( "  Invalid COptionConfig parameter type %d\n", aParam->Type() );
+				CleanupStack::PopAndDestroy( iniStringKey );
+				User::Leave( KErrCorrupt );
+				}
+			}// switch (COptionConfig::TOptionType)
+
+		LOG_MSG( "  CleanupStack::PopAndDestroy( iniStringKey )" );
+		CleanupStack::PopAndDestroy( iniStringKey );
+		}
+
+
+
+	// Save the Configuration Parameter Index
+		{
+		iniStringKey = GenerateKeyStringLC( aSaveIndex, EIniKeyIndex );
+
+		TInt keyIndex = aParam->Index();
+		TBuf<4> intIndexBuf;
+		LOG_MSG3( "  -> keyIndex%d = parameter index %d\n", aSaveIndex, keyIndex );
+		intIndexBuf.AppendNum( keyIndex );
+
+		err = aPersistConfigData->SetKey( aSectName, iniStringKey->Des(), intIndexBuf );
+
+		CleanupStack::PopAndDestroy( iniStringKey );
+		
+		if( KErrNone != err )
+			{
+			LOG_MSG2( "  ERROR !* aPersistConfigData->AddValue() returned %d\n", err );
+			}
+		User::LeaveIfError( err );
+		}
+
+
+	// Save the Configuration Parameter Type
+		{
+		iniStringKey = GenerateKeyStringLC( aSaveIndex, EIniKeyType );
+
+		TInt keyType = aParam->Type();
+		TBuf<8> intTypeBuf;
+		LOG_MSG3( "  -> KeyType%d = parameter type %d\n", aSaveIndex, keyType );
+		intTypeBuf.AppendNum( keyType );
+
+		err = aPersistConfigData->SetKey( aSectName, iniStringKey->Des(), intTypeBuf );
+
+		CleanupStack::PopAndDestroy( iniStringKey );
+		if( KErrNone != err )
+			{
+			LOG_MSG2( "  ERROR !* aPersistConfigData->AddValue() returned %d\n", err );
+			}
+		User::LeaveIfError( err );
+		}
+	}
+
+
+
+_LIT( KPluginExtension, ".plugin" );
+#define KPluginUIDCharsPerLine 8
+
+
+_LIT( KCDSConfig,				"CoreDumpServerConfiguration"			 );
+_LIT( KWriterConfig,			"WriterConfiguration"					 );
+_LIT( KFormatterConfig,			"FormatterConfiguration"				 );
+_LIT( KObservedConfig,			"ObservedConfiguration"					 );
+
+_LIT( KDefaultIniFile, "coredumpserver.ini" );
+_LIT( KUID, "UID" );
+_LIT( KPluginPair, "Pair" );
+
+
+
+
+
+/**
+Method to parse the set of files that contain the UIDs of the allowed plugins. 
+The files are read our private directory in all drives. Thus installed .plugin
+files are also checked. 
+
+The plugin files must have the extension ".plugin". The content must be in 
+ASCII-8. The format must be one UID per line, with no empty lines. 
+The EOL can be CR+LF or just CR.
+*/
+void CCoreDumpSession::ReadPluginUidFilesL( )
+	{
+
+	RFs	fsSession;
+	CleanupClosePushL( fsSession );
+	User::LeaveIfError( fsSession.Connect() );
+
+	//RProcess thisProc;
+	
+	TDriveList driveList;
+    TVolumeInfo volInfo;
+
+    User::LeaveIfError( fsSession.DriveList( driveList ) );
+
+	HBufC* sessionPath = HBufC::NewLC( KMaxFileName );
+	TPtr privPath( sessionPath->Des() );
+
+	RBuf8 allowedPluginUidStr;
+	allowedPluginUidStr.CleanupClosePushL();
+	allowedPluginUidStr.CreateL( KPluginUIDCharsPerLine );
+
+	RFile pluginFile;
+	CleanupClosePushL( pluginFile );
+
+    for( TInt driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++ )
+    {
+        if( ( !driveList[driveNumber] ) || 
+			( KErrNone != fsSession.Volume( volInfo, driveNumber) ) ||
+			( volInfo.iDrive.iType==EMediaNotPresent ) )
+            {
+            continue;
+            }
+
+		// Get a list of the files in the private directory of drive <driveNumber> 
+
+		fsSession.SetSessionToPrivate( driveNumber );
+		User::LeaveIfError( fsSession.SessionPath( privPath ) );
+		CDir * fileList = NULL;
+
+		// KEntryAttNormal gets only files (not dirs, hidden or system files)
+		TInt ret = fsSession.GetDir( privPath, KEntryAttNormal, ESortByName, fileList );
+		if( ( KErrNone != ret ) || ( !fileList ) )
+			{
+	if( fileList )
+				delete fileList;
+			continue;
+			}
+
+		CleanupStack::PushL( fileList );
+
+		for( TInt i = 0; i < fileList->Count(); i++ )
+			{
+			TEntry fileEntry = (*fileList)[i];
+			TParse fileNameParser;
+			fileNameParser.Set( fileEntry.iName, NULL, NULL );
+			if( fileNameParser.Ext() != KPluginExtension )
+				{
+				continue;
+				}
+
+            /*
+			RBuf8 pluginFilePrint;
+			pluginFilePrint.CreateL( fileEntry.iName.Length() + 1 );
+			pluginFilePrint.Copy( fileEntry.iName );
+			char* cl = (char*) pluginFilePrint.PtrZ();
+			LOG_MSG2("    Reading .plugin file %s\n", cl );
+            */
+
+			// File extension is .plugin, so add the list of UIDs contained inside 
+			// the file to our list of allowed plugins
+			//
+			ret = pluginFile.Open( fsSession, fileEntry.iName, EFileRead );
+			if( KErrNone != ret )
+				{
+				LOG_MSG("  Error openning file. Ignoring this file\n" );
+				continue;
+				}
+
+			while( KErrNone == ret )
+				{
+				// Read the UID characters on a line. Exactly 8 * 1 byte non-UNICODE chars per line
+				ret = pluginFile.Read( allowedPluginUidStr, KPluginUIDCharsPerLine );
+				if( ( KErrNone != ret ) || (allowedPluginUidStr.Length() != KPluginUIDCharsPerLine ) )
+					{
+					// Reached the end of file, so go to the next file
+					break;
+					}
+
+				TLex8 uidLex( allowedPluginUidStr );
+				TUint pluginUidValue = 0;
+				uidLex.Val( pluginUidValue, EHex );
+				TUid allowedUid = TUid::Uid( pluginUidValue );
+				iAllowedPlugins.AppendL( allowedUid );
+
+				// Now skip the end of line character/s CR 0x0D and possibly LF 0x0A
+				ret = pluginFile.Read( allowedPluginUidStr, 1 );
+				if( ( KErrNone == ret ) && (allowedPluginUidStr.Length() == 1) )
+					{
+					//Could have read the CR or LF
+					if( 0x0D == *(allowedPluginUidStr.Ptr()) )
+						{
+						// CR should be followed by LF, so read that too
+						ret = pluginFile.Read( allowedPluginUidStr, 1 );
+						}
+					}
+
+				if( allowedPluginUidStr.Length() == 0 )
+					{
+					ret = KErrEof;
+					}
+
+				} // while have read 8 bytes
+
+			pluginFile.Close();
+			} // for each file in file list
+
+		CleanupStack::PopAndDestroy( fileList );
+		}
+	
+	CleanupStack::PopAndDestroy( &pluginFile );
+	CleanupStack::PopAndDestroy( &allowedPluginUidStr );
+	CleanupStack::PopAndDestroy( sessionPath );
+	CleanupStack::PopAndDestroy( &fsSession );
+
+	if( 0 == iAllowedPlugins.Count() )
+		{
+		LOG_MSG( "  Warning : No plugins will be allowed\n" );
+		}
+	else
+		{
+		for( TInt i=0; i < iAllowedPlugins.Count(); i++ )
+			{
+			LOG_MSG2( "  Plugin 0x%X allowed\n", iAllowedPlugins[i] );
+			}
+		}
+
+	}
+
+void CCoreDumpSession::ValidatePluginL( const TUid aPluginUid ) const
+	{
+
+	LOG_MSG2( "->CCoreDumpSession::ValidatePlugin(aPluginId=0x%X)\n", aPluginUid.iUid );
+
+	for( TInt i = 0; i < iAllowedPlugins.Count(); i++ )
+		{
+		if( iAllowedPlugins[i] == aPluginUid )
+			{
+			LOG_MSG( "  Plugin Allowed\n" );
+			return;
+			}
+		}
+	LOG_MSG( "  Plugin Not Allowed\n" );
+    User::Leave(KErrPermissionDenied);
+	}
+
+/**
+@pre aFsSession FileSystem session must have been connected to and still be active
+@post aFileName and aPersistConfigData pushed onto the stack
+*/
+void CCoreDumpSession::OpenIniFileLC( const RMessage2	* aMessage, 
+									const TBool		  aSaving,
+									RFs				& aFsSession,
+									HBufC		   *& aFileName,
+									CIniDocument16 *& aPersistConfigData )
+	{
+
+
+	LOG_MSG( "CCoreDumpSession::OpenIniFileLC(RMessage2)\n" );
+
+	TInt ret;
+
+	TInt iniFileDesLen = 0;
+
+	if( aMessage )
+		{
+		LOG_MSG( " RMessage2 != NULL\n" );
+		iniFileDesLen = aMessage->GetDesLength( 0 );
+		if( iniFileDesLen > 0 )
+			{
+			//LOG_MSG( "  User supplied ini file name\n" );
+			aFileName = HBufC::NewL( iniFileDesLen );
+
+			//LOG_MSG( "  CleanupStack::PushL( aFileName )\n" );
+			CleanupStack::PushL( aFileName );
+
+			TPtr ptr( aFileName->Des() );
+			aMessage->ReadL( 0, ptr );
+			if( !aSaving && !aFsSession.IsValidName( ptr ) )
+				{
+				// If we are loading and the file and path are incorrect
+				//LOG_MSG( "  IsValidName() == EFalse\n" );
+				User::Leave( KErrPathNotFound );
+				}
+			}
+		}
+
+	if( 0 == iniFileDesLen )
+		{
+		aFsSession.SetSessionToPrivate( EDriveE );
+
+		RBuf privPath;
+		privPath.CleanupClosePushL();
+		privPath.CreateL( KMaxFileName );
+		
+		aFsSession.SessionPath( privPath );
+
+		privPath.Append( KDefaultIniFile );
+		aFileName = HBufC::NewL( privPath.Length() );
+		*aFileName = privPath;// Copy name
+        
+		CleanupStack::PopAndDestroy( &privPath );
+
+		CleanupStack::PushL( aFileName );
+
+		if( aSaving )
+			{
+			//LOG_MSG( " aFsSession.CreatePrivatePath( EDriveE )\n" );
+			ret = aFsSession.CreatePrivatePath( EDriveE );
+			if( ( KErrNone  != ret ) && ( KErrAlreadyExists != ret ) )
+				{
+				LOG_MSG2( " aFsSession.CreatePrivatePath( EDriveE ) returned ERROR %d\n", ret );
+				User::Leave( ret );
+				}
+			}
+		}
+
+	if( aSaving  ) 
+		{
+		// delete existing file since CIniDocument16::NewL expects a correctly formed 
+		// file or no file at all. An empty file makes the NewL Leave
+		//
+		//LOG_MSG( "  -> aFsSession.Delete( aFileName->Des() )\n");
+		aFsSession.Delete( aFileName->Des() );
+		}
+    else
+    {
+        TEntry entry;
+        User::LeaveIfError(aFsSession.Entry(aFileName->Des(), entry));
+    }
+	//LOG_MSG( "  ->CIniDocument16::NewL( aFsSession, aFileName->Des() )\n");
+	TRAPD(err, aPersistConfigData = CIniDocument16::NewL( aFsSession, aFileName->Des() ));
+
+	if( KErrNone != err )
+		{
+		LOG_MSG2( "  <- CIniDocument16::NewL( ) left with %d\n", err );
+		}
+
+	CleanupStack::PushL( aPersistConfigData );
+	}
+
+
+
+_LIT( KIniFileCommentTitle,	"CoreDumpServerSettingsFile" );
+_LIT( KIniFileCommentSymbian, "Symbian_Software_Ltd" );
+_LIT( KIniFileCommentSymbianYear, "2007" );
+_LIT( KIniFileCommentVersionString,	"Version" );
+_LIT( KIniFileCommentVersionNumber,	"1.0.0" );
+
+
+/*
+* Client request to load system configuration file
+*/
+void CCoreDumpSession::SaveConfigFileL( const RMessage2* aMessage )
+	{
+	
+	LOG_MSG( "CCoreDumpSession::SaveConfigFileL(RMessage2)\n");
+
+	RFs	fsSession;
+	CleanupClosePushL( fsSession );
+	User::LeaveIfError( fsSession.Connect() );
+
+
+	HBufC * fileName = NULL;
+	CIniDocument16 * persistConfigData = NULL;
+
+	OpenIniFileLC( aMessage, ETrue, fsSession, fileName, persistConfigData );
+
+	// persistConfigData is on top of the stack, and under it is fileName
+
+	TInt ret;
+  	TPtrC uidString;
+	uidString.Set( KUID );
+	TPtrC sectName;
+
+	sectName.Set( KIniFileCommentTitle );
+	ret = persistConfigData->AddSection( sectName );
+	User::LeaveIfError( ret );
+
+	ret = persistConfigData->SetKey( sectName, KIniFileCommentSymbian, KIniFileCommentSymbianYear );
+	User::LeaveIfError( ret );
+
+	ret = persistConfigData->SetKey( sectName, KIniFileCommentVersionString, KIniFileCommentVersionNumber );
+	User::LeaveIfError( ret );
+
+	
+	sectName.Set( KCDSConfig );
+	//LOG_MSG( "    persistConfigData->AddSection( KCDSConfig )\n" );
+	ret = persistConfigData->AddSection( sectName );
+	//LOG_MSG2( "    AddSection( KCDSConfig ) returned %d", ret );
+	User::LeaveIfError( ret );
+
+	RBuf cdsUidNumberString;
+    cdsUidNumberString.CleanupClosePushL();
+	cdsUidNumberString.CreateL( 8 );
+	cdsUidNumberString.AppendNumFixedWidth( (TUint)iOurSecureID.iUid, EHex, 8 );  // Width = 8 chars
+
+	//LOG_MSG( "    persistConfigData->SetKey( KCDSConfig, uidString, cdsUidNumberString )\n" );
+	ret = persistConfigData->SetKey( sectName, uidString, cdsUidNumberString );
+	User::LeaveIfError( ret );
+
+	for( TInt i = 0; i < iConfigList.Count(); i++ )
+		{
+		SaveConfigParamL( iConfigList[i], sectName, i, persistConfigData );
+		}
+    CleanupStack::PopAndDestroy(&cdsUidNumberString);	
+
+	if( iObservationList.Count() > 0 )
+		{
+
+		//LOG_MSG( "  Saving Observed section\n");
+
+		// There is no point in saving the id of a thread since the id is not predictable 
+		// and could be used in another boot session. Thus only save the names
+		// EIniKeyValue holds Target Name EIniKeyType holds TargetOwnerName
+		// Thus a process will have both the same, so we can differentiate them
+		HBufC * iniStringTargetValue;
+		HBufC * iniStringOwnerType;
+
+		TPtrC observationSection;
+		observationSection.Set( KObservedConfig );
+		//LOG_MSG( "  persistConfigData->AddSection( KObservedConfig )\n" );
+		ret = persistConfigData->AddSection( observationSection );
+		User::LeaveIfError( ret );
+
+		TInt observeKey = 0;
+
+		for( TInt i = 0; i < iObservationList.Count(); i ++ )
+			{
+            CTargetObserver *observer = iObservationList[i];
+            TInt count = observer->ThreadCount();
+            TInt j = 0;
+            do
+                {
+                // Key string for target name
+                iniStringTargetValue = GenerateKeyStringLC( observeKey, EIniKeyValue );
+                TPtrC targetName;
+                if(count == 0) //whole process, no threads on list => targetName == targetOwnerName
+                    {
+                    targetName.Set(observer->TargetName());
+                    }
+                else
+                    {
+                    targetName.Set(observer->Thread(j));
+                    }
+
+                //LOG_MSG2( " iPersistConfigData->SetKey( KObservedConfig, target.Length()=%d )\n", targetName.Length() );
+                ret = persistConfigData->SetKey( observationSection, 
+                                                 iniStringTargetValue->Des(), 
+                                                 targetName );
+
+                CleanupStack::PopAndDestroy( iniStringTargetValue );
+                if( KErrNone != ret )
+                    {
+                    LOG_MSG2( "  ERROR !* iPersistConfigData->AddValue() for observed target returned %d\n", ret );
+                    User::Leave( ret );
+                    }
+
+                // Key string for target owner name
+                iniStringOwnerType = GenerateKeyStringLC( observeKey, EIniKeyType ); 
+                TPtrC targetOwnerName( observer->TargetName() );
+
+                LOG_MSG2( " iPersistConfigData->SetKey( KObservedConfig, targetOwner.Length()=%d )\n", targetOwnerName.Length() );
+                ret = persistConfigData->SetKey( observationSection, 
+                                                 iniStringOwnerType->Des(), 
+                                                 targetOwnerName );
+
+                CleanupStack::PopAndDestroy( iniStringOwnerType );
+                if( KErrNone != ret )
+                    {
+                    LOG_MSG2( "  ERROR !* iPersistConfigData->AddValue() for observed target owner returned %d\n", ret );
+                    User::Leave( ret );
+                    }
+
+                j++;
+				observeKey ++;
+
+                } while(j < count);
+
+			} //for(i)
+		}
+
+    TBuf<63> sectionName;
+
+
+    for(TInt i = 0; i < iFormatterPlugins.Count(); i++)
+    {
+        sectionName = KFormatterConfig;
+        sectionName.AppendFormat(_L("%d"), i);
+
+		ret = persistConfigData->AddSection( sectionName );
+        User::LeaveIfError(ret);
+
+
+   		// Add a key "UID" with a value equal to the UID of the writer, so we can load it again
+		RBuf uidNumberString;
+        uidNumberString.CleanupClosePushL();
+		uidNumberString.CreateL( 8 );
+		uidNumberString.AppendNumFixedWidth( (TUint)iFormatterInfos[i]->Uid(), EHex, 8 ); // Width = 8 chars
+		ret = persistConfigData->SetKey( sectionName, uidString, uidNumberString );
+		User::LeaveIfError( ret );
+        CleanupStack::PopAndDestroy(&uidNumberString);
+
+        TPtrC pairString;
+        pairString.Set( KPluginPair );
+
+        //Add pair key with value equal to the paired writer plugin
+		RBuf pairNumberString;
+        pairNumberString.CleanupClosePushL();
+		pairNumberString.CreateL( 8 );
+		pairNumberString.AppendNumFixedWidth( (TUint)iFormatterInfos[i]->Pair(), EHex, 8 ); // Width = 8 chars
+		ret = persistConfigData->SetKey( sectionName, pairString, pairNumberString );
+		User::LeaveIfError( ret );
+        CleanupStack::PopAndDestroy(&pairNumberString);
+
+   		for( TInt j = 0; j < iTotalConfigList.Count(); j++ )
+			{
+			if( iTotalConfigList[j] && (COptionConfig::EFormatterPlugin == iTotalConfigList[j]->Source()) && (i == iTotalConfigList[j]->Instance()))
+				{
+				SaveConfigParamL( iTotalConfigList[j], sectionName, iTotalConfigList[j]->Index(), persistConfigData );
+				}
+			}
+    }
+
+    for(TInt i = 0; i < iWriterPlugins.Count(); i++)
+    {
+        sectionName = KWriterConfig;
+        sectionName.AppendFormat(_L("%d"), i);
+
+		ret = persistConfigData->AddSection( sectionName );
+        User::LeaveIfError(ret);
+
+   		// Add a key "UID" with a value equal to the UID of the writer, so we can load it again
+		RBuf uidNumberString;
+        uidNumberString.CleanupClosePushL();
+		uidNumberString.CreateL( 8 );
+		uidNumberString.AppendNumFixedWidth( (TUint)iWriterInfos[i]->Uid(), EHex, 8 ); // Width = 8 chars
+		ret = persistConfigData->SetKey( sectionName, uidString, uidNumberString );
+		User::LeaveIfError( ret );
+        CleanupStack::PopAndDestroy(&uidNumberString);
+
+   		for( TInt j = 0; j < iTotalConfigList.Count(); j++ )
+			{
+			if( iTotalConfigList[j] && (COptionConfig::EWriterPlugin == iTotalConfigList[j]->Source()) && (i == iTotalConfigList[j]->Instance()))
+				{
+				SaveConfigParamL( iTotalConfigList[j], sectionName, iTotalConfigList[j]->Index(), persistConfigData );
+				}
+			}
+    }
+
+	if( NULL == persistConfigData )
+		{
+		LOG_MSG( "  persistConfigData == NULL\n" );
+		}
+
+	// Now save the config to file
+	ret = persistConfigData->Externalise( fileName->Des() );
+	//LOG_MSG2( "  <- iPersistConfigData->Externalise() returned %d\n", ret );
+
+	//LOG_MSG( "  CleanupStack::PopAndDestroy( iPersistConfigData )" );
+	CleanupStack::PopAndDestroy( persistConfigData );
+
+	//LOG_MSG( "  CleanupStack::PopAndDestroy( fileName )" );
+	CleanupStack::PopAndDestroy( fileName );
+
+	//LOG_MSG( "  ->CleanupStack::PopAndDestroy( fsSession )" );
+	CleanupStack::PopAndDestroy( & fsSession );
+	//LOG_MSG( "  <-CleanupStack::PopAndDestroy( fsSession )" );
+
+	}
+
+/*
+* Client request to load system configuration file
+*/
+void CCoreDumpSession::LoadConfigFileL( const RMessage2* aMessage )
+	{
+	
+
+	LOG_MSG( "CCoreDumpSession::LoadConfigFileL(RMessage2)" );
+
+	RFs	fsSession;
+	//LOG_MSG( "  User::LeaveIfError( fsSession.Connect() )\n" );
+	User::LeaveIfError( fsSession.Connect() );
+	CleanupClosePushL( fsSession );
+
+	TPtrC16 value;
+
+	HBufC * fileName = NULL;
+	CIniDocument16 * persistConfigData = NULL;
+
+	//LOG_MSG( "   -> CIniDocument16 * iPersistConfigData = OpenIniFileLC()" );
+	OpenIniFileLC( aMessage, EFalse, fsSession, fileName, persistConfigData );
+
+	//LOG_MSG( "   -> RecreateConfigurationL( iPersistConfigData )\n" );
+	RecreateConfigurationL( persistConfigData );
+
+	//LOG_MSG( "   -> CleanupStack::PopAndDestroy( iPersistConfigData )" );
+	CleanupStack::PopAndDestroy( persistConfigData );
+	//LOG_MSG( "   -> CleanupStack::PopAndDestroy( fileName )" );
+	CleanupStack::PopAndDestroy( fileName );
+	//LOG_MSG( "   -> CleanupStack::PopAndDestroy( & fsSession )" );
+	CleanupStack::PopAndDestroy( & fsSession );
+	//LOG_MSG( "   returning from CCoreDumpSession::LoadConfigFileL(RMessage2)" );
+	}
+
+
+/**
+Method used to load and unload the formatter and writer plugins as a pair.
+Also configures the data source and data save for the formatter.
+If unloading the UIDs are still checked.
+*/
+void CCoreDumpSession::SetPluginsL( const TUid aFormatterUID, 
+								  const TUid aWriterUID, 
+								  const TBool aLoad )
+	{
+	ValidatePluginL( aFormatterUID );
+
+	ValidatePluginL( aWriterUID );
+
+    /*
+	if( iFormatter )
+		{
+		delete iFormatter;
+		iFormatterUid = TUid::Uid(0);
+		}
+
+	if( iWriter )
+		{
+		delete iWriter;
+		iWriterUid = TUid::Uid(0);
+		}
+
+	if( !aLoad )
+		{
+		return;
+		}
+
+	// We push the plugins onto the cleanup stack since if we leave here we 
+	// want them destroyed so that there is always a valid pair or none are loaded
+	iWriter = CCrashDataSave::NewL( aWriterUID );
+	CleanupStack::PushL( iWriter );
+
+	iFormatter = CCoreDumpFormatter::NewL( aFormatterUID );
+	CleanupStack::PushL( iFormatter );
+
+	iFormatter->ConfigureDataSourceL( iDataSource );
+	iFormatter->ConfigureDataSaveL( iWriter );
+
+	iFormatterUid = aFormatterUID;
+	iWriterUid = aWriterUID;
+
+	// We can pop the plugins
+	CleanupStack::Pop( 2, iWriter );
+
+    */
+	}
+
+
+
+/**
+Look through the iPersistConfigData object (initialised from the ini file)
+and attempt to recreate the state described by the object.
+This means 
+ - unloading current plugins, 
+ - loading new plugins, 
+ - updating the configuration list by calling UpdateConfigParametersL()
+ - recreating the configuration for section (CDS, formatter, writer )
+
+We have to be lax about the errors since we do not want to stop the 
+loading of a configuration if there is a non-fatal error. This applies to 
+loading of the plugins.
+*/
+void CCoreDumpSession::RecreateConfigurationL( CIniDocument16 * iPersistConfigData )
+	{
+
+	// for each section in ini file, 
+	//  read section's SID
+	//  load plugins
+	//  for each (type, index, value) triplet, 
+	//    create a COptionConfig 
+	//    append to aIniFileConfigList
+	//
+
+
+	TInt ret;
+	TBool foundCdsSection = EFalse;
+	TBool foundFormatterSection = EFalse;
+	TBool foundWriterSection = EFalse;
+
+	TPtrC uidString;
+	uidString.Set( KUID );
+
+	// Recreate CDS section
+		{
+		TPtrC cdsUidString;
+		//LOG_MSG("  iPersistConfigData->GetKeyValue( KCDSConfig, uidString, cdsUidString )\n" );
+		ret = iPersistConfigData->GetKeyValue( KCDSConfig, uidString, cdsUidString );
+		//LOG_MSG2("  iPersistConfigData->GetKeyValue( ) returned %d\n", ret );
+
+		if( KErrNone == ret )
+			{
+			foundCdsSection = ETrue;
+			}
+		else
+			{
+			// It an error for there to be no saved CDS configuration 
+			User::Leave( ret );
+			}
+
+		if( foundCdsSection )
+			{
+			TLex cdsUidLex( cdsUidString );
+			TUint cdsUidValue;
+			cdsUidLex.Val( cdsUidValue, EHex );
+			TUid savedCdsUid = TUid::Uid( cdsUidValue );
+			//LOG_MSG2("  Found CDS Config Section with UID 0x%X\n", cdsUidValue );
+			//LOG_MSG2("  Current UID is 0x%X\n", iOurSecureID.iUid );
+			if( savedCdsUid != iOurSecureID )
+				{
+				// The UID for the CDS does not match our current CDS SID.
+				// This could arise if the config file was created by a previous version 
+				// of the CDS, but more likely we are reading a corrupt file.
+				// Thus the safe option is to leave
+				LOG_MSG2( "  ERROR !* Read CDS UID from ini file as 0x%X, which is not same as our current value\n",
+					cdsUidValue );
+				User::Leave( KErrCorrupt );
+				}
+			}//foundCdsSection
+		}
+
+    TBuf<63> sectionName;
+
+
+    foundWriterSection = -1;
+    for(TInt i = 0;;i++)
+    {
+        sectionName = KWriterConfig;
+        sectionName.AppendFormat(_L("%d"), i);
+
+		TPtrC writerUidString;
+		ret = iPersistConfigData->GetKeyValue( sectionName, uidString, writerUidString );
+
+   		TUint writerUidValue;
+		if( KErrNone == ret )
+			{
+            foundWriterSection++;
+			TLex writerUidLex( writerUidString );
+			writerUidLex.Val( writerUidValue, EHex );
+			CreateWriterL( TUid::Uid( writerUidValue ) );
+			}
+		else
+			{
+                break;
+			}
+
+    } 
+
+
+    foundFormatterSection = -1;
+    for(TInt i = 0;;i++)
+    {
+        sectionName = KFormatterConfig;
+        sectionName.AppendFormat(_L("%d"), i);
+
+		TPtrC formatterUidString;
+		ret = iPersistConfigData->GetKeyValue( sectionName, uidString, formatterUidString );
+
+   		TUint formatterUidValue;
+		if( KErrNone == ret )
+			{
+			foundFormatterSection++;
+			TLex fromatterUidLex( formatterUidString );
+			fromatterUidLex.Val( formatterUidValue, EHex );
+			CreateFormatterL( TUid::Uid( formatterUidValue ) );
+
+            TPtrC pairString;
+            pairString.Set( KPluginPair );
+            TPtrC formatterPairString;
+            ret = iPersistConfigData->GetKeyValue(sectionName, pairString, formatterPairString);
+            if(ret == KErrNone)
+                {
+			    TLex fromatterPairLex( formatterPairString );
+                TUint formatterPairValue;
+			    fromatterPairLex.Val( formatterPairValue, EHex );
+                BindPluginsL(i, formatterPairValue);
+                }
+            }
+		else
+			{
+                break;
+			}
+
+    }
+
+    
+	// Now that the old plugins are unloaded (if a new one was specified in the ini file),
+	// and the new ones loaded, reconstruct the list of configuration parameters. 
+	// We will then change them with the ini file values that we are about to read.
+	// For plugins that have not been unloaded (because there was no mention in the init file)
+	// we will simply ask for the config params again, and we should get the current values.
+
+	UpdateConfigParametersL();
+
+	if( foundCdsSection )
+		{
+		//LOG_MSG( "  -> ChangeConfigParamsL( COptionConfig::ECoreDumpServer\n" );
+		ChangeConfigParamsL( COptionConfig::ECoreDumpServer, iPersistConfigData );
+		}
+
+    for(TInt i = 0; i <= foundFormatterSection; i++)
+		{
+		//LOG_MSG( "  -> ChangeConfigParamsL( COptionConfig::EFormatterPlugin\n" );
+		ChangeConfigParamsL( COptionConfig::EFormatterPlugin, iPersistConfigData, foundFormatterSection );
+		}
+
+    for(TInt i = 0; i <= foundWriterSection; i++)
+		{
+		//LOG_MSG( "  -> ChangeConfigParamsL( COptionConfig::EWriterPlugin\n" );
+		ChangeConfigParamsL( COptionConfig::EWriterPlugin, iPersistConfigData, foundWriterSection );
+		}
+
+	// Now rebuild the Observed list from the file
+		{
+
+		//LOG_MSG( "  About to Rebuild Observed Target List from Ini File\n" );
+		
+		HBufC * iniTargetValue;
+		HBufC * iniOwnerType;
+		TInt observeIndex = 0;
+		TBool targetFound = ETrue;
+		while( targetFound )
+			{
+
+			// Each value obtained via EIniKeyIndex from the file is the CConfigOption index 
+			// and is used to tie the saved to the live index.
+
+			//LOG_MSG2("  GenerateKeyStringLC( EIniKeyValue =%d)\n", observeIndex );
+			iniTargetValue = GenerateKeyStringLC( observeIndex, EIniKeyValue );
+
+			TPtrC observeTargetValue;
+
+			//LOG_MSG("  iPersistConfigData->GetKeyValue( KObservedConfig, targetName )\n" );
+			ret = iPersistConfigData->GetKeyValue( KObservedConfig, 
+													iniTargetValue->Des(), 
+													observeTargetValue );
+			//LOG_MSG2("  iPersistConfigData->GetKeyValue( ) returned %d\n", ret );
+
+			CleanupStack::PopAndDestroy( iniTargetValue );
+		
+			if( KErrNone != ret )
+				{
+				LOG_MSG2( "  Could not find a target : FindVar(EIniKeyValue) index %d returned false\n", 
+					observeIndex );
+				break;
+				}
+
+			//LOG_MSG2("  GenerateKeyStringLC( EIniKeyType =%d)\n", observeIndex );
+			iniOwnerType = GenerateKeyStringLC( observeIndex, EIniKeyType );
+
+			TPtrC observeTargetOwner;
+
+			/*
+			LOG_MSG3( "  ->FindVar( KObservedConfig, target owner %d. iniOwnerType.Length()=%d\n", 
+				observeIndex, iniOwnerType->Des().Length() );
+			*/
+
+			ret = iPersistConfigData->GetKeyValue( KObservedConfig, 
+													iniOwnerType->Des(), 
+													observeTargetOwner );
+			//LOG_MSG2("  iPersistConfigData->GetKeyValue( ) returned %d\n", ret );
+
+			CleanupStack::PopAndDestroy( iniOwnerType );
+
+			if( KErrNone != ret )
+				{
+				LOG_MSG2( "  Could not find a target owner: FindVar(EIniKeyValue) index %d returned false\n", 
+					observeIndex );
+				break;
+				}
+
+			//LOG_MSG("  Creating observation request\n" );
+
+            AttachTargetL(observeTargetValue, observeTargetOwner);
+
+			observeIndex++;
+			
+			}// while targetFound
+
+		} // Now rebuild the Observed list from the file
+
+	//LOG_MSG( "  <- returning from RecreateConfigurationL()\n" );
+
+	}
+
+
+/**
+Method that reads the saved configuration and attempts to recreate that state.
+For a given section of the ini file (indicated by the parameter aSource), 
+recreate each parameter from a triplet of settings (index, type, value) 
+and then apply the setting by calling SetConfigParameterL().
+
+@param aSource Section of the config file to read and update state for. 
+@param aPersistConfigData Pointer to CIniDocument16 object that contains 
+the parameters to restore
+
+@see CIniDocument16 
+*/
+void CCoreDumpSession::ChangeConfigParamsL( const COptionConfig::TParameterSource aSource,
+										  CIniDocument16 * aPersistConfigData, const TInt aInstance)
+	{
+
+	//LOG_MSG2( "ChangeConfigParamsL( source=%d )\n", aSource );
+
+	TPtrC sectName;
+	TInt ret = KErrNone;
+
+	switch(  aSource )
+		{
+		case COptionConfig::ECoreDumpServer:
+			sectName.Set( KCDSConfig );
+			break;
+		case COptionConfig::EFormatterPlugin:
+			sectName.Set( KFormatterConfig );
+			break;
+		case COptionConfig::EWriterPlugin:
+			sectName.Set( KWriterConfig );
+			break;
+		default:
+			User::Leave( KErrArgument );
+		}
+
+
+	HBufC * iniStringKey;
+	TUint index = 0;
+
+	// Loop to recreate all the parameters for a given section and then 
+	// call SetConfigParameterL() for each parameter
+	// As soon as one of the FindVar fails, we assume that there are no more entries for
+	// this section, and thus give up.
+
+	// Parameter index
+	TInt keyIndex;
+
+	// Parameter type
+	TInt keyType;
+
+	// Parameter integer value
+	TInt keyIntValue;
+	
+	TLex paramLex;
+
+	while( KErrNone == ret )
+		{
+
+		keyIndex = ELastParam;
+		keyType = -1;
+		keyIntValue = 0;
+		TPtrC keyStringValue;
+
+		// Get parameter index
+			{
+			// Each value obtained via EIniKeyIndex from the file is the CConfigOption index 
+			// and is used to tie the saved to the live index.
+			//LOG_MSG2("  ->GenerateKeyStringLC( index=%d, EIniKeyIndex )\n", index );
+			iniStringKey = GenerateKeyStringLC( index, EIniKeyIndex );
+			TPtrC keyIndexString;
+
+			//LOG_MSG("  ->aPersistConfigData->GetKeyValue( EIniKeyIndex )\n" );
+			ret = aPersistConfigData->GetKeyValue( sectName, iniStringKey->Des(), keyIndexString );
+			CleanupStack::PopAndDestroy( iniStringKey );
+			if( KErrNone != ret )
+				{
+				LOG_MSG3("  aPersistConfigData->GetKeyValue( EIniKeyIndex ) returned %d for index %d\n", ret, index );
+				break;
+				}
+			
+			paramLex.Assign( keyIndexString );
+			keyIndex = 0;
+			paramLex.Val( keyIndex );
+			//LOG_MSG2( "  found EIniKeyIndex =%d\n", keyIndex );
+			}
+
+
+		// Get parameter type
+			{
+
+			//LOG_MSG2("  ->GenerateKeyStringLC( index=%d, EIniKeyType )\n", index );
+			iniStringKey = GenerateKeyStringLC( index, EIniKeyType );
+			TPtrC keyTypeString;
+			
+			//LOG_MSG("  ->aPersistConfigData->GetKeyValue( EIniKeyType )\n" );
+			ret = aPersistConfigData->GetKeyValue( sectName, iniStringKey->Des(), keyTypeString );
+			CleanupStack::PopAndDestroy( iniStringKey );
+			if( KErrNone != ret )
+				{
+				LOG_MSG3("  aPersistConfigData->GetKeyValue( EIniKeyType ) returned %d for index %d\n", ret, index );
+				break;
+				}
+
+			paramLex.Assign( keyTypeString );
+			paramLex.Val( keyType );
+			//LOG_MSG2( "  found EIniKeyType =%d\n", keyType );
+			}
+
+		// Get parameter value
+			{
+
+			//LOG_MSG2("  ->GenerateKeyStringLC( index=%d, EIniKeyValue )\n", index );
+			iniStringKey = GenerateKeyStringLC( index, EIniKeyValue );
+
+			//LOG_MSG( "  aPersistConfigData->GetKeyValue( EIniKeyValue )\n" );
+			ret = aPersistConfigData->GetKeyValue( sectName, iniStringKey->Des(), keyStringValue );
+			
+			//LOG_MSG2( "  aPersistConfigData->GetKeyValue( EIniKeyValue ) returned string with length=%d\n", keyStringValue.Length() );
+			CleanupStack::PopAndDestroy( iniStringKey );
+			if( KErrNone != ret )
+				{
+				LOG_MSG3("  aPersistConfigData->GetKeyValue( EIniKeyValue ) returned %d for index %d\n", ret, index );
+				break;
+				}
+
+			switch( (COptionConfig::TOptionType) keyType )
+				{
+				case COptionConfig::ETInt:
+				case COptionConfig::ETUInt:
+				case COptionConfig::ETBool:
+					paramLex.Assign( keyStringValue );
+					paramLex.Val( keyIntValue );
+					keyStringValue.Set( KNullDesC );
+					break;
+				}
+			}
+
+
+			/*
+			{
+			if( -1 != keyIntValue )
+				{
+				LOG_MSG2( "  found EIniKeyValue as Int =%d\n", keyIntValue );
+				}
+
+			RBuf value;
+			value.Create( keyStringValue );
+			char* cl = (char*) value.Collapse().PtrZ();
+			RDebug::Printf("  found EIniKeyValue as String =%s\n", cl );
+			}
+			*/
+
+		LOG_MSG3( "  SetConfigParameterL( value=%d, string length=%d\n", keyIntValue, keyStringValue.Length() );
+
+		switch(  aSource )
+			{
+
+			case COptionConfig::ECoreDumpServer:
+				SetConfigParameterL( keyIndex, keyIntValue, keyStringValue );
+				break;
+
+			case COptionConfig::EFormatterPlugin:
+
+				if( (iFormatterPlugins.Count() > 0 ) && (iFormatterPlugins.Count() < aInstance) )
+					{
+					iFormatterPlugins[aInstance]->SetConfigParameterL( keyIndex, keyIntValue, keyStringValue );
+					}
+				else
+					{
+					LOG_MSG2("CCoreDumpSession::ChangeConfigParamsL() : formatter:%d not loaded\n", aInstance);
+					User::Leave( KErrArgument );
+					}
+				break;
+
+			case COptionConfig::EWriterPlugin:
+
+				if( (iWriterPlugins.Count() > 0 ) && (iWriterPlugins.Count() < aInstance) )
+					{
+					iWriterPlugins[aInstance]->SetConfigParameterL( keyIndex, keyIntValue, keyStringValue );
+					}
+				else
+					{
+					LOG_MSG2("CCoreDumpSession::ChangeConfigParamsL() : writer:%d not loaded\n", aInstance);
+					User::Leave( KErrArgument );
+					}
+				break;
+
+			default:
+				User::Leave( KErrArgument );
+			}
+		
+		index ++;
+		}//while
+	}
+
+
+_LIT(KKey,"Key");
+_LIT(KType,"Type");
+_LIT(KIndex,"Index");
+_LIT(KValue,"Value");
+
+/**
+This method allocates a string of two concatenated components. The first component is based on 
+the parameter aKey. The second component is the string representation of aIndex.
+Thus it maps an enum to a string and then it appends the index. The string is left on the 
+cleanup stack and it is the responsibility of the caller to remove it from the cleanup stack.
+*/
+HBufC * CCoreDumpSession::GenerateKeyStringLC( TUint aIndex, 
+										 CCoreDumpSession::TCoreDumpIniKey aKey )
+	{
+
+	HBufC * keyString = HBufC::NewL( 20 );
+	CleanupStack::PushL( keyString );
+
+	TPtr ptr = keyString->Des();
+	ptr.Append( KKey );
+
+	switch( aKey )
+		{
+		case EIniKeyType:
+			ptr.Append( KType );
+			break;
+
+		case EIniKeyIndex:
+			ptr.Append( KIndex );
+			break;
+
+		case EIniKeyValue:
+			ptr.Append( KValue );
+			break;
+		}
+
+	ptr.AppendNum( aIndex );
+	return keyString;
+	}
+
+void CCoreDumpSession::SuspendProcessL(TUint64 aPid)
+    {
+    LOG_MSG("->CCoreDumpSession::SuspendProcessL()\n");
+    iDataSource->GetThreadListL( aPid, iThreadPointerList, iTotalThreadListDescSize );
+    TInt err = KErrNone;
+    for(TInt i = 0; i < iThreadPointerList.Count(); i++)
+        {
+        LOG_MSG2("CCoreDumpSession::SuspenProcessL - suspending thread:%Ld\n", iThreadPointerList[i]->Id());
+        err = iSecSess.SuspendThread(iThreadPointerList[i]->Id());
+            if( (err != KErrNone) && (err != KErrAlreadyExists) )
+            {
+            LOG_MSG2("CCoreDumpSession::SuspendProcessL - unable to suspend thread! err:%d\n", err); 
+            User::LeaveIfError(err);
+            }
+        } 
+    }
+
+void CCoreDumpSession::ResumeThreadL(TUint64 aTid)
+{
+    LOG_MSG2("->CCoreDumpSession::ResumeThreadL(aTid=%Ld)\n", aTid);
+
+    TInt err = iSecSess.ResumeThread(TThreadId(aTid));
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CCoreDumpSession::ResumeThreadL - unable to resume thread! err:%d\n", err); 
+        User::LeaveIfError(err);
+        }
+}
+
+/**
+Called to resume all the threads of the specified process. CCoreCrashHandler executes it as a post-processing action.
+@param aPid ID of process to be resumed
+@leave err one of the system wide error codes
+@see SuspendProcessL
+*/
+void CCoreDumpSession::ResumeProcessL(TUint64 aPid)
+	{
+    LOG_MSG2("->CCoreDumpSession::ResumeProcessL(aPid=%Ld)\n", aPid);
+
+    iDataSource->GetThreadListL( aPid, iThreadPointerList, iTotalThreadListDescSize );
+
+    TInt err = KErrNone;
+    //first resume child threads
+    TInt looperr = KErrNone;
+    for(TInt j = 1; j < iThreadPointerList.Count(); j++)
+        {
+        LOG_MSG2("CCoreDumpSession::ResumeProcessL - resuming thread:%Ld\n", iThreadPointerList[j]->Id());
+        looperr = iSecSess.ResumeThread( iThreadPointerList[j]->Id() );
+        if( (looperr != KErrNone) && (looperr != KErrNotFound) )
+            {
+            err = looperr;
+            LOG_MSG2("CCoreDumpSession::ResumeProcessL - unable to resume thread! err:%d\n", err);
+            }
+        }
+
+    looperr = KErrNone;
+    //then resume the main thread
+    if(iThreadPointerList.Count())
+        {
+        LOG_MSG2("CCoreDumpSession::ResumeProcessL - resuming main thread:%Ld\n", iThreadPointerList[0]->Id());
+        looperr = iSecSess.ResumeThread(iThreadPointerList[0]->Id());
+        }
+
+    if( (looperr != KErrNone) && (looperr != KErrNotFound) )
+        {
+        err = looperr;
+        LOG_MSG2("CCoreDumpSession::ResumeProcessL - unable to resume main thread! err:%d\n", err); 
+        }
+
+    User::LeaveIfError(err);
+	}
+
+
+void CCoreDumpSession::KillProcessL(TUint64 aPid)
+    {
+    LOG_MSG2("->CCoreDumpSession::KillProcessL(aPid=%Ld)\n", aPid);
+    RProcess target;
+    //LOG_MSG("CCoreDumpSession::KillProcessL - opening crashed process handle\n"); 
+    TInt err = target.Open(aPid);
+    if(err != KErrNone)
+    {
+        LOG_MSG2("CCoreDumpSession::KillProcessL - unable to open process handle! err:%d\n", err); 
+        User::Leave(err);
+    }
+
+    CleanupClosePushL(target);
+
+    TInt i;
+    for(i = 0; i < iObservationList.Count(); i++)
+        {
+        if(iObservationList[i]->TargetName().CompareF(target.FileName()) == 0) break;
+        }
+
+    ResumeProcessL(aPid);
+
+    if(i == iObservationList.Count())
+        {
+        LOG_MSG("CCoreDumpSession::KillProcessL - unable to find process observer!\n");
+        User::Leave(KErrNotFound);
+        }
+
+	LOG_MSG("  -> SetCrashEventsL(*iObservationList[i], EActionIgnore)\n" ); 
+    SetCrashEventsL(*iObservationList[i], EActionIgnore);
+
+	LOG_MSG("  -> target.Terminate(KErrAbort)\n" ); 
+    target.Terminate(KErrAbort);
+	
+	TRequestStatus logonStatus;
+	LOG_MSG("  -> target.Logon( logonStatus );\n" ); 
+	target.Logon( logonStatus );
+	LOG_MSG("  <- target.Logon( logonStatus );\n" ); 
+
+	CleanupStack::PopAndDestroy(&target); //target
+
+	User::WaitForRequest( logonStatus );
+	LOG_MSG("  <- User::WaitForRequest( logonStatus );\n" ); 
+	
+
+    if( (iPreCrashEventAction & ESuspendThread) || 
+		(iPreCrashEventAction & ESuspendProcess) )
+        SetCrashEventsL(*iObservationList[i], EActionSuspend);
+    else
+        SetCrashEventsL(*iObservationList[i], EActionContinue);
+    }
+
+/**
+ * Cleanup item implementation for SCMConfiguration
+*/
+void CCoreDumpSession::CleanupSCMConfiguration(TAny* aScmConfig)
+	{
+	SCMConfiguration* config = static_cast<SCMConfiguration*> (aScmConfig);
+	delete config;
+	config = NULL;
+	}
+
+
+//void CCoreDumpSession::ReadSCMConfigListL()
+//	{	
+//	// read the config data from the flash data source	
+//	}
+//
+//void CCoreDumpSession::WriteSCMConfigListL()
+//	{	
+//	// read the config data from the flash data source	
+//	iFlashDataSource->WriteSCMConfigL();	
+//	}
+//
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/coretargetobserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,217 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#include "coretargetobserver.h"
+
+CTargetObserver::CTargetObserver(RSecuritySvrSession &aSecSession, CCrashHandler &aHandler)
+    : CActive(CActive::EPriorityStandard),
+    iSecSess(aSecSession),
+    iHandler(aHandler),
+    iEventInfoPtr( (TUint8*)&iCrashEventInfo, 0, sizeof(TEventInfo) ) 
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CTargetObserver* CTargetObserver::NewL(RSecuritySvrSession &aSecSession, CCrashHandler &aHandler, const TDesC &aProcessName)
+{
+    LOG_MSG("->CTargetObserver::NewL()\n");
+	CTargetObserver* self = CTargetObserver::NewLC(aSecSession, aHandler, aProcessName);
+	CleanupStack::Pop(self);
+    return self;
+}
+
+CTargetObserver* CTargetObserver::NewLC(RSecuritySvrSession &aSession, CCrashHandler &aHandler, const TDesC& aProcessName)
+	{
+    LOG_MSG("->CTargetObserver::NewLC()\n");
+	CTargetObserver *self = new (ELeave) CTargetObserver(aSession, aHandler);
+	CleanupStack::PushL(self);
+	self->ConstructL(aProcessName);
+	return self;
+	}
+
+void CTargetObserver::ConstructL(const TDesC& aTargetName)
+	{
+    LOG_MSG("->CTargetObserver::ConstructL()\n");
+
+	iTargetName.CreateL(aTargetName.Length());
+	iTargetName.Copy(aTargetName);
+    
+	LOG_MSG("CTargetObserver::Observe -> AttachExecutable\n");
+    User::LeaveIfError(iSecSess.AttachExecutable( iTargetName, EFalse));
+	}
+
+void CTargetObserver::SetCrashEventL(TEventType aType, TKernelEventAction aAction)
+{
+	LOG_MSG3("->CTargetObserver::SetCrashEventL(type=%d, action=%d)\n", aType, aAction );
+    User::LeaveIfError( iSecSess.SetEventAction( iTargetName, aType, aAction ));
+}
+
+CTargetObserver::~CTargetObserver()
+	{
+    LOG_MSG("->CTargetObserver::~CTargetObserver()\n");
+	Cancel();
+	iTargetName.Close();
+    iThreadList.ResetAndDestroy();
+	}
+
+void CTargetObserver::DoCancel()
+	{
+	LOG_MSG( "CTargetObserver::DoCancel -> CancelGetEvent\n");
+    TInt err = iSecSess.CancelGetEvent( iTargetName );
+    if(err != KErrNone)
+        {
+        LOG_MSG2( "CTargetObserver::DoCancel - iSecSess.DetachExecutable returned:%d!", err);
+        //panic client?? close DSS session?? 
+        }
+
+	LOG_MSG("CTargetObserver::DoCancel -> iSecSess.DetachExecutable\n");
+    err = iSecSess.DetachExecutable( iTargetName );
+    if(err != KErrNone)
+        {
+        LOG_MSG2( "CTargetObserver::DoCancel iSecSess.DetachExecutable returned:%d!\n", err);
+        //panic client?? close DSS session?? 
+        }
+	}
+
+const TDesC& CTargetObserver::TargetName() const
+{
+    return iTargetName;
+}
+
+TInt CTargetObserver::ThreadCount() const
+{
+    return iThreadList.Count();
+}
+
+const TDesC& CTargetObserver::Thread(TInt aIndex) const
+{
+    LOG_MSG2("CTargetObserver::Thread(%d)\n", aIndex);
+    return *iThreadList[aIndex];
+}
+
+void CTargetObserver::AddThreadL(const TDesC &aThreadName)
+{
+    LOG_MSG("->CTargetObserver::AddThreadL()\n");
+
+    if(HasThread(aThreadName))
+    {
+        LOG_MSG("->CTargetObserver::AddThreadL() - already exists!\n");
+        User::Leave(KErrAlreadyExists);
+    }
+    
+    HBufC *thread;
+    thread = HBufC::NewL(aThreadName.Length());
+    *thread = aThreadName;
+    iThreadList.AppendL(thread);
+    LOG_MSG("CTargetObserver::AddThreadL - thread added\n");
+}
+
+TBool CTargetObserver::HasThread(const TDesC &aThreadName) const
+{
+    LOG_MSG("->CTargetObserver::HasThread()");
+    TInt count = iThreadList.Count();
+    for(TInt i = 0; i < count; ++i)
+    {
+        if(iThreadList[i]->Des() == aThreadName)
+        {
+            LOG_MSG("CTargetObserver::HasThreadL - thread found");
+            return ETrue;
+        }
+    }
+    LOG_MSG("CTargetObserver::HasThreadL - thread not found");
+    return EFalse;
+}
+
+void CTargetObserver::DelThreadL(const TDesC &aThreadName)
+{
+    LOG_MSG("->CTargetObserver::DelThreadL()");
+
+    TInt count = iThreadList.Count();
+    for(TInt i = 0; i < count; ++i)
+    {
+        if(iThreadList[i]->Des() == aThreadName)
+        {
+            delete iThreadList[i];
+            iThreadList.Remove(i);
+            LOG_MSG("CTargetObserver::DelThreadL - thread deleted");
+            return;
+        }
+    }
+
+    LOG_MSG("CTargetObserver::DelThreadL - thread not found!");
+    User::Leave(KErrNotFound);
+}
+
+void CTargetObserver::ClearThreads()
+{
+    LOG_MSG("->CTargetObserver::ClearThreadsL()\n");
+    iThreadList.ResetAndDestroy();
+}
+
+// RunL() completes a previously issued Observe call 
+void CTargetObserver::RunL()
+	{
+    LOG_MSG2("->CTargetObserver::RunL(status:%d)", iStatus.Int());
+	User::LeaveIfError(iStatus.Int()); //something bad happened
+
+    iCrashEventInfo.iEventTime.UniversalTime(); //not 100% exact time of the crash, but as soon as we are notified about it
+
+    Observe(); 
+
+    RThread thread;
+    LOG_MSG2("CTargetObserver::RunL() - opening handle to crashed thread:%Lu\n", iCrashEventInfo.iThreadId);
+    TInt err = thread.Open(iCrashEventInfo.iThreadId);
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CTargetObserver::RunL - unable to open thread handle! err:%d\n", err); 
+        User::Leave(err);
+        }
+    CleanupClosePushL(thread); 
+    
+    if( (iThreadList.Count() == 0) || (HasThread(thread.FullName())) )
+        {
+        //crash event of the whole process or thread that we observe
+        LOG_MSG("CTargetObserver::RunL() -> HandleCrashEventL()");
+        iHandler.HandleCrashEventL(iCrashEventInfo);
+        }
+    else //crash event of thread that we don't care about
+        {
+        LOG_MSG("CTargetObserver::RunL() - resuming crashed thread");
+        iSecSess.ResumeThread(iCrashEventInfo.iThreadId);
+        }
+    CleanupStack::PopAndDestroy(); //thread
+
+	}
+
+
+// Report any leave to the client if possible.
+TInt CTargetObserver::RunError(TInt aError)
+	{
+	return KErrNone;
+	}
+
+void CTargetObserver::Observe()
+	{
+	LOG_MSG("->CTargetObserver::Observe()\n");
+	iSecSess.GetEvent( iTargetName, iStatus, iEventInfoPtr );
+    SetActive(); //wait for crash event
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/flashdatasource.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1765 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32debug.h>
+#include <d32btrace.h>
+#include <crashlogwalker.h>
+#include <optionconfig.h>
+#include "flashdatasource.h"
+
+// Required for interface to Debug Security Server via RSecuritySvrSession
+#include "coredumpsession.h"
+
+using namespace Debug;
+
+CFlashDataSource::CFlashDataSource(RSecuritySvrSession &aSource) :
+	iSecSess(aSource),
+	iLockData(NULL),
+	iRomBuildInfo(NULL),
+	iTraceDump(NULL),
+	iVarSpecData(NULL),
+    iWalker(iFlashBuf),
+	iScmConfig(NULL),
+	iCrashFound(EFalse)
+	{
+	//no implementation
+	}
+
+/**
+ * This looks at the crash logs header and keeps note of where all the different types of data reside
+ * @return one of the OS wide system codes
+ */
+TInt CFlashDataSource::ProcessCrashHeaderL(TInt aCrashStart)
+	{
+	LOG_MSG("CFlashDataSource::ProcessCrashHeader()");
+
+	//record where the crash started
+	TInt iCrashStart = aCrashStart;
+
+	User::LeaveIfError(ReadCrashLog(iCrashStart, Debug::KMaxCoreHeaderSize));
+	User::LeaveIfError(iWalker.ReadLogHeader(0));
+
+	iHdr = iWalker.GetCrashHeader();
+	iOffsetsHdr = iWalker.GetOffsetsHeader();
+
+	if(iOffsetsHdr.iId == ESCMOffsetsHeader)
+		{
+		iOffsetsPresent = ETrue;
+		}
+
+	return KErrNone;
+	}
+
+/**
+ * attempts to read the scm config block from start of flash to see if its there
+ * @return The configuration block if found. Check for NULL and ownership is passed to caller
+ */
+SCMConfiguration* CFlashDataSource::GetSCMConfigFromFlashL()
+	{
+	LOG_MSG("CFlashDataSource::GetSCMConfigFromFlashL()");
+
+	//Always at start of flash
+	TInt scmLocation = 0;
+	Debug::SCMConfiguration* config = new Debug::SCMConfiguration();
+	CleanupStack::PushL(config);
+
+	User::LeaveIfError(ReadCrashLog(scmLocation, SCMConfiguration::KScmConfigMaxSize));
+	CleanupStack::Pop();	
+	//Put a reader on the buffer
+	TByteStreamReader rdr(const_cast<TUint8*>(iFlashBuf.Ptr()));
+	if(config->Deserialize(rdr) == KErrNone)
+		{
+
+		LOG_MSG3("CFlashDataSource::GetSCMConfigFromFlashL()  Config found. It is [%d] [0x%X] bytes in size",
+					config->GetSize(), config->GetSize());
+
+		LOG_MSG("CFlashDataSource::GetSCMConfigFromFlashL() #2");
+		return config;
+		}
+	else
+		{
+		LOG_MSG("CFlashDataSource::GetSCMConfigFromFlashL() No config found");
+		delete config;
+		return NULL;
+		}
+	}
+
+/**
+ * This looks at the entire log partition looking for where the crash of this ID
+ * begins
+ * @param aCrashId ID we are looking for
+ * @return TInt where crash starts
+ * @leave One of the OS wide codes
+ */
+TInt CFlashDataSource::GetCrashStartFromCrashIDL(TInt aCrashId)
+	{
+	LOG_MSG2("CFlashDataSource::GetCrashStartFromCrashIDL(TInt aCrashId)	 ID = %d", aCrashId);
+
+	TInt crashStart = 0;
+	TInt readStatus = KErrNone;
+
+	//Start looking where the config ends if it exists
+	Debug::SCMConfiguration* config = GetSCMConfigFromFlashL();
+	if(config)
+		{
+		crashStart = config->GetSize();
+		}
+
+	delete config;
+
+	while(readStatus == KErrNone)
+		{
+		User::LeaveIfError(ReadCrashLog(crashStart, Debug::KMaxCoreHeaderSize));
+
+		readStatus = iWalker.ReadLogHeader(0); //Look at header from start of buffer
+
+		if(readStatus != KErrNone)
+			{
+			CLTRACE("CFlashDataSource::GetCrashStartFromCrashIDL ReadCrashLogL leaving with KErrNotFound #1");
+			User::Leave(KErrNotFound);
+			}
+		else if(iWalker.GetCrashHeader().iCrashId == aCrashId)
+			{
+			return crashStart;
+			}
+
+		const TCrashInfoHeader currentHdr = iWalker.GetCrashHeader();
+
+		TUint32 flashPadding = currentHdr.iFlashBlockSize - (crashStart + currentHdr.iLogSize)%currentHdr.iFlashBlockSize;
+		crashStart += (currentHdr.iLogSize + flashPadding);
+		}
+
+	CLTRACE("CFlashDataSource::GetCrashStartFromCrashIDL ReadCrashLogL leaving with KErrNotFound #2");
+	User::Leave(KErrNotFound);
+
+	return 0;  //avoid comp warnings
+	}
+
+/**
+ * This walks the crash log verifying it is not corrupt and builds up a map of the log so that we can get the
+ * data required faster later on when the appropriate call is made.
+ * @param Crash ID to look at
+ * @leave One of the system wide error codes
+ */
+void CFlashDataSource::AnalyseCrashL(TInt aCrashId)
+	{
+	LOG_MSG2("CFlashDataSource::AnalyseCrashL(TInt aCrashId = [%d])", aCrashId);
+
+	//Reset the state
+	iOffsetsPresent = EFalse;
+	iCrashMemoryMap.Reset();
+	iCodeSegMap.Reset();
+	iHdrProcd = EFalse;
+
+    if(iCurrentCodeSegSet)
+    	{
+		delete iCurrentCodeSegSet;
+		iCurrentCodeSegSet = NULL;
+    	}
+
+    if(iLockData)
+    	{
+    	delete iLockData;
+    	iLockData = NULL;
+    	}
+
+    if(iRomBuildInfo)
+    	{
+    	delete iRomBuildInfo;
+    	iRomBuildInfo = NULL;
+    	}
+
+	TInt crashStart = GetCrashStartFromCrashIDL(aCrashId);
+	ProcessCrashHeaderL(crashStart);
+
+	TInt dataSizeRead = 0;
+	TInt flashPos = crashStart;
+
+	//either read the defined amt or the log size, whichever is less
+	TInt rdSize = READ_SIZE;
+
+	/**
+	 *	Our conditions to keep reading  or decide log is corrupt are:
+	 *	1. Have we read logSize bytes?
+	 *			No - Keep Going
+	 *			Yes - Finished
+	 *			More - Corrupt
+	 *  2. There is no more data of interest to be read. Is the number of bytes read = log size?
+	 */
+
+	TInt recommendedReadSize = 0;
+
+	while(dataSizeRead != iHdr.iLogSize)
+		{
+		//We need to decide how much to read here. It is possible that we need to read greater than the log size
+		//as the reader can't know in advance the exact size of a struct, so it has to assume the worst case scenario
+		//of the largest size it could be
+		rdSize = (rdSize < READ_SIZE) ? READ_SIZE : rdSize;	//resize this to be large
+
+		TInt bytesRemaining = iHdr.iLogSize - dataSizeRead;
+		if(rdSize > bytesRemaining)
+			{
+			rdSize = bytesRemaining;
+			}
+
+		//always be at least the rec read size
+		rdSize = (rdSize < recommendedReadSize) ? recommendedReadSize : rdSize;
+
+		User::LeaveIfError(ReadCrashLog(flashPos, rdSize));
+
+		//Get what we can out of this buffer read
+		SCMStructId id = ESCMFirst;
+		TInt bufferPos = 0;
+		MByteStreamSerializable* data = NULL;
+
+		do
+			{
+			//Have we got to end of crash?
+			if(dataSizeRead == iHdr.iLogSize)
+				{
+				break;
+				}
+
+			data = iWalker.GetNextDataTypeL(bufferPos, id, recommendedReadSize);
+
+			//Analyse what we got
+			if(data)
+				{
+				CleanupStack::PushL(data);
+				dataSizeRead += data->GetSize();
+
+				//check we are within range
+				if(dataSizeRead > iHdr.iLogSize)
+					{
+					LOG_MSG4("CFlashDataSource::AnalyseCrashL: Corrupt -->    dataSizeRead [%d] > iHdr.iLogSize [%d] at line [%d]", dataSizeRead, iHdr.iLogSize, __LINE__);
+					User::Leave(KErrCorrupt);
+					}
+
+				HelpAnalyseCrashL(data, id, flashPos + bufferPos - data->GetSize());
+				CleanupStack::PopAndDestroy(data);
+				}
+			else
+				{
+				//if data was NULL, that means there wasnt enough room in the buffer to read the next one
+				flashPos += bufferPos;
+				}
+			}
+		while(data);
+		}
+	}
+
+/**
+ * Helper for crash analysis. Takes a pointer to a data type, an ID to tell us what type it is, and where
+ * in the flash it has been found. If it is a type of interest, we record its position
+ * @param aData Data Type of interest
+ * @param aStructId ID to describe data type
+ * @param aPosFound Where it was found in the flash
+ * @leave
+ */
+void CFlashDataSource::HelpAnalyseCrashL(const MByteStreamSerializable* aData, TInt aStructId, TInt aPosFound)
+	{
+
+	switch(aStructId)
+		{
+		case ESCMMemory :
+			{
+			//we want to keep track of this objects
+			TObjectLocation map;
+			map.iOffset = aPosFound;
+			map.iObjectId = static_cast<const TMemoryDump*>(aData)->iPid;
+
+			iCrashMemoryMap.AppendL(map);
+
+			break;
+			}
+		case ESCMCodeSegSet :
+			{
+			//The set contains the PID for the code segs to follow - copy to our cached version
+			if(iCurrentCodeSegSet)
+				{
+				delete iCurrentCodeSegSet;
+				iCurrentCodeSegSet = NULL;
+				}
+
+			iCurrentCodeSegSet = new TCodeSegmentSet();
+			*iCurrentCodeSegSet = *(static_cast<const TCodeSegmentSet*>(aData));
+
+			break;
+			}
+		case ESCMCodeSeg :
+			{
+			//ensure we have a code segment set for this
+			__ASSERT_ALWAYS(iCurrentCodeSegSet, User::Leave(KErrCorrupt));
+
+			//we want to keep track of these objects
+			TObjectLocation map;
+			map.iOffset = aPosFound;
+			map.iObjectId = iCurrentCodeSegSet->iPid;
+
+			iCodeSegMap.AppendL(map);
+
+			break;
+			}
+		case ESCMRomHeader :
+			{
+			if(iRomBuildInfo)
+				{
+				delete iRomBuildInfo;
+				iRomBuildInfo = NULL;
+				}
+
+			iRomBuildInfo = new TRomHeaderData();
+			*iRomBuildInfo = *(static_cast<const TRomHeaderData*>(aData));
+
+			break;
+			}
+		case ESCMLocks:
+			{
+			if(iLockData)
+				{
+				delete iLockData;
+				iLockData = NULL;
+				}
+
+			iLockData = new TSCMLockData();
+			*iLockData = *(static_cast<const TSCMLockData*>(aData));
+
+			break;
+			}
+		case ESCMTCrashInfo :
+			{
+			iHeaderStart = aPosFound;
+
+			break;
+			}
+		case ESCMTraceData :
+			{
+			if(iTraceDump)
+				{
+				delete iTraceDump;
+				iTraceDump = NULL;
+				}
+
+			iTraceDump = new TTraceDump();
+			*iTraceDump = *(static_cast<const TTraceDump*>(aData));
+
+			break;
+			}
+		case ESCMVariantData:
+			{
+			if(iVarSpecData)
+				{
+				delete iVarSpecData;
+				iVarSpecData = NULL;
+				}
+
+			iVarSpecData = new TVariantSpecificData();
+			*iVarSpecData = *(static_cast<const TVariantSpecificData*>(aData));
+
+			break;
+			}
+		case ESCMOffsetsHeader :
+		case ESCMProcessData :
+		case ESCMThreadData :
+		case ESCMThreadStack :
+		case ESCMRegisterValue :
+		case ESCMRegisterSet :
+		case ESCMRawData :
+			{
+			//No problem if we arent interested in the object, carry on, nothing to see here
+			break;
+			}
+		default :
+			{
+			LOG_MSG2("CFlashDataSource::HelpAnalyseCrashL --> Dont recognise struct ID = [%d] therefore corrupt", aStructId);
+
+			//if we dont recognise the object, then oddness is afoot and the mist of corruption reigns thick
+			User::Leave(KErrCorrupt);
+			}
+		}
+
+	}
+
+/**
+ * This Reads the portion of the crash log of interest into our buffer for processing later
+ *
+ * @param aPos Position of crash log to begin reading
+ * @param aSize amount of data to read
+ * @return KErrArgument if aSize exceeds the maximum read allowed or one of the other OS wide codes
+ */
+TInt CFlashDataSource::ReadCrashLog(const TInt aPos, const TUint aSize)
+	{
+	//ensure parameters are ok
+	if(aPos < 0)
+		{
+		return KErrArgument;
+		}
+
+	TInt err = ReallocFlashBuf(aSize);
+	if(err != KErrNone)
+		{
+		return err;
+		}
+
+	iWalker.UpdateBuffer(iFlashBuf);
+
+	iFlashBuf.Zero();
+
+	//Read the data from the flash buffer
+	return iSecSess.ReadCrashLog(aPos, iFlashBuf, aSize);
+	}
+
+/**
+ * Two Phase Constructor for CFlashDataSource
+ * @param aSource Reference to Security Server session
+ * @return Pointer to new CFlashDataSource object
+ * @leave
+ */
+CFlashDataSource* CFlashDataSource::NewL(RSecuritySvrSession &aSource)
+{
+    CFlashDataSource *self = new(ELeave) CFlashDataSource(aSource);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+}
+
+/**
+ * second-phase constructor
+ */
+void CFlashDataSource::ConstructL()
+    {
+    //Create flash buffer. Will be resized as required
+    iFlashBuf.CreateL(KInitialBufferSize);
+    iFlashBuf.FillZ();
+
+	iScmConfig = new (ELeave) Debug::SCMConfiguration();
+	iScmConfig->SetDefaultConfig();
+
+    }
+
+/**
+ * Destructor
+ */
+CFlashDataSource::~CFlashDataSource()
+    {
+	LOG_MSG( "server_crashdatasource.cpp::CFlashDataSource::~CFlashDataSource()\n" );
+	iFlashBuf.Close();
+	iFirstBlockBuf.Close();
+
+	iCodeSegMap.Close();
+	iCrashMemoryMap.Close();
+	iThreadOwners.Close();
+
+	if(iScmConfig)
+		{
+		delete iScmConfig;
+		iScmConfig = NULL;
+		}
+
+	if(iCurrentCodeSegSet)
+		{
+		delete iCurrentCodeSegSet;
+		iCurrentCodeSegSet = NULL;
+		}
+
+	if(iLockData)
+		{
+		delete iLockData;
+		iLockData = NULL;
+		}
+
+	if(iRomBuildInfo)
+		{
+		delete iRomBuildInfo;
+		iRomBuildInfo = NULL;
+		}
+
+	if(iTraceDump)
+		{
+		delete iTraceDump;
+		iTraceDump = NULL;
+		}
+
+	if(iVarSpecData)
+		{
+		delete iVarSpecData;
+		iVarSpecData = NULL;
+		}
+
+    }
+
+void CFlashDataSource::GetRegisterListL( RRegisterList & aRegisterList )
+	{
+	//Not used
+	User::Leave(KErrNotSupported);
+	}
+
+/**
+ * Reads registers from flash for a given thread
+ * @param aThreadId Thread of interest
+ * @param aRegisterList Appends any registers found to this list
+ * @leave OS wide code
+ */
+void CFlashDataSource::ReadRegistersL( const TUint64 aThreadId, RRegisterList  & aRegisterList )
+	{
+    LOG_MSG("CFlashDataSource::ReadRegistersL()");
+
+	// Delete any objects in the array, since we will replace them.
+	aRegisterList.Reset();
+
+    /**
+     * We keep 3 sets of registers in the flash at different points.
+     * The first is the FullCPU register set for the thread that has crashed.
+     * The second are the supervisor registers for a given thread (may not all be available)
+     * The third are the user registers for a given thread (may not all be available)
+     * These corrospond to 3 different configuration options
+     */
+
+	//See if it is the crashed threads full CPU set
+	if(aThreadId == iHdr.iTid)
+		{
+	   	//Put regs into list
+	   	HelpReadRegistersL(iOffsetsHdr.iCTFullRegOffset, iHdr.iLogSize, aThreadId, aRegisterList);
+		return;
+		}
+
+	//Now we look at SVR registers
+	HelpReadRegistersL(iOffsetsHdr.iSysSvrRegOffset, iOffsetsHdr.iSysUsrRegOffset, aThreadId, aRegisterList);
+
+	//And finally the USR registers
+	HelpReadRegistersL(iOffsetsHdr.iSysUsrRegOffset, iOffsetsHdr.iSysSvrRegOffset, aThreadId, aRegisterList);
+
+	}
+
+/**
+ * This takes in a register list and looks at our flash buffer. It reads any registers it can out of the buffer
+ * and appends them to the list.
+ * @param aRegStartPoint Position in flash to begin searching from
+ * @param aMaxReadPoint Position beyond which we shall not read
+ * @param aThreadId Thread whose registers we want
+ * @param aRegList List in which to store found registers
+ * @leave KErrCorrupt if the buffer doesnt contain valid buffer data
+ */
+void CFlashDataSource::HelpReadRegistersL(TInt aRegStartPoint, TInt aMaxReadPoint, TUint64 aThreadId, RRegisterList& aRegList)
+	{
+	TRegisterValue* regVal;
+	TBool stillMoreDataToBeHad = ETrue;
+	TInt flashPos = aRegStartPoint;
+	TInt rdSize = READ_SIZE;
+
+	//cycle through the flash partition, rdSize bytes at a time until there is no more data of interest to be had
+	while(stillMoreDataToBeHad)
+		{
+		User::LeaveIfError(ReadCrashLog(flashPos, rdSize));
+
+		//Get what we can out of this buffer read
+		TInt pos, bufferSize = 0;
+		SCMStructId id = ESCMLast;
+		MByteStreamSerializable* data = NULL;
+
+		TRAPD(err, data = iWalker.GetNextDataTypeL(pos, id, bufferSize));
+		if(err != KErrNone)
+			{
+			return; //We dont mind if this returns corrupt. This is only relevant during initial analysis
+			}
+
+		while(data && stillMoreDataToBeHad)
+			{
+			CleanupStack::PushL(data);
+
+			switch(id)
+				{
+				case ESCMRegisterSet :
+					{
+					break;
+					}
+				case ESCMRegisterValue :
+					{
+					regVal = static_cast<TRegisterValue*>(data);
+
+			    	//See if its for the right thread
+			    	if(regVal->iOwnId != aThreadId)
+			    		{
+			    		break;
+			    		}
+
+			    	TRegisterData newData;
+			    	ConvertFlashFormatRegL(newData, *regVal);
+			    	aRegList.AppendL(newData);
+
+					break;
+					}
+
+				//Dont care bout these
+				case ESCMFirst :
+				case ESCMOffsetsHeader :
+				case ESCMTCrashInfo :
+				case ESCMThreadData :
+				case ESCMThreadStack :
+				case ESCMMemory :
+				case ESCMCodeSegSet :
+				case ESCMCodeSeg :
+				case ESCMRawData :
+				case ESCMLast :
+				default :
+					{
+					//No more registers mean no more interest
+					stillMoreDataToBeHad = EFalse;
+					}
+				}
+
+			CleanupStack::PopAndDestroy(data);
+
+			//ignore beyond the max point
+			if(pos + flashPos == aMaxReadPoint)
+				{
+				return;
+				}
+				
+			if(stillMoreDataToBeHad)
+				{
+				//Get next type
+				TRAPD(err, data = iWalker.GetNextDataTypeL(pos, id, bufferSize));
+				if(err != KErrNone)
+					{
+					//We dont mind if this returns corrupt. This is only relevant during initial analysis
+					return;
+					}
+				}
+			}
+
+		//if data was null but there is still more data to be had, that means we need to read more data
+		//from the flash to give to our walker. it will need a buffer size of at least bufferSize, starting
+		//from flashPos + pos
+		flashPos += pos;
+		rdSize = (bufferSize > rdSize) ? bufferSize : rdSize;
+
+		}
+	}
+
+/**
+ * Helper to convert between register value formats
+ * @param aData Output format of the register data
+ * @param aOriginalVal register format as it appears in flash
+ */
+void CFlashDataSource::ConvertFlashFormatRegL(TRegisterData& aData, const TRegisterValue& aOriginalVal)
+	{
+
+	aData.iRegClass = aOriginalVal.iClass;
+	aData.iSubId = aOriginalVal.iSubId;
+	aData.iId = aOriginalVal.iType;
+	aData.iSize = aOriginalVal.iSize;
+	aData.iAvailable = ETrue;
+
+	switch(aOriginalVal.iSize)
+		{
+		case 0:
+			{
+			aData.iValue8 = aOriginalVal.iValue8;
+			break;
+			}
+		case 1:
+			{
+			aData.iValue16 = aOriginalVal.iValue16;
+			break;
+			}
+		case 2:
+			{
+			aData.iValue32 = aOriginalVal.iValue32;
+			break;
+			}
+		case 3:
+			{
+			aData.iValue64 = aOriginalVal.iValue64;
+			break;
+			}
+		//funny data, run for the hills
+		default: User::Leave(KErrCorrupt);
+		}
+	}
+
+/**
+Purpose:
+Read memory if dumped into the flash. The parameters relate to those when
+the system was live and running. If this memory region has not been dumped
+this leaves with a KErrNotFound
+
+@param aThreadId - The id of the thread relative to which the read should take place
+@param aAddress - The virtual address to read from
+@param aLength - The number of bytes to read
+@param aData - The buffer to read into
+@leave KErrNotFound if memory not available or one of the system wide codes
+*/
+void CFlashDataSource::ReadMemoryL(
+                   const TUint64    aThreadId,
+                   const TUint32    aAddress,
+                   const TUint32    aLength,
+                   TDes8          & aData )
+	{
+	LOG_MSG4("CFlashDataSource::ReadMemoryL ThreadID = [%ld] aAddress = [0x%X] aLength = [%d]", aThreadId, aAddress, aLength);
+
+	if(aLength == 0)
+		{
+		return;
+		}
+
+	//check arguments
+	if(aData.MaxLength() < aLength)
+		{
+		User::Leave(KErrOverflow);
+		}
+
+	const TUint64 procId = GetThreadOwnerL(aThreadId);
+	TInt errFound = KErrNone;
+
+	//Look through our memory map to see if we have anything for this thread
+	TInt cnt = iCrashMemoryMap.Count() - 1;
+	for(; cnt >= 0; cnt-- )
+		{
+		TObjectLocation& m = iCrashMemoryMap[cnt];
+
+		if(m.iObjectId == procId)
+			{
+			TInt sizeToRead = TMemoryDump::KSCMMemDumpMaxSize;
+
+			//we must read this struct to check if we are interested in it
+			User::LeaveIfError(ReadCrashLog(m.iOffset, sizeToRead));
+
+			TInt pos = 0;
+			SCMStructId id = ESCMLast;
+
+			MByteStreamSerializable* data = iWalker.GetNextDataTypeL(pos, id, sizeToRead);
+
+			if(id != ESCMMemory)
+				{
+				delete data;
+				errFound = KErrCorrupt;
+				//Still keep looking through the memory list
+				continue;
+				}
+
+			TMemoryDump* memDump = static_cast<TMemoryDump*>(data);
+			CleanupStack::PushL(memDump);
+
+			//have we dumped this memory
+			if(aAddress >= memDump->iStartAddress   && (aAddress + aLength) <= (memDump->iStartAddress + memDump->iLength))
+				{
+				//Now we need to read in the Raw data structure
+				User::LeaveIfError(ReadCrashLog(m.iOffset + memDump->GetSize(), TRawData::KSCMRawDataMaxSize + memDump->iLength));
+
+				TInt bufSize = 0;
+				TRawData* rawData = iWalker.GetRawDataTypeL(pos, bufSize, aData, aAddress - memDump->iStartAddress);
+				if(!rawData)
+					{
+					//descriptor not big enough
+					errFound = KErrOverflow;
+					CleanupStack::PopAndDestroy();
+
+					//Still keep looking through the memory list
+					continue;
+					}
+
+				CleanupStack::PushL(rawData);
+
+				//Now we need to copy into the buffer supplied
+				//aData.Copy(rawData->iData.Mid(memDump->iStartAddress - aAddress , aLength));
+
+				CleanupStack::PopAndDestroy(2);
+
+				return;
+				}
+
+			CleanupStack::PopAndDestroy();
+			}
+		}
+
+	if(errFound == KErrNone)
+		User::Leave(KErrNotFound);
+	else
+		User::Leave(errFound);
+
+	}
+
+void CFlashDataSource::GetProcessListL( RProcessPointerList & aProcessList,
+											  TUint & aTotalProcessListDescSize )
+    {
+    LOG_MSG("CFlashDataSource::GetProcessListL()");
+
+	// Delete any objects in the array, since we will replace them.
+	aProcessList.ResetAndDestroy();
+	aTotalProcessListDescSize = 0;
+
+    //Find out where in flash to read from
+    TInt flashPos = iOffsetsHdr.iPLstOffset;
+    TInt rdSize = READ_SIZE;
+    TBool stillMoreDataToBeHad = ETrue;
+
+	//cycle through the flash partition, rdSize bytes at a time until there is no more data of interest to be had
+	while(stillMoreDataToBeHad)
+		{
+		User::LeaveIfError(ReadCrashLog(flashPos, rdSize));
+
+		//Get what we can out of this buffer read
+		TInt pos, bufferSize = 0;
+		SCMStructId id = ESCMLast;
+		MByteStreamSerializable* data = NULL;
+		TProcessData* proc = NULL;
+
+		TRAPD(err, data = iWalker.GetNextDataTypeL(pos, id, bufferSize));
+		if(err != KErrNone)
+			{
+			return; //We dont mind if this returns corrupt. This is only relevant during initial analysis
+			}
+
+		while(data && stillMoreDataToBeHad)
+			{
+			CleanupStack::PushL(data);
+
+			switch(id)
+				{
+				case ESCMProcessData :
+					{
+					proc = static_cast<TProcessData*>(data);
+
+			    	//Now we need to widen the name descriptor to 16 bits
+			    	RBuf name16;
+			    	name16.CreateL(proc->iNamesize);
+			    	name16.CleanupClosePushL();
+
+			    	name16.Copy(proc->iName);
+
+			    	//create the new process object
+			    	CProcessInfo* pi = CProcessInfo::NewL(proc->iPid, name16);
+			    	aProcessList.AppendL(pi);
+
+			    	aTotalProcessListDescSize += pi->Size();
+
+			    	CleanupStack::PopAndDestroy();
+
+					break;
+					}
+				case ESCMFirst :
+				case ESCMOffsetsHeader :
+				case ESCMTCrashInfo :
+				case ESCMThreadData :
+				case ESCMThreadStack :
+				case ESCMRegisterValue :
+				case ESCMRegisterSet :
+				case ESCMMemory :
+				case ESCMCodeSegSet :
+				case ESCMCodeSeg :
+				case ESCMRawData :
+				case ESCMLast :
+				default :
+					{
+					//No more registers mean no more interest
+					stillMoreDataToBeHad = EFalse;
+					}
+				}
+
+			CleanupStack::PopAndDestroy(data);
+
+			//Get next type
+			TRAPD(err, data = iWalker.GetNextDataTypeL(pos, id, bufferSize));
+			if(err != KErrNone)
+				{
+				//We dont mind if this returns corrupt. This is only relevant during initial analysis
+				return;
+				}
+
+			}
+
+		if(data)
+			{
+			delete data;
+			}
+
+		//if data was null but there is still more data to be had, that means we need to read more data
+		//from the flash to give to our walker. it will need a buffer size of at least bufferSize, starting
+		//from flashPos + pos
+		flashPos += pos;
+		rdSize = (bufferSize > rdSize) ? bufferSize : rdSize;
+
+		}
+	}
+
+void CFlashDataSource::GetExecutableListL( RExecutablePointerList & aExecutableList,
+											  TUint & aTotalExecutableListDescSize )
+    {
+    //TODO
+    User::Leave(KErrNotSupported);
+	}
+
+/**
+ * Creates an ownership relation between a thread and a process. As when the board crashes we cant
+ * find this out from the system, we need to generate it as we go
+ * @param aOwningProcessId The owning process ID
+ * @param aThreadId The child thread ID
+ */
+void CFlashDataSource::AssignOwner(TInt64 aOwningProcessId, TInt64 aThreadId)
+	{
+	TChildOwnerPair pair(aOwningProcessId, aThreadId);
+	iThreadOwners.Append(pair);
+	}
+
+/**
+ * Obtain the thread list. If aProcessId is (TUint64 -1), we obtain the entire system
+ * thread list. If aProcessId is positive we get the thread list for that process
+ *
+ * @param aProcessId Process to gather threads for
+ * @param aThreadList Thread list stored here
+ * @param aTotalThreadListDescSize list size
+ * @leave One of the OS wide system codes
+ */
+void CFlashDataSource::GetThreadListL( const TUint64 aProcessId,
+											 RThreadPointerList & aThreadList,
+											 TUint & aTotalThreadListDescSize )
+	{
+    LOG_MSG("CFlashDataSource::GetThreadListL()");
+
+	// Delete any objects in the array, since we will replace them.
+    aThreadList.ResetAndDestroy();
+	aTotalThreadListDescSize = 0;
+
+    //Find out where in flash to read from
+    TInt flashPos = iOffsetsHdr.iTLstOffset;
+    TInt rdSize = READ_SIZE;
+    TBool stillMoreDataToBeHad = ETrue;
+
+	//cycle through the flash partition, rdSize bytes at a time until there is no more data of interest to be had
+	while(stillMoreDataToBeHad)
+		{
+		User::LeaveIfError(ReadCrashLog(flashPos, rdSize));
+
+		//Get what we can out of this buffer read
+		TInt pos, bufferSize = 0;
+		SCMStructId id = ESCMLast;
+		MByteStreamSerializable* data = NULL;
+		TThreadData* thread = NULL;
+
+		TRAPD(err, data = iWalker.GetNextDataTypeL(pos, id, bufferSize));
+		if(err != KErrNone)
+			{
+			return; //We dont mind if this returns corrupt. This is only relevant during initial analysis
+			}
+
+		while(data && stillMoreDataToBeHad)
+			{
+			CleanupStack::PushL(data);
+
+			switch(id)
+				{
+				case ESCMThreadData :
+					{
+					thread = static_cast<TThreadData*>(data);
+
+					AssignOwner(thread->iOwnerId, thread->iTid);
+
+					if(aProcessId == thread->iOwnerId || aProcessId == ((TUint64)-1))
+						{
+				    	//Now we need to widen this descriptor to 16 bits
+				    	RBuf name16;
+				    	name16.CreateL(thread->iNamesize);
+				    	name16.CleanupClosePushL();
+				    	name16.Copy(thread->iName);
+
+				    	//Get the thread info object and add it to the thread list
+			    		CThreadInfo* tinfo = CThreadInfo::NewL(thread->iTid,
+			    												name16,
+			    												thread->iOwnerId,
+			    												thread->iPriority,
+			    												thread->iSvcSP,
+			    												thread->iSvcStack,
+			    												thread->iSvcStacksize,
+			    												thread->iUsrStack,
+			    												thread->iUsrStacksize);
+
+						// note - to minimize changes elsewhere last cpu id not added
+			    		// to CThreadInfo c'tor - rather
+			    		//Until the SMP work is done: tinfo->SetLastCpuId(thread->iLastCpu);
+			    		tinfo->SetHeapBase(thread->iSvcHeap);
+			    		tinfo->SetHeapSize(thread->iSvcHeapSize);
+			    		aThreadList.AppendL(tinfo);
+			    		aTotalThreadListDescSize += tinfo->Size();
+
+			    		CleanupStack::PopAndDestroy();
+						}
+
+					break;
+					}
+				case ESCMFirst :
+				case ESCMOffsetsHeader :
+				case ESCMTCrashInfo :
+				case ESCMProcessData :
+				case ESCMThreadStack :
+				case ESCMRegisterValue :
+				case ESCMRegisterSet :
+				case ESCMMemory :
+				case ESCMCodeSegSet :
+				case ESCMCodeSeg :
+				case ESCMRawData :
+				case ESCMLast :
+				case ESCMTraceData :
+				default :
+					{
+					//No more registers mean no more interest
+					stillMoreDataToBeHad = EFalse;
+					}
+				}
+
+			CleanupStack::PopAndDestroy(data);
+
+			//Get next type
+			TRAPD(err, data = iWalker.GetNextDataTypeL(pos, id, bufferSize));
+			if(err != KErrNone)
+				{
+				//We dont mind if this returns corrupt. This is only relevant during initial analysis
+				return;
+				}
+
+			}
+
+		if(data)
+			{
+			delete data;
+			}
+
+		//if data was null but there is still more data to be had, that means we need to read more data
+		//from the flash to give to our walker. it will need a buffer size of at least bufferSize, starting
+		//from flashPos + pos
+		flashPos += pos;
+		rdSize = (bufferSize > rdSize) ? bufferSize : rdSize;
+
+		}
+	}
+
+/**
+ * Gets the owning process of this thread id
+ * @param aThreadId Thread ID of interest
+ * @return Owning process ID
+ * @leave One of the OS wide codes
+ */
+TUint64 CFlashDataSource::GetThreadOwnerL(TUint64 aThreadId)
+	{
+	for(TInt cnt = 0; cnt < iThreadOwners.Count(); cnt++)
+		{
+		TChildOwnerPair pair = iThreadOwners[cnt];
+		if(pair.iChildId == aThreadId)
+			{
+			return pair.iOwnerId;
+			}
+		}
+
+	User::Leave(KErrNotFound);
+
+	return 0;   //avoid warnings
+	}
+
+/**
+ * Obtains the code segment list for a given thread.
+ * @param aTid Thread identifier to obtain code segments for.
+ * @param aCodeSegList Array of code segments.
+ * @param aTotalCodeSegListDescSize Size in bytes of the descriptor
+ * @leave One of the OS wide system codes
+ */
+void CFlashDataSource::GetCodeSegmentsL( const TUint64 aTid, RCodeSegPointerList &aCodeSegList, TUint & aTotalCodeSegListDescSize )
+	{
+	TUint64 ownerId = 0;
+	TRAPD(err, ownerId = GetThreadOwnerL(aTid));
+
+	if(KErrNone == err)
+		{
+		GetCodeSegmentsFromPIDL(ownerId, aCodeSegList, aTotalCodeSegListDescSize);
+		}
+	}
+
+/**
+ * Obtains the code segment list for a given thread.
+ * @param aPid Process identifier to obtain code segments for.
+ * @param aCodeSegList Array of code segments.
+ * @param aTotalCodeSegListDescSize Size in bytes of the descriptor
+ * @leave One of the OS wide system codes
+ */
+void CFlashDataSource::GetCodeSegmentsFromPIDL( const TUint64 aPid, RCodeSegPointerList &aCodeSegList, TUint & aTotalCodeSegListDescSize )
+	{
+	LOG_MSG("CFlashDataSource::GetCodeSegmentsL()");
+
+	//sort out arguments
+	aTotalCodeSegListDescSize = 0;
+	aCodeSegList.ResetAndDestroy();
+
+	//Look through our code seg map to see if we have anything for this process
+	TInt cnt = iCodeSegMap.Count() - 1;
+
+	for(; cnt >= 0; cnt-- )
+		{
+		//Look through
+		TObjectLocation location = iCodeSegMap[cnt];
+
+		//see if we have code segments for this thread ID
+		if(location.iObjectId == aPid)
+			{
+			TInt bufferSize = TCodeSegment::KSCMCodeSegMaxSize;
+
+			//we must read this struct to check if we are interested in it
+			User::LeaveIfError(ReadCrashLog(location.iOffset, bufferSize));
+
+			TInt pos = 0;
+			SCMStructId id = ESCMLast;
+
+			MByteStreamSerializable* data = iWalker.GetNextDataTypeL(pos, id, bufferSize);
+			CleanupStack::PushL(data);
+
+			if(id != ESCMCodeSeg || !data)
+				{
+				CleanupStack::PopAndDestroy(data);
+				break;
+				}
+
+			TCodeSegment* seg = static_cast<TCodeSegment*>(data);
+
+			//take our flash structure and turn it into what we need
+			TCodeSegInfo* segInfo = new TCodeSegInfo();
+			CleanupStack::PushL(segInfo);
+
+			segInfo->iXIP = seg->iXip;
+			segInfo->iType = seg->iCodeSegType;
+
+			TModuleMemoryInfo memInfo = seg->iCodeSegMemInfo;
+
+			segInfo->iCodeSize = memInfo.iCodeSize;
+			segInfo->iCodeRunAddr = memInfo.iCodeBase;
+			segInfo->iRoDataSize = memInfo.iConstDataSize;
+			segInfo->iRoDataRunAddr = memInfo.iCodeBase + memInfo.iCodeSize;
+			segInfo->iDataSize = memInfo.iInitialisedDataSize + memInfo.iUninitialisedDataSize;
+			segInfo->iDataRunAddr = memInfo.iInitialisedDataBase;
+
+			//if the code seg is XIP then these are the same
+			if(segInfo->iXIP)
+				{
+				segInfo->iCodeLoadAddr = segInfo->iCodeRunAddr;
+				segInfo->iRoDataLoadAddr = segInfo->iRoDataRunAddr;
+				segInfo->iDataLoadAddr = segInfo->iDataRunAddr;
+				}
+			else
+				{
+				segInfo->iRoDataLoadAddr = 0; // as per current serverdatasource (dont worry for the moment)
+				segInfo->iCodeLoadAddr = 0; // as per current serverdatasource (dont worry for the moment)
+				segInfo->iDataLoadAddr = 0; // as per current serverdatasource (dont worry for the moment)
+				}
+
+			TFileName name;
+			name.Copy(seg->iName);
+
+			segInfo->iName = name;
+
+			// crashed process code segments may have been added twice to the list as they are added
+			// for the crashed process and for all processes
+
+			TBool found = EFalse;
+			for(TInt k=0;k<aCodeSegList.Count();k++)
+				{
+				const TCodeSegInfo& si = * aCodeSegList[k];
+				if(si.iDataRunAddr ==  segInfo->iDataRunAddr && si.iDataSize == segInfo->iDataSize)
+					{
+					found = ETrue;
+
+					LOG_MSG4("XXX CFlashDataSource::GetCodeSegmentsFromPIDL FOUND DUPLICATE MATCH k[%d]segInfo->iDataRunAddr[%x] segInfo->iDataSize[%d]"
+							, k
+							, segInfo->iDataRunAddr
+							, segInfo->iDataSize );
+
+					break;
+					}
+				}
+
+			if(!found)
+				{
+				aCodeSegList.AppendL(segInfo);
+				CleanupStack::Pop(segInfo);
+				}
+			else
+				{
+				CleanupStack::PopAndDestroy(segInfo);
+				}
+
+			CleanupStack::PopAndDestroy(data);
+			}
+		}
+
+	}
+
+/**
+ * Gets the size of the trace buffer that is available
+ */
+TUint CFlashDataSource::GetAvailableTraceSizeL()
+	{
+	CLTRACE("Start CFlashDataSource::GetAvailableTraceSizeL()");
+
+	if(iTraceDump)
+		{
+		return iTraceDump->iSizeOfMemory;
+		}
+	else
+		{
+		User::Leave(KErrNotFound);
+		}
+
+	return 0; //comp warnings
+	}
+
+/**
+ Reads data from the trace buffer into the supplied descriptor
+ @param aTraceData The buffer to be read into
+ @param aPos Position in trace buffer to read from
+ @leave KErrArgument if aPos is greater than the memory available or one of the other system wide codes
+*/
+void CFlashDataSource::ReadTraceBufferL(TDes8 &aTraceData, TUint aPos)
+	{
+    CLTRACE2("CFlashDataSource::ReadTraceBufferL() from aPos = [%d] into a buffer of [%d]", aPos, aTraceData.MaxLength());
+
+    aTraceData.Zero();
+
+    if(!iTraceDump)
+    	User::Leave(KErrNotFound);
+
+    CLTRACE1("traceDump->iNumberOfParts=%d", iTraceDump->iNumberOfParts);
+    TUint nextRawDataPos = iOffsetsHdr.iTraceOffset + iTraceDump->GetSize();
+    TInt currentTracePos = 0;
+
+	//Because the trace is a circular buffer it must be read in parts and therefore dumped on the flash
+	//in parts - ie. TRawData structs. Must read each of these and append to trace data
+    for(TInt part = 0; part < iTraceDump->iNumberOfParts; part++)
+		{
+		User::LeaveIfError(ReadCrashLog(nextRawDataPos, TRawData::KSCMRawDataMaxSize));
+
+		TInt nextRead = 0;
+		SCMStructId id = ESCMLast;
+		TInt nextBufSize = 0;
+
+		MByteStreamSerializable* theRawness = iWalker.GetNextDataTypeL(nextRead, id, nextBufSize);
+		if(theRawness && id == ESCMRawData)
+			{
+			TRawData* raw = static_cast<TRawData*>(theRawness);
+			CleanupStack::PushL(theRawness);
+
+			//Read the trace into the trace buffer
+			TUint rdSize = raw->iLength;
+			TUint rdPos = nextRawDataPos + TRawData::KSCMRawDataMaxSize;
+
+			if(aPos >= (currentTracePos + raw->iLength))
+				{
+				//no dumpage
+				}
+			else
+				{
+				if(aPos >= currentTracePos)
+					{
+					rdSize = currentTracePos + raw->iLength - aPos;
+					rdPos += aPos - currentTracePos;
+					}
+
+				ReadRawFlashL(aTraceData,  rdPos, rdSize);
+				}
+
+			nextRawDataPos += raw->GetSize();
+			currentTracePos += raw->iLength;
+
+			CleanupStack::PopAndDestroy(theRawness);
+			}
+		else
+			{
+			User::Leave(KErrNotFound);
+			}
+		}
+	}
+
+/**
+ * This allows us to read directly from the flash into a buffer of our choosing
+ * @param aDestinationBuffer This is the buffer we will read that data into. It will be appended on to the end of this descriptor
+ * @param aReadPos Point in flash from which to read
+ * @param aReadSize Amount of data to read. If this is greater than the space in aDestinationBuffer, not all the data will be read
+ * @leave one of the system wide codes
+ */
+void CFlashDataSource::ReadRawFlashL(TDes8& aDestinationBuffer, TUint aReadPos, TUint aReadSize)
+	{
+	TUint8* destination = const_cast<TUint8*>(aDestinationBuffer.Ptr());
+	TUint spaceInBuffer = aDestinationBuffer.MaxLength() - aDestinationBuffer.Length();
+	TUint rdSize = (aReadSize > spaceInBuffer) ? spaceInBuffer : aReadSize;
+
+	//Give it a ptr starting at the end of the desc so it doesnt overwrite any data already there (ReadCrashLog always writes the data from 0)
+	TPtr8 ptr(destination + aDestinationBuffer.Length(), aDestinationBuffer.MaxLength() - aDestinationBuffer.Length());
+
+	User::LeaveIfError(iSecSess.ReadCrashLog(aReadPos, ptr, rdSize));
+
+	aDestinationBuffer.SetLength(aDestinationBuffer.Length() + ptr.Length());
+	}
+
+/**
+ * Read the SCM configuration data from flash buffer
+ */
+void CFlashDataSource::ReadSCMConfigL(RConfigParameterList& aScmConfigList)
+	{
+
+	LOG_MSG("CFlashDataSource::ReadSCMConfigL");
+
+	aScmConfigList.ResetAndDestroy();
+
+	Debug::SCMConfiguration* theConfig = GetSCMConfigFromFlashL();
+
+	if(!theConfig)
+		{
+		CLTRACE("(CFlashDataSource::ReadSCMConfigL) no config saved - using default");
+		iScmConfig->SetDefaultConfig();
+		}
+	else
+		{
+
+		CLTRACE("(CFlashDataSource::ReadSCMConfigL) config FOUND");
+		delete iScmConfig;
+		iScmConfig = theConfig;
+
+		// ok we have a config - now read to see if we have a crash following
+		ReallocFlashBuf(Align4(TCrashInfoHeader::KSCMCrashInfoMaxSize));
+		User::LeaveIfError(iSecSess.ReadCrashLog(Align4(iScmConfig->GetSize()), iFlashBuf, TCrashInfoHeader::KSCMCrashInfoMaxSize));
+
+		TCrashInfoHeader header;
+		TByteStreamReader r2(const_cast<TUint8*>((iFlashBuf).Ptr()));
+		if( header.Deserialize(r2) == KErrNone)
+			{
+			CLTRACE("(CFlashDataSource::ReadSCMConfigL) HEADER found OK");
+
+ 			// we should now have a blocksize in the header
+  			iCrashFound = ETrue;
+  			// create a buffer big enough to hold the entire first block
+  			iFirstBlockBuf.Close();
+  			iFirstBlockBuf.Create(header.iFlashBlockSize);
+
+  			// read the whole block into the buffer
+  			TInt err = iSecSess.ReadCrashLog(0, iFirstBlockBuf, header.iFlashBlockSize);
+
+  			if(err != KErrNone)
+  				{
+				CLTRACE1("(CFlashDataSource::ReadSCMConfigL) Error reading cache block %d", err);
+				}
+  			}
+	 	else
+  			{
+  			CLTRACE("(CFlashDataSource::ReadSCMConfigL) NO crash header found");
+ 			}
+
+		}
+
+	TConfigItem* item = iScmConfig->ConfigList();
+	TInt i = 0;
+	while(item)
+		{
+		// transfer the TCongigItems into the array
+    	COptionConfig* config =  COptionConfig::NewL( i,
+    								   item->GetDataType(),
+    								   COptionConfig::ESCMConfig,
+    								   COptionConfig::ETInt,
+    								   TConfigItem::GetSCMConfigOptionText(item->GetDataType()),
+    								   0,
+    								   KNullDesC,
+    								   item->GetPriority(),
+    								   KNullDesC );
+        config->Instance(item->GetDataType());
+        i++;
+		aScmConfigList.AppendL(config);
+		item = item->Next();
+		}
+	}
+
+void CFlashDataSource::WriteSCMConfigL()
+	{
+	// if we have a crash found then use the appropriate buffer
+	RBuf8& buf = iCrashFound ? iFirstBlockBuf : iFlashBuf;
+
+	CLTRACE2("(CFlashDataSource::WriteSCMConfigL) - Writing config buf.Length() = %d iCrashFound %d",
+			buf.Length(), iCrashFound );
+
+	TByteStreamWriter writer(const_cast<TUint8*>(buf.Ptr()));
+	iScmConfig->Serialize(writer);
+
+	iSecSess.EraseCrashLog(0, 1);
+	TUint32 size = 0;
+	TInt res = iSecSess.WriteCrashConfig(0, buf, size);
+
+	CLTRACE2("(CFlashDataSource::WriteSCMConfigL) RESULT res = %d size = %d", res, size);
+	}
+
+void CFlashDataSource::ModifySCMConfigItemL(TUint32 aDataType, TInt32 aPriority)
+	{
+	CLTRACE2("(CFlashDataSource::ModifySCMConfigItemL) - modifying aDataType %d with priority %d", aDataType, aPriority);
+
+	//check for Priority value to be within 0-255 otherwise leave with KErrArgument
+	if( (aPriority < 0) || (aPriority > 255) )
+		{
+			LOG_MSG( " ERROR: SCM Priority out of bounds, should be within 0-255\n");
+			User::Leave(KErrArgument);
+		}
+
+	TInt err = iScmConfig->ModifyConfigItemPriority((Debug::TConfigItem::TSCMDataType)aDataType, aPriority);
+
+	if( err == KErrNone)
+		{
+		// also write change through to flash
+		WriteSCMConfigL();
+		}
+	else
+		{
+		 CLTRACE3("CFlashDataSource::ModifySCMConfigItemL) failed to modify err = %d aDataType = %d aPriority = %d"
+				 , err, aDataType, aPriority );
+		}
+	}
+
+Debug::SCMConfiguration& CFlashDataSource::SCMConfiguration()
+	{
+	return *iScmConfig;
+	}
+
+/**
+ * Cleanup item implementation for Code Seg List
+ * @param aArray pointer to the list that is supposed to be freed
+*/
+void CFlashDataSource::CleanupCodeSegList(TAny *aArray)
+	{
+    LOG_MSG("->CFlashDataSource::CleanupCodeSegList()\n");
+	RCodeSegPointerList *codeSegList = static_cast<RCodeSegPointerList*> (aArray);
+    codeSegList->ResetAndDestroy();
+    codeSegList->Close();
+    delete codeSegList;
+	}
+
+/**
+ * Cleanup item implementation for process list.
+ * @param aArray pointer to the list that is supposed to be freed
+*/
+void CFlashDataSource::CleanupProcessList(TAny *aArray)
+	{
+    LOG_MSG("->CFlashDataSource::CleanupProcessList()\n");
+	RProcessPointerList *processList = static_cast<RProcessPointerList*> (aArray);
+    processList->ResetAndDestroy();
+    processList->Close();
+    delete processList;
+	}
+
+/**
+ * Cleanup item implementation for thread list.
+ * @param aArray pointer to the list that is supposed to be freed
+*/
+void CFlashDataSource::CleanupThreadList(TAny *aArray)
+	{
+    LOG_MSG("->CFlashDataSource::CleanupThreadList()\n");
+	RThreadPointerList *threadList = static_cast<RThreadPointerList*> (aArray);
+    threadList->ResetAndDestroy();
+    threadList->Close();
+    delete threadList;
+	}
+
+/**
+ * CalculateChecksum - calsulates the checksum for the given length of
+ * the flash buffer (if this is the entire length it should not include
+ * the checksum footer)
+ * @param aLogSize - the total size of flash buf to check
+ * @param aChecksum -  the checksum where the result will be placed - as this checksum is
+ * commutative the aChecksum value may be reset or already hold data as required
+ * @return void
+*/
+void CFlashDataSource::CalculateChecksumL(TInt aStart, TInt aLength, TScmChecksum& aChecksum)
+	{
+	if( aLength <= 0)
+		{
+		// invalid block length
+		User::Leave(KErrGeneral);
+		}
+
+	const TInt KDefaultBlockSize = 0xFF;
+	const TInt KBlocksize = aLength > KDefaultBlockSize ? KDefaultBlockSize : aLength;
+
+	TInt remaining = aLength;
+	TInt pos = aStart;
+
+	while(remaining > KBlocksize)
+		{
+		//CLTRACE2("->CFlashDataSource::CalculateChecksum rem = %d blksz = %d\n", remaining, KBlocksize);
+		User::LeaveIfError(ReadCrashLog(pos, KBlocksize));
+		pos += KBlocksize;
+		remaining -= KBlocksize;
+		aChecksum.ChecksumBlock(iFlashBuf);
+		}
+
+	if(remaining > 0)
+		{
+		User::LeaveIfError(ReadCrashLog(pos, remaining));
+		aChecksum.ChecksumBlock(iFlashBuf);
+
+		pos += remaining;
+		if(pos != aLength)
+			{
+			User::Leave(KErrCorrupt);
+			}
+		}
+	}
+
+/**
+ * Retrieves ROM build information from flash partition if available
+ * @param aRomHeader stores the rom build info
+ * @leave one of the OS wide codes
+ */
+void CFlashDataSource::GetROMBuildInfoL(TRomHeaderData& aRomHeader)
+	{
+	if(iRomBuildInfo)
+		{
+		aRomHeader = *iRomBuildInfo;
+		return;
+		}
+
+	User::Leave(KErrNotFound);
+	}
+
+/**
+ * Retrieves System lock data
+ * @param aLockData Contains the data for the system locks
+ * @leave one of the OS wide codes
+ */
+void CFlashDataSource::GetLocksL(TSCMLockData& aLockData)
+	{
+	if(iLockData)
+		{
+		aLockData = *iLockData;
+		return;
+		}
+
+	User::Leave(KErrNotFound);
+	}
+
+TInt CFlashDataSource::ReallocFlashBuf(const TUint aSize)
+  	{
+  	//Reallocate the flash buffer to be the size required
+
+  	if(aSize > iFlashBuf.MaxLength())
+  		{
+  		TInt err = iFlashBuf.ReAlloc(aSize);
+  		if (KErrNone != err)
+  			{
+  			CLTRACE2("(CFlashDataSource::ReallocFlashBuf) - ERROR alloc on iFlashBuf err = %d. Trying to alloc aSize [0x%x] bytes", err, aSize);
+  			return err;
+  			}
+  		}
+  	else
+  		{
+		iFlashBuf.SetLength(aSize);
+  		}
+
+  	return KErrNone;
+  	}
+
+void CFlashDataSource::PrintFlashBuf()
+	{
+	CLTRACE1("(CFlashDataSource::PrintFlashBuf) iFlashBuf.Length = %d ", iFlashBuf.Length());
+	for(TInt i=0;i<iFlashBuf.Length();i++)
+		{
+		CLTRACE4("iFlashBuf[%d] = char<%c> dec<%d> hex<%x>", i, iFlashBuf[i], iFlashBuf[i] ,iFlashBuf[i]);
+		}
+	}
+
+void  CFlashDataSource::ReleaseFirstBlockBuf()
+	{
+	iFirstBlockBuf.Close();
+	iCrashFound = EFalse;
+	}
+
+void CFlashDataSource::GetExceptionStackL(const Debug::TArmProcessorModes aMode, TDes8& aStack, TUint aStartReadPoint)
+	{
+	//Not implemented
+	}
+
+/**
+ * @see CCrashDataSource::GetVersion
+ */
+TVersion CFlashDataSource::GetVersion() const
+	{
+	return KFlashCrashDataSourceVersion;
+	}
+
+/**
+ * @see CCrashDataSource::GetDataSourceFunctionalityBufSize
+ */
+TInt CFlashDataSource::GetDataSourceFunctionalityBufSize(TUint& aBufSize)
+	{
+	return KErrNotSupported;
+	}
+
+/**
+ * @see CCrashDataSource::GetDataSourceFunctionality
+ */
+TInt CFlashDataSource::GetDataSourceFunctionality(TDes8& aFuncBuffer)
+	{
+	return KErrNotSupported;
+	}
+/**
+ * @see CCrashDataSource::GetExceptionStackSizeL
+ */
+TUint CFlashDataSource::GetExceptionStackSizeL(const Debug::TArmProcessorModes aMode)
+  	{
+  /*    TInt bufferSize = 0;
+      TInt pos = 0;
+      SCMStructId id = ESCMLast;
+
+      TBool validStack = ETrue;
+      TUint32 rdPoint = iOffsetsHdr.iExcStkOffset;
+
+      while(validStack)
+      	{
+      	//Read in the thread stack, memory dump and raw data structs each time
+      	User::LeaveIfError(ReadCrashLog(rdPoint, TThreadStack::MAX_SIZE + TMemoryDump::MAX_SIZE + TRawData::MAX_SIZE));
+
+      	MByteStreamSerializable* data = iWalker.GetNextDataTypeL(pos, id, bufferSize);
+      	CleanupStack::PushL(data);
+
+      	//Make sure we have a valid TRawData or TMemory or TThreadStack
+      	if(id == ESCMThreadStack)
+      		{
+      		TThreadStack* thread = static_cast<TThreadStack*>(data);
+
+      		//The enums here dont match so gotta case
+      		switch(aMode)
+      			{
+      			case Debug::EFiqMode :
+      				{
+      				if(thread->iStackType == TThreadStack::EFIQStack)
+      					{
+      					CleanupStack::PopAndDestroy(data);
+      					return thread.iStackSize;
+      					}
+      				//otherwise fall through to default
+      				}
+      			case Debug::EIrqMode :
+      				{
+      				if(thread->iStackType == TThreadStack::EIRQStack)
+      					{
+      					CleanupStack::PopAndDestroy(data);
+      					return thread.iStackSize;
+      					}
+
+      				//otherwise fall through to default
+      				}
+      			//Not supported for now
+      			case Debug::ESvcMode :
+      			case Debug::EAbortMode :
+      			case Debug::EUndefMode :
+      			case Debug::EMaskMode :
+      			default:
+      				{
+      				CleanupStack::PopAndDestroy(data);
+      				continue;
+      				}
+      			}
+
+      		//Now is it the stack of interest
+      		}
+      	else
+      		{
+      		CleanupStack::PopAndDestroy(data);
+      		User::Leave(KErrNotFound);
+      		}
+      	}
+
+  	*/
+  	return 0;
+	}
+
+/**
+ * @see CCrashDataSource::GetVariantSpecificDataSize
+ */
+TInt CFlashDataSource::GetVariantSpecificDataSize(TUint& aDataSize)
+	{
+	CLTRACE("Start CFlashDataSource::GetVariantSpecificDataSize()");
+
+	if(iVarSpecData)
+		{
+		aDataSize = iVarSpecData->iSize;
+		return KErrNone;
+		}
+	else
+		{
+		return KErrNotSupported;
+		}
+	}
+
+/**
+ * @see CCrashDataSource::GetVariantSpecificData
+ */
+TInt CFlashDataSource::GetVariantSpecificData(TDes8 &aVarSpecData)
+	{
+	aVarSpecData.Zero();
+
+	if(!iVarSpecData)
+		{
+		CLTRACE("CFlashDataSource::GetVariantSpecificData --> No variant specific data in flash");
+		return KErrNotFound;
+		}
+
+	if(aVarSpecData.MaxSize() != iVarSpecData->iSize)
+		{
+		CLTRACE1("CFlashDataSource::GetVariantSpecificData --> Supplied descriptor was not big enough for data. Need at least [%d] bytes", iVarSpecData->iSize);
+		return KErrBadDescriptor;
+		}
+
+	TUint rawDataPos = iOffsetsHdr.iVarSpecInfOffset + iVarSpecData->GetSize();
+
+	TInt err = ReadCrashLog(rawDataPos, TRawData::KSCMRawDataMaxSize);
+	if(KErrNone != err)
+		{
+		CLTRACE1("CFlashDataSource::GetVariantSpecificData -- Unable to read variant data from crash log: [%d]", err);
+		return err;
+		}
+	
+	SCMStructId id = ESCMLast;
+	TInt nextBufferSizeIfNull = 0;
+	TInt nextBufferRead = 0;
+
+	//We now walk the data that we just buffered in the ReadCrashLog call (our data is at start of buffer)
+	MByteStreamSerializable* theRawness = iWalker.GetNextDataTypeL(nextBufferRead, id, nextBufferSizeIfNull);
+	if(theRawness && id == ESCMRawData)
+		{
+		TRawData* raw = static_cast<TRawData*>(theRawness);
+		CleanupStack::PushL(theRawness);
+
+		//Read the raw data into supplied buffer
+		TRAP(err, ReadRawFlashL(aVarSpecData, rawDataPos + TRawData::KSCMRawDataMaxSize, raw->iLength));
+		CleanupStack::PopAndDestroy(theRawness);
+		if(KErrNone != err)
+			{
+			CLTRACE1("CFlashDataSource::GetVariantSpecificData -- Reading raw data fromn flash failed: [%d]", err);
+			aVarSpecData.Zero();
+			return err;
+			}
+		}
+	else
+		{
+		//The read crash log gave it the correct values (size etc) so if its NULL it means it's not been found
+		//(Perhaps this should be a KErrCorrupt as to get this far, the crash log has been telling us there is
+		//var specific data. Don't want to make the parsing too strict though.)
+		return KErrNotFound;
+		}
+
+	return KErrNone;
+	}
+
+//eof flashdatasource.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,8 @@
+Directory for:
+  coredump\server\src
+
+All the source, including subdirectories, to implement the Core Dump server
+
+Implements the server of the config API. 
+Implements a client of the PlatSec Debug Server.
+Uses the ECOM plugins.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/server/src/servercrashdatasource.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,951 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32debug.h>
+#include <e32btrace.h> 
+#include <d32btrace.h>
+
+#include "servercrashdatasource.h"
+
+// Required for interface to Debug Security Server via RSecuritySvrSession
+#include "coredumpsession.h"
+
+CServerCrashDataSource::CServerCrashDataSource(RSecuritySvrSession &aSource)
+    : iSecSess(aSource)
+{
+//no implementation
+}
+
+CServerCrashDataSource* CServerCrashDataSource::NewL(RSecuritySvrSession &aSource)
+{
+    CServerCrashDataSource *self = new(ELeave) CServerCrashDataSource(aSource);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+}
+
+
+TTag* CServerCrashDataSource::GetTag(const TTagHeader* aTagHdr, const TInt aElement)
+	{
+	TUint8* ptr = (TUint8*)aTagHdr + sizeof(TTagHeader);
+	TUint8* blockEnd = ptr + (aTagHdr->iNumTags * sizeof(TTag));
+
+	while(ptr < blockEnd)
+		{
+		TTag* tag = (TTag*)ptr;
+		if(tag->iTagId == aElement)
+			{
+			return tag;
+			}
+		ptr += sizeof(TTag);
+		}
+	return NULL;
+	}
+
+// second-phase constructor
+void CServerCrashDataSource::ConstructL()
+    {
+	LOG_MSG("->CServerCrashDataSource::ConstructL()\n" );
+	// Get the debug func block and make appropriate changes to our structures
+    TInt err;
+	TUint32 bufsize = 0;
+	LOG_MSG( "  -> iSecSess->GetDebugFunctionalityBufSize( &bufsize )\n" );
+    err = iSecSess.GetDebugFunctionalityBufSize( &bufsize );
+
+	if( (err != KErrNone) || (0 == bufsize) )
+		{
+		// No debug functionality block, cannot do much without that.
+		LOG_MSG2("CServerCrashDataSource::ConstructL() - unable to get debug functionality block! err:%d\n", err);
+		User::Leave( KErrNotSupported );
+		}
+
+    RBuf8 DFBlock;
+    DFBlock.CreateL(bufsize);
+    DFBlock.CleanupClosePushL();
+
+	LOG_MSG2( "  -> HBufC8::NewLC( bufsize=%d )\n", bufsize );
+
+
+	LOG_MSG("CServerCrashDataSource::ConstrucL -> GetDebugFunctionality()\n" );
+    err = iSecSess.GetDebugFunctionality(DFBlock);
+	if( KErrNone != err )
+		{
+		LOG_MSG( "CServerCrashDataSource::ConstructL() : ERROR !* : Could not retrieve debug functionality block\n" );
+		User::Leave( KErrNotSupported );
+		}
+
+	LOG_MSG( "  -> GetDebugHeader( EDF_TagHdrId_RegistersCore )\n" );
+	TTagHeader * hdr = GetDebugHeader( ETagHeaderIdRegistersCore, DFBlock );
+
+	if( hdr == NULL )
+		{
+		LOG_MSG( "Could not retrieve ETagHeaderIdRegistersCore register debug block\n" );
+		}
+	else if( 0 == hdr->iNumTags )
+		{
+		LOG_MSG( "Zero tags found for ETagHeaderIdRegistersCore register debug block\n" );
+		}
+	else
+		{
+
+		iRegisterList.ReserveL( (TInt)hdr->iNumTags );
+
+		// Skip the header to get to the tags
+		TUint8 * ptr = ((TUint8 *) hdr) + sizeof( TTagHeader );
+		TTag * tag = (TTag *) ptr;
+
+		TRegisterData regData;
+		TRegisterData * reg = &regData;
+
+		// Process all the register tags
+		for( TInt regIdx = 0; regIdx < hdr->iNumTags; regIdx ++ )
+			{
+			reg->iRegClass  = 0;			// Core = 0
+			reg->iId        = tag->iTagId;	//
+			reg->iSubId     = 0;			//
+			reg->iSize      = 2;			// Should all be 32 bits == 2.
+			reg->iAvailable = ETrue;
+			reg->iValue64	= 0;
+			iRegisterList.Append( *reg );
+			tag++;
+			}
+		}
+
+	hdr = GetDebugHeader( ETagHeaderIdMemory, DFBlock );
+	if( hdr == NULL )
+		{
+		LOG_MSG( "Could not retrieve ETagHeaderIdMemory. Cannot read memory\n" );
+		iMaxMemReadSize = 0;
+		}
+	else if( 0 == hdr->iNumTags )
+		{
+		LOG_MSG( "Zero tags found for ETagHeaderIdMemory register debug block\n" );
+		iMaxMemReadSize = 0;
+		}
+	else
+		{
+		TTag* tag = GetTag( hdr, EMemoryMaxBlockSize );
+		if( tag )
+			{
+			//LOG_MSG2( " EMemoryMaxBlockSize =0x%X\n", tag->iValue );
+			iMaxMemReadSize = tag->iValue;
+			}
+		}
+
+	iLastThreadListSize = 1;
+	iLastProcListSize = 1;
+	iLastRegListSize = 1;
+
+	CleanupStack::PopAndDestroy(&DFBlock);
+    }
+
+//
+// Returns the start of the sub block for this TTagHdrId_e 
+//
+TTagHeader * CServerCrashDataSource::GetDebugHeader( const TTagHeaderId aTagHdrId, const TDesC8 &aDFBlock )
+	{
+	TInt DFBlockSize = aDFBlock.Size();
+
+	TTagHeader* headerPtr = (TTagHeader*) aDFBlock.Ptr();
+	TUint8 * ptr = (TUint8 * ) aDFBlock.Ptr();
+
+	while( headerPtr < ( (TTagHeader*)aDFBlock.Ptr() + DFBlockSize ) )
+		{
+
+		if( headerPtr->iTagHdrId != aTagHdrId )
+			{
+			ptr += sizeof(TTagHeader) + ( headerPtr->iNumTags * sizeof(TTag) );
+			headerPtr = (TTagHeader*) ptr;
+			}
+		else
+			{
+			return ( headerPtr );
+			}
+		}
+
+	return NULL;
+	}
+
+// destructor
+CServerCrashDataSource::~CServerCrashDataSource()
+    {
+	LOG_MSG( "server_crashdatasource.cpp::CServerCrashDataSource::~CServerCrashDataSource()\n" );
+	iRegisterList.Reset();
+    iThreadListBuffer.Close();
+    iProcListBuffer.Close();
+    iExecutableListBuffer.Close();
+    }
+
+void CServerCrashDataSource::SetRegValuesL( const TUint64 aThreadId, RRegisterList &aRegisterList )
+	{
+
+	LOG_MSG2("->CServerCrashDataSource::SetRegValuesL(aThreadId=%Lu)\n", aThreadId); 
+
+	TInt numberOfRegisters = aRegisterList.Count();
+
+	RBuf8 ids;
+	ids.CreateL( numberOfRegisters * sizeof(TFunctionalityRegister) );
+    ids.CleanupClosePushL();
+
+	TInt totalByteSize = 0; // Keeps track of the number of bytes that we are requesting
+
+	for( TInt i=0; i < numberOfRegisters; i++ )
+		{
+		TRegisterInfo reg = (TRegisterInfo)( aRegisterList[i].iId ); 
+
+		// iSize = (0 == 1 byte); (3 == 8 bytes)
+		TInt byteSize = (aRegisterList[i].iSize) << 1;
+		totalByteSize += byteSize;
+		ids.Append( reinterpret_cast<const TUint8*>(&reg), sizeof(TRegisterInfo) );
+		}
+
+	
+	RBuf8 registerValues;
+	registerValues.CreateL( totalByteSize );
+    registerValues.CleanupClosePushL();
+
+	RBuf8 registerFlags;
+	registerFlags.CreateL( numberOfRegisters );
+    registerFlags.CleanupClosePushL();
+
+    LOG_MSG("CServerCrashDataSource::SetRegValuesL - reading registers\n");
+    User::LeaveIfError(iSecSess.ReadRegisters( aThreadId, ids, registerValues, registerFlags ));
+
+	// Now copy the values back to the array and mark the availability from the flags
+
+	TUint8* valuePtr = (TUint8*) registerValues.Ptr();
+
+	for( TInt i=0; i < numberOfRegisters; i++ )
+		{
+
+		TRegisterData & reg = aRegisterList[i];
+
+		switch( reg.iSize )
+			{
+			case 0:
+				reg.iValue8 = *((TUint8 *)valuePtr);
+				valuePtr += 1;
+				break;
+			case 1:
+				reg.iValue16 = *((TUint16 *)valuePtr);
+				valuePtr += 2;
+				break;
+			case 2:
+				reg.iValue32 = *((TUint32 *)valuePtr);
+				valuePtr += 4;
+				break;
+			case 3:
+				reg.iValue64 = *((TUint64 *)valuePtr);
+				valuePtr += 8;
+				break;
+			}
+
+		if( EValid == registerFlags[i] ) 
+			{
+			reg.iAvailable = ETrue;
+			}
+		else
+			{
+			reg.iAvailable = EFalse;
+			}
+		}
+
+    CleanupStack::PopAndDestroy(&registerFlags);
+    CleanupStack::PopAndDestroy(&registerValues);
+    CleanupStack::PopAndDestroy(&ids);
+	}
+
+
+void CServerCrashDataSource::PrintRegs( RRegisterList & aRegisterList )
+	{
+
+	LOG_MSG( "CServerCrashDataSource::PrintRegs()\n" );
+
+	if( aRegisterList.Count() > 0 )
+		{
+
+
+		for( TInt i = 0; i < aRegisterList.Count(); i ++ )
+			{
+			
+			TRegisterData & reg = aRegisterList[i];
+
+			RDebug::Printf( " reg[%d] iRegClass=%d, iId=%d, iSubId=%d, iSize=%d, iAvailable=%d\n", 
+				i, reg.iRegClass, reg.iId, reg.iSubId, reg.iSize, reg.iAvailable );
+
+			switch ( reg.iSize )
+				{
+				case 0:
+					RDebug::Printf( "  iValue8=0x%X\n", reg.iValue8 ); break;
+				case 1:
+					RDebug::Printf( "  iValue16=0x%X\n", reg.iValue16 ); break;
+				case 2:
+					RDebug::Printf( "  iValue32=0x%X\n", reg.iValue32 ); break;
+				case 3:
+					RDebug::Printf( "  iValue64=0x%X%X\n", 
+						I64HIGH(reg.iValue64), I64LOW(reg.iValue64) ); 
+					break;
+				}
+			}
+		}
+	else
+		{
+		RDebug::Printf( " No registers to print\n" );
+		}
+	}
+
+
+
+void CServerCrashDataSource::GetRegisterListL( RRegisterList & aRegisterList )
+	{
+
+	LOG_MSG("CServerCrashDataSource::GetRegisterListL()\n");
+	/* Copy the registers that were returned in the debug functionality block */
+
+	aRegisterList.Reset();
+    TInt count = iRegisterList.Count();
+	for(TInt i = 0; i < count; ++i)
+		{
+		aRegisterList.AppendL( iRegisterList[i] );
+		}
+	}
+
+void CServerCrashDataSource::ReadRegistersL( const TUint64 aThreadId, RRegisterList  & aRegisterList )
+	{
+
+	LOG_MSG2("CServerCrashDataSource::ReadRegistersL(aThreadId=%Lu)\n", aThreadId);
+
+	if( aRegisterList.Count() )
+		{
+		LOG_MSG("CServerCrashDataSource::ReadRegistersL - register list already supplied\n" );
+		SetRegValuesL( aThreadId, aRegisterList );
+		}
+	else
+		{
+		LOG_MSG("CServerCrashDataSource::ReadRegistersL - suppliying register list\n" );
+		GetRegisterListL( aRegisterList );
+		SetRegValuesL( aThreadId, aRegisterList );
+		}
+
+	//PrintRegs( aRegisterList );
+	}
+
+
+/**
+Purpose:
+Read memory from the security server. If the length of the data is greater
+than the maximum length supported by the security server (as reported debug
+functionality block tag EMemoryMaxBlockSize), break up the read into reads 
+of this maximum size.
+
+@pre Must be connected to the debug security server
+@pre Must be attached to the process that owns aThreadId
+
+@param aThreadId - The id of the thread relative to which the read should take place
+@param aAddress - The virtual address to read from
+@param aLength - The number of bytes to read
+@param aData - The buffer to read into
+@return Any error which may be returned by Security Server::ReadMemory()
+*/
+void CServerCrashDataSource::ReadMemoryL(
+                   const TUint64    aThreadId,
+                   const TUint32    aAddress,
+                   const TUint32    aLength,
+                   TDes8          & aData )
+	{
+    LOG_MSG4("->CServerCrashDataSource::ReadMemoryL(aThreadId=0x%X, aAddress=0x%X, aLength=%d)\n",
+            I64LOW(aThreadId), aAddress, aLength);	
+    TInt err;
+
+	if( aLength <= iMaxMemReadSize )
+		{
+		err = iSecSess.ReadMemory( aThreadId, aAddress, aLength, aData, EAccess32, EEndLE8);
+		}
+    else
+        {
+        // If aLength is greater than iMaxMemReadSize, then break up the read into 
+        // smaller packets and append them to aData
+
+        RBuf8 readData;
+        readData.CreateL( iMaxMemReadSize );
+
+        TInt readLength = iMaxMemReadSize;
+        TInt readSoFar = 0;
+        do
+            {
+            LOG_MSG3( "  iSecSess->ReadMemory(addr=0x%X, length=%d)\n", aAddress+readSoFar, readLength );
+            err = iSecSess.ReadMemory( aThreadId, aAddress+readSoFar, readLength, readData, EAccess32, EEndLE8 );
+            if(err != KErrNone)
+                break;
+
+            readSoFar += readLength;
+            aData.Append( readData );
+            if( (aLength - readSoFar) < iMaxMemReadSize )
+                {
+                readLength = aLength - readSoFar;
+                }
+            }
+        while( readSoFar < aLength );
+        readData.Close();
+        }
+    User::LeaveIfError(err);
+	}
+
+
+void CServerCrashDataSource::GetProcessListL( RProcessPointerList & aProcessList,
+											  TUint & aTotalProcessListDescSize )
+    {
+	//LOG_MSG( "CServerCrashDataSource::GetProcessListL()\n" );
+
+	// Delete any objects in the array, since we will replace them. 
+	aProcessList.ResetAndDestroy();
+	aTotalProcessListDescSize = 0;
+
+	if( iProcListBuffer.Size() != iLastProcListSize )
+		{
+		LOG_MSG2( "  iProcListBuffer.ReAlloc( %d)\n", iLastProcListSize );
+		iProcListBuffer.ReAllocL( iLastProcListSize );
+		}
+
+	DoGetListL( EProcesses, (TUint)(-1), (TUint)(-1), iProcListBuffer, iLastProcListSize );
+
+	iLastProcListSize = iProcListBuffer.Size();
+
+	TUint8* ptr = (TUint8*)( iProcListBuffer.Ptr() );
+	const TUint8* ptrEnd = ptr + iLastProcListSize;
+	//LOG_MSG3( "  Data start,end=(0x%x, 0x%x)\n", ptr, ptrEnd );
+
+	while( ptr < ptrEnd ) 
+		{
+
+	    TProcessListEntry *entry = (TProcessListEntry*)ptr;
+
+		if( !entry )
+			{
+			LOG_MSG( "  ERROR !* : TProcessListEntry is NULL\n" );
+			User::Leave(KErrBadHandle);
+			}
+
+		TUint64 id = entry->iProcessId;
+		if( entry->iFileNameLength == 0 )
+			{
+			LOG_MSG4( "  Skipping process 0x%X%X : entry->iFileNameLength=%d", 
+				I64HIGH(entry->iProcessId), I64LOW(entry->iProcessId), entry->iFileNameLength );
+			ptr += Align4( entry->GetSize() );
+			continue;
+			}
+
+		/*
+		LOG_MSG4( "  process 0x%X%X has iFileNameLength=%d", 
+			I64HIGH(entry->iProcessId), I64LOW(entry->iProcessId), entry->iFileNameLength );
+		*/
+
+        TPtrC entryName(&(entry->iNames[0]), entry->iFileNameLength);
+       
+        CProcessInfo *procInfoPtr = CProcessInfo::NewL(id, entryName );
+
+		TInt err = aProcessList.Append( procInfoPtr );
+        if(err != KErrNone)
+            {
+            delete procInfoPtr;
+            User::Leave(err);
+            }
+
+		aTotalProcessListDescSize += procInfoPtr->Size();
+
+		ptr += Align4( entry->GetSize() );
+		}
+	}
+
+
+void CServerCrashDataSource::GetExecutableListL( RExecutablePointerList & aExecutableList,
+											  TUint & aTotalExecutableListDescSize )
+    {
+	LOG_MSG( "CServerCrashDataSource::GetExecutableListL()\n" );
+
+	// Delete any objects in the array, since we will replace them. 
+	aExecutableList.ResetAndDestroy();
+	aTotalExecutableListDescSize = 0;
+
+	if( iExecutableListBuffer.Size() != iLastExecutableListSize )
+		{
+		LOG_MSG2( "  iExecutableListBuffer.ReAlloc( %d)\n", iLastExecutableListSize );
+		iExecutableListBuffer.ReAllocL( iLastExecutableListSize );
+		}
+
+	DoGetListL( EExecutables, (TUint)(-1), (TUint)(-1), iExecutableListBuffer, iLastExecutableListSize );
+
+	iLastExecutableListSize = iExecutableListBuffer.Size();
+
+	TUint8* ptr = (TUint8*)( iExecutableListBuffer.Ptr() );
+	const TUint8* ptrEnd = ptr + iLastExecutableListSize;
+	//LOG_MSG3( "  Data start,end=(0x%x, 0x%x)\n", ptr, ptrEnd );
+
+	while( ptr < ptrEnd ) 
+		{
+
+	    TExecutablesListEntry *entry = (TExecutablesListEntry*)ptr;
+
+		if( !entry )
+			{
+			LOG_MSG( "  ERROR !* : TExecutablesListEntry is NULL\n" );
+			User::Leave(KErrBadHandle);
+			}
+
+		if( entry->iNameLength == 0 )
+			{
+			LOG_MSG( "  Skipping executable : entry->iNameLength=0" );
+			ptr += Align4( entry->GetSize() );
+			continue;
+			}
+
+        TPtrC entryName(&(entry->iName[0]), entry->iNameLength);
+       
+        CExecutableInfo *executableInfoPtr = 
+			CExecutableInfo::NewL(entryName, entry->iIsActivelyDebugged, entry->iIsPassivelyDebugged );
+
+		TInt err = aExecutableList.Append( executableInfoPtr );
+        if(err != KErrNone)
+            {
+            delete executableInfoPtr;
+            User::Leave(err);
+            }
+
+		aTotalExecutableListDescSize += executableInfoPtr->Size();
+
+		ptr += Align4( entry->GetSize() );
+		}
+	}
+
+
+void CServerCrashDataSource::DoGetListL(const TListId aListId, 
+										const TThreadId aThreadId,
+										const TProcessId aProcessId,
+										RBuf8 & aBuffer, 
+										TUint32 & aSize )
+	{
+
+	LOG_MSG5( "->CServerCrashDataSource::DoGetList(aListId=%d, aThredId=%Lu, aProcessId=%Lu, aSize=%d\n", aListId, aThreadId.Id(), aProcessId.Id(), aSize );
+
+	TInt ret;
+	TListLevel listLevel;
+
+	if( ((TUint)-1 == (TUint)aThreadId) && ((TUint)-1 == (TUint)aProcessId) )
+		{
+		listLevel = EListGlobal;
+		ret = iSecSess.GetList( aListId, aBuffer, aSize );
+		}
+	else if( ((TUint)-1 != (TUint)aThreadId) && ((TUint)-1 == (TUint)aProcessId) )
+		{
+		listLevel = EListThread;
+        LOG_MSG("CServerCrashDataSource::DoGetList - EListThread");
+		ret = iSecSess.GetList( aThreadId, aListId, aBuffer, aSize );
+		}
+	else
+		{
+		listLevel = EListProcess;
+        LOG_MSG("CServerCrashDataSource::DoGetList - EListProcess");
+		ret = iSecSess.GetList( aProcessId, aListId, aBuffer, aSize );
+		}
+		 
+	while( KErrTooBig == ret )
+		{
+		LOG_MSG2( "CServerCrashDataSource::DoGetListL - list too big, new size=%d\n", aSize );
+
+		// Too big, and aSize should have been modified to the required new size
+		// Since the list could have increased in size between calls, give it an 
+		// extra margin.
+		aSize += 256;
+
+		aBuffer.ReAllocL( aSize );
+
+		if( EListGlobal == listLevel )
+			{
+			ret = iSecSess.GetList( aListId, aBuffer, aSize );
+			}
+		else if( EListThread == listLevel )
+			{
+			ret = iSecSess.GetList( aThreadId, aListId, aBuffer, aSize );
+			}
+		else
+			{
+			ret = iSecSess.GetList( aProcessId, aListId, aBuffer, aSize );
+			}
+
+		}
+    User::LeaveIfError(ret);
+	}
+
+/** Obtain the thread list. If aProcessId is negative, we obtain the entire system
+thread list. If aProcessId is positive we get the thread list for that process */
+void CServerCrashDataSource::GetThreadListL( const TUint64 aProcessId, 
+											 RThreadPointerList & aThreadList,
+											 TUint & aTotalThreadListDescSize )
+	{
+	LOG_MSG2( "->CServerCrashDataSource::GetThreadListL(aProcessId=%Lu)\n", aProcessId); 
+
+	// Delete any objects in the array, since we will replace them. 
+	aThreadList.ResetAndDestroy();
+		
+	aTotalThreadListDescSize = 0;
+
+	if( iThreadListBuffer.Size() != iLastThreadListSize )
+		{
+		LOG_MSG2("CServerCrashDataSource::GetThreadListL -> iThreadListBuffer.ReAlloc(%d)\n", iLastThreadListSize );
+		iThreadListBuffer.ReAllocL( iLastThreadListSize );
+		}
+
+	LOG_MSG( "CServerCrashDataSource::GetThreadListL -> DoGetListL()\n" );
+	DoGetListL( EThreads, (TUint)-1, aProcessId, iThreadListBuffer, iLastThreadListSize );
+
+	iLastThreadListSize = iThreadListBuffer.Size();
+	
+
+	CThreadInfo		 *  threadInfoPtr;
+	RThread				thread;
+	TThreadStackInfo	stackInfo;
+	TThreadListEntry *	entry;
+	TUint				usrStackSize;
+	TLinAddr			usrStackAddr;
+	TLinAddr			svcStackPtr;
+	TLinAddr			svcStackBase;
+	TUint				svcStackSize;
+
+	TUint				priority;
+
+	TUint8* ptr = (TUint8*)( iThreadListBuffer.Ptr() );
+	const TUint8* ptrEnd = ptr + iLastThreadListSize;
+	//LOG_MSG3( "  Data start,end=(0x%x, 0x%x)\n", ptr, ptrEnd );
+
+	while( ptr < ptrEnd ) 
+		{
+
+		entry = (TThreadListEntry*)ptr;
+
+		if( !entry )
+			{
+			LOG_MSG( "  ERROR !* : TThreadListEntry is NULL\n" );
+			User::Leave(KErrBadHandle);
+			}
+
+		if( entry->iNameLength == 0 )
+			{
+			LOG_MSG4( "  Skipping Thread 0x%X%X : entry->iNameLength=%d", 
+				I64HIGH(entry->iThreadId), I64LOW(entry->iThreadId), entry->iNameLength );
+			ptr += Align4( entry->GetSize() );
+			continue;
+			}
+
+		//LOG_MSG3( "  entry &=0x%X, size=%d\n", &(entry->iThreadId), entry->GetSize() );
+		//LOG_MSG3( "  entry->iThreadId= 0x%X%X\n", I64HIGH(entry->iThreadId), I64LOW(entry->iThreadId) );
+		//LOG_MSG3( "  found tid=%d, pid=%d\n", I64LOW(entry->iThreadId), I64LOW(entry->iProcessId) );
+			
+		if( entry->iSupervisorStackPtrValid )
+			{
+			svcStackPtr = entry->iSupervisorStackPtr;
+			}
+		else
+			{
+			svcStackPtr = 0;
+			}
+
+		if( entry->iSupervisorStackBaseValid )
+			{
+			svcStackBase = entry->iSupervisorStackBase;
+			}
+		else
+			{
+			svcStackBase = 0;
+			}
+		
+		if( entry->iSupervisorStackSizeValid )
+			{
+			svcStackSize = entry->iSupervisorStackSize;
+			}
+		else
+			{
+			svcStackSize = 0;
+			}		
+
+
+
+		if( KErrNone == thread.Open( entry->iThreadId ) )
+			{
+			priority = (TUint)(thread.Priority());
+
+			if( KErrNone == thread.StackInfo( stackInfo ) )
+				{
+				usrStackAddr = stackInfo.iLimit;
+				usrStackSize = stackInfo.iBase - stackInfo.iLimit;
+				}
+			else
+				{
+				usrStackSize = 0;
+				usrStackAddr = 0;
+				}
+
+			thread.Close();
+			}
+		else
+			{
+			usrStackSize = 0;
+			usrStackAddr = 0;
+			priority = 0;
+			}
+
+		/*
+		LOG_MSG3( "  entry->iNameLength=%d, &(entry->iName[0])=0x%X\n", 
+				entry->iNameLength, &(entry->iName[0]) );
+		*/
+
+		TPtrC entryName( &(entry->iName[0]), entry->iNameLength );
+		//LOG_MSG2( "  -> threadInfoPtr = CThreadInfo::NewL( name.Size()=%d)\n", entryName.Size() );
+
+		threadInfoPtr = CThreadInfo::NewL( 
+										entry->iThreadId, 
+										entryName,
+										entry->iProcessId,
+										(TUint)priority,
+										svcStackPtr,
+										svcStackBase,
+										svcStackSize,
+										usrStackAddr,
+										usrStackSize );
+
+		/*
+		LOG_MSG3( "  threadInfoPtr->iSvcStackAddr=0x%X, threadInfoPtr->iSvcStackSize=0x%X\n", 
+			threadInfoPtr->SvcStackAddr(), threadInfoPtr->SvcStackSize() );
+		*/
+
+		TInt err = aThreadList.Append( threadInfoPtr );
+		if( err != KErrNone )
+			{
+			// We use this id so as not to use Push(), AppendL(), Pop()
+			delete threadInfoPtr;
+			User::Leave( err );
+			}
+
+		aTotalThreadListDescSize += threadInfoPtr->Size();
+
+		/*
+		LOG_MSG3( "  aTotalThreadListDescSize = %d after adding %d\n", 
+				aTotalThreadListDescSize, threadInfoPtr->Size() );
+
+		RBuf rPrintBuf;
+		rPrintBuf.Create( threadInfoPtr->Name()); 
+		RDebug::Printf( "  <- rPrintBuf.Create(), rPrintBuf.Length()=%d\n", rPrintBuf.Length() );
+		char* cl = (char*) rPrintBuf.Collapse().PtrZ();
+		RDebug::Printf("  name=%s\n", cl );
+		rPrintBuf.Close();
+		*/
+
+		ptr += Align4( entry->GetSize() );
+		//LOG_MSG2( "  ptr += Align4(entry->GetSize()) = 0x%X\n", ptr );
+
+		} // while
+
+	}
+
+void CServerCrashDataSource::GetCodeSegmentsL( const TUint64 aTid, RCodeSegPointerList &aCodeSegList, TUint & aTotalCodeSegListDescSize )
+	{
+	LOG_MSG2("->CServerCrashDataSource::GetCodeSegmentsL(aTid=%Lu)\n", aTid );
+
+    aCodeSegList.ResetAndDestroy();
+    aTotalCodeSegListDescSize = 0;
+
+	TUint32 size = KMaxFileName;
+	RBuf8 buffer;
+    buffer.CreateL(KMaxFileName);
+    CleanupClosePushL(buffer);
+
+	DoGetListL( ECodeSegs, aTid, (TUint)-1, buffer, size );
+	LOG_MSG2( " DoGetListL( ECodeSegs ) returned buffer.Size()=0x%X\n", buffer.Size() );
+
+	TUint8* ptr = (TUint8*)buffer.Ptr();
+	const TUint8* ptrEnd = ptr + size;
+
+	while(ptr < ptrEnd)
+		{
+		TCodeSegListEntry* entry = (TCodeSegListEntry*)ptr;
+
+		LOG_MSG4( "  entry->CodeBase=0x%X, CodeSize=0x%X, ConstDataSize=0x%X\n", 
+			entry->iCodeBase, entry->iCodeSize, entry->iConstDataSize );
+		LOG_MSG4( "  InitDataBase=0x%X, InitDataSize=0x%X, UnintDataSize=0x%X\n", 
+			entry->iInitialisedDataBase, entry->iInitialisedDataSize, entry->iUninitialisedDataSize );
+		LOG_MSG3( "  IsXip=0x%X, CodeSegType=0x%X\n", entry->iIsXip, entry->iCodeSegType );
+		
+        TCodeSegInfo *codeSeg = new(ELeave) TCodeSegInfo;
+
+		TPtr name(&(entry->iName[0]), entry->iNameLength, entry->iNameLength);
+        codeSeg->iName = name;	
+
+        codeSeg->iType = entry->iCodeSegType;
+        codeSeg->iXIP = entry->iIsXip;
+
+        codeSeg->iCodeSize = entry->iCodeSize;
+        codeSeg->iCodeRunAddr = entry->iCodeBase;
+        if( codeSeg->iXIP )
+            {
+            codeSeg->iCodeLoadAddr = codeSeg->iCodeRunAddr;
+            }
+        else
+            {
+            codeSeg->iCodeLoadAddr = 0; //TODO
+            }
+
+        codeSeg->iRoDataSize = entry->iConstDataSize;
+        codeSeg->iRoDataRunAddr = entry->iCodeBase + entry->iCodeSize;
+        if( codeSeg->iXIP )
+            {
+            codeSeg->iRoDataLoadAddr = codeSeg->iRoDataRunAddr;
+            }
+        else
+            {
+            codeSeg->iRoDataLoadAddr = 0; //TODO
+            }
+
+        codeSeg->iDataSize = entry->iInitialisedDataSize + entry->iUninitialisedDataSize;
+        codeSeg->iDataRunAddr = entry->iInitialisedDataBase;
+        if( codeSeg->iXIP )
+            {
+            codeSeg->iDataLoadAddr = codeSeg->iDataRunAddr;
+            }
+        else
+            {
+            codeSeg->iDataLoadAddr = 0; //TODO
+            }
+
+        TInt err = aCodeSegList.Append(codeSeg);
+        if(err != KErrNone)
+            {
+            delete codeSeg;
+            User::Leave(err);
+            }
+
+		aTotalCodeSegListDescSize += sizeof(TCodeSegInfo);
+        ptr += Align4(entry->GetSize());
+		}
+
+    CleanupStack::PopAndDestroy(&buffer);
+	}
+
+/**
+ * Returns the size of the trace data available
+ * @return Trace Size
+ * @leave One of the system wide codes
+ */
+TUint CServerCrashDataSource::GetAvailableTraceSizeL()
+	{
+	LOG_MSG("->CServerCrashDataSource::GetAvailableTraceSizeL()");
+    
+    RBTrace trace;
+    User::LeaveIfError(trace.Open());
+    
+    TUint8 *data = NULL;
+    TInt size = trace.GetData(data);
+
+    trace.Close();  
+    
+    return size;
+	}
+
+/**
+ Reads data from the trace buffer into the supplied descriptor. Not supported. Recommended 
+ approach is to use the live trace framework.
+ @param aTraceData The buffer to be read into
+ @param aPos Ignored
+*/
+void CServerCrashDataSource::ReadTraceBufferL(TDes8 &aTraceData, TUint aPos)
+	{
+    LOG_MSG("->CServerCrashDataSource::ReadTraceBuffer() -- Not supported: Please use the live trace system");
+    
+    User::Leave(KErrNotSupported);
+	}
+
+/**
+ * Gets locks data
+ * @param aLockData stores lock data
+ * @leave one of the OS wide codes
+ */
+void CServerCrashDataSource::GetLocksL(TSCMLockData& aLockData)
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+/**
+ * Gets the ROM build info if available
+ * @param aRomHeader
+ * @leave one of the OS wide codes
+ */
+void CServerCrashDataSource::GetROMBuildInfoL(TRomHeaderData& aRomHeader)
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+/**
+ * @see CCrashDataSource::GetExceptionStackSizeL
+ */
+TUint CServerCrashDataSource::GetExceptionStackSizeL(const Debug::TArmProcessorModes aMode)
+	{
+	User::Leave(KErrNotSupported);
+	return 0; //comp warnings
+	}
+
+/**
+ * @see CCrashDataSource::GetExceptionStackL
+ */
+void CServerCrashDataSource::GetExceptionStackL(const Debug::TArmProcessorModes aMode, TDes8& aStack, TUint aStartReadPoint)
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+/**
+ * @see CCrashDataSource::GetVersion
+ */
+TVersion CServerCrashDataSource::GetVersion() const
+	{
+	return KServerCrashDataSourceVersion;
+	}
+
+/**
+ * @see CCrashDataSource::GetDataSourceFunctionalityBufSize
+ */
+TInt CServerCrashDataSource::GetDataSourceFunctionalityBufSize(TUint& aBufSize)
+	{
+	return KErrNotSupported;
+	}
+
+/**
+ * @see CCrashDataSource::GetDataSourceFunctionality
+ */
+TInt CServerCrashDataSource::GetDataSourceFunctionality(TDes8& aFuncBuffer)
+	{
+	return KErrNotSupported;
+	}
+	
+TInt CServerCrashDataSource::GetVariantSpecificDataSize(TUint& aDataSize) 
+	{
+	(void)aDataSize;
+	return KErrNotSupported;
+	}
+
+TInt CServerCrashDataSource::GetVariantSpecificData(TDes8 &aVarSpecData)
+	{
+	(void)aVarSpecData;
+	return KErrNotSupported;
+	}
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/common/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/common/tcoredumpcommon.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+/**
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+/**
+ @file tcoredumpcommon.h
+ @internalTechnology
+*/
+#if (!defined __TCOREDUMPCOMMON_H__)
+#define __TCOREDUMPCOMMON_H__
+
+#include <plugindata.h>
+#include <threaddata.h>
+#include <processdata.h>
+#include <executabledata.h>
+#include <optionconfig.h>
+
+#include <coredumpserverapi.h>
+#include <coredumpinterface.h>
+
+#include <debuglogging.h>
+
+#define KAppDynamicArrayGranularity (20)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/nand/coredump_nandloader.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem  Batch file that boots into NAND
+
+nandloader -r -a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/nand/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,44 @@
+// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_EXPORTS
+
+PRJ_TESTEXPORTS
+..\scripts\te_coredumpserverSuite.script		\epoc32\winscw\c\scripts\te_coredumpserverSuite.script
+..\scripts\te_lists.script						\epoc32\winscw\c\scripts\te_lists.script
+..\scripts\te_self.script						\epoc32\winscw\c\scripts\te_self.script
+..\scripts\te_parameters.script					\epoc32\winscw\c\scripts\te_parameters.script
+..\scripts\te_dexec.script						\epoc32\winscw\c\scripts\te_dexec.script
+..\scripts\te_testformatter.script			    \epoc32\winscw\c\scripts\te_testformatter.script
+..\scripts\te_cdsconnections.script			    \epoc32\winscw\c\scripts\te_cdsconnections.script
+..\scripts\te_token.script			            \epoc32\winscw\c\scripts\te_token.script
+..\scripts\te_utrace.script						\epoc32\winscw\c\scripts\te_utrace.script
+..\scripts\te_self_trace.script					\epoc32\winscw\c\scripts\te_self_trace.script
+..\scripts\te_signaling.script                 \epoc32\winscw\c\scripts\te_signaling.script
+
+..\testdata\te_coredumpserverSuite.ini			\epoc32\winscw\c\testdata\configs\te_coredumpserverSuite.ini
+..\testdata\te_dexec.ini						\epoc32\winscw\c\testdata\configs\te_dexec.ini
+..\testdata\te_self.ini						\epoc32\winscw\c\testdata\configs\te_self.ini
+..\testdata\te_self_trace.ini						\epoc32\winscw\c\testdata\configs\te_self_trace.ini
+..\testdata\te_signaling.ini                       \epoc32\winscw\c\testdata\configs\te_signaling.ini
+.\tcoredumpserversuite.iby   					\epoc32\rom\include\tcoredumpserversuite.iby
+
+PRJ_MMPFILES
+
+PRJ_TESTMMPFILES
+tcoredumpserversuite.mmp
+
+PRJ_PLATFORMS
+ARMV5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/group/tcds_app.driver	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<driver:driver xmlns:driver="http://www.symbian.com/TestDriver">
+	<task name="coredump1">    
+
+		<task name="te_utrace">
+			<executeOnPC>
+				<build testBuild="true" URI="${sourceroot}\tcds_app\group">
+					<componentName>tcoredumpserversuite</componentName>
+				</build>
+			</executeOnPC>
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${epocroot}\epoc32\WINSCW\C\scripts\te_utrace.script" SymbianPath="c:\testdata\scripts\te_utrace.script"/>
+			</executeOnSymbian>
+		</task> 
+
+		<task name="te_cdsconnections">
+			<executeOnPC>
+				<build testBuild="true" URI="${sourceroot}\tcds_app\group">
+					<componentName>tcoredumpserversuite</componentName>
+				</build>
+			</executeOnPC>
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${epocroot}\epoc32\WINSCW\C\scripts\te_cdsconnections.script" SymbianPath="c:\testdata\scripts\te_cdsconnections.script"/>
+			</executeOnSymbian>
+		</task> 
+
+		<task name="te_token">
+			<executeOnPC>
+				<build testBuild="true" URI="${sourceroot}\tcds_app\group">
+					<componentName>tcoredumpserversuite</componentName>
+				</build>
+			</executeOnPC>
+
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\oemdebug_10282fe5.exe" SymbianPath="c:\sys\bin\oemdebug_10282fe5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${epocroot}\epoc32\WINSCW\C\scripts\te_token.script" SymbianPath="c:\testdata\scripts\te_token.script"/>
+			</executeOnSymbian>
+		</task>
+
+		<task name="te_testformatter">
+			<executeOnPC>
+				<build testBuild="true" URI="${sourceroot}\tcds_app\group">
+					<componentName>tcoredumpserversuite</componentName>
+				</build>
+			</executeOnPC>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${epocroot}\epoc32\WINSCW\C\scripts\te_testformatter.script" SymbianPath="c:\testdata\scripts\te_testformatter.script"/>
+			</executeOnSymbian>
+		</task>
+
+		<task name="te_dexec">
+			<executeOnPC>
+				<build testBuild="true" URI="${sourceroot}\tcds_app\group">
+					<componentName>tcoredumpserversuite</componentName>
+				</build>
+			</executeOnPC>
+
+			<transferToSymbian>
+				<transfer PCPath="${sourceroot}\tcds_app\testdata\te_dexec.ini" SymbianPath="c:\testdata\configs\te_dexec.ini"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${epocroot}\epoc32\WINSCW\C\scripts\te_dexec.script" SymbianPath="c:\testdata\scripts\te_dexec.script"/>
+			</executeOnSymbian>
+
+		</task>
+
+		<task name="te_lists">
+			<executeOnPC>
+				<build testBuild="true" URI="${sourceroot}\tcds_app\group">
+					<componentName>tcoredumpserversuite</componentName>
+				</build>
+			</executeOnPC>
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${epocroot}\epoc32\WINSCW\C\scripts\te_lists.script" SymbianPath="c:\testdata\scripts\te_lists.script"/>
+			</executeOnSymbian>
+		</task>
+
+
+		<task name="te_self">
+			<executeOnPC>
+				<build testBuild="true" URI="${sourceroot}\tcds_app\group">
+					<componentName>tcoredumpserversuite</componentName>
+				</build>
+			</executeOnPC>
+
+			<transferToSymbian>
+				<transfer PCPath="${sourceroot}\tcds_app\testdata\te_self.ini" SymbianPath="c:\testdata\configs\te_self.ini"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${epocroot}\epoc32\WINSCW\C\scripts\te_self.script" SymbianPath="c:\testdata\scripts\te_self.script"/>
+			</executeOnSymbian>
+		</task>
+
+		<task name="te_self_trace">
+			<executeOnPC>
+				<build testBuild="true" URI="${sourceroot}\tcds_app\group">
+					<componentName>tcoredumpserversuite</componentName>
+				</build>
+			</executeOnPC>
+
+			<transferToSymbian>
+				<transfer PCPath="${sourceroot}\tcds_app\testdata\te_self_trace.ini" SymbianPath="c:\testdata\configs\te_self_trace.ini"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${epocroot}\epoc32\WINSCW\C\scripts\te_self_trace.script" SymbianPath="c:\testdata\scripts\te_self_trace.script"/>
+			</executeOnSymbian>
+		</task>
+	
+		<task name="te_parameters">
+			<executeOnPC>
+				<build testBuild="true" URI="${sourceroot}\tcds_app\group">
+					<componentName>tcoredumpserversuite</componentName>
+				</build>
+			</executeOnPC>
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${epocroot}\epoc32\WINSCW\C\scripts\te_parameters.script" SymbianPath="c:\testdata\scripts\te_parameters.script"/>
+			</executeOnSymbian>
+		</task>
+		
+		<task name="te_signaling">
+			<executeOnPC>
+				<build testBuild="true" URI="${sourceroot}\tcds_app\group">
+					<componentName>tcoredumpserversuite</componentName>
+				</build>
+			</executeOnPC>
+			
+			<transferToSymbian>
+				<transfer PCPath="${sourceroot}\tcds_app\testdata\te_signaling.ini" SymbianPath="c:\testdata\configs\te_signaling.ini"/>
+			</transferToSymbian>
+			
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${epocroot}\epoc32\WINSCW\C\scripts\te_signaling.script" SymbianPath="c:\testdata\scripts\te_signaling.script"/>
+			</executeOnSymbian>
+		</task>
+
+	</task>
+</driver:driver>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/group/tcds_app_config.xml	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE preferences SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>
+
+<preferences EXTERNAL_XML_VERSION="1.0">
+  <root type="user">
+    <map />
+    <node name="com">
+      <map />
+      <node name="symbian">
+        <map />
+        <node name="driver">
+          <map>
+            <entry key="bldmake" value="true" />
+            <entry key="buildNumber" value="MSF00167_Symbian_OS_vtb92sf" />
+            <entry key="clean" value="false" />
+            <entry key="client" value="localhost" />
+            <entry key="entryPointAddress" value="file:/Y:\sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\automatictests\tcds_app\group\tcds_app.driver#coredump1" />
+            <entry key="epocRoot" value="Y:\" />
+            <entry key="jobID" value="0" />
+            <entry key="jobsfolder" value="c:\Jobs" />
+            <entry key="kernel" value="EKA2" />
+            <entry key="mode" value="sync" />
+            <entry key="platform" value="armv5" />
+            <entry key="platsec" value="true" />
+            <entry key="rdebug" value="" />
+            <entry key="repositoryRoot" value="Y:\testdriver\repos" />
+            <entry key="resultRoot" value="Y:\logs\testdriver" />
+            <entry key="rom" value="" />
+            <entry key="runNumber" value="2" />
+            <entry key="server" value="//localhost/RemoteTestDriver" />
+            <entry key="server_name" value="localhost" />
+            <entry key="service" value="RemoteTestDriver" />
+            <entry key="sysbin" value="false" />
+            <entry key="sourceRoot" value="Y:\sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\automatictests" />
+            <entry key="trgtest" value="0" />
+            <entry key="testExecute" value="false" />
+            <entry key="testPackage" value="Y:\\.\test.pkg" />
+            <entry key="transport" value="serial3" />
+            <entry key="uccAddress" value="" />
+            <entry key="variant" value="udeb" />
+            <entry key="wintap" value="192.168.0.3" />
+            <entry key="workingPath" value="c:\SITK\testdriver\" />
+            <entry key="xmlRoot" value="Y:\" />
+            <entry key="commDB" value="off" />
+            <entry key="uidFirst" value="0x10210D02" />
+            <entry key="uidLast" value="0x10210D32" />
+            <entry key="key" value="" />
+            <entry key="cert" value="" />
+            <entry key="statTimeout" value="300000" />
+          </map>
+        </node>
+      </node>
+    </node>
+  </root>
+</preferences>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/group/tcoredumpserversuite.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TE_COREDUMPSERVER_SUITE_IBY__
+#define __TE_COREDUMPSERVER_SUITE_IBY__
+
+#include <testexecute.iby>
+
+file=ABI_DIR\BUILD_DIR\Te_coredumpserverSuite.exe		sys\bin\Te_coredumpserverSuite.exe
+
+data=EPOCROOT##Epoc32\winscw\c\testdata\configs\te_coredumpserverSuite.ini		\testdata\configs\te_coredumpserversuite.ini
+data=EPOCROOT##Epoc32\winscw\c\testdata\configs\te_dexec.ini		\testdata\configs\te_dexec.ini
+data=EPOCROOT##Epoc32\winscw\c\testdata\configs\te_self.ini		\testdata\configs\te_self.ini
+data=EPOCROOT##Epoc32\winscw\c\testdata\configs\te_self_trace.ini		\testdata\configs\te_self_trace.ini
+data=EPOCROOT##Epoc32\winscw\c\testdata\configs\te_signaling.ini       \testdata\configs\te_signaling.ini
+
+data=EPOCROOT##Epoc32\winscw\c\scripts\te_cdsconnections.script	\scripts\te_cdsconnections.script
+data=EPOCROOT##Epoc32\winscw\c\scripts\te_coredumpserversuite.script	\scripts\te_coredumpserversuite.script
+data=EPOCROOT##Epoc32\winscw\c\scripts\te_dexec.script	\scripts\te_dexec.script
+data=EPOCROOT##Epoc32\winscw\c\scripts\te_lists.script	\scripts\te_lists.script
+data=EPOCROOT##Epoc32\winscw\c\scripts\te_parameters.script	\scripts\te_parameters.script
+data=EPOCROOT##Epoc32\winscw\c\scripts\te_self_trace.script	\scripts\te_self_trace.script
+data=EPOCROOT##Epoc32\winscw\c\scripts\te_self.script	\scripts\te_self.script
+data=EPOCROOT##Epoc32\winscw\c\scripts\te_testformatter.script	\scripts\te_testformatter.script
+data=EPOCROOT##Epoc32\winscw\c\scripts\te_token.script	\scripts\te_token.script
+data=EPOCROOT##Epoc32\winscw\c\scripts\te_utrace.script	\scripts\te_utrace.script
+data=EPOCROOT##Epoc32\winscw\c\scripts\te_signaling.script \scripts\te_signaling.script
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/group/tcoredumpserversuite.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Te_coredumpserverSuite.mmp
+//
+
+TARGET      Te_coredumpserverSuite.exe
+TARGETTYPE  exe
+UID             0x1000007A 0x102836B7 
+
+//Please add any change under here
+SOURCEPATH  ..\src
+SOURCE	            tcoredumpserversuiteserver.cpp
+SOURCE	            tcoredumpserversuitestepbase.cpp
+SOURCE              DEXCusersidestep.cpp
+SOURCE              liststep.cpp
+SOURCE              parameterstep.cpp
+SOURCE              SELFusersidestep.cpp
+SOURCE				SELFpluginstep.cpp
+SOURCE				DEXCpluginstep.cpp
+SOURCE 				testformatterusersidestep.cpp
+SOURCE 				CDSconnectionstep.cpp
+SOURCE 				CDStokenstep.cpp
+SOURCE				utracestep.cpp
+SOURCE				SELFusersidestrace.cpp
+SOURCE              testsignaling.cpp
+	
+USERINCLUDE   ..\..\common
+USERINCLUDE   ..\src
+USERINCLUDE   ..\inc
+
+SYSTEMINCLUDE \epoc32\include
+SYSTEMINCLUDE \epoc32\include\test
+SYSTEMINCLUDE \epoc32\include\drivers
+SYSTEMINCLUDE \epoc32\include\ecom
+SYSTEMINCLUDE \epoc32\include\tools\coredump
+SYSTEMINCLUDE \epoc32\include\tools
+
+//Please add your system include under here. 
+
+LIBRARY     euser.lib
+LIBRARY		testexecuteutils.lib 
+LIBRARY		testexecutelogclient.lib 
+LIBRARY     efsrv.lib
+
+//Please add your libraries under here. For example:
+LIBRARY     estor.lib
+LIBRARY     coredumpinterface.lib
+LIBRARY     cdssupport.lib
+LIBRARY     bafl.lib 
+LIBRARY     versit.lib
+
+CAPABILITY PowerMgmt
+
+MACRO CDSDEBUG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/CDSconnectionstep.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/**
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file DEXECPluginStep.h
+ @internalTechnology
+*/
+#if (!defined __CDSCONNECTIONS_STEP_H__)
+#define __CDSCONNECTIONS_STEP_H__
+#include <TestExecuteStepBase.h>
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpcommon.h"
+
+class CCDSConnectionsStep : public CTe_coredumpserverSuiteStepBase
+	{
+public:
+	CCDSConnectionsStep();
+	~CCDSConnectionsStep();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepL();
+	virtual TVerdict doTestStepPostambleL();
+
+// Please add/modify your class members here:
+private:
+	
+	void ClientAppL();
+	void TestConnectionsL();
+	};
+
+_LIT(KCDSConnectionsStep,"CDSConnectionsStep");
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/CDStokenstep.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,54 @@
+/**
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file tokenstep.h
+ @internalTechnology
+*/
+#if (!defined __TOKEN_STEP_H__)
+#define __TOKEN_STEP_H__
+#include <TestExecuteStepBase.h>
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpcommon.h"
+
+
+class CTokenStep : public CTe_coredumpserverSuiteStepBase
+	{
+public:
+	CTokenStep();
+	~CTokenStep();
+	
+	void ClientAppL();
+	
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepL();
+	virtual TVerdict doTestStepPostambleL();
+
+// Please add/modify your class members here:
+private:
+
+	RCoreDumpSession iSess;
+
+	void CheckAttachL();
+	
+	};
+
+_LIT(KTokenStep,"TokenStep");
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/DEXCpluginstep.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,55 @@
+/**
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file DEXECPluginStep.h
+ @internalTechnology
+*/
+#if (!defined __DEXECPLUGINS_STEP_H__)
+#define __DEXECPLUGINS_STEP_H__
+#include <TestExecuteStepBase.h>
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpcommon.h"
+
+class CDEXECPluginStep : public CTe_coredumpserverSuiteStepBase
+	{
+    enum { DexcMultipleTries = 11 };
+public:
+	CDEXECPluginStep();
+	~CDEXECPluginStep();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepL();
+	virtual TVerdict doTestStepPostambleL();
+
+// Please add/modify your class members here:
+private:
+
+	RCoreDumpSession iSess;
+	
+	void ClientAppL();
+	void LoadPluginL();
+    void UnloadPluginL();
+    void UnloadPluginL(const TInt aCounter);
+	void LoadMultiplePluginsL(const TInt aCounter);
+	void UnloadMultiplePluginsL(const TInt aCounter);
+	};
+
+_LIT(KDEXECPluginStep,"DEXECPluginStep");
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/DEXCusersidestep.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,74 @@
+/**
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file DEXECStep.h
+ @internalTechnology
+*/
+#if (!defined __DEXEC_STEP_H__)
+#define __DEXEC_STEP_H__
+#include <TestExecuteStepBase.h>
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpcommon.h"
+
+class CDEXECUserSideStep : public CTe_coredumpserverSuiteStepBase
+	{
+public:
+	CDEXECUserSideStep();
+	~CDEXECUserSideStep();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepL();
+	virtual TVerdict doTestStepPostambleL();
+
+// Please add/modify your class members here:
+private:
+
+
+	RCoreDumpSession iSess;
+	RFs iFs;
+	
+	void ClientAppL();
+	
+	//Tests
+	void HandleCrashL();
+	
+	
+	//Utility functions
+	void LoadDEXECFormatterL();
+    void LoadFileWriterL();
+    void BindPluginsL(const TInt aCount);
+	
+	void MonitorProgressL();
+	void DoConfigureL( const TUint32& aIndex, 
+					  const TUint32& aUID, 
+					  const COptionConfig::TParameterSource& aSource, 
+					  const COptionConfig::TOptionType& aType, 
+					  const TDesC& aPrompt, 
+					  const TUint32& aNumOptions,
+					  const TDesC& aOptions,
+					  const TInt32& aVal, 
+					  const TDesC& aStrValue,
+					  const TUint aInstance );
+
+    void CheckParametersL();
+	};
+
+_LIT(KDEXECUserSideStep,"DEXECUserSideStep");
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/SELFpluginstep.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,55 @@
+/**
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file SELFStep.h
+ @internalTechnology
+*/
+#if (!defined __SELFPLUGINS_STEP_H__)
+#define __SELFPLUGINS_STEP_H__
+#include <TestExecuteStepBase.h>
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpcommon.h"
+
+class CSELFPluginStep : public CTe_coredumpserverSuiteStepBase
+	{
+    enum {SelfMultipleTries = 11};
+public:
+	CSELFPluginStep();
+	~CSELFPluginStep();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepL();
+	virtual TVerdict doTestStepPostambleL();
+
+// Please add/modify your class members here:
+private:
+
+	RCoreDumpSession iSess;
+	
+	void ClientAppL();
+	void LoadPluginL();
+	void UnloadPluginL();
+	void UnloadPluginL(const TInt aIndex);
+	void LoadMultiplePluginsL(const TInt aCount);
+	void UnloadMultiplePluginsL(const TInt aCount);
+	};
+
+_LIT(KSELFPluginStep,"SELFPluginStep");
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/SELFusersidestep.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,77 @@
+/**
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file SELFStep.h
+ @internalTechnology
+*/
+#if (!defined __SELF_STEP_H__)
+#define __SELF_STEP_H__
+#include <TestExecuteStepBase.h>
+
+
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpcommon.h"
+
+_LIT(KSELFUserSideStep,"SELFUserSideStep");
+
+class CSELFUserSideStep : public CTe_coredumpserverSuiteStepBase
+	{
+public:
+	CSELFUserSideStep();
+	~CSELFUserSideStep();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepL();
+	virtual TVerdict doTestStepPostambleL();
+
+// Please add/modify your class members here:
+private:
+
+	RCoreDumpSession iSess;
+	RFs iFs;	
+	
+	void ClientAppL();
+	
+	//Tests
+	void HandleCrashL();
+
+	
+	//Utility functions
+	void LoadSELFFormatterL();
+    void LoadFileWriterL();
+    void BindPluginsL(const TInt aCoung);
+
+	void MonitorProgressL();
+    void DoConfigureL( const TUint32& aIndex, 
+					  const TUint32& aUID, 
+					  const COptionConfig::TParameterSource& aSource, 
+					  const COptionConfig::TOptionType& aType, 
+					  const TDesC& aPrompt, 
+					  const TUint32& aNumOptions,
+					  const TDesC& aOptions,
+					  const TInt32& aVal, 
+					  const TDesC& aStrValue,
+                      const TUint aInstance );
+
+    void CheckParametersL();
+	};
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/SELFusersidetrace.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,124 @@
+/**
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file SELFusersidetrace.h
+ @internalTechnology
+*/
+#if (!defined __SELF_USER_SIDE_TRACE_H__)
+#define ___SELF_USER_SIDE_TRACE_H__
+#include <TestExecuteStepBase.h>
+#include <symbianelfdefs.h>
+#include <bafindf.h>
+#include <crashdefs.h>
+
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpcommon.h"
+
+
+_LIT(KSELFUserSideTrace,"SELFUserSideTrace");
+
+//Maximum Number of DHDR expected in the SELF File
+const TInt MAXNUMBEROFDHDR = 200;
+
+_LIT( KCreateTraceData, "How much Trace data to capture (Kb)" );
+
+
+class CSELFUserSideTrace : public CTe_coredumpserverSuiteStepBase
+	{
+public:
+	CSELFUserSideTrace();
+	~CSELFUserSideTrace();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepL();
+	virtual TVerdict doTestStepPostambleL();
+
+// Please add/modify your class members here:
+private:
+
+	//session object to the Core Dump Server
+	RCoreDumpSession iCoreDumpSession;
+	//File Server session    
+	RFs iFsSession;
+	//File Handle for the ELF File
+	RFile iSELFFile;
+	//SELF File name
+	TBufC<KMaxFileName> iSELFFileName; 
+	//stores the SELF Program Header
+	TUint8* iSELFPHHeader;
+	//Number of Program Header Entries 
+	TInt iPHEntries;
+	//Program Header Offset 
+	TInt iPHOffset;
+	//stores the DHDR Buffers
+	TUint8* iDHDRBuffer[MAXNUMBEROFDHDR];
+	//actual SELF DHDR strcuture Sym32_dhdr
+	Sym32_dhdr* idhdr[MAXNUMBEROFDHDR];
+	//offset to the String section
+	TInt iOffsetStringSection;
+	//size of String section
+	TInt iSizeofStringSection;
+	//flag to determine whether there is trace or not
+	TBool iTraceFlag;
+	
+	void ClientAppL();
+	
+	//Tests
+	void HandleCrashL();
+	
+	void DoTestTraceSectionSELFFileL(TBool );
+	
+	void ValidateHeaderELFFileL();
+	
+	void ValidateProgramHeaderELFFileL();
+	
+	void ValidateTraceSectionELFFileL(TBool );
+	
+	void ValidateTraceBufferL(const TDesC8&  );
+
+	
+	//Utility functions
+	
+	void DoCmdLoadPluginsL();
+	
+	void DoCmdConfigurePluginsL( );
+	
+	void ConfigureSELF(TBool );
+
+	void MonitorProgressL();
+	
+    void DoConfigureL( const TUint32& aIndex, 
+					  const TUint32& aUID, 
+					  const COptionConfig::TParameterSource& aSource, 
+					  const COptionConfig::TOptionType& aType, 
+					  const TDesC& aPrompt, 
+					  const TUint32& aNumOptions,
+					  const TDesC& aOptions,
+					  const TInt32& aVal, 
+					  const TDesC& aStrValue,
+                      const TUint aInstance );
+    
+    void CleanupMethod(const TDesC& );
+
+
+	};
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/liststep.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,56 @@
+/**
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file ListsStep.h
+ @internalTechnology
+*/
+#if (!defined __LISTS_STEP_H__)
+#define __LISTS_STEP_H__
+#include <TestExecuteStepBase.h>
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpcommon.h"
+
+class CListsStep : public CTe_coredumpserverSuiteStepBase
+	{
+public:
+	CListsStep();
+	~CListsStep();
+	
+	void ClientAppL();
+	
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepL();
+	virtual TVerdict doTestStepPostambleL();
+
+// Please add/modify your class members here:
+private:
+
+	RCoreDumpSession iSess;
+
+	void ListProcessesL();
+	void ListThreadsL();
+	void ListExecutables();
+	void ListPlugins();
+	
+	};
+
+_LIT(KListsStep,"ListsStep");
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/parameterstep.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,91 @@
+/**
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file ParametersStep.h
+ @internalTechnology
+*/
+#if (!defined __PARAMETERS_STEP_H__)
+#define __PARAMETERS_STEP_H__
+#include <TestExecuteStepBase.h>
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpserversuiteserver.h"
+#include "optionconfig.h"
+#include "tcoredumpcommon.h"
+#include <rm_debug_api.h>
+
+using namespace Debug;
+
+_LIT(KParametersStep,"ParametersStep");
+
+const TUid KCrashAppUid = { 0x102831E5 };
+
+class CParametersStep : public CTe_coredumpserverSuiteStepBase
+	{
+public:
+	CParametersStep();
+	~CParametersStep();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepL();
+	virtual TVerdict doTestStepPostambleL();
+
+// Please add/modify your class members here:
+private:
+
+	RCoreDumpSession iSess;
+	RSecuritySvrSession iSecSess;
+	RFs iFs;
+
+	void ClientAppL();	
+	
+	//Tests
+	void CrashChildThreadAndTestPostProcL();
+	void CrashMainThreadAndTestPostProcL();
+	void CrashChildThreadAndTestPreProcL();
+	
+	//Utilities
+	void KillProcessAfterCrashL();	
+	void GenerateAndHandleCrashL(const TDesC& aCrashAppParameters, 
+								 const TUint& aCDSPostProcParam,
+								 const TUint& aCDSPreProcParam);
+
+	void DoConfigureL(const TUint32& aIndex, 
+	 	     		  const TUint32& aUID, 
+	 	     		  const COptionConfig::TParameterSource& aSource, 
+	 	     		  const COptionConfig::TOptionType& aType, 
+	 	     		  const TDesC& aPrompt, 
+	 	     		  const TUint32& aNumOptions,
+	 	     		  const TDesC& aOptions,
+	 	     		  const TInt32& aVal, 
+	 	     		  const TDesC& aStrValue );	
+	void MonitorProgressL();
+	TProcessId IsCrashAppAliveL();
+	void KillCrashAppL(const TDesC& aProcessName);
+	
+	void ResumeProcessL(TUint64 aPid);
+	TInt GetNumberOfProccessesL();
+	TInt GetNumberThreadsL();
+	
+	TBool IsCrashAppMainThreadRunningL();	
+	
+	};
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/tcoredumpserversuitedefs.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,79 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* This file define all the common values thoughout your test project
+*
+*/
+
+
+
+/**
+ @file Te_coredumpserverSuiteDefs.h
+ @internalTechnology
+*/
+#if (!defined __TE_COREDUMPSERVER_SUITEDEFS_H__)
+#define __TE_COREDUMPSERVER_SUITEDEFS_H__
+
+#include <rm_debug_api.h>
+
+using namespace Debug;
+
+static const TUid SELF_UID = TUid::Uid(0x10282FE3);  // For UID allocations see http://smglinx.intra/twiki/bin/view/PTD/CoreToolsDebugCoreDump
+static const TUid CDS_UID  = TUid::Uid(0x10282FE5);
+static const TUid DEXEC_UID = TUid::Uid(0x102832C5);
+static const TUid WRITER_UID = TUid::Uid(0x102831E4);
+static const TUid UTRACE_UID = TUid::Uid(0x102836BA);
+static const TUid KUidSELFFormatterV2 = TUid::Uid(0x102836bb);
+
+// Please modify below value with your project and must match with your configuration ini file which is required to be modified as well
+_LIT(KTe_coredumpserverSuiteString,"TheString");
+_LIT(KTe_coredumpserverSuiteInt,"TheInt");
+_LIT(KTe_coredumpserverSuiteBool,"TheBool");
+_LIT(KCrashAppFileName,"Z:\\sys\\bin\\crashapp.exe");
+_LIT(KCrashAppFileNameNonDebugBit,"Z:\\sys\\bin\\crashapp_nodebugbit.exe");
+_LIT( KPostCrashEventActionPrompt, "Action After Crash:\n  0-None,\n  1-Resume Thread,\n  2-Resume Process,\n  4-Kill Process" );
+
+_LIT(KTe_CrashAppParam,"CrashAppParam");
+_LIT(KTe_CrashFileName,"CrashFileName");
+_LIT(KWriterToUse, "WriterToUse");
+_LIT(KTrace, "Trace");
+_LIT(KNumberofCrashes, "CrashNumber");
+
+
+/** Expected Crash File Name */
+_LIT(KCrashFileName, "e:\\naibmys");
+/** String to be match when read from the INI file */
+_LIT(KTraceData, "Trace");
+/** wildcrad used to search for the File created */
+_LIT(KCrashWildCard, "naibmys*");
+/** Setting Directory Path to E:\\ MMC card */
+_LIT(KDir, "e:\\");
+_LIT( KFilePathPrompt, "not_important" );
+
+const TVersion securityServerVersion( 
+		KDebugServMajorVersionNumber, 
+		KDebugServMinorVersionNumber, 
+		KDebugServPatchVersionNumber );
+
+//These need to corrospond to those being set in the SELF formatter
+_LIT(KStartOfSELFProc, "-");
+_LIT(KStartOfUTraceProc, "started utrace formatting");
+
+_LIT(KStartOfDEXECProc, "crash dump started");
+_LIT(KEndOfProcessing, "idle");
+
+// For test step panics
+_LIT(KTe_coredumpserverSuitePanic,"Te_coredumpserverSuite");
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/tcoredumpserversuiteserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,47 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file Te_coredumpserverSuiteServer.h
+ @internalTechnology
+*/
+
+#if (!defined __TE_COREDUMPSERVER_SERVER_H__)
+#define __TE_COREDUMPSERVER_SERVER_H__
+#include <TestExecuteServerBase.h>
+#include <BADESCA.H>
+
+class CTe_coredumpserverSuite : public CTestServer
+	{
+public:
+	static CTe_coredumpserverSuite* NewL();
+	// Base class pure virtual override
+	virtual CTestStep* CreateTestStep(const TDesC& aStepName);
+	static void CleanupProcessList(TAny *aArray);
+	static void CleanupThreadList(TAny *aArray);
+	static void CleanupPluginList(TAny *aArray);
+	static void CleanupBufferArray(TAny *aArray);
+	static CDir* DoesFileExistL(const TDesC& aExpectedFile, TFindFile &aFileFinder);
+	static TBool FileStartsWith(const TDesC& aRoot, const TDesC& aFilename );
+
+// Please Add/modify your class members
+private:
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/tcoredumpserversuitestepbase.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,51 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file Te_coredumpserverSuiteStepBase.h
+ @internalTechnology
+*/
+
+#if (!defined __TE_COREDUMPSERVER_STEP_BASE__)
+#define __TE_COREDUMPSERVER_STEP_BASE__
+#include <TestExecuteStepBase.h>
+// Please add your include here if you have 
+
+/****************************************************************************
+* The reason to have a new step base is that it is very much possible
+* that the all individual test steps have project related common variables 
+* and members 
+* and this is the place to define these common variable and members.
+* 
+****************************************************************************/
+class CTe_coredumpserverSuiteStepBase : public CTestStep
+	{
+public:
+	virtual ~CTe_coredumpserverSuiteStepBase();
+	CTe_coredumpserverSuiteStepBase();
+	virtual TVerdict doTestStepPreambleL(); 
+	virtual TVerdict doTestStepPostambleL();
+
+//Please add your class members which will be common to all individual test steps:
+protected:
+	HBufC8*		iReadData;
+	HBufC8*		iWriteData;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/testformatterusersidestep.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,72 @@
+/**
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file SELFStep.h
+ @internalTechnology
+*/
+#if (!defined __TESTFORMATTER_STEP_H__)
+#define __TESTFORMATTER_STEP_H__
+#include <TestExecuteStepBase.h>
+
+
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpcommon.h"
+
+_LIT(KTestFormatterUserSideStep,"TestFormatterUserSideStep");
+
+class CTestFormatterUserSideStep : public CTe_coredumpserverSuiteStepBase
+	{
+public:
+	CTestFormatterUserSideStep();
+	~CTestFormatterUserSideStep();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepL();
+	virtual TVerdict doTestStepPostambleL();
+
+// Please add/modify your class members here:
+private:
+
+	RCoreDumpSession iSess;
+	RFs iFs;	
+	
+	void ClientAppL();
+	
+	//Tests
+	void HandleCrashL();
+
+	
+	//Utility functions
+	void LoadSELFFormatterL();
+
+	void MonitorProgressL();
+    void DoConfigureL( const TUint32& aIndex, 
+					  const TUint32& aUID, 
+					  const COptionConfig::TParameterSource& aSource, 
+					  const COptionConfig::TOptionType& aType, 
+					  const TDesC& aPrompt, 
+					  const TUint32& aNumOptions,
+					  const TDesC& aOptions,
+					  const TInt32& aVal, 
+					  const TDesC& aStrValue );
+	};
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/testsignaling.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,91 @@
+/**
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* Test ECrashMediaName RProperty signaling mechanism for application crashes
+*/
+
+/**
+ @file testsignaling.h
+ @internalTechnology
+*/
+
+#if (!defined __TEST_SIGNALING_H__)
+#define __TEST_SIGNALING_H__
+
+#include <e32property.h>
+#include <TestExecuteStepBase.h>
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpcommon.h"
+
+_LIT(KTestSignaling,"TestSignaling");
+
+class CTestSignaling : public CTe_coredumpserverSuiteStepBase
+    {
+
+public:
+    CTestSignaling();
+    ~CTestSignaling();
+
+    virtual TVerdict doTestStepPreambleL();
+    virtual TVerdict doTestStepPostambleL();
+    virtual TVerdict doTestStepL();
+
+private:
+
+    void ClientAppL();
+    void TestSignalingMechanismL();
+
+    // main methods to check teh signaling mechanism
+    void CheckUIDCrashProgressL();
+    void CheckCrashMediaNameL();
+    void TestCrashMessageBufferL();
+    void CheckCancelCrashL();
+
+    void LoadandConfigurePluginsL(const TDesC& aCrashFileName);
+    void DoConfigureL( const TUint32& aIndex, const TUint32& aUID,
+            const COptionConfig::TParameterSource& aSource,
+            const COptionConfig::TOptionType& aType, const TDesC& aPrompt,
+            const TUint32& aNumOptions, const TDesC& aOptions,
+            const TInt32& aVal, const TDesC& aStrValue, const TUint aInstance);
+
+    void StartCrashAppL(const TDesC& aCrashAppParam);
+    void ReadCrashProgressPacketL(TUint& aUID, TDes& aMessageBuffer);
+    void ParseMediaNameBufferL(TUint crashUID, TDes& crashMediaNameBuffer, TDes& statusbit);
+    void SaveCrashUIDL(TUint aSaveCrashUID);
+    void ZeroCrashMediaNameL();
+	void TidyFilesL(const TDesC& aFilenameRoot);
+
+ // member variables
+
+    RCoreDumpSession iSess;
+    RFs iFs;
+
+    RProperty iCrashProgress;
+    RProperty iCrashMediaName;
+    RProperty iCrashCancel;
+
+    RBuf iCrashProgressBuffer;
+    RBuf iCrashMediaNameBuffer;
+
+    TBuf<KMaxFileName> iCrashFileName;
+    // Crash UID for KNumofEntries crashes
+    TInt iCrashUID[KNumofEntries];
+
+    TInt iNumberofCrashes;
+
+    TInt iTimestoCrash;
+
+    };
+
+#endif //__TEST_SIGNALING_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/inc/utracestep.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+/**
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file SELFStep.h
+ @internalTechnology
+*/
+#if (!defined __UTRACE_STEP_H__)
+#define __UTRACE_STEP_H__
+#include <TestExecuteStepBase.h>
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpcommon.h"
+
+class CUTraceStep : public CTe_coredumpserverSuiteStepBase
+	{
+public:
+	CUTraceStep();
+	~CUTraceStep();
+	virtual TVerdict doTestStepPreambleL();
+	virtual TVerdict doTestStepL();
+	virtual TVerdict doTestStepPostambleL();
+
+	// Please add/modify your class members here:
+private:
+
+	RCoreDumpSession iSess;
+	RFs iFs;
+
+	void ClientAppL();
+	void HandleCrashL(const TDesC& aFileName);
+	void LoadUTraceFormatterL();
+	void LoadFileWriterL();
+	void DoConfigureL( const TUint32& aIndex, const TUint32& aUID,
+			const COptionConfig::TParameterSource& aSource,
+			const COptionConfig::TOptionType& aType, const TDesC& aPrompt,
+			const TUint32& aNumOptions, const TDesC& aOptions,
+			const TInt32& aVal, const TDesC& aStrValue, const TUint aInstance);
+
+	void MonitorProgressL();
+	void TestTraceDataL();
+	void VerifyTraceDataL(const TDesC& aFullFilename);
+
+	};
+
+_LIT(KUTraceUserSide, "UTraceUserSide");
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_cdsconnections.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								te_cdsconnections.script
+//
+
+//! @SYMTestSuiteName               	DT-coredumpserver-connections
+//! @SYMScriptTestEnvironment       	TEF
+
+PRINT Running te_coredumpserver.CDSCONNECTIONS
+
+LOAD_SERVER te_coredumpserverSuite
+
+START_TESTCASE                DT-coredumpserver-connections-0001
+//! @SYMTestCaseID              DT-coredumpserver-connections-0001
+//! @SYMTestCaseDesc            Test that we can connect to the CDS
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Test that we can connect to the CDS
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite CDSConnectionsStep
+END_TESTCASE DT-coredumpserver-connections-0001
+PRINT Completed te_coredumpserver.CDSCONNECTIONS
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_coredumpserversuite.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,31 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+//! @File								te_coredumpserversuite.script
+//! @SYMTestSuiteName               	Core Dump Application Crash
+//! @SYMScriptTestEnvironment       	TEF
+PRINT Run all te_coredumpserver Suite Tests
+
+//
+LOAD_SUITE te_coredumpserverSuite
+//
+
+//RUN_TEST_STEP 100 te_coredumpserverSuite DEXECStep \testdata\configs\te_coredumpserverSuite.ini Section0
+RUN_TEST_STEP 100 te_coredumpserverSuite ListsStep \testdata\configs\te_coredumpserverSuite.ini Section1
+//RUN_TEST_STEP 100 te_coredumpserverSuite ParametersStep \testdata\configs\te_coredumpserverSuite.ini Section2
+//RUN_TEST_STEP 100 te_coredumpserverSuite PluginsStep \testdata\configs\te_coredumpserverSuite.ini Section3
+//RUN_TEST_STEP 100 te_coredumpserverSuite SELFStep \testdata\configs\te_coredumpserverSuite.ini Section4
+
+PRINT Complate_te_coredumpserver_Tests
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_dexec.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,180 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								te_dexec.script
+//
+
+//! @SYMTestSuiteName               	DT-dexc-userside
+//! @SYMScriptTestEnvironment       	TEF
+
+PRINT Running te_coredumpserver.DEXC
+
+LOAD_SERVER te_coredumpserverSuite
+
+
+
+START_TESTCASE                DT-dexc-userside-0001
+//! @SYMTestCaseID              DT-dexc-userside-0001
+//! @SYMTestCaseDesc            Loading and unloading multiple dexc plugins
+//! @SYMTestPriority            High
+//! @SYMTestActions             Test we can load/unload 1 dexc plugin and then that we can load/unload multiple ones.
+//! @SYMTestExpectedResults     Should suceed without error and be available via the GetFormattersL call
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite DEXECPluginStep
+END_TESTCASE DT-dexc-userside-0001
+
+
+START_TESTCASE                DT-dexc-userside-0002
+//! @SYMTestCaseID              DT-dexc-userside-0002
+//! @SYMTestCaseDesc            dexc with Prefetch Abort
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app with prefetch abort and verify the dexc file is generated and that the crashed process has been correctly dealt with as per config
+//! @SYMTestExpectedResults     Should find expected dexc files and correct process list
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite DEXECUserSideStep \testdata\configs\te_dexec.ini user_PrefetchAbort
+END_TESTCASE DT-dexc-userside-0002
+
+
+START_TESTCASE                DT-dexc-userside-0003
+//! @SYMTestCaseID              DT-dexc-userside-0003
+//! @SYMTestCaseDesc            dexc with Data Read
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app with Data Read and verify the dexc file is generated and that the crashed process has been correctly dealt with as per config
+//! @SYMTestExpectedResults     Should find expected dexc files and correct process list
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite DEXECUserSideStep  \testdata\configs\te_dexec.ini user_DataRead
+END_TESTCASE DT-dexc-userside-0003
+
+
+START_TESTCASE                DT-dexc-userside-0004
+//! @SYMTestCaseID              DT-dexc-userside-0004
+//! @SYMTestCaseDesc            dexc with Data Write
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app with Data Write and verify the dexc file is generated and that the crashed process has been correctly dealt with as per config
+//! @SYMTestExpectedResults     Should find expected dexc files and correct process list
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite DEXECUserSideStep  \testdata\configs\te_dexec.ini user_DataWrite
+END_TESTCASE DT-dexc-userside-0004
+
+
+START_TESTCASE                DT-dexc-userside-0005
+//! @SYMTestCaseID              DT-dexc-userside-0005
+//! @SYMTestCaseDesc            dexc with Undefined Instruction
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app with undefined instruction and verify the dexc file is generated and that the crashed process has been correctly dealt with as per config
+//! @SYMTestExpectedResults     Should find expected dexc files and correct process list
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite DEXECUserSideStep  \testdata\configs\te_dexec.ini user_UndefInstr
+END_TESTCASE DT-dexc-userside-0005
+
+
+START_TESTCASE                DT-dexc-userside-0006
+//! @SYMTestCaseID              DT-dexc-userside-0006
+//! @SYMTestCaseDesc            dexc with User Panic
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app with user panic and verify the dexc file is generated and that the crashed process has been correctly dealt with as per config
+//! @SYMTestExpectedResults     Should find expected dexc files and correct process list
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite DEXECUserSideStep  \testdata\configs\te_dexec.ini user_UserPanic
+END_TESTCASE DT-dexc-userside-0006
+
+
+START_TESTCASE                DT-dexc-userside-0007
+//! @SYMTestCaseID              DT-dexc-userside-0007
+//! @SYMTestCaseDesc            dexc with User Exception
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app with user exception and verify the dexc file is generated and that the crashed process has been correctly dealt with as per config
+//! @SYMTestExpectedResults     Should find expected dexc files and correct process list
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite DEXECUserSideStep  \testdata\configs\te_dexec.ini user_UserException
+END_TESTCASE DT-dexc-userside-0007
+
+
+START_TESTCASE                DT-dexc-userside-0008
+//! @SYMTestCaseID              DT-dexc-userside-0008
+//! @SYMTestCaseDesc            dexc with stack overflow
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the board with stack overflow and verify the dexc file is generated and that the crashed process has been correctly dealt with as per config
+//! @SYMTestExpectedResults     Should find expected dexc files and correct process list
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite DEXECUserSideStep  \testdata\configs\te_dexec.ini user_StackOverflow
+END_TESTCASE DT-dexc-userside-0008
+
+
+START_TESTCASE                DT-dexc-userside-0009
+//! @SYMTestCaseID              DT-dexc-userside-0009
+//! @SYMTestCaseDesc            dexc with User Leave
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app with user leave and verify the dexc file is generated and that the crashed process has been correctly dealt with as per config
+//! @SYMTestExpectedResults     Should find expected dexc files and correct process list
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite DEXECUserSideStep  \testdata\configs\te_dexec.ini user_UserLeave
+END_TESTCASE DT-dexc-userside-0009
+
+
+START_TESTCASE                DT-dexc-userside-0010
+//! @SYMTestCaseID              DT-dexc-userside-0010
+//! @SYMTestCaseDesc            dexc with Thread Panic
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app with thread panic and verify the dexc file is generated and that the crashed process has been correctly dealt with as per config
+//! @SYMTestExpectedResults     Should find expected dexc files and correct process list
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite DEXECUserSideStep  \testdata\configs\te_dexec.ini user_ThreadPanic
+END_TESTCASE DT-dexc-userside-0010
+
+
+START_TESTCASE                DT-dexc-userside-0011
+//! @SYMTestCaseID              DT-dexc-userside-0011
+//! @SYMTestCaseDesc            dexc with Division By Zero
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app with division by zero and verify the dexc file is generated and that the crashed process has been correctly dealt with as per config
+//! @SYMTestExpectedResults     Should find expected dexc files and correct process list
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite DEXECUserSideStep  \testdata\configs\te_dexec.ini user_DivByZero
+END_TESTCASE DT-dexc-userside-0011
+PRINT Completed te_coredumpserver.DEXC
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_lists.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,39 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								te_lists.script
+//
+
+//! @SYMTestSuiteName               	DT-coredumpserver-lists
+//! @SYMScriptTestEnvironment       	TEF
+
+PRINT Running te_coredumpserver.Lists
+
+LOAD_SERVER te_coredumpserverSuite
+
+START_TESTCASE                DT-coredumpserver-lists-0001
+//! @SYMTestCaseID              DT-coredumpserver-lists-0001
+//! @SYMTestCaseDesc            Tests we can get required lists from CDS
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Test we can get expected thread, process, plugin and executable lists from CDS
+//! @SYMTestExpectedResults     Lists as expected.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite ListsStep
+END_TESTCASE DT-coredumpserver-lists-0001
+
+PRINT Completed te_coredumpserver.Lists
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_parameters.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,39 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								te_parameters.script
+//
+
+//! @SYMTestSuiteName               	DT-coredumpserver-params
+//! @SYMScriptTestEnvironment       	TEF
+
+PRINT Running te_coredumpserver.Parameters
+
+LOAD_SERVER te_coredumpserverSuite
+
+START_TESTCASE                DT-coredumpserver-params-0001
+//! @SYMTestCaseID              DT-coredumpserver-params-0001
+//! @SYMTestCaseDesc            Tests that the Core Dump Server Post Processing and Pre Processing values do what they should.
+//! @SYMTestPriority            High
+//! @SYMTestActions             Test varying combinations of pre and post processing values.
+//! @SYMTestExpectedResults     Expected
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 400 te_coredumpserverSuite ParametersStep
+END_TESTCASE DT-coredumpserver-params-0001
+
+PRINT Completed te_coredumpserver.Parameters
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_self.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,180 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								te_self.script
+//
+
+//! @SYMTestSuiteName               	DT-self-userside
+//! @SYMScriptTestEnvironment       	TEF
+
+PRINT Running te_coredumpserver.SELF
+
+LOAD_SERVER te_coredumpserverSuite
+
+
+
+START_TESTCASE                DT-self-userside-0001
+//! @SYMTestCaseID              DT-self-userside-0001
+//! @SYMTestCaseDesc            SELF plugins
+//! @SYMTestPriority            High
+//! @SYMTestActions             Test we can load/unload one and multiple plugins. Loaded plugins should be visible via CDS API.
+//! @SYMTestExpectedResults     Should Load and Unload as expected.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFPluginStep
+END_TESTCASE DT-self-userside-0001
+
+
+START_TESTCASE                DT-self-userside-0002
+//! @SYMTestCaseID              DT-self-userside-0002
+//! @SYMTestCaseDesc            self with prefetch abort
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app using specified crash reason and check that the SELF file is generated and the process list afterwards is as expected.
+//! @SYMTestExpectedResults     SELF file generated and expected post proc suceeded.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideStep  \testdata\configs\te_self.ini user_PrefetchAbort
+END_TESTCASE DT-self-userside-0002
+
+
+START_TESTCASE                DT-self-userside-0011
+//! @SYMTestCaseID              DT-self-userside-0011
+//! @SYMTestCaseDesc            self with data read
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app using specified crash reason and check that the SELF file is generated and the process list afterwards is as expected.
+//! @SYMTestExpectedResults     SELF file generated and expected post proc suceeded.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideStep  \testdata\configs\te_self.ini user_DataRead
+END_TESTCASE DT-self-userside-0011
+
+
+START_TESTCASE                DT-self-userside-0003
+//! @SYMTestCaseID              DT-self-userside-0003
+//! @SYMTestCaseDesc            self with data write
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app using specified crash reason and check that the SELF file is generated and the process list afterwards is as expected.
+//! @SYMTestExpectedResults     SELF file generated and expected post proc suceeded.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideStep  \testdata\configs\te_self.ini user_DataWrite
+END_TESTCASE DT-self-userside-0003
+
+
+START_TESTCASE                DT-self-userside-0004
+//! @SYMTestCaseID              DT-self-userside-0004
+//! @SYMTestCaseDesc            self with undefined instruction
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app using specified crash reason and check that the SELF file is generated and the process list afterwards is as expected.
+//! @SYMTestExpectedResults     SELF file generated and expected post proc suceeded.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideStep  \testdata\configs\te_self.ini user_UndefInstr
+END_TESTCASE DT-self-userside-0004
+
+
+START_TESTCASE                DT-self-userside-0005
+//! @SYMTestCaseID              DT-self-userside-0005
+//! @SYMTestCaseDesc            self with user panic
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app using specified crash reason and check that the SELF file is generated and the process list afterwards is as expected.
+//! @SYMTestExpectedResults     SELF file generated and expected post proc suceeded.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideStep  \testdata\configs\te_self.ini user_UserPanic
+END_TESTCASE DT-self-userside-0005
+
+
+START_TESTCASE                DT-self-userside-0006
+//! @SYMTestCaseID              DT-self-userside-0006
+//! @SYMTestCaseDesc            self with user exception
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app using specified crash reason and check that the SELF file is generated and the process list afterwards is as expected.
+//! @SYMTestExpectedResults     SELF file generated and expected post proc suceeded.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideStep  \testdata\configs\te_self.ini user_UserException
+END_TESTCASE DT-self-userside-0006
+
+
+START_TESTCASE                DT-self-userside-0007
+//! @SYMTestCaseID              DT-self-userside-0007
+//! @SYMTestCaseDesc            self with stack overflow
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app using specified crash reason and check that the SELF file is generated and the process list afterwards is as expected.
+//! @SYMTestExpectedResults     SELF file generated and expected post proc suceeded.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideStep  \testdata\configs\te_self.ini user_StackOverflow
+END_TESTCASE DT-self-userside-0007
+
+
+START_TESTCASE                DT-self-userside-0010
+//! @SYMTestCaseID              DT-self-userside-0010
+//! @SYMTestCaseDesc            self with user leave
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app using specified crash reason and check that the SELF file is generated and the process list afterwards is as expected.
+//! @SYMTestExpectedResults     SELF file generated and expected post proc suceeded.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideStep  \testdata\configs\te_self.ini user_UserLeave
+END_TESTCASE DT-self-userside-0010
+
+
+START_TESTCASE                DT-self-userside-0008
+//! @SYMTestCaseID              DT-self-userside-0008
+//! @SYMTestCaseDesc            self with thread panic
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app using specified crash reason and check that the SELF file is generated and the process list afterwards is as expected.
+//! @SYMTestExpectedResults     SELF file generated and expected post proc suceeded.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideStep  \testdata\configs\te_self.ini user_ThreadPanic
+END_TESTCASE DT-self-userside-0008
+
+
+START_TESTCASE                DT-self-userside-0009
+//! @SYMTestCaseID              DT-self-userside-0009
+//! @SYMTestCaseDesc            self with division by zero
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash the app using specified crash reason and check that the SELF file is generated and the process list afterwards is as expected.
+//! @SYMTestExpectedResults     SELF file generated and expected post proc suceeded.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideStep  \testdata\configs\te_self.ini user_DivByZero
+END_TESTCASE DT-self-userside-0009
+PRINT Completed te_coredumpserver.SELF
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_self_trace.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,56 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+//! @File								te_self_trace.script
+//! @SYMTestSuiteName               	DT-self-userside
+//! @SYMScriptTestEnvironment       	TEF
+
+PRINT Running te_coredumpserver.SELFTrace
+
+LOAD_SERVER te_coredumpserverSuite
+
+
+
+START_TESTCASE                DT-self-userside-0012
+//! @SYMTestCaseID              DT-self-userside-0012
+//! @SYMTestCaseDesc            Test SELF Configuration to hold trace data with a user side crash.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Configure the CDS to generate a core dump for our test crash application. Load the SELF formatter plugin and an arbitrary writer. Configure the SELF formatter to hold trace data. Generate a user side crash using our test crash application. Observe trace data in generated crash dump.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideTrace  \testdata\configs\te_self_trace.ini user_Trace
+END_TESTCASE DT-self-userside-0012
+
+
+START_TESTCASE                DT-self-userside-0013
+//! @SYMTestCaseID              DT-self-userside-0013
+//! @SYMTestCaseDesc            Test SELF Configuration to not hold trace data with a user side crash.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Configure the CDS to generate a core dump for our test crash application. Load the SELF formatter plugin and an arbitrary writer. Configure the SELF formatter to not hold trace data. Generate a user side crash with trace using our test crash application. Ensure there is no trace data in generated crash dump.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+RUN_TEST_STEP 100 te_coredumpserverSuite SELFUserSideTrace \testdata\configs\te_self_trace.ini user_WithoutTrace
+END_TESTCASE DT-self-userside-0013
+PRINT Completed te_coredumpserver.SELFTrace
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_signaling.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								te_signaling.script
+//
+
+//! @SYMTestSuiteName               	DT-self-signaling
+//! @SYMScriptTestEnvironment       	TEF
+
+PRINT Running te_signaling.SELF
+
+LOAD_SERVER te_coredumpserverSuite
+
+START_TESTCASE                DT-coredumpserver-signaling-0001
+//! @SYMTestCaseID              DT-coredumpserver-signaling-0001
+//! @SYMTestCaseDesc            Test Signling Mechanism using RProperty
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Read RProperty buffers and test signaling mechanism 
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            08/10/2009
+//! @SYMAuthor                  sakhyaghosh
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ2596
+RUN_TEST_STEP 1000 te_coredumpserverSuite TestSignaling \testdata\configs\te_signaling.ini 
+END_TESTCASE DT-coredumpserver-signaling-0001
+
+PRINT Completed te_signaling.SELF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_testformatter.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+//! @File								te_testformatter.script
+//! @SYMTestSuiteName               	Core Dump Application Crash
+//! @SYMScriptTestEnvironment       	TEF
+
+PRINT Running te_coredumpserver.TestFormatterUserSide
+
+LOAD_SERVER te_coredumpserverSuite
+
+RUN_TEST_STEP 100 te_coredumpserverSuite TestFormatterUserSideStep
+
+PRINT Completed te_coredumpserver.TestFormatterUserSide
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_token.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,39 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								te_token.script
+//
+
+//! @SYMTestSuiteName               	DT-coredumpserver-token
+//! @SYMScriptTestEnvironment       	TEF
+
+PRINT Running te_coredumpserver.Tokens
+
+LOAD_SERVER te_coredumpserverSuite
+
+START_TESTCASE                DT-coredumpserver-token-0001
+//! @SYMTestCaseID              DT-coredumpserver-token-0001
+//! @SYMTestCaseDesc            Test security is enforced by debug token.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Attach to something not marked debuggable with a token. Then attach to it without a token. Then attach to something marked as debuggable without a token.
+//! @SYMTestExpectedResults     attach to things marked as debuggable.
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+RUN_TEST_STEP 100 te_coredumpserverSuite TokenStep
+END_TESTCASE DT-coredumpserver-token-0001
+
+PRINT Completed te_coredumpserver.Tokens
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/scripts/te_utrace.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,71 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								te_utrace.script
+//
+
+//! @SYMTestSuiteName               	DT-formatters-utrace
+//! @SYMScriptTestEnvironment       	TEF
+
+PRINT Running te_coredumpserver.UTraceUserSide
+
+LOAD_SERVER te_coredumpserverSuite
+
+
+
+START_TESTCASE                DT-formatters-utrace-0001
+//! @SYMTestCaseID              DT-formatters-utrace-0001
+//! @SYMTestCaseDesc            UTRACE formatter should produce raw trace buffer data.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             UTRACE formatter should produce raw trace buffer data.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+RUN_TEST_STEP 100 te_coredumpserverSuite UTraceUserSide
+END_TESTCASE DT-formatters-utrace-0001
+
+
+START_TESTCASE                DT-formatters-utrace-0002
+//! @SYMTestCaseID              DT-formatters-utrace-0002
+//! @SYMTestCaseDesc            UTrace plugin should load successfully.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             UTrace plugin should load successfully.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+RUN_TEST_STEP 100 te_coredumpserverSuite UTraceUserSide
+END_TESTCASE DT-formatters-utrace-0002
+
+
+START_TESTCASE                DT-formatters-utrace-0003
+//! @SYMTestCaseID              DT-formatters-utrace-0003
+//! @SYMTestCaseDesc            UTrace plugin should unload successfully.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             UTrace plugin should unload successfully.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+RUN_TEST_STEP 100 te_coredumpserverSuite UTraceUserSide
+END_TESTCASE DT-formatters-utrace-0003
+PRINT Completed te_coredumpserver.UTraceUserSide
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/CDSconnectionstep.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,176 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example CTestStep derived implementation
+//
+
+
+
+/**
+ @file DEXECPlugin.cpp
+ @internalTechnology
+*/
+#include "SELFPluginStep.h"
+#include "tcoredumpserversuitedefs.h"
+#include "CDSconnectionstep.h"
+
+CCDSConnectionsStep::~CCDSConnectionsStep()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CCDSConnectionsStep::CCDSConnectionsStep()
+/**
+ * Constructor
+ */
+	{
+	// **MUST** call SetTestStepName in the constructor as the controlling
+	// framework uses the test step name immediately following construction to set
+	// up the step's unique logging ID.
+	SetTestStepName(KCDSConnectionsStep);
+	}
+
+TVerdict CCDSConnectionsStep::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	return TestStepResult();
+	}
+
+TVerdict CCDSConnectionsStep::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+	{
+	if (TestStepResult()==EPass)
+		{	
+		TInt ret = KErrNone;
+
+		__UHEAP_MARK;
+
+		TRAP(ret, ClientAppL());
+		if(KErrNone != ret)
+			{
+			SetTestStepResult(EFail);
+			ERR_PRINTF2(_L("Error %d from CCDSConnectionsStep->ClientAppL()"), ret);
+			}
+		
+		__UHEAP_MARKEND;
+
+		}
+	return TestStepResult();  
+	}
+
+void CCDSConnectionsStep::ClientAppL()
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+	{
+	INFO_PRINTF1(_L("Starting CSDConnections Plugin Test Suite") );
+	TestConnectionsL();
+	}
+
+void CCDSConnectionsStep::TestConnectionsL()
+	{
+	
+	if (TestStepResult()==EPass)
+		{
+		RCoreDumpSession cdsSess;
+		
+		//Try connecting
+		TInt ret = KErrNone;
+		ret = cdsSess.Connect(); 
+		CleanupClosePushL(cdsSess);
+		
+		if(ret != KErrNone)
+			{
+			SetTestStepResult( EFail );
+			ERR_PRINTF2(_L("Error %d from cdsSess->Connect()"), ret);
+			return;
+			}
+		INFO_PRINTF1(_L("Connected successfully"));
+		
+		//close the connection
+		cdsSess.Disconnect();
+		INFO_PRINTF1(_L("Disconnected successfully"));
+		
+		//Try opening another one straight away and using it...
+		ret = cdsSess.Connect();
+		if(ret != KErrNone)
+			{
+			SetTestStepResult( EFail );
+			ERR_PRINTF2(_L("Error %d from cdsSess->Connect() the second time (following a connection just being closed)"), ret);
+			return;
+			}
+		INFO_PRINTF1(_L("Connected successfully"));
+
+        //now try to attach/detach
+	    INFO_PRINTF1(_L("Attach to crashapp.exe") );
+        TRAPD(err, cdsSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue) );
+        if(err != KErrNone)
+            {
+            INFO_PRINTF2(_L("attach iSess.ObservationRequestL(z:\\sys\\bin\\crashapp.exe) failed:%d\n"), err);
+            SetTestStepResult(EFail);
+            User::Leave( err );
+            }
+
+	    INFO_PRINTF1(_L("Detach from crashapp.exe") );
+        TRAP(err, cdsSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, EFalse) );
+        if(err != KErrNone)
+            {
+            INFO_PRINTF2(_L("detach iSess.ObservationRequestL(z:\\sys\\bin\\crashapp.exe) failed:%d\n"), err);
+            SetTestStepResult(EFail);
+            User::Leave( err );
+            }
+
+	    INFO_PRINTF1(_L("Attach to crashappoem.exe") );
+        TRAPD(oem, cdsSess.ObservationRequestL( KCrashAppFileNameNonDebugBit, KCrashAppFileNameNonDebugBit, ETrue) );
+        if(oem != KErrPermissionDenied)
+            {
+            INFO_PRINTF2(_L("attach iSess.ObservationRequestL(z:\\sys\\bin\\crashappoem.exe) failed:%d\n"), oem);
+            SetTestStepResult(EFail);
+            User::Leave( oem );
+            }
+
+	    INFO_PRINTF1(_L("Detach from crashappoem.exe") );
+        TRAP(oem, cdsSess.ObservationRequestL( KCrashAppFileNameNonDebugBit, KCrashAppFileNameNonDebugBit, EFalse) );
+        if(oem != KErrNotFound)
+            {
+            INFO_PRINTF2(_L("detach iSess.ObservationRequestL(z:\\sys\\bin\\crashappoem.exe) failed:%d\n"), oem);
+            SetTestStepResult(EFail);
+            User::Leave( oem );
+            }
+		
+		CleanupStack::PopAndDestroy(&cdsSess);
+        }
+	}
+
+TVerdict CCDSConnectionsStep::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{	
+	return EPass;	
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/CDStokenstep.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,169 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// CTestStep derived implementation
+//
+
+
+
+/**
+ @file tokenstep.cpp
+ @internalTechnology
+*/
+#include "CDStokenstep.h"
+#include "tcoredumpserversuitedefs.h"
+#include "tcoredumpserversuiteserver.h"
+
+CTokenStep::~CTokenStep()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CTokenStep::CTokenStep()
+/**
+ * Constructor
+ */
+	{
+	// **MUST** call SetTestStepName in the constructor as the controlling
+	// framework uses the test step name immediately following construction to set
+	// up the step's unique logging ID.
+	SetTestStepName(KTokenStep);
+	}
+
+TVerdict CTokenStep::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	   
+	TInt ret = KErrNone;
+	ret = iSess.Connect(); 
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		ERR_PRINTF2(_L("Error %d from iSess->Connect()"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+
+	return TestStepResult();
+	}
+
+
+TVerdict CTokenStep::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+	{
+	  
+	if (TestStepResult()==EPass)
+		{	
+		TInt ret = KErrNone;
+
+		__UHEAP_MARK;
+
+		TRAP(ret, ClientAppL());
+		if(KErrNone != ret)
+			{
+			SetTestStepResult(EFail);
+			ERR_PRINTF2(_L("Error %d from CTokenStep->ClientAppL()"), ret);
+			}
+		
+		__UHEAP_MARKEND;
+
+		}
+	return TestStepResult();  
+
+	}
+
+
+
+TVerdict CTokenStep::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	
+	iSess.Disconnect();
+	return EPass;	
+	}
+
+
+void CTokenStep::ClientAppL()
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+	{
+	INFO_PRINTF1(_L("Starting Lists Test Suite") );
+    CheckAttachL();
+	}
+
+
+void CTokenStep::CheckAttachL()
+/**
+ * @return void
+ * This tests we can succesfully list the processes and that the returned values make sense
+ */
+	{
+	INFO_PRINTF1(_L("Token Test Suite: Attach") );
+
+	if (TestStepResult()==EPass)
+		{
+
+	    INFO_PRINTF1(_L("Attach to crashapp.exe") );
+        TRAPD(err, iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue) );
+        if(err != KErrNone)
+            {
+            INFO_PRINTF2(_L("attach iSess.ObservationRequestL(z:\\sys\\bin\\crashapp.exe) failed:%d\n"), err);
+            SetTestStepResult(EFail);
+            User::Leave( err );
+            }
+
+	    INFO_PRINTF1(_L("Detach from crashapp.exe") );
+        TRAP(err, iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, EFalse) );
+        if(err != KErrNone)
+            {
+            INFO_PRINTF2(_L("detach iSess.ObservationRequestL(z:\\sys\\bin\\crashapp.exe) failed:%d\n"), err);
+            SetTestStepResult(EFail);
+            User::Leave( err );
+            }
+
+	    INFO_PRINTF1(_L("Attach to crashappoem.exe") );
+        TRAPD(oem, iSess.ObservationRequestL( KCrashAppFileNameNonDebugBit, KCrashAppFileNameNonDebugBit, ETrue) );
+        if(oem != KErrNone)
+            {
+            INFO_PRINTF2(_L("attach iSess.ObservationRequestL(z:\\sys\\bin\\crashappoem.exe) failed:%d\n"), oem);
+            SetTestStepResult(EFail);
+            User::Leave( oem );
+            }
+
+	    INFO_PRINTF1(_L("Detach from crashappoem.exe") );
+        TRAP(oem, iSess.ObservationRequestL( KCrashAppFileNameNonDebugBit, KCrashAppFileNameNonDebugBit, EFalse) );
+        if(oem != KErrNone)
+            {
+            INFO_PRINTF2(_L("detach iSess.ObservationRequestL(z:\\sys\\bin\\crashappoem.exe) failed:%d\n"), oem);
+            SetTestStepResult(EFail);
+            User::Leave( oem );
+            }
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/DEXCpluginstep.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,387 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example CTestStep derived implementation
+//
+
+
+
+/**
+ @file DEXECPlugin.cpp
+ @internalTechnology
+*/
+#include "SELFPluginStep.h"
+#include "tcoredumpserversuitedefs.h"
+#include "DEXCpluginstep.h"
+
+CDEXECPluginStep::~CDEXECPluginStep()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CDEXECPluginStep::CDEXECPluginStep()
+/**
+ * Constructor
+ */
+	{
+	// **MUST** call SetTestStepName in the constructor as the controlling
+	// framework uses the test step name immediately following construction to set
+	// up the step's unique logging ID.
+	SetTestStepName(KSELFPluginStep);
+	}
+
+TVerdict CDEXECPluginStep::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	   
+	TInt ret = KErrNone;
+	ret = iSess.Connect(); 
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		INFO_PRINTF2(_L("Error %d from iSess->Connect()/n"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+
+	return TestStepResult();
+	}
+
+TVerdict CDEXECPluginStep::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+	{
+	if (TestStepResult()==EPass)
+		{	
+		TInt ret = KErrNone;
+
+		__UHEAP_MARK;
+
+		TRAP(ret, ClientAppL());
+		if(KErrNone != ret)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Error %d from CDEXECPluginStep->ClientAppL()"), ret);
+			}
+		
+		__UHEAP_MARKEND;
+
+		}
+	return TestStepResult();  
+	}
+
+void CDEXECPluginStep::ClientAppL()
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+	{
+	INFO_PRINTF1(_L("Starting DEXEC Plugin Test Suite") );
+
+    LoadPluginL();
+    UnloadPluginL();
+    for(TInt i = 1; i < DexcMultipleTries; i++)
+        {
+        LoadMultiplePluginsL(i);
+        UnloadMultiplePluginsL(i);
+        }
+	}
+
+void CDEXECPluginStep::LoadPluginL()
+/**
+ * @return void
+ * Tests that the plugin can be loaded correctly
+ */
+	{		
+	if (TestStepResult()==EPass)
+		{
+			
+		INFO_PRINTF1(_L("Attempting to load DEXEC Plugin"));
+		
+		TPluginRequest req;
+		req.iPluginType = TPluginRequest::EFormatter;
+		req.iLoad = ETrue;
+		req.iUid = DEXEC_UID;
+
+		// Should be allowed to load DEXEC
+		TRAPD(ret, iSess.PluginRequestL( req ));
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed loading plugin with UID 0x%X  -- DEXEC Plugin/n"), req.iUid );
+			User::Leave(ret);
+			}
+
+		RPluginList plugins;
+		CleanupClosePushL(plugins);
+       	TRAP(ret, iSess.GetPluginListL(plugins));
+		TInt dexecCounter = 0;
+		for (TInt i = 0; i < plugins.Count(); i++)
+			{
+			if (plugins[i].iUid ==  DEXEC_UID && plugins[i].iLoaded)
+				{
+                dexecCounter++;
+				break;
+				}
+			}
+        CleanupStack::PopAndDestroy();
+		
+        if(dexecCounter != 1)
+        {
+	        SetTestStepResult(EFail);
+			INFO_PRINTF1(_L("Fail - DEXEC plugin has been not marked as loaded"));
+            return;
+        }
+
+		INFO_PRINTF1(_L("DEXEC Plugin loaded successfully"));
+		}	
+	}
+
+void CDEXECPluginStep::UnloadPluginL()
+/**
+ * @return void
+ * Tests the plugin can be successfully unloaded
+ */
+	{
+	if(TestStepResult()==EPass)
+		{
+		INFO_PRINTF1(_L("Attempting to unload DEXEC Plugin"));
+		
+		TPluginRequest req;
+		req.iPluginType = TPluginRequest::EFormatter;
+		req.iLoad = EFalse;
+		req.iUid = DEXEC_UID;
+		
+		TRAPD(ret, iSess.PluginRequestL( req ));
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed unloading plugin with UID 0x%X  -- DEXEC Plugin"), req.iUid );
+			User::Leave(ret);
+			}
+
+		RPluginList plugins;
+		TRAP(ret, iSess.GetPluginListL(plugins));
+		if (ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed to get plugin list -- DEXEC Plugin. Error: %d"), ret);
+			User::Leave(ret);
+			}
+		
+		TInt dexecCounter = 0;
+		for (TInt i = 0; i < plugins.Count(); i++)
+			{
+			if (plugins[i].iUid ==  DEXEC_UID && plugins[i].iLoaded)
+				{
+                dexecCounter++;
+				break;
+				}
+			}
+        plugins.Close();
+		
+        if(dexecCounter != 0)
+        {
+	        SetTestStepResult(EFail);
+			INFO_PRINTF1(_L("Fail - DEXEC plugin has been not marked as unloaded"));
+            return;
+        }
+
+		INFO_PRINTF1(_L("DEXEC Plugin unloaded successfully"));
+		}		
+	}
+
+void CDEXECPluginStep::UnloadPluginL(const TInt aIndex)
+/**
+ * @return void
+ * Tests the plugin can be successfully unloaded
+ */
+	{
+	if(TestStepResult()==EPass)
+		{
+		INFO_PRINTF1(_L("Attempting to unload DEXEC Plugin"));
+		
+		TPluginRequest req;
+		req.iPluginType = TPluginRequest::EFormatter;
+		req.iLoad = EFalse;
+		req.iUid = DEXEC_UID;
+        req.iIndex = aIndex;
+        req.iPair = aIndex;
+		
+		TRAPD(ret, iSess.PluginRequestL( req ));
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed unloading plugin with UID 0x%X  -- DEXEC Plugin"), req.iUid );
+			User::Leave(ret);
+			}
+		
+		INFO_PRINTF1(_L("DEXEC Plugin unloaded successfully"));
+		}		
+	}
+
+void CDEXECPluginStep::LoadMultiplePluginsL(const TInt aCount)
+/**
+ * @return void
+ * This tests behaviour when we attempt to load an already loaded DEXEC plugin.
+ * Should only be loaded once, even after calling twice
+ */
+	{
+	if (TestStepResult()==EPass)
+		{	
+		INFO_PRINTF2(_L("Testing loading the DEXEC plugin multiple times  - %d"), aCount);
+        for(TInt i = 0; i < aCount; i++)
+            {
+		    LoadPluginL();	
+            }
+		
+		//Now we need to look in the plugin list and make sure the DEXEC plugin isnt there multiple times
+		RPluginList plugins;
+		CleanupClosePushL(plugins);
+		
+		TRAPD(ret, iSess.GetPluginListL(plugins));
+		if (ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed to get plugin list -- DEXEC Plugin. Error: %d"), ret);
+			User::Leave(ret);
+			}
+		
+		TInt dexecCounter = 0;
+		for (TInt i = 0; i < plugins.Count(); i++)
+			{
+			if (plugins[i].iUid ==  DEXEC_UID && plugins[i].iLoaded)
+				{
+                dexecCounter++;
+				break;
+				}
+			}
+		
+        if(dexecCounter == 0)
+        {
+	        SetTestStepResult(EFail);
+			INFO_PRINTF1(_L("Fail - DEXEC plugin has been not marked as loaded"));
+        }
+
+        RPluginPointerList formatterList;
+        TRAP(ret, iSess.GetFormattersL(formatterList));
+        dexecCounter = 0;
+        for(TInt i = 0; i < formatterList.Count(); i++)
+        {
+            if(TUid::Uid(formatterList[i]->Uid()) == DEXEC_UID)
+            {
+            dexecCounter++;
+            }
+        }
+        formatterList.ResetAndDestroy();
+
+		if(dexecCounter != aCount)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Fail - DEXEC plugin has not been found loaded %d times"), aCount);
+			}
+		else
+			{
+			INFO_PRINTF1(_L("Loading plugin multiple times is ok"));
+			}
+		
+		CleanupStack::PopAndDestroy();
+		}	
+	}
+
+void CDEXECPluginStep::UnloadMultiplePluginsL(const TInt aCount)
+/**
+ * @return void
+ * This tests behaviour when we attempt to unload the SELF plugin when it has
+ * not been loaded
+ */
+	{
+	if (TestStepResult()==EPass)
+		{
+		INFO_PRINTF2(_L("Testing unloading the DEXEC plugin multiple times - %d"), aCount);
+        for(TInt i = aCount; i > 0; i--)
+            {
+		    UnloadPluginL(i - 1);	
+            }
+		
+		//Now we need to look in the plugin list and make sure the SELF plugin isnt there
+		RPluginList plugins;
+		CleanupClosePushL(plugins);
+		
+		TRAPD(ret, iSess.GetPluginListL(plugins));
+		if (ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed to get plugin list -- DEXEC Plugin. Error: %d"), ret);
+			User::Leave(ret);
+			}
+		
+		TInt dexecCounter = aCount;
+		for (TInt i = 0; i < plugins.Count(); i++)
+			{
+			if (plugins[i].iUid ==  DEXEC_UID && plugins[i].iLoaded)
+				{
+                dexecCounter = 0;
+				break;
+				}
+			}
+	
+        if(dexecCounter == 0)
+        {
+			SetTestStepResult(EFail);
+			INFO_PRINTF1(_L("Fail - DEXEC plugin has been found marked as loaded"));
+        }
+
+        RPluginPointerList formatterList;
+        TRAP(ret, iSess.GetFormattersL(formatterList));
+        dexecCounter = 0;
+        for(TInt i = 0; i < formatterList.Count(); i++)
+        {
+            if(TUid::Uid(formatterList[i]->Uid()) == DEXEC_UID)
+            {
+            dexecCounter++;
+            }
+        }
+        formatterList.ResetAndDestroy();
+
+		if(dexecCounter > 0)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Fail - DEXEC %d plugins has been found loaded"), dexecCounter);
+			}
+		else
+			{
+			INFO_PRINTF1(_L("Unloading plugin multiple times is ok"));
+			}
+		
+		CleanupStack::PopAndDestroy();
+		}
+	}
+
+TVerdict CDEXECPluginStep::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	iSess.Disconnect();
+	return EPass;	
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/DEXCusersidestep.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,553 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example CTestStep derived implementation
+//
+
+
+
+/**
+ @file DEXECStep.cpp
+ @internalTechnology
+*/
+#include "DEXCusersidestep.h"
+#include "tcoredumpserversuitedefs.h"
+#include "tcoredumpserversuiteserver.h"
+#include <e32property.h>
+#include <crashdatasave.h>
+#include <e32std.h>
+#include <coredumpserverapi.h>
+
+CDEXECUserSideStep::~CDEXECUserSideStep()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CDEXECUserSideStep::CDEXECUserSideStep()
+/**
+ * Constructor
+ */
+	{
+	// **MUST** call SetTestStepName in the constructor as the controlling
+	// framework uses the test step name immediately following construction to set
+	// up the step's unique logging ID.
+	SetTestStepName(KDEXECUserSideStep);
+	}
+
+TVerdict CDEXECUserSideStep::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	   
+	TInt ret = KErrNone;
+	ret = iSess.Connect(); 
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		INFO_PRINTF2(_L("Error %d from iSess->Connect()/n"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+	
+	ret = iFs.Connect();
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		INFO_PRINTF2(_L("Error %d from iFs->Connect()/n"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+
+	return TestStepResult();
+	}
+
+
+TVerdict CDEXECUserSideStep::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+	{
+
+	if (TestStepResult()==EPass)
+		{	
+		TInt ret = KErrNone;
+
+		__UHEAP_MARK;		
+		
+		TRAP(ret, ClientAppL());
+		if(KErrNone != ret)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Error %d from CDEXECStep->ClientAppL()"), ret);
+			}		
+
+		__UHEAP_MARKEND;
+
+		}
+	return TestStepResult(); 
+	}
+
+void CDEXECUserSideStep::ClientAppL()
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+	{
+	INFO_PRINTF1(_L("Starting DEXEC Test Suite") );
+	HandleCrashL();
+    CheckParametersL();
+	}
+
+void CDEXECUserSideStep::HandleCrashL()
+/**
+ * @return void
+ * Tests handling a crash
+ */
+	{
+
+	if(TestStepResult()==EPass)
+		{
+		TPtrC crashAppParam;
+		TPtrC crashFileName;
+		TPtrC writerToUse;
+		
+		if(!GetStringFromConfig(ConfigSection(), KTe_CrashAppParam, crashAppParam) ||
+		   !GetStringFromConfig(ConfigSection(), KTe_CrashFileName, crashFileName) ||
+		   !GetStringFromConfig(ConfigSection(), KWriterToUse, writerToUse))
+			{
+			INFO_PRINTF1(_L("Failed to get data from ini file"));
+			SetTestStepResult(EFail);
+			User::Leave(KErrGeneral);
+			}
+		
+		INFO_PRINTF4(_L("The CrashApp Param is %S, The Filename is is %S, The writer is %S"), &crashAppParam, &crashFileName,&writerToUse); // Block end
+				
+		//Convert writer config to hex
+		TLex luther(writerToUse);
+		TUint32 writer;
+		luther.Val(writer, EHex);
+		
+		//Start the process that we intend to crash....
+		RProcess crashProcess;
+		CleanupClosePushL(crashProcess);
+		
+		TInt ret = crashProcess.Create( KCrashAppFileName, crashAppParam);
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Error %d from RProcess .Create(z:\\sys\\bin\\crashapp.exe)/n"), ret);
+			SetTestStepResult(EFail);
+			User::Leave(ret);
+			}
+		
+		INFO_PRINTF1(_L("Started userside crash app"));
+		
+		//Load DEXEC Formatter
+		LoadDEXECFormatterL();
+		
+		TPluginRequest req;
+		TUid writerUid = TUid::Uid(writer);
+		req.iUid = writerUid;
+		req.iPluginType = TPluginRequest::EWriter;
+		req.iLoad = ETrue;
+		
+		TRAP(ret, iSess.PluginRequestL( req ));
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed to load writer plugin, error = %d"), ret);
+			SetTestStepResult(EFail);
+			User::Leave(ret);
+			}
+		
+		INFO_PRINTF1(_L("Loaded writer plugin successfully"));
+		
+		//Now we configure CDS and writer		
+		_LIT( KFilePathPrompt, "not_important" );
+		
+		DoConfigureL(CCrashDataSave::ECoreFilePath, writerUid.iUid, COptionConfig::EWriterPlugin, COptionConfig::ETFileName,
+ 				     KFilePathPrompt, 1, KNullDesC, 0, crashFileName, 0);		
+		
+		// Observe the process and wait for a crash
+		TRAP(ret, iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue) );
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Error %d iSess.ObservationRequestL(z:\\sys\\bin\\crashapp.exe)\n"), ret);
+			SetTestStepResult(EFail);
+			User::Leave( ret );
+			}
+		
+		//start the crash process
+		crashProcess.Resume();
+		CleanupStack::PopAndDestroy(&crashProcess); //this is for crashProcess
+	
+		//Monitor the progress of the crash file being generated...
+		MonitorProgressL();
+
+		//Check dump has been generated...and is valid		
+        CDir *fileList = NULL;
+        TFindFile fileFinder(iFs);
+		TRAP(ret, fileList = CTe_coredumpserverSuite::DoesFileExistL(crashFileName, fileFinder));
+
+		if((ret != KErrNone) || (fileList == NULL))
+			{
+			INFO_PRINTF2(_L("Expected crash file was not generated:  %d"), ret);
+			SetTestStepResult(EFail);
+			User::Leave( ret );
+			}
+
+        CleanupStack::PushL(fileList);
+        for(TInt i = 0; i < fileList->Count(); i++)
+            {
+            TParse fullName;
+            fullName.Set((*fileList)[i].iName, &fileFinder.File(), NULL);
+            User::LeaveIfError(iFs.Delete(fullName.FullName()));
+            }
+        CleanupStack::PopAndDestroy(fileList);
+
+		INFO_PRINTF1(_L("Expected crash file was generated successfully"));
+		
+		RProcessPointerList procList;
+		TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupProcessList, (TAny*)&procList);
+		CleanupStack::PushL(cleanupProcesses);
+		
+		iSess.GetProcessesL( procList );			
+		
+		INFO_PRINTF1(_L("Looking through the procList"));
+		for(TInt i=0; i < procList.Count(); i++ )
+			{				
+			if(procList[i]->Name() == KCrashAppFileName)
+				{
+				SetTestStepResult( EFail );
+				INFO_PRINTF1(_L("Crash application was not killed as expected after crash"));
+				User::Leave(KErrGeneral);
+				}
+			}
+		CleanupStack::PopAndDestroy(&procList);
+		}
+	
+	}
+
+void CDEXECUserSideStep::CheckParametersL()
+/**
+ * This checks the DEXEC parameters - are we creating a stack file and text file?
+ */
+	{
+	if(TestStepResult()==EPass)
+		{
+        //Start the process that we intend to crash....
+        RProcess crashProcess;
+        CleanupClosePushL(crashProcess);
+        
+        _LIT(KCrashAppParam, "-c4 -d1");
+        TInt ret = crashProcess.Create( KCrashAppFileName, KCrashAppParam);
+        if(ret != KErrNone)
+            {
+            INFO_PRINTF2(_L("Error %d from RProcess .Create(z:\\sys\\bin\\crashapp.exe)/n"), ret);
+            SetTestStepResult(EFail);
+            User::Leave(ret);
+            }
+
+        LoadDEXECFormatterL();
+        LoadDEXECFormatterL();
+        LoadDEXECFormatterL();
+
+        LoadFileWriterL();
+        LoadFileWriterL();
+        LoadFileWriterL();
+
+        BindPluginsL(3);
+
+        _LIT(KTrue, "True");
+        _LIT(KFalse, "False");
+
+        //no stack file
+        DoConfigureL(0, DEXEC_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC,0, KFalse, 0);
+
+        //binary stack file
+        DoConfigureL(0, DEXEC_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC,0, KTrue, 1);
+
+        DoConfigureL(1, DEXEC_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC,0, KFalse, 1);
+
+        //ascii stack file
+        DoConfigureL(0, DEXEC_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC,0, KTrue, 2);
+
+        DoConfigureL(1, DEXEC_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC,0, KTrue, 2);
+
+        TUid writerUid = TUid::Uid(0x102831E4);//file writer
+        _LIT( KCrashFileName, "C:\\dexec_chkparam");
+        TBuf<63> fileName;
+        for(TInt i = 0; i < 3; i++)
+        {
+            fileName = KCrashFileName;
+            fileName.AppendFormat(_L("%d"), i);
+            DoConfigureL(CCrashDataSave::ECoreFilePath, writerUid.iUid, COptionConfig::EWriterPlugin, COptionConfig::ETFileName,
+                            KNullDesC, 1, KNullDesC, 0, fileName, i);	
+        }
+
+        // Observe the process and wait for a crash
+        TRAP(ret, iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue));
+        if(ret != KErrNone)
+            {
+            ERR_PRINTF2(_L("Error %d iSess.ObservationRequestL(z:\\sys\\bin\\crashapp.exe)\n"), ret);
+            SetTestStepResult(EFail);
+            User::Leave( ret );
+            }
+        
+        //start the crash process
+        crashProcess.Resume();
+        INFO_PRINTF1(_L("Started userside crash app"));
+        CleanupStack::PopAndDestroy(); //this is for crashProcess
+    
+        //Monitor the progress of the crash file being generated...
+        MonitorProgressL();
+
+        //Check dumps have been generated...		
+        CDir *fileList = NULL;
+        TFindFile fileFinder(iFs);
+        TRAP(ret, fileList = CTe_coredumpserverSuite::DoesFileExistL(KCrashFileName, fileFinder));
+        CleanupStack::PushL(fileList);
+        
+        if( (ret != KErrNone) || (fileList == NULL) )
+            {
+            ERR_PRINTF2(_L("Expected crash files were not generated:  %d"), ret);
+            SetTestStepResult(EFail);
+            User::Leave( ret );
+            }
+        
+        TInt txtFiles = 0;
+        TInt stkFiles = 0;
+        for(TInt i = 0; i < fileList->Count(); i++)
+            {
+            TParse fullName;
+            fullName.Set((*fileList)[i].iName, &fileFinder.File(), NULL);
+            if(fullName.Ext() == _L(".txt"))
+                txtFiles++;
+            if(fullName.Ext() == _L(".stk"))
+                stkFiles++;
+            INFO_PRINTF2(_L("%S"), &fullName.FullName());
+            User::LeaveIfError(iFs.Delete(fullName.FullName()));
+            }
+        CleanupStack::PopAndDestroy(fileList);
+
+        if( (txtFiles != 3) || (stkFiles != 2) )
+            {
+            ERR_PRINTF1(_L("Expected crash files were not generated"));
+            SetTestStepResult(EFail);
+            User::Leave(KErrNotFound);
+            }
+
+		RProcessPointerList procList;
+		TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupProcessList, (TAny*)&procList);
+		CleanupStack::PushL(cleanupProcesses);
+		
+		iSess.GetProcessesL( procList );			
+		
+		INFO_PRINTF1(_L("Looking through the procList"));
+		for(TInt i=0; i < procList.Count(); i++ )
+			{				
+			if(procList[i]->Name() == KCrashAppFileName)
+				{
+				SetTestStepResult( EFail );
+				ERR_PRINTF1(_L("Crash application was not killed as expected after crash"));
+				User::Leave(KErrGeneral);
+				}
+			}
+		CleanupStack::PopAndDestroy(&procList);
+		}
+	}
+
+void CDEXECUserSideStep::DoConfigureL(const TUint32& aIndex, 
+ 	     					  const TUint32& aUID, 
+                              const COptionConfig::TParameterSource& aSource, 
+                              const COptionConfig::TOptionType& aType, 
+                              const TDesC& aPrompt, 
+                              const TUint32& aNumOptions,
+                              const TDesC& aOptions,
+                              const TInt32& aVal, 
+                              const TDesC& aStrValue,
+                              const TUint aInstance )
+/**
+* @return void
+* @param aIndex Internal index to the component that owns the object
+* @param aUID UID of the component that owns the object
+* @param aSource Type of component that owns the object
+* @param aType Type of parameter
+* @param aPrompt Prompt to present to user 
+* @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
+* @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
+* @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
+* @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
+*/
+	{
+	COptionConfig * config;	
+	
+	config = COptionConfig::NewL( aIndex,
+		aUID,
+		aSource,
+		aType,
+		aPrompt,
+		aNumOptions,
+		aOptions,
+		aVal,
+		aStrValue);
+	
+	CleanupStack::PushL(config);
+	
+    config->Instance(aInstance);
+
+	//Configure now...
+	TRAPD(ret, iSess.SetConfigParameterL(*config) );
+	if(ret != KErrNone)
+		{
+		INFO_PRINTF2(_L("Error %d changing param/n"), ret );
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+	
+	CleanupStack::PopAndDestroy(config);
+	}
+
+void CDEXECUserSideStep::LoadFileWriterL()
+    {
+    TPluginRequest req;
+    TUid writerUid = TUid::Uid(0x102831E4);//file writer
+    req.iUid = writerUid;
+    req.iPluginType = TPluginRequest::EWriter;
+    req.iLoad = ETrue;
+    
+    TRAPD(ret, iSess.PluginRequestL( req ));
+    if(ret != KErrNone)
+        {
+        ERR_PRINTF2(_L("Failed to load writer plugin, error = %d"), ret);
+        SetTestStepResult(EFail);
+        User::Leave(ret);
+        }
+
+    }
+
+void CDEXECUserSideStep::LoadDEXECFormatterL()
+/**
+ * @return void
+ * Utility function to load the SELF formatter
+ */
+	{
+	
+	INFO_PRINTF1(_L("Attempting to load DEXEC Plugin"));
+	
+	TPluginRequest req;
+	req.iPluginType = TPluginRequest::EFormatter;
+	req.iLoad = ETrue;
+	req.iUid = DEXEC_UID;
+
+    TRAPD(ret, iSess.PluginRequestL( req ));
+    if(ret != KErrNone)
+        {
+        ERR_PRINTF2(_L("Failed to load writer plugin, error = %d"), ret);
+        SetTestStepResult(EFail);
+        User::Leave(ret);
+        }
+	}
+
+void CDEXECUserSideStep::BindPluginsL(const TInt aCount)
+/**
+ * @return void
+ * Utility function to load the SELF formatter
+ */
+	{
+	INFO_PRINTF1(_L("Attempting to bind plugins"));
+	
+	TPluginRequest req;
+	req.iPluginType = TPluginRequest::EFormatter;
+	req.iUid = TUid::Uid(0);
+
+    for(TInt i = 0; i < aCount; i++)
+        {
+        req.iIndex = req.iPair = i;
+        TRAPD(ret, iSess.PluginRequestL( req ));
+
+        if(ret != KErrNone)
+            {
+            ERR_PRINTF2(_L("Failed to bind plugin pair=%d"), i);
+            SetTestStepResult(EFail);
+            User::Leave(ret);
+            }
+        }
+	}
+
+void CDEXECUserSideStep::MonitorProgressL()
+/**
+ * @return void
+ * This method monitors the RProperty for the crash progress. There are several states of this but we are
+ * only interested in the start and finish of these properties
+ */
+	{
+	RProperty crashProgress;
+	User::LeaveIfError(crashProgress.Attach(KCoreDumpServUid, ECrashProgress));	
+	
+	TBuf<50> crashProg;			
+
+	TRequestStatus status;
+	crashProgress.Subscribe(status);
+	User::WaitForRequest(status);
+	//Subscribe for next one again...
+	crashProgress.Subscribe(status);
+	
+	//First one should be the start string = KStartOfDEXECProc
+	User::LeaveIfError(crashProgress.Get(crashProg ));		
+	if(crashProg != KStartOfDEXECProc)
+		{
+		INFO_PRINTF1(_L("DEXEC formatter has not started processing the data"));
+		}
+	
+	INFO_PRINTF1(_L("DEXEC formatters have started processing the data"));
+	INFO_PRINTF1(_L("Waiting to be notified of the timeout of the processing. A timeout here is a fail"));
+	//Now we wait until its finished
+	do
+		{			
+		User::WaitForRequest(status);		
+		crashProgress.Subscribe(status);
+
+		User::LeaveIfError(crashProgress.Get(crashProg ));		
+		}
+	while(crashProg != KEndOfProcessing);
+	
+	INFO_PRINTF1(_L("DEXEC formatter has finished processing the data"));			
+	}
+
+
+TVerdict CDEXECUserSideStep::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	iSess.Disconnect();
+	User::After(7000000); //ensure we give enough time for session to close
+	iFs.Close();
+	return EPass;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/SELFpluginstep.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,389 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example CTestStep derived implementation
+//
+
+
+
+/**
+ @file SELFStep.cpp
+ @internalTechnology
+*/
+#include "SELFpluginstep.h"
+#include "tcoredumpserversuitedefs.h"
+
+CSELFPluginStep::~CSELFPluginStep()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CSELFPluginStep::CSELFPluginStep()
+/**
+ * Constructor
+ */
+	{
+	// **MUST** call SetTestStepName in the constructor as the controlling
+	// framework uses the test step name immediately following construction to set
+	// up the step's unique logging ID.
+	SetTestStepName(KSELFPluginStep);
+	}
+
+TVerdict CSELFPluginStep::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	   
+	TInt ret = KErrNone;
+	ret = iSess.Connect(); 
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		INFO_PRINTF2(_L("Error %d from iSess->Connect()/n"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+
+	return TestStepResult();
+	}
+
+
+TVerdict CSELFPluginStep::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+	{
+	if (TestStepResult()==EPass)
+		{	
+		TInt ret = KErrNone;
+
+		__UHEAP_MARK;
+
+		TRAP(ret, ClientAppL());
+		if(KErrNone != ret)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Error %d from CSELFStep->ClientAppL()"), ret);
+			}
+		
+		__UHEAP_MARKEND;
+
+		}
+	return TestStepResult();  
+	}
+
+void CSELFPluginStep::ClientAppL()
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+	{
+	INFO_PRINTF1(_L("Starting SELF Plugin Test Suite") );
+	LoadPluginL();
+	UnloadPluginL();
+    for(TInt i = 1; i < SelfMultipleTries; i++)
+        {
+        LoadMultiplePluginsL(i);
+        UnloadMultiplePluginsL(i);
+        }
+
+	}
+
+void CSELFPluginStep::LoadPluginL()
+/**
+ * @return void
+ * Tests that the plugin can be loaded correctly
+ */
+	{		
+	if (TestStepResult()==EPass)
+		{
+			
+		INFO_PRINTF1(_L("Attempting to load SELF Plugin"));
+		
+		TPluginRequest req;
+		req.iPluginType = TPluginRequest::EFormatter;
+		req.iLoad = ETrue;
+		req.iUid = SELF_UID;
+
+		// Should be allowed to load Symbian ELF
+		TRAPD(ret, iSess.PluginRequestL( req ));
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed loading plugin with UID 0x%X  -- SELF Plugin/n"), req.iUid );
+			User::Leave(ret);
+			}
+		
+		//Now we need to look in the plugin list and make sure the SELF plugin isnt there
+		RPluginList plugins;
+		CleanupClosePushL(plugins);
+		
+		TRAP(ret, iSess.GetPluginListL(plugins));
+		if (ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed to get plugin list -- SELF Plugin. Error: %d"), ret);
+			User::Leave(ret);
+			}
+		
+		//Now we look through the list, until we find our plugin, its a fail
+		SetTestStepResult(EFail);
+		
+		for (TInt i = 0; i < plugins.Count(); i++)
+			{
+			if (plugins[i].iUid ==  SELF_UID && plugins[i].iLoaded)
+				{
+				SetTestStepResult(EPass);
+				INFO_PRINTF1(_L("SELF Plugin loaded successfully"));
+				CleanupStack::PopAndDestroy();//take plugins off cleanupstack
+				return;
+				}
+			}
+		
+		INFO_PRINTF1(_L("SELF Plugin failed to load successfully"));
+		CleanupStack::PopAndDestroy();
+
+		}	
+	}
+
+void CSELFPluginStep::UnloadPluginL()
+/**
+ * @return void
+ * Tests the plugin can be successfully unloaded
+ */
+	{
+	if(TestStepResult()==EPass)
+		{
+		INFO_PRINTF1(_L("Attempting to unload SELF Plugin"));
+		
+		TPluginRequest req;
+		req.iPluginType = TPluginRequest::EFormatter;
+		req.iLoad = EFalse;
+		req.iUid = SELF_UID;
+		
+		TRAPD(ret, iSess.PluginRequestL( req ));
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed unloading plugin with UID 0x%X  -- SELF Plugin"), req.iUid );
+			User::Leave(ret);
+			}
+		
+		//Now we need to look in the plugin list and make sure the SELF plugin isnt there
+		RPluginList plugins;
+		CleanupClosePushL(plugins);
+		
+		TRAP(ret, iSess.GetPluginListL(plugins));
+		if (ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed to get plugin list -- SELF Plugin. Error: %d"), ret);
+			User::Leave(ret);
+			}
+		
+		//Now we look through the list, until we find our plugin, its a fail
+		SetTestStepResult(EFail);
+		
+		for (TInt i = 0; i < plugins.Count(); i++)
+			{
+			if (plugins[i].iUid ==  SELF_UID && !plugins[i].iLoaded)
+				{
+				SetTestStepResult(EPass);
+				INFO_PRINTF1(_L("SELF Plugin unloaded successfully"));
+				CleanupStack::PopAndDestroy();
+				return;
+				}
+			}
+		
+		INFO_PRINTF1(_L("SELF Plugin failed to unload successfully"));
+		CleanupStack::PopAndDestroy();	
+		}		
+	}
+
+void CSELFPluginStep::UnloadPluginL(const TInt aIndex)
+/**
+ * @return void
+ * Tests the plugin can be successfully unloaded
+ */
+	{
+	if(TestStepResult()==EPass)
+		{
+		INFO_PRINTF2(_L("Attempting to unload SELF Plugin. Index = [%d]"), aIndex);
+		
+		TPluginRequest req;
+		req.iPluginType = TPluginRequest::EFormatter;
+		req.iLoad = EFalse;
+		req.iUid = SELF_UID;
+		
+		TRAPD(ret, iSess.PluginRequestL( req ));
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed unloading plugin with UID 0x%X  -- SELF Plugin"), req.iUid );
+			User::Leave(ret);
+			}
+		
+		INFO_PRINTF1(_L("SELF Plugin unloaded successfully"));
+		}		
+	}
+
+void CSELFPluginStep::LoadMultiplePluginsL(const TInt aCount)
+/**
+ * @return void
+ * This tests behaviour when we attempt to load an already loaded SELF plugin.
+ * Should only be loaded once, even after calling twice
+ */
+	{
+	if (TestStepResult()==EPass)
+		{	
+		INFO_PRINTF1(_L("Testing loading the SELF plugin multiple times"));
+        for(TInt i = 0; i < aCount; i++)
+            {
+		    LoadPluginL();	
+            }
+		
+		//Now we need to look in the plugin list and make sure the DEXEC plugin isnt there multiple times
+		RPluginList plugins;
+		CleanupClosePushL(plugins);
+		
+		TRAPD(ret, iSess.GetPluginListL(plugins));
+		if (ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed to get plugin list -- SELF Plugin. Error: %d"), ret);
+			User::Leave(ret);
+			}
+		
+		TInt selfCounter = 0;
+		for (TInt i = 0; i < plugins.Count(); i++)
+			{
+			if (plugins[i].iUid ==  SELF_UID && plugins[i].iLoaded)
+				{
+                selfCounter++;
+				break;
+				}
+			}
+		
+        if(selfCounter == 0)
+        {
+	        SetTestStepResult(EFail);
+			INFO_PRINTF1(_L("Fail - SELF plugin has been not marked as loaded"));
+        }
+
+        RPluginPointerList formatterList;
+        TRAP(ret, iSess.GetFormattersL(formatterList));
+        selfCounter = 0;
+        for(TInt i = 0; i < formatterList.Count(); i++)
+        {
+            if(TUid::Uid(formatterList[i]->Uid()) == SELF_UID)
+            {
+            selfCounter++;
+            }
+        }
+        formatterList.ResetAndDestroy();
+
+		if(selfCounter != aCount)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Fail - SELF plugin has not been found loaded %d times"), aCount);
+			}
+		else
+			{
+			INFO_PRINTF1(_L("Loading plugin multiple times is ok"));
+			}
+		
+		CleanupStack::PopAndDestroy();
+		}	
+	}
+
+void CSELFPluginStep::UnloadMultiplePluginsL(const TInt aCount)
+/**
+ * @return void
+ * This tests behaviour when we attempt to unload the SELF plugin when it has
+ * not been loaded
+ */
+   	{
+	if (TestStepResult()==EPass)
+		{
+		INFO_PRINTF2(_L("Testing unloading the SELF plugin multiple times - %d"), aCount);
+        for(TInt i = aCount; i > 0; i--)
+            {
+		    UnloadPluginL(i - 1);	
+            }
+		
+		//Now we need to look in the plugin list and make sure the SELF plugin isnt there
+		RPluginList plugins;
+		CleanupClosePushL(plugins);
+		
+		TRAPD(ret, iSess.GetPluginListL(plugins));
+		if (ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed to get plugin list -- SELF Plugin. Error: %d"), ret);
+			User::Leave(ret);
+			}
+		
+		TInt selfCounter = aCount;
+		for (TInt i = 0; i < plugins.Count(); i++)
+			{
+			if (plugins[i].iUid ==  SELF_UID && plugins[i].iLoaded)
+				{
+                selfCounter = 0;
+				break;
+				}
+			}
+	
+        if(selfCounter == 0)
+        {
+			SetTestStepResult(EFail);
+			INFO_PRINTF1(_L("Fail - SELF plugin has been found marked as loaded"));
+        }
+
+        RPluginPointerList formatterList;
+        TRAP(ret, iSess.GetFormattersL(formatterList));
+        selfCounter = 0;
+        for(TInt i = 0; i < formatterList.Count(); i++)
+        {
+            if(TUid::Uid(formatterList[i]->Uid()) == SELF_UID)
+            {
+            selfCounter++;
+            }
+        }
+        formatterList.ResetAndDestroy();
+
+		if(selfCounter > 0)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Fail - SELF %d plugins has been found loaded"), selfCounter);
+			}
+		else
+			{
+			INFO_PRINTF1(_L("Unloading plugin multiple times is ok"));
+			}
+		
+		CleanupStack::PopAndDestroy();
+		}
+	}
+
+TVerdict CSELFPluginStep::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	iSess.Disconnect();
+	User::After(10000000); //ensure we give enough time for session to close
+	return EPass;	
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/SELFusersidestep.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,611 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example CTestStep derived implementation
+//
+
+
+
+/**
+ @file SELFStep.cpp
+ @internalTechnology
+*/
+#include "SELFUserSideStep.h"
+#include "tcoredumpserverSuiteDefs.h"
+#include "tcoredumpserverSuiteServer.h"
+#include "optionconfig.h"
+#include <coredumpserverapi.h>
+#include <e32property.h>
+#include <crashdatasave.h>
+
+CSELFUserSideStep::~CSELFUserSideStep()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CSELFUserSideStep::CSELFUserSideStep()
+/**
+ * Constructor
+ */
+	{
+	// **MUST** call SetTestStepName in the constructor as the controlling
+	// framework uses the test step name immediately following construction to set
+	// up the step's unique logging ID.
+	SetTestStepName(KSELFUserSideStep);
+	}
+
+TVerdict CSELFUserSideStep::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	   
+	TInt ret = KErrNone;
+	ret = iSess.Connect(); 
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		INFO_PRINTF2(_L("Error %d from iSess->Connect()/n"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+	
+	ret = iFs.Connect();
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		INFO_PRINTF2(_L("Error %d from iFs->Connect()/n"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+
+	return TestStepResult();
+	}
+
+
+TVerdict CSELFUserSideStep::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+	{
+
+	if (TestStepResult()==EPass)
+		{	
+		TInt ret = KErrNone;
+
+		__UHEAP_MARK;		
+		
+		TRAP(ret, ClientAppL());
+		if(KErrNone != ret)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Error %d from CSELFStep->ClientAppL()"), ret);
+			}		
+
+		__UHEAP_MARKEND;
+
+		}
+	return TestStepResult();  
+	}
+
+void CSELFUserSideStep::ClientAppL()
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+	{
+	INFO_PRINTF1(_L("Starting SELF Test Suite") );
+	HandleCrashL();
+    //CheckParametersL();
+	}
+
+void CSELFUserSideStep::HandleCrashL()
+/**
+ * @return void
+ * Tests handling a crash
+ */
+	{
+
+	if(TestStepResult()==EPass)
+		{
+
+		
+		TPtrC crashAppParam;
+		TPtrC crashFileName;
+		TPtrC writerToUse;
+		
+		if(!GetStringFromConfig(ConfigSection(), KTe_CrashAppParam, crashAppParam) ||
+		   !GetStringFromConfig(ConfigSection(), KTe_CrashFileName, crashFileName) ||
+		   !GetStringFromConfig(ConfigSection(), KWriterToUse, writerToUse))
+			{
+			INFO_PRINTF1(_L("Failed to get data from ini file"));
+			SetTestStepResult(EFail);
+			User::Leave(KErrGeneral);
+			}
+		
+		INFO_PRINTF4(_L("The CrashApp Param is %S, The Filename is is %S, The writer is %S"), &crashAppParam, &crashFileName,&writerToUse); // Block end
+				
+		//Convert writer config to hex
+		TLex luther(writerToUse);
+		TUint32 writer;
+		luther.Val(writer, EHex);
+		
+		//Start the process that we intend to crash....
+		RProcess crashProcess;
+		CleanupClosePushL(crashProcess);
+		
+		TInt ret = crashProcess.Create( KCrashAppFileName, crashAppParam);
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Error %d from RProcess .Create(z:\\sys\\bin\\crashapp.exe)/n"), ret);
+			SetTestStepResult(EFail);
+			User::Leave(ret);
+			}
+		
+		INFO_PRINTF1(_L("Started userside crash app"));
+		
+		//Load SELF Formatter
+		LoadSELFFormatterL();
+		
+		TPluginRequest req;
+		TUid writerUid = TUid::Uid(writer);
+		req.iUid = writerUid;
+		req.iPluginType = TPluginRequest::EWriter;
+		req.iLoad = ETrue;
+		
+		TRAP(ret, iSess.PluginRequestL( req ));
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Failed to load writer plugin, error = %d"), ret);
+			SetTestStepResult(EFail);
+			User::Leave(ret);
+			}
+		
+		INFO_PRINTF1(_L("Loaded writer plugin successfully"));
+		
+		//Now we configure CDS and writer		
+		_LIT( KFilePathPrompt, "not_important" );
+		
+		DoConfigureL(2, CDS_UID.iUid, COptionConfig::ECoreDumpServer, COptionConfig::ETUInt, KPostCrashEventActionPrompt,
+					 1, KNullDesC, 4, KNullDesC, 0);	
+
+		DoConfigureL((TInt)(CCrashDataSave::ECoreFilePath), writerUid.iUid, COptionConfig::EWriterPlugin, COptionConfig::ETFileName,
+						    KFilePathPrompt, 1, KNullDesC, 0, crashFileName, 0);		
+		
+		// Observe the process and wait for a crash
+		TRAP(ret, iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue) );
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Error %d iSess.ObservationRequestL(z:\\sys\\bin\\crashapp.exe)\n"), ret);
+			SetTestStepResult(EFail);
+			User::Leave( ret );
+			}
+		
+		//start the crash process
+		crashProcess.Resume();
+		CleanupStack::PopAndDestroy(&crashProcess); //this is for crashProcess
+	
+		//Monitor the progress of the crash file being generated...
+		MonitorProgressL();
+        User::After(5000000);
+
+		//Check dump has been generated...and valid
+        CDir *fileList = NULL;
+        TFindFile fileFinder(iFs);
+		TRAP(ret, fileList = CTe_coredumpserverSuite::DoesFileExistL(crashFileName, fileFinder));
+		
+		if((ret != KErrNone) || (fileList == NULL))
+			{
+			INFO_PRINTF2(_L("Expected crash file was not generated:  %d"), ret);
+			SetTestStepResult(EFail);
+			User::Leave( ret );
+			}
+
+        CleanupStack::PushL(fileList);
+        for(TInt i = 0; i < fileList->Count(); i++)
+            {
+            TParse fullName;
+            fullName.Set((*fileList)[i].iName, &fileFinder.File(), NULL);
+            User::LeaveIfError(iFs.Delete(fullName.FullName()));
+            }
+        CleanupStack::PopAndDestroy(fileList);
+		
+		INFO_PRINTF1(_L("Expected crash file was generated successfully"));
+		
+		RProcessPointerList procList;
+		TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupProcessList, (TAny*)&procList);
+		CleanupStack::PushL(cleanupProcesses);
+	
+		iSess.GetProcessesL( procList );			
+		
+		INFO_PRINTF1(_L("Looking through the procList"));
+		for(TInt i=0; i < procList.Count(); i++ )
+			{				
+			if(procList[i]->Name() == KCrashAppFileName)
+				{
+				SetTestStepResult( EFail );
+				INFO_PRINTF1(_L("Crash application was not killed as expected after crash"));
+				User::Leave(KErrGeneral);
+				}
+			}
+		CleanupStack::PopAndDestroy(&procList);
+		}
+	}
+
+void CSELFUserSideStep::CheckParametersL()
+/**
+ * This checks the SELF parameters - are we creating a stack file and text file?
+ */
+	{
+	if(TestStepResult()==EPass)
+		{
+        //Start the process that we intend to crash....
+        RProcess crashProcess;
+        CleanupClosePushL(crashProcess);
+        
+        _LIT(KCrashAppParam, "-c4 -d1");
+        TInt ret = crashProcess.Create( KCrashAppFileName, KCrashAppParam);
+        if(ret != KErrNone)
+            {
+            INFO_PRINTF2(_L("Error %d from RProcess .Create(z:\\sys\\bin\\crashapp.exe)/n"), ret);
+            SetTestStepResult(EFail);
+            User::Leave(ret);
+            }
+
+        LoadSELFFormatterL();
+        LoadSELFFormatterL();
+        LoadSELFFormatterL();
+
+        LoadFileWriterL();
+        LoadFileWriterL();
+        LoadFileWriterL();
+
+        BindPluginsL(3);
+
+        _LIT(KTrue, "True");
+        _LIT(KFalse, "False");
+
+        
+        //enable system wide
+        DoConfigureL(0, SELF_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC, 1, KFalse, 0);
+
+        //disable process data
+        DoConfigureL(1, SELF_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC, 0, KFalse, 1);
+
+        //disable thread segs
+        DoConfigureL(4, SELF_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC, 0, KTrue, 1);
+
+        //disable process segs
+        DoConfigureL(7, SELF_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC, 0, KTrue, 1);
+
+        //disable data segs
+        DoConfigureL(2, SELF_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC, 0, KTrue, 2);
+        
+        //disable code segs
+        DoConfigureL(3, SELF_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC, 0, KTrue, 2);
+
+        //disable register segs
+        DoConfigureL(5, SELF_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC, 0, KTrue, 2);
+
+        //disable executable segs
+        DoConfigureL(6, SELF_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETString, 
+                KNullDesC, 1, KNullDesC, 0, KTrue, 2);
+
+
+        TUid writerUid = WRITER_UID;//file writer
+        _LIT( KCrashFileName, "c:\\self_chkparam");
+        TBuf<63> fileName;
+        for(TInt i = 0; i < 3; i++)
+        {
+            fileName = KCrashFileName;
+            fileName.AppendFormat(_L("%d"), i);
+            DoConfigureL(CCrashDataSave::ECoreFilePath, writerUid.iUid, COptionConfig::EWriterPlugin, COptionConfig::ETFileName,
+                            KNullDesC, 1, KNullDesC, 0, fileName, i);	
+        }
+
+        // Observe the process and wait for a crash
+        TRAP(ret, iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue));
+        if(ret != KErrNone)
+            {
+            ERR_PRINTF2(_L("Error %d iSess.ObservationRequestL(z:\\sys\\bin\\crashapp.exe)\n"), ret);
+            SetTestStepResult(EFail);
+            User::Leave( ret );
+            }
+        
+        //start the crash process
+        crashProcess.Resume();
+        INFO_PRINTF1(_L("Started userside crash app"));
+        CleanupStack::PopAndDestroy(&crashProcess);
+    
+        //Monitor the progress of the crash file being generated...
+        MonitorProgressL();
+
+        //Check dumps have been generated...		
+        CDir *fileList = NULL;
+        TFindFile fileFinder(iFs);
+        TRAP(ret, fileList = CTe_coredumpserverSuite::DoesFileExistL(KCrashFileName, fileFinder));
+
+        if( (ret != KErrNone) || (fileList == NULL) )
+            {
+            ERR_PRINTF2(_L("Expected crash files were not generated:  %d"), ret);
+            SetTestStepResult(EFail);
+            User::Leave( ret );
+            }
+        
+        TInt validFiles = 0;
+        CleanupStack::PushL(fileList);
+        _LIT(KElfDump, "z:\\sys\\bin\\elfdump.exe");
+        _LIT(KCoreFile, "c:\\core");
+        for(TInt i = 0; i < fileList->Count(); i++)
+            {
+            TParse fullName;
+            fullName.Set((*fileList)[i].iName, &fileFinder.File(), NULL);
+            INFO_PRINTF2(_L("%S"), &fullName.FullName());
+
+            RProcess elfdump;
+            TInt err = elfdump.Create(KElfDump, fullName.FullName());
+            if(err == KErrNone)
+                {
+                TRequestStatus status;
+                elfdump.Rendezvous(status);
+                elfdump.Resume();
+                User::WaitForRequest(status);
+                elfdump.Close();
+                if(status.Int() == KErrNone)
+                    {
+                    validFiles++;
+                    }
+                else
+                    {
+                    INFO_PRINTF2(_L("elfdump postprocessing finished abnormally:%d"), status.Int());
+                    }
+                }
+            else
+                {
+                INFO_PRINTF2(_L("unable to create elfdump process:%d"), err);
+                }
+            
+            //Now we validate the trace data
+
+            User::LeaveIfError(iFs.Delete(fullName.FullName()));
+            }
+        User::LeaveIfError(iFs.Delete(KCoreFile));
+
+        if( fileList->Count() != 3 )
+            {
+            ERR_PRINTF1(_L("Expected crash files were not generated"));
+            SetTestStepResult(EFail);
+            User::Leave(KErrNotFound);
+            }
+        CleanupStack::PopAndDestroy(fileList);
+
+        if( validFiles != 3 )
+            {
+            ERR_PRINTF1(_L("Expected crash files were generated but format was not valid"));
+            SetTestStepResult(EFail);
+            User::Leave(KErrCorrupt);
+            }
+
+		RProcessPointerList procList;
+		TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupProcessList, (TAny*)&procList);
+		CleanupStack::PushL(cleanupProcesses);
+		
+		iSess.GetProcessesL( procList );			
+		
+		INFO_PRINTF1(_L("Looking through the procList"));
+		for(TInt i=0; i < procList.Count(); i++ )
+			{				
+			if(procList[i]->Name() == KCrashAppFileName)
+				{
+				SetTestStepResult( EFail );
+				ERR_PRINTF1(_L("Crash application was not killed as expected after crash"));
+				User::Leave(KErrGeneral);
+				}
+			}
+		CleanupStack::PopAndDestroy(&procList);
+		}
+	}
+
+void CSELFUserSideStep::DoConfigureL(const TUint32& aIndex, 
+		  	     const TUint32& aUID, 
+                 const COptionConfig::TParameterSource& aSource, 
+                 const COptionConfig::TOptionType& aType, 
+                 const TDesC& aPrompt, 
+                 const TUint32& aNumOptions,
+                 const TDesC& aOptions,
+                 const TInt32& aVal, 
+                 const TDesC& aStrValue,
+                 const TUint aInstance)
+/**
+* @return void
+* @param aIndex Internal index to the component that owns the object
+* @param aUID UID of the component that owns the object
+* @param aSource Type of component that owns the object
+* @param aType Type of parameter
+* @param aPrompt Prompt to present to user 
+* @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
+* @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
+* @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
+* @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
+*/
+	{
+	COptionConfig * config;	
+	
+	config = COptionConfig::NewL( aIndex,
+			aUID,
+			aSource,
+			aType,
+			aPrompt,
+			aNumOptions,
+			aOptions,
+			aVal,
+			aStrValue);
+	
+	CleanupStack::PushL(config);
+	
+    config->Instance(aInstance);
+
+	//Configure now...
+	TRAPD(ret, iSess.SetConfigParameterL(*config) );
+	if(ret != KErrNone)
+		{
+		INFO_PRINTF2(_L("Error %d changing param/n"), ret );
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+
+	CleanupStack::PopAndDestroy(config);
+	}
+
+void CSELFUserSideStep::MonitorProgressL()
+/**
+ * @return void
+ * This method monitors the RProperty for the crash progress. There are several states of this but we are
+ * only interested in the start and finish of these properties
+ */
+	{
+	RProperty crashProgress;
+	User::LeaveIfError(crashProgress.Attach(KCoreDumpServUid, ECrashProgress));	
+	
+	TBuf<50> crashProg;			
+
+	TRequestStatus status;
+	crashProgress.Subscribe(status);
+	User::WaitForRequest(status);
+	//Subscribe for next one again...
+	crashProgress.Subscribe(status);
+	
+	//First one should be the start string = "-"
+	User::LeaveIfError(crashProgress.Get(crashProg ));		
+	if(crashProg != KStartOfSELFProc)
+		{
+		INFO_PRINTF1(_L("SELF formatter has not started processing the data"));
+		}
+	
+	INFO_PRINTF1(_L("SELF formatters have started processing the data"));
+	INFO_PRINTF1(_L("Waiting to be notified of the timeout of the processing. A timeout here is a fail"));
+	//Now we wait until its finished
+	do
+		{			
+		User::WaitForRequest(status);		
+		crashProgress.Subscribe(status);
+
+		User::LeaveIfError(crashProgress.Get(crashProg ));		
+		}
+	while(crashProg != KEndOfProcessing);
+	
+	INFO_PRINTF1(_L("SELF formatter has finished processing the data"));			
+	
+	}
+
+void CSELFUserSideStep::LoadSELFFormatterL()
+/**
+ * @return void
+ * Utility function to load the SELF formatter
+ */
+	{
+	
+	INFO_PRINTF1(_L("Attempting to load SELF Plugin"));
+	
+	TPluginRequest req;
+	req.iPluginType = TPluginRequest::EFormatter;
+	req.iLoad = ETrue;
+	req.iUid = SELF_UID;
+
+	// Should be allowed to load Symbian ELF
+    TRAPD(ret, iSess.PluginRequestL( req ));
+    if(ret != KErrNone)
+        {
+        ERR_PRINTF2(_L("Failed to load self formatter plugin, error = %d"), ret);
+        SetTestStepResult(EFail);
+        User::Leave(ret);
+        }
+	
+	}
+
+void CSELFUserSideStep::LoadFileWriterL()
+    {
+    TPluginRequest req;
+    TUid writerUid = WRITER_UID; 
+    req.iUid = writerUid;
+    req.iPluginType = TPluginRequest::EWriter;
+    req.iLoad = ETrue;
+    
+    TRAPD(ret, iSess.PluginRequestL( req ));
+    if(ret != KErrNone)
+        {
+        ERR_PRINTF2(_L("Failed to load writer plugin, error = %d"), ret);
+        SetTestStepResult(EFail);
+        User::Leave(ret);
+        }
+
+    }
+
+void CSELFUserSideStep::BindPluginsL(const TInt aCount)
+/**
+ * @return void
+ * Utility function to load the SELF formatter
+ */
+	{
+	INFO_PRINTF1(_L("Attempting to bind plugins"));
+	
+	TPluginRequest req;
+	req.iPluginType = TPluginRequest::EFormatter;
+	req.iUid = TUid::Uid(0);
+
+    for(TInt i = 0; i < aCount; i++)
+        {
+        req.iIndex = req.iPair = i;
+        TRAPD(ret, iSess.PluginRequestL( req ));
+
+        if(ret != KErrNone)
+            {
+            ERR_PRINTF2(_L("Failed to bind plugin pair=%d"), i);
+            SetTestStepResult(EFail);
+            User::Leave(ret);
+            }
+        }
+	}
+
+
+TVerdict CSELFUserSideStep::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	iSess.Disconnect();
+	User::After(7000000); //ensure we give enough time for session to close
+	iFs.Close();
+	return EPass;	
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/SELFusersidestrace.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,895 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example CTestStep derived implementation
+//
+
+
+
+/**
+ @file SELFusersidestrace.cpp
+ @internalTechnology
+*/
+#include "SELFusersidetrace.h"
+#include "tcoredumpserverSuiteDefs.h"
+#include "tcoredumpserverSuiteServer.h"
+#include "optionconfig.h"
+#include <coredumpserverapi.h>
+#include <e32property.h>
+#include <crashdatasave.h>
+
+CSELFUserSideTrace::~CSELFUserSideTrace()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CSELFUserSideTrace::CSELFUserSideTrace()
+/**
+ * Constructor
+ */
+	{
+	// **MUST** call SetTestStepName in the constructor as the controlling
+	// framework uses the test step name immediately following construction to set
+	// up the step's unique logging ID.
+	SetTestStepName(KSELFUserSideTrace);
+	}
+
+TVerdict CSELFUserSideTrace::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	   
+	TInt ret = KErrNone;
+	ret = iCoreDumpSession.Connect(); 
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		INFO_PRINTF2(_L("Error %d from iCoreDumpSession->Connect()/n"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+	
+	ret = iFsSession.Connect();
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		INFO_PRINTF2(_L("Error %d from iFsSession->Connect()/n"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+
+	return TestStepResult();
+	}
+
+
+TVerdict CSELFUserSideTrace::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+	{
+
+	if (TestStepResult()==EPass)
+		{	
+		TInt ret = KErrNone;
+
+		__UHEAP_MARK;		
+		
+		TRAP(ret, ClientAppL());
+		if(KErrNone != ret)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Error %d from CSELFStep->ClientAppL()"), ret);
+			}		
+
+		__UHEAP_MARKEND;
+
+		}
+	return TestStepResult();  
+	}
+
+void CSELFUserSideTrace::ClientAppL()
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+	{
+	INFO_PRINTF1(_L("Starting SELF Test Suite") );
+	HandleCrashL();
+    //CheckParameters();
+	}
+
+void CSELFUserSideTrace::HandleCrashL()
+/**
+ * @return void
+ * Tests handling a crash
+ */
+	{
+	iTraceFlag = EFalse;
+	if(TestStepResult()==EPass)
+		{
+		TPtrC crashAppParam;
+		TInt tracePresent;
+		
+		if(!GetStringFromConfig(ConfigSection(), KTe_CrashAppParam, crashAppParam) ||
+		   !GetIntFromConfig(ConfigSection(), KTrace, tracePresent))
+			{
+			INFO_PRINTF1(_L("Failed to get data from ini file"));
+			SetTestStepResult(EFail);
+			User::Leave(KErrGeneral);
+			}
+		
+		INFO_PRINTF3(_L("The CrashApp Param is %S, Ok so the trace parameter is %d"), &crashAppParam, &tracePresent); // Block end
+				
+		if(tracePresent == 1)
+			iTraceFlag = ETrue; //trace is present
+		else
+			iTraceFlag = EFalse; //trace not present
+			
+		INFO_PRINTF2(_L("iTraceFlag %d"), iTraceFlag);
+		
+		//Start the process that we intend to crash....
+		RProcess crashProcess;
+		CleanupClosePushL(crashProcess);
+		
+		TInt ret = crashProcess.Create( KCrashAppFileName, crashAppParam);
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Error %d from RProcess .Create(z:\\sys\\bin\\crashapp.exe)/n"), ret);
+			SetTestStepResult(EFail);
+			User::Leave(ret);
+			}
+		
+		INFO_PRINTF1(_L("Started userside crash app"));
+		
+		//Load SELF and Writer Formatter 
+		DoCmdLoadPluginsL();
+		
+		//configure the CDS and File Writer
+		DoCmdConfigurePluginsL();
+		
+		//configure the SELF formatter accordingly for trace/no trace
+		ConfigureSELF(iTraceFlag);
+		
+		// Observe the process and wait for a crash
+		TRAP(ret, iCoreDumpSession.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue) );
+		if(ret != KErrNone)
+			{
+			INFO_PRINTF2(_L("Error %d iCoreDumpSession.ObservationRequestL(z:\\sys\\bin\\crashapp.exe)\n"), ret);
+			SetTestStepResult(EFail);
+			User::Leave( ret );
+			}
+		
+		//start the crash process
+		crashProcess.Resume();
+		CleanupStack::PopAndDestroy(&crashProcess); //this is for crashProcess
+	
+		//Monitor the progress of the crash file being generated...
+		MonitorProgressL();
+        User::After(5000000);
+        
+        iFsSession.SetSessionPath(KDir); //set the default path to e:\\ MMC card
+    	//Use wildcard utilities to search for the SELF FIle Created
+    	TBuf<32> buf;
+    	buf = KDir;
+    	TUidType uid1;
+    	TUidType uid2(uid1.MostDerived());
+    	CFindFileByType* obj = new(ELeave) CFindFileByType(iFsSession);
+    	CleanupStack::PushL(obj);
+
+    	ret = obj->FindFirst(KCrashWildCard, buf, uid2);
+    	if (ret != KErrNone)
+    		{
+    		ERR_PRINTF2(
+    				_L("GenerateElfFileL Error finding the SELF File %d"),
+    				ret);
+    		SetTestStepResult(EFail);
+    		User::Leave(ret);
+    		}
+
+    	iSELFFileName = obj->Entry().iName;
+    	CleanupStack::PopAndDestroy(); //CFindFileByType
+        
+    	INFO_PRINTF2(_L("SELF File found: %S"),&iSELFFileName);
+    	
+    	//test for a valid Trace section
+    	DoTestTraceSectionSELFFileL(iTraceFlag);
+		
+		INFO_PRINTF1(_L("SUCCESS Trace Data Presence/Absence verified!"));
+		}
+	}
+
+/**
+ * Validates the presence of the trace data in the SELF file generated
+ */
+void CSELFUserSideTrace::DoTestTraceSectionSELFFileL(TBool aFlag)
+	{
+	
+	TInt err = iSELFFile.Open(iFsSession, iSELFFileName, EFileStream|EFileRead);
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::ProcessELFFile Error opening the SELF File %d"),
+				err);
+		SetTestStepResult(EFail);
+		User::Leave(err);
+		}
+	
+	//validate the SELF Header Format	
+	ValidateHeaderELFFileL();
+	
+	//validate the Program Header and store information about the string section Sections
+	ValidateProgramHeaderELFFileL();
+
+	//validate the trace section to be present
+	ValidateTraceSectionELFFileL(aFlag);
+	
+	//do the necessary clean up 
+	CleanupMethod(iSELFFileName);
+		
+	}
+
+/**
+ * Validates the Header Format Elf32_Ehdr for the SELF file 
+ */
+void CSELFUserSideTrace::ValidateHeaderELFFileL()
+	{// Elf32_Ehdr
+	INFO_PRINTF1(_L("CSELFUserSideTrace::ValidateHeaderELFFileL validating Elf32_Ehdr"));
+	
+	TInt sizeofELFHeader = sizeof(Elf32_Ehdr); //size of Elf32_Ehdr structure
+
+	// allocate buffer Elf32_Ehdr
+	TUint8* SELFHeader = new TUint8[sizeofELFHeader];
+	TPtr8 elfHeaderPointer(SELFHeader, sizeofELFHeader, sizeofELFHeader);
+	CleanupStack::PushL(SELFHeader);
+
+	//read the SELF file for Elf32_Ehdr
+	TInt ret = iSELFFile.Read(0, elfHeaderPointer, sizeofELFHeader);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CSELFUserSideTrace::ValidateHeaderELFFile Error reading the SELF Header Elf32_Ehdr %d"),
+				ret);
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+	//
+	Elf32_Ehdr* eh=(Elf32_Ehdr *)SELFHeader;
+
+	//VALIDATE THE Elf32_Ehdr
+
+	if (eh->e_ident[EI_MAG0] !=0x7f || eh->e_ident[EI_MAG1] != 0x45
+			|| eh->e_ident[EI_MAG2] !=0x4c || eh->e_ident[EI_MAG3] != 0x46)
+		{
+		// EI_MAG0 to EI_MAG3 - A files' first 4 bytes hold a 'magic number', identifying the file as an ELF object file.
+		ERR_PRINTF1(_L("Error:  is not a valid ELF file"));
+		SetTestStepResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+	if (eh->e_ident[EI_DATA] == 2)
+		{
+		// ELF Header size should be 52 bytes or converted into Big-Endian system 13312
+		if (eh->e_ehsize != 13312)
+			{
+			ERR_PRINTF1(_L("Error:  ELF Header contains invalid file typ"));
+			SetTestStepResult(EFail);
+			User::Leave(KErrGeneral);
+			}
+		// e_ident[EI_DATA] specifies the data encoding of the processor-specific data in the object file.
+		ERR_PRINTF1(_L("Error:  Data encoding ELFDATA2MSB (Big-Endian) not supported"));
+		SetTestStepResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+	if (eh->e_ehsize != 52)
+		{
+		// ELF Header size should be 52 bytes
+		ERR_PRINTF1(_L("Error:  ELF Header contains invalid file type"));
+		SetTestStepResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	//Number of entries in the program header table
+	if ((eh->e_phnum) == 0)
+		{
+		ERR_PRINTF1(_L("Error:  ELF Header contains zero program headers"));
+		SetTestStepResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+	
+	//store number of program header entries
+	iPHEntries = eh->e_phnum;
+	INFO_PRINTF2(_L("Program header entries:%d"), iPHEntries);
+
+	//Offset in bytes from the start of the file to the section header table
+	if ((eh->e_phoff) == 0)
+		{
+		ERR_PRINTF1(_L("Error:  ELF Header contains zero offset to the section header table"));
+		SetTestStepResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	//store program header offset
+	iPHOffset = eh->e_phoff;
+	INFO_PRINTF2(_L("Program header offsett:%d"), iPHOffset);
+
+	CleanupStack::PopAndDestroy(SELFHeader);
+	
+	INFO_PRINTF1(_L("Validation of Elf32_Ehdr successful"));
+	}
+
+/**
+ * Validates the Program Header Entries Elf32_Phdr of the SELF file 
+ */
+void CSELFUserSideTrace::ValidateProgramHeaderELFFileL()
+	{//Elf32_Phdr
+	INFO_PRINTF1(_L("CSELFUserSideTrace::ValidateProgramHeaderELFFileL validating the program header Entries"));
+
+	TInt sizeofELFProgramHeader = sizeof(Elf32_Phdr); //size of Elf32_Phdr
+	TInt totalsizeofELFProgramHeader = iPHEntries * sizeofELFProgramHeader;
+
+	//allocate buffer Elf32_Phdr
+	iSELFPHHeader = new TUint8[totalsizeofELFProgramHeader];
+	TPtr8 elfPHHeaderPointer(iSELFPHHeader, totalsizeofELFProgramHeader,
+			totalsizeofELFProgramHeader);
+
+	//read the SELF for the whole Program Header Table
+	TInt ret = iSELFFile.Read(iPHOffset, elfPHHeaderPointer,
+			totalsizeofELFProgramHeader);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CSELFUserSideTrace::ValidateProgramHeaderELFFileL Error reading the SELF Header Elf32_Phdr %d"),
+				ret);
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+
+	Elf32_Phdr* phdr = (Elf32_Phdr*) iSELFPHHeader;//Elf32_Phdr Program Header
+
+	//Prepare for each of the DHDR buffers 
+	TInt sizeofDhdr = sizeof(Sym32_dhdr);
+
+	//loop through the program headers to find out more information on the String section
+	for (TInt i = 0; i < iPHEntries; i++)
+		{
+		//allocate DHDR buffers Sym32_dhdr
+		iDHDRBuffer[i] = new TUint8[sizeofDhdr];
+		TPtr8 dhdrPointer(iDHDRBuffer[i], sizeofDhdr, sizeofDhdr);
+        
+		//read SELF file for the Sym32_dhdr
+		TInt ret = iSELFFile.Read(phdr[i].p_offset, dhdrPointer, sizeofDhdr);
+		if (ret != KErrNone)
+			{
+			ERR_PRINTF2(
+					_L("CSELFUserSideTrace::ValidateHeaderELFFile Error reading the SELF Header Sym32_dhdr %d"),
+					ret);
+			SetTestStepResult(EFail);
+			User::Leave(ret);
+			}
+
+		idhdr[i] = (Sym32_dhdr*) iDHDRBuffer[i];//array of Sym32_dhdr store it
+
+		//find information about the String Info section
+		if (phdr[i].p_type == PT_NOTE)
+			{
+			// Intend to store information about the string section ESYM_NOTE_STR
+			//the srting section is to be accessed for all sectiosn to be parsed
+			if (idhdr[i]->d_type == ESYM_NOTE_STR)
+				{
+				INFO_PRINTF2(_L("ESYM_NOTE_STR Header offset %d"),
+						phdr[i].p_offset);
+				INFO_PRINTF2(
+						_L("ESYM_NOTE_STR Size of single descriptor element %d "),
+						idhdr[i]->d_descrsz);
+
+				iOffsetStringSection = phdr[i].p_offset + sizeof(Sym32_dhdr);
+				iSizeofStringSection = idhdr[i]->d_descrsz;
+
+				}//if ESYM_NOTE_STR		
+			}//if PT_NOTE
+		}//for loop
+
+	}//end of function
+
+/**
+ * Validates the Trace Section Sym32_tracedata of the SELF file 
+ */
+void CSELFUserSideTrace::ValidateTraceSectionELFFileL(TBool aTraceCheck)
+	{
+	
+	INFO_PRINTF1(_L("CSELFUserSideTrace::ValidateTraceSectionELFFileL validating the Trace Section"));
+	
+	Elf32_Phdr* phdr = (Elf32_Phdr*) iSELFPHHeader;//Elf32_Phdr Program Header
+	
+	TBool dataPresent = EFalse;
+	//loop through the program headers to get information about the Symbian Info section
+	for (TInt i = 0; i < iPHEntries; i++)
+		{
+		if (phdr[i].p_type == PT_NOTE)
+			{
+			if (idhdr[i]->d_type == ESYM_NOTE_TRACE) //Trace Info
+				{
+				TInt sizeoftraceinfo = sizeof(Sym32_tracedata);
+				INFO_PRINTF2(_L("ESYM_NOTE_TRACE Size of trace section %d"), sizeoftraceinfo);
+				INFO_PRINTF2(_L("ESYM_NOTE_TRACE Header offset %d"), phdr[i].p_offset);
+				INFO_PRINTF2(_L("ESYM_NOTE_TRACE Size of single descriptor element %d"),
+						idhdr[i]->d_descrsz);
+				INFO_PRINTF2(_L("ESYM_NOTE_TRACE Number of elements %d"), idhdr[i]->d_elemnum); 
+
+				if (sizeof(Sym32_tracedata) != (idhdr[i]->d_descrsz))
+					{
+					ERR_PRINTF1(_L("CSELFUserSideTrace::ValidateTraceSectionELFFileL sizeof(Sym32_tracedata) %d is different from descriptor size") );
+					SetTestStepResult(EFail);
+					User::Leave(KErrGeneral);
+					}
+				
+				TInt offsettotraceinfod = phdr[i].p_offset + sizeof(Sym32_dhdr);
+				//allocate buffer for Sym32_tracedata
+				TUint8* symbianTraceSection = new TUint8[sizeoftraceinfo];
+				CleanupStack::PushL(symbianTraceSection);
+
+				TPtr8 ptrSymbianTraceSection(symbianTraceSection, sizeoftraceinfo,
+						sizeoftraceinfo);
+
+				TInt ret = iSELFFile.Read(offsettotraceinfod, ptrSymbianTraceSection, sizeoftraceinfo);
+				if (ret != KErrNone)
+					{
+					ERR_PRINTF2(
+							_L("CSELFUserSideTrace::ValidateTraceSectionELFFileL Error reading the SELF Header Sym32_thrdinfod %d"), ret);
+					SetTestStepResult(EFail);
+					User::Leave(ret);
+					}
+
+				Sym32_tracedata *traceInfo =
+										(Sym32_tracedata*) symbianTraceSection;
+			
+				INFO_PRINTF2(_L("Size of trace buffer: %d"), traceInfo->tr_size);
+				INFO_PRINTF2(_L("Offset of trace buffer:%d"), traceInfo->tr_data);
+				
+				//checking for the presence of trace data
+				if(traceInfo->tr_size != 0)//trace data present
+					{
+					dataPresent = ETrue;
+					//read the trace buffer
+					//unsigned char* data = ADDR(unsigned char, aElfHdr, aTraceData->tr_data);	
+					
+					RBuf8 tracebufferString;
+					tracebufferString.CleanupClosePushL();
+
+					//create trace buffer of size  traceInfo->tr_size
+					tracebufferString.CreateL(traceInfo->tr_size);
+					
+					TInt ret = iSELFFile.Read(traceInfo->tr_data, tracebufferString, traceInfo->tr_size);
+					if (ret != KErrNone)
+						{
+						ERR_PRINTF2(
+								_L("CSELFUserSideTrace::ValidateTraceSectionELFFileL Error reading the Trace Information  %d"),
+								ret);
+						SetTestStepResult(EFail);
+						User::Leave(ret);
+						}
+					
+					INFO_PRINTF1(_L("Validate the trace buffer now"));
+					ValidateTraceBufferL(tracebufferString);
+					
+					CleanupStack::PopAndDestroy();//tracebufferString
+					CleanupStack::PopAndDestroy();//symbianTraceSection
+					break;
+					}
+				else //expecting trace data to be present otherwise complain
+					{
+					ERR_PRINTF1(
+							_L("CSELFUserSideTrace::ValidateTraceSectionELFFileL Error found trace size to be zero"));
+					SetTestStepResult(EFail);
+					User::Leave(KErrGeneral);
+					
+					}
+				}			
+			}
+			
+		}
+
+	if(!aTraceCheck && dataPresent )
+		{
+		ERR_PRINTF1(
+				_L("CSELFUserSideTrace::ValidateTraceSectionELFFileL Error found trace section when there shouldnt be one"));
+		SetTestStepResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+	if(aTraceCheck  && !dataPresent )
+		{
+		ERR_PRINTF1(
+				_L("CSELFUserSideTrace::ValidateTraceSectionELFFileL Error did not find the trace section"));
+		SetTestStepResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+	
+	
+	}
+
+/**
+ * Utility Function to do trace data verification
+ */
+void CSELFUserSideTrace::ValidateTraceBufferL(const TDesC8& aBuffer)
+{
+	INFO_PRINTF2(_L("CSELFUserSideTrace::ValidateTraceBufferL: size: %d"), aBuffer.Length());
+	
+	const TUint8* tracePtr = aBuffer.Ptr();
+	TInt traceSize = aBuffer.Length();
+	
+/*	TUint8 recSize = 0;
+	TUint8 flags = 0;
+	TUint8 subCategory = 0;*/
+	TUint8 category = 0;
+	TInt cateogryCount = 0;
+	TInt totalCount = 0;
+
+	const TUint8* endPtr = tracePtr+traceSize;
+	while(tracePtr < endPtr)
+	{ 
+		//count of the total number of records
+		totalCount++;
+		category = 0;
+		
+/*		
+ * for keeping a record of other fields in the Trace		
+ 		recSize = flags = subCategory = 0;
+		recSize = tracePtr[BTrace::ESizeIndex];
+		flags = tracePtr[BTrace::EFlagsIndex];
+		subCategory = tracePtr[BTrace::ESubCategoryIndex];*/
+/*		
+ * printing the values
+ *      INFO_PRINTF2(_L("recSize: %d"), recSize);
+		INFO_PRINTF2(_L("flags: %d"), flags);
+		INFO_PRINTF2(_L("subCategory: %d"), subCategory);
+		INFO_PRINTF2(_L("category: %d"), category);*/
+		
+		//read trace header and parse for the Category
+		category = tracePtr[BTrace::ECategoryIndex];
+		
+		//check the parameter Category 
+		if(category == KTraceCategory)
+			{
+			cateogryCount++;//count the number of times the category 200 has appeared
+			}
+								
+		// go to the next trace packet
+		tracePtr = BTrace::NextRecord((TAny*)tracePtr);
+	}
+	
+	if(category == 0)
+		{// no Category KTraceCategory trace found out
+		ERR_PRINTF2(
+			_L("CSELFUserSideTrace::ValidateTraceBufferL Category %d trace data NOT found!"), KTraceCategory);
+		INFO_PRINTF2(_L("Total Number of trace records found: %d"), totalCount);
+		SetTestStepResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+	
+	if(category % KTRACENUMBER != 0)
+		{//checking for KTRACENUMBER number of KTraceCategory 
+		ERR_PRINTF3(	
+			_L("CSELFUserSideTrace::ValidateTraceBufferL %d number of Category type %d trace data NOT found!"), KTRACENUMBER, KTraceCategory);
+		INFO_PRINTF3(_L("Total number of Category type %d trace data found: %d"), KTraceCategory, cateogryCount);
+		INFO_PRINTF2(_L("Total Number of trace records found: %d"), totalCount);
+		SetTestStepResult(EFail);
+		User::Leave(KErrGeneral);	
+		}
+	
+	INFO_PRINTF3(_L("Total number of Category type %d trace data found: %d"), KTraceCategory, cateogryCount);
+	INFO_PRINTF2(_L("Total Number of trace records found: %d"), totalCount);
+	INFO_PRINTF1(_L("Validation of Trace Buffer Successful!!!")); 
+}
+
+/**
+* @return void
+* @param aIndex Internal index to the component that owns the object
+* @param aUID UID of the component that owns the object
+* @param aSource Type of component that owns the object
+* @param aType Type of parameter
+* @param aPrompt Prompt to present to user 
+* @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
+* @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
+* @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
+* @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
+*/
+void CSELFUserSideTrace::DoConfigureL(const TUint32& aIndex, 
+		  	     const TUint32& aUID, 
+                 const COptionConfig::TParameterSource& aSource, 
+                 const COptionConfig::TOptionType& aType, 
+                 const TDesC& aPrompt, 
+                 const TUint32& aNumOptions,
+                 const TDesC& aOptions,
+                 const TInt32& aVal, 
+                 const TDesC& aStrValue,
+                 const TUint aInstance)
+	{
+	COptionConfig * config;	
+	
+	config = COptionConfig::NewL( aIndex,
+			aUID,
+			aSource,
+			aType,
+			aPrompt,
+			aNumOptions,
+			aOptions,
+			aVal,
+			aStrValue);
+	
+	CleanupStack::PushL(config);
+	
+    config->Instance(aInstance);
+
+	//Configure now...
+	TRAPD(ret, iCoreDumpSession.SetConfigParameterL(*config) );
+	if(ret != KErrNone)
+		{
+		INFO_PRINTF2(_L("Error %d changing param/n"), ret );
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+
+	CleanupStack::PopAndDestroy(config);
+	}
+
+/**
+ * @return void
+ * This method monitors the RProperty for the crash progress. There are several states of this but we are
+ * only interested in the start and finish of these properties
+ */
+void CSELFUserSideTrace::MonitorProgressL()
+	{
+	RProperty crashProgress;
+	User::LeaveIfError(crashProgress.Attach(KCoreDumpServUid, ECrashProgress));	
+	
+	TBuf<50> crashProg;			
+
+	TRequestStatus status;
+	crashProgress.Subscribe(status);
+	User::WaitForRequest(status);
+	//Subscribe for next one again...
+	crashProgress.Subscribe(status);
+	
+	//First one should be the start string = "-"
+	User::LeaveIfError(crashProgress.Get(crashProg ));		
+	if(crashProg != KStartOfSELFProc)
+		{
+		INFO_PRINTF1(_L("SELF formatter has not started processing the data"));
+		}
+	
+	INFO_PRINTF1(_L("SELF formatters have started processing the data"));
+	INFO_PRINTF1(_L("Waiting to be notified of the timeout of the processing. A timeout here is a fail"));
+	//Now we wait until its finished
+	do
+		{			
+		User::WaitForRequest(status);		
+		crashProgress.Subscribe(status);
+
+		User::LeaveIfError(crashProgress.Get(crashProg ));		
+		}
+	while(crashProg != KEndOfProcessing);
+	
+	INFO_PRINTF1(_L("SELF formatter has finished processing the data"));			
+	
+	}
+
+/**
+ * Loads the SELF Formatter and the File Writer plugin
+ */
+void CSELFUserSideTrace::DoCmdLoadPluginsL()
+	{
+	INFO_PRINTF1(_L("\nCProcessCrashWrapperloading SELF Formatter and File Writer!!!"));
+
+	TPluginRequest loadSELFReq;
+	loadSELFReq.iPluginType = TPluginRequest::EFormatter;
+	loadSELFReq.iLoad = ETrue;
+	loadSELFReq.iUid = KUidSELFFormatterV2;
+
+	TPluginRequest loadWriterReq;
+	loadWriterReq.iPluginType = TPluginRequest::EWriter;
+	loadWriterReq.iLoad = ETrue;
+	loadWriterReq.iUid = WRITER_UID;
+
+	// loading Symbian ELF formatter
+	TRAPD(ret, iCoreDumpSession.PluginRequestL(loadSELFReq));
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CSELFUserSideTrace::DoCmdLoadPluginsL: Could not load SELF plugin!, err:%d\n"),
+				ret);
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+
+	// loading Symbian File writer
+	TRAP(ret, iCoreDumpSession.PluginRequestL(loadWriterReq));
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CSELFUserSideTrace::DoCmdLoadPluginsL: Could not load writer plugin!, err:%d\n"),
+				ret);
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+
+	//intend to check for the loaded SELF formatter and File Writer
+	RPluginList pluginLists;
+	CleanupClosePushL(pluginLists);
+
+	TRAP(ret, iCoreDumpSession.GetPluginListL(pluginLists));
+
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CSELFUserSideTrace::DoCmdLoadPluginsL: Could not get plugin list!, err:%d\n"),
+				ret);
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+
+	//Now we look through the list, until we find our plugin, its a fail
+
+	for (TInt i = 0; i < pluginLists.Count(); i++)
+		{
+		if (pluginLists[i].iUid == KUidSELFFormatterV2 && !(pluginLists[i].iLoaded))
+			{
+			ERR_PRINTF1(
+					_L("SELF Plugin Not loaded !\n"));
+			SetTestStepResult(EFail);
+			User::Leave(KErrNotFound);
+			}
+		}
+
+	for (TInt i = 0; i < pluginLists.Count(); i++)
+		{
+		if (pluginLists[i].iUid == WRITER_UID && !(pluginLists[i].iLoaded))
+			{
+			ERR_PRINTF1(
+								_L("Writer Plugin Not loaded !\n"));
+			SetTestStepResult(EFail);
+			User::Leave(KErrNotFound);
+			}
+		}
+
+	INFO_PRINTF1(_L("SELF Formatter and File Writer loaded successfully"));
+	CleanupStack::PopAndDestroy();//pluginLists	
+	}
+
+/**
+ * Configuring the Core Dump Server and the File Writer
+ */
+void CSELFUserSideTrace::DoCmdConfigurePluginsL()
+	{
+	INFO_PRINTF1(_L("CSELFUserSideTrace DoCmdConfigurePlugins configuring the Core dump server and File Writer plugin"));
+
+	//Configuring the Core Dump Server
+	TRAPD(ret, DoConfigureL(2, CDS_UID.iUid, COptionConfig::ECoreDumpServer,
+			COptionConfig::ETUInt, KPostCrashEventActionPrompt, 1, KNullDesC,
+			4, KNullDesC, 0));
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CSELFUserSideTrace::DoConfigureL for CDS Error %d changing param"),
+				ret);
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+
+	//Configuring the file writer plugin to have a specified crash file name
+	TRAPD(err, DoConfigureL((TInt)(CCrashDataSave::ECoreFilePath),
+			WRITER_UID.iUid, COptionConfig::EWriterPlugin,
+			COptionConfig::ETFileName, KFilePathPrompt, 1, KNullDesC, 0,
+			KCrashFileName, 0));
+
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(_L("CSELFUserSideTrace::DoConfigureL for File Writer Error %d changing param"),
+				err);
+		SetTestStepResult(EFail);
+		User::Leave(err);
+		}
+
+	}
+
+/**
+ * Utility Function to do SELF Configurations
+ */
+void CSELFUserSideTrace::ConfigureSELF(TBool aTracePresent)
+	{
+	INFO_PRINTF2(_L("CProcessCrashWrapper::ConfigureSELF confiugring SELF for Trace presence %d"), aTracePresent);
+
+	if(aTracePresent)
+		{//configure to have trace segments upto have 10KB data
+		DoConfigureL(8, KUidSELFFormatterV2.iUid, COptionConfig::EFormatterPlugin,
+				COptionConfig::ETInt,  KCreateTraceData, 
+				1, KNullDesC, 10, KNullDesC, 0);
+		
+		}
+	else
+		{//configure NOT to have trace segments
+		DoConfigureL(8, KUidSELFFormatterV2.iUid, COptionConfig::EFormatterPlugin,
+				COptionConfig::ETInt,  KCreateTraceData, 
+				1, KNullDesC, 0, KNullDesC, 0);
+		}
+	
+	}
+
+/**
+ * Utility Function to do cleanup activities
+ */
+void CSELFUserSideTrace::CleanupMethod(const TDesC& aDes)
+	{
+	RBuf fileDelete;
+	fileDelete.CreateL(aDes);
+	fileDelete.SetMax();
+	fileDelete.CleanupClosePushL();
+	INFO_PRINTF2(_L("Entered deletion routine for file %S"), &fileDelete);
+	
+	//close the file
+	iSELFFile.Close();
+	
+
+	TInt ret = iFsSession.Delete(fileDelete);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CSELFUserSideTrace::SELF File delete returned error %d"),
+				ret);
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+
+	CleanupStack::PopAndDestroy();//fileDelete
+	
+
+	//delete the buffers
+	if (iSELFPHHeader)
+		{
+		delete [] iSELFPHHeader;
+		iSELFPHHeader = NULL;
+		}
+
+	for (TInt i = 0; i < iPHEntries; i++)
+		{
+		delete [] iDHDRBuffer[i];
+		}	 
+
+	
+	INFO_PRINTF1(_L("Cleanup Done"));
+	}
+
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+TVerdict CSELFUserSideTrace::doTestStepPostambleL()
+	{
+	iCoreDumpSession.Disconnect();
+	User::After(7000000); //ensure we give enough time for session to close
+	iFsSession.Close();
+	return EPass;	
+	}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/liststep.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,341 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// CTestStep derived implementation
+//
+
+
+
+/**
+ @file ListsStep.cpp
+ @internalTechnology
+*/
+#include "liststep.h"
+#include "tcoredumpserversuitedefs.h"
+#include "tcoredumpserversuiteserver.h"
+
+CListsStep::~CListsStep()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CListsStep::CListsStep()
+/**
+ * Constructor
+ */
+	{
+	// **MUST** call SetTestStepName in the constructor as the controlling
+	// framework uses the test step name immediately following construction to set
+	// up the step's unique logging ID.
+	SetTestStepName(KListsStep);
+	}
+
+TVerdict CListsStep::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	   
+	TInt ret = KErrNone;
+	ret = iSess.Connect(); 
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		ERR_PRINTF2(_L("Error %d from iSess->Connect()"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+
+	return TestStepResult();
+	}
+
+
+TVerdict CListsStep::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+	{
+	  
+	if (TestStepResult()==EPass)
+		{	
+		TInt ret = KErrNone;
+
+		__UHEAP_MARK;
+
+		TRAP(ret, ClientAppL());
+		if(KErrNone != ret)
+			{
+			SetTestStepResult(EFail);
+			ERR_PRINTF2(_L("Error %d from CListsStep->ClientAppL()"), ret);
+			}
+		
+		__UHEAP_MARKEND;
+
+		}
+	return TestStepResult();  
+
+	}
+
+
+
+TVerdict CListsStep::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	
+	iSess.Disconnect();
+	User::After(10000000); //ensure we give enough time for session to close
+	return EPass;	
+	}
+
+
+void CListsStep::ClientAppL()
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+	{
+	INFO_PRINTF1(_L("Starting Lists Test Suite") );
+	ListProcessesL();
+	ListThreadsL();
+	ListExecutables();
+    ListPlugins();
+	}
+
+
+void CListsStep::ListProcessesL()
+/**
+ * @return void
+ * This tests we can succesfully list the processes and that the returned values make sense
+ */
+	{
+	INFO_PRINTF1(_L("Lists Test Suite: ListProcesses") );
+
+	if (TestStepResult()==EPass)
+		{
+
+		RProcessPointerList procList;
+		TCleanupItem cleanupProcList(CTe_coredumpserverSuite::CleanupProcessList, (TAny*)&procList);
+		CleanupStack::PushL(cleanupProcList);
+
+		TRAPD( ret, iSess.GetProcessesL( procList ) );
+
+		if( KErrNone != ret )
+			{
+			SetTestStepResult(EFail);
+			ERR_PRINTF2(_L("Error %d from iSess.GetProcessesL()"), ret);
+			return;
+			}
+
+		if( procList.Count() == 0 )
+			{
+			SetTestStepResult(EFail);
+			ERR_PRINTF1(_L("Error : GetProcessesL() returned empty list") );
+			return;
+			}
+		else
+			{
+			RProcess thisProc;
+			TInt i;
+			for( i=0; i < procList.Count(); i++ )
+				{
+				if( procList[i]->Id() == thisProc.Id() )
+					{
+					break;
+					}
+				}
+
+			if( i == procList.Count() )
+				{
+				SetTestStepResult(EFail);
+				ERR_PRINTF1(_L("Error : This process could not be found in GetProcessesL() list") );
+				return;
+				}
+			}
+
+		CleanupStack::PopAndDestroy();
+		}
+	}
+
+void CListsStep::ListThreadsL()
+/**
+ * @return void
+ * This checks the threads are listed correctly and the returned values make sense
+ */
+	{
+	INFO_PRINTF1(_L("Lists Test Suite: ListThreads") );
+
+	if (TestStepResult()==EPass)
+		{
+
+		RThreadPointerList threadList;
+		TCleanupItem cleanupThreadList(CTe_coredumpserverSuite::CleanupPluginList, (TAny*)&threadList);
+		CleanupStack::PushL(cleanupThreadList);
+
+		TRAPD( ret, iSess.GetThreadsL( threadList ) );
+		if( KErrNone != ret )
+			{
+			SetTestStepResult(EFail);
+			ERR_PRINTF2(_L("Error %d from iSess.GetThreadsL()"), ret);
+			return;
+			}
+
+		if( threadList.Count() == 0 )
+			{
+			SetTestStepResult(EFail);
+			ERR_PRINTF1(_L("Error : GetThreadsL() returned empty list") );
+			return;
+			}
+		else
+			{
+			RThread thisThread;
+			TInt i;
+			for( i=0; i < threadList.Count(); i++ )
+				{
+				if( threadList[i]->Id() == thisThread.Id() )
+					{
+					break;
+					}
+				}
+
+			if( i == threadList.Count() )
+				{
+				SetTestStepResult(EFail);
+				ERR_PRINTF1(_L("Error : This thread could not be found in GetThreadsL() list/n") );
+				return;
+				}
+			}
+
+		CleanupStack::PopAndDestroy();		
+
+		}
+	}
+
+void CListsStep::ListExecutables()
+/**
+ * @return void
+ * This tests we can succesfully list the executables and that the returned values make sense
+ */
+	{
+	INFO_PRINTF1(_L("Lists Test Suite: ListExecutables") );
+
+	if (TestStepResult()==EPass)
+		{
+
+		RExecutablePointerList execList;
+
+		TRAPD( err, iSess.GetExecutablesL( execList ) );
+
+		if(err != KErrNone)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Error %d from iSess.GetExecutablesL()/n"), err);
+			return;
+			}
+
+		if( execList.Count() == 0 )
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF1(_L("Error : GetExecutablesL() returned empty list/n") );
+			return;
+			}
+		else
+			{
+			RProcess thisProc;
+			TInt i;
+			for( i=0; i < execList.Count(); i++ )
+				{
+				if( execList[i]->Name() == thisProc.FileName() )
+					{
+					break;
+					}
+				}
+
+			if( i == execList.Count() )
+				{
+				SetTestStepResult(EFail);
+				INFO_PRINTF1(_L("Error : This executable could not be found in GetExecutablesL() list/n") );
+				return;
+				}
+			}
+
+		execList.ResetAndDestroy();
+		execList.Close();
+
+		}
+	}
+
+void CListsStep::ListPlugins()
+/**
+ * @return void
+ * This tests we can succesfully list the executables and that the returned values make sense
+ */
+	{
+	INFO_PRINTF1(_L("Lists Test Suite: ListPlugins") );
+
+	if (TestStepResult()==EPass)
+		{
+
+		RPluginList pluginList;
+
+		TRAPD( err, iSess.GetPluginListL( pluginList ) );
+
+		if(err != KErrNone)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Error %d from iSess.GetPluginsL()"), err);
+			return;
+			}
+
+		if( pluginList.Count() == 0 )
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF1(_L("Error : GetPluginsL() returned empty list") );
+			return;
+			}
+		else
+			{
+             
+			TInt i;
+			for( i=0; i < pluginList.Count(); i++ )
+				{
+				if( (pluginList[i].iUid == DEXEC_UID) || (pluginList[i].iUid == SELF_UID) )
+					{
+					break;
+					}
+				}
+
+			if( i == pluginList.Count() )
+				{
+				SetTestStepResult(EFail);
+				INFO_PRINTF1(_L("Error : DEXC nor SELF plugin could not be found in GetPluginsL() list") );
+				return;
+				}
+			}
+
+		pluginList.Reset();
+		pluginList.Close();
+
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/parameterstep.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,711 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example CTestStep derived implementation
+//
+
+
+
+/**
+ @file ParametersStep.cpp
+ @internalTechnology
+*/
+#include "parameterstep.h"
+#include "tcoredumpserversuitedefs.h"
+#include <e32property.h>
+#include <crashdatasave.h>
+#include <e32std.h>
+#include <coredumpserverapi.h>
+
+CParametersStep::~CParametersStep()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CParametersStep::CParametersStep()
+/**
+ * Constructor
+ */
+	{
+	// **MUST** call SetTestStepName in the constructor as the controlling
+	// framework uses the test step name immediately following construction to set
+	// up the step's unique logging ID.
+	SetTestStepName(KParametersStep);
+	}
+
+TVerdict CParametersStep::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{	   
+	TInt ret = KErrNone;
+	ret = iSess.Connect(); 
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		ERR_PRINTF2(_L("Error %d from iSess->Connect()"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+	
+	INFO_PRINTF1(_L("Successfully connected session to the Core Dump Server"));
+	
+	ret = iSecSess.Connect(securityServerVersion); 
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		ERR_PRINTF2(_L("Error %d from iSecSess->Connect()"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+	
+	INFO_PRINTF1(_L("Successfully connected session to the debug security server"));
+	
+	ret = iFs.Connect();
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		ERR_PRINTF2(_L("Error %d from iFs->Connect()"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+	
+	INFO_PRINTF1(_L("Successfully connected session to the file server"));
+	
+	return TestStepResult();
+	}
+
+TVerdict CParametersStep::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+	{
+	if (TestStepResult()==EPass)
+		{	
+		TInt ret = KErrNone;
+
+		__UHEAP_MARK;		
+		
+		TRAP(ret, ClientAppL());
+		if(KErrNone != ret)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Error %d from CParametersStep->ClientAppL()"), ret);
+			}		
+		
+		//Make sure its dead
+		_LIT(KCrashApp, "crash");	
+		KillCrashAppL(KCrashApp);
+
+		__UHEAP_MARKEND;
+
+		}
+	return TestStepResult(); 
+	}
+
+void CParametersStep::ClientAppL()
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+	{
+	INFO_PRINTF1(_L("Starting CDS Parameters Test Suite") );
+	INFO_PRINTF1(_L("This tests two scenarios: When the main thread crashes and when a child thread crashes"));
+	INFO_PRINTF1(_L("In each case we test all possible CDS config values to make sure that the correct things are happening \n\n"));
+	
+	//Here we are testing the post processing conditions when a main thread crashes and when a child thread crashes
+	CrashChildThreadAndTestPostProcL();
+	CrashMainThreadAndTestPostProcL();
+	
+	//Now we test the preprocessing values
+	CrashChildThreadAndTestPreProcL();	
+	}
+void CParametersStep::CrashChildThreadAndTestPreProcL()
+/**
+ * @return void
+ * Tests the pre processing values do the right thing when we crash a child thread
+ */
+	{
+	if (TestStepResult()==EPass)
+		{
+		INFO_PRINTF1(_L("Testing all pre proccessing options for when child thread crashes"));
+		
+		_LIT(KCrashAppParams, "-m1 -d2 -c2"); //Will have one child thread that crashes after 2 sec
+	
+		//1 = suspend thread, 2 = suspend process
+		for(TInt preVal = 1; preVal <3; preVal++ )
+			{
+			INFO_PRINTF3(_L("************* New Crash (Main thread) CDS PreProc val = %d Post Proc val = %d ************* "), preVal, 0);
+			//Call crash app
+			GenerateAndHandleCrashL(KCrashAppParams, 0, preVal);
+			TProcessId pid = IsCrashAppAliveL();
+	
+			if(preVal == 1)
+				{
+				//Here the child should be frozen and main thread still running
+				if(IsCrashAppMainThreadRunningL())
+					{
+					INFO_PRINTF1(_L("Main thread running as expected"));
+					}
+				else
+					{
+					SetTestStepError(EFail);
+					ERR_PRINTF1(_L("Main thread is expected to be running and it is not"));
+					User::Leave(KErrGeneral);
+					}
+				}
+			else if(preVal == 2)
+				{
+				if(!IsCrashAppMainThreadRunningL())
+					{
+					INFO_PRINTF1(_L("Main thread frozen as expected"));
+					}
+				else
+					{
+					SetTestStepError(EFail);
+					ERR_PRINTF1(_L("Main thread is expected to be frozen and is not"))	;
+					User::Leave(KErrGeneral);
+					}
+				}
+			
+			
+			//Disconnect the CDS' handle on this exe
+			if(pid)
+				{
+				iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, EFalse);
+				INFO_PRINTF1(_L("Attaching DSS to executable"));
+				User::LeaveIfError(iSecSess.AttachExecutable(KCrashAppFileName, EFalse));
+				ResumeProcessL(pid);	
+				User::LeaveIfError(iSecSess.DetachExecutable(KCrashAppFileName));
+				
+				_LIT(KCrashApp, "crash");
+				KillCrashAppL(KCrashApp);
+				User::After(2000000);
+				
+				if(IsCrashAppAliveL())
+					{
+					SetTestStepResult( EFail );
+					ERR_PRINTF1(_L("Failed to kill app"));
+					User::Leave(KErrGeneral);
+					}
+				}
+			
+			
+			}
+		}
+	
+	}
+
+void CParametersStep::CrashMainThreadAndTestPostProcL()
+/**
+ * @return void
+ * Tests the CDS post processing when the main thread of the crash app dies. 
+ * In all cases the app should be dead except when we do not resume the process (option 0)
+ */
+	{
+	if (TestStepResult()==EPass)
+		{
+		TInt cdsPreConfigVal = 2; //Suspend process (this is irrelevant really, we will check this seperately)
+		
+		INFO_PRINTF1(_L("Testing all post proccessing options for when main thread crashes (in all cases crash app should be gone)"));
+		INFO_PRINTF1(KPostCrashEventActionPrompt);	
+		
+		_LIT(KCrashAppParams, "-s -d1 -c2"); //Will have a second thread to main, and main will crash after 1 second
+	
+		TInt cdsPostConfigVal = 8;
+		do
+			{
+			//Right shift 1 to cycle 4,2,1,0
+			cdsPostConfigVal>>=1;
+		
+			INFO_PRINTF3(_L("************* New Crash (Main thread) CDS PreProc val = %d Post Proc val = %d ************* "), cdsPreConfigVal, cdsPostConfigVal);
+	
+			//Call crash app and handling with range of post processing values (0,1,2,4 inc)
+			GenerateAndHandleCrashL(KCrashAppParams, cdsPostConfigVal, cdsPreConfigVal);	
+			//Let the process be resumed or killed or whatever
+			User::After( 4500000 );				
+						
+			//Now we validate the post processing values
+			TProcessId pid = IsCrashAppAliveL();
+			if(pid)
+				{
+				//If post proc = 0 (suspend) it should still be alive. we need to resume it all so we can kill it
+				if(cdsPostConfigVal == 0)
+					{
+					INFO_PRINTF1(_L("CDS configured not to resume process and it is still alive as expected"));		
+					
+					//Disconnect the CDS' handle on this exe
+					iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, EFalse);
+					INFO_PRINTF1(_L("Attaching DSS to executable"));
+					User::LeaveIfError(iSecSess.AttachExecutable(KCrashAppFileName, EFalse));
+					ResumeProcessL(pid);	
+					User::LeaveIfError(iSecSess.DetachExecutable(KCrashAppFileName));			
+					}
+				else 
+					{
+					RDebug::Printf("Error is here ****************");
+					SetTestStepError(EFail);
+					ERR_PRINTF2(_L("Expected crash app to be dead and it wasn't. Crash was in main thread and CDS post processing was configured at %d"), cdsPostConfigVal);
+					User::Leave(KErrGeneral);
+					}
+				}
+			else if(cdsPostConfigVal ==0)
+				{
+				SetTestStepError(EFail);
+				ERR_PRINTF2(_L("Expected crash app to be alive and it wasn't. Crash was in main thread and CDS post processing was configured at %d"), cdsPostConfigVal);
+				User::Leave(KErrGeneral);
+				}
+			else
+				{
+				INFO_PRINTF2(_L("Crash app died as expected with post proc param %d"), cdsPostConfigVal);
+				}		
+			
+			_LIT(KCrashApp, "crash");
+			KillCrashAppL(KCrashApp);
+			User::After(3000000 );
+			
+			if(IsCrashAppAliveL())
+				{
+				SetTestStepResult( EFail );
+				ERR_PRINTF1(_L("Failed to kill app"));
+				User::Leave(KErrGeneral);
+				}
+			}
+		while(cdsPostConfigVal > 0);
+		}
+	}
+
+void CParametersStep::CrashChildThreadAndTestPostProcL()
+/**
+ * @return void 
+ * Tests the CDS post processing when the child thread of the crash app dies. The pre processing
+ * step is suspend process
+ */
+	{
+	if (TestStepResult()==EPass)
+		{
+		TInt cdsPreConfigVal = 2; //Suspend process (this is irrelevant really, we will check this seperately)
+		
+		INFO_PRINTF1(_L("Testing all post proccessing options for when main thread crashes (in all cases crash app should be gone)"));
+		INFO_PRINTF1(KPostCrashEventActionPrompt);	
+		
+		_LIT(KCrashAppParams, "-m1 -d1 -c2"); //Will have one child thread that crashes after 1 sec
+	
+		TInt cdsPostConfigVal = 8;
+		do
+			{
+			//Right shift 1 to cycle 4,2,1,0
+			cdsPostConfigVal>>=1;
+			
+			INFO_PRINTF3(_L("************* New Crash (Child thread) CDS PreProc val = %d Post Proc val = %d ************* "),cdsPreConfigVal, cdsPostConfigVal);
+			
+			//Call crash app and handling with range of post processing values (0,1,2,4 inc)
+			GenerateAndHandleCrashL(KCrashAppParams, cdsPostConfigVal, cdsPreConfigVal);	
+			//Wait for crashapp to be resumed or killed or whatever
+			User::After( 1000000 );				
+			
+			TProcessId pid = IsCrashAppAliveL();
+			
+			if(cdsPostConfigVal == 0)//do nothing
+				{
+				//In this case the whole process is suspended
+				if(pid && !IsCrashAppMainThreadRunningL())
+					{
+					INFO_PRINTF1(_L("Crash app alive and main thread suspended as expected"));				
+					}						
+				else
+					{
+					SetTestStepResult( EFail );
+					ERR_PRINTF1(_L("Crash app was dead - not expected"));
+					User::Leave(KErrGeneral);
+					}
+				}
+			else if(cdsPostConfigVal == 1)//resume thread
+				{
+				//Only thread is resumed, not whole process
+				if(pid && !IsCrashAppMainThreadRunningL())
+					{
+					INFO_PRINTF1(_L("Crash app alive and main thread suspended as expected"));				
+					}						
+				else
+					{
+					SetTestStepResult( EFail );
+					ERR_PRINTF1(_L("Crash app was dead - not expected"));
+					User::Leave(KErrGeneral);
+					}
+				}
+			else if(cdsPostConfigVal == 2)//resume proc
+				{
+				//Only thread is resumed, not whole process
+				if(pid && IsCrashAppMainThreadRunningL())
+					{
+					INFO_PRINTF1(_L("Crash app alive and main thread running as expected"));				
+					}						
+				else
+					{
+					SetTestStepResult( EFail );
+					ERR_PRINTF1(_L("Crash app main thread not running - not expected"));
+					User::Leave(KErrGeneral);
+					}
+				}
+			else if(cdsPostConfigVal == 4)//kill proc
+				{
+				if(pid)				
+					{
+					SetTestStepResult( EFail );
+					ERR_PRINTF1(_L("Process is still alive but should be dead"));	
+					User::Leave(KErrGeneral);
+					}
+				else
+					{
+					INFO_PRINTF1(_L("Process dead as expected"));
+					}				
+				}
+				
+			//Kill the process if its still running
+			if(pid)
+				{
+				
+				//Disconnect the CDS' handle on this exe
+				iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, EFalse);
+				INFO_PRINTF1(_L("Attaching DSS to executable"));
+				User::LeaveIfError(iSecSess.AttachExecutable(KCrashAppFileName, EFalse));
+				ResumeProcessL(pid);	
+				User::LeaveIfError(iSecSess.DetachExecutable(KCrashAppFileName));
+				
+				_LIT(KCrashApp, "crash");
+				KillCrashAppL(KCrashApp);
+				User::After(2000000);
+				
+				if(IsCrashAppAliveL())
+					{
+					SetTestStepResult( EFail );
+					ERR_PRINTF1(_L("Failed to kill app"));
+					User::Leave(KErrGeneral);
+					}
+				}		
+			}
+		while(cdsPostConfigVal > 0);
+		}
+	
+	}
+
+
+
+void CParametersStep::ResumeProcessL(TUint64 aPid)
+/**
+Called to resume all the threads of the specified process. CCoreCrashHandler executes it as a post-processing action.
+@param aPid ID of process to be resumed
+@leave err one of the system wide error codes
+iSecSess must be attached to the executable in question
+*/
+	{
+	INFO_PRINTF1(_L("Resuming process"));
+	
+	//Get the threads we wish to resume
+	RThreadPointerList threadList;
+    TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupThreadList, (TAny*)&threadList);
+    CleanupStack::PushL(cleanupProcesses);	
+	
+	iSess.GetThreadsL(threadList, aPid);	
+
+    TInt err = KErrNone;
+    //first resume child threads
+    TInt looperr = KErrNone;
+    for(TInt j = 1; j < threadList.Count(); j++)
+        {   
+        looperr = iSecSess.ResumeThread( threadList[j]->Id() );
+        if( (looperr != KErrNone) && (looperr != KErrNotFound) )
+            {
+            err = looperr;
+            ERR_PRINTF2(_L("CParametersStep::ResumeProcessL - unable to resume thread! err:%d"), err);
+            }
+        }
+
+    looperr = KErrNone;
+    //then resume the main thread
+    if(threadList.Count())
+        {
+        INFO_PRINTF2(_L("resuming main thread:%Ld\n"), threadList[0]->Id());
+        looperr = iSecSess.ResumeThread(threadList[0]->Id());
+        }
+
+    if( (looperr != KErrNone) && (looperr != KErrNotFound) )
+        {
+        err = looperr;
+        ERR_PRINTF2(_L("CCoreDumpSession::ResumeProcessL - unable to resume main thread! err:%d"), err); 
+        }
+    CleanupStack::PopAndDestroy(&threadList);
+    User::LeaveIfError(err);
+	}
+
+TProcessId CParametersStep::IsCrashAppAliveL()
+/**
+ * @return TInt PID of process if alive, null if not
+ * Scans the process list looking for crash app. Returns true if its found
+ */
+	{
+	TProcessId pid = NULL; 
+		
+	RProcessPointerList procList;
+	TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupProcessList, (TAny*)&procList);
+	CleanupStack::PushL(cleanupProcesses);
+	
+	iSess.GetProcessesL( procList );			
+
+	for(TInt i=0; i < procList.Count(); i++ )
+	{				
+		if(procList[i]->Name() == KCrashAppFileName)
+		{
+		INFO_PRINTF1(_L("Found the crash app"));
+		pid = procList[i]->Id();	
+		}
+	}
+	CleanupStack::PopAndDestroy(&procList);
+	
+	return pid;
+	
+	}
+
+void CParametersStep::KillCrashAppL(const TDesC& aProcessName)
+/**
+ * @return void
+ * Kills specified process
+ */
+	{	
+	_LIT(KAsterisk, "*");
+	HBufC* buf = HBufC::NewLC(1+aProcessName.Length());
+	TPtr bufPtr = buf->Des();
+	bufPtr.Append(aProcessName);
+	bufPtr.Append(KAsterisk);
+	
+	TFindProcess finder(bufPtr);
+	TFullName fullname;
+	RProcess process;
+	while(finder.Next(fullname) == KErrNone)
+		{
+		TInt err = process.Open(finder);
+		if(err == KErrNone)
+			{
+			INFO_PRINTF1(_L("Killing process"));
+			INFO_PRINTF1(process.Name());
+			process.Kill(KErrNone);
+			process.Close();	        
+			}
+		else
+			{
+			ERR_PRINTF2(_L("Failed to kill process. Error = %d "), err);
+			}
+		}
+	CleanupStack::PopAndDestroy(buf); 
+	}
+
+void CParametersStep::GenerateAndHandleCrashL(const TDesC& aCrashAppParameters, 
+											 const TUint& aCDSPostProcParam,
+											 const TUint& aCDSPreProcParam)
+/**
+ * @return void
+ * This will:
+ * 1. Load Formatter
+ * 2. Load writer
+ * 3. Configure CDS to post process after crash		
+ * 4. Observe the crash process
+ * 5. Start the crash process
+ * 6. Monitor the crash progress until its dead
+ */
+	{		
+	//Start the process that we intend to crash....
+	RProcess crashProcess;
+	CleanupClosePushL(crashProcess);
+	
+	TInt ret = crashProcess.Create( KCrashAppFileName, aCrashAppParameters);
+	if(ret != KErrNone)
+		{
+		ERR_PRINTF2(_L("Error %d from RProcess .Create(z:\\sys\\bin\\crashapp.exe)/n"), ret);
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+
+	//Now we configure CDS and writer			
+	INFO_PRINTF2(_L("Configuring pre processing of CDS with %d"), aCDSPreProcParam);
+	DoConfigureL(EPreCrashEventAction, CDS_UID.iUid, COptionConfig::ECoreDumpServer, COptionConfig::ETUInt, KNullDesC,
+				 1, KNullDesC, aCDSPreProcParam, KNullDesC);	
+	
+	INFO_PRINTF2(_L("Configuring post processing of CDS with %d"), aCDSPostProcParam);	
+	DoConfigureL(EPostCrashEventAction, CDS_UID.iUid, COptionConfig::ECoreDumpServer, COptionConfig::ETUInt, KNullDesC,
+				 1, KNullDesC, aCDSPostProcParam, KNullDesC );	
+
+   	INFO_PRINTF1(_L("Observing process"));
+	iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue);
+	
+	crashProcess.Resume();
+	CleanupStack::PopAndDestroy(&crashProcess);	
+	
+	//This waits for the formatting to complete
+	MonitorProgressL();	
+	}
+
+void CParametersStep::MonitorProgressL()
+/**
+ * @return void
+ * This method monitors the RProperty for the crash progress. There are several states of this but we are
+ * only interested in the start and finish of these properties
+ */
+	{
+	RProperty crashProgress;
+	User::LeaveIfError(crashProgress.Attach(KCoreDumpServUid, ECrashProgress));	
+	
+	TBuf<50> crashProg;			
+
+	TRequestStatus status;
+	crashProgress.Subscribe(status);
+    
+	INFO_PRINTF1(_L("CDS has started processing"));			
+	//Now we wait until its finished
+	do
+		{			
+		User::WaitForRequest(status);		
+		crashProgress.Subscribe(status);
+
+		User::LeaveIfError(crashProgress.Get(crashProg ));
+		LOG_MSG("Found property and it was:");
+		}
+	while(crashProg != KEndOfProcessing);
+	
+	INFO_PRINTF1(_L("CDS has finished processing"));			
+	
+	}
+
+TInt CParametersStep::GetNumberOfProccessesL()
+/**
+ * @return TInt
+ * Utility function to get the number of proccesses running
+ */
+	{		
+	
+	RProcessPointerList procList;
+    TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupProcessList, (TAny*)&procList);
+    CleanupStack::PushL(cleanupProcesses);
+
+	iSess.GetProcessesL(procList);	
+	TInt numProcs = procList.Count();	
+	
+	CleanupStack::PopAndDestroy();	
+
+	return numProcs;	
+	
+	}
+
+TInt CParametersStep::GetNumberThreadsL()
+/**
+ * @return TInt
+ * Utility function to get the number of proccesses running
+ */
+	{	
+	RThreadPointerList threadList;
+    TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupThreadList, (TAny*)&threadList);
+    CleanupStack::PushL(cleanupProcesses);
+	
+	iSess.GetThreadsL(threadList);	
+	TInt numThreads = threadList.Count();	
+	
+	CleanupStack::PopAndDestroy();	
+
+	return numThreads;
+	}
+
+void CParametersStep::DoConfigureL(const TUint32& aIndex, 
+ 	    const TUint32& aUID, 
+        const COptionConfig::TParameterSource& aSource, 
+        const COptionConfig::TOptionType& aType, 
+        const TDesC& aPrompt, 
+        const TUint32& aNumOptions,
+        const TDesC& aOptions,
+        const TInt32& aVal, 
+        const TDesC& aStrValue )
+/**
+* @return void
+* @param aIndex Internal index to the component that owns the object
+* @param aUID UID of the component that owns the object
+* @param aSource Type of component that owns the object
+* @param aType Type of parameter
+* @param aPrompt Prompt to present to user 
+* @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
+* @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
+* @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
+* @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
+*/
+	{
+	COptionConfig * config;	
+	
+	config = COptionConfig::NewL( aIndex,
+		aUID,
+		aSource,
+		aType,
+		aPrompt,
+		aNumOptions,
+		aOptions,
+		aVal,
+		aStrValue);
+	
+	CleanupStack::PushL(config);
+	
+	//Configure now...
+	TRAPD(ret, iSess.SetConfigParameterL(*config) );
+	if(ret != KErrNone)
+		{
+		ERR_PRINTF2(_L("Error %d changing param"), ret );
+		SetTestStepResult(EFail);
+		User::Leave(ret);
+		}
+	
+	CleanupStack::PopAndDestroy(config);
+	}
+
+TBool CParametersStep::IsCrashAppMainThreadRunningL()
+/**
+ * Reads the main threads property to make sure its being updated
+ */
+	{
+	TInt mainThreadCounter1 = 0;
+	TInt mainThreadCounter2 = 0;
+	User::LeaveIfError(RProperty::Get(KCrashAppUid, 0, mainThreadCounter1));
+	User::After(1500000);
+	User::LeaveIfError(RProperty::Get(KCrashAppUid, 0, mainThreadCounter2));
+	return (mainThreadCounter2 > mainThreadCounter1);
+	}
+
+TVerdict CParametersStep::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	iSess.Disconnect();
+	iSecSess.Close();
+	iFs.Close();
+	User::After(5000000); //ensure we give enough time for session to close
+	return TestStepResult();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/tcoredumpserversuiteserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,235 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example file/test code to demonstrate how to develop a TestExecute Server
+// Developers should take this project as a template and substitute their own
+// for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
+// in the process of the client. The client initialises the server by calling the
+// one and only ordinal.
+//
+
+
+
+/**
+ @file Te_coredumpserverSuiteServer.cpp
+ @internalTechnology
+*/
+
+#include "tcoredumpserversuiteserver.h"
+#include "DEXCusersidestep.h"
+#include "liststep.h"
+#include "parameterstep.h"
+#include "SELFUsersidestep.h"
+#include "SELFpluginstep.h"
+#include "DEXCpluginstep.h"
+#include "testformatterusersidestep.h"
+#include "CDSconnectionstep.h"
+#include "CDStokenstep.h"
+#include "utracestep.h"
+#include "SELFusersidetrace.h"
+#include "testsignaling.h"
+
+_LIT(KServerName,"Te_coredumpserverSuite");
+CTe_coredumpserverSuite* CTe_coredumpserverSuite::NewL()
+/**
+ * @return - Instance of the test server
+ * Same code for Secure and non-secure variants
+ * Called inside the MainL() function to create and start the
+ * CTestServer derived server.
+ */
+	{
+	CTe_coredumpserverSuite * server = new (ELeave) CTe_coredumpserverSuite();
+	CleanupStack::PushL(server);
+
+	server->ConstructL(KServerName);
+	CleanupStack::Pop(server);
+	return server;
+	}
+
+
+// Secure variants much simpler
+// For EKA2, just an E32Main and a MainL()
+LOCAL_C void MainL()
+/**
+ * Secure variant
+ * Much simpler, uses the new Rendezvous() call to sync with the client
+ */
+	{
+	// Leave the hooks in for platform security
+#if (defined __DATA_CAGING__)
+	RProcess().DataCaging(RProcess::EDataCagingOn);
+	RProcess().DataCaging(RProcess::ESecureApiOn);
+#endif
+	CActiveScheduler* sched=NULL;
+	sched=new(ELeave) CActiveScheduler;
+	CActiveScheduler::Install(sched);
+	CTe_coredumpserverSuite* server = NULL;
+	// Create the CTestServer derived server
+	TRAPD(err,server = CTe_coredumpserverSuite::NewL());
+	if(!err)
+		{
+		// Sync with the client and enter the active scheduler
+		RProcess::Rendezvous(KErrNone);
+		sched->Start();
+		}
+	delete server;
+	delete sched;
+	}
+
+
+
+GLDEF_C TInt E32Main()
+/**
+ * @return - Standard Epoc error code on process exit
+ * Secure variant only
+ * Process entry point. Called by client using RProcess API
+ */
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if(cleanup == NULL)
+		{
+		return KErrNoMemory;
+		}
+	TRAPD(err,MainL());
+	delete cleanup;
+	__UHEAP_MARKEND;
+	return err;
+    }
+
+
+CTestStep* CTe_coredumpserverSuite::CreateTestStep(const TDesC& aStepName)
+/**
+ * @return - A CTestStep derived instance
+ * Secure and non-secure variants
+ * Implementation of CTestServer pure virtual
+ */
+	{	
+	INFO_PRINTF1(aStepName);
+	
+	CTestStep* testStep = NULL;
+              if(aStepName == KDEXECUserSideStep)   
+                            testStep = new CDEXECUserSideStep();
+              else if(aStepName == KListsStep)
+                            testStep = new CListsStep();
+              else if(aStepName == KParametersStep)
+                            testStep = new CParametersStep();
+              else if(aStepName == KSELFUserSideStep)
+                            testStep = new CSELFUserSideStep();
+              else if(aStepName == KSELFPluginStep)
+            	  			testStep = new CSELFPluginStep();
+              else if(aStepName == KDEXECPluginStep)
+            	  			testStep = new CDEXECPluginStep();
+              else if(aStepName == KTestFormatterUserSideStep)
+            	  			testStep = new CTestFormatterUserSideStep();
+              else if(aStepName == KCDSConnectionsStep)
+            	  			testStep = new CCDSConnectionsStep();
+              else if(aStepName == KTokenStep)
+            	  			testStep = new CTokenStep();
+              else if(aStepName == KUTraceUserSide)
+            	  			testStep = new CUTraceStep();
+              else if(aStepName == KSELFUserSideTrace)
+            	  		testStep = new CSELFUserSideTrace();
+              else if(aStepName == KTestSignaling)
+                  testStep = new CTestSignaling();
+              
+	return testStep;
+	}
+
+void CTe_coredumpserverSuite::CleanupProcessList(TAny *aArray)
+/**
+ * Cleanup operation for RProcessPointerList
+ */
+	{
+		RProcessPointerList *processList = static_cast<RProcessPointerList*> (aArray);
+	    processList->ResetAndDestroy();
+	    processList->Close();
+	}
+void CTe_coredumpserverSuite::CleanupPluginList(TAny *aArray)
+/**
+ * Cleanup operation for RProcessPointerList
+ */
+	{
+		RPluginPointerList *pluginList = static_cast<RPluginPointerList*> (aArray);
+		pluginList->ResetAndDestroy();
+		pluginList->Close();
+	}
+
+void CTe_coredumpserverSuite::CleanupThreadList(TAny *aArray)
+/**
+ * Cleanup operation for RThreadPointerList
+ */
+	{
+		RThreadPointerList *threadList = static_cast<RThreadPointerList*> (aArray);
+		threadList->ResetAndDestroy();
+		threadList->Close();
+	}
+
+CDir* CTe_coredumpserverSuite::DoesFileExistL(const TDesC &aExpectedFile, TFindFile &aFileFinder)
+    {
+    TParse fileParse;
+    fileParse.Set(aExpectedFile, NULL, NULL);
+    
+    TBuf<63> filePattern;
+    filePattern = fileParse.Name();
+    filePattern.Append(_L("*"));
+
+    CDir* fileList = NULL;
+    aFileFinder.FindWildByDir(filePattern, fileParse.DriveAndPath(), fileList);
+    
+    if(fileList == NULL)
+        {
+        User::Leave(KErrNotFound);
+        }
+
+    return fileList;
+    }
+
+TBool CTe_coredumpserverSuite::FileStartsWith(const TDesC& aRoot, const TDesC& aFilename )
+/*
+ * @return - If the file starts with the root
+ * Takes a descriptor and see if it starts with the root
+ */
+	{	
+	if(aFilename.Length() < aRoot.Length())
+		{
+		return EFalse;
+		}
+
+	TInt rootLength = aRoot.Length();
+	TInt cnt = 0;
+	
+	while(cnt < rootLength)
+		{
+		
+		if(aRoot[cnt] != aFilename[cnt])
+			{			
+			return EFalse;
+			}
+		cnt++;	
+		}
+	LOG_MSG("leaving");
+	return ETrue;
+	}
+
+void CTe_coredumpserverSuite::CleanupBufferArray(TAny *aArray)
+	{
+		CDesC16ArrayFlat* buffArray = static_cast<CDesC16ArrayFlat*> (aArray);
+		TInt cntr = 0;
+		for(cntr =0; cntr<buffArray->MdcaCount(); cntr++)
+			{
+			TPtrC16 ptr = (*buffArray)[cntr];
+			}
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/tcoredumpserversuitestepbase.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,69 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file Te_coredumpserverSuiteStepBase.cpp
+ @internalTechnology
+*/
+
+#include "tcoredumpserversuitestepbase.h"
+#include "tcoredumpserversuitedefs.h"
+
+// Device driver constants
+
+TVerdict CTe_coredumpserverSuiteStepBase::doTestStepPreambleL()
+/**
+ * @return - TVerdict
+ * Implementation of CTestStep base class virtual
+ * It is used for doing all initialisation common to derived classes in here.
+ * Make it being able to leave if there are any errors here as there's no point in
+ * trying to run a test step if anything fails.
+ * The leave will be picked up by the framework.
+ */
+	{
+
+	// process some common pre setting to test steps then set SetTestStepResult to EFail or Epass.
+	INFO_PRINTF1(_L("Please delete this line or modify me!! I am in doTestStepPreambleL() of the class CTe_coredumpserverSuiteStepBase!"));
+	SetTestStepResult(EPass);
+	return TestStepResult();
+	}
+
+TVerdict CTe_coredumpserverSuiteStepBase::doTestStepPostambleL()
+/**
+ * @return - TVerdict
+ * Implementation of CTestStep base class virtual
+ * It is used for doing all after test treatment common to derived classes in here.
+ * Make it being able to leave
+ * The leave will be picked up by the framework.
+ */
+	{
+
+	// process some common post setting to test steps then set SetTestStepResult to EFail or Epass.
+	INFO_PRINTF1(_L("Please delete this line or modify me!! I am in doTestStepPostambleL() of the class CTe_coredumpserverSuiteStepBase!"));
+	//SetTestStepResult(EPass);  // or EFail
+	return TestStepResult();
+	}
+
+CTe_coredumpserverSuiteStepBase::~CTe_coredumpserverSuiteStepBase()
+	{
+	}
+
+CTe_coredumpserverSuiteStepBase::CTe_coredumpserverSuiteStepBase()
+	{
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/testformatterusersidestep.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,114 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example CTestStep derived implementation
+//
+
+
+
+/**
+ @file SELFStep.cpp
+ @internalTechnology
+*/
+#include "testformatterusersidestep.h"
+#include "tcoredumpserversuitedefs.h"
+#include "tcoredumpserversuiteserver.h"
+#include "optionconfig.h"
+
+CTestFormatterUserSideStep::~CTestFormatterUserSideStep()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CTestFormatterUserSideStep::CTestFormatterUserSideStep()
+/**
+ * Constructor
+ */
+	{
+	// **MUST** call SetTestStepName in the constructor as the controlling
+	// framework uses the test step name immediately following construction to set
+	// up the step's unique logging ID.
+	SetTestStepName(KTestFormatterUserSideStep);
+	}
+
+TVerdict CTestFormatterUserSideStep::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	   
+	TInt ret = KErrNone;
+	ret = iSess.Connect(); 
+	if(ret != KErrNone)
+		{
+		SetTestStepResult( EFail );
+		INFO_PRINTF2(_L("Error %d from iSess->Connect()/n"), ret);
+		}	
+	else
+		{
+		SetTestStepResult(EPass);
+		}
+
+	return TestStepResult();
+	}
+
+TVerdict CTestFormatterUserSideStep::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+	{
+	if (TestStepResult()==EPass)
+		{	
+		TInt ret = KErrNone;
+
+		__UHEAP_MARK;
+
+		TRAP(ret, ClientAppL());
+		if(KErrNone != ret)
+			{
+			SetTestStepResult(EFail);
+			INFO_PRINTF2(_L("Error %d from CTestFormatterUserSideStep->ClientAppL()"), ret);
+			}
+		
+		__UHEAP_MARKEND;
+
+		}
+	return TestStepResult();  
+	}
+
+void CTestFormatterUserSideStep::ClientAppL()
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+	{
+	INFO_PRINTF1(_L("Starting TestFormatterUserSide Plugin Test Suite") );
+
+	}
+
+TVerdict CTestFormatterUserSideStep::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	iSess.Disconnect();
+	return EPass;	
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/testsignaling.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,886 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example CTestStep derived implementation
+//
+
+/**
+ @file testsignaling.cpp
+ @internalTechnology
+*/
+
+#include <crashdatasave.h>
+#include <s32file.h>
+#include <bautils.h>
+
+#include "testsignaling.h"
+#include "tcoredumpserversuitedefs.h"
+#include "tcoredumpserverSuiteServer.h"
+
+/* Null UID set for ECrashProgress which does not have UID */
+const TUint KNULLUID = 999;
+
+/**
+ * Constructor
+ */
+CTestSignaling::CTestSignaling()
+
+    {
+    // **MUST** call SetTestStepName in the constructor as the controlling
+    // framework uses the test step name immediately following construction to set
+    // up the step's unique logging ID.
+    SetTestStepName (KTestSignaling);
+    }
+
+/**
+ * Destructor
+ */
+CTestSignaling::~CTestSignaling()
+    {
+    }
+
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ * establishing connection to core dump server and file server
+ * Property handles created and also the corresponding buffers
+ */
+TVerdict CTestSignaling::doTestStepPreambleL()
+    {
+    TInt ret = KErrNone;
+    SetTestStepResult (EPass);
+
+    ret = iSess.Connect ();
+    if ( ret != KErrNone)
+        {
+        SetTestStepResult ( EFail);
+        ERR_PRINTF2 (_L ("Error %d from iSess->Connect()/n"), ret);
+        User::Leave(ret);
+        }
+
+    ret = iFs.Connect ();
+    if ( ret != KErrNone)
+        {
+        SetTestStepResult ( EFail);
+        ERR_PRINTF2 (_L ("Error %d from iFs->Connect()/n"), ret);
+        User::Leave(ret);
+        }
+
+    ret = iCrashProgress.Attach(KCoreDumpServUid, ECrashProgress);
+    if ( ret != KErrNone)
+        {
+        SetTestStepResult ( EFail);
+        ERR_PRINTF2 (_L ("Error %d from iCrashProgress.Attach()/n"), ret);
+        User::Leave(ret);
+        }
+
+    ret = iCrashMediaName.Attach(KCoreDumpServUid, ECrashMediaName);
+    if ( ret != KErrNone)
+        {
+        SetTestStepResult ( EFail);
+        ERR_PRINTF2 (_L ("Error %d from iCrashMediaName.Attach()/n"), ret);
+        User::Leave(ret);
+        }
+
+    ret = iCrashCancel.Attach(KCoreDumpServUid, ECancelCrash);
+    if ( ret != KErrNone)
+        {
+        SetTestStepResult ( EFail);
+        ERR_PRINTF2 (_L ("Error %d from iCrashCancel.Attach()/n"), ret);
+        User::Leave(ret);
+        }
+
+    ret = iCrashProgressBuffer.Create(KMaxCrashProgressBuffer);
+    if ( ret != KErrNone)
+        {
+        SetTestStepResult ( EFail);
+        ERR_PRINTF2 (_L ("Error %d from iCrashProgressBuffer.Create()/n"), ret);
+        User::Leave(ret);
+        }
+
+    ret = iCrashMediaNameBuffer.Create(KNumofEntries * KMaxEntryLength);
+    if ( ret != KErrNone)
+        {
+        SetTestStepResult ( EFail);
+        ERR_PRINTF2 (_L ("Error %d from iCrashMediaNameBuffer.Create()/n"), ret);
+        User::Leave(ret);
+        }
+
+    return TestStepResult();
+    }
+
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ * releasing the sessions to the servers
+ * closing the RProperty handles and buffers
+ */
+TVerdict CTestSignaling::doTestStepPostambleL()
+    {
+    iSess.Disconnect();
+    User::After(10000000); //ensure we give enough time for session to close
+    iFs.Close();
+
+    iCrashProgress.Close();
+    iCrashMediaName.Close();
+    iCrashCancel.Close();
+
+    iCrashProgressBuffer.Close();
+    iCrashMediaNameBuffer.Close();
+
+    return EPass;
+    }
+
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+TVerdict CTestSignaling::doTestStepL()
+    {
+    if(TestStepResult() == EPass)
+        {
+        TInt ret = KErrNone;
+
+        __UHEAP_MARK;
+
+        TRAP (ret, ClientAppL ());
+        if (KErrNone != ret)
+            {
+            SetTestStepResult (EFail);
+            ERR_PRINTF2 (
+                    _L ("Error %d from CTestFormatterUserSideStep->ClientAppL()"),
+                    ret);
+            User::Leave(ret);
+            }
+
+        __UHEAP_MARKEND;
+
+        }
+    return TestStepResult ();
+    }
+
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+void CTestSignaling::ClientAppL()
+    {
+
+    INFO_PRINTF1 (_L ("Starting Test Signaling Mechanism Test Suite"));
+    TestSignalingMechanismL();
+
+    }
+
+/**
+ * @return void
+ * Tests the signaling mechanism through RProperty updates
+ * checks for the crash progress and crash media name property updates
+ */
+void CTestSignaling::TestSignalingMechanismL()
+    {
+    if (TestStepResult() == EPass)
+        {
+        //reading configuration from the ini file
+        TPtrC crashAppParam;
+        TPtrC crashFileName;
+        TPtrC testNumberofCrashes;
+
+        if(!GetStringFromConfig(ConfigSection(), KTe_CrashAppParam, crashAppParam) ||
+           !GetStringFromConfig(ConfigSection(), KTe_CrashFileName, crashFileName) ||
+           !GetStringFromConfig(ConfigSection(), KNumberofCrashes, testNumberofCrashes))
+            {
+            ERR_PRINTF1(_L("Failed to get data from the ini file"));
+            SetTestStepResult(EFail);
+            User::Leave(KErrGeneral);
+            }
+
+        //Convert number of crashes
+        TLex luther(testNumberofCrashes);
+        User::LeaveIfError(luther.Val(iTimestoCrash));
+
+        if(iTimestoCrash < KNumofEntries)
+            {
+            ERR_PRINTF3(_L ("Expecting the number of crashes %d to be more than %d"), iTimestoCrash, KNumofEntries);
+            SetTestStepResult(EFail);
+            User::Leave(KErrGeneral);
+            }
+
+        INFO_PRINTF2(_L("Number of crashes to happen %d"), iTimestoCrash);
+
+        iCrashFileName.Copy(crashFileName);
+
+        // setting the crash media name to zero
+        // ** caution this is just done for testing **
+        ZeroCrashMediaNameL();
+
+        // Load the SELF Formatter and File Writer
+        LoadandConfigurePluginsL(crashFileName);
+
+        //lets do the first crash
+        //start the application that would crash and observe it
+        StartCrashAppL(crashAppParam);
+
+        // check for the presence of UID in the crash progress messages
+        CheckUIDCrashProgressL();
+        iNumberofCrashes++;
+
+        // breather -- TODO: Why is this here? Document or remove
+        User::After(1000000);
+
+        // create more crashes to create iTimestoCrash - 1 crashes
+        // and check the ECrashMediaName buffer content
+        for (TInt i = 0; i < (iTimestoCrash - 1); i++ )
+            {
+
+            StartCrashAppL(crashAppParam);
+
+            //CheckUIDCrashProgressL();
+            CheckCrashMediaNameL();
+
+			// TODO: Why is this here? Document or remove
+            User::After(1000000);
+            }
+
+        // now we have done multiple crashes
+        // and we would like to investigate the crash media name buffer
+        TestCrashMessageBufferL();
+
+        //now going to test the cancel crash scenario
+        StartCrashAppL(crashAppParam);
+
+        CheckCancelCrashL();
+
+		TidyFilesL(crashFileName);
+
+        INFO_PRINTF1 (_L ("\nSuccessfully tested the signaling mechanism! Adios!\n"));
+
+        }
+
+    }
+
+/**
+ * Deletes the crash files generated by this test to prevent corruption
+ * of future test
+ * @param aFilenameRoot root of filename to remove (we will remove aFilenameRoot*)
+ * @leave One of the system wide error codes
+ */
+void CTestSignaling::TidyFilesL(const TDesC& aFilenameRoot)
+	{
+	_LIT(KWildCardMatch, "*");
+
+	TBuf<KMaxFileName> file;
+	file.Append(aFilenameRoot);
+	file.Append(KWildCardMatch);
+
+	BaflUtils::DeleteFile(iFs, file);
+	}
+
+/**
+ * @return void
+ * @param parameters for crashapp/exe
+ * Starts the crashapp.exe and observe for the crash via CDS
+ */
+void CTestSignaling::StartCrashAppL(const TDesC& aCrashAppParam)
+    {
+
+    INFO_PRINTF2(_L ("Executing crashapp.exe %S \n"), &aCrashAppParam);
+
+    //Start the process that we intend to crash....
+    RProcess crashProcess;
+    CleanupClosePushL (crashProcess);
+
+    TInt ret = crashProcess.Create(KCrashAppFileName, aCrashAppParam);
+    if ( ret != KErrNone)
+        {
+        ERR_PRINTF2 (
+             _L ("Error %d from RProcess.Create(z:\\sys\\bin\\crashapp.exe)/n"),
+             ret);
+        SetTestStepResult (EFail);
+        User::Leave(ret);
+        }
+
+    // Observe the process and wait for a crash
+    TRAP (ret, iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue));
+    if ( ret != KErrNone)
+      {
+      ERR_PRINTF2 (
+              _L ("Error %d iSess.ObservationRequestL(z:\\sys\\bin\\crashapp.exe)\n"),
+              ret);
+      SetTestStepResult(EFail);
+      User::Leave(ret);
+      }
+
+    //start the crash process
+    crashProcess.Resume ();
+    CleanupStack::PopAndDestroy (&crashProcess);
+    }
+
+/**
+ * @return void
+ * Check for the presence of UID in the crash progress messages
+ * also check for messages if they have the same crash UID
+*/
+void CTestSignaling::CheckUIDCrashProgressL()
+    {
+    INFO_PRINTF1(_L ("Subscribing and Reading ECrashProgress Messages"));
+
+    TUint uid = 0;
+    TUint saveduid = KNULLUID;
+    TRequestStatus status;
+    TInt i = 0;
+
+    iCrashProgressBuffer.Zero();
+    User::LeaveIfError(iCrashProgress.Get(iCrashProgressBuffer));
+
+    // read the crash UID and the crash progress message present
+    ReadCrashProgressPacketL(uid, iCrashProgressBuffer);
+
+    if(uid != KNULLUID)
+        {
+        ERR_PRINTF1(_L("First crashprogress message should no crash uid in it"));
+        SetTestStepResult(EFail);
+        User::Leave(KErrGeneral);
+        }
+
+    INFO_PRINTF2(_L ("CrashProgress Messages %S"), &iCrashProgressBuffer);
+
+    //Now we read the crash progress messages until the processing is finished
+    do
+        {
+        i++;
+
+        //start the subscription to see change in the property ECrashProgress
+        iCrashProgress.Subscribe(status);
+        User::WaitForRequest (status);
+        User::LeaveIfError(iCrashProgress.Get(iCrashProgressBuffer));
+
+        INFO_PRINTF2(_L ("CrashProgress Messages %S"), &iCrashProgressBuffer);
+
+        // read the crash UID and the crash progress message present
+        ReadCrashProgressPacketL(uid, iCrashProgressBuffer);
+
+        // check for first message to be "Start"
+        if ( (1 == i) &&  (iCrashProgressBuffer.CompareF(_L("Start")) != 0) )
+            {
+            // the first message has to be Start
+            ERR_PRINTF2(_L("First crashprogress message %S should have Start in it"), &iCrashProgressBuffer);
+            SetTestStepResult(EFail);
+            User::Leave(KErrGeneral);
+            }
+        else if ( (1 == i) &&  (iCrashProgressBuffer.CompareF(_L("Start")) == 0) )
+            {
+            // save the crash UID for future checks
+            if (uid != KNULLUID)
+                SaveCrashUIDL(uid);
+            }
+        else if( (saveduid != KNULLUID) && (uid != KNULLUID) )
+            {
+            // chec if all the messages do have the same crash UID
+            if(saveduid != uid)
+                {
+                ERR_PRINTF3(_L("Mismatch in the UID values saveduid %S does not match with uid %S"), saveduid, uid);
+                SetTestStepResult(EFail);
+                User::Leave(KErrGeneral);
+                }
+            }
+
+        saveduid = uid;
+        }
+    while(iCrashProgressBuffer != KEndOfProcessing);
+
+    iCrashProgressBuffer.Zero();
+
+    INFO_PRINTF1(_L ("Succesful Read all the ECrashProgress Messages"));
+    }
+
+/**
+ * @return void
+ * Check for the the crash media name messages
+ * parses the values and validates the crash media name and the status bit
+*/
+void CTestSignaling::CheckCrashMediaNameL()
+    {
+    INFO_PRINTF1(_L ("Validate the Crash Media Name Messages"));
+
+    TUint crashUID = 0;
+    TBuf<KMaxStatusLength> statusbit;
+    TRequestStatus status;
+
+    do
+        {
+        // subscribe to the Crash Progress Property
+        // intention is to be notified of the crash processing start
+        iCrashProgress.Subscribe(status);
+        User::WaitForRequest(status);
+
+        User::LeaveIfError(iCrashProgress.Get(iCrashProgressBuffer));
+        // extract the crash UID and the crash progress message
+        ReadCrashProgressPacketL(crashUID, iCrashProgressBuffer);
+
+        if(iCrashProgressBuffer.CompareF(_L("Start")) == 0)
+            {
+            // now read the crash media name which should be updated
+            // no need to subscribe for ECrashMediaName as it has already been updated
+            User::LeaveIfError(iCrashMediaName.Get(iCrashMediaNameBuffer));
+            INFO_PRINTF2(_L ("Crash Media Name Messages %S"), &iCrashMediaNameBuffer);
+
+            // read the crash media name entry for the particular crash uid
+            ParseMediaNameBufferL(crashUID, iCrashMediaNameBuffer, statusbit);
+
+            //check if the crash status bit "I" i.e it is still In Progress
+            if(statusbit.CompareF(_L("I")) != 0)
+                {
+                ERR_PRINTF2(_L("Incorrect status bit %S expecting it to be I"), &statusbit);
+                SetTestStepResult(EFail);
+                User::Leave(KErrGeneral);
+                }
+
+            // check if the CrashFile name is valid name
+            iCrashFileName.Append(_L("*"));
+            if (iCrashMediaNameBuffer.MatchF(iCrashFileName) == KErrNotFound)
+                {
+                ERR_PRINTF3(_L("Crash Media Name %S does not match with %S"), &iCrashFileName, &iCrashMediaNameBuffer);
+                SetTestStepResult(EFail);
+                User::Leave(KErrGeneral);
+                }
+
+            // happy to save the crash UID for future checks
+            SaveCrashUIDL(crashUID);
+
+            }
+
+        }
+    while(iCrashProgressBuffer != KEndOfProcessing);
+
+    //now check the status bit message
+    User::LeaveIfError(iCrashMediaName.Get(iCrashMediaNameBuffer));
+    INFO_PRINTF2(_L ("Crash Media Name Messages %S"), &iCrashMediaNameBuffer);
+    // parse the crash media name message
+    ParseMediaNameBufferL(iCrashUID[iNumberofCrashes - 1], iCrashMediaNameBuffer, statusbit);
+
+    //check if the crash status bit "D" i.e the crash processing is now done
+    if(statusbit.CompareF(_L("D")) != 0)
+        {
+        ERR_PRINTF2(_L("Incorrect status bit %S supposed to be D"), &statusbit);
+        SetTestStepResult(EFail);
+        User::Leave(KErrGeneral);
+        }
+
+    INFO_PRINTF1(_L ("Successful checked the Crash Media Name Messages"));
+    }
+
+/**
+ * @return void
+ * Check for the the crash media name messages after multiple crashes has happened
+ * expects that the number of crashes is more than the KNumofEntries
+ * parses the crash media name buffer and validates the status bit
+ * also checks if we have all the latest crashes in the crash media buffer
+*/
+void CTestSignaling::TestCrashMessageBufferL()
+    {
+    INFO_PRINTF1(_L ("Test the final Crash Media Name Message Buffer"));
+
+    // read the crash media name buffer
+    iCrashMediaNameBuffer.Zero();
+    User::LeaveIfError(iCrashMediaName.Get(iCrashMediaNameBuffer));
+    INFO_PRINTF2(_L("Final Crash Media name Buffer %S"), &iCrashMediaNameBuffer);
+
+    TInt numofEntries = iCrashMediaNameBuffer.Length() / KMaxEntryLength;
+    // expects that the number of crashes is greater than  KNumofEntries
+    if (numofEntries != KNumofEntries)
+        {
+        ERR_PRINTF2(_L("%d Entries is not equal to the max length"), numofEntries);
+        SetTestStepResult(EFail);
+        User::Leave(KErrGeneral);
+        }
+
+    // check for the buffer consistency
+    if( (iCrashMediaNameBuffer.Length() % KMaxEntryLength) != 0  )
+        {
+        ERR_PRINTF2(_L("Buffer corrupt iCrashMediaNameBuffer.Length() %d"), iCrashMediaNameBuffer.Length());
+        SetTestStepResult(EFail);
+        User::Leave(KErrGeneral);
+        }
+
+    // run through the buffer
+    for(TInt i = 0; i < numofEntries; i++ )
+        {
+        // check for the status bit
+        // used as a bit to check on the validity of the entry
+        TPtrC statusptr = iCrashMediaNameBuffer.Mid((i * KMaxEntryLength), KMaxStatusLength);
+
+        if ((statusptr.CompareF(_L("D")) != 0) )
+          {
+          ERR_PRINTF2(_L("Entry Number %d does not seem to have complete status"), i);
+          SetTestStepResult(EFail);
+          User::Leave(KErrGeneral);
+          }
+
+        // now check if we have all the latest crashes by checking on the crash UID
+        // check for UID and match with the saved UID values
+        // we have been saving the crash UID in the right fashion always keeping the latest crashes
+        TPtrC uidptr = iCrashMediaNameBuffer.Mid(((i * KMaxEntryLength) + KMaxStatusLength), KMaxUIDLength);
+
+        TUint uid = 0;
+        TLex lexuid(uidptr);
+        User::LeaveIfError(lexuid.Val(uid));
+
+        if ( uid != iCrashUID[i])
+            {
+            ERR_PRINTF3(_L("Entry Number %d does not match with iCrashUID %d"), uid, iCrashUID[i]);
+            SetTestStepResult(EFail);
+            User::Leave(KErrGeneral);
+            }
+
+        //check for the terminating character '/'
+        TPtrC endptr = iCrashMediaNameBuffer.Mid((((i + 1) * KMaxEntryLength) - KMaxEndLength), KMaxEndLength);
+
+        if(endptr.CompareF(_L("\\")) != 0 )
+            {
+            ERR_PRINTF3(_L("Entry Number %d does not have the right termination character instead has %S"), i, &endptr);
+            SetTestStepResult(EFail);
+            User::Leave(KErrGeneral);
+            }
+
+        }
+
+    INFO_PRINTF1(_L ("Successfully tested the final Crash Media Name Message Buffer"));
+    }
+
+void  CTestSignaling::CheckCancelCrashL()
+    {
+    INFO_PRINTF1(_L ("Test the Cancel status message update in the Crash Media Buffer"));
+
+    TUint crashUID = 0;
+    TBuf<KMaxStatusLength> statusbit;
+    TRequestStatus status;
+
+    do
+        {
+        // subscribe to the Crash Progress Property
+        // intention is to be notified of the crash processing start
+        iCrashProgress.Subscribe(status);
+        User::WaitForRequest(status);
+
+        User::LeaveIfError(iCrashProgress.Get(iCrashProgressBuffer));
+        // extract the crash UID and the crash progress message
+        ReadCrashProgressPacketL(crashUID, iCrashProgressBuffer);
+
+        if(iCrashProgressBuffer.CompareF(_L("Start")) == 0)
+            {
+            // now that the crash processing has started
+            // issue a cancel crash command
+            iCrashCancel.Set(ETrue);
+
+            }
+
+        }
+    while(iCrashProgressBuffer != KEndOfProcessing);
+
+    // once the processing is done
+    // read the crash media buffer to see
+    // if we have the latest crash has the cancelled status bit
+    User::LeaveIfError(iCrashMediaName.Get(iCrashMediaNameBuffer));
+
+    // read the last crash entry as it has the latest crash
+    // check for the status bit to have "C" signifying the processing was cancelled
+    TPtrC statusptr = iCrashMediaNameBuffer.Mid(((KNumofEntries - 1) * KMaxEntryLength), KMaxStatusLength);
+
+    if( statusptr.CompareF(_L("C")) != 0)
+        {
+        ERR_PRINTF2(_L("The entry does not seem to be valid status bit %S"), &statusptr);
+        SetTestStepResult(EFail);
+        User::Leave(KErrGeneral);
+        }
+
+    INFO_PRINTF1(_L ("Completed Successfully Cancel status message update in the Crash Media Buffer"));
+    }
+/**
+ * @return void
+ * @param aCrashUID crash UID used to find the matching crash in the entries
+ * @param aCrashMediaNameBuffer RProperty message buffer
+ * @param aStatusBit status bit of the crash media name entry
+ * Reads the CrashMediaName property value extracts the crash UID
+ * and the crash media name and the status bit
+ * The function runs through all the buffer entries
+ * but this is not needed as it is guranteed that the last entry has the latest crash information
+ * Here is how the buffer entries looks like
+ * there are KNumofEntries number of entries each of KMaxEntryLength
+ * |Status|         MediaName         |UID |END|
+ *   1              128 + 20           10   1   number of characters = KMaxEntryLength = 160
+
+ * Status:      D stands for Done
+ *              I stands for In progress
+ *              C stands for Cancel
+ * UID:         lower 32 bit of crash time
+ * MediaName:   medianame + 64 bit time appended to it
+ * END:         end character \
+ */
+void CTestSignaling::ParseMediaNameBufferL(TUint aCrashUID, TDes& aCrashMediaNameBuffer, TDes& aStatusBit)
+    {
+
+    TBool matchfound = EFalse;
+    TInt numofEntries = aCrashMediaNameBuffer.Length() / KMaxEntryLength;
+    // check the number of entries are not more than KNumofEntries
+    if (numofEntries > KNumofEntries)
+        {
+        ERR_PRINTF2(_L("entries %d more than the max length"), numofEntries);
+        SetTestStepResult(EFail);
+        User::Leave(KErrGeneral);
+        }
+
+    // check for the buffer consistency the each should be of length KMaxEntryLength
+    if( (iCrashMediaNameBuffer.Length() % KMaxEntryLength) != 0  )
+        {
+        ERR_PRINTF2(_L("Buffer corrupt iCrashMediaNameBuffer.Length() %d"), iCrashMediaNameBuffer.Length());
+        SetTestStepResult(EFail);
+        User::Leave(KErrGeneral);
+        }
+
+    // now read through all the entries and check for consistency
+    for(TInt i = 0; i < numofEntries; i++ )
+        {
+        // read the status bit and check for validity
+        TPtrC statusptr = aCrashMediaNameBuffer.Mid((i * KMaxEntryLength), KMaxStatusLength);
+
+        if ((statusptr.CompareF(_L("D")) == 0) || (statusptr.CompareF(_L("I")) == 0) || (statusptr.CompareF(_L("C")) == 0) )
+            {
+            // read the crash UID and see if we can find a match
+            TPtrC uidptr = aCrashMediaNameBuffer.Mid(((i * KMaxEntryLength) + KMaxStatusLength), KMaxUIDLength);
+
+            TUint uid = 0;
+            TLex lexuid(uidptr);
+            User::LeaveIfError(lexuid.Val(uid));
+
+            //check if the last the crash entry is the latest one
+            if (uid == aCrashUID)
+                {
+                if( (i+1) != numofEntries)
+                    {
+                    ERR_PRINTF2(_L("The last entry does not have the last crash information %d"), i);
+                    SetTestStepResult(EFail);
+                    User::Leave(KErrGeneral);
+                    }
+
+                TPtrC crashmediaptr = aCrashMediaNameBuffer.Mid(((i * KMaxEntryLength) + KMaxStatusLength + KMaxUIDLength), KMaxMediaLength);
+
+                //update the crash media name
+                aCrashMediaNameBuffer.Copy(crashmediaptr);
+                //update the status
+                aStatusBit.Copy(statusptr);
+
+                // we have found a macthing UID
+                matchfound = ETrue;
+                }
+
+            }
+        else
+            {
+            ERR_PRINTF2(_L("The entry does not seem to be valid status bit %S"), &statusptr);
+            SetTestStepResult(EFail);
+            User::Leave(KErrGeneral);
+            }
+
+        }
+
+    // if we dont find it match flag it as error
+    if(!matchfound)
+        {
+        ERR_PRINTF2(_L("The entry not found with the right UID %d"), aCrashUID);
+        SetTestStepResult(EFail);
+        User::Leave(KErrGeneral);
+        }
+
+    }
+
+/**
+ * @return void
+ * @param aUID carsh UID
+ * @param aMessageBuffer RProperty message for crashprogress
+ * Reads the CrashProgress property value extracts the crash UID
+ * and the crash progress message
+ */
+void CTestSignaling::ReadCrashProgressPacketL(TUint& aUID, TDes& aMessageBuffer)
+    {
+    if ( (aMessageBuffer.CompareF(_L("")) == 0) || (aMessageBuffer.CompareF(_L("clear")) == 0) || (aMessageBuffer.CompareF(_L("idle")) == 0) || (aMessageBuffer.CompareF(_L("Cancel")) == 0))
+        {
+        //signifying that these messages does not have a UID
+        aUID = KNULLUID;
+        }
+    else
+        {
+        //INFO_PRINTF2(_L("aMessageBuffer %S"), &aMessageBuffer);
+        //process the UID
+        RBuf uidbuf;
+        TInt ret = KErrNone;
+        ret = uidbuf.Create(aMessageBuffer, KMaxUIDLength);
+        if (ret != KErrNone)
+            {
+            ERR_PRINTF2(_L("Error %d rbuf create for UID /n"), ret);
+            SetTestStepResult (EFail);
+            User::Leave(ret);
+            }
+
+        TLex lexuid(uidbuf);
+        ret = lexuid.Val(aUID);
+        if (ret != KErrNone)
+            {
+            ERR_PRINTF2(_L("Error %d lex uid /n"), ret);
+            SetTestStepResult (EFail);
+            User::Leave(ret);
+            }
+        uidbuf.Close();
+
+        // stripping the UID and the crash progress message
+        TPtr message = aMessageBuffer.MidTPtr(KMaxUIDLength);
+        aMessageBuffer.Copy(message);
+        }
+    }
+
+/**
+ * @return void
+ * Utility function to save the crash UID present in the crash progress messages
+*/
+void CTestSignaling::SaveCrashUIDL(TUint aSaveCrashUID)
+    {
+    if (iNumberofCrashes < KNumofEntries)
+        {
+        iCrashUID[iNumberofCrashes] = aSaveCrashUID;
+        iNumberofCrashes++;
+        }
+    else
+        {
+        for (TInt i = 0; i < (KNumofEntries - 1); i++)
+            {
+                iCrashUID[i] = iCrashUID[i+1];
+            }
+
+        iCrashUID[iNumberofCrashes-1] = aSaveCrashUID;
+        }
+
+    if(iNumberofCrashes > iNumberofCrashes)
+        {
+        ERR_PRINTF2(_L("Mismatch in crash uid storing %d"), iNumberofCrashes);
+        SetTestStepResult(EFail);
+        User::Leave(KErrGeneral);
+        }
+    }
+/**
+ * @return void
+ * sets the CrashMediaName property to zero
+ * this is done solely for testing purposes
+ * clients of CDS are not expected to modify the property
+ */
+void CTestSignaling::ZeroCrashMediaNameL()
+    {
+
+    iCrashMediaNameBuffer.Zero();
+    User::LeaveIfError(iCrashMediaName.Set(iCrashMediaNameBuffer));
+    // setting this resets the crash UID array to zero
+    iNumberofCrashes = 0;
+
+    }
+
+/**
+ * @return void
+ * @param aIndex Internal index to the component that owns the object
+ * @param aUID UID of the component that owns the object
+ * @param aSource Type of component that owns the object
+ * @param aType Type of parameter
+ * @param aPrompt Prompt to present to user
+ * @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
+ * @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
+ * @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
+ * @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
+ */
+void CTestSignaling::DoConfigureL(const TUint32& aIndex, const TUint32& aUID,
+        const COptionConfig::TParameterSource& aSource,
+        const COptionConfig::TOptionType& aType, const TDesC& aPrompt,
+        const TUint32& aNumOptions, const TDesC& aOptions, const TInt32& aVal,
+        const TDesC& aStrValue, const TUint aInstance)
+
+    {
+    COptionConfig * config;
+
+    config = COptionConfig::NewL ( aIndex, aUID, aSource, aType, aPrompt,
+            aNumOptions, aOptions, aVal, aStrValue);
+
+    CleanupStack::PushL (config);
+
+    config->Instance (aInstance);
+
+    //Configure now...
+    TRAPD (ret, iSess.SetConfigParameterL (*config));
+    if ( ret != KErrNone)
+        {
+        ERR_PRINTF2(_L("Error %d changing parameter/n"), ret);
+        SetTestStepResult (EFail);
+        User::Leave(ret);
+        }
+
+    CleanupStack::PopAndDestroy (config);
+    }
+
+/**
+ * @return void
+ * Utility function to load the SELF Formatter and File Writer
+ * Configures the file writer and the CDS
+ */
+void CTestSignaling::LoadandConfigurePluginsL(const TDesC& aCrashFileName)
+    {
+    INFO_PRINTF1 (_L ("Attempting to load SELF Formatter V2 and File Writer"));
+
+    // SELF Formatter V2
+    TPluginRequest SELFreq;
+    SELFreq.iPluginType = TPluginRequest::EFormatter;
+    SELFreq.iLoad = ETrue;
+    SELFreq.iUid = KUidSELFFormatterV2;
+
+    TRAPD(ret, iSess.PluginRequestL(SELFreq));
+    if ( ret != KErrNone)
+        {
+        ERR_PRINTF2 (_L ("Failed to load SELF Formatter V2 plugin, error = %d"), ret);
+        SetTestStepResult (EFail);
+        User::Leave(ret);
+        }
+
+    // File Writer
+    TPluginRequest writerreq;
+    writerreq.iUid = WRITER_UID;
+    writerreq.iPluginType = TPluginRequest::EWriter;
+    writerreq.iLoad = ETrue;
+
+    TRAP(ret, iSess.PluginRequestL(writerreq ));
+    if(ret != KErrNone)
+        {
+        ERR_PRINTF2(_L("Failed to load writer plugin, error = %d"), ret);
+        SetTestStepResult(EFail);
+        User::Leave(ret);
+        }
+
+    INFO_PRINTF1(_L("Successfully loaded SELF Formatter V2 and File Writer"));
+
+    //Now we configure CDS and writer
+    _LIT( KFilePathPrompt, "not_important" );
+
+    DoConfigureL(2, CDS_UID.iUid, COptionConfig::ECoreDumpServer, COptionConfig::ETUInt, KPostCrashEventActionPrompt,
+                 1, KNullDesC, 4, KNullDesC, 0);
+
+    DoConfigureL((TInt)(CCrashDataSave::ECoreFilePath), WRITER_UID.iUid, COptionConfig::EWriterPlugin, COptionConfig::ETFileName,
+                        KFilePathPrompt, 1, KNullDesC, 0, aCrashFileName, 0);
+
+    INFO_PRINTF1(_L("Successfully configured File Writer and CDS"));
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/src/utracestep.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,357 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Example CTestStep derived implementation
+//
+
+
+
+/**
+ @file SELFStep.cpp
+ @internalTechnology
+*/
+#include "utracestep.h"
+#include "tcoredumpserversuitedefs.h"
+#include "tcoredumpserverSuiteServer.h"
+#include <crashdatasave.h>
+#include <s32file.h>
+#include <e32property.h>
+
+CUTraceStep::~CUTraceStep()
+/**
+ * Destructor
+ */
+	{
+	}
+
+CUTraceStep::CUTraceStep()
+/**
+ * Constructor
+ */
+	{
+	// **MUST** call SetTestStepName in the constructor as the controlling
+	// framework uses the test step name immediately following construction to set
+	// up the step's unique logging ID.
+	SetTestStepName (KUTraceUserSide);
+	}
+
+TVerdict CUTraceStep::doTestStepPreambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	TInt ret = KErrNone;
+	ret = iSess.Connect ();
+	if ( ret != KErrNone)
+		{
+		SetTestStepResult ( EFail);
+		INFO_PRINTF2 (_L ("Error %d from iSess->Connect()/n"), ret);
+		}
+	else
+		{
+		SetTestStepResult (EPass);
+		}
+
+	ret = iFs.Connect ();
+	if ( ret != KErrNone)
+		{
+		SetTestStepResult ( EFail);
+		INFO_PRINTF2 (_L ("Error %d from iFs->Connect()/n"), ret);
+		}
+	else
+		{
+		SetTestStepResult (EPass);
+		}
+
+	return TestStepResult ();
+	}
+
+void CUTraceStep::ClientAppL()
+/**
+ * @return void
+ * This calls each stage of the test
+ */
+	{
+	INFO_PRINTF1 (_L ("Starting UTrace User Side Test Suite"));
+	TestTraceDataL ();
+
+	}
+
+void CUTraceStep::TestTraceDataL()
+	{
+	_LIT (KCrashFileName, "c:\\trace");
+	HandleCrashL (KCrashFileName);
+	}
+
+void CUTraceStep::HandleCrashL(const TDesC& aFileName)
+/**
+ * @return void
+ * Tests handling a crash
+ */
+	{
+
+	if ( TestStepResult ()==EPass)
+		{
+		_LIT (KCrashAppParam, "-d1 -t");
+
+		INFO_PRINTF3 (_L ("The CrashApp Param is %S, The Filename is is %S"),
+				&KCrashAppParam, &aFileName);
+
+		//Start the process that we intend to crash....
+		RProcess crashProcess;
+		CleanupClosePushL (crashProcess);
+
+		TInt ret = crashProcess.Create ( KCrashAppFileName, KCrashAppParam);
+		if ( ret != KErrNone)
+			{
+			INFO_PRINTF2 (
+					_L ("Error %d from RProcess.Create(z:\\sys\\bin\\crashapp.exe)/n"),
+					ret);
+			SetTestStepResult (EFail);
+			User::Leave (ret);
+			}
+
+		LoadUTraceFormatterL ();
+		LoadFileWriterL ();
+
+		//configure cds and writer
+		_LIT ( KFilePathPrompt, "not_important");
+
+		INFO_PRINTF1 (_L ("Configuring CDS"));
+		DoConfigureL (2, CDS_UID.iUid, COptionConfig::ECoreDumpServer,
+				COptionConfig::ETUInt, KPostCrashEventActionPrompt, 1,
+				KNullDesC, 4, KNullDesC, 0);
+
+		INFO_PRINTF1 (_L ("Configuring File Writer"));
+		DoConfigureL ((TInt)(CCrashDataSave::ECoreFilePath), WRITER_UID.iUid,
+				COptionConfig::EWriterPlugin, COptionConfig::ETFileName,
+				KFilePathPrompt, 1, KNullDesC, 0, aFileName, 0);
+
+		// Observe the process and wait for a crash
+		INFO_PRINTF1 (_L ("Observing bad boy crash app"));
+		TRAP (ret, iSess.ObservationRequestL ( KCrashAppFileName,
+				KCrashAppFileName, ETrue));
+		if ( ret != KErrNone)
+			{
+			INFO_PRINTF2 (
+					_L ("Error %d iSess.ObservationRequestL(z:\\sys\\bin\\crashapp.exe)\n"),
+					ret);
+			SetTestStepResult (EFail);
+			User::Leave ( ret);
+			}
+
+		//start the crash process
+		crashProcess.Resume ();
+		CleanupStack::PopAndDestroy (&crashProcess); //this is for crashProcess
+
+		//Monitor the progress of the crash file being generated...
+		MonitorProgressL ();
+		User::After (5000000);
+
+		//Check dump has been generated...and valid
+		CDir *fileList = NULL;
+		TFindFile fileFinder(iFs);
+		TRAP (ret, fileList = CTe_coredumpserverSuite::DoesFileExistL (
+				aFileName, fileFinder));
+
+		if ( (ret != KErrNone) || (fileList == NULL))
+			{
+			INFO_PRINTF2 (_L ("Expected crash file was not generated:  %d"),
+					ret);
+			SetTestStepResult (EFail);
+			User::Leave ( ret);
+			}
+
+		CleanupStack::PushL (fileList);
+		for (TInt i = 0; i < fileList->Count (); i++)
+			{
+			TParse fullName;
+			fullName.Set ((*fileList)[i].iName, &fileFinder.File(), NULL);
+			VerifyTraceDataL (fullName.FullName ());
+			INFO_PRINTF2 (_L ("Deleting %S"), &fullName.FullName ());
+			User::LeaveIfError (iFs.Delete (fullName.FullName ()));
+			}
+		CleanupStack::PopAndDestroy (fileList);
+
+		INFO_PRINTF1 (_L ("Expected trace crash file was generated and parsed successfully"));
+
+		}
+
+	}
+
+void CUTraceStep::MonitorProgressL()
+	{
+	RProperty crashProgress;
+	User::LeaveIfError (crashProgress.Attach (KCoreDumpServUid, ECrashProgress));
+
+	TBuf<50> crashProg;
+
+	TRequestStatus status;
+	crashProgress.Subscribe (status);
+	User::WaitForRequest (status);
+	//Subscribe for next one again...
+	crashProgress.Subscribe (status);
+
+	//First one should be the start string = "-"
+	User::LeaveIfError (crashProgress.Get (crashProg));
+	if ( crashProg != KStartOfUTraceProc)
+		{
+		INFO_PRINTF1 (_L ("UTRACE formatter has not started processing the data"));
+		}
+
+	INFO_PRINTF1 (_L ("UTRACE formatter has started processing the data"));
+	INFO_PRINTF1 (_L ("Waiting to be notified of the timeout of the processing. A timeout here is a fail"));
+	//Now we wait until its finished
+	do
+		{
+		User::WaitForRequest (status);
+		crashProgress.Subscribe (status);
+
+		User::LeaveIfError (crashProgress.Get (crashProg));
+		}
+	while (crashProg != KEndOfProcessing);
+
+	INFO_PRINTF1 (_L ("UTRACE formatter has finished processing the data"));
+	}
+
+void CUTraceStep::DoConfigureL(const TUint32& aIndex, const TUint32& aUID,
+		const COptionConfig::TParameterSource& aSource,
+		const COptionConfig::TOptionType& aType, const TDesC& aPrompt,
+		const TUint32& aNumOptions, const TDesC& aOptions, const TInt32& aVal,
+		const TDesC& aStrValue, const TUint aInstance)
+/**
+ * @return void
+ * @param aIndex Internal index to the component that owns the object
+ * @param aUID UID of the component that owns the object
+ * @param aSource Type of component that owns the object
+ * @param aType Type of parameter
+ * @param aPrompt Prompt to present to user 
+ * @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
+ * @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
+ * @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
+ * @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
+ */
+	{
+	COptionConfig * config;
+
+	config = COptionConfig::NewL ( aIndex, aUID, aSource, aType, aPrompt,
+			aNumOptions, aOptions, aVal, aStrValue);
+
+	CleanupStack::PushL (config);
+
+	config->Instance (aInstance);
+
+	//Configure now...
+	TRAPD (ret, iSess.SetConfigParameterL (*config));
+	if ( ret != KErrNone)
+		{
+		INFO_PRINTF2 (_L ("Error %d changing param/n"), ret);
+		SetTestStepResult (EFail);
+		User::Leave (ret);
+		}
+
+	CleanupStack::PopAndDestroy (config);
+	}
+
+void CUTraceStep::LoadUTraceFormatterL()
+/**
+ * @return void
+ * Utility function to load the UTRACE formatter
+ */
+	{
+
+	INFO_PRINTF1 (_L ("Attempting to load UTRACE Plugin"));
+
+	TPluginRequest req;
+	req.iPluginType = TPluginRequest::EFormatter;
+	req.iLoad = ETrue;
+	req.iUid = UTRACE_UID;
+
+	// Should be allowed to load utrace formatter
+	TRAPD (ret, iSess.PluginRequestL ( req));
+	if ( ret != KErrNone)
+		{
+		ERR_PRINTF2 (_L ("Failed to load writer plugin, error = %d"), ret);
+		SetTestStepResult (EFail);
+		User::Leave (ret);
+		}
+
+	}
+
+void CUTraceStep::LoadFileWriterL()
+	{
+	TPluginRequest req;
+	TUid writerUid = WRITER_UID;
+	req.iUid = writerUid;
+	req.iPluginType = TPluginRequest::EWriter;
+	req.iLoad = ETrue;
+
+	TRAPD (ret, iSess.PluginRequestL ( req));
+	if ( ret != KErrNone)
+		{
+		ERR_PRINTF2 (_L ("Failed to load writer plugin, error = %d"), ret);
+		SetTestStepResult (EFail);
+		User::Leave (ret);
+		}
+
+	}
+
+TVerdict CUTraceStep::doTestStepL()
+/**
+ * @return - TVerdict code
+ * Override of base class pure virtual
+ * Our implementation only gets called if the base class doTestStepPreambleL() did
+ * not leave. That being the case, the current test result value will be EPass.
+ */
+	{
+	if ( TestStepResult ()==EPass)
+		{
+		TInt ret = KErrNone;
+
+		__UHEAP_MARK;
+
+		TRAP (ret, ClientAppL ());
+		if ( KErrNone != ret)
+			{
+			SetTestStepResult (EFail);
+			INFO_PRINTF2 (
+					_L ("Error %d from CTestFormatterUserSideStep->ClientAppL()"),
+					ret);
+			}
+
+		__UHEAP_MARKEND;
+
+		}
+	return TestStepResult ();
+	}
+
+TVerdict CUTraceStep::doTestStepPostambleL()
+/**
+ * @return - TVerdict code
+ * Override of base class virtual
+ */
+	{
+	iSess.Disconnect ();
+	User::After (10000000); //ensure we give enough time for session to close
+	iFs.Close ();
+	return EPass;
+	}
+
+void CUTraceStep::VerifyTraceDataL(const TDesC& aFullFilename)
+	{
+	INFO_PRINTF2 (_L ("VerifyTraceDataL (Not Implemented) The Filename is is %S"),
+			 &aFullFilename);
+
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/te_coredumpserversuite.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,25 @@
+
+[Section0]
+TheString=DEXECStep
+TheInt=0
+TheBool=False
+
+[Section1]
+TheString=ListsStep
+TheInt=1
+TheBool=True
+
+[Section2]
+TheString=ParametersStep
+TheInt=2
+TheBool=False
+
+[Section3]
+TheString=PluginsStep
+TheInt=3
+TheBool=True
+
+[Section4]
+TheString=SELFStep
+TheInt=4
+TheBool=False
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/te_dexec.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+[user_PrefetchAbort]
+CrashAppParam=-c1 -d1
+CrashFileName=E:\C1DEXECPA
+WriterToUse=102831E4
+
+[user_DataRead]
+CrashAppParam=-c2 -d1
+CrashFileName=E:\C2DEXECDR
+WriterToUse=102831E4
+
+[user_DataWrite]
+CrashAppParam=-c3 -d1
+CrashFileName=E:\C3DEXECDW
+WriterToUse=102831E4
+
+[user_UndefInstr]
+CrashAppParam=-c4 -d1
+CrashFileName=E:\C4DEXECUI
+WriterToUse=102831E4
+
+
+[user_UserPanic]
+CrashAppParam=-c5 -d1
+CrashFileName=E:\C5DEXECUP
+WriterToUse=102831E4
+
+[user_UserException]
+CrashAppParam=-c6 -d1
+CrashFileName=E:\C6DEXECUE
+WriterToUse=102831E4
+
+[user_StackOverflow]
+CrashAppParam=-c7 -d1
+CrashFileName=E:\C7DEXECSOF
+WriterToUse=102831E4
+
+[user_UserExit]
+CrashAppParam=-c8 -d1
+CrashFileName=E:\C8DEXECUE
+WriterToUse=102831E4
+
+[user_UserLeave]
+CrashAppParam=-c9 -d1
+CrashFileName=E:\C9DEXECUL
+WriterToUse=102831E4
+
+[user_ThreadKill]
+CrashAppParam=-c10 -d1
+CrashFileName=E:\C10DEXECTK
+WriterToUse=102831E4
+
+[user_ThreadPanic]
+CrashAppParam=-c11 -d1
+CrashFileName=E:\C11DEXECTP
+WriterToUse=102831E4
+
+[user_ThreadTerminate]
+CrashAppParam=-c12 -d1
+CrashFileName=E:\C12DEXECTT
+WriterToUse=102831E4
+
+[user_DivByZero]
+CrashAppParam=-c13 -d1
+CrashFileName=E:\C13DEXECDZ
+WriterToUse=102831E4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/te_self.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+[user_PrefetchAbort]
+CrashAppParam=-c1 -d1
+CrashFileName=E:\C1SElfPA
+WriterToUse=102831E4
+
+[user_DataRead]
+CrashAppParam=-c2 -d1
+CrashFileName=E:\C2SElfDR
+WriterToUse=102831E4
+
+[user_DataWrite]
+CrashAppParam=-c3 -d1
+CrashFileName=E:\C3SElfDW
+WriterToUse=102831E4
+
+[user_UndefInstr]
+CrashAppParam=-c4 -d1
+CrashFileName=E:\C4SElfUI
+WriterToUse=102831E4
+
+
+[user_UserPanic]
+CrashAppParam=-c5 -d1
+CrashFileName=E:\C5SElfUP
+WriterToUse=102831E4
+
+[user_UserException]
+CrashAppParam=-c6 -d1
+CrashFileName=E:\C6SElfUE
+WriterToUse=102831E4
+
+[user_StackOverflow]
+CrashAppParam=-c7 -d1
+CrashFileName=E:\C7SElfSOF
+WriterToUse=102831E4
+
+[user_UserExit]
+CrashAppParam=-c8 -d1
+CrashFileName=E:\C8SElfUE
+WriterToUse=102831E4
+
+[user_UserLeave]
+CrashAppParam=-c9 -d1
+CrashFileName=E:\C9SElfUL
+WriterToUse=102831E4
+
+[user_ThreadKill]
+CrashAppParam=-c10 -d1
+CrashFileName=E:\C10SElfTK
+WriterToUse=102831E4
+
+[user_ThreadPanic]
+CrashAppParam=-c11 -d1
+CrashFileName=E:\C11SElfTP
+WriterToUse=102831E4
+
+[user_ThreadTerminate]
+CrashAppParam=-c12 -d1
+CrashFileName=E:\C12SElfTT
+WriterToUse=102831E4
+
+[user_DivByZero]
+CrashAppParam=-c13 -d1
+CrashFileName=E:\C13SElfDZ
+WriterToUse=102831E4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/te_self_trace.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,8 @@
+[user_Trace]
+CrashAppParam=-c1 -d1 -t
+Trace=1
+
+
+[user_WithoutTrace]
+CrashAppParam=-c2 -d1
+Trace=0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/testdata/te_signaling.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,4 @@
+[user_Signaling]
+CrashAppParam=-c1 -d5
+CrashFileName=E:\babelfish
+CrashNumber=7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/tcoredumpserversuite.xml	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<testSuite>
+  <name>te_coredumpserverSuite</name>
+  <testItems>
+    <test>te_coredumpserverTest</test>
+  </testItems>
+  <testExecuteServers>
+    <server>te_coredumpserverSuite</server>
+  </testExecuteServers>
+</testSuite>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/tcoredumpserversuite/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/tcoredumpserversuite/tcoredumpservertest.xml	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<testExecuteTest>
+  <name>te_coredumpserverTest</name>
+  <timeout>10000</timeout>
+  <testScripts>
+    <script>
+      <hostPath>\te_coredumpserver\scripts\te_coredumpserverSuite.script</hostPath>
+      <devicePath>c:\te_coredumpserverSuite.script</devicePath>
+    </script>
+  </testScripts>
+  <testServers>
+    <server>te_coredumpserverSuite</server>
+  </testServers>
+  <dependencies>
+    <data>
+      <hostPath>\te_coredumpserver\testdata\te_coredumpserverSuite.ini</hostPath>
+      <devicePath>c:\testdata\configs\te_coredumpserverSuite.ini</devicePath>
+    </data>
+  </dependencies>
+</testExecuteTest>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/tcoredumpserversuite/testexecuteservers/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_app/xml/tcoredumpserversuite/testexecuteservers/tcoredumpserversuite.xml	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<testExecuteServer>
+  <name>te_coredumpserverSuite</name>
+  <mmpFile>te_coredumpserverSuite.mmp</mmpFile>
+  <bldInfPath>\te_coredumpserver\group\bld.inf</bldInfPath>
+</testExecuteServer>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-002.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,54 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-monitor-002.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Ensure build time configuration parameters are correct
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:TestScmConfig
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_entire_partition
+goto:eof
+
+:TestScmConfig
+echo Testing scm config with various values
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.coredump-monitor.coredump-monitor-002
+goto:eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-004.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,44 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-monitor-004.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Trusted clients should be able to view crash logger configuration parameters
+exit /B n
+
+:Main
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.coredump-monitor.coredump-monitor-004
+exit /B n
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-005.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,45 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-monitor-005.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Untrusted clients should not be able to view crash logger configuration parameters.
+exit /B n
+
+:Main
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.coredump-monitor.coredump-monitor-005
+exit /B n
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-007.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,73 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+time /t
+ECHO *********************************************
+ECHO DT-coredump-monitor-007.bat
+ECHO *********************************************
+
+ECHO TO CHECK FOR NEWEST CRASH
+
+ECHO *********************************************
+ECHO CLEAN FLASH PARTITION
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_partition
+
+ECHO *********************************************
+ECHO CONFIGURING SCM TO HOLD MINIMUM INFORMATION
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.processcrash.testSCMZeroConfig
+
+ECHO *********************************************
+ECHO CRASHING BOARD FOR THREE TIMES
+ECHO *********************************************
+
+ECHO *********************************************
+ECHO CRASH BOARD PREFETCH ABORT
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_prefetch_abort
+
+ECHO *********************************************
+ECHO SLEEP
+ECHO *********************************************
+call ..\util\sleepandrestart.bat
+
+ECHO *********************************************
+ECHO CRASH BOARD DATA READ ERROR
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_data_read
+
+ECHO *********************************************
+ECHO SLEEP
+ECHO *********************************************
+call ..\util\sleepandrestart.bat
+
+ECHO *********************************************
+ECHO CRASH BOARD DATA WRITE ERROR
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_data_write
+
+ECHO *********************************************
+ECHO SLEEP
+ECHO *********************************************
+call ..\util\sleepandrestart.bat
+
+ECHO *********************************************
+ECHO CHECK FOR FOUR SELF FILES TO BE GENERATED
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.coredump-monitor.coredump-monitor-007
+time /t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-009.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-monitor-002.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Ensure build time configuration parameters are correct
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:CrashBoardWithTrace
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.processcrash.testListAndDeleteAllCrashes
+goto:eof
+
+:CrashBoardWithTrace
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.crash_system.crash_data_read_with_trace
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.coredump-monitor.coredump-monitor-009
+goto:eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-010.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,86 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+ECHO *********************************************
+ECHO DT-coredump-monitor-010.bat
+ECHO *********************************************
+
+ECHO TO CHECK FOR MULTIPLE CRASHES
+
+ECHO *********************************************
+ECHO DELETING ALL CRASHES
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.processcrash.testListAndDeleteAllCrashes
+
+ECHO *********************************************
+ECHO CONFIGURING SCM TO HOLD MINIMUM INFORMATION
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.processcrash.testSCMZeroConfig
+
+ECHO *********************************************
+ECHO CRASHING BOARD FOR FOUR TIMES
+ECHO *********************************************
+
+ECHO *********************************************
+ECHO CRASH BOARD PREFETCH ABORT
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_prefetch_abort
+
+ECHO *********************************************
+ECHO SLEEP
+ECHO *********************************************
+call ..\util\sleepandrestart.bat
+
+ECHO *********************************************
+ECHO CRASH BOARD DATA READ ERROR
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_data_read
+
+ECHO *********************************************
+ECHO SLEEP
+ECHO *********************************************
+call ..\util\sleepandrestart.bat
+
+ECHO *********************************************
+ECHO CRASH BOARD DATA WRITE ERROR
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_data_write
+
+ECHO *********************************************
+ECHO SLEEP
+ECHO *********************************************
+call ..\util\sleepandrestart.bat
+
+ECHO *********************************************
+ECHO CRASH BOARD DATA Undef Instr ERROR
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_undef_Instr
+
+ECHO *********************************************
+ECHO SLEEP
+ECHO *********************************************
+call ..\util\sleepandrestart.bat
+
+ECHO *********************************************
+ECHO CHECK FOR FOUR CRASHES IN FLASH
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.coredump-monitor.coredump-monitor-010_1
+
+ECHO *********************************************
+ECHO DELETING ALL CRASHES
+ECHO *********************************************
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.processcrash.testListAndDeleteAllCrashes
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-011.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,66 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-monitor-011.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Test crash information in the ELF file namely
+echo			1 Crash Type
+echo			2 Thread Name
+echo			3 Process ID
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:CrashBoard
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.processcrash.testListAndDeleteAllCrashes
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_prefetch_abort
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.coredump-monitor.coredump-monitor-011
+goto:eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-012.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,94 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+rem Parse the input parameters
+set numCrashes=0
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/c" goto GetCrashNum
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:GetCrashNum
+shift
+set numCrashes=%1
+goto:while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-monitor-012.bat /c=c [/desc] [/?]
+echo.
+echo			num is the number of crashes to test. Must be greater than 1	/c num
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Test crash information in Multiple ELF file namely
+echo			1 Crash Type
+echo			2 Thread Name Validation
+echo			3 Process ID
+exit /B n
+
+:Main
+if %numCrashes% GTR 1 (
+	call:CleanFlashPartition
+	call:ConfigureScm
+	for /L %%i in (1,1,%numCrashes%) do (
+		call:CrashBoard
+		call:Sleep
+		)
+	call:ValidateFiles
+)else (
+	call:DisplayHelp
+)
+set numCrashes=
+
+exit /B n
+
+:CleanFlashPartition
+echo Cleaning flash partition...
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.processcrash.testListAndDeleteAllCrashes
+goto:eof
+
+:ConfigureScm
+echo Configuring SCM...
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.processcrash.testSCMZeroConfig
+goto:eof
+
+:CrashBoard
+echo Crashing board...
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_prefetch_abort
+goto:eof
+
+:Sleep
+echo Sleeping...
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:ValidateFiles
+echo Validating...
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.coredump-monitor.coredump-monitor-012
+goto:eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-013.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,64 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-monitor-013.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Processing Corrupt Crash should return KErrCorrupt, part of the negative test case of CDS ProcessCrash
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:CrashBoard
+call:ShortSleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.flash_utility.clean_partition
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_prefetch_abort
+goto:eof
+
+:ShortSleep
+call ..\util\shortersleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.coredump-monitor.coredump-monitor-013
+goto:eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-014.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-monitor-014.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Processing Asynchronously for the Crash Log from flash
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:CrashBoard
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_entire_partition
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_prefetch_abort
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.coredump-monitor.coredump-monitor-014
+goto:eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-monitor-015.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-monitor-015.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Processing Asynchronously for the Crash Log from flash while processing of live crash is in progress
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:CrashBoard
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_entire_partition
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_prefetch_abort
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.coredump-monitor.coredump-monitor-015
+goto:eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-performance-001.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,64 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem DT-coredump-performance-001.bat.bat
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-performance-001.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Performance validation
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:CrashBoard
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_partition
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_prefetch_abort
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.coredump-performance.coredump-performance-001
+goto:eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-server-001.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,64 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-server-001.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Trusted CDS should be able to retrieve system crash data via the new data source API
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:CrashBoard
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_partition
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.crash_system.crash_data_read
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.coredump-server.coredump-server-001
+goto:eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-server-002.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,49 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-server-002.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Untrusted CDS should not be able to retrieve crash data via the new data source API
+exit /B n
+
+:Main
+call:Validate
+exit /B n
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.coredump-server.coredump-server-002
+goto:eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-coredump-server-003.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem DT-coredump-server-003.bat
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-server-003.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Trusted CDS should be able to retrieve trace data via the new data source API
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:CrashBoard
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_partition
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.crash_system.crash_data_read_with_trace
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.coredump-server.coredump-server-003
+goto:eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-formatters-SELF-001.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-SELF-001.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Test SELF Configuration to hold trace data with a system crash
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:CrashBoard
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_partition
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_data_read_with_trace
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.formatters-SELF.formatters-SELF-001
+goto:eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-formatters-SELF-0010.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,69 @@
+@echo OFF
+
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem  Batch file to run this test case
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-SELF-0010.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		For system crashes the SELF file should contain variant specific data when the SCM is configured to dump it
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:ConfigureToHoldVariantSpecificData
+call:CrashBoard
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_partition
+goto:eof
+
+:ConfigureToHoldVariantSpecificData
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.configureScm.holdVariantData
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.crash_system.crash_data_read
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.formatters-SELF.formatters-SELF-0010
+goto:eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-formatters-SELF-0011.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,70 @@
+@echo OFF
+
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem  Batch file to run this test case
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-SELF-0011.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		For system crashes the SELF file should not contain variant specific data for a system crash when the
+echo		SCM is not configured to do
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:ConfigureToNotHoldVariantSpecificData
+call:CrashBoard
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_partition
+goto:eof
+
+:ConfigureToNotHoldVariantSpecificData
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.configureScm.dontDumpVariantData
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.crash_system.crash_data_read
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.formatters-SELF.formatters-SELF-0011
+goto:eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-formatters-SELF-005.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-SELF-005.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		Test SELF Configuration to hold heap data
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:CrashBoard
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_partition
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.crash_system.crash_prefetch_abort
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}/tcds_kernel/group/tcds_kernel.driver#system_crash.formatters-SELF.formatters-SELF-005
+goto:eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-formatters-SELF-009.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,64 @@
+@echo OFF
+
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+:while
+if "%1"=="" goto Main
+if "%1"=="/d" goto DisplayTestInfo
+if "%1"=="/?" goto DisplayHelp
+shift
+goto while
+
+:DisplayHelp
+echo.
+echo	Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+echo	All rights reserved.
+echo.
+echo		Usage:	DT-coredump-SELF-009.bat [/desc] [/?]
+echo.
+echo			Display Usage							/?
+echo			Display Description						/d
+exit /B n
+
+:DisplayTestInfo
+echo.
+echo		Test Description:
+echo		The SELF dump file should be verified to display the CPU ID of the thread it was running on
+exit /B n
+
+:Main
+call:CleanFlashPartition
+call:CrashBoard
+call:Sleep
+call:Validate
+exit /B n
+
+:CleanFlashPartition
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.flash_utility.clean_partition
+goto:eof
+
+:CrashBoard
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.crash_system.crash_data_read
+goto:eof
+
+:Sleep
+call ..\util\sleepandrestart.bat
+goto:eof
+
+:Validate
+call testdriver run -p armv5 -b udeb -s file:/${sourceroot}\tcds_kernel\group\tcds_kernel.driver#system_crash.formatters-SELF.formatters-SELF-009
+goto:eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/DT-runall.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,45 @@
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+@ECHO OFF
+
+@echo off
+setlocal
+set starttime=%time%
+
+REM Call our batch files first
+
+call DT-coredump-server-001.bat
+call DT-coredump-server-002.bat
+call DT-coredump-server-003.bat
+
+call DT-coredump-monitor-002.bat
+call DT-coredump-monitor-004.bat
+call DT-coredump-monitor-005.bat
+call DT-coredump-monitor-007.bat
+call DT-coredump-monitor-009.bat
+call DT-coredump-monitor-010.bat
+call DT-coredump-monitor-011.bat
+call DT-coredump-monitor-012.bat
+call DT-coredump-monitor-013.bat
+
+call DT-formatters-SELF-001.bat
+REM call DT-formatters-SELF-003.bat
+call DT-formatters-SELF-005.bat
+call DT-formatters-SELF-009.bat
+
+call DT-coredump-performance-001.bat
+
+echo Start Time=%starttime% - End Time=%time%
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/tests/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/autoexec.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,17 @@
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+testexecute Z:\scripts\tcds_kernel.script
+copy c:\logs\testexecute\* E:\*
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/buildandconfigtestdriver.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,29 @@
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem buildandconfiguretestdriver.bat
+rem
+
+@ECHO OFF
+ECHO Configure Test Driver
+
+call testdriver config --import ..\..\testdriver\td_proj_tefblock.xml
+
+call testdriver import
+
+call testdriver config
+
+REM BUILD COMPONENTS**************************************************************
+ECHO BUILD COMPONENTS
+
+call testdriver build 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/loopthetests.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,17 @@
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+REM  FOR /L %%parameter IN (start,step,end) DO command 
+FOR /L %%G IN (1,1,40) DO CALL maintestexecute.bat
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/maintestexecute.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,29 @@
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+@ECHO OFF
+
+REM EXECUTE STUFF*******************************************************************
+ECHO RUN THE CRASHAPP
+
+call testdriver run -p armv5 -b udeb -s file:/O:\perforce_root\1700\coredumpserver\personal\test\automatictests\tcds_kernel\group\tcds_kernel.driver#testCDS.testCrashSystem.testCrashPrefetchAbort
+call sleepandrestart.bat
+
+ECHO Run the process crash
+REM RUN the processcrash script
+call testdriver run -p armv5 -b udeb -s file:/O:\perforce_root\1700\coredumpserver\personal\test\automatictests\tcds_kernel\group\tcds_kernel.driver#testCDS.testProcessCrash.testProcessHeader
+
+ECHO DONE
+REM ************************************************************************************
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/shortersleepandrestart.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+@ECHO OFF
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO Lets not wait for the SCM to complete
+ping -n 50 127.0.0.1 >NUL
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+
+call hardwareswitch off
+ECHO Board Switched OFF
+ping -n 11 127.0.0.1 >NUL
+ECHO ---------------------
+ECHO Board Switched ON
+call hardwareswitch on
+ping -n 37 127.0.0.1 >NUL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/sleepandrestart.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+@ECHO OFF
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO Wait for a minute for the crash to happen
+ping -n 85 127.0.0.1 >NUL
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+ECHO .
+
+call hardwareswitch off
+ECHO Board Switched OFF
+ping -n 11 127.0.0.1 >NUL
+ECHO ---------------------
+ECHO Board Switched ON
+call hardwareswitch on
+ping -n 37 127.0.0.1 >NUL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/batch/util/wait.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,16 @@
+rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+call testdriver run -p armv5 -b udeb -s file:/M:/perforce/DP/development/personal/2008/sakhyaghosh/PREQ1700/master/debug/coredump/test/automatictests/tcds_kernel/group/tcds_kernel.driver#testCDS.testProcessCrash.testProcessHeader
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/data/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/data/tcds_kernel.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,64 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+//
+
+//Name of test session
+[crashb]
+name	=	crashb
+
+[Kernel_PrefetchAbort]
+CrashAppParam=-k -d60 -c1
+
+[Kernel_EDataRead]
+CrashAppParam=-k -d60 -c2
+
+[Kernel_EDataReadWithTrace]
+CrashAppParam=-k -d30 -c2 -t
+
+[Kernel_EDataWrite]
+CrashAppParam=-k -d60 -c3
+
+[Kernel_UndefInstr]
+CrashAppParam=-k -d60 -c4
+
+[Kernel_StackOverflow]
+CrashAppParam=-k -d60 -c7
+
+[Kernel_DivisionByZero]
+CrashAppParam=-k -d60 -c13
+
+[User_PrefetchAbort]
+CrashAppParam=-c2 -d1
+
+[SELFFile_Path]
+selffile = e:\\coredump
+
+//Name of test session
+[processb]
+name	=	processb
+
+[debugsecurityserver]
+name   =  debugsecurityserver
+
+[server]
+name   =  server
+
+[monitor]
+name   =  monitor
+
+[self]
+name   =  self
+
+//Add more Kernel Crashes
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/data/tcds_scm_config.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,77 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+//
+
+// @File tcds_scm_config.ini
+
+//Name of test session
+[scmConfig]
+name	=	scmConfig
+
+//Note, the options refer to the TSCMDataType enumeration
+[EExceptionStacks]
+value = 0
+
+[EVariantSpecificData]
+value = 1
+
+[ERomInfo]
+value = 2
+
+[ELocks]
+value = 3
+
+[EKernelHeap]
+value = 4
+
+[ETraceData]
+value = 5
+
+[EProcessCodeSegs]
+value = 6
+
+[EThreadsUsrStack]
+value = 7
+
+[EThreadsSvrStack]
+value = 8
+
+[EThreadsUsrRegisters]
+value = 9
+
+[EThreadsSvrRegisters]
+value = 10
+
+[EProcessMetaData]
+value = 11
+
+[EThreadsMetaData]
+value = 12
+
+[ECrashedProcessCodeSegs]
+value = 13
+
+[ECrashedProcessUsrStacks]
+value = 14
+
+[ECrashedProcessSvrStacks]
+value = 15
+
+[ECrashedProcessMetaData]
+value = 16
+
+[ECrashedThreadMetaData]
+value = 17
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/data/tcds_self.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,32 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+// @File tcds_self.ini
+
+
+[self]
+name	=	self
+
+[self0010]
+filename = C:\self0010.elf
+source = systemcrash
+crashid = 0
+section = variantdata
+
+[self0011]
+filename = C:\self0011.elf
+source = systemcrash
+crashid = 0
+section = variantdata
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+
+PRJ_TESTEXPORTS
+../scripts/tcds_scm_config.script			/epoc32/winscw/c/scripts/tcds_scm_config.script
+../scripts/tcds_kernel_crash.script			/epoc32/winscw/c/scripts/tcds_kernel_crash.script
+../scripts/tcds_kernel_process.script		/epoc32/winscw/c/scripts/tcds_kernel_process.script
+../scripts/DT-coredump-server.script		/epoc32/winscw/c/scripts/DT-coredump-server.script
+../scripts/DT-coredump-monitor.script		/epoc32/winscw/c/scripts/DT-coredump-monitor.script
+../scripts/DT-coredump-performance.script	/epoc32/winscw/c/scripts/DT-coredump-performance.script
+../../nand/coredump_nandloader.bat			/epoc32/rom/nandloader/autoexec.bat
+
+../data/tcds_scm_config.ini			/epoc32/winscw/c/data/tcds_scm_config.ini
+../data/tcds_self.ini			/epoc32/winscw/c/data/tcds_self.ini
+../data/tcds_kernel.ini			/epoc32/winscw/c/data/tcds_kernel.ini
+
+PRJ_MMPFILES
+// None
+
+PRJ_TESTMMPFILES
+tcds_kernel.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/tcds_kernel.driver	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,614 @@
+<?xml version="1.0" encoding="ASCII"?>
+<driver:driver xmlns:driver="http://www.symbian.com/TestDriver">
+<task name="system_crash" timeout="1000000">
+	<executeOnPC>
+		<build testBuild="true" URI="${sourceroot}\tcds_kernel\group">
+			<componentName>tcds_kernel</componentName>
+		</build>
+	</executeOnPC>
+
+	<task name="configureScm" timeout="100000">
+		<task name="holdVariantData" timeout="100000">
+			<transferToSymbian>
+				<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_scm_config.ini" SymbianPath="c:\data\tcds_scm_config.ini"/>
+			</transferToSymbian>
+
+			<transferToSymbian>
+					<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\oemdebug_10282FE5.exe" SymbianPath="c:\sys\bin\oemdebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_scm_config.script" SymbianPath="c:\scripts\tcds_scm_config.script">
+					<testCasesList operator="include">
+						<testCase target="DT-SCM-CONFIG-0001"/>
+					</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="dontDumpVariantData" timeout="100000">
+			<transferToSymbian>
+				<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_scm_config.ini" SymbianPath="c:\data\tcds_scm_config.ini"/>
+			</transferToSymbian>
+
+			<transferToSymbian>
+					<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\oemdebug_10282FE5.exe" SymbianPath="c:\sys\bin\oemdebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_scm_config.script" SymbianPath="c:\scripts\tcds_scm_config.script">
+					<testCasesList operator="include">
+						<testCase target="DT-SCM-CONFIG-0002"/>
+					</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+	</task>
+
+	<!-- This task performs flash utility methods such as cleaning the partition etc -->
+	<task name="flash_utility" timeout="100000">
+			<task name="clean_partition" timeout="100000">
+				<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+				</transferToSymbian>
+
+				<transferToSymbian>
+					<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\oemdebug_10282FE5.exe" SymbianPath="c:\sys\bin\oemdebug_10282FE5.exe"/>
+				</transferToSymbian>
+
+				<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_crash.script" SymbianPath="c:\scripts\tcds_kernel_crash.script">
+					<testCasesList operator="include">
+						<testCase target="DT-BOARD-UTILS-0008"/>
+					</testCasesList>
+					</testExecuteScript>
+				</executeOnSymbian>
+			</task>
+
+			<task name="clean_entire_partition" timeout="100000">
+				<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+				</transferToSymbian>
+
+				<transferToSymbian>
+					<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\oemdebug_102836BC.exe" SymbianPath="c:\sys\bin\oemdebug_102836BC.exe"/>
+				</transferToSymbian>
+
+				<transferToSymbian>
+					<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\oemdebug_10282FE5.exe" SymbianPath="c:\sys\bin\oemdebug_10282FE5.exe"/>
+				</transferToSymbian>
+
+				<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_crash.script" SymbianPath="c:\scripts\tcds_kernel_crash.script">
+					<testCasesList operator="include">
+						<testCase target="DT-BOARD-UTILS-0009"/>
+					</testCasesList>
+					</testExecuteScript>
+				</executeOnSymbian>
+			</task>
+	</task>
+
+	<task name="crash_system" timeout="100000">
+			<task name="crash_prefetch_abort" timeout="100000">
+				<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+				</transferToSymbian>
+				<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_crash.script" SymbianPath="c:\scripts\tcds_kernel_crash.script">
+					<testCasesList operator="include">
+						<testCase target="DT-BOARD-UTILS-0001"/>
+					</testCasesList>
+					</testExecuteScript>
+				</executeOnSymbian>
+			</task>
+
+			<task name="crash_data_read" timeout="100000">
+				<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+				</transferToSymbian>
+				<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_crash.script" SymbianPath="c:\scripts\tcds_kernel_crash.script">
+					<testCasesList operator="include">
+						<testCase target="DT-BOARD-UTILS-0002"/>
+					</testCasesList>
+					</testExecuteScript>
+				</executeOnSymbian>
+			</task>
+
+			<task name="crash_data_write" timeout="100000">
+				<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+				</transferToSymbian>
+				<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_crash.script" SymbianPath="c:\scripts\tcds_kernel_crash.script">
+					<testCasesList operator="include">
+						<testCase target="DT-BOARD-UTILS-0003"/>
+					</testCasesList>
+					</testExecuteScript>
+				</executeOnSymbian>
+			</task>
+
+			<task name="crash_undef_Instr" timeout="100000">
+				<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+				</transferToSymbian>
+				<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_crash.script" SymbianPath="c:\scripts\tcds_kernel_crash.script">
+					<testCasesList operator="include">
+						<testCase target="DT-BOARD-UTILS-0004"/>
+					</testCasesList>
+					</testExecuteScript>
+				</executeOnSymbian>
+			</task>
+
+			<task name="crash_stack_overflow" timeout="100000">
+				<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+				</transferToSymbian>
+				<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_crash.script" SymbianPath="c:\scripts\tcds_kernel_crash.script">
+					<testCasesList operator="include">
+						<testCase target="DT-BOARD-UTILS-0005"/>
+					</testCasesList>
+					</testExecuteScript>
+				</executeOnSymbian>
+			</task>
+
+			<task name="crash_division_by_zero" timeout="100000">
+				<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+				</transferToSymbian>
+				<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_crash.script" SymbianPath="c:\scripts\tcds_kernel_crash.script">
+					<testCasesList operator="include">
+						<testCase target="DT-BOARD-UTILS-0006"/>
+					</testCasesList>
+					</testExecuteScript>
+				</executeOnSymbian>
+			</task>
+
+			<task name="crash_data_read_with_trace" timeout="100000">
+				<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+				</transferToSymbian>
+				<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_crash.script" SymbianPath="c:\scripts\tcds_kernel_crash.script">
+					<testCasesList operator="include">
+						<testCase target="DT-BOARD-UTILS-0007"/>
+					</testCasesList>
+					</testExecuteScript>
+				</executeOnSymbian>
+			</task>
+
+	</task>
+
+	<task name="processcrash" timeout="1000000">
+		<task name="ProcessHeader" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_process.script" SymbianPath="c:\scripts\tcds_kernel_process.script"/>
+			</executeOnSymbian>
+			<retrieveFromSymbian>
+				<transfer move="true" PCPath="${resultroot}\tcds_kernel\thedump.dmp" SymbianPath="e:\thedump.dmp" />
+			</retrieveFromSymbian>
+		</task>
+
+		<task name="testListAndDeleteAllCrashes" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_process.script" SymbianPath="c:\scripts\tcds_kernel_process.script">
+				<testCasesList operator="include">
+					<testCase target="DT-kernelcrash-process-0002"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="testSCMZeroConfig" timeout="10000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_process.script" SymbianPath="c:\scripts\tcds_kernel_process.script">
+				<testCasesList operator="include">
+					<testCase target="DT-kernelcrash-process-0003"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="testValidELFFile" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\tcds_kernel_process.script" SymbianPath="c:\scripts\tcds_kernel_process.script">
+				<testCasesList operator="include">
+					<testCase target="DT-COREDUMP-MONITOR-011"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+	</task>
+
+	<task name="coredump-server" timeout="1000000">
+		<task name="coredump-server-001" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\oemdebug_102836BC.exe" SymbianPath="c:\sys\bin\oemdebug_102836BC.exe"/>
+			</transferToSymbian>
+
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-server.script" SymbianPath="c:\scripts\DT-coredump-server.script">
+						<testCasesList operator="include">
+							<testCase target="DT-coredump-server-001"/>
+						</testCasesList>
+					</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="coredump-server-002" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-server.script" SymbianPath="c:\scripts\DT-coredump-server.script">
+						<testCasesList operator="include">
+							<testCase target="DT-coredump-server-002"/>
+						</testCasesList>
+					</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="coredump-server-003" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\oemdebug_102836BC.exe" SymbianPath="c:\sys\bin\oemdebug_102836BC.exe"/>
+			</transferToSymbian>
+
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\oemdebug_10282FE5.exe" SymbianPath="c:\sys\bin\oemdebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-server.script" SymbianPath="c:\scripts\DT-coredump-server.script">
+						<testCasesList operator="include">
+							<testCase target="DT-coredump-server-003"/>
+						</testCasesList>
+					</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+	</task>
+
+	<task name="coredump-monitor" timeout="1000000">
+
+		<task name="coredump-monitor-002" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-monitor.script" SymbianPath="c:\scripts\DT-coredump-monitor.script">
+						<testCasesList operator="include">
+							<testCase target="DT-coredump-monitor-002"/>
+						</testCasesList>
+					</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="coredump-monitor-004" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-monitor.script" SymbianPath="c:\scripts\DT-coredump-monitor.script">
+						<testCasesList operator="include">
+							<testCase target="DT-coredump-monitor-004"/>
+						</testCasesList>
+					</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="coredump-monitor-005" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-monitor.script" SymbianPath="c:\scripts\DT-coredump-monitor.script">
+						<testCasesList operator="include">
+							<testCase target="DT-coredump-monitor-005"/>
+						</testCasesList>
+					</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="coredump-monitor-007" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-monitor.script" SymbianPath="c:\scripts\DT-coredump-monitor.script">
+				<testCasesList operator="include">
+					<testCase target="DT-COREDUMP-MONITOR-007"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="coredump-monitor-009" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-monitor.script" SymbianPath="c:\scripts\DT-coredump-monitor.script">
+				<testCasesList operator="include">
+					<testCase target="DT-COREDUMP-MONITOR-009"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="coredump-monitor-010_1" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-monitor.script" SymbianPath="c:\scripts\DT-coredump-monitor.script">
+				<testCasesList operator="include">
+					<testCase target="DT-COREDUMP-MONITOR-010"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="coredump-monitor-011" timeout="100000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-monitor.script" SymbianPath="c:\scripts\DT-coredump-monitor.script">
+				<testCasesList operator="include">
+					<testCase target="DT-COREDUMP-MONITOR-011"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="coredump-monitor-012" timeout="1000000">
+			<transferToSymbian>
+				<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+		
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-monitor.script" SymbianPath="c:\scripts\DT-coredump-monitor.script">
+				<testCasesList operator="include">
+					<testCase target="DT-COREDUMP-MONITOR-012"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="coredump-monitor-013" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+		
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-monitor.script" SymbianPath="c:\scripts\DT-coredump-monitor.script">
+				<testCasesList operator="include">
+					<testCase target="DT-COREDUMP-MONITOR-013"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+			</task>
+
+		<task name="coredump-monitor-014" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+		
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-monitor.script" SymbianPath="c:\scripts\DT-coredump-monitor.script">
+				<testCasesList operator="include">
+					<testCase target="DT-COREDUMP-MONITOR-014"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="coredump-monitor-015" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-monitor.script" SymbianPath="c:\scripts\DT-coredump-monitor.script">
+				<testCasesList operator="include">
+					<testCase target="DT-COREDUMP-MONITOR-015"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+	</task>
+
+	<task name="formatters-SELF" timeout="1000000">
+
+		<task name="formatters-SELF-001" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-formatters-SELF.script" SymbianPath="c:\scripts\DT-formatters-SELF.script">
+				<testCasesList operator="include">
+					<testCase target="DT-formatters-SELF-001"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="formatters-SELF-005" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-formatters-SELF.script" SymbianPath="c:\scripts\DT-formatters-SELF.script">
+				<testCasesList operator="include">
+					<testCase target="DT-formatters-SELF-005"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="formatters-SELF-009" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-formatters-SELF.script" SymbianPath="c:\scripts\DT-formatters-SELF.script">
+				<testCasesList operator="include">
+					<testCase target="DT-formatters-SELF-009"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="formatters-SELF-0010" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_self.ini" SymbianPath="c:\data\tcds_self.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-formatters-SELF.script" SymbianPath="c:\scripts\DT-formatters-SELF.script">
+				<testCasesList operator="include">
+					<testCase target="DT-formatters-SELF-0010"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+		<task name="formatters-SELF-0011" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_self.ini" SymbianPath="c:\data\tcds_self.ini"/>
+			</transferToSymbian>
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+				<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-formatters-SELF.script" SymbianPath="c:\scripts\DT-formatters-SELF.script">
+				<testCasesList operator="include">
+					<testCase target="DT-formatters-SELF-0011"/>
+				</testCasesList>
+				</testExecuteScript>
+			</executeOnSymbian>
+		</task>	
+	</task>
+
+	<task name="coredump-performance" timeout="1000000">
+
+		<task name="coredump-performance-001" timeout="1000000">
+			<transferToSymbian>
+					<transfer move="false" PCPath="${sourceroot}\tcds_kernel\data\tcds_kernel.ini" SymbianPath="c:\data\tcds_kernel.ini"/>
+			</transferToSymbian>
+
+			<transferToSymbian>
+				<transfer PCPath="${epocroot}\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" SymbianPath="c:\sys\bin\OEMDebug_10282FE5.exe"/>
+			</transferToSymbian>
+
+			<executeOnSymbian>
+					<testExecuteScript PCPath="${sourceroot}\tcds_kernel\scripts\DT-coredump-performance.script" SymbianPath="c:\scripts\DT-coredump-performance.script">
+						<testCasesList operator="include">
+							<testCase target="DT-coredump-performance-001"/>
+						</testCasesList>
+					</testExecuteScript>
+			</executeOnSymbian>
+		</task>
+
+	</task>
+
+</task>
+</driver:driver>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/tcds_kernel.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,68 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET				tcds_kernel.exe
+TARGETTYPE			exe
+UID					0x1000007A 0x102836BC
+
+//Please add any change under here
+SOURCEPATH			../src
+SOURCE				tcds_kernelBlockServer.cpp
+SOURCE				tcds_kernelBlockController.cpp
+
+USERINCLUDE 		../inc
+USERINCLUDE			../../../../server/inc
+USERINCLUDE			../inc/cds
+
+SYSTEMINCLUDE   \epoc32\include\stdapis
+
+SYSTEMINCLUDE		\epoc32\include
+SYSTEMINCLUDE		\epoc32\include\drivers
+SYSTEMINCLUDE		\epoc32\include\test
+SYSTEMINCLUDE		\epoc32\include\tools
+SYSTEMINCLUDE		\epoc32\include\tools\coredump
+SYSTEMINCLUDE		\epoc32\include\ecom
+SYSTEMINCLUDE		\epoc32\include\stdapis
+SYSTEMINCLUDE		\epoc32\include\libc
+
+//Please add your system include under here.
+
+LIBRARY				euser.lib
+LIBRARY				testexecuteutils.lib
+LIBRARY				testexecutelogclient.lib
+LIBRARY				cdssupport.lib
+LIBRARY				efsrv.lib
+LIBRARY				libc.lib
+LIBRARY				bafl.lib
+LIBRARY				hal.lib
+
+//WRAPPERS Source Code
+SOURCEPATH ..\src\cds
+
+SOURCE t_process_crash.cpp
+SOURCE t_crash_board.cpp
+SOURCE t_coredumpserver.cpp
+SOURCE t_coredumpmonitor.cpp
+SOURCE t_scm_config.cpp
+SOURCE t_self.cpp
+
+SOURCEPATH ../../../../server/src
+SOURCE flashdatasource.cpp
+
+LIBRARY coredumpinterface.lib //Core Dump Server
+
+STATICLIBRARY scmusr_lib.lib
+
+//MACRO CDSDEBUG for LOG_MSG SOURCE t_coredumpserver.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/tcds_kernel_autoexec.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+
+testexecute Z:\scripts\DT-formatters-SELF.script
+testexecute z:\scripts\DT-coredump-monitor.script
+testexecute z:\scripts\tcds_unit.script
+
+
+copy c:\logs\testexecute\* E:\*
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/group/tcds_kernel_config.xml	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE preferences SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>
+
+<preferences EXTERNAL_XML_VERSION="1.0">
+  <root type="user">
+    <map />
+    <node name="com">
+      <map />
+      <node name="symbian">
+        <map />
+        <node name="driver">
+          <map>
+            <entry key="bldmake" value="true" />
+            <entry key="buildNumber" value="MSF00167_Symbian_OS_vtb92sf" />
+            <entry key="clean" value="false" />
+            <entry key="client" value="localhost" />
+            <entry key="entryPointAddress" value="file:/Y:\sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\automatictests\tcds_kernel\group\tcds_kernel.driver#system_crash" />
+            <entry key="epocRoot" value="Y:\" />
+            <entry key="jobID" value="0" />
+            <entry key="jobsfolder" value="c:\Jobs" />
+            <entry key="kernel" value="EKA2" />
+            <entry key="mode" value="sync" />
+            <entry key="platform" value="armv5" />
+            <entry key="platsec" value="true" />
+            <entry key="rdebug" value="" />
+            <entry key="repositoryRoot" value="Y:\testdriver\repos" />
+            <entry key="resultRoot" value="Y:\logs\testdriver" />
+            <entry key="rom" value="" />
+            <entry key="runNumber" value="2" />
+            <entry key="server" value="//localhost/RemoteTestDriver" />
+            <entry key="server_name" value="localhost" />
+            <entry key="service" value="RemoteTestDriver" />
+            <entry key="sysbin" value="false" />
+            <entry key="sourceRoot" value="Y:\sf\dev\devicedbgsrvs\dbgsrv\coredumpserver\test\automatictests" />
+            <entry key="trgtest" value="0" />
+            <entry key="testExecute" value="false" />
+            <entry key="testPackage" value="Y:\\.\test.pkg" />
+            <entry key="transport" value="serial3" />
+            <entry key="uccAddress" value="" />
+            <entry key="variant" value="udeb" />
+            <entry key="wintap" value="192.168.0.3" />
+            <entry key="workingPath" value="c:\SITK\testdriver\" />
+            <entry key="xmlRoot" value="Y:\" />
+            <entry key="commDB" value="off" />
+            <entry key="uidFirst" value="0x10210D02" />
+            <entry key="uidLast" value="0x10210D32" />
+            <entry key="key" value="" />
+            <entry key="cert" value="" />
+            <entry key="statTimeout" value="300000" />
+          </map>
+        </node>
+      </node>
+    </node>
+  </root>
+</preferences>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_common_defs.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,107 @@
+/**
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file t_common_defs.h
+ @internalTechnology
+ @prototype
+*/
+
+#ifndef __COMMON_DEFS__
+#define __COMMON_DEFS__
+
+/** CDS UID */
+const TUid KCDSUid = TUid::Uid(0x10282FE5);
+
+/** UTRACE Formatter UID */
+const TUid KUtraceUid = TUid::Uid(0x102836BA);
+
+/** File Writer UID */
+const TUid KUidFileWriter= TUid::Uid(0x102831e4);
+
+/** Symbian ELF formatter UID */
+const TUid KUidELFFormatter = TUid::Uid(0x10282fe3);
+
+const TUid KUidELFFormatterV2 = TUid::Uid(0x102836bb);
+
+/** Expected Crash File Name */
+_LIT(KCrashFileName, "e:\\naibmys");
+
+/** wildcard used to search for the SELF File created for kernel crash*/
+_LIT(KCrashWildCard, "naibmys*");
+
+/** Setting Directory Path to E:\\ MMC card */
+_LIT(KDir, "e:\\");
+
+/** Thread name of the test driver that crashes */
+_LIT(KThreadKernelCrash, "ekern.exe::crashdriver");
+
+/** Thread name of the user application that crashed */
+_LIT(KThreadUserCrash, "crash");
+
+/** The Debug Security Server's major version number. */
+const TUint KDebugServMajorVersionNumber=2;
+
+/** The Debug Security Server's minor version number. */
+const TUint KDebugServMinorVersionNumber=2;
+
+/** The Debug Security Server's patch version number. */
+const TUint KDebugServPatchVersionNumber=0;
+
+/** User mode CPSR **/
+const TUint32 KCPSRUsrMode = 0x10;
+
+/** 0x1000 ARM REGISTER CPSR **/
+const TUint32 KCPSRReg = 0x1000; 
+
+/** M[4:0] mode bits of the CPSR **/
+const TUint32 KModeBitCPSR = 0x0F;
+
+/** Trace category to be checked for **/
+const TInt KTraceCategory = 200;
+
+/** Maximum Time Out Value to be checked with the SELF File Creation time **/
+const TInt KMAXTIMEOUT = 25;
+
+/** INI File parameter for the crashapp */
+_LIT(KTe_CrashAppParam,"CrashAppParam");
+
+/** crashapp application used to crash the kernel */
+_LIT(KCrashAppFileName,"Z:\\sys\\bin\\crashapp.exe");
+
+
+_LIT( KPostCrashEventActionPrompt, "Action After Crash:\n  0-None,\n  1-Resume Thread,\n  2-Resume Process,\n  4-Kill Process" );
+_LIT(KSELFFileName,"selffile");
+_LIT(KFlashDumpFileName,"Z:\\sys\\bin\\flashdump.exe");
+_LIT(KTe_FlashDumpParam,"E:\\thedump");
+_LIT(KEndOfProcessing, "idle");
+_LIT( KFilePathPrompt, "not_important" );
+_LIT(KStartOfSELFProc, "-");
+_LIT( KDataSegmentPrompt, "Create Data Segments?" );
+_LIT( KCodeSegmentPrompt, "Create Code Segments?" );
+_LIT( KThreadSegmentPrompt, "Create Thread Segments?" );
+_LIT( KTrueFalseOpt, "True,False" );
+_LIT( KTrueOpt, "True" );
+_LIT( KFalseOpt, "False" );
+_LIT( KCreateTraceData, "How much Trace data to capture (Kb)" );
+
+
+
+
+#endif // __CPROCESSCRASHWRAPPER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_coredumpmonitor.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,83 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __COREDUMP_MONITOR_H__
+#define __COREDUMP_MONITOR_H__
+
+#include <datawrapper.h>
+#include <e32base.h> 
+#include <rm_debug_api.h>
+#include <coredumpinterface.h>
+#include <coredumpserverapi.h>
+#include <crashdatasave.h>
+#include <bafindf.h> 
+#include <scmconfigitem.h>
+
+#include "t_common_defs.h"
+
+/**
+ * This class is responsible for the core dump monitor tests. This is an extension
+ * of the SCM and the only way we can access and test it
+ */
+class CCoreDumpMonitorWrapper : public CDataWrapper
+	{
+	public:
+	
+		~CCoreDumpMonitorWrapper();
+	
+		static CCoreDumpMonitorWrapper* NewL();
+	
+		virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
+		virtual TAny* GetObject() { }
+		virtual void SetObjectL(TAny* aObject);
+	
+	protected:
+		void ConstructL();
+	
+	private:
+		
+		CCoreDumpMonitorWrapper();
+	
+		void PrepareTestL();
+		void TestUntrustedAccessToCDSConfigL();
+		void TestTrustedAccessToCDSConfigL();
+		void TestTraceBufferAccessL();
+		void TestReadDefaultConfigValuesL();
+		void DoConfigureL(const TUint32& aIndex, const TUint32& aUID,
+				const COptionConfig::TParameterSource& aSource,
+				const COptionConfig::TOptionType& aType, const TDesC& aPrompt,
+				const TUint32& aNumOptions, const TDesC& aOptions,
+				const TInt32& aVal, const TDesC& aStrValue, const TUint aInstance);
+		
+		
+	    void TestValidateNewestCrashL();
+	    
+	private:
+		
+		RCoreDumpSession iCoreDumpSession;
+		RCrashInfoPointerList iCrashList;
+		RFs iFsSession;
+	};
+#endif __COREDUMP_MONITOR_H__
+
+//eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_coredumpserver.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,69 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __COREDUMP_SERVER_H__
+#define __COREDUMP_SERVER_H__
+
+#include <datawrapper.h>
+#include <e32base.h>
+#include <rm_debug_api.h>
+#include <coredumpinterface.h>
+#include <coredumpserverapi.h>
+
+#include "t_common_defs.h"
+
+/**
+ * This class is responsible for the core dump server tests relating to system crash,
+ * and specifically, the flash data source
+ */
+class CCoreDumpServerWrapper : public CDataWrapper
+	{
+	public:
+
+		~CCoreDumpServerWrapper();
+
+		static CCoreDumpServerWrapper* NewL();
+
+		virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
+		virtual TAny* GetObject() { }
+		virtual void SetObjectL(TAny* aObject);
+		static void CleanupCrashList(TAny *aArray);
+
+	protected:
+		void ConstructL();
+
+	private:
+
+		CCoreDumpServerWrapper();
+
+		void PrepareTestL();
+		void TestDataSourceReturnsSystemCrashDataL();
+		void TestDataSourceReturnsTraceDataL();
+		void TestUntrustedServerAccessL();
+
+	private:
+
+		RCoreDumpSession iCoreDumpSession;
+		RSecuritySvrSession iSecSess;
+
+	};
+#endif __COREDUMP_SERVER_H__
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_crash_board.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,70 @@
+/**
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file t_crash_board.h
+ @internalTechnology
+ @prototype
+*/
+
+#ifndef __CCRASHBOARDWRAPPER_H__
+#define __CCRASHBOARDWRAPPER_H__
+
+#include <datawrapper.h>
+#include <rm_debug_api.h>
+#include <coredumpinterface.h>
+#include <coredumpserverapi.h>
+
+#include "t_common_defs.h"
+
+/**
+ * This class is responsible for testing our crashing the system functionality
+ */
+class CCrashBoardWrapper : public CDataWrapper
+	{
+
+public:
+
+	~CCrashBoardWrapper();
+
+	static CCrashBoardWrapper* NewL();
+
+	virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
+	virtual TAny* GetObject() { }
+	virtual void SetObjectL(TAny* aObject);
+
+protected:
+	void ConstructL();
+
+private:
+	/** Constructor */
+	CCrashBoardWrapper();
+
+	void PrepareTestL();
+
+    void DoCmdCrashBoardL(const TDesC& );
+    void DoCmdCleanCrashPartition();
+	void DoCmdCleanEntireCrashPartitionL();
+
+private:
+//add members here
+	//DSS session
+	RSecuritySvrSession iSecSess;
+	};
+#endif // __CCrashBoardWRAPPER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_process_crash.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,216 @@
+/**
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+/**
+ @file t_process_crash.h
+ @internalTechnology
+ @prototype
+*/
+
+#ifndef __CPROCESSCRASHWRAPPER_H__
+#define __CPROCESSCRASHWRAPPER_H__
+#include <e32property.h>
+#include <datawrapper.h>
+#include <e32base.h>
+#include <f32file.h>
+#include <bafindf.h >
+#include <e32btrace.h>
+#include <e32std.h>
+#include <hal.h>
+
+#include <coredumpinterface.h> //core dump interface API
+#include <optionconfig.h>
+#include <coredumpserverapi.h>
+#include <crashdatasave.h>
+
+#include <scmdatatypes.h>
+#include <symbianelfdefs.h>
+#include <scmconfigitem.h>
+
+#include "t_common_defs.h"
+
+const TInt MAXNUMBEROFDHDR = 200;
+
+enum TValidateString {EValExecutable, EValThread};
+
+class CProcessCrashWrapper;
+/**
+ * This class implements an Active Object to test the asynchronous ProcessCrashLog
+ */
+class CAsyncProcessCrash : public CActive
+	{
+public:
+
+	static CAsyncProcessCrash* NewL(CProcessCrashWrapper* );
+
+	~CAsyncProcessCrash( );
+
+	void IssueProcessCrashRequest(TUint aCrashId);
+
+private:
+
+	void ConstructL();
+
+	CAsyncProcessCrash(CProcessCrashWrapper* );
+
+  // from CActive
+	void RunL();
+
+	TInt RunError(TInt aError);
+
+	void DoCancel();
+
+	CProcessCrashWrapper* iProcessCrashWrapper;
+
+	TUint iCrashId;
+  	} ;
+
+/**
+ * This class is responsible for processing the crash information
+ */
+class CProcessCrashWrapper : public CDataWrapper
+	{
+
+public:
+
+	~CProcessCrashWrapper();
+
+	static CProcessCrashWrapper* NewL();
+
+	virtual TBool DoCommandL(const TTEFFunction& aCommand,
+			const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
+	virtual TAny* GetObject()
+		{
+		}
+	virtual void SetObjectL(TAny* aObject);
+
+protected:
+	void ConstructL();
+
+private:
+	/** Constructor */
+	CProcessCrashWrapper();
+
+	void PrepareTestL();
+	void DoCmdNewL();
+	void DoCmdReadCrashInfoL();
+	void DoCmdCheckMultipleCrashesL();
+	void DoCmdDeleteAllCrashL();
+	void DoCmdLoadPluginsL();
+	void DoCmdUnLoadPluginsL();
+	void DoCmdProcessCrashL(const TDesC&);
+	void DoCmdConfigurePluginsL(const TDesC& );
+	void DoCmdConfigureSCMZeroPriorityL();
+	void DoConfigureL(const TUint32& aIndex, const TUint32& aUID,
+			const COptionConfig::TParameterSource& aSource,
+			const COptionConfig::TOptionType& aType, const TDesC& aPrompt,
+			const TUint32& aNumOptions, const TDesC& aOptions,
+			const TInt32& aVal, const TDesC& aStrValue, const TUint aInstance);
+
+	void DoCmdValidateSingleELFFileL();
+	void DoCmdValidateAsyncProcessCrashLogL();
+	void DoCmdValidateAsyncProcessAndLiveCrashCrashLogL(const TDesC& );
+	void GenerateLiveCrashL(const TDesC& );
+	void ProcessSELFFileCreatedL();
+	void DoProcessSELFLiveandKernelL();
+    void DoCmdValidateMultipleELFFileL();
+    void DoCmdValidateCpuIDL();
+    void DoCmdValidateHeapSELFFileL();
+    void DoCmdValidateTraceSELFFileL();
+    void DoCmdPerformanceMeasureSELFFileL();
+    void DoCmdValidateCorruptCrashL();
+	void DoCmdConfigureSELFPluginWithInvalidnessL();
+
+	void ValidateHeaderELFFileL();
+	void ValidateProgramHeaderELFFileL();
+    void ValidateSymInfoSectionELFFileL();
+    void ValidateThreadInfoSectionELFFileL(TBool aValidateCpuId, const TDesC& aThreadCrashed, TBool aCheck);
+    void ValidateRegisterInfoSectionELFFileL();
+    void ValidateHeapSectionELFFileL(TBool );
+    void ValidateTraceSectionELFFileL(TBool );
+    void ValidateExceptionL(TInt ,TInt , TBool );
+	void ValidateStringL(TValidateString , TInt , const TDesC& , TBool );
+	void ValidateTraceBufferL(const TDesC8&  );
+	void ValidatePerformanceELFFile();
+
+    void GenerateElfFileL(TUint aCrashId, TBool aTiming = EFalse);
+    void MonitorProgressL();
+	void ConfigureSELF(TBool , TInt );
+	void CleanupMethod(const TDesC& );
+
+	void HelpStartTestTimer(void) { iStartTick = User::NTickCount(); iStopTick = 0; };
+	void HelpStopTestTimer(void) { iStopTick = User::NTickCount(); };
+	TInt HelpGetTestTicks(void) { return (iStopTick - iStartTick); };
+	TInt HelpTicksPerSecond();
+
+	void PrintErrorCondition(TInt );
+
+private:
+
+	/** Object to be tested */
+	//session object to the Core Dump Server
+	RCoreDumpSession iCoreDumpSession;
+
+	//TCrashInfo structure for crash info
+	RCrashInfoPointerList iCrashList;
+
+	//Active Object to handle async processing
+	CAsyncProcessCrash* iProcessCrash;
+
+	//File Server session
+	RFs iFsSession;
+	//File Handle for the ELF File
+	RFile iSELFFile;
+	//SELF File name
+	TBufC<KMaxFileName> iSELFFileName;
+	//stores the SELF Program Header
+	TUint8* iSELFPHHeader;
+	//Number of Program Header Entries
+	TInt iPHEntries;
+	//Program Header Offset
+	TInt iPHOffset;
+	//storing crashed thread id
+	TInt64 iCrashedThreadId;
+	//storing the thread Heap base address
+	TUint32	iHeapBase;
+	//thread heap size
+	TUint32	iHeapSize;
+	//thread name that crashed
+	RBuf iThreadCrashed;
+	//type of crash User/System
+	TBool iSystemCrash;
+
+	//stores the DHDR Buffers
+	TUint8* iDHDRBuffer[MAXNUMBEROFDHDR];
+	//actual SELF DHDR strcuture Sym32_dhdr
+	Sym32_dhdr* idhdr[MAXNUMBEROFDHDR];
+
+	//offset to the String section
+	TInt iOffsetStringSection;
+	//size of String section
+	TInt iSizeofStringSection;
+
+	enum TSELFSegment {EHeap, ETrace, ECode, EThread};
+
+	//start and stop tick counts
+	TInt iStartTick;
+	TInt iStopTick;
+
+	friend class CAsyncProcessCrash;
+
+	};
+#endif // __CPROCESSCRASHWRAPPER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_scm_config.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,62 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  Utility functions to allow us to configure the System Crash Monitor
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __SCM_CONFIG_H__
+#define __SCM_CONFIG_H__
+
+#include <datawrapper.h>
+#include <e32base.h>
+#include <coredumpinterface.h>
+#include <optionconfig.h>
+#include <scmconfigitem.h>
+
+#include "t_common_defs.h"
+
+/**
+ * This class is the test wrapper we use to configure the System Crash
+ * Monitor
+ */
+class CSCMConfigurationWrapper : public CDataWrapper
+	{
+	public:
+		~CSCMConfigurationWrapper();
+		static CSCMConfigurationWrapper* NewL();
+
+		virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
+		virtual TAny* GetObject() { return NULL; }
+		virtual void SetObject(TAny* aObject) { (void)aObject; }
+
+	protected:
+		void ConstructL();
+
+	private:
+		CSCMConfigurationWrapper();
+
+		void TurnOffConfigOptionL(TConfigItem::TSCMDataType& aParameter);
+		void TurnOnConfigOptionL(TConfigItem::TSCMDataType& aParameter);
+		void CSCMConfigurationWrapper::SetSCMParameterL(TConfigItem::TSCMDataType& aParameter, const TInt aPriority);
+
+	private:
+		RCoreDumpSession iCoreDumpSession;
+	};
+
+#endif __SCM_CONFIG_H__
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/cds/t_self.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,114 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  Utility functions to allow us to configure the System Crash Monitor
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __SELF_WRAPPER_H__
+#define __SELF_WRAPPER_H__
+
+#include <datawrapper.h>
+#include <e32base.h>
+#include <coredumpinterface.h>
+#include <optionconfig.h>
+#include <scmconfigitem.h>
+#include <symbianelfdefs.h>
+
+#include "t_common_defs.h"
+
+//ini file keys
+_LIT(KKeyCrashSource, "source");
+_LIT(KKeyCrashId, "crashid");
+_LIT(KKeyCrashName, "filename");
+_LIT(KKeyElfSection, "section");
+
+//commands
+_LIT(KCommandGenerateFile, "GenerateSelfFile");
+_LIT(KCommandFindSection, "VerifySectionExists");
+_LIT(KCommandVerifyNoSection, "VerifySectionDoesNotExist");
+
+//sources
+_LIT(KSourceSystemCrash, "systemcrash");
+
+//sections
+_LIT(KSectionsVariantData, "variantdata");
+
+/**
+ * Can only use in void functions
+ * @param x Boolean
+ * @param If we fail, pop and destroy y items
+ */
+#define T_SELF_ASSERT_TRUE(x, y) \
+	if(!x){\
+		ERR_PRINTF2(_L("Assertion Error in t_self.cpp line [%d]"), __LINE__);\
+		SetBlockResult(EFail);\
+		if(y>0)\
+			CleanupStack::PopAndDestroy(y);\
+		return; \
+		}
+
+/**
+ * Use for TUint returning functions
+ * @param x Boolean
+ * @param If we fail, pop and destroy y items
+ */
+#define T_SELF_ASSERT_TRUE_RET(x, y, z) \
+	if(!x){\
+		ERR_PRINTF2(_L("Assertion Error in t_self.cpp line [%d]"), __LINE__);\
+		SetBlockResult(EFail);\
+		if(y>0)\
+			CleanupStack::PopAndDestroy(y);\
+		return z; \
+		}
+/**
+ * This class is the test wrapper we use to configure the System Crash
+ * Monitor
+ */
+class CSymbianElfWrapper : public CDataWrapper
+	{
+	public:
+		~CSymbianElfWrapper();
+		static CSymbianElfWrapper* NewL();
+
+		virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
+		virtual TAny* GetObject() { return NULL; }
+		virtual void SetObject(TAny* aObject) { (void)aObject; }
+
+	protected:
+		void ConstructL();
+
+	private:
+		CSymbianElfWrapper();
+		void GenerateFileFromSystemCrashL(TDesC& aCrashName, TInt aCrashId);
+
+		TUint GetSectionOffset(RFile& aElfFile, ESYM_NOTE_TYPE aNoteType);
+		TUint GetSectionSize(RFile& aElfFile, ESYM_NOTE_TYPE aNoteType);
+		void CacheElfHeader(RFile& aElfFile);
+
+		void VerifySection(TDesC& aSectionToVerify, TDesC& aCrashName, TBool aExists);
+		void ValidateElfFile(RFile& aElfFile);
+		void VerifyVariantData(RFile& aElfFile, TBool aExists);
+
+	private:
+		RCoreDumpSession iCoreDumpSession;
+		RFs iFsSession;
+		Elf32_Ehdr iElfHeader;
+	};
+
+#endif __SCM_CONFIG_H__
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/tcds_kernelBlockController.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,42 @@
+/**
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+/**
+ @file tcds_kernelBlockController.h
+ @internalTechnology
+*/
+
+#ifndef __TCDS_kernel_BLOCK_CONTROLLER_H__
+#define __TCDS_kernel_BLOCK_CONTROLLER_H__
+#include <TestBlockController.h>
+
+//wrapper includes here
+#include "t_crash_board.h"
+#include "t_process_crash.h"
+#include "t_coredumpserver.h"
+#include "t_coredumpmonitor.h"
+#include "t_scm_config.h"
+#include "t_self.h"
+
+class Ctcds_kernelBlockController : public CTestBlockController
+	{
+public:
+	static Ctcds_kernelBlockController* NewL();
+	virtual CDataWrapper* CreateDataL(const TDesC& aData);
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/inc/tcds_kernelBlockServer.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,41 @@
+/**
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file tcds_kernelBlockServer.h
+ @internalTechnology
+*/
+
+#if (!defined __TCDS_kernel_BLOCK_SERVER_H__)
+#define __TCDS_kernel_BLOCK_SERVER_H__
+#include <TestServer2.h>
+#include "tcds_kernelBlockController.h"
+
+class Ctcds_kernelBlockServer : public CTestServer2
+	{
+public:
+	static Ctcds_kernelBlockServer* NewL();
+	// Base class pure virtual override
+	virtual CTestBlockController* CreateTestBlock();
+
+// Please Add/modify your class members
+private:
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/DT-coredump-monitor.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,267 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								DT-coredump-monitor.script
+//
+
+//! @SYMTestSuiteName               	DT-coredump-monitor
+//! @SYMScriptTestEnvironment       	TEF
+
+LOAD_SUITE tcds_kernel
+
+//! @SYMTestCaseID              DT-coredump-monitor-002
+//! @SYMTestCaseDesc            The Crash Logger Config Values displayed in CDS should correspond to the default build time values
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Ensure build time configuration parameters are correct.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                CT
+//! @SYMTESTSTATUS              2. Functional
+//! @SYMPREQ                    PREQ1700
+START_TESTCASE DT-coredump-monitor-002
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCoreDumpMonitor	monitor 
+       	    COMMAND		    monitor	      ReadDefaultConfigValues
+    END_TEST_BLOCK
+END_TESTCASE DT-coredump-monitor-002
+
+START_TESTCASE DT-coredump-monitor-004
+//! @SYMTestCaseID              DT-coredump-monitor-004
+//! @SYMTestCaseDesc            Trusted clients should be able to view crash logger configuration parameters.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Using CDS API, a trusted agent should try to read the crash logger properties. This should suceed.
+//! @SYMTestExpectedResults     Parameters should be read sucessfully.
+//! @SYMTestType                CT
+//! @SYMCreationDate            22/8/2007
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     XXXX
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCoreDumpMonitor	monitor 
+       	    COMMAND		    monitor	      TrustedAccessToSCMConfig
+    END_TEST_BLOCK
+END_TESTCASE DT-coredump-monitor-004
+
+
+START_TESTCASE                DT-coredump-monitor-005
+//! @SYMTestCaseID              DT-coredump-monitor-005
+//! @SYMTestCaseDesc            Untrusted clients should not be able to view crash logger configuration parameters.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Using CDS API, a trusted agent should try to read the crash logger properties. This should fail with permission denied.
+//! @SYMTestExpectedResults     Parameters should be read sucessfully.
+//! @SYMTestType                CT
+//! @SYMCreationDate            22/8/2007
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     XXXX
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCoreDumpMonitor	monitor 
+       	    COMMAND		    monitor	      UntrustedAccessToSCMConfig
+    END_TEST_BLOCK
+END_TESTCASE DT-coredump-monitor-005
+
+
+START_TESTCASE                DT-coredump-monitor-007
+//! @SYMTestCaseID              DT-coredump-monitor-007
+//! @SYMTestCaseDesc            When crash log is full first crash should be
+//!								written at start of flash
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Crash the board sufficient times so that flash is full
+//!								then check that the first crash in flash is newest
+//! @SYMTestExpectedResults     First crash should be newest
+//! @SYMTestType                SYM-TEF
+//! @SYMTESTSTATUS              2. Functional
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     7209
+	START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT		CCoreDumpMonitor	monitor 
+			COMMAND         monitor       ValidateNewestCrash
+    END_TEST_BLOCK
+END_TESTCASE DT-coredump-monitor-007
+
+
+START_TESTCASE                DT-coredump-monitor-009
+//! @SYMTestCaseID              DT-coredump-monitor-009
+//! @SYMTestCaseDesc            Crash logger should be able to gather trace buffer data and include it with the rest of of the system crash data.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Configure the CDS to collect a crash log for our test crash application's crash event. Load the UTrace formatter and arbitrary writer. Generate a system crash by crashing kernel side code using our test crash application. The crash application should make trace calls so as to generate trace data. Restart the board, process the crash and verify the expected trace data is there
+//! @SYMTestExpectedResults     Expected trace data should be present in the crash log.
+//! @SYMTestType                CT
+//! @SYMCreationDate            13/8/2007
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     XXXX
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCoreDumpMonitor	monitor 
+       	    COMMAND		    monitor	      GatherTraceBuffer  
+	END_TEST_BLOCK
+END_TESTCASE DT-coredump-monitor-009
+
+
+START_TESTCASE                DT-coredump-monitor-010
+//! @SYMTestCaseID              DT-coredump-monitor-010
+//! @SYMTestCaseDesc            Ensure that the coredump monitor can dump multiple crashes
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Crash the board more than once
+//! @SYMTestExpectedResults     The List crashes call should return multiple crashes
+//! @SYMTestType                CT
+//! @SYMCreationDate            5/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     XXXX
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	monitor 
+       	    COMMAND		    monitor	      NewL  
+			COMMAND         monitor       CheckMultipleCrashes
+	END_TEST_BLOCK
+END_TESTCASE DT-coredump-monitor-010
+
+
+START_TESTCASE                DT-coredump-monitor-011
+//! @SYMTestCaseID              DT-coredump-monitor-011
+//! @SYMTestCaseDesc            Test crash information in the ELF file namely
+//!                             1) Crash Type
+//!                             2) Thread Name
+//!                             3) Process ID
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Crash the board with  a specific crash type
+//!                             verify the ELF file to be a valid ELF file
+//!                             Check on that crash type
+//!                             validate the thread name with the application that had crshed
+//! @SYMTestExpectedResults     Should fetch right results from the ELF File
+//!                             1) Crash Type
+//!                             2) Thread Name
+//!                             3) Process ID
+//! @SYMTestType                CT
+//! @SYMCreationDate            5/11/2008
+//! @SYMAuthor                  sakhyaghosh
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     XXXX
+    START_TEST_BLOCK    10000    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	monitor 
+            COMMAND		    monitor	      	 NewL   
+            COMMAND         monitor          ReadCrashInfo
+			COMMAND         monitor          LoadPlugins
+			COMMAND         monitor          ConfigurePlugins
+      	    COMMAND         monitor          ValidateSingleELFFile 
+       	    COMMAND         monitor          UnLoadPlugins 
+	END_TEST_BLOCK
+END_TESTCASE DT-coredump-monitor-011
+
+
+START_TESTCASE                DT-coredump-monitor-012
+//! @SYMTestCaseID              DT-coredump-monitor-012
+//! @SYMTestCaseDesc            Test crash information in Multiple ELF file namely
+//!                             1) Crash Type
+//!                             2) Thread Name Validation
+//!                             3) Process ID
+//! @SYMTestPriority            High
+//! @SYMTestActions             crash the board a number of times
+//!                             check for the crashes to be present
+//!                             read the crash information and process the crash
+//!                             with SELF formatter and file writter loaded generate multiple SELF files
+//!                             validate all the SELF files for the correctness
+//! @SYMTestExpectedResults     Should be able t generate multiple ELF Files for multiple crashes and then validate each of the ELF files for:
+//!                             1) Crash Type
+//!                             2) Thread Name
+//!                             3) Process ID
+//! @SYMTestType                CT
+//! @SYMCreationDate            14/11/2008
+//! @SYMAuthor                  sakhyaghosh
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     XXXX
+    START_TEST_BLOCK    1000    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	processb 
+            COMMAND		    processb	      NewL   
+            COMMAND         processb          ReadCrashInfo
+	        COMMAND         processb          LoadPlugins
+	        COMMAND         processb          ConfigurePlugins  
+       	    COMMAND         processb          ValidateMultipleSELFFile  
+       	    COMMAND         processb          UnLoadPlugins    
+	END_TEST_BLOCK
+END_TESTCASE DT-coredump-monitor-012
+
+START_TESTCASE                DT-coredump-monitor-013
+//! @SYMTestCaseID              DT-coredump-monitor-013
+//! @SYMTestCaseDesc            Processing Corrupt Crash should return KErrCorrupt, part of the negative test case of CDS ProcessCrashLog
+//! @SYMTestPriority            High
+//! @SYMTestActions             - Crash Board
+//!                             - Restart Board Before Crash has finished
+//!                             - Should see crash entry, but processing should return Corrupt
+//! @SYMTestExpectedResults     Processing the corrupt crash should return KErrCorrupt
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  sakhyaghosh
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     XXXX
+    START_TEST_BLOCK    1000    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	processb 
+            COMMAND		    processb	      NewL   
+       	    COMMAND         processb          ValidateCorruptCrash         
+	END_TEST_BLOCK
+END_TESTCASE DT-coredump-monitor-013
+START_TESTCASE                DT-coredump-monitor-014
+//! @SYMTestCaseID              DT-coredump-monitor-014
+//! @SYMTestCaseDesc            Processing Asynchronously for the Crash Log from flash
+//! @SYMTestPriority            High
+//! @SYMTestActions             - Crash Board
+//!                             - Restart Board Before Crash has finished
+//!                             - Should see teh crash log and process the crash asynchronously
+//! @SYMTestExpectedResults     Processing of the crash log from flash done asynchronously
+//! @SYMTestType                CT
+//! @SYMCreationDate            5/1/2009
+//! @SYMAuthor                  sakhyaghosh
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    1000    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	processb 
+            COMMAND		    processb	      NewL   
+            COMMAND         processb          ReadCrashInfo
+	        COMMAND         processb          LoadPlugins
+	        COMMAND         processb          ConfigurePlugins  
+       	    COMMAND         processb          ValidateAsyncProcessCrashLog  
+       	    COMMAND         processb          UnLoadPlugins    
+	END_TEST_BLOCK
+END_TESTCASE DT-coredump-monitor-014
+
+
+START_TESTCASE                DT-coredump-monitor-015
+//! @SYMTestCaseID              DT-coredump-monitor-015
+//! @SYMTestCaseDesc            Processing Asynchronously for the Crash Log from flash while processing of live crash is in progress
+//! @SYMTestPriority            High
+//! @SYMTestActions             - Crash Board
+//!                             - Restart Board Before Crash has finished
+//!                             - Should start a live crash
+//!                             - Process crash log from flash asynchronously while the live crash processing is in progress
+//! @SYMTestExpectedResults     Processing of the crash log done asynchronously whilst a live crash is ongoing
+//! @SYMTestType                CT
+//! @SYMCreationDate            5/1/2009
+//! @SYMAuthor                  sakhyaghosh
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    1000    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	processb 
+            COMMAND		    processb	      NewL   
+            COMMAND         processb          ReadCrashInfo
+	        COMMAND         processb          LoadPlugins
+	        COMMAND         processb          ConfigurePlugins  
+       	    COMMAND         processb          ValidateAsyncProcessAndLiveCrash    User_PrefetchAbort  
+       	    COMMAND         processb          UnLoadPlugins    
+	END_TEST_BLOCK
+END_TESTCASE DT-coredump-monitor-015
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/DT-coredump-performance.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,42 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+//! @File								DT-coredump-performance.script
+//! @SYMTestSuiteName               	Core Dump System Crash
+//! @SYMScriptTestEnvironment       	TEF
+ 
+LOAD_SUITE tcds_kernel
+
+//! @SYMTestCaseID              DT-coredump-performance-001
+//! @SYMTestCaseDesc            Performance of writing various size SELF file's
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             data source should allow reading of system crash data
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMTESTSTATUS              Implemented
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     REQ7701 REQ7702 REQ7703 REQ7704 REQ8106 REQ8107 REQ8112 REQ8118 REQ8119 REQ8120 REQ8137 REQ8138 REQ8139
+START_TESTCASE DT-coredump-performance-001
+    START_TEST_BLOCK    10000   tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	monitor 
+       	    COMMAND		    monitor	      	 NewL   
+            COMMAND         monitor          ReadCrashInfo
+			COMMAND         monitor          LoadPlugins
+			COMMAND         monitor          ConfigurePlugins
+       	    COMMAND		    monitor	         PerformanceMeasureSELFFile
+       	    COMMAND         monitor          UnLoadPlugins
+    END_TEST_BLOCK
+END_TESTCASE DT-coredump-performance-001
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/DT-coredump-server.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,80 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								DT-coredump-server.script
+//
+
+//! @SYMTestSuiteName               	DT-coredump-server
+//! @SYMScriptTestEnvironment       	TEF
+
+LOAD_SUITE tcds_kernel
+
+
+
+START_TESTCASE                DT-coredump-server-001
+//! @SYMTestCaseID              DT-coredump-server-001
+//! @SYMTestCaseDesc            Trusted CDS should be able to retrieve system crash data via the new data source API.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             The test should be able to access privelaged data via the data source API and it should be the data we expect.
+//! @SYMTestExpectedResults     Data should be successfuly returned from data source should match that we have in our mocked vendor falsh access software.
+//! @SYMTestType                CT
+//! @SYMCreationDate            13/8/2007
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     XXXX
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCoreDumpServer	server 
+       	    COMMAND		    server	      DataViaDataSource
+    END_TEST_BLOCK
+END_TESTCASE DT-coredump-server-001
+
+
+START_TESTCASE                DT-coredump-server-002
+//! @SYMTestCaseID              DT-coredump-server-002
+//! @SYMTestCaseDesc            Untrusted CDS should not be able to retrieve crash data via the new data source API.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Generate a system crash and an untrusted CDS should attempt to read it. It should fail.
+//! @SYMTestExpectedResults     Permission denied should be returned.
+//! @SYMTestType                CT
+//! @SYMCreationDate            13/8/2007
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     XXXX
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCoreDumpServer	server 
+       	    COMMAND		    server	      UntrustedDataAccess
+    END_TEST_BLOCK
+END_TESTCASE DT-coredump-server-002
+
+
+START_TESTCASE                DT-coredump-server-003
+//! @SYMTestCaseID              DT-coredump-server-003
+//! @SYMTestCaseDesc            Trusted CDS should be able to retrieve trace data via the new data source API.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             The CDS should be given trusted capabilities. An application will be written to write raw data to the flash partition, so we can write expected trace data here. The test should make calls to the data source API to get the trace data and the data returned should be what we expect.
+//! @SYMTestExpectedResults     Trace data from data source should match that we have written to the flash.
+//! @SYMTestType                CT
+//! @SYMCreationDate            13/8/2007
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+//! @SYMREQ                     XXXX
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCoreDumpServer	server 
+       	    COMMAND		    server	      TraceViaDataSource
+    END_TEST_BLOCK
+END_TESTCASE DT-coredump-server-003
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/DT-formatters-SELF.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,123 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								DT-formatters-SELF.script
+//
+
+//! @SYMTestSuiteName               	DT-formatters-SELF
+//! @SYMScriptTestEnvironment       	TEF
+
+LOAD_SUITE tcds_kernel
+
+START_TESTCASE                DT-formatters-SELF-001
+//! @SYMTestCaseID              DT-formatters-SELF-001
+//! @SYMTestCaseDesc            Test SELF Configuration to hold trace data with a system crash.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Configure the CDS to collect a crash log for our test crash application's crash event. Generate a system crash by crashing kernel side code using our test crash application and restart the board. Load the SELF formatter plugin and an arbitrary writer. Configure the SELF formatter to hold trace data. Process the crash log. Ensure the trace data is there and correct.
+//! @SYMTestExpectedResults     SELF crash dump should contain trace data.
+//! @SYMTestType                CT
+//! @SYMCreationDate            10/8/2007
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    1000    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	self
+            COMMAND		    self	      NewL
+            COMMAND         self          ReadCrashInfo
+	        COMMAND         self          LoadPlugins
+	        COMMAND         self          ConfigurePlugins
+       	    COMMAND         self          ValidateTraceSELFFile
+       	    COMMAND         self          UnLoadPlugins
+    END_TEST_BLOCK
+END_TESTCASE DT-formatters-SELF-001
+
+START_TESTCASE                DT-formatters-SELF-005
+//! @SYMTestCaseID              DT-formatters-SELF-005
+//! @SYMTestCaseDesc            Test SELF Configuration to hold heap data.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Configure the CDS to collect a crash log for our test crash application's crash event. Generate a system crash by crashing kernel side code using our test crash application and restart the board. Load the SELF formatter plugin and an arbitrary writer. Configure the SELF formatter to hold heap data. Process the crash log and confirm heap data is present.
+//! @SYMTestExpectedResults     SELF crash dump should contain trace data.
+//! @SYMTestType                CT
+//! @SYMCreationDate            13/8/2007
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    1000    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	self
+            COMMAND		    self	      NewL
+            COMMAND         self          ReadCrashInfo
+	        COMMAND         self          LoadPlugins
+	        COMMAND         self          ConfigurePlugins
+       	    COMMAND         self          ValidateHeapSELFFile
+       	    COMMAND         self          UnLoadPlugins
+    END_TEST_BLOCK
+END_TESTCASE DT-formatters-SELF-005
+
+START_TESTCASE                DT-formatters-SELF-009
+//! @SYMTestCaseID              DT-formatters-SELF-009
+//! @SYMTestCaseDesc            The SELF dump file should be verified to display the CPU ID of the thread it was running on.
+//! @SYMTestPriority            High
+//! @SYMTestActions             The CPU ID should be available. For a non SMP system (H4) it should be -1.
+//! @SYMTestExpectedResults     The CPU ID for the crashed threads should all be the same.
+//! @SYMTestType                CT
+//! @SYMCreationDate            10/6/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    1000    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	self
+       		COMMAND		    self	      NewL
+       		COMMAND 		self 		  ReadCrashInfo
+       	    COMMAND		    self	      LoadPlugins
+       	    COMMAND			self		  ConfigurePlugins
+       	    COMMAND		    self	      ValidateSelfCPUID
+       	    COMMAND			self 		  UnLoadPlugins
+    END_TEST_BLOCK
+END_TESTCASE DT-formatters-SELF-009
+
+START_TESTCASE                DT-formatters-SELF-0010
+//! @SYMTestCaseID              DT-formatters-SELF-0010
+//! @SYMTestCaseDesc			For system crashes the SELF file should contain variant specific data when configured to do so
+//! @SYMTestPriority            High
+//! @SYMTestActions				Configure SCM to dump with variant data and verify its in SELF file
+//! @SYMTestExpectedResults		Variant data section present
+//! @SYMTestType                CT
+//! @SYMCreationDate            30/9/2009
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ2596
+    START_TEST_BLOCK    1000    tcds_kernel \data\tcds_self.ini
+       	CREATE_OBJECT	CSymbianElfWrapper	self
+		COMMAND			self		GenerateSelfFile	self0010
+		COMMAND			self		VerifySectionExists	self0010
+    END_TEST_BLOCK
+END_TESTCASE DT-formatters-SELF-0010
+
+START_TESTCASE                DT-formatters-SELF-0011
+//! @SYMTestCaseID              DT-formatters-SELF-0011
+//! @SYMTestCaseDesc			For system crashes the SELF file should contain variant specific data when configured to do so
+//! @SYMTestPriority            High
+//! @SYMTestActions				Configure SCM to dump with no variant data (or use an app dump) and verify its not in SELF file
+//! @SYMTestExpectedResults		Variant data section present
+//! @SYMTestType                CT
+//! @SYMCreationDate            30/9/2009
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ2596
+    START_TEST_BLOCK    1000    tcds_kernel \data\tcds_self.ini
+       	CREATE_OBJECT	CSymbianElfWrapper	self
+		COMMAND			self		GenerateSelfFile			self0011
+		COMMAND			self		VerifySectionDoesNotExist	self0011
+    END_TEST_BLOCK
+END_TESTCASE DT-formatters-SELF-0011
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/tcds_kernel_crash.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,185 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								tcds_kernel_crash.script
+//
+
+//! @SYMTestSuiteName               	DT-board-utils
+//! @SYMScriptTestEnvironment       	TEF
+
+LOAD_SUITE tcds_kernel
+
+
+
+START_TESTCASE                DT-board-utils-0001
+//! @SYMTestCaseID              DT-board-utils-0001
+//! @SYMTestCaseDesc            Crash the board
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Crash the board by Prefetch Abort
+//! @SYMTestExpectedResults     System Crash
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCrashBoardWrapper	crashb
+		COMMAND		crashb	  CrashBoard  Kernel_PrefetchAbort
+    END_TEST_BLOCK
+END_TESTCASE DT-board-utils-0001
+
+
+START_TESTCASE                DT-board-utils-0002
+//! @SYMTestCaseID              DT-board-utils-0002
+//! @SYMTestCaseDesc            Crash the board
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Crash the board by data read error
+//! @SYMTestExpectedResults     System Crash
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCrashBoardWrapper	crashb
+		COMMAND		crashb	  CrashBoard  Kernel_EDataRead
+    END_TEST_BLOCK
+END_TESTCASE DT-board-utils-0002
+
+
+START_TESTCASE                DT-board-utils-0003
+//! @SYMTestCaseID              DT-board-utils-0003
+//! @SYMTestCaseDesc            Crash the board
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Crash the board by data write error
+//! @SYMTestExpectedResults     System Crash
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCrashBoardWrapper	crashb
+		COMMAND		crashb	  CrashBoard  Kernel_EDataWrite
+    END_TEST_BLOCK
+END_TESTCASE DT-board-utils-0003
+
+
+START_TESTCASE                DT-board-utils-0004
+//! @SYMTestCaseID              DT-board-utils-0004
+//! @SYMTestCaseDesc            Crash the board
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Crash the board by undefined instruction
+//! @SYMTestExpectedResults     System Crash
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCrashBoardWrapper	crashb
+		COMMAND		crashb	  CrashBoard  Kernel_UndefInstr
+    END_TEST_BLOCK
+END_TESTCASE DT-board-utils-0004
+
+
+START_TESTCASE                DT-board-utils-0005
+//! @SYMTestCaseID              DT-board-utils-0005
+//! @SYMTestCaseDesc            Crash the board
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Crash the board by stack overflow
+//! @SYMTestExpectedResults     System Crash
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCrashBoardWrapper	crashb
+		COMMAND		crashb	  CrashBoard  Kernel_StackOverflow
+    END_TEST_BLOCK
+END_TESTCASE DT-board-utils-0005
+
+
+START_TESTCASE                DT-board-utils-0006
+//! @SYMTestCaseID              DT-board-utils-0006
+//! @SYMTestCaseDesc            Crash the board
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Crash the board by division by zero
+//! @SYMTestExpectedResults     System Crash
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCrashBoardWrapper	crashb
+		COMMAND		crashb	  CrashBoard  Kernel_DivisionByZero
+    END_TEST_BLOCK
+END_TESTCASE DT-board-utils-0006
+
+
+START_TESTCASE                DT-board-utils-0007
+//! @SYMTestCaseID              DT-board-utils-0007
+//! @SYMTestCaseDesc            Crash the board
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Crash the board by data read error
+//! @SYMTestExpectedResults     System Crash
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCrashBoardWrapper	crashb
+		COMMAND		crashb	  CrashBoard  Kernel_EDataReadWithTrace
+    END_TEST_BLOCK
+END_TESTCASE DT-board-utils-0007
+
+
+START_TESTCASE                DT-board-utils-0008
+//! @SYMTestCaseID              DT-board-utils-0008
+//! @SYMTestCaseDesc            Cleans the Crash flash partition
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Cleans the Flash Partition
+//! @SYMTestExpectedResults     System Crash
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCrashBoardWrapper	crashb
+		COMMAND		crashb	  CleanFlashPartition  
+    END_TEST_BLOCK
+END_TESTCASE DT-board-utils-0008
+
+
+START_TESTCASE                DT-board-utils-0009
+//! @SYMTestCaseID              DT-board-utils-0009
+//! @SYMTestCaseDesc            Cleans the Entire Crash flash partition Using Debug Security Server
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Cleans the Entire Crash flash partition
+//! @SYMTestExpectedResults     System Crash
+//! @SYMTestType                UT
+//! @SYMCreationDate            3/12/2008
+//! @SYMAuthor                  sakhyaghosh
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CCrashBoardWrapper	crashb
+		COMMAND		crashb	  CleanEntireFlashPartition  
+    END_TEST_BLOCK
+END_TESTCASE DT-board-utils-0009
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/tcds_kernel_process.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,102 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								tcds_kernel_process.script
+//
+
+//! @SYMTestSuiteName               	DT-kernelcrash-process
+//! @SYMScriptTestEnvironment       	TEF
+
+LOAD_SUITE tcds_kernel
+
+
+
+START_TESTCASE                DT-kernelcrash-process-0001
+//! @SYMTestCaseID              DT-kernelcrash-process-0001
+//! @SYMTestCaseDesc            Check for valid system crash ELF
+//! @SYMTestPriority            High
+//! @SYMTestActions             Loads SELF, process crash and makes sure the file is valid
+//! @SYMTestExpectedResults     Valid ELF
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	processb 
+            COMMAND		    processb	      NewL
+			COMMAND         processb          ReadCrashInfo
+			COMMAND         processb          LoadPlugins
+			COMMAND         processb          ConfigurePlugins   SELFFile_Path
+			COMMAND         processb          ProcessCrash
+			COMMAND         processb          UnLoadPlugins
+			COMMAND         processb          ProcessELFFile
+
+    END_TEST_BLOCK
+END_TESTCASE DT-kernelcrash-process-0001
+
+
+START_TESTCASE                DT-kernelcrash-process-0002
+//! @SYMTestCaseID              DT-kernelcrash-process-0002
+//! @SYMTestCaseDesc            Deletes all crashes
+//! @SYMTestPriority            High
+//! @SYMTestActions             Delete all crashes in the partition
+//! @SYMTestExpectedResults     Partition should be deleted
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	processb 
+       	    COMMAND		    processb	      NewL  
+			COMMAND         processb          ReadCrashInfo
+			COMMAND         processb          DeleteAllCrashes
+    END_TEST_BLOCK
+END_TESTCASE DT-kernelcrash-process-0002
+
+
+START_TESTCASE                DT-kernelcrash-process-0003
+//! @SYMTestCaseID              DT-kernelcrash-process-0003
+//! @SYMTestCaseDesc            Configure the SCM to dump minimal data
+//! @SYMTestPriority            Medium
+//! @SYMTestActions             Configure the SCM to dump minimal data
+//! @SYMTestExpectedResults     Configuration should suceed
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	processb 
+       	    COMMAND		    processb	      NewL  
+			COMMAND         processb          ConfigureSCMZeroPriority
+    END_TEST_BLOCK
+END_TESTCASE DT-kernelcrash-process-0003
+
+
+START_TESTCASE                DT-kernelcrash-process-0004
+//! @SYMTestCaseID              DT-kernelcrash-process-0004
+//! @SYMTestCaseDesc            Checks for multiple crashes
+//! @SYMTestPriority            High
+//! @SYMTestActions             Crash board 4 times. Make sure we see 4 crashes
+//! @SYMTestExpectedResults     4 crashes found
+//! @SYMTestType                CT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_kernel.ini
+       	CREATE_OBJECT	CProcessCrashWrapper	processb 
+       	    COMMAND		    processb	      NewL  
+			COMMAND         processb          ReadCrashInfoAndCheckForFour
+	END_TEST_BLOCK
+END_TESTCASE DT-kernelcrash-process-0004
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/scripts/tcds_scm_config.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,84 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								tcds_scm_config.script
+//
+
+//! @SYMTestSuiteName               	DT-SCM-CONFIG
+//! @SYMScriptTestEnvironment       	TEF
+
+LOAD_SUITE tcds_kernel
+
+START_TESTCASE                DT-SCM-CONFIG-0001
+//! @SYMTestCaseID              DT-SCM-CONFIG-0001
+//! @SYMTestCaseDesc            Configure the SCM to dump variant specific data
+//! @SYMTestPriority            High
+//! @SYMTestActions             Configure the SCM to dump variant specific data
+//! @SYMTestExpectedResults     Configuration should succeed
+//! @SYMTestType                ST
+//! @SYMCreationDate            29/09/2009
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ2596
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_scm_config.ini
+       	CREATE_OBJECT	CSCMConfig	scmConfig
+		COMMAND		scmConfig	  ConfigureOn   EVariantSpecificData
+		COMMAND		scmConfig	  ConfigureOn   ECrashedProcessMetaData
+		COMMAND		scmConfig	  ConfigureOn   ECrashedThreadMetaData
+		COMMAND		scmConfig	  ConfigureOff  ERomInfo
+		COMMAND		scmConfig	  ConfigureOff  ELocks
+		COMMAND		scmConfig	  ConfigureOff  EKernelHeap
+		COMMAND		scmConfig	  ConfigureOff  ETraceData
+		COMMAND		scmConfig	  ConfigureOff  EProcessCodeSegs
+		COMMAND		scmConfig	  ConfigureOff  EThreadsUsrStack
+		COMMAND		scmConfig	  ConfigureOff  EThreadsSvrStack
+		COMMAND		scmConfig	  ConfigureOff  EThreadsSvrRegisters
+		COMMAND		scmConfig	  ConfigureOn   EProcessMetaData
+		COMMAND		scmConfig	  ConfigureOn   EThreadsMetaData
+		COMMAND		scmConfig	  ConfigureOn   ECrashedProcessCodeSegs
+		COMMAND		scmConfig	  ConfigureOn   ECrashedProcessUsrStacks
+		COMMAND		scmConfig	  ConfigureOn   ECrashedProcessSvrStacks
+    END_TEST_BLOCK
+END_TESTCASE DT-SCM-CONFIG-0001
+
+START_TESTCASE                DT-SCM-CONFIG-0002
+//! @SYMTestCaseID              DT-SCM-CONFIG-0002
+//! @SYMTestCaseDesc            Configure the SCM not to dump variant specific data
+//! @SYMTestPriority            High
+//! @SYMTestActions             Configure the SCM not to dump variant specific data
+//! @SYMTestExpectedResults     Configuration should succeed
+//! @SYMTestType                ST
+//! @SYMCreationDate            29/09/2009
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ2596
+    START_TEST_BLOCK    100    tcds_kernel \data\tcds_scm_config.ini
+		CREATE_OBJECT	CSCMConfig	scmConfig
+		COMMAND		scmConfig	  ConfigureOff   EVariantSpecificData
+		COMMAND		scmConfig	  ConfigureOn   ECrashedProcessMetaData
+		COMMAND		scmConfig	  ConfigureOn   ECrashedThreadMetaData
+		COMMAND		scmConfig	  ConfigureOff  ERomInfo
+		COMMAND		scmConfig	  ConfigureOff  ELocks
+		COMMAND		scmConfig	  ConfigureOff  EKernelHeap
+		COMMAND		scmConfig	  ConfigureOff  ETraceData
+		COMMAND		scmConfig	  ConfigureOff  EProcessCodeSegs
+		COMMAND		scmConfig	  ConfigureOff  EThreadsUsrStack
+		COMMAND		scmConfig	  ConfigureOff  EThreadsSvrStack
+		COMMAND		scmConfig	  ConfigureOff  EThreadsSvrRegisters
+		COMMAND		scmConfig	  ConfigureOn   EProcessMetaData
+		COMMAND		scmConfig	  ConfigureOn   EThreadsMetaData
+		COMMAND		scmConfig	  ConfigureOn   ECrashedProcessCodeSegs
+		COMMAND		scmConfig	  ConfigureOn   ECrashedProcessUsrStacks
+		COMMAND		scmConfig	  ConfigureOn   ECrashedProcessSvrStacks
+	END_TEST_BLOCK
+END_TESTCASE DT-SCM-CONFIG-0002
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_coredumpmonitor.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,488 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include "t_coredumpmonitor.h"
+
+//Names of functions to be tested - referenced from script file
+_LIT(KUntrustedAccessToSCMConfig, "UntrustedAccessToSCMConfig");
+_LIT(KGatherTraceBuffer, "GatherTraceBuffer");
+_LIT(KTrustedAccessToSCMConfig, "TrustedAccessToSCMConfig");
+_LIT(KReadDefaultConfigValues, "ReadDefaultConfigValues");
+_LIT(KValidateNewestCrash, "ValidateNewestCrash");
+
+/**
+ * Constructor for test wrapper
+ */
+CCoreDumpMonitorWrapper::CCoreDumpMonitorWrapper()
+	{
+	}
+
+/**
+ * Destructor
+ */
+CCoreDumpMonitorWrapper::~CCoreDumpMonitorWrapper()
+	{
+	iCoreDumpSession.Close();
+	iCrashList.ResetAndDestroy();
+	iFsSession.Close();
+	}
+
+/**
+ * Two phase constructor for CCoreDumpMonitorWrapper
+ * @return CCoreDumpMonitorWrapper object
+ * @leave
+ */
+CCoreDumpMonitorWrapper* CCoreDumpMonitorWrapper::NewL()
+	{
+	CCoreDumpMonitorWrapper* ret = new (ELeave) CCoreDumpMonitorWrapper();
+	CleanupStack::PushL(ret);
+	ret->ConstructL();
+	CleanupStack::Pop(ret);
+	return ret;
+	}
+
+/**
+ * Safe construction
+ * @leave
+ */
+void CCoreDumpMonitorWrapper::ConstructL()
+	{
+	
+
+	User::LeaveIfError(iCoreDumpSession.Connect());
+	User::LeaveIfError(iFsSession.Connect());
+	}
+
+/**
+ * Assign the object
+ * @param aObject TAny* to the object to test
+ * @leave
+ */
+void CCoreDumpMonitorWrapper::SetObjectL(TAny* aObject)
+	{}
+
+/**
+ * Runs a test preamble
+ */
+void CCoreDumpMonitorWrapper::PrepareTestL()
+	{
+	SetBlockResult(EPass);
+	INFO_PRINTF1(_L("CCoreDumpMonitorWrapper::Ready to start test"));
+	}
+
+/**
+ * Handle a command invoked from the script
+ * @param aCommand Is the name of the command for a TBuf
+ * @param aSection Is the .ini file section where parameters to the command are located
+ * @param aAsyncErrorIndex Is used by the TEF Block framework to handle asynchronous commands.
+ */
+TBool CCoreDumpMonitorWrapper::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
+	{
+	//__UHEAP_MARK;	
+	PrepareTestL();
+
+	if (KUntrustedAccessToSCMConfig() == aCommand)
+		{
+		TestUntrustedAccessToCDSConfigL();
+		}
+	else if(KGatherTraceBuffer() == aCommand)
+		{
+		TestTraceBufferAccessL();
+		}
+	else if(KTrustedAccessToSCMConfig() ==aCommand)
+		{
+		TestTrustedAccessToCDSConfigL();
+		}
+	else if (KReadDefaultConfigValues() == aCommand)
+		{
+		TestReadDefaultConfigValuesL();
+		}
+else if(KValidateNewestCrash() == aCommand)
+		{
+		TestValidateNewestCrashL();
+		}
+	else
+		{
+		return EFalse;
+		}
+
+	//__UHEAP_MARKEND;
+
+	return ETrue;
+	}
+
+void CCoreDumpMonitorWrapper::TestTrustedAccessToCDSConfigL()
+	{
+	INFO_PRINTF1(_L("TestTrustedAccessToCDSConfigL"));
+	
+	INFO_PRINTF1(_L("Getting the number of config parameters"));
+	
+	TUint numConfigParams = 0;
+	TRAPD(err, numConfigParams = iCoreDumpSession.GetNumberConfigParametersL());
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to get the number of config parameters. Returned %d"), err);		
+		SetBlockResult(EFail);
+		return;
+		}
+	
+	INFO_PRINTF2(_L("Found %d params"), numConfigParams);
+	TBool foundScmConfig = EFalse;
+	
+	for (TInt i = 0; i < numConfigParams; i++)
+		{
+		COptionConfig* conf;
+		conf = iCoreDumpSession.GetConfigParameterL(i);
+		
+		if (conf->Source()== COptionConfig::ESCMConfig)
+			{
+			foundScmConfig = ETrue;
+			}
+		
+		delete conf;
+		}
+	
+	if(!foundScmConfig)
+		{
+		ERR_PRINTF1(_L("Not Able to retrieve a config param for the SCM"));		
+		SetBlockResult(EFail);
+		return;
+		}
+	
+	INFO_PRINTF1(_L("Looked at all config parameters and found some SCM params so that is a pass"));
+	}
+
+/**
+ * Tests that that CDS enforces that untrusted users cannot 
+ * access the CDS configuration
+ */
+void CCoreDumpMonitorWrapper::TestUntrustedAccessToCDSConfigL()
+	{
+	INFO_PRINTF1(_L("TestUntrustedAccessToCDSConfigL"));
+	
+	INFO_PRINTF1(_L("Getting the number of config parameters"));
+	
+	TUint numConfigParams = 0;
+	TRAPD(err, numConfigParams = iCoreDumpSession.GetNumberConfigParametersL());
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to get the number of config parameters. Returned %d"), err);		
+		SetBlockResult(EFail);
+		return;
+		}
+	
+	INFO_PRINTF2(_L("Found %d params"), numConfigParams);
+	
+	for (TInt i = 0; i < numConfigParams; i++)
+		{
+		COptionConfig* conf;
+		conf = iCoreDumpSession.GetConfigParameterL(i);
+		
+		if (conf->Source()== COptionConfig::ESCMConfig)
+			{
+			ERR_PRINTF1(_L("Able to retrieve a config param for the SCM"));		
+			SetBlockResult(EFail);
+			delete conf;
+			return;
+			}
+		
+		delete conf;
+		}
+	
+	INFO_PRINTF1(_L("Looked at all config parameters and none were SCM params so that is a pass"));
+	}
+
+void CCoreDumpMonitorWrapper::TestTraceBufferAccessL()
+	{
+	//Step 1: Load the UTRACE formatter and file writter
+	INFO_PRINTF1(_L("CCoreDumpMonitorWrapper::TestTraceBufferAccessL loading UTRACE Formatter and File Writer"));
+
+	TPluginRequest loadUtracePlugin;
+	loadUtracePlugin.iPluginType = TPluginRequest::EFormatter;
+	loadUtracePlugin.iLoad = ETrue;
+	loadUtracePlugin.iUid = KUtraceUid;	
+	
+	TPluginRequest loadWriterReq;
+	loadWriterReq.iPluginType = TPluginRequest::EWriter;
+	loadWriterReq.iLoad = ETrue;
+	loadWriterReq.iUid = KUidFileWriter;
+	
+	// loading Symbian ELF formatter
+	TRAPD(err, iCoreDumpSession.PluginRequestL(loadUtracePlugin));
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(_L("CCoreDumpMonitorWrapper::TestTraceBufferAccessL() Could not load UTRACE plugin!, err:%d\n"), err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}	
+	
+	// loading Symbian File writer
+	TRAP(err, iCoreDumpSession.PluginRequestL(loadWriterReq));
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(_L("CCoreDumpMonitorWrapper::TestTraceBufferAccessL() Could not load writer plugin!, err:%d\n"), err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+	
+	//Configuring the file writer plugin to have a specified crash file name
+	TRAP(err, DoConfigureL((TInt)(CCrashDataSave::ECoreFilePath),
+			KUidFileWriter.iUid, COptionConfig::EWriterPlugin,
+			COptionConfig::ETFileName, KFilePathPrompt, 1, KNullDesC, 0,
+			KCrashFileName, 0));
+
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(_L("CCoreDumpMonitorWrapper::TestTraceBufferAccessL()() for File Writer Error %d changing param"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}	
+	
+	//List crashes in flash
+	iCrashList.Reset();
+	TRAP(err, iCoreDumpSession.ListCrashesInFlashL(iCrashList));
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(_L("CCoreDumpMonitorWrapper::TestTraceBufferAccessL() Could not read Crashes in the Flash! err:%d\n"), err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}	
+	
+	INFO_PRINTF2(_L("Number of crashes present: %d"),	iCrashList.Count());
+	if(iCrashList.Count() == 0)
+		{
+		ERR_PRINTF1(_L("Failed to find any crashes in log for the analysing"));
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+	
+	//Step 2: Process the crash
+	for (TInt i = 0; i < iCrashList.Count(); i++)
+		{
+		TRAP(err, iCoreDumpSession.ProcessCrashLogL(iCrashList[i]->iCrashId));
+		if (err != KErrNone)
+			{
+			ERR_PRINTF2(_L("CCoreDumpMonitorWrapper::TestTraceBufferAccessL() Could not process crash! err:%d\n"), err);
+			SetBlockResult(EFail);
+			User::Leave(err);
+			}
+		}
+	
+	INFO_PRINTF1(_L("Crashes Processed, Now looking for file generated"));
+	
+	//Step 3: Check the trace file has been generated
+	//Use wildcard utilities to search for the UTRACE FIle Created
+	TBuf<32> buf;
+	buf = KDir;
+	TUidType uid1;
+	TUidType uid2(uid1.MostDerived());
+
+	CFindFileByType* obj = new(ELeave) CFindFileByType(iFsSession);
+	CleanupStack::PushL(obj);
+
+	err = obj->FindFirst(KCrashWildCard, buf, uid2);
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CCoreDumpMonitorWrapper::TestTraceBufferAccessL() Error finding the UTRACE File %d"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+	
+	INFO_PRINTF2(_L("The UTRACE File Found is E:\\:%S "), &(obj->Entry().iName));	
+	
+	CleanupStack::PopAndDestroy(); //CFindFileByType
+	
+	
+	//Future improvements: Check contents of file
+	}
+
+/**
+ * Tests that that after deletion of the entire partition  
+ * SCM config values should correspond to the default build time values
+ */
+void CCoreDumpMonitorWrapper::TestReadDefaultConfigValuesL()
+	{
+	INFO_PRINTF1(_L("CCoreDumpMonitorWrapper::TestReadDefaultConfigValuesL Match with Build time SCM config values"));
+	
+	TInt noConfigParams = 0;
+	TInt scmConfigParams = 0;
+	// this will ultimateley read the config
+    TRAPD(err, noConfigParams = iCoreDumpSession.GetNumberConfigParametersL());
+    if(err != KErrNone)
+        {
+        ERR_PRINTF1(_L("Could not read number of config params"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);       
+        }
+    else
+    	{	
+    	INFO_PRINTF2(_L("Found %d config params"), noConfigParams);
+    	
+		for (TInt i = 0; i < noConfigParams; i++)
+			{
+			COptionConfig* conf = iCoreDumpSession.GetConfigParameterL(i);
+			CleanupStack::PushL(conf);
+			
+			if (conf->Source()== COptionConfig::ESCMConfig)
+				{
+				//count number of SCM configurations
+				scmConfigParams++;
+				TConfigItem::TSCMDataType dataType = (TConfigItem::TSCMDataType) conf->Instance();
+
+				//Default SCM Configuration for TConfigItem::EThreadsUsrStack has priority = 0
+				if(dataType == TConfigItem::EThreadsUsrStack && conf->Value() != 0)  
+					{
+					ERR_PRINTF3(_L("TConfigItem::EThreadsUsrStack did not match the ZERO Priority for config data type %d with priority %d"), dataType, conf->Value());
+					SetBlockResult(EFail);
+					User::Leave(KErrGeneral);
+					}
+				//Default SCM Configuration for TConfigItem::EThreadsSvrStack has priority = 0
+				else if(dataType == TConfigItem::EThreadsSvrStack && conf->Value() != 0)
+					{
+					ERR_PRINTF3(_L("TConfigItem::EThreadsSvrStack did not match the ZERO Priority for config data type %d with priority %d"), dataType, conf->Value());
+					SetBlockResult(EFail);
+					User::Leave(KErrGeneral);
+					}
+				else if (dataType == TConfigItem::EThreadsSvrStack || dataType == TConfigItem::EThreadsUsrStack)
+						{
+						INFO_PRINTF3(_L("VERIFIED ZERO priority for config data type %d priority %d"), dataType, conf->Value());
+						CleanupStack::PopAndDestroy(conf);
+						continue;
+						}
+ 
+				//Default SCM Configuration for all has a priority value equal to thier postion in the list + 1
+				if(conf->Value() != (dataType + 1) )
+					{
+					ERR_PRINTF3(_L("Did not match the DEFAULT Configurtion for config data type %d with priority %d"), dataType, conf->Value());
+					SetBlockResult(EFail);
+					User::Leave(KErrGeneral);			
+					}
+				
+				//happy to print the value
+				INFO_PRINTF3(_L("VERIFIED config data type %d has priority %d"), dataType, conf->Value());
+					
+				}
+		
+			CleanupStack::PopAndDestroy(conf);//COptionConfig
+			}//for loop for noConfigParams
+		
+		INFO_PRINTF2(_L("Match with DEFAULT config values Successful for %d SCM Configuration Parameters"),scmConfigParams);
+    	}//else for no errors GetNumberConfigParametersL
+	
+	}
+
+/**
+ * @return void
+ * @param aIndex Internal index to the component that owns the object
+ * @param aUID UID of the component that owns the object
+ * @param aSource Type of component that owns the object
+ * @param aType Type of parameter
+ * @param aPrompt Prompt to present to user 
+ * @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
+ * @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
+ * @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
+ * @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
+ */
+void CCoreDumpMonitorWrapper::DoConfigureL(const TUint32& aIndex,
+		const TUint32& aUID, const COptionConfig::TParameterSource& aSource,
+		const COptionConfig::TOptionType& aType, const TDesC& aPrompt,
+		const TUint32& aNumOptions, const TDesC& aOptions, const TInt32& aVal,
+		const TDesC& aStrValue, const TUint aInstance)
+	{
+	COptionConfig * config;
+
+	config = COptionConfig::NewL(aIndex, aUID, aSource, aType, aPrompt,
+			aNumOptions, aOptions, aVal, aStrValue);
+
+	CleanupStack::PushL(config);
+
+	config->Instance(aInstance);
+
+	//Configure now...
+	iCoreDumpSession.SetConfigParameterL(*config);
+
+	CleanupStack::PopAndDestroy(config);
+	}
+
+
+void CCoreDumpMonitorWrapper::TestValidateNewestCrashL()
+	{
+	
+	INFO_PRINTF1(_L("TestValidateNewestCrashL called"));
+	
+	//Do list all the Crash Information here
+	TRAPD(err, iCoreDumpSession.ListCrashesInFlashL(iCrashList));
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("TestValidateNewestCrashL Could not read Crashes in the Flash! err:%d\n"),
+				err);
+		SetBlockResult(EFail);
+		return;
+		//User::Leave(err);
+		}
+
+	INFO_PRINTF2(_L("TestValidateNewestCrashL Number of crash information present: %d"),
+			iCrashList.Count());
+
+	TInt expectedNewestIndex = 0;
+	
+	if( iCrashList.Count() > 0)
+		{
+		// must be entries for test to potentially fail	
+		TInt newestIndex = 0;
+		// start with first entry being newest time
+		TUint64 newestTime = iCrashList[0]->iTime;
+		
+		for (TInt i = 0; i < iCrashList.Count(); i++)
+			{		
+			INFO_PRINTF3(_L("Crash no: %d, CrashId %d"), i, iCrashList[i]->iCrashId);
+			INFO_PRINTF3(_L("Crash no: %d, Type %ld"), i, iCrashList[i]->iType);
+			INFO_PRINTF3(_L("Crash no: %d, Time %ld"), i, iCrashList[i]->iTime);
+			INFO_PRINTF3(_L("Crash no: %d, Thread ID %ld"), i, iCrashList[i]->iTid);
+			
+			// crash time held in the header as TUint64 - highest value should be the newset crash
+			if(iCrashList[i]->iTime > newestTime)
+				{
+				newestIndex = i;
+				newestTime = iCrashList[i]->iTime;
+				}	
+			}
+			
+		INFO_PRINTF2(_L("Newest crash is Crash no: %d"), newestIndex);
+		if(newestIndex != expectedNewestIndex)
+			{
+			ERR_PRINTF3(_L("DoCmdValidateNewestCrashL newest crash was not in expected position expected (%d) actual(%d)")
+					, expectedNewestIndex, newestIndex);
+			SetBlockResult(EFail);
+			//User::Leave(err);
+			}			
+		}
+	
+	INFO_PRINTF1(_L("TestValidateNewestCrashL finished"));
+	
+	}
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_coredumpserver.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,347 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include "t_coredumpserver.h"
+#include "flashdatasource.h"
+
+//Names of functions to be tested - referenced from script file
+_LIT(KDataViaDataSource, "DataViaDataSource");
+_LIT(KTraceViaDataSource, "TraceViaDataSource");
+_LIT(KUntrustedAccess, "UntrustedDataAccess");
+/**
+ * Constructor for test wrapper
+ */
+CCoreDumpServerWrapper::CCoreDumpServerWrapper()
+	{
+	}
+
+/**
+ * Destructor
+ */
+CCoreDumpServerWrapper::~CCoreDumpServerWrapper()
+	{
+	iCoreDumpSession.Close();
+	iSecSess.Close();
+	}
+
+/**
+ * Two phase constructor for CCoreDumpServerWrapper
+ * @return CProcessCrashWrapper object
+ * @leave
+ */
+CCoreDumpServerWrapper* CCoreDumpServerWrapper::NewL()
+	{
+	CCoreDumpServerWrapper* ret = new (ELeave) CCoreDumpServerWrapper();
+	CleanupStack::PushL(ret);
+	ret->ConstructL();
+	CleanupStack::Pop(ret);
+	return ret;
+	}
+
+/**
+ * Safe construction
+ * @leave
+ */
+void CCoreDumpServerWrapper::ConstructL()
+	{
+	User::LeaveIfError(iCoreDumpSession.Connect());
+
+	TVersion secVers(Debug::KDebugServMajorVersionNumber, Debug::KDebugServMinorVersionNumber, Debug::KDebugServPatchVersionNumber);
+	User::LeaveIfError(iSecSess.Connect(secVers));
+	}
+
+/**
+ * Assign the object
+ * @param aObject TAny* to the object to test
+ * @leave
+ */
+void CCoreDumpServerWrapper::SetObjectL(TAny* aObject)
+	{}
+
+/**
+ * Runs a test preamble
+ */
+void CCoreDumpServerWrapper::PrepareTestL()
+	{
+	SetBlockResult(EPass);
+	INFO_PRINTF1(_L("CCoreDumpMonitorWrapper::Ready to start test"));
+	}
+
+/**
+ * Handle a command invoked from the script
+ * @param aCommand Is the name of the command for a TBuf
+ * @param aSection Is the .ini file section where parameters to the command are located
+ * @param aAsyncErrorIndex Is used by the TEF Block framework to handle asynchronous commands.
+ */
+TBool CCoreDumpServerWrapper::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
+	{
+	//__UHEAP_MARK;
+
+	PrepareTestL();
+
+	if (KDataViaDataSource() == aCommand)
+		{
+		TestDataSourceReturnsSystemCrashDataL();
+		}
+	else if(KTraceViaDataSource() == aCommand)
+		{
+		TestDataSourceReturnsTraceDataL();
+		}
+	else if(KUntrustedAccess() == aCommand)
+		{
+		TestUntrustedServerAccessL();
+		}
+	else
+		{
+		return EFalse;
+		}
+
+	//__UHEAP_MARKEND;
+
+	return ETrue;
+	}
+
+/**
+ * This makes sure a formatter can retrieve data via the flash data source
+ */
+void CCoreDumpServerWrapper::TestDataSourceReturnsSystemCrashDataL()
+	{
+	INFO_PRINTF1(_L("TestDataSourceReturnsSystemCrashData"));
+
+	//Load Test Formatter
+	CFlashDataSource* src = CFlashDataSource::NewL(iSecSess);
+	CleanupStack::PushL(src);
+
+	RCrashInfoPointerList* crashList = new(ELeave)RCrashInfoPointerList;
+	TCleanupItem listCleanup(CCoreDumpServerWrapper::CleanupCrashList, (TAny*)crashList);
+	CleanupStack::PushL(listCleanup);
+
+	//Get the crashes from the flash partition
+	iCoreDumpSession.ListCrashesInFlashL(*crashList);
+
+	if(crashList->Count() == 0)
+		{
+		ERR_PRINTF1(_L("Failed to find any crashes in the flash that we could check out"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+
+	INFO_PRINTF2(_L("Found [%d] crash(es) on the partition"), crashList->Count());
+
+	INFO_PRINTF1(_L("Analysing crash 0"));
+	src->AnalyseCrashL(((*crashList)[0])->iCrashId);
+
+	INFO_PRINTF1(_L("Analysis successful"));
+
+	//Now we try and read back the core header via the flash data source
+	const TCrashInfoHeader& header = src->GetCrashHeader();
+
+	//There isn't much checking we can do here as a lot of the things are determinable.
+	//Its only a smoke test anyway to make sure the data source is functioning
+	INFO_PRINTF1(_L("Checking the process ID that crashed was 1"));
+	if(header.iPid != 0x1)
+		{
+		ERR_PRINTF1(_L("Failed to retrieve proper crashed process ID"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+
+	INFO_PRINTF1(_L("Checking a valid crashed process ID"));
+	if(header.iTid <= 0x1)
+		{
+		ERR_PRINTF1(_L("Failed to retrieve proper crashed process ID"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+
+	const TRmdArmExcInfo registers = src->GetCrashContext();
+
+	const TUint32 cpsr = registers.iCpsr;
+
+	INFO_PRINTF1(_L("Checking a valid CPSR and were in SVR mode when we crashed"));
+	if(KCPSRUsrMode == (cpsr & 0x1F))
+		{
+		ERR_PRINTF2(_L("CPSR = 0x%X    --> Not in SVR mode"), cpsr);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	//Now, erase the partition
+
+	TRAPD(err, iCoreDumpSession.DeleteCrashPartitionL());
+	if(KErrNone != err)
+		{
+		RDebug::Printf("\ndeleteing failed with %d", err);
+		}
+
+	INFO_PRINTF1(_L("Negative test. Testing flash data source does as expected when there is no data in partition"));
+
+	TRAP(err, src->AnalyseCrashL(0));
+	if(KErrNone == err)
+		{
+		ERR_PRINTF1(_L("Were able to analyse a non existant crash with KErrNone"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+
+	INFO_PRINTF2(_L("Analysis gave %d as expected"), err);
+
+	CleanupStack::PopAndDestroy(2);
+	}
+
+/**
+ * Testing we can retrieve trace data when it is present
+ */
+void CCoreDumpServerWrapper::TestDataSourceReturnsTraceDataL()
+	{
+	INFO_PRINTF1(_L("TestDataSourceReturnsTraceDataL"));
+
+	//Load Test Formatter
+	CFlashDataSource* src = CFlashDataSource::NewL(iSecSess);
+	CleanupStack::PushL(src);
+
+	RCrashInfoPointerList* crashList = new(ELeave)RCrashInfoPointerList;
+	TCleanupItem listCleanup(CCoreDumpServerWrapper::CleanupCrashList, (TAny*)crashList);
+	CleanupStack::PushL(listCleanup);
+
+	//Get the crashes from the flash partition
+	iCoreDumpSession.ListCrashesInFlashL(*crashList);
+
+	if(crashList->Count() == 0)
+		{
+		ERR_PRINTF1(_L("Failed to find any crashes in the flash that we could check out"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+
+	INFO_PRINTF2(_L("Found [%d] crash(es) on the partition"), crashList->Count());
+
+	INFO_PRINTF1(_L("Analysing crash 0"));
+	src->AnalyseCrashL(((*crashList)[0])->iCrashId);
+
+	INFO_PRINTF1(_L("Analysis successful"));
+
+	TUint sizeToRead = 0x100;
+	RBuf8 traceData;
+	traceData.CreateL(sizeToRead);
+	traceData.CleanupClosePushL();
+
+	INFO_PRINTF1(_L("Reading the trace buffer"));
+
+	TRAPD(err, src->ReadTraceBufferL(traceData));
+	if(err != KErrNone)
+		{
+		ERR_PRINTF1(_L("Failed to get trace data"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+
+	INFO_PRINTF1(_L("Making sure the trace data is correct"));
+
+	//Can't analyse this data, just make sure its there
+	if(sizeToRead != traceData.Length())
+		{
+		ERR_PRINTF1(_L("Didnt read all the trace data there"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+
+	INFO_PRINTF1(_L("Trying to read with a zero sized buffer"));
+
+	//See what happens when we put in a zero size buffer
+	RBuf8 buf;
+	buf.CreateL(0);
+	buf.CleanupClosePushL();
+
+	TRAP(err, src->ReadTraceBufferL(buf));
+	if(err != KErrNone)
+		{
+		ERR_PRINTF1(_L("Failed to get trace data with a zero size buffer"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(4);
+		return;
+		}
+
+	CleanupStack::PopAndDestroy(4);
+	}
+
+/**
+ * This tests that untrusted clients cannot do things with the CDS that they shouldnt
+ */
+void CCoreDumpServerWrapper::TestUntrustedServerAccessL()
+	{
+	INFO_PRINTF1(_L("TestUntrustedServerAccessL"));
+
+	INFO_PRINTF1(_L("Testing we can't list crashes from the flash partition"));
+
+	RCrashInfoPointerList* crashList = new(ELeave)RCrashInfoPointerList;
+	TRAPD(err, iCoreDumpSession.ListCrashesInFlashL(*crashList));
+	if(err != KErrPermissionDenied)
+		{
+		delete crashList;
+		ERR_PRINTF1(_L("Allowed to List crashes - shouldnt be. Are you sure the CDS token isn't in the ROM or on the device?"));
+		SetBlockResult(EFail);
+		return;
+		}
+
+	delete crashList;
+
+	INFO_PRINTF1(_L("Testing we can't delete the flash partition"));
+	TRAP(err, iCoreDumpSession.DeleteCrashPartitionL());
+	if(err != KErrPermissionDenied)
+		{
+		ERR_PRINTF1(_L("Allowed to delete flash partition - shouldnt be. Are you sure the CDS token isn't in the ROM or on the device?"));
+		SetBlockResult(EFail);
+		return;
+		}
+
+	INFO_PRINTF1(_L("Testing we can't process crash logs"));
+	TRAP(err, iCoreDumpSession.ProcessCrashLogL(0));
+	if(err != KErrPermissionDenied)
+		{
+		ERR_PRINTF2(_L("Allowed to process crash logs (%d) - shouldn't be. Are you sure the CDS token isn't in the ROM or on the device?"), err);
+		SetBlockResult(EFail);
+		return;
+		}
+
+	INFO_PRINTF1(_L("All is good. Move along, nothing to see here"));
+	}
+
+/**
+ * Cleanup item implementation for RCrashInfoPointerList
+ * @param aArray pointer to the list that is supposed to be freed
+*/
+void CCoreDumpServerWrapper::CleanupCrashList(TAny *aArray)
+	{
+	RCrashInfoPointerList* crashList = static_cast<RCrashInfoPointerList*> (aArray);
+	crashList->ResetAndDestroy();
+	crashList->Close();
+	delete crashList;
+	}
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_crash_board.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,192 @@
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file t_crash_board.cpp
+ @internalTechnology
+*/
+
+#include <coredumpinterface.h>
+#include "t_crash_board.h"
+
+//Names of functions to be tested - referenced from script file
+_LIT(KCrashBoard, "CrashBoard");
+_LIT(KCleanFlashPartition, "CleanFlashPartition");
+_LIT(KCleanEntireFlashPartition, "CleanEntireFlashPartition");
+
+
+/**
+ * Constructor for test wrapper
+ */
+CCrashBoardWrapper::CCrashBoardWrapper()
+	{
+	}
+
+/**
+ * Destructor
+ */
+CCrashBoardWrapper::~CCrashBoardWrapper()
+	{
+    }
+
+/**
+ * Two phase constructor for CCrashBoardWrapper
+ * @return CCrashBoardWrapper object
+ * @leave
+ */
+CCrashBoardWrapper* CCrashBoardWrapper::NewL()
+	{
+	CCrashBoardWrapper* ret = new (ELeave) CCrashBoardWrapper();
+	CleanupStack::PushL(ret);
+	ret->ConstructL();
+	CleanupStack::Pop(ret);
+	return ret;
+	}
+
+/**
+ * Safe construction
+ * @leave
+ */
+void CCrashBoardWrapper::ConstructL()
+	{
+	}
+
+/**
+ * Assign the object
+ *
+ * @param aObject TAny* to the object to test
+ * @leave
+ */
+void CCrashBoardWrapper::SetObjectL(TAny* aObject)
+	{
+    INFO_PRINTF1(_L("GETS CALLED CCrashBoardWrapper::SetObjectL"));
+	}
+
+/**
+ * Runs a test preamble
+ */
+void CCrashBoardWrapper::PrepareTestL()
+	{
+	SetBlockResult(EPass);
+
+	INFO_PRINTF1(_L("Ready to start test"));
+	}
+
+/**
+ * Process command to see what test to run
+ */
+TBool CCrashBoardWrapper::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
+	{
+	__UHEAP_MARK;
+	
+	PrepareTestL();
+
+	if (KCrashBoard() == aCommand)
+		{
+		INFO_PRINTF1(_L("CCrashBoardWrapper::DoCommandL: Inside Command KCrashBoard"));
+		DoCmdCrashBoardL(aSection);
+		}
+	else if (KCleanFlashPartition() == aCommand)
+		{
+		INFO_PRINTF1(_L("CCrashBoardWrapper::DoCommandL: Inside Command KCleanFlashPartition"));
+		DoCmdCleanCrashPartition();
+		}
+	else if (KCleanEntireFlashPartition() == aCommand)
+		{
+		INFO_PRINTF1(_L("CCrashBoardWrapper::DoCommandL: Inside Command KCleanEntireFlashPartition"));
+		DoCmdCleanEntireCrashPartitionL();
+		}
+	else
+		{
+        INFO_PRINTF1(_L("CCrashBoardWrapper::DoCommandL: NOT ** Inside Any Command"));
+		return EFalse;
+		}
+	RDebug::Printf("Returnng from DoCommandL");
+	__UHEAP_MARKEND;
+
+	return ETrue;
+	}
+
+void CCrashBoardWrapper::DoCmdCleanCrashPartition()
+	{
+	INFO_PRINTF1(_L("CCrashBoardWrapper::DoCmdCleanCrashPartition - Deleting entire crash flash partition"));
+	
+	RCoreDumpSession session;
+	session.Connect();
+	CleanupClosePushL(session);
+	
+	session.DeleteCrashPartitionL();
+	
+	INFO_PRINTF1(_L("CCrashBoardWrapper::DoCmdCleanCrashPartition - Deleting entire crash flash partition succesful"));
+	
+	CleanupStack::PopAndDestroy(&session);
+	}
+
+/**
+ * This tests deletes the entire crash flash partition using the DSS
+ * @leave
+ */
+void CCrashBoardWrapper::DoCmdCleanEntireCrashPartitionL()
+	{
+	INFO_PRINTF1(_L("CCrashBoardWrapper::DoCmdCleanEntireCrashPartitionL - Deleting entire crash flash partition using the DSS"));
+	TVersion secVers(Debug::KDebugServMajorVersionNumber, Debug::KDebugServMinorVersionNumber, Debug::KDebugServPatchVersionNumber);
+	User::LeaveIfError(iSecSess.Connect(secVers));
+	
+	INFO_PRINTF1(_L("Erasing the flash EraseCrashFlashPartition using DSS"));
+	iSecSess.EraseCrashFlashPartition();
+	
+	INFO_PRINTF1(_L("Erasing the flash EraseCrashFlashPartition using DSS Successful"));
+	iSecSess.Close();
+	
+	}
+/**
+ * This tests that we can succesfully construct
+ * @leave
+ */
+void CCrashBoardWrapper::DoCmdCrashBoardL(const TDesC& aSection)
+	{
+	TPtrC crashAppParam;
+	
+    //read from the INI for crashapp paramemters
+	if(!GetStringFromConfig(aSection, KTe_CrashAppParam, crashAppParam))
+		{
+		ERR_PRINTF1(_L("Failed to get data from ini file"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+	    }
+
+    INFO_PRINTF2(_L("The CrashApp Parameters are: crashapp %S, "), &crashAppParam); // print it to check
+
+	RProcess crashProcess;
+	CleanupClosePushL(crashProcess);
+
+	TInt ret = crashProcess.Create( KCrashAppFileName, crashAppParam);
+	if(ret != KErrNone)
+		{
+		ERR_PRINTF2( _L("Failed to create process CRASHAPP ret=%d\n"), ret );
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+    
+    //resume the crashapp process
+    crashProcess.Resume();
+
+    CleanupStack::PopAndDestroy(&crashProcess); //RProcess crashProcess
+
+	INFO_PRINTF1(_L("DoCmdCrashL DONE"));
+	}
+//eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_process_crash.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,2792 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file t_process_crash.cpp
+ @internalTechnology
+*/
+
+#include <bautils.h>
+
+#include "t_process_crash.h"
+
+using namespace Debug;
+
+//Names of functions to be tested - referenced from script file
+_LIT(KProcessCrashNewL, "NewL");
+_LIT(KReadCrashInfo, "ReadCrashInfo");
+_LIT(KDeleteAllCrash, "DeleteAllCrashes");
+_LIT(KLoadPlugins, "LoadPlugins");
+_LIT(KUnLoadPlugins, "UnLoadPlugins");
+_LIT(KConfigurePlugins, "ConfigurePlugins");
+_LIT(KConfigureSCMZeroPriority, "ConfigureSCMZeroPriority");
+_LIT(KCheckMultipleCrashes, "CheckMultipleCrashes");
+_LIT(KValidateSingleELFFile, "ValidateSingleELFFile");
+_LIT(KValidateMultipleSELFFile, "ValidateMultipleSELFFile");
+_LIT(KValidateSelfCPUId, "ValidateSelfCPUID");
+_LIT(KValidateHeapSELFFile, "ValidateHeapSELFFile");
+_LIT(KValidateTraceSELFFile, "ValidateTraceSELFFile");
+_LIT(KPerformanceMeasureSELFFile, "PerformanceMeasureSELFFile");
+_LIT(KValidateCorruptCrash, "ValidateCorruptCrash");
+_LIT(KValidateAsyncProcessCrashLog, "ValidateAsyncProcessCrashLog");
+_LIT(KValidateAsyncProcessAndLiveCrash, "ValidateAsyncProcessAndLiveCrash");
+
+//list of exception to check for
+enum TCheckExecption
+	{
+	ETestDataAbort = 24
+	};
+
+//Max String Read out from the SELF file String scetion
+const TInt KMaxStringLength = 200;
+
+//Minimum amount of crashes we need for multi crash tests
+const TInt KMinimumAcceptableCrashNumber = 2;
+
+// crash type
+enum TCrashType
+	{ECrashException, ECrashKill};
+
+/**
+ * Constructor for test wrapper
+ */
+CProcessCrashWrapper::CProcessCrashWrapper()
+	{
+	}
+
+/**
+ * Destructor
+ */
+CProcessCrashWrapper::~CProcessCrashWrapper()
+	{
+	iCrashList.ResetAndDestroy();
+	iCoreDumpSession.Disconnect();
+	iFsSession.Close();
+	iThreadCrashed.Close();
+	}
+
+/**
+ * Two phase constructor for CProcessCrashWrapper
+ * @return CProcessCrashWrapper object
+ * @leave
+ */
+CProcessCrashWrapper* CProcessCrashWrapper::NewL()
+	{
+	CProcessCrashWrapper* ret = new (ELeave) CProcessCrashWrapper();
+	CleanupStack::PushL(ret);
+	ret->ConstructL();
+	CleanupStack::Pop(ret);
+	return ret;
+	}
+
+/**
+ * Safe construction
+ * @leave
+ */
+void CProcessCrashWrapper::ConstructL()
+	{
+	User::LeaveIfError(iFsSession.Connect());
+	iFsSession.SetSessionPath(KDir);
+	}
+
+/**
+ * Assign the object
+ *
+ * @param aObject TAny* to the object to test
+ * @leave
+ */
+void CProcessCrashWrapper::SetObjectL(TAny* aObject)
+	{}
+
+/**
+ * Runs a test preamble
+ */
+void CProcessCrashWrapper::PrepareTestL()
+	{
+	SetBlockResult(EPass);
+
+	//Delete any crash files from previous tests
+	TBuf<KMaxFileName> name;
+	name.Append(KDir);
+	name.Append(KCrashWildCard);
+	BaflUtils::DeleteFile(iFsSession, name);
+	}
+
+/**
+ * Handle a command invoked from the script
+ *
+ * @param aCommand Is the name of the command
+ *   for a TBuf
+ * @param aSection Is the .ini file section where parameters to the command
+ *   are located
+ * @param aAsyncErrorIndex Is used by the TEF Block framework to handle
+ *   asynchronous commands.
+ */
+
+TBool CProcessCrashWrapper::DoCommandL(const TTEFFunction& aCommand,
+		const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
+	{
+
+	//__UHEAP_MARK;
+
+	PrepareTestL();
+
+	if (KProcessCrashNewL() == aCommand)
+		{
+		DoCmdNewL();
+		}
+	else if (KReadCrashInfo() == aCommand)
+		{
+		DoCmdReadCrashInfoL();
+		}
+	else if (KCheckMultipleCrashes() == aCommand)
+		{
+		DoCmdCheckMultipleCrashesL();
+		}
+	else if (KDeleteAllCrash() == aCommand)
+		{
+		DoCmdDeleteAllCrashL();
+		}
+	else if (KLoadPlugins() == aCommand)
+		{
+		DoCmdLoadPluginsL();
+		}
+	else if (KUnLoadPlugins() == aCommand)
+		{
+		DoCmdUnLoadPluginsL();
+		}
+	else if (KConfigurePlugins() == aCommand)
+		{
+		DoCmdConfigurePluginsL(KCrashFileName);
+		}
+	else if (KConfigureSCMZeroPriority() == aCommand)
+		{
+		DoCmdConfigureSCMZeroPriorityL();
+		}
+	else if (KValidateSingleELFFile() == aCommand)
+		{
+		DoCmdValidateSingleELFFileL();
+		}
+	else if (KValidateMultipleSELFFile() == aCommand)
+		{
+		DoCmdValidateMultipleELFFileL();
+		}
+	else if (KValidateSelfCPUId() == aCommand)
+		{
+		DoCmdValidateCpuIDL();
+		}
+	else if (KValidateHeapSELFFile() == aCommand)
+		{
+		DoCmdValidateHeapSELFFileL();
+		}
+	else if (KValidateTraceSELFFile() == aCommand)
+		{
+		DoCmdValidateTraceSELFFileL();
+		}
+	else if (KPerformanceMeasureSELFFile() == aCommand)
+		{
+		DoCmdPerformanceMeasureSELFFileL();
+		}
+	else if (KValidateCorruptCrash() == aCommand)
+		{
+		DoCmdValidateCorruptCrashL();
+		}
+	else if (KValidateAsyncProcessCrashLog() == aCommand)
+		{
+		DoCmdValidateAsyncProcessCrashLogL();
+		}
+	else if (KValidateAsyncProcessAndLiveCrash() == aCommand)
+		{
+		DoCmdValidateAsyncProcessAndLiveCrashCrashLogL(aSection);
+		}
+	else
+		{
+		INFO_PRINTF1(_L("NOT ** Inside Command"));
+		return EFalse;
+		}
+
+	//__UHEAP_MARKEND;
+
+	return ETrue;
+	}
+
+/**
+ * The initailization function wherein the sessions to Core Dump Server is established
+ */
+void CProcessCrashWrapper::DoCmdNewL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper::DoCmdNewL"));
+
+	TInt err = iCoreDumpSession.Connect();
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::DoCmdNewL: iCoreDumpSession->Connect() failed!, err:%d\n"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	}
+
+/**
+ * Reads all the crash information present in the flash
+ */
+void CProcessCrashWrapper::DoCmdReadCrashInfoL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper:: DoCmdReadCrashInfoL\n"));
+
+	//Do list all the Crash Information here
+	TRAPD(err, iCoreDumpSession.ListCrashesInFlashL(iCrashList));
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::DoCmdReadCrashInfoL: Could not read Crashes in the Flash! err:%d\n"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	INFO_PRINTF2(_L("Number of crash information present: %d"),
+			iCrashList.Count());
+
+	for (TInt i = 0; i < iCrashList.Count(); i++)
+		{
+		INFO_PRINTF3(_L("Crash no: %d, CrashId %d"), i, iCrashList[i]->iCrashId);
+		INFO_PRINTF3(_L("Crash no: %d, Type %ld"), i, iCrashList[i]->iType);
+		INFO_PRINTF3(_L("Crash no: %d, Time %ld"), i, iCrashList[i]->iTime);
+		INFO_PRINTF3(_L("Crash no: %d, Thread ID %ld"), i, iCrashList[i]->iTid);
+		}
+	}
+
+/**
+ * Test case specific to DT-coredump-monitor-010
+ * Reads all the crash information present
+ * Checks for exactly four crashed present
+ * Process the crash without any plugins
+ */
+void CProcessCrashWrapper::DoCmdCheckMultipleCrashesL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper:: DoCmdCheckMultipleCrashesL"));
+
+	//reads all the crash information present in the flash
+	DoCmdReadCrashInfoL();
+
+	//check for exactly four crashes present in the flash
+	if (iCrashList.Count() < KMinimumAcceptableCrashNumber)
+		{
+		ERR_PRINTF1(_L("CProcessCrashWrapper::DoCmdCheckMultipleCrashesL Could not find multiple crashes"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	INFO_PRINTF1(_L("Verified that there are multiple crashes present"));
+	INFO_PRINTF1(_L("CProcessCrashWrapper:: Procesing the crashes!!!"));
+
+	for (TInt i = 0; i < iCrashList.Count(); i++)
+		{
+		//process teh crash log for each of the crashes present
+		TRAPD(error, iCoreDumpSession.ProcessCrashLogL(iCrashList[i]->iCrashId));
+		if (error != KErrNone)
+			{
+			ERR_PRINTF2(
+					_L("CProcessCrashWrapper::ProcessCrashLogL: Could not process crash! err:%d\n"),
+					error);
+			SetBlockResult(EFail);
+			User::Leave(error);
+			}
+		}
+	}
+
+/**
+ * Deletes all crashes in the flash
+ * Always called after Reading all crash information present
+ * by CProcessCrashWrapper::DoCmdReadCrashInfoL()
+ */
+void CProcessCrashWrapper::DoCmdDeleteAllCrashL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper:: DoCmdDeleteAllCrashL deleting all the crashes"));
+
+	TRAPD(err, iCoreDumpSession.DeleteCrashPartitionL());
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::DoCmdDeleteAllCrashL: Could not delete crash! err:%d\n"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	INFO_PRINTF1(_L("Successfully deleted all the crashes"));
+	}
+
+/**
+ * Loads the SELF Formatter and the File Writer plugin
+ */
+void CProcessCrashWrapper::DoCmdLoadPluginsL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapperloading SELF Formatter and File Writer!!!"));
+
+	TPluginRequest loadSELFReq;
+	loadSELFReq.iPluginType = TPluginRequest::EFormatter;
+	loadSELFReq.iLoad = ETrue;
+	loadSELFReq.iUid = KUidELFFormatterV2;
+
+	TPluginRequest loadWriterReq;
+	loadWriterReq.iPluginType = TPluginRequest::EWriter;
+	loadWriterReq.iLoad = ETrue;
+	loadWriterReq.iUid = KUidFileWriter;
+
+	// loading Symbian ELF formatter
+	TRAPD(ret, iCoreDumpSession.PluginRequestL(loadSELFReq));
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::DoCmdLoadPluginsL: Could not load SELF plugin!, err:%d\n"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	// loading Symbian File writer
+	TRAP(ret, iCoreDumpSession.PluginRequestL(loadWriterReq));
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::DoCmdLoadPluginsL: Could not load writer plugin!, err:%d\n"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	//intend to check for the loaded SELF formatter and File Writer
+	RPluginList pluginLists;
+	CleanupClosePushL(pluginLists);
+
+	TRAP(ret, iCoreDumpSession.GetPluginListL(pluginLists));
+
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::DoCmdLoadPluginsL: Could not get plugin list!, err:%d\n"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	//Now we look through the list, until we find our plugin, its a fail
+
+	for (TInt i = 0; i < pluginLists.Count(); i++)
+		{
+		if (pluginLists[i].iUid == KUidELFFormatterV2 && !(pluginLists[i].iLoaded))
+			{
+			ERR_PRINTF1(
+					_L("SELF Plugin Not loaded !\n"));
+			SetBlockResult(EFail);
+			User::Leave(KErrNotFound);
+			}
+		}
+
+	for (TInt i = 0; i < pluginLists.Count(); i++)
+		{
+		if (pluginLists[i].iUid == KUidFileWriter && !(pluginLists[i].iLoaded))
+			{
+			ERR_PRINTF1(
+								_L("Writer Plugin Not loaded !\n"));
+			SetBlockResult(EFail);
+			User::Leave(KErrNotFound);
+			}
+		}
+
+	INFO_PRINTF1(_L("SELF Formatter and File Writer loaded successfully \n"));
+	CleanupStack::PopAndDestroy();//pluginLists
+	}
+
+/**
+ * UnLoads the SELF Formatter and the File Writer plugin
+ */
+void CProcessCrashWrapper::DoCmdUnLoadPluginsL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper DoCmdUnLoadPluginsL unloading SELF Formatter and File Writer"));
+
+	TPluginRequest unloadSELFReq;
+	unloadSELFReq.iPluginType = TPluginRequest::EFormatter;
+	unloadSELFReq.iLoad = EFalse;
+	unloadSELFReq.iUid = KUidELFFormatterV2;
+
+	TPluginRequest unloadWriterReq;
+	unloadWriterReq.iPluginType = TPluginRequest::EWriter;
+	unloadWriterReq.iLoad = EFalse;
+	unloadWriterReq.iUid = KUidFileWriter;
+
+	TRAPD(ret, iCoreDumpSession.PluginRequestL(unloadSELFReq));
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::DoCmdLoadPluginsL: Could not unload SELF plugin!, err:%d\n"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	TRAPD(err, iCoreDumpSession.PluginRequestL(unloadWriterReq));
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::DoCmdLoadPluginsL: Could not unload writer plugin!, err:%d\n"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	INFO_PRINTF1(_L("Successful unloading SELF Formatter and File Writer"));
+	}
+
+/**
+ * Configuring the SCM to have minimal information the flash
+ * Done inorder to incorporate more crashes in the flash
+ */
+void CProcessCrashWrapper::DoCmdConfigureSCMZeroPriorityL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper::DoCmdConfigureSCMZeroPriority setting all SCM configurations to zero priority"));
+
+	TInt noConfigParams = 0;
+	// this will ultimateley read the config
+    TRAPD(err, noConfigParams = iCoreDumpSession.GetNumberConfigParametersL());
+    if(err != KErrNone)
+        {
+        ERR_PRINTF1(_L("COULD not read number of config params"));
+		User::Leave(KErrGeneral);
+		SetBlockResult(EFail);
+        }
+    else
+    	{
+
+    	INFO_PRINTF2(_L("CProcessCrashWrapper::DoCmdConfigureSCMZeroPriority found %d config params"), noConfigParams);
+		for (TInt i = 0; i < noConfigParams; i++)
+			{
+			TInt priority = 1;//setting priority to one for all
+
+			COptionConfig* conf = iCoreDumpSession.GetConfigParameterL(i);
+			CleanupStack::PushL(conf);
+
+			if (conf->Source()== COptionConfig::ESCMConfig)
+				{
+				TConfigItem::TSCMDataType dataType = (TConfigItem::TSCMDataType) conf->Instance();
+
+//				INFO_PRINTF3(_L("CProcessCrashWrapper::DoCmdConfigureSCMZeroPriority found config data type %d priority %d")
+//						, dataType, conf->Value());
+
+				if(dataType == TConfigItem::EKernelHeap || dataType == TConfigItem::EThreadsUsrStack || dataType == TConfigItem::EThreadsSvrStack )
+					{
+					priority = 0;
+					INFO_PRINTF3(_L("CProcessCrashWrapper::DoCmdConfigureSCMZeroPriority modifying data type %d with priority %d")
+							, dataType, priority);
+					}
+
+				// set the value
+				conf->Value(priority);
+				TRAP(err, iCoreDumpSession.SetConfigParameterL(*conf));
+				if (err != KErrNone)
+					{
+					ERR_PRINTF3(
+							_L("CProcessCrashWrapper::DoCmdConfigureSCMZeroPriority for SCM Configurations failed error code is %d changing param for run no: %d"),
+							err, i);
+					SetBlockResult(EFail);
+					User::Leave(err);
+					}
+				}
+
+			CleanupStack::PopAndDestroy(conf);
+			}
+
+    	}
+
+	INFO_PRINTF1(_L("SCM Configuration successful"));
+	}
+
+/**
+ * Tests that the SELF plugin can handle invalid configuration
+ */
+void CProcessCrashWrapper::DoCmdConfigureSELFPluginWithInvalidnessL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper::DoCmdConfigureSELFPluginWithInvalidnessL configuring the Core dump server and File Writer plugin"));
+
+	TUint numConfigParams = 0;
+	TRAPD(err, numConfigParams = iCoreDumpSession.GetNumberConfigParametersL());
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to get the number of config parameters. Returned %d"), err);
+		SetBlockResult(EFail);
+		return;
+		}
+
+	INFO_PRINTF2(_L("Found %d params"), numConfigParams);
+
+	for (TInt i = 0; i < numConfigParams; i++)
+		{
+		COptionConfig* conf;
+		conf = iCoreDumpSession.GetConfigParameterL(i);
+		CleanupStack::PushL(conf);
+
+		if(conf->Source() == COptionConfig::EFormatterPlugin)
+			{
+			//Try to configure with the old invalidity
+			switch(conf->Type())
+				{
+				}
+			}
+
+		CleanupStack::PopAndDestroy(conf);
+
+		}
+
+	}
+
+/**
+ * Configuring the Core Dump Server and the File Writer
+ * @param aSELFFileName is the SELF File Name configuring the File Writer plugin
+ */
+void CProcessCrashWrapper::DoCmdConfigurePluginsL(const TDesC& aSELFFileName)
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper DoCmdConfigurePlugins configuring the Core dump server and File Writer plugin"));
+
+	//Configuring the Core Dump Server
+	TRAPD(ret, DoConfigureL(2, KCDSUid.iUid, COptionConfig::ECoreDumpServer,
+			COptionConfig::ETUInt, KPostCrashEventActionPrompt, 1, KNullDesC,
+			4, KNullDesC, 0));
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::DoConfigureL for CDS Error %d changing param"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	//Configuring the file writer plugin to have a specified crash file name
+	TRAPD(err, DoConfigureL((TInt)(CCrashDataSave::ECoreFilePath),
+			KUidFileWriter.iUid, COptionConfig::EWriterPlugin,
+			COptionConfig::ETFileName, KFilePathPrompt, 1, KNullDesC, 0,
+			aSELFFileName, 0));
+
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(_L("CProcessCrashWrapper::DoConfigureL for File Writer Error %d changing param"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	}
+/**
+ * @return void
+ * @param aIndex Internal index to the component that owns the object
+ * @param aUID UID of the component that owns the object
+ * @param aSource Type of component that owns the object
+ * @param aType Type of parameter
+ * @param aPrompt Prompt to present to user
+ * @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
+ * @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
+ * @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
+ * @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
+ */
+void CProcessCrashWrapper::DoConfigureL(const TUint32& aIndex,
+		const TUint32& aUID, const COptionConfig::TParameterSource& aSource,
+		const COptionConfig::TOptionType& aType, const TDesC& aPrompt,
+		const TUint32& aNumOptions, const TDesC& aOptions, const TInt32& aVal,
+		const TDesC& aStrValue, const TUint aInstance)
+	{
+	COptionConfig * config;
+
+	config = COptionConfig::NewL(aIndex, aUID, aSource, aType, aPrompt,
+			aNumOptions, aOptions, aVal, aStrValue);
+
+	CleanupStack::PushL(config);
+
+	config->Instance(aInstance);
+
+	//Configure now...
+	iCoreDumpSession.SetConfigParameterL(*config);
+
+	CleanupStack::PopAndDestroy(config);
+	}
+
+void CProcessCrashWrapper::DoCmdValidateCpuIDL()
+	{
+	LOG_MSG(_L("CProcessCrashWrapper::DoCmdValidateCpuIDL()"));
+
+	//expects one crash information to be present in the flash otherwise complain
+	if (iCrashList.Count() != 1)
+		{
+		ERR_PRINTF1(_L("More than one crash information present"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	GenerateElfFileL(iCrashList[0]->iCrashId);
+
+	//open the SELF File for processing
+	TInt err = iSELFFile.Open(iFsSession, iSELFFileName, EFileStream|EFileRead);
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::ProcessELFFile Error opening the SELF File %d"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	//Parse start of ELF file
+	ValidateHeaderELFFileL();
+	ValidateProgramHeaderELFFileL();
+	ValidateSymInfoSectionELFFileL();
+
+	//Validate the CPU Id
+	RDebug::Printf("Looking at CPU ID");
+	ValidateThreadInfoSectionELFFileL(ETrue, KThreadKernelCrash, ETrue);
+
+	TBuf<KMaxFileName> fileName;
+	iSELFFile.Name(fileName);
+
+	INFO_PRINTF2(_L("Finished with %S So im sharking it"), &fileName);
+	iSELFFile.Close();
+	iFsSession.Delete(fileName);
+	}
+/**
+ * Generate the SELF File and search for the generated file
+ * aCrashId  = crash id
+ * aTiming (default value is False) determines the timing measurement
+ */
+void CProcessCrashWrapper::GenerateElfFileL(TUint aCrashId, TBool aTiming)
+	{
+	if(aTiming) HelpStartTestTimer();
+
+	//process the crash with configured SELF formatter and file writer
+	TRAPD(ret, iCoreDumpSession.ProcessCrashLogL(aCrashId));
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(_L("CProcessCrashWrapper::ProcessCrashLogL for CDS Error %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	MonitorProgressL();
+
+	if(aTiming) HelpStopTestTimer();
+
+	INFO_PRINTF1(_L("ProcessCrashLogL Successful"));
+
+	//Use wildcard utilities to search for the SELF FIle Created
+	TBuf<32> buf;
+	buf = KDir;
+	TUidType uid1;
+	TUidType uid2(uid1.MostDerived());
+
+	CFindFileByType* obj = new(ELeave) CFindFileByType(iFsSession);
+	CleanupStack::PushL(obj);
+
+	ret = obj->FindFirst(KCrashWildCard, buf, uid2);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("GenerateElfFileL Error finding the SELF File %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	iSELFFileName = obj->Entry().iName;
+
+	CleanupStack::PopAndDestroy(); //CFindFileByType
+	INFO_PRINTF2(_L("The SELF File Found is E:\\%S "), &iSELFFileName);
+	}
+
+/**
+ * Generate the SELF File and Validate the Symbian INFO and executable sections
+ */
+void CProcessCrashWrapper::DoCmdValidateSingleELFFileL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper DoCmdSingleValidateELFFileL"));
+
+	//expects one crash information to be present in the flash otherwise complain
+	if (iCrashList.Count() != 1)
+		{
+		ERR_PRINTF1(_L("More than one crash information present"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	//generate the SELF File by calling ProcessCrashLogL
+	GenerateElfFileL(iCrashList[0]->iCrashId);
+
+	//open the SELF File for processing
+	TInt err = iSELFFile.Open(iFsSession, iSELFFileName, EFileStream|EFileRead);
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::ProcessELFFile Error opening the SELF File %d"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	//validate the SELF Header Format
+	ValidateHeaderELFFileL();
+
+	//validate the Program Header and store information about the string section Sections
+	ValidateProgramHeaderELFFileL();
+
+	//validate the Symbian Info section
+	ValidateSymInfoSectionELFFileL();
+
+	//validate Thread name that crashed
+	ValidateThreadInfoSectionELFFileL(EFalse, KThreadKernelCrash, ETrue);
+
+	//do the necessary clean up
+	CleanupMethod(iSELFFileName);
+	}
+
+/**
+ * Process the crash log using the asynchrnous API ProcessCrashLog
+ */
+void CProcessCrashWrapper::DoCmdValidateAsyncProcessCrashLogL()
+	{
+
+	INFO_PRINTF1(_L("CProcessCrashWrapper DoCmdValidateAsyncProcessCrashLogL"));
+
+	//expects one crash information to be present in the flash otherwise complain
+	if (iCrashList.Count() != 1)
+		{
+		ERR_PRINTF1(_L("More than one crash information present"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	//create the Active Object to process the crash log asynchrnously
+	CAsyncProcessCrash* asyncProcessCrash = CAsyncProcessCrash::NewL(this);
+	CleanupStack::PushL(asyncProcessCrash);
+
+	asyncProcessCrash->IssueProcessCrashRequest(iCrashList[0]->iCrashId);
+
+	CActiveScheduler::Start();// Doesn’t return until it is explicitly
+
+	RDebug::Printf("After CActiveScheduler::Start");
+	CleanupStack::PopAndDestroy();
+	INFO_PRINTF1(_L("DoCmdValidateAsyncProcessCrashLogL Successful with processing the crash log asynchrnouly"));
+
+	}
+
+/**
+ * Process the crash log using the asynchrnous API ProcessCrashLog whilst a user side crash
+ */
+void CProcessCrashWrapper::DoCmdValidateAsyncProcessAndLiveCrashCrashLogL(const TDesC& aSection)
+	{
+
+	INFO_PRINTF1(_L("CProcessCrashWrapper DoCmdValidateAsyncProcessAndLiveCrashCrashLogL"));
+
+	//expects one crash information to be present in the flash otherwise complain
+	if (iCrashList.Count() != 1)
+		{
+		ERR_PRINTF1(_L("More than one crash information present"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	//generate a live crash using the test application crashapp.exe
+	GenerateLiveCrashL(aSection);
+
+	//start processing the crash log in the flash
+	TRequestStatus asyncSystemCrash;
+    iCoreDumpSession.ProcessCrashLog( (iCrashList[0]->iCrashId), asyncSystemCrash);
+	User::WaitForRequest(asyncSystemCrash);
+
+	//This user after is to ensure the live crash has completed before analysis
+    User::After(3000000);
+
+    //process the two SELF files created
+    DoProcessSELFLiveandKernelL();
+
+	}
+
+/**
+ * Generates a user side crash using the crashapp
+ */
+void CProcessCrashWrapper::GenerateLiveCrashL(const TDesC& aSection)
+	{
+
+	TPtrC crashAppParam;
+	    //read from the INI for crashapp paramemters
+	if(!GetStringFromConfig(aSection, KTe_CrashAppParam, crashAppParam))
+		{
+		ERR_PRINTF1(_L("Failed to get data from ini file"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+	    }
+
+	INFO_PRINTF2(_L("The CrashApp Parameters are: crashapp %S, "), &crashAppParam); // print it to check
+	//Start the process that we intend to crash....
+	RProcess crashProcess;
+	CleanupClosePushL(crashProcess);
+
+	TInt ret = crashProcess.Create( KCrashAppFileName, crashAppParam);
+	if(ret != KErrNone)
+		{
+		INFO_PRINTF2(_L("Error %d from RProcess .Create(z:\\sys\\bin\\crashapp.exe)/n"), ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	INFO_PRINTF1(_L("Started userside crash app"));
+
+	// Observe the process and wait for a crash
+	TRAP(ret, iCoreDumpSession.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue) );
+	if(ret != KErrNone)
+		{
+		INFO_PRINTF2(_L("Error %d iCoreDumpSession.ObservationRequestL(z:\\sys\\bin\\crashapp.exe)\n"), ret);
+		SetBlockResult(EFail);
+		User::Leave( ret );
+		}
+
+	//start the crash process which should go ahead a create a crash
+	crashProcess.Resume();
+	CleanupStack::PopAndDestroy(&crashProcess); //this is for crashProcess
+
+	}
+
+/**
+ * Complete the processing the SELF file generated after the async ProcessCrashLog
+ * called from RunL
+ */
+void CProcessCrashWrapper::ProcessSELFFileCreatedL()
+	{
+
+	INFO_PRINTF1(_L("CProcessCrashWrapper ProcessSELFFileCreatedL called after RunL"));
+
+	//Use wildcard utilities to search for the SELF FIle Created
+	TBuf<32> buf;
+	buf = KDir;
+	TUidType uid1;
+	TUidType uid2(uid1.MostDerived());
+
+	CFindFileByType* obj = new(ELeave) CFindFileByType(iFsSession);
+	CleanupStack::PushL(obj);
+
+	TInt ret = obj->FindFirst(KCrashWildCard, buf, uid2);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(_L("GenerateElfFileL Error finding the SELF File %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	iSELFFileName = obj->Entry().iName;
+	CleanupStack::PopAndDestroy();//CFindFileByType* obj
+
+	INFO_PRINTF2(_L("The SELF File Found is E:\\%S "), &iSELFFileName);
+
+	//open the SELF File for processing
+	TInt err = iSELFFile.Open(iFsSession, iSELFFileName, EFileStream|EFileRead);
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::ProcessSELFFileCreatedL Error opening the SELF File %d"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	//validate the SELF Header Format
+	ValidateHeaderELFFileL();
+
+	//validate the Program Header and store information about the string section Sections
+	ValidateProgramHeaderELFFileL();
+
+	//validate the Symbian Info section
+	ValidateSymInfoSectionELFFileL();
+
+	//validate Thread name that crashed
+	ValidateThreadInfoSectionELFFileL(EFalse, KThreadKernelCrash, ETrue);
+
+	//do the necessary clean up
+	CleanupMethod(iSELFFileName);
+
+	}
+
+/**
+ * Process the two SELF files created for user and kernel side crashes
+ */
+void CProcessCrashWrapper::DoProcessSELFLiveandKernelL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper DoProcessSELFLiveandKernel about process user and kernel crashes"));
+
+	TBool systemcrash = EFalse;
+
+	//Use wildcard utilities to search for the two SELF File Created
+	TBuf<32> buf;
+	buf = KDir;
+	TUidType uid1;
+	TUidType uid2(uid1.MostDerived());
+
+	CFindFileByType* obj = new(ELeave) CFindFileByType(iFsSession);
+	CleanupStack::PushL(obj);
+
+	TInt ret = obj->FindFirst(KCrashWildCard, buf, uid2);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("DoProcessSELFLiveandKernelL Error finding the SELF File %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	iSELFFileName = obj->Entry().iName;
+	INFO_PRINTF2(_L("The SELF File Found is E:\\%S "), &iSELFFileName);
+
+    ret = iSELFFile.Open(iFsSession, iSELFFileName, EFileStream|EFileRead);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("DoProcessSELFLiveandKernelL Error opening the SELF File %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	//validate the SELF Header Format
+	ValidateHeaderELFFileL();
+
+	//validate the Program Header and store information about the string section Sections
+	ValidateProgramHeaderELFFileL();
+
+	//validate the Symbian Info section
+	ValidateSymInfoSectionELFFileL();
+
+	//validate the Register Info Section also verifies the CPSR to check on the type of the crash
+	ValidateRegisterInfoSectionELFFileL();
+
+	if(iSystemCrash)//if it is a System Crash
+		{
+		//checking this SELF file for the kernel crash
+		ValidateThreadInfoSectionELFFileL(EFalse, KThreadKernelCrash, ETrue);
+		}
+	else
+		{
+		//checking this one for user crash
+		ValidateThreadInfoSectionELFFileL(EFalse, KThreadUserCrash, ETrue);
+		}
+
+	systemcrash = iSystemCrash;
+	//do the necessary clean up
+	CleanupMethod(iSELFFileName);
+
+	//Find the next SELF file
+	ret = obj->FindNext();
+
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF1(
+				_L("DoProcessSELFLiveandKernelL Expecting Two SELF files to be created"));
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	iSELFFileName = obj->Entry().iName;
+	INFO_PRINTF2(_L("The SELF File Found is E:\\%S "), &iSELFFileName);
+
+	CleanupStack::PopAndDestroy(); //CFindFileByType
+
+	//open the SELF File for processing
+	ret = iSELFFile.Open(iFsSession, iSELFFileName, EFileStream|EFileRead);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("DoProcessSELFLiveandKernelL Error opening the SELF File %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	//validate the SELF Header Format
+	ValidateHeaderELFFileL();
+
+	//validate the Program Header and store information about the string section Sections
+	ValidateProgramHeaderELFFileL();
+
+	//validate the Symbian Info section
+	ValidateSymInfoSectionELFFileL();
+
+	//validate the Register Info Section also verifies the CPSR to check on the type of the crash
+	ValidateRegisterInfoSectionELFFileL();
+
+	if(iSystemCrash == systemcrash)
+		{
+		ERR_PRINTF1( _L("Expecting to have two different types of crashes one User side and the other one as System Crash"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	if(iSystemCrash)//if it is a System Crash
+		{
+		//checking this SELF file for the kernel crash
+		ValidateThreadInfoSectionELFFileL(EFalse, KThreadKernelCrash, ETrue);
+		}
+	else
+		{
+		//checking this one for user crash
+		ValidateThreadInfoSectionELFFileL(EFalse, KThreadUserCrash, ETrue);
+		}
+
+	//do the necessary clean up
+	CleanupMethod(iSELFFileName);
+
+	}
+/**
+ * Generate multiple SELF File and Validate the Symbian INFO and executable sections
+ */
+void CProcessCrashWrapper::DoCmdValidateMultipleELFFileL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper::DoCmdValidateMultipleELFFileL parsing multiple SELF files"));
+
+	//expects MULTIPLECRASHNUMBERCHECK to be present in the flash otherwise complain
+	if (iCrashList.Count() < KMinimumAcceptableCrashNumber)
+		{
+		ERR_PRINTF1(_L("Did not find multiple crashes"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	for (TInt i = 0; i < iCrashList.Count(); i++)
+		{
+		//generate the SELF File(s) by calling ProcessCrashLogL
+		GenerateElfFileL(iCrashList[i]->iCrashId);
+
+		TInt err = iSELFFile.Open(iFsSession, iSELFFileName, EFileStream|EFileRead);
+		if (err != KErrNone)
+			{
+			ERR_PRINTF2(
+					_L("CProcessCrashWrapper::ProcessELFFile Error opening the SELF File %d"),
+					err);
+			SetBlockResult(EFail);
+			User::Leave(err);
+			}
+
+		//validate the SELF Header Format
+		ValidateHeaderELFFileL();
+
+		//validate the Program Header and store information about the string section Sections
+		ValidateProgramHeaderELFFileL();
+
+		//validate the Symbian Info section
+		ValidateSymInfoSectionELFFileL();
+
+		//validate Thread name that crashed
+		ValidateThreadInfoSectionELFFileL(EFalse, KThreadKernelCrash, ETrue);
+
+		//do the necessary clean up
+		CleanupMethod(iSELFFileName);
+
+		}
+
+/*
+ * code to check on multiple files in the directory and storing them
+ * commented for future reference
+ * RBuf selfname;
+	selfname.CreateL(obj->Entry().iName);
+	selfname.SetMax();
+
+	TBufC<100> selfnamebuffer = obj->Entry().iName;
+	HBufC* selfname = selfnamebuffer.AllocL();
+
+	iArray.Append(selfname);
+
+	INFO_PRINTF2(_L("The SELF File Found is E:\\%S "), &iArray[0]);
+
+	for (TInt i = 0; i < iCrashList.Count() - 1; i++)
+		{
+
+		ret = obj->FindNext();
+		if (ret != KErrNone)
+			{
+			ERR_PRINTF2(
+					_L("CProcessCrashWrapper::CFindFileByType Error finding the SELF File %d"),
+					ret);
+			SetBlockResult(EFail);
+			User::Leave(ret);
+			}
+
+		RBuf selfname2;
+		selfname2.CreateL(obj->Entry().iName);
+		selfname2.SetMax();
+
+		TBufC<100> selfnamebuffer2 = obj->Entry().iName;
+		HBufC* selfname2 = selfnamebuffer2.AllocL();
+
+		iArray.Append(selfname2);// no close
+
+		INFO_PRINTF2(_L("The SELF File Found is E:\\%S "), &iArray[i]);
+	*/
+
+	}
+
+/**
+ * Validates the presence of the heap data in the SELF file
+ */
+void CProcessCrashWrapper::DoCmdValidateHeapSELFFileL()
+	{
+	INFO_PRINTF1(_L("\nDoCmdValidateHeapSELFFileL intend to validate the Heap Section of SELF File"));
+
+	//expects one crash information to be present in the flash otherwise complain
+	if (iCrashList.Count() != 1)
+		{
+		ERR_PRINTF1(_L("More than one crash information present"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	/*
+	 * POSITIVE TEST CASE
+	 * Test for the positive case let the Heap Section be present
+	 */
+
+	//configuring the SELF Formatter to have the date segment
+    ConfigureSELF(ETrue, EHeap);
+
+	//generate the SELF File by calling ProcessCrashLogL
+	GenerateElfFileL(iCrashList[0]->iCrashId);
+
+	//open the SELF File for processing
+	TInt err = iSELFFile.Open(iFsSession, iSELFFileName, EFileStream|EFileRead);
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::ProcessELFFile Error opening the SELF File %d"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	//validate the SELF Header Format
+	ValidateHeaderELFFileL();
+
+	//validate the Program Header and store information about the string section Sections
+	ValidateProgramHeaderELFFileL();
+
+	//validate the Symbian Info section
+	ValidateSymInfoSectionELFFileL();
+
+	//validate Thread name that crashed
+	ValidateThreadInfoSectionELFFileL(EFalse, KThreadKernelCrash, ETrue);
+
+	//validate the heap section to be present
+	ValidateHeapSectionELFFileL(ETrue);
+
+	//clean up of the generated SELF file
+	iSELFFile.Close();
+    TInt ret = iFsSession.Delete(iSELFFileName);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::SELF File delete returned error %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	INFO_PRINTF1(_L("Validation of the Positive Heap Test Case Successful!!!\n\n"));
+
+	/*
+	 * NEGATIVE TEST CASE
+	 * Test for the negative test case let the Heap Section be NOT present
+	 */
+
+	//configuring the SELF NOT to have data segment/heap
+	ConfigureSELF(EFalse, EHeap);
+
+	//generate the SELF File by calling ProcessCrashLogL
+	GenerateElfFileL(iCrashList[0]->iCrashId);
+
+	//open the SELF File for processing
+	err = iSELFFile.Open(iFsSession, iSELFFileName, EFileStream|EFileRead);
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::ProcessELFFile Error opening the SELF File %d"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	//validate the SELF Header Format
+	ValidateHeaderELFFileL();
+
+	//validate the Program Header and store information about the string section Sections
+	ValidateProgramHeaderELFFileL();
+
+	//validate the Symbian Info section
+	ValidateSymInfoSectionELFFileL();
+
+	//validate Thread name that crashed
+	ValidateThreadInfoSectionELFFileL(EFalse, KThreadKernelCrash, ETrue);
+
+	//validate the heap section NOT to be present this time
+	ValidateHeapSectionELFFileL(EFalse);
+
+	//do necessary clean up
+	CleanupMethod(iSELFFileName);
+
+	INFO_PRINTF1(_L("Validation of the Negative Heap Test Case Successful!!!\n\n"));
+	}
+
+/**
+ * Validates the presence of the trace data in the SELF file
+ */
+void CProcessCrashWrapper::DoCmdValidateTraceSELFFileL()
+	{
+	INFO_PRINTF1(_L("\nDoCmdValidateTraceSELFFileL intend to validate the Trace Section of SELF File"));
+
+	//expects one crash information to be present in the flash otherwise complain
+	if (iCrashList.Count() != 1)
+		{
+		ERR_PRINTF1(_L("More than one crash information present"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	/*
+	 * POSITIVE TEST CASE
+	 * Test for the positive case let the Trace Section be present
+	 */
+
+	//configuring the SELF Formatter to have the trace segment
+    ConfigureSELF(ETrue, ETrace);
+
+    //generate the SELF File by calling ProcessCrashLogL
+    GenerateElfFileL(iCrashList[0]->iCrashId);
+
+	//open the SELF File for processing
+	TInt err = iSELFFile.Open(iFsSession, iSELFFileName, EFileStream|EFileRead);
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::ProcessELFFile Error opening the SELF File %d"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	//validate the SELF Header Format
+	ValidateHeaderELFFileL();
+
+	//validate the Program Header and store information about the string section Sections
+	ValidateProgramHeaderELFFileL();
+
+	//validate the Symbian Info section
+	ValidateSymInfoSectionELFFileL();
+
+	//validate Thread name that crashed
+	ValidateThreadInfoSectionELFFileL(EFalse, KThreadKernelCrash, ETrue);
+
+	//validate the trace section to be present
+	ValidateTraceSectionELFFileL(ETrue);
+
+	//clean up of the generated SELF file
+	iSELFFile.Close();
+	TInt ret = iFsSession.Delete(iSELFFileName);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::SELF File delete returned error %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	INFO_PRINTF1(_L("Validation of the Positive Test Case Successful!!!\n\n"));
+
+	/*
+	 * NEGATIVE TEST CASE
+	 * Test for the negative test case let the Trace Section be NOT present
+	 */
+
+	//configuring the SELF NOT to have trace segment
+	ConfigureSELF(EFalse, ETrace);
+
+    //generate the SELF File by calling ProcessCrashLogL
+    GenerateElfFileL(iCrashList[0]->iCrashId);
+
+	//open the SELF File for processing
+	err = iSELFFile.Open(iFsSession, iSELFFileName, EFileStream|EFileRead);
+	if (err != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::ProcessELFFile Error opening the SELF File %d"),
+				err);
+		SetBlockResult(EFail);
+		User::Leave(err);
+		}
+
+	//validate the SELF Header Format
+	ValidateHeaderELFFileL();
+
+	//validate the Program Header and store information about the string section Sections
+	ValidateProgramHeaderELFFileL();
+
+	//validate the Symbian Info section
+	ValidateSymInfoSectionELFFileL();
+
+	//validate Thread name that crashed
+	ValidateThreadInfoSectionELFFileL(EFalse, KThreadKernelCrash, ETrue);
+
+	//validate the heap section NOT to be present this time
+	ValidateTraceSectionELFFileL(EFalse);
+
+	//do necessary clean up
+	CleanupMethod(iSELFFileName);
+
+	INFO_PRINTF1(_L("Validation of the Negative Test Case Successful!!!\n\n"));
+
+	}
+
+/**
+ * Benchmark test of SELF files
+ */
+void CProcessCrashWrapper::DoCmdPerformanceMeasureSELFFileL()
+	{
+	INFO_PRINTF1(_L("CProcessCrashWrapper::DoCmdPerformanceMeasureSELFFileL performing Performance measurement on various SELF file(s)"));
+
+	//expects one crash information to be present in the flash otherwise complain
+	if (iCrashList.Count() != 1)
+		{
+		ERR_PRINTF1(_L("More than one crash information present"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	/*
+	 * WITH OR WITHOUT HEAP DATA
+	 */
+
+	//configuring SELF to have the Heap section
+	ConfigureSELF(ETrue, EHeap);
+
+	//Generate the SELF File keeping a record of the time
+	GenerateElfFileL(iCrashList[0]->iCrashId , ETrue);
+
+	INFO_PRINTF1(_L("SELF File has Heap Data"));
+	ValidatePerformanceELFFile();
+
+	//configuring SELF NOT to have the Heap section
+	ConfigureSELF(EFalse, EHeap);
+
+	//Generate the SELF File keeping a record of the time
+	GenerateElfFileL(iCrashList[0]->iCrashId , ETrue);
+
+	INFO_PRINTF1(_L("SELF File has NO Heap Data"));
+	ValidatePerformanceELFFile();
+
+	/*
+	 * WITH OR WITHOUT CODE SEGEMENT
+	 */
+
+	//configuring SELF to have the Code Segment
+	ConfigureSELF(ETrue, ECode);
+	//putting back the heap data as well
+	ConfigureSELF(ETrue, EHeap);
+
+	//Generate the SELF File keeping a record of the time
+	GenerateElfFileL(iCrashList[0]->iCrashId , ETrue);
+
+	INFO_PRINTF1(_L("SELF File has Code Segement"));
+	ValidatePerformanceELFFile();
+
+	//configuring SELF NOT to have the Code segment
+	ConfigureSELF(EFalse, ECode);
+
+	//Generate the SELF File keeping a record of the time
+	GenerateElfFileL(iCrashList[0]->iCrashId , ETrue);
+
+	INFO_PRINTF1(_L("SELF File has NO Code Segement"));
+	ValidatePerformanceELFFile();
+
+	/*
+	 * WITH OR WITHOUT THREAD SEGEMENT
+	 */
+
+	//configuring SELF to have the Thread Segment
+	ConfigureSELF(ETrue, EThread);
+	//putting back the code segement as well
+	ConfigureSELF(ETrue, ECode);
+
+	//Generate the SELF File keeping a record of the time
+	GenerateElfFileL(iCrashList[0]->iCrashId , ETrue);
+
+	INFO_PRINTF1(_L("SELF File has Thread Segement"));
+	ValidatePerformanceELFFile();
+
+	//configuring SELF NOT to have the Thread segment
+	ConfigureSELF(EFalse, EThread);
+
+	//Generate the SELF File keeping a record of the time
+	GenerateElfFileL(iCrashList[0]->iCrashId , ETrue);
+
+	INFO_PRINTF1(_L("SELF File has NO Thread Segement"));
+	ValidatePerformanceELFFile();
+
+	INFO_PRINTF1(_L("Benchmarking of SELF files successful"));
+	}
+
+/**
+ * Validates the Corrupted Crash Information
+ * Part of neagtive test on ProcessCrashLog
+ */
+void CProcessCrashWrapper::DoCmdValidateCorruptCrashL()
+	{
+	LOG_MSG(_L("CProcessCrashWrapper::DoCmdValidateCorruptCrashL() validating the Corrupted Crash"));
+
+	//reads all the crash information present in the flash
+	DoCmdReadCrashInfoL();
+
+	//expects one crash information to be present in the flash otherwise complain
+	if (iCrashList.Count() != 1)
+		{
+		ERR_PRINTF1(_L("More than one crash information present"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	INFO_PRINTF1(_L("Able to read crash log now start processing the crash"));
+
+	TRAPD(error, iCoreDumpSession.ProcessCrashLogL(iCrashList[0]->iCrashId));
+	if (error == KErrCorrupt)
+		{
+		INFO_PRINTF2(_L("Success!!! The crash information is corrupted returns error %d\n"), error);
+		}
+	else
+		{
+		ERR_PRINTF2(
+				_L("Returns error %d which is NOT  KErrCorrupt\n"),
+				error);
+		SetBlockResult(EFail);
+		User::Leave(error);
+		}
+	}
+
+/**
+ * Validates the Header Format Elf32_Ehdr for the SELF file
+ */
+void CProcessCrashWrapper::ValidateHeaderELFFileL()
+	{// Elf32_Ehdr
+	INFO_PRINTF1(_L("CProcessCrashWrapper::ValidateHeaderELFFileL validating Elf32_Ehdr"));
+	RDebug::Printf("Validating the ELF file");
+
+	TInt sizeofELFHeader = sizeof(Elf32_Ehdr); //size of Elf32_Ehdr structure
+
+	// allocate buffer Elf32_Ehdr
+	TUint8* SELFHeader = new TUint8[sizeofELFHeader];
+	TPtr8 elfHeaderPointer(SELFHeader, sizeofELFHeader, sizeofELFHeader);
+	CleanupStack::PushL(SELFHeader);
+
+	//read the SELF file for Elf32_Ehdr
+	TInt ret = iSELFFile.Read(0, elfHeaderPointer, sizeofELFHeader);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::ValidateHeaderELFFile Error reading the SELF Header Elf32_Ehdr %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+	//
+	Elf32_Ehdr* eh=(Elf32_Ehdr *)SELFHeader;
+
+	//VALIDATE THE Elf32_Ehdr
+
+	if (eh->e_ident[EI_MAG0] !=0x7f || eh->e_ident[EI_MAG1] != 0x45
+			|| eh->e_ident[EI_MAG2] !=0x4c || eh->e_ident[EI_MAG3] != 0x46)
+		{
+		// EI_MAG0 to EI_MAG3 - A files' first 4 bytes hold a 'magic number', identifying the file as an ELF object file.
+		ERR_PRINTF1(_L("Error:  is not a valid ELF file"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+	if (eh->e_ident[EI_DATA] == 2)
+		{
+		// ELF Header size should be 52 bytes or converted into Big-Endian system 13312
+		if (eh->e_ehsize != 13312)
+			{
+			ERR_PRINTF1(_L("Error:  ELF Header contains invalid file typ"));
+			SetBlockResult(EFail);
+			User::Leave(KErrGeneral);
+			}
+		// e_ident[EI_DATA] specifies the data encoding of the processor-specific data in the object file.
+		ERR_PRINTF1(_L("Error:  Data encoding ELFDATA2MSB (Big-Endian) not supported"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+	if (eh->e_ehsize != 52)
+		{
+		// ELF Header size should be 52 bytes
+		ERR_PRINTF1(_L("Error:  ELF Header contains invalid file type"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	//Number of entries in the program header table
+	if ((eh->e_phnum) == 0)
+		{
+		ERR_PRINTF1(_L("Error:  ELF Header contains zero program headers"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	//store number of program header entries
+	iPHEntries = eh->e_phnum;
+	INFO_PRINTF2(_L("Program header entries:%d"), iPHEntries);
+
+	//Offset in bytes from the start of the file to the section header table
+	if ((eh->e_phoff) == 0)
+		{
+		ERR_PRINTF1(_L("Error:  ELF Header contains zero offset to the section header table"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	//store program header offset
+	iPHOffset = eh->e_phoff;
+	INFO_PRINTF2(_L("Program header offsett:%d"), iPHOffset);
+
+	CleanupStack::PopAndDestroy(SELFHeader);
+
+	INFO_PRINTF1(_L("Validation of Elf32_Ehdr successful"));
+	}
+
+/**
+ * Validates the Program Header Entries Elf32_Phdr of the SELF file
+ */
+void CProcessCrashWrapper::ValidateProgramHeaderELFFileL()
+	{//Elf32_Phdr
+	INFO_PRINTF1(_L("CProcessCrashWrapper::ValidateProgramHeaderELFFileL validating the program header Entries"));
+
+	TInt sizeofELFProgramHeader = sizeof(Elf32_Phdr); //size of Elf32_Phdr
+	TInt totalsizeofELFProgramHeader = iPHEntries * sizeofELFProgramHeader;
+
+	//allocate buffer Elf32_Phdr
+	iSELFPHHeader = new TUint8[totalsizeofELFProgramHeader];
+	TPtr8 elfPHHeaderPointer(iSELFPHHeader, totalsizeofELFProgramHeader,
+			totalsizeofELFProgramHeader);
+
+	//read the SELF for the whole Program Header Table
+	TInt ret = iSELFFile.Read(iPHOffset, elfPHHeaderPointer,
+			totalsizeofELFProgramHeader);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::ValidateProgramHeaderELFFileL Error reading the SELF Header Elf32_Phdr %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	Elf32_Phdr* phdr = (Elf32_Phdr*) iSELFPHHeader;//Elf32_Phdr Program Header
+
+	//Prepare for each of the DHDR buffers
+	TInt sizeofDhdr = sizeof(Sym32_dhdr);
+
+	//loop through the program headers to find out more information on the String section
+	for (TInt i = 0; i < iPHEntries; i++)
+		{
+		//allocate DHDR buffers Sym32_dhdr
+		iDHDRBuffer[i] = new TUint8[sizeofDhdr];
+		TPtr8 dhdrPointer(iDHDRBuffer[i], sizeofDhdr, sizeofDhdr);
+
+		//read SELF file for the Sym32_dhdr
+		TInt ret = iSELFFile.Read(phdr[i].p_offset, dhdrPointer, sizeofDhdr);
+		if (ret != KErrNone)
+			{
+			ERR_PRINTF2(
+					_L("CProcessCrashWrapper::ValidateHeaderELFFile Error reading the SELF Header Sym32_dhdr %d"),
+					ret);
+			SetBlockResult(EFail);
+			User::Leave(ret);
+			}
+
+		idhdr[i] = (Sym32_dhdr*) iDHDRBuffer[i];//array of Sym32_dhdr store it
+
+		//find information about the String Info section
+		if (phdr[i].p_type == PT_NOTE)
+			{
+			// Intend to store information about the string section ESYM_NOTE_STR
+			//the srting section is to be accessed for all sectiosn to be parsed
+			if (idhdr[i]->d_type == ESYM_NOTE_STR)
+				{
+				INFO_PRINTF2(_L("ESYM_NOTE_STR Header offset %d"),
+						phdr[i].p_offset);
+				INFO_PRINTF2(
+						_L("ESYM_NOTE_STR Size of single descriptor element %d "),
+						idhdr[i]->d_descrsz);
+
+				iOffsetStringSection = phdr[i].p_offset + sizeof(Sym32_dhdr);
+				iSizeofStringSection = idhdr[i]->d_descrsz;
+
+				}//if ESYM_NOTE_STR
+			}//if PT_NOTE
+		}//for loop
+
+	}//end of function
+
+/**
+ * Validates the Symbian Info Section Sym32_syminfod of the SELF file
+ */
+void CProcessCrashWrapper::ValidateSymInfoSectionELFFileL()
+	{//Sym32_syminfod
+	INFO_PRINTF1(_L("CProcessCrashWrapper::ValidateSymInfoSection validating the Symbian Info Section"));
+
+	Elf32_Phdr* phdr = (Elf32_Phdr*) iSELFPHHeader;//Elf32_Phdr Program Header
+
+	//loop through the program headers to get information about the Symbian Info section
+	for (TInt i = 0; i < iPHEntries; i++)
+		{
+		if (phdr[i].p_type == PT_NOTE)
+			{
+			if (idhdr[i]->d_type == ESYM_NOTE_SYM) //SYMBIAN INFO SEGMENT
+				{
+				if (sizeof(Sym32_syminfod) != (idhdr[i]->d_descrsz))
+					{
+					ERR_PRINTF1(_L("CProcessCrashWrapper::ValidateProgramHeaderELFFileL sizeof(Sym32_syminfod)is different from descriptor size") );
+					SetBlockResult(EFail);
+					User::Leave(KErrGeneral);
+					}
+				TInt sizeofsyminfo = sizeof(Sym32_syminfod);
+				INFO_PRINTF2(_L("ESYM_NOTE_SYM Header offset %d"), phdr[i].p_offset);
+				INFO_PRINTF2(_L("ESYM_NOTE_SYM Size of single descriptor element %d"),
+						idhdr[i]->d_descrsz);
+
+				TInt offsettosyminfod = phdr[i].p_offset + sizeof(Sym32_dhdr);
+
+				//allocate buffer for Sym32_syminfod
+				TUint8* symbianInfoSection = new TUint8[sizeofsyminfo];
+				CleanupStack::PushL(symbianInfoSection);
+
+				TPtr8 ptrSymbianInfoSection(symbianInfoSection, sizeofsyminfo,
+						sizeofsyminfo);
+
+				TInt ret = iSELFFile.Read(offsettosyminfod, ptrSymbianInfoSection, sizeofsyminfo);
+				if (ret != KErrNone)
+					{
+					ERR_PRINTF2(
+							_L("CProcessCrashWrapper::ValidateProgramHeaderELFFileL Error reading the SELF Header Sym32_syminfod %d"), ret);
+					SetBlockResult(EFail);
+					User::Leave(ret);
+					}
+				Sym32_syminfod *syminfod = (Sym32_syminfod*) symbianInfoSection; //Symbian Info Section Sym32_syminfod
+
+				// Validation Phase of the Symbian Info section
+				INFO_PRINTF2(_L("Executable Crc32 %X"), syminfod->sd_execid.exec_crc);
+				INFO_PRINTF2(_L("Crashed Thread %ld"), syminfod->sd_thread_id);
+				INFO_PRINTF2(_L("Owning Process %ld"), syminfod->sd_proc_id);
+
+				iCrashedThreadId = syminfod->sd_thread_id;
+				if (ECrashException == syminfod->sd_exit_type)
+					{
+					INFO_PRINTF2(_L("Hardware Exception Number:%d"),
+							syminfod->sd_exit_reason);
+					ValidateExceptionL(syminfod->sd_exit_reason, ETestDataAbort, EFalse); //print the exception string
+					}
+				else
+					if (ECrashKill == syminfod->sd_exit_type)
+						{
+						INFO_PRINTF2(_L("Exit Type\t\t\t:%d"),
+								syminfod->sd_exit_reason);
+						switch (syminfod->sd_exit_reason)
+							{
+							case 0:
+								INFO_PRINTF1(_L(":EExitKill\n"));
+								break;
+							case 1:
+								INFO_PRINTF1(_L(":EExitTerminate\n"));
+								break;
+							case 2:
+								INFO_PRINTF1(_L(":EExitPanic\n"));
+								break;
+							case 3:
+								INFO_PRINTF1(_L(":EExitPending\n"));
+								break;
+							default:
+								INFO_PRINTF1(_L(":Unknown\n"));
+								break;
+							}
+						}
+					else
+						{
+						INFO_PRINTF1(_L("\tUnknown Crash Type\n"));
+						}
+
+				CleanupStack::PopAndDestroy(symbianInfoSection);
+
+				}//if ESYM_NOTE_SYM
+
+			if (idhdr[i]->d_type == ESYM_NOTE_EXEC) //EXECUTABLE INFO SEGMENT
+				{
+				if (sizeof(Sym32_execinfod) != (idhdr[i]->d_descrsz))
+					{
+					ERR_PRINTF1(_L("CProcessCrashWrapper::ValidateProgramHeaderELFFileL sizeof(Sym32_execinfod))is different from descriptor size") );
+					User::Leave(KErrGeneral);
+					}
+
+				TInt sizeofsymexecinfo = sizeof(Sym32_execinfod);
+				INFO_PRINTF2(_L("ESYM_NOTE_EXEC Header offset %d"),
+						phdr[i].p_offset);
+				INFO_PRINTF2(
+						_L("ESYM_NOTE_EXEC Size of single descriptor element %d"),
+						idhdr[i]->d_descrsz);
+
+				//Sym32_execinfod *execinfod = ADDR(Sym32_execinfod,eh,data+sizeof(Sym32_dhdr));
+				TInt offsettosymexecinfod = phdr[i].p_offset
+						+ sizeof(Sym32_dhdr);
+
+				TUint8* symbianExecInfoSection = new TUint8[sizeofsymexecinfo];
+				CleanupStack::PushL(symbianExecInfoSection);
+
+				TPtr8 ptrSymbianExecInfoSection(symbianExecInfoSection,
+						sizeofsymexecinfo, sizeofsymexecinfo);
+
+				TInt ret = iSELFFile.Read(offsettosymexecinfod,
+						ptrSymbianExecInfoSection, sizeofsymexecinfo);
+				if (ret != KErrNone)
+					{
+					ERR_PRINTF2(
+							_L("CProcessCrashWrapper::ValidateProgramHeaderELFFileL Error reading the SELF Header Sym32_execinfod %d"),
+							ret);
+					User::Leave(ret);
+					}
+				Sym32_execinfod *execinfod =
+						(Sym32_execinfod*) symbianExecInfoSection; //Symbian Info Section Sym32_syminfod
+
+				TBufC<30> nameToCheck(KCrashAppFileName);
+
+				ValidateStringL(EValExecutable, execinfod->ed_name, nameToCheck, EFalse);
+
+				CleanupStack::PopAndDestroy();
+				}//if ESYM_NOTE_EXEC
+
+			}//if PT_NOTE
+
+		}//for loop PHEntries
+	INFO_PRINTF1(_L("Sym_Info validated"));
+	}
+
+/**
+ * Validates the Symbian Thread Section Sym32_thrdinfod of the SELF file
+ * @param aValidateCpuId If this is true, this test will fail if all the CPU Id's are not the same
+ */
+void CProcessCrashWrapper::ValidateThreadInfoSectionELFFileL(TBool aValidateCpuId, const TDesC& aThreadCrashed, TBool aCheck)
+	{
+	INFO_PRINTF1(_L("Validating the Symbian Thread Info Section"));
+
+	Elf32_Phdr* phdr = (Elf32_Phdr*) iSELFPHHeader;//Elf32_Phdr Program Header
+	TInt cpuId = -1;
+
+	//loop through the program headers to get information about the Symbian Info section
+	for (TInt i = 0; i < iPHEntries; i++)
+		{
+		if (phdr[i].p_type == PT_NOTE)
+			{
+			if (idhdr[i]->d_type == ESYM_NOTE_THRD) //SYMBIAN INFO SEGMENT
+				{
+				if (sizeof(Sym32_thrdinfod) != (idhdr[i]->d_descrsz))
+					{
+					ERR_PRINTF1(_L("CProcessCrashWrapper::ValidateThreadInfoSectionELFFileL sizeof(Sym32_thrdinfod) %d is different from descriptor size") );
+					SetBlockResult(EFail);
+					User::Leave(KErrGeneral);
+					}
+
+				TInt sizeofthreadinfo = sizeof(Sym32_thrdinfod);
+				INFO_PRINTF2(_L("ESYM_NOTE_THRD Header offset %d"), phdr[i].p_offset);
+				INFO_PRINTF2(_L("ESYM_NOTE_THRD Size of single descriptor element %d"),
+						idhdr[i]->d_descrsz);
+				INFO_PRINTF2(_L("ESYM_NOTE_THRD Number of elements %d"), idhdr[i]->d_elemnum);
+
+				TInt offsettothreadinfod = phdr[i].p_offset + sizeof(Sym32_dhdr);
+				TInt newoffsettothreadinfod = offsettothreadinfod;
+
+				//allocate buffer for Sym32_thrdinfod
+				TUint8* symbianThreadSection = new TUint8[sizeofthreadinfo];
+				CleanupStack::PushL(symbianThreadSection);
+
+				TPtr8 ptrSymbianThreadSection(symbianThreadSection, sizeofthreadinfo,
+						sizeofthreadinfo);
+
+				TInt ret = iSELFFile.Read(offsettothreadinfod, ptrSymbianThreadSection, sizeofthreadinfo);
+				if (ret != KErrNone)
+					{
+					ERR_PRINTF2(
+							_L("CProcessCrashWrapper::ValidateThreadInfoSectionELFFileL Error reading the SELF Header Sym32_thrdinfod %d"), ret);
+					SetBlockResult(EFail);
+					User::Leave(ret);
+					}
+				Sym32_thrdinfod *thrdinfod = (Sym32_thrdinfod*) symbianThreadSection; //Symbian Info Section Sym32_syminfod
+
+				for(int thrIdx = 0; thrIdx < idhdr[i]->d_elemnum; thrIdx++ )
+					{
+					//valid checking fo thread id
+
+					if (iCrashedThreadId == thrdinfod->td_id)
+						{
+						INFO_PRINTF2(_L("Owning process %ld"), thrdinfod->td_owning_process);
+						INFO_PRINTF2(_L("Thread Priority %d"), thrdinfod->td_priority);
+						INFO_PRINTF2(_L("Heap Adress 0x%X"), thrdinfod->td_heap_add);
+						INFO_PRINTF2(_L("Heap Size %d"), thrdinfod->td_heap_sz);
+						//storing the heap address and the Heap Siz for future verification
+						iHeapBase = thrdinfod->td_heap_add;
+						iHeapSize = thrdinfod->td_heap_sz;
+
+						ValidateStringL(EValThread, thrdinfod->td_name, aThreadCrashed, aCheck);
+
+						}
+
+					if(aValidateCpuId)
+						{
+						//If its the first, set the CPU ID to be this
+						if(cpuId < 0)
+							{
+							cpuId = thrdinfod->td_last_cpu_id;
+							}
+						else
+							{
+							//Otherwise, the current CPU ID should be the same as the previous
+							if(thrdinfod->td_last_cpu_id != cpuId)
+								{
+								ERR_PRINTF3(_L("CProcessCrashWrapper::ValidateThreadInfoSectionELFFileL CPU ID Not as expected. Current is not the same as previous. Current = [%d] Previous = [%d]"), thrdinfod->td_last_cpu_id, cpuId);
+								SetBlockResult(EFail);
+								User::Leave(KErrCorrupt);
+								}
+							cpuId = thrdinfod->td_last_cpu_id;
+							}
+						}
+
+					newoffsettothreadinfod = newoffsettothreadinfod + sizeofthreadinfo;
+
+					ret = iSELFFile.Read(newoffsettothreadinfod, ptrSymbianThreadSection, sizeofthreadinfo);
+					if (ret != KErrNone)
+						{
+						ERR_PRINTF2(
+								_L("CProcessCrashWrapper::ValidateThreadInfoSectionELFFileL Error reading the SELF Header Sym32_thrdinfod %d"), ret);
+						SetBlockResult(EFail);
+						User::Leave(ret);
+						}
+
+					thrdinfod = (Sym32_thrdinfod*) symbianThreadSection;
+
+					}
+
+				CleanupStack::PopAndDestroy();
+				}//if ESYM_NOTE_THRD
+
+			}//if PT_NOTE
+
+		}//for PHEntries
+
+	}
+
+/**
+ * Validates the Register Info Section
+ * Reads the CPSR value to determine the type of the crash (user/system)
+ */
+void CProcessCrashWrapper::ValidateRegisterInfoSectionELFFileL()
+	{
+
+	INFO_PRINTF1(_L("CProcessCrashWrapper::ValidateRegisterInfoSectionELFFileL validating the regsiter Section"));
+
+	TBool matchfound = EFalse;
+	Elf32_Phdr* phdr = (Elf32_Phdr*) iSELFPHHeader;//Elf32_Phdr Program Header
+
+	//loop through the program headers to get information about the Symbian Info section
+	for (TInt i = 0; (i < iPHEntries) && !matchfound; i++)
+		{
+		if (phdr[i].p_type == PT_NOTE)
+			{
+			if (idhdr[i]->d_type == ESYM_NOTE_REG) //SYMBIAN REGISTER INFO SEGEMENT
+				{
+
+				TInt sizeofreginfo = sizeof(Sym32_reginfod);
+				TInt offsettoreginfod = phdr[i].p_offset + sizeof(Sym32_dhdr);
+
+				//allocate buffer for Sym32_reginfod
+				TUint8* symbianRegSection = new TUint8[sizeofreginfo];
+				CleanupStack::PushL(symbianRegSection);
+
+				TPtr8 ptrSymbianRegSection(symbianRegSection, sizeofreginfo,
+						sizeofreginfo);
+
+				TInt ret = iSELFFile.Read(offsettoreginfod, ptrSymbianRegSection, sizeofreginfo);
+				if (ret != KErrNone)
+					{
+					ERR_PRINTF2(
+							_L("CProcessCrashWrapper::ValidateRegisterInfoSectionELFFileL Error reading the SELF Header Sym32_thrdinfod %d"), ret);
+					SetBlockResult(EFail);
+					User::Leave(ret);
+					}
+				Sym32_reginfod *reginfod = (Sym32_reginfod*) symbianRegSection; //Symbian Register Info Section Sym32_reginfod
+
+				if(reginfod->rid_thread_id == iCrashedThreadId)
+					{
+
+					INFO_PRINTF2(_L("Crashed Thread id %ld"), iCrashedThreadId);
+					INFO_PRINTF2(_L("Thread ID %ld"), reginfod->rid_thread_id);
+
+					TInt offsettoregdatad = offsettoreginfod + sizeofreginfo;
+
+					for( TInt i = 0; (i < reginfod->rid_num_registers) && !matchfound; i++ )
+						{
+						//Sym32_regdatad immediately following the Register Info descriptor header
+						TInt sizeofregdatad = sizeof (Sym32_regdatad);
+						offsettoregdatad = offsettoregdatad + sizeofreginfo;
+
+						TUint8* symbianRegDatad = new TUint8[sizeofregdatad];
+						CleanupStack::PushL(symbianRegDatad);
+
+						TPtr8 ptrSymbianRegDatad(symbianRegDatad, sizeofregdatad,
+								sizeofregdatad);
+
+						TInt ret = iSELFFile.Read(offsettoregdatad, ptrSymbianRegDatad, sizeofregdatad);
+						if (ret != KErrNone)
+							{
+							ERR_PRINTF2(
+									_L("CProcessCrashWrapper::ValidateRegisterInfoSectionELFFileL Error reading the SELF Header Sym32_thrdinfod %d"), ret);
+							SetBlockResult(EFail);
+							User::Leave(ret);
+							}
+
+						Sym32_regdatad *regdatad = (Sym32_regdatad*) symbianRegDatad; //Symbian Register Info Section Sym32_regdatad
+
+						if( (ESYM_REG_CORE == reginfod->rid_class) && (ESYM_REG_32 == reginfod->rid_repre) && (KCPSRReg == regdatad->rd_id) )
+							{
+							//we have found the CPSR value for the crashed thread, now read the register value
+							TInt sizeofELF32Word = sizeof(Elf32_Word);
+							TUint8* rd_data_cpsr = new TUint8[sizeofELF32Word];
+							CleanupStack::PushL(rd_data_cpsr);
+
+							TPtr8 ptrSymbianRdDataCpsr(rd_data_cpsr, sizeofELF32Word,
+									sizeofELF32Word);
+
+							TInt ret = iSELFFile.Read(regdatad->rd_data , ptrSymbianRdDataCpsr, sizeofELF32Word);
+							if (ret != KErrNone)
+								{
+								ERR_PRINTF2(
+									_L("CProcessCrashWrapper::ValidateRegisterInfoSectionELFFileL Error reading the SELF Header Sym32_thrdinfod %d"), ret);
+								SetBlockResult(EFail);
+								User::Leave(ret);
+								}
+
+							Elf32_Word * val32 = (Elf32_Word*) rd_data_cpsr;
+
+							TUint cpsrval = *val32;
+
+							if(cpsrval & KModeBitCPSR) //checking on the M[4:0] mode bits of the CPSR
+								{
+								INFO_PRINTF2(_L("System Crash CPSR  value: 0x%X\n"), cpsrval );
+								iSystemCrash = ETrue; //system crash
+								}
+							else
+								{
+								INFO_PRINTF2(_L("User Side Crash CPSR  value: 0x%X\n"), cpsrval );
+								iSystemCrash = EFalse; //user crash
+								}
+
+							matchfound = ETrue;
+
+							CleanupStack::PopAndDestroy();//rd_data_cpsr CPSR data value
+							}
+
+						CleanupStack::PopAndDestroy();//Sym32_regdatad symbianRegDatad
+						}// for loop reginfod->rid_num_registers
+
+					}//if iCrashedThreadId
+
+				CleanupStack::PopAndDestroy();
+
+				}
+			}
+		}
+
+	}
+
+/**
+ * Validates the Heap Section of the SELF file
+ */
+void CProcessCrashWrapper::ValidateHeapSectionELFFileL(TBool aHeapCheck)
+	{
+
+	INFO_PRINTF1(_L("CProcessCrashWrapper::ValidateHeapSectionELFFileL validating the Heap Section"));
+
+	Elf32_Phdr* phdr = (Elf32_Phdr*) iSELFPHHeader;//Elf32_Phdr Program Header
+
+	TBool matchfound = EFalse;
+	//loop through the program headers to get information about the Symbian Info section
+	for (TInt i = 0; i < iPHEntries; i++)
+		{
+		if (phdr[i].p_type == PT_LOAD)
+			{
+			if(phdr[i].p_vaddr == iHeapBase && phdr[i].p_filesz == iHeapSize )
+				{
+				if(phdr[i].p_filesz == 0) //if the heap size is zero just complain
+					{
+					ERR_PRINTF1(
+							_L("CProcessCrashWrapper::ValidateHeapSectionELFFileL Error Heap Size found to be zero"));
+					SetBlockResult(EFail);
+					User::Leave(KErrGeneral);
+					}
+				matchfound = ETrue;
+				INFO_PRINTF2(_L("Heap section found at PHDR offset %d"), phdr[i].p_offset);
+				break;
+				}
+
+			}
+		}
+	if(!aHeapCheck && matchfound )
+		{
+		ERR_PRINTF1(
+				_L("CProcessCrashWrapper::ValidateHeapSectionELFFileL Error found heap section when there shouldnt be one"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+	if(aHeapCheck  && !matchfound )
+		{
+		ERR_PRINTF1(
+				_L("CProcessCrashWrapper::ValidateHeapSectionELFFileL Error did not find the heap section"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	}
+
+/**
+ * Validates the Trace Section Sym32_tracedata of the SELF file
+ */
+void CProcessCrashWrapper::ValidateTraceSectionELFFileL(TBool aTraceCheck)
+	{
+
+	INFO_PRINTF1(_L("CProcessCrashWrapper::ValidateTraceSectionELFFileL validating the Trace Section"));
+
+	Elf32_Phdr* phdr = (Elf32_Phdr*) iSELFPHHeader;//Elf32_Phdr Program Header
+
+	TBool dataPresent = EFalse;
+	//loop through the program headers to get information about the Symbian Info section
+	for (TInt i = 0; i < iPHEntries; i++)
+		{
+		if (phdr[i].p_type == PT_NOTE)
+			{
+			if (idhdr[i]->d_type == ESYM_NOTE_TRACE) //Trace Info
+				{
+				TInt sizeoftraceinfo = sizeof(Sym32_tracedata);
+				INFO_PRINTF2(_L("ESYM_NOTE_TRACE Size of trace section %d"), sizeoftraceinfo);
+				INFO_PRINTF2(_L("ESYM_NOTE_TRACE Header offset %d"), phdr[i].p_offset);
+				INFO_PRINTF2(_L("ESYM_NOTE_TRACE Size of single descriptor element %d"),
+						idhdr[i]->d_descrsz);
+				INFO_PRINTF2(_L("ESYM_NOTE_TRACE Number of elements %d"), idhdr[i]->d_elemnum);
+
+				if (sizeof(Sym32_tracedata) != (idhdr[i]->d_descrsz))
+					{
+					ERR_PRINTF1(_L("CProcessCrashWrapper::ValidateTraceSectionELFFileL sizeof(Sym32_tracedata) %d is different from descriptor size") );
+					SetBlockResult(EFail);
+					User::Leave(KErrGeneral);
+					}
+
+				TInt offsettotraceinfod = phdr[i].p_offset + sizeof(Sym32_dhdr);
+				//allocate buffer for Sym32_tracedata
+				TUint8* symbianTraceSection = new TUint8[sizeoftraceinfo];
+				CleanupStack::PushL(symbianTraceSection);
+
+				TPtr8 ptrSymbianTraceSection(symbianTraceSection, sizeoftraceinfo,
+						sizeoftraceinfo);
+
+				TInt ret = iSELFFile.Read(offsettotraceinfod, ptrSymbianTraceSection, sizeoftraceinfo);
+				if (ret != KErrNone)
+					{
+					ERR_PRINTF2(
+							_L("CProcessCrashWrapper::ValidateTraceSectionELFFileL Error reading the SELF Header Sym32_thrdinfod %d"), ret);
+					SetBlockResult(EFail);
+					User::Leave(ret);
+					}
+
+				Sym32_tracedata *traceInfo =
+										(Sym32_tracedata*) symbianTraceSection;
+
+				INFO_PRINTF2(_L("Size of trace buffer: %d"), traceInfo->tr_size);
+				INFO_PRINTF2(_L("Offset of trace buffer:%d"), traceInfo->tr_data);
+
+				//checking for the presence of trace data
+				if(traceInfo->tr_size != 0)//trace data present
+					{
+					dataPresent = ETrue;
+					//read the trace buffer
+					//unsigned char* data = ADDR(unsigned char, aElfHdr, aTraceData->tr_data);
+
+					RBuf8 tracebufferString;
+					tracebufferString.CleanupClosePushL();
+
+					tracebufferString.CreateL(traceInfo->tr_size);//READING 200 characters assuming strings to be not more than 200 characters
+
+					TInt ret = iSELFFile.Read(traceInfo->tr_data, tracebufferString, traceInfo->tr_size);
+					if (ret != KErrNone)
+						{
+						ERR_PRINTF2(
+								_L("CProcessCrashWrapper::ValidateTraceSectionELFFileL Error reading the Trace Information  %d"),
+								ret);
+						SetBlockResult(EFail);
+						User::Leave(ret);
+						}
+
+					INFO_PRINTF1(_L("Validate the trace buffer now"));
+					ValidateTraceBufferL(tracebufferString);
+
+					CleanupStack::PopAndDestroy();//tracebufferString
+					CleanupStack::PopAndDestroy();//symbianTraceSection
+					break;
+					}
+				else //expecting trace data to be present otherwise complain
+					{
+					ERR_PRINTF1(
+							_L("CProcessCrashWrapper::ValidateTraceSectionELFFileL Error found trace size to be zero"));
+					SetBlockResult(EFail);
+					User::Leave(KErrGeneral);
+
+					}
+				}
+			}
+
+		}
+
+	if(!aTraceCheck && dataPresent )
+		{
+		ERR_PRINTF1(
+				_L("CProcessCrashWrapper::ValidateTraceSectionELFFileL Error found trace section when there shouldnt be one"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+	if(aTraceCheck  && !dataPresent )
+		{
+		ERR_PRINTF1(
+				_L("CProcessCrashWrapper::ValidateTraceSectionELFFileL Error did not find the trace section"));
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	}
+
+/**
+ * @return void
+ * This method monitors the RProperty for the crash progress. There are several states of this but we are
+ * only interested in the start and finish of these properties
+ */
+void CProcessCrashWrapper::MonitorProgressL()
+	{
+	RProperty crashProgress;
+	User::LeaveIfError(crashProgress.Attach(KCoreDumpServUid, ECrashProgress));
+
+	TBuf<50> crashProg;
+
+	TRequestStatus status;
+	crashProgress.Subscribe(status);
+	User::WaitForRequest(status);
+	//Subscribe for next one again...
+	crashProgress.Subscribe(status);
+
+	//First one should be the start string = "-"
+	User::LeaveIfError(crashProgress.Get(crashProg ));
+	if(crashProg != KStartOfSELFProc)
+		{
+		INFO_PRINTF1(_L("SELF formatter has not started processing the data"));
+		}
+
+	INFO_PRINTF1(_L("SELF formatters have started processing the data"));
+	INFO_PRINTF1(_L("Waiting to be notified of the timeout of the processing. A timeout here is a fail"));
+	//Now we wait until its finished
+	do
+		{
+		User::WaitForRequest(status);
+		crashProgress.Subscribe(status);
+
+		User::LeaveIfError(crashProgress.Get(crashProg ));
+		}
+	while(crashProg != KEndOfProcessing);
+
+	INFO_PRINTF1(_L("SELF formatter has finished processing the data"));
+
+	}
+/**
+ * Utility Function to print and validate the exception type
+ * @param aException exception number
+ * @param acheckException exception to check for
+ * @param aCheck whether to validate the exception or not
+ */
+void CProcessCrashWrapper::ValidateExceptionL(TInt aException, TInt acheckException, TBool aCheck)
+	{
+	INFO_PRINTF2(_L("Hardware Exception of type: %d"), aException);
+	switch (aException)
+		{
+		case 0:
+			INFO_PRINTF1(_L(":EExcGeneral"));
+			break;
+		case 1:
+			INFO_PRINTF1(_L(":EExcIntegerDivideByZero"));
+			break;
+		case 2:
+			INFO_PRINTF1(_L(":EExcSingleStep"));
+			break;
+		case 3:
+			INFO_PRINTF1(_L(":EExcBreakPoint"));
+			break;
+		case 4:
+			INFO_PRINTF1(_L(":EExcIntegerOverflow"));
+			break;
+		case 5:
+			INFO_PRINTF1(_L(":EExcBoundsCheck"));
+			break;
+		case 6:
+			INFO_PRINTF1(_L(":EExcInvalidOpCode"));
+			break;
+		case 7:
+			INFO_PRINTF1(_L(":EExcDoubleFault"));
+			break;
+		case 8:
+			INFO_PRINTF1(_L(":EExcStackFault"));
+			break;
+		case 9:
+			INFO_PRINTF1(_L(":EExcAccessViolation"));
+			break;
+		case 10:
+			INFO_PRINTF1(_L(":EExcPrivInstruction"));
+			break;
+		case 11:
+			INFO_PRINTF1(_L(":EExcAlignment"));
+			break;
+		case 12:
+			INFO_PRINTF1(_L(":EExcPageFault"));
+			break;
+		case 13:
+			INFO_PRINTF1(_L(":EExcFloatDenormal"));
+			break;
+		case 14:
+			INFO_PRINTF1(_L(":EExcFloatDivideByZero"));
+			break;
+		case 15:
+			INFO_PRINTF1(_L(":EExcFloatInexactResult"));
+			break;
+		case 16:
+			INFO_PRINTF1(_L(":EExcFloatInvalidOperation"));
+			break;
+		case 17:
+			INFO_PRINTF1(_L(":EExcFloatOverflow"));
+			break;
+		case 18:
+			INFO_PRINTF1(_L(":EExcFloatStackCheck"));
+			break;
+		case 19:
+			INFO_PRINTF1(_L(":EExcFloatUnderflow"));
+			break;
+		case 20:
+			INFO_PRINTF1(_L(":EExcAbort"));
+			break;
+		case 21:
+			INFO_PRINTF1(_L(":EExcKill"));
+			break;
+		case 22:
+			INFO_PRINTF1(_L(":EExcUserInterrupt"));
+			break;
+		case 23:
+			INFO_PRINTF1(_L(":EExcDataAbort"));
+			break;
+		case 24:
+			INFO_PRINTF1(_L(":EExcCodeAbort"));
+			break;
+		case 25:
+			INFO_PRINTF1(_L(":EExcMaxNumber"));
+			break;
+		case 26:
+			INFO_PRINTF1(_L(":EExcInvalidVector"));
+			break;
+		default:
+			ERR_PRINTF1(_L("Unknown Exception"));
+			break;
+		}
+
+		if(aCheck)
+			{
+		    if( aException != acheckException )
+		    	{
+		    	ERR_PRINTF1(
+						_L("CProcessCrashWrapper::ValidateExceptionL is not the valid type"));
+				SetBlockResult(EFail);
+				User::Leave(KErrGeneral);
+		    	}
+
+		    INFO_PRINTF1(_L("Hardware Exception matched successful!"));
+			}
+
+	}
+/**
+ * Utility Function to print and validate a string
+ * Reads the String section and searches for a NULL character to find the right string
+ * @param aIndex index to the string section
+ * @param aStingToMatch string to be matched
+ * @param aCheck whether to validate the string or not
+ */
+void CProcessCrashWrapper::ValidateStringL(TValidateString aType, TInt aIndex, const TDesC& aStingToMatch, TBool aCheck)
+	{
+	INFO_PRINTF2(_L("CProcessCrashWrapper::ValidateStringL Index %d"), aIndex);
+
+	RBuf8 bufferString;
+	bufferString.CleanupClosePushL();
+	bufferString.CreateL(KMaxStringLength);//Reading 200 characters assuming strings to be not more than 200 characters
+
+	//going to the string in the string node
+	TInt offsetString = iOffsetStringSection + aIndex;
+	TInt ret = iSELFFile.Read(offsetString, bufferString, KMaxStringLength);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::PrintStringL Error reading the String Information  %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	//trying to find a NULL terminating character
+	TInt nullPos = -1;
+	TInt loop = 0;
+	while ((nullPos = bufferString.Locate(NULL)) > KErrNotFound)
+		{
+		loop++;
+		if (loop > KMaxStringLength)
+			{
+			ERR_PRINTF1(_L("CProcessCrashWrapper::ValidateStringL Error reading NULL character from the string"));
+			SetBlockResult(EFail);
+			User::Leave(KErrGeneral);
+			}
+		else
+			{
+			//found the NULL character exit the loop
+			INFO_PRINTF2(_L("ValidateStringL postion of NULL character %d"), nullPos);
+			break;
+			}
+		}
+
+	CleanupStack::PopAndDestroy(); //bufferString
+
+	//create a new actual string to hold the value we want
+	RBuf8 printString;
+	printString.CreateL(nullPos+2);
+	printString.CleanupClosePushL();
+
+	ret = iSELFFile.Read(offsetString, printString, nullPos);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::ValidateStringL Error reading reading the String Information %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	//create a NULL terminated string for printing on serial output
+	char* clPrompt = (char*) printString.PtrZ();
+	RDebug::Printf("String printed %s", clPrompt);
+
+	RBuf bigString;
+	bigString.CreateL(KMaxFileName);
+	bigString.CleanupClosePushL();
+
+	bigString.Copy(printString); //8 to 16 bit conversion
+
+	if(aType == EValExecutable)
+		{
+		INFO_PRINTF2(_L("Crashed Executable name: %S"), &bigString);
+
+		}
+
+	else if(aType == EValThread)
+		{
+		if(!aCheck) //NOT to check on the thread name
+			{
+			//just happy printing the name of the thread
+			INFO_PRINTF2(_L("Crashed Thread name: %S"), &bigString);
+			}
+		else
+			{
+			// check with the thread name passed
+			RBuf stringtoCheck;
+			stringtoCheck.Create(aStingToMatch);
+			stringtoCheck.CleanupClosePushL();
+
+			bigString.SetLength(stringtoCheck.Length()); //reducing the length
+
+			INFO_PRINTF2(_L("Crashed Thread name Verified : %S"), &bigString);
+
+			if(bigString.Compare(stringtoCheck) != 0)
+				{
+				ERR_PRINTF1(
+						_L("CProcessCrashWrapper::ValidateStringL Application name does not match "));
+				SetBlockResult(EFail);
+				User::Leave(KErrGeneral);
+				}
+
+			INFO_PRINTF1( _L("CProcessCrashWrapper::ValidateStringL Crashed Application Match Successful ! "));
+
+			CleanupStack::PopAndDestroy();//stringtoCheck
+
+			}
+
+		}
+	CleanupStack::PopAndDestroy();//bigString
+	CleanupStack::PopAndDestroy(); //printString
+
+	}
+
+/**
+ * Utility Function to do trace data verification
+ */
+void CProcessCrashWrapper::ValidateTraceBufferL(const TDesC8& aBuffer)
+{
+	INFO_PRINTF2(_L("CDataTranslator::ValidateTraceBufferL: size: %d"), aBuffer.Length());
+
+	const TUint8* tracePtr = aBuffer.Ptr();
+	TInt traceSize = aBuffer.Length();
+
+/*	TUint8 recSize = 0;
+	TUint8 flags = 0;*/
+	TUint8 category = 0;
+/*	TUint8 subCategory = 0;*/
+	TInt count = 0;
+
+	const TUint8* endPtr = tracePtr+traceSize;
+	while(tracePtr < endPtr)
+	{
+		count++;
+		category = 0;
+
+		/*recSize = flags = subCategory = 0;
+		recSize = tracePtr[BTrace::ESizeIndex];
+		flags = tracePtr[BTrace::EFlagsIndex];
+		subCategory = tracePtr[BTrace::ESubCategoryIndex];*/
+
+		//read trace header
+		category = tracePtr[BTrace::ECategoryIndex];
+
+		//check the parameter Category
+		if(category != KTraceCategory)
+			{
+			ERR_PRINTF1(
+					_L("CProcessCrashWrapper::ValidateTraceBufferL Category 200 did not match with the trace buffer"));
+			SetBlockResult(EFail);
+			User::Leave(KErrGeneral);
+			}
+
+		tracePtr = BTrace::NextRecord((TAny*)tracePtr);
+	}
+
+	INFO_PRINTF2(_L("Number of trace packets found: %d"), count);
+}
+
+/**
+ * Reports performance metrics from all the tests
+ */
+void CProcessCrashWrapper::ValidatePerformanceELFFile()
+	{
+
+	TInt ticks = HelpGetTestTicks();
+	TInt nkTicksPerSecond = HelpTicksPerSecond();
+
+	TInt actualtimeinseconds = ticks/nkTicksPerSecond;
+
+	INFO_PRINTF3(_L("SELF File Creation E:\\%S took: %d seconds\n") , &iSELFFileName, ticks/nkTicksPerSecond);
+
+	if (actualtimeinseconds > KMAXTIMEOUT)
+		{
+		ERR_PRINTF2(
+				_L("SELF File Creation had exceeded TIME OUT of %d secs "), KMAXTIMEOUT);
+		SetBlockResult(EFail);
+		User::Leave(KErrGeneral);
+		}
+
+	//clean up routine for the file created
+	TInt ret = iFsSession.Delete(iSELFFileName);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::SELF File delete returned error %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+	iStartTick = iStopTick = 0;//reset the timer ticks
+
+	}
+/**
+ * Utility Function to do SELF Configurations
+ */
+void CProcessCrashWrapper::ConfigureSELF(TBool aPresent, TInt aSegment)
+	{
+
+	INFO_PRINTF3(_L("CProcessCrashWrapper::ConfigureSELF confiugring SELF for segment %d to present %d"), aSegment, aPresent);
+
+	if(EHeap == aSegment)
+		{//heap segment is configured through the data segemnts in the SELF file
+		if(aPresent)
+			{//configure to have data segments
+			DoConfigureL(2, KUidELFFormatterV2.iUid, COptionConfig::EFormatterPlugin,
+					COptionConfig::ETBool, KDataSegmentPrompt,
+					1, KTrueFalseOpt, 1, KTrueOpt, 0);
+
+			}
+		else
+			{//configure NOT to have data segments
+			DoConfigureL(2, KUidELFFormatterV2.iUid, COptionConfig::EFormatterPlugin,
+					COptionConfig::ETBool, KDataSegmentPrompt,
+					1, KTrueFalseOpt, 0, KFalseOpt, 0);
+			}
+		}
+
+    if(ETrace == aSegment)
+    	{//trace segment configured here
+    	if(aPresent)
+			{//configure to have trace segments upto have 10KB data
+			DoConfigureL(8, KUidELFFormatterV2.iUid, COptionConfig::EFormatterPlugin,
+					COptionConfig::ETInt,  KCreateTraceData,
+					1, KNullDesC, 10, KNullDesC, 0);
+
+			}
+		else
+			{//configure NOT to have trace segments
+			DoConfigureL(8, KUidELFFormatterV2.iUid, COptionConfig::EFormatterPlugin,
+					COptionConfig::ETInt,  KCreateTraceData,
+					1, KNullDesC, 0, KNullDesC, 0);
+			}
+    	}
+
+    if(ECode == aSegment)
+    	{//code segment configured here
+    	if(aPresent)
+    		{//configure to have Code Segements
+			DoConfigureL(3, KUidELFFormatterV2.iUid, COptionConfig::EFormatterPlugin,
+					COptionConfig::ETBool, KCodeSegmentPrompt,
+					1, KTrueFalseOpt, 1, KTrueOpt, 0);
+    		}
+    	else
+    		{//configure NOT to have Code Segments
+			DoConfigureL(3, KUidELFFormatterV2.iUid, COptionConfig::EFormatterPlugin,
+					COptionConfig::ETBool, KCodeSegmentPrompt,
+					1, KTrueFalseOpt, 0, KFalseOpt, 0);
+    		}
+    	}
+
+    if(EThread == aSegment)
+    	{//thread segment configured here
+    	if(aPresent)
+    		{//configure to have Thread Segments
+			DoConfigureL(4, KUidELFFormatterV2.iUid, COptionConfig::EFormatterPlugin,
+					COptionConfig::ETBool, KThreadSegmentPrompt,
+					1, KTrueFalseOpt, 1, KTrueOpt, 0);
+    		}
+    	else
+    		{//configure NOT to have Thread Segments
+			DoConfigureL(4, KUidELFFormatterV2.iUid, COptionConfig::EFormatterPlugin,
+					COptionConfig::ETBool, KThreadSegmentPrompt,
+					1, KTrueFalseOpt, 0, KFalseOpt, 0);
+    		}
+    	}
+
+	}
+
+/**
+ * Utility Function to do cleanup activities
+ */
+void CProcessCrashWrapper::CleanupMethod(const TDesC& aDes)
+	{
+	RBuf fileDelete;
+	fileDelete.CreateL(aDes);
+	fileDelete.SetMax();
+	fileDelete.CleanupClosePushL();
+	INFO_PRINTF2(_L("Entered deletion routine for file %S"), &fileDelete);
+
+	//close the file
+	iSELFFile.Close();
+
+	TInt ret = iFsSession.Delete(fileDelete);
+	if (ret != KErrNone)
+		{
+		ERR_PRINTF2(
+				_L("CProcessCrashWrapper::SELF File delete returned error %d"),
+				ret);
+		SetBlockResult(EFail);
+		User::Leave(ret);
+		}
+
+	CleanupStack::PopAndDestroy();//fileDelete
+
+	//delete the buffers
+	if (iSELFPHHeader)
+		{
+		delete [] iSELFPHHeader;
+		iSELFPHHeader = NULL;
+		}
+
+	for (TInt i = 0; i < iPHEntries; i++)
+		{
+		delete [] iDHDRBuffer[i];
+		}
+
+	INFO_PRINTF1(_L("Cleanup Done of the SELF File\n"));
+	}
+
+/**
+ * Returns the number of nanokernel ticks in one second
+ * @return Number of nanokernel ticks. 0 if unsuccesful
+ */
+TInt CProcessCrashWrapper::HelpTicksPerSecond(void)
+	{
+	TInt nanokernel_tick_period;
+	HAL::Get(HAL::ENanoTickPeriod, nanokernel_tick_period);
+
+	ASSERT(nanokernel_tick_period != 0);
+
+	static const TInt KOneMillion = 1000000;
+
+	return KOneMillion/nanokernel_tick_period;
+	}
+
+/**
+ *Prints the error condition for TEF log/output
+ */
+void CProcessCrashWrapper::PrintErrorCondition(TInt aError)
+	{
+	//print out the error and put the result as failure
+	ERR_PRINTF2(_L("Oops!!! error %d"),aError);
+	SetBlockResult(EFail);
+	}
+/*
+ * class CAsyncProcessCrash Implementation
+ */
+
+/**
+ * Two phase constructor for CAsyncProcessCrash
+ * @return CAsyncProcessCrash object
+ * @leave
+ */
+CAsyncProcessCrash* CAsyncProcessCrash::NewL(CProcessCrashWrapper* aProcessCrashWrapper)
+	{
+	CAsyncProcessCrash* ret = new (ELeave) CAsyncProcessCrash(aProcessCrashWrapper);
+	CleanupStack::PushL(ret);
+	ret->ConstructL();
+	CleanupStack::Pop(ret);
+	return ret;
+	}
+
+/**
+ * Safe construction
+ * @leave
+ */
+void CAsyncProcessCrash::ConstructL()
+	{
+	}
+
+/*
+ * Constructor for the CActive derived object
+ */
+CAsyncProcessCrash::CAsyncProcessCrash(CProcessCrashWrapper* aProcessCrashWrapper)
+	: CActive(CActive::EPriorityStandard),
+	  iProcessCrashWrapper(aProcessCrashWrapper),
+	  iCrashId(0)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+/*
+ * Function that issues request to the Core Dump Server
+ * @param aCrashId is the crash id
+ * to process crash log
+ */
+void CAsyncProcessCrash::IssueProcessCrashRequest(TUint aCrashId)
+	{
+	RDebug::Printf("CAsyncProcessCrash::IssueProcessCrashRequest");
+
+	iCrashId = aCrashId;
+
+	ASSERT(!IsActive());
+
+	// Actually issue the request
+	iProcessCrashWrapper->iCoreDumpSession.ProcessCrashLog( iCrashId, iStatus);
+
+	// Tell the framework that a request is pending but
+	// do it after the async request in case it Leaves
+	SetActive();
+	}
+
+/*
+ * RunL from CActive when the asynchronous request completes
+ *
+ */
+void CAsyncProcessCrash::RunL()
+	{
+	RDebug::Printf("CAsyncProcessCrash::RunL %d", iStatus.Int());
+	// that errors are handled in RunError()
+	User::LeaveIfError(iStatus.Int());
+
+	// request-handling code
+  	iProcessCrashWrapper->ProcessSELFFileCreatedL();
+
+  	CActiveScheduler::Stop();
+	}
+
+/*
+ * RunError from CActive called when RunL leaves
+ */
+TInt CAsyncProcessCrash::RunError(TInt aError)
+	{
+	RDebug::Printf("CAsyncProcessCrash::RunError");
+
+	iProcessCrashWrapper->PrintErrorCondition(aError);
+
+	CActiveScheduler::Stop();
+
+	return KErrNone; // error handled
+	}
+
+/*
+ * Destructor for clean up purposes
+ */
+CAsyncProcessCrash::~CAsyncProcessCrash()
+	{
+	RDebug::Printf("CAsyncProcessCrash::~CAsyncProcessCrash");
+	//cancel any outstanding request
+	Cancel();
+
+	}
+
+/*
+ * Destructor for clean up purposes
+ */
+void CAsyncProcessCrash::DoCancel()
+	{
+	RDebug::Printf("CAsyncProcessCrash::DoCancel");
+	//cancel the processing the crashlog
+	iProcessCrashWrapper->iCoreDumpSession.CancelProcessCrashLog(iCrashId);
+	}
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_scm_config.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,150 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include "t_scm_config.h"
+
+_LIT(KConfigureOn, "ConfigureOn");
+_LIT(KConfigureOff, "ConfigureOff");
+_LIT(KKeyValue, "value");
+
+CSCMConfigurationWrapper::CSCMConfigurationWrapper()
+	{}
+
+CSCMConfigurationWrapper::~CSCMConfigurationWrapper()
+	{
+	iCoreDumpSession.Close();
+	}
+
+/**
+ * Two phase constructor for CSCMConfigurationWrapper
+ * @return CSCMConfigurationWrapper object
+ * @leave
+ */
+CSCMConfigurationWrapper* CSCMConfigurationWrapper::NewL()
+	{
+	CSCMConfigurationWrapper* ret = new (ELeave) CSCMConfigurationWrapper();
+	CleanupStack::PushL(ret);
+	ret->ConstructL();
+	CleanupStack::Pop(ret);
+	return ret;
+	}
+
+/**
+ * Safe construction
+ * @leave
+ */
+void CSCMConfigurationWrapper::ConstructL()
+	{
+	User::LeaveIfError(iCoreDumpSession.Connect());
+	}
+
+/**
+ * Handle a command invoked from the script
+ * @param aCommand Is the name of the command for a TBuf
+ * @param aSection Is the .ini file section where parameters to the command are located
+ * @param aAsyncErrorIndex Is used by the TEF Block framework to handle asynchronous commands.
+ * @leaves One of the system wide error codes
+ */
+TBool CSCMConfigurationWrapper::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
+	{
+	//Get the enum value from the ini file
+	TConfigItem::TSCMDataType type;
+	TInt enumValue;
+
+	if(GetIntFromConfig(aSection,KKeyValue, enumValue))
+		{
+		type = (TConfigItem::TSCMDataType)enumValue;
+		}
+	else
+		{
+		ERR_PRINTF1(_L("Unable to get the proper config option from ini file. Are you sure its valid?"));
+		return EFalse;
+		}
+
+	//Look at the command to see what we need to do
+	if(KConfigureOn() == aCommand)
+		{
+		TurnOnConfigOptionL(type);
+		}
+	else if(KConfigureOff() == aCommand)
+		{
+		TurnOffConfigOptionL(type);
+		}
+	else
+		{
+		ERR_PRINTF1(_L("Unable to get the proper command from script file. Are you sure its valid?"));
+		return EFalse;
+		}
+
+	return ETrue;
+	}
+
+/**
+ * This method allows the test wrapper to configure the SCM to not dump one of the
+ * possible options
+ * @param aParameter The param we wish to set
+ * @leaves One of the system wide error codes
+ */
+void CSCMConfigurationWrapper::TurnOffConfigOptionL(TConfigItem::TSCMDataType& aParameter)
+	{
+	TInt zeroPriority = 0;
+	SetSCMParameterL(aParameter, zeroPriority);
+	}
+
+/**
+ * This method allows the test wrapper to configure the SCM to dump one of the
+ * possible options
+ * @param aParameter The param we wish to set
+ * @leaves One of the system wide error codes
+ */
+void CSCMConfigurationWrapper::TurnOnConfigOptionL(TConfigItem::TSCMDataType& aParameter)
+	{
+	TInt highestPriority = 255;
+	SetSCMParameterL(aParameter, highestPriority);
+	}
+
+/**
+ * Sets an SCM parameter to a given priority
+ * @param aParameter The SCM parameter we wish to change
+ * @param aPriority The new priority
+ * @leaves One of the System wide codes
+ */
+void CSCMConfigurationWrapper::SetSCMParameterL(TConfigItem::TSCMDataType& aParameter, const TInt aPriority)
+	{
+	//Unfortunately, there is no "get by instance" method (just a get by index - which we dont know
+	TInt numConfigParams = iCoreDumpSession.GetNumberConfigParametersL();
+	for(TUint cnt = 0; cnt < numConfigParams; cnt++)
+		{
+		COptionConfig* conf = iCoreDumpSession.GetConfigParameterL(cnt);
+		CleanupStack::PushL(conf);
+
+		if (conf->Source()== COptionConfig::ESCMConfig && conf->Instance() == aParameter)
+			{
+			//Found the one of interest. Set config to desired value
+			INFO_PRINTF3(_L("Setting config value %d to be %d"), aParameter, aPriority);
+
+			conf->Value(aPriority);
+			iCoreDumpSession.SetConfigParameterL(*conf);
+			}
+		CleanupStack::PopAndDestroy(conf);
+		}
+	}
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/cds/t_self.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,310 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  Test wrapper for Symbian ELF testing
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <crashdatasave.h>
+
+#include "t_self.h"
+#include "t_coredumpserver.h"
+
+CSymbianElfWrapper::CSymbianElfWrapper()
+	{}
+
+CSymbianElfWrapper::~CSymbianElfWrapper()
+	{
+	iCoreDumpSession.Close();
+	iFsSession.Close();
+	}
+
+/**
+ * Two phase constructor for CSymbianElfWrapper
+ * @return CSymbianElfWrapper object
+ * @leave
+ */
+CSymbianElfWrapper* CSymbianElfWrapper::NewL()
+	{
+	RDebug::Printf("\ncreating test oibject");
+	CSymbianElfWrapper* ret = new (ELeave) CSymbianElfWrapper();
+	CleanupStack::PushL(ret);
+	ret->ConstructL();
+	CleanupStack::Pop(ret);
+	return ret;
+	}
+
+/**
+ * Safe construction
+ * @leave
+ */
+void CSymbianElfWrapper::ConstructL()
+	{
+	User::LeaveIfError(iCoreDumpSession.Connect());
+	User::LeaveIfError(iFsSession.Connect());
+	}
+
+/**
+ * Handle a command invoked from the script
+ * @param aCommand Is the name of the command for a TBuf
+ * @param aSection Is the .ini file section where parameters to the command are located
+ * @param aAsyncErrorIndex Is used by the TEF Block framework to handle asynchronous commands.
+ * @leaves One of the system wide error codes
+ */
+TBool CSymbianElfWrapper::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
+	{
+	//First we need to get the parameters from the ini file
+	TInt crashId;
+	TPtrC crashName;
+	TPtrC crashSource;
+	TPtrC section;
+
+	TBool valsOk = GetIntFromConfig(aSection, KKeyCrashId, crashId) &&
+				   GetStringFromConfig(aSection, KKeyCrashName, crashName) &&
+				   GetStringFromConfig(aSection, KKeyCrashSource, crashSource) &&
+				   GetStringFromConfig(aSection, KKeyElfSection, section);
+
+	if(!valsOk)
+		{
+		ERR_PRINTF1(_L("Unable to get the proper config option from ini file. Are you sure its valid?"));
+		return EFalse;
+		}
+
+	//Look at the command to see what we need to do
+	if(KCommandGenerateFile() == aCommand && KSourceSystemCrash() == crashSource)
+		{
+		GenerateFileFromSystemCrashL(crashName, crashId);
+		}
+	else if(KCommandFindSection() == aCommand)
+		{
+		VerifySection(section, crashName, ETrue);
+		}
+	else if(KCommandVerifyNoSection() == aCommand)
+		{
+		VerifySection(section, crashName, EFalse);
+		}
+	else
+		{
+		ERR_PRINTF1(_L("Unable to get the proper command from script file. Are you sure its valid?"));
+		return EFalse;
+		}
+
+	return ETrue;
+	}
+
+/**
+ * Verifies a given section in the elf file
+ * @param aSectionToVerify Section to verify
+ * @param aCrashName ELF file name
+ * @param aExists To check if the section exists and is valid, or not
+ */
+void CSymbianElfWrapper::VerifySection(TDesC& aSectionToVerify, TDesC& aCrashName, TBool aExists)
+	{
+	RFile selfFile;
+
+	TInt err = selfFile.Open(iFsSession, aCrashName, EFileStream|EFileRead);
+	INFO_PRINTF3(_L("Trying to open crash file at [%S] and got back [%d]"), &aCrashName, err);
+
+	T_SELF_ASSERT_TRUE(err == KErrNone, 0);
+	CleanupClosePushL(selfFile);
+
+	CacheElfHeader(selfFile);
+	ValidateElfFile(selfFile);
+
+	if(aSectionToVerify == KSectionsVariantData())
+		{
+		VerifyVariantData(selfFile, aExists);
+		}
+
+	CleanupStack::PopAndDestroy();
+	}
+
+/**
+ * Verifies Variant data in the elf file
+ * @param aElfFile File handle to elf file
+ */
+void CSymbianElfWrapper::VerifyVariantData(RFile& aElfFile, TBool aExists)
+	{
+	INFO_PRINTF1(_L("Looking at the size of variant data section."));
+
+	TUint sectionOffset = GetSectionOffset(aElfFile, ESYM_NOTE_VARIANT_DATA);
+	T_SELF_ASSERT_TRUE(sectionOffset > 0, 0);
+
+	TUint sectionSize = GetSectionSize(aElfFile, ESYM_NOTE_VARIANT_DATA);
+	if(aExists)
+		{
+		T_SELF_ASSERT_TRUE(sectionSize > 0, 0);
+		}
+	else
+		{
+		T_SELF_ASSERT_TRUE(sectionSize == 0, 0);
+		}
+
+	//Now look at the actual structure
+	Sym32_variant_spec_data varData;
+	TPtr8 varDataDes((TUint8*)&varData, sizeof(Sym32_variant_spec_data));
+
+	T_SELF_ASSERT_TRUE(aElfFile.Read(sectionOffset, varDataDes) == KErrNone, 0);
+	
+	INFO_PRINTF1(_L("Looking at the details of variant data structure. Must be > 0"));
+	T_SELF_ASSERT_TRUE(varData.es_data > 0, 0);
+
+	if(aExists)
+		{
+		T_SELF_ASSERT_TRUE(varData.es_size > 0, 0);
+		}
+	else
+		{
+		T_SELF_ASSERT_TRUE(varData.es_size == 0, 0);
+		}
+
+	INFO_PRINTF2(_L("Variant data lives in the file at [0x%X]"), varData.es_data);
+	INFO_PRINTF2(_L("Variant data is [0x%X] in size"), varData.es_size);
+	}
+
+/**
+ * Looks at elf signature to see if its ok
+ * @param aElfFile File to check
+ */
+void CSymbianElfWrapper::ValidateElfFile(RFile& aElfFile)
+	{
+	INFO_PRINTF1(_L("Verifying Elf Header..."));
+	T_SELF_ASSERT_TRUE(iElfHeader.e_ident[EI_MAG0] == 0x7f, 1);
+	T_SELF_ASSERT_TRUE(iElfHeader.e_ident[EI_MAG1] == 0x45, 1);
+	T_SELF_ASSERT_TRUE(iElfHeader.e_ident[EI_MAG2] == 0x4c, 1);
+	T_SELF_ASSERT_TRUE(iElfHeader.e_ident[EI_MAG3] == 0x46, 1);
+	}
+
+/**
+ * Caches the ELF header in the object
+ * @param aElfFile file to look at
+ */
+void CSymbianElfWrapper::CacheElfHeader(RFile& aElfFile)
+	{
+	INFO_PRINTF1(_L("Reading Elf Header..."));
+	TUint fileLocation = 0;
+	TPtr8 hdrDes((TUint8*)&iElfHeader, sizeof(Elf32_Ehdr));
+	T_SELF_ASSERT_TRUE(aElfFile.Read(fileLocation, hdrDes) == KErrNone, 0);
+	}
+
+/**
+ * Gets the size of a given section in the elf file.
+ * @param aElfFile File to look at
+ * @param aNoteType Note of interest
+ * @return Section size, 0 if not found
+ */
+TUint CSymbianElfWrapper::GetSectionSize(RFile& aElfFile, ESYM_NOTE_TYPE aNoteType)
+	{
+	INFO_PRINTF2(_L("Getting section size for section [0x%X]..."), aNoteType);
+	TUint32 sectionOffset = GetSectionOffset(aElfFile, aNoteType);
+
+	T_SELF_ASSERT_TRUE_RET(sectionOffset != 0, 0, 0);
+
+	Sym32_dhdr dhdr;
+	TPtr8 dhdrDes((TUint8*)&dhdr, sizeof(Sym32_dhdr));
+
+	T_SELF_ASSERT_TRUE_RET(aElfFile.Read(sectionOffset, dhdrDes) == KErrNone, 0, 0);
+
+	return dhdr.d_descrsz;
+	}
+
+/**
+ * Searches the elf file for a given section and returns the offset of that section
+ * @return Section offset - 0 if not found
+ */
+TUint CSymbianElfWrapper::GetSectionOffset(RFile& aElfFile, ESYM_NOTE_TYPE aNoteType)
+	{
+	INFO_PRINTF2(_L("Getting section offset for section [0x%X]..."), aNoteType);
+
+	//Look through descriptor notes for this type
+	for(TUint j = 0; j < iElfHeader.e_phnum; j++)
+		{
+		Elf32_Phdr phdr;
+		TPtr8 phdrDes((TUint8*)&phdr, sizeof(Elf32_Phdr));
+		T_SELF_ASSERT_TRUE_RET(aElfFile.Read(iElfHeader.e_phoff + j*sizeof(Elf32_Phdr), phdrDes) == KErrNone, 0, 0);
+
+		if(phdr.p_type == PT_NOTE)
+			{
+			Sym32_dhdr dhdr;
+			TPtr8 dhdrDes((TUint8*)&dhdr, sizeof(Sym32_dhdr));
+			T_SELF_ASSERT_TRUE_RET(aElfFile.Read(phdr.p_offset, dhdrDes) == KErrNone, 0, 0);
+
+			if(dhdr.d_type == aNoteType)
+				{
+				return phdr.p_offset + sizeof(Sym32_dhdr);
+				}
+			}
+		}
+
+	return 0;
+	}
+
+/**
+ * Looks at a given system crash and generates a symbian elf file describing it at
+ * specified file
+ * @param aCrashName Name of ELF file to generate
+ * @param aCrashId ID of crash to analyse
+ */
+void CSymbianElfWrapper::GenerateFileFromSystemCrashL(TDesC& aCrashName, TInt aCrashId)
+	{
+	INFO_PRINTF1(_L("Generating ELF file from System crash"));
+
+	//Load SELF and filewriter and configure them to dump where required
+	TPluginRequest loadSELFReq;
+	loadSELFReq.iPluginType = TPluginRequest::EFormatter;
+	loadSELFReq.iLoad = ETrue;
+	loadSELFReq.iUid = KUidELFFormatterV2;
+
+	TPluginRequest loadWriterReq;
+	loadWriterReq.iPluginType = TPluginRequest::EWriter;
+	loadWriterReq.iLoad = ETrue;
+	loadWriterReq.iUid = KUidFileWriter;
+
+	INFO_PRINTF1(_L("Loading the file writer and symbian elf..."));
+	iCoreDumpSession.PluginRequestL(loadWriterReq);
+	iCoreDumpSession.PluginRequestL(loadSELFReq);
+
+	COptionConfig * config = COptionConfig::NewL((TInt)(CCrashDataSave::ECoreFilePath),
+		   KUidFileWriter.iUid, COptionConfig::EWriterPlugin, COptionConfig::ETFileName, KFilePathPrompt,
+			1, KNullDesC, 0, aCrashName);
+
+	CleanupStack::PushL(config);
+	config->Instance(0);
+
+	INFO_PRINTF2(_L("Configuring the file writer to dump file at [%S]..."), &aCrashName);
+	iCoreDumpSession.SetConfigParameterL(*config);
+	CleanupStack::PopAndDestroy(config);
+
+	//Get the crashes from the flash partition
+	RCrashInfoPointerList* crashList = new(ELeave)RCrashInfoPointerList;
+	TCleanupItem listCleanup(CCoreDumpServerWrapper::CleanupCrashList, (TAny*)crashList);
+	CleanupStack::PushL(listCleanup);
+
+	INFO_PRINTF1(_L("Looking at crashes in flash to find ours..."));
+	iCoreDumpSession.ListCrashesInFlashL(*crashList);
+	T_SELF_ASSERT_TRUE(crashList->Count() != 0, 1);
+	T_SELF_ASSERT_TRUE((*crashList)[0]->iCrashId == 0, 1);
+
+	CleanupStack::PopAndDestroy(1);
+
+	TRequestStatus status;
+    iCoreDumpSession.ProcessCrashLog(aCrashId, status);
+	User::WaitForRequest(status);
+
+	T_SELF_ASSERT_TRUE(KErrNone == status.Int(), 0);
+	}
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/tcds_kernelBlockController.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,81 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file tcds_unitBlockController.cpp
+ @internalTechnology
+*/
+
+#include "tcds_kernelBlockController.h"
+
+_LIT(KCrashBoardWrapper, "CCrashBoardWrapper");
+_LIT(KProcessCrashWrapper, "CProcessCrashWrapper");
+_LIT(KCoreDumpMonitorWrapper, "CCoreDumpMonitor");
+_LIT(KCoreDumpServerWrapper, "CCoreDumpServer");
+_LIT(KSCMConfiguration, "CSCMConfig");
+_LIT(KCSelfWrapper, "CSymbianElfWrapper");
+
+/**
+ * @return - Instance of the test block controller
+ */
+Ctcds_kernelBlockController* Ctcds_kernelBlockController::NewL()
+	{
+	Ctcds_kernelBlockController* block = new (ELeave) Ctcds_kernelBlockController();
+	return block;
+	}
+
+/**
+ * Called to create test wrapper. The argument is the wrapper to create. This argument comes
+ * from the script file
+ * @param aData Wrapper to create
+ * @return TestWrapper
+ */
+CDataWrapper* Ctcds_kernelBlockController::CreateDataL(const TDesC& aData)
+	{
+	CDataWrapper* wrapper = NULL;
+	if (KCrashBoardWrapper() == aData)
+		{
+		wrapper = CCrashBoardWrapper::NewL();
+		}
+	else if(KProcessCrashWrapper() == aData)
+		{
+		wrapper = CProcessCrashWrapper::NewL();
+		}
+	else if(KCoreDumpServerWrapper() == aData)
+		{
+		wrapper = CCoreDumpServerWrapper::NewL();
+		}
+	else if(KCoreDumpMonitorWrapper() == aData)
+		{
+		wrapper = CCoreDumpMonitorWrapper::NewL();
+		}
+	else if(KSCMConfiguration() == aData)
+		{
+		wrapper = CSCMConfigurationWrapper::NewL();
+		}
+	else if(KCSelfWrapper() == aData)
+		{
+		wrapper = CSymbianElfWrapper::NewL();
+		}
+	else
+		{
+		_LIT(KPanic, "%S");
+		TBuf<128> buf;
+		buf.Format(KPanic, &aData);
+		User::Panic(buf, KErrNotFound);
+		}
+
+	return wrapper;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/src/tcds_kernelBlockServer.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,97 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file tcds_kernelBlockServer.cpp
+ @internalTechnology
+*/
+
+#include "tcds_kernelBlockServer.h"
+
+Ctcds_kernelBlockServer* Ctcds_kernelBlockServer::NewL()
+	{
+	Ctcds_kernelBlockServer* server = new (ELeave) Ctcds_kernelBlockServer();
+	CleanupStack::PushL(server);
+	server->ConstructL();
+	CleanupStack::Pop(server);
+	return server;
+	}
+
+CTestBlockController* Ctcds_kernelBlockServer::CreateTestBlock()
+/**
+ * @return - Instance of the test block controller
+ * Called when Ctcds_kernelBlockServer initializing.
+ */
+	{
+	CTestBlockController* controller = NULL;
+
+	TRAPD(err, controller = Ctcds_kernelBlockController::NewL());
+	if(KErrNone != err)
+		{
+		User::Panic(_L("Failed to create Ctcds_kernelBlockController"), err);
+		}
+
+	return controller;
+	}
+
+// Secure variants much simpler
+// For EKA2, just an E32Main and a MainL()
+LOCAL_C void MainL()
+/**
+ * Secure variant
+ * Much simpler, uses the new Rendezvous() call to sync with the client
+ */
+	{
+	// Leave the hooks in for platform security
+#if (defined __DATA_CAGING__)
+	RProcess().DataCaging(RProcess::EDataCagingOn);
+	RProcess().DataCaging(RProcess::ESecureApiOn);
+#endif
+	CActiveScheduler* sched=NULL;
+	sched=new(ELeave) CActiveScheduler;
+	CActiveScheduler::Install(sched);
+	Ctcds_kernelBlockServer* server = NULL;
+	// Create the Ctcds_kernelBlockServer derived server
+	TRAPD(err,server = Ctcds_kernelBlockServer::NewL());
+	if(!err)
+		{
+		// Sync with the client and enter the active scheduler
+		RProcess::Rendezvous(KErrNone);
+		sched->Start();
+		}
+	delete server;
+	delete sched;
+	}
+
+GLDEF_C TInt E32Main()
+/**
+ * @return - Standard Epoc error code on process exit
+ * Secure variant only
+ * Process entry point. Called by client using RProcess API
+ */
+	{
+	__UHEAP_MARK;
+
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if(cleanup == NULL)
+		{
+		return KErrNoMemory;
+		}
+	TRAPD(err,MainL());
+	delete cleanup;
+
+	__UHEAP_MARKEND;
+	return err;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,24 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file bld.inf Build information file
+//
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_MMPFILES
+coredumptest_debug_token.mmp
+
+PRJ_EXPORTS
+coredumptest_debug_token.iby	/epoc32/rom/include/coredumptest_debug_token.iby
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/coredump_debug_token.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,31 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#include <e32base.h>
+
+GLDEF_C TInt E32Main()
+	{
+	// No need to do anything, the only requirement is that
+	// this executable can be loaded and runs to completion
+	return 0;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/coredump_debug_token.pkg	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,28 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+&EN
+; Localised vendor names
+%{"Symbian Software Ltd."}
+; Single, non-localised (global) vendor name
+:"Symbian Software Ltd."
+;
+; Replace the Package UID (0xE8000091) with your own.
+;
+#{"OEM Debug Token SIS"},(0x102836B8),1,0,0
+;
+"\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" - "!:\sys\bin\OEMDebug_10282FE5.exe"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/coredumptest_debug_token.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __COREDUMPDEBUGTOKEN_IBY__
+#define __COREDUMPDEBUGTOKEN_IBY__
+
+file=ABI_DIR\BUILD_DIR\oemdebug_10282fe5.exe	                              	Sys\Bin\oemdebug_10282fe5.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/coredumptest_debug_token.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,37 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// oem_debug_token.mmp
+//
+
+ALWAYS_BUILD_AS_ARM
+
+target         OEMDebug_102836BC.exe
+targettype     exe
+
+source        	coredump_debug_token.cpp 
+
+library		euser.lib
+
+systeminclude  \epoc32\include
+
+capability AllFiles TCB
+
+UID            0x1000008D 0x102836BD
+SECUREID       0x10286A64
+
+//
+// Set this to be your own vendor ID if any.
+//
+VENDORID       0x70000001
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_kernel/testtoken/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/tcds_unit.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,20 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+//Name of test session
+[session1]	
+name	=	session1
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/tcds_unit_selflib.ini	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,21 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  Data for the selflib tests
+//
+
+//Name of test session
+[wrapper]
+name	=	wrapper
+
+
Binary file dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/testelf1.elf has changed
Binary file dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/testelfexecutable.elf has changed
Binary file dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/testelfinvalid.elf has changed
Binary file dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/testelfinvalidsize.elf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/data/tinytestelf.elf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+EL
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,44 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_PLATFORMS
+ARMV5 WINSCW
+
+PRJ_EXPORTS
+
+PRJ_TESTEXPORTS
+../scripts/tcds_unit_selflib.script		/epoc32/winscw/c/scripts/tcds_unit_selflib.script
+../scripts/tcds_unit.script				/epoc32/winscw/c/scripts/tcds_unit.script
+
+../data/tcds_unit.ini					/epoc32/release/winscw/udeb/z/data/tcds_unit.ini
+../data/tcds_unit_selflib.ini			/epoc32/release/winscw/udeb/z/data/tcds_unit_selflib.ini
+../data/testelf1.elf					/epoc32/release/winscw/udeb/z/data/testelf1.elf
+../data/testelfinvalid.elf				/epoc32/release/winscw/udeb/z/data/testelfinvalid.elf
+../data/tinytestelf.elf					/epoc32/release/winscw/udeb/z/data/tinytestelf.elf
+../data/testelfexecutable.elf			/epoc32/release/winscw/udeb/z/data/testelfexecutable.elf
+
+tcds_unit.iby							/epoc32/rom/include/tcds_unit.iby
+tcds_unit_autoexec.bat					/epoc32/rom/tcds_unit_autoexec.bat
+
+PRJ_MMPFILES
+
+PRJ_TESTMMPFILES
+
+#if defined(MARM)
+tcds_unit
+coredumptest_debug_token
+#endif
+
+tcds_unit_selflib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/coredumptest_debug_token.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// oem_debug_token.mmp
+//
+
+ALWAYS_BUILD_AS_ARM
+
+target         OEMDebug_10286A65.exe
+targettype     exe
+
+SOURCEPATH			../src
+SOURCE        	coredump_debug_token.cpp 
+
+library		euser.lib
+
+systeminclude  \epoc32\include
+
+capability AllFiles TCB
+
+UID            0x1000008D 0x102836BD
+SECUREID       0x10286A66 
+
+//
+// Set this to be your own vendor ID if any.
+//
+VENDORID       0x70000001
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/tcds_unit.driver	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ASCII"?>
+<driver:driver xmlns:driver="http://www.symbian.com/TestDriver">
+  <task name="tcds_unit" timeout="100000">
+    <task name="buildProject" timeout="100000">
+      <executeOnPC>
+        <cmd URI="${sourceRoot}" phase="build">cov01 -1</cmd>
+        <build testBuild="true" URI="$(sourceRoot)\tcds_unit\group"/>
+        <cmd URI="${sourceRoot}" phase="build">cov01 -0</cmd>
+      </executeOnPC>
+    </task>
+    <task name="testProject" timeout="100000">
+      <executeOnPC>
+        <build testBuild="true" URI="${sourceRoot}\tcds_unit\group"/>
+      </executeOnPC>
+      <transferToSymbian>
+        <transfer move="false" PCPath="${sourceRoot}\tcds_unit\data\tcds_unit.ini" SymbianPath="c:\data\tcds_unit.ini"/>
+      </transferToSymbian>
+      <executeOnSymbian>
+        <testExecuteScript PCPath="${sourceRoot}\tcds_unit\scripts\tcds_unit.script" SymbianPath="c:\scripts\tcds_unit.script"/>
+      </executeOnSymbian>
+    </task>
+  </task>
+</driver:driver>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/tcds_unit.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,34 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//	iby file for tcds_unit tests
+
+#ifndef __TCDS_UNIT_IBY__
+#define __TCDS_UNIT_IBY__
+
+#include <testexecute.iby>
+
+file=ABI_DIR/BUILD_DIR/OEMDebug_10286A65.exe				sys/bin/oemdebug_10286A65.exe
+file=ABI_DIR/BUILD_DIR/tcds_unit.exe						sys/bin/tcds_unit.exe
+file=ABI_DIR/BUILD_DIR/tcds_unit_selflib.exe				sys/bin/tcds_unit_selflib.exe
+
+data=EPOCROOT##Epoc32/winscw/c/scripts/tcds_unit.script				/scripts/tcds_unit.script
+data=EPOCROOT##Epoc32/winscw/c/scripts/tcds_unit_selflib.script		/scripts/tcds_unit_selflib.script
+data=EPOCROOT##Epoc32/release/winscw/udeb/z/data/tcds_unit.ini					/data/tcds_unit.ini
+data=EPOCROOT##Epoc32/release/winscw/udeb/z/data/tcds_unit_selflib.ini			/data/tcds_unit_selflib.ini
+data=EPOCROOT##Epoc32/release/winscw/udeb/z/data/testelf1.elf					/data/testelf1.elf 
+data=EPOCROOT##Epoc32/release/winscw/udeb/z/data/testelfexecutable.elf			/data/testelfexecutable.elf
+data=EPOCROOT##Epoc32/release/winscw/udeb/z/data/testelfinvalid.elf				/data/testelfinvalid.elf
+data=EPOCROOT##Epoc32/release/winscw/udeb/z/data/tinytestelf.elf					/data/tinytestelf.elf
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/tcds_unit.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,53 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET				tcds_unit.exe
+TARGETTYPE			exe
+UID					0x1000007A 0x00A7DA92
+SECUREID 0x10286A65
+
+//Please add any change under here
+SOURCEPATH			../src
+SOURCE				tcds_unitBlockServer.cpp
+SOURCE				tcds_unitBlockController.cpp
+SOURCE				../../../../server/src/flashdatasource.cpp
+SOURCE				../../../../server/src/servercrashdatasource.cpp
+
+USERINCLUDE 		../inc
+USERINCLUDE			../../../../server/inc
+USERINCLUDE			../inc/cds
+USERINCLUDE			../../../../plugins/formatters/symbianelf/inc
+USERINCLUDE			../../../../plugins/formatters/symbianelf/incv2
+
+SYSTEMINCLUDE		/epoc32/include
+SYSTEMINCLUDE		/epoc32/include/drivers
+SYSTEMINCLUDE		/epoc32/include/test
+SYSTEMINCLUDE		/epoc32/include/tools/coredump
+SYSTEMINCLUDE 		/epoc32/include/ecom
+
+//Please add your system include under here.
+
+LIBRARY				euser.lib
+LIBRARY				testexecuteutils.lib
+LIBRARY				testexecutelogclient.lib
+LIBRARY 			cdssupport.lib
+LIBRARY				efsrv.lib
+LIBRARY				btracec.lib
+
+STATICLIBRARY		scmusr_lib.lib
+
+SOURCEPATH ../src/cds
+SOURCE CFlashDataSourceWrapper.cpp
+SOURCE CServerDataSourceWrapper.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/tcds_unit_autoexec.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,18 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+
+testexecute Z:\scripts\tcds_unit.script
+copy c:\logs\testexecute\* E:\*
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/group/tcds_unit_selflib.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,45 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET				tcds_unit_selflib.exe
+TARGETTYPE			exe
+UID					0x1000007A 0x00A7DA92
+SECUREID 0x10286A65
+
+//Please add any change under here
+SOURCEPATH			../src
+SOURCE				tcds_unit_selflib_block.cpp
+
+SOURCEPATH ../src/cds
+SOURCE CSELFLibWrapper.cpp
+
+SYSTEMINCLUDE		/epoc32/include
+SYSTEMINCLUDE		/epoc32/include/test
+SYSTEMINCLUDE		/epoc32/include/tools
+SYSTEMINCLUDE		/epoc32/include/tools/coredump
+
+USERINCLUDE 		../inc
+USERINCLUDE			../../../../server/inc
+USERINCLUDE			../inc/cds
+USERINCLUDE			../../../../plugins/formatters/symbianelf/inc
+USERINCLUDE			../../../../plugins/formatters/symbianelf/incv2
+
+LIBRARY				euser.lib
+LIBRARY				testexecuteutils.lib
+LIBRARY				testexecutelogclient.lib
+LIBRARY				selflib.lib
+LIBRARY				efsrv.lib
+LIBRARY				hal.lib
+LIBRARY				bafl.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/cds/CFlashDataSourceWrapper.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,187 @@
+/**
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file CFlashDataSourceWrapper.h
+ @internalTechnology
+ @prototype 
+*/
+
+#ifndef __CFLASHDATASOURCEWRAPPER_H__
+#define __CFLASHDATASOURCEWRAPPER_H__
+
+#include <datawrapper.h>
+#include <rm_debug_api.h>
+#include <scmdatatypes.h>
+#include <scmbytestreamutil.h>
+
+#include "flashdatasource.h"
+
+using namespace Debug;
+
+/**
+This is the version of the security server that we have developed our code against
+and it comes from the interface definition of the DSS at the time of compilation.
+*/
+const TVersion securityServerVersion( 
+				KDebugServMajorVersionNumber, 
+				KDebugServMinorVersionNumber, 
+				KDebugServPatchVersionNumber );
+
+const TInt CRASH_ID = 1;
+
+const TUint KMaxCacheSize = 32;
+/**
+ * This class is responsible for testing our CFlashDataSource class
+ */
+class CFlashDataSourceWrapper : public CDataWrapper
+	{
+	
+public:
+	
+	~CFlashDataSourceWrapper();
+
+	static CFlashDataSourceWrapper* NewL();
+
+	virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
+	virtual TAny* GetObject() { return iObject; }
+	virtual void SetObjectL(TAny* aObject);
+
+protected:
+	void ConstructL();
+
+private:
+	
+	/** Constructor */
+	CFlashDataSourceWrapper();	
+	
+	/** Tests CFlashDataSource::NewL */
+	void DoCmdCrashFlashDataSource_NewL_TestL();
+	
+	/** Tests CFlashDataSource::ReadCrashLog 
+	 *  Ensures the crash Log can be read correctly into our flash buffer
+	 */
+	void DoCmd_ReadCrashLog_L();
+	
+	/** Tests CFlashDataSource::GetFlashBuffer 
+	 *  Ensures that the flash buffer is correctly returned by getter
+	 */
+	void DoCmd_GetFlashBuffer_L();
+	
+	/** Tests CFlashDataSource::ProcessCrashHeader 
+	  * Ensures we can correctly process the crash header
+	  */
+	void DoCmd_ProcessCrashHeader1_L();
+	
+	/** Tests CFlashDataSource::ProcessCrashHeader 
+	  * Ensures we can recognise a corrupt header
+	  */
+	void DoCmd_ProcessCrashHeader2_L();
+	
+	/** Tests CFlashDataSource::GetProcessListL 
+	 *  Writes known process list to flash and makes sure we can get it back
+	 */
+	void DoCmd_GetProcessListL1_Test_L();
+	
+	/** Tests CFlashDataSource::GetProcessListL 
+	 *  Ensure we recognise corrupt process list
+	 */
+	void DoCmd_GetProcessListL2_Test_L();
+	
+	/** Tests CFlashDataSource::GetThreadList 
+	 *  Writes known system wide thread list to flash and makes sure we can get it back
+	 */
+	void DoCmd_GetThreadListL1_Test_L();
+	
+	/** Tests CFlashDataSource::GetThreadList 
+	 *  Ensure we recognise corrupt thread list
+	 */
+	void DoCmd_GetThreadListL2_Test_L();
+	
+	/** Tests CFlashDataSource::GetThreadList 
+	 *  Looks at a process specific thread list
+	 */
+	void DoCmd_GetThreadListL3_Test_L();
+	
+	/** Tests CFlashDataSource::ReadRegistersL
+	 *  Writes known registers to flash and ensures the correct ones are returned 
+	 */
+	void DoCmd_ReadRegistersL1_Test_L();
+	
+	/** Tests CFlashDataSource::ReadMemoryL 
+	 *  Writes known memory to flash and ensures the correct ones are returned  
+	 */
+	void DoCmd_ReadMemoryL1_Test_L();
+	
+	/** Negative tests for read memory 
+	 *  Ensures we cant read memory we havent dumped 
+	 */
+	void DoCmd_ReadMemoryL2_Test_L();
+	
+	/** Tests CFlashDataSource::GetCodeSegmentsL
+	 *  Writes known code segments to flash and ensures we can get them back
+	 */
+	void DoCmd_GetCodeSegmentsL1_Test_L();
+	
+	/** Tests CFlashDataSource::GetCodeSegmentsL
+	 *  Ensure we recognise corrupt data
+	 */
+	void DoCmd_GetCodeSegmentsL2_Test_L();
+
+	/**
+	 *  Tests CFlashDataSource::GetCodeSegmentsL
+	 *  Ensure we do not recieve duplicate segments back 
+	 *  even when we write duplicates to flash
+	 */
+	void DoCmd_GetCodeSegmentsL3_Test_L();
+
+	/** Tests CFlashDataSource::ReadTraceBufferL
+	 *  Ensure we can read back the correct test data
+	 */
+	void DoCmd_ReadTraceBufferL1_Test_L();
+	
+	/** Tests data checksums */
+	void DoCmd_CalculateChecksum_TestL();
+	
+	/** Tests we can get back the correct trace size */
+	void DoCmd_TraceDataSizeL_TestL();
+	
+	/** Tests we can handle the size not being found */
+	void DoCmd_TraceDataSizeNotFoundL_TestL();
+	
+	/** Tests we can read trace with an offset */
+	void DoCmd_ReadTraceBufferL2_Test_L();
+	
+	void PrepareTestL();
+	
+private:
+	
+	/** Object to be tested */
+	CFlashDataSource* iObject;
+	
+	/** Handle to debug security server */
+	RSecuritySvrSession iSecSess;
+	
+	/** These are our crash headers */
+	TCrashInfoHeader iInfHdr;
+	TCrashOffsetsHeader iOffsetsHdr;
+	TRegisterSet iContextHdr;
+	
+	};
+#endif // __CFLASHDATASOURCEWRAPPER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/cds/CSELFLibWrapper.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,149 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  Test wrapper for unit tests of the self lib
+
+/**
+ * @file CSelfLibWrapper.h
+ * @internalTechnology
+ * @prototype
+ */
+
+#ifndef __CSELFLIB_WRAPPER_H__
+#define __CSELFLIB_WRAPPER_H__
+
+#include <datawrapper.h>
+#include <selflib.h>
+#include <hal.h>
+
+//Constructor TestCase names
+_LIT(KSELFNewLC, "NewLC");
+_LIT(KSELFNewL, "NewL");
+
+//Negative tests for construction
+_LIT(KSELF_InvalidSignature, "TestConstruction_InvalidFile_Signature");
+_LIT(KSELF_InvalidSize, "TestConstruction_InvalidFile_Size");
+_LIT(KSELF_NotSupported, "TestConstruction_NotSupported");
+_LIT(KSELF_TestConstruction_Inuse, "TestConstruction_Inuse");
+
+//Test for getters
+_LIT(KSELF_GetElfHeaderL, "GetElfHeaderL");
+
+//Test for insertion
+_LIT(KSELF_InsertVariantSpecificData, "InsertVariantSpecificData");
+_LIT(KSELF_InsertMultipleVariants, "InsertMultipleVariants");
+_LIT(KSELF_InsertNothingAndUpdate, "InsertNothingAndUpdate");
+_LIT(KSELF_TestPerformance, "TestPerformance");
+_LIT(KSELF_TestStress, "TestStress");
+
+//ELF Files to test
+_LIT(KSELFFileName, "C:\\data\\testelf1.elf");
+_LIT(KSELFFileNameInvalidBySignature, "C:\\data\\testelfinvalid.elf");
+_LIT(KSELFFileNameTiny, "C:\\data\\tinytestelf.elf");
+_LIT(KSELFFileNameNonExistant, "C:\\idontexist1.elf");
+_LIT(KSELFFileNameExe, "C:\\data\\testelfexecutable.elf");
+
+_LIT(KROMSELFFileName, "Z:\\data\\testelf1.elf");
+_LIT(KROMSELFFileNameInvalidBySignature, "Z:\\data\\testelfinvalid.elf");
+_LIT(KROMSELFFileNameTiny, "Z:\\data\\tinytestelf.elf");
+_LIT(KROMSELFFileNameNonExistant, "Z:\\idontexist1.elf");
+_LIT(KROMSELFFileNameExe, "Z:\\data\\testelfexecutable.elf");
+
+//Preamble tests
+_LIT(KPrepareFiles, "PrepareFiles");
+_LIT(KTearDownFiles, "TearDownFiles");
+
+/**
+ * Can only use in void functions
+ * @param x Boolean
+ * @param If we fail, pop and destroy y items
+ */
+#define T_SELFLIB_ASSERT_TRUE(x, y)\
+	if(x == 0){\
+		ERR_PRINTF2(_L("Assertion Error in CSELFLibWrapper.cpp line [%d]"), __LINE__);\
+		SetBlockResult(EFail);\
+		if(y>0)\
+			CleanupStack::PopAndDestroy(y);\
+		return;\
+		}\
+
+/**
+ * Use for TUint returning functions
+ * @param x Boolean
+ * @param If we fail, pop and destroy y items and return z
+ */
+#define T_SELFLIB_ASSERT_TRUE_RET(x, y, z) \
+	if(!x){\
+		ERR_PRINTF2(_L("Assertion Error in CSELFLibWrapper.cpp line [%d]"), __LINE__);\
+		SetBlockResult(EFail);\
+		if(y>0)\
+			CleanupStack::PopAndDestroy(y);\
+		return z; \
+		}
+
+_LIT8(KTestData1, "This is some test variant data");
+_LIT8(KTestData2, "This is some more variant data");
+_LIT8(KTestData3, "This is even more variant data");
+
+static const TUint KLargeDataSize = 0xE1000;
+
+/**
+ * This class is responsible for testing the SELF editing library
+ */
+class CSELFLibWrapper : public CDataWrapper
+	{
+	public:
+		static CSELFLibWrapper* NewL();
+		~CSELFLibWrapper();
+
+		virtual TBool DoCommandL(const TTEFFunction& aCommand,
+			   const TTEFSectionName& aSection,
+			   const TInt aAsyncErrorIndex);
+
+		virtual TAny* GetObject() { return NULL; /* *iObject */ }
+		virtual void SetObject(TAny* aObject) { (void)aObject; }
+
+	protected:
+		void ConstructL();
+
+	private:
+		CSELFLibWrapper();
+		void LogELFHeader(const Elf32_Ehdr& aHeader);
+
+		//Test cases
+		void TestNewL_L();
+		void TestNewLC_L();
+		void TestInsertDataL();
+		void TestConstruction_InvalidELF_SignatureL();
+		void TestConstruction_InvalidELF_SizeL();
+		void TestConstruction_ValidELF_NotSupported();
+		void TestConstruction_Inuse();
+		void TestGetElfHeaderL();
+		void TestMultipleInsertionL();
+		void TestInsertNothingL();
+		void TestPerformanceL();
+		void TestStressL();
+
+		void CopyFilesToWritablePlaceL();
+		void TearDownFilesL();
+
+		TInt GetNumberofVariantSegmentsL(const TDesC& aFilename);
+		TInt GetVariantSegmentSizeL(const TUint aIndex, const TDesC& aFilename);
+		void GetVariantSegmentDataL(TUint aIndex, TDes8& aData, const TDesC& aFilename);
+		TInt HelpTicksPerSecond();
+
+	private:
+		RFs iFs;
+	};
+
+#endif // __CSELFLIB_WRAPPER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/cds/CServerDataSourceWrapper.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,86 @@
+/**
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file CServerDataSourceWrapper.h
+ @internalTechnology
+ @prototype 
+*/
+
+#ifndef __CSERVERDATASOURCEWRAPPER_H__
+#define __CSERVERDATASOURCEWRAPPER_H__
+
+#include <datawrapper.h>
+#include <rm_debug_api.h>
+
+#include "servercrashdatasource.h" 
+
+using namespace Debug;
+
+/**
+This is the version of the security server that we have developed our code against
+and it comes from the interface definition of the DSS at the time of compilation.
+*/
+const TVersion dssVersion( 
+				KDebugServMajorVersionNumber, 
+				KDebugServMinorVersionNumber, 
+				KDebugServPatchVersionNumber );
+
+_LIT(KCrashAppFileName,"Z:\\sys\\bin\\crashapp.exe");
+
+const TInt KTraceSizeFromCrashApp = 2560;
+/**
+ * This class is responsible for testing our CFlashDataSource class
+ */
+class CServerDataSourceWrapper : public CDataWrapper
+	{
+	
+public:
+	
+	~CServerDataSourceWrapper();
+
+	static CServerDataSourceWrapper* NewL();
+
+	virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
+	virtual TAny* GetObject() { return iObject; }
+	virtual void SetObjectL(TAny* aObject);
+
+protected:
+	void ConstructL();
+
+private:
+	
+	/** Constructor */
+	CServerDataSourceWrapper();	
+	
+	/** Tests GetAvailableTraceSizeL */
+	void DoCmdGetAvailableTraceSizeL_TestL();
+	
+	void PrepareTestL();
+	
+private:
+	
+	/** Object to be tested */
+	CServerCrashDataSource* iObject;
+	
+	/** Handle to debug security server */
+	RSecuritySvrSession iSecSess;
+	
+	};
+#endif // __CFLASHDATASOURCEWRAPPER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/cds/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/tcds_unitBlockController.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/**
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file tcds_unitBlockController.h
+ @internalTechnology
+*/
+
+#if (!defined __TCDS_UNIT_BLOCK_CONTROLLER_H__)
+#define __TCDS_UNIT_BLOCK_CONTROLLER_H__
+#include <TestBlockController.h>
+#include "CFlashDataSourceWrapper.h"
+#include "CServerDataSourceWrapper.h"
+
+
+class Ctcds_unitBlockController : public CTestBlockController
+	{
+public:
+	static Ctcds_unitBlockController* NewL();
+	// Base class pure virtual override
+	virtual CDataWrapper* CreateDataL(const TDesC& aData);
+
+// Please Add/modify your class members
+private:
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/tcds_unitBlockServer.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,41 @@
+/**
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file tcds_unitBlockServer.h
+ @internalTechnology
+*/
+
+#if (!defined __TCDS_UNIT_BLOCK_SERVER_H__)
+#define __TCDS_UNIT_BLOCK_SERVER_H__
+#include <TestServer2.h>
+#include "tcds_unitBlockController.h"
+
+class Ctcds_unitBlockServer : public CTestServer2
+	{
+public:
+	static Ctcds_unitBlockServer* NewL();
+	// Base class pure virtual override
+	virtual CTestBlockController* CreateTestBlock();
+
+// Please Add/modify your class members
+private:
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/inc/tcds_unit_selflib_block.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,51 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  Server header for unit test of sELFlib
+
+/**
+ * @file tcds_unit_sELFlib_blockserver.h
+ * @internalTechnology
+ */
+
+#ifndef __TCDS_UNIT_SELFLIB_BLOCK_SERVER_H__
+#define __TCDS_UNIT_SELFLIB_BLOCK_SERVER_H__
+
+#include <TestBlockController.h>
+#include <TestServer2.h>
+
+#include "CSELFLibWrapper.h"
+
+_LIT(KCSELFLibWrapper, "CSELFLibWrapper");
+
+/**
+ * This is the test test block server for the sELF lib tests
+ */
+class CSELFLibBlockServer : public CTestServer2
+	{
+	public:
+		static CSELFLibBlockServer* NewL();
+		virtual CTestBlockController* CreateTestBlock();
+	};
+
+/**
+ * This is the test block controller for the sELFlib tests
+ */
+class CSELFLibBlockController : public CTestBlockController
+	{
+	public:
+		static CSELFLibBlockController* NewL();
+		virtual CDataWrapper* CreateDataL(const TDesC& aData);
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/scripts/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/scripts/tcds_unit.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,400 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @File								tcds_unit.script
+//
+
+//! @SYMTestSuiteName               	DT-SCDS-UNIT
+//! @SYMScriptTestEnvironment       	TEF
+
+LOAD_SUITE tcds_unit
+
+
+
+START_TESTCASE                DT-SCDS-UNIT-0001
+//! @SYMTestCaseID              DT-SCDS-UNIT-0001
+//! @SYMTestCaseDesc            Test we can construct a flash data source and delete it succesfully.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Call NewL and delete it.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	NewL
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0001
+                     
+
+
+START_TESTCASE                DT-SCDS-UNIT-0002
+//! @SYMTestCaseID              DT-SCDS-UNIT-0002
+//! @SYMTestCaseDesc            Tests the ReadCrashLog method on the flash data source.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write dummy data to flash and read it back via GetFlashBuffer.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	ReadCrashLog
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0002
+
+
+START_TESTCASE                DT-SCDS-UNIT-0003
+//! @SYMTestCaseID              DT-SCDS-UNIT-0003
+//! @SYMTestCaseDesc            Tests we can retrieve the flash buffer of the flash data source.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Get the flash buffer with GetFlashBuffer and make sure its ok.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	GetFlashBuffer
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0003
+
+
+START_TESTCASE                DT-SCDS-UNIT-0004
+//! @SYMTestCaseID              DT-SCDS-UNIT-0004
+//! @SYMTestCaseDesc            Tests we can read and process a crash header from the flash partition.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a dummy header to the flash partition and read it back. It should be as expected. Tests ProcessCrashHeader().
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	ProcessCrashHeader1
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0004
+
+
+START_TESTCASE                DT-SCDS-UNIT-0005
+//! @SYMTestCaseID              DT-SCDS-UNIT-0005
+//! @SYMTestCaseDesc            Tests we can recognise a corrupt crash header from the flash partition
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a dummy data to the flash partition and read it back. Should recognise as corrupt. Tests ProcessCrashHeader.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	ProcessCrashHeader2
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0005
+
+
+START_TESTCASE                DT-SCDS-UNIT-0006
+//! @SYMTestCaseID              DT-SCDS-UNIT-0006
+//! @SYMTestCaseDesc            Tests we can retrieve the process list.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a known process list to flash and then read it back. Should be as expected.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	GetProcessListL1
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0006
+
+
+START_TESTCASE                DT-SCDS-UNIT-0007
+//! @SYMTestCaseID              DT-SCDS-UNIT-0007
+//! @SYMTestCaseDesc            Tests we can handle things ok when there is no process list.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a dummy crash with no process list. Should handle it and return a zero sized process list.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	GetProcessListL2
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0007
+
+
+START_TESTCASE                DT-SCDS-UNIT-0008
+//! @SYMTestCaseID              DT-SCDS-UNIT-0008
+//! @SYMTestCaseDesc            Tests we can retrieve the system wide thread list.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a known system wide thread list to flash and then read it back. Should be as expected.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	GetThreadListL1
+    END_TEST_BLOCK
+END_TESTCASE  DT-SCDS-UNIT-0008
+
+
+START_TESTCASE                DT-SCDS-UNIT-0009
+//! @SYMTestCaseID              DT-SCDS-UNIT-0009
+//! @SYMTestCaseDesc            Tests we can handle things ok when there is no process list.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a dummy crash with no thread list. Should handle it and return a zero sized process list.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	GetThreadListL2
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0009
+
+
+START_TESTCASE                DT-SCDS-UNIT-0010
+//! @SYMTestCaseID              DT-SCDS-UNIT-0010
+//! @SYMTestCaseDesc            Tests we can retrieve process specific thread list.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a dummy crash with a thread list with threads for multiple known process IDs. Retrieve the thread list via one of those process ID's and should only see the threads for that process.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	GetThreadListL3
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0010
+
+
+START_TESTCASE                DT-SCDS-UNIT-0011
+//! @SYMTestCaseID              DT-SCDS-UNIT-0011
+//! @SYMTestCaseDesc            Tests we can read registers back from the flash succesfully.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a dummy crash with registers for the crashed thread, usr registers and svr registers. Should be able to retrieve all.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	ReadRegistersL1
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0011
+
+
+START_TESTCASE                DT-SCDS-UNIT-0012
+//! @SYMTestCaseID              DT-SCDS-UNIT-0012
+//! @SYMTestCaseDesc            Tests we can read memory back from the flash succesfully.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a dummy crash with some memory. Should be able to retrieve it.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	ReadMemoryL1
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0012
+
+
+START_TESTCASE                DT-SCDS-UNIT-0013
+//! @SYMTestCaseID              DT-SCDS-UNIT-0013
+//! @SYMTestCaseDesc            Tests we can read code segments back from the flash succesfully.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a dummy crash with some code segments. Should be able to retrieve expected code segments.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	GetCodeSegmentsL1
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0013
+
+
+START_TESTCASE                DT-SCDS-UNIT-0014
+//! @SYMTestCaseID              DT-SCDS-UNIT-0014
+//! @SYMTestCaseDesc            Tests we can recognise corrupt code segments.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a dummy crash with some code segments but not code segment set (descriptor). Should get back a KErrCorrupt.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	GetCodeSegmentsL2
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0014
+
+
+START_TESTCASE                DT-SCDS-UNIT-0015
+//! @SYMTestCaseID              DT-SCDS-UNIT-0015
+//! @SYMTestCaseDesc            Tests we can read back entire trace data via flash data source.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a dummy crash with some trace data. Should retrieve expected trace.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	ReadTraceBufferL1
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0015
+
+
+START_TESTCASE                DT-SCDS-UNIT-0016
+//! @SYMTestCaseID              DT-SCDS-UNIT-0016
+//! @SYMTestCaseDesc            Tests we can calculate the check sum of the crash.
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Calculate check sum and should be as expected.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	CalcChecksum
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0016
+
+
+START_TESTCASE                DT-SCDS-UNIT-0018
+//! @SYMTestCaseID              DT-SCDS-UNIT-0018
+//! @SYMTestCaseDesc            Tests we can get back the correct size of trace available
+//! @SYMTestPriority            High
+//! @SYMTestActions             Write trace data to flash. Should get back expected.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	TraceDataSize
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0018
+
+
+START_TESTCASE                DT-SCDS-UNIT-0019
+//! @SYMTestCaseID              DT-SCDS-UNIT-0019
+//! @SYMTestCaseDesc            Tests we can get back KErrNotFound when trace is not available
+//! @SYMTestPriority            High
+//! @SYMTestActions             Write no trace data to flash. Should get KErrNotFound when we look for it.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            26/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	TraceDataSizeNotFound
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0019
+
+START_TESTCASE                DT-SCDS-UNIT-0020
+//! @SYMTestCaseID              DT-SCDS-UNIT-0020
+//! @SYMTestCaseDesc            Tests we can read the trace buffer with an offset
+//! @SYMTestPriority            High
+//! @SYMTestActions             Write trace data to flash. Read little chunks. Should be as expected.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            27/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	ReadTraceBufferL2
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0020
+
+START_TESTCASE                DT-CDS-UNIT-0001
+//! @SYMTestCaseID              DT-CDS-UNIT-0001
+//! @SYMTestCaseDesc            Tests we can get trace buffer size
+//! @SYMTestPriority            High
+//! @SYMTestActions             Write trace data to buffer. Get size and should be4 expected.
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            27/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CServerDataSourceWrapper	session1
+		COMMAND		session1	GetAvailableTraceSizeL
+    END_TEST_BLOCK
+END_TESTCASE DT-CDS-UNIT-0001
+
+
+START_TESTCASE                DT-SCDS-UNIT-0021
+//! @SYMTestCaseID              DT-SCDS-UNIT-0021
+//! @SYMTestCaseDesc            Tests data source does not return duplicate segments
+//! @SYMTestPriority            Critical
+//! @SYMTestActions             Write a dummy crash with duplicate code segmentscheck no duplicates in returned list
+//! @SYMTestExpectedResults     Pass
+//! @SYMTestType                UT
+//! @SYMCreationDate            25/11/2008
+//! @SYMAuthor                  stephenroberts
+//! @SYMTestStatus              2. Functional
+//! @SYMPREQ                    PREQ1700
+    START_TEST_BLOCK    100    tcds_unit \data\tcds_unit.ini
+    	CREATE_OBJECT	CFlashDataSourceWrapper	session1
+		COMMAND		session1	GetCodeSegmentsL3
+    END_TEST_BLOCK
+END_TESTCASE DT-SCDS-UNIT-0021
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/scripts/tcds_unit_selflib.script	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,122 @@
+//! @File
+//! @SYMTestSuiteName					DT-SELFLIB-UNIT
+//! @SYMScriptTestEnvironment			TEF
+
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+LOAD_SUITE tcds_unit_selflib
+
+START_TESTCASE					DT-SELFLIB-UNIT-0001
+//! @SYMTestCaseID				DT-SELFLIB-UNIT-0001
+//! @SYMTestCaseDesc			Basic NewL & NewLC testing
+//! @SYMTestPriority			Critical
+//! @SYMTestActions				Call NewL/NewLC and delete it.
+//! @SYMTestExpectedResults		Pass
+//! @SYMTestType				UT
+//! @SYMCreationDate			10/05/2009
+//! @SYMAuthor					stephenroberts
+//! @SYMTestStatus				2. Functional
+//! @SYMPREQ					PREQ2596
+	START_TEST_BLOCK	100	tcds_unit_selflib \data\tcds_unit_selflib.ini
+		CREATE_OBJECT	CSELFLibWrapper	wrapper
+		COMMAND		wrapper	PrepareFiles
+		COMMAND		wrapper	NewL
+		COMMAND		wrapper NewLC
+		COMMAND		wrapper	TearDownFiles
+	END_TEST_BLOCK
+END_TESTCASE DT-SELFLIB-UNIT-0001
+
+START_TESTCASE					DT-SELFLIB-UNIT-0002
+//! @SYMTestCaseID				DT-SELFLIB-UNIT-0002
+//! @SYMTestCaseDesc			Test that construction fails a) files with invalid signatures b) corrupt ELF files
+//! @SYMTestPriority			Critical
+//! @SYMTestActions				Call it on various files
+//! @SYMTestExpectedResults		Pass
+//! @SYMTestType				UT
+//! @SYMCreationDate			10/08/2009
+//! @SYMAuthor					stephenroberts
+//! @SYMTestStatus				2. Functional
+//! @SYMPREQ					PREQ2596
+	START_TEST_BLOCK	100	tcds_unit_selflib \data\tcds_unit_selflib.ini
+		CREATE_OBJECT	CSELFLibWrapper	wrapper
+		COMMAND		wrapper	PrepareFiles
+		COMMAND		wrapper	TestConstruction_InvalidFile_Signature
+		COMMAND		wrapper	TestConstruction_InvalidFile_Size
+		COMMAND		wrapper TestConstruction_NotSupported
+		COMMAND		wrapper TestConstruction_Inuse
+		COMMAND		wrapper	TearDownFiles
+	END_TEST_BLOCK
+END_TESTCASE DT-SELFLIB-UNIT-0002
+
+START_TESTCASE					DT-SELFLIB-UNIT-0003
+//! @SYMTestCaseID				DT-SELFLIB-UNIT-0003
+//! @SYMTestCaseDesc			Tests we can get the ELF header via SELF lib
+//! @SYMTestPriority			Critical
+//! @SYMTestActions				Open file, validate returned ELF header
+//! @SYMTestExpectedResults		Pass
+//! @SYMTestType				UT
+//! @SYMCreationDate			10/09/2009
+//! @SYMAuthor					stephenroberts
+//! @SYMTestStatus				2. Functional
+//! @SYMPREQ					PREQ2596
+	START_TEST_BLOCK	100	tcds_unit_selflib \data\tcds_unit_selflib.ini
+		CREATE_OBJECT	CSELFLibWrapper	wrapper
+		COMMAND		wrapper	PrepareFiles
+		COMMAND		wrapper	GetElfHeaderL
+		COMMAND		wrapper	TearDownFiles
+	END_TEST_BLOCK
+END_TESTCASE DT-SELFLIB-UNIT-0003
+
+START_TESTCASE					DT-SELFLIB-UNIT-0004
+//! @SYMTestCaseID				DT-SELFLIB-UNIT-0004
+//! @SYMTestCaseDesc			Test we can insert Variant Specific data to the ELF file
+//! @SYMTestPriority			Critical
+//! @SYMTestActions				Test we can insert Variant Specific data to the ELF file
+//! @SYMTestExpectedResults		Pass
+//! @SYMTestType				UT
+//! @SYMCreationDate			12/09/2009
+//! @SYMAuthor					stephenroberts
+//! @SYMTestStatus				2. Functional
+//! @SYMPREQ					PREQ2596
+	START_TEST_BLOCK	100	tcds_unit_selflib \data\tcds_unit_selflib.ini
+		CREATE_OBJECT	CSELFLibWrapper	wrapper
+		COMMAND		wrapper	PrepareFiles
+		COMMAND		wrapper	InsertVariantSpecificData
+		COMMAND		wrapper InsertMultipleVariants
+		COMMAND		wrapper InsertNothingAndUpdate
+		COMMAND		wrapper	TearDownFiles
+	END_TEST_BLOCK
+END_TESTCASE DT-SELFLIB-UNIT-0004
+
+START_TESTCASE					DT-SELFLIB-UNIT-0005
+//! @SYMTestCaseID				DT-SELFLIB-UNIT-0005
+//! @SYMTestCaseDesc			Performance test
+//! @SYMTestPriority			Critical
+//! @SYMTestActions				Test the performance is acceptable
+//! @SYMTestExpectedResults		Pass
+//! @SYMTestType				UT
+//! @SYMCreationDate			16/09/2009
+//! @SYMAuthor					stephenroberts
+//! @SYMTestStatus				2. Functional
+//! @SYMPREQ					PREQ2596
+	START_TEST_BLOCK	1000000	tcds_unit_selflib \data\tcds_unit_selflib.ini
+		CREATE_OBJECT	CSELFLibWrapper	wrapper
+		COMMAND		wrapper	PrepareFiles
+		COMMAND		wrapper	TestPerformance
+		COMMAND		wrapper TestStress
+		COMMAND		wrapper	TearDownFiles
+	END_TEST_BLOCK
+END_TESTCASE DT-SELFLIB-UNIT-0005
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/cds/CFlashDataSourceWrapper.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,2279 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file CFlashDataSourceWrapper.cpp
+ @internalTechnology 
+*/
+#include "CFlashDataSourceWrapper.h"
+
+using namespace Debug;
+
+//Names of functions to be tested - referenced from script file
+_LIT(KNewL_Debug, "NewL");
+_LIT(KReadCrashLog, "ReadCrashLog");
+_LIT(KGetFlashBuffer, "GetFlashBuffer");
+_LIT(KProcessCrashHeader1, "ProcessCrashHeader1");
+_LIT(KProcessCrashHeader2, "ProcessCrashHeader2");
+_LIT(KGetProcessListL1, "GetProcessListL1");
+_LIT(KGetProcessListL2, "GetProcessListL2");
+_LIT(KGetThreadListL1, "GetThreadListL1");
+_LIT(KGetThreadListL2, "GetThreadListL2");
+_LIT(KGetThreadListL3, "GetThreadListL3");
+_LIT(KReadRegistersL1, "ReadRegistersL1");
+_LIT(KReadMemoryL1, "ReadMemoryL1");
+_LIT(KReadMemoryL2, "ReadMemoryL2");
+_LIT(KGetCodeSegmentsL1, "GetCodeSegmentsL1");
+_LIT(KGetCodeSegmentsL2, "GetCodeSegmentsL2");
+_LIT(KGetCodeSegmentsL3, "GetCodeSegmentsL3");
+
+_LIT(KReadTraceBufferL1, "ReadTraceBufferL1");
+_LIT(KReadTraceBufferL2, "ReadTraceBufferL2");
+_LIT(KCalcChecksum, "CalcChecksum");
+_LIT(KTraceDataSize, "TraceDataSize");
+_LIT(KTraceDataSizeNotFound, "TraceDataSizeNotFound");
+
+_LIT8(KCrashDummyData, "This is a sample write");
+
+const TInt FLASH_ALIGN = sizeof(TInt32);
+const TInt START_OF_FLASH = 0;
+
+/**
+ * Constructor for test wrapper
+ */
+CFlashDataSourceWrapper::CFlashDataSourceWrapper()
+	:iObject(NULL)
+	{
+	}
+
+/**
+ * Destructor
+ */
+CFlashDataSourceWrapper::~CFlashDataSourceWrapper()
+	{
+	}
+
+/**
+ * Two phase constructor for CFlashDataSourceWrapper
+ * @return CFlashDataSourceWrapper object
+ * @leave
+ */
+CFlashDataSourceWrapper* CFlashDataSourceWrapper::NewL()
+	{
+	CFlashDataSourceWrapper* ret = new (ELeave) CFlashDataSourceWrapper();
+	CleanupStack::PushL(ret);
+	ret->ConstructL();
+	CleanupStack::Pop(ret);
+	return ret;
+	}
+
+/**
+ * Safe construction
+ * @leave
+ */
+void CFlashDataSourceWrapper::ConstructL()
+	{
+	
+	}
+
+/** 
+ * Assign the object
+ *  
+ * @param aObject TAny* to the object to test
+ * @leave
+ */
+void CFlashDataSourceWrapper::SetObjectL(TAny* aObject)
+	{
+	delete iObject;
+	iObject = NULL;
+	iObject = static_cast<CFlashDataSource*> (aObject);	
+	}
+
+/**
+ * Runs a test preamble
+ */
+void CFlashDataSourceWrapper::PrepareTestL()
+	{
+	SetBlockResult(EPass);		
+	
+	INFO_PRINTF1(_L("Connecting to DSS"));
+	//get a session to the security server
+	User::LeaveIfError(iSecSess.Connect(securityServerVersion));
+	
+	INFO_PRINTF1(_L("Erasing crash log"));
+	User::LeaveIfError(iSecSess.EraseCrashLog(0, 1));
+	
+	INFO_PRINTF1(_L("Creating data source"));
+	
+	//Hackage: TEF doesnt support preamble/postamble and destructs iObject each time. Until they sort it out
+	//or document how it is done the hackage shall have to continue. Oh for JUnit....
+	delete iObject;		//to be sure
+	iObject = CFlashDataSource::NewL(iSecSess);
+	//end of hackage
+	
+	INFO_PRINTF1(_L("Ready to start test"));
+	}
+
+/**
+ * Process command to see what test to run 
+ */
+TBool CFlashDataSourceWrapper::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
+	{
+	__UHEAP_MARK;	
+	
+	PrepareTestL();
+	
+	if (KNewL_Debug() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::NewL()");
+		TRAPD(err , DoCmdCrashFlashDataSource_NewL_TestL());	
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed!");
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if (KReadCrashLog() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::ReadCrashLog()");
+		TRAPD(err , DoCmd_ReadCrashLog_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if (KGetFlashBuffer() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::GetFlashBuffer()");
+		TRAPD(err , DoCmd_GetFlashBuffer_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if (KProcessCrashHeader1() == aCommand)
+		{
+		TRAPD(err , DoCmd_ProcessCrashHeader1_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if (KProcessCrashHeader2() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::ProcessCrashHeader() - 2nd test");
+		TRAPD(err , DoCmd_ProcessCrashHeader2_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}	
+	else if( KGetProcessListL1() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::GetProcessListL() - 1st test");
+		TRAPD(err , DoCmd_GetProcessListL1_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if ( KGetProcessListL2() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::GetProcessListL() - 2nd test");
+		TRAPD(err , DoCmd_GetProcessListL2_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if (KGetThreadListL1() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::GetThreadListL() - 1st test");
+		TRAPD(err , DoCmd_GetThreadListL1_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if( KGetThreadListL2() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::GetThreadListL() - 2nd test");
+		TRAPD(err , DoCmd_GetThreadListL2_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if( KGetThreadListL3() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::GetThreadListL() - 3rd test");
+		TRAPD(err , DoCmd_GetThreadListL3_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}	
+	else if( KReadRegistersL1() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::ReadRegistersL() - 1st test");
+		TRAPD(err , DoCmd_ReadRegistersL1_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if( KReadMemoryL1() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::ReadMemoryL() - 1st test");
+		TRAPD(err , DoCmd_ReadMemoryL1_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if( KReadMemoryL2() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::ReadMemoryL() - 2nd test");
+		TRAPD(err , DoCmd_ReadMemoryL2_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if( KGetCodeSegmentsL1() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource::GetCodeSegmentsL() - 1st test");
+		TRAPD(err , DoCmd_GetCodeSegmentsL1_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else if( KGetCodeSegmentsL2() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource - Code Segment Analysis - 2nd test");
+		TRAPD(err , DoCmd_GetCodeSegmentsL2_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}	
+	else if( KGetCodeSegmentsL3() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource - Code Segment Analysis - 3rd test");
+		TRAPD(err , DoCmd_GetCodeSegmentsL3_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}	
+	else if( KReadTraceBufferL1() == aCommand)
+		{
+		RDebug::Printf("Looking at CFlashDataSource - Trace Buffer - 1st test");
+		TRAPD(err , DoCmd_ReadTraceBufferL1_Test_L());
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed! [%d]", err);
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+  	else if(KCalcChecksum() == aCommand)
+  		{ 
+  		TRAPD(err , DoCmd_CalculateChecksum_TestL());
+  		if(BlockResult() != EPass || KErrNone != err)
+  			{
+  			RDebug::Printf("\tFailed! [%d]", err);
+  			}		
+  		}
+  	else if(KTraceDataSizeNotFound() == aCommand)
+  		{ 
+  		TRAPD(err , DoCmd_TraceDataSizeNotFoundL_TestL());
+  		if(BlockResult() != EPass || KErrNone != err)
+  			{
+  			RDebug::Printf("\tFailed! [%d]", err);
+  			}		
+  		}
+  	else if(KTraceDataSize() == aCommand)
+  	  		{ 
+  	  		TRAPD(err , DoCmd_TraceDataSizeL_TestL());
+  	  		if(BlockResult() != EPass || KErrNone != err)
+  	  			{
+  	  			RDebug::Printf("\tFailed! [%d]", err);
+  	  			}		
+  	  		}
+  	else if(KReadTraceBufferL2() == aCommand)
+			{ 
+			TRAPD(err , DoCmd_ReadTraceBufferL2_Test_L());
+			if(BlockResult() != EPass || KErrNone != err)
+				{
+				RDebug::Printf("\tFailed! [%d]", err);
+				}		
+			}	
+	else 		
+		{
+		RDebug::Printf("Not found");
+		
+		delete iObject;	
+		iSecSess.Close();
+		
+		__UHEAP_MARKEND;
+		
+		return EFalse;
+		}
+	
+	delete iObject;	
+	iSecSess.Close();	
+	
+	__UHEAP_MARKEND;
+	
+	return ETrue;
+	}
+
+/**
+ * This tests that we can succesfully construct 
+ * @leave
+ */
+void CFlashDataSourceWrapper::DoCmdCrashFlashDataSource_NewL_TestL()
+	{
+	//first we delete the CFlashDataSource created by our post amble to ensure we are testing a fresh object
+	delete iObject;
+	
+	SetBlockResult(EPass);
+	
+	INFO_PRINTF1(_L("Testing: CFlashDataSource::NewL()"));		
+	
+	//Try to create a flash data source object
+	TRAPD(err, iObject = CFlashDataSource::NewL(iSecSess));
+	
+	//Check errors
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Leave when creating CFlashDataSource: [%d]"),err);
+		SetBlockResult(EFail);
+		}
+	
+	//make sure its not null
+	if(!iObject)
+		{
+		ERR_PRINTF1(_L("Problems with creating CFlashDataSource object"));
+		SetBlockResult(EFail);
+		}	
+	
+	INFO_PRINTF1(_L("CFlashDataSource object constructed succesfully"));	
+	}
+
+/**
+ * Tests the ReadCrashLog method on the flash data source
+ */
+void CFlashDataSourceWrapper::DoCmd_ReadCrashLog_L()
+	{	
+	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadCrashLog()"));	
+	
+	//Write some expected data to the flash partition
+	TUint32 size = 0;
+	
+	INFO_PRINTF1(_L("Writing dummy data to crash log"));
+	iSecSess.WriteCrashConfig(START_OF_FLASH, KCrashDummyData, size);
+	
+	INFO_PRINTF1(_L("Reading dummy data back from crash log"));
+	TInt err = iObject->ReadCrashLog(START_OF_FLASH, size);
+	
+	//make sure we got the right data back
+	if( KErrNone != err || 0 != iObject->GetFlashBuffer().Compare(KCrashDummyData) )
+		{
+		ERR_PRINTF2(_L("Failed to read the correct data back via flash data source: Err = [%d]"), err);
+		SetBlockResult(EFail);
+		return;
+		}
+	
+	//test the parameters	
+	INFO_PRINTF1(_L("Testing that reading from a negative position will fail"));
+	
+	TInt32 negative = -2;
+	err = iObject->ReadCrashLog(negative, size);
+	
+	if(err != KErrArgument)
+		{
+		ERR_PRINTF1(_L("We were able to read data from a negative position"));
+		SetBlockResult(EFail);
+		return;
+		}
+	}
+
+/**
+ * Tests the flash data source get flash buffer
+ */
+void CFlashDataSourceWrapper::DoCmd_GetFlashBuffer_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource::GetFlashBuffer()"));
+		
+	//Ensure that the buffer has been created
+	INFO_PRINTF1(_L("Ensuring the buffer has been succesfully created"));
+
+	TDes8& buf = iObject->GetFlashBuffer();
+	
+	if(KInitialBufferSize != buf.Size())
+		{
+		ERR_PRINTF1(_L("Buffer was not created"));
+		SetBlockResult(EFail);
+		return;
+		}
+	}
+
+/**
+ * Tests that we correctly process the crash header
+ */
+void CFlashDataSourceWrapper::DoCmd_ProcessCrashHeader1_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource::ProcessCrashHeader() - 1st Test"));
+	
+	TInt64 tid = 22;	
+	
+	iContextHdr.iNumRegisters = 0;
+	iInfHdr.iFlashAlign = FLASH_ALIGN;
+	iInfHdr.iTid = tid;
+	iInfHdr.iCrashId = CRASH_ID;
+	
+	TInt logSz = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize();
+	iInfHdr.iLogSize = logSz;
+	
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + TRegisterSet::KSCMRegisterSetMaxSize + KMaxCacheSize;
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);	
+
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	
+	INFO_PRINTF1(_L("Writing header to flash"));
+	
+	TUint32 size = 0;		
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data, size));	
+	
+	CleanupStack::PopAndDestroy();
+	
+	INFO_PRINTF1(_L("Processing crash header"));
+	
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to process crash log: [%d]"), err);
+		SetBlockResult(EFail);
+		return;
+		}
+	
+	//Read the buffer back
+	TDes8& buf = iObject->GetFlashBuffer();
+	
+	INFO_PRINTF1(_L("Ensuring crash header read back is correct"));	
+	
+	//Test our getters work correctly too
+	if(tid != iObject->GetCrashedThreadId())
+		{
+		ERR_PRINTF1(_L("Unable to Get Crashed Thread ID from header"));
+		SetBlockResult(EFail);
+		return;
+		}
+	
+	if(FLASH_ALIGN != iObject->GetFlashAlignment())
+		{
+		ERR_PRINTF1(_L("Unable to Get Correct flash alignment from header"));
+		SetBlockResult(EFail);
+		return;
+		}
+	
+	if(logSz != iObject->GetCrashLogSize())
+		{
+		ERR_PRINTF1(_L("Unable to Get correct log size from header"));
+		SetBlockResult(EFail);
+		return;
+		}	
+	
+	INFO_PRINTF1(_L("All is good. Move along now."));	
+	}
+
+/**
+ * Negative test to make sure if there is no header we get told so
+ */
+void CFlashDataSourceWrapper::DoCmd_ProcessCrashHeader2_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource::ProcessCrashHeader() - 2nd Test"));
+	
+	//write a struct that isnt TCrashInfoHeader
+	TProcessData dummy;	
+	TPtr8 data((TUint8*)&dummy, sizeof(TProcessData), sizeof(TProcessData));
+	
+	TUint32 size = 0;
+	
+	INFO_PRINTF1(_L("Writing header to flash"));	
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data, size));
+	
+	INFO_PRINTF1(_L("Processing crash header"));	
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
+	if(KErrNotFound != err)
+		{
+		ERR_PRINTF2(_L("Process header should have been corrupt but wasnt [%d]"), err);
+		SetBlockResult(EFail);
+		return;
+		}
+	}
+
+/**
+ * Tests we can succesfully read back known processes from flash
+ */
+void CFlashDataSourceWrapper::DoCmd_GetProcessListL1_Test_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource::GetProcessListL() - 1st test"));
+	
+	//We need to write some process data (will just do 2) to the flash, and update the header with its location
+	TInt64 p1id = 100;
+	TInt32 p1prior = 4;
+	
+	TInt64 p2id = 200;
+	TInt32 p2prior = 5;
+	
+	//Process names
+	_LIT8(KProc1, "t_proc1");
+	_LIT8(KProc2, "tproc2");
+	
+	//buffer for data
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + TRegisterSet::KSCMRegisterSetMaxSize + 2 * TProcessData::KSCMProcessDataMaxSize + KMaxCacheSize;
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);			
+	
+	TCrashOffsetsHeader hdr;
+	hdr.iPLstOffset = sizeof(TCrashInfoHeader) + sizeof(TCrashOffsetsHeader); //starts right after headers 
+	
+	//The first process data
+	TProcessData proc1;
+	proc1.iPid = p1id;
+	proc1.iPriority = p1prior;
+	proc1.iNamesize = KProc1().Size();
+	proc1.iName = KProc1;
+	
+	//The second process data
+	TProcessData proc2;
+	proc2.iPid = p2id;
+	proc2.iPriority = p2prior;
+	proc2.iNamesize = KProc2().Size();
+	proc2.iName = KProc2;
+	
+	iInfHdr.iCrashId = CRASH_ID;	
+	iContextHdr.iNumRegisters = 0; //no context
+	iOffsetsHdr.iPLstOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers
+	iInfHdr.iLogSize = iOffsetsHdr.iPLstOffset + proc1.GetSize() + proc2.GetSize();		
+	
+	INFO_PRINTF1(_L("Writing known processes to flash"));
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	proc1.Serialize(writer);
+	proc2.Serialize(writer);
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
+	
+	//Now we try get these processes back via GetProcessListL
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy();
+		return;
+		}
+	
+	RProcessPointerList *processList = new(ELeave)RProcessPointerList;
+	TCleanupItem processCleanup(CFlashDataSource::CleanupProcessList, (TAny*)processList);
+	CleanupStack::PushL(processCleanup);
+		
+	TUint wr = 0;
+	
+	INFO_PRINTF1(_L("Getting process list"));
+	TRAP(err, iObject->GetProcessListL(*processList, wr));
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to get process list: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	if(processList->Count() != 2)
+		{
+		ERR_PRINTF2(_L("Didnt find the expected 2 processes. There were [%d] instead"), processList->Count());
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	CProcessInfo* p1 = (*processList)[0];
+	CProcessInfo* p2 = (*processList)[1];
+	
+	INFO_PRINTF1(_L("Retrieveing processes"));
+	if(!p1 || !p2)
+		{
+		ERR_PRINTF1(_L("Failed to retrieve non null processes"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	INFO_PRINTF1(_L("Making sure processes are as expected"));
+	
+	//Check ID's
+	if(p1->Id() != proc1.iPid  ||  p2->Id() != proc2.iPid)
+		{
+		ERR_PRINTF1(_L("Failed to retrieve correct process ID's:"));
+		ERR_PRINTF3(_L("P1 expected [%d] but found [%d]"), proc1.iPid, p1->Id());
+		ERR_PRINTF3(_L("P2 expected [%d] but found [%d]"), proc2.iPid, p2->Id());
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}	
+	
+	//check names
+	RBuf wide;	
+	wide.CreateL(KProc1().Size());
+	wide.CleanupClosePushL();	
+	wide.Copy(KProc1);
+	
+	INFO_PRINTF1(_L("Checking process 1 name is ok"));
+	if( p1->Name().Compare(wide) != 0 )
+		{
+		ERR_PRINTF3(_L("Wrong name retrieved, expected [%S] but got [%S]"), &KProc1, &wide);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+	
+	wide.Copy(KProc2);
+	
+	INFO_PRINTF1(_L("Checking process 2 name is ok"));
+	if( p2->Name().Compare(wide) != 0 )
+		{
+		ERR_PRINTF3(_L("Wrong name retrieved, expected [%S] but got [%S]"), &KProc2, &wide);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}	
+
+	INFO_PRINTF1(_L("All looks good"));
+	
+	CleanupStack::PopAndDestroy(3);
+
+	}
+
+/**
+ * Negative tests should the flash contain corrupt data
+ */
+void CFlashDataSourceWrapper::DoCmd_GetProcessListL2_Test_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource::GetProcessList() - 2nd test"));
+	
+	//buffer for data
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 3 * TRegisterSet::KSCMRegisterSetMaxSize + KMaxCacheSize;
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);				
+	
+	iInfHdr.iCrashId = CRASH_ID;	
+	iContextHdr.iNumRegisters = 0; //no context
+	iOffsetsHdr.iPLstOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers
+	iInfHdr.iLogSize = iOffsetsHdr.iPLstOffset + 2 * iContextHdr.GetSize();		
+	
+	INFO_PRINTF1(_L("Writing known processes to flash"));
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);	
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
+	
+	RProcessPointerList *processList = new(ELeave)RProcessPointerList;
+	TCleanupItem processCleanup(CFlashDataSource::CleanupProcessList, (TAny*)processList);
+	CleanupStack::PushL(processCleanup);
+	
+		
+	INFO_PRINTF1(_L("Getting process list"));
+	
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to process header [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	
+	TUint wr = 0;
+	TRAP(err, iObject->GetProcessListL( *processList, wr));	
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Should have retrieved zero sized process list"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	
+	if(processList->Count() != 0)
+		{
+		ERR_PRINTF1(_L("Should have retrieved zero sized process list"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	INFO_PRINTF1(_L("Everything is as expected"));
+	
+	CleanupStack::PopAndDestroy(2);
+	}
+
+/**
+ * Tests to make sure we can get back a thread list (two here) from the flash
+ */
+void CFlashDataSourceWrapper::DoCmd_GetThreadListL1_Test_L()
+	{	
+	INFO_PRINTF1(_L("Testing CFlashDataSource::GetThreadListL() 1st Test - System wide thread list"));
+	
+	//We need to write some thread data (will just do 2) to the flash, and update the header with its location
+	TInt64 t1id = 100;
+	TInt32 t1prior = 4;
+	TInt32 t1SvcSp = 20;
+	TInt32 t1UsrStkSize = 40;
+	
+	TInt64 t2id = 200;
+	TInt32 t2prior = 5;
+	TInt32 t2SvcSp = 25;
+	TInt32 t2UsrStkSize = 47;	
+	
+	//thread names
+	_LIT8(KThread1, "t_thread1");
+	_LIT8(KThread2, "thread2");	
+
+	//buffer for data
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
+						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TThreadData::KSCMThreadDataMaxSize + 
+						KMaxCacheSize;
+	
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
+	
+	TInt owner1 = 100;
+	TInt owner2 = 200;
+	
+	//The first thread data
+	TThreadData t1;
+	t1.iTid = t1id;
+	t1.iPriority = t1prior;
+	t1.iSvcSP = t1SvcSp;
+	t1.iUsrStacksize = t1UsrStkSize;
+	t1.iNamesize = KThread1().Size();
+	t1.iName = KThread1;
+	t1.iOwnerId = owner1;
+	
+	//The second thread data
+	TThreadData t2;
+	t2.iTid = t2id;
+	t2.iPriority = t2prior;
+	t2.iSvcSP = t2SvcSp;
+	t2.iUsrStacksize = t2UsrStkSize;
+	t2.iNamesize = KThread2().Size();
+	t2.iName = KThread2;
+	t2.iOwnerId = owner2;
+	
+	iInfHdr.iCrashId = CRASH_ID;	
+	iContextHdr.iNumRegisters = 0; //no context
+	iOffsetsHdr.iTLstOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers
+	iInfHdr.iLogSize = iOffsetsHdr.iTLstOffset + t1.GetSize() + t2.GetSize();		
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	t1.Serialize(writer);
+	t2.Serialize(writer);	
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
+
+	//Now we try get these threads back via GetThreadListL
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy();
+		return;
+		}
+	
+	RThreadPointerList *threadList = new(ELeave)RThreadPointerList;
+	TCleanupItem threadCleanup(CFlashDataSource::CleanupThreadList, (TAny*)threadList);
+	CleanupStack::PushL(threadCleanup);
+	
+	TUint wr = 0;
+	
+	INFO_PRINTF1(_L("Getting thread list"));
+	TRAP(err, iObject->GetThreadListL(((TUint64)-1), *threadList, wr));
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to get thread list: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	if(threadList->Count() != 2)
+		{
+		ERR_PRINTF1(_L("Retrieved wrong number of threads"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+		
+	CThreadInfo* ti1 = (*threadList)[0];
+	CThreadInfo* ti2 = (*threadList)[1];
+	
+	INFO_PRINTF1(_L("Retrieveing threads"));
+	if(!ti1 || !ti2)
+		{
+		ERR_PRINTF1(_L("Failed to retrieve non null threads"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	INFO_PRINTF1(_L("Making sure processes are as expected"));
+	
+	//Check ID's
+	if(ti1->Id() != t1.iTid ||  ti2->Id() != t2.iTid)
+		{
+		ERR_PRINTF1(_L("Failed to retrieve correct thread ID's:"));
+		ERR_PRINTF3(_L("T1 expected [%d] but found [%d]"), t1.iTid, ti1->Id());
+		ERR_PRINTF3(_L("T2 expected [%d] but found [%d]"), t2.iTid, ti2->Id());
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}	
+	
+	//check names
+	RBuf wide;	
+	wide.CreateL(KThread1().Size());
+	wide.CleanupClosePushL();	
+	wide.Copy(KThread1);
+	
+	INFO_PRINTF1(_L("Checking thread 1 name is ok"));
+	if( ti1->Name().Compare(wide) != 0 )
+		{
+		ERR_PRINTF3(_L("Wrong name retrieved, expected [%S] but got [%S]"), &KThread1, &wide);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+	
+	if(KThread2().Size() > wide.Size())
+		{
+		wide.ReAllocL(KThread2().Size());
+		}
+	wide.Copy(KThread2);
+	
+	INFO_PRINTF1(_L("Checking thread 2 name is ok"));
+	if( ti2->Name().Compare(wide) != 0 )
+		{
+		ERR_PRINTF3(_L("Wrong name retrieved, expected [%S] but got [%S]"), &KThread2, &wide);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}	
+
+	INFO_PRINTF1(_L("All looks good"));
+	
+	CleanupStack::PopAndDestroy(3);	
+	
+	}
+
+/**
+ * Looks at a process specific thread list
+ */
+void CFlashDataSourceWrapper::DoCmd_GetThreadListL3_Test_L()
+	{	
+	INFO_PRINTF1(_L("Testing CFlashDataSource::GetThreadListL() 3rd Test - Process specific thread list"));
+	
+	//We need to write some thread data (will just do 2) to the flash, and update the header with its location
+	TInt64 t1id = 100;
+	TInt32 t1prior = 4;
+	TInt32 t1SvcSp = 20;
+	TInt32 t1UsrStkSize = 40;
+	
+	TInt64 t2id = 200;
+	TInt32 t2prior = 5;
+	TInt32 t2SvcSp = 25;
+	TInt32 t2UsrStkSize = 47;	
+	
+	//thread names
+	_LIT8(KThread1, "t_thread1");
+	_LIT8(KThread2, "thread2");	
+
+	//buffer for data
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
+						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TThreadData::KSCMThreadDataMaxSize + 
+						KMaxCacheSize;
+	
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
+	
+	TInt owner1 = 100;
+	TInt owner2 = 200;
+	
+	//The first thread data
+	TThreadData t1;
+	t1.iTid = t1id;
+	t1.iPriority = t1prior;
+	t1.iSvcSP = t1SvcSp;
+	t1.iUsrStacksize = t1UsrStkSize;
+	t1.iNamesize = KThread1().Size();
+	t1.iName = KThread1;
+	t1.iOwnerId = owner1;
+	
+	//The second thread data
+	TThreadData t2;
+	t2.iTid = t2id;
+	t2.iPriority = t2prior;
+	t2.iSvcSP = t2SvcSp;
+	t2.iUsrStacksize = t2UsrStkSize;
+	t2.iNamesize = KThread2().Size();
+	t2.iName = KThread2;
+	t2.iOwnerId = owner2;
+	
+	iInfHdr.iCrashId = CRASH_ID;	
+	iContextHdr.iNumRegisters = 0; //no context
+	iOffsetsHdr.iTLstOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers
+	iInfHdr.iLogSize = iOffsetsHdr.iTLstOffset + t1.GetSize() + t2.GetSize();		
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	t1.Serialize(writer);
+	t2.Serialize(writer);	
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
+
+	//Now we try get these threads back via GetThreadListL
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy();
+		return;
+		}
+	
+	RThreadPointerList *threadList = new(ELeave)RThreadPointerList;
+	TCleanupItem threadCleanup(CFlashDataSource::CleanupThreadList, (TAny*)threadList);
+	CleanupStack::PushL(threadCleanup);
+	
+	TUint wr = 0;
+	
+	INFO_PRINTF1(_L("Getting thread list"));
+	TRAP(err, iObject->GetThreadListL(owner1, *threadList, wr));
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to get thread list: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	if(threadList->Count() != 1)
+		{
+		ERR_PRINTF1(_L("Retrieved wrong number of threads"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+		
+	CThreadInfo* ti1 = (*threadList)[0];
+	
+	INFO_PRINTF1(_L("Retrieveing threads"));
+	if(!ti1)
+		{
+		ERR_PRINTF1(_L("Failed to retrieve non null threads"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	INFO_PRINTF1(_L("Making sure processes are as expected"));
+	
+	//Check ID's
+	if(ti1->Id() != t1.iTid)
+		{
+		ERR_PRINTF1(_L("Failed to retrieve correct thread ID's:"));
+		ERR_PRINTF3(_L("T1 expected [%d] but found [%d]"), t1.iTid, ti1->Id());
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}	
+	
+	//check names
+	RBuf wide;	
+	wide.CreateL(KThread1().Size());
+	wide.CleanupClosePushL();	
+	wide.Copy(KThread1);
+	
+	INFO_PRINTF1(_L("Checking thread 1 name is ok"));
+	if( ti1->Name().Compare(wide) != 0 )
+		{
+		ERR_PRINTF3(_L("Wrong name retrieved, expected [%S] but got [%S]"), &KThread1, &wide);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+
+	INFO_PRINTF1(_L("All looks good"));
+	
+	CleanupStack::PopAndDestroy(3);	
+	
+	}
+
+
+/**
+ * Negative tests should the flash contain corrupt data
+ */
+void CFlashDataSourceWrapper::DoCmd_GetThreadListL2_Test_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource::GetThreadList() - 2nd test"));
+	
+	//buffer for data
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 3 * TRegisterSet::KSCMRegisterSetMaxSize + KMaxCacheSize;
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);				
+	
+	iInfHdr.iCrashId = CRASH_ID;	
+	iContextHdr.iNumRegisters = 0; //no context
+	iOffsetsHdr.iTLstOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers
+	iInfHdr.iLogSize = iOffsetsHdr.iTLstOffset + 2 * iContextHdr.GetSize();		
+	
+	INFO_PRINTF1(_L("Writing known processes to flash"));
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);	
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
+	
+	RThreadPointerList *threadList = new(ELeave)RThreadPointerList;
+	TCleanupItem threadCleanup(CFlashDataSource::CleanupThreadList, (TAny*)threadList);
+	CleanupStack::PushL(threadCleanup);
+	
+		
+	INFO_PRINTF1(_L("Getting thread list"));
+	
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to process header [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}	
+	
+	TUint wr = 0;	
+	TRAP(err, iObject->GetThreadListL(START_OF_FLASH, *threadList, wr));
+	
+	if(threadList->Count() != 0)
+		{
+		ERR_PRINTF1(_L("Should have retrieved zero sized thread list"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	INFO_PRINTF1(_L("Everything is as expected"));
+	
+	CleanupStack::PopAndDestroy(2);
+	
+	}
+
+/**
+ * Tests we can read registers back from the flash succesfully
+ */
+void CFlashDataSourceWrapper::DoCmd_ReadRegistersL1_Test_L()
+	{
+	
+	/**
+	 * The 3 different register sets corrospond to the 3 different register related configuration
+	 * options:
+	 * 			ECrashedThreadFullRegisters starts from iCTFullReg
+	 * 			EThreadsUsrRegisters starts from iSysSvrReg
+	 * 			EThreadsSvrRegisters starts from iSysUsrReg
+	 * 
+	 * Are going to write the following data to flash:
+	 * 
+	 * |--TCrashHeader--||--TRegisterValue--| ... |--TRegisterValue--|      at the ECrashedThreadFullRegisters point
+	 * 					 <--               For a crashed thread                      -->    
+	 * 					 |--TRegisterValue--| ... |--TRegisterValue--|      at the EThreadsUsrRegisters point
+	 * 					 <--    For a system thread (at user registers point)        -->  
+	 * 					 |--TRegisterValue--| ... |--TRegisterValue--|      at the EThreadsSvrRegisters point
+	 * 					 <--    For a system thread  (at svr register point)      -->        
+	 */
+	
+	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadRegistersL() Test1"));
+	
+	TThreadId crashedThread = TThreadId(139); //arbitrary vals
+	TThreadId otherThread = TThreadId(15);		//arbitrary vals
+
+	//buffer for data
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 6 * TRegisterValue::KSCMRegisterValueMaxSize + KMaxCacheSize;
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);	
+	
+	//Headers - as much as we need	
+	iInfHdr.iTid = crashedThread.Id();
+	iInfHdr.iCrashId = CRASH_ID;	
+	iOffsetsHdr.iCTFullRegOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers	
+	iContextHdr.iNumRegisters = 0; //no context
+	
+	//For this test we will put in 2 registers for each config option
+	TRegisterValue r1;
+	r1.iValue32 = 0xDEADDEAA;
+	r1.iOwnId = crashedThread.Id();
+	
+	TRegisterValue r2;
+	r2.iValue32 = 0xDEADEADB;
+	r2.iOwnId = crashedThread.Id();
+	
+	TRegisterValue r3;
+	r3.iValue32 = 0xDEADEADC;
+	r3.iOwnId = otherThread.Id();
+	
+	TRegisterValue r4;
+	r4.iValue32 = 0xDEADEADD;
+	r4.iOwnId = otherThread.Id();
+	
+	TRegisterValue r5;
+	r5.iValue32 = 0xDEADEADE;
+	r5.iOwnId = otherThread.Id();
+	
+	TRegisterValue r6;
+	r6.iValue32 = 0xDEADEADF;
+	r6.iOwnId = otherThread.Id();
+
+	iOffsetsHdr.iSysSvrRegOffset = iOffsetsHdr.iCTFullRegOffset + r1.GetSize() + r2.GetSize();
+	iOffsetsHdr.iSysUsrRegOffset = iOffsetsHdr.iSysSvrRegOffset + r3.GetSize() + r4.GetSize();	
+	iInfHdr.iLogSize = iOffsetsHdr.iSysUsrRegOffset + r6.GetSize() + r5.GetSize();	
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	r1.Serialize(writer);
+	r2.Serialize(writer);
+	r3.Serialize(writer);
+	r4.Serialize(writer);
+	r5.Serialize(writer);
+	r6.Serialize(writer);
+	
+	INFO_PRINTF1(_L("Writing known registers to flash"));
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(0, data ,written));
+	
+	//Now we try and get them back via ReadRegistersL
+	RRegisterList regList;
+	CleanupClosePushL(regList);
+	
+	INFO_PRINTF1(_L("Reading back registers"));
+	
+	TRAPD(err, iObject->AnalyseCrashL(1));	
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to analyse crash header: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	//Read for crashed thread first (hard coded in the absence of TSymbianInfo for now)
+	TRAP(err, iObject->ReadRegistersL(crashedThread.Id(), regList));
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to read registers: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	if(regList.Count() != 2)
+		{
+		ERR_PRINTF2(_L("Got wrong amount of registers back: [%d]"), regList.Count());
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	if(regList[0].iValue32 != r1.iValue32 || regList[1].iValue32 != r2.iValue32)
+		{
+		ERR_PRINTF1(_L("Got wrong register values back"));
+		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r1.iValue32,regList[0].iValue32);
+		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r2.iValue32,regList[1].iValue32);
+		
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	//and for "system" thread
+	TRAP(err, iObject->ReadRegistersL(otherThread.Id(), regList));
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to read registers: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+
+	if(regList.Count() != 4)
+		{
+		ERR_PRINTF2(_L("Got wrong amount of registers back: [%d]"), regList.Count());
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	if(regList[0].iValue32 != r3.iValue32 
+			|| regList[1].iValue32 != r4.iValue32
+			|| regList[2].iValue32 != r5.iValue32
+			|| regList[3].iValue32 != r6.iValue32)
+		{
+		ERR_PRINTF1(_L("Got wrong register values back"));
+		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r3.iValue32,regList[0].iValue32);
+		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r4.iValue32,regList[1].iValue32);
+		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r5.iValue32,regList[2].iValue32);
+		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r6.iValue32,regList[3].iValue32);
+
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	INFO_PRINTF1(_L("Got back all registers as expected"));
+	
+	CleanupStack::PopAndDestroy(2);	
+	}
+
+/** 
+ * Tests that we can read memory from the crash log
+ */
+void CFlashDataSourceWrapper::DoCmd_ReadMemoryL1_Test_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadMemoryL() Test1"));
+	
+	//buffer to hold memory
+	TInt32 numBytes = 8; //we will dump 8 bytes of memory
+	TUint8 memoryToDump = 0xAB;		
+	
+	RBuf8 mem;
+	mem.CreateL(numBytes * sizeof(TUint8));	
+	mem.CleanupClosePushL();
+	
+	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
+		{
+		mem.Append(&memoryToDump, sizeof(TUint8));
+		}
+	
+	//buffer to hold log
+	TInt dataLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + TRegisterSet::KSCMRegisterSetMaxSize + numBytes + TMemoryDump::KSCMMemDumpMaxSize + TRawData::KSCMRawDataMaxSize;
+	
+	RBuf8 data;	
+	data.CreateL(dataLength);
+	data.SetLength(dataLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
+	
+	TUint32 startAdd = 0x10000000;
+	TUint64 procId = 100;
+	
+	TMemoryDump memDump;
+	memDump.iStartAddress = startAdd;
+	memDump.iPid = procId;
+	memDump.iLength = mem.Length();
+	
+	TRawData rawData;
+	rawData.iLength = mem.Length();	
+	rawData.iData.Set(mem.MidTPtr(0));
+	
+	TInt32 crashSize = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize() + memDump.GetSize() + rawData.GetSize();
+	iInfHdr.iLogSize = crashSize;
+	iInfHdr.iCrashId = CRASH_ID;
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	memDump.Serialize(writer);
+	rawData.Serialize(writer);
+	
+	INFO_PRINTF1(_L("Writing known memory to flash"));
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
+	
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to analyse crash: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	RBuf8 found;
+	found.CreateL(mem.Length());
+	found.CleanupClosePushL();
+	
+	
+	//We read memory by thread ID. So we will create an arbitrary thread and assign it to belong to the
+	//process ID we have dumped memory for
+	TInt64 threadId = 23;
+	iObject->AssignOwner(procId, threadId);
+	
+	TRAP(err, iObject->ReadMemoryL(threadId, startAdd, mem.Length(), found));
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to read memory: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+	
+	for(TInt cnt = found.Length() -1; cnt >= 0; cnt--)
+		{
+		if(found[cnt] != memoryToDump)
+			{
+			ERR_PRINTF2(_L("Wrong memory returned = [0x%X]"),found[cnt]);
+			SetBlockResult(EFail);
+			CleanupStack::PopAndDestroy(3);
+			return;
+			}
+		}	
+	
+	INFO_PRINTF1(_L("Got back all memory as expected"));
+		
+	CleanupStack::PopAndDestroy(3);
+	}
+
+/** 
+ * Negative Tests to see we can handle dodgy params
+ */
+void CFlashDataSourceWrapper::DoCmd_ReadMemoryL2_Test_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadMemoryL() Test2"));
+	
+	//buffer to hold memory
+	TInt32 numBytes = 8; //we will dump 8 bytes of memory
+	TUint8 memoryToDump = 0xAB;		
+	
+	RBuf8 mem;
+	mem.CreateL(numBytes * sizeof(TUint8));	
+	mem.CleanupClosePushL();
+	
+	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
+		{
+		mem.Append(&memoryToDump, sizeof(TUint8));
+		}
+	
+	//buffer to hold log
+	TInt dataLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + TRegisterSet::KSCMRegisterSetMaxSize + numBytes + TMemoryDump::KSCMMemDumpMaxSize + TRawData::KSCMRawDataMaxSize;
+	
+	RBuf8 data;	
+	data.CreateL(dataLength);
+	data.SetLength(dataLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
+	
+	TUint32 startAdd = 0x10000000;
+	TUint64 procId = 100;
+	
+	TMemoryDump memDump;
+	memDump.iStartAddress = startAdd;
+	memDump.iPid = procId;
+	memDump.iLength = mem.Length();
+	TRawData rawData;
+	rawData.iLength = mem.Length();	
+	rawData.iData.Set(mem.MidTPtr(0));
+	
+	TInt32 crashSize = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize() + memDump.GetSize() + rawData.GetSize();
+	iInfHdr.iLogSize = crashSize;
+	iInfHdr.iCrashId = CRASH_ID;
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	memDump.Serialize(writer);
+	rawData.Serialize(writer);
+	
+	INFO_PRINTF1(_L("Writing known memory to flash"));
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
+	
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to analyse crash: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	RBuf8 found;
+	found.CreateL(mem.Length());
+	found.CleanupClosePushL();
+	
+	//reading from address not dumped
+	TRAP(err, iObject->ReadMemoryL(procId, 0xDEDEADAD, mem.Length(), found));
+	if(KErrNotFound != err)
+		{
+		ERR_PRINTF2(_L("Able to read memory not dumped: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+	
+	//read from a thread not dumped
+	TRAP(err, iObject->ReadMemoryL(50, startAdd, mem.Length(), found));
+	if(KErrNotFound != err)
+		{
+		ERR_PRINTF2(_L("able to read memory from thread not dumped: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+	
+	INFO_PRINTF1(_L("Got back all memory as expected"));
+		
+	CleanupStack::PopAndDestroy(3);
+	}
+
+/** 
+ * 	Tests CFlashDataSource::GetCodeSegmentsL
+ *  Writes known code segments to flash and ensures we can get them back
+ *  
+ *  Description:
+ *  We will pretend we have a process ID of 100. We will also have a thread ID of 101.
+ *  We will assign ownership between these two - ie. thread ID 101 exists in process ID 100.
+ *  We will write a mini crash log to flash:
+ *  <---Crash Header---><---Code Segment Set---><---Code Segment 1---><---Code Segment 2--->
+ *  
+ *  The code segments will exist for process ID 100. We will then try to read the code segments 
+ *  for thread ID 101 and we should retrieve code seg 1 and 2.
+ *  
+ */
+void CFlashDataSourceWrapper::DoCmd_GetCodeSegmentsL1_Test_L()
+	{		
+	INFO_PRINTF1(_L("Testing CFlashDataSource::GetCodeSegmentsL() - 1st test"));	
+	
+	TUint64 procId = 100; //arbitrary	
+	TInt numSegs = 2;
+	
+	TCodeSegmentSet segSet;
+	segSet.iNumSegs = 2;
+	segSet.iPid = procId;
+	segSet.iNumSegs = numSegs;
+	
+	//seg names
+	_LIT8(KSeg1, "seg1");
+	_LIT8(KSeg2, "cseg2");
+	
+
+	//buffer for data
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
+						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TCodeSegment::KMaxSegmentNameSize + 
+						KMaxCacheSize;
+	
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
+	
+	TCodeSegment seg1;
+	seg1.iNameLength = KSeg1().Size();
+	seg1.iName = KSeg1;
+	seg1.iCodeSegType = EExeCodeSegType;
+	
+	TCodeSegment seg2;
+	seg2.iNameLength = KSeg2().Size();
+	seg2.iName = KSeg2;
+	seg2.iCodeSegType = EExeCodeSegType;
+	
+	//For code segments to make sense we need to assign thread to process ownership
+	TInt64 threadId = 101;
+	iObject->AssignOwner(procId, threadId); 
+	
+	iInfHdr.iCrashId = CRASH_ID;	
+	iContextHdr.iNumRegisters = 0; //no context
+	iInfHdr.iLogSize = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize() + segSet.GetSize() + seg1.GetSize() + seg2.GetSize();		
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	segSet.Serialize(writer);
+	seg1.Serialize(writer);
+	seg2.Serialize(writer);
+	
+	INFO_PRINTF1(_L("Writing known Code Segs to flash"));
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));	
+
+	//Now we try get these threads back via GetCodeSegmentsL
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy();
+		return;
+		}
+	
+	RCodeSegPointerList* list = new(ELeave)RCodeSegPointerList;
+	TCleanupItem segCleanup(CFlashDataSource::CleanupCodeSegList, (TAny*)list);
+	CleanupStack::PushL(segCleanup);
+	
+	TUint sz = 0;
+	TRAP(err, iObject->GetCodeSegmentsL(threadId, *list, sz));
+	
+	if(list->Count() != numSegs)
+		{
+		ERR_PRINTF3(_L("Failed to retrieve right amount of code segs. Expected [%d] got [%d]"),numSegs, list->Count());
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	TCodeSegInfo* cs1 = (*list)[0];
+	TCodeSegInfo* cs2 = (*list)[1];
+	
+	INFO_PRINTF1(_L("Retrieveing code segs"));
+	if(!cs1 || !cs2)
+		{
+		ERR_PRINTF1(_L("Failed to retrieve non null threads"));
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	//Check types
+	INFO_PRINTF1(_L("Checking code seg types are ok"));
+	if(cs1->iType != EExeCodeSegType ||  cs2->iType != EExeCodeSegType)
+		{
+		ERR_PRINTF1(_L("Failed to retrieve correct code seg types:"));
+		ERR_PRINTF3(_L("CS1 expected [%d] but found [%d]"), EExeCodeSegType, cs1->iType);
+		ERR_PRINTF3(_L("CS2 expected [%d] but found [%d]"), EExeCodeSegType, cs2->iType);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(2);
+		return;
+		}
+	
+	//check names
+	RBuf wide;	
+	wide.CreateL(KSeg1().Size());
+	wide.CleanupClosePushL();	
+	wide.Copy(KSeg1);
+	
+	INFO_PRINTF1(_L("Checking code seg name's are ok"));
+	
+	TBool passed = (cs1->iName.Compare(wide) == 0) || (cs2->iName.Compare(wide) == 0);
+	
+	if(!passed)
+		{
+		ERR_PRINTF4(_L("Wrong name retrieved, expected [%S] but got [%S] and [%S]"), &wide, &cs2->iName, &cs1->iName);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+	
+	if(2 *KSeg2().Size() > wide.Size())
+		{
+		wide.ReAllocL(2 * KSeg2().Size());
+		}
+	
+	wide.Copy(KSeg2);
+	
+	INFO_PRINTF1(_L("Checking second code seg name is ok"));
+	
+	passed = (cs1->iName.Compare(wide) == 0) || (cs2->iName.Compare(wide) == 0);
+	
+	if(!passed)
+		{
+		ERR_PRINTF4(_L("Wrong name retrieved, expected [%S] but got [%S] and [%S]"), &wide, &cs2->iName, &cs1->iName);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+	
+	CleanupStack::PopAndDestroy(3);
+	
+	}
+
+/**
+ *  Tests CFlashDataSource::GetCodeSegmentsL
+ *  Ensure we recognise corrupt segments (ie. no segment set to describe it)
+ */
+void CFlashDataSourceWrapper::DoCmd_GetCodeSegmentsL2_Test_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource() - Code Segment Analysis - 2nd test"));
+	
+	//seg names
+	_LIT8(KSeg1, "seg1");
+	_LIT8(KSeg2, "cseg2");	
+
+	//buffer for data
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
+						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TCodeSegment::KMaxSegmentNameSize + 
+						KMaxCacheSize;
+	
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
+	
+	TCodeSegment seg1;
+	seg1.iNameLength = KSeg1().Size();
+	seg1.iName = KSeg1;
+	seg1.iCodeSegType = EExeCodeSegType;
+	
+	TCodeSegment seg2;
+	seg2.iNameLength = KSeg2().Size();
+	seg2.iName = KSeg2;
+	seg2.iCodeSegType = EExeCodeSegType;
+	
+	iInfHdr.iCrashId = CRASH_ID;	
+	iContextHdr.iNumRegisters = 0; //no context
+	iInfHdr.iLogSize = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize()+ seg1.GetSize() + seg2.GetSize();		
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	seg1.Serialize(writer);
+	seg2.Serialize(writer);
+	
+	INFO_PRINTF1(_L("Writing known corrupt Code Segs to flash"));
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));	
+
+	//Now we try get these threads back via GetCodeSegmentsL
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
+	if(KErrCorrupt != err)
+		{
+		ERR_PRINTF2(_L("Failed to recognise corrupt data: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy();
+		return;
+		}
+	
+	CleanupStack::PopAndDestroy();
+	
+	INFO_PRINTF1(_L("Corrupt data recognised"));
+	}
+
+
+
+/**
+ *  Tests CFlashDataSource::GetCodeSegmentsL
+ *  Ensure we do not reciev duplicate segments 
+ * even after we place then in flash
+ */
+void CFlashDataSourceWrapper::DoCmd_GetCodeSegmentsL3_Test_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource() - Code Segment Analysis - 3rd test"));
+	
+	TUint64 procId = 100; //arbitrary	
+	const TInt KNumRepeatSegs = 3;
+	
+	TCodeSegmentSet segSet;
+	segSet.iNumSegs = KNumRepeatSegs;
+	segSet.iPid = procId;
+	
+	//seg names
+	_LIT8(KSeg1, "seg1");
+	
+	//buffer for data
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
+						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TCodeSegment::KMaxSegmentNameSize + 
+						KMaxCacheSize;
+	
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
+	
+	TCodeSegment seg1;
+	seg1.iNameLength = KSeg1().Size();
+	seg1.iName = KSeg1;
+	seg1.iCodeSegType = EExeCodeSegType;
+	
+	
+	//For code segments to make sense we need to assign thread to process ownership
+	TInt64 threadId = 101;
+	iObject->AssignOwner(procId, threadId); 
+	
+	iInfHdr.iCrashId = CRASH_ID;	
+	iContextHdr.iNumRegisters = 0; //no context
+	
+	
+	iInfHdr.iLogSize = 
+		iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize() 
+		+ segSet.GetSize() + ( seg1.GetSize() * KNumRepeatSegs);		
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	segSet.Serialize(writer);
+	
+	// serialize the same segment a number of times
+	for(TInt i=0;i<segSet.iNumSegs;i++)
+		{
+		seg1.Serialize(writer);
+		}
+	
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));	
+
+	//Now we try get these threads back via GetCodeSegmentsL
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy();
+		return;
+		}
+	
+	RCodeSegPointerList* list = new(ELeave)RCodeSegPointerList;
+	TCleanupItem segCleanup(CFlashDataSource::CleanupCodeSegList, (TAny*)list);
+	CleanupStack::PushL(segCleanup);
+	
+	TUint sz = 0;
+	TRAP(err, iObject->GetCodeSegmentsL(threadId, *list, sz));
+	
+	
+	// loop through the code seg list check that none are the same
+	for(TInt i=0;i<list->Count();i++)
+		{
+		TCodeSegInfo* csinf1 = (*list)[i];			
+		for(TInt j=1;j<list->Count();j++)
+			{
+			TCodeSegInfo* csinf2 = (*list)[j];
+			
+			// check not checking same item
+			if( csinf1 != csinf2 )
+				{
+				if(csinf1->iDataRunAddr == csinf2->iDataRunAddr && 
+				   csinf1->iDataSize == csinf2->iDataSize )
+					{
+					ERR_PRINTF1(_L("DUPLICATE code segs 1") );
+					SetBlockResult(EFail);
+					CleanupStack::PopAndDestroy(2);
+					return;
+					
+					}
+				}
+			}	
+		}
+	
+	CleanupStack::PopAndDestroy(2);  // data , list
+	}
+
+/**
+ * Tests we can get ALL expected trace data back
+ */
+void CFlashDataSourceWrapper::DoCmd_ReadTraceBufferL1_Test_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadTraceBufferL() Test1"));
+	
+	//buffer to hold trace - will do in 2 parts to simulate the circular buffer
+	TInt32 numBytes = 8; //we will dump 8 bytes of trace
+	TUint8 traceToDump1 = 0xAB;
+	TUint8 traceToDump2 = 0xCD;
+	
+	RBuf8 trace1;
+	trace1.CreateL(numBytes * sizeof(TUint8));	
+	trace1.CleanupClosePushL();
+		
+	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
+		{
+		trace1.Append(&traceToDump1, sizeof(TUint8));
+		}
+	
+	RBuf8 trace2;
+	trace2.CreateL(numBytes * sizeof(TUint8));	
+	trace2.CleanupClosePushL();
+	
+	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
+		{
+		trace2.Append(&traceToDump2, sizeof(TUint8));
+		}
+	
+	//buffer to hold log
+	TInt dataLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + 
+							TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
+							TRegisterSet::KSCMRegisterSetMaxSize +							 
+							TTraceDump::KSCMTraceDumpMaxSize + 
+							2 * (TRawData::KSCMRawDataMaxSize + numBytes);
+	
+	RBuf8 data;	
+	data.CreateL(dataLength);
+	data.SetLength(dataLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);	
+	
+	TTraceDump traceDump;
+	traceDump.iSizeOfMemory = 2 * numBytes;
+	traceDump.iNumberOfParts = 2;
+	
+	TRawData rawData1;
+	rawData1.iLength = trace1.Length();	
+	rawData1.iData.Set(trace1.MidTPtr(0));
+	
+	TRawData rawData2;
+	rawData2.iLength = trace2.Length();	
+	rawData2.iData.Set(trace2.MidTPtr(0));
+	
+	TInt32 crashSize = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize() + traceDump.GetSize() + rawData1.GetSize() + rawData2.GetSize();
+	iInfHdr.iLogSize = crashSize;
+	iInfHdr.iCrashId = CRASH_ID;
+	iOffsetsHdr.iTraceOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize();
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	traceDump.Serialize(writer);
+	rawData1.Serialize(writer);
+	rawData2.Serialize(writer);
+	
+	INFO_PRINTF1(_L("Writing known trace to flash"));
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
+	
+	//Now we try get the trace data back
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
+	
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+		
+	TUint traceBufferAvailable = 0;
+	
+	TRAP(err, traceBufferAvailable = iObject->GetAvailableTraceSizeL());
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to read trace data size: [%d]"), err);
+		SetBlockResult(EFail);		
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+	
+	RBuf8 found;
+	found.CreateL(traceBufferAvailable);
+	found.CleanupClosePushL();
+	
+	//reading from address not dumped	
+	TRAP(err, iObject->ReadTraceBufferL(found));
+	
+	RDebug::Printf("Printing trace found");
+	for(TInt x = 0; x<found.Length(); x++)
+		{			
+		RDebug::Printf("[0x%X]", found[x]);
+		}
+	
+	RBuf8 totalTrace;
+	totalTrace.CreateL(trace1.Length() + trace2.Length());
+	totalTrace.CleanupClosePushL();
+	
+	totalTrace.Append(trace1);
+	totalTrace.Append(trace2);
+	
+	if(totalTrace.Compare(found) != 0)
+		{
+		ERR_PRINTF1(_L("Found trace did not match expected trace"));
+		SetBlockResult(EFail);		
+		CleanupStack::PopAndDestroy(5);
+		return;
+		}
+	
+	CleanupStack::PopAndDestroy(5);
+	}
+
+void CFlashDataSourceWrapper::DoCmd_CalculateChecksum_TestL()
+  	{  	
+  	// check sum is commutative - so it should add up to same value
+  	// however blocks were requested
+  	
+	INFO_PRINTF1(_L("DoCmd_CalculateChecksum_TestL called"));
+  	
+  	TScmChecksum chksm1, chksm2;  	
+  
+  	iObject->CalculateChecksumL(0, 10, chksm1);
+  	iObject->CalculateChecksumL(10, 10, chksm1);  	  	
+  	iObject->CalculateChecksumL(0, 20, chksm2);  	
+  	
+  	SetBlockResult((chksm1 == chksm2) ? EPass : EFail );  	  	
+  	}
+
+/**
+ * Tests we can get back the correct trace buffer size
+ */
+void CFlashDataSourceWrapper::DoCmd_TraceDataSizeL_TestL()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource() - Trace Size Test"));
+
+	//buffer for data
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
+						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TCodeSegment::KMaxSegmentNameSize + 
+						KMaxCacheSize;
+	
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
+	
+	TUint memSize = 1243;
+	TTraceDump trace;
+	trace.iSizeOfMemory = memSize;
+	
+	iInfHdr.iCrashId = CRASH_ID;	
+	iContextHdr.iNumRegisters = 0; //no context
+	iInfHdr.iLogSize = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize()+ trace.GetSize();		
+	iOffsetsHdr.iTraceOffset = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize();
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	trace.Serialize(writer);
+	
+	INFO_PRINTF1(_L("Writing known trace struct to flash"));
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));	
+
+	//Now we try get these threads back via GetCodeSegmentsL
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to analyse crash: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy();
+		return;
+		}
+	
+	CleanupStack::PopAndDestroy();
+	
+	TUint recoveredMemSize = 0;
+	TRAP(err, recoveredMemSize = iObject->GetAvailableTraceSizeL());
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to get back trace size: [%d]"), err);
+		SetBlockResult(EFail);
+		return;
+		}
+	
+	if(recoveredMemSize != memSize)
+		{
+		ERR_PRINTF3(_L("Failed to get back correct trace size: Got [%d] Expected [%d]"), recoveredMemSize, memSize);
+		SetBlockResult(EFail);
+		return;
+		}
+	
+	INFO_PRINTF1(_L("Trace size looks good"));
+	}
+
+/**
+ * Tests we can get back the correct trace buffer size
+ */
+void CFlashDataSourceWrapper::DoCmd_TraceDataSizeNotFoundL_TestL()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource() - Trace Size Test - Negative"));
+
+	//buffer for data
+	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
+						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TCodeSegment::KMaxSegmentNameSize + 
+						KMaxCacheSize;
+	
+	RBuf8 data;	
+	data.CreateL(bufLength);
+	data.SetLength(bufLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);
+	
+	iInfHdr.iCrashId = CRASH_ID;	
+	iContextHdr.iNumRegisters = 0; //no context
+	iInfHdr.iLogSize = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize();		
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);	
+	
+	INFO_PRINTF1(_L("Writing known trace struct to flash"));
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));	
+
+	//Now we try get these threads back via GetCodeSegmentsL
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to analyse crash: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy();
+		return;
+		}
+	
+	CleanupStack::PopAndDestroy();
+		
+	TRAP(err, TUint recoveredMemSize = iObject->GetAvailableTraceSizeL());
+	if(KErrNotFound != err)
+		{
+		ERR_PRINTF2(_L("Failed to get back KErrNone for non available trace size: [%d]"), err);
+		SetBlockResult(EFail);
+		return;
+		}
+	
+	INFO_PRINTF1(_L("All as expected."));
+	}
+
+/**
+ * Tests we can get ALL expected trace data back
+ */
+void CFlashDataSourceWrapper::DoCmd_ReadTraceBufferL2_Test_L()
+	{
+	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadTraceBufferL() Test2"));
+	
+	//buffer to hold trace - will do in 2 parts to simulate the circular buffer
+	TInt32 numBytes = 8; //we will dump 8 bytes of trace
+	TUint8 traceToDump1 = 0xAB;
+	TUint8 traceToDump2 = 0xCD;
+	
+	RBuf8 trace1;
+	trace1.CreateL(numBytes * sizeof(TUint8));	
+	trace1.CleanupClosePushL();
+		
+	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
+		{
+		trace1.Append(&traceToDump1, sizeof(TUint8));
+		}
+	
+	RBuf8 trace2;
+	trace2.CreateL(numBytes * sizeof(TUint8));	
+	trace2.CleanupClosePushL();
+	
+	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
+		{
+		trace2.Append(&traceToDump2, sizeof(TUint8));
+		}
+	
+	//buffer to hold log
+	TInt dataLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + 
+							TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
+							TRegisterSet::KSCMRegisterSetMaxSize +							 
+							TTraceDump::KSCMTraceDumpMaxSize + 
+							2 * (TRawData::KSCMRawDataMaxSize + numBytes);
+	
+	RBuf8 data;	
+	data.CreateL(dataLength);
+	data.SetLength(dataLength);
+	data.CleanupClosePushL();
+	
+	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);	
+	
+	TTraceDump traceDump;
+	traceDump.iSizeOfMemory = 2 * numBytes;
+	traceDump.iNumberOfParts = 2;
+	
+	TRawData rawData1;
+	rawData1.iLength = trace1.Length();	
+	rawData1.iData.Set(trace1.MidTPtr(0));
+	
+	TRawData rawData2;
+	rawData2.iLength = trace2.Length();	
+	rawData2.iData.Set(trace2.MidTPtr(0));
+	
+	TInt32 crashSize = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize() + traceDump.GetSize() + rawData1.GetSize() + rawData2.GetSize();
+	iInfHdr.iLogSize = crashSize;
+	iInfHdr.iCrashId = CRASH_ID;
+	iOffsetsHdr.iTraceOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize();
+	
+	iInfHdr.Serialize(writer);
+	iOffsetsHdr.Serialize(writer);
+	iContextHdr.Serialize(writer);
+	traceDump.Serialize(writer);
+	rawData1.Serialize(writer);
+	rawData2.Serialize(writer);
+	
+	INFO_PRINTF1(_L("Writing known trace to flash"));
+	
+	TUint32 written = 0;
+	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
+	
+	//Now we try get the trace data back
+	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
+	
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
+		SetBlockResult(EFail);
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+		
+	TUint traceBufferAvailable = 0;
+	
+	TRAP(err, traceBufferAvailable = iObject->GetAvailableTraceSizeL());
+	if(KErrNone != err)
+		{
+		ERR_PRINTF2(_L("Unable to read trace data size: [%d]"), err);
+		SetBlockResult(EFail);		
+		CleanupStack::PopAndDestroy(3);
+		return;
+		}
+	
+	RBuf8 totalTrace;
+	totalTrace.CreateL(trace1.Length() + trace2.Length());
+	totalTrace.CleanupClosePushL();
+	
+	totalTrace.Append(trace1);
+	totalTrace.Append(trace2);
+	
+	//Read 1 byte at a time
+	RBuf8 read;
+	read.CreateL(1);
+	read.CleanupClosePushL();
+	
+	for(TInt x = 0; x< traceBufferAvailable; x++)
+		{
+		TRAP(err, iObject->ReadTraceBufferL(read, x));
+		if(err != KErrNone)
+			{
+			ERR_PRINTF2(_L("Unable to read trace data: [%d]"), err);
+			SetBlockResult(EFail);		
+			CleanupStack::PopAndDestroy(5);
+			return;
+			}
+		
+		RDebug::Printf("Found [0x%X] expected [0x%X]", read[0], totalTrace[x]);
+		
+		if(read[0] != totalTrace[x])
+			{
+			ERR_PRINTF1(_L("Didnt get back expected trace"));
+			SetBlockResult(EFail);		
+			CleanupStack::PopAndDestroy(5);
+			return;
+			}
+		}
+	
+	CleanupStack::PopAndDestroy(5);
+	}
+
+//eof
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/cds/CSelfLibWrapper.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,831 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  Test wrapper for unit tests of the sELF lib
+
+/**
+ * @file CSELFLibWrapper.cpp
+ * @internalTechnology
+ */
+
+#include <f32file.h>
+#include <bautils.h>
+
+#include "CSELFLibWrapper.h"
+
+CSELFLibWrapper::CSELFLibWrapper()
+	{}
+
+CSELFLibWrapper::~CSELFLibWrapper()
+	{
+	iFs.Close();
+	}
+
+/**
+ * Two phase constructor for CFlashDataSourceWrapper
+ * @return CFlashDataSourceWrapper object
+ * @leave
+ */
+CSELFLibWrapper* CSELFLibWrapper::NewL()
+	{
+	CSELFLibWrapper* ret = new (ELeave) CSELFLibWrapper();
+	CleanupStack::PushL(ret);
+	ret->ConstructL();
+	CleanupStack::Pop(ret);
+	return ret;
+	}
+
+/**
+ * Safe construction
+ * @leave
+ */
+void CSELFLibWrapper::ConstructL()
+	{
+	User::LeaveIfError(iFs.Connect());
+	}
+
+/**
+ * Process command to see what test to run
+ */
+TBool CSELFLibWrapper::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
+	{
+	__UHEAP_MARK;
+
+	(void)aSection;
+	(void)aAsyncErrorIndex;
+
+	RBuf8 name;
+	name.CreateL(aCommand.Length());
+	name.Copy(aCommand);
+	RDebug::Printf("\nNext Test Case... [%S]", &name);
+	name.Close();
+
+	if(KSELFNewL() == aCommand)
+		TestNewL_L();
+	else if(KSELFNewLC() == aCommand)
+		TestNewLC_L();
+	else if(KSELF_InvalidSignature() == aCommand)
+		TestConstruction_InvalidELF_SignatureL();
+	else if(KSELF_InvalidSize() == aCommand)
+		TestConstruction_InvalidELF_SizeL();
+	else if(KSELF_NotSupported() == aCommand)
+		TestConstruction_ValidELF_NotSupported();
+	else if(KSELF_TestConstruction_Inuse() == aCommand)
+		TestConstruction_Inuse();
+	else if(KSELF_GetElfHeaderL() == aCommand)
+		TestGetElfHeaderL();
+	else if(KSELF_InsertVariantSpecificData() == aCommand)
+		TestInsertDataL();
+	else if(KSELF_InsertMultipleVariants() == aCommand)
+		TestMultipleInsertionL();
+	else if(KSELF_InsertNothingAndUpdate() == aCommand)
+		TestInsertNothingL();
+	else if(KSELF_TestPerformance() == aCommand)
+		TestPerformanceL();
+	else if(KSELF_TestStress() == aCommand)
+		TestStressL();
+	else if(KPrepareFiles() == aCommand)
+		CopyFilesToWritablePlaceL();
+	else if(KTearDownFiles() == aCommand)
+		TearDownFilesL();
+
+	__UHEAP_MARKEND;
+
+	return ETrue;
+	}
+
+/**
+ * Unit test for:
+ * CSELFEditor* CSELFEditor::NewL()
+ * @see CSELFEditor
+ */
+void CSELFLibWrapper::TestNewL_L()
+	{
+	INFO_PRINTF1(_L("Testing CSELFEditor::NewL"));
+
+	//Try a file we know does not exist
+	CSELFEditor* editor = NULL;
+	TRAPD(err, editor = CSELFEditor::NewL(KSELFFileNameNonExistant()));
+
+	INFO_PRINTF3(_L("CSELFEditor::NewL(%S) returns [%d]"), &KSELFFileNameNonExistant, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNotFound == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor == NULL, 0);
+
+	//Try a file we know does exist
+	TRAP(err, editor = CSELFEditor::NewL(KSELFFileName()));
+
+	INFO_PRINTF3(_L("CSELFEditor::NewL(%S) returns [%d]"), &KSELFFileName, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor != NULL, 0);
+
+	delete editor;
+	editor = NULL;
+
+#ifdef _DEBUG		//__UHEAP_FAILNEXT won't work on urel
+
+	//Try with an allocation fail
+	__UHEAP_FAILNEXT(1);
+	TRAP(err, editor = CSELFEditor::NewL(KSELFFileName()));
+
+	INFO_PRINTF3(_L("CSELFEditor::NewL(%S) returns [%d] (with __UHEAP_FAILNEXT)"), &KSELFFileName, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNoMemory == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor == NULL, 0);
+
+#endif
+	}
+
+/**
+ * Unit test for:
+ * CSELFEditor* CSELFEditor::NewLC()
+ * @see CSELFEditor
+ */
+void CSELFLibWrapper::TestNewLC_L()
+	{
+ 	INFO_PRINTF1(_L("Testing CSELFEditor::NewLC"));
+
+	//Try a file we know does not exist
+	CSELFEditor* editor = NULL;
+	TRAPD(err, editor = CSELFEditor::NewLC(KSELFFileNameNonExistant()); CleanupStack::Pop(););
+
+	INFO_PRINTF3(_L("CSELFEditor::NewLC(%S) returns [%d]"), &KSELFFileNameNonExistant, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNotFound == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor == NULL, 0);
+
+	//Try a file we know does exist
+	TRAP(err, editor = CSELFEditor::NewLC(KSELFFileName()); CleanupStack::Pop(););
+
+	INFO_PRINTF3(_L("CSELFEditor::NewLC(%S) returns [%d]"), &KSELFFileName, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor != NULL, 0);
+
+	delete editor;
+	editor = NULL;
+
+#ifdef _DEBUG			//__UHEAP_FAILNEXT won't work on urel
+
+	//Try with an allocation fail
+	__UHEAP_FAILNEXT(1);
+	TRAP(err, editor = CSELFEditor::NewLC(KSELFFileName()); CleanupStack::Pop());
+
+	INFO_PRINTF3(_L("CSELFEditor::NewLC(%S) returns [%d] (with __UHEAP_FAILNEXT)"), &KSELFFileName, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNoMemory == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor == NULL, 0);
+
+#endif
+	}
+
+/**
+ * Unit test for:
+ * CSELFEditor::InsertVariantSpecificDataL()
+ * @see CSELFEditor
+ */
+void CSELFLibWrapper::TestInsertDataL()
+	{
+	INFO_PRINTF1(_L("Testing CSELFEditor Insert Variant Sepcific data"));
+
+	//Get the number of variant data segments there before
+	TInt prenumsegments = GetNumberofVariantSegmentsL(KSELFFileName());
+	INFO_PRINTF2(_L("There are [0x%X] variant data segments before the test"), prenumsegments);
+
+	CSELFEditor* editor = NULL;
+	TRAPD(err, editor = CSELFEditor::NewL(KSELFFileName()));
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor != NULL, 0);
+
+	CleanupStack::PushL(editor);
+
+	INFO_PRINTF1(_L("Inserting the variant specific"));
+	TRAP(err, editor->InsertVariantSpecificDataL(KTestData1()));
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 2);
+
+	TRAP(err, editor->InsertVariantSpecificDataL(KTestData2()));
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 2);
+
+	TRAP(err, editor->InsertVariantSpecificDataL(KTestData3()));
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 2);
+
+	INFO_PRINTF1(_L("Updating the ELF file"));
+	TRAP(err, editor->WriteELFUpdatesL());
+
+	INFO_PRINTF2(_L("ELF File updating returned [%d]"), err);
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 2);
+
+	CleanupStack::PopAndDestroy(editor);
+
+	TInt postnumsegments = GetNumberofVariantSegmentsL(KSELFFileName());
+	INFO_PRINTF2(_L("There are [0x%X] variant data segments after the test"),postnumsegments);
+
+	T_SELFLIB_ASSERT_TRUE(prenumsegments + 3 == postnumsegments, 0);
+
+	TInt bufferRequired = GetVariantSegmentSizeL(postnumsegments - 1, KSELFFileName());
+	RBuf8 data;
+	data.CreateL(bufferRequired);
+	data.CleanupClosePushL();
+
+	TRAP(err, GetVariantSegmentDataL(postnumsegments - 1, data, KSELFFileName()));
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 1);
+	T_SELFLIB_ASSERT_TRUE(0 == KTestData3().Compare(data), 1);
+
+	TRAP(err, GetVariantSegmentDataL(postnumsegments - 2, data, KSELFFileName()));
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 1);
+	T_SELFLIB_ASSERT_TRUE(0 == KTestData2().Compare(data), 1);
+
+	TRAP(err, GetVariantSegmentDataL(postnumsegments - 3, data, KSELFFileName()));
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 1);
+	T_SELFLIB_ASSERT_TRUE(0 == KTestData1().Compare(data), 1);
+
+	INFO_PRINTF1(_L("Data looks good"));
+
+	CleanupStack::PopAndDestroy(&data);
+	}
+
+/**
+ * Tests that you can't have mutliple CSELFEditors open on the same ELF file
+ * @see CSELFEditor
+ */
+void CSELFLibWrapper::TestConstruction_Inuse()
+	{
+	INFO_PRINTF1(_L("Testing CSELFEditor multiple handles"));
+
+	CSELFEditor* handle1 = NULL;
+	CSELFEditor* handle2 = NULL;
+
+	//Open one handle
+	TRAPD(err, handle1 = CSELFEditor::NewL(KSELFFileName()));
+
+	INFO_PRINTF3(_L("CSELFEditor::NewL(%S) returns [%d]"), &KSELFFileName, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 0);
+	T_SELFLIB_ASSERT_TRUE(handle1 != NULL, 0);
+
+	//Try handle two
+	TRAP(err, handle2 = CSELFEditor::NewL(KSELFFileName()));
+
+	INFO_PRINTF3(_L("CSELFEditor::NewL(%S) returns [%d] (this is the second handle)"), &KSELFFileName, err);
+	T_SELFLIB_ASSERT_TRUE(KErrInUse == err, 0);
+	T_SELFLIB_ASSERT_TRUE(handle2 == NULL, 0);
+
+	delete handle1;
+	}
+
+/**
+ * Unit test for:
+ * CSELFEditor::NewL
+ * Tests with an invalid ELF file. This is invalid due to its signature
+ * @see CSELFEditor
+ */
+void CSELFLibWrapper::TestConstruction_InvalidELF_SignatureL()
+	{
+	INFO_PRINTF1(_L("Testing CSELFEditor construction with an invalid file - bad signature"));
+
+	//Create an ELF file editor
+	CSELFEditor* editor = NULL;
+	TRAPD(err, editor = CSELFEditor::NewL(KSELFFileNameInvalidBySignature()));
+
+	INFO_PRINTF3(_L("Opening [%S] returned [%d]"), &KSELFFileNameInvalidBySignature, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrCorrupt == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor == NULL, 0);
+
+#ifdef _DEBUG		//__UHEAP_FAILNEXT won't work on urel
+
+	//Try it again with a failed memory alloc
+	__UHEAP_FAILNEXT(1);
+
+	TRAP(err, editor = CSELFEditor::NewL(KSELFFileNameInvalidBySignature()));
+
+	INFO_PRINTF3(_L("Opening [%S] returned [%d] (with __UHEAP_FAILNEXT)"), &KSELFFileNameInvalidBySignature, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNoMemory == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor == NULL, 0);
+
+#endif
+	}
+
+/**
+ * There are valid ELF files that the ELF lib won't support (mainly) none Core files
+ * This tests that it throws a KErrNotSupported.
+ * @see CSELFEditor
+ */
+void CSELFLibWrapper::TestConstruction_ValidELF_NotSupported()
+	{
+	INFO_PRINTF1(_L("Testing CSELFEditor construction with an valid file but unsupported"));
+
+	//Create an ELF file editor
+	CSELFEditor* editor = NULL;
+	TRAPD(err, editor = CSELFEditor::NewL(KSELFFileNameExe()));
+
+	INFO_PRINTF3(_L("Opening [%S] returned [%d]"), &KSELFFileNameExe, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNotSupported == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor == NULL, 0);
+	}
+
+/**
+ * Unit test for:
+ * CSELFEditor::NewL
+ * Tests with an invalid ELF file. This is invalid due to its size
+ * @see CSELFEditor
+ */
+void CSELFLibWrapper::TestConstruction_InvalidELF_SizeL()
+	{
+	INFO_PRINTF1(_L("Testing CSELFEditor construction with an invalid file - bad size"));
+
+	//Create an ELF file editor
+	CSELFEditor* editor = NULL;
+	TRAPD(err, editor = CSELFEditor::NewL(KSELFFileNameTiny()));
+
+	INFO_PRINTF3(_L("Opening [%S] returned [%d]"), &KSELFFileNameTiny, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrCorrupt == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor == NULL, 0);
+
+#ifdef _DEBUG			//__UHEAP_FAILNEXT won't work on urel
+
+	//Try it again with a failed memory alloc
+	__UHEAP_FAILNEXT(1);
+
+	TRAP(err, editor = CSELFEditor::NewL(KSELFFileNameTiny()));
+
+	INFO_PRINTF3(_L("Opening [%S] returned [%d] (with __UHEAP_FAILNEXT)"), &KSELFFileNameTiny, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNoMemory == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor == NULL, 0);
+
+#endif	
+	}
+
+/**
+ * Unit test for:
+ * CSELFEditor::GetElfHeaderL()
+ * @see CSELFEditor
+ */
+void CSELFLibWrapper::TestGetElfHeaderL()
+	{
+	INFO_PRINTF1(_L("Testing CSELFEditor::GetElfHeaderL()"));
+
+	//Try a file we know does exist
+	CSELFEditor* editor = NULL;
+	TRAPD(err, editor = CSELFEditor::NewL(KSELFFileName()));
+
+	INFO_PRINTF3(_L("CSELFEditor::NewL(%S) returns [%d]"), &KSELFFileName, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor != NULL, 0);
+
+	CleanupStack::PushL(editor);
+
+	Elf32_Ehdr header;
+	editor->GetELFHeader(header);
+
+	LogELFHeader(header);
+
+	//Assert on the values we can be sure of to be sure potatoes
+	T_SELFLIB_ASSERT_TRUE(header.e_type == ET_CORE, 1);
+	T_SELFLIB_ASSERT_TRUE(header.e_version == EV_CURRENT, 1);
+	T_SELFLIB_ASSERT_TRUE(header.e_machine == EM_ARM, 1);
+	T_SELFLIB_ASSERT_TRUE(header.e_entry == 0, 1);
+	T_SELFLIB_ASSERT_TRUE(header.e_ehsize == sizeof(Elf32_Ehdr), 1);
+	T_SELFLIB_ASSERT_TRUE(header.e_phnum > 0, 1);
+
+	CleanupStack::PopAndDestroy(editor);
+	}
+
+/**
+ * Test we can insert more than one variant specific segment
+ * @leave One of the system wide codes
+ */
+void CSELFLibWrapper::TestMultipleInsertionL()
+	{
+	INFO_PRINTF1(_L("Testing CSELFEditor Insert Multiple Variant Sepcific data"));
+
+	//Get the number of variant data segments there before
+	TInt prenumsegments = GetNumberofVariantSegmentsL(KSELFFileName());
+	INFO_PRINTF2(_L("There are [0x%X] variant data segments before the test"), prenumsegments);
+
+	CSELFEditor* editor = NULL;
+	TRAPD(err, editor = CSELFEditor::NewL(KSELFFileName()));
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 0);
+	T_SELFLIB_ASSERT_TRUE(editor != NULL, 0);
+
+	CleanupStack::PushL(editor);
+
+	INFO_PRINTF1(_L("Inserting the variant specific data"));
+	TRAP(err, editor->InsertVariantSpecificDataL(KTestData1()));
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 2);
+
+	INFO_PRINTF1(_L("Updating the ELF file"));
+	TRAP(err, editor->WriteELFUpdatesL());
+
+	INFO_PRINTF2(_L("ELF File updating returned [%d]"), err);
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 2);
+
+	//Write a second time
+	INFO_PRINTF1(_L("Inserting more variant specific data"));
+	TRAP(err, editor->InsertVariantSpecificDataL(KTestData2()));
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 2);
+
+	INFO_PRINTF1(_L("Updating the ELF file"));
+	TRAP(err, editor->WriteELFUpdatesL());
+
+	CleanupStack::PopAndDestroy(editor);
+
+	TInt postnumsegments = GetNumberofVariantSegmentsL(KSELFFileName());
+	INFO_PRINTF2(_L("There are [0x%X] variant data segments after the test"),postnumsegments);
+
+	T_SELFLIB_ASSERT_TRUE(prenumsegments + 2 == postnumsegments, 0);
+
+	TInt bufferRequired = GetVariantSegmentSizeL(postnumsegments - 1, KSELFFileName());
+	RBuf8 data;
+	data.CreateL(bufferRequired);
+	data.CleanupClosePushL();
+
+	TRAP(err, GetVariantSegmentDataL(postnumsegments - 1, data, KSELFFileName()));
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 1);
+	T_SELFLIB_ASSERT_TRUE(0 == KTestData2().Compare(data), 1);
+
+	TRAP(err, GetVariantSegmentDataL(postnumsegments - 2, data, KSELFFileName()));
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 1);
+	T_SELFLIB_ASSERT_TRUE(0 == KTestData1().Compare(data), 1);
+
+	INFO_PRINTF1(_L("Data looks good"));
+
+	CleanupStack::PopAndDestroy(&data);
+
+	}
+
+/**
+ * Adds nothing to the ELF file but calls the update function. Verifies that the
+ * file remains the same
+ * @leave One of the system wide codes
+ */
+void CSELFLibWrapper::TestInsertNothingL()
+	{
+	INFO_PRINTF1(_L("Testing Inserting nothing"));
+
+	//Get size of file before
+	RFile theFile;
+	User::LeaveIfError(theFile.Open(iFs, KSELFFileName(), EFileRead));
+	CleanupClosePushL(theFile);
+
+	TInt previousFileSize = 0;
+	User::LeaveIfError(theFile.Size(previousFileSize));
+	CleanupStack::PopAndDestroy(&theFile);
+
+	INFO_PRINTF2(_L("The test file before is [0x%X] bytes"), previousFileSize);
+
+	CSELFEditor* editor = NULL;
+	TRAPD(err, editor = CSELFEditor::NewL(KSELFFileName()));
+
+	INFO_PRINTF3(_L("CSELFEditor::NewL(%S) returns [%d]"), &KSELFFileName, err);
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 1);
+	T_SELFLIB_ASSERT_TRUE(editor != NULL, 1);
+
+	CleanupStack::PushL(editor);
+
+	//Update having made no updates
+	INFO_PRINTF1(_L("Updating the ELF file"));
+	TRAP(err, editor->WriteELFUpdatesL());
+
+	CleanupStack::PopAndDestroy(editor);
+
+	//Now get the file size again, should be the same
+	TInt currentFileSize = 0;
+	User::LeaveIfError(theFile.Open(iFs, KSELFFileName(), EFileRead));	
+	CleanupClosePushL(theFile);
+
+	User::LeaveIfError(theFile.Size(currentFileSize));
+	INFO_PRINTF2(_L("The test file after is [0x%X] bytes"), currentFileSize);
+
+	CleanupStack::PopAndDestroy(&theFile);
+
+	T_SELFLIB_ASSERT_TRUE(currentFileSize == previousFileSize, 0);
+	}
+
+/**
+ * Logs an ELF header to the test logs
+ * @param aHeader Header to log
+ */
+void CSELFLibWrapper::LogELFHeader(const Elf32_Ehdr& aHeader)
+	{
+ 	INFO_PRINTF1(_L("The ELF Header looks like:"));
+ 	INFO_PRINTF2(_L("\te_type:\t\t0x%X"), aHeader.e_type);
+	INFO_PRINTF2(_L("\te_version:\t0x%X"), aHeader.e_version);
+	INFO_PRINTF2(_L("\te_machine:\t0x%X"), aHeader.e_machine);
+	INFO_PRINTF2(_L("\te_entry:\t0x%X"), aHeader.e_entry);
+	INFO_PRINTF2(_L("\te_phoff:\t0x%X"), aHeader.e_phoff);
+	INFO_PRINTF2(_L("\te_shoff:\t0x%X"), aHeader.e_shoff);
+	INFO_PRINTF2(_L("\te_flags:\t0x%X"), aHeader.e_flags);
+	INFO_PRINTF2(_L("\te_ehsize:\t0x%X"), aHeader.e_ehsize);
+	INFO_PRINTF2(_L("\te_phentsize:\t0x%X"), aHeader.e_phentsize);
+	INFO_PRINTF2(_L("\te_phnum:\t0x%X"), aHeader.e_phnum);
+	INFO_PRINTF2(_L("\te_shentsize:\t0x%X"), aHeader.e_shentsize);
+	INFO_PRINTF2(_L("\te_shnum:\t0x%X"), aHeader.e_shnum);
+	INFO_PRINTF2(_L("\te_shstrndx:\t0x%X"), aHeader.e_shstrndx);
+	}
+
+void CSELFLibWrapper::TestPerformanceL()
+	{
+	INFO_PRINTF1(_L("Testing performance"));
+
+	//Use case 1: Normal use case, insert 1 variant specific data segment
+	TUint startTick = User::NTickCount();
+
+	CSELFEditor* editor = NULL;
+	editor = CSELFEditor::NewLC(KSELFFileName());
+	editor->InsertVariantSpecificDataL(KTestData1());
+	editor->WriteELFUpdatesL();
+
+	TUint stopTick = User::NTickCount();
+	TReal seconds = (TReal)(stopTick - startTick)/(TReal)HelpTicksPerSecond();
+	INFO_PRINTF2(_L("Inserting one segment takes %f seconds"), seconds);
+	CleanupStack::PopAndDestroy(editor);
+
+	//Use case 2: Lots of inserts
+	//Get size of file before
+	RFile theFile;
+	User::LeaveIfError(theFile.Open(iFs, KSELFFileName(), EFileRead));
+	CleanupClosePushL(theFile);
+
+	TInt startingFileSize = 0;
+	User::LeaveIfError(theFile.Size(startingFileSize));
+	CleanupStack::PopAndDestroy(&theFile);
+
+	TInt prenumsegments = GetNumberofVariantSegmentsL(KSELFFileName());
+	INFO_PRINTF2(_L("There are [0x%X] variant data segments before the test"), prenumsegments);
+
+	editor = CSELFEditor::NewLC(KSELFFileName());
+
+	INFO_PRINTF1(_L("Inserting the variant specific data"));
+
+	static const int numToTest = 50;
+	startTick = User::NTickCount();
+	for(TUint i = 0; i < numToTest; i++)
+		{
+		editor->InsertVariantSpecificDataL(KTestData1());
+		}
+
+	INFO_PRINTF1(_L("Updating the ELF file"));
+	editor->WriteELFUpdatesL();
+
+	stopTick = User::NTickCount();
+	seconds = (TReal)(stopTick - startTick)/(TReal)HelpTicksPerSecond();
+
+	CleanupStack::PopAndDestroy(editor);
+
+	TInt postnumsegments = GetNumberofVariantSegmentsL(KSELFFileName());
+	INFO_PRINTF2(_L("There are [0x%X] variant data segments after the test"), postnumsegments);
+
+	T_SELFLIB_ASSERT_TRUE(prenumsegments + numToTest == postnumsegments, 0);
+	INFO_PRINTF4(_L("Starting file size: 0x%X %d and took %f seconds"), startingFileSize, startingFileSize, seconds);
+
+	}
+
+/**
+ * Tests we can insert a large amount of data into the ELF file
+ * @leave ONe of the system wide codes
+ */
+void CSELFLibWrapper::TestStressL()
+	{
+	INFO_PRINTF1(_L("Testing CSELFEditor Insert Large amount of Variant Sepcific data"));
+
+	//Get the number of variant data segments there before
+	TInt prenumsegments = GetNumberofVariantSegmentsL(KSELFFileName());
+	INFO_PRINTF2(_L("There are [0x%X] variant data segments before the test"), prenumsegments);
+
+	RBuf8 largeData;
+	largeData.CreateL(KLargeDataSize);
+	largeData.CleanupClosePushL();
+
+	CSELFEditor* editor = NULL;
+	TRAPD(err, editor = CSELFEditor::NewL(KSELFFileName()));
+
+	INFO_PRINTF2(_L("getting %d"), err);
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 1);
+	T_SELFLIB_ASSERT_TRUE(editor != NULL, 1);
+
+	CleanupStack::PushL(editor);
+
+	INFO_PRINTF1(_L("Inserting the variant specific"));
+	TRAP(err, editor->InsertVariantSpecificDataL(largeData));
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 2);
+
+	INFO_PRINTF1(_L("Updating the ELF file"));
+	TRAP(err, editor->WriteELFUpdatesL());
+
+	INFO_PRINTF2(_L("ELF File updating returned [%d]"), err);
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 2);
+
+	CleanupStack::PopAndDestroy(editor);
+
+	TInt postnumsegments = GetNumberofVariantSegmentsL(KSELFFileName());
+	INFO_PRINTF2(_L("There are [0x%X] variant data segments after the test"),postnumsegments);
+
+	T_SELFLIB_ASSERT_TRUE(prenumsegments + 1 == postnumsegments, 0);
+
+	TInt bufferRequired = GetVariantSegmentSizeL(postnumsegments - 1, KSELFFileName());
+	RBuf8 data;
+	data.CreateL(bufferRequired);
+	data.CleanupClosePushL();
+
+	TRAP(err, GetVariantSegmentDataL(postnumsegments - 1, data, KSELFFileName()));
+
+	T_SELFLIB_ASSERT_TRUE(KErrNone == err, 2);
+	T_SELFLIB_ASSERT_TRUE(0 == largeData.Compare(data), 2);
+
+	INFO_PRINTF1(_L("Data looks good"));
+	CleanupStack::PopAndDestroy(&data);
+	CleanupStack::PopAndDestroy(&largeData);
+	}
+
+/**
+ * Returns the number of nanokernel ticks in one second
+ * @return Number of nanokernel ticks. 0 if unsuccesful
+ */
+TInt CSELFLibWrapper::HelpTicksPerSecond()
+	{
+	TInt nanokernel_tick_period;
+	HAL::Get(HAL::ENanoTickPeriod, nanokernel_tick_period);
+	static const TInt KOneMillion = 1000000;
+	return KOneMillion/nanokernel_tick_period;
+	}
+
+/**
+ * Utility to get the number of variant data segments in the file
+ * @leave One of the system wide codes
+ */
+TInt CSELFLibWrapper::GetNumberofVariantSegmentsL(const TDesC& aFilename)
+	{
+	RFile elfFile;
+	User::LeaveIfError(elfFile.Open(iFs, aFilename, EFileRead));
+	CleanupClosePushL(elfFile);
+
+	READ_STRUCTL(Elf32_Ehdr, ehdr, elfFile, 0);
+
+	TUint count = 0;
+
+	//Now go through program headers and count relevant dhdrs
+	for(TUint i = 0; i < ehdr.e_phnum; i++)
+		{
+		READ_STRUCTL(Elf32_Phdr, phdr, elfFile, ehdr.e_phoff + (i * sizeof(Elf32_Phdr)));
+		if(phdr.p_type == PT_NOTE)
+			{
+			READ_STRUCTL(Sym32_dhdr, dhdr, elfFile, phdr.p_offset);
+			if(dhdr.d_type == ESYM_NOTE_VARIANT_DATA)
+				++count;
+			}
+		}
+
+	CleanupStack::PopAndDestroy(&elfFile);
+
+	return count;
+	}
+
+/**
+ * Gets the size of the aIndexth variant segment element we find
+ * in the ELF file
+ * @param aIndex Index of the segment of interest
+ * @return The size required to read this data
+ * @leave KErrNotFound if the index is wrong or one of the system wide codes
+ */
+TInt CSELFLibWrapper::GetVariantSegmentSizeL(const TUint aIndex, const TDesC& aFilename)
+	{
+	RFile elfFile;
+	User::LeaveIfError(elfFile.Open(iFs, aFilename, EFileRead));
+	CleanupClosePushL(elfFile);
+
+	READ_STRUCTL(Elf32_Ehdr, ehdr, elfFile, 0);
+
+	TUint count = 0;
+
+	//Now go through program headers and count relevant dhdrs
+	for(TUint i = 0; i < ehdr.e_phnum; i++)
+		{
+		READ_STRUCTL(Elf32_Phdr, phdr, elfFile, ehdr.e_phoff + (i * sizeof(Elf32_Phdr)));
+		if(phdr.p_type == PT_NOTE)
+			{
+			READ_STRUCTL(Sym32_dhdr, dhdr, elfFile, phdr.p_offset);
+			if(dhdr.d_type == ESYM_NOTE_VARIANT_DATA)
+				{
+				if(count == aIndex)
+					{
+					READ_STRUCTL(Sym32_variant_spec_data, vdata, elfFile, phdr.p_offset + sizeof(Sym32_dhdr));
+					CleanupStack::PopAndDestroy(&elfFile);
+					return vdata.es_size;
+					}
+				count++;
+				}
+			}
+		}
+
+	User::Leave(KErrNotFound);
+	return 0; //avoid warnings
+	}
+
+/**
+ * Gets the data of the aIndexth variant segment element we find
+ * in the ELF file
+ * @param aIndex Index of the segment of interest
+ * @param aData buffer to hold data
+ * @leave KErrNotFound if the index is wrong or one of the system wide codes
+ */
+void CSELFLibWrapper::GetVariantSegmentDataL(TUint aIndex, TDes8& aData, const TDesC& aFilename)
+	{
+	RFile elfFile;
+	User::LeaveIfError(elfFile.Open(iFs, aFilename, EFileRead));
+	CleanupClosePushL(elfFile);
+
+	READ_STRUCTL(Elf32_Ehdr, ehdr, elfFile, 0);
+
+	TUint count = 0;
+
+	//Now go through program headers and count relevant dhdrs
+	for(TUint i = 0; i < ehdr.e_phnum; i++)
+		{
+		READ_STRUCTL(Elf32_Phdr, phdr, elfFile, ehdr.e_phoff + (i * sizeof(Elf32_Phdr)));
+		if(phdr.p_type == PT_NOTE)
+			{
+			READ_STRUCTL(Sym32_dhdr, dhdr, elfFile, phdr.p_offset);
+			if(dhdr.d_type == ESYM_NOTE_VARIANT_DATA)
+				{
+				if(count == aIndex)
+					{
+					READ_STRUCTL(Sym32_variant_spec_data, vdata, elfFile, phdr.p_offset + sizeof(Sym32_dhdr));
+					if(aData.MaxLength() < vdata.es_size)
+						{
+						User::Leave(KErrTooBig);
+						}
+					//read the data
+					elfFile.Read(vdata.es_data, aData);
+					CleanupStack::PopAndDestroy(&elfFile);
+					return;
+					}
+				count++;
+				}
+			}
+		}
+
+	User::Leave(KErrNotFound);
+	}
+
+/**
+ * Copies test files from not writable z:\ drive to writable place
+ * @leave One of the system wide codes
+ */
+void CSELFLibWrapper::CopyFilesToWritablePlaceL()
+	{
+	INFO_PRINTF1(_L("Copying the files and setting correct attributes"));
+ 	BaflUtils::EnsurePathExistsL(iFs, KSELFFileName);
+
+	TUint attToRemove = KEntryAttReadOnly;
+	TUint attToSet = 0;
+
+ 	User::LeaveIfError(BaflUtils::CopyFile(iFs, KROMSELFFileName, KSELFFileName));
+	iFs.SetAtt(KSELFFileName, attToSet, attToRemove);
+
+	User::LeaveIfError(BaflUtils::CopyFile(iFs, KROMSELFFileNameInvalidBySignature, KSELFFileNameInvalidBySignature));
+	iFs.SetAtt(KSELFFileNameInvalidBySignature, attToSet, attToRemove);
+
+	User::LeaveIfError(BaflUtils::CopyFile(iFs, KROMSELFFileNameTiny, KSELFFileNameTiny));
+	iFs.SetAtt(KSELFFileNameTiny, attToSet, attToRemove);
+
+	User::LeaveIfError(BaflUtils::CopyFile(iFs, KROMSELFFileNameExe, KSELFFileNameExe));
+	iFs.SetAtt(KSELFFileNameExe, attToSet, attToRemove);
+	}
+
+/**
+ * Cleans the files copied by CopyFilesToWritablePlaceL() to tidy up
+ */
+void CSELFLibWrapper::TearDownFilesL()
+	{
+	INFO_PRINTF1(_L("Deleting the files"));
+
+ 	User::LeaveIfError(BaflUtils::DeleteFile(iFs, KSELFFileName));
+	User::LeaveIfError(BaflUtils::DeleteFile(iFs, KSELFFileNameInvalidBySignature));
+	User::LeaveIfError(BaflUtils::DeleteFile(iFs, KSELFFileNameTiny));
+	User::LeaveIfError(BaflUtils::DeleteFile(iFs, KSELFFileNameExe));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/cds/CServerDataSourceWrapper.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,182 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file CServerDataSourceWrapper.cpp
+ @internalTechnology 
+*/
+
+#include <d32btrace.h>
+
+#include "CServerDataSourceWrapper.h"
+
+using namespace Debug;
+
+//Names of functions to be tested - referenced from script file
+_LIT(KGetAvailableTraceSizeL, "GetAvailableTraceSizeL");
+
+/**
+ * Constructor for test wrapper
+ */
+CServerDataSourceWrapper::CServerDataSourceWrapper()
+	:iObject(NULL)
+	{
+	}
+
+/**
+ * Destructor
+ */
+CServerDataSourceWrapper::~CServerDataSourceWrapper()
+	{
+	}
+
+/**
+ * Two phase constructor for CFlashDataSourceWrapper
+ * @return CFlashDataSourceWrapper object
+ * @leave
+ */
+CServerDataSourceWrapper* CServerDataSourceWrapper::NewL()
+	{
+	CServerDataSourceWrapper* ret = new (ELeave) CServerDataSourceWrapper();
+	CleanupStack::PushL(ret);
+	ret->ConstructL();
+	CleanupStack::Pop(ret);
+	return ret;
+	}
+
+/**
+ * Safe construction
+ * @leave
+ */
+void CServerDataSourceWrapper::ConstructL()
+	{
+	
+	}
+
+/** 
+ * Assign the object
+ *  
+ * @param aObject TAny* to the object to test
+ * @leave
+ */
+void CServerDataSourceWrapper::SetObjectL(TAny* aObject)
+	{
+	delete iObject;
+	iObject = NULL;
+	iObject = static_cast<CServerCrashDataSource*> (aObject);	
+	}
+
+/**
+ * Runs a test preamble
+ */
+void CServerDataSourceWrapper::PrepareTestL()
+	{
+	SetBlockResult(EPass);		
+	
+	INFO_PRINTF1(_L("Connecting to DSS"));
+	//get a session to the security server
+	User::LeaveIfError(iSecSess.Connect(dssVersion));
+	
+	INFO_PRINTF1(_L("Creating data source"));
+	
+	//Hackage: TEF doesnt support preamble/postamble and destructs iObject each time. Until they sort it out
+	//or document how it is done the hackage shall have to continue. Oh for JUnit....
+	delete iObject;		//to be sure
+	iObject = CServerCrashDataSource::NewL(iSecSess);
+	//end of hackage
+	
+	INFO_PRINTF1(_L("Ready to start test"));
+	}
+
+/**
+ * Process command to see what test to run 
+ */
+TBool CServerDataSourceWrapper::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
+	{
+	__UHEAP_MARK;	
+	
+	PrepareTestL();
+	
+	if (KGetAvailableTraceSizeL() == aCommand)
+		{
+		RDebug::Printf("Looking at CServerDataSource::GetAvailableTraceSizeL()");
+		TRAPD(err , DoCmdGetAvailableTraceSizeL_TestL());	
+		if(BlockResult() != EPass || KErrNone != err)
+			{
+			RDebug::Printf("\tFailed!");
+			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
+			SetBlockResult(EFail);
+			}
+		}
+	else 		
+		{
+		RDebug::Printf("Not found");
+		
+		delete iObject;	
+		iSecSess.Close();
+		
+		__UHEAP_MARKEND;
+		
+		return EFalse;
+		}
+	
+	delete iObject;	
+	iSecSess.Close();	
+	
+	__UHEAP_MARKEND;
+	
+	return ETrue;
+	}
+
+void CServerDataSourceWrapper::DoCmdGetAvailableTraceSizeL_TestL()
+	{	
+	//Step 1: Empty trace buffer
+	INFO_PRINTF1(_L("Emptying the trace buffer"));
+	RBTrace trace;
+	trace.Open();	
+	trace.Empty();
+	trace.Close();
+	
+	//step 1: Put our data in
+	INFO_PRINTF1(_L("Generating trace data"));
+	RProcess crashapp;
+	User::LeaveIfError(crashapp.Create(KCrashAppFileName, _L("-t -d1 -c13")));
+	
+	TRequestStatus stat;
+	crashapp.Rendezvous(stat);
+	crashapp.Resume();
+	
+	User::WaitForRequest(stat);	
+	
+	crashapp.Close();
+	
+	//step 2: Read it
+	INFO_PRINTF1(_L("Getting size of trace data"));
+	
+	TUint bytesFound = iObject->GetAvailableTraceSizeL();
+	
+	if(bytesFound != KTraceSizeFromCrashApp)
+		{
+		ERR_PRINTF3(_L("Read the wrong amount of trace. Expected [0x%X] bytes but got [0x%X] bytes"), KTraceSizeFromCrashApp, bytesFound);
+		SetBlockResult(EFail);
+		return;
+		}		
+	}
+
+//eof
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/cds/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/coredump_debug_token.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,31 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#include <e32base.h>
+
+GLDEF_C TInt E32Main()
+	{
+	// No need to do anything, the only requirement is that
+	// this executable can be loaded and runs to completion
+	return 0;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/tcds_unitBlockController.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,55 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file tcds_unitBlockController.cpp
+ @internalTechnology
+*/
+
+#include "tcds_unitBlockController.h"
+
+_LIT(KCFlashDataSourceWrapper, "CFlashDataSourceWrapper");
+_LIT(KServerDataSourceWrapper, "CServerDataSourceWrapper");
+
+
+Ctcds_unitBlockController* Ctcds_unitBlockController::NewL()
+/**
+ * @return - Instance of the test block controller
+ */
+    {
+    RDebug::Printf("Ctcds_unitBlockController::NewL()");
+    Ctcds_unitBlockController* block = new (ELeave) Ctcds_unitBlockController();
+    return block;
+    }
+
+
+CDataWrapper* Ctcds_unitBlockController::CreateDataL(const TDesC& aData)
+    {
+    
+    RDebug::Printf("Ctcds_unitBlockController::CreateDataL()");
+    CDataWrapper* wrapper = NULL;
+	if (KCFlashDataSourceWrapper() == aData)
+		{
+		wrapper = CFlashDataSourceWrapper::NewL();
+		}
+	if (KServerDataSourceWrapper() == aData)
+		{
+		wrapper = CServerDataSourceWrapper::NewL();
+		}	
+
+    return wrapper;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/tcds_unitBlockServer.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,96 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file tcds_unitBlockServer.cpp
+ @internalTechnology
+*/
+
+#include "tcds_unitBlockServer.h"
+
+Ctcds_unitBlockServer* Ctcds_unitBlockServer::NewL()
+    {
+	Ctcds_unitBlockServer* server = new (ELeave) Ctcds_unitBlockServer();
+	CleanupStack::PushL(server);
+	server->ConstructL();
+	CleanupStack::Pop(server);
+	return server; 
+	}
+
+CTestBlockController* Ctcds_unitBlockServer::CreateTestBlock()
+/**
+ * @return - Instance of the test block controller
+ * Called when Ctcds_unitBlockServer initializing.
+ */
+    {
+    CTestBlockController* controller = NULL;
+    TRAPD(err, controller = Ctcds_unitBlockController::NewL());
+    if(KErrNone != err)
+    	User::Panic(_L("Failed to create Ctcds_unitBlockController"), err);
+    
+    return controller;
+    }
+
+// Secure variants much simpler
+// For EKA2, just an E32Main and a MainL()
+LOCAL_C void MainL()
+/**
+ * Secure variant
+ * Much simpler, uses the new Rendezvous() call to sync with the client
+ */
+	{
+	// Leave the hooks in for platform security
+#if (defined __DATA_CAGING__)
+	RProcess().DataCaging(RProcess::EDataCagingOn);
+	RProcess().DataCaging(RProcess::ESecureApiOn);
+#endif
+	CActiveScheduler* sched=NULL;
+	sched=new(ELeave) CActiveScheduler;
+	CActiveScheduler::Install(sched);
+	Ctcds_unitBlockServer* server = NULL;
+	// Create the Ctcds_unitBlockServer derived server
+	TRAPD(err,server = Ctcds_unitBlockServer::NewL());
+	if(!err)
+		{
+		// Sync with the client and enter the active scheduler
+		RProcess::Rendezvous(KErrNone);
+		sched->Start();
+		}
+	delete server;
+	delete sched;
+	}
+
+
+
+GLDEF_C TInt E32Main()
+/**
+ * @return - Standard Epoc error code on process exit
+ * Secure variant only
+ * Process entry point. Called by client using RProcess API
+ */
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if(cleanup == NULL)
+		{
+		return KErrNoMemory;
+		}
+	TRAPD(err,MainL());
+	delete cleanup;
+	__UHEAP_MARKEND;
+	return err;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/tcds_unit_selflib_block.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,112 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//  Block server for the sELF lib unit tests
+
+/**
+ * @file tcds_unit_sELFlib_block.cpp
+ * @internalTechnology
+ */
+
+#include "tcds_unit_selflib_block.h"
+
+CSELFLibBlockController* CSELFLibBlockController::NewL()
+    {
+    CSELFLibBlockController* block = new (ELeave) CSELFLibBlockController();
+    return block;
+    }
+
+/**
+ * Creates the Wrapper object with which we test
+ * @param Descriptor of object to create
+ * @return Test data wrapper
+ * @leaves One of the system wide error codes
+ */
+CDataWrapper* CSELFLibBlockController::CreateDataL(const TDesC& aData)
+    {
+    CDataWrapper* wrapper = NULL;
+
+	TBuf8<300> x;
+	x.SetLength(aData.Length() * 2);
+	x.Copy(aData);
+
+	if(KCSELFLibWrapper() == aData)
+		{
+		wrapper = CSELFLibWrapper::NewL();
+		}
+	else
+		{
+    	User::Panic(_L("Testwrapper Not Found"), KErrNotFound);
+		}
+
+    return wrapper;
+    }
+
+CSELFLibBlockServer* CSELFLibBlockServer::NewL()
+    {
+	CSELFLibBlockServer* server = new (ELeave) CSELFLibBlockServer();
+	CleanupStack::PushL(server);
+	server->ConstructL();
+	CleanupStack::Pop(server);
+	return server;
+	}
+
+CTestBlockController* CSELFLibBlockServer::CreateTestBlock()
+    {
+    CTestBlockController* controller = NULL;
+    TRAPD(err, controller = CSELFLibBlockController::NewL());
+    if(KErrNone != err)
+		{
+    	User::Panic(_L("Failed to create CSELFLibBlockServer"), err);
+		}
+
+    return controller;
+    }
+
+LOCAL_C void MainL()
+	{
+	// Leave the hooks in for platform security
+#if (defined __DATA_CAGING__)
+	RProcess().DataCaging(RProcess::EDataCagingOn);
+	RProcess().DataCaging(RProcess::ESecureApiOn);
+#endif
+	CActiveScheduler* sched=NULL;
+	sched=new(ELeave) CActiveScheduler;
+	CActiveScheduler::Install(sched);
+	CSELFLibBlockServer* server = NULL;
+	// Create the CSELFLibBlockServer derived server
+	TRAPD(err,server = CSELFLibBlockServer::NewL());
+	if(KErrNone == err)
+		{
+		// Sync with the client and enter the active scheduler
+		RDebug::Printf("\nStarting the SELF Library Test Suite\n");
+		RProcess::Rendezvous(KErrNone);
+		sched->Start();
+		}
+	delete server;
+	delete sched;
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if(cleanup == NULL)
+		{
+		return KErrNoMemory;
+		}
+	TRAPD(err,MainL());
+	delete cleanup;
+	__UHEAP_MARKEND;
+	return err;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/testdriver/coredump_testdriver.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,21 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+
+call testdriver rbuild
+call testdriver config --import td_proj.xml
+call testdriver config --testexec off
+call testdriver run
+call perl html_file_copier.pl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/testdriver/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/automatictests/testdriver/html_file_copier.pl	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+// html_file_copier.pl
+//
+// Copyright (c) 2007 - 2008 Symbian Software Ltd.  All rights reserved.
+//
+
+use warnings;
+use strict;
+use File::Copy;
+
+my $resDir = `testdriver resultpath`;
+chomp $resDir;
+print "$resDir\n";
+if($resDir=~/^(.*testdriver\\[^\\]+\\armv5\\udeb\\)\d+\\$/)
+	{
+	print "$1\n";
+	my $prevDir = $1;
+	my @files = <$prevDir*>;
+	foreach my $file (@files)
+		{
+		print "$file\n";
+		if(-d $file)
+			{
+			print "Setting resDir: $resDir\n";
+			$resDir = $file . "\\";
+			next;
+			}
+		}
+	}
+
+if($resDir=~/^(.*testdriver\\)([^\\]+)\\armv5\\udeb\\(\d+)\\$/)
+	{
+	my $outputDir = $1;
+	my $build = $2;
+	my $run = $3;
+	my $input = "$resDir" . "run$run\_$build.html";
+	print "Input: $input\n";
+	my $output = "$outputDir". "out.html";
+	print "Output: $output\n";
+	if(!copy($input, $output))
+		{
+		print "Couldn't copy results";
+		exit (2);
+		}
+	}
+else
+	{
+	print "Couldn't find results";
+	exit(1);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,40 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+
+crashapp.iby	/epoc32/rom/include/crashapp.iby
+crashdriver.iby /epoc32/rom/include/crashdriver.iby
+..\inc\crashdefs.h     /epoc32/include/crashdefs.h
+
+PRJ_MMPFILES
+
+crashapp.mmp
+crashapp_nodebugbit.mmp
+
+//Driver only builds on device
+#if defined(MARM_ARMV5)
+//scmtest
+crashdriver 
+#endif
+
+
+
+
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/group/crashapp.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,22 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef CRASHAPP_IBY
+#define CRASHAPP_IBY
+
+file=ABI_DIR\BUILD_DIR\crashapp.exe  sys\bin\crashapp.exe
+file=ABI_DIR\BUILD_DIR\crashapp_nodebugbit.exe  sys\bin\crashapp_nodebugbit.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/group/crashapp.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,47 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// textcrashconfig.mmp
+//
+
+
+
+TARGET        crashapp.exe
+TARGETTYPE    exe
+UID			  0x1000008D 0x102831E5
+SECUREID      0x102831E5
+VENDORID	  0x70000001
+
+ 
+USERINCLUDE   ..\inc 
+SOURCEPATH    ..\src
+SOURCE        crashapp.cpp
+#if defined(MARM_ARMV5)
+SOURCE 		  crash.s
+#endif
+
+SYSTEMINCLUDE \epoc32\include 
+
+LIBRARY       euser.lib
+LIBRARY     btracec.lib
+
+DEBUGGABLE
+
+MACRO CDSDEBUG
+MACRO SYMBIAN_TRACE_ENABLE
+
+OPTION_REPLACE ARMCC -O2 -O0 //Turn off optimisation to allow us to div by zero in urel
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/group/crashapp_nodebugbit.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,36 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// textcrashconfig.mmp
+//
+
+
+
+TARGET        crashapp_nodebugbit.exe
+TARGETTYPE    exe
+UID			  0x1000008D 0x102831E5
+SECUREID      0x102831E5
+VENDORID	  0x70000001
+
+ 
+USERINCLUDE   ..\inc 
+SOURCEPATH    ..\src
+SOURCE        crashapp.cpp
+#if defined(MARM_ARMV5)
+SOURCE 		  crash.s
+#endif
+
+SYSTEMINCLUDE \epoc32\include 
+
+LIBRARY       euser.lib
+LIBRARY     btracec.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/group/crashdriver.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef CRASHDRIVER_IBY
+#define CRASHDRIVER_IBY	
+
+#ifdef _NAND2
+file=KERNEL_DIR\DEBUG_DIR\crashdriverldd.ldd	\sys\bin\crashdriverldd.ldd
+#else
+device[VARID]=KERNEL_DIR\DEBUG_DIR\crashdriverldd.ldd	\sys\bin\crashdriverldd.ldd
+#endif
+
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/group/crashdriver.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,36 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "kernel\kern_ext.mmh"
+
+TARGET			crashdriverldd.ldd
+TARGETTYPE		ldd
+
+USERINCLUDE   	..\inc 
+SOURCEPATH    	..\src
+SOURCE			d_crashdriver_ldd.cpp
+#if defined(MARM_ARMV5)
+SOURCE 			crash.s
+#endif
+
+//LIBRARY			scmonitor.lib
+
+UID				0x100000af
+
+CAPABILITY ALL
+
+OPTION_REPLACE ARMCC -O2 -O0 //Turn off optimisation to allow us to div by zero in urel
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/inc/crash.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+* definitions of functions in crash.s
+*
+*/
+
+#ifndef CRASH_H
+#define CRASH_H
+
+extern "C"
+{
+	// ARM tests
+	unsigned int InfLoop(void);
+	unsigned int SetRegs(void);
+	unsigned int SetUpperRegs(void);
+}
+#endif // CRASH_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/inc/crashdefs.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,22 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// decalarations used in crashapp.cpp
+/*Trace Category used to trace*/
+const TInt KTraceCategory = 200;
+/*Number of Trace records*/
+const TInt KTRACENUMBER = 50;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/inc/d_crashdriver_ldd.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,84 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Kernel side interfaces to example Logical Device Drivers
+//
+
+
+
+#ifndef __D_CRASHDRIVER_LDD_H__
+#define __D_CRASHDRIVER_LDD_H__
+
+
+#include <kernel\kern_priv.h>
+
+/**
+ * Logical Device (factory class) for 'crashdriver'
+ */
+class DCrashDriverFactory : public DLogicalDevice
+    {
+public:    
+	DCrashDriverFactory();
+    ~DCrashDriverFactory();
+    //  Inherited from DLogicalDevice
+    virtual TInt Install();
+    virtual void GetCaps(TDes8& aDes) const;
+    virtual TInt Create(DLogicalChannelBase*& aChannel);
+    };
+    
+
+/**
+ *  Logical Channel class for 'crashdriver'
+ */    
+class DCrashDriverChannel : public DLogicalChannel
+    {
+public:
+	DCrashDriverChannel();
+    virtual ~DCrashDriverChannel();
+    // Inherited from DObject
+    virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
+    // Inherited from DLogicalChannelBase
+    virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
+    // Inherited from DLogicalChannel
+    virtual void HandleMsg(TMessageBase* aMsg);
+private:
+    // Panic reasons
+    enum TPanic
+        {
+        ERequestAlreadyPending = 1
+        };
+    // Implementation for the differnt kinds of requests send through RBusLogicalChannel
+    TInt DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
+    void DoCancel(TUint aMask); 
+    
+    void PrefetchAbort();
+    void DataRead();
+    void DataWrite();
+    void UndefinedInst();
+    void DivByZero();
+    void StackOverFlow();
+    
+    //void TestConfigInsertL(TBool& aPass, TDes8& aResult);
+    
+    typedef void (*Tfunc)();
+   
+private:
+	TDynamicDfcQue* iDfcQ;
+    DThread* iClient;
+    TRequestStatus* iStatus;
+    TInt recurseCount;
+   
+    };    
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/inc/t_crashdriver_drv.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,215 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Core Dump Server Crash Driver
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @prototype
+*/
+
+#ifndef __T_CRASHDRIVER_DRV_H__
+#define __T_CRASHDRIVER_DRV_H__
+
+#include <e32cmn.h>
+#include <e32ver.h>
+#ifndef __KERNEL_MODE__
+#include <e32std.h>
+#endif
+
+//size of message buffer
+const TInt KMaxBufferSize = 150;
+
+/**
+User interface for 'crashdriver'
+*/
+class RKernelCrashDrv : public RBusLogicalChannel
+    {
+public:
+	/**
+    Structure for holding driver capabilities information
+    (Just a version number in this example.)
+    */
+    class TCaps
+        {
+    public:
+        TVersion iVersion;
+        };
+    
+public:
+    TInt Open();   
+    void SendNullPointerFault(TRequestStatus& aStatus);
+    void SendPrefetchAbortFault(TRequestStatus& aStatus);
+    void SendDataReadFault(TRequestStatus& aStatus);
+    void SendDataWriteFault(TRequestStatus& aStatus);  
+    void SendUndefInstructionFault(TRequestStatus& aStatus);
+    void SendDivByZeroFault(TRequestStatus& aStatus);
+    void SendStackOverFlowFault(TRequestStatus& aStatus);
+    void TestSCMConfigInsertMethod(TRequestStatus& aStatus, TBool& aPass, TDes8& aBuf);
+    
+    inline static const TDesC& Name();
+    inline static TVersion VersionRequired();
+
+public:
+     /**
+    Enumeration of Request messages. Causes kernel Panics
+    */
+    enum TRequest
+        {
+        ENullPointer,
+        EPrefetchAbort,
+        EDataRead,
+        EDataWrite,
+        EUndefInst,
+        EDivByZero,
+        EStackOverflow,
+        ETestSCMConfigInsertMethod,
+        };      
+    };
+
+
+/**
+  Returns the driver's name
+*/
+inline const TDesC& RKernelCrashDrv::Name()
+    {
+    _LIT(KCrashDriverName,"crashdriver");
+    return KCrashDriverName;
+    }
+
+/**
+  Returns the version number of the driver
+*/
+inline TVersion RKernelCrashDrv::VersionRequired()
+    {
+    const TInt KMajorVersionNumber=1;
+    const TInt KMinorVersionNumber=0;
+    const TInt KBuildVersionNumber=KE32BuildVersionNumber;
+    return TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
+    }
+
+/*
+  NOTE: The following member functions would normally be exported from a seperate client DLL
+  but are included inline in this header file for convenience.
+*/
+
+#ifndef __KERNEL_MODE__
+
+/**
+  Opens a logical channel to the driver
+
+  @return One of the system wide error codes.
+*/
+TInt RKernelCrashDrv::Open()
+    {
+    __UHEAP_MARK;
+    TInt x = DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread);    
+    __UHEAP_MARKEND;
+    return x;
+    }
+
+
+/** 
+ *   Sends data to the device.
+ *   Only one send request may be pending at any time.
+ *   @param aStatus The request to be signalled when the data has been sent.
+ *                  The result value will be set to KErrNone on success;
+ *                  or set to one of the system wide error codes when an error occurs.
+ */
+void RKernelCrashDrv::SendPrefetchAbortFault(TRequestStatus& aStatus)
+    {
+    DoRequest(EPrefetchAbort,aStatus);
+    }
+
+/**
+ *   Sends data to the device.
+ *   Only one send request may be pending at any time.
+ *   @param aStatus The request to be signalled when the data has been sent.
+ *                  The result value will be set to KErrNone on success;
+ *                  or set to one of the system wide error codes when an error occurs.
+ */
+void RKernelCrashDrv::SendDataReadFault(TRequestStatus& aStatus)
+    {
+    DoRequest(EDataRead,aStatus);
+    }
+
+/**
+ *   Sends data to the device.
+ *   Only one send request may be pending at any time.
+ *   @param aStatus The request to be signalled when the data has been sent.
+ *                  The result value will be set to KErrNone on success;
+ *                  or set to one of the system wide error codes when an error occurs.
+ */
+void RKernelCrashDrv::SendDataWriteFault(TRequestStatus& aStatus)
+    {
+    DoRequest(EDataWrite,aStatus);
+    }
+
+/**
+ *   Sends data to the device.
+ *   Only one send request may be pending at any time.
+ *   @param aStatus The request to be signalled when the data has been sent.
+ *                  The result value will be set to KErrNone on success;
+ *                  or set to one of the system wide error codes when an error occurs.
+ */
+void RKernelCrashDrv::SendUndefInstructionFault(TRequestStatus& aStatus)
+    {
+    DoRequest(EUndefInst,aStatus);
+    }
+
+/**
+ *   Sends data to the device.
+ *   Only one send request may be pending at any time.
+ *   @param aStatus The request to be signalled when the data has been sent.
+ *                  The result value will be set to KErrNone on success;
+ *                  or set to one of the system wide error codes when an error occurs.
+ */
+void RKernelCrashDrv::SendDivByZeroFault(TRequestStatus& aStatus)
+    {
+    DoRequest(EDivByZero,aStatus);
+    }
+
+/**
+ *   Sends data to the device.
+ *   Only one send request may be pending at any time.
+ *   @param aStatus The request to be signalled when the data has been sent.
+ *                  The result value will be set to KErrNone on success;
+ *                  or set to one of the system wide error codes when an error occurs.
+ */
+void RKernelCrashDrv::SendStackOverFlowFault(TRequestStatus& aStatus)
+    {
+    DoRequest(EStackOverflow,aStatus);
+    }
+
+/**
+ *   Sends data to the device.
+ *   Only one send request may be pending at any time.
+ *   @param aStatus The request to be signalled when the data has been sent.
+ *                  The result value will be set to KErrNone on success;
+ *                  or set to one of the system wide error codes when an error occurs.
+ */
+void RKernelCrashDrv::TestSCMConfigInsertMethod(TRequestStatus& aStatus, TBool& aPass, TDes8& aBuf)
+    {
+    DoRequest(ETestSCMConfigInsertMethod, aStatus, reinterpret_cast<TAny*>(&aPass), reinterpret_cast<TAny*>(&aBuf));
+    }
+
+
+
+#endif   // !__KERNEL_MODE__
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/src/crash.s	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,46 @@
+;
+; Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+;
+
+        AREA |crash$$Code|, CODE, READONLY, ALIGN=6
+
+	CODE32
+
+	; ARM tests
+	
+; 
+; Non-PC modifying
+;
+	EXPORT InfLoop
+	EXPORT SetRegs
+	EXPORT SetUpperRegs
+	
+InfLoop
+	bl		InfLoop
+
+SetRegs
+	mov r7, #0xF000
+	mov r8, #0xEA
+	bx  lr
+	
+SetUpperRegs
+	mov r8, #0xF000
+	mov r11, #0xEA
+	bx  lr
+
+	END
+
+; End of file - crash.s
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/src/crashapp.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,714 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32base.h>    //base stuff
+#include <e32debug.h>   //logging
+#include <e32cons.h>    //console
+#include <e32property.h>
+#include <e32utrace.h>
+#include <d32btrace.h>
+#include <uloggerclient.h>
+#include "t_crashdriver_drv.h"
+#include "crash.h"
+#include "crashdefs.h"//definitions included
+
+_LIT(KAlloc, "-a <num_of_kbytes> : memory to be allocated on the heap; default is zero\n");
+_LIT(KChunks, "-n <num_of_chunks> :  first global - 1k, the rest 0.5k are local to the process; default is none\n");
+_LIT(KDelay, "-d <num_of_seconds> : time before the app crashes; default is 60s\n");
+_LIT(KFault, "-c <fault_type> : crash type; default is null pointer dereference\n");
+_LIT(KFaultTypes, "None=0, PrefetchAbort=1, DataRead=2\n DataWrite=3, UndefInstr=4, UserPanic=5\n UserException=6, EStackOverflow=7, UserExit=8\n UserLeave=9, ThreadKill=10, ThreadPanic=11\n ThreadTerminate=12, DivByZero=13\n");
+_LIT(KLoad, "-l : load esock.dll library into process address space; default is no\n");
+_LIT(KSimon, "-s : to create a dummy child thread that is not going to crash; default is no\n");
+_LIT(KThreads, "-m <num_of_threads> : that are going to be created and then crashed; if not specified the main thread is going to crash\n");
+_LIT(KTrace, "-t: includes test trace data\n");
+_LIT(KKernelCrash, "-k: causes the crash to occur in a device driver\n");
+_LIT(KCrashDriverLddFileName, "crashdriverldd");
+
+//crash app trace filter
+#define CrashAppTraceFilter 200
+
+/** Crash App UID */
+const TUid KCrashAppUid = { 0x102831E5 };
+
+using namespace Ulogger;
+
+enum TFaultType
+{
+    ENone			=0,
+    EPrefetchAbort	=1,
+    EDataRead		=2,
+    EDataWrite		=3,
+    EUndefInstr		=4,
+    EUserPanic		=5,
+    EUserException	=6,
+    EStackOverflow	=7,
+
+    EUserExit		=8,
+    EUserLeave		=9,
+    EThreadKill		=10,
+    EThreadPanic	=11,
+    EThreadTerminate=12,
+    EDivByZero		=13,
+
+};
+
+enum TProgress 
+{ 
+	EMainThread, 	
+	EChildThread	
+};
+
+CConsoleBase *console;
+
+_LIT(KPanicCategory, "example panic category");
+
+TInt gAlloc = 0;
+TInt gDelay = 60; 
+TBool gLibrary = EFalse;
+TInt gChunks = 0;
+TInt gMultikill = 0;
+TBool gScreamer = EFalse;
+TFaultType gFault = ENone;
+TBool gTrace = EFalse;
+TBool gKernelSide = EFalse;
+
+void WriteTraceData()
+	{	
+	RBTrace trace;
+    TInt e = trace.Open();
+    if(e != KErrNone)
+    	{
+    	RDebug::Printf("crashapp: opening trace buffer failed: %d\n", e);
+    	trace.Close();
+    	return;
+    	}
+    RDebug::Printf("crashapp: opening trace buffer succesful\n");
+    
+    trace.SetFilter(200, ETrue);
+    trace.SetFilter2(1);
+    trace.SetMode(RBTrace::EEnable);
+	
+	//do some tracing
+	TPrimaryFilter prim = KTraceCategory; //arbitrary once between 192 and 253
+	RDebug::Printf("crashapp: making trace calls");
+	User::After(15000000);
+	for(TInt i=0; i<KTRACENUMBER; i++)
+		{				
+		TUTrace::PrintfPrimary(prim, ETrue, ETrue, "crashapp trace call number %d", i);
+		}
+	
+	
+	
+	trace.Close();		
+	}
+
+typedef void (*Tfunc)();
+
+void PrefetchAbort()
+{
+    Tfunc f = NULL;
+    f();
+}
+
+void DataRead()
+{
+  	TInt* r = (TInt*) 0x1000;
+   	TInt rr = (TInt)*r;
+
+	// Stop compilation warning. Should not get here anyway.
+	rr++;
+}
+
+void DataWrite()
+{
+  	TInt* r = (TInt*) 0x1000;
+   	*r = 0x42;                
+}
+
+void UndefInstr()
+{
+   	TUint32 undef = 0xE6000010;
+   	Tfunc f = (Tfunc) &undef;
+   	f();
+}
+
+void DivByZero()
+{
+    int i = 1;
+    int j = 10;
+    for(j=10; j>0; --j)
+    	{
+    	//this is here to avoid compiler div by zero warnings 
+    	}
+    i = i/j;
+}
+
+void UserPanic()
+{
+    User::Panic(KPanicCategory, KErrGeneral); 
+}
+
+void UserException()
+{
+    User::RaiseException(EExcGeneral);
+}
+
+void UserExit()
+{
+    User::Exit(KErrGeneral);
+}
+
+void UserLeaveL()
+{
+    User::Leave(KErrGeneral);
+}
+
+void ThreadKill()
+{
+    RThread thread;
+    thread.Kill(KErrNone);
+}
+
+void ThreadPanic()
+{
+    RThread thread;
+    thread.Panic(KPanicCategory, KErrGeneral);
+}
+
+void ThreadTerminate()
+{
+    RThread thread;
+    thread.Terminate(KErrGeneral);
+}
+
+static TUint recurseCount;
+void StackOverflow()
+{
+	TUint32 array[128];
+	array[0] = ++recurseCount;
+    StackOverflow();
+	TUint warnRem = array[0];
+	array[0] = warnRem;
+}
+
+void ParseCommandlineArgsL()
+{
+    TInt argc = User::CommandLineLength();
+
+    if(argc > 0)
+    {
+	    HBufC* args = HBufC::NewLC(User::CommandLineLength());
+        TPtr argv = args->Des();
+	    User::CommandLine(argv);
+
+	    TLex lex(*args);
+
+        while(!lex.Eos())
+        {
+            if(lex.Get() == '-')
+            {
+                TChar c = lex.Get();
+                if(c == '-')
+                {
+                    TPtrC16 token = lex.NextToken();
+                    c = token[0];
+                }
+
+                lex.SkipSpace();
+                switch(c)
+                {
+                    case 'a':
+                        lex.Val(gAlloc);
+                        break;
+                    case 'd':
+                        lex.Val(gDelay);
+                        break;
+                    case 'n':
+                        lex.Val(gChunks);
+                        break;
+                    case 'c':
+                        lex.Val((TInt&)gFault);
+                        break;
+                    case 'l':
+                        gLibrary = ETrue;
+                        break;
+                    case 'm':
+                        lex.Val(gMultikill);
+                        break;
+                    case 's':
+                        gScreamer = ETrue;
+                        break;
+                    case 't':
+                    	gTrace = ETrue;
+                    	break;
+                    case 'k':
+                    	gKernelSide = ETrue;
+                    	break;
+                    case 'h':
+                    default:
+                        _LIT(KParams, "full parameter list:\n");
+                        console->Printf(KParams);
+
+                        console->Printf(KAlloc);
+                        console->Printf(KChunks);
+                        console->Printf(KDelay);
+                        console->Printf(KFault);
+						console->Printf(KFaultTypes);
+                        console->Printf(KLoad);
+                        console->Printf(KSimon);
+                        console->Printf(KThreads);
+                        console->Printf(KTrace);
+                        console->Printf(KKernelCrash);
+                        
+                        _LIT(KPressAnyKey,"[press any key]");
+                        console->Printf(KPressAnyKey);
+	                    console->Getch();
+                        User::Leave(KErrNone);
+                }
+            }
+            lex.SkipSpace();
+        }
+	    CleanupStack::PopAndDestroy(args);  
+    }
+}
+
+TInt ThreadSimon(TAny* /*aCall*/)
+{
+    RThread thread;
+    TUint simonCounter = 1;
+    while(simonCounter++)
+    {
+        User::After(1000000);
+        RDebug::Printf("crashapp.exe - Simon[%Lu] says...%d\n", thread.Id().Id(), simonCounter);
+    }
+    return 0;
+}
+
+TInt ThreadCrash(TAny* aCall)
+{
+    User::After(gDelay*1000000);
+    Tfunc call = (Tfunc)(aCall);
+    RThread thread;
+    RDebug::Printf("crashapp.exe - time to die[%Lu]!\n", thread.Id().Id());
+    call();
+    return 0;
+}
+
+void MainL()
+{
+	//Setup a property to monitor main thread    
+	static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
+	TInt err = RProperty::Define(KCrashAppUid, EMainThread, RProperty::EInt, KAllowAllPolicy, KAllowAllPolicy);
+	if (err != KErrAlreadyExists)
+	    {
+	    User::LeaveIfError(err);
+	    }
+
+    Tfunc call = NULL;
+	recurseCount = 0;
+
+    _LIT(KConsole, "crash console");
+    console = Console::NewL(KConsole, TSize(KConsFullScreen, KConsFullScreen));
+    CleanupStack::PushL(console);          
+
+    ParseCommandlineArgsL();
+    
+    if(gTrace)
+    	{
+    	WriteTraceData();
+    	}
+
+    CleanupStack::PopAndDestroy(console);
+    
+    //Load crash driver
+    RKernelCrashDrv crashDriver;
+    if(gKernelSide)
+    	{
+    	err = User::LoadLogicalDevice(KCrashDriverLddFileName);
+    	if(KErrNone != err && KErrAlreadyExists != err )
+    		{
+    		RDebug::Printf("Unable to load kernel crash driver (%d)", err);
+    		User::Leave(err);
+    		}
+    	CleanupClosePushL(crashDriver);
+    	RDebug::Printf("Crash Driver loaded");
+    	
+    	err = crashDriver.Open();
+    	if(KErrNone != err)
+    		{
+    		RDebug::Printf("Unable to open kernel crash driver (%d)", err);
+    		User::Leave(err);
+    		}
+    	RDebug::Printf("Crash Driver opened");
+    	
+    	}        
+
+    TInt32 array[3];
+	array[0] = 0xDEADDEAD;
+	array[1] = 0xF000BEEF;
+	array[2] = 0xBEEBEE00;
+    
+    RDebug::Printf("crashapp.exe will crash after %d secs, crash type: ", gDelay);
+    TRequestStatus status;
+    switch(gFault)
+    {
+        default:
+        case ENone:
+        	{
+            RDebug::Printf("null pointer\n");        	             
+            break;
+        	}
+        case EPrefetchAbort:
+        	{
+            RDebug::Printf("prefetch abort\n");
+        	if(gKernelSide)
+	    		{
+	    		User::After(gDelay*1000000);
+#ifdef __MARM__	    		
+	    		SetRegs();
+#endif	    		
+	    		crashDriver.SendPrefetchAbortFault(status);
+	    		User::WaitForRequest(status);
+	    		err = status.Int();
+	    		if(KErrNone != err)
+	    			{
+	    			RDebug::Printf("Send request failed (%d)", err);
+	    			User::Leave(err);
+	    			}
+	    		break;
+	    		}              
+            call = PrefetchAbort;
+            break;
+        	}
+        case EDataRead:
+        	{
+            RDebug::Printf("data read");
+        	if(gKernelSide)
+	    		{
+	    		User::After(gDelay*1000000);
+#ifdef __MARM__	    		
+	    		SetRegs();
+#endif	    	
+	    		crashDriver.SendDataReadFault(status);
+	    		User::WaitForRequest(status);
+	    		err = status.Int();
+	    		if(KErrNone != err)
+	    			{
+	    			RDebug::Printf("Send request failed (%d)", err);
+	    			User::Leave(err);
+	    			}
+	    		break;
+	    		}            
+            call = DataRead;
+            break;
+        	}            
+        case EDataWrite:
+        	{
+            RDebug::Printf("data write");
+        	if(gKernelSide)
+	    		{
+	    		User::After(gDelay*1000000);
+#ifdef __MARM__	    		
+	    		SetRegs();
+#endif	    		
+	    		crashDriver.SendDataWriteFault(status);
+	    		User::WaitForRequest(status);
+	    		err = status.Int();
+	    		if(KErrNone != err)
+	    			{
+	    			RDebug::Printf("Send request failed (%d)", err);
+	    			User::Leave(err);
+	    			}
+	    		break;
+	    		}            
+            call = DataWrite;
+            break;
+        	}
+        case EUndefInstr:
+        	{        	
+        	RDebug::Printf("Undefined instruction");
+        	if(gKernelSide)
+	    		{
+	    		User::After(gDelay*1000000);
+#ifdef __MARM__	    		
+	    		SetRegs();
+#endif	    		
+	    		crashDriver.SendUndefInstructionFault(status);
+	    		User::WaitForRequest(status);
+	    		err = status.Int();
+	    		if(KErrNone != err)
+	    			{
+	    			RDebug::Printf("Send request failed (%d)", err);
+	    			User::Leave(err);
+	    			}
+	    		break;
+	    		}
+            RDebug::Printf("undefined instruction");
+            call = UndefInstr;
+            break;
+        	}        
+        case EDivByZero:
+        	{
+        	RDebug::Printf("Division by zero");
+        	if(gKernelSide)
+        		{
+        		User::After(gDelay*1000000);
+#ifdef	__MARM__        		
+        		SetRegs();
+#endif        		
+        		crashDriver.SendDivByZeroFault(status);
+        		User::WaitForRequest(status);
+        		err = status.Int();
+        		if(KErrNone != err)
+        			{
+        			RDebug::Printf("Send request failed (%d)", err);
+        			User::Leave(err);
+        			}
+        		break;
+        		}
+        	
+            RDebug::Printf("division by zero");
+            call = DivByZero;
+            break;
+        	}        
+        case EUserPanic:
+        	{        	
+            RDebug::Printf("user panic");
+        	if(gKernelSide)
+        		{
+        		RDebug::Printf("This crash is not supported kernel side");
+        		User::Leave(KErrNotSupported);
+        		}            
+            call = UserPanic;
+            break;
+        	}
+        case EUserException:
+        	{
+            RDebug::Printf("user exception\n");
+        	if(gKernelSide)
+        		{
+        		RDebug::Printf("This crash is not supported kernel side");
+        		User::Leave(KErrNotSupported);
+        		}            
+            call = UserException;
+            break;
+        	}
+        case EUserExit:
+        	{
+            RDebug::Printf("user exit\n");
+        	if(gKernelSide)
+        		{
+        		RDebug::Printf("This crash is not supported kernel side");
+        		User::Leave(KErrNotSupported);
+        		}            
+            call = UserExit;
+            break;
+        	}
+        case EUserLeave:
+        	{
+            RDebug::Printf("user leave\n");
+        	if(gKernelSide)
+        		{
+        		RDebug::Printf("This crash is not supported kernel side");
+        		User::Leave(KErrNotSupported);
+        		}            
+            call = UserLeaveL;
+            break;
+        	}
+        case EThreadKill:
+        	{
+            RDebug::Printf("thread kill\n");
+        	if(gKernelSide)
+        		{
+        		RDebug::Printf("This crash is not supported kernel side");
+        		User::Leave(KErrNotSupported);
+        		}            
+            call = ThreadKill;
+            break;
+        	}
+        case EThreadPanic:
+        	{
+            RDebug::Printf("thread panic\n");
+        	if(gKernelSide)
+        		{
+        		RDebug::Printf("This crash is not supported kernel side");
+        		User::Leave(KErrNotSupported);
+        		}            
+            call = ThreadPanic;
+            break;
+        	}
+        case EThreadTerminate:
+        	{
+            RDebug::Printf("thread terminate\n");
+        	if(gKernelSide)
+        		{
+        		RDebug::Printf("This crash is not supported kernel side");
+        		User::Leave(KErrNotSupported);
+        		}            
+            call = ThreadTerminate;
+            break;
+        	}
+        case EStackOverflow:
+        	{
+            RDebug::Printf("stack overflow");
+        	if(gKernelSide)
+        		{
+#ifdef __MARM__        		
+        		SetRegs();
+#endif        		
+        		crashDriver.SendStackOverFlowFault(status);
+        		User::WaitForRequest(status);
+        		err = status.Int();
+        		if(KErrNone != err)
+        			{
+        			RDebug::Printf("Send request failed (%d)", err);
+        			User::Leave(err);
+        			}
+        		break;
+        		}            
+            call = StackOverflow;
+            break;
+        	}
+    }
+    
+    if(gKernelSide) 
+    	{    	
+    	CleanupStack::PopAndDestroy(&crashDriver);
+    	err = User::FreeLogicalDevice(RKernelCrashDrv::Name());
+    	if(KErrNone != err)
+    		{
+    		RDebug::Printf("Unable to free kernel crash driver");
+    		User::Leave(err);
+    		}
+    	}
+
+    if(gLibrary)
+    {
+        _LIT(KDllName, "esock.dll");
+        RLibrary dll;
+        TInt err = dll.Load(KDllName);
+    }
+
+    for(TInt i = 0; i < gChunks; i++)
+    {
+        RChunk chunk;
+
+        if(!i)
+        {
+            _LIT(KCrashChunk, "crashchunk");
+            RDebug::Printf("crashapp.exe - creating global chunk\n");
+            TInt err = chunk.CreateGlobal(KCrashChunk, 1024, 4096);
+            TUint8 data = 0xCA;
+            TUint8 *ptr = chunk.Base();
+            for(TInt i = 0; i < 1024; i++)
+                ptr[i] = data; 
+        }
+        else
+        {
+            RDebug::Printf("crashapp.exe - creating global chunk:%d\n", i);
+            TInt err = chunk.CreateLocal(512, 1024);
+            TUint8 data = 0xBA;
+            TUint8 *ptr = chunk.Base();
+            for(TInt i = 0; i < 512; i++)
+                ptr[i] = data; 
+        }
+    }
+
+    RDebug::Printf("crashapp.exe - allocating %d kbytes of heap space", gAlloc); 
+    if(gAlloc)
+    {
+        TAny *memory = User::Alloc(gAlloc*1024);
+        if(!memory)
+        {
+            RDebug::Printf("crashapp.exe - unable to allocate memory on the heap!!!\n");
+        }
+        else
+        {
+            TUint8 data = 0xDA;
+            TUint8 *ptr = (TUint8*)memory;
+            for(TInt i = 0; i < gAlloc*1024; i++)
+                ptr[i] = data;
+        }
+    }
+
+    if(gScreamer)
+    {
+        //screaming thread just
+        _LIT(KThreadSimon, "SimonTheFirst");
+        RThread threadSimon;
+        threadSimon.Create(KThreadSimon(), ThreadSimon, KDefaultStackSize, NULL, (TAny*)NULL);
+        threadSimon.Resume();
+        threadSimon.Close();
+    }
+
+
+    if(gMultikill == 0) //main thread crashes, no child threads
+    {
+        User::After(gDelay*1000000); //crash timeout
+        RDebug::Printf("crashapp.exe - main thread says...\n");
+        call();
+    }
+    else //child threads crashing
+    {
+        RDebug::Printf("crashapp.exe - child threads crashing every second...\n");
+        _LIT(KCrashThread, "crashthread%d");
+        TBuf<36> threadName;
+        for(TInt i = 0; i < gMultikill; i++)
+        {
+            RThread crashThread;
+            threadName.Format(KCrashThread, i);
+            crashThread.Create(threadName, ThreadCrash, KDefaultStackSize, NULL, (TAny*)call);
+            crashThread.Resume();
+            crashThread.Close();
+            User::After(1000000);
+        }
+    }
+    
+    RThread thread;
+    TUint mainCounter = 1;
+    while(mainCounter++) //main thread keep alive signals
+    {
+        User::After(300000);
+        RDebug::Printf("main thread[%Lu] loop:%d\n", thread.Id().Id(), mainCounter);
+        RDebug::Printf("setting property to %d: ", mainCounter);
+        err = RProperty::Set(KCrashAppUid, EMainThread, mainCounter);
+        if(err != KErrNone)
+            {
+            RDebug::Printf("Failed to set RProperty in main thread! err:%d\n", err);
+            }              
+    }
+    delete console;
+    
+    
+    if(array[0] > 1) //remove warning
+    	return;
+}
+
+TInt E32Main()
+{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	_LIT(KPanicCleanup, "CRASH-NO-CLEANUP");
+	__ASSERT_ALWAYS(cleanup, User::Panic(KPanicCleanup, KErrNoMemory));
+
+	TRAPD(err, MainL());
+	_LIT(KPanicLeave, "CRASH-LEAVE");
+ 	__ASSERT_ALWAYS(err == KErrNone, User::Panic(KPanicLeave, err));
+
+	delete cleanup;
+	__UHEAP_MARKEND;
+
+	return err;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/src/d_crashdriver_ldd.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,593 @@
+// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "t_crashdriver_drv.h"
+#include "d_crashdriver_ldd.h"
+#include "crash.h"
+#include <arm_types.h>
+//#include <scmonitor.h>
+
+/**
+ * Utility method to append a string to a kernel side descriptor
+ */
+void AppendString(TDes8& aDes, const char* aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list,aFmt);
+	Kern::AppendFormat(aDes,aFmt,list);
+	}
+
+/**
+ * DCrashDriverFactory
+ * Standard export function for LDDs. This creates a DLogicalDevice derived object,
+ * in this case, our DCrashDriverFactory
+ */
+DECLARE_STANDARD_LDD()
+    {
+    return new DCrashDriverFactory;
+    }
+
+/**
+ * Constructor
+ */
+DCrashDriverFactory::DCrashDriverFactory()
+    {
+    // Set version number for this device
+    iVersion=RKernelCrashDrv::VersionRequired();
+    }
+     
+     
+/**
+  Destructor
+*/
+DCrashDriverFactory::~DCrashDriverFactory()
+    {
+    }
+
+/**
+  Second stage constructor for DKernelCrashAppFactory.
+  This must at least set a name for the driver object.
+
+  @return KErrNone if successful, otherwise one of the other system wide error codes.
+*/
+TInt DCrashDriverFactory::Install()
+    {
+    return SetName(&RKernelCrashDrv::Name());
+    }
+
+/**
+  Return the drivers capabilities.
+  Called in the response to an RDevice::GetCaps() request.
+
+  @param aDes Descriptor into which capabilities information is to be written.
+*/
+void DCrashDriverFactory::GetCaps(TDes8& aDes) const
+    {
+    // Create a capabilities object
+    RKernelCrashDrv::TCaps caps;
+    caps.iVersion = iVersion;
+    // Write it back to user memory
+    Kern::InfoCopy(aDes,(TUint8*)&caps,sizeof(caps));
+    }
+
+
+/**
+  Called by the kernel's device driver framework to create a Logical Channel.
+  This is called in the context of the user thread (client) which requested the creation
+  of the Logical Channel (e.g. through a call to RBusLogicalChannel::DoCreate).
+  The thread is in a critical section.
+
+  @param aChannel Set to point to the created Logical Channel
+
+  @return KErrNone if successful, otherwise one of the other system wide error codes.
+*/
+TInt DCrashDriverFactory::Create(DLogicalChannelBase*& aChannel)
+    {
+    aChannel=new DCrashDriverChannel;
+    if(!aChannel)
+        return KErrNoMemory;
+
+    return KErrNone;
+    }
+
+
+//
+// Logical Channel
+//
+
+/**
+  Constructor
+*/
+DCrashDriverChannel::DCrashDriverChannel() :
+	iDfcQ(NULL)
+    {
+    // Get pointer to client thread's DThread object
+    iClient=&Kern::CurrentThread();
+
+    // Open a reference on client thread so its control block can't disappear until
+    // this driver has finished with it.
+    // Note, this call to Open() can't fail since it is the thread we are currently running in.
+    iClient->Open();
+    recurseCount = 0;
+    }
+
+
+/**
+  Destructor
+*/
+DCrashDriverChannel::~DCrashDriverChannel()
+    {
+    if(iDfcQ)
+    	iDfcQ->Destroy();
+    
+    // Cancel all processing that we may be doing
+    //DoCancel(RKernelCrashApp::EAllRequests); not needed as of now check while debugging - praveenc
+    //Close our reference on the client thread
+    Kern::SafeClose((DObject*&)iClient,NULL);
+    }
+
+
+/**
+  Second stage constructor called by the kernel's device driver framework.
+  This is called in the context of the user thread (client) which requested the creation
+  of the Logical Channel (e.g. through a call to RBusLogicalChannel::DoCreate())
+  The thread is in a critical section.
+
+  @param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate()
+  @param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate()
+  @param aVer The version argument supplied by the client to RBusLogicalChannel::DoCreate()
+
+  @return KErrNone if successful, otherwise one of the other system wide error codes.
+*/
+TInt DCrashDriverChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
+    {
+    if(!Kern::CurrentThreadHasCapability(ECapability_None,__PLATSEC_DIAGNOSTIC_STRING("Checked by crashdriver")))
+        return KErrPermissionDenied;
+     
+    // Check version
+    if (!Kern::QueryVersionSupported(RKernelCrashDrv::VersionRequired(),aVer))
+        return KErrNotSupported;
+    
+    // Setup LDD for receiving client messages.
+	TInt err = Kern::DynamicDfcQCreate(iDfcQ, 25, RKernelCrashDrv::Name());
+	if(err != KErrNone)
+		{
+		Kern::Printf("Creating Dfc queue failed.");  	
+		}
+	SetDfcQ(iDfcQ);       
+    iMsgQ.Receive();
+
+    return KErrNone;    
+    }
+
+
+/**
+  Called when a user thread requests a handle to this channel.
+*/
+TInt DCrashDriverChannel::RequestUserHandle(DThread* aThread, TOwnerType aType)
+    {
+    // Make sure that only our client can get a handle
+    if (aType!=EOwnerThread || aThread!=iClient)
+    	{    
+        return KErrAccessDenied;
+    	}
+    return KErrNone;    
+    }
+
+
+/**
+  Process a message for this logical channel.
+  This function is called in the context of a DFC thread.
+
+  @param aMessage The message to process.
+                  The iValue member of this distinguishes the message type:
+                  iValue==ECloseMsg, channel close message
+                  iValue==KMaxTInt, a 'DoCancel' message
+                  iValue>=0, a 'DoControl' message with function number equal to iValue
+                  iValue<0, a 'DoRequest' message with function number equal to ~iValue
+*/
+void DCrashDriverChannel::HandleMsg(TMessageBase* aMsg)
+    {    
+    TThreadMessage& m=*(TThreadMessage*)aMsg;//needs checking -praveenc
+
+    // Get message type
+    TInt id=m.iValue;
+
+    // Decode the message type and dispatch it to the relevent handler function...    
+    if (id==(TInt)ECloseMsg) //check later praveenc
+        {
+        // Channel Close        
+        m.Complete(KErrNone, EFalse);
+        return;
+        }   
+
+    if (id<0)
+        {
+        TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
+        TInt r=DoRequest(~id,pS,m.Ptr1(), m.Ptr2());
+        if (r==KErrNone)
+            Kern::RequestComplete(iClient,pS,r);
+        m.Complete(KErrNone,ETrue);
+        }
+    }
+
+/**
+ * Loop thread - infinite loop so we have a thread in a known state
+ * @param aPtr
+ * @return One of the symbian wide return codes
+ */
+TInt Loop(TAny* aPtr)
+	{    
+    TInt32 array[3];
+	array[0] = 0xDEADDEAD;
+	array[1] = 0xF000BEEF;
+	array[2] = 0xBEEBEE00;
+	
+	//set registers for known state for testing
+	SetRegs();
+	
+	//go into infinite loop
+	InfLoop();
+	
+	return array[0]; //to avoid warning - will never get here anyway
+	}
+
+TInt StartInfLoop()
+	{
+    //set registers for known state for testing
+    SetUpperRegs();
+	
+    //Launch another kernel thread
+    SThreadCreateInfo info;
+    info.iType = EThreadSupervisor;
+    info.iFunction = Loop; 
+    info.iPtr = NULL;
+    info.iSupervisorStack=NULL;
+    info.iSupervisorStackSize=0;    // zero means use default value
+    info.iInitialThreadPriority= 25;
+    info.iName.Set(_L("cdsknownthread"));
+    info.iTotalSize = sizeof(info);
+    
+    NKern::ThreadEnterCS();
+    TInt err = Kern::ThreadCreate(info);
+    NKern::ThreadLeaveCS();
+    
+    if(err != KErrNone)
+    	return err;
+    
+    DThread* kernTh = (DThread*)info.iHandle;
+    Kern::ThreadResume(*kernTh);
+    
+    NKern::Sleep(NKern::TimerTicks(3000)); //wait 3 seconds to ensure our other thread has been scheduled
+    
+    return KErrNone;
+	}
+
+/**
+  Process asynchronous requests
+*/
+TInt DCrashDriverChannel::DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2)
+    {               
+    
+    
+	Kern::Printf("DCrashDriverChannel::DoRequest");
+
+    TInt err = KErrNone;   
+    
+    switch(aReqNo)
+        {      
+        case RKernelCrashDrv::EPrefetchAbort:
+        	{    
+        	err = StartInfLoop();  
+        	if(err != KErrNone)
+        		return err;
+        	PrefetchAbort();
+        	break;
+        	}            
+        case RKernelCrashDrv::EDataRead:
+        	{
+        	err = StartInfLoop();  
+        	if(err != KErrNone)
+        		return err;
+        	DataRead();
+            break;
+        	}
+        case RKernelCrashDrv::EDataWrite:
+        	{
+        	err = StartInfLoop();  
+        	if(err != KErrNone)
+        		return err;
+        	DataWrite();
+            break;
+        	}         
+        case RKernelCrashDrv::EUndefInst:
+        	{
+        	err = StartInfLoop();  
+        	if(err != KErrNone)
+        		return err;
+        	UndefinedInst();
+            break;
+        	}            
+        case RKernelCrashDrv::EDivByZero:
+        	{
+        	err = StartInfLoop();  
+        	if(err != KErrNone)
+        		return err;
+        	DivByZero();
+        	break;
+        	}        	
+        case RKernelCrashDrv::EStackOverflow:
+        	{
+        	err = StartInfLoop();  
+        	if(err != KErrNone)
+        		return err;
+        	StackOverFlow();
+            break;
+        	}
+        case RKernelCrashDrv::ETestSCMConfigInsertMethod:
+        	{
+        	//read the argmuents
+        	HBuf8* tmp = HBuf8::New(KMaxBufferSize);
+        	
+        	TInt err = Kern::ThreadDesRead(iClient, a2, *tmp, 0, 0 );
+			if (err != KErrNone || tmp->MaxLength() < KMaxBufferSize)
+			{				
+				Kern::Printf("Unable to read argument or buffer too small");
+
+				// We could not read information from the user, so the a2 argument is probably wrong
+				Kern::RequestComplete(iClient, aStatus, KErrArgument);
+				return KErrArgument;
+			}
+        	
+			//run the test and gather the results
+			TBool pass;
+			
+			//run test
+        	//TestConfigInsertL(pass, *tmp);
+        	
+        	//write the results back to client thread
+        	err = Kern::ThreadRawWrite(iClient, a1, (TUint8*)&pass, sizeof(TBool), iClient);
+        	if(err != KErrNone)
+        		{
+				Kern::Printf("Unable to write data back to client");
+
+				// We could not read information from the user, so the a2 argument is probably wrong
+				Kern::RequestComplete(iClient, aStatus, KErrArgument);
+				return err;
+        		}
+        	
+        	//and write the buffer back...
+        	err = Kern::ThreadDesWrite(iClient, a2, *tmp, 0, 0, iClient);
+        	if(err != KErrNone)
+        		{
+        		Kern::Printf("Unable to write data back to client");
+        		
+				// We could not read information from the user, so the a2 argument is probably wrong
+				Kern::RequestComplete(iClient, aStatus, KErrArgument);
+				return err;
+        		}
+        	
+        	break;
+        	}
+        default:
+        	{        	
+            err=KErrNotSupported;
+            break;
+        	}
+        }
+
+    return err;
+    }
+
+
+/**
+  Process cancelling of asynchronous requests //need later -praveenc
+*/
+void DCrashDriverChannel::DoCancel(TUint aMask)
+    {
+    //give definition later - praveenc
+    //if(aMask&(1<<RKernelCrashApp::ESendData))
+      //  SendDataCancel();
+    //if(aMask&(1<<RKernelCrashApp::EReceiveData))
+      //  ReceiveDataCancel();
+    }
+
+/**
+ * Method to cause board to crash with a prefetch abort
+ */
+void DCrashDriverChannel::PrefetchAbort()
+	{
+    Tfunc f = NULL;
+    f();
+	}
+
+/**
+ * Method to cause board to read from a location we arent allowed
+ */
+void DCrashDriverChannel::DataRead()
+	{
+	Kern::Printf("Causing a data read crash");
+	TInt* r = (TInt*) 0x1000;
+   	TInt rr = (TInt)*r;
+
+	// Stop compilation warning. Should not get here anyway.
+	rr++;	
+	
+	}
+
+/**
+ * Method to cause board to crash from writing to a location we are not allowed
+ */
+void DCrashDriverChannel::DataWrite()
+	{
+	Kern::Printf("Causing a data write crash");
+  	TInt* r = (TInt*) 0x1000;
+   	*r = 0x42;
+	}
+
+/**
+ * Method to cause board to crash from executing an undefined instruction
+ */
+void DCrashDriverChannel::UndefinedInst()
+	{
+	Kern::Printf("Executing an undefined instruction");
+   	TUint32 undef = 0xE6000010;
+   	Tfunc f = (Tfunc) &undef;
+   	f();
+	}
+
+/**
+ * Method to cause board to crash with a division by zero
+ */
+void DCrashDriverChannel::DivByZero()
+	{
+	Kern::Printf("\tDivision By zero crash...");
+	int x = 5;
+	int y = 5;
+	for(y = 5; y>0; --y)
+		{
+		//this is to avoid compiler errors
+		}
+	x = x/y;
+	}
+
+/**
+ * Method to cause board to crash with a stack overflow
+ */
+void DCrashDriverChannel::StackOverFlow()
+	{
+	Kern::Printf("\tAbout to cause a stackoverflow");
+	TUint32 array[128];
+	array[0] = ++recurseCount;
+	StackOverFlow();
+	TUint warnRem = array[0];
+	array[0] = warnRem;
+	}
+
+// Testing methods for SCMConfig //
+
+/**
+ * This tests we can succesfully enter and retrieve items from our config class
+ *//*
+void DCrashDriverChannel::TestConfigInsertL(TBool& aPass, TDes8& aResult)
+	{	
+	//create our config object (We want a fresh one every time)
+	SCMConfiguration* config = new SCMConfiguration();
+	
+	TInt32 highPriority = 200;
+	TInt32 highishPriority = 150;
+	TInt32 mediumPriority = 100;
+	TInt32 lowishPriority = 50;
+	TInt32 lowPriority = 10;
+	
+	TUint8 numbytes1 = 20;
+	TUint8 numbytes2 = 30;
+	TUint8 numbytes3 = 40;
+	TUint8 numbytes4 = 50;
+	TUint8 numbytes5 = 60;
+	TUint8 numbytes6 = 10;
+	
+	config->SetConfigItem(SCMConfiguration::ECrashedProcessMetaData, highishPriority, numbytes2);
+	config->SetConfigItem(SCMConfiguration::ECrashedThreadMetaData, lowPriority, numbytes5);
+	config->SetConfigItem(SCMConfiguration::ECrashedThreadUsrRegisters, highPriority, numbytes1);
+	config->SetConfigItem(SCMConfiguration::EExceptionStacks, mediumPriority, numbytes3);
+	config->SetConfigItem(SCMConfiguration::EThreadsSvrStack, lowishPriority, numbytes4);
+	config->SetConfigItem(SCMConfiguration::EProcessMetaData, lowishPriority, numbytes6);
+	
+	//now we make sure they come back in the right order
+	TInt32 size = 0;
+	SCMConfiguration::TSCMDataType type;
+	
+	//for each item, ensure that the expected size and type is correct
+	type = config->GetNextItemToDump(size);
+	aPass = (type == SCMConfiguration::ECrashedThreadUsrRegisters ) && (size == numbytes1);
+		
+	if(!aPass)
+		{
+		delete config;
+		AppendString(aResult, "Expected ECrashedThreadUsrRegisters but got %d and expected size to be %d but got %d", type, numbytes1, size );
+		return;
+		}
+	
+	type = config->GetNextItemToDump(size);
+	aPass = (type == SCMConfiguration::ECrashedProcessMetaData ) && (size == numbytes2);
+	
+	if(!aPass)
+		{
+		delete config;
+		AppendString(aResult, "Expected ECrashedProcessMetaData but got %d and expected size to be %d but got %d", type, numbytes2, size );
+		return;
+		}
+	
+	type = config->GetNextItemToDump(size);
+	aPass = (type == SCMConfiguration::EExceptionStacks ) && (size == numbytes3);
+	
+	if(!aPass)
+		{
+		delete config;
+		AppendString(aResult, "Expected EExceptionStacks but got %d and expected size to be %d but got %d", type, numbytes3, size);
+		return;
+		}
+	
+	//these next 2 went in at the same priority but the last one that goes in will be retrieved first
+	type = config->GetNextItemToDump(size);
+	aPass = (type == SCMConfiguration::EProcessMetaData ) && (size == numbytes6);
+	
+	if(!aPass)
+		{
+		delete config;
+		AppendString(aResult, "Expected EProcessMetaData but got %d and expected size to be %d but got %d", type, numbytes6, size);
+		return;
+		}
+	
+	type = config->GetNextItemToDump(size);
+	aPass = (type == SCMConfiguration::EThreadsSvrStack ) && (size == numbytes4);
+	
+	if(!aPass)
+		{
+		delete config;
+		AppendString(aResult, "Expected EThreadsSvrStack but got %d and expected size to be %d but got %d", type, numbytes4, size);
+		return;
+		}
+	
+	type = config->GetNextItemToDump(size);
+	aPass = (type == SCMConfiguration::ECrashedThreadMetaData ) && (size == numbytes5);
+	
+	if(!aPass)
+		{
+		delete config;
+		AppendString(aResult, "Expected ECrashedThreadMetaData but got %d and expected size to be %d but got %d", type, numbytes5, size);
+		return;
+		}
+	
+	//if we get here, test has passed
+	aResult.Zero();
+	aResult.SetLength(50);
+	AppendString(aResult, "TestConfigInsertL passed");
+	aPass = ETrue;
+	
+	
+	delete config;
+	}*/
+
+//eof d_crashdriver_ldd.cpp
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/crashapps/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/elfdump/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,22 @@
+// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+PRJ_PLATFORMS
+TOOLS2
+
+PRJ_MMPFILES
+elfdump.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/elfdump/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/elfdump/elfdump.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1190 @@
+// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <symbianelfdefs.h>
+#include <sys/stat.h>
+#include <time.h>
+#if defined(__MSVCDOTNET__) || defined(__TOOLS2__)
+#include <iostream>
+#include <iomanip>
+using namespace std;
+#else //(!__MSVCDOTNET__ && !__TOOLS2__)
+#include <iostream.h>
+#include <iomanip.h>
+#endif //__MSVCDOTNET__
+
+#define ADDR(rtype, p, o) (rtype *)(((char *)p) + o)
+
+bool ignoreSomeSections;
+void hexdump_data(unsigned char *data,int aSize,int j)
+{
+	int i=0;
+	int p=0;
+
+	while (i<aSize)
+		{
+		int count=0;
+		if(p==0)
+		{
+			printf("\t0x%08x:\t\t\t",j);
+		} // offset into section
+
+		while (i<aSize && count<4)
+			{
+			printf("%02X", *data);		// print 4 lots of %08x for the data expresed as 32-bit word
+			data++;
+			i++;
+			count++;
+			j++;
+			}
+
+		printf("  ");
+		p++;
+		if (p==4)
+			{
+			data=data-16;
+			for (int i=0;i<16;i++)			//print 16 bytes of memory interpreted
+				{							//as ASCII characters with all non-printing
+				if (*data>32 && *data <127)	//characters converted to dots
+					{
+					printf("%1c",*data);
+					}
+				else
+					{
+					printf(".");
+					}
+					data++;
+				}
+			p=0;
+			printf("\n ");
+			}
+		}
+		//printf("\n");
+	}
+void hexdump(unsigned char* data, int aSize, int offset)
+	//  print hex dump of relevant sections
+	{
+	int i=0;
+	int p=0;
+	while (i<aSize)
+		{
+		int count=0;
+		if(p==0){printf("\t%06x   ",offset);} // offset into section
+		while (i<aSize && count<4)
+			{
+			printf("%02X", *data);		// print 4 lots of %08x for the data expresed as 32-bit word
+			data++;
+			i++;
+			count++;
+			offset++;
+			}
+
+		printf("  ");
+		p++;
+		if (p==4)
+			{
+			data=data-16;
+			for (int i=0;i<16;i++)			//print 16 bytes of memory interpreted
+				{							//as ASCII characters with all non-printing
+				if (*data>32 && *data <127)	//characters converted to dots
+					{
+					printf("%1c",*data);
+					}
+				else
+					{
+					printf(".");
+					}
+					data++;
+				}
+			p=0;
+			printf(" \n ");
+			}
+		}
+		printf(" \n\n ");
+	}
+
+void print_directive(unsigned char* data, int size)
+	// print formatted text of directive section
+	{
+	printf ("\t");
+
+	for (int i=0; i<size; i++)
+		{
+		if ((char)data[i]>31 && (char)data[i]<127)
+			{
+			printf ("%c", (char)data[i]);
+			}
+
+		if ((char)data[i]=='\n')
+			{
+			printf ("\n\t");
+			}
+		}
+
+	printf ("\n");
+	}
+
+void print_reloc(Elf32_Ehdr* eh, Elf32_Sym* symT, unsigned char* strtab)
+	// print relocation section
+	{
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, eh->e_shoff);
+	for (int j=0;j< eh->e_shnum;j++)
+		{
+		char* sname = ADDR(char, eh, shdr[eh->e_shstrndx].sh_offset);
+		if ( (shdr[j].sh_type==9) &&
+		     ( (!ignoreSomeSections) ||
+		       (strncmp(".rel.debug_", &sname[shdr[j].sh_name], 11))
+		     )
+		   )
+			{
+			unsigned char* data = ADDR(unsigned char, eh, shdr[j].sh_offset);
+			int noOfReloc=shdr[j].sh_size / shdr[j].sh_entsize;
+			printf("\n\n\n\t\t\t%s\n", &sname[shdr[j].sh_name]);
+			Elf32_Rel* rl=(Elf32_Rel*)data;				// pointer to relocation section
+			for (int i=0;i<noOfReloc;i++)
+				{
+				unsigned char* symbolName = strtab;		// pointer to firest element of string											// table which holds symbol names
+				Elf32_Sym*  sym = symT;					// pointer to symbol table
+				int symTIndx= ELF32_R_SYM(rl->r_info);		// symbol Tableindex
+				sym=sym+symTIndx;
+				symbolName=symbolName+sym->st_name;		// index into string table section
+															// with symbol names
+				printf("\t0x%08x \t", rl->r_offset);		// prints offset into relocation section
+				printf("%d", symTIndx);					// symbol table index
+				printf("\t%s\n",symbolName);				// symbol name
+				rl++;
+				}
+			}
+		}
+	}
+
+void print_GlSymbols(Elf32_Ehdr* eh, Elf32_Sym* symT, unsigned char* strtab)
+	// print global symbols from Symbol Table
+	{
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, eh->e_shoff);
+	char* sname = ADDR(char, eh, shdr[eh->e_shstrndx].sh_offset);
+	for (int i=0;i< eh->e_shnum;i++)
+		{
+		if (!strcmp(".symtab", &sname[shdr[i].sh_name]))
+			{
+		  	int noOfSym=shdr[i].sh_size / shdr[i].sh_entsize; 	// number of symbols
+		  	const char *symName =(const char *)strtab;
+		  	int count = 1;
+		  	printf("Global symbols:\n");
+		  	printf("=================\n\n");
+		  	for (int l=0;l< noOfSym ;l++)
+				{
+				symT=symT+1;
+				if( ELF32_ST_BIND(symT->st_info) == 1)			// searching for global symbols
+			 		{
+			  		symName = symName + symT->st_name;			// index into string table section
+			 		printf("%d	",count);
+			  		printf(symName);
+			  		printf("\n");
+			  		symName = symName - symT->st_name;			// back to pointing to first byte of string table
+			  		count++;
+					}
+
+				}
+			}
+		}
+	}
+
+void print_elf_header(Elf32_Ehdr* eh)
+	{
+	// print elf header
+	if (eh->e_version==1)
+		printf("\tHeader version: EV_CURRENT (Current version)\n");
+	else
+		printf("\tInvalid version: EV_NONE (Invalid version)\n");
+
+	printf("\tFile Type\t\t\t:");
+	if (eh->e_type==0)
+		printf("ET_NONE (No file type) (0)\n");
+	else if (eh->e_type==1)
+		printf("ET_REL (Relocatable object) (1)\n");
+	else if (eh->e_type==2)
+		printf("ET_EXEC (Executable file) (2)\n");
+	else if (eh->e_type==3)
+		printf("ET_DYN (Shared object file) (3)\n");
+	else if (eh->e_type==4)
+		printf("ET_CORE (Core File) (4)\n");
+	else if (eh->e_type==65280)
+		printf("ET_LOPROC (Precessor Specific) (ff00)\n");
+	else
+		printf("ET_HIPROC (Precessor Specific) (ffff)\n");
+
+	if (eh->e_machine==40)
+		printf("\tMachine\t\t\t\t:EM_ARM (ARM)\n");
+	else
+		printf("\tERROR:\tUnexpected machine\n");
+
+	if(eh->e_ident[EI_DATA] == ELFDATA2LSB)
+		printf("\tData Encoding\t\t\t:ELFDATA2LSB\n");
+	else if(eh->e_ident[EI_DATA] == ELFDATA2MSB)
+		printf("\tData Encoding\t\t\t:ELFDATA2MSB\n");
+
+	printf("\tEntry offset (in SHF_ENTRYSECT section):0x%08x \n",eh->e_entry);
+	printf("\tProgram header entries\t\t:%d\n",eh->e_phnum);
+	printf("\tSection header entries\t\t:%d\n",eh->e_shnum);
+	printf("\tProgram header offset\t\t:%d",eh->e_phoff);
+	printf("  bytes (0x%08X",eh->e_phoff);
+	printf(")\n");
+	printf("\tSection header offset\t\t:%d",eh->e_shoff);
+	printf("  bytes (0x%08X",eh->e_shoff);
+	printf(")\n");
+
+	printf("\tProgram header entry size\t:%d",eh->e_phentsize);
+	printf("  bytes (0x%02X",eh->e_phentsize);
+	printf(")\n");
+	printf("\tSection header entry size\t:%d",eh->e_shentsize);
+	printf("  bytes (0x%02X",eh->e_shentsize);
+	printf(")\n");
+	printf("\tSection header string table index: %d \n", eh->e_shstrndx);
+	printf("\tHeader size\t\t\t:%d", eh->e_ehsize);
+	printf("  bytes (0x%02X",eh->e_ehsize);
+	printf(")\n");
+	}
+
+void print_sect_header(char* sname, Elf32_Shdr* shdr, int count)
+	// print section header names
+	{
+	static const char* KtypeName[]={"0","SHT_PROGBITS (1)","SHT_SYMTAB (2)","SHT_STRTAB (3)",
+								  "SHT_RELA (4)","5",	"SHT_DINAMIC (6)","7","8","SHT_REL (9)",
+								  "10","SHT_DINSYM (11)"};
+
+	printf("\n\n\tName\t\t:%1s\n ",&sname[shdr[count].sh_name]);
+	printf("\tType\t\t: %s\n",  KtypeName[shdr[count].sh_type]);
+	printf("\tAddr\t\t: 0x%08X\n",shdr[count].sh_addr);
+	printf("\tSize\t\t: %1d", shdr[count].sh_size);
+	printf("  bytes (0x%X",shdr[count].sh_size);
+	printf(")\n");
+	printf("\tEntry Size\t: %1d\n",shdr[count].sh_entsize);
+	printf("\tAligment\t: %1d\n\n\n",shdr[count].sh_addralign);
+	}
+
+unsigned char* findSymbolStringT(Elf32_Ehdr* eh)
+	//calculate and return pointer to the first byte of string table(the one with symbol names)
+	{
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, eh->e_shoff);
+	char* sname = ADDR(char, eh, shdr[eh->e_shstrndx].sh_offset);
+	for (int i=0;i < eh->e_shnum; i++)
+		{
+		if (!strcmp(".strtab", &sname[shdr[i].sh_name]))
+			{
+			unsigned char* data = ADDR(unsigned char, eh, shdr[i].sh_offset);
+			return data;	//pointer to the first byte of string table section
+			}
+		}
+	return NULL;	//if not found
+	}
+
+Elf32_Sym* findSymbolT(Elf32_Ehdr* eh)
+	//calculate and return pointer to the first element of symbol table
+	{
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, eh->e_shoff);
+	for (int i=0;i < eh->e_shnum;i++)
+		{
+		if (shdr[i].sh_type==2)
+			{
+			unsigned char* data = ADDR(unsigned char, eh, shdr[i].sh_offset);
+			Elf32_Sym* sym=(Elf32_Sym*)data;
+			return sym;		//pointer to the first element of symbol table.
+			}
+		}
+	return NULL; // if not found
+	}
+
+void print_Summary(Elf32_Ehdr* eh)
+	{
+	//print section names
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, eh->e_shoff);
+	char* sname = ADDR(char, eh, shdr[eh->e_shstrndx].sh_offset);
+	printf("\nSummary: \n");
+	printf("==========\n");
+	for (int i=0;i< eh->e_shnum;i++)
+		{
+		printf(&sname[shdr[i].sh_name]);
+		printf("\n");
+		}
+	}
+
+bool printAll;
+/*char  *ctime( const time_t *date)
+{
+
+}*/
+
+enum TCrashType { ECrashException, ECrashKill };
+
+enum TExcType
+	{
+	EExcGeneral=0,
+	EExcIntegerDivideByZero=1,
+	EExcSingleStep=2,
+	EExcBreakPoint=3,
+	EExcIntegerOverflow=4,
+	EExcBoundsCheck=5,
+	EExcInvalidOpCode=6,
+	EExcDoubleFault=7,
+	EExcStackFault=8,
+	EExcAccessViolation=9,
+	EExcPrivInstruction=10,
+	EExcAlignment=11,
+	EExcPageFault=12,
+	EExcFloatDenormal=13,
+	EExcFloatDivideByZero=14,
+	EExcFloatInexactResult=15,
+	EExcFloatInvalidOperation=16,
+	EExcFloatOverflow=17,
+	EExcFloatStackCheck=18,
+	EExcFloatUnderflow=19,
+	EExcAbort=20,
+	EExcKill=21,
+	EExcUserInterrupt=22,
+	EExcDataAbort=23,
+	EExcCodeAbort=24,
+	EExcMaxNumber=25,
+	EExcInvalidVector=26,
+	};
+
+char * TExcTypeNames[EExcInvalidVector+1] =
+	{
+	"EExcGeneral",
+	"EExcIntegerDivideByZero",
+	"EExcSingleStep",
+	"EExcBreakPoint",
+	"EExcIntegerOverflow",
+	"EExcBoundsCheck",
+	"EExcInvalidOpCode",
+	"EExcDoubleFault",
+	"EExcStackFault",
+	"EExcAccessViolation",
+	"EExcPrivInstruction",
+	"EExcAlignment",
+	"EExcPageFault",
+	"EExcFloatDenormal",
+	"EExcFloatDivideByZero",
+	"EExcFloatInexactResult",
+	"EExcFloatInvalidOperation",
+	"EExcFloatOverflow",
+	"EExcFloatStackCheck",
+	"EExcFloatUnderflow",
+	"EExcAbort",
+	"EExcKill",
+	"EExcUserInterrupt",
+	"EExcDataAbort",
+	"EExcCodeAbort",
+	"EExcMaxNumber",
+	"EExcInvalidVector"
+	};
+
+void print_symbian_info(Sym32_syminfod *syminfod)
+{
+
+	//printf("\tDate and time of the crash\t:=0x%X",syminfod->sd_date_time );
+	const time_t unix_time = 62168256000LL;//from 0AD to 1970 in seconds = 365*1971*86 400
+	//printf("\traw Date =0x%X\n", (syminfod->sd_date_time[1]<<32+syminfod->sd_date_time[0])/*/1000000*/ );
+    time_t date = syminfod->sd_date_time/1000000; //convert to seconds
+    date -= unix_time; //convert to unix time
+	printf("\tDate and time of the crash\t: %s\n", ctime(&date));
+
+	if( SYM32_EXECID_SIZE != sizeof(Sym32_execid) )
+		{
+		printf("\tWarning! : Expected Size of EXECUTABLE ID %d is different from sizeof operator %d\n\n",
+			SYM32_EXECID_SIZE, sizeof(Sym32_execid) );
+		}
+
+	printf("\tExecutable Crc32 (first 1kb)\t:0x%X\n",syminfod->sd_execid.exec_crc );
+
+	if( ECrashException == syminfod->sd_exit_type )
+		{
+		printf("\tHardware Exception\t\t:%d\n",syminfod->sd_exit_reason);
+		//printf("\tException Type\t\t\t:%s\n", TExcTypeNames[syminfod->sd_exit_reason] );
+		}
+	else if ( ECrashKill == syminfod->sd_exit_type )
+		{
+		printf("\tExit Type\t\t\t:%d",syminfod->sd_exit_reason);
+		switch(syminfod->sd_exit_reason)
+			{
+			case 0:printf(":EExitKill\n");		break;
+			case 1:printf(":EExitTerminate\n");	break;
+			case 2:printf(":EExitPanic\n");		break;
+			case 3:printf(":EExitPending\n");	break;
+			default:printf(":Unknown\n");			break;
+			}
+		}
+	else
+		{
+		printf("\t\tUnknown Crash Type\n" );
+		}
+
+	printf("\tCrashed Thread Id\t\t:0x%X\n",syminfod->sd_thread_id);
+	printf("\tOwning process\t\t\t:0x%X\n",syminfod->sd_proc_id);
+}
+
+void print_lockdata_info(Sym32_lockdata* lockdata)
+	{
+	printf("\n\n\tNum locks\t\t\t:%d\n", lockdata->lk_lock_count);
+	printf("\tmutex thread wait count\t\t:%d\n",lockdata->lk_mutex_thread_wait_count);
+	printf("\tmutex thread held count\t\t:%d\n",lockdata->lk_mutex_held_count);
+	}
+
+void print_thread_info(Sym32_thrdinfod *thrdinfod)
+{
+
+	//printf("\tIndex into the CORE.SYMBIAN.STR note segment defining");
+	//printf(" the name of the thread or ESYM_STR_UNDEF :%d\n",thrdinfod->td_name);
+	printf("\tThread ID\t\t\t:0x%X\n",thrdinfod->td_id);
+	printf("\tOwning process\t\t\t:0x%X\n",thrdinfod->td_owning_process);
+	printf("\tThread Priority\t\t\t:%d\n",thrdinfod->td_priority);
+	printf("\tSupervisor Stack Pointer\t:0x%08X\n",thrdinfod->td_svc_sp);
+	printf("\tSupervisor Stack Address\t:0x%08X\n",thrdinfod->td_svc_stack);
+	printf("\tSupervisor Stack Size\t\t:%u",thrdinfod->td_svc_stacksz);
+	printf("  bytes (0x%08X",thrdinfod->td_svc_stacksz);
+	printf(")\n");
+    printf("\tUser Stack Address\t\t:0x%08X\n",thrdinfod->td_usr_stack);
+    printf("\tUser Stack Size\t\t\t:%u",thrdinfod->td_usr_stacksz);
+	printf("  bytes (0x%08X)\n",thrdinfod->td_usr_stacksz);
+    printf("\tHeap base Address\t\t:0x%08X\n",thrdinfod->td_heap_add);
+    printf("\tHeap Size\t\t\t:%u",thrdinfod->td_heap_sz);
+	printf("  bytes (0x%08X)\n",thrdinfod->td_heap_sz);
+}
+
+void print_process_info(Sym32_procinfod *procinfod)
+{
+
+	//printf("\t\t\tIndex into the CORE.SYMBIAN.STR note segment defining");
+	//printf(" the name of the process or ESYM_STR_UNDEF:%d\n",procinfod->pd_name);
+	printf("\tProcess ID\t\t\t:0x%X\n",procinfod->pd_id);
+	printf("\tProcess Priority\t\t:%d\n",procinfod->pd_priority);
+
+}
+
+void print_executable_info(Sym32_execinfod *execinfod)
+{
+
+	printf("\tExecutable ID\t\t\t:0x%08X\n",execinfod->ed_execid.exec_id);
+	printf("\tExecutable Crc32 (first 1kb)\t:0x%X\n",execinfod->ed_execid.exec_crc );
+
+	if(execinfod->ed_XIP == 1)
+	{
+		printf("\tXIP ROM\t\t\t\t:TRUE\n");
+    }
+    else if(execinfod->ed_XIP == 0)
+    {
+	     printf("\tXIP ROM\t\t\t\t:FALSE\n");
+    }
+
+	printf("\tSize of executable code segment\t\t\t:%d",execinfod->ed_codesize);
+	printf("  bytes (0x%08X)\n",execinfod->ed_codesize);
+
+	printf("\tExecution address of the code segment\t\t:0x%08X\n",execinfod->ed_coderunaddr);
+
+	printf("\tBuild address of the code segment\t\t:0x%08X\n",execinfod->ed_codeloadaddr);
+
+	printf("\tSize of the executable read only data segment\t:%d",execinfod->ed_rodatasize);
+	printf("  bytes (0x%08X)\n",execinfod->ed_rodatasize);
+
+	printf("\tExecution address of the read only data segment\t:0x%08X\n",execinfod->ed_rodatarunaddr);
+
+    printf("\tBuild address of the read only data segment\t:0x%08X\n",execinfod->ed_rodataloadaddr);
+
+    printf("\tSize of the executable data segment\t\t:%d", execinfod->ed_datasize);
+	printf("  bytes (0x%08X)\n",execinfod->ed_datasize);
+
+    printf("\tExecution address of the data segment\t\t:0x%08X\n",execinfod->ed_datarunaddr);
+
+    printf("\tBuild address of the data segment\t\t:0x%08X\n",execinfod->ed_dataloadaddr);
+}
+
+//void print_register_info(Sym32_reginfod *reginfod,unsigned int nreg,Sym32_regdatad *regdatad,char *array,unsigned int elenum)
+void print_register_info( Sym32_reginfod *reginfod, Elf32_Ehdr* eh, char *array )
+{
+	printf("\tVersion of the register data info descriptor\t:%s\n",&array[reginfod->rid_version]);
+	printf("\tThread ID\t\t\t:0x%X\n",reginfod->rid_thread_id);
+	printf("\tNumber of registers\t\t:%d\n",reginfod->rid_num_registers);
+
+	printf("\tRegister Class\t\t\t:%d",reginfod->rid_class);
+	switch( reginfod->rid_class )
+		{
+		case ESYM_REG_CORE:
+			printf( " : ESYM_REG_CORE\n" );
+			break;
+		case ESYM_REG_COPRO:
+			printf( " : ESYM_REG_COPRO\n" );
+			break;
+		default:
+			printf( " : Unknown Register Class\n" );
+		}
+
+	printf("\tRegister Representation\t\t:%d",reginfod->rid_repre );
+	switch( reginfod->rid_repre )
+		{
+		case ESYM_REG_8:
+			printf( " : ESYM_REG_8\n" );
+			break;
+		case ESYM_REG_16:
+			printf( " : ESYM_REG_16\n" );
+			break;
+		case ESYM_REG_32:
+			printf( " : ESYM_REG_32\n" );
+			break;
+		case ESYM_REG_64:
+			printf( " : ESYM_REG_64\n" );
+			break;
+		default:
+			printf( "\n" );
+		}
+
+	printf( "\n" );
+
+	Sym32_regdatad *regdatad = ADDR(Sym32_regdatad, reginfod, sizeof (Sym32_reginfod) );
+
+	for( unsigned int i = 0; i < reginfod->rid_num_registers; i++ )
+	{
+		printf("\tRegister ID\t\t\t:0x%X ", regdatad->rd_id);
+
+		if( ESYM_REG_CORE == reginfod->rid_class )
+		{
+			switch(regdatad->rd_id)
+			{
+				case 0x00000000: printf("ARM REGISTER R0\n"); break;
+				case 0x00000100: printf("ARM REGISTER R1\n"); break;
+				case 0x00000200: printf("ARM REGISTER R2\n"); break;
+				case 0x00000300: printf("ARM REGISTER R3\n"); break;
+				case 0x00000400: printf("ARM REGISTER R4\n"); break;
+				case 0x00000500: printf("ARM REGISTER R5\n"); break;
+				case 0x00000600: printf("ARM REGISTER R6\n"); break;
+				case 0x00000700: printf("ARM REGISTER R7\n"); break;
+				case 0x00000800: printf("ARM REGISTER R8\n"); break;
+				case 0x00000900: printf("ARM REGISTER R9\n"); break;
+				case 0x00000a00: printf("ARM REGISTER R10\n"); break;
+				case 0x00000b00: printf("ARM REGISTER R11\n"); break;
+				case 0x00000c00: printf("ARM REGISTER R12\n"); break;
+				case 0x00000d00: printf("ARM REGISTER R13\n"); break;
+				case 0x00000e00: printf("ARM REGISTER R14\n"); break;
+				case 0x00000f00: printf("ARM REGISTER R15\n"); break;
+				case 0x00001000: printf("ARM REGISTER CPSR\n"); break;
+				case 0x00001100: printf("ARM REGISTER R13_SVC\n"); break;
+				case 0x00001200: printf("ARM REGISTER R14_SVC\n"); break;
+				case 0x00001300: printf("ARM REGISTER SPSR_SVC\n"); break;
+				case 0x00001400: printf("ARM REGISTER R13_ABT\n"); break;
+				case 0x00001500: printf("ARM REGISTER R14_ABT\n"); break;
+				case 0x00001600: printf("ARM REGISTER SPSR_ABT\n"); break;
+				case 0x00001700: printf("ARM REGISTER R13_UND\n"); break;
+				case 0x00001800: printf("ARM REGISTER R14_UND\n"); break;
+				case 0x00001900: printf("ARM REGISTER SPSR_UND\n"); break;
+				case 0x00001a00: printf("ARM REGISTER R13_IRQ\n"); break;
+				case 0x00001b00: printf("ARM REGISTER R14_IRQ\n"); break;
+				case 0x00001c00: printf("ARM REGISTER SPSR_IRQ\n"); break;
+				case 0x00001d00: printf("ARM REGISTER R8_FIQ\n"); break;
+				case 0x00001e00: printf("ARM REGISTER R9_FIQ\n"); break;
+				case 0x00001f00: printf("ARM REGISTER R10_FIQ\n"); break;
+				case 0x00002000: printf("ARM REGISTER R11_FIQ\n"); break;
+				case 0x00002100: printf("ARM REGISTER R12_FIQ\n"); break;
+				case 0x00002200: printf("ARM REGISTER R13_FIQ\n"); break;
+				case 0x00002300: printf("ARM REGISTER R14_FIQ\n"); break;
+				case 0x00002400: printf("ARM REGISTER SPSR_FIQ\n"); break;
+				default:printf("Unknown Core Register\n"); break;
+			} // switch
+		} // if CORE
+		else
+		{
+			printf("\n\tRegister SubId\t\t\t:0x%X\n",regdatad->rd_sub_id);
+		}
+
+		switch( reginfod->rid_repre )
+		{
+		case ESYM_REG_8:
+			Elf32_Byte * val8;
+			val8 = ADDR( Elf32_Byte, eh, regdatad->rd_data );
+			printf( "\tESYM_REG_8 Value\t\t:0x%02X\n", *val8 );
+			break;
+		case ESYM_REG_16:
+			Elf32_Half * val16;
+			val16 = ADDR( Elf32_Half, eh, regdatad->rd_data );
+			printf( "\tESYM_REG_16 Value\t\t:0x%04X\n", *val16 );
+			break;
+		case ESYM_REG_32:
+			Elf32_Word * val32;
+			val32 = ADDR( Elf32_Word, eh, regdatad->rd_data );
+			printf( "\tESYM_REG_32 Value\t\t:0x%08X\n", *val32 );
+			break;
+
+		case ESYM_REG_64:
+			// We need to split the printing of a 64 bit number since the
+			// printf is not working correctly for this size.
+			Elf32_Word * val64_0;
+			Elf32_Word * val64_1;
+			val64_0 = ADDR( Elf32_Word, eh, regdatad->rd_data );
+			val64_1 = ADDR( Elf32_Word, eh, regdatad->rd_data + 4 );
+			printf( "\tESYM_REG_64 Value\t\t:0x%X%X\n", *val64_1, *val64_0 );
+			break;
+
+		default:
+			printf( "\n" );
+		}
+
+		regdatad++;
+	} // for
+ }
+
+void print_trace_info( Sym32_tracedata *aTraceData, Elf32_Ehdr* aElfHdr, char *aArray)
+	{
+	printf("\tVersion of the trace data info descriptor\t:%s\n", &aArray[aTraceData->tr_version]);
+	printf("\tSize of trace buffer\t\t:%d bytes\n", aTraceData->tr_size);
+
+	if(aTraceData->tr_data == 0)
+		{
+		printf("\tNo trace data present\n");
+		}
+	else
+		{
+		unsigned char* data = ADDR(unsigned char, aElfHdr, aTraceData->tr_data);
+		printf("\tTrace Data starts at\t\t:0x%X\n", data);
+		}
+	}
+void print_variant_data(const Sym32_variant_spec_data* aVarData, const Elf32_Ehdr* aElfHeader)
+	{
+	printf("\n\n\tVariant data size\t\t:0x%X\n", aVarData->es_size);
+
+	unsigned char* data = ADDR(unsigned char, aElfHeader, aVarData->es_data);
+	hexdump_data(data, aVarData->es_size, 0);
+	printf("\n");
+	}
+
+void print_rom_info(const Sym32_rombuild* aRomInfo)
+	{
+	printf("\tROM Major Version\t\t:%hd\n", aRomInfo->rom_major_version);
+	printf("\tROM Minor Version\t\t:%hd\n",aRomInfo->rom_minor_version);
+	printf("\tROM Build Number\t\t:%hd\n",aRomInfo->rom_build);
+
+	const time_t unix_time = 62168256000LL;//from 0AD to 1970 in seconds = 365*1971*86 400
+	time_t date = aRomInfo->rom_time/1000000; //convert to seconds
+	date -= unix_time; //convert to unix time
+	printf("\tDate and time of the ROM Build\t:%s", ctime(&date));
+	}
+
+int do_elf_file(char* buffer, char* name)
+	{
+	Elf32_Ehdr* eh=(Elf32_Ehdr *)buffer;	//elf header
+	if (eh->e_ident[EI_MAG0] !=0x7f || eh->e_ident[EI_MAG1] != 0x45 || eh->e_ident[EI_MAG2] !=0x4c || eh->e_ident[EI_MAG3] != 0x46)
+		{
+		// EI_MAG0 to EI_MAG3 - A files' first 4 bytes hold a 'magic number', identifying the file as an ELF object file.
+		printf("Error: %s is not a valid ELF file", name);
+		return 1;
+		}
+	if (eh->e_ident[EI_DATA] == 2)
+		{
+		// ELF Header size should be 52 bytes or converted into Big-Endian system 13312
+		if (eh->e_ehsize != 13312)
+			{
+			printf("\tERROR:\tELF Header contains invalid file type\n");
+			exit(1);
+			}
+		// e_ident[EI_DATA] specifies the data encoding of the processor-specific data in the object file.
+		printf("\tERROR:\tData encoding ELFDATA2MSB (Big-Endian) not supported\n");
+		exit(1);
+		}
+	if (eh->e_ehsize != 52)
+		{
+		// ELF Header size should be 52 bytes
+		printf("\tERROR:\tELF Header contains invalid file type\n");
+		exit(1);
+		}
+
+	printf("\n\nELF HEADER INFORMATION\n");
+	print_elf_header(eh);									// print Elf Header
+	int phnum = eh->e_phnum;
+	int phoff =eh->e_phoff;
+	Elf32_Phdr* phdr = ADDR(Elf32_Phdr,eh,phoff);
+
+	//segments start here
+	char *array = NULL;
+	for(int j = 0; j < phnum; j++)
+		{
+		if(phdr[j].p_type == PT_NOTE)
+			{
+			Sym32_dhdr *dhdr = ADDR(Sym32_dhdr, eh, phdr[j].p_offset);
+			if(dhdr->d_type == ESYM_NOTE_STR)
+				{
+				array = (char*)dhdr + sizeof(Sym32_dhdr);
+				}
+			}
+		}
+
+	for(int i = 0; i < phnum; i++)
+		{
+		unsigned int data = phdr[i].p_offset;
+
+		if( SYM32_DESCHDR_SIZE != sizeof(Sym32_dhdr) )
+			{
+			printf("\n\tWarning! : Expected Size of SYM32_DESCHDR_SIZE %d is different from sizeof(Sym32_dhdr) %d\n\n",
+				 SYM32_DESCHDR_SIZE, sizeof(Sym32_dhdr) );
+			}
+
+		Sym32_dhdr *dhdr = ADDR(Sym32_dhdr,eh,data);
+		printf("\nPROGRAM HEADER ENTRY  %d INFORMATION \n",i);
+		printf("\tHeader offset\t\t\t:%d",phdr[i].p_offset);
+		printf("  bytes (0x%08X",phdr[i].p_offset);
+		printf(")\n");
+		printf("\tVirtual address\t\t\t:0x%08X\n",phdr[i].p_vaddr);
+
+		printf("\tSize of mapping from the file\t:0x%X (%d bytes)\n",phdr[i].p_filesz, phdr[i].p_filesz);
+		printf("\tSize of mapping in memory\t:0x%X (%d bytes)\n",phdr[i].p_memsz, phdr[i].p_memsz);
+
+		unsigned int  flag = phdr[i].p_flags;
+		switch(flag)
+			{
+			case 1 :
+				printf("\tFlag\t\t\t\t:PF_X : (1) \n");
+				break;
+			case 2 :
+				printf("\tFlag\t\t\t\t:PF_W: (2) \n");
+				break;
+			case 4 :
+				printf("\tFlag\t\t\t\t:PF_R : (4) \n");
+				break;
+			case 5:
+				printf("\tFlag\t\t\t\t:PF_X|PF_R : (5)\n");
+				break;
+			case 6:
+				printf("\tFlag\t\t\t\t:PF_W|PF_R : (6)\n");
+				break;
+			}
+
+		printf("\tAlignment to word boundary      :%d \n",phdr[i].p_align);
+
+		if(phdr[i].p_type == PT_LOAD)
+			{
+			printf("\tLOADABLE CODE/DATA SEGMENT\n"); //load
+			unsigned char* data = ADDR(unsigned char, eh, phdr[i].p_offset);
+			const int scope = 128;
+			//printf("\tDatasegment starts from here:%p, size:%d\n",data, phdr[i].p_memsz);
+			if(phdr[i].p_filesz == 0) continue;
+			if(phdr[i].p_filesz < 2*scope)
+				hexdump_data(data,phdr[i].p_memsz,phdr[i].p_vaddr);
+			else
+				{
+				hexdump_data(data,scope,phdr[i].p_vaddr);
+				printf("\t...\n");
+				hexdump_data(data+phdr[i].p_filesz-scope,scope,phdr[i].p_vaddr+phdr[i].p_filesz-scope);
+				}
+			if(phdr[i].p_filesz%16) printf("\n");
+			}
+		else if(phdr[i].p_type == PT_NOTE)
+			{
+			printf("\tName of the descriptor\t\t:%s\n",&array[dhdr->d_name]);
+			printf("\tSize of single descriptor element:%d \n",dhdr->d_descrsz);
+			printf("\tVersion string\t\t\t:%s\n",&array[dhdr->d_version]);
+			printf("\tNumber of descriptor elements\t:%d\n",dhdr->d_elemnum);
+			printf("\tSegment type\t\t\t:");
+
+			if( dhdr->d_type == ESYM_NOTE_SYM )
+				{
+				printf("SYMBIAN INFO SEGMENT\n\n");
+
+				if( sizeof(Sym32_syminfod) != dhdr->d_descrsz )
+					{
+					printf("\tWarning! : sizeof(Sym32_syminfod) %d is different from descriptor size %d\n\n",
+						 sizeof(Sym32_syminfod), dhdr->d_descrsz );
+					}
+
+				if( SYM32_SYMINFO_SIZE != dhdr->d_descrsz )
+					{
+					printf("\tWarning! : Expected Size of SYMBIAN INFO SEGMENT %d is different from descriptor size %d\n\n",
+						 SYM32_SYMINFO_SIZE, dhdr->d_descrsz );
+					}
+
+				Sym32_syminfod *syminfod = ADDR(Sym32_syminfod,eh,data+sizeof(Sym32_dhdr));
+				if( syminfod->sd_exit_cat > 0 )
+					{
+					printf("\tCrash reason\t\t\t:%s\n",&array[syminfod->sd_exit_cat]);
+					}
+				print_symbian_info(syminfod);
+				}
+			else if( dhdr->d_type == ESYM_NOTE_THRD)
+				{
+				printf("THREAD INFO SEGMENT\n\n");
+
+				if( sizeof(Sym32_thrdinfod) != dhdr->d_descrsz )
+					{
+					printf("\tWarning! : sizeof(Sym32_thrdinfod) %d is different from descriptor size %d\n\n",
+						sizeof(Sym32_thrdinfod), dhdr->d_descrsz );
+					}
+
+				if( SYM32_THRINFO_SIZE!= dhdr->d_descrsz )
+					{
+					printf("\tWarning! : Expected Size of THREAD INFO SEGMENT %d is different from descriptor size %d\n\n",
+						 SYM32_THRINFO_SIZE, dhdr->d_descrsz );
+					}
+
+				Sym32_thrdinfod *thrdinfod = ADDR(Sym32_thrdinfod,eh,data+sizeof(Sym32_dhdr));
+				for(int thrIdx = 0; thrIdx < dhdr->d_elemnum; thrIdx++ )
+					{
+					printf("\tThread Name\t\t\t:%s\n",&array[thrdinfod->td_name]);
+					print_thread_info(thrdinfod);
+					thrdinfod ++;
+					}
+				}
+			else if(dhdr->d_type == ESYM_NOTE_PROC )
+				{
+				printf("PROCESS INFO SEGMENT\n\n");
+
+				if( sizeof(Sym32_procinfod) != dhdr->d_descrsz )
+					{
+					printf("\tWarning! :  sizeof(Sym32_procinfod) %d is different from descriptor size %d\n\n",
+						sizeof(Sym32_procinfod), dhdr->d_descrsz );
+					}
+
+				if( SYM32_PROCINFO_SIZE != dhdr->d_descrsz )
+					{
+					printf("\tWarning! : Expected Size of PROCESS INFO SEGMENT %d is different from descriptor size %d\n\n",
+						 SYM32_PROCINFO_SIZE, dhdr->d_descrsz );
+					}
+
+				Sym32_procinfod *procinfod = ADDR(Sym32_procinfod,eh,data+sizeof(Sym32_dhdr));
+
+				for(int procIdx = 0; procIdx < dhdr->d_elemnum; procIdx ++ )
+					{
+					printf("\tProcess Name\t\t\t:%s\n",&array[procinfod->pd_name]);
+					print_process_info(procinfod);
+					procinfod ++;
+					printf("\n");
+					}
+				}
+			else if(dhdr->d_type == ESYM_NOTE_EXEC)
+				{
+				printf("EXECUTABLE INFO SEGMENT\n\n");
+
+				if( sizeof(Sym32_execinfod) != dhdr->d_descrsz )
+					{
+					printf("\tWarning! : sizeof(Sym32_execinfod) %d is different from descriptor size %d\n\n",
+						sizeof(Sym32_execinfod), dhdr->d_descrsz );
+					}
+
+				if( SYM32_EXECINFO_SIZE != dhdr->d_descrsz )
+					{
+					printf("\tWarning! : Expected Size of EXECUTABLE INFO SEGMENT %d is different from descriptor size %d\n\n",
+						 SYM32_EXECINFO_SIZE, dhdr->d_descrsz );
+					}
+
+				Sym32_execinfod *execinfod = ADDR(Sym32_execinfod,eh,data+sizeof(Sym32_dhdr));
+				for(int i = 0; i < dhdr->d_elemnum; i++)
+					{
+					if(i) printf("\n");
+					printf("\tCrashed Executable Name\t\t:%s\n",&array[execinfod->ed_name]);
+					print_executable_info(execinfod);
+					execinfod++;
+					}
+				}
+			else if(dhdr->d_type == ESYM_NOTE_REG)
+				{
+				printf("REGISTER INFO SEGMENT\n\n");
+
+				if( SYM32_REGINFO_SIZE != sizeof(Sym32_reginfod) )
+					{
+					printf("\tWarning! : Expected Size of REGISTER INFO SEGMENT %d is different from sizeof operator %d\n\n",
+						SYM32_REGINFO_SIZE, sizeof(Sym32_reginfod) );
+					}
+
+				if( SYM32_REGDATA_SIZE != sizeof(Sym32_regdatad) )
+					{
+					printf("\tWarning! : Expected Size of REGISTER INFO DATA SEGMENT %d is different from sizeof operator %d\n\n",
+						SYM32_REGDATA_SIZE, sizeof(Sym32_regdatad) );
+					}
+
+				Sym32_reginfod *reginfod = ADDR(Sym32_reginfod,eh,data+sizeof(Sym32_dhdr));
+
+				for( int regInfoD = 0; regInfoD < dhdr->d_elemnum; regInfoD++ )
+					{
+					print_register_info(reginfod, eh, array);
+					reginfod ++;
+					}
+
+				}
+			else if(dhdr->d_type == ESYM_NOTE_TRACE)
+				{
+				printf("TRACE INFO SEGMENT\n\n");
+
+				if( SYM32_TRACEDATA_SIZE != sizeof(Sym32_tracedata) )
+					{
+					printf("\tWarning! : Expected Size of TRACE INFO SEGMENT %d is different from sizeof operator %d\n\n",
+							SYM32_TRACEDATA_SIZE, sizeof(Sym32_tracedata) );
+					}
+
+				Sym32_tracedata *traceInfo = ADDR(Sym32_tracedata, eh, data+sizeof(Sym32_dhdr));
+
+				for( int cnt = 0; cnt < dhdr->d_elemnum; cnt++ )
+					{
+					print_trace_info(traceInfo, eh, array);
+					traceInfo++;
+					}
+				}
+			else if(dhdr->d_type == ESYM_NOTE_ROMBUILD)
+				{
+				printf("ROM BUILD INFO SEGMENT\n\n");
+
+				if( SYM32_ROMBUILD_SIZE != sizeof(Sym32_rombuild) )
+					{
+					printf("\tWarning! : Expected Size of ROM BUILD INFO SEGMENT %d is different from sizeof operator %d\n\n",
+							SYM32_ROMBUILD_SIZE, sizeof(Sym32_rombuild) );
+					}
+
+				Sym32_rombuild *romInf = ADDR(Sym32_rombuild, eh, data+sizeof(Sym32_dhdr));
+
+				for( int cnt = 0; cnt < dhdr->d_elemnum; cnt++ )
+					{
+					print_rom_info(romInf);
+					romInf++;
+					}
+				}
+			else if(dhdr->d_type == ESYM_NOTE_VARIANT_DATA)
+				{
+				printf("VARIANT SPECIFIC DATA SEGMENT");
+
+				Sym32_variant_spec_data* varData = ADDR(Sym32_variant_spec_data,eh,data+sizeof(Sym32_dhdr));
+				if(SYM32_VARIANT_SPEC_DATA_SIZE != sizeof(Sym32_variant_spec_data))
+					{
+					printf("\tWarning! : Expected Size of VARIANT SPECIFIC DATA SEGMENT %d is different from sizeof operator %d\n\n",
+						SYM32_VARIANT_SPEC_DATA_SIZE, sizeof(Sym32_variant_spec_data));
+					}
+	
+				if(sizeof(Sym32_variant_spec_data) != dhdr->d_descrsz )
+					{
+					printf("\tWarning! :  sizeof(Sym32_variant_spec_data) %d is different from descriptor size %d\n\n",
+						sizeof(Sym32_variant_spec_data), dhdr->d_descrsz );
+					}
+
+				print_variant_data(varData, eh);
+
+				}
+			else if(dhdr->d_type == ESYM_NOTE_LOCKDATA)
+				{
+				printf("LOCK DATA SEGMENT");
+
+				Sym32_lockdata* lockdata = ADDR(Sym32_lockdata,eh,data+sizeof(Sym32_dhdr));
+				if( SYM32_LOCKDATA_SIZE != sizeof(Sym32_lockdata))
+					{
+					printf("\tWarning! : Expected Size of LOCK DATA SEGMENT %d is different from sizeof operator %d\n\n",
+					SYM32_LOCKDATA_SIZE, sizeof(Sym32_lockdata) );
+					}
+
+				if( sizeof(Sym32_lockdata) != dhdr->d_descrsz )
+					{
+					printf("\tWarning! :  sizeof(Sym32_lockdata) %d is different from descriptor size %d\n\n",
+						sizeof(Sym32_lockdata), dhdr->d_descrsz );
+					}
+
+				print_lockdata_info(lockdata);
+				}	
+			else if(dhdr->d_type == ESYM_NOTE_STR)
+				{
+				printf("STRING INFO SEGMENT\n\n");
+				char *temp=array+dhdr->d_descrsz;
+				printf("\t");
+				while(array<=temp)
+					{
+					printf("%c",*array);
+					array++;
+					}
+				}
+			}
+		else
+			{
+		 	//printf("\t other p_types\n"); //unknown
+		 	continue;
+			}
+		}
+
+	//sections start here
+	int shoff = eh->e_shoff;							    // offset of section header table
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, shoff);			// calculating pointer to Secton Header Table
+															// Elf32_Shdr * shdr = (Elf32_Shdr *)(buffer+shoff);
+	int shnum = eh->e_shnum;							    // number of section headers
+	int shstrndx = eh->e_shstrndx;
+	int snameoffset = shdr[shstrndx].sh_offset;				// offset in file of sections' names
+	char* sname = ADDR(char, eh, snameoffset);				// pointer to String Table which holds section names
+															// char * sname = (char *)(buffer+snameoffset);
+
+	Elf32_Sym* symT= findSymbolT(eh);	// pointer to Symbol table
+	if (symT==NULL)
+		{
+		printf("\nSymbol table not found\n");
+		}
+
+	unsigned char* strtab=findSymbolStringT(eh);	// pointer to String table which holds symbol names
+	if (strtab==NULL)
+		{
+		printf("\nString table holding symbol names not found\n");
+		}
+
+	print_reloc(eh,symT, strtab);	// print relocation info showing symbol names and
+					        // and the name of section in which the relocaton occurs.
+	for(int k = 0; k < shnum; k++)
+		{
+		unsigned char* data = ADDR(unsigned char, eh, shdr[k].sh_offset);	//pointer to the first byte in the section
+															//unsigned char * data = (unsigned char * )(buffer+shdr[k].sh_offset);
+		int size = shdr[k].sh_size;	// section size in bytes
+
+		//print directive section
+		if (!strcmp(".directive", &sname[shdr[k].sh_name]))
+			{
+			print_sect_header(sname, shdr, k);
+			print_directive(data,size);
+			}
+
+		if (!strcmp(".symtab", &sname[shdr[k].sh_name]))
+			{
+			 print_sect_header(sname, shdr, k);
+			 // print global symbols
+			 print_GlSymbols(eh,symT, strtab);
+			}
+
+		//print relevant section header names
+ 		//print hex dump of relevant sections
+		if (shdr[k].sh_type==1 || shdr[k].sh_type==4 || shdr[k].sh_type==6 ||
+			shdr[k].sh_type==9 || shdr[k].sh_type==11)
+			{
+			if (strcmp(".comment", &sname[shdr[k].sh_name])&&
+				strcmp(".line", &sname[shdr[k].sh_name])   &&
+				strcmp(".hash", &sname[shdr[k].sh_name])   &&
+				strcmp(".note", &sname[shdr[k].sh_name])   &&
+				strcmp(".directive", &sname[shdr[k].sh_name]) &&
+				strncmp(".debug",&sname[shdr[k].sh_name] ,6))
+				{
+				if (!((ignoreSomeSections) &&
+					(strncmp(".rel.debug_", &sname[shdr[k].sh_name], 11)==0)))
+					{
+					print_sect_header(sname, shdr, k);
+					hexdump(data,size,k);
+					}
+				}
+			}
+		if (printAll)		// displays extra information
+			{
+			if(k!=0)
+			 	{
+				print_sect_header(sname, shdr, k);
+				hexdump(data,size,k);
+				}
+			}
+		}
+	print_Summary(eh);	// print section names
+	return 0;
+}
+
+int read_ar_element_header(char* ptr)
+	{
+	int length = strtol(ptr+48,0,10);
+
+	if (strncmp(ptr+58, "\x60\x0A", 2) != 0)
+		{
+		return -1;
+		}
+	return length;
+	}
+
+int main(int argc, char* argv[])
+	{
+	char* arg;
+	int numberOfOptions=2;
+	printAll=0;
+	ignoreSomeSections=0;
+	if (argc<2)
+		{
+		printf("File not specified");
+		exit(1);
+		}
+	else if (argc>numberOfOptions+2)
+		{
+		printf("Too many arguments");
+		exit(1);
+		}
+	else
+		{
+		for (int i=1;i<=argc-2;i++)
+			{
+			if ( strcmp("-i", argv[i]) ==0 )
+				{
+				ignoreSomeSections=1;
+				}
+			else if ( strcmp("-a", argv[i]) ==0 )
+				{
+				printAll=1;
+				}
+			}
+		arg=argv[argc-1];
+		}
+
+	struct stat results;
+	stat(arg, &results);
+	FILE *elffile;
+	if((elffile  = fopen(arg, "rb" )) == NULL)
+		{
+		cout << "Error opening file " << arg;
+		exit (1);
+		}
+
+	char* buffer=new  char [results.st_size];//allocating enough memory
+	fread( buffer, sizeof( char ), results.st_size, elffile);
+	fclose(elffile);
+
+	if (strncmp(buffer, "!<arch>\x0A", 8) != 0)
+		{
+		// plain ELF file
+		if (do_elf_file(buffer, arg) != 0)
+			{
+			return 1;
+			}
+		return 0;
+		}
+
+	// library file
+	char* nextfile = buffer;
+	int remainder = results.st_size;
+
+#define ADVANCE(n)	nextfile+=(n); remainder-=(n);
+
+	ADVANCE(8);
+
+	while (remainder > 0)
+		{
+		int element_length = read_ar_element_header(nextfile);
+		ADVANCE(60);
+
+		if (element_length < 0 || element_length > remainder)
+			{
+			cout << "Error: archive file corrupt";
+			return 1;
+			}
+
+		if (strncmp(nextfile, "\x7F\x45\x4C\x46",4) == 0)
+			{
+			if (do_elf_file(nextfile, "archive_element") != 0)
+				{
+				return 1;
+				}
+			}
+		element_length += element_length&1;	// round up to a multiple of 2
+		ADVANCE(element_length);
+		}
+
+	return 0;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/elfdump/elfdump.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,30 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+TARGET			elfdump.exe
+TARGETTYPE		exe
+SOURCE			elfdump.cpp 
+
+option GCC -w
+
+
+SYSTEMINCLUDE	/epoc32/include/tools
+SYSTEMINCLUDE	/epoc32/include/tools/coredump
+
+
+VENDORID 0x70000001
+
+MACRO CDSDEBUG
\ No newline at end of file
Binary file dbgsrv/coredumpserver/test/elfdump/testelf1.elf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/flashdump/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/flashdump/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,24 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_EXPORTS
+
+flashdump.iby		/epoc32/rom/include/flashdump.iby
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_MMPFILES
+flashdump.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/flashdump/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/flashdump/group/flashdump.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __RUNSELF__
+#define __RUNSELF__
+
+file=ABI_DIR\BUILD_DIR\flashdump.exe		sys\bin\flashdump.exe
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/flashdump/group/flashdump.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,34 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET		  flashdump.exe
+TARGETTYPE	  exe
+UID			 0 0xE8D09EED
+
+USERINCLUDE	 ..\inc
+SYSTEMINCLUDE   \epoc32\include
+
+SOURCEPATH	  ..\src
+
+LIBRARY		 euser.lib
+LIBRARY		 efsrv.lib
+
+DEBUGGABLE
+
+SOURCE main.cpp
+SOURCE flashdump.cpp
+
+
+MACRO FLASHDUMPDEBUG
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/flashdump/inc/debuglogging.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,54 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Logging macros for use in debug subsystem
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef DEBUG_LOGGING_H
+#define DEBUG_LOGGING_H
+
+/* 
+ * Debug messages are only generated for debug builds.
+ */
+
+#ifdef FLASHDUMPDEBUG
+
+    #include <e32debug.h>
+    #define LOG_DES(des) {if(des.Length() > 0) {RBuf buf; buf.CreateL(des); char *ptr = (char*)buf.Collapse().PtrZ(); LOG_MSG2("\n(%s)\n", ptr); buf.Close();} }
+
+    #define LOG_MSG( a )              RDebug::Printf( a )
+    #define LOG_MSG2( a, b )          RDebug::Printf( a, b )
+    #define LOG_MSG3( a, b, c )       RDebug::Printf( a, b, c )
+    #define LOG_MSG4( a, b, c, d )    RDebug::Printf( a, b, c, d )
+    #define LOG_MSG5( a, b, c, d, e ) RDebug::Printf( a, b, c, d, e )
+
+#else
+
+    #define LOG_DES(des)
+    #define LOG_MSG( a )
+    #define LOG_MSG2( a, b )
+    #define LOG_MSG3( a, b, c )
+    #define LOG_MSG4( a, b, c, d )
+    #define LOG_MSG5( a, b, c, d, e )
+
+#endif
+
+#endif //DEBUG_LOGGING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/flashdump/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/flashdump/inc/flashdump.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __FLASHDUMP_H__
+#define __FLASHDUMP_H__
+
+#include <e32base.h>
+#include <e32std.h>
+#include <e32cons.h>
+#include <rm_debug_api.h>
+#include <f32file.h>
+
+using namespace Debug;
+
+/**
+This is the version of the security server that we have developed our code against
+and it comes from the interface definition of the DSS at the time of compilation.
+*/
+const TVersion KSecurityServerVersion( 
+				KDebugServMajorVersionNumber, 
+				KDebugServMinorVersionNumber, 
+				KDebugServPatchVersionNumber );
+
+//We have 1 meg on a h4
+const TUint KCrashFlashPartitionSize = 0x100000;
+
+class CCrashFlashDump : public CBase
+	{
+	public:
+		static CCrashFlashDump* NewL();
+		static CCrashFlashDump* NewLC();
+		virtual ~CCrashFlashDump();
+		
+		void OpenFileL(const TDesC& aFileName);
+		void DumpFlashToFileL();
+		
+	private:
+		void ConstructL();
+		CCrashFlashDump();
+		
+	private:
+		
+		RSecuritySvrSession iSecSess;
+		RFs iFs;
+		RFile iFile;
+	};
+
+
+
+#endif  // __FLASHDUMP_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/flashdump/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/flashdump/src/flashdump.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,118 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "flashdump.h"
+#include "debuglogging.h"
+
+/**
+ * 1st stage construction
+ * @return pointer to the newly created object, caller takes ownership of the object.
+ */
+CCrashFlashDump* CCrashFlashDump::NewL()
+	{
+	LOG_MSG("->CFlashDump::NewL()->\n");
+	CCrashFlashDump* self = CCrashFlashDump::NewLC();
+	CleanupStack::Pop();
+	return self;
+	}
+
+/**
+ * 1st stage construction
+ * @return pointer to the newly created object, caller takes ownership of the object. 
+ */
+CCrashFlashDump* CCrashFlashDump::NewLC()
+	{
+	LOG_MSG("->CFlashDump::NewLC()->\n");
+	CCrashFlashDump* self = new(ELeave)CCrashFlashDump();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+/**
+ * Constructor
+ */
+CCrashFlashDump::CCrashFlashDump()
+	{
+	}
+
+/**
+ * 2nd stage construction
+ */
+void CCrashFlashDump::ConstructL()
+	{
+	LOG_MSG("CCrashFlashDump::ConstructL");
+	
+	User::LeaveIfError(iFs.Connect());
+	User::LeaveIfError(iSecSess.Connect(KSecurityServerVersion));
+	}
+
+/**
+ * Opens a file to dump the flash to
+ * @param aFileName name of file to open for the flash dump
+ * @leave one of the OS wide codes
+ */
+void CCrashFlashDump::OpenFileL(const TDesC& aFileName)
+	{
+	LOG_MSG2("CCrashFlashDump::OpenFileL --> [%S]", &aFileName);
+	
+	iFile.Close();	
+	User::LeaveIfError(iFile.Create(iFs, aFileName, EFileWrite | EFileRead));
+	}
+
+/**
+ * This goes through the crash flash partition and dumps it to the file
+ * @leave one of the os wide codes
+ */
+void CCrashFlashDump::DumpFlashToFileL()
+	{
+	LOG_MSG("CCrashFlashDump::DumpFlashToFile");
+	
+	//We know on a H4 the flash 
+	TInt remaining = KCrashFlashPartitionSize;
+	
+	//We shall dump 10k at a time
+	RBuf8 tmpBuf;
+	TUint bufSize = 0x2800;
+	TUint sizeDumped = 0; 
+	
+	User::LeaveIfError(tmpBuf.Create(bufSize));
+	tmpBuf.CleanupClosePushL();
+	
+	while(remaining > 0)
+		{
+		LOG_MSG3("Reading [%d] bytes from crash flash position [0x%X]", bufSize, sizeDumped);
+		User::LeaveIfError(iSecSess.ReadCrashLog(sizeDumped, tmpBuf, bufSize));
+		User::LeaveIfError(iFile.Write(tmpBuf));
+		
+		sizeDumped += bufSize;
+		remaining -= bufSize;
+		
+		bufSize = (bufSize > remaining) ? remaining : bufSize;
+		}						
+	
+	CleanupStack::PopAndDestroy();
+	}
+
+/**
+ * destructor
+ */
+CCrashFlashDump::~CCrashFlashDump()
+	{
+	iSecSess.Close();
+	iFile.Close();
+	}
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/flashdump/src/main.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,113 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "flashdump.h"
+#include "debuglogging.h"
+#include <e32base.h>
+#include <e32std.h>
+#include <e32cons.h>
+
+_LIT(KTextConsoleTitle, "The CrashFlash Dumper");
+
+LOCAL_D CConsoleBase* console; // write all messages to this
+
+
+GLDEF_C TInt E32Main();
+
+//  Local Functions
+
+LOCAL_C HBufC* ReadCommandLineL()
+	{
+	TInt cmdSize = User::CommandLineLength();
+
+	if(cmdSize > 0)
+		{
+		HBufC* cmd = HBufC::NewL(cmdSize);
+		TPtr p(cmd->Des());
+
+		User::CommandLine(p);
+		
+		return cmd;
+		}
+		
+	console->Printf(_L("\nusage: flashdump <filename>\n"));
+	console->Printf(_L("\nAny key to continue\n"));
+	console->Getch();
+	
+	return NULL;
+	}
+
+LOCAL_C void MainL()
+	{
+	CCrashFlashDump* dumper = CCrashFlashDump::NewL();
+	CleanupStack::PushL(dumper);
+	
+	HBufC* file = ReadCommandLineL();
+	if(!file)
+		{
+		User::Leave(KErrArgument);
+		}
+	
+	CleanupStack::PushL(file);
+	
+	LOG_MSG("Opening File");	
+	dumper->OpenFileL(file->Des());
+	
+	LOG_MSG("Dumping file to flash");
+	dumper->DumpFlashToFileL();
+	
+	CleanupStack::PopAndDestroy(file);
+	CleanupStack::PopAndDestroy(dumper);	
+	}
+
+LOCAL_C void DoStartL()
+	{
+	MainL();
+	}
+
+//  Global Functions
+
+GLDEF_C TInt E32Main()
+	{
+	// Create cleanup stack
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+
+	// Create output console
+	TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
+	if (createError)
+	return createError;
+
+	// Run application code inside TRAP harness, wait keypress when terminated
+	TRAPD(mainError, DoStartL());
+	if(mainError == KErrNone)
+		{
+		LOG_MSG("Flash dump succesful!");
+		}
+	else
+		{
+		LOG_MSG2("Flash dump failed with [%d]", mainError);
+		}
+	
+	delete console;
+	delete cleanup;
+	__UHEAP_MARKEND;
+	return mainError;
+	}
+
+
+//eof
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/oeelfdump/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_MMPFILES
+oeelfdump.mmp
+
+PRJ_PLATFORMS
+
+ARMV5
+
+
+PRJ_EXPORTS
+oeelfdump.iby	/epoc32/rom/include/oeelfdump.iby
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/oeelfdump/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/oeelfdump/oeelfdump.c	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1177 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <symbianelfdefs.h>
+#include <sys/stat.h>
+#include <time.h>
+
+#define ADDR(rtype, p, o) (rtype *)(((char *)p) + o)
+
+FILE *core;
+int ignoreSomeSections;
+void hexdump_data(unsigned char *data,int aSize,int j)
+{
+	int i=0;
+	int p=0;
+    int m=0;
+	while (i<aSize)	
+		{
+		int count=0;
+		if(p==0)
+		{
+			fprintf(core,"\t0x%08x:\t\t\t",j);
+		} // offset into section
+
+		while (i<aSize && count<4)
+			{ 
+			fprintf(core,"%02X", *data);		// print 4 lots of %08x for the data expresed as 32-bit word 
+			data++;
+			i++;
+			count++;
+			j++;
+			}
+
+		fprintf(core,"  ");
+		p++;
+		if (p==4)
+			{
+			data=data-16;
+			for (m=0;m<16;m++)			//print 16 bytes of memory interpreted 
+				{							//as ASCII characters with all non-printing 
+				if (*data>32 && *data <127)	//characters converted to dots
+					{
+					fprintf(core,"%1c",*data);
+					}
+				else
+					{
+					fprintf(core,".");
+					}
+					data++;
+				}
+			p=0; 
+			fprintf(core,"\n "); 
+			}
+		}
+		//fprintf(core,"\n"); 	   	
+	}
+void hexdump(unsigned char* data, int aSize, int offset)
+	//  print hex dump of relevant sections
+	{
+	int i=0;
+	int p=0;
+    int m=0;
+	while (i<aSize)	
+		{
+		int count=0;
+		if(p==0){fprintf(core,"\t%06x   ",offset);} // offset into section
+		while (i<aSize && count<4)
+			{ 
+			fprintf(core,"%02X", *data);		// print 4 lots of %08x for the data expresed as 32-bit word 
+			data++;
+			i++;
+			count++;
+			offset++;
+			}
+
+		fprintf(core,"  ");
+		p++;
+		if (p==4)
+			{
+			data=data-16;
+			for (m=0;m<16;m++)			//print 16 bytes of memory interpreted 
+				{							//as ASCII characters with all non-printing 
+				if (*data>32 && *data <127)	//characters converted to dots
+					{
+					fprintf(core,"%1c",*data);
+					}
+				else
+					{
+					fprintf(core,".");
+					}
+					data++;
+				}
+			p=0; 
+			fprintf(core," \n "); 
+			}
+		}
+		fprintf(core," \n\n "); 	   	
+	}
+
+void print_directive(unsigned char* data, int size)
+	// print formatted text of directive section
+	{
+    int i=0;
+	printf ("\t");
+
+	for (i=0; i<size; i++)
+		{
+		if ((char)data[i]>31 && (char)data[i]<127)
+			{
+			printf ("%c", (char)data[i]);
+			}
+
+		if ((char)data[i]=='\n')
+			{
+			printf ("\n\t");
+			}
+		}
+
+	printf ("\n");
+	}
+
+void print_reloc(Elf32_Ehdr* eh, Elf32_Sym* symT, unsigned char* strtab)
+	// print relocation section
+	{
+    int i=0;
+    int j=0;
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, eh->e_shoff);
+	for (j=0;j< eh->e_shnum;j++)
+		{
+		char* sname = ADDR(char, eh, shdr[eh->e_shstrndx].sh_offset);
+		if ( (shdr[j].sh_type==9) && 
+		     ( (!ignoreSomeSections) || 
+		       (strncmp(".rel.debug_", &sname[shdr[j].sh_name], 11))
+		     )
+		   )
+			{
+			unsigned char* data = ADDR(unsigned char, eh, shdr[j].sh_offset);
+			Elf32_Rel* rl=(Elf32_Rel*)data;				// pointer to relocation section	
+			int noOfReloc=shdr[j].sh_size / shdr[j].sh_entsize;
+			fprintf(core,"\n\n\n\t\t\t%s\n", &sname[shdr[j].sh_name]);
+			for (i=0;i<noOfReloc;i++)
+				{
+				unsigned char* symbolName = strtab;		// pointer to firest element of string											// table which holds symbol names
+				Elf32_Sym*  sym = symT;					// pointer to symbol table
+				int symTIndx= ELF32_R_SYM(rl->r_info);		// symbol Tableindex
+				sym=sym+symTIndx;							
+				symbolName=symbolName+sym->st_name;		// index into string table section 
+															// with symbol names
+				fprintf(core,"\t0x%08x \t", rl->r_offset);		// prints offset into relocation section
+				fprintf(core,"%d", symTIndx);					// symbol table index
+				fprintf(core,"\t%s\n",symbolName);				// symbol name
+				rl++;			
+				}
+			}
+		}
+	}	
+
+void print_GlSymbols(Elf32_Ehdr* eh, Elf32_Sym* symT, unsigned char* strtab)
+	// print global symbols from Symbol Table
+	{	
+    int i=0;
+    int l=0;
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, eh->e_shoff);
+	char* sname = ADDR(char, eh, shdr[eh->e_shstrndx].sh_offset);
+	for (i=0;i< eh->e_shnum;i++)
+		{
+		if (!strcmp(".symtab", &sname[shdr[i].sh_name]))
+			{
+		  	int noOfSym=shdr[i].sh_size / shdr[i].sh_entsize; 	// number of symbols
+		  	const char *symName =(const char *)strtab;
+		  	int count = 1;										
+		  	fprintf(core,"Global symbols:\n");
+		  	fprintf(core,"=================\n\n");
+		  	for (l=0;l< noOfSym ;l++)
+				{
+				symT=symT+1;
+				if( ELF32_ST_BIND(symT->st_info) == 1)			// searching for global symbols
+			 		{
+			  		symName = symName + symT->st_name;			// index into string table section 
+			 		fprintf(core,"%d	",count);
+			  		fprintf(core,symName);
+			  		fprintf(core,"\n");
+			  		symName = symName - symT->st_name;			// back to pointing to first byte of string table
+			  		count++;
+					}
+			
+				}
+			}
+		}
+	}
+	
+void print_elf_header(Elf32_Ehdr* eh)
+	{
+	// print elf header
+	if (eh->e_version==1)
+		fprintf(core,"\tHeader version: EV_CURRENT (Current version)\n");
+	else
+		fprintf(core,"\tInvalid version: EV_NONE (Invalid version)\n");
+
+
+	fprintf(core,"\tFile Type\t\t\t:");
+	if (eh->e_type==0)
+		fprintf(core,"ET_NONE (No file type) (0)\n");
+	else if (eh->e_type==1)
+		fprintf(core,"ET_REL (Relocatable object) (1)\n");
+	else if (eh->e_type==2)
+		fprintf(core,"ET_EXEC (Executable file) (2)\n"); 
+	else if (eh->e_type==3)
+		fprintf(core,"ET_DYN (Shared object file) (3)\n"); 
+	else if (eh->e_type==4)
+		fprintf(core,"ET_CORE (Core File) (4)\n"); 
+	else if (eh->e_type==65280)
+		fprintf(core,"ET_LOPROC (Precessor Specific) (ff00)\n");
+	else	
+		fprintf(core,"ET_HIPROC (Precessor Specific) (ffff)\n");
+
+	if (eh->e_machine==40)
+		fprintf(core,"\tMachine\t\t\t\t:EM_ARM (ARM)\n");
+	else
+		fprintf(core,"\tERROR:\tUnexpected machine\n");
+
+	fprintf(core,"\tEntry offset (in SHF_ENTRYSECT section):0x%08x \n",eh->e_entry);
+	fprintf(core,"\tProgram header entries\t\t:%d\n",eh->e_phnum); 
+	fprintf(core,"\tSection header entries\t\t:%d\n",eh->e_shnum); 
+  
+	fprintf(core,"\tProgram header offset\t\t:%d",eh->e_phoff); 
+	fprintf(core,"  bytes (0x%08X",eh->e_phoff);
+	fprintf(core,")\n");
+	fprintf(core,"\tSection header offset\t\t:%d",eh->e_shoff); 
+	fprintf(core,"  bytes (0x%08X",eh->e_shoff);
+	fprintf(core,")\n");
+
+	fprintf(core,"\tProgram header entry size\t:%d",eh->e_phentsize); 
+	fprintf(core,"  bytes (0x%02X",eh->e_phentsize);
+	fprintf(core,")\n");
+	fprintf(core,"\tSection header entry size\t:%d",eh->e_shentsize); 
+	fprintf(core,"  bytes (0x%02X",eh->e_shentsize);
+	fprintf(core,")\n");
+	fprintf(core,"\tSection header string table index: %d \n", eh->e_shstrndx);
+	fprintf(core,"\tHeader size\t\t\t:%d", eh->e_ehsize);
+	fprintf(core,"  bytes (0x%02X",eh->e_ehsize);
+	fprintf(core,")\n");
+	}
+
+void print_sect_header(char* sname, Elf32_Shdr* shdr, int count)
+	// print section header names
+	{
+	static const char* KtypeName[]={"0","SHT_PROGBITS (1)","SHT_SYMTAB (2)","SHT_STRTAB (3)",
+								  "SHT_RELA (4)","5",	"SHT_DINAMIC (6)","7","8","SHT_REL (9)",
+								  "10","SHT_DINSYM (11)"};
+						
+	fprintf(core,"\n\n\tName\t\t:%1s\n ",&sname[shdr[count].sh_name]);
+	fprintf(core,"\tType\t\t: %s\n",  KtypeName[shdr[count].sh_type]);
+	fprintf(core,"\tAddr\t\t: 0x%08X\n",shdr[count].sh_addr);
+	fprintf(core,"\tSize\t\t: %1d", shdr[count].sh_size);
+	fprintf(core,"  bytes (0x%X",shdr[count].sh_size);
+	fprintf(core,")\n");
+	fprintf(core,"\tEntry Size\t: %1d\n",shdr[count].sh_entsize);
+	fprintf(core,"\tAligment\t: %1d\n\n\n",shdr[count].sh_addralign);		 	
+	}
+
+unsigned char* findSymbolStringT(Elf32_Ehdr* eh)
+	//calculate and return pointer to the first byte of string table(the one with symbol names)
+	{
+    int i=0;
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, eh->e_shoff);
+	char* sname = ADDR(char, eh, shdr[eh->e_shstrndx].sh_offset);
+	for (i=0;i < eh->e_shnum; i++)
+		{
+		if (!strcmp(".strtab", &sname[shdr[i].sh_name]))
+			{
+			unsigned char* data = ADDR(unsigned char, eh, shdr[i].sh_offset); 
+			return data;	//pointer to the first byte of string table section
+			}
+		}
+	return NULL;	//if not found  
+	}
+
+Elf32_Sym* findSymbolT(Elf32_Ehdr* eh)
+	//calculate and return pointer to the first element of symbol table	
+	{
+    int i=0;
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, eh->e_shoff);
+	for (i=0;i < eh->e_shnum;i++)
+		{
+		if (shdr[i].sh_type==2)
+			{
+			unsigned char* data = ADDR(unsigned char, eh, shdr[i].sh_offset);
+			Elf32_Sym* sym=(Elf32_Sym*)data;
+			return sym;		//pointer to the first element of symbol table.
+			}
+		}
+	return NULL; // if not found
+	}
+
+void print_Summary(Elf32_Ehdr* eh)
+	{
+    int i=0;
+	//print section names
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, eh->e_shoff);
+	char* sname = ADDR(char, eh, shdr[eh->e_shstrndx].sh_offset);
+	fprintf(core,"\nSummary: \n");
+	fprintf(core,"==========\n");
+	for (i=0;i< eh->e_shnum;i++)
+		{
+		fprintf(core,&sname[shdr[i].sh_name]);
+		fprintf(core,"\n");
+		}
+	}
+
+int printAll;
+/*char  *ctime( const time_t *date)
+{
+	 
+}*/	
+	
+
+enum TCrashType { ECrashException, ECrashKill };
+
+enum TExcType
+	{
+	EExcGeneral=0,
+	EExcIntegerDivideByZero=1,
+	EExcSingleStep=2,
+	EExcBreakPoint=3,
+	EExcIntegerOverflow=4,
+	EExcBoundsCheck=5,
+	EExcInvalidOpCode=6,
+	EExcDoubleFault=7,
+	EExcStackFault=8,
+	EExcAccessViolation=9,
+	EExcPrivInstruction=10,
+	EExcAlignment=11,
+	EExcPageFault=12,
+	EExcFloatDenormal=13,
+	EExcFloatDivideByZero=14,
+	EExcFloatInexactResult=15,
+	EExcFloatInvalidOperation=16,
+	EExcFloatOverflow=17,
+	EExcFloatStackCheck=18,
+	EExcFloatUnderflow=19,
+	EExcAbort=20,
+	EExcKill=21,
+	EExcUserInterrupt=22,
+	EExcDataAbort=23,
+	EExcCodeAbort=24,
+	EExcMaxNumber=25,
+	EExcInvalidVector=26
+	};
+
+char * TExcTypeNames[EExcInvalidVector+1] = 
+	{
+	"EExcGeneral",
+	"EExcIntegerDivideByZero",
+	"EExcSingleStep",
+	"EExcBreakPoint",
+	"EExcIntegerOverflow",
+	"EExcBoundsCheck",
+	"EExcInvalidOpCode",
+	"EExcDoubleFault",
+	"EExcStackFault",
+	"EExcAccessViolation",
+	"EExcPrivInstruction",
+	"EExcAlignment",
+	"EExcPageFault",
+	"EExcFloatDenormal",
+	"EExcFloatDivideByZero",
+	"EExcFloatInexactResult",
+	"EExcFloatInvalidOperation",
+	"EExcFloatOverflow",
+	"EExcFloatStackCheck",
+	"EExcFloatUnderflow",
+	"EExcAbort",
+	"EExcKill",
+	"EExcUserInterrupt",
+	"EExcDataAbort",
+	"EExcCodeAbort",
+	"EExcMaxNumber",
+	"EExcInvalidVector"
+	};
+
+void print_symbian_info(Sym32_syminfod *syminfod)
+{    
+	  
+	//fprintf(core,"\tDate and time of the crash\t:=0x%X",syminfod->sd_date_time );
+	const time_t unix_time = (time_t)62168256000LL;//from 0AD to 1970 in seconds = 365*1971*86 400
+	//fprintf(core,"\traw Date =0x%X\n", (syminfod->sd_date_time[1]<<32+syminfod->sd_date_time[0])/*/1000000*/ );
+    time_t date = syminfod->sd_date_time/1000000; //convert to seconds
+    date -= unix_time; //convert to unix time
+	fprintf(core,"\tDate and time of the crash\t: %s\n", ctime(&date));
+
+	if( SYM32_EXECID_SIZE != sizeof(Sym32_execid) )
+		{
+		fprintf(core,"\tWarning! : Expected Size of EXECUTABLE ID %d is different from sizeof operator %d\n\n", 
+			SYM32_EXECID_SIZE, sizeof(Sym32_execid) );
+		}
+
+	fprintf(core,"\tExecutable Crc32 (first 1kb)\t:0x%X\n",syminfod->sd_execid.exec_crc );
+
+	if( ECrashException == syminfod->sd_exit_type )
+		{
+		fprintf(core,"\tHardware Exception\t\t:%d\n",syminfod->sd_exit_reason);
+		fprintf(core,"\tException Type\t\t\t:%s\n", TExcTypeNames[syminfod->sd_exit_reason] );
+		}
+	else if ( ECrashKill == syminfod->sd_exit_type )
+		{
+		fprintf(core,"\tExit Type\t\t\t:%d",syminfod->sd_exit_reason);
+		switch(syminfod->sd_exit_reason)
+			{
+			case 0:fprintf(core,":EExitKill\n");		break;
+			case 1:fprintf(core,":EExitTerminate\n");	break;
+			case 2:fprintf(core,":EExitPanic\n");		break;
+			case 3:fprintf(core,":EExitPending\n");	break;
+			default:fprintf(core,":Unknown\n");			break;
+			}    
+		}
+	else
+		{
+		fprintf(core,"\t\tUnknown Crash Type\n" );
+		}
+	
+
+	fprintf(core,"\tCrashed Thread Id\t\t:0x%X\n",syminfod->sd_thread_id);
+	fprintf(core,"\tOwning process\t\t\t:0x%X\n",syminfod->sd_proc_id);
+}	
+
+void print_thread_info(Sym32_thrdinfod *thrdinfod)
+{
+	
+	//fprintf(core,"\tIndex into the CORE.SYMBIAN.STR note segment defining");
+	//fprintf(core," the name of the thread or ESYM_STR_UNDEF :%d\n",thrdinfod->td_name);
+	fprintf(core,"\tThread ID\t\t\t:0x%X\n",thrdinfod->td_id);
+	fprintf(core,"\tOwning process\t\t\t:0x%X\n",thrdinfod->td_owning_process);
+	fprintf(core,"\tThread Priority\t\t\t:%d\n",thrdinfod->td_priority);
+	fprintf(core,"\tSupervisor Stack Pointer\t:0x%08X\n",thrdinfod->td_svc_sp);
+	fprintf(core,"\tSupervisor Stack Address\t:0x%08X\n",thrdinfod->td_svc_stack);
+	fprintf(core,"\tSupervisor Stack Size\t\t:%u",thrdinfod->td_svc_stacksz);
+	fprintf(core,"  bytes (0x%08X",thrdinfod->td_svc_stacksz);
+	fprintf(core,")\n");
+    fprintf(core,"\tUser Stack Address\t\t:0x%08X\n",thrdinfod->td_usr_stack);
+    fprintf(core,"\tUser Stack Size\t\t\t:%u",thrdinfod->td_usr_stacksz);
+	fprintf(core,"  bytes (0x%08X)\n",thrdinfod->td_usr_stacksz);
+	fprintf(core,"\tCPU id\t\t\t:%d\n\n",thrdinfod->td_last_cpu_id);	
+}	
+
+void print_lock_data(Sym32_lockdata* lockdata)
+	{
+	fprintf(core,"\tNum locks\t\t\t:%d\n", lockdata->lk_lock_count);
+	fprintf(core,"\tmutex thread wait count\t\t\t:%d\n",lockdata->lk_mutex_thread_wait_count);
+	fprintf(core,"\tmutex thread held count\t\t\t:%d\n",lockdata->lk_mutex_held_count);
+	}
+
+void print_process_info(Sym32_procinfod *procinfod)
+{
+	
+	//fprintf(core,"\t\t\tIndex into the CORE.SYMBIAN.STR note segment defining");
+	//fprintf(core," the name of the process or ESYM_STR_UNDEF:%d\n",procinfod->pd_name);
+	fprintf(core,"\tProcess ID\t\t\t:0x%X\n",procinfod->pd_id);
+	fprintf(core,"\tProcess Priority\t\t:%d\n",procinfod->pd_priority);
+
+}
+
+void print_executable_info(Sym32_execinfod *execinfod)
+{
+	
+	fprintf(core,"\tExecutable ID\t\t\t:0x%08X\n",execinfod->ed_execid.exec_id);
+	fprintf(core,"\tExecutable Crc32 (first 1kb)\t:0x%X\n",execinfod->ed_execid.exec_crc );
+
+	if(execinfod->ed_XIP == 1)
+	{
+		fprintf(core,"\tXIP ROM\t\t\t\t:TRUE\n");
+    }
+    else if(execinfod->ed_XIP == 0)
+    {
+	     fprintf(core,"\tXIP ROM\t\t\t\t:FALSE\n");
+    }
+
+	fprintf(core,"\tSize of executable code segment\t\t\t:%d",execinfod->ed_codesize);
+	fprintf(core,"  bytes (0x%08X)\n",execinfod->ed_codesize);
+
+	fprintf(core,"\tExecution address of the code segment\t\t:0x%08X\n",execinfod->ed_coderunaddr);
+
+	fprintf(core,"\tBuild address of the code segment\t\t:0x%08X\n",execinfod->ed_codeloadaddr);
+
+	fprintf(core,"\tSize of the executable read only data segment\t:%d",execinfod->ed_rodatasize);
+	fprintf(core,"  bytes (0x%08X)\n",execinfod->ed_rodatasize);
+
+	fprintf(core,"\tExecution address of the read only data segment\t:0x%08X\n",execinfod->ed_rodatarunaddr);
+
+    fprintf(core,"\tBuild address of the read only data segment\t:0x%08X\n",execinfod->ed_rodataloadaddr);
+
+    fprintf(core,"\tSize of the executable data segment\t\t:%d", execinfod->ed_datasize);
+	fprintf(core,"  bytes (0x%08X)\n",execinfod->ed_datasize);
+
+    fprintf(core,"\tExecution address of the data segment\t\t:0x%08X\n",execinfod->ed_datarunaddr);
+	
+    fprintf(core,"\tBuild address of the data segment\t\t:0x%08X\n",execinfod->ed_dataloadaddr);
+}
+
+//void print_register_info(Sym32_reginfod *reginfod,unsigned int nreg,Sym32_regdatad *regdatad,char *array,unsigned int elenum)
+void print_register_info( Sym32_reginfod *reginfod, Elf32_Ehdr* eh, char *array )
+{   
+    unsigned int i=0;
+	Sym32_regdatad *regdatad = ADDR(Sym32_regdatad, reginfod, sizeof (Sym32_reginfod) );
+	fprintf(core,"\tVersion of the register data info descriptor\t:%s\n",&array[reginfod->rid_version]);
+	fprintf(core,"\tThread ID\t\t\t:0x%X\n",reginfod->rid_thread_id);
+	fprintf(core,"\tNumber of registers\t\t:%d\n",reginfod->rid_num_registers);
+
+	fprintf(core,"\tRegister Class\t\t\t:%d",reginfod->rid_class);
+	switch( reginfod->rid_class )
+		{
+		case ESYM_REG_CORE:
+			fprintf(core, " : ESYM_REG_CORE\n" );
+			break;
+		case ESYM_REG_COPRO:
+			fprintf(core, " : ESYM_REG_COPRO\n" );
+			break;
+		default:
+			fprintf(core, " : Unknown Register Class\n" );
+		}
+
+	fprintf(core,"\tRegister Representation\t\t:%d",reginfod->rid_repre );
+	switch( reginfod->rid_repre )
+		{
+		case ESYM_REG_8:
+			fprintf(core, " : ESYM_REG_8\n" );
+			break;
+		case ESYM_REG_16:
+			fprintf(core, " : ESYM_REG_16\n" );
+			break;
+		case ESYM_REG_32:
+			fprintf(core, " : ESYM_REG_32\n" );
+			break;
+		case ESYM_REG_64:
+			fprintf(core, " : ESYM_REG_64\n" );
+			break;
+		default:
+			fprintf(core, "\n" );
+		}
+
+	fprintf(core, "\n" );
+
+
+	for( i = 0; i < reginfod->rid_num_registers; i++ )
+	{
+		fprintf(core,"\tRegister ID\t\t\t:0x%X ", regdatad->rd_id);
+
+		if( ESYM_REG_CORE == reginfod->rid_class )
+		{
+			switch(regdatad->rd_id)
+			{
+				case 0x00000000: fprintf(core,"ARM REGISTER R0\n"); break;
+				case 0x00000100: fprintf(core,"ARM REGISTER R1\n"); break;
+				case 0x00000200: fprintf(core,"ARM REGISTER R2\n"); break;
+				case 0x00000300: fprintf(core,"ARM REGISTER R3\n"); break;
+				case 0x00000400: fprintf(core,"ARM REGISTER R4\n"); break;
+				case 0x00000500: fprintf(core,"ARM REGISTER R5\n"); break;
+				case 0x00000600: fprintf(core,"ARM REGISTER R6\n"); break;
+				case 0x00000700: fprintf(core,"ARM REGISTER R7\n"); break;
+				case 0x00000800: fprintf(core,"ARM REGISTER R8\n"); break;
+				case 0x00000900: fprintf(core,"ARM REGISTER R9\n"); break;
+				case 0x00000a00: fprintf(core,"ARM REGISTER R10\n"); break;
+				case 0x00000b00: fprintf(core,"ARM REGISTER R11\n"); break;
+				case 0x00000c00: fprintf(core,"ARM REGISTER R12\n"); break;
+				case 0x00000d00: fprintf(core,"ARM REGISTER R13\n"); break;
+				case 0x00000e00: fprintf(core,"ARM REGISTER R14\n"); break;
+				case 0x00000f00: fprintf(core,"ARM REGISTER R15\n"); break;
+				case 0x00001000: fprintf(core,"ARM REGISTER CPSR\n"); break;
+				case 0x00001100: fprintf(core,"ARM REGISTER R13_SVC\n"); break;
+				case 0x00001200: fprintf(core,"ARM REGISTER R14_SVC\n"); break;
+				case 0x00001300: fprintf(core,"ARM REGISTER SPSR_SVC\n"); break;
+				case 0x00001400: fprintf(core,"ARM REGISTER R13_ABT\n"); break;
+				case 0x00001500: fprintf(core,"ARM REGISTER R14_ABT\n"); break;
+				case 0x00001600: fprintf(core,"ARM REGISTER SPSR_ABT\n"); break;
+				case 0x00001700: fprintf(core,"ARM REGISTER R13_UND\n"); break;
+				case 0x00001800: fprintf(core,"ARM REGISTER R14_UND\n"); break;
+				case 0x00001900: fprintf(core,"ARM REGISTER SPSR_UND\n"); break;
+				case 0x00001a00: fprintf(core,"ARM REGISTER R13_IRQ\n"); break;
+				case 0x00001b00: fprintf(core,"ARM REGISTER R14_IRQ\n"); break;
+				case 0x00001c00: fprintf(core,"ARM REGISTER SPSR_IRQ\n"); break;
+				case 0x00001d00: fprintf(core,"ARM REGISTER R8_FIQ\n"); break;
+				case 0x00001e00: fprintf(core,"ARM REGISTER R9_FIQ\n"); break;
+				case 0x00001f00: fprintf(core,"ARM REGISTER R10_FIQ\n"); break;
+				case 0x00002000: fprintf(core,"ARM REGISTER R11_FIQ\n"); break;
+				case 0x00002100: fprintf(core,"ARM REGISTER R12_FIQ\n"); break;
+				case 0x00002200: fprintf(core,"ARM REGISTER R13_FIQ\n"); break;
+				case 0x00002300: fprintf(core,"ARM REGISTER R14_FIQ\n"); break; 
+				case 0x00002400: fprintf(core,"ARM REGISTER SPSR_FIQ\n"); break;
+				default:fprintf(core,"Unknown Core Register\n"); break;
+			} // switch
+		} // if CORE
+		else
+		{
+			fprintf(core,"\n\tRegister SubId\t\t\t:0x%X\n",regdatad->rd_sub_id);
+		}
+
+		switch( reginfod->rid_repre )
+		{
+		case ESYM_REG_8:
+            {
+			Elf32_Byte * val8;
+			val8 = ADDR( Elf32_Byte, eh, regdatad->rd_data );
+			fprintf(core, "\tESYM_REG_8 Value\t\t:0x%02X\n", *val8 );
+			break;
+            }
+		case ESYM_REG_16:
+            {
+			Elf32_Half * val16;
+			val16 = ADDR( Elf32_Half, eh, regdatad->rd_data );
+			fprintf(core, "\tESYM_REG_16 Value\t\t:0x%04X\n", *val16 );
+			break;
+            }
+		case ESYM_REG_32:
+            {
+			Elf32_Word * val32;
+			val32 = ADDR( Elf32_Word, eh, regdatad->rd_data );
+			fprintf(core, "\tESYM_REG_32 Value\t\t:0x%08X\n", *val32 );
+			break;
+            }
+		case ESYM_REG_64:
+            {
+			// We need to split the printing of a 64 bit number since the 
+			// printf is not working correctly for this size.
+			Elf32_Word * val64_0;
+			Elf32_Word * val64_1;
+			val64_0 = ADDR( Elf32_Word, eh, regdatad->rd_data );
+			val64_1 = ADDR( Elf32_Word, eh, regdatad->rd_data + 4 );
+			fprintf(core, "\tESYM_REG_64 Value\t\t:0x%X%X\n", *val64_1, *val64_0 );
+			break;
+	        }	
+		default:
+			fprintf(core, "\n" );
+		}
+
+		fprintf(core, "\n" );
+
+		regdatad++;
+
+	} // for
+ }
+
+void print_trace_info( Sym32_tracedata *aTraceData, Elf32_Ehdr* aElfHdr, char *aArray)
+	{	
+	fprintf(core, "\tVersion of the trace data info descriptor\t:%s\n", &aArray[aTraceData->tr_version]);
+	fprintf(core, "\tSize of trace buffer\t\t:%d bytes\n", aTraceData->tr_size);	
+			
+	if(aTraceData->tr_data == 0)
+		{
+		fprintf(core, "\tNo trace data present\n");
+		}
+	else
+		{
+		unsigned char* data = ADDR(unsigned char, aElfHdr, aTraceData->tr_data);	
+		fprintf(core, "\tTrace Data starts at\t\t:0x%X\n\n", data);
+		}	
+
+	fprintf(core, "\n\n");
+	}
+ 
+
+int do_elf_file(char* buffer, char* name)
+	{
+    int i=0;
+    int j=0;
+    int k=0;
+    char *array = NULL;
+	Elf32_Ehdr* eh=(Elf32_Ehdr *)buffer;	//elf header
+	int phnum = eh->e_phnum;
+	int phoff =eh->e_phoff;  
+	Elf32_Phdr* phdr = ADDR(Elf32_Phdr,eh,phoff);
+
+    int shoff = eh->e_shoff;							    // offset of section header table
+	Elf32_Shdr* shdr = ADDR(Elf32_Shdr, eh, shoff);			// calculating pointer to Secton Header Table
+															// Elf32_Shdr * shdr = (Elf32_Shdr *)(buffer+shoff); 
+	int shnum = eh->e_shnum;							    // number of section headers
+	int shstrndx = eh->e_shstrndx;
+	int snameoffset = shdr[shstrndx].sh_offset;				// offset in file of sections' names
+	char* sname = ADDR(char, eh, snameoffset);				// pointer to String Table which holds section names
+	Elf32_Sym* symT= findSymbolT(eh);	// pointer to Symbol table
+	unsigned char* strtab=findSymbolStringT(eh);	// pointer to String table which holds symbol names
+
+
+	if (eh->e_ident[EI_MAG0] !=0x7f || eh->e_ident[EI_MAG1] != 0x45 || eh->e_ident[EI_MAG2] !=0x4c || eh->e_ident[EI_MAG3] != 0x46)
+		{
+		// EI_MAG0 to EI_MAG3 - A files' first 4 bytes hold a 'magic number', identifying the file as an ELF object file. 
+        fprintf(core,"Error: %s is not a valid ELF file", name);
+		return 1;
+		}
+	if (eh->e_ident[EI_DATA] == 2)							
+		{
+		// ELF Header size should be 52 bytes or converted into Big-Endian system 13312
+		if (eh->e_ehsize != 13312)
+			{
+			fprintf(core,"\tERROR:\tELF Header contains invalid file type\n");
+			exit(1);
+			}
+		// e_ident[EI_DATA] specifies the data encoding of the processor-specific data in the object file.
+		fprintf(core,"\tERROR:\tData encoding ELFDATA2MSB (Big-Endian) not supported\n");
+		exit(1);
+		}
+	if (eh->e_ehsize != 52)
+		{
+		// ELF Header size should be 52 bytes
+        fprintf(core,"\tERROR:\tELF Header contains invalid file type\n");
+        exit(1);
+        }
+    
+	fprintf(core,"ELF HEADER INFORMATION\n");  
+	print_elf_header(eh);									// print Elf Header
+
+    //segments start here
+	for(j = 0; j < phnum; j++)
+		{
+		if(phdr[j].p_type == PT_NOTE)
+			{
+			Sym32_dhdr *dhdr = ADDR(Sym32_dhdr, eh, phdr[j].p_offset);
+			if(dhdr->d_type == ESYM_NOTE_STR)
+				{
+                array = (char*)dhdr + sizeof(Sym32_dhdr);
+				}
+		    }	
+		}   
+    
+    for(i = 0; i < phnum; i++)
+		{
+	    unsigned int data = phdr[i].p_offset;
+        Sym32_dhdr *dhdr = ADDR(Sym32_dhdr,eh,data);
+	    unsigned int  flag = phdr[i].p_flags;
+
+		if( SYM32_DESCHDR_SIZE != sizeof(Sym32_dhdr) )
+			{
+			fprintf(core,"\n\tWarning! : Expected Size of SYM32_DESCHDR_SIZE %d is different from sizeof(Sym32_dhdr) %d\n\n", 
+				 SYM32_DESCHDR_SIZE, sizeof(Sym32_dhdr) );
+			}
+
+	    fprintf(core,"\nPROGRAM HEADER ENTRY  %d INFORMATION \n",i);
+	    fprintf(core,"\tHeader offset\t\t\t:%d",phdr[i].p_offset); 
+	    fprintf(core,"  bytes (0x%08X",phdr[i].p_offset);
+	    fprintf(core,")\n");
+	    fprintf(core,"\tVirtual address\t\t\t:0x%08X\n",phdr[i].p_vaddr);
+	    
+	    fprintf(core,"\tSize of mapping from the file\t:0x%X (%d bytes)\n",phdr[i].p_filesz, phdr[i].p_filesz);
+	    fprintf(core,"\tSize of mapping in memory\t:0x%X (%d bytes)\n",phdr[i].p_memsz, phdr[i].p_memsz);
+	    
+	    switch(flag)
+			{
+		    case 1 :
+		             fprintf(core,"\tFlag\t\t\t\t:PF_X : (1) \n");
+		              break;
+		    case 2 :
+		             fprintf(core,"\tFlag\t\t\t\t:PF_W: (2) \n");
+		             break;
+		    case 4 :
+		             fprintf(core,"\tFlag\t\t\t\t:PF_R : (4) \n");
+		             break;
+		    case 5:
+		             fprintf(core,"\tFlag\t\t\t\t:PF_X|PF_R : (5)\n");
+		             break;
+		    case 6:
+		             fprintf(core,"\tFlag\t\t\t\t:PF_W|PF_R : (6)\n");
+		             break;
+			}
+
+		fprintf(core,"\tAlignment to word boundary      :%d \n",phdr[i].p_align);
+		
+	    if(phdr[i].p_type == PT_LOAD)
+			{
+		 	unsigned char* data = ADDR(unsigned char, eh, phdr[i].p_offset);
+            const int scope = 128;
+		 	fprintf(core,"\tLOADABLE CODE/DATA SEGMENT\n"); //load  
+		 	 //fprintf(core,"\tDatasegment starts from here:%p, size:%d\n",data, phdr[i].p_memsz);
+             if(phdr[i].p_filesz == 0) continue;
+             if(phdr[i].p_filesz < 2*scope)
+		        hexdump_data(data,phdr[i].p_memsz,phdr[i].p_vaddr);									
+             else
+                 {
+                 hexdump_data(data,scope,phdr[i].p_vaddr);
+                 fprintf(core,"\t...\n"); 
+                 hexdump_data(data+phdr[i].p_filesz-scope,scope,phdr[i].p_vaddr+phdr[i].p_filesz-scope);
+                 }
+             if(phdr[i].p_filesz%16) fprintf(core,"\n");
+			}
+	    else if(phdr[i].p_type == PT_NOTE)
+			{
+            fprintf(core,"\tName of the descriptor\t\t:%s\n",&array[dhdr->d_name]);
+            fprintf(core,"\tSize of single descriptor element:%d \n",dhdr->d_descrsz);
+	        fprintf(core,"\tVersion string\t\t\t:%s\n",&array[dhdr->d_version]);
+	        fprintf(core,"\tNumber of descriptor elements\t:%d\n",dhdr->d_elemnum); 
+			fprintf(core,"\tSegment type\t\t\t:");
+
+	        if( dhdr->d_type == ESYM_NOTE_SYM )
+				{
+				Sym32_syminfod *syminfod = ADDR(Sym32_syminfod,eh,data+sizeof(Sym32_dhdr));
+				fprintf(core,"SYMBIAN INFO SEGMENT\n\n");
+
+				if( sizeof(Sym32_syminfod) != dhdr->d_descrsz )
+					{
+					fprintf(core,"\tWarning! : sizeof(Sym32_syminfod) %d is different from descriptor size %d\n\n", 
+						 sizeof(Sym32_syminfod), dhdr->d_descrsz );
+					}
+
+				if( SYM32_SYMINFO_SIZE != dhdr->d_descrsz )
+					{
+					fprintf(core,"\tWarning! : Expected Size of SYMBIAN INFO SEGMENT %d is different from descriptor size %d\n\n", 
+						 SYM32_SYMINFO_SIZE, dhdr->d_descrsz );
+					}
+
+				if( syminfod->sd_exit_cat > 0 )
+					{
+					fprintf(core,"\tCrash reason\t\t\t:%s\n",&array[syminfod->sd_exit_cat]);
+					}
+				print_symbian_info(syminfod);
+	            }                 
+			else if( dhdr->d_type == ESYM_NOTE_THRD)
+				{
+		        Sym32_thrdinfod *thrdinfod = ADDR(Sym32_thrdinfod,eh,data+sizeof(Sym32_dhdr));
+		        fprintf(core,"THREAD INFO SEGMENT\n\n");
+
+				if( sizeof(Sym32_thrdinfod) != dhdr->d_descrsz )
+					{
+					fprintf(core,"\tWarning! : sizeof(Sym32_thrdinfod) %d is different from descriptor size %d\n\n", 
+						sizeof(Sym32_thrdinfod), dhdr->d_descrsz );
+					}
+
+				if( SYM32_THRINFO_SIZE!= dhdr->d_descrsz )
+					{
+					fprintf(core,"\tWarning! : Expected Size of THREAD INFO SEGMENT %d is different from descriptor size %d\n\n", 
+						 SYM32_THRINFO_SIZE, dhdr->d_descrsz );
+					}
+
+				for(j = 0; j < dhdr->d_elemnum; j++ )
+					{
+					fprintf(core,"\tThread Name\t\t\t:%s\n",&array[thrdinfod->td_name]);
+					print_thread_info(thrdinfod);
+					thrdinfod ++;
+					}
+				}                      
+			else if(dhdr->d_type == ESYM_NOTE_PROC )
+				{
+		        Sym32_procinfod *procinfod = ADDR(Sym32_procinfod,eh,data+sizeof(Sym32_dhdr));
+		        fprintf(core,"PROCESS INFO SEGMENT\n\n");
+
+				if( sizeof(Sym32_procinfod) != dhdr->d_descrsz )
+					{
+					fprintf(core,"\tWarning! :  sizeof(Sym32_procinfod) %d is different from descriptor size %d\n\n", 
+						sizeof(Sym32_procinfod), dhdr->d_descrsz );
+					}
+
+				if( SYM32_PROCINFO_SIZE != dhdr->d_descrsz )
+					{
+					fprintf(core,"\tWarning! : Expected Size of PROCESS INFO SEGMENT %d is different from descriptor size %d\n\n", 
+						 SYM32_PROCINFO_SIZE, dhdr->d_descrsz );
+					}
+
+				
+				for(j = 0; j < dhdr->d_elemnum; j++ )
+					{
+					fprintf(core,"\tProcess Name\t\t\t:%s\n",&array[procinfod->pd_name]);
+					print_process_info(procinfod);
+					procinfod ++;
+					fprintf(core,"\n");
+					}
+				}                        
+			else if(dhdr->d_type == ESYM_NOTE_EXEC)
+				{ 
+		        Sym32_execinfod *execinfod = ADDR(Sym32_execinfod,eh,data+sizeof(Sym32_dhdr));
+		        fprintf(core,"EXECUTABLE INFO SEGMENT\n\n");
+				
+				if( sizeof(Sym32_execinfod) != dhdr->d_descrsz )
+					{
+					fprintf(core,"\tWarning! : sizeof(Sym32_execinfod) %d is different from descriptor size %d\n\n", 
+						sizeof(Sym32_execinfod), dhdr->d_descrsz );
+					}
+
+				if( SYM32_EXECINFO_SIZE != dhdr->d_descrsz )
+					{
+					fprintf(core,"\tWarning! : Expected Size of EXECUTABLE INFO SEGMENT %d is different from descriptor size %d\n\n", 
+						 SYM32_EXECINFO_SIZE, dhdr->d_descrsz );
+					}
+
+                for(j = 0; j < dhdr->d_elemnum; j++)
+                    {
+                    if(j) fprintf(core,"\n");
+		            fprintf(core,"\tCrashed Executable Name\t\t:%s\n",&array[execinfod->ed_name]);
+			        print_executable_info(execinfod);
+                    execinfod++;
+                    }
+				}                      
+			else if(dhdr->d_type == ESYM_NOTE_REG)
+				{
+			    Sym32_reginfod *reginfod = ADDR(Sym32_reginfod,eh,data+sizeof(Sym32_dhdr));
+			    fprintf(core,"REGISTER INFO SEGMENT\n\n");
+
+				if( SYM32_REGINFO_SIZE != sizeof(Sym32_reginfod) )
+					{
+					fprintf(core,"\tWarning! : Expected Size of REGISTER INFO SEGMENT %d is different from sizeof operator %d\n\n", 
+						SYM32_REGINFO_SIZE, sizeof(Sym32_reginfod) );
+					}
+
+				if( SYM32_REGDATA_SIZE != sizeof(Sym32_regdatad) )
+					{
+					fprintf(core,"\tWarning! : Expected Size of REGISTER INFO DATA SEGMENT %d is different from sizeof operator %d\n\n", 
+						SYM32_REGDATA_SIZE, sizeof(Sym32_regdatad) );
+					}
+
+			    
+				for( j = 0; j < dhdr->d_elemnum; j++ )
+					{
+				    print_register_info(reginfod, eh, array);
+					reginfod ++;
+					}
+			    
+				}   
+			else if(dhdr->d_type == ESYM_NOTE_TRACE)
+				{
+				Sym32_tracedata *traceInfo = ADDR(Sym32_tracedata, eh, data+sizeof(Sym32_dhdr));
+				int cnt = 0;
+				fprintf(core, "TRACE INFO SEGMENT\n\n");
+				
+				if( SYM32_TRACEDATA_SIZE != sizeof(Sym32_tracedata) )
+					{
+					fprintf(core, "\tWarning! : Expected Size of TRACE INFO SEGMENT %d is different from sizeof operator %d\n\n", 
+							SYM32_TRACEDATA_SIZE, sizeof(Sym32_tracedata) );
+					}
+
+				if( SYM32_TRACEDATA_SIZE != sizeof(Sym32_tracedata) )
+					{
+					fprintf(core, "\tWarning! : Expected Size of TRACE INFO DATA SEGMENT %d is different from sizeof operator %d\n\n", 
+							SYM32_TRACEDATA_SIZE, sizeof(Sym32_regdatad) );
+					}														
+				
+				for( cnt = 0; cnt < dhdr->d_elemnum; cnt++ )
+					{
+					print_trace_info(traceInfo, eh, array);
+					traceInfo++;
+					}
+				
+				}
+			else if(dhdr->d_type == ESYM_NOTE_STR)
+				{
+			    char *temp=array+dhdr->d_descrsz;
+				fprintf(core,"STRING INFO SEGMENT\n\n");
+			    fprintf(core,"\t");
+			    while(array<=temp)
+					{
+				    fprintf(core,"%c",*array);
+			        array++;
+		            }
+		        }
+			else if(dhdr->d_type == ESYM_NOTE_LOCKDATA)
+				{
+
+				Sym32_lockdata* lockdata = ADDR(Sym32_lockdata,eh,data+sizeof(Sym32_dhdr));
+		        fprintf(core,"LOCK DATA SEGMENT\n\n");
+
+				if( sizeof(Sym32_lockdata) != dhdr->d_descrsz )
+					{
+					fprintf(core,"\tWarning! :  sizeof(Sym32_lockdata) %d is different from descriptor size %d\n\n", 
+						sizeof(Sym32_lockdata), dhdr->d_descrsz );
+					}
+
+				if( SYM32_LOCKDATA_SIZE != dhdr->d_descrsz )
+					{
+					fprintf(core,"\tWarning! : Expected Size of LOCK DATA SEGMENT %d is different from descriptor size %d\n\n", 
+							SYM32_LOCKDATA_SIZE, dhdr->d_descrsz );
+					}				
+	            fprintf(core,"\tLock Data\n");
+	            print_lock_data(lockdata);
+				}
+			}    
+		else
+			{
+		 	//fprintf(core,"\t other p_types\n"); //unknown 
+		 	continue;  
+			}
+		}
+	
+    //sections start here
+   	if (symT==NULL)
+		{
+		fprintf(core,"\nSymbol table not found\n");
+		}
+
+	if (strtab==NULL)
+		{	
+		fprintf(core,"\nString table holding symbol names not found\n");
+		}
+
+	print_reloc(eh,symT, strtab);	// print relocation info showing symbol names and
+					        // and the name of section in which the relocaton occurs.														
+	for(k = 0; k < shnum; k++)
+		{    
+		unsigned char* data = ADDR(unsigned char, eh, shdr[k].sh_offset);	//pointer to the first byte in the section
+															//unsigned char * data = (unsigned char * )(buffer+shdr[k].sh_offset);
+		int size = shdr[k].sh_size;	// section size in bytes
+	
+		//print directive section
+		if (!strcmp(".directive", &sname[shdr[k].sh_name])) 
+			{ 
+			print_sect_header(sname, shdr, k);
+			print_directive(data,size);
+			}
+
+		if (!strcmp(".symtab", &sname[shdr[k].sh_name])) 
+			{
+			 print_sect_header(sname, shdr, k);	
+			 // print global symbols
+			 print_GlSymbols(eh,symT, strtab);								
+			}
+
+		//print relevant section header names
+ 		//print hex dump of relevant sections
+		if (shdr[k].sh_type==1 || shdr[k].sh_type==4 || shdr[k].sh_type==6 ||
+		    shdr[k].sh_type==9 || shdr[k].sh_type==11)
+			{
+			if (strcmp(".comment", &sname[shdr[k].sh_name])&&
+				strcmp(".line", &sname[shdr[k].sh_name])   &&
+				strcmp(".hash", &sname[shdr[k].sh_name])   &&
+				strcmp(".note", &sname[shdr[k].sh_name])   &&
+				strcmp(".directive", &sname[shdr[k].sh_name]) &&
+				strncmp(".debug",&sname[shdr[k].sh_name] ,6))
+				{
+				if ( ! ( (ignoreSomeSections) &&
+					 (strncmp(".rel.debug_", &sname[shdr[k].sh_name], 11)==0)
+				       )
+				   )
+					{
+					print_sect_header(sname, shdr, k);			
+			 	    hexdump(data,size,k);
+					}
+				}
+			}
+		if (printAll)		// displays extra information
+			{ 	
+			if(k!=0)
+			 	{
+		 	 	print_sect_header(sname, shdr, k);					
+		 		hexdump(data,size,k);				
+		 		}
+		 	}		
+		}
+	print_Summary(eh);	// print section names
+	return 0;
+}
+
+int read_ar_element_header(char* ptr)
+	{
+	int length = strtol(ptr+48,0,10);
+
+	if (strncmp(ptr+58, "\x60\x0A", 2) != 0)
+		{
+		return -1;
+		}
+	return length;
+	}
+	
+int main(int argc, char* argv[])
+	{
+	struct stat results;
+	FILE *elffile;
+    int i=0;
+	char* arg = NULL;
+	int numberOfOptions=2;
+    int remainder = 0;
+    char *buffer = NULL;
+    char *nextfile = NULL;
+
+	printAll=0;
+	ignoreSomeSections=0;
+
+	if (argc<2)
+		{
+		fprintf(stderr,"File not specified");
+		exit(1);
+		}
+	else if (argc>numberOfOptions+2)
+		{
+		fprintf(stderr,"Too many arguments");
+		exit(1);
+		}
+	else
+		{
+		for (i=1;i<=argc-2;i++)
+			{
+			if ( strcmp("-i", argv[i]) ==0 )
+				{
+				ignoreSomeSections=1;
+				}
+			else if ( strcmp("-a", argv[i]) ==0 )
+				{
+				printAll=1;
+				}
+			}
+		arg=argv[argc-1];
+		}
+
+    
+    if((core = fopen("c:\\core", "w")) == NULL)
+    {
+        fprintf(stderr, "Error opening core\n");
+        exit(1);
+    }
+
+	stat(arg, &results); 
+	if((elffile  = fopen(arg, "rb" )) == NULL)
+   		{
+   		fprintf(stderr,"Error opening file %s", arg);
+		exit (1); 
+   		}
+
+    buffer = (char*) calloc(results.st_size, sizeof(char));
+	remainder = fread( buffer, sizeof( char ), results.st_size, elffile);
+	fclose(elffile);						
+	
+	if (strncmp(buffer, "!<arch>\x0A", 8) != 0)
+		{
+		// plain ELF file
+		if (do_elf_file(buffer, arg) != 0)
+			{
+			return 1;
+			}
+		return 0;
+		}
+
+    fclose(core);
+	// library file
+	nextfile = buffer;
+	remainder = results.st_size;
+
+#define ADVANCE(n)	nextfile+=(n); remainder-=(n);
+
+	ADVANCE(8);
+		
+	while (remainder > 0)
+		{
+		int element_length = read_ar_element_header(nextfile);
+		ADVANCE(60);
+		
+		if (element_length < 0 || element_length > remainder)
+			{
+			fprintf(stderr,"Error: archive file corrupt");
+			return 1;
+			}
+		
+		if (strncmp(nextfile, "\x7F\x45\x4C\x46",4) == 0)
+			{
+			if (do_elf_file(nextfile, "archive_element") != 0)
+				{
+				return 1;
+				}
+			}
+		element_length += element_length&1;	// round up to a multiple of 2
+		ADVANCE(element_length);
+		}
+		
+    free(buffer);
+	return 0;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/oeelfdump/oeelfdump.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __OEELFDUMP_IBY__
+#define __OEELFDUMP_IBY__
+
+file=ABI_DIR\BUILD_DIR\oeelfdump.exe	                              	Sys\Bin\elfdump.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/oeelfdump/oeelfdump.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+TARGET   oeelfdump.exe
+
+TARGETTYPE   exe 
+UID          0x20004c45 0x102836B6
+
+CAPABILITY 	 ALL -TCB
+
+SOURCE		oeelfdump.c
+
+SYSTEMINCLUDE   \epoc32\include 
+SYSTEMINCLUDE   \epoc32\include\stdapis
+
+SYSTEMINCLUDE	/epoc32/include/tools
+SYSTEMINCLUDE	/epoc32/include/tools/coredump
+
+
+LIBRARY       libc.lib euser.lib efsrv.lib 
+
+STATICLIBRARY libcrt0.lib
+
+OPTION ARMCC --pointer_alignment=1
+OPTION ARMCC --min_array_alignment=1
+
+MACRO CDSDEBUG
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/oemtoken/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,24 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file bld.inf Build information file
+//
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_MMPFILES
+coredump_debug_token.mmp
+
+PRJ_EXPORTS
+coredump_debug_token.iby	/epoc32/rom/include/coredump_debug_token.iby
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/oemtoken/coredump_debug_token.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,31 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#include <e32base.h>
+
+GLDEF_C TInt E32Main()
+	{
+	// No need to do anything, the only requirement is that
+	// this executable can be loaded and runs to completion
+	return 0;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/oemtoken/coredump_debug_token.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __COREDUMPDEBUGTOKEN_IBY__
+#define __COREDUMPDEBUGTOKEN_IBY__
+
+file=ABI_DIR\BUILD_DIR\oemdebug_10282fe5.exe	                              	Sys\Bin\oemdebug_10282fe5.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/oemtoken/coredump_debug_token.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,37 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// oem_debug_token.mmp
+//
+
+ALWAYS_BUILD_AS_ARM
+
+target         OEMDebug_10282FE5.exe
+targettype     exe
+
+source        	coredump_debug_token.cpp 
+
+library		euser.lib
+
+systeminclude  \epoc32\include
+
+capability AllFiles TCB
+
+UID            0x1000008D 0x102836BD
+SECUREID       0x102836BD
+
+//
+// Set this to be your own vendor ID if any.
+//
+VENDORID       0x70000001
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/oemtoken/coredump_debug_token.pkg	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,28 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+&EN
+; Localised vendor names
+%{"Symbian Software Ltd."}
+; Single, non-localised (global) vendor name
+:"Symbian Software Ltd."
+;
+; Replace the Package UID (0xE8000091) with your own.
+;
+#{"OEM Debug Token SIS"},(0x102836B8),1,0,0
+;
+"\epoc32\release\armv5\urel\OEMDebug_10282FE5.exe" - "!:\sys\bin\OEMDebug_10282FE5.exe"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/oemtoken/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/data/coredumptestplugin.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,53 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Registry file for Core Dump Server testing
+//
+
+
+//#include "RegistryInfoV2.rh"
+#include "RegistryInfo.rh"
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+	{
+
+	//resource_format_version = RESOURCE_FORMAT_VERSION_2;
+
+	// UID for the DLL
+	dll_uid = 0x102832C6;
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of interface that is implemented
+			interface_uid = 0x10282fe2;
+
+			implementations = 
+				{
+
+				// Info for Implementation
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102832C7;
+					version_no = 1;
+					display_name = "Test Plugin for Core Dump Formatter v 1.0.0";
+					default_data = "Test V1.0.0";
+					opaque_data = "test_opaque_data";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/data/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,27 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file bld.inf Build information file
+//
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+
+coredumptestplugin.iby		/epoc32/rom/include/coredumptestplugin.iby
+
+PRJ_MMPFILES
+
+coredumptestplugin.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/group/coredumptestplugin.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// @file coredumptestplugin.iby ROM build file for plugins tests
+//
+
+#ifndef CORE_DUMP_SERVER_TEST_PLUGIN_IBY
+#define CORE_DUMP_SERVER_TEST_PLUGIN_IBY
+
+ECOM_PLUGIN( coredumptestplugin.dll, coredumptestplugin.rsc )
+
+#endif // CORE_DUMP_SERVER_TEST_PLUGIN_IBY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/group/coredumptestplugin.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,55 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Core Dump Plugin Test MMP file
+// coredumptestplugin.dll ECOM plugin used to test Coer Dump Server
+//
+
+
+
+/**
+ @file 
+*/
+
+TARGET      coredumptestplugin.dll
+TARGETTYPE  plugin
+UID         0x10009D8D  0x102832C6 //second uid=ecom uid, third UID Test plugin dll
+
+VENDORID    0x70000001
+
+CAPABILITY 	PowerMgmt
+exportunfrozen
+
+SOURCEPATH  ../src
+SOURCE      coredumptestplugin.cpp
+source		coredumptestpluginproxy.cpp
+
+
+USERINCLUDE ../inc
+
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE	/epoc32/include/drivers
+SYSTEMINCLUDE	/epoc32/include/tools/coredump
+//
+// ECOM plugin resource file
+//
+sourcepath		../src
+start resource ../data/coredumptestplugin.rss
+target coredumptestplugin.rsc
+end
+
+library		ecom.lib
+LIBRARY		euser.lib
+
+MACRO CDSDEBUG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/inc/coredumptestplugin.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,79 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implements an ECOM Plugin for the purpose of testing the Core Dump Server
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+ @see CCoreDumpFormatter
+*/
+
+
+#ifndef CORE_DUMP_TEST_PLUGIN
+#define CORE_DUMP_TEST_PLUGIN
+
+
+// Abstract ECOM API definition
+#include <formatterapi.h>
+
+
+class CCrashDataSave;
+class CCrashDataSource;
+class TCrashInfo;
+
+/** 
+CTestFormatter test class. Only used for internal testing
+*/
+class CTestFormatter : public CCoreDumpFormatter
+{
+public:
+	static CTestFormatter* NewL();
+	static CTestFormatter* NewLC();
+	virtual ~CTestFormatter();
+
+public:
+
+	virtual void ConfigureDataSaveL( CCrashDataSave * aDataSave );
+
+	virtual void ConfigureDataSourceL( CCrashDataSource * aDataSource );
+	
+	virtual void GetDescription( TDes & aPluginDescription );
+
+	virtual void CrashEventL( TCrashInfo* aCrashInfo);
+
+	virtual TInt GetNumberConfigParametersL( );
+
+	virtual COptionConfig * GetConfigParameterL( const TInt aIndex );
+
+	virtual void SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue );
+
+	TInt SetToUseFlashDataSource();
+	
+public:
+
+private:
+	void ConstructL();
+	CTestFormatter();
+	
+private:
+	
+	//CCrashDataSource* iDataSource;
+
+};
+
+#endif // 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/src/coredumptestplugin.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,127 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <e32base.h>
+#include "coredumptestplugin.h"
+
+#include <e32debug.h>
+#include <debuglogging.h>
+
+// Two phase construction of implementation
+CTestFormatter* CTestFormatter::NewL()
+	{
+	LOG_MSG( "CTestFormatter::NewL()\n" );
+	CTestFormatter* self = CTestFormatter::NewLC();
+	LOG_MSG( "CTestFormatter::NewL() <- CTestFormatter::NewLC()\n" );
+
+	LOG_MSG( "  NewL() -> Pop()\n" );
+	CleanupStack::Pop();
+	LOG_MSG( "  NewL() <- Pop()\n" );
+	return self;
+	}
+
+
+CTestFormatter* CTestFormatter::NewLC()
+	{
+	LOG_MSG( "CTestFormatter::NewLC() -> new(ELeave)CTestFormatter\n" );
+	CTestFormatter* self = new(ELeave)CTestFormatter();
+	CleanupStack::PushL(self);
+
+	self->ConstructL();
+	LOG_MSG( "CTestFormatter::NewL() <- self->ConstructL()\n" );
+
+	return self;
+	}
+
+
+CTestFormatter::CTestFormatter()
+	{
+	}
+
+void CTestFormatter::ConstructL()
+	{
+	}
+
+CTestFormatter::~CTestFormatter()
+	{
+	LOG_MSG( "CTestFormatter::~CTestFormatter()\n" );
+
+	}
+
+// Interface methods
+void CTestFormatter::ConfigureDataSaveL( CCrashDataSave * aDataSave )
+	{
+	LOG_MSG( "CTestFormatter::ConfigureDataSaveL()\n" );
+    User::LeaveIfNull( aDataSave );
+	}
+
+	
+void CTestFormatter::ConfigureDataSourceL( CCrashDataSource * aDataSource )
+	{
+	LOG_MSG( "CTestFormatter::ConfigureDataSource()\n" );
+    User::LeaveIfNull( aDataSource );
+	}
+
+
+TInt CTestFormatter::GetNumberConfigParametersL( )
+	{
+	return ( 0 );
+	}
+
+
+COptionConfig * CTestFormatter::GetConfigParameterL( const TInt aIndex )
+	{
+	// return the config identified by aIndex
+	return ( (COptionConfig *) NULL );
+	}
+
+
+void CTestFormatter::SetConfigParameterL( const TInt aIndex, 
+										  const TInt32 & aValue, 
+										  const TDesC & aDescValue )
+	{
+	LOG_MSG( "CTestFormatter::SetConfigParameterL()\n" );
+
+	TInt remIntWarn = aIndex;
+	TInt32 remInt32Warn = aValue;
+	remIntWarn = remInt32Warn;
+	remInt32Warn = remIntWarn;
+	TInt remInt2Warn = aDescValue.Length();
+	}
+
+
+void CTestFormatter::GetDescription( TDes & aPluginDescription )
+	{
+	LOG_MSG( "CTestFormatter::GetDescription()\n" );
+
+	_LIT( KPluginDescription, "CTestFormatter::GetDescription" );
+	aPluginDescription = *(KPluginDescription().AllocL());
+	}
+
+
+void CTestFormatter::CrashEventL( TCrashInfo* aCrashInfo) 
+	{
+	LOG_MSG( " CTestFormatter::CrashEvent()\n" );
+
+	User::LeaveIfNull( aCrashInfo );
+	}
+
+TInt CTestFormatter::SetToUseFlashDataSource()
+	{
+	return KErrNone;
+	}
+
+
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/src/coredumptestpluginproxy.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,31 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include <implementationproxy.h>
+
+#include "coredumptestplugin.h"
+
+// ECom boiler template code
+const TImplementationProxy ImplementationTable[] =
+{
+	IMPLEMENTATION_PROXY_ENTRY( 0x102832C7, CTestFormatter::NewL )
+};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+	return ImplementationTable;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/plugins/testplugin/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,5 @@
+Directory for:
+  coredump\
+test files
+
+The tests at this level should be integration tests
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/rundump/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/rundump/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,24 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+
+rundump.iby		/epoc32/rom/include/rundump.iby
+
+PRJ_MMPFILES
+rundump.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/rundump/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/rundump/group/rundump.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __RUNSELF__
+#define __RUNSELF__
+
+file=ABI_DIR\BUILD_DIR\megadump.exe		sys\bin\megadump.exe
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/rundump/group/rundump.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,35 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET		  megadump.exe
+TARGETTYPE	  exe
+UID			 0 0xEAA2F613
+
+USERINCLUDE	 ..\inc
+
+SYSTEMINCLUDE \epoc32\include
+SYSTEMINCLUDE \epoc32\include\test
+SYSTEMINCLUDE \epoc32\include\drivers
+SYSTEMINCLUDE \epoc32\include\ecom
+SYSTEMINCLUDE \epoc32\include\tools\coredump
+
+SOURCEPATH	  ..\src
+SOURCE		  rundump.cpp
+
+LIBRARY		 euser.lib
+LIBRARY     cdssupport.lib
+LIBRARY     coredumpinterface.lib
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/rundump/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/rundump/inc/rundump.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __RUNDUMP_H__
+#define __RUNDUMP_H__
+
+
+//  Include Files
+
+#include <e32base.h>
+#include "optionconfig.h"
+#include <coredumpinterface.h>
+
+
+//  Function Prototypes
+
+GLDEF_C TInt E32Main();
+void DoConfigureL(const TUint32& aIndex, 
+	     const TUint32& aUID, 
+	        const COptionConfig::TParameterSource& aSource, 
+	        const COptionConfig::TOptionType& aType, 
+	        const TDesC& aPrompt, 
+	        const TUint32& aNumOptions,
+	        const TDesC& aOptions,
+	        const TInt32& aVal, 
+	        const TDesC& aStrValue,
+	        const TUint aInstance,
+	        const RCoreDumpSession &sess);
+
+
+#endif  // __RUNDUMP_H__
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/rundump/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/rundump/src/rundump.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,252 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "rundump.h"
+#include <e32base.h>
+#include <e32std.h>
+#include <e32cons.h>			// Console
+
+#include <coredumpserverapi.h>
+#include <e32property.h>
+#include <crashdatasave.h>
+
+
+
+//  Constants
+
+_LIT(KTextConsoleTitle, "Console");
+_LIT(KTextFailed, " failed, leave code = %d");
+_LIT(KTextPressAnyKey, " [press any key]\n");
+_LIT(KCrashAppFileName,"Z:\\sys\\bin\\crashapp.exe");
+
+//  Global Variables
+
+LOCAL_D CConsoleBase* console;  // write all messages to this
+
+
+//  Local Functions
+
+LOCAL_C void MainL()
+	{
+	TUid SELF_UID_V2 = { 0x102836bb };
+	TUid WRITER_UID = { 0x102831E4 };
+	TUid CDS_UID  = { 0x10282FE5 };
+	TUid UTRACE_UID = { 0x102836BA };
+	TUid DEXC_UID = { 0x102832C5 };
+	
+	RCoreDumpSession cdsSess;
+	CleanupClosePushL(cdsSess);
+	cdsSess.Connect();	
+	
+	//
+	// add your program code here, example code below
+	//
+	console->Write(_L("Starting megadump\n"));
+	console->Write(_L("SELF or UTRACE or DEXC? (s/u/d)"));
+	TChar inp = console->Getch();	
+
+	//Load plugins	
+	TPluginRequest req;
+	req.iPluginType = TPluginRequest::EFormatter;
+	req.iLoad = ETrue;
+	
+	switch(inp)
+	{
+	case('s'):
+		{
+		req.iUid = SELF_UID_V2;
+		console->Write(_L("\nLoading SELF formatter V2\n"));
+		break;
+		}
+	case('u'):
+		{
+		req.iUid = UTRACE_UID;
+		console->Write(_L("\nLoading UTRACE formatter\n"));
+		break;
+		}
+	case('d'):
+		{
+		req.iUid = DEXC_UID;
+		console->Write(_L("\nLoading DEXC Formatter"));
+		return;
+		}
+	default:
+		{
+		console->Write(_L("\nNot an option"));
+		return;
+		}
+		
+	}
+	
+	TBuf<10> crashAppParam; 
+	console->Write(_L("Should crashapp write trace data? (y/n)\n"));
+	inp = console->Getch();
+	switch(inp)
+	{
+	case('y'):
+		{
+		console->Write(_L("Crashapp will write trace data\n"));
+		crashAppParam.Append(_L("-d1 -t"));
+		break;
+		}
+	default:
+		{
+		console->Write(_L("Crashapp will not write any trace data\n"));
+		crashAppParam.Append(_L("-d1"));
+		break;
+		}
+	}
+	
+	//Start the process that we intend to crash....
+	RProcess crashProcess;
+	CleanupClosePushL(crashProcess);
+	crashProcess.Create( KCrashAppFileName, crashAppParam);
+	
+    cdsSess.PluginRequestL( req );
+    
+    TPluginRequest req2;
+    req2.iUid = WRITER_UID;
+    req2.iPluginType = TPluginRequest::EWriter;
+    req2.iLoad = ETrue;
+	
+    console->Write(_L("Loading File writer\n"));
+	cdsSess.PluginRequestL( req2 );
+	
+	_LIT( KPostCrashEventActionPrompt, "Action After Crash:\n  0-None,\n  1-Resume Thread,\n  2-Resume Process,\n  4-Kill Process" );
+	_LIT( KFilePathPrompt, "not_important" );
+	_LIT( KCrashFileName, "e:\\file");
+	
+	console->Write(_L("Configuring CDS\n"));
+	DoConfigureL(2, CDS_UID.iUid, COptionConfig::ECoreDumpServer, COptionConfig::ETUInt, KPostCrashEventActionPrompt,
+			 1, KNullDesC, 4, KNullDesC, 0, cdsSess);
+	
+	console->Write(_L("Configuring Writer\n"));
+	DoConfigureL((TInt)(CCrashDataSave::ECoreFilePath), WRITER_UID.iUid, COptionConfig::EWriterPlugin, COptionConfig::ETFileName,
+		    KFilePathPrompt, 1, KNullDesC, 0, KCrashFileName, 0, cdsSess);
+	
+/*	if(trace)
+		{
+		console->Write(_L("Configuring Trace\n"));
+		DoConfigureL(0, UTRACE_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETInt,
+		    KFilePathPrompt, 1, KNullDesC, 1, KCrashFileName, 0, cdsSess);
+		}*/
+	
+	console->Write(_L("Observing\n"));
+	cdsSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue) ;
+	
+	console->Write(_L("Starting process\n"));
+	crashProcess.Resume();
+	CleanupStack::PopAndDestroy(&crashProcess);
+	CleanupStack::PopAndDestroy(&cdsSess);
+	
+	console->Write(_L("Any key to exit...."));
+	console->Getch();
+	
+	}
+
+void DoConfigureL(const TUint32& aIndex, 
+ 	     const TUint32& aUID, 
+        const COptionConfig::TParameterSource& aSource, 
+        const COptionConfig::TOptionType& aType, 
+        const TDesC& aPrompt, 
+        const TUint32& aNumOptions,
+        const TDesC& aOptions,
+        const TInt32& aVal, 
+        const TDesC& aStrValue,
+        const TUint aInstance,
+        const RCoreDumpSession &aSess)
+/**
+* @return void
+* @param aIndex Internal index to the component that owns the object
+* @param aUID UID of the component that owns the object
+* @param aSource Type of component that owns the object
+* @param aType Type of parameter
+* @param aPrompt Prompt to present to user 
+* @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
+* @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
+* @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
+* @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
+*/
+	{
+	COptionConfig * config;	
+	
+	config = COptionConfig::NewL( aIndex,
+		aUID,
+		aSource,
+		aType,
+		aPrompt,
+		aNumOptions,
+		aOptions,
+		aVal,
+		aStrValue);
+	
+	CleanupStack::PushL(config);
+	
+	config->Instance(aInstance);
+	
+	//Configure now...
+	aSess.SetConfigParameterL(*config);	
+	
+	CleanupStack::PopAndDestroy(config);
+	}
+
+
+LOCAL_C void DoStartL()
+	{
+	// Create active scheduler (to run active objects)
+	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+
+	TRAPD(err, MainL());
+	
+	if(err != KErrNone)
+		{
+		console->Printf(_L("All is not well in the land of megadump. Error = %d\n"), err);
+		}
+
+	// Delete active scheduler
+	CleanupStack::PopAndDestroy(scheduler);
+	}
+
+
+//  Global Functions
+
+GLDEF_C TInt E32Main()
+	{
+	// Create cleanup stack
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+
+	// Create output console
+	TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
+	if (createError)
+		return createError;
+
+	// Run application code inside TRAP harness, wait keypress when terminated
+	TRAPD(mainError, DoStartL());
+	if (mainError)
+		console->Printf(KTextFailed, mainError);
+	console->Printf(KTextPressAnyKey);
+	console->Getch();
+	
+	delete console;
+	delete cleanup;
+	__UHEAP_MARKEND;
+	return KErrNone;
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/testclient/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,27 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+
+testclient.iby	/epoc32/rom/include/testclient.iby
+
+PRJ_MMPFILES
+
+testclient.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/testclient/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/testclient/testclient.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,170 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Tests the Core Dump Server and the Debug Security Server
+// by debugging the same executable. This is not possible but should fail
+// gracefully. This is done as follows:
+// 1 Start a client of the DSS called CRunModeAgent
+// 2 Start a test debug application (crashapp.exe)
+// 3 Actively attach to crashapp.exe
+// 4 Start coredumpscript.exe, which starts the Core Dump Server 
+// and then loads the saved config. If the configuration has been set
+// to observe the crashapp.exe, the DSS should not allow this.
+//
+
+#include <e32base.h>
+#include <e32cons.h>
+#include <e32debug.h>
+#include <rm_debug_api.h>
+
+
+class CRunModeAgent : public CBase
+	{
+public:
+	static CRunModeAgent* NewL();
+	~CRunModeAgent();
+	void ClientAppL();
+
+private:
+	CRunModeAgent();
+	void ConstructL();
+	void AttachToDSS();
+	void SetupAndAttachToDSS();
+
+private:
+	Debug::RSecuritySvrSession iServSession;
+	};
+
+
+
+using namespace Debug;
+
+/**
+This is the version of the security server that we have developed our code against
+and it comes from the interface definition of the DSS at the time of compilation.
+*/
+const TVersion securityServerVersion( 
+				KDebugServMajorVersionNumber, 
+				KDebugServMinorVersionNumber, 
+				KDebugServPatchVersionNumber );
+
+CRunModeAgent::CRunModeAgent()
+//
+// CRunModeAgent constructor
+//
+	{
+	}
+
+CRunModeAgent* CRunModeAgent::NewL()
+//
+// CRunModeAgent::NewL
+//
+	{
+	CRunModeAgent* self = new(ELeave) CRunModeAgent();
+
+  	self->ConstructL();
+
+	return self;
+	}
+
+CRunModeAgent::~CRunModeAgent()
+//
+// CRunModeAgent destructor
+//
+	{
+	iServSession.Close();
+	}
+
+
+void CRunModeAgent::ConstructL()
+//
+// CRunModeAgent::ConstructL
+//
+	{
+	// nothing to do here
+	}
+
+
+void CRunModeAgent::SetupAndAttachToDSS()
+	{
+	TInt err = iServSession.Connect(securityServerVersion);
+	if (err != KErrNone)
+		{
+		User::Panic(_L("Can't open server session"), err);
+		}
+	}
+
+
+_LIT( KCrashAppFileName,"z:\\sys\\bin\\crashapp.exe");
+_LIT( KCoreDumpServerClientProc,"z:\\sys\\bin\\coredumpscript.exe");
+
+
+void CRunModeAgent::ClientAppL()
+	{
+
+	RDebug::Printf( "CRunModeAgent::ClientAppL\n" );
+	
+	SetupAndAttachToDSS();
+
+
+	RProcess iCrashProcess;
+	RDebug::Printf( "Creating crashing application\n" );
+	TInt err = iCrashProcess.Create( KCrashAppFileName, KNullDesC );
+	RDebug::Printf( "  iCrashProcess.Create( KCrashAppFileName ) returned %d\n", err  );
+	User::After( 2000000 );
+	iCrashProcess.Resume();
+	
+	//attach to process actively
+	err = iServSession.AttachExecutable( KCrashAppFileName, EFalse );
+	RDebug::Printf( "  iServSession.AttachExecutable( KCrashAppFileName, EFalse ) returned %d\n", err  );
+	User::After( 2000000 );
+
+	RProcess iCoreDumpServerClientProc;
+	RDebug::Printf( "Creating Core Dump Server Client Proc\n" );
+	err = iCoreDumpServerClientProc.Create( KCoreDumpServerClientProc, KNullDesC );
+	RDebug::Printf( "  iCoreDumpServerClientProc.Create( KCoreDumpServerClientProc ) returned %d\n", err  );
+	User::After( 2000000 );
+	iCoreDumpServerClientProc.Resume();
+	User::After( 5000000 );
+	
+	iServSession.DetachExecutable( KCrashAppFileName );
+
+	}
+
+
+
+GLDEF_C TInt E32Main()
+	{
+	TInt ret = KErrNone;
+
+	
+	CTrapCleanup* trap = CTrapCleanup::New();
+	if (!trap)
+		return KErrNoMemory;
+
+   	
+	CRunModeAgent *RunModeAgent = NULL;
+	TRAPD(err, RunModeAgent = CRunModeAgent::NewL());
+	if (RunModeAgent != NULL && err == KErrNone)
+		{
+        __UHEAP_MARK;
+	    TRAP(ret,RunModeAgent->ClientAppL());
+	    __UHEAP_MARKEND;
+
+	    delete RunModeAgent;
+		}
+       
+	delete trap;
+
+	return ret;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/testclient/testclient.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef TESTCLIENT_IBY
+#define TESTCLIENT_IBY
+
+file=ABI_DIR\BUILD_DIR\testclient.exe  sys\bin\testclient.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/test/testclient/testclient.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,36 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+TARGET        testclient.exe
+TARGETTYPE    exe
+UID			  0x1000008D 0x10282FE4
+SECUREID      0x10282FE4
+VENDORID	  0x70000001
+
+ 
+SOURCEPATH    .
+SOURCE        testclient.cpp
+
+SYSTEMINCLUDE \epoc32\include 
+
+LIBRARY       euser.lib
+
+MACRO CDSDEBUG
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/group/Bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_PLATFORMS
+ARMV5
+PRJ_EXPORTS
+
+../group/coredumpui.iby	/epoc32/rom/include/coredumpui.iby
+
+PRJ_MMPFILES
+
+coredumpui.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/group/coredumpresource.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,17 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/group/coredumpui.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef _CORE_DUMP_UI_IBY_
+#define _CORE_DUMP_UI_IBY_
+
+file=ABI_DIR\BUILD_DIR\coredumpui.exe  sys\bin\coredumpui.exe
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\resource\Apps\coredumpui  resource\Apps\coredumpui)
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\resource\Apps\coredumpuiloc  resource\Apps\coredumpuiloc)
+data=MULTI_LINGUIFY(RSC EPOCROOT##epoc32\data\Z\private\10003a3f\apps\coredumpuireg  private\10003a3f\apps\coredumpuireg)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/group/coredumpui.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,80 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Using relative paths for sourcepath and user includes
+//
+
+
+#ifndef WINSCW
+MACRO HW
+#endif
+
+
+TARGET        coredumpui.exe
+TARGETTYPE    exe
+
+epocstacksize 0x5000
+
+UID           0x100039CE 0x102833b5
+
+VENDORID 0x70000001
+
+START RESOURCE ..\group\coredumpui.rss
+	HEADER
+	TARGETPATH \resource\apps	
+END
+
+START RESOURCE ..\group\coredumpuiloc.rss
+	TARGETPATH \resource\apps
+END
+
+START RESOURCE		../group/coredumpuireg.rss
+	TARGETPATH		/private/10003a3f/apps
+END
+
+SOURCEPATH    ../src
+SOURCE        coredumpuimain.cpp
+SOURCE        coredumpuiapplication.cpp
+SOURCE        coredumpuidocument.cpp
+SOURCE        coredumpuiappui.cpp
+SOURCE        coredumpuiresourceview.cpp
+SOURCE	      coredumpuidialogs.cpp
+SOURCE	      coredumpuiresourcelist.cpp
+SOURCE	      coredumpuinotifier.cpp 
+SOURCE 		  coredumpscmdialog.cpp 
+SOURCE		  coredumpcdsdialog.cpp
+
+
+USERINCLUDE		. 
+USERINCLUDE		../inc
+
+SYSTEMINCLUDE /epoc32/include 
+SYSTEMINCLUDE /epoc32/include/techview
+SYSTEMINCLUDE /epoc32/include/ecom +\include\drivers
+SYSTEMINCLUDE /epoc32/include/tools/coredump
+SYSTEMINCLUDE /epoc32/include/test
+
+LIBRARY		euser.lib apparc.lib cone.lib eikcore.lib ws32.lib apgrfx.lib
+LIBRARY		eikcoctl.lib efsrv.lib eikctl.lib gdi.lib
+LIBRARY		eikdlg.lib hal.lib bafl.lib 
+LIBRARY		coredumpinterface.lib 
+LIBRARY		cdssupport.lib 
+
+#ifdef WINSCW
+library		ecom.lib
+#endif
+
+MACRO CDSDEBUG
+
+LIBRARY estor.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/group/coredumpui.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1039 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+NAME CDUI
+
+#include "coredumpui.hrh"
+
+#include <eikon.rh>
+
+#include <eikcore.rsg>
+// for symbolic definition of buttons
+#include <eikon.rsg> //for runtime
+
+// The three following resources are mandatory fields and need to be the 
+// first resource fields in the resource file. Need to be defined in this order.
+// These resources don't need to contain any useful info, just need to be there.
+
+// RSS_SIGNATURE can be used to specify version information
+RESOURCE RSS_SIGNATURE {}
+
+// Defines the name of the default file the application framework creates.
+// This resource must always be the second resource in the resource file.
+RESOURCE TBUF { buf=""; }
+
+// This resource is used to define an application's GUI. 
+RESOURCE EIK_APP_INFO
+{
+	menubar=r_resource_menubar;
+}
+
+//
+// Menus
+//
+
+RESOURCE MENU_BAR r_resource_menubar
+{
+	titles=
+	{
+		MENU_TITLE { menu_pane=r_resource_menu_1; txt="Lists"; },
+		MENU_TITLE { menu_pane=r_resource_menu_2; txt="Configure"; },
+		MENU_TITLE { menu_pane=r_resource_menu_3; txt="Flash"; }
+	};
+}
+
+RESOURCE MENU_PANE r_resource_menu_1
+{
+	items=
+	{
+		MENU_ITEM {command=EResourceMenu1Item0; txt="Process";},
+		MENU_ITEM {command=EResourceMenu1Item1; txt="Thread"; },
+		MENU_ITEM {command=EResourceMenu1Item2; txt="Plugin Types"; },
+		MENU_ITEM {command=EResourceMenu1PluginInstances; txt="Plugin Instances"; },
+		MENU_ITEM {command=EResourceMenu1Executables; txt="Executables"; },
+		MENU_ITEM {command=EEikCmdExit; txt="Exit"; }
+	};
+}
+
+RESOURCE MENU_PANE r_resource_menu_2
+{
+	items=
+	{	
+		MENU_ITEM {command=EResMenu2ConfCDS; txt="Configure CDS"; },
+		MENU_ITEM {command=EResMenu2ConfSCM; txt="Configure SCM"; },
+		MENU_ITEM {command=EResMenu2CancelCrash; txt="Cancel Crash"; }
+	};
+}
+
+RESOURCE MENU_PANE r_resource_menu_3
+{
+	items=
+	{
+		MENU_ITEM {command=EResMenu3ListCrashes; txt="Show Crashes"; }
+	};
+}
+
+//
+// CDS dialog
+//
+
+RESOURCE DIALOG r_configure_cds_dialog
+{
+	title = "Configure CDS";
+	flags = EEikDialogFlagWait;
+	buttons = r_cds_dialog_buttons;
+	pages = r_cds_dialog_pages;
+}
+
+RESOURCE DLG_BUTTONS r_cds_dialog_buttons
+{
+	buttons=
+	{
+		DLG_BUTTON
+		{
+			id=EBidCDSConfigure;
+			button=CMBUT {txt="Configure";};
+			hotkey = 'F';
+		},
+		DLG_BUTTON
+		{
+			id=EEikBidCancel;
+			button=CMBUT {txt="Cancel";};
+			hotkey = 'C';
+		}
+	};
+}
+
+RESOURCE ARRAY r_cds_dialog_pages
+{
+	items =
+	{
+		PAGE
+		{
+			text = "CDS Configuration";
+			id = EConfigCDSPage;
+			lines = r_cds_dialog_lines;
+		}
+	};
+}
+
+RESOURCE ARRAY r_cds_dialog_lines
+{
+	items =
+	{
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel1;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin1;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel2;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type = EEikCtEdwin;
+			id = EEdwin2;
+			control = EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel3;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin3;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel4;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin4;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel5;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin5;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel6;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin6;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel7;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin7;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		}
+	};
+}
+
+
+//
+// Plugin dialog
+//
+
+RESOURCE DIALOG r_configure_plugin_dialog
+{
+	title = "Configure plugin";
+	flags = EEikDialogFlagWait;
+	buttons = r_plugin_dialog_buttons;
+	pages = r_plugin_dialog_pages;
+}
+
+RESOURCE DLG_BUTTONS r_plugin_dialog_buttons
+{
+	buttons=
+	{
+		DLG_BUTTON
+		{
+			id=EBidPluginConfigure;
+			button=CMBUT {txt="Configure";};
+			hotkey = 'F';
+		},
+		DLG_BUTTON
+		{
+			id=EEikBidCancel;
+			button=CMBUT {txt="Cancel";};
+			hotkey = 'C';
+		}
+	};
+}
+
+RESOURCE ARRAY r_plugin_dialog_pages
+{
+	items =
+	{
+		PAGE
+		{
+			text = "Plugin Configuration";
+			id = EConfigPluginPage;
+			lines = r_plugin_dialog_lines;
+		}
+	};
+}
+
+RESOURCE ARRAY r_plugin_dialog_lines
+{
+	items =
+	{
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel1;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin1;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel2;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type = EEikCtEdwin;
+			id = EPluginEdwin2;
+			control = EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel3;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin3;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel4;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin4;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel5;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin5;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel6;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin6;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel7;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin7;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel8;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin8;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel9;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin9;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel10;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin10;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel11;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin11;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel12;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin12;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel13;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin13;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel14;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin14;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel15;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin15;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel16;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin16;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel17;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin17;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = EPluginLabel18;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EPluginEdwin18;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		}
+	};
+}
+
+
+
+// configure SCM dialog //
+
+RESOURCE DIALOG r_configure_scm_dialog
+{
+	title = "Configure SCM";
+	flags = EEikDialogFlagWait;
+	buttons = r_scm_dialog_buttons;
+	pages = r_scm_dialog_pages;
+}
+
+RESOURCE DLG_BUTTONS r_scm_dialog_buttons
+{
+	buttons=
+	{
+		DLG_BUTTON
+		{
+			id=EBidCDSConfigure;
+			button=CMBUT {txt="Configure";};
+			hotkey = 'F';
+		},
+		DLG_BUTTON
+		{
+			id=EEikBidCancel;
+			button=CMBUT {txt="Cancel";};
+			hotkey = 'C';
+		}
+	};
+}
+
+RESOURCE ARRAY r_scm_dialog_pages
+{
+	items =
+	{
+		PAGE
+		{
+			text = "SCM Configuration";
+			id = EConfigSCMPage;
+			lines = r_scm_dialog_lines;
+		}
+	};
+}
+
+
+
+
+RESOURCE ARRAY r_scm_dialog_lines
+{
+	items =
+	{
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel0;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin0;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel1;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin1;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel2;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type = EEikCtEdwin;
+			id = EEdwin2;
+			control = EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel3;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin3;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel4;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin4;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel5;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin5;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel6;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin6;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel7;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin7;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel8;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin8;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel9;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin9;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel10;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin10;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel11;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin11;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel12;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin12;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel13;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin13;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},		
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel14;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin14;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},		
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel15;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin15;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel16;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin16;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},		
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel17;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin17;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtLabel;
+			id = ELabel18;
+			control = LABEL
+			{
+				horiz_align=EEikLabelAlignHLeft;
+			};
+		},
+		DLG_LINE
+		{
+			type=EEikCtEdwin;
+			id = EEdwin18;
+			control=EDWIN
+			{
+				width = 20;
+			};
+		}
+
+	};
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/group/coredumpuiaif.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,40 @@
+// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// CoreDumpUI -- Application Information Resource file
+// System Includes
+//
+
+
+
+
+#include <aiftool.rh>
+
+/********************************************************************************
+ * 
+ * Application Information
+ *
+ *******************************************************************************/
+RESOURCE AIF_DATA
+{
+	app_uid = 0x102833b5;
+
+	caption_list=
+	{ 
+		CAPTION { code = ELangEnglish; caption = "CoreDumpUI"; }
+	};
+
+	embeddability = KAppNotEmbeddable;
+	hidden = KAppNotHidden ;
+	newfile = KAppDoesNotSupportNewFile;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/group/coredumpuiloc.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,44 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// CoreDumpUI_loc.rss -- CoreDumpUI localised resource file
+// System Headers
+//
+
+
+
+
+#include <appinfo.rh>
+
+/********************************************************************************
+ *
+ * Local Headers
+ *
+ *******************************************************************************/
+
+/********************************************************************************
+ *
+ * Resources
+ *
+ *******************************************************************************/
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = "CDUI";
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO 
+			{
+			caption = "CoreDumpUI";
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/group/coredumpuireg.rss	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,45 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// CoreDumpUIreg.rss -- CoreDumpUI application registration file
+// System Headers
+//
+
+
+
+
+#include <appinfo.rh>
+
+/********************************************************************************
+ *
+ * Local Headers
+ *
+ *******************************************************************************/
+
+/********************************************************************************
+ *
+ * Resources
+ *
+ *******************************************************************************/
+UID2 KUidAppRegistrationResourceFile
+
+UID3 0x102833b5
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file					= "CoreDumpUI";
+	localisable_resource_file	= "\\resource\\apps\\coredumpuiloc";
+	hidden						= KAppNotHidden;
+	embeddability				= KAppNotEmbeddable;
+	newfile						= KAppDoesNotSupportNewFile;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpcdsdialog.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,47 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef __COREDUMPCDSDIALOG_H_INCLUDED__
+#define __COREDUMPCDSDIALOG_H_INCLUDED__
+
+#include "coredumpuidialogs.h"
+
+class CConfigureCDSDialog : public CCoreDumpDialogBase
+	{
+public:
+	// constructor
+	CConfigureCDSDialog(RCoreDumpSession &aCoreDumpSession);
+	~CConfigureCDSDialog();
+
+private:
+	void PreLayoutDynInitL();
+	void PostLayoutDynInitL();
+	TBool OkToExitL(TInt aKeycode);
+	void UpdateDialogDataL(void);
+	void UpdateDialogDataReal(void);
+	void UpdateDialogDataAll(void);
+	void UpdatePriorityText(void); //updates the priority number value to correspond to the priority option selected
+	};
+
+
+#endif // __COREDUMPCDSDIALOG_H_INCLUDED__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpscmdialog.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,48 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+
+#ifndef __COREDUMPSCMDIALOG_H_INCLUDED__
+#define __COREDUMPSCMDIALOG_H_INCLUDED__
+
+#include "coredumpuidialogs.h"
+
+class CConfigureSCMDialog : public CCoreDumpDialogBase
+	{
+public:
+	CConfigureSCMDialog(RCoreDumpSession &aCoreDumpSession);
+	~CConfigureSCMDialog();
+
+private:
+	void PreLayoutDynInitL();
+	void PostLayoutDynInitL();
+	TBool OkToExitL(TInt aKeycode);
+	void UpdateDialogDataL(void);
+	void UpdateDialogDataReal(void);
+	void UpdateDialogDataAll(void);
+	void UpdatePriorityText(void); //updates the priority number value to correspond to the priority option selected
+
+	};
+
+
+#endif // __COREDUMPSCMDIALOG_H_INCLUDED__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpui.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,323 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __CoreDumpUI_H
+#define __CoreDumpUI_H
+
+/**
+@file
+@internalTechnology
+@released
+*/
+
+#include "coredumpui.hrh"
+//for storing resource data
+#include "coredumpuidatastructs.h"
+
+#include <coeccntx.h>
+
+#include <eikenv.h>
+#include <eikappui.h>
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <eikmenup.h>
+
+#include "coredumpuidialogs.h"
+
+#include <coredumpui.rsg>
+#include <eikchkbx.h>
+#include <eikchlst.h>
+#include <eiklbbut.h>
+
+#include <eiklabel.h>
+#include <eikcmbut.h>
+
+#include <eikhopbt.h>
+
+#include <eikclb.h> //for column list box
+#include <eikclbd.h> // for CColumnListBoxData
+
+// for CEikButtonGroupContainer
+#include <eikbtgpc.h>
+
+#include <eikon.hrh>
+
+
+#include <e32base.h>
+#include <e32cons.h>
+#include <e32hal.h>
+#include <e32std.h>
+
+#include <eikedwin.h>
+#include <smut.h>
+#include <f32file.h>
+#include <f32dbg.h>
+#include <e32property.h> //KMaxPropertySize
+
+#include <coredumpinterface.h>
+
+
+_LIT(KFormatDec, "%d");
+_LIT(KFormatDec64, "%ld");
+_LIT(KFormatUDec,"%u");
+_LIT(KFormatHex, "%x");
+_LIT(KAsterisk, "*");
+_LIT(KFillName, "ResMan");
+_LIT(KYes, "Yes");
+_LIT(KSpaces, "   ");
+
+
+enum TObjectsViewed
+	{
+	EObjectNone,
+	EObjectProcess,
+	EObjectThread,
+	EObjectPlugin,
+	EObjectPluginInstance,
+	EObjectExecutable,
+	EObjectCrashList	
+	};
+
+// Forward declarations
+
+class CResourceAppUi;
+class CResourceAppView;
+class CResourceListView;
+class CResourceView;
+class CCrashNotifier;
+//
+//
+// CResourceApplication
+//
+//
+
+class CResourceApplication :  public CEikApplication
+	{
+private: 
+	           // Inherited from class CApaApplication
+	CApaDocument* CreateDocumentL();
+	TUid AppDllUid() const;
+	};
+//
+//
+// CResourceDocument
+//
+//
+class CResourceDocument : public CEikDocument
+	{
+public:
+	static CResourceDocument* NewL(CEikApplication& aApp);
+	CResourceDocument(CEikApplication& aApp);
+	void ConstructL();
+private: 
+	           // Inherited from CEikDocument
+	CEikAppUi* CreateAppUiL();
+	};
+//
+//
+// CResourceAppUi
+//
+//
+class CResourceAppUi : public CEikAppUi
+    {
+public:
+    void ConstructL();
+	~CResourceAppUi();
+
+private:
+	// Inherited from class CEikAppUi
+	void HandleCommandL(TInt aCommand);
+	
+private:
+	void SetCDSL(void);
+	void SetSCM();
+	void CancelCrashL(void);
+
+private:
+	CResourceView* iListBoxView;
+    CCrashNotifier *iCrashNotifier;
+	};
+
+
+#define KTargetString (250)
+
+class TObservationRequest
+{
+public:
+
+	/** Name of the debug target */
+	TBuf<KTargetString>		iTargetName;
+
+	/**
+	If the target is a thread, the name of its process
+	If a process, can be left empty 
+	*/
+	TBuf<KTargetString>		iTargetOwnerName;
+
+	static const TInt iOffset;
+	
+private:
+	TSglQueLink iLink;
+};
+
+//
+//
+// CResourceList
+//
+//
+class CResourceList: public CCoeControl, public MCoeControlObserver
+{
+public:
+	void ConstructL(TInt aTablePosition);
+	~CResourceList();
+    RCoreDumpSession &CoreDumpInterface() { return iCoreDumpSession; }
+	
+protected:
+	void UpdateResourceCount(TUint aNumberOfResource) {iResourceCount = aNumberOfResource;}
+	void UpdateListDataL();
+	
+	CCoeControl* GetListBox() const;
+	void SetObservedL();	
+	void ConfigurePluginL();
+	void LoadPluginL();
+	void UnloadPluginL();
+	void BindPluginsL();
+	void ProcessCrashL();
+	void DeleteCrashLogL();
+	void DeleteEntireCrashPartitionL();
+
+private:
+	void SetUpProcessTableL();
+	void SetUpThreadTableL();
+	void SetUpPluginTableL();
+	void SetUpExecutableTableL();
+	void SetUpPluginInstanceTableL();
+	void SetUpCrashListTableL();
+	void SetUpListL(); //uses single column tables
+	
+	void GetResourceListL();
+	void AddRowL(const TUIProcessData& aProcessData);
+	void AddRowL(const TUIThreadData& aThreadData);
+	void AddRowL(const TUIPluginData& aChunkData);
+	void AddRowL(const TListData& aListData);
+	void AddRowL(const TUIExecutableData& aExeData);
+	void AddRowL(const TUIPluginInstanceData& aPluginInstance);
+	void AddRowL(const TCrashInfo& aCrashInfo);
+
+	void GetThreadListL(void);
+	void GetProcessListL(void);
+	void GetPluginListL(void);
+	void GetExecutableListL(void);
+	void GetPluginInstancesListL(void);
+	void GetCrashListL(void);
+
+	void EmptyList();
+	static void CleanupEComArray(TAny* aArray);
+    static void CleanupSelection(TAny *aList);
+    static void CleanupProcessList(TAny *aArray);
+    static void CleanupThreadList(TAny *aArray);
+    static void CleanupExecutableList(TAny *aArray);
+    static void CleanupPluginList(TAny *aArray);
+    static void CleanupCrashList(TAny* aArray);
+    
+	void BuildSelectedListL(TSglQue<TObservationRequest> &aSelectedList);
+	void SetObservedProcessesL();	
+	void SetObservedThreadsL();	
+	void SetObservedExecutablesL();
+	
+	TCrashInfo* GetCrashInfoL(const TInt aCrashId);
+	
+	TInt GetNumberFormattersL(TUid& aUid);
+	TInt GetNumberWritersL(TUid& aUid);
+	
+	RArray<TInt>* GetMarkedCrashIDsFromUIL();
+		
+	CEikColumnListBox* iListBox;
+	CTextListBoxModel* iModel;
+	MDesCArray* iTextArray;
+	CDesCArray* iListBoxItems;
+	CColumnListBoxData* iListBoxData;
+    RCoreDumpSession iCoreDumpSession;
+    RBuf iRowItem;
+	
+protected:
+	TUIProcessData iProcessData;
+	TUIThreadData iThreadData;
+	TUIPluginData iPluginData;
+	TUIPluginInstanceData iPluginInstanceData;
+	TUIExecutableData iExeData;
+	
+	TInt iBorder;
+	TUint iResourceCount; // Count of number of items in table
+    TBuf<RProperty::KMaxPropertySize> iCrashProgress; //crash progress state
+	TObjectsViewed iObjectsViewed; // What view is showing
+	
+private:	
+	RCrashInfoPointerList iCrashList;  //what crashes we have stored in the log
+};
+ 
+//
+//
+// CResourceView
+//
+//
+class CResourceView : public CResourceList
+    {
+public:
+	static CResourceView* NewL(const TRect& aRect, CResourceAppUi* aAppUi);
+	
+	~CResourceView();
+	
+	void SetCurrentObjects(TObjectsViewed aViewed)
+		{iObjectsViewed = aViewed;};
+
+	void UpdateViewL();
+    void UpdateCrashProgressL();
+
+    TDes& CrashProgress();
+
+private:
+	// Private constructor to force NewL
+	CResourceView();
+	void ConstructL(const TRect& aRect, CResourceAppUi* aAppUi);
+	void InvalidateView(void) const;
+	void UpdateTitleL(void);
+
+protected:
+
+	// Inherited from CCoeControl
+	virtual TInt CountComponentControls() const;				
+	virtual CCoeControl* ComponentControl(TInt aIndex) const;
+	virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
+
+private:
+	
+	// Inherited from CCoeControl
+	void Draw(const TRect& /*aRect*/) const;
+
+private:
+	
+	CResourceAppUi* iAppUi;
+
+	// State Data
+	TBuf<RProperty::KMaxPropertySize> iTitle; // Title above table
+	// Controls
+	CEikCommandButton* iCommandButton;
+	CEikCommandButton* iObserveButton;
+	CEikCommandButton* iLoadButton;
+    };
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpui.hrh	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,127 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "coredumpuiplatform.hrh"
+
+/**
+@file
+@internalTechnology
+@released
+*/
+
+enum TResourceMenuCommands
+	{
+	EResourceMenu1Item0 = 200,
+	EResourceMenu1Item1,
+	EResourceMenu1Item2,
+	EResourceMenu1PluginInstances,
+	EResourceMenu1Executables,
+	EResMenu2ConfCDS = 300,
+	EResMenu2ConfPlugin,
+	EResMenu2CancelCrash,
+	EResMenu3ListCrashes,
+	EResMenu2ConfSCM
+	};
+
+enum TResourceDialogControls
+	{
+	EPage1 = 1000,
+	EPage2,
+
+	ELabel0 = 1050,
+	ELabel1,
+	ELabel2,
+	ELabel3,
+	ELabel4,
+	ELabel5,
+	ELabel6,
+	ELabel7,
+	ELabel8,
+	ELabel9,
+	ELabel10,
+	ELabel11,
+	ELabel12,
+	ELabel13,
+	ELabel14,
+	ELabel15,
+	ELabel16,
+	ELabel17,
+	ELabel18,
+	
+	EEdwin0,
+	EEdwin1,
+	EEdwin2,
+	EEdwin3,
+	EEdwin4,
+	EEdwin5,
+	EEdwin6,
+	EEdwin7,
+	EEdwin8,
+	EEdwin9,
+	EEdwin10,
+	EEdwin11,
+	EEdwin12,
+	EEdwin13,
+	EEdwin14,
+	EEdwin15,
+	EEdwin16,
+	EEdwin17,
+	EEdwin18,
+	
+	EBidCDSConfigure,
+	EBidPluginConfigure,
+	
+	EConfigCDSPage,
+	EConfigSCMPage,
+	
+	EConfigPluginPage,
+	EPluginLabel1,
+	EPluginLabel2,
+	EPluginLabel3,
+	EPluginLabel4,
+	EPluginLabel5,
+	EPluginLabel6,
+	EPluginLabel7,
+	EPluginLabel8,
+	EPluginLabel9,
+	EPluginLabel10,
+	EPluginLabel11,
+	EPluginLabel12,
+	EPluginLabel13,
+	EPluginLabel14,
+	EPluginLabel15,
+	EPluginLabel16,
+	EPluginLabel17,
+	EPluginLabel18,
+	EPluginEdwin1,
+	EPluginEdwin2,
+	EPluginEdwin3,
+	EPluginEdwin4,
+	EPluginEdwin5,
+	EPluginEdwin6,
+	EPluginEdwin7,
+	EPluginEdwin8,
+	EPluginEdwin9,
+	EPluginEdwin10,
+	EPluginEdwin11,
+	EPluginEdwin12,
+	EPluginEdwin13,
+	EPluginEdwin14,
+	EPluginEdwin15,
+	EPluginEdwin16,
+	EPluginEdwin17,
+	EPluginEdwin18
+	
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpuidatastructs.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,80 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __CoreDumpUI_DataStructs_H
+#define __CoreDumpUI_DataStructs_H
+
+/**
+@file
+@internalTechnology
+@released
+*/
+
+#include <e32std.h> //descriptors, TUidType etc
+
+struct TListData
+/** Stores library, server, device and logical channel data */
+{
+	TFullName iName;
+};
+
+struct TUIProcessData
+/** Stores process details */
+	{
+	TBuf<8> iIdString;
+	TFileName iProcessName; // this is a TBuf (big)
+
+	TBuf<3> iObserved;
+	};
+
+struct TUIThreadData
+/** Stores thread details */
+	{
+	TBuf<8> iIdString;
+	TFileName iThreadName; // this is a TBuf (big)
+	TBuf<10> iPriorityString;
+	TBuf<8> iOwnerIdString;
+	TBuf<3>	 iObserved;
+	};
+
+struct TUIPluginData
+/** Stores plugin details */
+	{
+	TFullName iName; // this is a TBuf (big)
+	TBuf<128> iDescription;
+	TBuf<10> iUid;	 // UID of the plugin
+	TBuf<50> iType;   
+	TBuf<8> iInstances;
+	};
+	
+struct TUIExecutableData
+/** Stores the executable details */
+	{
+	TFileName iExeName;
+	TBuf<3> iObserved;
+	};
+
+struct TUIPluginInstanceData
+/** Stores plugin instance data */
+	{
+	TBuf<8> iIdString;
+	TFullName iName; // this is a TBuf (big)
+	TBuf<128> iDescription;
+	TBuf<10> iUid;	 // UID of the plugin
+	TBuf<50> iType;  
+	TBuf<10> iBoundTo;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpuidialogs.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,69 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef CoreDumpUI_DIALOGS_H
+#define CoreDumpUI_DIALOGS_H
+
+#include <eikdialg.h>
+#include <coredumpinterface.h>
+#include <optionconfig.h>
+
+class CCoreDumpDialogBase : public CEikDialog
+	{
+public:
+	// constructor
+	CCoreDumpDialogBase(RCoreDumpSession &aCoreDumpSession);
+	virtual ~CCoreDumpDialogBase();
+public:
+	void DisplayErrorL(TDesC& aMessage, TInt aErrorNumber);
+	void DisplayErrorL(TDesC& aMessage);
+	
+protected:
+    RCoreDumpSession &iCoreDumpSession;  
+	RPointerArray<COptionConfig> iConfs; 
+
+	};
+
+
+class CConfigurePluginDialog : public CCoreDumpDialogBase
+	{
+public:
+	// constructor
+	CConfigurePluginDialog(TUid aUid, RCoreDumpSession &aCoreDumpSession, TInt aInstance);
+	~CConfigurePluginDialog();
+
+private:
+	void PreLayoutDynInitL();
+	void PostLayoutDynInitL();
+	TBool OkToExitL(TInt aKeycode);
+	void UpdateDialogDataL(void);
+	void UpdatePriorityText(void);
+	void UpdateProcessId(void);
+
+private:
+	TUid iUid;
+	TInt iInstance;
+	};
+
+
+#endif 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpuinotifier.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,47 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Core dump progress observer active object class definition.
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#ifndef CORE_DUMP_UI_NOTIFIER_H
+#define CORE_DUMP_UI_NOTIFIER_H
+
+#include "coredumpui.h"
+
+class CCrashNotifier : public CActive
+{
+
+public:
+    static CCrashNotifier *NewL(CResourceView &aResourceView);
+    ~CCrashNotifier();
+
+protected:
+    CCrashNotifier(CResourceView &aResourceView);
+    void ConstructL();
+    void RunL();
+    void DoCancel();
+
+private:
+    RProperty iProperty; //property that stores crash progress
+    CResourceView &iResourceView; //ui view to be notified about the progress
+};
+#endif //CORE_DUMP_UI_NOTIFIER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/inc/coredumpuiplatform.hrh	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,25 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#define TV
+#define WINS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/src/coredumpcdsdialog.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,330 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+
+#include "coredumpui.h"
+#include "coredumpcdsdialog.h"
+
+// CConfigureCDSDialog //
+
+CConfigureCDSDialog::CConfigureCDSDialog(RCoreDumpSession &aCoreDumpSession)
+    : CCoreDumpDialogBase(aCoreDumpSession)
+    {
+    }
+
+CConfigureCDSDialog::~CConfigureCDSDialog()
+	{
+	iConfs.ResetAndDestroy();
+	}
+
+void CConfigureCDSDialog::PreLayoutDynInitL()
+	{
+	UpdateDialogDataL();
+	}
+
+void CConfigureCDSDialog::PostLayoutDynInitL()
+	{
+	}
+
+void CConfigureCDSDialog::UpdateDialogDataL()
+	{
+	//update dialog
+	RPointerArray<CEikEdwin> edwins;
+	CEikEdwin *edwin = static_cast<CEikEdwin*>(Control(EEdwin1));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin2));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin3));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin4));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin5));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin6));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin7));
+	edwins.Append(edwin);
+	for (TInt i = 0; i < edwins.Count(); i++)
+		{
+		edwins[i]->SetDimmed(ETrue);
+		edwins[i]->SetReadOnly(ETrue);
+		}
+
+	RPointerArray<CEikLabel> labels;
+	CEikLabel *label = static_cast<CEikLabel*>(Control(ELabel1));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(ELabel2));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(ELabel3));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(ELabel4));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(ELabel5));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(ELabel6));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(ELabel7));
+	labels.Append(label);
+
+	// Read config parameters from CDS
+	TInt noConfigParams = 0;
+	iConfs.ResetAndDestroy();
+	
+    TRAPD(err, noConfigParams = iCoreDumpSession.GetNumberConfigParametersL());
+    if(err != KErrNone)
+        {
+		TBuf<23> error;
+		error.Format(_L("Error: %d"), err);
+		CEikonEnv::InfoWinL(_L("Could not get number of config params!"), error);
+        User::Leave(err);
+        }
+	TInt control = 0;
+	//RDebug::Print(_L("CConfigureCDSDialog::UpdateDialogDataL: noConfigParams: %d"), noConfigParams);
+	for (TInt i = 0; i < noConfigParams; i++)
+		{
+		COptionConfig* conf;
+		conf = iCoreDumpSession.GetConfigParameterL(i);
+		if (conf->Source()== COptionConfig::ECoreDumpServer)
+			{
+			iConfs.Append(conf);
+			TBuf<255> buf = conf->Prompt();
+			switch (conf->Type())
+				{
+				case COptionConfig::ETInt:
+					{
+					buf.Append(_L("\n(Signed int)"));
+					TBuf<255> value;
+					value.Format(_L("%d"), iConfs[control]->Value());
+					edwins[control]->SetTextL(&value);
+					}
+					break;
+
+				case COptionConfig::ETUInt:
+					{
+					buf.Append(_L("\n(Unsigned int)"));
+					TBuf<255> value;
+					value.Format(_L("%d"), iConfs[control]->Value());
+					edwins[control]->SetTextL(&value);
+					}
+					break;
+
+				case COptionConfig::ETString:
+					{
+					buf.Append(_L("\n(String)"));
+					edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc()));
+					}
+					break;
+
+				case COptionConfig::ETFileName:
+					{
+					buf.Append(_L("\n(File name)"));
+					edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc()));
+					}
+					break;
+
+				case COptionConfig::ETSingleEntryEnum:
+					{
+					buf.Append(_L("\n"));
+					buf.Append(conf->Options());
+					edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc()));
+					}
+					break;
+
+				case COptionConfig::ETMultiEntryEnum:
+					{
+					buf.Append(_L("\n"));
+					buf.Append(conf->Options());
+					edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc()));
+					}
+					break;
+
+				case COptionConfig::ETBool:
+					{
+					buf.Append(_L("\n"));
+					buf.Append(conf->Options());
+					TBuf<255> value;
+					iConfs[control]->Value() ? value = _L("True") : value = _L("False");
+					edwins[control]->SetTextL(&value);
+					}
+					break;
+
+				default:
+					break;
+				}
+			labels[control]->SetTextL(buf);
+			edwins[control]->SetDimmed(EFalse);
+			edwins[control++]->SetReadOnly(EFalse);
+			}
+        else
+            {
+            delete conf;
+            }
+		}
+	edwins.Close();
+	labels.Close();
+	}
+
+TBool CConfigureCDSDialog::OkToExitL(TInt aButtonId)
+	{
+	LOG_MSG( "-> CConfigureCDSDialog::OkToExitL" );
+	TBool ret = ETrue;
+	TInt err;
+
+	RPointerArray<CEikEdwin> edwins;
+	CEikEdwin *edwin = static_cast<CEikEdwin*>(Control(EEdwin1));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin2));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin3));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin4));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin5));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin6));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EEdwin7));
+	edwins.Append(edwin);
+
+	switch (aButtonId)
+		{
+		case EEikBidCancel:
+			{
+			//RDebug::Print(_L("CConfigureCDSDialog::OkToExitL: Cancel pressed"));
+			}
+			break;
+		case EBidCDSConfigure:
+			{
+			//RDebug::Print(_L("CConfigureCDSDialog::OkToExitL: iConfs.Count() == %d"), iConfs.Count());
+			for (TInt i = 0; ( i < iConfs.Count() ) && ret; i++)
+				{
+				err = KErrNone;
+
+				HBufC *input = NULL;
+				if (edwins[i]->TextLength() > 0)
+					{
+					input = edwins[i]->GetTextInHBufL();
+					}
+				if ( ! input )
+					{
+					LOG_MSG2( "  NULL input for param %d" , i );
+					continue;
+					}
+
+				//RDebug::Print(_L("CConfigureCDSDialog::OkToExitL: iConfs[i]->Type() == %d"), iConfs[i]->Type());
+
+				switch (iConfs[i]->Type())
+					{
+					case COptionConfig::ETInt:
+					case COptionConfig::ETUInt:
+						{
+						TLex opts(*input);
+						TInt32 conf;
+						err = opts.Val(conf);
+						if ( err )
+							{
+							LOG_MSG("  error from opts.Val(conf) -> CConfigureCDSDialog::CEikonEnv::Static()->InfoMsg;" );
+							CEikonEnv::Static()->InfoMsg(_L("Value must be an integer"));
+							break;
+							}
+
+						//RDebug::Print(_L("CConfigureCDSDialog::OkToExitL: conf == %d"), conf);
+						iConfs[i]->Value(conf);
+						TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) );
+						}
+						break;
+
+					case COptionConfig::ETFileName:
+					case COptionConfig::ETString:
+					case COptionConfig::ETSingleEntryEnum:
+					case COptionConfig::ETMultiEntryEnum:
+						{						
+						TRAP( err, iConfs[i]->ValueL(*input) );
+						if ( KErrNone == err )
+							{
+							TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) );
+							}
+						}
+						break;
+
+					case COptionConfig::ETBool:
+						if (input->CompareF(_L("True"))== 0)
+							{
+							iConfs[i]->Value(ETrue);
+							iConfs[i]->ValueL(_L("True"));
+							}
+						else if (input->CompareF(_L("False"))== 0)
+							{
+							iConfs[i]->Value(EFalse);
+							iConfs[i]->ValueL(_L("False"));
+							}
+						else
+							{
+							err = KErrCorrupt;
+							}
+
+						if ( KErrNone == err )
+							{
+							TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) );
+							}
+
+						break;
+
+					default:
+						CEikonEnv::Static()->InfoMsg(_L("Error with parameter type"));
+						LOG_MSG( "CConfigureCDSDialog::OkToExitL: none of the above" );
+						err = KErrCorrupt;
+						break;
+
+					}//switch
+
+				if ( err )
+					{
+					RBuf errorString;
+					CleanupClosePushL( errorString );
+					errorString.CreateL( 128 );
+					errorString.Append( _L("CDS Error ") ); 
+					errorString.AppendNum( err );
+					errorString.Append( _L(" setting parameter number ") );
+					errorString.AppendNum( i );
+					CEikonEnv::InfoWinL( errorString, KNullDesC );
+					CleanupStack::PopAndDestroy( &errorString );
+					ret = EFalse;
+					}
+                if(input)
+                    {
+                    delete input;
+                    input = NULL;
+                    }
+				}
+			}
+			break;
+		default:
+			break;
+		}
+
+    edwins.Close();
+	return ret;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/src/coredumpscmdialog.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,214 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Implementation of CConfigureSCMDialog class 
+//
+
+
+
+/**
+ @file
+ @internalTechnology 
+ @released
+ @see CCoreDumpFormatter
+*/
+
+#include "coredumpui.h"
+#include "coredumpscmdialog.h"
+
+
+CConfigureSCMDialog::CConfigureSCMDialog(RCoreDumpSession &aCoreDumpSession)
+    : CCoreDumpDialogBase(aCoreDumpSession)
+    {
+    }
+
+CConfigureSCMDialog::~CConfigureSCMDialog()
+	{
+	iConfs.ResetAndDestroy();
+	}
+
+void CConfigureSCMDialog::PreLayoutDynInitL()
+	{
+	UpdateDialogDataL();
+	}
+
+void CConfigureSCMDialog::PostLayoutDynInitL()
+	{
+	}
+
+void CConfigureSCMDialog::UpdateDialogDataL()
+	{
+	// We are loading up edwins as defined in rss file here
+	// A better approach may be to create the items dynamically if time allows
+	// example code for this at http://wiki.forum.nokia.com/index.php/Create_Modal_dialog_and_add_controls_dynamically
+	
+	//update dialog
+	RPointerArray<CEikEdwin> edwins;
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin0)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin1)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin2)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin3)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin4)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin5)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin6)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin7)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin8)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin9)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin10)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin11)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin12)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin13)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin14)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin15)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin16)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin17)));
+	edwins.Append(static_cast<CEikEdwin*>(Control(EEdwin18)));
+	
+	for (TInt i = 0; i < edwins.Count(); i++)
+		{
+		edwins[i]->SetDimmed(ETrue);
+		edwins[i]->SetReadOnly(ETrue);
+		}
+
+	RPointerArray<CEikLabel> labels;
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel0)));  	// 0
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel1)));  	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel2)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel3)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel4)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel5)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel6)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel7)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel8)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel9)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel10)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel11)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel12)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel13)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel14)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel15)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel16)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel17)));	
+	labels.Append(static_cast<CEikLabel*>(Control(ELabel18)));	
+
+	// Read config parameters from CDS
+	TInt noConfigParams = 0;
+	iConfs.ResetAndDestroy();
+	
+    TRAPD(err, noConfigParams = iCoreDumpSession.GetNumberConfigParametersL());
+    if(err != KErrNone)
+        {
+		TBuf<23> error;
+		error.Format(_L("Error: %d"), err);
+		CEikonEnv::InfoWinL(_L("Could not get number of config params!"), error);
+        User::Leave(err);
+        }
+	TInt control = 0;
+
+	for (TInt i = 0; i < noConfigParams; i++)
+		{
+		COptionConfig* conf;
+		conf = iCoreDumpSession.GetConfigParameterL(i);
+		if (conf->Source()== COptionConfig::ESCMConfig && control < edwins.Count())
+			{
+			iConfs.Append(conf);
+			
+			TBuf<255> buf = conf->Prompt();
+			switch (conf->Type())
+				{
+				// SCM configuration options are all TInt (TInt priority)
+				case COptionConfig::ETInt:
+					{
+					buf.Append(_L("\n(priority (0-255) "));
+					TBuf<100> value;
+					value.Format(_L("%d"), iConfs[control]->Value());
+					edwins[control]->SetTextL(&value);
+					// save the edwin in the tag field of option config 
+					// this will make unloading the data easier
+					conf->SetTag(edwins[control]);
+					}
+					break;
+				default:
+					break;
+				}
+			labels[control]->SetTextL(buf);
+			edwins[control]->SetDimmed(EFalse);
+			edwins[control++]->SetReadOnly(EFalse);
+			}
+        else
+            {
+            delete conf;
+            }
+		}
+	edwins.Close();
+	labels.Close();
+	}
+
+
+TBool CConfigureSCMDialog::OkToExitL(TInt aButtonId)
+	{
+	
+	TBool ret = ETrue;
+	TInt err = KErrNone;
+	
+	
+	// for the scm dialog - each edwin contains an integer value priority 
+	for (TInt i = 0; i <iConfs.Count(); i++)
+		{
+		COptionConfig* conf = iConfs[i];
+		if(!conf)
+			{
+			continue;
+			}
+
+
+		// retrieve the edwin pointer (saved in iTag member)
+		CEikEdwin* edwin = (CEikEdwin*) conf->Tag();
+		if(edwin)
+			{
+			HBufC* hBuf = edwin->GetTextInHBufL();
+			CleanupStack::PushL(hBuf);
+			//hBuf->Des()
+			TLex lex(*hBuf);
+			TInt32 priority;
+			err = lex.Val(priority);
+			
+			if(err != KErrNone)
+				{
+				LOG_MSG("  error from lex.Val(conf) -> CConfigureSCMDialog::CEikonEnv::Static()->InfoMsg;" );
+				CEikonEnv::Static()->InfoMsg(_L("Value must be an integer"));
+				}			
+			else if(priority != conf->Value())
+				{
+				iConfs[i]->Value(priority);
+
+				LOG_MSG4("CConfigureSCMDialog::OkToExitL modifying item uid=%d instance=%d value=%d",
+						conf->Uid(), conf->Instance(), conf->Value());
+
+				
+				
+				TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) );
+				if( err != KErrNone)
+					{
+					CEikonEnv::Static()->InfoMsg(_L("Error changing config param "));
+					}
+				
+				}
+
+			CleanupStack::PopAndDestroy(hBuf);
+			}
+
+		}
+	
+	return ret;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuiapplication.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,29 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "coredumpui.h"
+ 
+
+TUid CResourceApplication::AppDllUid() const
+	{
+	TUid KUidCoreDumpUI = { 0x102833b5 };
+	return KUidCoreDumpUI;
+	}
+
+CApaDocument* CResourceApplication::CreateDocumentL()
+	{
+	return new (ELeave) CResourceDocument(*this);
+	}
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuiappui.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,143 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include "coredumpui.h"
+#include <coredumpui.rsg>
+#include "coredumpuinotifier.h"
+
+#include "coredumpcdsdialog.h"
+#include "coredumpscmdialog.h"
+
+void CResourceAppUi::ConstructL()
+{
+	BaseConstructL();
+	iListBoxView = CResourceView::NewL(ClientRect(), this);
+    iCrashNotifier = CCrashNotifier::NewL(*iListBoxView);
+	//construct a default view
+	HandleCommandL(EResourceMenu1Item0);
+}
+
+CResourceAppUi::~CResourceAppUi()
+{
+    delete iCrashNotifier;
+	delete iListBoxView;
+}
+
+void CResourceAppUi::HandleCommandL(TInt aCommand)
+{
+	LOG_MSG("->[UI]CResourceAppUi::HandleCommandL(TInt aCommand)");
+	// Increase this threads priority for a proper snapshot
+	RThread thisThread;
+	thisThread.SetPriority(EPriorityAbsoluteHigh);
+	thisThread.Close();
+
+	TObjectsViewed objectViewed = EObjectNone;
+
+	switch (aCommand)
+		{	
+		// Menu 1	
+		case EResourceMenu1Item0:
+			{
+			objectViewed = EObjectProcess;
+			break;
+			}
+		case EResourceMenu1Item1:
+			{
+			objectViewed = EObjectThread;
+			break;
+			}
+		case EResourceMenu1Item2:
+			{
+			objectViewed = EObjectPlugin;
+			break;
+			}
+		case EResourceMenu1Executables:
+			{
+			objectViewed = EObjectExecutable;
+			break;
+			}
+		case EResourceMenu1PluginInstances:
+			{
+			objectViewed = EObjectPluginInstance;
+			break;
+			}
+		// Menu 2
+		case EResMenu2ConfCDS:
+			{
+			SetCDSL();
+			break;
+			}
+		case EResMenu2ConfSCM:
+			{
+			SetSCM();
+			break;
+			}
+		case EResMenu2CancelCrash:
+			{
+			CancelCrashL();
+			break;
+			}
+			
+		//Flash Menu
+		case EResMenu3ListCrashes:
+			{
+			objectViewed = EObjectCrashList;
+			break;
+			}
+		case EEikCmdExit: // necessary for uninstalling
+			{
+			Exit();
+			break;
+			}
+		default:
+			{
+			break;
+			}
+		}
+
+	// Set view data
+	if (objectViewed != EObjectNone)
+	{
+		iListBoxView->SetCurrentObjects(objectViewed);
+		iListBoxView->UpdateViewL();
+	}
+
+	// ResetPriority
+	RThread thisThread2;
+	thisThread2.SetPriority(EPriorityNormal);
+	thisThread2.Close();
+
+}
+
+void CResourceAppUi::CancelCrashL()
+    {
+    LOG_MSG("->CResourceAppUI::CancelCrashL()");
+    User::LeaveIfError(RProperty::Set(KCoreDumpServUid, ECancelCrash, ETrue));
+    }
+
+void CResourceAppUi::SetCDSL()
+	{
+	CConfigureCDSDialog* dialog = new(ELeave) CConfigureCDSDialog(iListBoxView->CoreDumpInterface());	
+	dialog->ExecuteLD(R_CONFIGURE_CDS_DIALOG);
+	}
+
+
+void CResourceAppUi::SetSCM()
+	{
+	CConfigureSCMDialog* dialog = new (ELeave) CConfigureSCMDialog(iListBoxView->CoreDumpInterface());	
+	dialog->ExecuteLD(R_CONFIGURE_SCM_DIALOG);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuidialogs.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,436 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "coredumpui.h"
+#include <optionconfig.h>
+#include <bautils.h>
+
+
+ // CDialogBase //
+
+CCoreDumpDialogBase::CCoreDumpDialogBase(RCoreDumpSession &aCoreDumpSession)
+: iCoreDumpSession(aCoreDumpSession)
+	{
+	}
+
+CCoreDumpDialogBase::~CCoreDumpDialogBase()
+	{
+	iConfs.ResetAndDestroy();
+	}
+
+void CCoreDumpDialogBase::DisplayErrorL(TDesC& aMessage, TInt aErrorNumber)
+	{
+	//could check doesn't go out of bounds
+	TBuf<250> errorMssge(aMessage);
+	errorMssge.Append(_L(" fails with system error no. "));
+	TBuf<3> errorNum;
+	_LIT(KFormatDec, "%d");
+	errorNum.Format(KFormatDec, aErrorNumber);
+	errorMssge.Append(errorNum);
+	iEikonEnv->InfoWinL(_L("Error"), errorMssge);
+	}
+
+void CCoreDumpDialogBase::DisplayErrorL(TDesC& aMessage)
+	{
+	//could check don't go out of bounds
+	TBuf<250> errorMssge(aMessage);
+	iEikonEnv->InfoWinL(_L("Error"), errorMssge);
+	}
+
+
+// CConfigurePluginDialog //
+
+CConfigurePluginDialog::CConfigurePluginDialog(TUid aUid, RCoreDumpSession &aCoreDumpSession, TInt aInstance)
+    : CCoreDumpDialogBase(aCoreDumpSession), iUid(aUid), iInstance(aInstance)
+	{
+	}
+
+CConfigurePluginDialog::~CConfigurePluginDialog()
+	{
+	iConfs.ResetAndDestroy();
+	}
+
+void CConfigurePluginDialog::PreLayoutDynInitL()
+	{
+	UpdateDialogDataL();
+	}
+
+void CConfigurePluginDialog::PostLayoutDynInitL()
+	{
+	}
+
+void CConfigurePluginDialog::UpdateDialogDataL()
+	{
+	//update dialog
+	//RDebug::Print(_L("CConfigurePluginDialog::UpdateDialogDataL()"));
+	LOG_MSG("->[UI]CConfigurePluginDialog::UpdateDialogDataL()");
+	
+	RPointerArray<CEikEdwin> edwins;
+	RPointerArray<CEikLabel> labels;
+	CEikEdwin *edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin1));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin2));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin3));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin4));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin5));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin6));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin7));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin8));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin9));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin10));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin11));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin12));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin13));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin14));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin15));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin16));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin17));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin18));
+	edwins.Append(edwin);
+	for (TInt i = 0; i < edwins.Count(); i++)
+		{
+		edwins[i]->SetDimmed(ETrue);
+		edwins[i]->SetReadOnly(ETrue);
+		}
+
+	CEikLabel *label = static_cast<CEikLabel*>(Control(EPluginLabel1));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel2));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel3));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel4));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel5));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel6));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel7));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel8));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel9));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel10));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel11));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel12));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel13));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel14));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel15));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel16));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel17));
+	labels.Append(label);
+	label = static_cast<CEikLabel*>(Control(EPluginLabel18));
+	labels.Append(label);
+	
+
+	// Read config parameters from CDS
+	//RDebug::Print(_L("Read config parameters from CDS"));
+	TInt noConfigParams = 0;
+	iConfs.ResetAndDestroy();
+	
+	LOG_MSG("\tiCoreDumpSession.GetNumberConfigParametersL()");
+	TRAPD(err, noConfigParams = iCoreDumpSession.GetNumberConfigParametersL());
+    if(err != KErrNone)
+        {
+		TBuf<23> error;
+		error.Format(_L("Error: %d"), err);
+		CEikonEnv::InfoWinL(_L("Could not get number of config params!"), error);
+        User::Leave(err);
+        }
+
+	TInt control = 0;
+	LOG_MSG2( "CConfigurePluginDialog::UpdateDialogDataL: noConfigParams: %d", noConfigParams);
+	for (TInt i = 0; i < noConfigParams; i++)
+		{
+		COptionConfig* conf;
+		RDebug::Printf("Getting ID = %d", i);
+		conf = iCoreDumpSession.GetConfigParameterL(i);
+		if (iUid == TUid::Uid(conf->Uid()) && iInstance == conf->Instance())
+			{			
+			iConfs.Append(conf);
+			TBuf<255> buf = conf->Prompt();
+			switch (conf->Type())
+				{
+				case COptionConfig::ETInt:
+					{
+					buf.Append(_L("\n(Signed int)"));
+					TBuf<255> value;
+					value.Format(_L("%d"), iConfs[control]->Value());
+					edwins[control]->SetTextL(&value);
+					}
+					break;
+
+				case COptionConfig::ETUInt:
+					{
+					buf.Append(_L("\n(Unsigned int)"));
+					TBuf<255> value;
+					value.Format(_L("%d"), iConfs[control]->Value());
+					edwins[control]->SetTextL(&value);
+					}
+					break;
+
+				case COptionConfig::ETString:
+					{
+					buf.Append(_L("\n(String)"));
+					edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc()));
+					}
+					break;
+
+				case COptionConfig::ETFileName:
+					{
+					buf.Append(_L("\n(File name)"));
+					/*
+					RDebug::Print(_L("edwins[control]->SetTextL(ValueAsDesc() Length=%d"),
+						(iConfs[control]->ValueAsDesc()).Size() );
+					*/
+					edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc()));
+					}
+					break;
+
+				case COptionConfig::ETSingleEntryEnum:
+					{
+					buf.Append(_L("\n"));
+					buf.Append(conf->Options());
+					edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc()));
+					}
+					break;
+
+				case COptionConfig::ETMultiEntryEnum:
+					{
+					buf.Append(_L("\n"));
+					buf.Append(conf->Options());
+					edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc()));
+					}
+					break;
+
+				case COptionConfig::ETBool:
+					{
+					buf.Append(_L("\n"));
+					buf.Append(conf->Options());
+					TBuf<255> value;
+					iConfs[control]->Value() ? value = _L("True") : value = _L("False");
+					edwins[control]->SetTextL(&value);
+					}
+					break;
+
+				default:
+					break;
+				}
+			labels[control]->SetTextL(buf);
+			edwins[control]->SetDimmed(EFalse);
+			edwins[control++]->SetReadOnly(EFalse);
+			}
+        else
+            {
+            delete conf;
+            }
+		}
+	edwins.Close();
+	labels.Close();
+	}
+
+TBool CConfigurePluginDialog::OkToExitL(TInt aButtonId)
+	{
+	LOG_MSG( "-> CConfigurePluginDialog::::OkToExitL" );
+	TBool ret = ETrue;
+	TInt err;
+
+	RPointerArray<CEikEdwin> edwins;
+	CEikEdwin *edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin1));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin2));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin3));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin4));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin5));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin6));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin7));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin8));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin9));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin10));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin11));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin12));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin13));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin14));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin15));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin16));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin17));
+	edwins.Append(edwin);
+	edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin18));
+	edwins.Append(edwin);
+
+	switch (aButtonId)
+		{
+		case EEikBidCancel:
+			{
+			//RDebug::Print(_L("CConfigurePluginDialog::OkToExitL: Cancel pressed"));
+			}
+			break;
+		case EBidPluginConfigure:
+			{
+			RDebug::Print(_L("CConfigurePluginDialog::OkToExitL: iConfs.Count() == %d"), iConfs.Count());
+			for (TInt i = 0; i < iConfs.Count(); i++)
+				{
+				err = KErrNone;
+				HBufC *input = NULL;
+				if (edwins[i]->TextLength() > 0)
+					{
+					input = edwins[i]->GetTextInHBufL();
+					}
+				if ( ! input )
+					{
+					input = HBufC::NewL(KMaxFileName);
+					TPtr ptr(input->Des());
+					ptr = KNullDesC;
+					}
+
+				RDebug::Print(_L("CConfigurePluginDialog::OkToExitL: input == %S"), input);
+				RDebug::Print(_L("CConfigurePluginDialog::OkToExitL: iConfs[i]->Type() == %d"), iConfs[i]->Type());
+
+				switch (iConfs[i]->Type())
+					{
+					case COptionConfig::ETInt:
+					case COptionConfig::ETUInt:
+						{
+						TLex opts(*input);
+						TInt32 conf;
+						//RDebug::Print(_L("err = opts.Val(conf);"));
+						err = opts.Val(conf);
+						//RDebug::Print(_L("CConfigurePluginDialog::err = opts.Val(conf);"));
+						if ( err )
+							{
+							LOG_MSG("CConfigurePluginDialog::CEikonEnv::Static()->InfoMsg;");
+							CEikonEnv::Static()->InfoMsg(_L("Value must be an integer"));
+							break;
+							}
+
+						iConfs[i]->Value(conf);
+						TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) );
+						}
+						break;
+					case COptionConfig::ETFileName:
+					case COptionConfig::ETString:
+					case COptionConfig::ETSingleEntryEnum:
+					case COptionConfig::ETMultiEntryEnum:
+						{
+						TRAP( err, iConfs[i]->ValueL(*input) );
+						if ( KErrNone == err )
+							{
+							TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) );
+							}
+						}
+						break;
+
+					case COptionConfig::ETBool:
+						if (input->CompareF(_L("True"))== 0)
+							{
+							//RDebug::Print(_L("input->CompareF(_L(True))== 0"));
+							iConfs[i]->Value(ETrue);
+							iConfs[i]->ValueL(_L("True"));
+							}
+						else if (input->CompareF(_L("False"))== 0)
+							{
+							//RDebug::Print(_L("input->CompareF(_L(False))== 0"));
+							iConfs[i]->Value(EFalse);
+							iConfs[i]->ValueL(_L("False"));
+							}
+						else
+							{
+							LOG_MSG( "  CConfigurePluginDialog::OkToExitL err = KErrCorrupt" );
+							err = KErrCorrupt;
+							}
+
+						if( KErrNone == err )
+							{
+							TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) );
+							RDebug::Print(_L("CConfigurePluginDialog::OkToExitL: SetConfigParameterL ret %d"), err);
+							}
+						break;
+
+					default:
+						CEikonEnv::Static()->InfoMsg(_L("Error with parameter type"));
+						LOG_MSG("CConfigurePluginDialog::OkToExitL: none of the above" );
+						LOG_MSG("default err = KErrCorrupt");
+						err = KErrCorrupt;						
+						break;
+					}
+
+				if ( err != KErrNone )
+					{
+					RBuf errorString;
+					CleanupClosePushL( errorString );
+					errorString.CreateL( 128 );
+					errorString.Append( _L("Config Plugin - Error ") ); 
+					errorString.AppendNum( err );
+					errorString.Append( _L(" setting parameter number ") );
+					errorString.AppendNum( i );
+					CEikonEnv::InfoWinL( errorString, KNullDesC );
+					CleanupStack::PopAndDestroy( &errorString );
+					ret = EFalse;
+					}
+                if(input)
+                    {
+                    delete input;
+                    input = NULL;
+                    }
+				}//for
+			}//switch
+			break;
+		default:
+			break;
+		}
+	//RDebug::Print(_L("<--------- CConfigurePluginDialog::OkToExitL"));
+    edwins.Close();
+	return ret;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuidocument.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,36 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "coredumpui.h" 
+
+//             The constructor of the document class just passes the
+//             supplied reference to the constructor initialisation list.
+//             The document has no real work to do in this application.
+//
+CResourceDocument::CResourceDocument(CEikApplication& aApp)
+		: CEikDocument(aApp)
+	{
+	}
+
+
+//             This is called by the UI framework as soon as the 
+//             document has been created. It creates an instance
+//             of the ApplicationUI. The Application UI class is
+//             an instance of a CEikAppUi derived class.
+//
+CEikAppUi* CResourceDocument::CreateAppUiL()
+	{
+    return new(ELeave) CResourceAppUi;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuimain.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,36 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "coredumpui.h"
+#include <eikstart.h>
+
+//             The entry point for the application code. It creates
+//             an instance of the CApaApplication derived
+//             class, CResourceApplication.
+//
+
+
+LOCAL_C CApaApplication* NewApplication()
+	{
+	return new CResourceApplication;
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+	TInt result = EikStart::RunApplication(NewApplication);
+	__UHEAP_MARKEND;
+	return result;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuinotifier.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,75 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Core dump progress observer active object class implementation.
+//
+
+#include "coredumpuinotifier.h"
+
+CCrashNotifier* CCrashNotifier::NewL(CResourceView &aResourceView)
+    {
+    CCrashNotifier* self = new(ELeave) CCrashNotifier(aResourceView);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+/**
+ * Adds itself into the active scheduler.
+ */
+CCrashNotifier::CCrashNotifier(CResourceView &aResourceView)
+    :CActive(EPriorityStandard),
+    iResourceView(aResourceView)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+/**
+ * Attaches to the core dump server crash progress property. And starts observation right away.
+ */
+void CCrashNotifier::ConstructL()
+    {
+    LOG_MSG3("CCrashNotifier::ConstrucL() - attach %d.%d", KCoreDumpServUid, ECrashProgress);
+    User::LeaveIfError(iProperty.Attach(KCoreDumpServUid, ECrashProgress));
+    RunL(); //start watching
+    }
+
+/**
+ * Cancels the wait for outstanding request and closes handle to crash progress property. 
+ */
+CCrashNotifier::~CCrashNotifier()
+    {
+    Cancel();
+    iProperty.Close();
+    }
+
+/**
+ * Cancels subscription to the crash progress property.
+ */
+void CCrashNotifier::DoCancel()
+    {
+    iProperty.Cancel();
+    }
+
+/**
+ * Handles completion of observation request, notifies the UI and reissues another observation request.
+ */
+void CCrashNotifier::RunL()
+    {
+    LOG_MSG( "CCrashNotifier::RunL()" );
+    User::LeaveIfError(iProperty.Get(iResourceView.CrashProgress()));
+    iResourceView.UpdateCrashProgressL(); 
+    iProperty.Subscribe(iStatus); 
+    SetActive();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuiresourcelist.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1404 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#include <eiktxlbm.h> //CTextListBoxModel
+
+#include <eiklbv.h> // CListBoxView
+#include <e32std.h>
+
+#include "coredumpui.h"
+//#include <tefexportconst.h>
+//#include <e32def.h>
+
+#ifndef HW
+#include <formatterapi.h>
+#include <crashdatasave.h>
+#include <optionconfig.h>
+
+#endif
+
+const TInt TObservationRequest::iOffset=  _FOFF(TObservationRequest, iLink);
+
+void CResourceList::ConstructL(TInt aTablePosition)
+	{
+	// Create the basic list box
+	iListBox = new(ELeave) CEikColumnListBox;
+	//This view is parent. Also constructs the associated list box model and item drawer for the list box.
+	iListBox->ConstructL( this, CEikListBox::EMultipleSelection);
+
+	iListBox->SetContainerWindowL( *this);
+	iListBox->CreateScrollBarFrameL();
+	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto,
+			CEikScrollBarFrame::EAuto);
+
+	iListBox->SetPosition(TPoint(iBorder, aTablePosition + iBorder));
+
+	iListBox->SetSize(Rect().Size()-TSize(0, aTablePosition)-TSize(iBorder*2, iBorder*2));
+
+	iListBox->ActivateL();
+
+	iModel = iListBox->Model();
+
+	iTextArray = iModel->ItemTextArray();
+	iListBoxItems = static_cast<CDesCArray*>(iTextArray);
+	iListBoxData = static_cast<CColumnListBoxItemDrawer*>(iListBox->View()->ItemDrawer())->ColumnData();
+	
+	iRowItem.CreateL(500);
+
+#ifdef HW
+	LOG_MSG("CResourceList::ConstructL: iCoreDumpSession->Connect() \n");
+    TInt err = iCoreDumpSession.Connect();
+	if (err != KErrNone)
+		{
+		LOG_MSG2("CResourceList::ConstructL: iCoreDumpSession->Connect() failed!, err:%d\n", err);
+        User::Leave(err);
+		}
+#endif
+	}
+
+CResourceList::~CResourceList()
+	{
+	delete iListBox;
+	iModel = NULL;
+	iTextArray = NULL;
+	iListBoxItems = NULL;
+	iListBoxData = NULL;
+	iCoreDumpSession.Disconnect();
+	iRowItem.Close();
+	
+	iCrashList.ResetAndDestroy();
+	iCrashList.Close();
+	
+	}
+
+CCoeControl* CResourceList::GetListBox() const
+	{
+	return iListBox;
+	}
+
+void CResourceList::EmptyList()
+	{
+	iListBoxItems->Reset();
+	iListBox->Reset();
+	}
+
+void CResourceList::ConfigurePluginL()
+	{
+	LOG_MSG( "->[UI]CResourceList::ConfigurePlugin" );
+	const CListBoxView::CSelectionIndexArray * indexes = iListBox->SelectionIndexes();
+
+	if (indexes->Count()> 0)
+		{
+		TPtrC e = (*iListBoxItems)[indexes->At(0)];
+				
+		TLex input(e);	
+		
+		//Get the instance ID
+		input.Mark();
+		input.SkipCharacters();
+		TInt instanceId;
+		// extract ID
+		if (input.TokenLength()) // if valid potential token
+			{
+			TLex inst(input.MarkedToken());
+			inst.Val(instanceId);
+			}
+		LOG_MSG2("\tPlugin Instance ID = %d", instanceId);
+
+		do 
+			{
+			input.Get();
+			}
+		while (input.Peek()!= '\t');
+
+		
+		input.SkipSpace();
+		input.Mark();
+		input.SkipCharacters();
+		TUint u;
+		// extract UID
+		if (input.TokenLength()) // if valid potential token
+			{
+			TPtrC p = input.MarkedToken();
+			TLex value(p.Mid(2)); // leave out 0x
+	        value.Val(u, EHex);
+			}
+		TUid uid = TUid::Uid(u);
+		LOG_MSG2( "\tCResourceList::ConfigurePlugin, UID in hex: %x" , u);
+
+		RPluginList data;
+		CleanupClosePushL(data);
+		LOG_MSG( "\tCResourceList::GetPluginList iCoreDumpSession->GetPluginsL(data)" );
+		TRAPD(err, iCoreDumpSession.GetPluginListL(data));
+		if (err != KErrNone)
+			{
+			TBuf<23> buf;
+			buf.Format(_L("Error: %d"), err);
+			CEikonEnv::InfoWinL(_L("Could not get plugin list from CDS!"), buf);
+            User::Leave(err);
+			}
+
+		CleanupStack::PopAndDestroy(&data);
+		CConfigurePluginDialog* dialog = new(ELeave) CConfigurePluginDialog(uid, iCoreDumpSession, instanceId);
+		
+		dialog->ExecuteLD(R_CONFIGURE_PLUGIN_DIALOG);
+		}
+
+	}
+
+void CResourceList::BindPluginsL()
+	{
+	//Get selected items
+	LOG_MSG("->[UI]CResourceList::BindPluginsL()");
+	const CListBoxView::CSelectionIndexArray* indexes = iListBox->SelectionIndexes();
+	TInt numSelected = indexes->Count();
+	
+	TBuf<50> errBuf;
+	errBuf.Format(_L("Must Select one formatter and one writer to bind"));
+	
+	TInt writerInstance = -1;
+	TInt formatterInstance = -1;
+
+	for(TInt cnt =0; cnt < numSelected; cnt++)
+		{
+		TPtrC e = (*iListBoxItems)[indexes->At(cnt)];
+		
+		TLex input(e);	
+		
+		//Get the instance ID
+		input.Mark();
+		input.SkipCharacters();
+		TInt instanceId;
+		// extract ID
+		if (input.TokenLength()) // if valid potential token
+			{
+			TLex inst(input.MarkedToken());
+			inst.Val(instanceId);
+			}
+		LOG_MSG2("\tPlugin Instance ID = %d", instanceId);
+
+		do 
+			{
+			input.Get();
+			}
+		while (input.Peek()!= '\t');
+
+		//head on to the last tab
+		input.SkipSpace();
+		input.Mark();
+		input.SkipCharacters();			
+		
+		input.SkipSpace();
+		input.Mark();
+		input.SkipCharacters();
+		// Extract plugin type
+		if (input.TokenLength()) // if valid potential token
+			{
+			TPtrC p = input.MarkedToken();
+			if (p.Compare(_L("Formatter"))== 0)
+				{
+				formatterInstance = instanceId;
+				}
+			else if (p.Compare(_L("Writer"))== 0)
+				{
+				writerInstance = instanceId;
+				}
+			}
+		
+		}
+	
+	LOG_MSG3("\tFormatter Instance ID = %d will be bound to Writer Instance ID = %d", formatterInstance, writerInstance);
+	
+	if(formatterInstance < 0 || writerInstance < 0)
+		{
+		CEikonEnv::InfoWinL(_L("Cannot bind"), errBuf);
+		return;
+		}
+
+	//Now we have a fomatter and writer and so can bind
+	TPluginRequest bindReq;
+	bindReq.iIndex = formatterInstance;
+	bindReq.iPair = writerInstance;
+	bindReq.iUid = TUid::Uid(0);
+	
+#ifdef HW	
+	TRAPD(ret, iCoreDumpSession.PluginRequestL(bindReq));
+	if(ret != KErrNone)
+		{
+		errBuf.Format(_L("Error: %d"), ret);
+		CEikonEnv::InfoWinL(_L("Cannot bind"), errBuf);
+		return;
+		}	
+#endif
+	}
+
+void CResourceList::DeleteEntireCrashPartitionL()
+	{
+	LOG_MSG("->[UI]CResourceList::DeleteCrashPartitionL()");
+	
+	iCoreDumpSession.DeleteCrashPartitionL();
+	}
+
+/**
+ * Deletes the crash via the core dump server interface, using the UI's currently selected crash(es)
+ * @return void
+ */
+void CResourceList::DeleteCrashLogL()
+	{
+	LOG_MSG("->[UI]CResourceList::DeleteCrashLogL()");	
+	
+	RArray<TInt>* crashIds = GetMarkedCrashIDsFromUIL();
+	
+	for(TInt cnt = crashIds->Count() - 1; cnt >= 0; cnt--)
+		{	
+		iCoreDumpSession.DeleteCrashLogL((*crashIds)[cnt]);
+		}
+	
+	crashIds->Close();
+	delete crashIds;
+	}
+
+/**
+ * Processes the crash via the core dump server interface, using the UI's currently selected crash(es)
+ * @return void
+ */
+void CResourceList::ProcessCrashL()
+	{
+	LOG_MSG("->[UI]CResourceList::ProcessCrashL()");
+	
+	RArray<TInt>* crashIds = GetMarkedCrashIDsFromUIL();
+	
+	if(!crashIds)
+		{
+		CEikonEnv::Static()->InfoMsg(_L("No crashes Selected (null crashIds"));		
+		}
+	else if (crashIds->Count() ==  0)
+		{
+		CEikonEnv::Static()->InfoMsg(_L("No crashes Selected"));
+		}
+	else
+		{		
+		for(TInt cnt = crashIds->Count() -1; cnt >= 0; cnt--)
+			{
+	/*		TCrashInfo* inf = GetCrashInfoL((*crashIds)[cnt]);		
+			iCoreDumpSession.ProcessCrashLogL(*inf);*/
+			iCoreDumpSession.ProcessCrashLogL((*crashIds)[cnt]);
+			}	
+		}
+	crashIds->Close();
+	delete crashIds;
+	}
+
+/**
+ * This helper method looks at the UI Panel and returns an RArray of crashID's for those marked .
+ * Note: Ownership of this array is passed on to the caller
+ * @return RArray of the crashID's marked
+ */
+RArray<TInt>* CResourceList::GetMarkedCrashIDsFromUIL()
+	{
+	LOG_MSG("->[UI]CResourceList::GetMarkedCrashIDsFromUIL()");
+	
+	RArray<TInt>* crashIds = new RArray<TInt>();
+	
+	const CListBoxView::CSelectionIndexArray* indexes = iListBox->SelectionIndexes();
+	
+	for(TInt cnt = 0; cnt < indexes->Count(); cnt++)
+		{
+		TPtrC item = (*iListBoxItems)[indexes->At(cnt)];
+		TLex input(item);
+		
+		//we want to get the crash ID from the UI display - its the first character
+		input.SkipSpace();
+		input.Mark();
+		input.SkipCharacters();
+		
+		TUint crashId;
+		if (input.TokenLength()) // if valid potential token
+			{
+			TLex value(input.MarkedToken());
+			value.Val(crashId, EDecimal);
+			
+			crashIds->AppendL(crashId);
+			}		
+		}
+	
+	return crashIds;
+	}
+
+/**
+ * This returns a pointer to the TCrashInfo object in our cached array. Leaves if not found.
+ * @param aCrashId
+ * @return Pointer to crash info object
+ * @leave one of the OS wide Codes
+ */
+TCrashInfo* CResourceList::GetCrashInfoL(const TInt aCrashId)
+	{	
+	LOG_MSG2("->[UI]CResourceList::GetCrashInfoL(crashID = [%d])", aCrashId);
+	
+	for(TInt cnt = iCrashList.Count() -1; cnt >= 0; cnt--)
+		{
+		if(iCrashList[cnt]->iCrashId == aCrashId)
+			{
+			return iCrashList[cnt];
+			}
+		}
+	
+	//if we get here, we havent found it
+	User::Leave(KErrNotFound);
+	
+	return NULL; //unreachable, but avoid compiler warnings
+	}
+
+void CResourceList::UnloadPluginL()
+	{
+	LOG_MSG("->[UI]CResourceList::UnloadPlugin()");
+	TPluginRequest unloadReq;
+	
+	const CListBoxView::CSelectionIndexArray* indexes = iListBox->SelectionIndexes();
+	
+	for(TInt cnt = 0; cnt < indexes->Count(); cnt++)
+		{
+		TPtrC item = (*iListBoxItems)[indexes->At(cnt)];
+		TLex input(item);
+		
+		TInt tabCnt =0;
+		while(tabCnt < 2)
+			{
+			do 
+				{
+				input.Get();
+				}
+			while (input.Peek()!= '\t');
+			tabCnt++;
+			}
+		input.SkipSpace();
+		input.Mark();
+		input.SkipCharacters();
+		TUint u;
+		// extract UID
+		if (input.TokenLength()) // if valid potential token
+			{
+			TPtrC p = input.MarkedToken();
+			TLex value(p.Mid(2)); // skip 0x
+			value.Val(u, EHex);
+			}
+		TUid uid = TUid::Uid(u);
+		unloadReq.iUid = uid;
+		LOG_MSG2("\tUID to unload = %x", uid);
+		
+		//Now get the type...
+		input.SkipSpace();
+		input.Mark();
+		input.SkipCharacters();
+		// Extract plugin type
+		if (input.TokenLength()) // if valid potential token
+			{
+			TPtrC p = input.MarkedToken();
+			if (p.Compare(_L("Formatter"))== 0)
+				{
+				unloadReq.iPluginType = TPluginRequest::EFormatter;
+				}
+			else if (p.Compare(_L("Writer"))== 0)
+				{
+				unloadReq.iPluginType = TPluginRequest::EWriter;
+				}
+			}				
+		}
+	
+	unloadReq.iLoad = EFalse;
+	
+#ifdef HW
+	TRAPD(err, iCoreDumpSession.PluginRequestL(unloadReq));
+	if (err != KErrNone)
+		{
+		TBuf<23> buf;
+		buf.Format(_L("Error: %d"), err);
+		CEikonEnv::InfoWinL(_L("Could not load plugin"), buf);
+		LOG_MSG2("\tCResourceList::LoadPlugin could not load plugin: %d", err);
+		}
+#endif	
+	}
+
+void CResourceList::LoadPluginL()
+	{
+	LOG_MSG("->[UI]CResourceList::LoadPluginL()");
+	const CListBoxView::CSelectionIndexArray* indexes = iListBox->SelectionIndexes();
+	TInt numSelected = indexes->Count();
+	
+	for(TInt cnt =0; cnt < numSelected; cnt++)
+		{
+		TPtrC e = (*iListBoxItems)[indexes->At(cnt)];	
+		TPluginRequest loadReq;
+
+		TLex input(e);
+		do // skip all text until first \t
+			{
+			input.Get();
+			}
+		while (input.Peek()!= '\t');
+		input.SkipSpace();
+		input.Mark();
+		input.SkipCharacters();
+		TUint u;
+		// extract UID
+		if (input.TokenLength()) // if valid potential token
+			{
+			TPtrC p = input.MarkedToken();
+			TLex value(p.Mid(2)); // skip 0x
+			value.Val(u, EHex);
+			}
+		TUid uid = TUid::Uid(u);
+		loadReq.iUid = uid;
+		input.SkipSpace();
+		input.Mark();
+		input.SkipCharacters();
+		
+		
+		// Extract plugin type
+		if (input.TokenLength()) // if valid potential token
+			{
+			TPtrC p = input.MarkedToken();
+			if (p.Compare(_L("Formatter"))== 0)
+				{
+				loadReq.iPluginType = TPluginRequest::EFormatter;
+				}
+			else if (p.Compare(_L("Writer"))== 0)
+				{
+				loadReq.iPluginType = TPluginRequest::EWriter;
+				}
+			}
+
+		loadReq.iLoad = ETrue;					
+
+#ifdef HW
+		TRAPD(err, iCoreDumpSession.PluginRequestL(loadReq));
+		if (err != KErrNone)
+			{
+			TBuf<23> buf;
+			buf.Format(_L("Error: %d"), err);
+			CEikonEnv::InfoWinL(_L("Could not load plugin"), buf);
+			LOG_MSG2("\tCResourceList::LoadPlugin could not load plugin: %d", err);
+			}
+#endif
+		}
+	}
+
+void CResourceList::BuildSelectedListL(TSglQue<TObservationRequest> &aSelectedList)
+	{
+	const CListBoxView::CSelectionIndexArray
+			* indexes = iListBox->SelectionIndexes();
+
+    LOG_MSG2("CResoutceList::BuildSelectedListL - no of indexes:%d\n", indexes->Count());
+
+	for (TInt i = 0; i < indexes->Count(); i++)
+		{
+		// extract the data
+		TObservationRequest* cdsData = new (ELeave)TObservationRequest;
+		TPtrC line = (*iListBoxItems)[indexes->At(i)];
+		switch (iObjectsViewed)
+			{
+			case EObjectProcess:
+				{
+				TPtrC namePlus = line.Mid(1+line.Locate('\t')); //skip index
+                TPtrC onlyName = namePlus.Mid(0, namePlus.Locate('\t')); //cut off the rest
+
+                //LOG_DES(onlyName);
+				cdsData->iTargetName = onlyName;
+				cdsData->iTargetOwnerName = onlyName;
+				}
+				break;
+
+			case EObjectThread:
+				{
+                TPtrC namePlus = line.Mid(1+line.Locate('\t')); //skip index
+                TPtrC onlyName = namePlus.Mid(0, namePlus.Locate('\t')); //cut off the rest
+                cdsData->iTargetName = onlyName;
+
+                TPtrC priorityPlus = namePlus.Mid(1+namePlus.Locate('\t')); //skip name
+                TPtrC ownerPlus = priorityPlus.Mid(1+priorityPlus.Locate('\t')); //skip priority
+
+                //LOG_DES(ownerPlus);
+                TLex value(ownerPlus);
+				TInt ownerId;
+                value.Val(ownerId);
+
+                LOG_MSG2("owner id:%d\n", ownerId);
+				RProcess rp;
+				TInt err = rp.Open(ownerId);
+                if(err != KErrNone)
+                    {
+                    LOG_MSG2("unable to open proces handle! err:%d", err);
+                    delete cdsData;
+                    User::Leave(err);
+                    }
+                cdsData->iTargetOwnerName.Copy(rp.FileName());
+                rp.Close();
+				}
+				break;
+
+			case EObjectExecutable:
+				{
+				TPtrC name = line.Mid(0, line.Locate('\t'));
+
+				cdsData->iTargetName = name;
+				cdsData->iTargetOwnerName = name;
+				}
+
+			default:
+				break;
+			}
+		aSelectedList.AddLast(*cdsData);
+		}
+	}
+
+void CResourceList::SetObservedL()
+	{
+
+	switch (iObjectsViewed)
+		{
+		case EObjectProcess:
+			{
+			SetObservedProcessesL();
+		    break;
+			}
+
+		case EObjectThread:
+			{
+			SetObservedThreadsL();
+		    break;
+			}
+		case EObjectExecutable:
+			{
+			SetObservedExecutablesL();
+			break;
+			}
+
+		default:
+		break;
+		}
+	}
+
+/**
+    Cleanup item implementation for selection list in SetObserved() methods.
+ */
+void CResourceList::CleanupSelection(TAny *aList)
+{
+	TSglQue<TObservationRequest> *selectedList = static_cast<TSglQue<TObservationRequest>*>(aList);
+	TSglQueIter<TObservationRequest> selIter(*selectedList);
+    selIter.SetToFirst();
+    TObservationRequest *selItem;
+    while( (selItem = selIter++) != NULL)
+        {
+        selectedList->Remove(*selItem);
+        delete selItem;
+        }
+}
+
+/**
+    Cleanup item implementation for process list in SetObservedProcesses() method.
+ */
+void CResourceList::CleanupProcessList(TAny *aArray)
+{
+	RProcessPointerList *processList = static_cast<RProcessPointerList*> (aArray);
+    processList->ResetAndDestroy();
+    processList->Close();
+}
+
+void CResourceList::SetObservedProcessesL()
+{
+    LOG_MSG("->CResourceList::SetObservedProcesses()\n");
+
+	RProcessPointerList processList;
+    TCleanupItem cleanupProcesses(CResourceList::CleanupProcessList, (TAny*)&processList);
+    CleanupStack::PushL(cleanupProcesses);
+
+   	TRAPD(err, iCoreDumpSession.GetProcessesL(processList));
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CResourceList::SetObservedProcesses - unable get process list! err:%d\n", err);
+        TBuf<23> error;
+        error.Format(_L("Error: %d"), err);
+        CEikonEnv::InfoWinL(_L("Unable to get process list!"), error);
+        User::Leave(err);
+        }
+
+	TSglQue<TObservationRequest> selectedList(TObservationRequest::iOffset);
+    TCleanupItem cleanupSelection(CResourceList::CleanupSelection, (TAny*)&selectedList);
+    CleanupStack::PushL(cleanupSelection);
+	BuildSelectedListL(selectedList);
+
+	TSglQueIter<TObservationRequest> selIter(selectedList);
+    TObservationRequest *selItem;
+    selIter.SetToFirst();
+    while((selItem = selIter++) != NULL)
+        {
+        //locate and inspect the target
+        TBool observe = ETrue;
+        for(TInt i = 0; i < processList.Count(); i++)
+            {
+            if(processList[i]->Name() == selItem->iTargetName)
+                {
+                //choose the right action - toggle states
+                observe = !processList[i]->Observed();
+                break;
+                }
+            }
+
+	    LOG_MSG("CResourceList::SetObservedProcesses -> iCoreDumpSession->ObservationRequestL()\n");
+        TRAP(err, iCoreDumpSession.ObservationRequestL(selItem->iTargetName, selItem->iTargetOwnerName, observe));
+        if (err != KErrNone)
+            {
+	        LOG_MSG3("CResourceList::SetObservedProcesses - unable to perform action:%d! err:%d\n", observe, err);
+            TBuf<23> error;
+            RBuf buf;
+            buf.CreateL(KMaxFullName);
+            error.Format(_L("Error: %d"), err);
+            if(observe)
+                buf.Append(_L("Unable to attach to "));
+            else
+                buf.Append(_L("Unable to detach from "));
+
+            buf.AppendFormat(_L("process:%S"), &selItem->iTargetName);
+            CEikonEnv::InfoWinL(buf, error);
+            buf.Close();
+            }
+        }
+        CleanupStack::PopAndDestroy(2); //results in calling CleanupProcessList and CleanupSelection
+}
+
+void CResourceList::SetObservedExecutablesL()
+	{
+	LOG_MSG("->CResourceList::SetObservedExecutablesL()\n");
+
+	RExecutablePointerList exeList;
+	TCleanupItem cleanupExes(CResourceList::CleanupExecutableList, (TAny*)&exeList);
+	CleanupStack::PushL(cleanupExes);
+
+	TRAPD(err, iCoreDumpSession.GetExecutablesL(exeList));
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CResourceList::SetObservedExecutablesL - unable get exe list! err:%d\n", err);
+        TBuf<23> error;
+        error.Format(_L("Error: %d"), err);
+        CEikonEnv::InfoWinL(_L("Unable to get executable list"), error);
+        User::Leave(err);
+        }
+
+	TSglQue<TObservationRequest> selectedList(TObservationRequest::iOffset);
+    TCleanupItem cleanupSelection(CResourceList::CleanupSelection, (TAny*)&selectedList);
+    CleanupStack::PushL(cleanupSelection);
+	BuildSelectedListL(selectedList);
+    LOG_MSG("selected list built");
+
+    TSglQueIter<TObservationRequest> selIter(selectedList);
+    TObservationRequest *selItem;
+    selIter.SetToFirst();
+    while((selItem = selIter++) != NULL)
+        {
+        //locate and inspect the target
+        TBool observe = ETrue;
+        LOG_MSG("Looking through the exe list to mark as observed");
+        for(TInt i = 0; i < exeList.Count(); i++)
+            {
+            if(exeList[i]->Name() == selItem->iTargetName)
+                {
+                //choose the right action - toggle states
+                observe = !exeList[i]->Observed();
+                break;
+                }
+            }
+
+	    LOG_MSG("CResourceList::SetObservedExecutables -> iCoreDumpSession->ObservationRequestL()  Observing:");
+        TRAP(err, iCoreDumpSession.ObservationRequestL(selItem->iTargetName, selItem->iTargetOwnerName, observe));
+        if (err != KErrNone)
+            {
+	        LOG_MSG3("CResourceList::SetObservedExecutables - unable to perform action:%d! err:%d\n", observe, err);
+            TBuf<23> error;
+            RBuf buf;
+            buf.CreateL(KMaxFullName);
+            error.Format(_L("Error: %d"), err);
+            if(observe)
+                buf.Append(_L("Unable to attach to "));
+            else
+                buf.Append(_L("Unable to detach from "));
+
+            buf.AppendFormat(_L("executable:%S"), &selItem->iTargetName);
+            CEikonEnv::InfoWinL(buf, error);
+            buf.Close();
+            }
+        }
+        CleanupStack::PopAndDestroy(2); //results in calling CleanupProcessList and CleanupSelection
+
+	}
+
+/**
+    Cleanup item implementation for thread list in SetObservedThreads() method.
+ */
+void CResourceList::CleanupThreadList(TAny *aArray)
+{
+	RThreadPointerList *threadList = static_cast<RThreadPointerList*> (aArray);
+    threadList->ResetAndDestroy();
+    threadList->Close();
+}
+
+void CResourceList::CleanupExecutableList(TAny *aArray)
+	{
+	RExecutablePointerList *exeList = static_cast<RExecutablePointerList*> (aArray);
+	exeList->ResetAndDestroy();
+	exeList->Close();
+	}
+
+void CResourceList::CleanupPluginList(TAny* aArray)
+	{
+	RPluginPointerList* list = static_cast<RPluginPointerList*> (aArray);
+	list->ResetAndDestroy();
+	list->Close();
+	}
+
+void CResourceList::CleanupCrashList(TAny* aArray)
+	{
+	RCrashInfoPointerList* list = static_cast<RCrashInfoPointerList*> (aArray);
+	list->ResetAndDestroy();
+	list->Close();
+	}
+
+void CResourceList::SetObservedThreadsL()
+    {
+    LOG_MSG("->CResourceList::SetObservedThreads()\n");
+
+	RThreadPointerList threadList;
+    TCleanupItem cleanup(CResourceList::CleanupThreadList, (TAny*)&threadList);
+    CleanupStack::PushL(cleanup);
+
+
+   	TRAPD(err, iCoreDumpSession.GetThreadsL(threadList));
+    if(err != KErrNone)
+        {
+        LOG_MSG2("CResourceList::SetObservedProcesses - unable get thread list! err:%d\n", err);
+        TBuf<23> error;
+        error.Format(_L("Error: %d"), err);
+        CEikonEnv::InfoWinL(_L("Unable to get thread list!"), error);
+        User::Leave(err);
+        }
+
+	TSglQue<TObservationRequest> selectedList(TObservationRequest::iOffset);
+    TCleanupItem cleanupSelection(CResourceList::CleanupSelection, (TAny*)&selectedList);
+    CleanupStack::PushL(cleanupSelection);
+	BuildSelectedListL(selectedList);
+
+	TSglQueIter<TObservationRequest> selIter(selectedList);
+    TObservationRequest *selItem;
+    selIter.SetToFirst();
+    while((selItem = selIter++) != NULL)
+        {
+        //locate and inspect the target
+        TBool observe = ETrue;
+        for(TInt i = 0; i < threadList.Count(); i++)
+            {
+            if(threadList[i]->Name() == selItem->iTargetName)
+                {
+                //choose the right action - toggle states
+                observe = !threadList[i]->Observed();
+                break;
+                }
+            }
+
+	    LOG_MSG("CResourceList::SetObservedThreads -> iCoreDumpSession->ObservationRequestL()\n");
+        TRAP(err, iCoreDumpSession.ObservationRequestL(selItem->iTargetName, selItem->iTargetOwnerName, observe));
+        if (err != KErrNone)
+            {
+	        LOG_MSG3("CResourceList::SetObservedThreads - unable to perform action:%d! err:%d\n", observe, err);
+            TBuf<23> error;
+            RBuf buf;
+            buf.CreateL(KMaxFullName);
+            error.Format(_L("Error: %d"), err);
+            if(observe)
+                buf.Append(_L("Unable to attach to "));
+            else
+                buf.Append(_L("Unable to detach from "));
+
+            buf.AppendFormat(_L("thread:%S"), &selItem->iTargetName);
+            CEikonEnv::InfoWinL(buf, error);
+            buf.Close();
+            }
+        }
+        CleanupStack::PopAndDestroy(2); //results in calling CleanupThreadList and CleanupSelection
+    }
+
+#define CW_Id 25
+#define CW_ProcessName 195
+#define CW_Medium 90
+#define CW_UID 100
+#define CW_Bound 100
+#define CW_PluginName 350
+#define GapWidth 25
+#define CW_Short 60
+#define CW_ThreadName 380
+#define CW_Priority 85
+#define CW_ProcessId 95
+#define CW_Writeable 90
+#define CW_Read 70
+#define CW_FileName 500
+#define CW_ExeName 195
+#define CW_PluginId 25
+#define CW_CRASHID	75
+#define CW_CRASHTIME 120
+#define CW_CRASHPROCESSED 100
+
+void CResourceList::SetUpProcessTableL()
+	{
+	// deal with the columns
+	iListBoxData->SetColumnWidthPixelL( 0, CW_Id); // Id
+	iListBoxData->SetColumnWidthPixelL( 1, CW_ProcessName); // Name
+	iListBoxData->SetColumnAlignmentL( 1, CGraphicsContext::ELeft);
+	iListBoxData->SetColumnWidthPixelL( 2, CW_FileName); //Observed?
+	iListBoxData->SetColumnHorizontalGapL( 2, GapWidth);
+	iListBoxData->SetColumnAlignmentL( 2, CGraphicsContext::ELeft);
+
+	_LIT(KTitles, "Id\tName\tObserved");
+	iListBoxItems->AppendL(KTitles);
+	}
+
+void CResourceList::SetUpThreadTableL()
+	{
+	iListBoxData->SetColumnWidthPixelL( 0, CW_Id);
+	iListBoxData->SetColumnWidthPixelL( 1, CW_ThreadName);
+	iListBoxData->SetColumnAlignmentL( 1, CGraphicsContext::ELeft);
+	iListBoxData->SetColumnWidthPixelL( 2, CW_Priority); //Priority
+	iListBoxData->SetColumnAlignmentL( 2, CGraphicsContext::ERight);
+	iListBoxData->SetColumnWidthPixelL( 3, CW_ProcessId); //ProcessId
+	iListBoxData->SetColumnAlignmentL( 3, CGraphicsContext::ERight);
+	iListBoxData->SetColumnWidthPixelL( 4, CW_FileName); //Observed?
+	iListBoxData->SetColumnHorizontalGapL( 4, GapWidth);
+	iListBoxData->SetColumnAlignmentL( 4, CGraphicsContext::ECenter);
+
+	_LIT(KTitles, "Id\tName\tPriority\tProcess\tObserved");
+	iListBoxItems->AppendL(KTitles);
+	}
+
+void CResourceList::SetUpPluginTableL()
+	{	
+	iListBoxData->SetColumnWidthPixelL( 0, CW_PluginName);
+	iListBoxData->SetColumnWidthPixelL( 1, CW_Medium); // Uid
+	iListBoxData->SetColumnAlignmentL(1, CGraphicsContext::ERight);
+	iListBoxData->SetColumnWidthPixelL( 2, CW_Medium + GapWidth); // Type
+	iListBoxData->SetColumnAlignmentL(2, CGraphicsContext::ERight);
+	iListBoxData->SetColumnHorizontalGapL( 2, GapWidth);
+	iListBoxData->SetColumnWidthPixelL( 3, CW_Medium); // Loaded?
+	iListBoxData->SetColumnAlignmentL(3, CGraphicsContext::ERight);
+
+	_LIT(KTitles, "Name\tUid\tType\tInstances");
+	iListBoxItems->AppendL(KTitles);
+	}
+
+void CResourceList::SetUpExecutableTableL()
+	{
+	iListBoxData->SetColumnWidthPixelL(0, CW_ExeName); //Name of exe
+	iListBoxData->SetColumnAlignmentL(0, CGraphicsContext::ELeft);
+	iListBoxData->SetColumnWidthPixelL(1, CW_FileName); //Observed?
+	iListBoxData->SetColumnHorizontalGapL( 1, GapWidth);
+	iListBoxData->SetColumnAlignmentL( 1, CGraphicsContext::ELeft);
+
+	_LIT(KTitles, "Name\tObserved");
+	iListBoxItems->AppendL(KTitles);
+	}
+
+void CResourceList::SetUpPluginInstanceTableL()
+	{
+	iListBoxData->SetColumnWidthPixelL( 0, CW_PluginId);
+	iListBoxData->SetColumnWidthPixelL( 1, CW_PluginName);
+	iListBoxData->SetColumnAlignmentL( 1, CGraphicsContext::ELeft);
+	iListBoxData->SetColumnWidthPixelL( 2, CW_UID); // Uid
+	iListBoxData->SetColumnAlignmentL(2, CGraphicsContext::ERight);
+	iListBoxData->SetColumnWidthPixelL( 3, CW_Medium + GapWidth); // Type
+	iListBoxData->SetColumnAlignmentL(3, CGraphicsContext::ERight);
+	iListBoxData->SetColumnHorizontalGapL( 3, GapWidth);
+	iListBoxData->SetColumnWidthPixelL(4, CW_Bound);
+	iListBoxData->SetColumnAlignmentL(4, CGraphicsContext::ERight);
+
+	_LIT(KTitles, "ID\tName\tUid\tType\tBound To");
+	iListBoxItems->AppendL(KTitles);
+	}
+
+void CResourceList::SetUpCrashListTableL()
+	{
+	iListBoxData->SetColumnWidthPixelL( 0, CW_CRASHID);
+	iListBoxData->SetColumnAlignmentL(0, CGraphicsContext::ELeft);
+	
+	iListBoxData->SetColumnWidthPixelL(1, CW_CRASHTIME);
+	iListBoxData->SetColumnAlignmentL(1, CGraphicsContext::ELeft);
+	
+	iListBoxData->SetColumnWidthPixelL(2, CW_CRASHPROCESSED); 
+	iListBoxData->SetColumnAlignmentL(2, CGraphicsContext::ERight);
+	
+	_LIT(KTitles, "Crash ID\tTime Of Crash\tProcessed");
+	iListBoxItems->AppendL(KTitles);
+	}
+
+void CResourceList::SetUpListL()
+	{
+	iListBoxData->SetColumnWidthPixelL( 0, 300);
+	}
+
+void CResourceList::UpdateListDataL()
+	{
+	LOG_MSG("->[UI]CResourceList::UpdateListDataL()");
+	switch (iObjectsViewed)
+		{
+		case EObjectProcess:
+			{
+			EmptyList();
+			SetUpProcessTableL();
+			break;
+			}
+		case EObjectThread:
+			{
+			EmptyList();
+			SetUpThreadTableL();
+			break;
+			}
+		case EObjectPlugin:
+			{
+			EmptyList();
+			SetUpPluginTableL();
+			break;
+			}
+		case EObjectPluginInstance:
+			{
+			EmptyList();
+			SetUpPluginInstanceTableL();
+			break;
+			}
+		case EObjectExecutable:
+			{
+			EmptyList();
+			SetUpExecutableTableL();
+			break;
+			}
+		case EObjectCrashList:
+			{
+			EmptyList();
+			SetUpCrashListTableL();
+			break;
+			}
+		default:
+			{
+			break;
+			}
+		}
+	GetResourceListL();
+	}
+
+void CResourceList::GetResourceListL()
+	{	
+	switch (iObjectsViewed)
+		{
+		case EObjectProcess:
+			{
+			GetProcessListL();
+			break;
+			}
+		case EObjectThread:
+			{
+			GetThreadListL();
+			break;
+			}
+		case EObjectPlugin:
+			{
+			GetPluginListL();
+			break;
+			}
+		case EObjectPluginInstance:
+			{
+			GetPluginInstancesListL();
+			break;
+			}
+		case EObjectExecutable:
+			{
+			GetExecutableListL();
+			break;
+			}
+		case EObjectCrashList:
+			{
+			GetCrashListL();
+			break;
+			}
+		default:
+			{
+			break;
+			}
+		}
+	
+	iListBox->HandleItemAdditionL();
+	iListBox->DrawDeferred();	
+	
+	}
+
+/**
+ * Gets the crash list from the CDS server
+ * @leave one of the OS wide error codes
+ */
+void CResourceList::GetCrashListL()
+	{
+	LOG_MSG("->[UI]CResourceList::GetCrashListL()");
+	
+	//Get the list and for each crash, add it to the UI
+	iCoreDumpSession.ListCrashesInFlashL(iCrashList);	
+	TInt crashCnt = iCrashList.Count() -1;
+	
+	for(; crashCnt >=0; crashCnt--)
+		{
+		AddRowL(*(iCrashList[crashCnt]));		
+		}
+	
+	UpdateResourceCount(iCrashList.Count());
+	}
+
+void CResourceList::GetPluginInstancesListL()
+	{
+	//Get loaded plugin instances
+	LOG_MSG("->[UI]CResourceList::GetPluginInstancesListL()");
+    RPluginPointerList pluginPtrList;
+	TCleanupItem cleanup(CResourceList::CleanupPluginList, (TAny*)&pluginPtrList);
+    CleanupStack::PushL(cleanup);
+    TInt totalPluginCount = 0;
+    
+    LOG_MSG("\tCResourceList::GetPluginInstancesListL()  iCoreDumpSession.GetFormattersL(pluginPtrList);");
+    iCoreDumpSession.GetFormattersL(pluginPtrList);
+    LOG_MSG2("\tCResourceList::GetPluginInstancesListL()  Found %d formatters", pluginPtrList.Count());
+    
+    for(TInt cnt = 0; cnt < pluginPtrList.Count(); cnt ++)
+    	{    	
+    	iPluginInstanceData.iIdString.Format(_L("%d"), cnt);
+    	iPluginInstanceData.iName = pluginPtrList[cnt]->Name();    	
+    	iPluginInstanceData.iUid.Format(_L("0x%X"), pluginPtrList[cnt]->Uid());
+    	iPluginInstanceData.iType = _L("Formatter");
+    	if(pluginPtrList[cnt]->Pair() == KMaxTUint32)
+    		{
+    		iPluginInstanceData.iBoundTo.Format(_L("-"));
+    		}
+    	else
+    		{
+    		iPluginInstanceData.iBoundTo.Format(_L("%u"), pluginPtrList[cnt]->Pair());
+    		}
+    	
+    	AddRowL(iPluginInstanceData);
+    	
+    	totalPluginCount++;
+    	}
+
+    CleanupStack::PopAndDestroy(&pluginPtrList);     
+    
+    //Now we get the writer list                
+    LOG_MSG("\tCResourceList::GetPluginInstancesListL()  iCoreDumpSession.GetWritersL(pluginPtrList);");
+    iCoreDumpSession.GetWritersL(pluginPtrList);
+    LOG_MSG2("\tCResourceList::GetPluginInstancesListL()  Found %d writers", pluginPtrList.Count());
+    CleanupStack::PushL(cleanup);
+    
+    for(TInt cnt = 0; cnt < pluginPtrList.Count(); cnt++)
+    	{
+    	iPluginInstanceData.iIdString.Format(_L("%d"), cnt);
+    	iPluginInstanceData.iName = pluginPtrList[cnt]->Name();    	
+    	iPluginInstanceData.iUid.Format(_L("0x%X"), pluginPtrList[cnt]->Uid());
+    	iPluginInstanceData.iType = _L("Writer");
+    	iPluginInstanceData.iBoundTo.Format(_L(""));
+    	AddRowL(iPluginInstanceData);
+    	
+    	totalPluginCount++;
+    	}
+    
+
+    UpdateResourceCount(totalPluginCount);
+    CleanupStack::PopAndDestroy(&pluginPtrList);
+	}
+
+void CResourceList::GetExecutableListL()
+	{
+	//Get executables
+	RExecutablePointerList exes;
+	LOG_MSG("CResourceList::GetExecutableListL()  iCoreDumpSession.GetExecutablesL(exes)");
+	TRAPD(err, iCoreDumpSession.GetExecutablesL(exes));
+	if( err != KErrNone )
+		{
+		LOG_MSG2("CResourceList::GetExecutableListL() - unable to get exe list! err:%d", err);
+        TBuf<23> error;
+		error.Format(_L("Error: %d"), err);
+		CEikonEnv::InfoWinL(_L("Unable to get executable list!"), error);
+        User::Leave(err);
+		}
+
+	for( TInt i = 0; i < exes.Count(); i++)
+		{
+		iExeData.iExeName.Copy(exes[i]->Name());
+		iExeData.iObserved.Copy(KSpaces);
+
+		if(exes[i]->Observed())
+            {
+            iExeData.iObserved.Copy(KYes);
+            }
+
+		AddRowL(iExeData);
+		}
+	UpdateResourceCount(exes.Count());
+	exes.ResetAndDestroy();
+	}
+
+void CResourceList::GetProcessListL()
+	{
+	// get data from CDS
+	RProcessPointerList processes;
+	LOG_MSG(" CResourceList::GetProcessList iCoreDumpSession->GetProcessesL(processes)" );
+	TRAPD(err, iCoreDumpSession.GetProcessesL(processes));
+	if (err != KErrNone)
+		{
+        LOG_MSG2("CResourceList::GetProcessListL() - unable to get process list! err:%d", err);
+        TBuf<23> error;
+		error.Format(_L("Error: %d"), err);
+		CEikonEnv::InfoWinL(_L("Unable to get process list!"), error);
+        User::Leave(err);
+		}
+
+	for (TInt i = 0; i < processes.Count(); i++)
+		{
+		iProcessData.iIdString.Format(KFormatDec, processes[i]->Id());
+		iProcessData.iProcessName.Copy(processes[i]->Name());
+
+		iProcessData.iObserved.Copy(KSpaces);
+        if(processes[i]->Observed())
+            {
+            iProcessData.iObserved.Copy(KYes);
+            }
+
+		AddRowL(iProcessData);
+		}
+	UpdateResourceCount(processes.Count());
+	processes.ResetAndDestroy();
+	}
+
+void CResourceList::GetThreadListL(void)
+	{
+	// get data from CDS
+	RThreadPointerList threads;
+	LOG_MSG( "CResourceList::GetThreadList iCoreDumpSession->GetThreadsL(&threads);" );
+	TRAPD(err, iCoreDumpSession.GetThreadsL(threads));
+	if (err != KErrNone)
+		{
+        LOG_MSG2("CResourceList::GetThreadListL() - unable to get thread list! err:%d", err);
+        TBuf<23> error;
+		error.Format(_L("Error: %d"), err);
+		CEikonEnv::InfoWinL(_L("Unable to get thread list!"), error);
+        User::Leave(err);
+		}
+
+	LOG_MSG2( "CResourceList::GetThreadList threads->Count() = %d", threads.Count());
+	for (TInt i = 0; i<threads.Count(); i++)
+		{
+
+		iThreadData.iIdString.Format(KFormatDec, threads[i]->Id());
+
+		// Name
+		iThreadData.iThreadName.Copy(threads[i]->Name());
+
+		// Priority
+		iThreadData.iPriorityString.Format(KFormatDec, threads[i]->Priority());
+
+		// Owner Process
+		iThreadData.iOwnerIdString.Format(KFormatDec, threads[i]->ProcessId());
+
+        // Observed
+		iThreadData.iObserved.Copy(KSpaces);
+        if(threads[i]->Observed())
+            {
+            iThreadData.iObserved.Copy(KYes);
+            }        
+
+		AddRowL(iThreadData);
+		}
+	UpdateResourceCount(threads.Count());
+	threads.ResetAndDestroy();
+	}
+
+void CResourceList::CleanupEComArray(TAny* aArray)
+	{
+	(static_cast<RImplInfoPtrArray*> (aArray))->ResetAndDestroy();
+	(static_cast<RImplInfoPtrArray*> (aArray))->Close();
+	}
+
+void CResourceList::GetPluginListL()
+	{
+	// get data from CDS
+	RPluginList data;
+	CleanupClosePushL(data);
+	LOG_MSG( "CResourceList::GetPluginList iCoreDumpSession->GetFormatters(&data)" );
+	TRAPD(err, iCoreDumpSession.GetPluginListL(data));
+	if (err != KErrNone)
+		{
+		TBuf<23> error;
+		error.Format(_L("Error: %d"), err);
+		CEikonEnv::InfoWinL(_L("Could not get plugin list!"), error);
+        User::Leave(err);
+		}
+
+	LOG_MSG2( "CResourceList::GetPluginList No of plugins is/are: %d", data.Count() );
+
+	TUIPluginData uiData;
+
+	for (TInt i = 0; i < data.Count(); i++)
+		{
+		uiData.iName = data[i].iName;
+		TUid uid = data[i].iUid;
+		uiData.iUid.Format(_L("0x%x"), uid);
+		if (data[i].iType == TPluginRequest::EFormatter)
+			{
+			uiData.iType = _L("Formatter");
+			uiData.iInstances.Format(_L("%d"), GetNumberFormattersL(uid));
+			}
+		else if (data[i].iType == TPluginRequest::EWriter)
+			{
+			uiData.iType = _L("Writer");
+			uiData.iInstances.Format(_L("%d"), GetNumberWritersL(uid));
+			}
+		
+		AddRowL(uiData);
+		}
+	UpdateResourceCount(data.Count());
+	CleanupStack::PopAndDestroy(&data);
+	}
+
+void CResourceList::AddRowL(const TUIProcessData& aProcessData)
+	{
+	// The actual item text format depends on the listbox type, see tables with listbox types
+	iRowItem.Format(_L("%S\t%S\t%S"), &aProcessData.iIdString,
+	&aProcessData.iProcessName,
+	&aProcessData.iObserved);
+
+	iListBoxItems->AppendL(iRowItem);
+	}
+
+void CResourceList::AddRowL(const TUIPluginData& aPluginData)
+	{
+	// The actual item text format depends on the listbox type, see tables with listbox types
+	iRowItem.Format(_L("%S\t%S\t%S\t%S"), &aPluginData.iName,
+	&aPluginData.iUid,
+	&aPluginData.iType,
+	&aPluginData.iInstances);
+
+	iListBoxItems->AppendL(iRowItem);
+	}
+
+void CResourceList::AddRowL(const TUIPluginInstanceData& aPluginInstance)
+	{
+	iRowItem.Format(_L("%S\t%S\t%S\t%S\t%S"), 
+			&aPluginInstance.iIdString,
+			&aPluginInstance.iName,
+			&aPluginInstance.iUid,
+			&aPluginInstance.iType,
+			&aPluginInstance.iBoundTo);
+	
+	iListBoxItems->AppendL(iRowItem);
+	}
+
+void CResourceList::AddRowL(const TUIThreadData& aThreadData)
+	{
+	// The actual item text format depends on the listbox type, see tables with listbox types
+	iRowItem.Format(_L("%S\t%S\t%S\t%S\t%S"), &aThreadData.iIdString,
+	&aThreadData.iThreadName,
+	&aThreadData.iPriorityString,
+	&aThreadData.iOwnerIdString,
+	&aThreadData.iObserved);
+
+	iListBoxItems->AppendL(iRowItem);
+	}
+
+void CResourceList::AddRowL(const TListData& aListData)
+	{
+	// The actual item text format depends on the listbox type, see tables with listbox types
+	iRowItem.Format(_L("%S"), &aListData.iName);
+
+	iListBoxItems->AppendL(iRowItem);
+	}
+
+void CResourceList::AddRowL(const TUIExecutableData& aExeData)
+	{
+	// The actual item text format depends on the listbox type, see tables with listbox types
+	iRowItem.Format(_L("%S\t%S"), &aExeData.iExeName, &aExeData.iObserved);
+
+	iListBoxItems->AppendL(iRowItem);
+	}
+
+void CResourceList::AddRowL(const TCrashInfo& aCrashInfo)
+	{	
+	iRowItem.Format(_L("%d\t%lu"), aCrashInfo.iCrashId, aCrashInfo.iTime);
+	
+	iListBoxItems->AppendL(iRowItem);
+	}
+
+TInt CResourceList::GetNumberFormattersL(TUid& aUid)
+	{
+	TInt numFormatters = 0;
+	
+	//Get loaded plugin instances
+	LOG_MSG("->[UI]CResourceList::GetNumberFormatters(TUid& aUid)");
+    RPluginPointerList pluginPtrList;
+	TCleanupItem cleanup(CResourceList::CleanupPluginList, (TAny*)&pluginPtrList);
+    CleanupStack::PushL(cleanup);
+    
+    LOG_MSG("\tCResourceList::GetNumberFormatters(TUid& aUid)  iCoreDumpSession.GetFormattersL(pluginPtrList);");
+    LOG_MSG2("\tLooking for Formatters of UID of %x", aUid.iUid);
+    iCoreDumpSession.GetFormattersL(pluginPtrList);
+    
+    for(TInt cnt = 0; cnt < pluginPtrList.Count(); cnt ++)
+    	{ 
+    	TUid uid = TUid::Uid(pluginPtrList[cnt]->Uid());
+    	if(uid == aUid)
+    		{
+    		numFormatters++;
+    		}
+    	}
+
+    CleanupStack::PopAndDestroy(&pluginPtrList); 	
+	
+	return numFormatters;
+	}
+
+TInt CResourceList::GetNumberWritersL(TUid& aUid)
+	{
+	TInt numWriters = 0;
+	
+	//Get loaded plugin instances
+	LOG_MSG("->[UI]CResourceList::GetNumberWritersL(TUid& aUid)");
+    RPluginPointerList pluginPtrList;
+	TCleanupItem cleanup(CResourceList::CleanupPluginList, (TAny*)&pluginPtrList);
+    CleanupStack::PushL(cleanup);
+    
+    LOG_MSG("\tCResourceList::GetNumberWritersL(TUid& aUid)  iCoreDumpSession.GetFormattersL(pluginPtrList);");
+    LOG_MSG2("\tLooking for Writers of UID of %x", aUid.iUid);
+    iCoreDumpSession.GetWritersL(pluginPtrList);
+    
+    for(TInt cnt = 0; cnt < pluginPtrList.Count(); cnt ++)
+    	{ 
+    	TUid uid = TUid::Uid(pluginPtrList[cnt]->Uid());
+    	if(uid == aUid)
+    		{
+    		numWriters++;
+    		}
+    	}
+
+    CleanupStack::PopAndDestroy(&pluginPtrList); 
+	
+	return numWriters;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/src/coredumpuiresourceview.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,313 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Source file for the implementation of the 
+// application view class - CResourceView
+//
+
+#include "coredumpui.h"
+
+CResourceView::CResourceView()
+	{
+	}
+
+CResourceView* CResourceView::NewL(const TRect& aRect, CResourceAppUi *aAppUi)
+	{
+	CResourceView* self = new(ELeave) CResourceView();
+	CleanupStack::PushL(self);
+	self->ConstructL(aRect, aAppUi);
+	CleanupStack::Pop();
+	return self;
+	}
+
+CResourceView::~CResourceView()
+	{
+    delete iCommandButton;
+    delete iObserveButton;
+    delete iLoadButton;
+	}
+
+void CResourceView::ConstructL(const TRect& aRect, CResourceAppUi* aAppUi)
+    {
+	// Initialisation
+	iAppUi = aAppUi;
+	iObjectsViewed = EObjectProcess;
+
+	CreateWindowL();
+	           
+	// Whole extent of view
+	SetRect(aRect);
+
+	// Border around components in pixels
+	iBorder = 1;
+
+	// Place the refresh button	
+	iCommandButton = new(ELeave) CEikCommandButton;
+	iCommandButton->SetTextL(_L("Refresh"));
+	iCommandButton->SetSize(iCommandButton->MinimumSize());
+	iCommandButton->SetPosition(TPoint(Rect().Width() - iCommandButton->Size().iWidth - iBorder, iBorder));
+	iCommandButton->SetContainerWindowL(*this);
+	iCommandButton->SetObserver(this);
+
+	// Place the observe button	
+	iObserveButton = new(ELeave) CEikCommandButton;
+	iObserveButton->SetTextL(_L("Observe"));
+	iObserveButton->SetSize(iObserveButton->MinimumSize());
+	TInt x = Rect().Width() - iObserveButton->Size().iWidth - iCommandButton->Size().iWidth - iBorder;
+	iObserveButton->SetPosition(TPoint(x , iBorder));
+	iObserveButton->SetContainerWindowL(*this);
+	iObserveButton->SetObserver(this);
+
+	// Place the load button
+	iLoadButton = new(ELeave) CEikCommandButton;
+	iLoadButton->SetTextL(_L("Load"));
+	iLoadButton->SetSize(iLoadButton->MinimumSize());
+	x -= iLoadButton->Size().iWidth;
+	iLoadButton->SetPosition(TPoint(x , iBorder));
+	iLoadButton->SetContainerWindowL(*this);
+	iLoadButton->SetObserver(this);
+	iLoadButton->SetDimmed(ETrue);
+
+	TInt buttonHeight = iCommandButton->Size().iHeight;	
+
+	// Get the title font height
+	TInt titleHeight = iEikonEnv->TitleFont()->HeightInPixels();
+	TInt tablePosition = 0;
+	if (titleHeight>=buttonHeight) 
+		tablePosition=titleHeight;
+	else
+		tablePosition=buttonHeight;
+
+	CResourceList::ConstructL(tablePosition);// Activate the main window control - this will also activate the contained controls
+	
+	ActivateL();
+	DrawNow();
+	
+	}
+
+TDes& CResourceView::CrashProgress()
+	{
+    return iCrashProgress;
+	}
+
+void CResourceView::Draw(const TRect& /*aRect*/) const
+	{
+	CWindowGc& gc = SystemGc();                     
+
+	gc.Clear();
+		
+	// Put title on view
+	const CFont* fontUsed = iEikonEnv->TitleFont();
+	gc.UseFont(fontUsed);
+	gc.SetPenColor(KRgbBlack);
+	TPoint pos(iBorder,fontUsed->AscentInPixels()+iBorder);
+	gc.DrawText(iTitle, pos);
+
+	gc.DiscardFont();
+	}
+
+TInt CResourceView::CountComponentControls() const
+	{
+	return 4;
+	}
+
+CCoeControl* CResourceView::ComponentControl(TInt aIndex) const
+	{
+	CCoeControl* cmd = NULL;
+	switch (aIndex)
+		{
+		case 0:
+			{
+			cmd = iCommandButton;
+			break;
+			}		
+		case 1:
+			{
+			cmd = iObserveButton;
+			break;
+			}		
+		case 2:
+			{
+			cmd = iLoadButton;
+			break;
+			}		
+		default:
+			{
+			cmd = CResourceList::GetListBox();
+			}
+		}
+	return cmd;
+	}
+
+// for use by refresh button control
+void CResourceView::HandleControlEventL(CCoeControl* aControl,TCoeEvent /*aEventType*/)
+	{	
+	// This code is not nice. A better solution is to extend the CEikCommandButton class to have an enumerator 
+	// that distinguishes the buttons purpose in a given context. This avoids relying on the text of the label. I dont
+	// have the time to do it now. Also, the button names make no sense. They were named originally in the context of 
+	// 1 function, now they serve many
+	
+	LOG_MSG("->[UI]CResourceView::HandleControlEventL()");
+	if (aControl == iCommandButton)
+		{
+		if(iCommandButton->Label()->Text()->Compare(_L("Refresh")) == 0)
+			{
+			UpdateViewL();
+			}
+		else if(iCommandButton->Label()->Text()->Compare(_L("Bind")) == 0)
+			{
+			BindPluginsL();
+			}
+		UpdateViewL();
+		}
+	else if (aControl == iObserveButton)
+		{
+		if (iObserveButton->Label()->Text()->Compare(_L("Configure"))==0)
+			{
+			ConfigurePluginL();
+			}
+		else if(iObserveButton->Label()->Text()->Compare(_L("Observe"))==0)
+			{
+			SetObservedL();
+			}
+		else if(iObserveButton->Label()->Text()->Compare(_L("Process"))==0)
+			{
+			ProcessCrashL();
+			}
+		UpdateViewL();
+		}
+	else if (aControl == iLoadButton)
+		{
+		if(iLoadButton->Label()->Text()->Compare(_L("Load")) == 0)
+			{
+			LoadPluginL(); 
+			}
+		else if(iLoadButton->Label()->Text()->Compare(_L("Unload")) == 0)
+			{
+			UnloadPluginL(); 
+			}
+		else if(iLoadButton->Label()->Text()->Compare(_L("Delete")) == 0)
+			{
+			DeleteEntireCrashPartitionL();
+			}
+		UpdateViewL();
+		}
+	}
+
+void CResourceView::InvalidateView(void) const
+	{
+	Window().Invalidate(Rect()); //calls Draw()
+	}
+
+void CResourceView::UpdateViewL(void)
+	{
+	LOG_MSG("->[UI]CResourceView::UpdateView(void)");
+	UpdateListDataL();	
+	InvalidateView();
+	UpdateTitleL();
+	}
+
+void CResourceView::UpdateCrashProgressL()
+{    
+    InvalidateView();
+    UpdateTitleL();
+}
+
+void CResourceView::UpdateTitleL(void)
+	{
+	// assume the table data, iResourceCount and iObjectViewed data are up to date
+	TBufC<20> title;
+
+	// Set the title appropriately
+	switch (iObjectsViewed)
+		{
+		case EObjectProcess: 
+			{
+			iLoadButton->SetDimmed(ETrue);
+			iObserveButton->SetTextL(_L("Observe"));
+			title = _L("Processes");
+			iCommandButton->SetTextL(_L("Refresh"));
+			break;
+			}
+		case EObjectThread:
+			{
+			iLoadButton->SetDimmed(ETrue);
+			iObserveButton->SetTextL(_L("Observe"));
+			title = _L("Threads");
+			iCommandButton->SetTextL(_L("Refresh"));
+			break;
+			}
+		case EObjectPlugin:
+			{
+			iLoadButton->SetDimmed(EFalse);
+			title = _L("Plugins");
+			// for plugins, also change the label of the observe button to Configure
+			iObserveButton->SetDimmed(ETrue);
+			iLoadButton->SetTextL(_L("Load"));
+			iLoadButton->SetDimmed(EFalse);
+			iCommandButton->SetTextL(_L("Refresh"));
+			break;
+			}
+		case EObjectExecutable:
+			{
+			iLoadButton->SetDimmed(ETrue);
+			title = _L("Executables");
+			iObserveButton->SetTextL(_L("Observe"));
+			iObserveButton->SetDimmed(EFalse);
+			iCommandButton->SetTextL(_L("Refresh"));
+			break;
+			}
+		case EObjectPluginInstance:
+			{
+			title = _L("Plugin Instances");
+			iObserveButton->SetTextL(_L("Configure"));
+			iObserveButton->SetDimmed(EFalse);
+			iLoadButton->SetTextL(_L("Unload"));
+			iLoadButton->SetDimmed(EFalse);
+			iCommandButton->SetTextL(_L("Bind"));
+			break;
+			}
+		case EObjectCrashList:
+			{
+			title = _L("Crash List in Flash");
+			iObserveButton->SetTextL(_L("Process"));
+			iObserveButton->SetDimmed(EFalse);
+			iLoadButton->SetTextL(_L("Delete"));
+			iLoadButton->SetDimmed(EFalse);
+			iCommandButton->SetTextL(_L(""));
+			iCommandButton->SetDimmed(ETrue);
+			break;
+			}
+		default:
+			{
+			break;
+			}
+		}
+		
+	iObserveButton->SetSize(iObserveButton->MinimumSize());
+	TInt x = Rect().Width() - iObserveButton->Size().iWidth - iCommandButton->Size().iWidth - iBorder;
+	iObserveButton->SetPosition(TPoint(x, iBorder));
+	iObserveButton->SetContainerWindowL(*this);
+	iObserveButton->SetObserver(this);
+    
+	iLoadButton->SetSize(iLoadButton->MinimumSize());
+	x -= iLoadButton->Size().iWidth;
+	iLoadButton->SetPosition(TPoint(x, iBorder));
+	iLoadButton->SetContainerWindowL(*this);
+	iLoadButton->SetObserver(this);
+
+	//set title and resource count
+	TBuf<2> openingBracket(_L(" ("));
+	TBuf<1> closingBracket(_L(")"));
+	iTitle.Format(_L("%S%S%u%S %S"), &title, &openingBracket, iResourceCount, &closingBracket, &iCrashProgress);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/coredumpui/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/scriptconfig/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_PLATFORMS
+ARMV5
+PRJ_EXPORTS
+
+coredumpscriptconfig.iby	/epoc32/rom/include/coredumpscriptconfig.iby
+
+PRJ_MMPFILES
+
+coredumpscriptconfig.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/scriptconfig/coredumpscriptconfig.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,143 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+/**
+ @file
+ @internalTechnology
+ @released
+*/
+
+#include <e32cons.h>
+#include <e32debug.h>
+#include <bacline.h>
+#include <e32property.h>
+
+#include <coredumpinterface.h>
+#include <debuglogging.h>
+
+LOCAL_C void processConfigL()
+	{
+
+	// Create a CCrashConfig object, the configuration client-side 
+	// object of the CoreDump Server .
+    RCoreDumpSession coredumpinterface;
+
+	TInt ret = coredumpinterface.Connect();
+
+	if( KErrNone != ret )
+		{
+		LOG_MSG2( "requestConfigLoadL():: Could not create a Core Dump configuration object, error=%d", ret );
+		User::Leave( ret );
+		}
+
+	TUint crashes = 1;
+
+    TInt argc = User::CommandLineLength();
+    TPtrC configFile(KNullDesC);	
+	HBufC* args = NULL;
+    if(argc > 0)
+    {
+        args = HBufC::NewLC(User::CommandLineLength());
+        TPtr argv = args->Des();
+	    User::CommandLine(argv);
+
+	    TLex lex(*args);
+
+        while(!lex.Eos())
+        {
+            if(lex.Get() == '-')
+            {
+                TChar c = lex.Get();
+                if(c == '-')
+                {
+                    TPtrC16 token = lex.NextToken();
+                    c = token[0];
+                }
+
+                lex.SkipSpace();
+                switch(c)
+                {
+                case 'c':
+                    lex.Val(crashes);
+                    break;
+                case 'f':
+                    configFile.Set(lex.NextToken());
+                    break;
+                default:
+                    User::Leave(KErrArgument);
+                }
+            }
+            lex.SkipSpace();
+        }
+    }
+
+    TRAPD(err, coredumpinterface.LoadConfigL( configFile ));
+
+    if(err != KErrNone)
+    {
+	LOG_MSG2("unable to load config file! err:%d\n", err );
+    coredumpinterface.Disconnect();
+    User::Leave(err);
+    }
+
+	LOG_MSG2( "Will wait for %u crashes\n", crashes );
+
+	RProperty crashCountProperty;
+	User::LeaveIfError( crashCountProperty.Attach( KCoreDumpServUid, ECrashCount ) );
+
+	TInt crashCount = 0;
+	do
+		{
+		
+		User::After(5000000);
+		ret = crashCountProperty.Get( crashCount );
+		LOG_MSG2( "  crashCountProperty.Get( crashCount )=%d\n", crashCount );
+		if ( KErrNone != ret )
+			{
+			break;
+			}
+		}
+	while( crashes > crashCount );
+
+    crashCountProperty.Close();
+	if(args)
+        {
+        CleanupStack::PopAndDestroy(args);  
+        }
+    coredumpinterface.Disconnect();
+	LOG_MSG( "  returned from CleanupStack::PopAndDestroy( cmd );" );
+
+	}
+
+
+GLDEF_C TInt E32Main() // main function called by E32
+    {
+	__UHEAP_MARK;
+
+	CTrapCleanup* cleanup=CTrapCleanup::New();
+    if(!cleanup)
+        return KErrNoMemory;
+
+	TRAPD(err,processConfigL());
+   
+
+	delete cleanup;
+	__UHEAP_MARKEND; // Check memory leaks
+
+	return err;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/scriptconfig/coredumpscriptconfig.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef COREDUMPSCRIPTCONFIG_IBY
+#define COREDUMPSCRIPTCONFIG_IBY
+
+file=ABI_DIR\BUILD_DIR\coredumpscript.exe  sys\bin\coredumpscript.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/scriptconfig/coredumpscriptconfig.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,41 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Core Dump Script Executable MMP file
+// A simple client of the Core Dump Server. Does not require user interaction
+//
+
+
+
+TARGET        coredumpscript.exe
+TARGETTYPE    exe
+UID			  0x102831E6 0x102831E6
+VENDORID	  0x70000001
+
+ 
+SOURCEPATH    .
+SOURCE        coredumpscriptconfig.cpp
+
+
+SYSTEMINCLUDE \epoc32\include
+SYSTEMINCLUDE \epoc32\include\drivers 
+SYSTEMINCLUDE \epoc32\include\tools\coredump
+
+LIBRARY       euser.lib
+LIBRARY       coredumpinterface.lib
+LIBRARY       cdssupport.lib
+LIBRARY       estor.lib
+LIBRARY       bafl.lib
+
+MACRO CDSDEBUG
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/scriptconfig/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/text/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,26 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_PLATFORMS
+ARMV5
+PRJ_EXPORTS
+
+textcrashconfig.iby	/epoc32/rom/include/textcrashconfig.iby
+
+PRJ_MMPFILES
+
+textcrashconfig.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/text/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/text/textcrashconfig.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,655 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// $Change: $
+//
+
+#include <e32cons.h>
+#include <e32debug.h>
+#include <e32test.h>
+
+#include <plugindata.h>
+#include <threaddata.h>
+#include <processdata.h>
+#include <executabledata.h>
+
+#include <coredumpinterface.h>
+
+#include <optionconfig.h>
+#include <debuglogging.h>
+
+LOCAL_C void doTestL();   // the test code
+
+GLDEF_C TInt E32Main() // main function called by E32
+    {
+	__UHEAP_MARK;
+	// Because this is not an EIKON program we have to create our
+	// own clean-up stack.
+	CTrapCleanup* cleanup=CTrapCleanup::New();
+
+	__UHEAP_MARK;
+
+	// Trap any leaves that occur during test code
+	TRAPD(error,doTestL());
+	RDebug::Printf( "TRAPD(error,doTestL())=%d;\n", error);
+	// Handle any leaves that occured during the test code.
+	// Since this is a test program, we don't need any special error handling to
+	// handle leaves - just panic the test program.
+	
+	_LIT(KTxtTrainingTest,"Crash Configuration Tester");	
+
+	RDebug::Printf( "__ASSERT_ALWAYS(!error,User::Panic(KTxtTrainingTest,error));\n");
+	__ASSERT_ALWAYS(!error,User::Panic(KTxtTrainingTest,error));
+
+
+	RDebug::Printf( "__UHEAP_MARKEND; before deleting cleanup stack\n");
+	__UHEAP_MARKEND; // Check the test program doesn't leak memory.
+
+	RDebug::Printf( "delete cleanup;\n");
+	delete cleanup;
+
+	RDebug::Printf( "__UHEAP_MARKEND; before returning\n");
+	__UHEAP_MARKEND; // Check the test program doesn't leak memory.
+
+	RDebug::Printf( "__UHEAP_CHECK(0);\n");
+    __UHEAP_CHECK(0);
+
+	RDebug::Printf( "E32Main returning KErrNone; \n");
+	return KErrNone;
+	}
+
+
+
+_LIT(KCrashAppFileName,"z:\\Sys\\Bin\\crashapP.exe");
+
+#define KListGranularity (20)
+
+LOCAL_C void doTestL()
+	{
+
+	// Create an RTest object for performing the tests.
+	_LIT(KTestTitle, "Crash Config - Text UI");
+	RTest test(KTestTitle);
+	CleanupClosePushL(test);
+		
+	_LIT(KFormatString1,"Connecting to Server (correct result = KErrNone)");
+	test.Start( KFormatString1 );
+
+	RDebug::Printf( "__UHEAP_MARK; //before CCrashConfig::NewL( );\n");
+	__UHEAP_MARK; // crashConfig
+
+    RCoreDumpSession iSess;
+
+	RDebug::Printf( "__UHEAP_MARK; //after CCrashConfig::NewL( );\n");
+	__UHEAP_MARK; // crashConfig
+
+	// Now connect to the server.
+	test( iSess.Connect() == KErrNone );
+    RDebug::Printf("connected\n");
+
+
+	_LIT(KMainMenu, "\n Menu: \n  0: Save/Load Config\t 1:List Plugins\t2:Load Plugin\n a: List Plugin Infos\tb: Unload Plugin\tc:Bind Plugins\n 3:List Threads\t4:List Procs\t5:List Exes\n 6:Observe Proc by Name\t 7 : Leave Proc by Name\t 8 : Configure System\t 9 : Create Crashing Proc\n");
+	_LIT(KConfigMenu,     "\n            0: Save Config\t 1: Load Config\n");
+	_LIT(KProcObserveMenu, "\n            Type Process ID to observe:\n");
+	
+	TChar c;
+	TBool finish = EFalse;
+	TInt ret = KErrNone;
+
+	_LIT( KSaveConfigMsg,		"Save Current Configuration to File" );
+	_LIT( KLoadConfigMsg,		"Load Configuration From File" );
+
+
+	_LIT( KGetThreadMsg,		"Request Thread List" );
+	_LIT( KGetProcMsg,			"Request Proc List" );
+	_LIT( KGetExeMsg,			"Request Executable List" );
+	
+	_LIT( KObserveProcName,	    "Observe a Process by Name" );
+	_LIT( KLeaveProcName,	    "Leave a Process by Name" );
+
+
+	RPluginList pluginsList;
+	pluginsList.Reserve(KListGranularity);
+
+	RThreadPointerList threadPtrList;
+	threadPtrList.Reserve(KListGranularity);
+
+	RProcessPointerList procPtrList;
+	procPtrList.Reserve(KListGranularity);	
+
+	RExecutablePointerList executablePtrList;
+	executablePtrList.Reserve(KListGranularity);	
+
+    RPluginPointerList formatterPtrList;
+    formatterPtrList.Reserve(KListGranularity);
+
+    RPluginPointerList writerPtrList;
+    writerPtrList.Reserve(KListGranularity);
+
+	do
+		{
+		test.Printf(KMainMenu);
+		c=test.Getch();
+
+		switch(c)
+			{
+
+			case('0'):
+				{
+				test.Printf(KConfigMenu);
+				c=test.Getch();
+				if( c == '0' )
+					{
+					test.Next(KSaveConfigMsg);
+					RDebug::Printf( "doTestL() -> SaveConfig(KNullDesc==Default )\n");
+					TRAP(ret, iSess.SaveConfigL( KNullDesC ));
+					test( KErrNone == ret );
+					RDebug::Printf( "doTestL : <- SaveConfig() returned 0x%X\n", ret );
+					}
+				else
+					{
+					test.Next(KLoadConfigMsg);
+					RDebug::Printf( "doTestL() -> LoadConfig(KNullDesc==Dafault)\n");
+					TRAP(ret, iSess.LoadConfigL( KNullDesC ));
+					test( KErrNone == ret );
+					RDebug::Printf( "doTestL : <- LoadConfig() returned 0x%X\n", ret );
+					}
+				break;
+				}
+                
+			case('1'):
+				{
+	            _LIT( KGetPluginsMsg,		"Request Plugin List" );
+				test.Next(KGetPluginsMsg);
+				pluginsList.Reset();
+
+				RDebug::Printf( "doTestL() -> GetPlugins()\n");
+
+				TRAP(ret, iSess.GetPluginListL( pluginsList ));
+				test( KErrNone == ret );
+
+				RDebug::Printf( "doTestL : <- GetPlugins() returned 0x%X, pluginList.Count()=%d, with following names:\n", 
+					ret, pluginsList.Count() );
+				
+				for(TUint i = 0; i < pluginsList.Count(); i++ )
+					{
+
+					test.Printf(_L("   Plugin List[%d].iName=%S, UID=0x%X, type=%d, loaded=%d\n"), 
+						i, 
+						&(pluginsList[i].iName),
+						pluginsList[i].iUid,
+						pluginsList[i].iType, 
+						pluginsList[i].iLoaded );
+					}
+
+				break;
+
+				}
+
+			case('a'):
+				{
+	            _LIT( KGetPluginInfosMsg,		"Request Plugin Info List" );
+				test.Next(KGetPluginInfosMsg);
+
+				formatterPtrList.ResetAndDestroy();
+				RDebug::Print( _L("doTestL() -> GetFormattersL()\n"));
+				TRAP( ret, iSess.GetFormattersL( formatterPtrList ));
+				test( KErrNone == ret );
+				RDebug::Print( _L(" doTestL() : <- GetFormatters() returned 0x%X, formatterPtrList.Count()=%d, with following names:\n"), 
+					ret, formatterPtrList.Count() );
+
+				writerPtrList.ResetAndDestroy();
+				RDebug::Print( _L("doTestL() -> GetWritersL()\n"));
+				TRAP( ret, iSess.GetWritersL( writerPtrList ));
+				test( KErrNone == ret );
+				RDebug::Print( _L(" doTestL() : <- GetWriters() returned 0x%X, writerPtrList.Count()=%d, with following names:\n"), 
+					ret, writerPtrList.Count() );
+
+				for(TUint i = 0; i < formatterPtrList.Count(); i++ )
+					{
+
+					test.Printf(_L("   Formatter List[%d].iName=%S, UID=0x%X, version=%d, type=%d\n"), 
+						i, 
+						&(formatterPtrList[i]->Name()),
+						formatterPtrList[i]->Uid(),
+						formatterPtrList[i]->Version(), 
+						formatterPtrList[i]->Type() );
+					}
+
+				for(TUint i = 0; i < writerPtrList.Count(); i++ )
+					{
+
+					test.Printf(_L("   Writter List[%d].iName=%S, UID=0x%X, version=%d, type=%d\n"), 
+						i, 
+						&(writerPtrList[i]->Name()),
+						writerPtrList[i]->Uid(),
+						writerPtrList[i]->Version(), 
+						writerPtrList[i]->Type() );
+					}
+
+				break;
+
+				}
+
+			case('2'):
+				{
+	            _LIT( KLoadPluginMsg, "Load Plugin" );
+				test.Next(KLoadPluginMsg);
+
+	            _LIT(KPluginLoadMenu, "\n\t\t\tType Index of the plugin to load:\n");
+				test.Printf(KPluginLoadMenu);
+				c=test.Getch();
+				TInt pluginIndex = c.GetNumericValue();
+
+				RDebug::Print(_L("doTestL() ->  LoadPlugin[%d].iName=%S, UID=0x%X\n"),
+							  pluginIndex, &(pluginsList[pluginIndex].iName), pluginsList[pluginIndex].iUid ) ;
+
+                TPluginRequest req;
+                req.iUid = pluginsList[pluginIndex].iUid;
+                req.iPluginType = pluginsList[pluginIndex].iType;
+                req.iLoad = ETrue;
+
+                TRAP(ret, iSess.PluginRequestL( req ));
+                test(ret == KErrNone);
+                RDebug::Printf( " Plugin with UID = 0x%X has been loaded\n", req.iUid );
+                test.Printf( _L("   Plugin with UID = 0x%X has been loaded\n"), req.iUid ); 
+
+				break;
+
+				}
+            case('b'):
+                {
+	            _LIT( KLoadPluginMsg, "Unload Plugin" );
+				test.Next(KLoadPluginMsg);
+
+                TPluginRequest req;
+                req.iLoad = EFalse;
+
+	            _LIT(KPluginUnloadoadMenu, "\n\t\t\tType Index of the plugin to unload:\n");
+				test.Printf(KPluginUnloadoadMenu);
+				c=test.Getch();
+				TInt pluginIndex = c.GetNumericValue();
+
+	            _LIT(KPluginTypeUnloadMenu, "\n\t\t\tType type of the plugin to unload:[f/w]\n");
+				test.Printf(KPluginTypeUnloadMenu);
+				c=test.Getch();
+
+                if(c == 'f')
+                {
+				    RDebug::Print(_L("doTestL() ->  UnloadPlugin[%d].iName=%S, UID=0x%X\n"),
+							      pluginIndex, &(formatterPtrList[pluginIndex]->Name()), formatterPtrList[pluginIndex]->Uid() ) ;
+
+                    req.iPluginType = TPluginRequest::EFormatter;
+                    req.iUid = TUid::Uid(formatterPtrList[pluginIndex]->Uid());
+                }
+                else if(c == 'w')
+                {
+				    RDebug::Print(_L("doTestL() ->  UnloadPlugin[%d].iName=%S, UID=0x%X\n"),
+							      pluginIndex, &(writerPtrList[pluginIndex]->Name()), writerPtrList[pluginIndex]->Uid() ) ;
+                    req.iPluginType = TPluginRequest::EWriter;
+                    req.iUid = TUid::Uid(writerPtrList[pluginIndex]->Uid());
+                }
+                else
+                {
+                    test.Printf(_L("Unknown plugin type!\n"));
+                    break;
+                }
+
+                TRAP(ret, iSess.PluginRequestL( req ));
+                test(ret == KErrNone);
+                RDebug::Printf( " Plugin with UID = 0x%X has been unloaded\n", req.iUid );
+                test.Printf( _L("   Plugin with UID = 0x%X has been unloaded\n"), req.iUid ); 
+                break;
+                }
+
+            case('c'):
+                {
+	            _LIT( KBindPluginMsg, "Bind Plugins" );
+				test.Next(KBindPluginMsg);
+
+	            _LIT(KFormatterBindMenu, "\n\t\t\tType Index of the formatter plugin to bind:\n");
+				test.Printf(KFormatterBindMenu);
+				c=test.Getch();
+				TInt formatterIndex = c.GetNumericValue();
+
+	            _LIT(KWriterBindMenu, "\n\t\t\tType Index of the writer plugin to bind:\n");
+				test.Printf(KWriterBindMenu);
+				c=test.Getch();
+				TInt writerIndex = c.GetNumericValue();
+
+                TPluginRequest req;
+                req.iIndex = formatterIndex;
+                req.iPair = writerIndex;
+                req.iUid = TUid::Uid(0); 
+
+                TRAP(ret, iSess.PluginRequestL( req ));
+                test(ret == KErrNone);
+                RDebug::Printf( " Plugin %d and %d have been bound\n", req.iIndex, req.iPair );
+                test.Printf( _L(" Plugin %d and %d have been bound\n"), req.iIndex, req.iPair );
+                break;
+                }
+
+			case('3'):
+				{
+
+				test.Next(KGetThreadMsg);
+				threadPtrList.ResetAndDestroy();
+
+				RDebug::Print( _L("doTestL() -> GetThreads()\n"));
+
+				TRAP( ret, iSess.GetThreadsL( threadPtrList ));
+				test( KErrNone == ret );
+
+				RDebug::Print( _L(" doTestL() : <- GetThreads() returned 0x%X, threadPtrList.Count()=%d, with following names:\n"), 
+					ret, threadPtrList.Count() );
+
+				RBuf rPrintBuf;
+
+				TUint64 pId;
+				TUint32 pIdLow;
+				TUint32 pIdHigh;
+
+				for(TUint i = 0; i < threadPtrList.Count(); i++ )
+					{
+					pId = threadPtrList[i]->ProcessId();
+					pIdLow = I64LOW( pId );
+					pIdHigh = I64HIGH( pId );
+
+					test.Printf(_L("   threadList[%d].iName=%S, id=0x%X"), 
+						i, &(threadPtrList[i]->Name()), threadPtrList[i]->Id() );
+					test.Printf(_L("  owner=0x%X%X\n"), pIdHigh, pIdLow );
+                    }
+				}
+
+				break;
+
+			case('4'):
+				{
+
+				test.Next( KGetProcMsg );
+				procPtrList.ResetAndDestroy();
+
+				RDebug::Print( _L("doTestL() -> GetProcess()\n"));
+
+                TRAP( ret, iSess.GetProcessesL( procPtrList ));
+				test( KErrNone == ret );
+
+				RDebug::Printf( "doTestL() <- GetProcesses() returned 0x%X, procPtrList.Count()=%d, with following names:\n", 
+					ret, procPtrList.Count() );
+				
+				for(TUint i = 0; i < procPtrList.Count(); i++ )
+					{
+					test.Printf(_L("   procPtrList[%d].iName=%S, id=%d \n"), 
+						i, 
+						&(procPtrList[i]->Name()),
+						procPtrList[i]->Id() );
+					}
+
+				}
+
+				break;
+
+			case('5'):
+				{
+
+				test.Next( KGetExeMsg );
+
+				executablePtrList.ResetAndDestroy();
+
+				RDebug::Print( _L("doTestL() -> GetExecutable()\n"));
+
+                TRAP( ret, iSess.GetExecutablesL( executablePtrList ));
+				test( KErrNone == ret );
+
+				RDebug::Printf( "doTestL() <- GetExecutable() returned 0x%X, executablePtrList.Count()=%d, with following names:\n", 
+					ret, executablePtrList.Count() );
+				
+				for(TUint i = 0; i < executablePtrList.Count(); i++ )
+					{
+					test.Printf(_L("   executablePtrList[%d].iName=%S, active=%d, passive=%d, observed=%d\n"), 
+						i, 
+						&(executablePtrList[i]->Name()),
+						executablePtrList[i]->ActivelyDebugged(),
+						executablePtrList[i]->PassivelyDebugged(),
+						executablePtrList[i]->Observed() );
+					}		
+				}
+
+				break;
+
+
+			case('6'):
+				{
+
+				test.Next( KObserveProcName );
+				c=test.Getch();
+				TInt procId1 = c.GetNumericValue();
+				c=test.Getch();
+				TInt procId2 = c.GetNumericValue();
+				c=test.Getch();
+				TInt procId3 = c.GetNumericValue();
+
+				TInt procId = procId1 * 100 + 10 * procId2 + procId3;
+
+				TBool found = EFalse;
+				TUint i;
+				for( i = 0; i < procPtrList.Count(); i++ )
+					{
+
+					if( procId == procPtrList[i]->Id() )
+						{
+							found = ETrue;
+							break;
+						}
+					}
+
+				if( found )
+					{
+					RDebug::Print( _L("doTestL() : -> Observe( proc name: %S )\n"), &procPtrList[i]->Name() );
+
+                    TRAP(ret, iSess.ObservationRequestL( procPtrList[i]->Name(), procPtrList[i]->Name(), ETrue) );
+
+					RDebug::Printf( "doTestL() <- Observe() returned %d\n", ret );
+
+					test( KErrNone == ret );
+
+					}
+			
+				}
+
+				break;
+
+			case('7'):
+				{
+
+				test.Next( KLeaveProcName );
+
+				test.Printf( KProcObserveMenu );
+				c=test.Getch();
+				TInt procId1 = c.GetNumericValue();
+				c=test.Getch();
+				TInt procId2 = c.GetNumericValue();
+				c=test.Getch();
+				TInt procId3 = c.GetNumericValue();
+
+				TInt procId = procId1 * 100 + 10 * procId2 + procId3;
+
+				TBool found = EFalse;
+				TUint i;
+				for( i = 0; i < procPtrList.Count(); i++ )
+					{
+
+					if( procId == procPtrList[i]->Id() )
+						{
+							found = ETrue;
+							break;
+						}
+					}
+
+				if( found )
+					{
+					RDebug::Print( _L("doTestL() : -> Leave( proc name: %S )\n"), &procPtrList[i]->Name() );
+
+                    TRAP(ret, iSess.ObservationRequestL( procPtrList[i]->Name(), procPtrList[i]->Name(), EFalse) );
+
+					RDebug::Printf( "doTestL() <- Leave() returned %d\n", ret );
+
+					test( KErrNone == ret );
+
+					}
+			
+				}
+
+				break;
+                
+
+			case('8'):
+				{
+	            _LIT( KConfigureSystem,     "Configure the System Parameters" );
+				test.Next( KConfigureSystem );
+
+				TInt numConfigParams = -1;
+			
+				RPointerArray<COptionConfig> configParams;
+				COptionConfig * config = NULL;
+
+				numConfigParams = iSess.GetNumberConfigParametersL();
+				RDebug::Printf( "There are %d system params\n", numConfigParams );
+
+                for(TInt i = 0 ; i < numConfigParams; i++)
+                {
+				    config = iSess.GetConfigParameterL(i);
+                    configParams.AppendL(config);
+                }
+
+                for(TInt i = 0 ; i < numConfigParams; i++)
+                {
+                    config = configParams[i];
+                    RDebug::Printf("param[%d] index=%d, instance=%d, source=%d, type=%d, value=%d values=%S",
+                                   i, config->Index(), config->Instance(), config->Source(), config->Type(),
+                                   config->Value(), &config->ValueAsDesc() );
+                }
+
+                configParams.ResetAndDestroy();
+
+	            _LIT(KFormatterConfigMenu, "\n\t\t\tType Index of the parameter to change:\n");
+				test.Printf(KFormatterConfigMenu);
+				c=test.Getch();
+				TInt paramIndex = c.GetNumericValue();
+
+				config = iSess.GetConfigParameterL( paramIndex );
+				if(config)
+                {
+                    const TDesC & lastPrompt = config->Prompt();
+                    const TDesC & lastOpts = config->Options();
+
+                    RBuf printPromptBuf;
+                    printPromptBuf.Create( lastPrompt , lastPrompt.Length()+1 );
+                    //printPromptBuf.SetMax();
+                    char* clPrompt = (char*) printPromptBuf.Collapse().PtrZ();
+                    RDebug::Printf("  lastPrompt=%s, length=%d\n", clPrompt, printPromptBuf.Length() );
+                    printPromptBuf.Close();
+
+                    RBuf printOptsBuf;
+                    printOptsBuf.Create( lastOpts , lastOpts.Length()+1 );
+                    //printPromptBuf.SetMax();
+                    char* clOpts = (char*) printOptsBuf.Collapse().PtrZ();
+                    RDebug::Printf("  lastOpts=%s, length=%d\n", clOpts , printOptsBuf.Length() );
+                    printOptsBuf.Close();
+
+                    RDebug::Printf("  Enter param value:\n" );
+                    c=test.Getch();
+                    TInt paramValue = c.GetNumericValue();
+                    LOG_MSG3( "  ->SetConfigParameterL( paramIndex=%d, value=%d )\n", paramIndex, paramValue );
+                    config->ValueL( KNullDesC );//To let us change the value as an int
+                    config->Value( paramValue );
+                    TRAP(ret, iSess.SetConfigParameterL(*config) );
+                    delete config;
+				    config = iSess.GetConfigParameterL( paramIndex );
+                    if(config)
+                    {
+                        RDebug::Printf( "param[%d] index=%d, instance=%d, type=%d, source=%d, value=%d values=%S",
+                                config->Index(), config->Instance(), config->Type(), config->Source(),
+                                config->Value(), &config->ValueAsDesc() );
+                    }
+                    test(KErrNone == ret);
+                }
+				break;
+				}
+
+
+			case('9'):
+				{
+
+				// Create crashing app
+				RProcess iCrashProcess;
+				RDebug::Printf( "Creating crashing application\n" );
+				TInt err = iCrashProcess.Create( KCrashAppFileName, KNullDesC );
+				test( err == KErrNone );
+
+				User::After( 1000000 );
+				iCrashProcess.Resume();
+				//
+				
+				break;
+				}
+
+			case('q'):
+				{
+				iSess.Disconnect();
+				finish = ETrue;
+				break;
+				}
+
+			default:
+				{
+				break;
+				}
+
+			}// switch
+
+		}
+	while( finish == EFalse );
+
+	RDebug::Printf( "pluginsList.Close();\n");
+	pluginsList.Close();
+
+	RDebug::Printf( "threadPtrList.ResetAndDestroy();\n");
+	threadPtrList.ResetAndDestroy();
+
+	RDebug::Printf( "procPtrList.ResetAndDestroy();\n");
+	procPtrList.ResetAndDestroy();
+
+	RDebug::Printf( "executablePtrList.ResetAndDestroy();\n");
+	executablePtrList.ResetAndDestroy();
+
+
+	RDebug::Printf( "formatterPtrList.ResetAndDestroy();\n");
+	formatterPtrList.ResetAndDestroy();
+
+	RDebug::Printf( "writerPtrList.ResetAndDestroy();\n");
+	writerPtrList.ResetAndDestroy();
+
+	__UHEAP_MARKEND; 
+	__UHEAP_MARKEND; 
+
+	RDebug::Printf( "CleanupStack::Pop(); // test\n");
+	CleanupStack::Pop(); // test
+	RDebug::Printf( "test.End();\n");
+	test.End();
+	_LIT(KPressAnyKey, "\nPress any key\n");
+	test.Printf(KPressAnyKey);
+	RDebug::Printf( "test.Getch();\n");
+	test.Getch();
+	test.Close();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/text/textcrashconfig.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#ifndef TEXTCRASHCONFIG_IBY
+#define TEXTCRASHCONFIG_IBY
+
+//file=ABI_DIR\BUILD_DIR\textcrashconfig.exe  sys\bin\textcrashconfig.exe
+file=ABI_DIR\BUILD_DIR\textcrashconfig.exe  sys\bin\textui.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbgsrv/coredumpserver/ui/text/textcrashconfig.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,36 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+TARGET        textcrashconfig.exe
+TARGETTYPE    exe
+UID			  0x1000008D 0x1112FFFF
+VENDORID	  0x70000001
+
+ 
+SOURCEPATH    .
+SOURCE        textcrashconfig.cpp
+
+SYSTEMINCLUDE \epoc32\include 
+SYSTEMINCLUDE \epoc32\include\drivers
+SYSTEMINCLUDE \epoc32\include\tools\coredump
+
+LIBRARY       euser.lib
+LIBRARY       coredumpinterface.lib
+LIBRARY       estor.lib
+LIBRARY       cdssupport.lib
+
+//MACRO CDSDEBUG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,25 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+PRJ_EXPORTS
+./ftpd.iby  /epoc32/rom/include/test_ftpd.iby
+
+PRJ_TESTEXPORTS
+
+PRJ_TESTMMPFILES
+
+PRJ_MMPFILES
+ftpd.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/group/ftpd.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,27 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __FTPD_IBY__
+#define __FTPD_IBY__
+
+REM FTP Server
+
+#include <openenv.iby> 
+#include <stdlib.iby>
+
+file=ABI_DIR/DEBUG_DIR/test_ftpd.exe        Sys/bin/test_ftpd.exe
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/group/ftpd.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,42 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET test_ftpd.exe
+TARGETTYPE EXE
+
+UID 0 0x10210D4B
+VENDORID 0x70000001
+
+
+CAPABILITY NetworkServices ReadDeviceData ReadUserData
+
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN  /EPOC32/INCLUDE
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN  /EPOC32/INCLUDE/STDAPIS
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN  /EPOC32/INCLUDE/LIBC
+
+LIBRARY		euser.lib
+LIBRARY	 	libc.lib
+LIBRARY		efsrv.lib
+LIBRARY		esock.lib
+LIBRARY		insock.lib
+STATICLIBRARY	libcrt0.lib
+
+SOURCEPATH ../src
+SOURCE ftpd.cpp logutmp.cpp popen.cpp ftpcmd.cpp
+
+USERINCLUDE ../inc
+
+EPOCSTACKSIZE 51200
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/group/ftpd.tdf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tool name="FTP Daemon" 
+	description="A file transfer protocol server (FTP) to manage files on devices, reference hardware or emulators."  
+	version="1.0.1000" 
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
+ 
+  <files>
+    <file source="/epoc32/release/winscw/udeb/test_ftpd.exe" target="$EPOCROOT/epoc32/release/winscw/udeb"/>
+    <file source="/epoc32/release/winscw/urel/test_ftpd.exe" target="$EPOCROOT/epoc32/release/winscw/urel"/>
+    <file source="/epoc32/release/armv5/udeb/test_ftpd.exe" target="$EPOCROOT/epoc32/release/armv5/udeb"/>
+    <file source="/epoc32/release/armv5/urel/test_ftpd.exe" target="$EPOCROOT/epoc32/release/armv5/urel"/>
+     <file source="/epoc32/rom/include/test_ftpd.iby" target="$EPOCROOT/epoc32/rom/include"/>
+  </files>
+	
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/group/ftpsrv.mrp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,9 @@
+component	dev_devicedbgsrvs_genericunixprotocols_ftpsrv
+
+source	/src/tools/dev/devicedbgsrvs/genericunixprotocols/ftpsrv/group
+binary	/src/tools/dev/devicedbgsrvs/genericunixprotocols/ftpsrv/group all
+exports	/src/tools/dev/devicedbgsrvs/genericunixprotocols/ftpsrv/group
+
+ipr T
+
+notes_source /component_defs/release.src
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/inc/extern.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,94 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)extern.h	8.2 (Berkeley) 4/4/94
+ *	NetBSD: extern.h,v 1.2 1995/04/11 02:44:49 cgd Exp
+ *      $Id: extern.h,v 1.5 1999/07/16 01:12:54 dholland Exp $
+ */
+
+void	blkfree __P((char **));
+char  **copyblk __P((char **));
+void	cwd __P((const char *));
+void	dele __P((char *));
+void	dologout __P((int));
+void	fatal __P((const char *));
+int	ftpd_pclose __P((FILE *));
+FILE   *ftpd_popen __P((char *, const char *));
+char   *ftpd_getline __P((char *, int, FILE *));
+void	ftpdlogwtmp __P((const char *, const char *, const char *));
+void	lreply __P((int, const char *, ...));
+void	makedir __P((char *));
+void	nack __P((const char *));
+void	pass __P((char *));
+void	passive __P((void));
+void	perror_reply __P((int, const char *));
+void	pwd __P((void));
+void	removedir __P((char *));
+void	renamecmd __P((char *, char *));
+char   *renamefrom __P((char *));
+void	reply __P((int, const char *, ...));
+void	retrieve __P((const char *, const char *));
+void	send_file_list __P((const char *, int));
+void	statcmd __P((void));
+void	statfilecmd __P((char *));
+void	store __P((const char *, const char *, int));
+void	upper __P((char *));
+void	user __P((char *));
+void	yyerror __P((char *));
+void	toolong __P((int));
+int	yyparse __P((void));
+void    sizecmd __P((char *));
+
+struct utmp;
+void login(const struct utmp *);
+int logout(const char *line);
+
+#ifdef __linux__
+#include "daemon.h"
+#include "setproctitle.h"
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/inc/pathnames.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,62 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)pathnames.h	8.1 (Berkeley) 6/4/93
+ *	NetBSD: pathnames.h,v 1.5 1995/04/11 02:44:59 cgd Exp
+ *	OpenBSD: pathnames.h,v 1.2 1996/07/28 22:42:46 downsj Exp
+ *	OpenBSD: pathnames.h,v 1.3 1997/03/25 22:47:08 millert Exp
+ *      $Id: pathnames.h,v 1.3 1999/07/15 22:37:26 dholland Exp $
+ */
+
+#include <paths.h>
+
+#define	_PATH_FTPCHROOT		"/etc/ftpchroot"
+#define	_PATH_FTPWELCOME	"c:\\etc\\ftpwelcome"
+#define	_PATH_FTPLOGINMESG	"/etc/motd"
+#define _PATH_FTPDSTATFILE	"/var/log/ftpd"
+#define _PATH_CWDMESG		".message"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/inc/version.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,18 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+char pkg[]="$NetKit: linux-ftpd-0.17 $";
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,31 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+
+
+FTP Daemon
+
+Directory for:
+  connectivity\ftpd\
+
+
+- Component Summary
+
+-- FTP Daemon, ported from Linux using open environment libraries
+
+- Components Detail
+
+-- FTP Daemon
+MRP : \group\ftpd.mrp
+IBY : \group\ftpd.iby
+Source : \src
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/src/ftpcmd.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,3051 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/* A Bison parser, made by GNU Bison 2.1.  */
+
+/* Skeleton parser for Yacc-like parsing with Bison,
+   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, when this file is copied by Bison into a
+   Bison output file, you may use that output file without restriction.
+   This special exception was added by the Free Software Foundation
+   in version 1.24 of Bison.  */
+
+/* Written by Richard Stallman by simplifying the original so called
+   ``semantic'' parser.  */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+   infringing on user name space.  This should be done even for local
+   variables, as they might otherwise be expanded by user macros.
+   There are some unavoidable exceptions within include files to
+   define necessary library symbols; they are noted "INFRINGES ON
+   USER NAME SPACE" below.  */
+
+/* Identify Bison output.  */
+#define YYBISON 1
+
+/* Bison version.  */
+#define YYBISON_VERSION "2.1"
+
+/* Skeleton name.  */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers.  */
+#define YYPURE 0
+
+/* Using locations.  */
+#define YYLSP_NEEDED 0
+
+
+
+/* Tokens.  */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+   /* Put the tokens into the symbol table, so that GDB and other debuggers
+      know about them.  */
+   enum yytokentype {
+     A = 258,
+     B = 259,
+     C = 260,
+     E = 261,
+     F = 262,
+     I = 263,
+     L = 264,
+     N = 265,
+     P = 266,
+     R = 267,
+     S = 268,
+     T = 269,
+     SP = 270,
+     CRLF = 271,
+     COMMA = 272,
+     USER = 273,
+     PASS = 274,
+     ACCT = 275,
+     REIN = 276,
+     QUIT = 277,
+     PORT = 278,
+     PASV = 279,
+     TYPE = 280,
+     STRU = 281,
+     MODE = 282,
+     RETR = 283,
+     STOR = 284,
+     APPE = 285,
+     MLFL = 286,
+     MAIL = 287,
+     MSND = 288,
+     MSOM = 289,
+     MSAM = 290,
+     MRSQ = 291,
+     MRCP = 292,
+     ALLO = 293,
+     REST = 294,
+     RNFR = 295,
+     RNTO = 296,
+     ABOR = 297,
+     DELE = 298,
+     CWD = 299,
+     LIST = 300,
+     NLST = 301,
+     SITE = 302,
+     STAT = 303,
+     HELP = 304,
+     NOOP = 305,
+     MKD = 306,
+     RMD = 307,
+     PWD = 308,
+     CDUP = 309,
+     STOU = 310,
+     SMNT = 311,
+     SYST = 312,
+     SIZE = 313,
+     MDTM = 314,
+     UMASK = 315,
+     IDLE = 316,
+     CHMOD = 317,
+     LEXERR = 318,
+     STRING = 319,
+     NUMBER = 320
+   };
+#endif
+/* Tokens.  */
+#define A 258
+#define B 259
+#define C 260
+#define E 261
+#define F 262
+#define I 263
+#define L 264
+#define N 265
+#define P 266
+#define R 267
+#define S 268
+#define T 269
+#define SP 270
+#define CRLF 271
+#define COMMA 272
+#define USER 273
+#define PASS 274
+#define ACCT 275
+#define REIN 276
+#define QUIT 277
+#define PORT 278
+#define PASV 279
+#define TYPE 280
+#define STRU 281
+#define MODE 282
+#define RETR 283
+#define STOR 284
+#define APPE 285
+#define MLFL 286
+#define MAIL 287
+#define MSND 288
+#define MSOM 289
+#define MSAM 290
+#define MRSQ 291
+#define MRCP 292
+#define ALLO 293
+#define REST 294
+#define RNFR 295
+#define RNTO 296
+#define ABOR 297
+#define DELE 298
+#define CWD 299
+#define LIST 300
+#define NLST 301
+#define SITE 302
+#define STAT 303
+#define HELP 304
+#define NOOP 305
+#define MKD 306
+#define RMD 307
+#define PWD 308
+#define CDUP 309
+#define STOU 310
+#define SMNT 311
+#define SYST 312
+#define SIZE 313
+#define MDTM 314
+#define UMASK 315
+#define IDLE 316
+#define CHMOD 317
+#define LEXERR 318
+#define STRING 319
+#define NUMBER 320
+
+
+
+
+/* Copy the first part of user declarations.  */
+#line 43 "ftpcmd.y"
+
+
+char ftpcmd_rcsid[] = 
+  "$Id: ftpcmd.y,v 1.11 1999/10/09 02:32:12 dholland Exp $";
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+
+#include <netinet/in.h>
+#include <arpa/ftp.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <glob.h>
+#include <pwd.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+//#include <syslog.h>
+#include <time.h>
+#include <unistd.h>
+
+//#ifndef __linux__
+//#include <tzfile.h>
+//#else
+#define TM_YEAR_BASE 1900
+//#endif
+
+#include "extern.h"
+
+extern	struct sockaddr_in data_dest;
+extern	int logged_in;
+extern	struct passwd *pw;
+extern	int guest;
+extern	int logging;
+extern	int type;
+extern	int form;
+extern	int debug;
+extern	int timeout;
+extern	int maxtimeout;
+extern  int pdata;
+extern	char hostname[], remotehost[];
+extern	char proctitle[];
+extern	int usedefault;
+extern  int transflag;
+extern  char tmpline[];
+extern	int portcheck;
+extern	struct sockaddr_in his_addr;
+
+off_t	restart_point;
+
+static	int cmd_type;
+static	int cmd_form;
+static	int cmd_bytesz;
+char	cbuf[512];
+char	*fromname;
+
+struct tab;
+static int	 yylex __P((void));
+//static void	 sizecmd __P((char *));
+static void	 help __P((struct tab *, char *));
+
+//extern struct tab cmdtab[];
+//extern struct tab sitetab[];
+
+#define	CMD	0	/* beginning of command */
+#define	ARGS	1	/* expect miscellaneous arguments */
+#define	STR1	2	/* expect SP followed by STRING */
+#define	STR2	3	/* expect STRING */
+#define	OSTR	4	/* optional SP then STRING */
+#define	ZSTR1	5	/* SP then optional STRING */
+#define	ZSTR2	6	/* optional STRING after SP */
+#define	SITECMD	7	/* SITE command */
+#define	NSTR	8	/* Number followed by a string */
+
+struct tab {
+const char	*name;
+short	token;
+short	state;
+short	implemented;	/* 1 if command is implemented */
+const char	*help;
+};
+
+
+
+extern struct tab cmdtab[] = {		/* In order defined in RFC 765 */
+{ "USER", USER, STR1, 1,	"<sp> username" },
+{ "PASS", PASS, ZSTR1, 1,	"<sp> password" },
+{ "ACCT", ACCT, STR1, 0,	"(specify account)" },
+{ "SMNT", SMNT, ARGS, 0,	"(structure mount)" },
+{ "REIN", REIN, ARGS, 0,	"(reinitialize server state)" },
+{ "QUIT", QUIT, ARGS, 1,	"(terminate service)", },
+{ "PORT", PORT, ARGS, 1,	"<sp> b0, b1, b2, b3, b4" },
+{ "PASV", PASV, ARGS, 1,	"(set server in passive mode)" },
+{ "TYPE", TYPE, ARGS, 1,	"<sp> [ A | E | I | L ]" },
+{ "STRU", STRU, ARGS, 1,	"(specify file structure)" },
+{ "MODE", MODE, ARGS, 1,	"(specify transfer mode)" },
+{ "RETR", RETR, STR1, 1,	"<sp> file-name" },
+{ "STOR", STOR, STR1, 1,	"<sp> file-name" },
+{ "APPE", APPE, STR1, 1,	"<sp> file-name" },
+{ "MLFL", MLFL, OSTR, 0,	"(mail file)" },
+{ "MAIL", MAIL, OSTR, 0,	"(mail to user)" },
+{ "MSND", MSND, OSTR, 0,	"(mail send to terminal)" },
+{ "MSOM", MSOM, OSTR, 0,	"(mail send to terminal or mailbox)" },
+{ "MSAM", MSAM, OSTR, 0,	"(mail send to terminal and mailbox)" },
+{ "MRSQ", MRSQ, OSTR, 0,	"(mail recipient scheme question)" },
+{ "MRCP", MRCP, STR1, 0,	"(mail recipient)" },
+{ "ALLO", ALLO, ARGS, 1,	"allocate storage (vacuously)" },
+{ "REST", REST, ARGS, 1,	"<sp> offset (restart command)" },
+{ "RNFR", RNFR, STR1, 1,	"<sp> file-name" },
+{ "RNTO", RNTO, STR1, 1,	"<sp> file-name" },
+{ "ABOR", ABOR, ARGS, 1,	"(abort operation)" },
+{ "DELE", DELE, STR1, 1,	"<sp> file-name" },
+{ "CWD",  CWD,  OSTR, 1,	"[ <sp> directory-name ]" },
+{ "XCWD", CWD,	OSTR, 1,	"[ <sp> directory-name ]" },
+{ "LIST", LIST, OSTR, 1,	"[ <sp> path-name ]" },
+{ "NLST", NLST, OSTR, 1,	"[ <sp> path-name ]" },
+{ "SITE", SITE, SITECMD, 1,	"site-cmd [ <sp> arguments ]" },
+{ "SYST", SYST, ARGS, 1,	"(get type of operating system)" },
+{ "STAT", STAT, OSTR, 1,	"[ <sp> path-name ]" },
+{ "HELP", HELP, OSTR, 1,	"[ <sp> <string> ]" },
+{ "NOOP", NOOP, ARGS, 1,	"" },
+{ "MKD",  MKD,  STR1, 1,	"<sp> path-name" },
+{ "XMKD", MKD,  STR1, 1,	"<sp> path-name" },
+{ "RMD",  RMD,  STR1, 1,	"<sp> path-name" },
+{ "XRMD", RMD,  STR1, 1,	"<sp> path-name" },
+{ "PWD",  PWD,  ARGS, 1,	"(return current directory)" },
+{ "XPWD", PWD,  ARGS, 1,	"(return current directory)" },
+{ "CDUP", CDUP, ARGS, 1,	"(change to parent directory)" },
+{ "XCUP", CDUP, ARGS, 1,	"(change to parent directory)" },
+{ "STOU", STOU, STR1, 1,	"<sp> file-name" },
+{ "SIZE", SIZE, OSTR, 1,	"<sp> path-name" },
+{ "MDTM", MDTM, OSTR, 1,	"<sp> path-name" },
+{ NULL,   0,    0,    0,	0 }
+};
+
+extern struct tab sitetab[] = {
+{ "UMASK", UMASK, ARGS, 1,	"[ <sp> umask ]" },
+{ "IDLE", IDLE, ARGS, 1,	"[ <sp> maximum-idle-time ]" },
+{ "CHMOD", CHMOD, NSTR, 1,	"<sp> mode <sp> file-name" },
+{ "HELP", HELP, OSTR, 1,	"[ <sp> <string> ]" },
+{ NULL,   0,    0,    0,	0 }
+};
+
+
+
+/* Enabling traces.  */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages.  */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* Enabling the token table.  */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+#line 113 "ftpcmd.y"
+typedef union YYSTYPE {
+	int	i;
+	char   *s;
+} YYSTYPE;
+/* Line 196 of yacc.c.  */
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+
+
+/* Copy the second part of user declarations.  */
+
+
+/* Line 219 of yacc.c.  */
+
+#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
+# define YYSIZE_T __SIZE_TYPE__
+#endif
+#if ! defined (YYSIZE_T) && defined (size_t)
+# define YYSIZE_T size_t
+#endif
+#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+#endif
+#if ! defined (YYSIZE_T)
+# define YYSIZE_T unsigned int
+#endif
+
+#ifndef YY_
+# if YYENABLE_NLS
+#  if ENABLE_NLS
+#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+#   define YY_(msgid) dgettext ("bison-runtime", msgid)
+#  endif
+# endif
+# ifndef YY_
+#  define YY_(msgid) msgid
+# endif
+#endif
+
+#if ! defined (yyoverflow) || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols.  */
+
+# ifdef YYSTACK_USE_ALLOCA
+#  if YYSTACK_USE_ALLOCA
+#   ifdef __GNUC__
+#    define YYSTACK_ALLOC __builtin_alloca
+#   else
+#    define YYSTACK_ALLOC alloca
+#    if defined (__STDC__) || defined (__cplusplus)
+#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+#     define YYINCLUDED_STDLIB_H
+#    endif
+#   endif
+#  endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+   /* Pacify GCC's `empty if-body' warning. */
+#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
+#  ifndef YYSTACK_ALLOC_MAXIMUM
+    /* The OS might guarantee only one guard page at the bottom of the stack,
+       and a page size can be as small as 4096 bytes.  So we cannot safely
+       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
+       to allow for a few compiler-allocated temporary stack slots.  */
+#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
+#  endif
+# else
+#  define YYSTACK_ALLOC YYMALLOC
+#  define YYSTACK_FREE YYFREE
+#  ifndef YYSTACK_ALLOC_MAXIMUM
+#   define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
+#  endif
+#  ifdef __cplusplus
+extern "C" {
+#  endif
+#  ifndef YYMALLOC
+#   define YYMALLOC malloc
+#   if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
+	&& (defined (__STDC__) || defined (__cplusplus)))
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+#   endif
+#  endif
+#  ifndef YYFREE
+#   define YYFREE free
+#   if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
+	&& (defined (__STDC__) || defined (__cplusplus)))
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+#   endif
+#  endif
+#  ifdef __cplusplus
+}
+#  endif
+# endif
+#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
+
+
+#if (! defined (yyoverflow) \
+     && (! defined (__cplusplus) \
+	 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member.  */
+union yyalloc
+{
+  short int yyss;
+  YYSTYPE yyvs;
+  };
+
+/* The size of the maximum gap between one aligned stack and the next.  */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+   N elements.  */
+# define YYSTACK_BYTES(N) \
+     ((N) * (sizeof (short int) + sizeof (YYSTYPE))			\
+      + YYSTACK_GAP_MAXIMUM)
+
+/* Copy COUNT objects from FROM to TO.  The source and destination do
+   not overlap.  */
+# ifndef YYCOPY
+#  if defined (__GNUC__) && 1 < __GNUC__
+#   define YYCOPY(To, From, Count) \
+      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+#  else
+#   define YYCOPY(To, From, Count)		\
+      do					\
+	{					\
+	  YYSIZE_T yyi;				\
+	  for (yyi = 0; yyi < (Count); yyi++)	\
+	    (To)[yyi] = (From)[yyi];		\
+	}					\
+      while (0)
+#  endif
+# endif
+
+/* Relocate STACK from its old location to the new one.  The
+   local variables YYSIZE and YYSTACKSIZE give the old and new number of
+   elements in the stack, and YYPTR gives the new location of the
+   stack.  Advance YYPTR to a properly aligned location for the next
+   stack.  */
+# define YYSTACK_RELOCATE(Stack)					\
+    do									\
+      {									\
+	YYSIZE_T yynewbytes;						\
+	YYCOPY (&yyptr->Stack, Stack, yysize);				\
+	Stack = &yyptr->Stack;						\
+	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+	yyptr += yynewbytes / sizeof (*yyptr);				\
+      }									\
+    while (0)
+
+#endif
+
+#if defined (__STDC__) || defined (__cplusplus)
+   typedef signed char yysigned_char;
+#else
+   typedef short int yysigned_char;
+#endif
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL  2
+/* YYLAST -- Last index in YYTABLE.  */
+#define YYLAST   206
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS  66
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS  16
+/* YYNRULES -- Number of rules. */
+#define YYNRULES  75
+/* YYNRULES -- Number of states. */
+#define YYNSTATES  216
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
+#define YYUNDEFTOK  2
+#define YYMAXUTOK   320
+
+#define YYTRANSLATE(YYX)						\
+  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
+static const unsigned char yytranslate[] =
+{
+       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
+       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
+      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
+      35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
+      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
+      55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
+      65
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+   YYRHS.  */
+static const unsigned short int yyprhs[] =
+{
+       0,     0,     3,     4,     7,    10,    15,    20,    26,    30,
+      36,    42,    48,    54,    64,    70,    76,    82,    86,    92,
+      96,   102,   108,   112,   118,   124,   128,   132,   138,   141,
+     146,   149,   155,   161,   165,   169,   174,   181,   187,   195,
+     205,   211,   219,   225,   229,   235,   241,   244,   247,   253,
+     259,   261,   262,   264,   266,   278,   280,   282,   284,   286,
+     290,   292,   296,   298,   300,   304,   307,   309,   311,   313,
+     315,   317,   319,   321,   323,   325
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yysigned_char yyrhs[] =
+{
+      67,     0,    -1,    -1,    67,    68,    -1,    67,    69,    -1,
+      18,    15,    70,    16,    -1,    19,    15,    71,    16,    -1,
+      23,    81,    15,    73,    16,    -1,    24,    81,    16,    -1,
+      25,    81,    15,    75,    16,    -1,    26,    81,    15,    76,
+      16,    -1,    27,    81,    15,    77,    16,    -1,    38,    81,
+      15,    65,    16,    -1,    38,    81,    15,    65,    15,    12,
+      15,    65,    16,    -1,    28,    81,    15,    78,    16,    -1,
+      29,    81,    15,    78,    16,    -1,    30,    81,    15,    78,
+      16,    -1,    46,    81,    16,    -1,    46,    81,    15,    64,
+      16,    -1,    45,    81,    16,    -1,    45,    81,    15,    78,
+      16,    -1,    48,    81,    15,    78,    16,    -1,    48,    81,
+      16,    -1,    43,    81,    15,    78,    16,    -1,    41,    81,
+      15,    78,    16,    -1,    42,    81,    16,    -1,    44,    81,
+      16,    -1,    44,    81,    15,    78,    16,    -1,    49,    16,
+      -1,    49,    15,    64,    16,    -1,    50,    16,    -1,    51,
+      81,    15,    78,    16,    -1,    52,    81,    15,    78,    16,
+      -1,    53,    81,    16,    -1,    54,    81,    16,    -1,    47,
+      15,    49,    16,    -1,    47,    15,    49,    15,    64,    16,
+      -1,    47,    15,    60,    81,    16,    -1,    47,    15,    60,
+      81,    15,    80,    16,    -1,    47,    15,    62,    81,    15,
+      80,    15,    78,    16,    -1,    47,    15,    81,    61,    16,
+      -1,    47,    15,    81,    61,    15,    65,    16,    -1,    55,
+      81,    15,    78,    16,    -1,    57,    81,    16,    -1,    58,
+      81,    15,    78,    16,    -1,    59,    81,    15,    78,    16,
+      -1,    22,    16,    -1,     1,    16,    -1,    40,    81,    15,
+      78,    16,    -1,    39,    81,    15,    72,    16,    -1,    64,
+      -1,    -1,    64,    -1,    65,    -1,    65,    17,    65,    17,
+      65,    17,    65,    17,    65,    17,    65,    -1,    10,    -1,
+      14,    -1,     5,    -1,     3,    -1,     3,    15,    74,    -1,
+       6,    -1,     6,    15,    74,    -1,     8,    -1,     9,    -1,
+       9,    15,    72,    -1,     9,    72,    -1,     7,    -1,    12,
+      -1,    11,    -1,    13,    -1,     4,    -1,     5,    -1,    79,
+      -1,    64,    -1,    65,    -1,    -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
+static const unsigned short int yyrline[] =
+{
+       0,   148,   148,   150,   155,   159,   164,   170,   199,   205,
+     239,   253,   267,   273,   279,   286,   293,   300,   305,   312,
+     317,   324,   331,   336,   343,   357,   362,   367,   374,   378,
+     396,   400,   407,   414,   419,   424,   428,   435,   445,   460,
+     474,   481,   497,   504,   530,   547,   569,   574,   580,   594,
+     607,   612,   615,   619,   623,   647,   651,   655,   662,   667,
+     672,   677,   682,   686,   691,   697,   705,   709,   713,   720,
+     724,   728,   735,   779,   783,   811
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+  "$end", "error", "$undefined", "A", "B", "C", "E", "F", "I", "L", "N",
+  "P", "R", "S", "T", "SP", "CRLF", "COMMA", "USER", "PASS", "ACCT",
+  "REIN", "QUIT", "PORT", "PASV", "TYPE", "STRU", "MODE", "RETR", "STOR",
+  "APPE", "MLFL", "MAIL", "MSND", "MSOM", "MSAM", "MRSQ", "MRCP", "ALLO",
+  "REST", "RNFR", "RNTO", "ABOR", "DELE", "CWD", "LIST", "NLST", "SITE",
+  "STAT", "HELP", "NOOP", "MKD", "RMD", "PWD", "CDUP", "STOU", "SMNT",
+  "SYST", "SIZE", "MDTM", "UMASK", "IDLE", "CHMOD", "LEXERR", "STRING",
+  "NUMBER", "$accept", "cmd_list", "cmd", "rcmd", "username", "password",
+  "byte_size", "host_port", "form_code", "type_code", "struct_code",
+  "mode_code", "pathname", "pathstring", "octal_number", "check_login", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+   token YYLEX-NUM.  */
+static const unsigned short int yytoknum[] =
+{
+       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
+     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
+     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
+     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
+     295,   296,   297,   298,   299,   300,   301,   302,   303,   304,
+     305,   306,   307,   308,   309,   310,   311,   312,   313,   314,
+     315,   316,   317,   318,   319,   320
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
+static const unsigned char yyr1[] =
+{
+       0,    66,    67,    67,    67,    68,    68,    68,    68,    68,
+      68,    68,    68,    68,    68,    68,    68,    68,    68,    68,
+      68,    68,    68,    68,    68,    68,    68,    68,    68,    68,
+      68,    68,    68,    68,    68,    68,    68,    68,    68,    68,
+      68,    68,    68,    68,    68,    68,    68,    68,    69,    69,
+      70,    71,    71,    72,    73,    74,    74,    74,    75,    75,
+      75,    75,    75,    75,    75,    75,    76,    76,    76,    77,
+      77,    77,    78,    79,    80,    81
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
+static const unsigned char yyr2[] =
+{
+       0,     2,     0,     2,     2,     4,     4,     5,     3,     5,
+       5,     5,     5,     9,     5,     5,     5,     3,     5,     3,
+       5,     5,     3,     5,     5,     3,     3,     5,     2,     4,
+       2,     5,     5,     3,     3,     4,     6,     5,     7,     9,
+       5,     7,     5,     3,     5,     5,     2,     2,     5,     5,
+       1,     0,     1,     1,    11,     1,     1,     1,     1,     3,
+       1,     3,     1,     1,     3,     2,     1,     1,     1,     1,
+       1,     1,     1,     1,     1,     0
+};
+
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
+   means the default is an error.  */
+static const unsigned char yydefact[] =
+{
+       2,     0,     1,     0,     0,     0,     0,    75,    75,    75,
+      75,    75,    75,    75,    75,    75,    75,    75,    75,    75,
+      75,    75,    75,    75,     0,    75,     0,     0,    75,    75,
+      75,    75,    75,    75,    75,    75,     3,     4,    47,     0,
+      51,    46,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,    75,
+       0,     0,    28,    30,     0,     0,     0,     0,     0,     0,
+       0,     0,    50,     0,    52,     0,     0,     8,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,    25,     0,
+       0,    26,     0,    19,     0,    17,     0,    75,    75,     0,
+       0,    22,     0,     0,     0,    33,    34,     0,    43,     0,
+       0,     5,     6,     0,     0,    58,    60,    62,    63,     0,
+      66,    68,    67,     0,    70,    71,    69,     0,    73,     0,
+      72,     0,     0,     0,    53,     0,     0,     0,     0,     0,
+       0,     0,     0,    35,     0,     0,     0,     0,    29,     0,
+       0,     0,     0,     0,     0,     7,     0,     0,     0,    65,
+       9,    10,    11,    14,    15,    16,     0,    12,    49,    48,
+      24,    23,    27,    20,    18,     0,     0,    37,     0,     0,
+      40,    21,    31,    32,    42,    44,    45,     0,    57,    55,
+      56,    59,    61,    64,     0,    36,    74,     0,     0,     0,
+       0,     0,    38,     0,    41,     0,     0,     0,     0,    13,
+      39,     0,     0,     0,     0,    54
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const short int yydefgoto[] =
+{
+      -1,     1,    36,    37,    73,    75,   135,   114,   191,   119,
+     123,   127,   129,   130,   197,    42
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+   STATE-NUM.  */
+#define YYPACT_NINF -102
+static const short int yypact[] =
+{
+    -102,    47,  -102,   -13,    -9,     1,     8,  -102,  -102,  -102,
+    -102,  -102,  -102,  -102,  -102,  -102,  -102,  -102,  -102,  -102,
+    -102,  -102,  -102,  -102,    11,  -102,    52,    29,  -102,  -102,
+    -102,  -102,  -102,  -102,  -102,  -102,  -102,  -102,  -102,    -4,
+      -2,  -102,    64,    65,    69,    88,   102,   105,   113,   114,
+     115,   116,   117,   118,   119,   121,    92,    94,    96,   -47,
+      98,    70,  -102,  -102,   122,   123,   124,   125,   127,   128,
+     130,   131,  -102,   132,  -102,   133,    74,  -102,    55,    71,
+       7,    79,    79,    79,    82,    85,    79,    79,  -102,    79,
+      79,  -102,    79,  -102,    87,  -102,   100,  -102,  -102,    91,
+      79,  -102,   137,    79,    79,  -102,  -102,    79,  -102,    79,
+      79,  -102,  -102,   138,   140,   139,   142,  -102,    -6,   143,
+    -102,  -102,  -102,   144,  -102,  -102,  -102,   145,  -102,   146,
+    -102,   147,   148,   107,  -102,   149,   150,   151,   152,   153,
+     154,   155,   108,  -102,   109,   158,   111,   159,  -102,   160,
+     161,   162,   163,   164,    93,  -102,     9,     9,    85,  -102,
+    -102,  -102,  -102,  -102,  -102,  -102,   169,  -102,  -102,  -102,
+    -102,  -102,  -102,  -102,  -102,   166,   120,  -102,   120,   126,
+    -102,  -102,  -102,  -102,  -102,  -102,  -102,   157,  -102,  -102,
+    -102,  -102,  -102,  -102,   168,  -102,  -102,   170,   172,   173,
+     129,   134,  -102,    79,  -102,   167,   174,   176,   135,  -102,
+    -102,   171,   136,   178,   141,  -102
+};
+
+/* YYPGOTO[NTERM-NUM].  */
+static const yysigned_char yypgoto[] =
+{
+    -102,  -102,  -102,  -102,  -102,  -102,  -101,  -102,    36,  -102,
+    -102,  -102,   -82,  -102,    18,    21
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
+   positive, shift that token.  If negative, reduce the rule which
+   number is the opposite.  If zero, do what YYDEFACT says.
+   If YYTABLE_NINF, syntax error.  */
+#define YYTABLE_NINF -1
+static const unsigned char yytable[] =
+{
+     131,   132,    96,    38,   136,   137,    39,   138,   139,   158,
+     140,   124,   125,    97,   188,    98,    40,   159,   147,   189,
+     126,   149,   150,   190,    41,   151,    59,   152,   153,    43,
+      44,    45,    46,    47,    48,    49,    50,    51,    52,    53,
+      54,    55,    56,    57,    58,    63,    60,     2,     3,    64,
+      65,    66,    67,    68,    69,    70,    71,   193,   115,   134,
+      72,   116,    74,   117,   118,     4,     5,    61,    62,     6,
+       7,     8,     9,    10,    11,    12,    13,    14,   120,    76,
+      99,    77,   121,   122,    78,    15,    16,    17,    18,    19,
+      20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
+      30,    31,    32,    79,    33,    34,    35,    90,    91,    92,
+      93,    94,    95,   100,   101,   142,   143,    80,   144,   145,
+      81,   207,   166,   167,   176,   177,   179,   180,    82,    83,
+      84,    85,    86,    87,   102,    88,    89,   103,   104,   113,
+     105,   106,   107,   128,   108,   109,   110,   133,   111,   112,
+     134,   141,   146,   148,   156,   154,   155,   157,   187,   160,
+     161,   162,   163,   164,   165,   168,   169,   170,   171,   172,
+     173,   174,   175,   178,   200,   181,   182,   183,   184,   185,
+     186,   194,   195,   201,   208,   196,   202,   203,   212,   204,
+     209,   199,   210,   192,   205,   214,   198,     0,     0,   206,
+     211,   213,     0,     0,     0,     0,   215
+};
+
+static const short int yycheck[] =
+{
+      82,    83,    49,    16,    86,    87,    15,    89,    90,    15,
+      92,     4,     5,    60,     5,    62,    15,   118,   100,    10,
+      13,   103,   104,    14,    16,   107,    15,   109,   110,     8,
+       9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
+      19,    20,    21,    22,    23,    16,    25,     0,     1,    28,
+      29,    30,    31,    32,    33,    34,    35,   158,     3,    65,
+      64,     6,    64,     8,     9,    18,    19,    15,    16,    22,
+      23,    24,    25,    26,    27,    28,    29,    30,     7,    15,
+      59,    16,    11,    12,    15,    38,    39,    40,    41,    42,
+      43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
+      53,    54,    55,    15,    57,    58,    59,    15,    16,    15,
+      16,    15,    16,    15,    16,    15,    16,    15,    97,    98,
+      15,   203,    15,    16,    15,    16,    15,    16,    15,    15,
+      15,    15,    15,    15,    64,    16,    15,    15,    15,    65,
+      16,    16,    15,    64,    16,    15,    15,    65,    16,    16,
+      65,    64,    61,    16,    15,    17,    16,    15,    65,    16,
+      16,    16,    16,    16,    16,    16,    16,    16,    16,    16,
+      16,    16,    64,    15,    17,    16,    16,    16,    16,    16,
+      16,    12,    16,    15,    17,    65,    16,    15,    17,    16,
+      16,    65,    16,   157,    65,    17,   178,    -1,    -1,    65,
+      65,    65,    -1,    -1,    -1,    -1,    65
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+   symbol of state STATE-NUM.  */
+static const unsigned char yystos[] =
+{
+       0,    67,     0,     1,    18,    19,    22,    23,    24,    25,
+      26,    27,    28,    29,    30,    38,    39,    40,    41,    42,
+      43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
+      53,    54,    55,    57,    58,    59,    68,    69,    16,    15,
+      15,    16,    81,    81,    81,    81,    81,    81,    81,    81,
+      81,    81,    81,    81,    81,    81,    81,    81,    81,    15,
+      81,    15,    16,    16,    81,    81,    81,    81,    81,    81,
+      81,    81,    64,    70,    64,    71,    15,    16,    15,    15,
+      15,    15,    15,    15,    15,    15,    15,    15,    16,    15,
+      15,    16,    15,    16,    15,    16,    49,    60,    62,    81,
+      15,    16,    64,    15,    15,    16,    16,    15,    16,    15,
+      15,    16,    16,    65,    73,     3,     6,     8,     9,    75,
+       7,    11,    12,    76,     4,     5,    13,    77,    64,    78,
+      79,    78,    78,    65,    65,    72,    78,    78,    78,    78,
+      78,    64,    15,    16,    81,    81,    61,    78,    16,    78,
+      78,    78,    78,    78,    17,    16,    15,    15,    15,    72,
+      16,    16,    16,    16,    16,    16,    15,    16,    16,    16,
+      16,    16,    16,    16,    16,    64,    15,    16,    15,    15,
+      16,    16,    16,    16,    16,    16,    16,    65,     5,    10,
+      14,    74,    74,    72,    12,    16,    65,    80,    80,    65,
+      17,    15,    16,    15,    16,    65,    65,    78,    17,    16,
+      16,    65,    17,    65,    17,    65
+};
+
+#define yyerrok		(yyerrstatus = 0)
+#define yyclearin	(yychar = YYEMPTY)
+#define YYEMPTY		(-2)
+#define YYEOF		0
+
+#define YYACCEPT	goto yyacceptlab
+#define YYABORT		goto yyabortlab
+#define YYERROR		goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror.  This remains here temporarily
+   to ease the transition to the new meaning of YYERROR, for GCC.
+   Once GCC version 2 has supplanted version 1, this can go.  */
+
+#define YYFAIL		goto yyerrlab
+
+#define YYRECOVERING()  (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value)					\
+do								\
+  if (yychar == YYEMPTY && yylen == 1)				\
+    {								\
+      yychar = (Token);						\
+      yylval = (Value);						\
+      yytoken = YYTRANSLATE (yychar);				\
+      YYPOPSTACK;						\
+      goto yybackup;						\
+    }								\
+  else								\
+    {								\
+      yyerror (YY_("syntax error: cannot back up")); \
+      YYERROR;							\
+    }								\
+while (0)
+
+
+#define YYTERROR	1
+#define YYERRCODE	256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+   If N is 0, then set CURRENT to the empty location which ends
+   the previous symbol: RHS[0] (always defined).  */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N)				\
+    do									\
+      if (N)								\
+	{								\
+	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
+	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
+	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
+	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
+	}								\
+      else								\
+	{								\
+	  (Current).first_line   = (Current).last_line   =		\
+	    YYRHSLOC (Rhs, 0).last_line;				\
+	  (Current).first_column = (Current).last_column =		\
+	    YYRHSLOC (Rhs, 0).last_column;				\
+	}								\
+    while (0)
+#endif
+
+
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+   This macro was not mandated originally: define only if we know
+   we won't break user code: when these are the locations we know.  */
+
+#ifndef YY_LOCATION_PRINT
+# if YYLTYPE_IS_TRIVIAL
+#  define YY_LOCATION_PRINT(File, Loc)			\
+     fprintf (File, "%d.%d-%d.%d",			\
+              (Loc).first_line, (Loc).first_column,	\
+              (Loc).last_line,  (Loc).last_column)
+# else
+#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments.  */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (YYLEX_PARAM)
+#else
+# define YYLEX yylex ()
+#endif
+
+/* Enable debugging if requested.  */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+#  define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args)			\
+do {						\
+  if (yydebug)					\
+    YYFPRINTF Args;				\
+} while (0)
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)		\
+do {								\
+  if (yydebug)							\
+    {								\
+      YYFPRINTF (stderr, "%s ", Title);				\
+      yysymprint (stderr,					\
+                  Type, Value);	\
+      YYFPRINTF (stderr, "\n");					\
+    }								\
+} while (0)
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included).                                                   |
+`------------------------------------------------------------------*/
+
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yy_stack_print (short int *bottom, short int *top)
+#else
+static void
+yy_stack_print (bottom, top)
+    short int *bottom;
+    short int *top;
+#endif
+{
+  YYFPRINTF (stderr, "Stack now");
+  for (/* Nothing. */; bottom <= top; ++bottom)
+    YYFPRINTF (stderr, " %d", *bottom);
+  YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top)				\
+do {								\
+  if (yydebug)							\
+    yy_stack_print ((Bottom), (Top));				\
+} while (0)
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced.  |
+`------------------------------------------------*/
+
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yy_reduce_print (int yyrule)
+#else
+static void
+yy_reduce_print (yyrule)
+    int yyrule;
+#endif
+{
+  int yyi;
+  unsigned long int yylno = yyrline[yyrule];
+  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
+             yyrule - 1, yylno);
+  /* Print the symbols being reduced, and their result.  */
+  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
+    YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
+  YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
+}
+
+# define YY_REDUCE_PRINT(Rule)		\
+do {					\
+  if (yydebug)				\
+    yy_reduce_print (Rule);		\
+} while (0)
+
+/* Nonzero means print parse trace.  It is left uninitialized so that
+   multiple parsers can coexist.  */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks.  */
+#ifndef	YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+   if the built-in stack extension method is used).
+
+   Do not make this value too large; the results are undefined if
+   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+   evaluated with infinite-precision integer arithmetic.  */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+#  if defined (__GLIBC__) && defined (_STRING_H)
+#   define yystrlen strlen
+#  else
+/* Return the length of YYSTR.  */
+static YYSIZE_T
+#   if defined (__STDC__) || defined (__cplusplus)
+yystrlen (const char *yystr)
+#   else
+yystrlen (yystr)
+     const char *yystr;
+#   endif
+{
+  const char *yys = yystr;
+
+  while (*yys++ != '\0')
+    continue;
+
+  return yys - yystr - 1;
+}
+#  endif
+# endif
+
+# ifndef yystpcpy
+#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
+#   define yystpcpy stpcpy
+#  else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+   YYDEST.  */
+static char *
+#   if defined (__STDC__) || defined (__cplusplus)
+yystpcpy (char *yydest, const char *yysrc)
+#   else
+yystpcpy (yydest, yysrc)
+     char *yydest;
+     const char *yysrc;
+#   endif
+{
+  char *yyd = yydest;
+  const char *yys = yysrc;
+
+  while ((*yyd++ = *yys++) != '\0')
+    continue;
+
+  return yyd - 1;
+}
+#  endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+   quotes and backslashes, so that it's suitable for yyerror.  The
+   heuristic is that double-quoting is unnecessary unless the string
+   contains an apostrophe, a comma, or backslash (other than
+   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
+   null, do not copy; instead, return the length of what the result
+   would have been.  */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+  if (*yystr == '"')
+    {
+      size_t yyn = 0;
+      char const *yyp = yystr;
+
+      for (;;)
+	switch (*++yyp)
+	  {
+	  case '\'':
+	  case ',':
+	    goto do_not_strip_quotes;
+
+	  case '\\':
+	    if (*++yyp != '\\')
+	      goto do_not_strip_quotes;
+	    /* Fall through.  */
+	  default:
+	    if (yyres)
+	      yyres[yyn] = *yyp;
+	    yyn++;
+	    break;
+
+	  case '"':
+	    if (yyres)
+	      yyres[yyn] = '\0';
+	    return yyn;
+	  }
+    do_not_strip_quotes: ;
+    }
+
+  if (! yyres)
+    return yystrlen (yystr);
+
+  return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+#endif /* YYERROR_VERBOSE */
+
+
+
+#if YYDEBUG
+/*--------------------------------.
+| Print this symbol on YYOUTPUT.  |
+`--------------------------------*/
+
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yysymprint (yyoutput, yytype, yyvaluep)
+    FILE *yyoutput;
+    int yytype;
+    YYSTYPE *yyvaluep;
+#endif
+{
+  /* Pacify ``unused variable'' warnings.  */
+  (void) yyvaluep;
+
+  if (yytype < YYNTOKENS)
+    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+  else
+    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+
+# ifdef YYPRINT
+  if (yytype < YYNTOKENS)
+    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# endif
+  switch (yytype)
+    {
+      default:
+        break;
+    }
+  YYFPRINTF (yyoutput, ")");
+}
+
+#endif /* ! YYDEBUG */
+/*-----------------------------------------------.
+| Release the memory associated to this symbol.  |
+`-----------------------------------------------*/
+
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep)
+    const char *yymsg;
+    int yytype;
+    YYSTYPE *yyvaluep;
+#endif
+{
+  /* Pacify ``unused variable'' warnings.  */
+  (void) yyvaluep;
+
+  if (!yymsg)
+    yymsg = "Deleting";
+  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+  switch (yytype)
+    {
+
+      default:
+        break;
+    }
+}
+
+
+/* Prevent warnings from -Wmissing-prototypes.  */
+
+#ifdef YYPARSE_PARAM
+# if defined (__STDC__) || defined (__cplusplus)
+int yyparse (void *YYPARSE_PARAM);
+# else
+int yyparse ();
+# endif
+#else /* ! YYPARSE_PARAM */
+#if defined (__STDC__) || defined (__cplusplus)
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+
+/* The look-ahead symbol.  */
+int yychar;
+
+/* The semantic value of the look-ahead symbol.  */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far.  */
+int yynerrs;
+
+
+
+/*----------.
+| yyparse.  |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+# if defined (__STDC__) || defined (__cplusplus)
+int yyparse (void *YYPARSE_PARAM)
+# else
+int yyparse (YYPARSE_PARAM)
+  void *YYPARSE_PARAM;
+# endif
+#else /* ! YYPARSE_PARAM */
+#if defined (__STDC__) || defined (__cplusplus)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+    ;
+#endif
+#endif
+{
+  
+  int yystate;
+  int yyn;
+  int yyresult;
+  /* Number of tokens to shift before error messages enabled.  */
+  int yyerrstatus;
+  /* Look-ahead token as an internal (translated) token number.  */
+  int yytoken = 0;
+
+  /* Three stacks and their tools:
+     `yyss': related to states,
+     `yyvs': related to semantic values,
+     `yyls': related to locations.
+
+     Refer to the stacks thru separate pointers, to allow yyoverflow
+     to reallocate them elsewhere.  */
+
+  /* The state stack.  */
+  short int yyssa[YYINITDEPTH];
+  short int *yyss = yyssa;
+  short int *yyssp;
+
+  /* The semantic value stack.  */
+  YYSTYPE yyvsa[YYINITDEPTH];
+  YYSTYPE *yyvs = yyvsa;
+  YYSTYPE *yyvsp;
+
+
+
+#define YYPOPSTACK   (yyvsp--, yyssp--)
+
+  YYSIZE_T yystacksize = YYINITDEPTH;
+
+  /* The variables used to return semantic value and location from the
+     action routines.  */
+  YYSTYPE yyval;
+
+
+  /* When reducing, the number of symbols on the RHS of the reduced
+     rule.  */
+  int yylen;
+
+  YYDPRINTF ((stderr, "Starting parse\n"));
+
+  yystate = 0;
+  yyerrstatus = 0;
+  yynerrs = 0;
+  yychar = YYEMPTY;		/* Cause a token to be read.  */
+
+  /* Initialize stack pointers.
+     Waste one element of value and location stack
+     so that they stay on the same level as the state stack.
+     The wasted elements are never initialized.  */
+
+  yyssp = yyss;
+  yyvsp = yyvs;
+
+  goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate.  |
+`------------------------------------------------------------*/
+ yynewstate:
+  /* In all cases, when you get here, the value and location stacks
+     have just been pushed. so pushing a state here evens the stacks.
+     */
+  yyssp++;
+
+ yysetstate:
+  *yyssp = yystate;
+
+  if (yyss + yystacksize - 1 <= yyssp)
+    {
+      /* Get the current used size of the three stacks, in elements.  */
+      YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+      {
+	/* Give user a chance to reallocate the stack. Use copies of
+	   these so that the &'s don't force the real ones into
+	   memory.  */
+	YYSTYPE *yyvs1 = yyvs;
+	short int *yyss1 = yyss;
+
+
+	/* Each stack pointer address is followed by the size of the
+	   data in use in that stack, in bytes.  This used to be a
+	   conditional around just the two extra args, but that might
+	   be undefined if yyoverflow is a macro.  */
+	yyoverflow (YY_("memory exhausted"),
+		    &yyss1, yysize * sizeof (*yyssp),
+		    &yyvs1, yysize * sizeof (*yyvsp),
+
+		    &yystacksize);
+
+	yyss = yyss1;
+	yyvs = yyvs1;
+      }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+      goto yyexhaustedlab;
+# else
+      /* Extend the stack our own way.  */
+      if (YYMAXDEPTH <= yystacksize)
+	goto yyexhaustedlab;
+      yystacksize *= 2;
+      if (YYMAXDEPTH < yystacksize)
+	yystacksize = YYMAXDEPTH;
+
+      {
+	short int *yyss1 = yyss;
+	union yyalloc *yyptr =
+	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+	if (! yyptr)
+	  goto yyexhaustedlab;
+	YYSTACK_RELOCATE (yyss);
+	YYSTACK_RELOCATE (yyvs);
+
+#  undef YYSTACK_RELOCATE
+	if (yyss1 != yyssa)
+	  YYSTACK_FREE (yyss1);
+      }
+# endif
+#endif /* no yyoverflow */
+
+      yyssp = yyss + yysize - 1;
+      yyvsp = yyvs + yysize - 1;
+
+
+      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+		  (unsigned long int) yystacksize));
+
+      if (yyss + yystacksize - 1 <= yyssp)
+	YYABORT;
+    }
+
+  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+  goto yybackup;
+
+/*-----------.
+| yybackup.  |
+`-----------*/
+yybackup:
+
+/* Do appropriate processing given the current state.  */
+/* Read a look-ahead token if we need one and don't already have one.  */
+/* yyresume: */
+
+  /* First try to decide what to do without reference to look-ahead token.  */
+
+  yyn = yypact[yystate];
+  if (yyn == YYPACT_NINF)
+    goto yydefault;
+
+  /* Not known => get a look-ahead token if don't already have one.  */
+
+  /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
+  if (yychar == YYEMPTY)
+    {
+      YYDPRINTF ((stderr, "Reading a token: "));
+      yychar = YYLEX;
+    }
+
+  if (yychar <= YYEOF)
+    {
+      yychar = yytoken = YYEOF;
+      YYDPRINTF ((stderr, "Now at end of input.\n"));
+    }
+  else
+    {
+      yytoken = YYTRANSLATE (yychar);
+      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+    }
+
+  /* If the proper action on seeing token YYTOKEN is to reduce or to
+     detect an error, take that action.  */
+  yyn += yytoken;
+  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+    goto yydefault;
+  yyn = yytable[yyn];
+  if (yyn <= 0)
+    {
+      if (yyn == 0 || yyn == YYTABLE_NINF)
+	goto yyerrlab;
+      yyn = -yyn;
+      goto yyreduce;
+    }
+
+  if (yyn == YYFINAL)
+    YYACCEPT;
+
+  /* Shift the look-ahead token.  */
+  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+  /* Discard the token being shifted unless it is eof.  */
+  if (yychar != YYEOF)
+    yychar = YYEMPTY;
+
+  *++yyvsp = yylval;
+
+
+  /* Count tokens shifted since error; after three, turn off error
+     status.  */
+  if (yyerrstatus)
+    yyerrstatus--;
+
+  yystate = yyn;
+  goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state.  |
+`-----------------------------------------------------------*/
+yydefault:
+  yyn = yydefact[yystate];
+  if (yyn == 0)
+    goto yyerrlab;
+  goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction.  |
+`-----------------------------*/
+yyreduce:
+  /* yyn is the number of a rule to reduce with.  */
+  yylen = yyr2[yyn];
+
+  /* If YYLEN is nonzero, implement the default value of the action:
+     `$$ = $1'.
+
+     Otherwise, the following line sets YYVAL to garbage.
+     This behavior is undocumented and Bison
+     users should not rely upon it.  Assigning to YYVAL
+     unconditionally makes the parser a bit smaller, and it avoids a
+     GCC warning that YYVAL may be used uninitialized.  */
+  yyval = yyvsp[1-yylen];
+
+
+  YY_REDUCE_PRINT (yyn);
+  switch (yyn)
+    {
+        case 3:
+#line 151 "ftpcmd.y"
+    {
+			fromname = (char *) 0;
+			restart_point = (off_t) 0;
+		}
+    break;
+
+  case 5:
+#line 160 "ftpcmd.y"
+    {
+			user((yyvsp[-1].s));
+			free((yyvsp[-1].s));
+		}
+    break;
+
+  case 6:
+#line 165 "ftpcmd.y"
+    {
+			pass((yyvsp[-1].s));
+			memset((yyvsp[-1].s), 0, strlen((yyvsp[-1].s)));
+			free((yyvsp[-1].s));
+		}
+    break;
+
+  case 7:
+#line 171 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i)) {
+				if ((yyvsp[-1].i)) {
+					usedefault = 1;
+					reply(500,	
+					    "Illegal PORT rejected (range errors).");
+				} else if (portcheck &&
+				    /*ntohs(*/data_dest.sin_port/*)*/ < IPPORT_RESERVED) {
+					usedefault = 1;
+					reply(500,
+					    "Illegal PORT rejected (reserved port).");
+				} else if (portcheck &&
+				    memcmp(&data_dest.sin_addr,
+				    &his_addr.sin_addr,
+				    sizeof data_dest.sin_addr)) {
+					usedefault = 1;
+					reply(500,
+					    "Illegal PORT rejected (address wrong).");
+				} else {
+					usedefault = 0;
+					if (pdata >= 0) {
+						(void) close(pdata);
+						pdata = -1;
+					}
+					reply(200, "PORT command successful.");
+				}
+			}
+		}
+    break;
+
+  case 8:
+#line 200 "ftpcmd.y"
+    {
+			if ((yyvsp[-1].i)) {
+				passive();
+			}
+		}
+    break;
+
+  case 9:
+#line 206 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i)) {
+				switch (cmd_type) {
+
+				case TYPE_A:
+					if (cmd_form == FORM_N) {
+						reply(200, "Type set to A.");
+						type = cmd_type;
+						form = cmd_form;
+					} else
+						reply(504, "Form must be N.");
+					break;
+
+				case TYPE_E:
+					reply(504, "Type E not implemented.");
+					break;
+	
+				case TYPE_I:
+					reply(200, "Type set to I.");
+					type = cmd_type;
+					break;
+
+				case TYPE_L:
+					if (cmd_bytesz == 8) {
+					       reply(200,
+					       "Type set to L (byte size 8).");
+					       type = cmd_type;
+					} else
+					    reply(504, "Byte size must be 8.");
+
+				}
+			}
+		}
+    break;
+
+  case 10:
+#line 240 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i)) {
+				switch ((yyvsp[-1].i)) {
+
+				case STRU_F:
+					reply(200, "STRU F ok.");
+					break;
+
+				default:
+					reply(504, "Unimplemented STRU type.");
+				}
+			}
+		}
+    break;
+
+  case 11:
+#line 254 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i)) {
+				switch ((yyvsp[-1].i)) {
+
+				case MODE_S:
+					reply(200, "MODE S ok.");
+					break;
+
+				default:
+					reply(502, "Unimplemented MODE type.");
+				}
+			}
+		}
+    break;
+
+  case 12:
+#line 268 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i)) {
+				reply(202, "ALLO command ignored.");
+			}
+		}
+    break;
+
+  case 13:
+#line 274 "ftpcmd.y"
+    {
+			if ((yyvsp[-7].i)) {
+				reply(202, "ALLO command ignored.");
+			}
+		}
+    break;
+
+  case 14:
+#line 280 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				retrieve((char *) 0, (yyvsp[-1].s));
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 15:
+#line 287 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				store((yyvsp[-1].s), "w", 0);
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 16:
+#line 294 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				store((yyvsp[-1].s), "a", 0);
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 17:
+#line 301 "ftpcmd.y"
+    {
+			if ((yyvsp[-1].i))
+				send_file_list(".",1);
+		}
+    break;
+
+  case 18:
+#line 306 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				send_file_list((yyvsp[-1].s),1);
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 19:
+#line 313 "ftpcmd.y"
+    {
+			if ((yyvsp[-1].i))
+				send_file_list(".",0);
+				//retrieve("/bin/ls -lgA", "");
+		}
+    break;
+
+  case 20:
+#line 318 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				send_file_list((yyvsp[-1].s),0);
+				//retrieve("/bin/ls -lgA %s", (yyvsp[-1].s));
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 21:
+#line 325 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				statfilecmd((yyvsp[-1].s));
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 22:
+#line 332 "ftpcmd.y"
+    {
+			if ((yyvsp[-1].i))
+				statcmd();
+		}
+    break;
+
+  case 23:
+#line 337 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				dele((yyvsp[-1].s));
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 24:
+#line 344 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i)) {
+				if (fromname) {
+					renamecmd(fromname, (yyvsp[-1].s));
+					free(fromname);
+					fromname = (char *) 0;
+				} else {
+					reply(503, 
+					  "Bad sequence of commands.");
+				}
+			}
+			free((yyvsp[-1].s));
+		}
+    break;
+
+  case 25:
+#line 358 "ftpcmd.y"
+    {
+			if ((yyvsp[-1].i)) 
+				reply(225, "ABOR command successful.");
+		}
+    break;
+
+  case 26:
+#line 363 "ftpcmd.y"
+    {
+			if ((yyvsp[-1].i))
+				cwd(pw->pw_dir);
+		}
+    break;
+
+  case 27:
+#line 368 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				cwd((yyvsp[-1].s));
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 28:
+#line 375 "ftpcmd.y"
+    {
+			help(cmdtab, (char *) 0);
+		}
+    break;
+
+  case 29:
+#line 379 "ftpcmd.y"
+    {
+			char *cp = (yyvsp[-1].s);
+
+			if (strncasecmp(cp, "SITE", 4) == 0) {
+				cp = (yyvsp[-1].s) + 4;
+				if (*cp == ' ')
+					cp++;
+				if (*cp)
+					help(sitetab, cp);
+				else
+					help(sitetab, (char *) 0);
+			}
+			else
+				help(cmdtab, (yyvsp[-1].s));
+
+			if ((yyvsp[-1].s) != NULL)
+				free ((yyvsp[-1].s));
+		}
+    break;
+
+  case 30:
+#line 397 "ftpcmd.y"
+    {
+			reply(200, "NOOP command successful.");
+		}
+    break;
+
+  case 31:
+#line 401 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				makedir((yyvsp[-1].s));
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 32:
+#line 408 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				removedir((yyvsp[-1].s));
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 33:
+#line 415 "ftpcmd.y"
+    {
+			if ((yyvsp[-1].i))
+				pwd();
+		}
+    break;
+
+  case 34:
+#line 420 "ftpcmd.y"
+    {
+			if ((yyvsp[-1].i))
+				cwd("..");
+		}
+    break;
+
+  case 35:
+#line 425 "ftpcmd.y"
+    {
+			help(sitetab, (char *) 0);
+		}
+    break;
+
+  case 36:
+#line 429 "ftpcmd.y"
+    {
+			help(sitetab, (yyvsp[-1].s));
+
+			if ((yyvsp[-1].s) != NULL)
+				free ((yyvsp[-1].s));
+		}
+    break;
+
+  case 37:
+#line 436 "ftpcmd.y"
+    {
+			int oldmask;
+
+			if ((yyvsp[-1].i)) {
+				oldmask = umask(0);
+				(void) umask(oldmask);
+				reply(200, "Current UMASK is %03o", oldmask);
+			}
+		}
+    break;
+
+  case 38:
+#line 446 "ftpcmd.y"
+    {
+			int oldmask;
+
+			if ((yyvsp[-3].i)) {
+				if (((yyvsp[-1].i) == -1) || ((yyvsp[-1].i) > 0777)) {
+					reply(501, "Bad UMASK value");
+				} else {
+					oldmask = umask((yyvsp[-1].i));
+					reply(200,
+					    "UMASK set to %03o (was %03o)",
+					    (yyvsp[-1].i), oldmask);
+				}
+			}
+		}
+    break;
+
+  case 39:
+#line 461 "ftpcmd.y"
+    {
+			if ((yyvsp[-5].i) && ((yyvsp[-1].s) != NULL)) {
+				if ((yyvsp[-3].i) > 0777)
+					reply(501,
+				"CHMOD: Mode value must be between 0 and 0777");
+				else if (chmod((yyvsp[-1].s), (yyvsp[-3].i)) < 0)
+					perror_reply(550, (yyvsp[-1].s));
+				else
+					reply(200, "CHMOD command successful.");
+			}
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 40:
+#line 475 "ftpcmd.y"
+    {
+			if ((yyvsp[-2].i))
+			  reply(200,
+	       		    "Current IDLE time limit is %d seconds; max %d",
+				timeout, maxtimeout);
+		}
+    break;
+
+  case 41:
+#line 482 "ftpcmd.y"
+    {
+			if ((yyvsp[-4].i)) {
+				if ((yyvsp[-1].i) < 30 || (yyvsp[-1].i) > maxtimeout) {
+				reply(501,
+	       		 "Maximum IDLE time must be between 30 and %d seconds",
+				    maxtimeout);
+				} else {
+					timeout = (yyvsp[-1].i);
+					//(void) alarm((unsigned) timeout);
+					reply(200,
+					 "Maximum IDLE time set to %d seconds",
+					    timeout);
+				}
+			}
+		}
+    break;
+
+  case 42:
+#line 498 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				store((yyvsp[-1].s), "w", 1);
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 43:
+#line 505 "ftpcmd.y"
+    {
+			if ((yyvsp[-1].i))
+#ifdef __linux__
+			reply(215, "UNIX Type: L%d (Linux)", CHAR_BIT);
+#else
+#ifdef unix
+#ifdef BSD
+			reply(215, "UNIX Type: L%d Version: BSD-%d",
+				CHAR_BIT, BSD);
+#else /* BSD */
+			reply(215, "UNIX Type: L%d", CHAR_BIT);
+#endif /* BSD */
+#else /* unix */
+#ifdef __SYMBIAN32__		
+			reply(215, "UNIX Type: L%d", CHAR_BIT);
+#else
+			reply(215, "UNKNOWN Type: L%d", CHAR_BIT);
+#endif /* __SYMBIAN32__ */			
+#endif /* unix */
+#endif /* __linux__ */
+		}
+    break;
+
+  case 44:
+#line 531 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL)
+				sizecmd((yyvsp[-1].s));
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 45:
+#line 548 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i) && (yyvsp[-1].s) != NULL) {
+				struct stat stbuf;
+				if (stat((yyvsp[-1].s), &stbuf) < 0)
+					reply(550, "%s: %s",
+					    (yyvsp[-1].s), strerror(errno));
+				else if (!S_ISREG(stbuf.st_mode)) {
+					reply(550, "%s: not a plain file.", (yyvsp[-1].s));
+				} else {
+					struct tm *t;
+					t = gmtime(&stbuf.st_mtime);
+					reply(213,
+					    "%04d%02d%02d%02d%02d%02d",
+					    TM_YEAR_BASE + t->tm_year,
+					    t->tm_mon+1, t->tm_mday,
+					    t->tm_hour, t->tm_min, t->tm_sec);
+				}
+			}
+			if ((yyvsp[-1].s) != NULL)
+				free((yyvsp[-1].s));
+		}
+    break;
+
+  case 46:
+#line 570 "ftpcmd.y"
+    {
+			reply(221, "Goodbye.");
+			dologout(0);
+		}
+    break;
+
+  case 47:
+#line 575 "ftpcmd.y"
+    {
+			yyerrok;
+		}
+    break;
+
+  case 48:
+#line 581 "ftpcmd.y"
+    {
+			restart_point = (off_t) 0;
+			if ((yyvsp[-3].i) && (yyvsp[-1].s)) {
+				fromname = renamefrom((yyvsp[-1].s));
+				if (fromname == (char *) 0 && (yyvsp[-1].s)) {
+					free((yyvsp[-1].s));
+				}
+			} else {
+				if ((yyvsp[-1].s))
+					free ((yyvsp[-1].s));
+			}
+		}
+    break;
+
+  case 49:
+#line 595 "ftpcmd.y"
+    {
+			if ((yyvsp[-3].i)) {
+			    fromname = (char *) 0;
+			    restart_point = (yyvsp[-1].i);	/* XXX $4 is only "int" */
+			    reply(350, "Restarting at %qd. %s", 
+			       (quad_t) restart_point,
+			       "Send STORE or RETRIEVE to initiate transfer.");
+			}
+		}
+    break;
+
+  case 51:
+#line 612 "ftpcmd.y"
+    {
+			(yyval.s) = (char *)calloc(1, sizeof(char));
+		}
+    break;
+
+  case 54:
+#line 625 "ftpcmd.y"
+    {
+			char *a, *p;
+
+			if ((yyvsp[-10].i) < 0 || (yyvsp[-10].i) > 255 || (yyvsp[-8].i) < 0 || (yyvsp[-8].i) > 255 ||
+			    (yyvsp[-6].i) < 0 || (yyvsp[-6].i) > 255 || (yyvsp[-4].i) < 0 || (yyvsp[-4].i) > 255 ||
+			    (yyvsp[-2].i) < 0 || (yyvsp[-2].i) > 255 || (yyvsp[0].i) < 0 || (yyvsp[0].i) > 255) {
+				(yyval.i) = 1;
+			} else {
+//#ifndef __linux__
+//				data_dest.sin_len = sizeof(struct sockaddr_in);
+//#endif
+				data_dest.sin_family = AF_INET;
+				p = (char *)&data_dest.sin_port;
+				p[0] = (yyvsp[-2].i); p[1] = (yyvsp[0].i);
+				a = (char *)&data_dest.sin_addr;
+				a[0] = (yyvsp[-10].i); a[1] = (yyvsp[-8].i); a[2] = (yyvsp[-6].i); a[3] = (yyvsp[-4].i);
+				(yyval.i) = 0;
+			}
+		}
+    break;
+
+  case 55:
+#line 648 "ftpcmd.y"
+    {
+			(yyval.i) = FORM_N;
+		}
+    break;
+
+  case 56:
+#line 652 "ftpcmd.y"
+    {
+			(yyval.i) = FORM_T;
+		}
+    break;
+
+  case 57:
+#line 656 "ftpcmd.y"
+    {
+			(yyval.i) = FORM_C;
+		}
+    break;
+
+  case 58:
+#line 663 "ftpcmd.y"
+    {
+			cmd_type = TYPE_A;
+			cmd_form = FORM_N;
+		}
+    break;
+
+  case 59:
+#line 668 "ftpcmd.y"
+    {
+			cmd_type = TYPE_A;
+			cmd_form = (yyvsp[0].i);
+		}
+    break;
+
+  case 60:
+#line 673 "ftpcmd.y"
+    {
+			cmd_type = TYPE_E;
+			cmd_form = FORM_N;
+		}
+    break;
+
+  case 61:
+#line 678 "ftpcmd.y"
+    {
+			cmd_type = TYPE_E;
+			cmd_form = (yyvsp[0].i);
+		}
+    break;
+
+  case 62:
+#line 683 "ftpcmd.y"
+    {
+			cmd_type = TYPE_I;
+		}
+    break;
+
+  case 63:
+#line 687 "ftpcmd.y"
+    {
+			cmd_type = TYPE_L;
+			cmd_bytesz = CHAR_BIT;
+		}
+    break;
+
+  case 64:
+#line 692 "ftpcmd.y"
+    {
+			cmd_type = TYPE_L;
+			cmd_bytesz = (yyvsp[0].i);
+		}
+    break;
+
+  case 65:
+#line 698 "ftpcmd.y"
+    {
+			cmd_type = TYPE_L;
+			cmd_bytesz = (yyvsp[0].i);
+		}
+    break;
+
+  case 66:
+#line 706 "ftpcmd.y"
+    {
+			(yyval.i) = STRU_F;
+		}
+    break;
+
+  case 67:
+#line 710 "ftpcmd.y"
+    {
+			(yyval.i) = STRU_R;
+		}
+    break;
+
+  case 68:
+#line 714 "ftpcmd.y"
+    {
+			(yyval.i) = STRU_P;
+		}
+    break;
+
+  case 69:
+#line 721 "ftpcmd.y"
+    {
+			(yyval.i) = MODE_S;
+		}
+    break;
+
+  case 70:
+#line 725 "ftpcmd.y"
+    {
+			(yyval.i) = MODE_B;
+		}
+    break;
+
+  case 71:
+#line 729 "ftpcmd.y"
+    {
+			(yyval.i) = MODE_C;
+		}
+    break;
+
+  case 72:
+#line 736 "ftpcmd.y"
+    {
+			/*
+			 * Problem: this production is used for all pathname
+			 * processing, but only gives a 550 error reply.
+			 * This is a valid reply in some cases but not in others.
+			 */
+			if (logged_in && (yyvsp[0].s) && strchr((yyvsp[0].s), '~') != NULL) {
+				glob_t gl;
+#ifdef __linux__
+				/* see popen.c */
+				int flags = GLOB_NOCHECK;
+#else
+				int flags =
+				 GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE;
+#endif
+				char *pptr = (yyvsp[0].s);
+
+				/*
+				 * glob() will only find a leading ~, but
+				 * Netscape kindly puts a slash in front of
+				 * it for publish URLs.  There needs to be
+				 * a flag for glob() that expands tildes
+				 * anywhere in the string.
+				 */
+				if ((pptr[0] == '/') && (pptr[1] == '~'))
+					pptr++;
+
+				memset(&gl, 0, sizeof(gl));
+				if (glob(pptr, flags, NULL, &gl) ||
+				    gl.gl_pathc == 0) {
+					reply(550, "not found");
+					(yyval.s) = NULL;
+				} else {
+					(yyval.s) = strdup(gl.gl_pathv[0]);
+				}
+				globfree(&gl);
+				free((yyvsp[0].s));
+			} else
+				(yyval.s) = (yyvsp[0].s);
+		}
+    break;
+
+  case 74:
+#line 784 "ftpcmd.y"
+    {
+			int ret, dec, multby, digit;
+
+			/*
+			 * Convert a number that was read as decimal number
+			 * to what it would be if it had been read as octal.
+			 */
+			dec = (yyvsp[0].i);
+			multby = 1;
+			ret = 0;
+			while (dec) {
+				digit = dec%10;
+				if (digit > 7) {
+					ret = -1;
+					break;
+				}
+				ret += digit * multby;
+				multby *= 8;
+				dec /= 10;
+			}
+			(yyval.i) = ret;
+		}
+    break;
+
+  case 75:
+#line 811 "ftpcmd.y"
+    {
+			if (logged_in)
+				(yyval.i) = 1;
+			else {
+				reply(530, "Please login with USER and PASS.");
+				(yyval.i) = 0;
+			}
+		}
+    break;
+
+
+      default: break;
+    }
+
+/* Line 1126 of yacc.c.  */
+
+  yyvsp -= yylen;
+  yyssp -= yylen;
+
+
+  YY_STACK_PRINT (yyss, yyssp);
+
+  *++yyvsp = yyval;
+
+
+  /* Now `shift' the result of the reduction.  Determine what state
+     that goes to, based on the state we popped back to and the rule
+     number reduced by.  */
+
+  yyn = yyr1[yyn];
+
+  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+    yystate = yytable[yystate];
+  else
+    yystate = yydefgoto[yyn - YYNTOKENS];
+
+  goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+  /* If not already recovering from an error, report this error.  */
+  if (!yyerrstatus)
+    {
+      ++yynerrs;
+#if YYERROR_VERBOSE
+      yyn = yypact[yystate];
+
+      if (YYPACT_NINF < yyn && yyn < YYLAST)
+	{
+	  int yytype = YYTRANSLATE (yychar);
+	  YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+	  YYSIZE_T yysize = yysize0;
+	  YYSIZE_T yysize1;
+	  int yysize_overflow = 0;
+	  char *yymsg = 0;
+#	  define YYERROR_VERBOSE_ARGS_MAXIMUM 5
+	  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+	  int yyx;
+
+#if 0
+	  /* This is so xgettext sees the translatable formats that are
+	     constructed on the fly.  */
+	  YY_("syntax error, unexpected %s");
+	  YY_("syntax error, unexpected %s, expecting %s");
+	  YY_("syntax error, unexpected %s, expecting %s or %s");
+	  YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+	  YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+#endif
+	  char *yyfmt;
+	  char const *yyf;
+	  static char const yyunexpected[] = "syntax error, unexpected %s";
+	  static char const yyexpecting[] = ", expecting %s";
+	  static char const yyor[] = " or %s";
+	  char yyformat[sizeof yyunexpected
+			+ sizeof yyexpecting - 1
+			+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+			   * (sizeof yyor - 1))];
+	  char const *yyprefix = yyexpecting;
+
+	  /* Start YYX at -YYN if negative to avoid negative indexes in
+	     YYCHECK.  */
+	  int yyxbegin = yyn < 0 ? -yyn : 0;
+
+	  /* Stay within bounds of both yycheck and yytname.  */
+	  int yychecklim = YYLAST - yyn;
+	  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+	  int yycount = 1;
+
+	  yyarg[0] = yytname[yytype];
+	  yyfmt = yystpcpy (yyformat, yyunexpected);
+
+	  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+	    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+	      {
+		if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+		  {
+		    yycount = 1;
+		    yysize = yysize0;
+		    yyformat[sizeof yyunexpected - 1] = '\0';
+		    break;
+		  }
+		yyarg[yycount++] = yytname[yyx];
+		yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+		yysize_overflow |= yysize1 < yysize;
+		yysize = yysize1;
+		yyfmt = yystpcpy (yyfmt, yyprefix);
+		yyprefix = yyor;
+	      }
+
+	  yyf = YY_(yyformat);
+	  yysize1 = yysize + yystrlen (yyf);
+	  yysize_overflow |= yysize1 < yysize;
+	  yysize = yysize1;
+
+	  if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
+	    yymsg = (char *) YYSTACK_ALLOC (yysize);
+	  if (yymsg)
+	    {
+	      /* Avoid sprintf, as that infringes on the user's name space.
+		 Don't have undefined behavior even if the translation
+		 produced a string with the wrong number of "%s"s.  */
+	      char *yyp = yymsg;
+	      int yyi = 0;
+	      while ((*yyp = *yyf))
+		{
+		  if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
+		    {
+		      yyp += yytnamerr (yyp, yyarg[yyi++]);
+		      yyf += 2;
+		    }
+		  else
+		    {
+		      yyp++;
+		      yyf++;
+		    }
+		}
+	      yyerror (yymsg);
+	      YYSTACK_FREE (yymsg);
+	    }
+	  else
+	    {
+	      yyerror (YY_("syntax error"));
+	      goto yyexhaustedlab;
+	    }
+	}
+      else
+#endif /* YYERROR_VERBOSE */
+	yyerror (YY_("syntax error"));
+    }
+
+
+
+  if (yyerrstatus == 3)
+    {
+      /* If just tried and failed to reuse look-ahead token after an
+	 error, discard it.  */
+
+      if (yychar <= YYEOF)
+        {
+	  /* Return failure if at end of input.  */
+	  if (yychar == YYEOF)
+	    YYABORT;
+        }
+      else
+	{
+	  yydestruct ("Error: discarding", yytoken, &yylval);
+	  yychar = YYEMPTY;
+	}
+    }
+
+  /* Else will try to reuse look-ahead token after shifting the error
+     token.  */
+  goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR.  |
+`---------------------------------------------------*/
+yyerrorlab:
+
+  /* Pacify compilers like GCC when the user code never invokes
+     YYERROR and the label yyerrorlab therefore never appears in user
+     code.  */
+  if (0)
+     goto yyerrorlab;
+
+yyvsp -= yylen;
+  yyssp -= yylen;
+  yystate = *yyssp;
+  goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR.  |
+`-------------------------------------------------------------*/
+yyerrlab1:
+  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
+
+  for (;;)
+    {
+      yyn = yypact[yystate];
+      if (yyn != YYPACT_NINF)
+	{
+	  yyn += YYTERROR;
+	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+	    {
+	      yyn = yytable[yyn];
+	      if (0 < yyn)
+		break;
+	    }
+	}
+
+      /* Pop the current state because it cannot handle the error token.  */
+      if (yyssp == yyss)
+	YYABORT;
+
+
+      yydestruct ("Error: popping", yystos[yystate], yyvsp);
+      YYPOPSTACK;
+      yystate = *yyssp;
+      YY_STACK_PRINT (yyss, yyssp);
+    }
+
+  if (yyn == YYFINAL)
+    YYACCEPT;
+
+  *++yyvsp = yylval;
+
+
+  /* Shift the error token. */
+  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+  yystate = yyn;
+  goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here.  |
+`-------------------------------------*/
+yyacceptlab:
+  yyresult = 0;
+  goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here.  |
+`-----------------------------------*/
+yyabortlab:
+  yyresult = 1;
+  goto yyreturn;
+
+#ifndef yyoverflow
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here.  |
+`-------------------------------------------------*/
+yyexhaustedlab:
+  yyerror (YY_("memory exhausted"));
+  yyresult = 2;
+  /* Fall through.  */
+#endif
+
+yyreturn:
+  if (yychar != YYEOF && yychar != YYEMPTY)
+     yydestruct ("Cleanup: discarding lookahead",
+		 yytoken, &yylval);
+  while (yyssp != yyss)
+    {
+      yydestruct ("Cleanup: popping",
+		  yystos[*yyssp], yyvsp);
+      YYPOPSTACK;
+    }
+#ifndef yyoverflow
+  if (yyss != yyssa)
+    YYSTACK_FREE (yyss);
+#endif
+  return yyresult;
+}
+
+
+#line 821 "ftpcmd.y"
+
+
+extern jmp_buf errcatch;
+
+
+
+
+
+//static void	 help __P((struct tab *, char *));
+static struct tab *
+		 lookup __P((struct tab *, char *));
+//static void	 sizecmd __P((char *));
+static int	 yylex __P((void));
+
+static struct tab *lookup(struct tab *p, char *cmd)
+{
+
+	for (; p->name != NULL; p++)
+		if (strcmp(cmd, p->name) == 0)
+			return (p);
+	return (0);
+}
+
+#include <arpa/telnet.h>
+
+/*
+ * getline - a hacked up version of fgets to ignore TELNET escape codes.
+ */
+char * ftpd_getline(char *s, int n, FILE *iop)
+{
+	int c;
+	register char *cs;
+
+	cs = s;
+/* tmpline may contain saved command from urgent mode interruption */
+	for (c = 0; tmpline[c] != '\0' && --n > 0; ++c) {
+		*cs++ = tmpline[c];
+		if (tmpline[c] == '\n') {
+			*cs++ = '\0';
+//			if (debug)
+//				syslog(LOG_DEBUG, "command: %s", s);
+			tmpline[0] = '\0';
+			return(s);
+		}
+		if (c == 0)
+			tmpline[0] = '\0';
+	}
+	while ((c = getc(iop)) != EOF) {
+		c &= 0377;
+		if (c == IAC) {
+		    if ((c = getc(iop)) != EOF) {
+			c &= 0377;
+			switch (c) {
+			case WILL:
+			case WONT:
+				c = getc(iop);
+				printf("%c%c%c", IAC, DONT, 0377&c);
+				(void) fflush(stdout);
+				continue;
+			case DO:
+			case DONT:
+				c = getc(iop);
+				printf("%c%c%c", IAC, WONT, 0377&c);
+				(void) fflush(stdout);
+				continue;
+			case IAC:
+				break;
+			default:
+				continue;	/* ignore command */
+			}
+		    }
+		}
+		*cs++ = c;
+		if (--n <= 0 || c == '\n')
+			break;
+	}
+	if (c == EOF && cs == s)
+		return (NULL);
+	*cs++ = '\0';
+	if (debug) {
+		if (!guest && strncasecmp("pass ", s, 5) == 0) {
+			/* Don't syslog passwords */
+			//syslog(LOG_DEBUG, "command: %.5s ???", s);
+		} else {
+			register char *cp;
+			register int len;
+
+			/* Don't syslog trailing CR-LF */
+			len = strlen(s);
+			cp = s + len - 1;
+			while (cp >= s && (*cp == '\n' || *cp == '\r')) {
+				--cp;
+				--len;
+			}
+			//syslog(LOG_DEBUG, "command: %.*s", len, s);
+		}
+	}
+	return (s);
+}
+
+void toolong(int signo)
+{
+	(void)signo;
+
+	reply(421,
+	    "Timeout (%d seconds): closing control connection.", timeout);
+//	if (logging)
+//		syslog(LOG_INFO, "User %s timed out after %d seconds",
+//		    (pw ? pw -> pw_name : "unknown"), timeout);
+	dologout(1);
+}
+
+static int yylex(void)
+{
+	static int cpos, state;
+	char *cp, *cp2;
+	struct tab *p;
+	int n, value;
+	char c;
+
+	for (;;) {
+		switch (state) {
+
+		case CMD:
+			//(void) signal(SIGALRM, toolong);
+			//(void) alarm((unsigned) timeout);
+			if (ftpd_getline(cbuf, sizeof(cbuf)-1, stdin)==NULL) {
+				reply(221, "You could at least say goodbye.");
+				dologout(0);
+			}
+			//(void) alarm(0);
+			cp = strchr(cbuf, '\r');
+			if (cp) {
+				*cp++ = '\n';
+				*cp = '\0';
+			}
+#ifdef HASSETPROCTITLE
+			if (strncasecmp(cbuf, "PASS", 4) != 0) {
+				cp = strpbrk(cbuf, "\n");
+				if (cp) {
+					c = *cp;
+					*cp = '\0';
+					setproctitle("%s: %s", proctitle, cbuf);
+					*cp = c;
+				}
+			}
+#endif /* HASSETPROCTITLE */
+			cp = strpbrk(cbuf, " \n");
+			if (cp)
+				cpos = cp - cbuf;
+			if (cpos == 0)
+				cpos = 4;
+			c = cbuf[cpos];
+			cbuf[cpos] = '\0';
+			upper(cbuf);
+			p = lookup(cmdtab, cbuf);
+			cbuf[cpos] = c;
+			if (p != 0) {
+				if (p->implemented == 0) {
+					nack(p->name);
+					longjmp(errcatch,0);
+					/* NOTREACHED */
+				}
+				state = p->state;
+				yylval.s = (char *)p->name;  /* XXX */
+				return (p->token);
+			}
+			break;
+
+		case SITECMD:
+			if (cbuf[cpos] == ' ') {
+				cpos++;
+				return (SP);
+			}
+			cp = &cbuf[cpos];
+			cp2 = strpbrk(cp, " \n");
+			if (cp2)
+				cpos = cp2 - cbuf;
+			c = cbuf[cpos];
+			cbuf[cpos] = '\0';
+			upper(cp);
+			p = lookup(sitetab, cp);
+			cbuf[cpos] = c;
+			if (p != 0) {
+				if (p->implemented == 0) {
+					state = CMD;
+					nack(p->name);
+					longjmp(errcatch,0);
+					/* NOTREACHED */
+				}
+				state = p->state;
+				yylval.s = (char *) p->name;  /* XXX */
+				return (p->token);
+			}
+			state = CMD;
+			break;
+
+		case OSTR:
+			if (cbuf[cpos] == '\n') {
+				state = CMD;
+				return (CRLF);
+			}
+			/* FALLTHROUGH */
+
+		case STR1:
+		case ZSTR1:
+		dostr1:
+			if (cbuf[cpos] == ' ') {
+				cpos++;
+				/* DOH!!! who wrote this?
+				 * state = ++state; is undefined in C!
+				 * state = state == OSTR ? STR2 : ++state;
+				 * looks elegant but not correct, adding 'value'
+				 */
+				value = state == OSTR ? STR2 : ++state;
+				state = value;
+				return (SP);
+			}
+			break;
+
+		case ZSTR2:
+			if (cbuf[cpos] == '\n') {
+				state = CMD;
+				return (CRLF);
+			}
+			/* FALLTHROUGH */
+
+		case STR2:
+			cp = &cbuf[cpos];
+			n = strlen(cp);
+			cpos += n - 1;
+			/*
+			 * Make sure the string is nonempty and \n terminated.
+			 */
+			if (n > 1 && cbuf[cpos] == '\n') {
+				cbuf[cpos] = '\0';
+				yylval.s = strdup(cp);
+				if (yylval.s == NULL)
+					fatal("Ran out of memory.");
+				cbuf[cpos] = '\n';
+				state = ARGS;
+				return (STRING);
+			}
+			break;
+
+		case NSTR:
+			if (cbuf[cpos] == ' ') {
+				cpos++;
+				return (SP);
+			}
+			if (isdigit(cbuf[cpos])) {
+				cp = &cbuf[cpos];
+				while (isdigit(cbuf[++cpos]))
+					;
+				c = cbuf[cpos];
+				cbuf[cpos] = '\0';
+				yylval.i = atoi(cp);
+				cbuf[cpos] = c;
+				state = STR1;
+				return (NUMBER);
+			}
+			state = STR1;
+			goto dostr1;
+
+		case ARGS:
+			if (isdigit(cbuf[cpos])) {
+				cp = &cbuf[cpos];
+				while (isdigit(cbuf[++cpos]))
+					;
+				c = cbuf[cpos];
+				cbuf[cpos] = '\0';
+				yylval.i = atoi(cp);
+				cbuf[cpos] = c;
+				return (NUMBER);
+			}
+			switch (cbuf[cpos++]) {
+
+			case '\n':
+				state = CMD;
+				return (CRLF);
+
+			case ' ':
+				return (SP);
+
+			case ',':
+				return (COMMA);
+
+			case 'A':
+			case 'a':
+				return (A);
+
+			case 'B':
+			case 'b':
+				return (B);
+
+			case 'C':
+			case 'c':
+				return (C);
+
+			case 'E':
+			case 'e':
+				return (E);
+
+			case 'F':
+			case 'f':
+				return (F);
+
+			case 'I':
+			case 'i':
+				return (I);
+
+			case 'L':
+			case 'l':
+				return (L);
+
+			case 'N':
+			case 'n':
+				return (N);
+
+			case 'P':
+			case 'p':
+				return (P);
+
+			case 'R':
+			case 'r':
+				return (R);
+
+			case 'S':
+			case 's':
+				return (S);
+
+			case 'T':
+			case 't':
+				return (T);
+
+			}
+			break;
+
+		default:
+			fatal("Unknown state in scanner.");
+		}
+		yyerror((char *) 0);
+		state = CMD;
+		longjmp(errcatch,0);
+	}
+}
+
+void upper(char *s)
+{
+	while (*s != '\0') {
+		if (islower(*s))
+			*s = toupper(*s);
+		s++;
+	}
+}
+
+
+static void help(struct tab *ctab, char *s)
+{
+	struct tab *c;
+	int width, NCMDS;
+	const char *type;
+
+	if (ctab == sitetab)
+		type = "SITE ";
+	else
+		type = "";
+	width = 0, NCMDS = 0;
+	for (c = ctab; c->name != NULL; c++) {
+		int len = strlen(c->name);
+
+		if (len > width)
+			width = len;
+		NCMDS++;
+	}
+	width = (width + 8) &~ 7;
+	if (s == 0) {
+		int i, j, w;
+		int columns, lines;
+
+		lreply(214, "The following %scommands are recognized %s.",
+		    type, "(* =>'s unimplemented)");
+		columns = 76 / width;
+		if (columns == 0)
+			columns = 1;
+		lines = (NCMDS + columns - 1) / columns;
+		for (i = 0; i < lines; i++) {
+			printf("   ");
+			for (j = 0; j < columns; j++) {
+				c = ctab + j * lines + i;
+				printf("%s%c", c->name,
+					c->implemented ? ' ' : '*');
+				if (c + lines >= &ctab[NCMDS])
+					break;
+				w = strlen(c->name) + 1;
+				while (w < width) {
+					putchar(' ');
+					w++;
+				}
+			}
+			printf("\r\n");
+		}
+		(void) fflush(stdout);
+		reply(214, "Direct comments to ftp-bugs@%s.", hostname);
+		return;
+	}
+	upper(s);
+	c = lookup(ctab, s);
+	if (c == (struct tab *)0) {
+		reply(502, "Unknown command %s.", s);
+		return;
+	}
+	if (c->implemented)
+		reply(214, "Syntax: %s%s %s", type, c->name, c->help);
+	else
+		reply(214, "%s%-*s\t%s; unimplemented.", type, width,
+		    c->name, c->help);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/src/ftpcmd.y	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1374 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/*
+ * Copyright (c) 1985, 1988, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)ftpcmd.y	8.3 (Berkeley) 4/6/94
+ *	NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp
+ *	OpenBSD: ftpcmd.y,v 1.16 1998/05/22 06:46:09 deraadt Exp
+ */
+
+/*
+ * Grammar for FTP commands.
+ * See RFC 959.
+ */
+
+%{
+
+char ftpcmd_rcsid[] = 
+  "$Id: ftpcmd.y,v 1.11 1999/10/09 02:32:12 dholland Exp $";
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+
+#include <netinet/in.h>
+#include <arpa/ftp.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <glob.h>
+#include <pwd.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <time.h>
+#include <unistd.h>
+
+#ifndef __linux__
+#include <tzfile.h>
+#else
+#define TM_YEAR_BASE 1900
+#endif
+
+#include "extern.h"
+
+extern	struct sockaddr_in data_dest;
+extern	int logged_in;
+extern	struct passwd *pw;
+extern	int guest;
+extern	int logging;
+extern	int type;
+extern	int form;
+extern	int debug;
+extern	int timeout;
+extern	int maxtimeout;
+extern  int pdata;
+extern	char hostname[], remotehost[];
+extern	char proctitle[];
+extern	int usedefault;
+extern  int transflag;
+extern  char tmpline[];
+extern	int portcheck;
+extern	struct sockaddr_in his_addr;
+
+off_t	restart_point;
+
+static	int cmd_type;
+static	int cmd_form;
+static	int cmd_bytesz;
+char	cbuf[512];
+char	*fromname;
+
+struct tab;
+static int	 yylex __P((void));
+//static void	 sizecmd __P((char *));
+static void	 help __P((struct tab *, char *));
+
+extern struct tab cmdtab[];
+extern struct tab sitetab[];
+
+%}
+
+%union {
+	int	i;
+	char   *s;
+}
+
+%token
+	A	B	C	E	F	I
+	L	N	P	R	S	T
+
+	SP	CRLF	COMMA
+
+	USER	PASS	ACCT	REIN	QUIT	PORT
+	PASV	TYPE	STRU	MODE	RETR	STOR
+	APPE	MLFL	MAIL	MSND	MSOM	MSAM
+	MRSQ	MRCP	ALLO	REST	RNFR	RNTO
+	ABOR	DELE	CWD	LIST	NLST	SITE
+	STAT	HELP	NOOP	MKD	RMD	PWD
+	CDUP	STOU	SMNT	SYST	SIZE	MDTM
+
+	UMASK	IDLE	CHMOD
+
+	LEXERR
+
+%token	<s> STRING
+%token	<i> NUMBER
+
+%type	<i> check_login octal_number byte_size
+%type	<i> struct_code mode_code type_code form_code
+%type	<s> pathstring pathname password username
+%type	<i> host_port
+
+%start	cmd_list
+
+%%
+
+cmd_list
+	: /* empty */
+	| cmd_list cmd
+		{
+			fromname = (char *) 0;
+			restart_point = (off_t) 0;
+		}
+	| cmd_list rcmd
+	;
+
+cmd
+	: USER SP username CRLF
+		{
+			user($3);
+			free($3);
+		}
+	| PASS SP password CRLF
+		{
+			pass($3);
+			memset($3, 0, strlen($3));
+			free($3);
+		}
+	| PORT check_login SP host_port CRLF
+		{
+			if ($2) {
+				if ($4) {
+					usedefault = 1;
+					reply(500,	
+					    "Illegal PORT rejected (range errors).");
+				} else if (portcheck &&
+				    ntohs(data_dest.sin_port) < IPPORT_RESERVED) {
+					usedefault = 1;
+					reply(500,
+					    "Illegal PORT rejected (reserved port).");
+				} else if (portcheck &&
+				    memcmp(&data_dest.sin_addr,
+				    &his_addr.sin_addr,
+				    sizeof data_dest.sin_addr)) {
+					usedefault = 1;
+					reply(500,
+					    "Illegal PORT rejected (address wrong).");
+				} else {
+					usedefault = 0;
+					if (pdata >= 0) {
+						(void) close(pdata);
+						pdata = -1;
+					}
+					reply(200, "PORT command successful.");
+				}
+			}
+		}
+	| PASV check_login CRLF
+		{
+			if ($2) {
+				passive();
+			}
+		}
+	| TYPE check_login SP type_code CRLF
+		{
+			if ($2) {
+				switch (cmd_type) {
+
+				case TYPE_A:
+					if (cmd_form == FORM_N) {
+						reply(200, "Type set to A.");
+						type = cmd_type;
+						form = cmd_form;
+					} else
+						reply(504, "Form must be N.");
+					break;
+
+				case TYPE_E:
+					reply(504, "Type E not implemented.");
+					break;
+	
+				case TYPE_I:
+					reply(200, "Type set to I.");
+					type = cmd_type;
+					break;
+
+				case TYPE_L:
+					if (cmd_bytesz == 8) {
+					       reply(200,
+					       "Type set to L (byte size 8).");
+					       type = cmd_type;
+					} else
+					    reply(504, "Byte size must be 8.");
+
+				}
+			}
+		}
+	| STRU check_login SP struct_code CRLF
+		{
+			if ($2) {
+				switch ($4) {
+
+				case STRU_F:
+					reply(200, "STRU F ok.");
+					break;
+
+				default:
+					reply(504, "Unimplemented STRU type.");
+				}
+			}
+		}
+	| MODE check_login SP mode_code CRLF
+		{
+			if ($2) {
+				switch ($4) {
+
+				case MODE_S:
+					reply(200, "MODE S ok.");
+					break;
+
+				default:
+					reply(502, "Unimplemented MODE type.");
+				}
+			}
+		}
+	| ALLO check_login SP NUMBER CRLF
+		{
+			if ($2) {
+				reply(202, "ALLO command ignored.");
+			}
+		}
+	| ALLO check_login SP NUMBER SP R SP NUMBER CRLF
+		{
+			if ($2) {
+				reply(202, "ALLO command ignored.");
+			}
+		}
+	| RETR check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL)
+				retrieve((char *) 0, $4);
+			if ($4 != NULL)
+				free($4);
+		}
+	| STOR check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL)
+				store($4, "w", 0);
+			if ($4 != NULL)
+				free($4);
+		}
+	| APPE check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL)
+				store($4, "a", 0);
+			if ($4 != NULL)
+				free($4);
+		}
+	| NLST check_login CRLF
+		{
+			if ($2)
+				send_file_list(".",1);
+		}
+	| NLST check_login SP STRING CRLF
+		{
+			if ($2 && $4 != NULL)
+				send_file_list($4,1);
+			if ($4 != NULL)
+				free($4);
+		}
+	| LIST check_login CRLF
+		{
+			if ($2)
+				send_file_list(".",0);
+				//retrieve("/bin/ls -lgA", "");
+		}
+	| LIST check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL)
+				send_file_list($4,0);
+				//retrieve("/bin/ls -lgA %s", $4);
+			if ($4 != NULL)
+				free($4);
+		}
+	| STAT check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL)
+				statfilecmd($4);
+			if ($4 != NULL)
+				free($4);
+		}
+	| STAT check_login CRLF
+		{
+			if ($2)
+				statcmd();
+		}
+	| DELE check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL)
+				dele($4);
+			if ($4 != NULL)
+				free($4);
+		}
+	| RNTO check_login SP pathname CRLF
+		{
+			if ($2) {
+				if (fromname) {
+					renamecmd(fromname, $4);
+					free(fromname);
+					fromname = (char *) 0;
+				} else {
+					reply(503, 
+					  "Bad sequence of commands.");
+				}
+			}
+			free($4);
+		}
+	| ABOR check_login CRLF
+		{
+			if ($2) 
+				reply(225, "ABOR command successful.");
+		}
+	| CWD check_login CRLF
+		{
+			if ($2)
+				cwd(pw->pw_dir);
+		}
+	| CWD check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL)
+				cwd($4);
+			if ($4 != NULL)
+				free($4);
+		}
+	| HELP CRLF
+		{
+			help(cmdtab, (char *) 0);
+		}
+	| HELP SP STRING CRLF
+		{
+			char *cp = $3;
+
+			if (strncasecmp(cp, "SITE", 4) == 0) {
+				cp = $3 + 4;
+				if (*cp == ' ')
+					cp++;
+				if (*cp)
+					help(sitetab, cp);
+				else
+					help(sitetab, (char *) 0);
+			} else
+				help(cmdtab, $3);
+
+			if ($3 != NULL)
+				free ($3);
+		}
+	| NOOP CRLF
+		{
+			reply(200, "NOOP command successful.");
+		}
+	| MKD check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL)
+				makedir($4);
+			if ($4 != NULL)
+				free($4);
+		}
+	| RMD check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL)
+				removedir($4);
+			if ($4 != NULL)
+				free($4);
+		}
+	| PWD check_login CRLF
+		{
+			if ($2)
+				pwd();
+		}
+	| CDUP check_login CRLF
+		{
+			if ($2)
+				cwd("..");
+		}
+	| SITE SP HELP CRLF
+		{
+			help(sitetab, (char *) 0);
+		}
+	| SITE SP HELP SP STRING CRLF
+		{
+			help(sitetab, $5);
+
+			if ($5 != NULL)
+				free ($5);
+		}
+	| SITE SP UMASK check_login CRLF
+		{
+			int oldmask;
+
+			if ($4) {
+				oldmask = umask(0);
+				(void) umask(oldmask);
+				reply(200, "Current UMASK is %03o", oldmask);
+			}
+		}
+	| SITE SP UMASK check_login SP octal_number CRLF
+		{
+			int oldmask;
+
+			if ($4) {
+				if (($6 == -1) || ($6 > 0777)) {
+					reply(501, "Bad UMASK value");
+				} else {
+					oldmask = umask($6);
+					reply(200,
+					    "UMASK set to %03o (was %03o)",
+					    $6, oldmask);
+				}
+			}
+		}
+	| SITE SP CHMOD check_login SP octal_number SP pathname CRLF
+		{
+			if ($4 && ($8 != NULL)) {
+				if ($6 > 0777)
+					reply(501,
+				"CHMOD: Mode value must be between 0 and 0777");
+				else if (chmod($8, $6) < 0)
+					perror_reply(550, $8);
+				else
+					reply(200, "CHMOD command successful.");
+			}
+			if ($8 != NULL)
+				free($8);
+		}
+	| SITE SP check_login IDLE CRLF
+		{
+			if ($3)
+			  reply(200,
+	       		    "Current IDLE time limit is %d seconds; max %d",
+				timeout, maxtimeout);
+		}
+	| SITE SP check_login IDLE SP NUMBER CRLF
+		{
+			if ($3) {
+				if ($6 < 30 || $6 > maxtimeout) {
+				reply(501,
+	       		 "Maximum IDLE time must be between 30 and %d seconds",
+				    maxtimeout);
+				} else {
+					timeout = $6;
+					(void) alarm((unsigned) timeout);
+					reply(200,
+					 "Maximum IDLE time set to %d seconds",
+					    timeout);
+				}
+			}
+		}
+	| STOU check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL)
+				store($4, "w", 1);
+			if ($4 != NULL)
+				free($4);
+		}
+	| SYST check_login CRLF
+		{
+			if ($2)
+#ifdef __linux__
+			reply(215, "UNIX Type: L%d (Linux)", CHAR_BIT);
+#else
+#ifdef unix
+#ifdef BSD
+			reply(215, "UNIX Type: L%d Version: BSD-%d",
+				CHAR_BIT, BSD);
+#else /* BSD */
+			reply(215, "UNIX Type: L%d", CHAR_BIT);
+#endif /* BSD */
+#else /* unix */
+#ifdef __SYMBIAN32__		
+			reply(215, "UNIX Type: L%d", CHAR_BIT);
+#else
+			reply(215, "UNKNOWN Type: L%d", CHAR_BIT);
+#endif /* __symbian32__ */	
+#endif /* unix */
+#endif /* __linux__ */
+		}
+
+		/*
+		 * SIZE is not in RFC959, but Postel has blessed it and
+		 * it will be in the updated RFC.
+		 *
+		 * Return size of file in a format suitable for
+		 * using with RESTART (we just count bytes).
+		 */
+	| SIZE check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL)
+				sizecmd($4);
+			if ($4 != NULL)
+				free($4);
+		}
+
+		/*
+		 * MDTM is not in RFC959, but Postel has blessed it and
+		 * it will be in the updated RFC.
+		 *
+		 * Return modification time of file as an ISO 3307
+		 * style time. E.g. YYYYMMDDHHMMSS or YYYYMMDDHHMMSS.xxx
+		 * where xxx is the fractional second (of any precision,
+		 * not necessarily 3 digits)
+		 */
+	| MDTM check_login SP pathname CRLF
+		{
+			if ($2 && $4 != NULL) {
+				struct stat stbuf;
+				if (stat($4, &stbuf) < 0)
+					reply(550, "%s: %s",
+					    $4, strerror(errno));
+				else if (!S_ISREG(stbuf.st_mode)) {
+					reply(550, "%s: not a plain file.", $4);
+				} else {
+					struct tm *t;
+					t = gmtime(&stbuf.st_mtime);
+					reply(213,
+					    "%04d%02d%02d%02d%02d%02d",
+					    TM_YEAR_BASE + t->tm_year,
+					    t->tm_mon+1, t->tm_mday,
+					    t->tm_hour, t->tm_min, t->tm_sec);
+				}
+			}
+			if ($4 != NULL)
+				free($4);
+		}
+	| QUIT CRLF
+		{
+			reply(221, "Goodbye.");
+			dologout(0);
+		}
+	| error CRLF
+		{
+			yyerrok;
+		}
+	;
+rcmd
+	: RNFR check_login SP pathname CRLF
+		{
+			restart_point = (off_t) 0;
+			if ($2 && $4) {
+				fromname = renamefrom($4);
+				if (fromname == (char *) 0 && $4) {
+					free($4);
+				}
+			} else {
+				if ($4)
+					free ($4);
+			}
+		}
+
+	| REST check_login SP byte_size CRLF
+		{
+			if ($2) {
+			    fromname = (char *) 0;
+			    restart_point = $4;	/* XXX $4 is only "int" */
+			    reply(350, "Restarting at %qd. %s", 
+			       (quad_t) restart_point,
+			       "Send STORE or RETRIEVE to initiate transfer.");
+			}
+		}
+	;
+
+username
+	: STRING
+	;
+
+password
+	: /* empty */
+		{
+			$$ = (char *)calloc(1, sizeof(char));
+		}
+	| STRING
+	;
+
+byte_size
+	: NUMBER
+	;
+
+host_port
+	: NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA
+		NUMBER COMMA NUMBER
+		{
+			char *a, *p;
+
+			if ($1 < 0 || $1 > 255 || $3 < 0 || $3 > 255 ||
+			    $5 < 0 || $5 > 255 || $7 < 0 || $7 > 255 ||
+			    $9 < 0 || $9 > 255 || $11 < 0 || $11 > 255) {
+				$$ = 1;
+			} else {
+#ifndef __linux__
+				data_dest.sin_len = sizeof(struct sockaddr_in);
+#endif
+				data_dest.sin_family = AF_INET;
+				p = (char *)&data_dest.sin_port;
+				p[0] = $9; p[1] = $11;
+				a = (char *)&data_dest.sin_addr;
+				a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7;
+				$$ = 0;
+			}
+		}
+	;
+
+form_code
+	: N
+		{
+			$$ = FORM_N;
+		}
+	| T
+		{
+			$$ = FORM_T;
+		}
+	| C
+		{
+			$$ = FORM_C;
+		}
+	;
+
+type_code
+	: A
+		{
+			cmd_type = TYPE_A;
+			cmd_form = FORM_N;
+		}
+	| A SP form_code
+		{
+			cmd_type = TYPE_A;
+			cmd_form = $3;
+		}
+	| E
+		{
+			cmd_type = TYPE_E;
+			cmd_form = FORM_N;
+		}
+	| E SP form_code
+		{
+			cmd_type = TYPE_E;
+			cmd_form = $3;
+		}
+	| I
+		{
+			cmd_type = TYPE_I;
+		}
+	| L
+		{
+			cmd_type = TYPE_L;
+			cmd_bytesz = CHAR_BIT;
+		}
+	| L SP byte_size
+		{
+			cmd_type = TYPE_L;
+			cmd_bytesz = $3;
+		}
+		/* this is for a bug in the BBN ftp */
+	| L byte_size
+		{
+			cmd_type = TYPE_L;
+			cmd_bytesz = $2;
+		}
+	;
+
+struct_code
+	: F
+		{
+			$$ = STRU_F;
+		}
+	| R
+		{
+			$$ = STRU_R;
+		}
+	| P
+		{
+			$$ = STRU_P;
+		}
+	;
+
+mode_code
+	: S
+		{
+			$$ = MODE_S;
+		}
+	| B
+		{
+			$$ = MODE_B;
+		}
+	| C
+		{
+			$$ = MODE_C;
+		}
+	;
+
+pathname
+	: pathstring
+		{
+			/*
+			 * Problem: this production is used for all pathname
+			 * processing, but only gives a 550 error reply.
+			 * This is a valid reply in some cases but not in others.
+			 */
+			if (logged_in && $1 && strchr($1, '~') != NULL) {
+				glob_t gl;
+#ifdef __linux__
+				/* see popen.c */
+				int flags = GLOB_NOCHECK;
+#else
+				int flags =
+				 GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE;
+#endif
+				char *pptr = $1;
+
+				/*
+				 * glob() will only find a leading ~, but
+				 * Netscape kindly puts a slash in front of
+				 * it for publish URLs.  There needs to be
+				 * a flag for glob() that expands tildes
+				 * anywhere in the string.
+				 */
+				if ((pptr[0] == '/') && (pptr[1] == '~'))
+					pptr++;
+
+				memset(&gl, 0, sizeof(gl));
+				if (glob(pptr, flags, NULL, &gl) ||
+				    gl.gl_pathc == 0) {
+					reply(550, "not found");
+					$$ = NULL;
+				} else {
+					$$ = strdup(gl.gl_pathv[0]);
+				}
+				globfree(&gl);
+				free($1);
+			} else
+				$$ = $1;
+		}
+	;
+
+pathstring
+	: STRING
+	;
+
+octal_number
+	: NUMBER
+		{
+			int ret, dec, multby, digit;
+
+			/*
+			 * Convert a number that was read as decimal number
+			 * to what it would be if it had been read as octal.
+			 */
+			dec = $1;
+			multby = 1;
+			ret = 0;
+			while (dec) {
+				digit = dec%10;
+				if (digit > 7) {
+					ret = -1;
+					break;
+				}
+				ret += digit * multby;
+				multby *= 8;
+				dec /= 10;
+			}
+			$$ = ret;
+		}
+	;
+
+
+check_login
+	: /* empty */
+		{
+			if (logged_in)
+				$$ = 1;
+			else {
+				reply(530, "Please login with USER and PASS.");
+				$$ = 0;
+			}
+		}
+	;
+
+%%
+
+extern jmp_buf errcatch;
+
+#define	CMD	0	/* beginning of command */
+#define	ARGS	1	/* expect miscellaneous arguments */
+#define	STR1	2	/* expect SP followed by STRING */
+#define	STR2	3	/* expect STRING */
+#define	OSTR	4	/* optional SP then STRING */
+#define	ZSTR1	5	/* SP then optional STRING */
+#define	ZSTR2	6	/* optional STRING after SP */
+#define	SITECMD	7	/* SITE command */
+#define	NSTR	8	/* Number followed by a string */
+
+struct tab {
+	const char	*name;
+	short	token;
+	short	state;
+	short	implemented;	/* 1 if command is implemented */
+	const char	*help;
+};
+
+struct tab cmdtab[] = {		/* In order defined in RFC 765 */
+	{ "USER", USER, STR1, 1,	"<sp> username" },
+	{ "PASS", PASS, ZSTR1, 1,	"<sp> password" },
+	{ "ACCT", ACCT, STR1, 0,	"(specify account)" },
+	{ "SMNT", SMNT, ARGS, 0,	"(structure mount)" },
+	{ "REIN", REIN, ARGS, 0,	"(reinitialize server state)" },
+	{ "QUIT", QUIT, ARGS, 1,	"(terminate service)", },
+	{ "PORT", PORT, ARGS, 1,	"<sp> b0, b1, b2, b3, b4" },
+	{ "PASV", PASV, ARGS, 1,	"(set server in passive mode)" },
+	{ "TYPE", TYPE, ARGS, 1,	"<sp> [ A | E | I | L ]" },
+	{ "STRU", STRU, ARGS, 1,	"(specify file structure)" },
+	{ "MODE", MODE, ARGS, 1,	"(specify transfer mode)" },
+	{ "RETR", RETR, STR1, 1,	"<sp> file-name" },
+	{ "STOR", STOR, STR1, 1,	"<sp> file-name" },
+	{ "APPE", APPE, STR1, 1,	"<sp> file-name" },
+	{ "MLFL", MLFL, OSTR, 0,	"(mail file)" },
+	{ "MAIL", MAIL, OSTR, 0,	"(mail to user)" },
+	{ "MSND", MSND, OSTR, 0,	"(mail send to terminal)" },
+	{ "MSOM", MSOM, OSTR, 0,	"(mail send to terminal or mailbox)" },
+	{ "MSAM", MSAM, OSTR, 0,	"(mail send to terminal and mailbox)" },
+	{ "MRSQ", MRSQ, OSTR, 0,	"(mail recipient scheme question)" },
+	{ "MRCP", MRCP, STR1, 0,	"(mail recipient)" },
+	{ "ALLO", ALLO, ARGS, 1,	"allocate storage (vacuously)" },
+	{ "REST", REST, ARGS, 1,	"<sp> offset (restart command)" },
+	{ "RNFR", RNFR, STR1, 1,	"<sp> file-name" },
+	{ "RNTO", RNTO, STR1, 1,	"<sp> file-name" },
+	{ "ABOR", ABOR, ARGS, 1,	"(abort operation)" },
+	{ "DELE", DELE, STR1, 1,	"<sp> file-name" },
+	{ "CWD",  CWD,  OSTR, 1,	"[ <sp> directory-name ]" },
+	{ "XCWD", CWD,	OSTR, 1,	"[ <sp> directory-name ]" },
+	{ "LIST", LIST, OSTR, 1,	"[ <sp> path-name ]" },
+	{ "NLST", NLST, OSTR, 1,	"[ <sp> path-name ]" },
+	{ "SITE", SITE, SITECMD, 1,	"site-cmd [ <sp> arguments ]" },
+	{ "SYST", SYST, ARGS, 1,	"(get type of operating system)" },
+	{ "STAT", STAT, OSTR, 1,	"[ <sp> path-name ]" },
+	{ "HELP", HELP, OSTR, 1,	"[ <sp> <string> ]" },
+	{ "NOOP", NOOP, ARGS, 1,	"" },
+	{ "MKD",  MKD,  STR1, 1,	"<sp> path-name" },
+	{ "XMKD", MKD,  STR1, 1,	"<sp> path-name" },
+	{ "RMD",  RMD,  STR1, 1,	"<sp> path-name" },
+	{ "XRMD", RMD,  STR1, 1,	"<sp> path-name" },
+	{ "PWD",  PWD,  ARGS, 1,	"(return current directory)" },
+	{ "XPWD", PWD,  ARGS, 1,	"(return current directory)" },
+	{ "CDUP", CDUP, ARGS, 1,	"(change to parent directory)" },
+	{ "XCUP", CDUP, ARGS, 1,	"(change to parent directory)" },
+	{ "STOU", STOU, STR1, 1,	"<sp> file-name" },
+	{ "SIZE", SIZE, OSTR, 1,	"<sp> path-name" },
+	{ "MDTM", MDTM, OSTR, 1,	"<sp> path-name" },
+	{ NULL,   0,    0,    0,	0 }
+};
+
+struct tab sitetab[] = {
+	{ "UMASK", UMASK, ARGS, 1,	"[ <sp> umask ]" },
+	{ "IDLE", IDLE, ARGS, 1,	"[ <sp> maximum-idle-time ]" },
+	{ "CHMOD", CHMOD, NSTR, 1,	"<sp> mode <sp> file-name" },
+	{ "HELP", HELP, OSTR, 1,	"[ <sp> <string> ]" },
+	{ NULL,   0,    0,    0,	0 }
+};
+
+static void	 help __P((struct tab *, char *));
+static struct tab *
+		 lookup __P((struct tab *, char *));
+static void	 sizecmd __P((char *));
+static int	 yylex __P((void));
+
+static struct tab *lookup(struct tab *p, char *cmd)
+{
+
+	for (; p->name != NULL; p++)
+		if (strcmp(cmd, p->name) == 0)
+			return (p);
+	return (0);
+}
+
+#include <arpa/telnet.h>
+
+/*
+ * getline - a hacked up version of fgets to ignore TELNET escape codes.
+ */
+char * ftpd_getline(char *s, int n, FILE *iop)
+{
+	int c;
+	register char *cs;
+
+	cs = s;
+/* tmpline may contain saved command from urgent mode interruption */
+	for (c = 0; tmpline[c] != '\0' && --n > 0; ++c) {
+		*cs++ = tmpline[c];
+		if (tmpline[c] == '\n') {
+			*cs++ = '\0';
+			if (debug)
+				syslog(LOG_DEBUG, "command: %s", s);
+			tmpline[0] = '\0';
+			return(s);
+		}
+		if (c == 0)
+			tmpline[0] = '\0';
+	}
+	while ((c = getc(iop)) != EOF) {
+		c &= 0377;
+		if (c == IAC) {
+		    if ((c = getc(iop)) != EOF) {
+			c &= 0377;
+			switch (c) {
+			case WILL:
+			case WONT:
+				c = getc(iop);
+				printf("%c%c%c", IAC, DONT, 0377&c);
+				(void) fflush(stdout);
+				continue;
+			case DO:
+			case DONT:
+				c = getc(iop);
+				printf("%c%c%c", IAC, WONT, 0377&c);
+				(void) fflush(stdout);
+				continue;
+			case IAC:
+				break;
+			default:
+				continue;	/* ignore command */
+			}
+		    }
+		}
+		*cs++ = c;
+		if (--n <= 0 || c == '\n')
+			break;
+	}
+	if (c == EOF && cs == s)
+		return (NULL);
+	*cs++ = '\0';
+	if (debug) {
+		if (!guest && strncasecmp("pass ", s, 5) == 0) {
+			/* Don't syslog passwords */
+			syslog(LOG_DEBUG, "command: %.5s ???", s);
+		} else {
+			register char *cp;
+			register int len;
+
+			/* Don't syslog trailing CR-LF */
+			len = strlen(s);
+			cp = s + len - 1;
+			while (cp >= s && (*cp == '\n' || *cp == '\r')) {
+				--cp;
+				--len;
+			}
+			syslog(LOG_DEBUG, "command: %.*s", len, s);
+		}
+	}
+	return (s);
+}
+
+void toolong(int signo)
+{
+	(void)signo;
+
+	reply(421,
+	    "Timeout (%d seconds): closing control connection.", timeout);
+	if (logging)
+		syslog(LOG_INFO, "User %s timed out after %d seconds",
+		    (pw ? pw -> pw_name : "unknown"), timeout);
+	dologout(1);
+}
+
+static int yylex(void)
+{
+	static int cpos, state;
+	char *cp, *cp2;
+	struct tab *p;
+	int n, value;
+	char c;
+
+	for (;;) {
+		switch (state) {
+
+		case CMD:
+			(void) signal(SIGALRM, toolong);
+			(void) alarm((unsigned) timeout);
+			if (ftpd_getline(cbuf, sizeof(cbuf)-1, stdin)==NULL) {
+				reply(221, "You could at least say goodbye.");
+				dologout(0);
+			}
+			(void) alarm(0);
+			cp = strchr(cbuf, '\r');
+			if (cp) {
+				*cp++ = '\n';
+				*cp = '\0';
+			}
+#ifdef HASSETPROCTITLE
+			if (strncasecmp(cbuf, "PASS", 4) != 0) {
+				cp = strpbrk(cbuf, "\n");
+				if (cp) {
+					c = *cp;
+					*cp = '\0';
+					setproctitle("%s: %s", proctitle, cbuf);
+					*cp = c;
+				}
+			}
+#endif /* HASSETPROCTITLE */
+			cp = strpbrk(cbuf, " \n");
+			if (cp)
+				cpos = cp - cbuf;
+			if (cpos == 0)
+				cpos = 4;
+			c = cbuf[cpos];
+			cbuf[cpos] = '\0';
+			upper(cbuf);
+			p = lookup(cmdtab, cbuf);
+			cbuf[cpos] = c;
+			if (p != 0) {
+				if (p->implemented == 0) {
+					nack(p->name);
+					longjmp(errcatch,0);
+					/* NOTREACHED */
+				}
+				state = p->state;
+				yylval.s = (char *)p->name;  /* XXX */
+				return (p->token);
+			}
+			break;
+
+		case SITECMD:
+			if (cbuf[cpos] == ' ') {
+				cpos++;
+				return (SP);
+			}
+			cp = &cbuf[cpos];
+			cp2 = strpbrk(cp, " \n");
+			if (cp2)
+				cpos = cp2 - cbuf;
+			c = cbuf[cpos];
+			cbuf[cpos] = '\0';
+			upper(cp);
+			p = lookup(sitetab, cp);
+			cbuf[cpos] = c;
+			if (p != 0) {
+				if (p->implemented == 0) {
+					state = CMD;
+					nack(p->name);
+					longjmp(errcatch,0);
+					/* NOTREACHED */
+				}
+				state = p->state;
+				yylval.s = (char *) p->name;  /* XXX */
+				return (p->token);
+			}
+			state = CMD;
+			break;
+
+		case OSTR:
+			if (cbuf[cpos] == '\n') {
+				state = CMD;
+				return (CRLF);
+			}
+			/* FALLTHROUGH */
+
+		case STR1:
+		case ZSTR1:
+		dostr1:
+			if (cbuf[cpos] == ' ') {
+				cpos++;
+				/* DOH!!! who wrote this?
+				 * state = ++state; is undefined in C!
+				 * state = state == OSTR ? STR2 : ++state;
+				 * looks elegant but not correct, adding 'value'
+				 */
+				value = state == OSTR ? STR2 : ++state;
+				state = value;
+				return (SP);
+			}
+			break;
+
+		case ZSTR2:
+			if (cbuf[cpos] == '\n') {
+				state = CMD;
+				return (CRLF);
+			}
+			/* FALLTHROUGH */
+
+		case STR2:
+			cp = &cbuf[cpos];
+			n = strlen(cp);
+			cpos += n - 1;
+			/*
+			 * Make sure the string is nonempty and \n terminated.
+			 */
+			if (n > 1 && cbuf[cpos] == '\n') {
+				cbuf[cpos] = '\0';
+				yylval.s = strdup(cp);
+				if (yylval.s == NULL)
+					fatal("Ran out of memory.");
+				cbuf[cpos] = '\n';
+				state = ARGS;
+				return (STRING);
+			}
+			break;
+
+		case NSTR:
+			if (cbuf[cpos] == ' ') {
+				cpos++;
+				return (SP);
+			}
+			if (isdigit(cbuf[cpos])) {
+				cp = &cbuf[cpos];
+				while (isdigit(cbuf[++cpos]))
+					;
+				c = cbuf[cpos];
+				cbuf[cpos] = '\0';
+				yylval.i = atoi(cp);
+				cbuf[cpos] = c;
+				state = STR1;
+				return (NUMBER);
+			}
+			state = STR1;
+			goto dostr1;
+
+		case ARGS:
+			if (isdigit(cbuf[cpos])) {
+				cp = &cbuf[cpos];
+				while (isdigit(cbuf[++cpos]))
+					;
+				c = cbuf[cpos];
+				cbuf[cpos] = '\0';
+				yylval.i = atoi(cp);
+				cbuf[cpos] = c;
+				return (NUMBER);
+			}
+			switch (cbuf[cpos++]) {
+
+			case '\n':
+				state = CMD;
+				return (CRLF);
+
+			case ' ':
+				return (SP);
+
+			case ',':
+				return (COMMA);
+
+			case 'A':
+			case 'a':
+				return (A);
+
+			case 'B':
+			case 'b':
+				return (B);
+
+			case 'C':
+			case 'c':
+				return (C);
+
+			case 'E':
+			case 'e':
+				return (E);
+
+			case 'F':
+			case 'f':
+				return (F);
+
+			case 'I':
+			case 'i':
+				return (I);
+
+			case 'L':
+			case 'l':
+				return (L);
+
+			case 'N':
+			case 'n':
+				return (N);
+
+			case 'P':
+			case 'p':
+				return (P);
+
+			case 'R':
+			case 'r':
+				return (R);
+
+			case 'S':
+			case 's':
+				return (S);
+
+			case 'T':
+			case 't':
+				return (T);
+
+			}
+			break;
+
+		default:
+			fatal("Unknown state in scanner.");
+		}
+		yyerror((char *) 0);
+		state = CMD;
+		longjmp(errcatch,0);
+	}
+}
+
+void upper(char *s)
+{
+	while (*s != '\0') {
+		if (islower(*s))
+			*s = toupper(*s);
+		s++;
+	}
+}
+
+static void help(struct tab *ctab, char *s)
+{
+	struct tab *c;
+	int width, NCMDS;
+	const char *type;
+
+	if (ctab == sitetab)
+		type = "SITE ";
+	else
+		type = "";
+	width = 0, NCMDS = 0;
+	for (c = ctab; c->name != NULL; c++) {
+		int len = strlen(c->name);
+
+		if (len > width)
+			width = len;
+		NCMDS++;
+	}
+	width = (width + 8) &~ 7;
+	if (s == 0) {
+		int i, j, w;
+		int columns, lines;
+
+		lreply(214, "The following %scommands are recognized %s.",
+		    type, "(* =>'s unimplemented)");
+		columns = 76 / width;
+		if (columns == 0)
+			columns = 1;
+		lines = (NCMDS + columns - 1) / columns;
+		for (i = 0; i < lines; i++) {
+			printf("   ");
+			for (j = 0; j < columns; j++) {
+				c = ctab + j * lines + i;
+				printf("%s%c", c->name,
+					c->implemented ? ' ' : '*');
+				if (c + lines >= &ctab[NCMDS])
+					break;
+				w = strlen(c->name) + 1;
+				while (w < width) {
+					putchar(' ');
+					w++;
+				}
+			}
+			printf("\r\n");
+		}
+		(void) fflush(stdout);
+		reply(214, "Direct comments to ftp-bugs@%s.", hostname);
+		return;
+	}
+	upper(s);
+	c = lookup(ctab, s);
+	if (c == (struct tab *)0) {
+		reply(502, "Unknown command %s.", s);
+		return;
+	}
+	if (c->implemented)
+		reply(214, "Syntax: %s%s %s", type, c->name, c->help);
+	else
+		reply(214, "%s%-*s\t%s; unimplemented.", type, width,
+		    c->name, c->help);
+}
+
+static void sizecmd(char *filename)
+{
+	switch (type) {
+	case TYPE_L:
+	case TYPE_I: {
+		struct stat stbuf;
+		if (stat(filename, &stbuf) < 0 || !S_ISREG(stbuf.st_mode))
+			reply(550, "%s: not a plain file.", filename);
+		else
+			reply(213, "%qu", (quad_t) stbuf.st_size);
+		break; }
+	case TYPE_A: {
+		FILE *fin;
+		int c;
+		off_t count;
+		struct stat stbuf;
+		fin = fopen(filename, "r");
+		if (fin == NULL) {
+			perror_reply(550, filename);
+			return;
+		}
+		if (fstat(fileno(fin), &stbuf) < 0 || !S_ISREG(stbuf.st_mode)) {
+			reply(550, "%s: not a plain file.", filename);
+			(void) fclose(fin);
+			return;
+		}
+
+		count = 0;
+		while((c=getc(fin)) != EOF) {
+			if (c == '\n')	/* will get expanded to \r\n */
+				count++;
+			count++;
+		}
+		(void) fclose(fin);
+
+		reply(213, "%qd", (quad_t) count);
+		break; }
+	default:
+		reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/src/ftpd.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,2060 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/*
+ * Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * FTP server.
+ */
+
+
+#include <netinet/net_types.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/mman.h>
+#include <netinet/in.h>
+
+#define	FTP_NAMES
+#include <arpa/ftp.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <glob.h>
+#include <limits.h> /* for CHAR_BIT */
+#include <netdb.h>
+#include <pwd.h>
+#include <setjmp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <utmp.h>
+#include <spawn.h>
+
+#include "pathnames.h"
+#include "extern.h"
+
+// Symbian includes
+
+#include <f32file.h>
+#include <in_iface.h>
+
+static char version[]="v1.0.1000";
+
+extern	off_t restart_point;
+extern	char cbuf[];
+
+struct	sockaddr_in server_addr;
+struct	sockaddr_in ctrl_addr;
+struct	sockaddr_in data_source;
+struct	sockaddr_in data_dest;
+struct	sockaddr_in his_addr;
+struct	sockaddr_in pasv_addr;
+
+in_addr server_in_addr;
+
+int	daemon_mode = 0;
+int	data;
+jmp_buf	errcatch, urgcatch;
+int	logged_in;
+struct	passwd *pw;
+int	debug = 0;
+int	timeout = 900;    /* timeout after 15 minutes of inactivity */
+int	maxtimeout = 7200;/* don't allow idle time to be set beyond 2 hours */
+int	logging = 0;
+int	replicate = 0;
+int	high_data_ports = 0;
+int	anon_only = 0;
+int	multihome = 0;
+int guest;
+int	stats;
+int	statfd = -1;
+int	portcheck = 1;
+int	dochroot;
+int	type;
+int	form;
+int	stru;			/* avoid C keyword */
+int	mode;
+int	doutmp = 0;		/* update utmp file */
+int	usedefault = 1;		/* for data transfers */
+int	pdata = -1;		/* for passive mode */
+int port = 21;    /* default FTP port */
+//sig_atomic_t transflag;
+int transflag;
+off_t	file_size;
+off_t	byte_count;
+#if !defined(CMASK) || CMASK == 0
+#undef CMASK
+#define CMASK 027
+#endif
+int	defumask = CMASK;		/* default umask value */
+char	tmpline[7];
+char	hostname[]="Symbian"; 
+char*	remotehost=hostname; 
+char*	dhostname=hostname;
+char	*guestpw;
+static char ttyline[20];
+char	*tty = ttyline;		/* for klogin */
+static struct utmp utmp;	/* for utmp */
+
+TDriveNumber drive;
+
+char	*ident = NULL;
+
+int root = 1;
+FILE* logFile;
+/*
+ * Timeout intervals for retrying connections
+ * to hosts that don't accept PORT cmds.  This
+ * is a kludge, but given the problems with TCP...
+ */
+#define	SWAITMAX	90	/* wait at most 90 seconds */
+#define	SWAITINT	5	/* interval between retries */
+
+int	swaitmax = SWAITMAX;
+int	swaitint = SWAITINT;
+
+#ifdef HASSETPROCTITLE
+char	proctitle[BUFSIZ];	/* initial part of title */
+#endif /* HASSETPROCTITLE */
+
+#define LOG(message) \
+	if (logging/* > 1*/) { \
+	    fprintf(logFile, "LOG_INFO %s\r\n", message); \
+		fflush(logFile); }
+
+#define LOGCMD(cmd, file) \
+	if (logging/* > 1*/) { \
+	    fprintf(logFile, "LOG_INFO %s %s\r\n", cmd, file); \
+		fflush(logFile); }
+#define LOGCMD2(cmd, file1, file2) \
+	 if (logging/* > 1*/) { \
+	 	fprintf(logFile, "LOG_INFO %s %s %s\r\n", cmd, file1, file2); \
+		fflush(logFile); }
+#define LOGBYTES(cmd, file, cnt) \
+	if (logging/* > 1*/) { \
+		if (cnt == (off_t)-1) \
+		    fprintf(logFile, "LOG_INFO %s %s\r\n", cmd, file); \
+		else \
+		    fprintf(logFile, "LOG_INFO %s %s = %qd bytes\r\n", cmd, file, (quad_t)(cnt)); \
+		fflush(logFile) ; \
+	}
+
+static void	 ack __P((const char *));
+static FILE	*dataconn __P((const char *, off_t, const char *));
+static void	 dolog __P((struct sockaddr_in *));
+static void	 end_login __P((void));
+static FILE	*getdatasock __P((const char *));
+static int	guniquefd __P((const char *, char **));
+static int	 receive_data __P((FILE *, FILE *));
+static void	 replydirname __P((const char *, const char *));
+static void	 send_data __P((FILE *, FILE *, off_t, off_t, int));
+
+#if defined(TCPWRAPPERS)
+static int	 check_host __P((struct sockaddr_in *));
+#endif
+
+in_addr getServerAddress();
+TDriveNumber getSystemDrive();
+
+void logxfer __P((const char *, off_t, time_t));
+
+#define MAXUSERNAME 64
+char * username[MAXUSERNAME];
+char * userhome[MAXPATHLEN];
+
+#undef IP_PORTRANGE
+
+int
+main(int argc, char *argv[], char **envp)
+{
+	int ch, on = 1;
+	socklen_t addrlen;
+	char *cp, line[LINE_MAX];
+	FILE *fd;
+	const char *argstr = "RAdDhlMSt:T:u:UvP:";
+	
+	tzset();	/* in case no timezone database in ~ftp */
+
+	/* set this here so klogin can use it... */
+	(void)snprintf(ttyline, sizeof(ttyline), "ftp%d", getpid());
+
+	while ((ch = getopt(argc, argv, argstr)) != -1) {
+		switch (ch) {
+		case 'A':
+			anon_only = 1;
+			break;
+
+		case 'd':
+			debug = 1;
+			break;
+
+		case 'D':
+		
+			for(int i=1 /*no name*/; i<argc; i++)
+				{
+				for(unsigned int j=0;j<strlen(argv[i]); j++)
+					if(argv[i][j]=='D')
+						{ 
+						//Daemon token found, change it to allow replication to new background processes
+						argv[i][j]='R';
+						}
+				}
+			posix_spawn(NULL,argv[0],NULL,NULL,argv,envp);
+			exit(0);
+		
+			break;
+
+		case 'R':
+			replicate = 1;
+			break;
+			
+		case 'P':
+			port = atoi(optarg);
+			break;
+			
+		case 'h':
+			high_data_ports = 1;
+			break;
+
+		case 'l':
+			logging++;	/* > 1 == extra logging */
+			break;
+
+		case 'M':
+			multihome = 1;
+			break;
+
+		case 'S':
+			stats = 1;
+			break;
+
+		case 't':
+			timeout = atoi(optarg);
+			if (maxtimeout < timeout)
+				maxtimeout = timeout;
+			break;
+
+		case 'T':
+			maxtimeout = atoi(optarg);
+			if (timeout > maxtimeout)
+				timeout = maxtimeout;
+			break;
+
+		case 'u':
+		    {
+			long val = 0;
+
+			val = strtol(optarg, &optarg, 8);
+			if (*optarg != '\0' || val < 0 || (val & ~ACCESSPERMS))
+				printf("bad value for -u");
+			else
+				defumask = val;
+			break;
+		    }
+
+		case 'U':
+			doutmp = 1;
+			break;
+
+		case 'v':
+			debug = 1;
+			break;
+
+		default:
+			printf("unknown flag -%c ignored", optopt);
+			scanf("");
+			break;
+		}
+	}
+
+	(void) freopen(_PATH_DEVNULL, "w", stderr);
+
+	/*
+	 * LOG_NDELAY sets up the logging connection immediately,
+	 * necessary for anonymous ftp's that chroot and can't do it later.
+	 */
+#ifndef LOG_FTP
+#define LOG_FTP LOG_DAEMON
+#endif
+	
+		int ctl_sock, fd2;
+	
+		server_in_addr = getServerAddress();
+		
+		/*
+		 * Open a socket, bind it to the FTP port, and start
+		 * listening.
+		 */
+		ctl_sock = socket(AF_INET, SOCK_STREAM, 0);
+		if (ctl_sock < 0) {
+            User::Panic(_L("socket error"),0);
+			LOG("socket error");
+			exit(1);
+		}
+		
+		setsockopt(ctl_sock, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on));
+	
+		server_addr.sin_family = 0;
+		server_addr.sin_addr.s_addr = INADDR_ANY;
+		server_addr.sin_port = port; 
+		if (bind(ctl_sock, (struct sockaddr *)&server_addr,
+			 sizeof(server_addr))) {
+			 User::Panic(_L("bind error"),0);
+            LOG("bind error");
+			exit(1);
+		}
+		if (listen(ctl_sock, 32) < 0) {
+		    User::Panic(_L("listen error"),0);
+			LOG("listen error");
+			exit(1);
+		}
+			addrlen = sizeof(his_addr);
+			fd2 = accept(ctl_sock, (struct sockaddr *)&his_addr,
+				    &addrlen);
+			
+			(void) dup2(fd2, 0);
+			(void) dup2(fd2, 1);
+			close(ctl_sock);
+			close(fd2);
+
+
+	drive = getSystemDrive();
+	
+	if(logging)
+	{
+		char logFileName[MAXPATHLEN];
+		
+		char driveLetter = 'A'+drive;
+		
+		sprintf(logFileName,"%c:\\ftpd_%d.log",driveLetter,getpid());
+		logFile = fopen(logFileName,"w");
+		
+		fprintf(logFile, "** Log file for the FTP instance with PID %d **\r\n",getpid());
+		fflush(logFile);
+	}
+	
+	
+	addrlen = sizeof(ctrl_addr);
+	if (getsockname(0, (struct sockaddr *)&ctrl_addr, &addrlen) < 0) {
+		User::Panic(_L("getsockname error"),0);
+		exit(1);
+	}
+
+	//clone to accept new connections
+	if(replicate)
+		posix_spawn(NULL,argv[0],NULL,NULL,argv,envp);
+	
+	data_source.sin_port = htons(ntohs(ctrl_addr.sin_port) - 1);
+
+	dolog(&his_addr);
+	/*
+	 * Set up default state
+	 */
+	data = -1;
+	type = TYPE_A;
+	form = FORM_N;
+	stru = STRU_F;
+	mode = MODE_S;
+	tmpline[0] = '\0';
+
+	/* If logins are disabled, print out the message. */
+	if ((fd = fopen(_PATH_NOLOGIN,"r")) != NULL) {
+		while (fgets(line, sizeof(line), fd) != NULL) {
+			if ((cp = strchr(line, '\n')) != NULL)
+				*cp = '\0';
+			lreply(530, "%s", line);
+		}
+		(void) fflush(stdout);
+		(void) fclose(fd);
+		reply(530, "System not available.");
+		exit(0);
+	}
+	if ((fd = fopen(_PATH_FTPWELCOME, "r")) != NULL) {
+		while (fgets(line, sizeof(line), fd) != NULL) {
+			if ((cp = strchr(line, '\n')) != NULL)
+				*cp = '\0';
+			lreply(220, "%s", line);
+		}
+		(void) fflush(stdout);
+		(void) fclose(fd);
+		/* reply(220,) must follow */
+	}
+	
+	reply(220, "%s FTP server (%s) ready.",
+			hostname, version);
+	(void) setjmp(errcatch);
+	for (;;)
+		(void) yyparse();
+	/* NOTREACHED */
+}
+
+static int login_attempts;	/* number of failed login attempts */
+static int askpasswd;		/* had user command, ask for passwd */
+static char curname[16];	/* current USER name */
+
+/*
+ * USER command.
+ * Sets global passwd pointer pw if named account exists and is acceptable;
+ * sets askpasswd if a PASS command is expected.  If logged in previously,
+ * need to reset state.  If name is "ftp" or "anonymous", the name is not in
+ * _PATH_FTPUSERS, and ftp account exists, set guest and pw, then just return.
+ * If account doesn't exist, ask for passwd anyway.  Otherwise, check user
+ * requesting login privileges.  Disallow anyone who does not have a standard
+ * shell as returned by getusershell().  Disallow anyone mentioned in the file
+ * _PATH_FTPUSERS to allow people such as root and uucp to be avoided.
+ */
+void user(char *name)
+{
+	//const char *cp, *shell;
+
+	if (logged_in) {
+		if (guest) {
+			reply(530, "Can't change user from guest login.");
+			return;
+		} else if (dochroot) {
+			reply(530, "Can't change user from chroot user.");
+			return;
+		}
+		end_login();
+	}
+
+	guest = 0;
+
+	// check password
+	
+	pw = (passwd *)malloc(sizeof(pw));
+	
+	strcpy((char*)username,name);
+	pw->pw_name = (char*)username;
+	
+	strcpy((char*)userhome,"/");
+	pw->pw_dir = (char*)userhome;
+	
+	if (logging) {
+		strncpy(curname, name, sizeof(curname)-1);
+		curname[sizeof(curname)-1] = '\0';
+	}
+	
+	if (strcmp(name, "ftp") == 0 || strcmp(name, "anonymous") == 0) 
+		reply(331,"Guest login ok, type your name as password.");
+	else
+		reply(331, "Password required for %s.", name);
+
+	askpasswd = 1;
+	/*
+	 * Delay before reading passwd after first failed
+	 * attempt to slow down passwd-guessing programs.
+	 */
+	if (login_attempts)
+		sleep((unsigned) login_attempts);
+}
+
+
+/*
+ * Terminate login as previous user, if any, resetting state;
+ * used when USER command is given or login fails.
+ */
+static void end_login(void)
+{
+	(void) seteuid((uid_t)0);
+	if (logged_in) {
+		if (doutmp)
+			logout(utmp.ut_line);
+	}
+	pw = NULL;
+	logged_in = 0;
+	guest = 0;
+	dochroot = 0;
+}
+
+void pass(char *passwd)
+{
+	int rval;
+	FILE *fd;
+	
+	if (logged_in || askpasswd == 0) {
+		reply(503, "Login with USER first.");
+		return;
+	}
+	askpasswd = 0;
+	
+	if (!guest) {		/* "ftp" is only account allowed no password */
+	
+		/*
+		 * Authenticate password...
+		 */
+
+		rval = 0;
+
+		/*
+		 * If rval == 1, the user failed the authentication check
+		 * above.  If rval == 0, either Kerberos or local authentication
+		 * succeeded.
+		 */
+		if (rval) {
+			reply(530, "Login incorrect.");
+			pw = NULL;
+			return;
+		}
+	} else {
+		/* Save anonymous' password. */
+		guestpw = strdup(passwd);
+		if (guestpw == (char *)NULL)
+			fatal("Out of memory");
+	}
+	login_attempts = 0;		/* this time successful */
+	
+	if (setegid((gid_t)pw->pw_gid) < 0) {
+		reply(550, "Can't set gid.");
+		return;
+	}
+	(void) initgroups(pw->pw_name, pw->pw_gid);
+
+	/* open utmp before chroot */
+	if (doutmp) {
+		memset((void *)&utmp, 0, sizeof(utmp));
+		(void)time(&utmp.ut_time);
+		(void)strncpy(utmp.ut_name, pw->pw_name, sizeof(utmp.ut_name));
+		(void)strncpy(utmp.ut_host, remotehost, sizeof(utmp.ut_host));
+		(void)strncpy(utmp.ut_line, ttyline, sizeof(utmp.ut_line));
+		login(&utmp);
+	}
+
+	/* open stats file before chroot */
+	if (guest && (stats == 1) && (statfd < 0))
+		if ((statfd = open(_PATH_FTPDSTATFILE, O_WRONLY|O_APPEND)) < 0)
+			stats = 0;
+
+	logged_in = 1;
+	dochroot = 0; 
+	
+	/*
+	 * Set home directory to root
+	 */
+	chdir("/"); //root
+
+	/*
+	 * Display a login message, if it exists.
+	 * N.B. reply(230,) must follow the message.
+	 */
+	if ((fd = fopen(_PATH_FTPLOGINMESG, "r")) != NULL) {
+		char *cp, line[LINE_MAX];
+
+		while (fgets(line, sizeof(line), fd) != NULL) {
+			if ((cp = strchr(line, '\n')) != NULL)
+				*cp = '\0';
+			lreply(230, "%s", line);
+		}
+		(void) fflush(stdout);
+		(void) fclose(fd);
+	}
+	if (guest) {
+		if (ident != NULL)
+			free(ident);
+		ident = strdup(passwd);
+		if (ident == (char *)NULL)
+			fatal("Ran out of memory.");
+		reply(230, "Guest login ok, access restrictions apply.");
+	} else {
+		reply(230, "User %s logged in.", pw->pw_name);
+	}
+	(void) umask(defumask);
+	return;
+}
+
+void internalName(char* output, const char *input)
+	{
+		//from /c/aaa.txt to c:\aaa.txt
+		
+		strcpy(output,input);
+		
+		//root is a special case
+		if(strcmp(output,"/")==0)
+			{
+			return;
+			}
+		
+		for(unsigned int i=0 ; i<strlen(output); i++)
+			{
+			if(output[i]=='/')
+				output[i]= '\\';
+			}
+		
+		//relative path, do not modify
+		if((output[0]!='\\' && strlen(output)>1) || strcmp(output,".")==0)
+			{
+			return;
+			}
+		
+		if(strlen(output)==1 && root)
+			{
+			//it's a drive: C\0 -> C:\0
+			output[2]=output[1];
+			output[1]=':';
+			
+			}
+		else
+			{
+			
+			// /C/system\n -> C:/system\n
+			output[0]=output[1];
+			output[1]=':';
+			}
+	}
+
+void externalName(char* output, const char *input)
+	{
+		//from c:/aaa.txt to /c/aaa.txt 
+
+		strcpy(output,input);
+		
+		for(unsigned int i=0 ; i<strlen(output); i++)
+			{
+			if(output[i]=='\\')
+				output[i]= '/';
+			}
+		
+		output[1]=output[0];
+		output[0]='/';
+	}
+
+void retrieve(const char *cmd, const char *name)
+{
+	FILE *fin, *dout;
+	struct stat st;
+	int (*closefunc) __P((FILE *));
+	time_t start;
+
+	char adaptedName[MAXPATHLEN];
+	internalName(adaptedName,name);
+	
+	LOGCMD("RETR", adaptedName);
+	
+	if (cmd == 0) {
+		fin = fopen(adaptedName, "r"); closefunc = fclose;
+		st.st_size = 0;
+	} else {
+		char line[BUFSIZ];
+		
+		(void) snprintf(line, sizeof(line), cmd, adaptedName);
+		name = line;
+		fin = ftpd_popen(line, "r"), closefunc = ftpd_pclose;
+		st.st_size = -1;
+		st.st_blksize = BUFSIZ;
+	}
+	if (fin == NULL) {
+		if (errno != 0) {
+			perror_reply(550, name);
+			if (cmd == 0) {
+				LOGCMD("get", adaptedName);
+			}
+		}
+		return;
+	}
+	byte_count = -1;
+	if (cmd == 0 && (fstat(fileno(fin), &st) < 0 || !S_ISREG(st.st_mode))) {
+		reply(550, "%s: not a plain file.", name);
+		goto done;
+	}
+	
+	
+	if (restart_point) {
+		if (type == TYPE_A) {
+			off_t i, n;
+			int c;
+
+			n = restart_point;
+			i = 0;
+			while (i++ < n) {
+				if ((c=getc(fin)) == EOF) {
+					perror_reply(550, name);
+					goto done;
+				}
+				if (c == '\n')
+					i++;
+			}
+		} else if (lseek(fileno(fin), restart_point, SEEK_SET) < 0) {
+			perror_reply(550, name);
+			goto done;
+		}
+	}
+	
+	dout = dataconn(name, st.st_size, "w");
+	if (dout == NULL)
+		goto done;
+	time(&start);
+	send_data(fin, dout, st.st_blksize, st.st_size,
+		  (restart_point == 0 && cmd == 0 && S_ISREG(st.st_mode)));
+	if ((cmd == 0) && stats)
+		logxfer(name, st.st_size, start);
+	(void) fclose(dout);
+	data = -1;
+	pdata = -1;
+done:
+	if (cmd == 0)
+		LOGBYTES("get", name, byte_count);
+	(*closefunc)(fin);
+}
+
+void store(const char *name, const char *mode, int unique)
+{
+
+	FILE *fout, *din;
+	int (*closefunc) __P((FILE *));
+	struct stat st;
+	int fd;
+
+	char adaptedName[MAXPATHLEN];
+	internalName(adaptedName,name);
+	
+	LOGCMD("STOR", adaptedName);
+	
+	if (unique && stat(adaptedName, &st) == 0) {
+		char *nam;
+
+		fd = guniquefd(adaptedName, &nam);
+		if (fd == -1) {
+			LOGCMD(*mode == 'w' ? "put" : "append", name);
+			return;
+		}
+		name = nam;
+		if (restart_point)
+			mode = "r+";
+		fout = fdopen(fd, mode);
+	} else
+		fout = fopen(adaptedName, mode);
+
+	closefunc = fclose;
+	if (fout == NULL) {
+		perror_reply(553, name);
+		LOGCMD(*mode == 'w' ? "put" : "append", name);
+		return;
+	}
+	byte_count = -1;
+	if (restart_point) {
+		if (type == TYPE_A) {
+			off_t i, n;
+			int c;
+
+			n = restart_point;
+			i = 0;
+			while (i++ < n) {
+				if ((c=getc(fout)) == EOF) {
+					perror_reply(550, name);
+					goto done;
+				}
+				if (c == '\n')
+					i++;
+			}
+			/*
+			 * We must do this seek to "current" position
+			 * because we are changing from reading to
+			 * writing.
+			 */
+			if (fseek(fout, 0L, SEEK_CUR) < 0) {
+				perror_reply(550, name);
+				goto done;
+			}
+		} else if (lseek(fileno(fout), restart_point, SEEK_SET) < 0) {
+			perror_reply(550, name);
+			goto done;
+		}
+	}
+	din = dataconn(adaptedName, (off_t)-1, "r");
+	if (din == NULL)
+		goto done;
+	if (receive_data(din, fout) == 0) {
+		if (unique)
+			reply(226, "Transfer complete (unique file name:%s).",
+			    name);
+		else
+			reply(226, "Transfer complete.");
+	}
+	(void) fclose(din);
+	data = -1;
+	pdata = -1;
+done:
+	LOGBYTES(*mode == 'w' ? "put" : "append", name, byte_count);
+	(*closefunc)(fout);
+}
+
+static FILE * getdatasock(const char *mode)
+{
+	int on = 1, s, t, tries;
+	
+	if (data >= 0)
+		return (fdopen(data, mode));
+	(void) seteuid((uid_t)0);
+	s = socket(AF_INET, SOCK_STREAM, 0);
+	if (s < 0)
+		goto bad;
+	if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
+	    (char *) &on, sizeof(on)) < 0)
+		goto bad;
+	/* anchor socket to avoid multi-homing problems */
+
+	data_source.sin_family = AF_INET;
+	data_source.sin_addr = ctrl_addr.sin_addr;
+	for (tries = 1; ; tries++) {
+		if (bind(s, (struct sockaddr *)&data_source,
+		    sizeof(data_source)) >= 0)
+			break;
+		if (errno != EADDRINUSE || tries > 10)
+			goto bad;
+		sleep(tries);
+	}
+	(void) seteuid((uid_t)pw->pw_uid);
+
+	return (fdopen(s, mode));
+bad:
+	/* Return the real value of errno (close may change it) */
+	t = errno;
+	(void) seteuid((uid_t)pw->pw_uid);
+	(void) close(s);
+	errno = t;
+	return (NULL);
+}
+
+static FILE * dataconn(const char *name, off_t size, const char *mode)
+{
+	char sizebuf[32];
+	FILE *file;
+	int retry = 0;
+
+	file_size = size;
+	byte_count = 0;
+	if (size != (off_t) -1) {
+		(void) snprintf(sizebuf, sizeof(sizebuf), " (%lld bytes)", 
+				(quad_t) size);
+	} else
+		sizebuf[0] = '\0';
+	
+	if (pdata >= 0) {
+		struct sockaddr_in from;
+		int s;
+		socklen_t fromlen = sizeof(from);
+
+		s = accept(pdata, (struct sockaddr *)&from, &fromlen);
+		
+		//TODO: OE bug ? sizebuf seems to be changed to 0x18 after accept
+		//reassigning sizebuf
+		if (size != (off_t) -1) {
+		(void) snprintf(sizebuf, sizeof(sizebuf), " (%lld bytes)", 
+				(quad_t) size);
+		} else
+			sizebuf[0] = '\0';
+		
+		
+		if (s < 0) {
+			reply(425, "Can't open data connection.");
+			(void) close(pdata);
+			pdata = -1;
+			return (NULL);
+		}
+		if (ntohs(from.sin_port) < IPPORT_RESERVED) {
+			perror_reply(425, "Can't build data connection");
+			(void) close(pdata);
+			(void) close(s);
+			pdata = -1;
+			return (NULL);
+		}
+		if (from.sin_addr.s_addr != his_addr.sin_addr.s_addr) {
+			perror_reply(435, "Can't build data connection"); 
+			(void) close(pdata);
+			(void) close(s);
+			pdata = -1;
+			return (NULL);
+		}
+		(void) close(pdata);
+		pdata = s;
+
+		if (size != (off_t) -1) {
+		(void) snprintf(sizebuf, sizeof(sizebuf), " (%lld bytes)", 
+				(quad_t) size);
+		} else
+			sizebuf[0] = '\0';
+		
+		reply(150, "Opening %s mode data connection for '%s'%s.",
+		     type == TYPE_A ? "ASCII" : "BINARY", name, sizebuf);
+		return (fdopen(pdata, mode));
+	}
+	if (data >= 0) {
+		reply(125, "Using existing data connection for '%s'%s.",
+		    name, sizebuf);
+		usedefault = 1;
+		return (fdopen(data, mode));
+	}
+	if (usedefault)
+		data_dest = his_addr;
+	usedefault = 1;
+	file = getdatasock(mode);
+	if (file == NULL) {
+		reply(425, "Can't create data socket (%s,%d): %s.",
+		    inet_ntoa(data_source.sin_addr),
+		    ntohs(data_source.sin_port), strerror(errno));
+		return (NULL);
+	}
+	data = fileno(file);
+
+	/*
+	 * attempt to connect to reserved port on client machine;
+	 * this looks like an attack
+	 */
+	if (ntohs(data_dest.sin_port) < IPPORT_RESERVED ||
+	    ntohs(data_dest.sin_port) == 2049) {		/* XXX */
+		perror_reply(425, "Can't build data connection");
+		(void) fclose(file);
+		data = -1;
+		return NULL;
+	}
+	if (data_dest.sin_addr.s_addr != his_addr.sin_addr.s_addr) {
+		perror_reply(435, "Can't build data connection");
+		(void) fclose(file);
+		data = -1;
+		return NULL;
+	}
+	while (connect(data, (struct sockaddr *)&data_dest,
+	    sizeof(data_dest)) < 0) {
+		if (errno == EADDRINUSE && retry < swaitmax) {
+			sleep((unsigned) swaitint);
+			retry += swaitint;
+			continue;
+		}
+		perror_reply(425, "Can't build data connection");
+		(void) fclose(file);
+		data = -1;
+		return (NULL);
+	}
+	reply(150, "Opening %s mode data connection for '%s'%s.",
+	     type == TYPE_A ? "ASCII" : "BINARY", name, sizebuf);
+	return (file);
+}
+
+/*
+ * Tranfer the contents of "instr" to "outstr" peer using the appropriate
+ * encapsulation of the data subject to Mode, Structure, and Type.
+ *
+ * NB: Form isn't handled.
+ */
+static void send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg)
+{
+	int c, cnt, filefd, netfd;
+	char *buf, *bp;
+	size_t len,size;
+
+	transflag++;
+	if (setjmp(urgcatch)) {
+		transflag = 0;
+		return;
+	}
+	switch (type) {
+
+	case TYPE_A:
+		while ((c = getc(instr)) != EOF) {
+			byte_count++;
+			(void) putc(c, outstr);
+		}
+		fflush(outstr);
+		transflag = 0;
+		if (ferror(instr))
+			goto file_err;
+		if (ferror(outstr))
+			goto data_err;
+		reply(226, "Transfer complete.");
+		return;
+
+	case TYPE_I:
+	case TYPE_L:
+		/*
+		 * isreg is only set if we are not doing restart and we
+		 * are sending a regular file
+		 */
+		netfd = fileno(outstr);
+		filefd = fileno(instr);
+
+		if (isreg && filesize < (off_t)16 * 1024 * 1024) {
+			buf = (char *)mmap(0, filesize, PROT_READ, MAP_SHARED, filefd, (off_t)0);
+			if (buf==MAP_FAILED || buf==NULL) {
+				goto oldway;
+			}
+			bp = buf;
+			len = filesize;
+			do {
+				cnt = write(netfd, bp, len);
+				len -= cnt;
+				bp += cnt;
+				if (cnt > 0) byte_count += cnt;
+			} while(cnt > 0 && len > 0);
+
+			transflag = 0;
+			munmap(buf, (size_t)filesize);
+			if (cnt < 0)
+				goto data_err;
+			reply(226, "Transfer complete.");
+			return;
+		}
+
+oldway:
+		size = blksize * 16; 
+	
+		if ((buf = (char *)malloc(size)) == NULL) {
+			transflag = 0;
+			perror_reply(451, "Local resource failure: malloc");
+			return;
+		}
+
+		while ((cnt = read(filefd, buf, size)) > 0 &&
+		    write(netfd, buf, cnt) == cnt)
+			byte_count += cnt;
+
+		transflag = 0;
+		(void)free(buf);
+		if (cnt != 0) {
+			if (cnt < 0)
+				goto file_err;
+			goto data_err;
+		}
+		reply(226, "Transfer complete.");
+		return;
+	default:
+		transflag = 0;
+		reply(550, "Unimplemented TYPE %d in send_data", type);
+		return;
+	}
+
+data_err:
+	transflag = 0;
+	perror_reply(426, "Data connection");
+	return;
+
+file_err:
+	transflag = 0;
+	perror_reply(551, "Error on input file");
+}
+
+/*
+ * Transfer data from peer to "outstr" using the appropriate encapulation of
+ * the data subject to Mode, Structure, and Type.
+ *
+ * N.B.: Form isn't handled.
+ */
+static int receive_data(FILE *instr, FILE *outstr)
+{
+	int c;
+	int cnt;
+	volatile int bare_lfs = 0;
+	char buf[BUFSIZ];
+
+	transflag++;
+	if (setjmp(urgcatch)) {
+		transflag = 0;
+		return (-1);
+	}
+	switch (type) {
+
+	case TYPE_I:
+	case TYPE_L:
+		
+		do {
+			cnt = read(fileno(instr), buf, sizeof(buf));
+		
+			if (cnt > 0) {
+				if (write(fileno(outstr), buf, cnt) != cnt)
+					goto file_err;
+				byte_count += cnt;
+			}
+		} while (cnt > 0);
+		transflag = 0;
+		return (0);
+
+	case TYPE_E:
+		reply(553, "TYPE E not implemented.");
+		transflag = 0;
+		return (-1);
+
+	case TYPE_A:
+		while ((c = getc(instr)) != EOF) {
+			byte_count++;
+			(void) putc(c, outstr);
+		}
+		fflush(outstr);
+		if (ferror(outstr))
+			goto file_err;
+		transflag = 0;
+		if (bare_lfs) {
+			lreply(226,
+		"WARNING! %d bare linefeeds received in ASCII mode",
+			    bare_lfs);
+		(void)printf("   File may not have transferred correctly.\r\n");
+		}
+		return (0);
+	default:
+		reply(550, "Unimplemented TYPE %d in receive_data", type);
+		transflag = 0;
+		return (-1);
+	}
+	
+file_err:
+	transflag = 0;
+	perror_reply(452, "Error writing file");
+	return (-1);
+}
+
+void statfilecmd(char *filename)
+{
+	FILE *fin;
+	int c;
+	char line[LINE_MAX];
+
+	char adaptedName[MAXPATHLEN];
+	internalName(adaptedName,filename);
+	
+	(void)snprintf(line, sizeof(line), "/bin/ls -lgA %s", filename);
+	fin = ftpd_popen(line, "r");
+	
+	lreply(211, "status of %s:", filename);
+	while ((c = getc(fin)) != EOF) {
+		if (c == '\n') {
+			if (ferror(stdout)){
+				perror_reply(421, "control connection");
+				(void) ftpd_pclose(fin);
+				dologout(1);
+				/* NOTREACHED */
+			}
+			if (ferror(fin)) {
+				perror_reply(551, filename);
+				(void) ftpd_pclose(fin);
+				return;
+			}
+			(void) putc('\r', stdout);
+		}
+		(void) putc(c, stdout);
+	}
+	(void) ftpd_pclose(fin);
+	
+	
+	reply(211, "End of Status");
+}
+
+void statcmd(void)
+{
+	struct sockaddr_in *sn;
+	u_char *a, *p;
+
+	lreply(211, "%s FTP server status:", hostname, version);
+	printf("     %s\r\n", version);
+	printf("     Connected to %s", remotehost);
+	if (!isdigit(remotehost[0]))
+		printf(" (%s)", inet_ntoa(server_in_addr));
+	printf("\r\n");
+	if (logged_in) {
+		if (guest)
+			printf("     Logged in anonymously\r\n");
+		else
+			printf("     Logged in as %s\r\n", pw->pw_name);
+	} else if (askpasswd)
+		printf("     Waiting for password\r\n");
+	else
+		printf("     Waiting for user name\r\n");
+	printf("     TYPE: %s", typenames[type]);
+	if (type == TYPE_A || type == TYPE_E)
+		printf(", FORM: %s", formnames[form]);
+	if (type == TYPE_L)
+#if CHAR_BIT == 8
+		printf(" %d", CHAR_BIT);
+#else
+		printf(" %d", bytesize);	/* need definition! */
+#endif
+	printf("; STRUcture: %s; transfer MODE: %s\r\n",
+	    strunames[stru], modenames[mode]);
+	if (data != -1)
+		printf("     Data connection open\r\n");
+	else if (pdata != -1) {
+		printf("     in Passive mode");
+		sn = &pasv_addr;
+		goto printaddr;
+	} else if (usedefault == 0) {
+		printf("     PORT");
+		sn = &data_dest;
+printaddr:
+		a = (u_char *) &sn->sin_addr;
+		p = (u_char *) &sn->sin_port;
+#define UC(b) (((int) b) & 0xff)
+		printf(" (%d,%d,%d,%d,%d,%d)\r\n", UC(a[0]),
+			UC(a[1]), UC(a[2]), UC(a[3]), UC(p[0]), UC(p[1]));
+#undef UC
+	} else
+		printf("     No data connection\r\n");
+	
+	
+	printf("     System Drive: %c\r\n",'A'+drive);
+	
+	reply(211, "End of status");
+}
+
+void fatal(const char *s)
+{
+
+	reply(451, "Error in server: %s\n", s);
+	reply(221, "Closing connection due to server error.");
+	dologout(0);
+	/* NOTREACHED */
+}
+
+void
+#ifdef __STDC__
+reply(int n, const char *fmt, ...)
+#else
+reply(int n, char *fmt, va_dcl va_alist)
+#endif
+{
+	va_list ap;
+#ifdef __STDC__
+	va_start(ap, fmt);
+#else
+	va_start(ap);
+#endif
+	(void)printf("%d ", n);
+	(void)vprintf(fmt, ap);
+	(void)printf("\r\n");
+	(void)fflush(stdout);
+}
+
+void
+#ifdef __STDC__
+lreply(int n, const char *fmt, ...)
+#else
+lreply(n, fmt, va_alist)
+	int n;
+	char *fmt;
+	va_dcl
+#endif
+{
+	va_list ap;
+#ifdef __STDC__
+	va_start(ap, fmt);
+#else
+	va_start(ap);
+#endif
+	(void)printf("%d- ", n);
+	(void)vprintf(fmt, ap);
+	(void)printf("\r\n");
+	(void)fflush(stdout);
+}
+
+static void ack(const char *s)
+{
+
+	reply(250, "%s command successful.", s);
+}
+
+void nack(const char *s)
+{
+
+	reply(502, "%s command not implemented.", s);
+}
+
+/* ARGSUSED */
+
+void yyerror(char *s)
+{
+	char *cp;
+        
+	(void)s; /* ignore argument */
+
+	if ((cp = strchr(cbuf,'\n'))!=NULL)
+		*cp = '\0';
+	reply(500, "'%s': command not understood.", cbuf);
+}
+
+void dele(char *name)
+{
+	struct stat st;
+	
+	char internalPath[MAXPATHLEN];
+	internalName(internalPath,name);
+
+	LOGCMD("delete", name);
+	if (stat(internalPath, &st) < 0) {
+		perror_reply(550, name);
+		return;
+	}
+	if ((st.st_mode&S_IFMT) == S_IFDIR) {
+		if (rmdir(internalPath) < 0) {
+			perror_reply(550, name);
+			return;
+		}
+		goto done;
+	}
+	if (unlink(internalPath) < 0) {
+		perror_reply(550, name);
+		return;
+	}
+done:
+	ack("DELE");
+}
+
+void cwd(const char *path)
+{
+	FILE *message;
+	
+	LOGCMD("cwd", path);
+	
+	char internalPath[MAXPATHLEN];
+	
+	char cwd_path[MAXPATHLEN];
+	getcwd(cwd_path, sizeof cwd_path);
+	
+	
+	if( (strlen(path)==1 && path[0]=='/') || (strlen(cwd_path)==2 && strcmp(path,"..")==0))
+	{
+		root=1;
+		ack("CWD");
+	}
+	else
+	{
+		
+		internalName(internalPath, path);
+
+		if (chdir(internalPath) < 0)
+			perror_reply(550, path);
+		else {
+		
+			if ((message = fopen(_PATH_CWDMESG, "r")) != NULL) {
+				char *cp, line[LINE_MAX];
+	
+				while (fgets(line, sizeof(line), message) != NULL) {
+					if ((cp = strchr(line, '\n')) != NULL)
+						*cp = '\0';
+					lreply(250, "%s", line);
+				}
+				(void) fflush(stdout);
+				(void) fclose(message);
+			}
+			root = 0;
+			ack("CWD");
+		}
+	}
+}
+
+void replydirname(const char *name, const char *message)
+{
+	char npath[MAXPATHLEN];
+	int i;
+
+	for (i = 0; *name != '\0' && i < (int)sizeof(npath) - 1; i++, name++) {
+		npath[i] = *name;
+		if (*name == '"')
+			npath[++i] = '"';
+	}
+	npath[i] = '\0';
+	reply(257, "\"%s\" %s", npath, message);
+}
+
+void makedir(char *name)
+{
+
+	LOGCMD("mkdir", name);
+
+	char path[MAXPATHLEN];
+
+	internalName(path, name);
+	
+	if (mkdir(path, 0777) < 0)
+		perror_reply(550, name);
+	else
+		replydirname(name, "directory created.");
+}
+
+void removedir(char *name)
+{
+
+	char path[MAXPATHLEN];
+
+	internalName(path, name);
+
+	LOGCMD("rmdir", name);
+	if (rmdir(path) < 0)
+		perror_reply(550, name);
+	else
+		ack("RMD");
+}
+void pwd(void)
+{
+	char path[MAXPATHLEN];
+	
+	if(root)
+		{
+		replydirname("/", "is current directory.");
+		}
+	else
+		if (getcwd(path, sizeof path) == (char *)NULL)
+		{	
+		    externalName(path, path);
+			reply(550, "%s.", path);
+		}
+		else
+		{
+			externalName(path, path);
+			replydirname(path, "is current directory.");
+		}
+}
+
+char * renamefrom(char *name)
+{
+	struct stat st;
+	
+	char internal[MAXPATHLEN];
+	
+	internalName(internal,name);
+
+	if (stat(internal, &st) < 0) {
+		perror_reply(550, name);
+		return ((char *)0);
+	}
+	reply(350, "File exists, ready for destination name");
+	return (name);
+}
+
+void renamecmd(char *from, char *to)
+{
+
+	char internalFrom[MAXPATHLEN];
+	char internalTo[MAXPATHLEN];
+
+	internalName(internalFrom,from);
+	internalName(internalTo,to);
+	
+	LOGCMD2("rename", from, to);
+	if (rename(internalFrom, internalTo) < 0)
+		perror_reply(550, "rename");
+	else
+		ack("RNTO");
+}
+
+static void dolog(struct sockaddr_in *sn)
+{
+	struct hostent *hp = gethostbyaddr((char *)&sn->sin_addr,
+		sizeof(struct in_addr), AF_INET);
+
+	if (hp)
+		(void) strncpy(remotehost, hp->h_name, sizeof(remotehost)-1);
+	else
+		(void) strncpy(remotehost, inet_ntoa(sn->sin_addr),
+		    sizeof(remotehost)-1);
+	remotehost[sizeof(remotehost)-1] = '\0';
+}
+
+/*
+ * Record logout in wtmp file
+ * and exit with supplied status.
+ */
+void dologout(int status)
+{
+	transflag = 0;
+
+	if(logging)
+	{
+		fclose(logFile);
+	}
+		
+	if (logged_in) {
+		(void) seteuid((uid_t)0);
+		if (doutmp)
+			logout(utmp.ut_line);
+	}
+	/* beware of flushing buffers after a SIGPIPE */
+	_exit(status);
+}
+
+/*
+ * Note: a response of 425 is not mentioned as a possible response to
+ *	the PASV command in RFC959. However, it has been blessed as
+ *	a legitimate response by Jon Postel in a telephone conversation
+ *	with Rick Adams on 25 Jan 89.
+ */
+void passive(void)
+{
+	socklen_t len;
+#ifdef IP_PORTRANGE
+	int on;
+#else
+	u_short port;
+#endif
+	char *p, *a;
+
+	if (pw == NULL) {
+		reply(530, "Please login with USER and PASS");
+		return;
+	}
+	if (pdata >= 0)
+		close(pdata);
+	pdata = socket(AF_INET, SOCK_STREAM, 0);
+	if (pdata < 0) {
+		perror_reply(425, "Can't open passive connection");
+		return;
+	}
+
+#ifdef IP_PORTRANGE
+	on = high_data_ports ? IP_PORTRANGE_HIGH : IP_PORTRANGE_DEFAULT;
+	if (setsockopt(pdata, IPPROTO_IP, IP_PORTRANGE,
+		       (char *)&on, sizeof(on)) < 0)
+		goto pasv_error;
+#else
+#define FTP_DATA_BOTTOM 40000
+#define FTP_DATA_TOP    44999
+	if (high_data_ports) {
+		for (port = FTP_DATA_BOTTOM; port <= FTP_DATA_TOP; port++) {
+			pasv_addr = ctrl_addr;
+			pasv_addr.sin_port = htons(port);
+			if (bind(pdata, (struct sockaddr *) &pasv_addr,
+				 sizeof(pasv_addr)) == 0)
+				break;
+			if (errno != EADDRINUSE)
+				goto pasv_error;
+		}
+		if (port > FTP_DATA_TOP)
+			goto pasv_error;
+	}
+	else
+#endif
+	{
+		pasv_addr = ctrl_addr;
+		pasv_addr.sin_port = 0;
+		if (bind(pdata, (struct sockaddr *)&pasv_addr,
+			 sizeof(pasv_addr)) < 0)
+			goto pasv_error;
+	}
+
+	len = sizeof(pasv_addr);
+	if (getsockname(pdata, (struct sockaddr *) &pasv_addr, &len) < 0)
+		goto pasv_error;
+	if (listen(pdata, 1) < 0)
+		goto pasv_error;
+	
+	in_addr addr = getServerAddress();
+	
+	a = (char *) &addr;
+	p = (char *) &pasv_addr.sin_port;
+
+#define UC(b) (((int) b) & 0xff)
+
+	reply(227, "Entering Passive Mode (%d,%d,%d,%d,%d,%d)", UC(a[0]),
+		UC(a[1]), UC(a[2]), UC(a[3]), UC(p[0]), UC(p[1]));
+	return;
+
+pasv_error:
+	(void) close(pdata);
+	pdata = -1;
+	perror_reply(425, "Can't open passive connection");
+	return;
+}
+
+/*
+ * Generate unique name for file with basename "local".
+ * The file named "local" is already known to exist.
+ * Generates failure reply on error.
+ */
+static int guniquefd(const char *local, char **nam)
+{
+	static char newch[MAXPATHLEN];
+	struct stat st;
+	int count, len, fd;
+	char *cp;
+
+	cp = strrchr(local, '/');
+	if (cp)
+		*cp = '\0';
+	if (stat(cp ? local : ".", &st) < 0) {
+		perror_reply(553, cp ? local : ".");
+		return (-1);
+	}
+	if (cp)
+		*cp = '/';
+	(void) strncpy(newch, local, sizeof(newch)-1);
+	newch[sizeof(newch)-1] = '\0';
+	len = strlen(newch);
+	if (len+2+1 >= (int)sizeof(newch)-1)
+		return (-1);
+	cp = newch + len;
+	*cp++ = '.';
+	for (count = 1; count < 100; count++) {
+		(void)snprintf(cp, sizeof(newch) - (cp - newch), "%d", count);
+		fd = open(newch, O_RDWR|O_CREAT|O_EXCL, 0666);
+		if (fd == -1)
+			continue;
+		if (nam)
+			*nam = newch;
+		return (fd);
+	}
+	reply(452, "Unique file name cannot be created.");
+	return (-1);
+}
+
+/*
+ * Format and send reply containing system error number.
+ */
+void perror_reply(int code, const char *string)
+{
+
+	reply(code, "%s: %s.", string, strerror(errno));
+}
+
+static const char *onefile[] = {
+	"",
+	0
+};
+
+
+void send_file_list(const char *whichf, int simple)
+{
+	struct stat st;
+	DIR *dirp = NULL;
+	struct dirent *dir;
+	FILE *volatile dout = NULL;
+	char const *const *volatile dirlist;
+	const char *dirname;
+	//volatile int simple = 0;
+	volatile int freeglob = 0;
+	glob_t gl;
+	char time[26];
+
+	char internal_whichf[MAXPATHLEN];
+	
+	//remove modifier for hidden files "-a" 
+	if(whichf[0]=='-' && whichf[1]=='a')
+		{
+		strcpy(internal_whichf,whichf+2);
+		
+		//if target location is empty, set "."
+		if(internal_whichf[0]==0)
+			strcpy(internal_whichf,".");
+		
+		internalName(internal_whichf,internal_whichf);
+		}
+	else
+		{
+		internalName(internal_whichf,whichf);
+		}
+
+	
+	LOGCMD("send_file_list",internal_whichf);
+	
+	/* XXX: should the { go away if __linux__? */
+	
+	if((root && strcmp(internal_whichf, ".")==0) || strcmp(internal_whichf, "/")==0  )
+		{
+		if (dout == NULL) {
+		dout = dataconn("file list", (off_t)-1,
+			"w");
+		if (dout == NULL)
+			goto out;
+		transflag++;
+		}
+	
+		//get the drives list
+		RFs fileSystem;
+		fileSystem.Connect();
+		
+		TDriveList	driveList;
+		fileSystem.DriveList(driveList);
+	
+		
+		if (simple)
+			{
+			for(int i=0; i<driveList.Length(); i++)
+				{
+				if(driveList[i]!=0)
+					{
+					fprintf(dout,"%c%s\n", 'A'+i ,type == TYPE_A ? "\r" : "");
+					}
+				}
+			}
+		else
+			{
+			
+			for(int i=0; i<driveList.Length(); i++)
+				{
+				if(driveList[i]!=0)
+					{
+					fprintf(dout,"drw-------   1 ftp ftp         0 Jan 01  2008 %c%s\n", 'A'+i ,type == TYPE_A ? "\r" : "");
+					}
+				}
+			}
+		
+		fileSystem.Close();
+			
+		}
+	else
+		{
+		
+		if (strpbrk(whichf, "~{[*?") != NULL) {	
+	#ifdef __linux__
+		        /* see popen.c */
+			int flags = GLOB_NOCHECK;
+	#else
+			int flags = GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE;
+	#endif
+	
+			memset(&gl, 0, sizeof(gl));
+			freeglob = 1;
+			if (glob(internal_whichf, flags, 0, &gl)) {
+				reply(550, "not found");
+				goto out;
+			} else if (gl.gl_pathc == 0) {
+				errno = ENOENT;
+				perror_reply(550, whichf);
+				goto out;
+			}
+			/* The cast is necessary because of bugs in C's type system */
+			dirlist = (char const *const *) gl.gl_pathv;
+		} else {
+			onefile[0] = internal_whichf;
+			dirlist = onefile;
+		}
+	
+		if (setjmp(urgcatch)) {
+			transflag = 0;
+			goto out;
+		}
+		
+		 while ((dirname = *dirlist++)!=NULL) {
+			if (stat(dirname, &st) < 0) {
+				perror_reply(550, whichf);
+				if (dout != NULL) {
+					(void) fclose(dout);
+					transflag = 0;
+					data = -1;
+					pdata = -1;
+				}
+				goto out;
+			}
+	
+			if (S_ISREG(st.st_mode)) {
+				if (dout == NULL) {
+					dout = dataconn("file list", (off_t)-1, "w");
+					if (dout == NULL)
+						goto out;
+					transflag++;
+				}
+			} else if (!S_ISDIR(st.st_mode))
+				continue;
+	
+			if ((dirp = opendir(dirname)) == NULL)
+				continue;
+	
+			while ((dir = readdir(dirp)) != NULL) {
+				char nbuf[MAXPATHLEN];
+
+				if (dir->d_name[0] == '.' && dir->d_namlen == 1)
+					continue;
+				if (dir->d_name[0] == '.' && dir->d_name[1] == '.' &&
+				    dir->d_namlen == 2)
+					continue;
+
+				snprintf(nbuf, sizeof(nbuf), "%s/%s", dirname,
+				dir->d_name);
+	
+				/*
+				 * We have to do a stat to insure it's
+				 * not a directory or special file.
+				 */
+				stat(nbuf, &st);
+				
+				if (simple){
+					if (dout == NULL) {
+						dout = dataconn("file list", (off_t)-1,
+							"w");
+						if (dout == NULL)
+							goto out;
+						transflag++;
+					}
+					
+					fprintf(dout, "%s%s\n", dir->d_name, type == TYPE_A ? "\r" : "");
+					
+					byte_count += strlen(nbuf) + 1;
+				}
+				else //!simple
+					{
+					
+					if (dout == NULL) {
+					dout = dataconn("file list", (off_t)-1,
+						"w");
+					if (dout == NULL)
+						goto out;
+					transflag++;
+					}
+					
+					ctime_r(&st.st_atime,time);
+				    //"Mon Dec 10 17:35:44 2007"
+				    
+				    char month[4];
+				    month[0] = time[4]; //'D'
+				    month[1] = time[5]; //'e'
+				    month[2] = time[6]; //'c'
+				    month[3] = '\0';			    
+				    
+				    char day[3];
+				    day[0] = time[8]; //'1'
+				    day[1] = time[9]; //'0'
+				    day[2] = '\0';
+				    
+				    char year[5];
+				    year[0] = time[20]; //'2'
+	  			    year[1] = time[21]; //'0'			    
+	 			    year[2] = time[22]; //'0'
+	                year[3] = time[23]; //'7'
+	 			    year[4] = '\0';               
+				    
+				    
+				    fprintf(dout, "%c%c%c%c%c%c%c%c%c%c   1 ftp ftp %9jd %s %s  %s %s%s\n",
+				    	S_ISDIR(st.st_mode) ? 'd' : '-',
+			            st.st_mode & S_IRUSR ? 'r' : '-',
+			            st.st_mode & S_IWUSR ? 'w' : '-',
+	            		st.st_mode & S_IXUSR ? 'x' : '-',
+	            		st.st_mode & S_IRGRP ? 'r' : '-',
+	            		st.st_mode & S_IWGRP ? 'w' : '-',
+	            		st.st_mode & S_IXGRP ? 'x' : '-',
+	            		st.st_mode & S_IROTH ? 'r' : '-',
+	            		st.st_mode & S_IWOTH ? 'w' : '-',
+	            		st.st_mode & S_IXOTH ? 'x' : '-',
+			            st.st_size,
+			            month,
+			            day,
+			            year,
+			            dir->d_name,
+			            type == TYPE_A ? "\r" : ""
+			           );
+						
+					}
+			}
+			(void) closedir(dirp);
+		}
+	}
+	if (dout == NULL)
+		reply(550, "No files found.");
+	else if (ferror(dout) != 0)
+		perror_reply(550, "Data connection");
+	else
+		reply(226, "Transfer complete.");
+
+	transflag = 0;
+	if (dout != NULL)
+		(void) fclose(dout);
+	data = -1;
+	pdata = -1;
+out:
+	if (freeglob) {
+		freeglob = 0;
+		globfree(&gl);
+	}
+}
+
+void logxfer(const char *name, off_t size, time_t start)
+{
+	char buf[400 + MAXHOSTNAMELEN*4 + MAXPATHLEN*4];
+	char dir[MAXPATHLEN], path[MAXPATHLEN], rpath[MAXPATHLEN];
+	char vremotehost[MAXHOSTNAMELEN*4], vpath[MAXPATHLEN*4];
+	char *vpw;
+	time_t now;
+
+	if ((statfd >= 0) && (getcwd(dir, sizeof(dir)) != NULL)) {
+		time(&now);
+
+		vpw = (char *)malloc(strlen((guest) ? guestpw : pw->pw_name)*4+1);
+		if (vpw == NULL)
+			return;
+
+		snprintf(path, sizeof path, "%s/%s", dir, name);
+		if (realpath(path, rpath) == NULL) {
+			strncpy(rpath, path, sizeof rpath-1);
+			rpath[sizeof rpath-1] = '\0';
+		}
+
+		snprintf(buf, sizeof(buf),
+		    "%.24s %ld %s %qd %s %c %s %c %c %s ftp %d %s %s\n",
+		    ctime(&now), (long)(now - start + (now == start)),
+		    vremotehost, (long long) size, vpath,
+		    ((type == TYPE_A) ? 'a' : 'b'), "*" /* none yet */,
+		    'o', ((guest) ? 'a' : 'r'),
+		    vpw, 0 /* none yet */,
+		    ((guest) ? "*" : pw->pw_name),
+		    dhostname);
+		write(statfd, buf, strlen(buf));
+		free(vpw);
+	}
+}
+
+TDriveNumber getSystemDrive()
+	{
+	_LIT(KFileSrvDll, "efsrv.dll");
+	
+	TDriveNumber defaultSysDrive(EDriveC);
+	RLibrary pluginLibrary;
+	TInt pluginErr = pluginLibrary.Load(KFileSrvDll);
+	
+	if (pluginErr == KErrNone)
+		{
+		typedef TDriveNumber(*fun1)();
+		fun1 sysdrive;
+	
+	#ifdef __EABI__
+		sysdrive = (fun1)pluginLibrary.Lookup(336);
+	#else
+		sysdrive = (fun1)pluginLibrary.Lookup(304);
+	#endif
+		
+		if(sysdrive!=NULL)
+			{
+			defaultSysDrive = sysdrive();
+			}
+		}
+	pluginLibrary.Close();
+	return defaultSysDrive;
+	}
+
+in_addr getServerAddress()
+	{
+	
+	in_addr address;
+	
+	//default adddress to be returned if failure
+	inet_aton("0.0.0.0", &address);
+	
+	RSocketServ rSockServer;
+	if(KErrNone==rSockServer.Connect())
+    {
+    RConnection rConnect;
+    if(KErrNone==rConnect.Open(rSockServer))
+        {
+        TRequestStatus status; 
+        rConnect.Start(status);
+            
+        User::WaitForRequest(status); 
+        }
+    }
+	
+	TAutoClose<RSocketServ> ss;
+    User::LeaveIfError(ss.iObj.Connect());
+    ss.PushL();
+
+    TAutoClose<RSocket> sock;
+    User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp")));
+    sock.PushL();
+
+    User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl));
+
+    TProtocolDesc in;
+    User::LeaveIfError(sock.iObj.Info(in));
+    TPckgBuf<TSoInetInterfaceInfo> info, next;
+
+    TInt res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, info);
+	
+    while(res==KErrNone)
+        {
+		
+        res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, next);
+		if(info().iState != EIfUp || info().iFeatures&KIfIsLoopback || info().iName.Left(4) == _L("eth6")) 
+		{
+		info = next; continue;	
+		}
+		
+		TName address_descriptor;
+	    char address_string[16]; //xxx.xxx.xxx.xxx\0
+	    
+        info().iAddress.Output(address_descriptor);
+        
+        int i=0;
+        
+        for(i=0; i<address_descriptor.Length(); i++)
+        	{
+	        address_string[i]=address_descriptor[i];
+        	}
+        
+        address_string[i]='\0';
+        
+        inet_aton(address_string, &address);
+        
+        if(res==KErrNone)
+            {
+            info = next;
+         	}
+        }
+	
+    sock.Pop();
+    ss.Pop();
+    
+    rSockServer.Close();
+    
+    return address;
+	}
+
+
+void sizecmd(char *filename)
+{
+
+	char internalFilename[MAXPATHLEN];
+
+	internalName(internalFilename,filename);
+
+	switch (type) {
+	case TYPE_L:
+	case TYPE_I: 
+	case TYPE_A: {
+		struct stat stbuf;
+		if (stat(internalFilename, &stbuf) < 0 || !S_ISREG(stbuf.st_mode))
+			reply(550, "%s: not a plain file.", filename);
+		else
+			reply(213, "%qu", (quad_t) stbuf.st_size);
+		break; }
+	default:
+		reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/src/logutmp.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,152 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/*
+ * Portions Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * Portions Copyright (c) 1996, Jason Downs.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * From: OpenBSD: logutmp.c,v 1.1 1996/06/18 10:09:23 downsj Exp
+ * From: OpenBSD: logutmp.c,v 1.2 1998/07/13 02:11:17 millert Exp
+ */
+char logutmp_rcsid[] =
+  "$Id: logutmp.c,v 1.4 1999/07/16 01:12:54 dholland Exp $";
+
+#include <sys/types.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <utmp.h>
+#include <stdio.h>
+#include <string.h>
+//#ifndef __linux__
+//#include <ttyent.h>
+//#endif
+#include "extern.h"
+
+typedef struct utmp UTMP;
+
+#ifndef __linux__
+static int fd = -1;
+static int topslot = -1;
+#endif
+
+/*
+ * Special versions of login()/logout() which hold the utmp file open,
+ * for use with ftpd.
+ */
+
+void
+login(const UTMP *ut)
+{
+#ifndef __linux__
+	UTMP ubuf;
+
+	/*
+	 * First, loop through /etc/ttys, if needed, to initialize the
+	 * top of the tty slots, since ftpd has no tty.
+	 */
+	if (topslot < 0) {
+		topslot = 0;
+	}
+	if ((topslot < 0) || ((fd < 0)
+	    && (fd = open(_PATH_UTMP, O_RDWR|O_CREAT, 0644)) < 0))
+	    	return;
+
+	/*
+	 * Now find a slot that's not in use...
+	 */
+	(void)lseek(fd, (off_t)(topslot * sizeof(UTMP)), SEEK_SET);
+
+	while (1) {
+		if (read(fd, &ubuf, sizeof(UTMP)) == sizeof(UTMP)) {
+			if (!ubuf.ut_name[0]) {
+				(void)lseek(fd, -(off_t)sizeof(UTMP), SEEK_CUR);
+				break;
+			}
+			topslot++;
+		} else {
+			(void)lseek(fd, (off_t)(topslot * sizeof(UTMP)), SEEK_SET);
+			break;
+		}
+	}
+
+	(void)write(fd, ut, sizeof(UTMP));
+#else
+	(void)ut;
+#endif
+}
+
+int
+logout(register const char *line)
+{
+#ifndef __linux__
+	UTMP ut;
+	int rval;
+
+	rval = 0;
+	if (fd < 0)
+		return(rval);
+
+	(void)lseek(fd, 0, SEEK_SET);
+
+	while (read(fd, &ut, sizeof(UTMP)) == sizeof(UTMP)) {
+		if (!ut.ut_name[0]
+		    || strncmp(ut.ut_line, line, UT_LINESIZE))
+			continue;
+		bzero(ut.ut_name, UT_NAMESIZE);
+		bzero(ut.ut_host, UT_HOSTSIZE);
+		(void)lseek(fd, -(off_t)sizeof(UTMP), SEEK_CUR);
+		(void)write(fd, &ut, sizeof(UTMP));
+		rval = 1;
+	}
+	return(rval);
+#else
+	(void)line;
+	return 1;
+#endif
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/src/popen.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,163 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+/*
+ * Copyright (c) 1988, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software written by Ken Arnold and
+ * published in UNIX Review, Vol. 6, No. 8.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+/*
+ * From: @(#)popen.c	8.3 (Berkeley) 4/6/94
+ * From: NetBSD: popen.c,v 1.5 1995/04/11 02:45:00 cgd Exp
+ * From: OpenBSD: popen.c,v 1.8 1996/12/07 10:52:06 bitblt Exp
+ * From: OpenBSD: popen.c,v 1.10 1999/02/26 00:15:54 art Exp
+ */
+char popen_rcsid[] = 
+  "$Id: popen.c,v 1.6 1999/07/16 01:12:54 dholland Exp $";
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <arpa/ftp.h>
+
+#include <errno.h>
+#include <glob.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <dirent.h>
+
+#include "extern.h"
+
+
+//#define SIG_BLOCK 1	/* set of signals to block */
+//#define SIG_SETMASK 0	/* set mask with sigprocmask() */
+
+/*
+ * Special version of popen which avoids call to shell.  This ensures noone
+ * may create a pipe to a hidden program as a side effect of a list or dir
+ * command.
+ *
+ * Note: destroys "program".
+ */
+static int *pids;
+
+
+extern int root;
+extern int type;
+extern off_t	byte_count;
+
+
+#define MAX_ARGV	100
+#define MAX_GARGV	1000
+
+
+FILE *
+ftpd_popen(char *program, const char *type)
+{
+	FILE *volatile iop;
+	int pdes[2];
+
+	if ((*type != 'r' && *type != 'w') || type[1])
+		return (NULL);
+
+
+	if (pipe(pdes) < 0)
+		return (NULL);
+	
+	
+	 if (( iop = popen(program, "r")) == NULL)
+		    {
+			 return (NULL);
+		    }
+	
+	if (*type == 'r') {
+	iop = fdopen(pdes[0], type);
+	(void)close(pdes[1]);
+ 	} else {
+	iop = fdopen(pdes[1], type);
+	(void)close(pdes[0]);
+ 	}
+	
+
+	return (iop);
+}
+
+int
+ftpd_pclose(FILE *iop)
+{
+	int fdes, status;
+	pid_t pid;
+	
+	/*
+	 * pclose returns -1 if stream is not associated with a
+	 * `popened' command, or, if already `pclosed'.
+	 */
+	if (pids == 0 || pids[fdes = fileno(iop)] == 0)
+		return (-1);
+	(void)fclose(iop);
+
+	while ((pid = waitpid(pids[fdes], &status, 0)) < 0 && errno == EINTR)
+		continue;
+	pids[fdes] = 0;
+	if (pid < 0)
+		return (pid);
+	if (WIFEXITED(status))
+		return (WEXITSTATUS(status));
+	return (1);
+}
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/.classpath	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="lib" path="./lib/junit.jar"/>
+	<classpathentry kind="lib" path="./lib/jakarta-oro-2.0.8.jar"/>
+	<classpathentry kind="lib" path="./lib/commons-net-1.4.1.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/.project	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>test_ftpd</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Binary file genericunixprotocols/ftpsrv/test/bin/FTPPassiveTest.class has changed
Binary file genericunixprotocols/ftpsrv/test/bin/FTPTest.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/bin/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
Binary file genericunixprotocols/ftpsrv/test/data/bigfile.bin has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/data/bigfile.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,64 @@
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/data/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
Binary file genericunixprotocols/ftpsrv/test/data/smallfile.bin has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/data/smallfile.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,64 @@
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
+hello
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
Binary file genericunixprotocols/ftpsrv/test/lib/commons-net-1.4.1.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/lib/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
Binary file genericunixprotocols/ftpsrv/test/lib/jakarta-oro-2.0.8.jar has changed
Binary file genericunixprotocols/ftpsrv/test/lib/junit.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/src/FTPPassiveTest.java	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,27 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+public class FTPPassiveTest extends FTPTest {
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	
+	protected void setPassive()
+	{
+		ftpClient.enterLocalPassiveMode();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/src/FTPTest.java	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1194 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.net.ftp.FTP;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPFile;
+import org.apache.commons.net.ftp.FTPReply;
+
+
+
+
+/** 
+ * @author JavierM
+ * 
+ */
+public abstract class FTPTest extends TestCase {
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	FTPClient ftpClient = new FTPClient();
+	
+	protected void setUp() throws Exception {
+		super.setUp();
+		
+		String address = System.getProperty("address");
+		
+		ftpClient.connect(/*"10.16.160.35"*/address);
+		ftpClient.user("me");
+		ftpClient.pass("friend");
+		
+		ftpClient.setBufferSize(1460*10);
+		
+		setPassive();
+	}
+
+	protected void setPassive()
+	{
+		ftpClient.enterLocalActiveMode();
+	}
+	
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		
+		ftpClient.logout();
+		ftpClient.disconnect();
+	}
+	
+	
+//	public void testUploadFileInSmallChunks() throws IOException
+//	{
+//		
+//		byte b[] = new byte[1];
+//		
+//		String sentence = new String(b);//"El veloz murciélago hind?comía feliz cardillo y kiwi\r\n";
+//		int times =  10000;
+//		
+//		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+//		
+//		//BINARY
+//		
+//		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+//		
+//		OutputStream out = ftpClient.storeFileStream("test.txt");
+//		assertNotNull(out);
+//		
+//		for (int i = 0; i < times; i++) {
+//			out.write(sentence.getBytes());	
+//			out.flush();
+//			System.out.print(".");
+//		}
+//		
+//		out.close();
+//		assertTrue(ftpClient.completePendingCommand());
+//		
+//		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/test.txt")));
+//		assertEquals(times*sentence.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+//		
+//		ftpClient.deleteFile("/C/test.txt");
+//		
+//		//ASCII
+//		
+//		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+//		
+//		out = ftpClient.storeFileStream("test.txt");
+//		assertNotNull(out);
+//		
+//		for (int i = 0; i < times; i++) {
+//			out.write(sentence.getBytes());	
+//		}
+//		
+//		out.close();
+//		assertTrue(ftpClient.completePendingCommand());
+//		
+//		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/test.txt")));
+//		assertEquals(times*sentence.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+//		
+//		ftpClient.deleteFile("/C/test.txt");
+//		
+//	}
+	
+	
+	public void testSyst()  throws IOException
+	{
+		String name = ftpClient.getSystemName();
+		assertEquals(name,"UNIX Type: L8");
+		
+	}
+	
+	
+	
+	public void testListDrives()  throws IOException{
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		FTPFile[] drives = ftpClient.listFiles();
+		
+		assertNotNull(drives);
+		
+		for (int i = 0; i < drives.length; i++) {
+			
+			String driveName  = drives[i].getName();
+			
+			assertTrue(driveName.length()==1 && 
+					   driveName.charAt(0) >= 'A' && 
+					   driveName.charAt(0) <= 'Z');
+		}
+		
+		String[] names = ftpClient.listNames();
+		
+		assertNotNull(names);
+		
+		for (int i = 0; i < drives.length; i++) {
+			
+			String driveName  = names[i];
+			
+			assertTrue(driveName.length()==1 && 
+					   driveName.charAt(0) >= 'A' && 
+					   driveName.charAt(0) <= 'Z');
+		}
+		
+		
+	}
+	
+	public void testListFiles()  throws IOException{
+		
+		FTPFile[] files;
+			
+		//UNIX parseable contents on C	
+			
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		files = ftpClient.listFiles();
+		
+		assertNotNull(files);
+		
+		//UNIX parseable contents on Z	
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/Z")));
+		files = ftpClient.listFiles();
+		assertNotNull(files); 
+		
+	}
+	
+public void testListLocation() throws IOException{
+		
+		
+		FTPFile[] files1;
+		FTPFile[] files2;
+		
+		//UNIX parseable contents on /C/System	
+			
+		files1 = ftpClient.listFiles("/C/System");
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C/System")));
+		files2 = ftpClient.listFiles();
+		
+		assertEquals(files2.length, files1.length);
+
+		
+		
+		//UNIX parseable contents on root	
+		
+ 		files1 = ftpClient.listFiles("/");
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		files2 = ftpClient.listFiles();
+		
+		assertEquals(files2.length, files1.length);
+		
+		//UNIX parseable contents on /C	
+		
+		files1 = ftpClient.listFiles("/C");
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		files2 = ftpClient.listFiles();
+		
+		assertEquals(files2.length, files1.length);
+
+	
+	}
+	
+	
+	public void testCreateDeleteFolder() throws IOException
+	{
+		//clean up
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		ftpClient.removeDirectory("testFolder");
+		
+		
+		assertTrue(ftpClient.makeDirectory("testFolder"));
+		ftpClient.removeDirectory("testFolder");
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertTrue(ftpClient.makeDirectory("/C/testFolder"));
+		assertTrue(ftpClient.removeDirectory("/C/testFolder"));
+		
+		
+		//clean up
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		ftpClient.removeDirectory("testFolder");
+		
+		
+	}
+	
+	
+	public void testStoreBinaryFile() throws IOException
+	{
+		
+		//for (int i = 0; i < 20; i++) {
+			assertTrue(ftpClient.storeFile("/C/testDriver_TEF_0x10210D31.sis", new FileInputStream("d:\\testDriver_TEF_0x10210D32.sis")));
+			ftpClient.deleteFile("/C/testDriver_TEF_0x10210D31.sis");
+		//	System.out.println(i);
+		//}
+	}
+	
+	public void testStoreAsciiFile() throws IOException
+	{
+		
+		//for (int i = 0; i < 20; i++) {
+		//	assertTrue(ftpClient.storeFile("/C/donquixote.txt", new FileInputStream("./data/donquixote.txt")));
+			ftpClient.deleteFile("/C/donquixote.txt");
+		//	System.out.println(i);
+		//}
+	}
+	
+	
+	public void testCreateDeleteFile() throws IOException
+	{
+		
+		//clean possible previous failed tests
+		ftpClient.deleteFile("/C/test.txt");
+		
+		//from same location
+		
+		OutputStream out = ftpClient.storeFileStream("/C/test.txt");
+		assertNotNull(out);
+		out.write("test file".getBytes());
+		out.close();
+		ftpClient.completePendingCommand();
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		assertTrue(ftpClient.deleteFile("test.txt"));
+		
+		//from different location
+		
+		out = ftpClient.storeFileStream("/C/test.txt");
+		assertNotNull(out);
+		out.write("test file".getBytes());
+		out.close();
+		ftpClient.completePendingCommand();
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertTrue(ftpClient.deleteFile("/C/test.txt"));
+		
+	}
+	
+	public void testRename() throws IOException {
+		
+		OutputStream out = ftpClient.storeFileStream("/C/test.txt");
+		assertNotNull(out);
+		out.write("test file".getBytes());
+		out.close();
+		ftpClient.completePendingCommand();
+		
+		//from directory to same directory
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		assertTrue(ftpClient.rename("test.txt", "test2.txt"));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size test2.txt")));
+		
+		//from different directory
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertTrue(ftpClient.rename("/C/test2.txt", "/C/test.txt"));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size test.txt")));
+		
+		assertTrue(ftpClient.deleteFile("/C/test.txt"));
+		
+	}
+	
+	public void testMove() throws IOException {
+		
+		OutputStream out = ftpClient.storeFileStream("/C/test.txt");
+		assertNotNull(out);
+		out.write("test file".getBytes());
+		out.close();
+		ftpClient.completePendingCommand();
+		
+		assertTrue(ftpClient.makeDirectory("/C/testFolder"));
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertTrue(ftpClient.rename("/C/test.txt", "/C/testFolder/test.txt"));
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C/testFolder")));
+		assertTrue(ftpClient.rename("test.txt", "/C/test.txt"));
+		assertTrue(ftpClient.rename("/C/test.txt", "test.txt"));
+		
+		assertTrue(ftpClient.deleteFile("/C/testFolder/test.txt"));
+		assertTrue(ftpClient.removeDirectory("/C/testFolder"));
+		
+	}
+	
+	public void testCdup() throws IOException {
+		
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C/system")));
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cdup()));
+		assertEquals("/C", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cdup()));
+		assertEquals("/", ftpClient.printWorkingDirectory());
+		
+	}
+	
+	public void testBrowse() throws IOException {
+	
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertEquals("/", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("C")));
+		assertEquals("/C", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("system")));
+		assertEquals("/C/system", ftpClient.printWorkingDirectory());
+	
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertEquals("/", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C/system")));
+		assertEquals("/C/system", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertEquals("/", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C/system/.././system")));
+		assertEquals("/C/system", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("..")));
+		assertEquals("/C", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("..")));
+		assertEquals("/", ftpClient.printWorkingDirectory());
+		
+			
+		
+	}
+	
+	public void testHelp() throws IOException {
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("help")));
+		
+	}
+	
+	public void testStat() throws IOException {
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.stat()));
+		
+	}
+	
+	public void testWrongCommands() throws IOException {
+		
+		assertTrue(FTPReply.isNegativePermanent(ftpClient.sendCommand("!\"?%^&*())__+")));
+		assertTrue(FTPReply.isNegativePermanent(ftpClient.sendCommand("asdasdasdasdsdjkklahsdjkajkhsdkhajksdasjkdjkasjkdhasjkdhasdhjkashdjkhasjkdhasjdhjkashdjkhasjkdhjkashashdhasjdhjashdjhasjkhdjkashdhjkashdjkashdhasdkhasdjkahskdajkshdjkashdjkashdjkashdjkashjkdhasjkdhkashkdhasdjkahsjkdhasjkhdjkashdjkhaskdjhajkshdjkahsdjkahsdkjahksdh")));
+		assertTrue(FTPReply.isNegativePermanent(ftpClient.sendCommand("asda sda sda sd sdj kk  l   \t	ahs \n \r")));
+		
+	}
+	
+	public void testGetSystemDrive() throws IOException{
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.stat()));
+		String s = ftpClient.getReplyString();
+		assertNotNull(s);
+		
+		Pattern p = Pattern.compile(".*System Drive: (\\w).*", Pattern.DOTALL); //Pattern.DOTALL => '.' includes end of line
+		Matcher m = p.matcher(s);
+		assertTrue(m.matches());
+		
+	}
+	
+	public void testSize() throws IOException {
+		
+		//try{
+		String testString = "test file";
+		
+		OutputStream out = ftpClient.storeFileStream("/C/test.txt");
+		assertNotNull(out);
+		out.write(testString.getBytes());
+		out.close();
+		ftpClient.completePendingCommand();
+		
+		//absolute
+		//file
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/test.txt")));
+		assertEquals(testString.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		
+		//folder
+		assertTrue(FTPReply.isNegativePermanent(ftpClient.sendCommand("size /C/system")));
+		assertTrue(ftpClient.getReplyString().matches(".*not a plain file.*\r\n"));
+		
+		
+		//relative
+		//file
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size test.txt")));
+		assertEquals(testString.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		
+		//folder
+		assertTrue(FTPReply.isNegativePermanent(ftpClient.sendCommand("size system")));
+		assertTrue(ftpClient.getReplyString().matches(".*not a plain file.*\r\n"));
+		
+		ftpClient.deleteFile("/C/test.txt");
+	}
+	
+	
+	//FTP&Telnet-File Transfer-001
+	//To Transfer a file of size 0 from Pc to device (H2 /H4) from current working directory
+	
+	public void testFTP_Telnet_File_Transfer_001() throws IOException {
+		
+		String fileUnderTest = "emptyFile";
+		
+		File f = new File("./data/"+fileUnderTest);
+		
+		if(!f.exists())
+		{
+			f.createNewFile();
+		}
+		
+		//ASCII
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		ftpClient.deleteFile("/C/"+fileUnderTest);
+		
+		//BINARY
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		ftpClient.deleteFile("/C/"+fileUnderTest);
+		
+	}
+	
+	//FTP&Telnet-File Transfer-002
+	//To Transfer a file of normal size  from Pc to device (H2 /H4) from current working directory
+	
+	public void testFTP_Telnet_File_Transfer_002_ASCII() throws IOException {
+		
+		String fileUnderTest = "smallfile.txt";
+		File f = new File("./data/"+fileUnderTest);
+		
+		//ASCII
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+		//BINARY
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+	}
+	
+	//FTP&Telnet-File Transfer-002
+	//To Transfer a file of normal size  from Pc to device (H2 /H4) from current working directory
+	
+	public void testFTP_Telnet_File_Transfer_002_BINARY() throws IOException {
+		
+		String fileUnderTest = "smallfile.bin";
+		File f = new File("./data/"+fileUnderTest);
+		
+		//ASCII
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertTrue(f.length() != Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+		//BINARY
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+	}
+	
+	
+	//FTP&Telnet-File Transfer-003
+	//To Transfer a file of Large size  from Pc to device (H2 /H4) from current working directory
+	
+	public void testFTP_Telnet_File_Transfer_003_ASCII() throws IOException {
+		
+		String fileUnderTest = "bigfile.txt";
+		File f = new File("./data/"+fileUnderTest);
+		
+		//ASCII
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+		//BINARY
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+	}
+	
+	public void testFTP_Telnet_File_Transfer_003_BINARY() throws IOException {
+		
+		String fileUnderTest = "bigfile.bin";
+		File f = new File("./data/"+fileUnderTest);
+		
+		//ASCII
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertTrue(f.length() != Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+		//BINARY
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+	}
+	
+	//FTP&Telnet-Connection-003
+	//To change the mode of transfer from remote host to Device (H2/H4)
+	public void testFTP_Telnet_Connection_Execution_003() throws IOException
+	{
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+	}
+	
+	//FTP&Telnet-File Transfer-007
+	//To Transfer a file from Pc to device (H2 /H4) from  working directory to non Existence directory
+	public void testFTP_Telnet_File_Transfer_007_ASCII_Mode() throws IOException
+	{
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		assertFalse(ftpClient.storeFile("/C/nonexistingfolder/smallfile.txt", new FileInputStream("./data/smallfile.txt")));
+	}
+	
+	//FTP&Telnet-File Transfer-007
+	//To Transfer a file from Pc to device (H2 /H4) from  working directory to non Existence directory
+	public void testFTP_Telnet_File_Transfer_007_BINARY_Mode() throws IOException
+	{
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		assertFalse(ftpClient.storeFile("/C/nonexistingfolder/smallfile.txt", new FileInputStream("./data/smallfile.txt")));
+	}
+	
+	//FTP&Telnet-File Retrieve-001
+	//To Retrieve a file of size 0 from device to PC
+	
+	public void testFTP_Telnet_File_Retrieve_001() throws IOException {
+		
+		String fileUnderTest = "emptyFile";
+		
+		File f = new File("./data/"+fileUnderTest);
+		
+		if(!f.exists())
+			f.createNewFile();
+		
+		f.deleteOnExit();
+		
+		//upload and verify correctly uploaded
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		
+		
+		//download file
+		
+		File f2 = File.createTempFile("FTP_Telnet_File_Retrieve_001",".txt");
+		File f3 = File.createTempFile("FTP_Telnet_File_Retrieve_001",".bin");
+		f2.deleteOnExit();
+		f3.deleteOnExit();
+		
+		//ASCII download
+		
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		assertTrue(ftpClient.retrieveFile("/C/"+fileUnderTest, new FileOutputStream(f2)));
+		assertEquals(f.length(), f2.length());
+		
+		//BINARY download
+		
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		assertTrue(ftpClient.retrieveFile("/C/"+fileUnderTest, new FileOutputStream(f3)));
+		assertEquals(f.length(), f3.length());
+		
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+	}
+	
+	//FTP&Telnet-File Retrieve-002
+	//To Retrieve a file of normal size  from device to Pc 
+	
+	public void testFTP_Telnet_File_Retrieve_002_ASCII() throws IOException {
+		
+		String fileUnderTest = "smallfile.txt";
+		File f = new File("./data/"+fileUnderTest);
+		
+		//ASCII
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		
+		//download file
+		
+		File f2 = File.createTempFile("FTP_Telnet_File_Retrieve_002_ASCII",".txt");
+		File f3 = File.createTempFile("FTP_Telnet_File_Retrieve_002_ASCII",".bin");
+		f3.deleteOnExit();
+		f2.deleteOnExit();
+		
+		//ASCII download
+		
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		assertTrue(ftpClient.retrieveFile("/C/"+fileUnderTest, new FileOutputStream(f2)));
+		assertEquals(f.length(), f2.length());
+		
+		//BINARY download
+		
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		assertTrue(ftpClient.retrieveFile("/C/"+fileUnderTest, new FileOutputStream(f3)));
+		assertEquals(f.length(), f3.length());
+		
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+	}
+	
+	//FTP&Telnet-File Retrieve-002
+	//To Transfer a file of normal size  from  device to pc
+	
+	public void testFTP_Telnet_File_Retrieve_002_BINARY() throws IOException {
+		
+		String fileUnderTest = "smallfile.bin";
+		File f = new File("./data/"+fileUnderTest);
+		
+		//BINARY
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		
+		//download file
+		
+		File f2 = File.createTempFile("FTP_Telnet_File_Retrieve_002_BINARY",".txt");
+		File f3 = File.createTempFile("FTP_Telnet_File_Retrieve_002_BINARY",".bin");
+		f2.deleteOnExit();
+		f3.deleteOnExit();
+		
+		//ASCII download
+		
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		assertTrue(ftpClient.retrieveFile("/C/"+fileUnderTest, new FileOutputStream(f2)));
+		assertEquals(f.length() , f2.length());
+		
+		//BINARY download
+		
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		assertTrue(ftpClient.retrieveFile("/C/"+fileUnderTest, new FileOutputStream(f3)));
+		assertEquals(f.length(), f3.length());
+		
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+		
+		
+	}
+	
+	
+	//FTP&Telnet-File Retrieve-003
+	//To Transfer a file of Large size  from device to pc
+	
+	public void testFTP_Telnet_File_Retrieve_003_ASCII() throws IOException {
+		
+		String fileUnderTest = "bigfile.txt";
+		File f = new File("./data/"+fileUnderTest);
+		
+		//ASCII
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+	
+		//download file
+		
+		File f2 = File.createTempFile("testFTP_Telnet_File_Retrieve_003_ASCII",".txt");
+		File f3 = File.createTempFile("testFTP_Telnet_File_Retrieve_003_ASCII",".bin");
+		f2.deleteOnExit();
+		
+		//ASCII download
+		
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		assertTrue(ftpClient.retrieveFile("/C/"+fileUnderTest, new FileOutputStream(f2)));
+		assertEquals(f.length(), f2.length());
+		
+		//BINARY download
+		
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		assertTrue(ftpClient.retrieveFile("/C/"+fileUnderTest, new FileOutputStream(f3)));
+		assertEquals(f.length(), f3.length());
+		
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+	}
+	
+	//FTP&Telnet-File Retrieve-003
+	//To Transfer a file of Large size from device to pc
+	
+	
+	public void testFTP_Telnet_File_Retrieve_003_BINARY() throws IOException {
+		
+		String fileUnderTest = "bigfile.bin";
+		File f = new File("./data/"+fileUnderTest);
+		
+		//BINARY
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		
+		//download file
+		
+		File f2 = File.createTempFile("FTP_Telnet_File_Retrieve_003_BINARY",".txt");
+		File f3 = File.createTempFile("FTP_Telnet_File_Retrieve_003_BINARY",".bin");
+		f2.deleteOnExit();
+		f3.deleteOnExit();
+		
+		//ASCII download
+		
+		assertTrue(ftpClient.setFileType(FTP.ASCII_FILE_TYPE));
+		assertTrue(ftpClient.retrieveFile("/C/"+fileUnderTest, new FileOutputStream(f2)));
+		assertEquals(f.length() , f2.length());
+		
+		//BINARY download
+		
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		assertTrue(ftpClient.retrieveFile("/C/"+fileUnderTest, new FileOutputStream(f3)));
+		assertEquals(f.length(), f3.length());
+		
+		
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+	}
+	
+  	//FTP&Telnet-File Retrieve-009
+	//retrieve from non-existing directory
+	
+	public void testFTP_Telnet_File_Retrieve_009() throws IOException {
+		
+		assertFalse(ftpClient.retrieveFile("/C/nonexisting", System.out));
+		
+	}
+	
+	//FTP&Telnet-File Retrieve-016
+	//To Retrieve  a Directory from  device (H2 /H4) to PC
+	
+	public void testFTP_Telnet_File_Retrieve_016() throws IOException {
+		
+		assertFalse(ftpClient.retrieveFile("/C/system", System.out));
+		
+	}
+	
+	//FTP&Telnet-File Delete-001
+	//To Delete  a file of size 0 from Pc
+	
+	public void testFTP_Telnet_File_Delete_001() throws IOException {
+		
+		String fileUnderTest = "emptyFile";
+		
+		File f = new File("./data/"+fileUnderTest);
+		
+		//upload and verify correctly uploaded
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+		assertTrue(FTPReply.isNegativePermanent(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+	}
+	
+	//FTP&Telnet-File Delete-003
+	//To Delete a file of normal size on Device (H2/H4)  from Pc
+	public void testFTP_Telnet_File_Delete_003() throws IOException {
+		
+		String fileUnderTest = "smallfile.bin";
+		File f = new File("./data/"+fileUnderTest);
+		
+		//BINARY
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+		assertTrue(FTPReply.isNegativePermanent(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+	}
+	
+	//FTP&Telnet-File Delete-004
+	//To Delete a file of Large size on Device (H2/H4)  from Pc
+	public void testFTP_Telnet_File_Delete_004() throws IOException {
+		
+		String fileUnderTest = "bigfile.bin";
+		File f = new File("./data/"+fileUnderTest);
+		
+		//BINARY
+		assertTrue(ftpClient.setFileType(FTP.BINARY_FILE_TYPE));
+		
+		assertTrue(ftpClient.storeFile("/C/"+fileUnderTest, new FileInputStream(f)));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+		assertEquals(f.length(), Integer.parseInt(ftpClient.getReplyString().substring(4).trim()));
+		
+		assertTrue(ftpClient.deleteFile("/C/"+fileUnderTest));
+		
+		assertTrue(FTPReply.isNegativePermanent(ftpClient.sendCommand("size /C/"+fileUnderTest)));
+	}
+	
+	//FTP&Telnet-File Delete-006
+	//To Delete a non existent  file on Device (H2/H4)  from Pc
+	public void testFTP_Telnet_File_Delete_006() throws IOException {
+		
+		assertFalse(ftpClient.deleteFile("/C/nonexistingfile"));
+	}
+	
+	//FTP&Telnet-File Retrieve-018
+	//To Retrieve a drive listing on Device (H2/H4)  from Pc
+	public void testFTP_Telnet_File_Retrieve_018() throws IOException {
+
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		FTPFile[] drives = ftpClient.listFiles();
+
+		assertNotNull(drives);
+
+		for (int i = 0; i < drives.length; i++) {
+
+			String driveName = drives[i].getName();
+
+			assertTrue(driveName.length() == 1 && driveName.charAt(0) >= 'A'
+					&& driveName.charAt(0) <= 'Z');
+		}
+
+	}
+	
+	
+	// FTP&Telnet-File Retrieve-019
+	//To Retrieve a directory listing on Device (H2/H4)  from Pc
+	
+	public void testFTP_Telnet_File_Retrieve_019()  throws IOException{
+		
+		FTPFile[] files;
+			
+		//UNIX parseable contents on C	
+			
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		files = ftpClient.listFiles();
+		
+		assertNotNull(files);
+		
+		//UNIX parseable contents on Z	
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/Z")));
+		files = ftpClient.listFiles();
+		assertNotNull(files); 
+		
+	}
+	
+	//FTP&Telnet-File Retrieve-020
+	//To check a particular file/Folder on Device (H2/H4)  from Pc
+	
+	public void testFTP_Telnet_File_Retrieve_020()  throws IOException{
+		
+		FTPFile[] files;
+		String[] names;
+		
+		boolean found = false;
+		
+		//folder
+		//List C:\System
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		files = ftpClient.listFiles();
+		
+		for (int i = 0; i < files.length; i++) {
+			if(files[i].getName().equalsIgnoreCase("System") && files[i].isDirectory())
+				found = true;
+		}
+		
+		assertTrue(found);
+		
+		found = false;
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		
+		names = ftpClient.listNames();
+		
+		for (int i = 0; i < names.length; i++) {
+			if(names[i].equalsIgnoreCase("System"))
+				found = true;
+		}
+		
+		assertTrue(found);
+		
+		found = false;
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		
+		files = ftpClient.listFiles("/C");
+		
+		for (int i = 0; i < files.length; i++) {
+			if(files[i].getName().equalsIgnoreCase("System") && files[i].isDirectory())
+				found = true;
+		}
+		
+		assertTrue(found);
+		
+		
+		found = false;
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		
+		names = ftpClient.listNames("/C");
+		
+		for (int i = 0; i < names.length; i++) {
+			if(names[i].equalsIgnoreCase("System"))
+				found = true;
+		}
+		
+		assertTrue(found);
+		
+		
+		found = false;
+		
+		//file
+		//List C:\System\System.ini	
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C/System")));
+		files = ftpClient.listFiles();
+		
+		for (int i = 0; i < files.length; i++) {
+			if(files[i].getName().equalsIgnoreCase("System.ini") && files[i].isFile())
+				found = true;
+		}
+		
+		assertTrue(found);
+		
+		found = false;
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C/System")));
+		
+		names = ftpClient.listNames();
+		
+		for (int i = 0; i < names.length; i++) {
+			if(names[i].equalsIgnoreCase("System.ini"))
+				found = true;
+		}
+		
+		assertTrue(found);
+		
+		found = false;
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		files = ftpClient.listFiles("/C/System");
+		
+		for (int i = 0; i < files.length; i++) {
+			if(files[i].getName().equalsIgnoreCase("System.ini") && files[i].isFile())
+				found = true;
+		}
+		
+		assertTrue(found);
+		
+		
+		found = false;
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		
+		names = ftpClient.listNames("/C/System");
+		
+		for (int i = 0; i < names.length; i++) {
+			if(names[i].equalsIgnoreCase("System.ini"))
+				found = true;
+		}
+		
+		assertTrue(found);
+		
+		
+	}
+	
+	//FTP&Telnet-Directory-001 + 002
+	//To create a  Directory on device(H2/H4) from PC Side
+	//To Remove a  Directory on device(H2/H4) from PC Side
+	
+	public void testFTP_Telnet_Directory_001()  throws IOException{
+		
+		boolean found = false;
+		
+		//create folder
+		assertTrue(ftpClient.makeDirectory("/C/newFolder"));
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		FTPFile[] files = ftpClient.listFiles();
+		
+		for (int i = 0; i < files.length; i++) {
+			if(files[i].getName().equalsIgnoreCase("newFolder") && files[i].isDirectory())
+				found = true;
+		}
+		
+		assertTrue(found);
+		
+		found = false;
+		
+		//delete folder
+		assertTrue(ftpClient.removeDirectory("/C/newFolder"));
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		files = ftpClient.listFiles();
+		
+		for (int i = 0; i < files.length; i++) {
+			if(files[i].getName().equalsIgnoreCase("newFolder") && files[i].isDirectory())
+				found = true;
+		}
+		
+		assertFalse(found);
+				
+	}
+	
+	//FTP&Telnet-Directory-003
+	//To Rename a  file on device(H2/H4) from PC Side
+	
+	public void testFTP_Telnet_Directory_003()  throws IOException{
+		
+		OutputStream out = ftpClient.storeFileStream("/C/test.txt");
+		assertNotNull(out);
+		out.write("test file".getBytes());
+		out.close();
+		ftpClient.completePendingCommand();
+		
+		//from directory to same directory
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C")));
+		assertTrue(ftpClient.rename("test.txt", "test2.txt"));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size test2.txt")));
+		
+		//from different directory
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertTrue(ftpClient.rename("/C/test2.txt", "/C/test.txt"));
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.sendCommand("size test.txt")));
+		
+		assertTrue(ftpClient.deleteFile("/C/test.txt"));
+	}
+	
+	//FTP&Telnet-Directory-004
+	//To Move a  file on device(H2/H4) from PC Side
+	
+	public void testFTP_Telnet_Directory_004()  throws IOException{
+		OutputStream out = ftpClient.storeFileStream("/C/test.txt");
+		assertNotNull(out);
+		out.write("test file".getBytes());
+		out.close();
+		ftpClient.completePendingCommand();
+		
+		assertTrue(ftpClient.makeDirectory("/C/testFolder"));
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertTrue(ftpClient.rename("/C/test.txt", "/C/testFolder/test.txt"));
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C/testFolder")));
+		assertTrue(ftpClient.rename("test.txt", "/C/test.txt"));
+		assertTrue(ftpClient.rename("/C/test.txt", "test.txt"));
+		
+		assertTrue(ftpClient.deleteFile("/C/testFolder/test.txt"));
+		assertTrue(ftpClient.removeDirectory("/C/testFolder"));
+	}
+	
+	//FTP&Telnet-Directory-006
+	//To Change the current directory  on device(H2/H4) from PC Side
+	public void testFTP_Telnet_Directory_006()  throws IOException{
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertEquals("/", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("C")));
+		assertEquals("/C", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("system")));
+		assertEquals("/C/system", ftpClient.printWorkingDirectory());
+	
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertEquals("/", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C/system")));
+		assertEquals("/C/system", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/")));
+		assertEquals("/", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("/C/system/.././system")));
+		assertEquals("/C/system", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("..")));
+		assertEquals("/C", ftpClient.printWorkingDirectory());
+		
+		assertTrue(FTPReply.isPositiveCompletion(ftpClient.cwd("..")));
+		assertEquals("/", ftpClient.printWorkingDirectory());
+
+	}
+	
+	//FTP&Telnet-Directory-007
+	//To change a current working directory from a valid directory to a non existence directory from PC to Device(H2/H4)
+	public void testFTP_Telnet_Directory_007()  throws IOException{
+		assertTrue(FTPReply.isNegativePermanent(ftpClient.cwd("/ajdaskldjklasdjlasjdlasldjklasjdl")));
+		assertTrue(FTPReply.isNegativePermanent(ftpClient.cwd("/C/ajdaskldjklasdjlasjdlasldjklasjdl")));
+	}
+	
+	//FTP&Telnet-Directory-008
+	//To change a current working directory from a valid directory to a non existence directory of different drive from PC to Device(H2/H4)
+	
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/ftpsrv/test/test.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,18 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+
+java  -Daddress="%1" -cp .\lib\junit.jar;.\lib\commons-net-1.4.1.jar;.\lib\jakarta-oro-2.0.8.jar;.\bin org.junit.runner.JUnitCore FTPPassiveTest
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+telnetd.mmp
+kill.mmp
+install.mmp
+uninstall.mmp
+restart.mmp
+
+PRJ_EXPORTS
+telnetd.iby 			/epoc32/rom/include/test_telnetd.iby
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/group/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/group/install.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+TARGET		  test_install.exe
+TARGETTYPE	  exe
+UID			 0 0x10210D47
+
+USERINCLUDE	 ../inc
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE /EPOC32/INCLUDE/STDAPIS
+SYSTEMINCLUDE /EPOC32/INCLUDE/LIBC
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+SOURCEPATH	  ../src
+SOURCE		  install.cpp uihandler.cpp
+
+LIBRARY		euser.lib
+LIBRARY		 libc.lib
+LIBRARY		 sishelper.lib
+LIBRARY      charconv.lib
+STATICLIBRARY	libcrt0.lib
+
+CAPABILITY ProtServ TrustedUI
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/group/kill.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+TARGET		  test_kill.exe
+TARGETTYPE	  exe
+UID			  0 0x10210D46 
+
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE /EPOC32/INCLUDE/STDAPIS
+SYSTEMINCLUDE /EPOC32/INCLUDE/LIBC
+
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+SOURCEPATH	  ../src
+SOURCE		  kill.cpp
+
+LIBRARY		euser.lib
+LIBRARY		 libc.lib
+STATICLIBRARY	libcrt0.lib
+
+CAPABILITY PowerMgmt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/group/restart.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+TARGET		  test_restart.exe
+TARGETTYPE	  exe
+UID			 0 0x10210D49
+
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+SOURCEPATH	  ../src
+SOURCE		  restart.cpp
+
+LIBRARY		euser.lib
+LIBRARY		 libc.lib
+LIBRARY		hal.lib
+STATICLIBRARY	libcrt0.lib
+
+CAPABILITY PowerMgmt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/group/telnetd.iby	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __TEST_TELNETD_IBY__
+#define __TEST_TELNETD_IBY__
+
+REM Test Telnet Server
+
+#include <openenv.iby>
+#include <zsh.iby>
+#include <stdlib.iby>
+
+file=ABI_DIR/DEBUG_DIR/test_telnetd.exe        Sys/bin/test_telnetd.exe
+file=ABI_DIR/DEBUG_DIR/test_install.exe        Sys/bin/test_install.exe
+file=ABI_DIR/DEBUG_DIR/test_uninstall.exe      Sys/bin/test_uninstall.exe
+file=ABI_DIR/DEBUG_DIR/test_kill.exe       	   Sys/bin/test_kill.exe
+file=ABI_DIR/DEBUG_DIR/test_restart.exe        Sys/bin/test_restart.exe
+
+#endif //__TEST_TELNETD_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/group/telnetd.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+TARGET		  test_telnetd.exe
+TARGETTYPE	  exe
+UID			 0 0x10210D4A
+
+CAPABILITY NetworkServices
+
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE /EPOC32/INCLUDE/STDAPIS
+SYSTEMINCLUDE /EPOC32/INCLUDE/LIBC
+
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+SOURCEPATH	  ../src
+SOURCE		  telnetd.cpp
+
+LIBRARY		euser.lib
+LIBRARY		 libc.lib
+LIBRARY		 esock.lib
+STATICLIBRARY	libcrt0.lib
+
+EPOCSTACKSIZE 51200
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/group/telnetd.tdf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tool name="TELNET Daemon" 
+	description="A telnet protocol server (TELNET) on devices, reference hardware or emulators."  
+	version="1.0.1000" 
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
+ 
+  <files>
+    <file source="/epoc32/release/winscw/udeb/test_telnetd.exe" target="$EPOCROOT/epoc32/release/winscw/udeb"/>
+    <file source="/epoc32/release/winscw/urel/test_telnetd.exe" target="$EPOCROOT/epoc32/release/winscw/urel"/>
+    <file source="/epoc32/release/armv5/udeb/test_telnetd.exe" target="$EPOCROOT/epoc32/release/armv5/udeb"/>
+    <file source="/epoc32/release/armv5/urel/test_telnetd.exe" target="$EPOCROOT/epoc32/release/armv5/urel"/>
+    
+    <file source="/epoc32/release/winscw/udeb/test_install.exe" target="$EPOCROOT/epoc32/release/winscw/udeb"/>
+    <file source="/epoc32/release/winscw/urel/test_install.exe" target="$EPOCROOT/epoc32/release/winscw/urel"/>
+    <file source="/epoc32/release/armv5/udeb/test_install.exe" target="$EPOCROOT/epoc32/release/armv5/udeb"/>
+    <file source="/epoc32/release/armv5/urel/test_install.exe" target="$EPOCROOT/epoc32/release/armv5/urel"/>
+    
+    <file source="/epoc32/release/winscw/udeb/test_uninstall.exe" target="$EPOCROOT/epoc32/release/winscw/udeb"/>
+    <file source="/epoc32/release/winscw/urel/test_uninstall.exe" target="$EPOCROOT/epoc32/release/winscw/urel"/>
+    <file source="/epoc32/release/armv5/udeb/test_uninstall.exe" target="$EPOCROOT/epoc32/release/armv5/udeb"/>
+    <file source="/epoc32/release/armv5/urel/test_uninstall.exe" target="$EPOCROOT/epoc32/release/armv5/urel"/>
+    
+    <file source="/epoc32/release/winscw/udeb/test_kill.exe" target="$EPOCROOT/epoc32/release/winscw/udeb"/>
+    <file source="/epoc32/release/winscw/urel/test_kill.exe" target="$EPOCROOT/epoc32/release/winscw/urel"/>
+    <file source="/epoc32/release/armv5/udeb/test_kill.exe" target="$EPOCROOT/epoc32/release/armv5/udeb"/>
+    <file source="/epoc32/release/armv5/urel/test_kill.exe" target="$EPOCROOT/epoc32/release/armv5/urel"/>
+    
+    <file source="/epoc32/release/winscw/udeb/test_restart.exe" target="$EPOCROOT/epoc32/release/winscw/udeb"/>
+    <file source="/epoc32/release/winscw/urel/test_restart.exe" target="$EPOCROOT/epoc32/release/winscw/urel"/>
+    <file source="/epoc32/release/armv5/udeb/test_restart.exe" target="$EPOCROOT/epoc32/release/armv5/udeb"/>
+    <file source="/epoc32/release/armv5/urel/test_restart.exe" target="$EPOCROOT/epoc32/release/armv5/urel"/>
+    
+    <file source="/epoc32/rom/include/test_telnetd.iby" target="$EPOCROOT/epoc32/rom/include"/>
+    
+    
+  </files>
+	
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/group/telnetsrv.mrp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,9 @@
+component	dev_devicedbgsrvs_genericunixprotocols_telnetsrv
+
+source	/src/tools/dev/devicedbgsrvs/genericunixprotocols/telnetsrv/group
+binary	/src/tools/dev/devicedbgsrvs/genericunixprotocols/telnetsrv/group all
+exports	/src/tools/dev/devicedbgsrvs/genericunixprotocols/telnetsrv/group
+
+ipr		T
+
+notes_source	/component_defs/release.src
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/group/uninstall.mmp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+TARGET		  test_uninstall.exe
+TARGETTYPE	  exe
+UID			 0 0x10210D48
+
+USERINCLUDE	 ../inc
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE /EPOC32/INCLUDE/STDAPIS
+SYSTEMINCLUDE /EPOC32/INCLUDE/LIBC
+
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+SOURCEPATH	  ../src
+SOURCE		  uninstall.cpp uihandler.cpp
+
+LIBRARY		euser.lib
+LIBRARY		 libc.lib
+LIBRARY		 sishelper.lib
+LIBRARY      charconv.lib
+STATICLIBRARY	libcrt0.lib
+
+CAPABILITY ProtServ TrustedUI
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/inc/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/inc/uihandler.h	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,341 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// Epoc Include
+#include <swi/msisuihandlers.h>
+
+/*@{*/
+///Macros
+#define KUserNameMaxLength	64
+#define KPassword			64
+/*@}*/
+
+enum KMyErrCode
+	{
+	KErrNothing,
+	KErrLanguage,        
+	KErrDrive,
+	KErrOptions,        
+	KErrAbortInstall,
+	KErrAbortUnInstall,        
+	KErrLeave,
+	KErrCannotOverwriteFile,
+	KErrError        
+	};
+	
+/**
+This represents the User Interface handler for the install engine
+The higher code should provide one of these interfaces for the engine
+to use for a UI.
+
+@publishedPartner
+@released
+*/
+using namespace Swi;
+
+class CUIHandler : public CBase, public Swi::MUiHandler
+// This represents the User Interface handler for the install engine
+// The higher code should provide one of these interfaces for the engine
+// to use for a UI
+	{
+	public:
+		static CUIHandler* NewL();
+		
+		~CUIHandler();
+
+		/**
+		 * Displays a dialog at the beginning of an installation with details about the SISX package
+	 	 * being installed. This dialog must be shown in TrustedUI mode.
+	 	 *
+	 	 * @param aAppInfo	Information about the application.
+	 	 * @param aLogo		The logo data in the SISX file. If no logo is present it will be NULL.
+		 * @param aCertificates An array of end entity certificates, one for each chain in the SISX file.
+		 *				If the SISX file is unsigned this array will have zero length.
+		 *
+		 * @note 		Trusted UI
+	   	 *
+		 * @return		ETrue if the user pressed the Yes button to continue the install,
+		 *				EFalse if the user pressed the No button, aborting the installation.
+		 */
+		TBool  DisplayInstallL (const CAppInfo& aAppInfo, 
+			const CApaMaskedBitmap* aLogo, 
+			const RPointerArray <CCertificateInfo> & aCertificates);
+		/**
+		 * Displays a dialog requesting that the user grants these capabilities to the SISX package 
+		 * being installed. This dialog must be shown in TrustedUI mode.
+		 *
+		 * @param aAppInfo	 Information about the application.
+		 * @param aCapabilitySet The capabilities requested by the SISX package.
+		 *
+		 * @note Trusted UI
+		 *
+		 * @return		ETrue to continue the installation, or EFalse to abort the installation.
+		 */
+		TBool DisplayGrantCapabilitiesL(const CAppInfo& aAppInfo, 
+						const TCapabilitySet& aCapabilitySet);
+										
+		/**
+		 * Requests preferred language and dialect information from the UI.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aLanguages	Array of languages supported by the SIS file. 
+		 *
+		 * @return		Must return index in the passed array that corresponds to the user's selected 
+		 *			preferred language. If out-of-bounds value is returned, the engine will abort 
+		 *			installation.
+		 */
+		TInt DisplayLanguageL(const CAppInfo& aAppInfo, 
+				      const RArray<TLanguage>& aLanguages);
+	
+		/**
+		 * Requests the drive to install the package on, from the UI.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aSize		Total size of the files that will be installed on the configurable drive.
+		 * @param aDriveLetters	Array of drive letters on which the package can be installed.
+		 * @param aDriveSpaces	Array of space free (in bytes) on each of the drives in the aDriveLetters array. 
+		 *
+		 * @return		An index in the drive array. If the index is out of range the engine will abort
+		 *                      the installation.
+		 */
+		TInt DisplayDriveL(const CAppInfo& aAppInfo, 
+				   TInt64 aSize,
+				   const RArray<TChar>& aDriveLetters,
+				   const RArray<TInt64>& aDriveSpaces);
+	
+		/**
+		 * Displays a dialog asking whether we want to upgrade an application present on the device.
+		 *
+		 * @param aAppInfo	        Information about the application being installed.
+		 * @param aExistingAppInfo	Information about the existing application.
+		 *
+		 * @return		ETrue if the user pressed the Yes button,
+		 *			EFalse if the user pressed the No button.
+		 */
+		TBool DisplayUpgradeL(const CAppInfo& aAppInfo, 
+				      const CAppInfo& aExistingAppInfo);
+	
+		/**
+		 * Displays a dialog box asking which options the user wishes to install.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aOptions	An array of option names.
+		 * @param aSelections	An array of booleans, corresponding to the aOptions array.
+		 *
+		 * @return		ETrue on success, EFalse on error.
+		 */
+		TBool DisplayOptionsL(const CAppInfo& aAppInfo,
+				      const RPointerArray<TDesC>& aOptions,
+				      RArray<TBool>& aSelections);
+	
+		/**
+		 * Informs the UI of events occurring during installation.  
+		 *
+		 * @param aEvent	The event which has occurred.
+		 * @param aValue	The value associated with the event if applicable.
+		 * @param aDes          A descriptor associated with the event if applicable.
+		 */
+		TBool HandleInstallEventL(const CAppInfo& aAppInfo,
+						TInstallEvent aEvent, 
+						TInt aValue=0, 
+						const TDesC& aDes=KNullDesC);
+		/**
+		 * Informs the UI of cancellable events occurring during installation.  
+		 *
+		 * @param aEvent	 The event which has occurred.
+		 * @param aCancelHandler This mix-in is used to inform Software Install that the user has
+		 *			 pressed the cancel button on the dialog.
+		 * @param aValue	 The value associated with the event if applicable.
+		 * @param aDes           A descriptor associated with the event if applicable.
+		 */
+		void HandleCancellableInstallEventL(const CAppInfo& aAppInfo,
+						TInstallCancellableEvent aEvent, 
+						MCancelHandler& aCancelHandler,
+						TInt aValue=0, 
+						const TDesC& aDes=KNullDesC);
+		/**
+		 * Displays a dialog indicating that the package is unsigned, or that signature validation has failed.
+		 *
+		 * @param aAppInfo              Information about the application.
+		 * @param aSigValidationResult	The result of signature validation.
+		 * @param aPkixResult           Results of a validation of the PKIX  certificate chain.
+		 *                              Note that is can be NULL, in this case no validation results are available.
+		 * @param aCertificates         An array containing information about the certificates in the chain.
+		 * @param aInstallAnyway		ETrue if installation is allowed to continue.
+		 *
+		 * @return						ETrue to continue the installation, EFalse to abort.
+		 */
+		TBool DisplaySecurityWarningL(const CAppInfo& aAppInfo,
+						Swi::TSignatureValidationResult aSigValidationResult,
+						RPointerArray<CPKIXValidationResultBase>& aPkixResults,
+						RPointerArray<CCertificateInfo>& aCertificates,
+						TBool aInstallAnyway);
+	
+		/**
+		 * Displays a dialog indicating that there was an error carrying out online certificate status checking.
+		 *
+		 * @param aMessage	The error which occurred during online certificate status checking
+		 * @param aOutcome	The outcome of the OCSP check. If no outcome can be given, it will be NULL.
+		 * @param aWarningOnly	ETrue if the installation is allowed to continue after a warning, EFalse otherwise.
+		 *
+		 * @return		ETrue on success, EFalse on error.
+		 */
+		TBool DisplayOcspResultL(const CAppInfo& aAppInfo,
+						TRevocationDialogMessage aMessage, 
+						RPointerArray<TOCSPOutcome>& aOutcomes, 
+						RPointerArray<CCertificateInfo>& aCertificates,
+						TBool aWarningOnly);
+	
+		/**
+		 * Used to inform the user the installation they are attempting is trying to overwrite
+		 * a file that does not belong to it. Following this message installation is aborted.
+		 *
+		 * @param aAppInfo	        Information about the application.
+		 * @param aInstalledAppInfo	Information about the application that owns the file in question.
+		 * @param aFileName		The filename of the file in question
+		 */
+		void DisplayCannotOverwriteFileL(const CAppInfo& aAppInfo,
+						 const CAppInfo& aInstalledAppInfo,
+						 const TDesC& aFileName);
+						 
+		/**
+		 * Displays a dialog at the start of the uninstallation with information about the application
+		 * to be uninstalled. The user may cancel the uninstallation at this stage. This dialog must 
+		 * be shown in TrustedUI mode.
+		 *	
+		 * @param aAppInfo	Information about the application.
+		 *
+		 * @note Trusted UI
+		 *
+		 * @return			ETrue to continue the uninstallation, or EFalse to abort the uninstallation.
+		 */
+		TBool DisplayUninstallL(const CAppInfo& aAppInfo);
+
+
+		/**
+		 * Displays a dialog containing text. This dialog has only a Continue button if aOption is 
+		 * EInstFileTextOptionContinue, or Yes and No buttons otherwise.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aOption	The type of dialog box to display.
+		 * @param aText		The text to display
+		 *
+		 * @return		ETrue is the user wants to go forward, EFalse otherwise.
+		 */
+		 TBool DisplayTextL(const CAppInfo& aAppInfo, 
+				    TFileTextOption aOption,
+				    const TDesC& aText);
+	 
+		/**
+		 * Displays a dialog showing an error message. 
+		 *
+		 * @param aAppInfo	    Information about the application.
+		 * @param aType		    The error message to display.
+		 * @param aParam	    An error specific parameter.
+		 */
+		void DisplayErrorL(const CAppInfo& aAppInfo,
+				   TErrorDialog aType, 
+				   const TDesC& aParam);
+
+		/**
+		 * Displays a dialog indicating that a component which is being uninstalled is a dependency
+		 * of another component installed.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aComponents	An array of components which depend on components of the application
+		 *
+		 * @return		ETrue to continue the uninstallation, EFalse to abort.
+		 */
+		TBool DisplayDependencyBreakL(const CAppInfo& aAppInfo,
+					      const RPointerArray<TDesC>& aComponents);
+		
+		/**
+		 * Informs user that the applications are in use during an uninstallation.
+		 * Return ETrue if the user wishes to continue the removal process and 
+		 * close the applications anyway
+		 *
+		 * @param aAppNames		An array containing the name of the application in use.
+		 *
+		 * @return			ETrue if the user wishes to continue with removal.
+		 */
+		TBool DisplayApplicationsInUseL(const CAppInfo& aAppInfo, const RPointerArray<TDesC>& aAppNames);
+	
+		/**
+		 * Displays a generic question dialog with a Yes/No answer.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aQuestion The question to ask.
+		 * @param aDes		A descriptor associated with the question if applicable. 
+		 *
+		 * @return			ETrue if the user pressed the Yes button,
+		 *				EFalse if the user pressed the No button.
+		 */
+		TBool DisplayQuestionL(const CAppInfo& aAppInfo, TQuestionDialog aQuestion, const TDesC& aDes=KNullDesC);
+	
+		/**
+	 	* Used to inform the user of a missing dependency needed to install the 
+	 	* current package. It is up to the UI implementors and/or the user whether
+	 	* or not this warning can be overridden.
+	 	*
+	 	* @param aAppInfo           Info about the current application.
+	 	* @param aDependencyName    Name of the missing dependency.
+	 	* @param aWantedVersionFrom Starting suitable version number of the mising
+	 	*                           dependency. Can be all zeros, meaning it is 
+	 	*                           unknown.
+		 * @param aWantedVersionFrom Ending suitable version number of the mising
+	 	*                           dependency. Can be all zeros, meaning it is 
+	 	*                           unknown.
+	 	* @param aInstalledVersion  The installed (unsuitable) version of the 
+	 	*                           missing dependency. Can be all zeros, meaning 
+	 	*                           the missing dependency is not installed.
+	 	*
+	 	* @return \e ETrue to continue installation, \e EFalse to abort.
+	 	*/
+		TBool DisplayMissingDependencyL(
+		const CAppInfo& aAppInfo,
+		const TDesC& aDependencyName,
+		TVersion aWantedVersionFrom,
+		TVersion aWantedVersionTo,
+		TVersion aInstalledVersion);
+	
+
+
+
+		TBool 	iDispInstall;
+		TBool	iDispGrantCapabilities;
+		TBool	iDispUnInstall;
+		TInt	iDispLanguage;
+		TInt	iDispDialect;
+		TChar	iDispDrive;
+		TBool	iDispUpgrade;
+		TBool	iDispDependencyBreak;
+		TBool	iDispQuestion;
+		TBool	iDispSecurityWarning;
+		TBool	iDispRevocationQuery;
+		TBool	iDispApplicationInUse;
+		TBool	iDispTextDialog;
+		TInt	iDispOptions;
+		TInt	iAppUID;
+		
+		KMyErrCode 	iErrCode;
+		
+	private:
+		CUIHandler();
+		void ConstructL();
+	};
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/readme.txt	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,31 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+
+
+Telnet Daemon
+
+Directory for:
+  connectivity\telnetd\
+
+
+- Component Summary
+
+-- Telnet Daemon, implemented using open environment libraries
+
+- Components Detail
+
+-- Telnet Daemon
+MRP : \group\telnetd.mrp
+IBY : \group\telnetd.iby
+Source : \src
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/src/install.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <e32base.h>
+#include <utf.h>
+#include <swi/launcher.h>
+#include <unistd.h>
+#include "uihandler.h"
+
+int main(int argc, char *argv[], char **/*envp*/)
+	{
+	
+	TInt err = KErrNone;
+	
+	if(argc!=2)
+		{
+		printf("Usage:\n");
+		printf("test_install [SIS file absolute path]\n");
+		printf("Example:\n");
+		printf("test_install c:\\package.sis\n");
+		exit(KErrNone);
+		}
+	
+	TBuf16<KMaxFileName> desc;
+	
+	TPtrC8 src((const TUint8*)argv[1]);
+	
+	CnvUtfConverter::ConvertToUnicodeFromUtf8(desc, src);
+	
+	TFileName fileName(desc);
+	
+	fileName.PtrZ();
+	
+	Swi::CInstallPrefs* installPrefs = Swi::CInstallPrefs::NewL();
+	CUIHandler* uiHandler = CUIHandler::NewL();
+	
+	err = Swi::Launcher::Install(*uiHandler,fileName,*installPrefs);
+
+	delete uiHandler;
+	delete installPrefs;
+	
+	printf("Return Code: %d\n",err);
+	
+	exit(err);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/src/kill.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <e32base.h>
+
+int main(int argc, char *argv[], char **/*envp*/)
+	{
+	
+	TInt64 handleNumber;
+	TInt err = KErrNone;
+	
+	if(argc!=2)
+		{
+		printf("Usage:\n");
+		printf("test_kill [pid]\n");
+		exit(KErrNone); 
+		}
+	
+	TBuf8<10> desc;
+	TInt size = strlen(argv[1]);
+	desc.Copy((TUint8 *)argv[1],size);
+	
+	TLex8 conv(desc);
+	
+	err = conv.Val(handleNumber);
+	
+	if(err==KErrNone)
+		{
+		RProcess newProcess;
+		err = newProcess.Open(TProcessId(handleNumber));
+		if(err==KErrNone)
+			{
+			newProcess.Kill(1);
+			}
+		newProcess.Close();	
+		}
+	
+	printf("Return Code: %d\n",err);
+	
+	return err;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/src/restart.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <hal.h>
+
+int main(int /*argc*/, char */*argv[]*/, char **/*envp*/)
+	{
+	return HAL::Set(HAL::ECustomRestart,1);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/src/telnetd.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,413 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+//  Include Files
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <sys/select.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <arpa/telnet.h>
+
+//For connect
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+//For posix_spawn
+#include <spawn.h>
+
+//for pipe
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+
+//Symbian headers
+#include <e32std.h>
+#include <es_sock.h>
+#include <f32file.h>
+
+void add_return(char* source, char* dest);
+int startConnection();
+TDriveNumber getSystemDrive();
+
+int main(int argc, char *argv[], char **envp)
+	{
+
+	int net;
+	int fds[3];
+	int pid;
+	int ctl_sock;
+	int on = 1;
+	int replicate = 0;
+	int ch = 1;
+
+	char ayt_response[]={IAC,NOP};
+
+	socklen_t addrlen;
+
+	int port = 23;
+
+	sockaddr_in server_addr;
+	sockaddr_in his_addr;
+
+	const char *argstr = "RDP:";
+
+	while ((ch = getopt(argc, argv, argstr)) != -1) {
+		switch (ch) {
+
+		case 'D':
+
+			for(int i=1 /*no name*/; i<argc; i++)
+				{
+				for(unsigned int j=0;j<strlen(argv[i]); j++)
+					if(argv[i][j]=='D')
+						{
+						//Daemon token found, change it to allow replication to new background processes
+						argv[i][j]='R';
+						}
+				}
+			posix_spawn(NULL,argv[0],NULL,NULL,argv,envp);
+			exit(0);
+			break;
+
+		case 'R':
+			replicate = 1;
+			break;
+
+		case 'P':
+			port = atoi(optarg);
+			break;
+
+		default:
+			printf("unknown flag -%c ignored", optopt);
+			scanf("");
+			break;
+		}
+	}
+
+	if(startConnection() != KErrNone)
+		{
+		exit(1);
+		}
+
+	ctl_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+
+	if (ctl_sock < 0)
+		{
+		exit(1);
+		}
+
+	if (setsockopt(ctl_sock, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
+		{
+		exit(1);
+		}
+
+
+	server_addr.sin_family = AF_INET;
+	server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+	server_addr.sin_port = htons(port);
+
+	if (bind(ctl_sock, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0)
+		{
+		exit(1);
+		}
+
+	if (listen(ctl_sock, 32) < 0)
+		{
+		exit(1);
+		}
+
+	addrlen = sizeof(his_addr);
+
+	net = accept(ctl_sock, (struct sockaddr *)&his_addr, &addrlen);
+
+	if(net<0)
+		{
+		exit(1);
+		}
+
+	close(ctl_sock);
+
+	//replicate server
+	if(replicate)
+		posix_spawn(NULL,argv[0],NULL,NULL,argv,envp);
+
+	//launch shell and redirect the commands...
+	pid=popen3("zsh.exe", NULL, NULL, fds);
+
+
+	if(pid>0)
+		{
+
+		char read_zsh[256];
+		char read_zsh_crlf[512];
+		int sock_cnt=0, zsh_cnt=0, ret;
+		int max=0;
+	    fd_set read_fds;
+
+	    //create fifo pipe
+		char pipeName[MAXPATHLEN];
+		sprintf(pipeName,"%c:\\telnetd_%d_pipe",getSystemDrive()+'A',getpid());
+
+		if (mkfifo(pipeName, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH) < 0)
+			{
+			exit(1);
+			}
+
+		int pipe = open(pipeName, O_RDONLY | O_NONBLOCK);
+
+
+	    max =  fds[1] > fds[2] ? fds[1] : fds[2];
+		max =  max > net ? max : net;
+		max =  max > pipe ? max : pipe;
+
+		char exportVariable[MAXPATHLEN];
+		sprintf(exportVariable,"PIPE='%s'\n",pipeName);
+
+		//read first prompt and write PIPE variable
+		read(fds[1], read_zsh, 11); //"localhost# "
+		write(fds[0], exportVariable, strlen(exportVariable));
+
+		for(;;)
+			{
+			int status=-1;
+
+			FD_ZERO(&read_fds);
+			FD_SET(net, &read_fds);
+			FD_SET(fds[1], &read_fds);
+			FD_SET(fds[2], &read_fds);
+			FD_SET(pipe, &read_fds);
+
+			//is child terminated...
+
+			//Fix for defect to prevent the process from taking too much of the processor
+			sleep(1);
+
+			int wait_pid=waitpid(pid, &status, WNOHANG);
+			if(pid == wait_pid || wait_pid == -1) //dont wait for the child to terminate
+				{
+				break;
+				}
+
+			//is any of the fds ready for read...
+			ret=select(max+1, &read_fds, NULL, NULL, NULL);
+
+			if(ret==-1)
+				{
+				break;
+				}
+
+   		    //is there any data to be written onto socket..
+			if(FD_ISSET(fds[1], &read_fds))
+				{
+				memset(&read_zsh[0], 0, 256);
+
+				zsh_cnt=read(fds[1], read_zsh, 255);
+				if(zsh_cnt>0)
+					{
+					//reading from the socket can have more than one \n
+					//so replace all \n with \r\n.
+					add_return(read_zsh,read_zsh_crlf);
+					write(net, read_zsh_crlf, strlen(read_zsh_crlf));
+					}
+				}
+
+   		    //is there any data to be written onto socket..
+			if (FD_ISSET(fds[2], &read_fds))
+				{
+				memset(&read_zsh[0], 0, 256);
+
+				zsh_cnt=read(fds[2], read_zsh, 255);
+				if(zsh_cnt>0)
+					{
+					//reading from the socket can have more than one \n
+					//so replace all \n with \r\n.
+					add_return(read_zsh,read_zsh_crlf);
+					write(net, read_zsh_crlf, strlen(read_zsh_crlf));
+					}
+				}
+
+
+			//is there any data to be written on to pipe
+			if(FD_ISSET(net, &read_fds))
+				{
+				//char* ptr=0;
+				char temp,temp2;
+
+				sock_cnt=0;
+
+				sock_cnt=read(net, &temp, 1);
+				if(sock_cnt > 0)
+					{
+					//echo the command..
+					//write(net, &temp, 1);
+
+					switch(temp & 0xFF)
+						{
+						case '\r':
+								sock_cnt=read(net, &temp, 1); //expect \n here...
+								//write(net, &temp, 1);
+								if(sock_cnt && !(write(fds[0], &temp, 1) > 0))
+									printf("1 telnetd: zsh is not waiting for data.\n");
+								break;
+
+						case IAC: //telnet command
+							{
+								read(net, &temp2, 1);
+								switch(temp2 & 0xFF)
+									{
+									case AYT:
+										write(net,&ayt_response,2);
+										break;
+									}
+								break;
+							}
+
+						default:
+							if(!(write(fds[0], &temp, 1) > 0))
+								printf("2 telnetd: zsh is not waiting for data.\n");
+						}
+
+					}
+   		    	}
+
+
+			if(FD_ISSET(pipe, &read_fds))
+				{
+				memset(&read_zsh[0], 0, 256);
+				zsh_cnt=read(pipe, read_zsh, 255);
+
+				if(zsh_cnt>0)
+					{
+					write(net, read_zsh, strlen(read_zsh));
+					}
+				}
+
+
+			}
+
+		close(net);
+		close(fds[0]);
+		close(fds[1]);
+		close(fds[2]);
+		close(pipe);
+
+		//delete pipe file
+		unlink(pipeName);
+
+		exit(0);//exit server here...
+
+
+
+		}
+	else
+		{
+
+		char errorMessage[]="\n\rShell (zsh.exe) not launched\n\r";
+
+		write(net, errorMessage, strlen(errorMessage));
+		sleep(5);
+		exit(-1); //exit here
+		}
+
+	}
+
+
+void add_return(char* source, char* dest)
+	{
+
+	int sourceLen = strlen(source);
+	int destIndex = 0;
+	int sourceIndex = 0;
+
+	for(; sourceIndex<sourceLen; sourceIndex++, destIndex++)
+		{
+		if(source[sourceIndex]=='\n')
+			{
+			dest[destIndex]='\r';
+			destIndex++;
+			}
+		dest[destIndex] = source[sourceIndex];
+		}
+
+	dest[destIndex] = '\0';
+
+	}
+
+
+int startConnection()
+	{
+
+	int error;
+
+	RSocketServ rSockServer;
+
+	error = rSockServer.Connect();
+
+	if(error == KErrNone)
+    {
+    RConnection rConnect;
+    error = rConnect.Open(rSockServer);
+    if(error == KErrNone)
+        {
+        TRequestStatus status;
+        rConnect.Start(status);
+        User::WaitForRequest(status);
+        }
+    rConnect.Close();
+    }
+
+	rSockServer.Close();
+
+	return error;
+
+	}
+
+
+TDriveNumber getSystemDrive()
+	{
+	_LIT(KFileSrvDll, "efsrv.dll");
+
+	TDriveNumber defaultSysDrive(EDriveC);
+	RLibrary pluginLibrary;
+	TInt pluginErr = pluginLibrary.Load(KFileSrvDll);
+
+	if (pluginErr == KErrNone)
+		{
+		typedef TDriveNumber(*fun1)();
+		fun1 sysdrive;
+
+	#ifdef __EABI__
+		sysdrive = (fun1)pluginLibrary.Lookup(336);
+	#else
+		sysdrive = (fun1)pluginLibrary.Lookup(304);
+	#endif
+
+		if(sysdrive!=NULL)
+			{
+			defaultSysDrive = sysdrive();
+			}
+		}
+	pluginLibrary.Close();
+	return defaultSysDrive;
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/src/uihandler.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,485 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// User includes
+#include "uihandler.h"
+
+/**
+ * Creates a new Instance of the CTestSecurityInstUIHandler and calls the
+ * appropriate ConsturctL
+ * @param None
+ * @return CTestSecurityInstUIHandler* 
+ * 
+ */
+CUIHandler* CUIHandler::NewL()
+	{
+	CUIHandler*	self=new(ELeave) CUIHandler();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+/**
+ * Constructor for CUIHandler
+ */	
+CUIHandler::CUIHandler()
+:	iDispInstall(TRUE),
+	iDispGrantCapabilities(TRUE),
+	iDispUnInstall(TRUE),
+	iDispLanguage(0),
+	iDispDialect(0),
+	iDispDrive('C'),
+	iDispUpgrade(TRUE),
+	iDispDependencyBreak(TRUE),
+	iDispQuestion(TRUE),
+	iDispSecurityWarning(TRUE),
+	iDispRevocationQuery(TRUE),
+	iDispApplicationInUse(TRUE),
+	iDispTextDialog(TRUE),
+	iDispOptions(0),
+	iAppUID(0),
+	iErrCode(KErrNothing)
+	{
+	}
+
+/**
+ * Second stage constructor for CUIHandler
+ */	
+void CUIHandler::ConstructL()
+	{
+	}
+
+/**
+ * Destructor for CUIHandler
+ */	
+CUIHandler::~CUIHandler()
+	{
+	iDispInstall = FALSE;
+	iDispGrantCapabilities = FALSE;
+	iDispUnInstall = FALSE;
+	iDispLanguage = 0;
+	iDispDialect = 0;
+	iDispDrive = 'C';
+	iDispUpgrade = FALSE;
+	iDispDependencyBreak = FALSE;
+	iDispQuestion = FALSE;
+	iDispSecurityWarning = FALSE;
+	iDispRevocationQuery = FALSE;
+	iDispApplicationInUse = FALSE;
+	iDispTextDialog = FALSE;
+	iDispOptions = 0;
+	iAppUID = 0;
+		
+	iErrCode = KErrNothing;
+	}
+
+/**
+ * Displays a dialog at the beginning of an installation with details about the SISX package
+ * being installed. This dialog must be shown in TrustedUI mode.
+ *
+ * @param aAppInfo		Information about the application.
+ * @param aLogo			The logo data in the SISX file. If no logo is present it will be NULL.
+ * @param aCertificates An array of end entity certificates, one for each chain in the SISX file.
+ *						If the SISX file is unsigned this array will have zero length.
+ *
+ * @note 				Trusted UI
+ *
+ * @return				ETrue if the user pressed the Yes button to continue the install,
+ *						EFalse if the user pressed the No button, aborting the installation.
+ */
+TBool CUIHandler::DisplayInstallL(const CAppInfo& /*aAppInfo*/, 
+			const CApaMaskedBitmap* /*aLogo*/, 
+			const RPointerArray< CCertificateInfo >& /*aCertificates*/)
+	{
+	return iDispInstall;
+	}
+
+/**
+ * Displays a dialog requesting that the user grants these capabilities to the SISX package 
+ * being installed. This dialog must be shown in TrustedUI mode.
+ *
+ * @param aAppInfo	 		Information about the application.
+ * @param aCapabilitySet 	The capabilities requested by the SISX package.
+ *
+ * @note 					Trusted UI
+ *
+ * @return					ETrue to continue the installation, or EFalse to abort the installation.
+ */
+TBool CUIHandler::DisplayGrantCapabilitiesL(const CAppInfo& /*aAppInfo*/, 
+			const TCapabilitySet& /*aCapabilitySet*/)
+	{
+	return iDispGrantCapabilities;
+	}
+
+/**
+ * Requests preferred language and dialect information from the UI.
+ *
+ * @param aAppInfo		Information about the application.
+ * @param aLanguages	Array of languages supported by the SIS file. 
+ *
+ * @return				Must return index in the passed array that corresponds to the user's selected 
+ *						preferred language. If out-of-bounds value is returned, the engine will abort 
+ *						installation.
+ */
+TInt CUIHandler::DisplayLanguageL(const CAppInfo& /*aAppInfo*/, 
+	      const RArray<TLanguage>& aLanguages)
+	{
+	TInt languageCode = iDispLanguage;
+	TInt index;
+	
+	// Return the index value in the array which matches the language code 
+	// obtained from the ini file.
+	for (index=0; index<aLanguages.Count(); index++)
+		{
+		if (aLanguages[index] == (TLanguage)languageCode)
+			{
+			return index;
+			}
+		}
+	// Language Code did not match - error
+	iErrCode = KErrLanguage;
+	
+	return languageCode;
+	}
+	
+/**
+ * Requests the drive to install the package on, from the UI.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aSize		Total size of the files that will be installed on the configurable drive.
+ * @param aDriveLetters	Array of drive letters on which the package can be installed.
+ * @param aDriveSpaces	Array of space free (in bytes) on each of the drives in the aDriveLetters array. 
+ *
+ * @return		An index in the drive array. If the index is out of range the engine will abort
+ *                      the installation.
+ */
+TInt CUIHandler::DisplayDriveL(const CAppInfo& /*aAppInfo*/, 
+		   TInt64 /*aSize*/,
+		   const RArray<TChar>& aDriveLetters,
+		   const RArray<TInt64>& /*aDriveSpaces*/)
+	{
+	TInt index;
+	TInt driveIndex=0;
+	for (index=0; index < aDriveLetters.Count(); index++)
+		{
+		if (aDriveLetters[index] == iDispDrive)
+			{
+			driveIndex = index;
+			break;
+			}
+		}
+		
+	if (index == aDriveLetters.Count()) // Out of range error 
+		{
+		iErrCode = KErrDrive;
+		driveIndex = index;
+		}
+	return driveIndex;
+	}
+	
+/**
+ * Displays a dialog asking whether we want to upgrade an application present on the device.
+ *
+ * @param aAppInfo	        Information about the application being installed.
+ * @param aExistingAppInfo	Information about the existing application.
+ *
+ * @return		ETrue if the user pressed the Yes button,
+ *			EFalse if the user pressed the No button.
+ */
+TBool CUIHandler::DisplayUpgradeL(const CAppInfo& /*aAppInfo*/, 
+		      const CAppInfo& /*aExistingAppInfo*/)
+	{
+	return iDispUpgrade;
+	}
+	
+/**
+ * Displays a dialog box asking which options the user wishes to install.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aOptions	An array of option names.
+ * @param aSelections	An array of booleans, corresponding to the aOptions array.
+ *
+ * @return		ETrue on success, EFalse on error.
+ */
+TBool CUIHandler::DisplayOptionsL(const CAppInfo& /*aAppInfo*/,
+		      const RPointerArray<TDesC>& aOptions,
+		      RArray<TBool>& aSelections)
+	{
+	
+	TInt index;
+	TBool setFlag = EFalse;
+	
+	for (index=0; index<aOptions.Count();index++)
+		{
+		if (index == iDispOptions)
+			{
+			aSelections[index] = ETrue;
+			setFlag = ETrue;
+			}
+		else
+			{
+			aSelections[index] = EFalse;
+			}
+		}
+
+	if (setFlag == (TBool)ETrue)
+		{
+		return ETrue;
+		}
+	else
+		{
+		iErrCode = KErrOptions;
+		return EFalse;
+		}
+	}
+	
+/**
+ * Informs the UI of events occurring during installation.  
+ *
+ * @param aEvent	The event which has occurred.
+ * @param aValue	The value associated with the event if applicable.
+ * @param aDes		A descriptor associated with the event if applicable.
+ * @return TBool	Always returns ETrue to indicate the Install Event is always handled
+ */
+TBool CUIHandler::HandleInstallEventL(const CAppInfo& /*aAppInfo*/,
+			 TInstallEvent aEvent, 
+			 TInt /*aValue=0*/, 
+			 const TDesC& /*aDes=KNullDesC*/)
+	{
+	switch (aEvent)
+		{
+		case EEventSetProgressBarFinalValue:
+			break;
+		case EEventUpdateProgressBar:
+			break;
+		case EEventAbortedInstall:
+			iErrCode = KErrAbortInstall;
+			break;
+		case EEventCompletedInstall:
+			break;
+		case EEventCompletedUnInstall:
+			break;
+		case EEventAbortedUnInstall:
+			iErrCode = KErrAbortUnInstall;
+			break;
+		case EEventCompletedNoMessage:
+			break;
+		case EEventLeave:
+			iErrCode = KErrLeave;
+			break;
+		case EEventOcspCheckEnd:
+			break;
+		default:
+			break;
+		}
+	return ETrue;
+	}
+	
+/**
+ * Informs the UI of cancellable events occurring during installation.  
+ *
+ * @param aEvent	 		The event which has occurred.
+ * @param aCancelHandler 	This mix-in is used to inform Software Install that the user has
+ *			 				pressed the cancel button on the dialog.
+ * @param aValue	 		The value associated with the event if applicable.
+ * @param aDes           	A descriptor associated with the event if applicable.
+ */
+void CUIHandler::HandleCancellableInstallEventL(const CAppInfo& /*aAppInfo*/,
+			TInstallCancellableEvent aEvent, 
+		    MCancelHandler& /*aCancelHandler*/,
+		    TInt /*aValue=0*/, 
+		    const TDesC& /*aDes=KNullDesC*/)
+	{
+	switch (aEvent)
+		{
+		case EEventRemovingFiles:
+			break;
+		case EEventShuttingDownApps:
+			break;
+		case EEventCopyingFiles:
+			break;
+		case EEventOcspCheckStart:
+			break;
+		default:
+			break;
+		}
+	}
+
+/**
+ * Displays a dialog indicating that the package is unsigned, or that signature validation has failed.
+ *
+ * @param aAppInfo              Information about the application.
+ * @param aSigValidationResult	The result of signature validation.
+ * @param aPkixResult           Results of a validation of the PKIX  certificate chain.
+ *                              Note that is can be NULL, in this case no validation results are available.
+ * @param aCertificates         An array containing information about the certificates in the chain.
+ * @param aInstallAnyway		ETrue if installation is allowed to continue.
+ *
+ * @return						ETrue to continue the installation, EFalse to abort.
+ */
+TBool CUIHandler::DisplaySecurityWarningL(const CAppInfo& /*aAppInfo*/,
+						Swi::TSignatureValidationResult /*aSigValidationResult*/,
+						RPointerArray<CPKIXValidationResultBase>& /*aPkixResults*/,
+						RPointerArray<CCertificateInfo>& /*aCertificates*/,
+						TBool /*aInstallAnyway*/)
+	{
+	return ETrue;
+	}
+
+/**
+ * Displays a dialog indicating that there was an error carrying out online certificate status checking.
+ *
+ * @param aMessage		The error which occurred during online certificate status checking
+ * @param aOutcome		The outcome of the OCSP check. If no outcome can be given, it will be NULL.
+ * @param aWarningOnly	ETrue if the installation is allowed to continue after a warning, EFalse otherwise.
+ *
+ * @return				ETrue on success, EFalse on error.
+ */
+TBool CUIHandler::DisplayOcspResultL(const CAppInfo& /*aAppInfo*/,
+						TRevocationDialogMessage /*aMessage*/, 
+						RPointerArray<TOCSPOutcome>& /*aOutcomes*/, 
+						RPointerArray<CCertificateInfo>& /*aCertificates*/,
+						TBool aWarningOnly)
+	{
+	return aWarningOnly;
+	}
+	
+/**
+ * Used to inform the user the installation they are attempting is trying to overwrite
+ * a file that does not belong to it. Following this message installation is aborted.
+ *
+ * @param aAppInfo	        Information about the application.
+ * @param aInstalledAppInfo	Information about the application that owns the file in question.
+ * @param aFileName			The filename of the file in question
+ */
+void CUIHandler::DisplayCannotOverwriteFileL(const CAppInfo& /*aAppInfo*/,
+				 const CAppInfo& /*aInstalledAppInfo*/,
+				 const TDesC& /*aFileName*/)
+	{
+	iErrCode = KErrCannotOverwriteFile;
+	}
+	
+/**
+ * Displays a dialog at the start of the uninstallation with information about the application
+ * to be uninstalled. The user may cancel the uninstallation at this stage. This dialog must 
+ * be shown in TrustedUI mode.
+ *	
+ * @param aAppInfo	Information about the application.
+ *
+ * @note Trusted UI
+ *
+ * @return			ETrue to continue the uninstallation, or EFalse to abort the uninstallation.
+ */
+TBool CUIHandler::DisplayUninstallL(const CAppInfo& /*aAppInfo*/)
+	{
+	return iDispUnInstall;
+	}
+
+/**
+ * Displays a dialog containing text. This dialog has only a Continue button if aOption is 
+ * EInstFileTextOptionContinue, or Yes and No buttons otherwise.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aOption	The type of dialog box to display.
+ * @param aText		The text to display
+ *
+ * @return		ETrue if the user wants to go forward, EFalse otherwise.
+ */
+TBool CUIHandler::DisplayTextL(const CAppInfo& /*aAppInfo*/, 
+			    TFileTextOption /*aOption*/,
+			    const TDesC& /*aText*/)
+	{
+	return iDispTextDialog;
+	}
+	
+/**
+ * Displays a dialog showing an error message. 
+ *
+ * @param aAppInfo	    Information about the application.
+ * @param aType		    The error message to display.
+ * @param aParam	    An error specific parameter.
+ */
+void CUIHandler::DisplayErrorL(const CAppInfo& /*aAppInfo*/,
+			   TErrorDialog /*aType*/,
+			   const TDesC& /*aParam*/)
+	{
+	iErrCode = KErrError;
+	}
+
+/**
+ * Displays a dialog indicating that a component which is being uninstalled is a dependency
+ * of another component installed.
+ *
+ * @param aAppInfo		Information about the application.
+ * @param aComponents	An array of components which depend on components of the application
+ *
+ * @return				ETrue to continue the uninstallation, EFalse to abort.
+ */
+TBool CUIHandler::DisplayDependencyBreakL(const CAppInfo& /*aAppInfo*/,
+		      const RPointerArray<TDesC>& /*aComponents*/)
+	{
+	return iDispDependencyBreak;
+	}
+	
+/**
+ * Informs user that the applications are in use during an uninstallation.
+ * Return ETrue if the user wishes to continue the removal process and 
+ * close the applications anyway
+ *
+ * @param aAppNames		An array containing the name of the application in use.
+ *
+ * @return				ETrue if the user wishes to continue with removal.
+ */
+TBool CUIHandler::DisplayApplicationsInUseL(const CAppInfo& /*aAppInfo*/, 
+			const RPointerArray<TDesC>& /*aAppNames*/)
+	{
+	return iDispApplicationInUse;
+	}
+	
+/**
+ * Displays a generic question dialog with a Yes/No answer.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aQuestion The question to ask.
+ * @param aDes		A descriptor associated with the question if applicable. 
+ *
+ * @return			ETrue if the user pressed the Yes button,
+ *					EFalse if the user pressed the No button.
+ */
+TBool CUIHandler::DisplayQuestionL(const CAppInfo& /*aAppInfo*/, 
+			TQuestionDialog aQuestion, const TDesC& /*aDes=KNullDesC*/)
+	{
+	
+	switch(aQuestion)
+		{
+		case EQuestionIncompatible:
+			break;
+		default:
+			break;
+		}
+		
+	return iDispQuestion;
+	}
+
+TBool CUIHandler::DisplayMissingDependencyL(const CAppInfo& /*aAppInfo*/,
+	const TDesC& /*aDependencyName*/,TVersion /*aWantedVersionFrom*/,
+	TVersion /*aWantedVersionTo*/,TVersion /*aInstalledVersion*/)
+	{
+	return ETrue;
+	}
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/src/uninstall.cpp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <e32base.h>
+#include <utf.h>
+#include <swi\launcher.h>
+#include "uihandler.h"
+
+int main(int argc, char *argv[], char **/*envp*/)
+	{
+	
+	TInt err = KErrNone;
+	
+	if(argc!=2)
+		{
+		printf("Usage:\n");
+		printf("test_uninstall [UID in hexadecimal]\n");
+		printf("Example:\n");
+		printf("test_uninstall 10203040\n");
+		exit(KErrNone);
+		}
+	
+	TBuf16<10> desc;
+	
+	TPtrC8 src((const TUint8*)argv[1]);
+	
+	CnvUtfConverter::ConvertToUnicodeFromUtf8(desc, src);
+	
+	TLex conv(desc);
+	
+	TUint32 id;
+	
+	err = conv.Val(id,EHex);
+	
+	if(err==KErrNone)
+		{
+		TUid uid = TUid::Uid(id);
+		
+		CUIHandler* uiHandler = CUIHandler::NewL();
+
+		err = Swi::Launcher::Uninstall(*uiHandler, uid);
+		
+		delete uiHandler;
+		}
+	
+	printf("Return Code: %d\n",err);
+	
+	exit(err);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/test/.classpath	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="lib" path="./lib/junit.jar"/>
+	<classpathentry kind="lib" path="./lib/jakarta-oro-2.0.8.jar"/>
+	<classpathentry kind="lib" path="./lib/commons-net-1.4.1.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/test/.project	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>test_telnetd</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Binary file genericunixprotocols/telnetsrv/test/bin/TelnetTest.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/test/bin/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/test/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
Binary file genericunixprotocols/telnetsrv/test/lib/commons-net-1.4.1.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/test/lib/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
Binary file genericunixprotocols/telnetsrv/test/lib/jakarta-oro-2.0.8.jar has changed
Binary file genericunixprotocols/telnetsrv/test/lib/junit.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/test/src/TelnetTest.java	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,314 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.net.telnet.TelnetClient;
+
+
+public class TelnetTest extends TestCase {
+	
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	TelnetClient telnetClient = new TelnetClient();
+	
+	InputStream is;
+	OutputStream os;
+	byte promptBuffer[] = new byte[11]; //"localhost# "
+	String prompt = "localhost# ";
+	
+	
+	//FTP&Telnet-Connection-001
+	//To Establish a connection from remote host to Symbian OS device(H2/H4)
+	
+	protected void setUp() throws Exception {
+		super.setUp();
+		
+		String address = System.getProperty("address");
+		
+		telnetClient.connect(/*"172.0.0.3"*/address);
+		
+		is = telnetClient.getInputStream();
+		os = telnetClient.getOutputStream();
+		
+		is.read(promptBuffer);
+		
+		
+	}
+	
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	
+	//FTP&Telnet-Connection-002
+	//To Close a connection from remote host to Symbian OS device(H2/H4)
+	
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		
+		os.write("exit\r\n".getBytes());
+		os.flush();
+	
+		telnetClient.disconnect();
+	}
+	
+	private String readUntil(InputStream in, String pattern) throws IOException {
+		StringBuffer sb = new StringBuffer();
+		while(!(sb.toString().endsWith(prompt)))
+		{
+			sb.append((char)in.read());
+		}
+		return sb.toString();
+	}
+	
+	public void testAYT() throws IOException, IllegalArgumentException, InterruptedException
+	{
+		assertTrue(telnetClient.sendAYT(5000));
+	}
+	
+	public void testCd() throws IOException
+	{
+		os.write("cd c:\r\n".getBytes());
+		os.flush();
+		is.read(promptBuffer);	//"localhost# "
+		assertEquals(prompt, new String(promptBuffer));
+	}
+	
+	public void testPwd() throws IOException
+	{
+		os.write("pwd\r\n".getBytes());
+		os.flush();
+		
+		String s = readUntil(is,prompt);
+		s = s.substring(1, s.indexOf(prompt));
+		
+		assertEquals(":\\Private\\2000cd0f\\\r\n", s);
+		
+	}
+	
+	public void testCdPwd() throws IOException
+	{
+		
+		os.write("cd c:\r\n".getBytes());
+		os.flush();
+		is.read(promptBuffer);	//"localhost# "
+		assertEquals(new String(promptBuffer),prompt);
+		
+		os.write("pwd\r\n".getBytes());
+		os.flush();
+		
+		String s = readUntil(is,prompt);
+		s = s.substring(0, s.indexOf(prompt));
+		
+		assertEquals("c:\r\n", s);
+	}
+	
+	//DEF117414
+	//zsh cannot run external commands after running 82 commands
+	//TODO: change maxIter to 100 when fixed
+	
+	public void testPs() throws IOException
+	{
+	
+		int maxIter = 2;
+		
+		for(int i=0; i<maxIter; i++)
+		{
+
+		os.write("ps\r\n".getBytes());
+		os.flush();
+		
+		String s = readUntil(is,prompt);
+		
+		s = s.substring(0, s.indexOf(prompt));
+		
+		System.out.println(s);
+		
+		System.out.println("iteration "+(i+1)+" of "+maxIter);
+		
+		Pattern p = Pattern.compile(".*ps.EXE\\[2000ee91\\]\\d\\d\\d\\d\r\n$", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); //Pattern.DOTALL => '.' includes end of line
+		Matcher m = p.matcher(s);
+		assertTrue(m.matches());
+		}
+		
+	}
+	
+	
+	//DEF116570
+	//after few successful ps and grep, when you do ps and grep on non exsiting string the emulator hangs
+	
+	public void testPsGrepNonExistingString() throws IOException
+	{
+		int maxIter = 2;
+		
+		for(int i=0; i<maxIter; i++)
+		{
+		
+		os.write("ps | grep nonexisting\r\n".getBytes());
+		os.flush();
+		
+		String s = readUntil(is,prompt);
+		
+		s = s.substring(0, s.indexOf(prompt));
+		
+		assertEquals(0,s.length());
+		}
+	}
+	
+	//FTP&Telnet-Remote Execution-001
+	//To Launch a process on a remote Symbian OS device(H2/H4) from PC
+	
+	public void testFTP_Telnet_Remote_Execution_001() throws IOException
+	{
+		os.write("testexecute c:\\nonexisting.script\r\n".getBytes());
+		os.flush();
+		
+		String s = readUntil(is,prompt);
+		
+		assertEquals(11, s.length());
+	}
+	
+	
+	//FTP&Telnet-Remote Execution-002
+	//To pool all the process on the symbian OS device(H2/H4) from PC
+	
+	public void testFTP_Telnet_Remote_Execution_002() throws IOException
+	{
+		os.write("ps\r\n".getBytes());
+		os.flush();
+		
+		String s = readUntil(is,prompt);
+		
+		s = s.substring(0, s.indexOf(prompt));
+		
+	//	System.out.println(s);
+		
+		Pattern p = Pattern.compile(".*ps.EXE\\[2000ee91\\]\\d\\d\\d\\d\r\n$", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); //Pattern.DOTALL => '.' includes end of line
+		Matcher m = p.matcher(s);
+		assertTrue(m.matches());
+	}
+	
+	
+	//FTP&Telnet-Remote Execution-003
+	// Kill any process on Symbian OS device(H2/H4) from PC
+	
+	public void testFTP_Telnet_Remote_Execution_003() throws IOException
+	{
+		os.write("testexecute\r\n".getBytes());
+		os.flush();
+		
+		//this shell will lock, open another one and kill TEF
+		
+		TelnetClient tc = new TelnetClient();
+		tc.connect(telnetClient.getRemoteAddress());
+		
+		InputStream is2 = tc.getInputStream();
+		OutputStream os2 = tc.getOutputStream();
+		
+		readUntil(is2, prompt);
+		
+		os2.write("ps | grep TestExecute\r\n".getBytes());
+		os2.flush();
+		
+		String s = readUntil(is2, prompt);
+		
+		Pattern p = Pattern.compile(".*\\D+(\\d+)\\s[\\s:\\d]+TestExecute Script Engine.*", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); //Pattern.DOTALL => '.' includes end of line
+		Matcher m = p.matcher(s);
+		
+		assertTrue(m.matches());
+				
+		String s1 = m.group(1);
+		
+		int pid = Integer.parseInt(s1);
+		
+		os2.write(("kill "+pid+"\r\n").getBytes());
+		os2.flush();
+		readUntil(is2, prompt);
+		os2.write("bye\r\n".getBytes());
+		os2.flush();
+		
+		//we should be able now to close the other shell
+		
+		readUntil(is, prompt);
+		
+		
+	}
+	
+	//FTP&Telnet-Remote Execution-004
+	//To verify the output stream of any Symbian OS process(H2/H4) to PC
+	public void testFTP_Telnet_Remote_Execution_004() throws IOException
+	{
+		
+		os.write("helloworld $PIPE\r\n".getBytes());
+		os.flush();
+		
+		String s = readUntil(is, prompt);
+		
+		assertTrue(s.length()>0); //should print "ABCDEFG...".length() > 0
+		
+	}
+	
+	//FTP&Telnet-Remote Execution-005
+	//To verify the Standard Error display on Symbian OS device(H2/H4) to PC
+	public void testFTP_Telnet_Remote_Execution_005() throws IOException
+	{
+		os.write("aaa\r\n".getBytes());
+		os.flush();
+		
+		String s = readUntil(is, prompt);
+		
+		assertEquals("zsh: command not found: aaa",s.substring(0, s.lastIndexOf("\r\n"))); 
+	}
+	
+	
+	//FTP&Telnet-Software Install-001
+	//Install a SIS file on the Symbian OS device (H2/H4) from PC
+	public void testFTP_Telnet_Install_001() throws IOException
+	{
+		
+		os.write("install c:\\10210d02.sis\r\n".getBytes());
+		os.flush();
+		
+		String s = readUntil(is, prompt);
+		
+		assertEquals("Return Code: 0",s.substring(0, s.lastIndexOf("\r\n"))); 
+	}
+	
+	//FTP&Telnet-Software Install-002
+	//Uninstall the SIS file on the symbian OS device (H2/H4) from PC
+	public void testFTP_Telnet_Install_002() throws IOException
+	{
+		
+		os.write("uninstall 10210d02\r\n".getBytes());
+		os.flush();
+		
+		String s = readUntil(is, prompt);
+		
+		assertEquals("Return Code: 0",s.substring(0, s.lastIndexOf("\r\n"))); 
+	}
+	
+	
+	
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/test/src/distribution.policy.s60	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocols/telnetsrv/test/test.bat	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,18 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+
+java -Daddress="%1" -cp .\lib\junit.jar;.\lib\commons-net-1.4.1.jar;.\lib\jakarta-oro-2.0.8.jar;.\bin org.junit.runner.JUnitCore TelnetTest
+
Binary file genericunixprotocolsguides/ftpandtelnetdaemonsguide/com.nokia.ftptelnet_0.1.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocolsguides/ftpandtelnetdaemonsguide/group/bld.inf	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,3 @@
+
+PRJ_EXPORTS
+../com.nokia.ftptelnet_0.1.jar /plugins/com.nokia.ftptelnet_0.1.jar
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/genericunixprotocolsguides/ftpandtelnetdaemonsguide/group/dbgconsolutionsguide.mrp	Tue Mar 02 10:33:16 2010 +0530
@@ -0,0 +1,9 @@
+component	dev_devicedbgsrvs_genericunixprotocolsguides_ftpandtelnetdaemonsguide
+
+source /src/tools/dev/devicedbgsrvs/genericunixprotocolsguides/ftpandtelnetdaemonsguide/com.nokia.ftptelnet_0.1.jar
+source /src/tools/dev/devicedbgsrvs/genericunixprotocolsguides/ftpandtelnetdaemonsguide/group/dbgconsolutionsguide.mrp
+source /src/tools/dev/devicedbgsrvs/genericunixprotocolsguides/ftpandtelnetdaemonsguide/group/bld.inf
+
+exports /src/tools/dev/devicedbgsrvs/genericunixprotocolsguides/ftpandtelnetdaemonsguide/group
+
+notes_source	\component_defs\release.src
\ No newline at end of file