major and minor macros in /usr/include/x86_64-linux-gnu/sys/sysmacros.h

2012-01-04 Thread Pedro Larroy
Hi

Shouldn't major and minor macros in
/usr/include/x86_64-linux-gnu/sys/sysmacros.h be inline functions?
They prevent doing stuff like

struct T {
 T() : major() {}
 int major;
};

in C++.  According to the C++ standard those names shoudn't be
reserved to the implementation, and thus be available.

Pedro.


Re: GCC stack backtraces

2012-09-14 Thread Pedro Larroy
If you link with -rdynamic you can show a backtrace with something
like the attached code.

On Wed, Aug 29, 2012 at 9:22 AM, Ian Lance Taylor  wrote:
> I've spent the last couple of days working on a stack backtrace library.
>
> It uses the GCC unwind interface to collect a stack trace, and parses
> DWARF debug info to get file/line/function information.  (Of course it's
> silly to write yet another DWARF reader, but I didn't find an existing
> reader that seemed wholly suitable.)  The code currently only works for
> ELF/DWARF, but it's designed to support other object file and debug
> formats should anybody care to write them.  Since its use in GCC would
> be purely for GCC developers, it's not essential that it be fully
> portable.
>
>
> I picked a random PR that causes an ICE.  Here is the final output of
> g++ -c foo.cc:
>
> foo.cc:6:6: internal compiler error: in cp_lexer_new_from_tokens, at 
> cp/parser.c:638
> 0xed6e77 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
> ../../trunk/gcc/diagnostic.c:700
> 0xed7c2f internal_error(char const*, ...)
> ../../trunk/gcc/diagnostic.c:1003
> 0xed6703 fancy_abort(char const*, int, char const*)
> ../../trunk/gcc/diagnostic.c:1057
> 0x5bc3ee cp_lexer_new_from_tokens
> ../../trunk/gcc/cp/parser.c:638
> 0x5bc3ee cp_parser_push_lexer_for_tokens
> ../../trunk/gcc/cp/parser.c:3293
> 0x5c5510 cp_parser_late_parsing_for_member
> ../../trunk/gcc/cp/parser.c:21741
> 0x5c5510 cp_parser_class_specifier_1
> ../../trunk/gcc/cp/parser.c:18210
> 0x5c5510 cp_parser_class_specifier
> ../../trunk/gcc/cp/parser.c:18234
> 0x5c5510 cp_parser_type_specifier
> ../../trunk/gcc/cp/parser.c:13393
> 0x5dd56d cp_parser_decl_specifier_seq
> ../../trunk/gcc/cp/parser.c:10734
> 0x5e00d7 cp_parser_single_declaration
> ../../trunk/gcc/cp/parser.c:21344
> 0x5e1211 cp_parser_template_declaration_after_export
> ../../trunk/gcc/cp/parser.c:21231
> 0x5ea9f9 cp_parser_declaration
> ../../trunk/gcc/cp/parser.c:10186
> 0x5e9507 cp_parser_declaration_seq_opt
> ../../trunk/gcc/cp/parser.c:10108
> 0x5eae92 cp_parser_translation_unit
> ../../trunk/gcc/cp/parser.c:3760
> 0x5eae92 c_parse_file()
> ../../trunk/gcc/cp/parser.c:27585
> 0x6ed0c4 c_common_parse_file()
> ../../trunk/gcc/c-family/c-opts.c:1137
> 0xa2017b compile_file
> ../../trunk/gcc/toplev.c:546
> 0xa21d89 do_compile
> ../../trunk/gcc/toplev.c:1863
> 0xa21d89 toplev_main(int, char**)
> ../../trunk/gcc/toplev.c:1939
> 0x7fb0a50d8c4c ???
> ???:0
> 0x4c6db8 ???
> ???:0
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See  for instructions.
>
>
> So, big deal.  You can get a stack backtrace from gdb anyhow.
>
> For a more interesting use I hacked ggc-common.c to collect detailed
> statistics when used with -fmem-report.  This gives us data similar to,
> and better than, that you get when you configure GCC with
> --enable-gather-detailed-mem-stats.  However, with this approach you do
> not need to recompile GCC.  Running this modified GCC with -fmem-report
> -O2 -g combine.ii took 36 seconds.  The full report is too large to
> attach here, but here are the last few entries of the ggc-common.c.
> Note that I spent exactly 0 seconds making the report pretty.
>
> 0xbf1151 ../../trunk/gcc/tree.c:7607 build_function_type(tree_node*, 
> tree_node*)
> 0x50f1c0 ../../trunk/gcc/cp/decl.c:9346 grokdeclarator(cp_declarator const*, 
> cp_decl_specifier_seq const*, decl_context, int, tree_node**)
> 0x514a75 ../../trunk/gcc/cp/decl.c:4366 start_decl(cp_declarator const*, 
> cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**)
> 0x5dbeca ../../trunk/gcc/cp/parser.c:15720 cp_parser_init_declarator
> 0x5de4ba ../../trunk/gcc/cp/parser.c:10445 cp_parser_simple_declaration
> 0x5e6337 ../../trunk/gcc/cp/parser.c:10326 cp_parser_block_declaration
> 0x5ea8fb ../../trunk/gcc/cp/parser.c:10222 cp_parser_declaration
> 0x5e9507 ../../trunk/gcc/cp/parser.c:10108 cp_parser_declaration_seq_opt
> 0x5eae92 ../../trunk/gcc/cp/parser.c:3760 cp_parser_translation_unit
> 0x5eae92 ../../trunk/gcc/cp/parser.c:27585 c_parse_file()
> 0x6ed0c4 ../../trunk/gcc/c-family/c-opts.c:1137 c_common_parse_file()
> 0xa2017b ../../trunk/gcc/toplev.c:546 compile_file
> 0xa21d89 ../../trunk/gcc/toplev.c:1863 do_compile
> 0xa21d89 ../../trunk/gcc/toplev.c:1939 toplev_main(int, char**)
> 0x7f4044f36c4c ???:0 ???
> 0x4c6db8 ???:0 ???
> 611352: 1.0%  0: 0.0% 181776: 0.6%  0: 0.0%   4721
> 0xbf342f ../../trunk/gcc/tree.c:1224 build_int_cst_wide(tree_node*, unsigned 
> long, long)
> 0xbf37a5 ../../trunk/gcc/tree.c:1065 double_int_to_tree(tree_node*, 
> double_int)
> 0xbf37ea ../../trunk/gcc/tree.c:1042 build_int_cst(tree_node*, long)
> 0xa19fee ../../trunk/gcc/stor-layout.c:2545 
> set_min_and_max_values_for_integral_