Posted by: Sue Loh
I recently became aware of a detail about assembly functions showing up in the Monte Carlo profiler. I was involved in a discussion where someone was having trouble getting profiler hits for assembly functions. They could see the functions in their .map files, and they were sure they were running a decent portion of the time, but the functions weren't showing up in the profiler.
Let me take time out to explain how the profiler gets function symbols. When you set IMGPROFILER=1 (in your target build options or on the command line) before making an image, this affects a rule in config.bib. That rule sets PROFILE=ON, which ends up going into the ce.bib file that is passed to the "romimage" tool which builds your image. PROFILE=ON is a signal to romimage that it needs to build up a big table of all the symbols for all the modules from the MODULES section of ROM, and add this table to ROM itself. It’s this table that the monte carlo profiler uses to look up symbols for the profiler hits. It can add a substantial amount of data to your image, sometimes 2MB or more. To get these symbols, romimage reads the .map files from your release directory. If you're not getting hits for assembly functions, the first place to look is these .map files. In this case, the .map file contents were something like this:
0001:0000e61c CFunction1 f mycomponent:mycfile.obj
0001:0000e9f0 CFunction2 1000f9f0 f mycomponent:mycfile.obj
0001:0000ef1c AssemblyFunction1 1000ff1c mycomponent:myasmfile.obj
0001:0000f1c4 AssemblyFunction2 100101c4 mycomponent:myasmfile.obj
0001:0000f5a8 CFunction3 100105a8 f mycomponent:myothercfile.obj
Where AssemblyFunction1 and AssemblyFunction2 were not showing up in the profiler output, while the C functions were. In this case the functions were properly listed (as opposed to missing altogether), but they didn't have the "f" flag indicating that they were functions. So romimage was not including the symbols into the image, and therefore the profiler didn't know about them. A quick hack to fix the profiler was to manually edit the .map files, to add the "f," and then re-run makeimg. This did the trick.
But where does the "f" flag come from, and why was it missing? It turns out that the linker gets this from a special modifier to the export directive:
EXPORT MyFunction [FUNC]
So adding this tag to your assembly may fix the problem. There is still a problem with macros like NESTED_ENTRY and LEAF_ENTRY, which we will need to fix. Now that we're aware of the problem, hopefully we can take care of it soon. In the meantime, if you're stuck with NESTED_ENTRY and LEAF_ENTRY macros that don't work, I guess you'll have to do some .map file editing. It's a pain because you'd have to redo your work each time you rebuild the DLL or EXE, since that would regenerate the .map file. One possible way to do it in an automated fashion is to write a C# script or perl script that runs in preromimage.bat, to take care of the problem. Sorry, I don't have such a script to give you.