"Print Call stack"
(GDB) bt #0 epoll_wait () at bionic/libc/arch-arm/syscalls/epoll_wait. S:10 #1 0x401275ea in Android::looper::p ollinner ([email protected]=0x747fd3f0, timeoutmillis=<optimized out [email protected]=85688516] at system/core/libutils/looper.cpp:223 #2 0x40127814 in Android::Looper:: Pollonce (this=0x747fd3f0, timeoutmillis=85688516, [email protected]=0x0, [email protected]=0x0, [email protected]=0x0) at system/core/libutils/looper.cpp:191 #3 0x401d13dc in pollonce (timeoutmillis=<optimized o Ut>, this=<optimized out>) at system/core/include/utils/looper.h:176 #4 Android::nativemessagequeue:: Pollonce (this=0x747fef58, env=0x4151dfa8, timeoutmillis=<optimized out>) at frameworks/base/core/jni/android_ os_messagequeue.cpp:97 #5 0x4153d310 in Dvmplatforminvoke () @ dalvik/vm/arch/arm/calleabi.s:258 #6 0x4156d8de in DvmCa Lljnimethod (Args=0x6d5a5e18, presult=0x4151f568, Method=0x6d60e2d8, self=0x4151f558) at dalvik/vm/Jni.cpp:1159 #7 0x41546724 in Dalvik_mterp () at dalvik/vm/mterp/out/interpasm-armv7-a-neon.s:16240
"Switch to the nth layer of the call stack"
(GDB) F-one #11 0x41587ff6 in dalvik_java_lang_reflect_method_invokenative (args=<optimized out>, pResult= 0x4151f568) at dalvik/vm/native/java_lang_reflect_method.cpp:101101 Noaccesscheck);
"Show assembly Code"
(GDB) disassemble Dump of assembler code for function dalvik_java_lang_reflect_method_invokenative (U4 const*, jvalue*): 0x41587f7c <+0>: Stmdb sp!, {r0, r1, R2, R4, R5, R6, R7, R8, R9, R10, R11, LR} 0x41587f80 <+4>: ADD.W R4, R0, #12 0x41587f84 <+8>: ldmia.w R4, {r4, R8, R9} 0x41587f88 <+12>: mov R5, R0 0x41587f8a <+14>: mov r11, R1 0x41587f8c <+16>: Ldr R6, [R0, #4] 0x41587f8e <+18>: Ldr R7, [R0, #8] 0x41587f90 <+20>: LDR.W R10, [R0, #28] 0x41587f94 <+24>: Ldr R1, [R5 , #24] 0x41587f96 <+26>: mov r0, r4 0x41587f98 <+28>: BL 0x4158e828 <dvmslottomethod (Clas sobject*, int) > 0x41587f9c <+32>: Ldr R3, [R0, #4] ... (GDB) Disassemble 0x401b406c Dump of assembler code for function _jnienv::callstaticvoidmethod (_jclass*, _jmethodid*, ... ): 0x401b4058 <+0>: Push {R2, r3} 0x401b405a <+2>: Push {r0, r1, R4, LR} 0x401b405c <+4>: Add R3, SP, #16 0x401b405e <+6>: Ldr R4, [R0 , #0] 0x401b4060 <+8>: LDR.W R2, [R3], #4 0x401b4064 <+12>: LDR.W R4, [R4, #568]; 0x238 0x401b4068 <+16>: str R3, [SP, #4] 0x401b406a <+18>: BLX R4 0x401b406c <+20>: LDMIA.W sp!, {R2, R3, R4, LR} 0x401b4070 <+24>: Add sp, #8 0x401b4072 <+26>: bx LR En D of Assembler dump.
"View Current Register Value"
(GDB) Info reg r0 0x0 0 R1 0x4151dfa8 1095884712 R2 0x10 0 R3 0x0 R4 0x4175c138 1098236216 R5 0x6d68eeb8 1835593400 R6 0x0 0 R7 0x42dc4350 1121731408 R8 0x42dc4278 1121731192 r9 0x416f12a8 1097798312 r10 0x0 0 R11 0x4151f568 1095890280 R12 0xbe88e2d8 3196642008 sp 0xbe88e6c0 0xbe88e6c0 LR 0X41587FF7 1096318967 pc 0x41587ff6 0x41587ff6 <dalvik_java_lang_reflect_method_invokenative ( U4 const*, jvalue*) +122> cpsr 0x200f0030 537854000
"Show all threads for the current process"
(GDB) info thread ID Target ID Frame 1992 LWP epoll_wait () at Bionic/libc/arch-arm/syscalls /epoll_wait. S:10 LWP 2076 epoll_wait () at bionic/libc/arch-arm/syscalls/epoll_wait. S:10 LWP 1815 __futex_syscall3 () at Bionic/libc/arch-arm/bionic/futex_arm. s:39 LWP 1814 recvmsg () at bionic/libc/arch-arm/syscalls/recvmsg. S:9 One LWP 1808 __futex_syscall3 () at Bionic/libc/arch-arm/bionic/futex_arm. s:39 LWP 1817 __futex_syscall3 () at Bionic/libc/arch-arm/bionic/futex_arm. s:39 9 LWP 1813 __rt_sigtimedwait () at bionic/libc/arch-arm/syscalls/__rt_sigtimedwait. S:10 8 LWP 1819 __futex_syscall3 () at Bionic/libc/arch-arm/bionic/futex_arm. s:39 7 LWP 2062 __futex_syscall3 () at Bionic/libc/arch-arm/bionic/futex_arm. s:39 6 LWP 1818 __futex_syscall3 () at Bionic/libc/arch-arm/bionic/futex_arm. s:39 5 LWP 1826 __ioctl () at BioniC/libc/arch-arm/syscalls/__ioctl. S:9 4 LWP 2320 __ioctl () at Bionic/libc/arch-arm/syscalls/__ioctl. S:9 3 LWP 2210 epoll_wait () at bionic/libc/arch-arm/syscalls/epoll_wait. S:10 2 LWP 1824 __ioctl () at Bionic/libc/arch-arm/syscalls/__ioctl. S:9 * 1 LWP 1804 epoll_wait () at bionic/libc/arch-arm/syscalls/epoll_wait. S:10
"Switch Threads"
(GDB) T 9 [Switching to Thread 9 (LWP 1813)] #0 __rt_sigtimedwait () at Bionic/libc/arch-arm/syscalls/__rt_sigtimedwai T.s:10 mov r7, IP (gdb) bt #0 __rt_sigtimedwait () at bionic/libc/arch-arm/syscalls/__rt_sigtimedwait. S:10 #1 0x400b039c in sigwait (set=<optimized out>, sig=0x7194ad48) at bionic/libc/bionic/sigwait.cpp:43 #2 C6/>0x415716ca in Signalcatcherthreadstart (arg=<optimized out>) at dalvik/vm/signalcatcher.cpp:287 #3 0x41574176 in Internalthreadstart (ARG=0X747FD9D8) at dalvik/vm/thread.cpp:1746 ...
"View Memory Value"
(gdb) x/32wx 0x7194ad48 0x7194ad48: 0x00000004 0x6fbf3830 0x415dabd8 0x41573619 0x7194ad58: 0x41700880 0x42dc0768 0x00000005 0x00000001 0x7194ad68: 0x00000001 0x00000000 0x6fbf3830 0x747fd9d8 0x7194ad78: 0x415dabd8 0xbe88e598 0x747fd9d8 0x41574129 0x7194ad88: 0x7184d000 0x415db07c 0x400e92ec 0x41574177 0x7194ad98: 0x747fd9d8 0x00010002 0x747fd9f8 0x41700880 0x7194ada8: 0x7194add0 0x747f85a8 0x41574129 0x400aa1d4 0x7194adb8: 0x747fd9d8 0x747f85a8 0x7194add0 0x00000001 (gdb) x/20c 0XBE88EB48 0xbe88eb48: + ' /' + ' s ' 98 ' B ' "I ' n ' [] : ' + ' /' 118 ' V ' 0xbe88eb50: 101 ' e ' n ' [' d ' 111 ' o ' ' R '/' 98 ' B ' 0xbe88eb58: ' n ' + ' : ' + ' /' s '
"Show Symbols"
(GDB) p * (method*) 0x6d682328 $ = {Clazz = 0x41755dc0, AccessFlags = 9, Methodindex = 0, registerssize = 6, outssize = 3, Inssize = 1, name = 0x6f8c1862 <address 0x6f8c1862 out of bounds>, prototype = {Dexfile = 0x6d5aac48, protoidx = 3750}, shorty = 0x6f88be67 <address 0x6f88be67 out of bounds>, Insns = 0x6f745d98, Jniarginfo = 0, Nativefunc = 0x0 , Fastjni = False, Noref = False, Shouldtrace = False,
"Several configurations"
Set print pretty on: the structure looks pretty
Set Print Union: Sets whether the Union data is explicitly inside when the structure is displayed.
Set Print Vtbl: When this option is turned on, GDB will display the virtual function table in a more structured format. It is turned off by default.
For example:
(GDB) Set print pretty on (GDB) p * (method*) 0x6d682328 $ = { Clazz = 0x41755dc0, accessflags = 9, methodindex = 0,< C4/>registerssize = 6, outssize = 3, inssize = 1, name = 0x6f8c1862 <address 0x6f8c1862 out of bounds>,< C8/>prototype = { Dexfile = 0x6d5aac48, protoidx = 3750 }, shorty = 0x6f88be67 <address 0x6f88be67 Out of Bounds>, Insns = 0x6f745d98, jniarginfo = 0, nativefunc = 0x0, Fastjni = False, Noref = False, Shouldtrace = False, Registermap = 0x71a557d8, inprofile = false}
"namespace display error problem in C + +"
(GDB) P * (art::scopedobjectaccess *) 0xbe81e618a syntax error in expression, near ') 0xbe81e618 '.
Solution: Use single quotation marks to expand the type name, such as:
(GDB) p * (' art::scopedobjectaccess ' *) 0xbe81e618$19 = { <art::ScopedObjectAccessUnchecked> = { <art: :scopedobjectaccessalreadyrunnable> = { self_ = 0xb4f07800, env_ = 0xb4f512b0, vm_ = 0xb4f5c280 },< C6/>members of art::scopedobjectaccessunchecked: tsc_ = { self_ = 0xb4f07800, Thread_state_ = Art:: Krunnable, old_thread_state_ = art::knative, Expected_has_no_thread_ = False } }, <no data Fields>}
"How to get the offset of a class member in a class"
"How to get the size of a class"
(GDB) p ((' art::scopedobjectaccess ' *) 0) +1$33 = (art::scopedobjectaccess *) 0x1c
"Set Code search Path"
(GDB) directory ~/disk/android/source directories searched:/home/disk/android: $cdir: $CWD
(gdb) list67 }68 //uncompress an encoded reference from its bit representation.70 mirrortype* Uncompress () const shared_locks_required (locks::mutator_lock_) { uintptr_t as_bits = kpoisonreferences? Reference_: reference_;72 return reinterpret_cast<mirrortype*> (as_bits); }74 Friend Class object;76
GDB Common Commands