2012年11月27日 星期二

如何過濾不要的log

在分析Android的device log時, 常常會有夾雜許多不需要分析的log, 提供一個方法將之過濾並轉存新檔, 以便縮小log檔並去除不必要的log.

grep -v "Pattern" log_file > target_file

透過這個命令, 將 "Pattern" 換成你要去除的Log pattern,
並指向來源的 log_file, 將結果輸出到 target_file.

完成, log file看起來清爽多了, 以易於分析囉.

2012年8月13日 星期一

grep 輸出到檔名

常用的方法是:
grep -inR "Exception" device_e000* > out.txt
                pattern          source                target

參數說明:
-i, --ignore-case         ignore case distinctions

-n, --line-number         print line number with output lines
      --line-buffered       flush output on every line

-R, -r, --recursive       equivalent to --directories=recurse
      --include=PATTERN     files that match PATTERN will be examined
      --exclude=PATTERN     files that match PATTERN will be skipped.
      --exclude-from=FILE   files that match PATTERN in FILE will be skipped.

2012年7月5日 星期四

How to build Android under ubuntu 12.04 LTS 64bit version


Installing required packages (Ubuntu 12.04)

Building on Ubuntu 12.04 is currently only experimentally supported and is not guaranteed to work on branches other than master.
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Then you need to do below change:
Simply change build/core/combo/HOST_linux-x86.mk line 61:

    -HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
    +HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

His commit message is as follows:

    HOST_linux-x86: Avoid doubly define macro _FORTIFY_SOURCE
    While building Android with latest host gcc,
    it causes the following build error:

    Install: out/host/linux-x86/bin/mkbootimg
    host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
    :0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
    :0:0: note: this is the location of the previous definition
    cc1plus: all warnings being treated as errors

    In order to make build system happy, this patch does unset macro
    _FORTIFY_SOURCE and then define it in host cflags.

If there have below error log:

Host OS:
Linux 3.0.0-12-generic #20-Ubuntu SMP x86_64 GNU/Linux
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1

Compiling Android from git (master) stops with error:

android_repo/external/llvm/lib/Support/Threading.cpp:96: undefined reference to `pthread_create'
android_repo/external/llvm/lib/Support/Threading.cpp:91: undefined reference to `pthread_attr_setstacksize'
android_repo/external/llvm/lib/Support/Threading.cpp:100: undefined reference to `pthread_join'
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `MutexImpl':
android_repo/external/llvm/lib/Support/Mutex.cpp:69: undefined reference to `pthread_mutexattr_init'
android_repo/external/llvm/lib/Support/Mutex.cpp:75: undefined reference to `pthread_mutexattr_settype'
android_repo/external/llvm/lib/Support/Mutex.cpp:80: undefined reference to `pthread_mutexattr_setpshared'
android_repo/external/llvm/lib/Support/Mutex.cpp:89: undefined reference to `pthread_mutexattr_destroy'
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::tryacquire()':
android_repo/external/llvm/lib/Support/Mutex.cpp:143: undefined reference to `pthread_mutex_trylock'
collect2: ld returned 1 exit status

Solution:


Add "LOCAL_LDLIBS := -lpthread -ldl" in external/llvm/llvm-host-build.mk
Have Fun!!

2012年6月11日 星期一

重新開始~~~

許久,
未曾在此留下任何消息!
忙碌,
只是個藉口.

但很開心,  在經歷過一段黯淡的時光後,
對未來就有了一些憧憬.
雖然, 未來依舊不可預期,
但, 希望越來越靠近.