GDB windows powershell 如何把一个命令输出结果赋值给一个变量

本文介绍如何在Windows环境下使用GDB和ADB工具组合进行Android应用程序的远程调试,包括设置端口转发、使用gdbserver以及处理信号停止等具体操作步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

找了一轮没有找到,发现可以使用$X=(...)这样来实现

awk是安装了NDK中带的, 在 android-ndk-r9d\toolchains\x86-4.8\prebuilt\windows-x86_64\bin 

 

 

或者(

http://sourceforge.net/projects/gnuwin32/files/gawk/3.1.6-1/gawk-3.1.6-1-bin.zip/download

 

PS C:\Users> $XXX=(adb shell ps  | findstr "xxxxb" | awk '{print $2}')
PS C:\Users> echo XXX
7147



PS C:\Users> $XPID=(adb shell ps  | findstr "xxxb" | awk '{print $2}') ; adb shell /data/local/gdbserver :23456 --attach $XPID

Attached; pid = 7147
Listening on port 23456

 

这个目录还有编译好的 i686-linux-android-gdb-orig.exe

复制一份它,把名字改成 gdbo.exe, 方便后面打命令。

转发一下端口
C:\Users>adb forward tcp:23456 tcp:23456

C:\Users>gdbo
GNU gdb (GDB) 7.3.1-gg2
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-mingw32msvc --target=i686-pc-linux-android".
For bug reporting instructions, please see:
<http://source.android.com/source/report-bugs.html>.
(gdb) target remote 127.0.0.1:23456
Remote debugging using 127.0.0.1:23456
warning: Could not load vsyscall page because no executable was specified
try using the "file" command first.
0xb74e2656 in ?? ()
(gdb) handle SIGPWR SIGXCPU nostop
Signal        Stop      Print   Pass to program Description
SIGXCPU       No        Yes     Yes             CPU time limit exceeded
SIGPWR        No        Yes     Yes             Power fail/restart
(gdb) handle SIG33  nostop pass
Signal        Stop      Print   Pass to program Description
SIG33         No        Yes     Yes             Real-time event 33
(gdb) c
Continuing.
[New Thread 13837]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 13837]
0xb37ed9f6 in ?? ()
(gdb) bt
#0  0xb37ed9f6 in ?? ()
#1  0xb30c021a in ?? ()
#2  0x00000000 in ?? ()
(gdb) info sharedlibrary

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值