From d1e05bd797fe021880234d5b85704d14117da325 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Fri, 19 Jul 2013 13:28:04 +0400 Subject: [PATCH] [PROTO] Merge swap_draft <- tizen_2.2 as generic commit --- Makefile | 1 + helper/libdaprobe.c | 24 +++++++------ probe_badaapi/bada_lifecycle.cpp | 41 ++++++++++++--------- probe_event/orientation.c | 78 ++++++++++++++++++++++++++++++++++++++++ probe_memory/da_memory.h | 6 ++++ probe_memory/libdamemalloc.c | 31 +++++++--------- probe_memory/libdanew.cpp | 19 +++++----- probe_tizenapi/tizen_appfw.c | 12 ++++++- 8 files changed, 153 insertions(+), 59 deletions(-) create mode 100644 probe_event/orientation.c diff --git a/Makefile b/Makefile index eff31da..be2c399 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,7 @@ COMMON_SRCS = ./helper/libdaprobe.c \ ./probe_socket/libdasocket.c \ ./probe_event/da_event.c \ ./probe_event/keytouch.c \ + ./probe_event/orientation.c \ ./probe_third/libdaemon.c \ ./probe_thread/libdathread.c \ ./probe_thread/libdasync.c \ diff --git a/helper/libdaprobe.c b/helper/libdaprobe.c index a9f131e..e4ba315 100755 --- a/helper/libdaprobe.c +++ b/helper/libdaprobe.c @@ -670,22 +670,24 @@ int preBlockBegin(void* caller, bool bFiltering, enum DaOptions option) } } - if((!user) && bFiltering) + if(user) { - TRACE_STATE_UNSET(TS_ENTER_PROBE_BLOCK); - return 0; + gProbeDepth++; + return 2; // user call } else { - // nothing to do + if(bFiltering) + { + TRACE_STATE_UNSET(TS_ENTER_PROBE_BLOCK); + return 0; // not probing + } + else + { + gProbeDepth++; + return 1; // internal call + } } - - gProbeDepth++; - - if(user) - return 2; // user call - else - return 1; // internal call } int postBlockBegin(int preresult) diff --git a/probe_badaapi/bada_lifecycle.cpp b/probe_badaapi/bada_lifecycle.cpp index 0264988..31e6ee8 100755 --- a/probe_badaapi/bada_lifecycle.cpp +++ b/probe_badaapi/bada_lifecycle.cpp @@ -3,18 +3,18 @@ * * Copyright (File::*c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: + * Contact: * * Jaewon Lim * Woojin Jung * Juyoung Kim * Anastasia Lyupa - * + * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the * Free Software Foundation; either version 2.1 of the License, or (at your option) * any later version. - * + * * This library 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 Lesser General Public @@ -27,10 +27,11 @@ * Contributors: * - S-Core Co., Ltd * - Samsung RnD Institute Russia - * + * */ #include +#include #include #include @@ -40,6 +41,11 @@ #include "osp_probe.h" #include "binproto.h" +extern "C" +{ +Ecore_Event_Handler* register_orientation_event_listener(); +void unregister_orientation_event_listener(Ecore_Event_Handler* handler); +} using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -55,10 +61,10 @@ namespace Tizen { namespace App class _AppImpl { static void OnTerminate(void* user_data); - static void OnDeviceOrientationChanged(app_device_orientation_e orientation, void* user_data); +// static void OnDeviceOrientationChanged(app_device_orientation_e orientation, void* user_data); }; -class _UiAppImpl +class _UiAppImpl // : public Tizen::Base::Object // , public _IAppImpl { @@ -77,13 +83,14 @@ result UiApp::Execute(UiAppInstanceFactory pUiAppFactory, { typedef result (*methodType)(UiAppInstanceFactory pFactory, const IList* pArgs); static methodType uiapp_executep; - probeInfo_t probeInfo; - result ret; + DECLARE_VARIABLE_STANDARD; + Ecore_Event_Handler* handler; GET_REAL_FUNC_OSP(_ZN5Tizen3App5UiApp7ExecuteEPFPS1_vEPKNS_4Base10Collection5IListE, LIBOSP_UIFW, uiapp_executep); probeBlockStart(); + handler = register_orientation_event_listener(); if(gTraceInfo.exec_map.map_start == NULL) { get_map_address(CALLER_ADDRESS, &(gTraceInfo.exec_map.map_start), @@ -103,6 +110,7 @@ result UiApp::Execute(UiAppInstanceFactory pUiAppFactory, PACK_COMMON_END(ret, 0, 0); FLUSH_LOCAL_BUF(); + unregister_orientation_event_listener(handler); probeBlockEnd(); return ret; @@ -113,7 +121,7 @@ void _AppImpl::OnTerminate(void* user_data) typedef void (*methodType)(void*); static methodType appimpl_onterminatep; probeInfo_t probeInfo; - + GET_REAL_FUNC_OSP(_ZN5Tizen3App8_AppImpl11OnTerminateEPv, LIBOSP_APPFW, appimpl_onterminatep); probeBlockStart(); @@ -130,12 +138,12 @@ void _AppImpl::OnTerminate(void* user_data) appimpl_onterminatep(user_data); } - +/* void _AppImpl::OnDeviceOrientationChanged(app_device_orientation_e orientation, void* user_data) { typedef void (*methodType)(app_device_orientation_e, void*); static methodType appimpl_ondeviceorientationchangedp; - + GET_REAL_FUNC_OSP(_ZN5Tizen3App8_AppImpl26OnDeviceOrientationChangedE24app_device_orientation_ePv, LIBOSP_APPFW, appimpl_ondeviceorientationchangedp); @@ -145,13 +153,13 @@ void _AppImpl::OnDeviceOrientationChanged(app_device_orientation_e orientation, appimpl_ondeviceorientationchangedp(orientation, user_data); } - +*/ void _AppInfo::SetAppState(AppState appState) { typedef void (*methodType)(AppState appstate); static methodType appinfo_setappstatep; probeInfo_t probeInfo; - + GET_REAL_FUNC_OSP(_ZN5Tizen3App8_AppInfo11SetAppStateENS0_8AppStateE, LIBOSP_APPFW, appinfo_setappstatep); probeBlockStart(); @@ -176,7 +184,7 @@ void _UiAppImpl::OnBackground(void) typedef void (_UiAppImpl::*methodType)(void); static methodType uiappimpl_onbackgroundp; probeInfo_t probeInfo; - + GET_REAL_FUNC_OSP(_ZN5Tizen3App10_UiAppImpl12OnBackgroundEv, LIBOSP_UIFW, uiappimpl_onbackgroundp); probeBlockStart(); @@ -200,7 +208,7 @@ void _UiAppImpl::OnForeground(void) typedef void (_UiAppImpl::*methodType)(void); static methodType uiappimpl_onforegroundp; probeInfo_t probeInfo; - + GET_REAL_FUNC_OSP(_ZN5Tizen3App10_UiAppImpl12OnForegroundEv, LIBOSP_UIFW, uiappimpl_onforegroundp); probeBlockStart(); @@ -225,7 +233,7 @@ void _UiAppImpl::OnDeviceOrientationChanged(app_device_orientation_e orientation { typedef void (*methodType)(_UiAppImpl* th, app_device_orientation_e orientation); static methodType uiappimpl_ondeviceorientationchangedp; - + GET_REAL_FUNC_OSP(_ZThn4_N5Tizen3App10_UiAppImpl26OnDeviceOrientationChangedE24app_device_orientation_e, LIBOSP_UIFW, uiappimpl_ondeviceorientationchangedp); @@ -237,4 +245,3 @@ void _UiAppImpl::OnDeviceOrientationChanged(app_device_orientation_e orientation } */ } } // end of namespace - diff --git a/probe_event/orientation.c b/probe_event/orientation.c new file mode 100644 index 0000000..661c351 --- /dev/null +++ b/probe_event/orientation.c @@ -0,0 +1,78 @@ +/* + * DA probe + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * + * Jaewon Lim + * Woojin Jung + * Juyoung Kim + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include +#include + +#include "daprobe.h" +#include "dahelper.h" + +Eina_Bool _da_onclientmessagereceived(void* pData, int type, void* pEvent) +{ + Ecore_X_Event_Client_Message* pClientEvent; + + probeBlockStart(); + pClientEvent = (Ecore_X_Event_Client_Message*)pEvent; + + if(pClientEvent != NULL) + { + if(pClientEvent->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST) + { + int orientation = pClientEvent->data.l[1]; + on_orientation_changed(orientation, false); + } + } + probeBlockEnd(); + + return ECORE_CALLBACK_RENEW; +} + +Ecore_Event_Handler* register_orientation_event_listener() +{ + Ecore_Event_Handler* handler; + + probeBlockStart(); + ecore_init(); + ecore_x_init(NULL); + handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _da_onclientmessagereceived, NULL); + probeBlockEnd(); + + return handler; +} + +void unregister_orientation_event_listener(Ecore_Event_Handler* handler) +{ + probeBlockStart(); + if(handler) + { + ecore_event_handler_del(handler); + } + probeBlockEnd(); +} diff --git a/probe_memory/da_memory.h b/probe_memory/da_memory.h index bb50486..0196503 100644 --- a/probe_memory/da_memory.h +++ b/probe_memory/da_memory.h @@ -35,6 +35,12 @@ #include "daprobe.h" +//#define INTERNALFILTERING (!isEnableInternalMalloc()) +#define INTERNAL_MALLOC_FILTERING true +#define INTERNAL_FREE_FILTERING true +#define INTERNAL_NEW_FILTERING true +#define INTERNAL_DELETE_FILTERING true + /******************************************************************* * MEMORY PROBE MACRO * diff --git a/probe_memory/libdamemalloc.c b/probe_memory/libdamemalloc.c index 58fa4be..cf126f9 100755 --- a/probe_memory/libdamemalloc.c +++ b/probe_memory/libdamemalloc.c @@ -3,19 +3,19 @@ * * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: + * Contact: * * Jaewon Lim * Woojin Jung * Juyoung Kim * Anastasia Lyupa * Dmitry Bogatov - * + * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the * Free Software Foundation; either version 2.1 of the License, or (at your option) * any later version. - * + * * This library 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 Lesser General Public @@ -28,7 +28,7 @@ * Contributors: * - S-Core Co., Ltd * - Samsung RnD Institute Russia - * + * */ #include @@ -46,8 +46,6 @@ #include "da_memory.h" #include "binproto.h" -//#define INTERNALFILTERING (!isEnableInternalMalloc()) -#define INTERNALFILTERING true static enum DaOptions _sopt = OPT_ALLOC; static void* (*saved_malloc_hook)(size_t, const void*); @@ -84,7 +82,6 @@ static void *malloc_hook(size_t size, const void* caller) void *pret; teardown_memory_hooks(); - bfiltering = INTERNALFILTERING; PRE_PROBEBLOCK(); pret = malloc(size); @@ -95,7 +92,7 @@ static void *malloc_hook(size_t size, const void* caller) } POST_PACK_PROBEBLOCK_BEGIN(); - + PREPARE_LOCAL_BUF(); PACK_COMMON_BEGIN(MSG_PROBE_MEMORY, API_ID_malloc, @@ -103,7 +100,7 @@ static void *malloc_hook(size_t size, const void* caller) PACK_COMMON_END(pret, newerrno, blockresult); PACK_MEMORY(size, MEMORY_API_ALLOC, pret); FLUSH_LOCAL_BUF(); - + POST_PACK_PROBEBLOCK_END(); install_memory_hooks(); @@ -117,7 +114,6 @@ static void free_hook(void *ptr, const void *caller) teardown_memory_hooks(); - bfiltering = INTERNALFILTERING; PRE_PROBEBLOCK(); if(ptr != NULL && getTraceState() == 0) @@ -128,7 +124,7 @@ static void free_hook(void *ptr, const void *caller) free(ptr); POST_PACK_PROBEBLOCK_BEGIN(); - + PREPARE_LOCAL_BUF(); PACK_COMMON_BEGIN(MSG_PROBE_MEMORY, API_ID_free, @@ -136,7 +132,7 @@ static void free_hook(void *ptr, const void *caller) PACK_COMMON_END(0, newerrno, blockresult); PACK_MEMORY(0, MEMORY_API_FREE, ptr); FLUSH_LOCAL_BUF(); - + POST_PACK_PROBEBLOCK_END(); install_memory_hooks(); @@ -149,7 +145,6 @@ static void* realloc_hook(void *memblock, size_t size, const void* caller) teardown_memory_hooks(); - bfiltering = INTERNALFILTERING; PRE_PROBEBLOCK(); if(memblock != NULL && getTraceState() == 0) @@ -165,7 +160,7 @@ static void* realloc_hook(void *memblock, size_t size, const void* caller) } POST_PACK_PROBEBLOCK_BEGIN(); - + PREPARE_LOCAL_BUF(); PACK_COMMON_BEGIN(MSG_PROBE_MEMORY, API_ID_realloc, @@ -173,7 +168,7 @@ static void* realloc_hook(void *memblock, size_t size, const void* caller) PACK_COMMON_END(pret, newerrno, blockresult); PACK_MEMORY(size, MEMORY_API_ALLOC, pret); FLUSH_LOCAL_BUF(); - + POST_PACK_PROBEBLOCK_END(); install_memory_hooks(); @@ -193,12 +188,11 @@ void *calloc(size_t nelem, size_t elsize) DECLARE_VARIABLE_STANDARD; void *pret; size_t size = nelem * elsize; - bfiltering = INTERNALFILTERING; PRE_PROBEBLOCK(); pret = (size < elsize) ? NULL : malloc(size); - if (pret) - adhoc_bzero(pret, nelem * elsize); + if (pret) /* `memset' somewhy deadloops */ + adhoc_bzero(pret, nelem * elsize); if(pret != NULL && getTraceState() == 0) { @@ -220,4 +214,3 @@ void *calloc(size_t nelem, size_t elsize) return pret; } - diff --git a/probe_memory/libdanew.cpp b/probe_memory/libdanew.cpp index 10c8f93..a4b006b 100644 --- a/probe_memory/libdanew.cpp +++ b/probe_memory/libdanew.cpp @@ -43,9 +43,6 @@ #include "da_memory.h" #include "binproto.h" -//#define INTERNALFILTERING (!isEnableInternalMalloc()) -#define INTERNALFILTERING true - static enum DaOptions _sopt = OPT_ALLOC; void *operator new(std::size_t size) throw (std::bad_alloc) @@ -56,7 +53,7 @@ void *operator new(std::size_t size) throw (std::bad_alloc) GET_REAL_FUNCP_RTLD_NEXT_CPP(_Znwj,newp); - bfiltering = INTERNALFILTERING; + bfiltering = INTERNAL_NEW_FILTERING; PRE_PROBEBLOCK(); pret = newp(size); @@ -89,7 +86,7 @@ void *operator new[](std::size_t size) throw (std::bad_alloc) GET_REAL_FUNCP_RTLD_NEXT_CPP(_Znaj, newp); - bfiltering = INTERNALFILTERING; + bfiltering = INTERNAL_NEW_FILTERING; PRE_PROBEBLOCK(); pret = newp(size); @@ -121,7 +118,7 @@ void operator delete(void *ptr) throw() GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdlPv, deletep); - bfiltering = INTERNALFILTERING; + bfiltering = INTERNAL_DELETE_FILTERING; PRE_PROBEBLOCK(); if(ptr != NULL && getTraceState() == 0) @@ -151,7 +148,7 @@ void operator delete[](void *ptr) throw() GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdaPv, deletep); - bfiltering = INTERNALFILTERING; + bfiltering = INTERNAL_DELETE_FILTERING; PRE_PROBEBLOCK(); if(ptr != NULL && getTraceState() == 0) @@ -182,7 +179,7 @@ void *operator new(std::size_t size, const std::nothrow_t& nothrow) throw() GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZnwjRKSt9nothrow_t, newp); - bfiltering = INTERNALFILTERING; + bfiltering = INTERNAL_NEW_FILTERING; PRE_PROBEBLOCK(); pret = newp(size, nothrow); @@ -215,7 +212,7 @@ void *operator new[](std::size_t size, const std::nothrow_t& nothrow) throw() GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZnajRKSt9nothrow_t, newp); - bfiltering = INTERNALFILTERING; + bfiltering = INTERNAL_NEW_FILTERING; PRE_PROBEBLOCK(); pret = newp(size, nothrow); @@ -247,7 +244,7 @@ void operator delete(void *ptr, const std::nothrow_t& nothrow) throw() GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdlPvRKSt9nothrow_t, deletep); - bfiltering = INTERNALFILTERING; + bfiltering = INTERNAL_DELETE_FILTERING; PRE_PROBEBLOCK(); if(ptr != NULL && getTraceState() == 0) @@ -277,7 +274,7 @@ void operator delete[](void *ptr, const std::nothrow_t& nothrow) throw() GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdaPvRKSt9nothrow_t, deletep); - bfiltering = INTERNALFILTERING; + bfiltering = INTERNAL_DELETE_FILTERING; PRE_PROBEBLOCK(); if(ptr != NULL && getTraceState() == 0) diff --git a/probe_tizenapi/tizen_appfw.c b/probe_tizenapi/tizen_appfw.c index 2e6c710..e5369ae 100644 --- a/probe_tizenapi/tizen_appfw.c +++ b/probe_tizenapi/tizen_appfw.c @@ -31,12 +31,15 @@ */ #include +#include #include "daprobe.h" #include "dahelper.h" #include "probeinfo.h" - #include "binproto.h" +Ecore_Event_Handler* register_orientation_event_listener(); +void unregister_orientation_event_listener(Ecore_Event_Handler* handler); + app_event_callback_s gAppCallback; #define PACK_ORIGINAL_APPFWCYCLE(API_ID, RVAL, INPUTFORMAT, ...) \ @@ -128,10 +131,13 @@ static void _dalc_app_deviceorientationchanged(app_device_orientation_e orientat int app_efl_main(int *argc, char ***argv, app_event_callback_s *callback, void *user_data) { static int (*app_efl_mainp)(int* argc, char*** argv, app_event_callback_s* callback, void* user_data); + Ecore_Event_Handler* handler; int ret; GET_REAL_FUNC(app_efl_main, LIBCAPI_APPFW_APPLICATION); + probeBlockStart(); + handler = register_orientation_event_listener(); gAppCallback.create = callback->create; gAppCallback.terminate = callback->terminate; gAppCallback.pause = callback->pause; @@ -150,15 +156,19 @@ int app_efl_main(int *argc, char ***argv, app_event_callback_s *callback, void * if(callback->service) callback->service = _dalc_app_service; callback->device_orientation = _dalc_app_deviceorientationchanged; + probeBlockEnd(); ret = app_efl_mainp(argc, argv, callback, user_data); + probeBlockStart(); + unregister_orientation_event_listener(handler); callback->create = gAppCallback.create; callback->terminate = gAppCallback.terminate; callback->pause = gAppCallback.pause; callback->resume = gAppCallback.resume; callback->service = gAppCallback.service; callback->device_orientation = gAppCallback.device_orientation; + probeBlockEnd(); return ret; } -- 2.7.4