0

We are working on STM32F103(ARM Cortex M3) chip and compile our project with uVersion(ARM-MDK compiler). When crash happened, we saved the PC and LR registers. After that, we'd like to map addresses saved in PC and LR registers to source code lines for human reading by writing certain scripts. I read this What are .axf files?, which says axf contains such information. But I don't know how to utilize it. Thanks a lot.

[update 1]
Today I tried the fromelf.exe which can dump some debug useful information(fromelf.exe --text -g E:\proj_keil\keil_output\test.axf), for example:

008f5d: SPECIAL(0, 1) : 13 080043cc: ..\init\main.c:23.5 
008f5e: DW_LNS_negate_stmt : 06 
008f5f: SPECIAL(1, 2) : 1a 080043d0: ..\init\main.c:24.5 [

When I search the crashed PC address(0x080043d0), I can find its corresponding source line, though I did not find the LR address's source line for this crash.

So can I use fromelf.exe to solve my problem?

Community
  • 1
  • 1
bettermanlu
  • 627
  • 1
  • 9
  • 28
  • I don't know about ARM-MDK but gcc toolchain has the "addr2line" utility used for that purpose. Your toolchain most probably has something similar. Addr2line needs .elf file with debug informaton. .axf seems to be the same file as .elf with debug.. – mkmk88 Dec 28 '15 at 09:28

1 Answers1

1

The symbol and debug information is used by the debugger. The current code location, and the call-stack are directly displayed in the debugger.

If you want to post-mortem a particular address, you can start up the debugger, on the target or in the simulator, and request a disassembly at said address. Both the disassembly and if available the original source code will be displayed.

If you need to do this post-mortem with no debug information, it can be determined manually using information from the map file to determine the nearest public symbol, and then the .lst files to determine the precise location as an offset from the link map location. Generation of both .map and .lst files are project options in uVision.

Clifford
  • 88,407
  • 13
  • 85
  • 165
  • Thank you @Clifford, today I tried the fromelf.exe and updated some information about it, can I use fromelf.exe instead? – bettermanlu Dec 28 '15 at 10:42
  • 1
    Using a tool to extract debug symbols from the object code will work so long as the object code file actually contains debug information. The map file is generated at the build and is generated regardless of whether debug information is compiled in. Since the debugger is in any case usually the simplest way to *debug* code, then I can see little advantage in doing it the hard way. – Clifford Dec 28 '15 at 20:03
  • Thank you Clifford. We'd like to do some data analysis work with scripts automatically, such as classifying failure categories based on source code, thus using certain automation tool is more preferable than debugger IDE. – bettermanlu Dec 29 '15 at 01:48