From: Nikita Kalyazin Date: Thu, 28 Nov 2013 09:26:08 +0000 (+0400) Subject: [REFACTOR] direct call from app determination X-Git-Tag: Tizen_SDK_2.3~97 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7c126f574db70477e5080536ff783494c933ff7;p=platform%2Fcore%2Fsystem%2Fswap-probe.git [REFACTOR] direct call from app determination Change-Id: I2921bd85c47f663af10e10876e5bf77c4fa0699d Signed-off-by: Nikita Kalyazin --- diff --git a/helper/libdaprobe.c b/helper/libdaprobe.c index 09ebba8..8473392 100755 --- a/helper/libdaprobe.c +++ b/helper/libdaprobe.c @@ -567,11 +567,29 @@ static inline bool isNoFiltOptionEnabled(enum DaOptions option) && isOptionEnabled(OPT_GLES_ALWAYS)); } -int preBlockBegin(void* caller, bool bFiltering, enum DaOptions option) +static inline bool is_user_call(const void *caller) { bool user = false; - void* tarray[1]; - char** strings; + char **strings; + + if (gTraceInfo.exec_map.map_start != NULL) { + if (caller >= gTraceInfo.exec_map.map_start && + caller <= gTraceInfo.exec_map.map_end) + user = true; + } else { + strings = BACKTRACE_SYMBOLS((void * const *)caller, 1); + if (strings != NULL) { + if (determineCaller(strings[0]) == 0) + user = true; + free(strings); + } + } + + return user; +} + +int preBlockBegin(const void *caller, bool bFiltering, enum DaOptions option) +{ bool opt_nofilt; if(gProbeBlockCount != 0 || gProbeDepth != 0) @@ -582,7 +600,7 @@ int preBlockBegin(void* caller, bool bFiltering, enum DaOptions option) opt_nofilt = isNoFiltOptionEnabled(option); - /* Actually we are considering 3 conditions here: + /* Actually we are considering 3 variables here: - regular option is enabled - non-filtering (always) option is enabled - per-probe filtering @@ -594,52 +612,16 @@ int preBlockBegin(void* caller, bool bFiltering, enum DaOptions option) probeBlockStart(); - if(gTraceInfo.exec_map.map_start != NULL) - { - // address comparison - if(caller >= gTraceInfo.exec_map.map_start && - caller <= gTraceInfo.exec_map.map_end) - { - user = true; - } - else - { - // nothing to do - } - } - else - { - // backtrace for filtering - tarray[0] = caller; - strings = BACKTRACE_SYMBOLS(tarray, 1); - if(strings != NULL) - { - if((determineCaller(strings[0]) == 0)) - user = true; - free(strings); - } - else - { - // nothing to do - } - } - - if(user) - { + if (is_user_call(caller)) { probingStart(); - return 2; // user call - } - else - { - if(bFiltering) - { + return 2; /* user call */ + } else { + if (bFiltering) { probeBlockEnd(); - return 0; // not probing - } - else - { + return 0; /* not probing */ + } else { probingStart(); - return 1; // internal call + return 1; /* internal call */ } } } diff --git a/include/daprobe.h b/include/daprobe.h index 18d1e72..b31f06e 100644 --- a/include/daprobe.h +++ b/include/daprobe.h @@ -102,7 +102,7 @@ extern __thread int gProbeDepth; * helper apis ***************************************************************************/ -int preBlockBegin(void* caller, bool bFiltering, enum DaOptions); +int preBlockBegin(const void *caller, bool bFiltering, enum DaOptions); void preBlockEnd(); int postBlockBegin(int preresult);