- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 MK64FN1M0xxx12支持 OpenSDA 的开发套件。为了使调试更容易,我闪现了 J-Link支持 SEGGER 调试器命令集的固件。在这样做之前,我确保我的设备是 officially supported .
更详细地说,我正在尝试调试 mbed-os 5 ,特别是 uVisor安全补丁。 uVisor Github 页面有一个 debugging write-up它提供了通过 GDB session 连接到设备以接收调试打印的说明。我能够正确连接 J-Link session ,但我似乎无法实际调试二进制文件。此外,我似乎无法正确刷新设备。不过,我能够将二进制文件推送到设备 RAM。
他们的指示是这样的:
(gdb) target remote localhost:2331
(gdb) monitor reset
(gdb) monitor halt
(gdb) monitor semihosting enable
(gdb) monitor loadbin ./build/${target}/source/${your_app}.bin 0
(gdb) monitor flash device = ${device_name}
(gdb) load ./build/${target}/source/${your_app}
(gdb) file ./build/${target}/source/${your_app}
所以,我尝试复制他们的工作。通过 J-Link 连接到设备
$ JLinkGDBServer -device MK64FN1M0xxx12
SEGGER J-Link GDB Server V6.00g Command Line Version
JLinkARM.dll V6.00g (DLL compiled Aug 17 2016 13:20:32)
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: MK64FN1M0xxx12
Target interface: JTAG
Target interface speed: 1000kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link OpenSDA 2 compiled Sep 15 2016 14:57:31
Hardware: V1.00
S/N: 621000000
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...ERROR: Debugger tries to select target interface JTAG.
This interface is not supported by the connected emulator.
Selection will be ignored by the DLL.
J-Link found 1 JTAG device, Total IRLen = 4
JTAG ID: 0x2BA01477 (Cortex-M4)
Connected to target
Waiting for GDB connection...
建立GDB客户端 session
(gdb) target remote localhost:2331
Remote debugging using localhost:2331
0x200171fe in ?? ()
(gdb) monitor reset
Resetting target
(gdb) monitor halt
(gdb) monitor semihosting enable
Semi-hosting enabled (Handle on BKPT)
(gdb) monitor flash download 1
Flash download enabled
(gdb) shell cp ../.build/K64F/GCC_ARM/mbed-os-example-uvisor.bin /tmp
(gdb) monitor loadbin /tmp/mbed-os-example-uvisor.bin
Binary file loaded successfully (210240 bytes downloaded)
(gdb) monitor flash device = MK64FN1M0xxx12
Selecting device: MK64FN1M0xxx12
(gdb) load ../.build/K64F/GCC_ARM/source/main.o
Loading section .text._ZN4rtos6ThreadC2E10osPrioritymPh, size 0x54 lma 0x0
Loading section .text._ZN16NetworkInterfaceD2Ev, size 0x28 lma 0x0
Loading section .text._ZN16NetworkInterfaceD0Ev, size 0x1c lma 0x0
Loading section .text._ZN4mbed10DigitalOutC2E7PinName, size 0x24 lma 0x0
Loading section .text._ZN4mbed10DigitalOut5writeEi, size 0x1c lma 0x0
Loading section .text._ZN4mbed10DigitalOutaSEi, size 0x1c lma 0x0
Loading section .rodata._ZL10g_main_acl, size 0xc0 lma 0x0
Loading section .rodata.__uvisor_priv_sys_irq_hooks, size 0xc lma 0x0
Loading section .keep.uvisor.bss.boxes, size 0x80 lma 0x0
Loading section .rodata.__uvisor_mode, size 0x4 lma 0x0
Loading section .keep.uvisor.cfgtbl, size 0x28 lma 0x0
Loading section .keep.uvisor.cfgtbl_ptr_first, size 0x4 lma 0x0
Loading section .text._Z30local_ENET_Transmit_IRQHandlerv, size 0x14 lma 0x0
Loading section .text._Z29local_ENET_Receive_IRQHandlerv, size 0x14 lma 0x0
Loading section .text._ZN16NetworkInterfaceC2Ev, size 0x18 lma 0x0
Loading section .text._ZN12EthInterfaceC2Ev, size 0x24 lma 0x0
Loading section .text._ZN12EthInterfaceD2Ev, size 0x30 lma 0x0
Loading section .text._ZN12EthInterfaceD0Ev, size 0x1c lma 0x0
Loading section .text._ZN17EthernetInterfaceC2Ev, size 0x24 lma 0x0
Loading section .rodata, size 0xd4 lma 0x0
Loading section .text._Z16ethernet_connectv, size 0x54 lma 0x0
Loading section .text.main, size 0x174 lma 0x0
Loading section .text._ZN4mbed8CallbackIFvvEEC2EPS1_, size 0x1c lma 0x0
Loading section .text._ZN4mbed8CallbackIFvvEE6attachEPS1_, size 0x30 lma 0x0
Loading section .text._ZN4mbed8CallbackIFvvEE12_staticthunkEPvS3_, size 0x14 lma 0x0
Loading section .rodata._ZTV12EthInterface, size 0x24 lma 0x0
Loading section .rodata._ZTV16NetworkInterface, size 0x18 lma 0x0
Loading section .text._ZN17EthernetInterfaceD2Ev, size 0x30 lma 0x0
Loading section .text._ZN17EthernetInterfaceD0Ev, size 0x1c lma 0x0
Loading section .text._Z41__static_initialization_and_destruction_0ii, size 0x3c lma 0x0
Loading section .text._GLOBAL__sub_I___uvisor_priv_sys_irq_hooks, size 0x10 lma 0x0
Loading section .init_array, size 0x4 lma 0x0
Start address 0x0, load size 1816
Transfer rate: 1773 KB/sec, 56 bytes/write.
(gdb) file ../.build/K64F/GCC_ARM/source/main.o
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from ../.build/K64F/GCC_ARM/source/main.o...done.
(gdb) c
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
rtos::Thread::Thread (this=<error reading variable: Cannot access memory at address 0xfffffff4>, priority=<error reading variable: Cannot access memory at address 0xfffffff2>, stack_size=<error reading variable: Cannot access memory at address 0xffffffec>,
stack_pointer=<error reading variable: Cannot access memory at address 0xffffffe8>) at ../mbed-os/rtos/rtos/Thread.h:42
42 Thread(osPriority priority=osPriorityNormal,
(gdb)
生成的 J-Link 控制台输出
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x200171FE (Data = 0xEA126221)
Read 2 bytes @ address 0x200171FE (Data = 0x6221)
Resetting target
Halting target CPU...
...Target halted (PC = 0x200171FE)
Semi-hosting enabled (Handle on BKPT)
Flash download enabled
Loading binary file [/tmp/mbed-os-example-uvisor.bin] ...
Downloading 210240 bytes @ address 0x00000000
Binary file loaded successfully (210240 bytes downloaded)
Selecting device: MK64FN1M0xxx12
Downloading 84 bytes @ address 0x00000000
Downloading 40 bytes @ address 0x00000000
Downloading 28 bytes @ address 0x00000000
Downloading 36 bytes @ address 0x00000000
Downloading 28 bytes @ address 0x00000000
Downloading 28 bytes @ address 0x00000000
Downloading 192 bytes @ address 0x00000000
Downloading 12 bytes @ address 0x00000000
Downloading 128 bytes @ address 0x00000000
Downloading 4 bytes @ address 0x00000000
Downloading 40 bytes @ address 0x00000000
Downloading 4 bytes @ address 0x00000000
Downloading 20 bytes @ address 0x00000000
Downloading 20 bytes @ address 0x00000000
Downloading 24 bytes @ address 0x00000000
Downloading 36 bytes @ address 0x00000000
Downloading 48 bytes @ address 0x00000000
Downloading 28 bytes @ address 0x00000000
Downloading 36 bytes @ address 0x00000000
Downloading 212 bytes @ address 0x00000000
Downloading 84 bytes @ address 0x00000000
Downloading 372 bytes @ address 0x00000000
Downloading 28 bytes @ address 0x00000000
Downloading 48 bytes @ address 0x00000000
Downloading 20 bytes @ address 0x00000000
Downloading 36 bytes @ address 0x00000000
Downloading 24 bytes @ address 0x00000000
Downloading 48 bytes @ address 0x00000000
Downloading 28 bytes @ address 0x00000000
Downloading 60 bytes @ address 0x00000000
Downloading 16 bytes @ address 0x00000000
Downloading 4 bytes @ address 0x00000000
Writing register (PC = 0x00000000)
Read 4 bytes @ address 0x00000000 (Data = 0x00000000)
Read 2 bytes @ address 0x00000000 (Data = 0x0000)
Reading all registers
Read 4 bytes @ address 0x00000000 (Data = 0x00000000)
Starting target CPU...
ERROR: Can not read register 15 (R15) while CPU is running
Reading all registers
ERROR: Can not read register 0 (R0) while CPU is running
ERROR: Can not read register 1 (R1) while CPU is running
ERROR: Can not read register 2 (R2) while CPU is running
ERROR: Can not read register 3 (R3) while CPU is running
ERROR: Can not read register 4 (R4) while CPU is running
ERROR: Can not read register 5 (R5) while CPU is running
ERROR: Can not read register 6 (R6) while CPU is running
ERROR: Can not read register 7 (R7) while CPU is running
ERROR: Can not read register 8 (R8) while CPU is running
ERROR: Can not read register 9 (R9) while CPU is running
ERROR: Can not read register 10 (R10) while CPU is running
ERROR: Can not read register 11 (R11) while CPU is running
ERROR: Can not read register 12 (R12) while CPU is running
ERROR: Can not read register 13 (R13) while CPU is running
ERROR: Can not read register 14 (R14) while CPU is running
ERROR: Can not read register 15 (R15) while CPU is running
ERROR: Can not read register 16 (XPSR) while CPU is running
ERROR: Can not read register 17 (MSP) while CPU is running
ERROR: Can not read register 18 (PSP) while CPU is running
ERROR: Can not read register 24 (PRIMASK) while CPU is running
ERROR: Can not read register 25 (BASEPRI) while CPU is running
ERROR: Can not read register 26 (FAULTMASK) while CPU is running
ERROR: Can not read register 27 (CONTROL) while CPU is running
ERROR: Can not read register 32 (FPSCR) while CPU is running
ERROR: Can not read register 33 (FPS0) while CPU is running
ERROR: Can not read register 34 (FPS1) while CPU is running
ERROR: Can not read register 35 (FPS2) while CPU is running
ERROR: Can not read register 36 (FPS3) while CPU is running
ERROR: Can not read register 37 (FPS4) while CPU is running
ERROR: Can not read register 38 (FPS5) while CPU is running
ERROR: Can not read register 39 (FPS6) while CPU is running
ERROR: Can not read register 40 (FPS7) while CPU is running
ERROR: Can not read register 41 (FPS8) while CPU is running
ERROR: Can not read register 42 (FPS9) while CPU is running
ERROR: Can not read register 43 (FPS10) while CPU is running
ERROR: Can not read register 44 (FPS11) while CPU is running
ERROR: Can not read register 45 (FPS12) while CPU is running
ERROR: Can not read register 46 (FPS13) while CPU is running
ERROR: Can not read register 47 (FPS14) while CPU is running
ERROR: Can not read register 48 (FPS15) while CPU is running
ERROR: Can not read register 49 (FPS16) while CPU is running
ERROR: Can not read register 50 (FPS17) while CPU is running
ERROR: Can not read register 51 (FPS18) while CPU is running
ERROR: Can not read register 52 (FPS19) while CPU is running
ERROR: Can not read register 53 (FPS20) while CPU is running
ERROR: Can not read register 54 (FPS21) while CPU is running
ERROR: Can not read register 55 (FPS22) while CPU is running
ERROR: Can not read register 56 (FPS23) while CPU is running
ERROR: Can not read register 57 (FPS24) while CPU is running
ERROR: Can not read register 58 (FPS25) while CPU is running
ERROR: Can not read register 59 (FPS26) while CPU is running
ERROR: Can not read register 60 (FPS27) while CPU is running
ERROR: Can not read register 61 (FPS28) while CPU is running
ERROR: Can not read register 62 (FPS29) while CPU is running
ERROR: Can not read register 63 (FPS30) while CPU is running
ERROR: Can not read register 64 (FPS31) while CPU is running
Read 4 bytes @ address 0x00000000 (Data = 0x00000000)
Read 4 bytes @ address 0x00000000 (Data = 0x00000000)
Read 4 bytes @ address 0x00000000 (Data = 0x00000000)
WARNING: Failed to read memory @ address 0xFFFFFFF4
WARNING: Failed to read memory @ address 0xFFFFFFF2
WARNING: Failed to read memory @ address 0xFFFFFFEC
WARNING: Failed to read memory @ address 0xFFFFFFE8
看起来事情几乎 工作了,但我对 GDB 不够精通,不知道哪里可能失败了。从 J-Link 控制台输出看来,第二个 load
正在覆盖 RAM 的早期内容。如果我省略这条指令(但保留最后一个 file
命令)那么不会报告任何错误,但是通过 nc
的连接不会显示任何调试消息
$ nc localhost 2333
SEGGER J-Link GDB Server V6.00g - Terminal output channel
尽管 uVisor 调试记录(在 GDB 命令列表之后)表明许多类型的消息应该在运行时报告。除此之外,我的程序(看似)成功下载到电路板时在执行时表现不正常(没有闪烁的 LED 等)。
正如我之前使用 uVisor 发现的几次(因为它非常新),文档可能已过时。另外,我通过研究发现其他人需要使用 monitor flash download = 1
命令来启用 flash 编程,尽管它似乎对我不起作用。尽管此命令的输出显示为 Flash download enabled
,但据我所知(考虑输出和运行时间),没有任何内容写入闪存。
最佳答案
我能够使用以下命令集正确附加和接收调试语句:
file ./build/${target}/source/${your_app}.elf
target remote localhost:2331
monitor reset
monitor semihosting enable
load
似乎有必要从 elf 的调试符号加载,而不是通过 monitor
命令代理委托(delegate)加载二进制文件。此外,load
命令似乎将最后一个文件用作其默认目标(在本例中为 *.elf)。然而,这似乎很奇怪,考虑到 mBed-OS 不解析 ELF header 或加载任何东西......
无论如何,J-Link 控制台中的输出看起来更像我预期的那样:
Downloading 1024 bytes @ address 0x00000000
Downloading 16 bytes @ address 0x00000400
Downloading 4096 bytes @ address 0x00000410
Downloading 4096 bytes @ address 0x00001410
Downloading 4096 bytes @ address 0x00002410
Downloading 4096 bytes @ address 0x00003410
...
这不是一个完整的解决方案,所以我不会这样标记它。
关于linux - 使用 J-Link OpenSDA 固件和 GDB 调试 mBed-OS 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39617746/
假设我定义了一个 new gdb command其中包括别名。 import gdb import string class PrettyPrintString (gdb.Command):
是否可以使用 gdb 的 if 或 while 条件来测试 gdb 命令是否成功(而不是查询程序值或变量)? 现在为了清楚起见,我谈论的是 gdb 内置命令(即当您在 gdb 中键入 help 时出现
我只是使用 gdb 逐行逐行执行代码,以了解它是如何工作的以及它在做什么。我第一次这样做时效果很好,但现在下一个命令无法正常工作。有时它前进,有时它倒退。这没有意义。每次我这样做似乎都是相同的模式。下
我怎样才能运行类似 gdb -e path/to/exe -ex 'run --argnamae argvalue' 的东西? 让我们假设在过去一两年内有一个最新版本的 gfb。 Gdb 运行并打印响
我正在使用 gdb 调试程序,并且我想要命令的输出 $(perl -e 'print "A"x20') 作为我的论点。我怎样才能做到这一点?这样,论点将非常灵活。 最佳答案 您可以使用 run 命令,
我在 linux 上使用 gdb 版本 7.5.1,并试图使用诸如 $_memeq 之类的便利功能只是发现它显然不存在: Undefined command: "$_memeq". Try "help
我有: 正在运行的剥离二进制文件 总局 未剥离的二进制文件 我可以连接到运行剥离的二进制文件 (gdp -p PID)。如何将未剥离二进制文件中的符号提供给连接到正在运行的进程的 gdb? 最佳答案
我偶然发现了gdb的自动显示功能,该功能非常强大且方便。打电话后 (gdb) display/i $pc (gdb) display $rax 监视的值将在每个步骤后自动显示: (gdb) si 0x
我知道 Linux 等现代操作系统并不总是在应用程序最初链接的同一地址执行应用程序。但是,当调试器开始四处查看时,它需要知道原始链接地址和最终执行地址之间的关系。 GDB如何计算偏移量? 澄清:我不是
我想知道是否有可能从GDB本身获取已调试应用程序已打开但未关闭的文件/目录的列表? 当前,我设置了一个断点,然后使用lsof这样的外部程序来检查打开的文件。 但是这种方法确实很烦人。 环境:Debia
我想执行非常简单的命令 print var1, var2, var3, var4 在 gdb 中不时检查变量的值。 我不想使用显示,因为它会扰乱我的 View 。 我该如何做到这一点?现在我能做的就是
这个问题已经有答案了: gdb scripting: execute commands at selected breakpoint (1 个回答) 已关闭 8 年前。 我需要检查一个变量以确定它是否
在命令行下,我知道使用 echo $?给我退出代码。在gdb中,我使用“r”来运行程序,程序终止,那么gdb是如何得到这个退出码的呢? gdb 里面有什么命令吗? 谢谢! 最佳答案 当程序退出时,gd
我遇到了核心,无法从中获取回溯。我有两个问题。 我可以从以下位置找出导致崩溃的行或崩溃发生的位置吗列出命令输出? 否则如何处理。我应该将 heuristic-fence-post 设置为多少才能得到一
调试时加断点,运行bt可以看到栈帧。 通过运行信息寄存器选择帧时,可以看到特定帧上的寄存器值。 例如,考虑在第 5 帧设置断点。当断点被击中时,进入第 3 帧,可以看到查看寄存器值。 在第 5 帧设置
gdb 如何打印结构?来自 zengr 在 how does gdb work? 引用的“GDB 内部”文档看起来 GDB 使用 BFD 库从一个或多个符号表加载符号。如果是这种情况,gdb 怎么知道
我只是使用 gdb 逐行逐行执行代码,以了解它是如何工作的以及它在做什么。我第一次这样做时效果很好,但现在下一个命令无法正常工作。有时它前进,有时它倒退。这没有意义。每次我这样做似乎都是相同的模式。下
当我执行以下命令时,我得到不同的 function() 地址 (gdb) 中断函数() function() 0x804834a 处的断点 1。 (gdb) 打印函数() function() 0x8
我已经安装了 (OSX Mojave 10.14.6.) Eclipse CDT 和 GNU MCU Eclipse plugin最后 GNU Tools for ARM .我的目标是使用 GDB (
我必须对文件(main 和 functions)进行 cpp,然后让它们构建一个 exe 文件(代码)和两个目标文件(main.o 和 functions.o)。 如何从 gdb 命令行调试特定文件“
我是一名优秀的程序员,十分优秀!