[RFC] Symbol Separation - Debugging
Devang Patel
dpatel@apple.com
Tue Jul 1 21:56:00 GMT 2003
In a typical Mac OS X project, every source file includes very
large header. This happens in large projects on other platforms
also. Usually such large headers do not change frequently
and they add their overhead in standard compile-link-debug
cycle. As far as debugging information is concerned, it adds
overheads in 4 steps:
(1) GCC has to generate redundant debugging information
for types while compiling every source file.
(2) GCC has to dump this redundant info in .s files.
(3) Assembler has to chew more bytes and emit bigger .o files.
(4) Linker has to chew more bytes and do more work to reduce
redundant info.
In many cases PCH helps to reduce step(1) overhead. If project
has hundreds of object files then size bloat in .o files due to
redundant debugging info. causes headaches.
Various people at Apple have spent some time addressing this
overhead. Symbol Separation is first attempt to reduce these overheads.
It changes how various tools generates, stores and uses debugging
info.
In new Symbol Separation model, separate repositories
containing debugging informations are created in advance. While
compiling source files, GCC consults these repositories before
generating debugging information for each header and avoids
redundant debugging info. In the end, these repositories (they are
simple .o files) are supplied to linker so that it include them in final
executable. We have talked about possibility of GDB directly using
these repositories on the fly without requiring linker to glue them in
final image.
To make repository
cc <compiler options> -fsave-repository=/my_ss/ MyHeader.h
This will create two files.
(1) MyHeader.h.o: Object file with debugging info. This will be created
in
current working directory or its name and location can be controlled
using -o option.
(2) MyHeader.cinfo : Context info file to validate MyHeader.h.o. It
will be
created in /my_ss/ directory.
To use repository
cc <compiler options> -grepository -I/my_ss/ foo.c
While searching for MyHeader.h, if GCC finds MyHeader.cinfo, it will
validate
it. If it is valid then GCC will not generate debugging info for
MyHeader.h
I am attaching patch that ports symbol separation with this email. It
is based on
back-ported PCH in Darwin GCC (which is based on FSF GCC 3.3 as of Feb
'03)
so various pieces are out of sync. I have not finished bootstrap and
regression
testing yet.
Symbol separation is very different from current usage model. It will
require
some real life experience in using it to get it right. Plus
views/ideas/suggestions
from different people. So I would like to get your views about this
approach.
Is this a good idea ?
There is room for improvements in current implementation. I welcome your
suggestions in this regard also.
Thank you,
-Devang
2003-07-01 Devang Patel <dpatel@apple.com>
* c-common.c (cb_restore_write_symbols): New function.
(cb_clear_write_symbols): Same.
(cb_start_symbol_repository): Same.
(cb_end_symbol_repository): Same.
(cb_is_builtin_identifier): Same.
* c-common.h (dbg_dir): New.
(dbg_ss_init): New.
(c_common_write_context): New.
(cb_clear_write_symbols): New.
(cb_restore_write_symbols): New.
(cb_start_symbol_repository): New.
(cb_end_symbol_repository): New.
(c_valid_cinfo): New.
(cb_is_builtin_identifier): New.
* c-lex.c (init_c_lex): Initialize call backs for symbol
separation.
(c_common_write_context): New function.
* c-objc-common.c (c_objc_common_finish_file): Write context.
* c-opts (dbg_dir): New.
(c_common_parse_file): Init symbol separation.
(finish_options): Clear write_symbols, if required.
* cppfiles.c (struct include_file): New member suppress_dbg.
(context_ident): New.
(cinfo_file): New.
(stabs_checksum): New.
(c_valid_cinfo): New.
(stack_include_file): Clear write_symbols, if required.
(find_include_cinfo): New.
(find_include_file): Search valid cinfo.
(_cpp_read_file): Same.
(c_valid_cinfo): New function.
(suppress_dbg_info): Same.
(cpp_symbol_separation_init): Same.
(cpp_write_symbol_deps): Same.
(cpp_read_stabs_checksum): Same.
(cpp_get_stabs_checksum): Same.
* cpphash.h (enum cpp_cinfo_state): New.
(struct cpp_reader): New members - cinfo_candidate_file,
cinfo_src_file, cinfo_state.
* cppinit.c (cpp_read_main_file): Search valid cinfo.
* cpplib.c (_cpp_pop_buffer): Restore write_symbols.
* cpplib.h (struct cpp_options): New members - making_pch,
making_ss, warn_invalid_sr and use_ss.
(struct cpp_stab_checksum): New.
* cpppch.h (count_defs): Do not count builtins for symbol
separation.
(write_defs): Do not write builtins for symbol separation.
(cpp_valid_state): Warn if -Winvalid-sr is set.
* dbxout.c (dbxout_restore_write_symbols): New.
(dbxout_clear_write_symbols): New.
(dbxout_start_symbol_repository): New.
(dbxout_end_symbol_repository): New.
(struct gcc_debug_hooks): New members.
(dbxout_start_source_file): Do not start file, if separate
repository
is available.
(dbxout_end_source_file): Do not end file, if separate
repository is
available.
* flags.h (flag_grepository): New.
* gcc.c (pch): New.
(asm_options): Handle -fsave-repository.
(dbg_ss): New.
* toplev.c (orig_write_symbols): New.
(flag_grepository): New.
(documented_lang_options): New option -Winvalid-sr
(decode_g_option): Handle -grepository.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ss.diff
Type: application/octet-stream
Size: 38313 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20030701/a752331e/attachment.obj>
-------------- next part --------------
(ss.diff)
More information about the Gcc-patches
mailing list