天道酬勤,学无止境

systrace

LD_PRELOAD can not intercept syscalls, but only libcalls?

Question My code works well with malloc, but not with mmap. The code is below: main.c #include <stdio.h> #include <stdlib.h> int main(){ int * p = (int*) malloc(sizeof(int)); printf("in main(): value p = %d\n", *p); free(p); } preload.c #define _GNU_SOURCE #include <time.h> #include <dlfcn.h> #include <stdio.h> #include <sys/types.h> void *(*orig_malloc)(size_t size); void *malloc(size_t size){ printf(" Hooked(preload)! malloc:size:%lu\n", size); return orig_malloc(size); } void * (*orig_mmap)(void *start, size_t length, int prot, int flags, int fd, off_t offset); void * mmap(void *start, size

2021-09-22 08:07:04    分类:技术分享    c   system-calls   ld-preload   systrace

LD_PRELOAD can not intercept syscalls, but only libcalls?

Question My code works well with malloc, but not with mmap. The code is below: main.c #include <stdio.h> #include <stdlib.h> int main(){ int * p = (int*) malloc(sizeof(int)); printf("in main(): value p = %d\n", *p); free(p); } preload.c #define _GNU_SOURCE #include <time.h> #include <dlfcn.h> #include <stdio.h> #include <sys/types.h> void *(*orig_malloc)(size_t size); void *malloc(size_t size){ printf(" Hooked(preload)! malloc:size:%lu\n", size); return orig_malloc(size); } void * (*orig_mmap)(void *start, size_t length, int prot, int flags, int fd, off_t offset); void * mmap(void *start, size

2021-09-22 08:05:06    分类:技术分享    c   system-calls   ld-preload   systrace

Systrace on Android 4.3

Question I'm trying to measure performance attributes of my app through systrace by using the new Trace API introduced in JB 4.3. The idea is similar to the use of traceview method profiling, i.e. you can measure a specific code section using Trace.beginSection and Trace.endSection. However, when I run systrace through the python script provided in Android tools, I don't see anything relating to the sections specified by the above calls. Am I missing something? Is this the correct way of accessing the systrace output? I see in the documentation for the Trace calls that it "Writes trace events

2021-07-13 04:05:39    分类:技术分享    android   systrace

Android DDMS v22.0.1 unable to generate a systrace using Droid Razor 4.1.2

Question I've selected several of the trace tags and when I run the trace (from DDMS) I get the following output: Unexpected error while collecting system trace. Unable to find trace start marker 'TRACE:': error opening /sys/kernel/debug/tracing/options/overwrite: No such file or directory (2) error openi(cuts off the error here) indeed there is no debug file in the kernel directory, but which mechanism will generate the necessary path? Answer1 It looks like your cellphone is running a boot(kernel) image that does not support systrace. "error opening /sys/kernel/debug/tracing/options/overwrite

2021-07-12 19:27:52    分类:技术分享    android   ddms   systrace

Does Android systrace require root access?

Question I am trying to run systrace on a non-rooted device. It always gives the following error if any of the trace events is selected: Unable to find trace start marker 'TRACE:': error opening /sys/kernel/debug/tracing/events/cpufreq_interactive/enable: No such file or directory If no trace event is selected, it works, but the trace is not very usweful. Does systrace requires root access? Note that I am running systrace directly from Eclipse (DDMS) on Windows-7. Answer1 According to systrace.py --help, the following traces require root access: -d, --disk: trace disk I/O (requires root) -u, -

2021-07-11 06:44:17    分类:技术分享    android   systrace

Android app first start is very slow and systrace shows 30 seconds of bindApplication

Question I'm currently developing an Android app and trying to improve the start time. In order to do so, I'm using the Systrace tool. The first time I run the app (right after installed), it takes ~40 seconds to start, and I get this trace: As you can see, there is a 30 seconds light purple tag with title bindApplication. After this, I close the app (swiped away from recent activities) and reopen it. This time the bindApplication tag is just 4 seconds long: Does anybody know if it's normal for the first run to take so long ? What can I do to improve it ? My guess here is that bindApplication

2021-06-24 18:05:28    分类:技术分享    android   performance   systrace

Android Systrace Trace File Format

Question Android systrace tool, calls atrace tool via ADB. However, I don't understand very well the format of the traces file. Apparently it is very similar to linux ftrace tool with some differences. The main difference is that is doesn't uses a System.Map file but it includes all that information into the trace file. Also, there are new B|E entries that are android specific. There is some information about this format in Android Source Code at: http://androidxref.com/4.1.1/xref/external/chromium-trace/src/tracing/linux_perf_importer.js However, in that documentation we can read that the

2021-06-10 00:34:21    分类:技术分享    android   linux   perf   ftrace   systrace

Running Android systrace on device

Question I'm unable to run the Android SDK tool called systrace.pl because I get errors like: error opening /sys/kernel/debug/tracing/options/overwrite: No such file or directory And indeed the /sys/kernel/debug/tracing directory doesn't even exist. A little research showed I need to enable debugfs with the following command: mount -o rw,remount -t debugfs none /sys/kernel/debug Running mount there afterwards indicates the debugfs is running: #mount ... /sys/kernel/debug /sys/kernel/debug debugfs rw,relatime 0 0 ... And I have trace enabled (all items) in the developer settings menu. I'm using

2021-05-19 11:04:17    分类:技术分享    android   debugging   trace   systrace

Unable to view HTML trace report generated by Systrace tool in Android SDK

Question I am trying to generate trace reports with Systrace tool in the Android SDK, but I cant view the report in the browser. It is blank and does not contain any information. I read in some forums that I need to open the report in Chrome browser, I opened it with Chrome as well but the report is blank. I have enabled USB Debugging from the Developer Options and device is running Android 4.2 and I am using DDMS tool from the Android SDK to generate the traces. http://developer.android.com/tools/help/systrace.html Answer1 Firstly, if anyone is using Chrome v50.0+ on OS X or Windows, just try

2021-05-18 16:57:43    分类:技术分享    android   ddms   systrace

Error running systrace tool in ADB using a Jelly Bean 4.1 emulator on Windows 7

Question How can I run systrace to show its html output? After watching the Google I/O 2012 talk "For Butter or Worse" I am having trouble getting systrace to work on Windows 7 using the emulator running Jelly Bean 4.1. I did the following: Installed Python 2.7, and added the install folder to my PATH Ran the following: C:\android-sdk\platform-tools\systrace>python systrace.py (with older SDKs: C:\android-sdk\tools\systrace>python systrace.py) But I get the following error in cmd: Traceback (most recent call last): File "systrace.py", line 212, in <module> main() File "systrace.py", line 124

2021-04-03 16:51:07    分类:技术分享    android   windows-7   adb   android-4.2-jelly-bean   systrace