Search code examples
delphiresourcesdelphi-7delphi-10-seattlemap-files

Is there any way to add .map file as resource of the project when compiling?


I'd like to add the map file as resource, then extract the file every time that execute the system, to ensure that the map file is always right, and make the life of support easier. In Delphi 7 I can compile the project, with the map file as resource, but the map is wrong, because when an exception is raised the call stack is wrong. In Delphi Seattle, I can't even compile, because it tries to add the resource before generating the map. I know that I can add the file in a post-compile task, but is there any way to do it in compiling/building time?

Sorry if I'm not very specific, that's my first question here. Thanks.

UPDATE

After I read some answers, I did some research. I was already using JEDI exception unit in my project, but I did not know the JEDI Debug expert. It does exactly what I want and more. JEDI Debug expert convert a .map file to .jdbg file, which is an encrypted file of map (map is just a text file). Also, the jdbg file is about 12% smaller then the map. It also has the options to insert the jdbg into binary (exe). To do that, I enabled the options:

  • Project -> JCL Debug expert -> Generate .jdbg files -> Enabled for this project

  • Project -> JCL Debug expert -> Insert jdbg data into binary -> Enabled for this project

  • Project -> JCL Debug expert -> Delete map files after conversion -> Enabled for this project (if you want to delete the file, of course)

To use this tool outside the IDE, with Jenkins for example, I had to build the project available in JEDI\jcl\examples\windows\debug\tools\MakeJclDbg.dpr. After build, it will generate the exe file in the bin directory of jcl. How to use:

MakeJclDbg -J -E -M map_filename

J - Create .JDBG files

E - Insert debug data into executable files

M - Delete MAP file after conversion

Executable files must be in the same directory as the MAP files. This will create the jdbg file (based in the map file), insert into the exe and delete the map. With this (and with the exception unit of JEDI), when an exception is raised, It's available to me the stack trace, the versions of all dll's used by the system, operation system info, and more, and also send all this to an email.

I realized that Embarcadero also have jdbg files of theirs bpl, so I think they use JCL tool as well.


Solution

  • No, the map file is generated after the program output is linked. It is impossible to incorporate a, not-yet generated, map file as a resource into the project.