ARM assembly debugging

Publisher:annye_chengLatest update time:2016-05-05 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
I've been learning ARM assembly recently, but ARM is not as easy to debug as x86. Fortunately, there are virtual machines and universal debuggers like GDB. After searching Google for a long time and combining my own practice, I finally succeeded in debugging ARM assembly. I would like to share this with students who are interested in ARM embedded systems.


First, let me explain the tools you need
. 1. QEMU This emulator can not only simulate x86, but also ARM and MIPS, which is very powerful.
2. GDB (source code) Needless to say, it is a universal debugger, but it needs to be compiled from source code.
3. arm-linux cross toolchain I use the 3.4 version that comes with my own development board, but you can just download one from www.uclinux.org

(but it seems that uclinux has been blocked by GFW...) Compile GDB first and set the target to the ARM platform:
$ ./configure --target=arm-linux
$ make

$ make install

Note: The default directory is /usr/local/bin/

OK, start writing the assembly program. The sample code is very simple. It assigns values ​​to three registers and then loops endlessly. Note that there must be an endless loop, otherwise illegal instructions or unknown instructions will be encountered.

=======test.S========
.globl _start
_start:
  mov r0, #0
  mov r1, #1
  mov r2, #2
loop:
  b loop
=======EOF=========

Compile:
$ arm-linx-as -o test.o test.SLink
:
$ arm-linux-ld -o test test.oNow
you can use objdump to view the contents of test:
$ arm-linux-objdump -d testThe
next step is debugging. Use qemu to start gdb port monitoring:
$ qemu-arm -g 11111 testAfter
starting gdb, note that test must be specified when starting. You cannot use file to specify test after starting (why not, it's not clear, but it's the test result):
$ arm-linux-gdb /PATH_TO_TEST Note that the gdb here is not the system's gdb, but the gdb just compiled
(gdb) target remote localhost:11111 Set the target to the local port 11111
(gdb) disassemble Disassembly
(gdb) display /10i $pc-16 This command displays the 10 instructions near the current pc, replacing the list command for debugging x86 programs
(gdb) si si, not s, is a single-step execution instruction. If it is s, it will execute to the next label. Similar to ni
(gdb) info register Well, this is to view the value of the register~
(gdb) x /16 0 This is to view the memory information of the 16 words (32 bits per word) starting from 0x00000000

That's about it. There is a problem that I don't know how to set the breakpoint of the instruction. I'll try it later...
If you run the program directly, directly

qemu-arm test
Now you can practice while reading the book~ QEMU also supports Thumb instruction set and Jazelle instruction set, which should be debugged in this way

Keywords:ARM Reference address:ARM assembly debugging

Previous article:Conversion between ARM assembly and Gnu assembly
Next article:In Ubuntu, when connected to the arm development board, use the wireless network card to set up Internet access

Recommended ReadingLatest update time:2024-11-17 07:36

Realization of traction therapy system based on ARM
Introduction In medicine, physical traction is usually used as a conservative treatment method for lumbar spine diseases such as lumbar disc herniation. This traction bed system uses a two-section bed as a treatment platform, adopts embedded processors such as ARM and combines computers to achieve distributed
[Microcontroller]
Realization of traction therapy system based on ARM
ARM9 2440 clock
In fact, ARM9 is nothing special, it is basically the same as ARM7 and 6, and there is no difference when running naked. I personally feel that it is wrong! But the omnipotent C language is real!  U32 val; U8 m, p, s; val = rMPLLCON; m = (val 12)&0xff; p = (val 4)&0x3f; s = val&3; //(m+8)*FIN*2 Do not exceed 32 di
[Microcontroller]
ARM commonly used pseudo instructions
1. AREA  The AREA directive is used to define a code segment or a data segment.        Syntax format:         AREA segment name attribute 1, attribute 2, ...         If the segment name starts with a number, the segment name must be enclosed in “|”, such as |1_test|.         The attribute field indicates the relevant
[Microcontroller]
The Light of ARM (3) --- UART
       today,we will study the UART of S3C2410,there is no doubt that the datasheet of S3C2410 is very important.        let’s go!       UART special registers      (1)UART LINE CONTROL REGISTER        there are three UART line control registers including ULCON0.ULCON1.and ULCON2 in the UART block.the address of three
[Microcontroller]
The Light of ARM (3) --- UART
Big models bring new momentum to edge AI, Arm launches Ethos-U85 NPU supporting Transformer
2023 is undoubtedly the first year of generative AI. From the emergence of ChatGPT to the 'Thousand Model War', the Transformer architecture has received great attention. The Transformer architecture revolutionized generative AI when it was introduced in 2017 and has become the architecture of choice fo
[Embedded]
Big models bring new momentum to edge AI, Arm launches Ethos-U85 NPU supporting Transformer
ARM assembly coprocessor instructions
Coprocessor: A chip that offloads specific processing tasks from a system's microprocessor. ARM microprocessors can support up to 16 coprocessors for various coprocessing operations. During program execution, each coprocessor only executes coprocessing instructions for itself and ignores instructions from the ARM pr
[Microcontroller]
ARM Basics: Popular Understanding of ARM Knowledge
/************************************************************************************************************************** Reference: Description:. **************************************************************************************************************/  Let me remember some concepts, I have my own understandi
[Microcontroller]
ARM Basics: Popular Understanding of ARM Knowledge
ARM instruction condition codes
1. Condition flag bit of the program status register N is the b31-bit value of the result of the operation. For signed two's complement, N=1 when the result is negative, and N=0 when the result is positive or zero; When the result of the Z instruction is 0, Z=1, otherwise Z=0; C When using addition (including
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号