---
title: "android gdb ndk so lib"
author: "ggsonic"
date: "2013-02-26T15:57:34Z"
tags: []
categories: ["移动开发"]
slug: "android-gdb-ndk-so-lib"
draft: false
lastmod: "2013-02-26T15:59:48Z"
id: 1815371
url: "https://ggsonic.iteye.com/blog/1815371"
---

```shell

1. adb root           
手机需要rooted，并且开发者选项中设置adb可以获得root权限;                                                                                                                         
root access is disabled by system setting - enable in settings -> development options

2. ndk-build 设置
 ndk-build NDK_DEBUG=1
   V=1 
Android.mk : LOCAL_CFLAGS := -g
(there should be gdb.setup gdbserver files under the libs/armeabi after ndk-build)..

3. adb shell
su
#am start -n com.xxx.xxx/.MainActivity
#ps |grep -i xxx
#gdbserver :5039 --attach your_process_id

4.
$adb forward tcp:5039 tcp:5039
$/Users/xxx/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi-gdb
5.
(from the libs/armeabi/gdb.setup file, get the following path)
(gdb)set solib-search-path /Users/xxxx/obj/local/armeabi-v7a
(gdb)directory /path/to/your/project's all source/directory
(gdb)target remote :5039
(gdb) bt full
(gdb) set logging on

```

references:
1. http://www.bobbog.com/archives/24
2. http://wiki.debian.org/HowToGetABacktrace
3. http://www.kandroid.org/online-pdk/guide/debugging_gdb.html