Topic: Possible to generate symbol table?
Is there an option for either the compiler, debugger or any other tool to generate a symbol table that lists all variables/constants within a project?
For discussions of all Approximatrix products and related software
You are not logged in. Please login or register.
Approximatrix Forums → User Support → Possible to generate symbol table?
Is there an option for either the compiler, debugger or any other tool to generate a symbol table that lists all variables/constants within a project?
The closest you'll get to what you're asking is a map file generated by the linker. On Windows and GNU/Linux, you can add the flags:
-Wl,-Map,output.map
and on macOS:
-Wl,-map,output.map
The resulting file will list every routine in the executable and its address within the executable. It might also list global/common variables, but it certainly would not list variables that exist only in the scope of a single procedure or module. The flags can be added to the "Linker" box under the Compiler Flags category in Project Options.
I italicized the word "every" because the map will also list every internal routine that the Fortran runtime library will call. It can be overwhelming to see all the routines listed.
It accepted the linker flags with no issue. I assume that "output.map" is a text file with the symbol table (as well as other data), but could not find it in the folder associated with the project. Is it stored somewhere else?
Thanks.
output.map is indeed a text file, and you can use whatever name you want. It should be, by default, in the same directory as your project file. It would be located in the working directory where the compiler was run, so, if you're working with a project, it would be in the project's directory.
If you're using the Compile and Run Current File option in the Build menu, then the output file will be buried somewhere in your temporary directory. I don't recommend trying to locate it in that case.
Interesting, I noted that I did not follow your flag format exactly as typed, and when I did cut and paste the flags into the linker section, and rebuilt the project, got this output:
Generating target.exe
c:/program files (x86)/simply fortran 3/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find : Invalid argument
c:/program files (x86)/simply fortran 3/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find Map,output.map: No such file or directory
collect2.exe: error: ld returned 1 exit status
Error: Last command making (target.exe) returned a bad status
Error: Make execution terminated
* Failed *
Just to be sure, the first flag is Wl (lower case L) and not W1 (number 1)?
EDIT; does not like "W1" so it must be "Wl"
Thanks
Yes, it was a lowercase "L," not the number one. Sorry about that!
So what iis the source of the error messages listed in my previous messages?
I misunderstood your earlier post, and I thought you were saying that it worked. Regardless, I did make a mistake. It should be:
-Wl,-Map=output.map
Notice the equals sign in the flag, which is what I had missed.
A cleaner way to inspect the executable, though, might be to use the nm command from the command line. If Simply Fortran installed correctly, it should be on the path. You can use the command:
nm myprog.exe > output.lst
and it should produce a more readable output.
Approximatrix Forums → User Support → Possible to generate symbol table?
Powered by PunBB, supported by Informer Technologies, Inc.