1 # dump dalvik backtrace 2 define dbt 3 if $argc == 1 4 set $FP = $arg0 5 else 6 set $FP = $r5 7 end 8 9 set $frame = 0 10 set $savedPC = 0 11 while $FP 12 set $stackSave = $FP - sizeof(StackSaveArea) 13 set $savedPC = ((StackSaveArea *)$stackSave)->savedPc 14 set $method = ((StackSaveArea *)$stackSave)->method 15 printf "#%d\n", $frame 16 printf " FP = %#x\n", $FP 17 printf " stack save = %#x\n", $stackSave 18 printf " Curr pc = %#x\n", ((StackSaveArea *) $stackSave)->xtra.currentPc 19 printf " FP prev = %#x\n", ((StackSaveArea *) $stackSave)->prevFrame 20 if $method != 0 21 printf " returnAddr: 0x%x\n", \ 22 ((StackSaveArea *)$stackSave)->returnAddr 23 printf " class = %s\n", ((Method *) $method)->clazz->descriptor 24 printf " method = %s (%#08x)\n", ((Method *) $method)->name, $method 25 printf " signature = %s\n", ((Method *) $method)->shorty 26 printf " bytecode offset = 0x%x\n", (short *) (((StackSaveArea *) $stackSave)->xtra.currentPc) - (short *) (((Method *) $method)->insns) 27 set $regSize = ((Method *) $method)->registersSize 28 set $insSize = ((Method *) $method)->insSize 29 set $index = 0 30 while $index < $regSize 31 printf " v%d = %d", $index, ((int *)$FP)[$index] 32 if $regSize - $index <= $insSize 33 printf " (in%d)\n", $insSize - $regSize + $index 34 else 35 printf " (local%d)\n", $index 36 end 37 set $index = $index + 1 38 end 39 else 40 printf " break frame\n" 41 end 42 set $FP = (int) ((StackSaveArea *)$stackSave)->prevFrame 43 set $frame = $frame + 1 44 end 45 end 46 47 document dbt 48 Unwind Dalvik stack frames. Argument 0 is the frame address of the top 49 frame. If omitted r5 will be used as the default (as the case in the 50 interpreter and JIT'ed code). 51 end 52