Eric
Eric

Reputation: 19873

How to map PC (ARMv5) address to source code?

I'm developing on an ARM9E processor running Linux. Sometimes my application crashes with the following message :

[ 142.410000] Alignment trap: rtspserverd (996) PC=0x4034f61c Instr=0xe591300c Address=0x0000000d FSR 0x001

How can I translate the PC address to actual source code? In other words, how can I make sense out of this message?

Upvotes: 3

Views: 1305

Answers (2)

starblue
starblue

Reputation: 56812

You can turn on listings in the compiler and tell the linker to produce a map file. The map file will give you the meaning of the absolute addresses up to the function where the problem occurs, while the listing will help you pinpoint the exact location of the exception within the function.

For example in gcc you can do

gcc -Wa,-a,-ad -c foo.c > foo.lst

to produce a listing in the file foo.lst.

-Wa, sends the following options to the assembler (gas).

-a tells gas to produce a listing on standard output.

-ad tells gas to omit debug directives, which would otherwise add a lot of clutter.

The option for the GNU linker to produce a map file is -M or --print-map. If you link with gcc you need to pass the option to the linker with an option starting with -Wl,, for example -Wl,-M.

Alternatively you could also run your application in the debugger (e.g. gdb) and look at the stack dump after the crash with the bt command.

Upvotes: 2

nmichaels
nmichaels

Reputation: 51009

With objdump. Dump your executable, then search for 4034f61c:. The -x, --disassemble, and -l options are particularly useful.

Upvotes: 4

Related Questions