converting Ada to handle USE_MAPPED_LOCATION
Per Bothner
per@bothner.com
Sat Mar 19 21:38:00 GMT 2005
I fixed the regressions USE_MAPPED_LOCATION for C and C++, and
we've now branched, so it's is probably time to get Ada working.
(There is a Java problem, for which I have a patch, but it may
hurt debugging. Until that is fixed, leave Java out of
--enable-languages, or apply this patch:
http://gcc.gnu.org/ml/gcc-patches/2005-03/msg01094.html )
Some links to the pervious discussions:
http://gcc.gnu.org/ml/gcc/2004-10/msg00012.html
http://gcc.gnu.org/ml/gcc/2004-10/msg00200.html
http://gcc.gnu.org/ml/gcc/2004-10/msg00229.html
http://gcc.gnu.org/ml/gcc/2004-10/msg00248.html
http://gcc.gnu.org/ml/gcc/2004-10/msg00261.html
http://gcc.gnu.org/ml/gcc/2004-10/msg00265.html
There wasn't really a consensus on how to do it. The ideal solution
I think is for Ada to use line-map's source_location for Sloc in its lexer.
I don't think it would be that hard, but an easier solution may be
to leave Sloc alone, and instead translate Sloc integers to source_location
when we translate the Ada intermal format to Gcc trees. See:
http://gcc.gnu.org/ml/gcc/2004-10/msg00248.html
I think this is my current recommendation; to expand on it a little:
We can add a new function line-map.h:
source_location
linemap_get_location (struct line_table*,
const char *filename, int line, int column);
A simple implementation:
(1) check that (file, line, column) can use the current line_map:
strcmp (filename, map->to_file) == 0
&& line >= map->to_line
&& column < (1 << map->column_bits)
&& line not excessively big;
The latter is a heuristic to avoid using up line number too greedily;
I suspect it may not be an issue.
(2) If the test passes, calculate the source_location from (line, column)
using map->start_location and map->column_bits. Also update
highest_location and highest_line.
(3) Otherwise, allocate a new map using linemap_add.
In the future we can improve linemap_get_location if it turns out to be
necessarily; for example searching previously used map entries and/or
keeping a cache of recently used maps.
Some people suggested instead that the location_t in the shared Gcc
should be a language-defined opaque time, and have language call-backs.
The default would be source_location as managed by line_map, but Ada
could use a different implementation. That may be a short-term easier
for Ada, but I don't think it's the best long-term solution for Gcc
as a whole.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
More information about the Gcc
mailing list