diff options
author | dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-17 09:59:40 +0000 |
---|---|---|
committer | dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-17 09:59:40 +0000 |
commit | 62db153a9b1799e87fcc12393c34a4c9a1fa0ef5 (patch) | |
tree | 1df29dda9c3f6fb6e559fa82140695ea5b6130d1 /libcpp/line-map.c | |
parent | 3de02a0fadcb82dc5ec168ca091a6f47ffe0575b (diff) | |
download | gcc-62db153a9b1799e87fcc12393c34a4c9a1fa0ef5.tar.gz |
Support -fdebug-cpp option
This patch adds -fdebug-cpp option. When used with -E this dumps the
relevant macro map before every single token. This clutters the output
a lot but has proved to be invaluable in tracking some bugs during the
development of the virtual location support.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180084 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/line-map.c')
-rw-r--r-- | libcpp/line-map.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libcpp/line-map.c b/libcpp/line-map.c index fe07c16c37d..3dbaeaba7c9 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -1105,3 +1105,41 @@ linemap_expand_location_full (struct line_maps *set, xloc = linemap_expand_location (map, loc); return xloc; } + +/* Dump debugging information about source location LOC into the file + stream STREAM. SET is the line map set LOC comes from. */ + +void +linemap_dump_location (struct line_maps *set, + source_location loc, + FILE *stream) +{ + const struct line_map *map; + source_location location; + const char *path, *from; + int l,c,s,e; + + if (loc == 0) + return; + + location = + linemap_resolve_location (set, loc, LRK_MACRO_DEFINITION_LOCATION, &map); + path = LINEMAP_FILE (map); + + l = SOURCE_LINE (map, location); + c = SOURCE_COLUMN (map, location); + s = LINEMAP_SYSP (map) != 0; + e = location != loc; + + if (e) + from = "N/A"; + else + from = (INCLUDED_FROM (set, map)) + ? LINEMAP_FILE (INCLUDED_FROM (set, map)) + : "<NULL>"; + + /* P: path, L: line, C: column, S: in-system-header, M: map address, + E: macro expansion?. */ + fprintf (stream, "{P:%s;F:%s;L:%d;C:%d;S:%d;M:%p;E:%d,LOC:%d}", + path, from, l, c, s, (void*)map, e, loc); +} |