Android 동작중에 달빅이 리셋되는 경우가 있다.
이 경우 fingerprint 메세지가 나오는데 이것을 분석하는 방법입니다.
우선 fingerprint가 저장된 로그를 저장해 둔다.
---------------------------------------------------------------------------------------------------------------------------------
07-14 17:00:05.909: INFO/DEBUG(1198): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-14 17:00:05.909: INFO/DEBUG(1198): Build fingerprint: 'XXXXX/XXXX/XXXXX/8x50:2.1-update1/ERE27/eng.xxxxx.20100712.092719:userdebug/test-keys'
07-14 17:00:05.909: INFO/DEBUG(1198): pid: 1354, tid: 2191 >>> system_server <<<
07-14 17:00:05.909: INFO/DEBUG(1198): signal 11 (SIGSEGV), fault addr 00000000
07-14 17:00:05.909: INFO/DEBUG(1198): r0 00000001 r1 00000007 r2 00000002 r3 0069b920
07-14 17:00:05.909: INFO/DEBUG(1198): r4 007061b0 r5 00000000 r6 00000001 r7 6d07bb88
07-14 17:00:05.909: INFO/DEBUG(1198): r8 00100000 r9 6d3647e1 10 38361000 fp 00000000
07-14 17:00:05.909: INFO/DEBUG(1198): ip 6d07b05c sp 38460df0 lr 6d035c57 pc 6d035c58 cpsr 20000030
---------------------------------------------------------------------------------------------------------------------------------
1. 우선 컴파일 된 경로의 root를 간다. [cmd 창 연다]
보통 아래 처럼 경로가 있는데 android 상위 폴더에서 처리한다.
Project -
android
modem
2. 저장시킬 로그를 project 폴더에 복사한다.
3. "parse_mapfile.pl" 파일을 생성하고 아래 내용을 저정한다.
---------------------------------------------------------------------------------------------------------------------------------
##########################################################
#
#!/usr/bin/perl
#
# Searches android logfiles for android stack dumps and
# generates a calltrace.
#
# Syntax : perl ./parse_mapfile.pl
#
# is option and is not needed if calling script
# from /build folder e.g.
#
# For emulator builds
# perl ./scripts/parse_mapfile.pl generic
#
# For dream builds
# perl ./scripts/parse_mapfile.pl dream
#
#
##########################################################
use strict;
sub findsym;
my $mydroid_root = "../mydroid"; #default
my $logfile = $ARGV[0];
my $target = "generic"; # default emulator
if ($ARGV[1])
{
$target = $ARGV[1];
}
if ($ARGV[2])
{
$mydroid_root = $ARGV[2];
}
print("target=$target\n");
print("mydroid_root=$mydroid_root\n");
my $nm="$mydroid_root/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/arm-eabi/bin/nm";
my $sympath = "$mydroid_root/out/target/product/$target/symbols";
my $sympath_alt = "$mydroid_root/out/target/product/$target/";
my $parsing_syms = 0;
my $pos;
my $i;
open LOGFILE, "<", $logfile or die $!;
# Search for stack dump
while ()
{
my($logline) = $_;
my $search_start="Build fingerprint:";
my $search_stop="stack:";
chomp($logline);
$pos++;
if($logline =~ m/$search_start/)
{
print("#######################################################################################\n");
print("# Found stackdump @ line $pos....generating calltrace\n\n");
$parsing_syms = 1;
$i = 0;
}
if ($parsing_syms)
{
if($logline =~ m/(#.*)pc (.*) (.*)/g)
{
findsym($2, $3);
}
}
if($logline =~ m/$search_stop/)
{
$parsing_syms = 0;
print("\n#\n#######################################################################################\n");
}
}
sub findsym
{
my $mapfile = "syms.map";
my $hprev_sym;
my $hprev_addr = 0;
my $hcur_addr;
my $hcur_sym = 0;
my $binary=@_[1];
my $mappath;
my $symbol = @_[0];
my $cmd;
my $prev_sz;
my @line1;
my $cur;
my $offset;
my $pos = 0;
my $symfile;
chomp($nm);
chomp($binary);
# remove and CR/LF
$binary =~ s/\r|\n//g;
$symfile = "$sympath$binary";
if (! -e $symfile)
{
# try alternate location
$symfile = "$sympath_alt$binary";
#print("Couldn't find $binary, try alternate path\n");
}
if (! -e $symfile)
{
print("could not find binary, exit");
exit 1;
}
my $my_cmd="$nm $symfile | sort > $mapfile";
system($my_cmd);
open MAPFILE, "<", $mapfile or die $!;
while ()
{
my($line) = $_;
chomp($line);
# split line on any nbr spaces
@line1 = split(/ +/, $line);
# search all code segments
{
$hcur_addr = $line1[0];
$hcur_sym = $line1[2];
$cur = hex($symbol);
$a = hex $hprev_addr;
$b = hex $hcur_addr;
$prev_sz = $b-$a;
#print "lr=$cur, a=$a(0x$hprev_addr), b=$b(0x$hcur_addr)\n";
if (($cur >= $a) && ($cur <= $b))
{
$offset = $cur-$a;
print sprintf("%25s @ 0x%08x (fn pos %04d/%04d) [0x%08x] $binary\n",
$hprev_sym, $a, $offset, $prev_sz, $cur);
$i++;
}
}
$hprev_sym = $hcur_sym;
$hprev_addr = $hcur_addr;
}
close MAPFILE;
my $my_cmd="rm $mapfile";
system($my_cmd);
}
---------------------------------------------------------------------------------------------------------------------------------
4. cmd창에서 아래의 형식으로 명령을 수행한다.
perl parse_mapfile.pl
만약 모델 명 XXTT1, android 폴더명이 "android", fingerprint로그가 저장된 파일명이
"log.log"라면 아래와 같이 해준다.
perl parse_mapfile.pl Log.log XXTT1 android
5. 위와 같이 실행후 나온 결과를 분석한다. call stack이 찍힌다.
수행 결과 => 숫자들이 알아볼 수 있도록 변경된 것을 확인 할 수 있습니다.
#######################################################################################
# Found stackdump @ line 161....generating calltrace
attachThread @ 0x00035bbc (fn pos 0156/0184) [0x00035c58] /system/lib/libdvm.so
AttachCurrentThread @ 0x00035c80 (fn pos 0004/0012) [0x00035c84] /system/lib/libdvm.so
_ZN8broadcomL19handleTestModeEventEitP11tBTL_PARAMS @ 0x0005c698 (fn pos 0034/0364) [0x0005c6ba] /system/lib/libandroid_runtime.so
btl_ifc_notify_local_event @ 0x000641ac (fn pos 0040/0108) [0x000641d4] /system/lib/libandroid_runtime.so
ctrl_socket_disconnected @ 0x00064560 (fn pos 0106/0160) [0x000645ca] /system/lib/libandroid_runtime.so
process_ctrl_data @ 0x00064684 (fn pos 0078/0248) [0x000646d2] /system/lib/libandroid_runtime.so
monitor_ctrl_fds @ 0x0006477c (fn pos 0010/0024) [0x00064786] /system/lib/libandroid_runtime.so
main_client_thread @ 0x000647e0 (fn pos 0226/0324) [0x000648c2] /system/lib/libandroid_runtime.so
__thread_entry @ 0x0000fd70 (fn pos 0048/0060) [0x0000fda0] /system/lib/libc.so
pthread_create @ 0x0000f7b4 (fn pos 0188/0612) [0x0000f870] /system/lib/libc.so
#
#######################################################################################
출처 : http://blog.naver.com/PostView.nhn?blogId=kkamci25&logNo=10098930924&viewDate=¤tPage=1&listtype=0
[출처] [Android 디버깅] Fingerprint 추적 방법|작성자 충전중
출처 : http://blog.naver.com/PostView.nhn?blogId=kkamci25&logNo=10098930924&viewDate=¤tPage=1&listtype=0
'안드로이드' 카테고리의 다른 글
Android: gdb를 이용한 Dalvik VM 디버깅 (0) | 2011.01.27 |
---|---|
서비스를 부팅시 시작시키기 (Start Service at Boot Time) (0) | 2011.01.27 |
디바이스의 고유 정보값 얻어오기 (0) | 2011.01.27 |
타이틀 바 꾸미기 (0) | 2011.01.27 |
웹킷 브라우저 (0) | 2011.01.27 |