技术标签: debug gdb shell android google
The GNU Project debugger (GDB) is a commonly used Unix debugger. This page details using gdb to debug Android apps and processes for platform developers. For third-party app development, see Debug Your App.
To use GDB for debugging apps and processes:
For more help with setting up your environment, see Preparing to Build.
To connect to an already-running app or native daemon, use gdbclient.py with a PID. For example, to debug the process with PID 1234, run:
gdbclient.py -p 1234
The script sets up port forwarding, starts the appropriate gdbserver on the device, starts the appropriate gdb on the host, configures gdb to find symbols, and connects gdb to the remote gdbserver.
Note: In Android 6 and lower the script was a shell script called gdbclient instead of a Python script called gdbclient.py.
To debug a process as it starts, use gdbserver or gdbserver64. For a 64-bit executable:
adb shell gdbserver64 :5039 /system/bin/MY_TEST_64_BIT_APP
For a 32-bit executable:
adb shell gdbserver :5039 /system/bin/MY_TEST_32_BIT_APP
Example output:
Process MY_TEST_64_BIT_APP created; pid = 3460
Listening on port 5039
Next, identify the application PID from the gdbserver output and use it in another terminal window:
gdbclient.py -p APP_PID
Finally, enter continue at the gdb prompt.
Note: If you specify the wrong gdbserver, you'll get an unhelpful error message (such as "Reply contains invalid hex digit 59").
Sometimes you want to debug an app as it starts, such as when there's a crash and you want to step through code to see what happens before the crash. Attaching works in some cases, but in other cases is impossible because the app crashes before you can attach. The logwrapper approach (used for strace and valgrind) does not always work because the app might not have permissions to open a port, and gdbserver inherits that restriction.
To debug app startup, use the developer options in Settings to instruct the app to wait for a Java debugger to attach:
adb shell am start -a android.intent.action.MAIN -n APP_NAME/.APP_ACTIVITY
To let the app actually run, attach a Java Debug Wire Protocol (JDWP) debugger such as Java Debugger (jdb):
adb forward tcp:12345 jdwp:XXX # (Where XXX is the pid of the debugged process.)
jdb -attach localhost:12345
If you want debuggerd to suspend crashed processes so you can attach gdb, set the appropriate property:
# Android 7.0 Nougat and later.
adb shell setprop debug.debuggerd.wait_for_gdb true
# Android 6.0 Marshmallow and earlier.
adb shell setprop debug.db.uid 999999
At the end of the usual crash output, debuggerd provides instructions on how to connect gdb using the command:
gdbclient.py -p PID
For 32-bit ARM, if you don’t have symbols, gdb can get confused about the instruction set it is disassembling (ARM or Thumb). To specify the instruction set chosen as the default when symbol information is missing, set the following property:
set arm fallback-mode arm # or thumb
GDB supports debugging platform code on Visual Studio Code. You can use the VS Code debugger frontend instead of the GDB CLI interface to control and debug native code running on devices.
Before using VS Code for debugging, make sure you install the C/C++ extension.
To debug code using VS Code:
gdbclient.py -p pid | -n proc-name | -r ... --setup-forwarding vscode ANY_OTHER_FLAGS
This prints a JSON object and gdbclient.py continues running. This is expected; do not kill the gdbclient.py program.
After setting up the debugger configuration for the first time, you can skip steps 3 through 6.
消息拉取两个或多个客户端在互相发送和接受消息的时候,通常会使用以下两种方法来传递消息 。第一种方法被称为消息推送(push messaging),也就是由发送者来确保所有接收者已经成功接受到了消息。Redis内置了用于进行消息推送的PUBLISH命令和SUBSCRIBE命令。以前我们说过了这两个命令的缺陷。第二种方法被称为消息拉取(pull messaging),这种方法要求接收者
快捷键自定义系统快捷键代码补全 也属于快捷键
oracle数据库优化有很多种方法,下面介绍中采用session跟踪的方式:select event "Wait Event", time_waited "Time waited", time_waited /(...
一、案例分析1、需求分析若用户在一个全场8折的网站中购买了2斤香蕉、1斤苹果和3斤橘子,它们的价格分别为7.99元/斤、6.89元/斤、3.99元/斤,那么如何使用PHP程序来计算此用户实际需支付的费用呢? 下面通过PHP中提供的变量与常量、算术运算符以及赋值运算符等相关知识来实现PHP中的商品价格计算。2、设计思路使用PHP提供的变量保存用户所购买商品的名称、价格及数量。 由于网站中所有商品的折扣相同,所以使用PHP提供的常量来保存。 分别计算用户购买香蕉、苹果和橘子的价格。 计算打
#include<iostream>using namespace std;int main(){ int n; while (cin >> n, n != 0) { int m=1; for (int i = 1;i < n;++i) { ...
1. HashSet底层通过包装HashMap来实现,HashSet在添加一个值的时候,实际上是将此值作为HashMap中的key来进行保存。2. HashMap的底层实现是通过初始化化一个Entry数组来实现key、value的保存。3. 在HashMap的Entry中有四个变量,key、value、hash、next,其中next用于在hash方法添加值冲突时候,所指向的下一个
接着上篇tensorflow compute graph的理解,其中operation node 需要给运算定义forward 和backward函数。这篇中我们实现一个简单的fully_connected layer的forward 和backward 函数:class fullyconnect(Operation): def __init__(self, x, w, b):...
倒计时天时分秒函数(cocos-js)第一次写的方法,和优化后的方法第一次优化后在onload()中创建定时器感谢第一次写的方法,和优化后的方法第一次doSomething1(second_time) { if (parseInt(second_time) &lt; 60) { var time = "&lt;color=#ffffff&gt;倒计时:...
python读取数据文件以进行下一步分析我一般用pandas,代码很简单import pandas as pdimport numpy as npdata_file = pd.read_csv(file_name)但这会遇到两个问题:文件路径和编码1.文件路径选择mac不存在地址栏,有时候你去获取文件路径粘贴过来打开会报错File b'***.csv' does not exist而你不想每次要去...
Cisco Packet Tracer 实验之动态路由,ospf文章目录Cisco Packet Tracer 实验之动态路由,ospf准备工作1.动态路由2.ospf准备工作先配置电脑ip和路由器网关–en 进入全局模式–conf t 进入配置模式在全局模式下,先指定一个接口,告诉路由器,我现在要配置那个接口,然后,配置指定接口的 ip地址(也称网关)–最后打开(默认状态下,该接口链路是关闭的)如上图,先配置每一个接口的ip地址,直到所有接口都配置完成,如下图所示,每个接口的灯都变亮
hive导出查询文件到本地文件的2种办法 通过HQL语句可以将hive 中表的数据生成到指定的目录。有时候 我们可以利用hive来生成统计的中间文件(比源文件小的多的)方法有如下2种: www.2cto.com 1.INSERT OVERWRITE LOCAL DIRECTORY将结果输出到指定的目录:生成的文件数 和
定时任务每天凌晨1分30秒执行 bat脚本脚本内容@echo offset path=%path%;D:\mysql-5.7.34-winx64\binset y=%date:~0,4%set m=%date:~5,2%set d=%date:~8,2%set h=%time:~0,2%set cdate=%y%%m%%d%_%h%mysqldump -uroot -proot chemical > D:\database_backup\chemical_%cdate%.sql