public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* -femit-struct-debug-reduced/baseonly debug info
@ 2013-06-18 11:40 Evgeny Gavrin
  2013-06-18 13:43 ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Evgeny Gavrin @ 2013-06-18 11:40 UTC (permalink / raw)
  To: gcc-help

Hi!

I'm trying to reduce the amount of debug info in my binaries.

What kind of debug info will I loose in case of using -femit-struct-debug-reduced or -femit-struct-debug-baseonly?
And what is still available?

/*
With optimism,
Evgeny Gavrin

email : evgeny.gavrin@hotmail.com
*/ 		 	   		  

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: -femit-struct-debug-reduced/baseonly debug info
  2013-06-18 11:40 -femit-struct-debug-reduced/baseonly debug info Evgeny Gavrin
@ 2013-06-18 13:43 ` Ian Lance Taylor
  2013-06-18 14:53   ` Evgeny Gavrin
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2013-06-18 13:43 UTC (permalink / raw)
  To: Evgeny Gavrin; +Cc: gcc-help

On Tue, Jun 18, 2013 at 4:40 AM, Evgeny Gavrin
<evgeny.gavrin@hotmail.com> wrote:
>
> I'm trying to reduce the amount of debug info in my binaries.
>
> What kind of debug info will I loose in case of using -femit-struct-debug-reduced or -femit-struct-debug-baseonly?
> And what is still available?

The GCC manual explains how those options work.  I could repeat that
documentation but that seems unhelpful.  Perhaps it would help if you
could explain what you don't understand about the documentation.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: -femit-struct-debug-reduced/baseonly debug info
  2013-06-18 13:43 ` Ian Lance Taylor
@ 2013-06-18 14:53   ` Evgeny Gavrin
  2013-06-18 16:23     ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Evgeny Gavrin @ 2013-06-18 14:53 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Quote from the documentations is not clear to me: "Emit debug information for struct-like types only when the base name of the compilation source file matches the base name of file in which the type was defined, unless the struct is a template or defined in a system header. "

As I understood, this'll store info only about static types and I'll loose info about inlining, for example, am I right?

And to extend the question:
I don't understand what means direct or indirect accessed structs? Ordinary or generic ones? Where I can read about it?

/*
With optimism,
Evgeny Gavrin

email : evgeny.gavrin@hotmail.com
*/


----------------------------------------
> Date: Tue, 18 Jun 2013 06:43:18 -0700
> Subject: Re: -femit-struct-debug-reduced/baseonly debug info
> From: iant@google.com
> To: evgeny.gavrin@hotmail.com
> CC: gcc-help@gcc.gnu.org
>
> On Tue, Jun 18, 2013 at 4:40 AM, Evgeny Gavrin
> <evgeny.gavrin@hotmail.com> wrote:
>>
>> I'm trying to reduce the amount of debug info in my binaries.
>>
>> What kind of debug info will I loose in case of using -femit-struct-debug-reduced or -femit-struct-debug-baseonly?
>> And what is still available?
>
> The GCC manual explains how those options work. I could repeat that
> documentation but that seems unhelpful. Perhaps it would help if you
> could explain what you don't understand about the documentation.
>
> Ian 		 	   		  

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: -femit-struct-debug-reduced/baseonly debug info
  2013-06-18 14:53   ` Evgeny Gavrin
@ 2013-06-18 16:23     ` Ian Lance Taylor
  2013-06-19 15:38       ` Evgeny Gavrin
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2013-06-18 16:23 UTC (permalink / raw)
  To: Evgeny Gavrin; +Cc: gcc-help

On Tue, Jun 18, 2013 at 7:53 AM, Evgeny Gavrin
<evgeny.gavrin@hotmail.com> wrote:
> Quote from the documentations is not clear to me: "Emit debug information for struct-like types only when the base name of the compilation source file matches the base name of file in which the type was defined, unless the struct is a template or defined in a system header. "
>
> As I understood, this'll store info only about static types and I'll loose info about inlining, for example, am I right?

No.  This only affect the debug info for "struct-like types", meaning,
in C++, classes and structs.  It doesn't affect inlining.  You're
right that it will keep info about static types.  And if you are
compiling foo.cc, it will keep info about class foo.

> And to extend the question:
> I don't understand what means direct or indirect accessed structs? Ordinary or generic ones? Where I can read about it?

This is documented with the -femit-struct-debug-detailed option.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: -femit-struct-debug-reduced/baseonly debug info
  2013-06-18 16:23     ` Ian Lance Taylor
@ 2013-06-19 15:38       ` Evgeny Gavrin
  2013-06-19 15:51         ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Evgeny Gavrin @ 2013-06-19 15:38 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

[-- Attachment #1: Type: text/plain, Size: 2488 bytes --]

Ok, from the documentation:
"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>


This is not clear to me why first parameter affects so much.

/*
With optimism,
Evgeny Gavrin

email : evgeny.gavrin@hotmail.com
*/


----------------------------------------
> Date: Tue, 18 Jun 2013 09:23:01 -0700
> Subject: Re: -femit-struct-debug-reduced/baseonly debug info
> From: iant@google.com
> To: evgeny.gavrin@hotmail.com
> CC: gcc-help@gcc.gnu.org
>
> On Tue, Jun 18, 2013 at 7:53 AM, Evgeny Gavrin
> <evgeny.gavrin@hotmail.com> wrote:
>> Quote from the documentations is not clear to me: "Emit debug information for struct-like types only when the base name of the compilation source file matches the base name of file in which the type was defined, unless the struct is a template or defined in a system header. "
>>
>> As I understood, this'll store info only about static types and I'll loose info about inlining, for example, am I right?
>
> No. This only affect the debug info for "struct-like types", meaning,
> in C++, classes and structs. It doesn't affect inlining. You're
> right that it will keep info about static types. And if you are
> compiling foo.cc, it will keep info about class foo.
>
>> And to extend the question:
>> I don't understand what means direct or indirect accessed structs? Ordinary or generic ones? Where I can read about it?
>
> This is documented with the -femit-struct-debug-detailed option.
>
> Ian 		 	   		  

[-- Attachment #2: test.c --]
[-- Type: text/plain, Size: 328 bytes --]

#include <malloc.h>
#include "test-nonbase.h"

int main()
{
  struct DIR_ORD  dir_ord;
  struct IND_ORD *indir_ord = (struct IND_ORD*)malloc(sizeof(struct IND_ORD));

  dir_ord.a = 5;
  dir_ord.b = 'a';

  indir_ord->a = 10;
  indir_ord->b = 'b';

  int a = dir_ord.a;
  int b = indir_ord->b;

  free(indir_ord);

  return 0;
}

[-- Attachment #3: test-nonbase.h --]
[-- Type: text/plain, Size: 80 bytes --]

struct DIR_ORD
{
  int a;
  char b;
};

struct IND_ORD
{
  int a;
  char b;
};


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: -femit-struct-debug-reduced/baseonly debug info
  2013-06-19 15:38       ` Evgeny Gavrin
@ 2013-06-19 15:51         ` Ian Lance Taylor
  2013-06-19 16:29           ` Evgeny Gavrin
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2013-06-19 15:51 UTC (permalink / raw)
  To: Evgeny Gavrin; +Cc: gcc-help

On Wed, Jun 19, 2013 at 8:38 AM, Evgeny Gavrin
<evgeny.gavrin@hotmail.com> wrote:
>
> 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.

Because you used "ind", the compiler generates debug info for
essentially every struct that is explicitly named in your source code.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: -femit-struct-debug-reduced/baseonly debug info
  2013-06-19 15:51         ` Ian Lance Taylor
@ 2013-06-19 16:29           ` Evgeny Gavrin
  2013-06-19 18:08             ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Evgeny Gavrin @ 2013-06-19 16:29 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help, slava.garbuzov

Ok, it's understandable, but the logic of implementation tells the following:
./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:].

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;

What am I missing? On my view, there is smth wrong, or processing of this option has some additional shadow logic, that I failed to find.

/*
With optimism,
Evgeny Gavrin

email : evgeny.gavrin@hotmail.com
*/


----------------------------------------
> Date: Wed, 19 Jun 2013 08:51:17 -0700
> Subject: Re: -femit-struct-debug-reduced/baseonly debug info
> From: iant@google.com
> To: evgeny.gavrin@hotmail.com
> CC: gcc-help@gcc.gnu.org
>
> On Wed, Jun 19, 2013 at 8:38 AM, Evgeny Gavrin
> <evgeny.gavrin@hotmail.com> wrote:
>>
>> 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.
>
> Because you used "ind", the compiler generates debug info for
> essentially every struct that is explicitly named in your source code.
>
> Ian 		 	   		  

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: -femit-struct-debug-reduced/baseonly debug info
  2013-06-19 16:29           ` Evgeny Gavrin
@ 2013-06-19 18:08             ` Ian Lance Taylor
  2013-06-19 19:47               ` Evgeny Gavrin
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2013-06-19 18:08 UTC (permalink / raw)
  To: Evgeny Gavrin; +Cc: gcc-help, slava.garbuzov

On Wed, Jun 19, 2013 at 9:29 AM, Evgeny Gavrin
<evgeny.gavrin@hotmail.com> wrote:
>
> 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:].
>
> 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;
>
> What am I missing? On my view, there is smth wrong, or processing of this option has some additional shadow logic, that I failed to find.


Are you saying that the behaviour of the compiler does not match the
documentation?  Or are you saying that you don't understand why it
works?  Or are you saying that the documentation is unclear?

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: -femit-struct-debug-reduced/baseonly debug info
  2013-06-19 18:08             ` Ian Lance Taylor
@ 2013-06-19 19:47               ` Evgeny Gavrin
  2013-06-19 19:51                 ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Evgeny Gavrin @ 2013-06-19 19:47 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help, slava.garbuzov

Behavior of the compiler does not match the documentation.

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.

I think that there is a bug in interpretation of optional parameters.

/*
With optimism,
Evgeny Gavrin
email : evgeny.gavrin@hotmail.com
*/
----------------------------------------
> Date: Wed, 19 Jun 2013 11:08:05 -0700
> Subject: Re: -femit-struct-debug-reduced/baseonly debug info
> From: iant@google.com
> To: evgeny.gavrin@hotmail.com
> CC: gcc-help@gcc.gnu.org; slava.garbuzov@gmail.com
>
> On Wed, Jun 19, 2013 at 9:29 AM, Evgeny Gavrin
> <evgeny.gavrin@hotmail.com> wrote:
>>
>> 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:].
>>
>> 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;
>>
>> What am I missing? On my view, there is smth wrong, or processing of this option has some additional shadow logic, that I failed to find.
>
>
> Are you saying that the behaviour of the compiler does not match the
> documentation? Or are you saying that you don't understand why it
> works? Or are you saying that the documentation is unclear?
>
> Ian 		 	   		  

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: -femit-struct-debug-reduced/baseonly debug info
  2013-06-19 19:47               ` Evgeny Gavrin
@ 2013-06-19 19:51                 ` Ian Lance Taylor
  0 siblings, 0 replies; 10+ messages in thread
From: Ian Lance Taylor @ 2013-06-19 19:51 UTC (permalink / raw)
  To: Evgeny Gavrin; +Cc: gcc-help, slava.garbuzov

On Wed, Jun 19, 2013 at 12:47 PM, Evgeny Gavrin
<evgeny.gavrin@hotmail.com> wrote:
> Behavior of the compiler does not match the documentation.
>
> 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.
>
> I think that there is a bug in interpretation of optional parameters.

OK--please file a bug report following the directions at
http://gcc.gnu.org/bugs/ .  Thanks.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-06-19 19:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-18 11:40 -femit-struct-debug-reduced/baseonly debug info Evgeny Gavrin
2013-06-18 13:43 ` Ian Lance Taylor
2013-06-18 14:53   ` Evgeny Gavrin
2013-06-18 16:23     ` Ian Lance Taylor
2013-06-19 15:38       ` Evgeny Gavrin
2013-06-19 15:51         ` Ian Lance Taylor
2013-06-19 16:29           ` Evgeny Gavrin
2013-06-19 18:08             ` Ian Lance Taylor
2013-06-19 19:47               ` Evgeny Gavrin
2013-06-19 19:51                 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).