I think I have a better handle of where the pch regressions with
--enable-mapped-location are coming from.  This is a follow-up
to some debugging/experimentation that Zack did - in September!

I agree with Zack that the problem is that the line_table
data structure needs to saved into the gch file along with the
other state.  But I think Zack missed some subtleties.

* The line_table.maps[0] entry represents the main file, and so
should *not* be restored from the gch file.

* The other line_table.maps[i], i > 0 appear to be "correct" in
the sense that their names and location values at gch-generation
time can replace the line_table.maps[i], i > 0 at restore time.

* However, there is some trickiness with "the tail" of the table:
we need to restore the line_table.highest_line and .high_location
from the gch file.  Furthermore, we need to create a current line_map
for "back in the main file again".  We also need to make sure the
LC_ENTER/LC_RENAME/LC_LEAVE nesting is sane and the new line_map
has the MAIN_FILE_P property.

* Note that we compile the gch file as it were the main file
- i.e. it has the MAIN_FILE_P property, and it is not included
from any file.  This means the restored line_table is slightly
anomalous.  One solution to this is when we generate the gch file,
we pretend the .h file is included in a dummy file, which we
may call <main>.  This adds two line_map entries: one for <main>
before the LC_ENTER of the .h file, and one at the end to LC_LEAVE
the .h file.  Then when we restore, we patch both of these to
replace "<main>" by the real main file name.

* Alternatively, we can keep gch-generation as is.  In that case
after restoration, we need to add a line_map that does an
LC_RENAME back to the main file.

* Any source_location values handed out before the #include
that restores the gch will become invalid.  They will be re-mapped
to that in the pre-compiled header.  Presumably that's ok - there's
no declartions or expressions in the main file at that point, or
the restore would have failed.  Any declarations that are <builtin>
or in the <command line> will presumably be the same either way.

* Presumably we need custom code to save and restore the line-map.
Zack experimented with having the entire line_table we gc-allocated,
and thus making using of the GTY machinery.  This addes an extra
indirection for each access to the line_table (probably not a big
deal - cpplib accesses are via the cpp_reader and thus unchanged).
But note we still need custom restore code.
--
        --Per Bothner
[EMAIL PROTECTED]   http://per.bothner.com/

Reply via email to