Can I debug relocated code at source-level with DS-5 Debugger?
2017-10-20 13:22
543 查看
origin: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15225.html
ARM Technical Support Knowledge Articles
DS-5
Assuming you have a debug version of the ELF image (compiled with -g) available that contains debug information, you can load the debug symbols into DS-5 Debugger and have them applied with an address offset.
For example, if you have some code within an executable file prog.axf that is built at a base address 0x8000, but which relocates some functions at run-time (without the build tools knowledge, for example, without using the ARM Linker's scatter-loading mechanism)
to an address 0x18000, then an address offset of 0x10000 can be applied to allow the code to be debugged after it has moved.
You can debug this initial code (for example, single-step though it) at source level.
Now run the code that moves/copies some functions. Stop the code just before executing one of those functions, then:
You can now debug that function (for example, single-step though it) at source level.
If you need to return to the original unmoved calling code:
This feature is typically used for debugging bootloaders such as U-Boot that relocate code to a different place in RAM (for an example, see the DS-5 U-Boot example), and also for debugging OS code before the MMU is turned on, for example, in the Linux kernel.
For source-level debug of the Linux kernel before the MMU is on you need to calculate the offset between the virtual and physical addresses of the code. For instance if the kernel is linked at virtual address 0xC0008000 and has been loaded at physical address
0x80008000 (as is the case with the DS-5 Example Linux Distribution), the offset is 0x80008000 - 0xC0008000 = -0x40000000.
You can the load the kernel debug symbols, with the offset:
For a complete example of how DS-5 Debugger can be used to debug the Linux kernel, both pre-MMU enable and post-MMU enable stages, see Software Enablement Blog:
Porting Linux Made Easy With DS-5
ARM Technical Support Knowledge Articles
Document Merge (0) Favorite Articles (0) |
Can I debug relocated code at source-level with DS-5 Debugger?
Applies to:DS-5
Answer
Yes, DS-5 Debugger supports the debug at source-level of code that has been relocated (that is, moved or copied to execute at another address in the memory map), by using the add-symbol-file command.Assuming you have a debug version of the ELF image (compiled with -g) available that contains debug information, you can load the debug symbols into DS-5 Debugger and have them applied with an address offset.
For example, if you have some code within an executable file prog.axf that is built at a base address 0x8000, but which relocates some functions at run-time (without the build tools knowledge, for example, without using the ARM Linker's scatter-loading mechanism)
to an address 0x18000, then an address offset of 0x10000 can be applied to allow the code to be debugged after it has moved.
loadfile prog.axf # Load image and its debug information
You can debug this initial code (for example, single-step though it) at source level.
Now run the code that moves/copies some functions. Stop the code just before executing one of those functions, then:
file # Discard existing debug information add-symbol-file prog.axf 0x10000 # Load debug information and apply an offset
You can now debug that function (for example, single-step though it) at source level.
If you need to return to the original unmoved calling code:
file # Discard existing debug information add-symbol-file prog.axf # Load debug information for original base address
This feature is typically used for debugging bootloaders such as U-Boot that relocate code to a different place in RAM (for an example, see the DS-5 U-Boot example), and also for debugging OS code before the MMU is turned on, for example, in the Linux kernel.
For source-level debug of the Linux kernel before the MMU is on you need to calculate the offset between the virtual and physical addresses of the code. For instance if the kernel is linked at virtual address 0xC0008000 and has been loaded at physical address
0x80008000 (as is the case with the DS-5 Example Linux Distribution), the offset is 0x80008000 - 0xC0008000 = -0x40000000.
You can the load the kernel debug symbols, with the offset:
add-symbol-file vmlinux -0x40000000
For a complete example of how DS-5 Debugger can be used to debug the Linux kernel, both pre-MMU enable and post-MMU enable stages, see Software Enablement Blog:
Porting Linux Made Easy With DS-5
相关文章推荐
- Debugging with GDB: The GNU Source-Level Debugger
- vs2008 debug with .net framework source code!
- how can i get the source code path && file names from an ELF file(compired with -g)?
- vs2008 debug with .net framework source code!
- ASP.NET: Custom AutoCompleteTextBox WebControl [With Source Code]
- debug with dump at Visual Studio 2005
- 收藏:Getting started with the uClinux source code
- Configuring Visual Studio to Debug .NET Framework Source Code
- How to debug test code on Windows Mobile Emulator with Visual Studio
- [AIR]AIR SQLite Administrator(with Source Code)
- SQL Server 2005 Bible (with source code)
- Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.错误解决办法
- CORBA Programming with TAO - 2.Compile Source Code(编译ACE/TAO/CIAO)
- CORBA Programming with TAO - 2.Compile Source Code(编译ACE/TAO/CIAO)
- paip.php调试imcompatible debug sever version..with zend debugger
- android数据库操作 sqlite returned: error code = 14, msg = cannot open file at source line 25502
- 报错Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
- TinyOS论文06:Clairvoyant: A Comprehensive Source-Level Debugger for Wireless Sensor Networks
- can not create edge 'e0' with unspecified source解决方案