[Bug debug/57667] -femit-struct-debug-detailed
evgeny.gavrin at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Jun 21 09:07:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57667
--- Comment #2 from Evgeny Gavrin <evgeny.gavrin at hotmail dot com> ---
Hi!
>From the documentation to -femit-struct-debug-detailed:
"The value `base' means that the base of name of the file in which the type
declaration appears must match the base of the name of the main compilation
file."
I've created two files test.c and test-nonbase.h. (attached)
So, as I understand, when compiling like "gcc-4.7 test.c -O0 -g2
-femit-struct-debug-detailed=ind:ord:base" info about structs declared in
test-nonbase.h shouldn't be emitted.
But I can get all debug info on structs declared in test-nonbase.h using gdb:
Starting program: ./gcc-tests/a.out
Breakpoint 1, main () at test.c:18
18 free(indir_ord);
(gdb) p a
$1 = 5
(gdb) p b
$2 = 98
(gdb) p dir_ord
$3 = {a = 5, b = 97 'a'}
(gdb) p *indir_ord
$4 = {a = 10, b = 98 'b'}
Meanwhile, compiling with "-femit-struct-debug-detailed=ord:base" gdb can't
find the debug info:
Starting program: ./gcc-tests/a.out
Breakpoint 1, main () at test.c:18
18 free(indir_ord);
(gdb) p dir_ord
$1 = <incomplete type>
(gdb) p *inddir_ord
No symbol "inddir_ord" in current context.
(gdb) p *indir_ord
$2 = <incomplete type>
Let's see the code:
./gcc/opts.c
51 void
52 set_struct_debug_option (struct gcc_options *opts, location_t loc,
53 const char *spec)
54 {
*************
62 /* Default is to apply to as much as possible. */
63 enum debug_info_usage usage = DINFO_USAGE_NUM_ENUMS;
64 int ord = 1, gen = 1;
*************
96 if (usage == DINFO_USAGE_NUM_ENUMS)
97 {
98 if (ord)
99 {
100 opts->x_debug_struct_ordinary[DINFO_USAGE_DFN] = files;
101 opts->x_debug_struct_ordinary[DINFO_USAGE_DIR_USE] = files;
102 opts->x_debug_struct_ordinary[DINFO_USAGE_IND_USE] = files;
103 }
104 if (gen)
105 {
106 opts->x_debug_struct_generic[DINFO_USAGE_DFN] = files;
107 opts->x_debug_struct_generic[DINFO_USAGE_DIR_USE] = files;
108 opts->x_debug_struct_generic[DINFO_USAGE_IND_USE] = files;
109 }
110 }
111 else
112 {
113 if (ord)
114 opts->x_debug_struct_ordinary[usage] = files;
115 if (gen)
116 opts->x_debug_struct_generic[usage] = files;
117 }
This means that first optional parameter shouldn't affect so much. In case it's
omitted debug info should be emitted both for [dir:] and [ind:], but only for
base files.
Two cases:
1) test.c -O0 -g2 -femit-struct-debug-detailed=ind:ord:base
opts->x_debug_struct_ordinary[usage] = files;
2) test.c -O0 -g2 -femit-struct-debug-detailed=ord:base
opts->x_debug_struct_ordinary[DINFO_USAGE_DFN] = files;
opts->x_debug_struct_ordinary[DINFO_USAGE_DIR_USE] = files;
opts->x_debug_struct_ordinary[DINFO_USAGE_IND_USE] = files;
The following "-femit-struct-debug-detailed=ind:ord:base" means that debug info
should be emitted for structs used indirectly and declared in file that matches
the base name of the compilation file (test.c/test.h).
So, in the particular case, when struct is used indirectly in test.c and
declared in test-nonbase.h - info on structs shouldn't be emitted.
In case of, "-femit-struct-debug-detailed=ord:base" - it works correctly and
emits nothing.
More information about the Gcc-bugs
mailing list