Monday, 23 April 2012

arm-elf-gdb as arm-simulator

To make your development more efficient and reduce time to market, you must take help of simulators. Today, I will talk about using arm-elf-gdb/run as arm-simulator

main.c
#include <stdio.h>
 
int main(void)
{
  puts("Hello World");
 
  return 0;
}

Get Newlib-syscalls.c

compile code as follows:
$ arm-elf-gcc -o main.elf -g hello.c Newlib-syscalls.c

# Run
arm-elf-run main.elf
Hello World!

# Debug
arm-elf-gdb main.elf
(gdb) target sim
Connected to the simulator.
(gdb) load
Loading section .init, size 0x20 vma 0x8000
Loading section .text, size 0x2f70 vma 0x8020
Loading section .fini, size 0x1c vma 0xaf90
Loading section .rodata, size 0x1c vma 0xafac
Loading section .eh_frame, size 0x4 vma 0xafc8
Loading section .ctors, size 0x8 vma 0xb0cc
Loading section .dtors, size 0x8 vma 0xb0d4
Loading section .jcr, size 0x4 vma 0xb0dc
Loading section .data, size 0x934 vma 0xb0e0
Start address 0x8100
Transfer rate: 116896 bits in <1 sec.
(gdb) list
1       #include <stdio.h>
2        
3       int main(void)
4       {
5         puts("Hello World");
6        
7         return 0;
8       }
(gdb) break 5
Breakpoint 1 at 0x8218: file main.c, line 5.
(gdb) run
Starting program: /private/tmp/main.elf 

Breakpoint 1, main () at main.c:5
5         puts("Hello World");
(gdb) cont
Continuing.
Hello World

Program exited normally.


courtesy "http://embdev.net"

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home