Search code examples
androiddelphidelphi-xe6map-files

How to create debug map file for Android app in Delphi XE6?


I have implemented a back trace for my android app compiled in XE6 using the Posix.Backtrace from https://bitbucket.org/shadow_cs/delphi-arm-backtrace. As it is now I get the backtrace but not the line numbers.

I am looking to create the map file for my android .so so that I can feed the addresses at runtime to addr2line so that my bug report will contain the line numbers.

I looked to the IDE to create a map file as I would for a Win32 Delphi app by selecting

Project > Options > Delphi Compiler > Linking.

There is no option for map file if Android Platform is selected. Selecting All Configurations Android seems explicitly excluded: Map File ARM, iOS Device Platform only; Map file, 32-bitWindows, OSx, iOS simulator only. I tried it anyway with optimization off, and debug on, and got no .map file.

Is there a way to create a .map file for an Android app in Delphi?

Thank you!


Solution

  • If you run up a RAD Studio Command Prompt and invoke dccaarm.exe you will see that despite the IDE not surfacing it, the compiler supports the -G and -GD command-line switches, both of which emit a map file.

    Invoke the project options dialog (Ctrl+Shift+F11) and in the options tree choose Delphi Compiler, Compiling. Now select Other options, Additional options to pass to the compiler and enter -G

    Recompile your project and a map file will be produced, e.g. project_folder\Android\Debug\libProject1.so.map

    Note, the IDE linker option is still absent in Delphi 10.1 Berlin, which I'm looking at - the question relates to Delphi XE7 and so some of the specifics of the steps outlined above may need minor tweaking.