public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Reducing debug info for C++ ctors/dtors
@ 2005-07-12  0:37 Devang Patel
  2005-07-12  0:56 ` Daniel Jacobowitz
  0 siblings, 1 reply; 11+ messages in thread
From: Devang Patel @ 2005-07-12  0:37 UTC (permalink / raw)
  To: GCC Development

Our analysis suggests that reducing certain stabs info for C++ ctors/ 
dtors can lead to significant final size reduction without noticeable  
change in quality of debugging (in STABS world, at least).

For example,

class Base1 {
   public: int x;
   Base1(int i) { x = i; }
   int getx (void) { return x; }
};
int main () {
   Base1 myobj(5);
   return myobj.getx();
}

will emit a class definition LSYM of

         .stabs  "Base1:Tt(0,41)=s4x:(0,9),0,32;__base_ctor ::(0,42)=# 
(0,41),(0,36),(0,43)=*(0,41),(0,9),(0,36);:_ZN5Base1C2Ei; 
2A.;__comp_ctor ::(0,42):_ZN5Base1C1Ei;2A.;getx::(0,44)=#(0,41),(0,9), 
(0,43),(0,36);:_ZN5Base14getxEv;2A.;;",128,0,1,0


However, it is good enough to have

         .stabs "Base1:Tt(0,41)=s4x:(0,9),0,32;getx::(0,44)=#(0,41), 
(0,9),(0,43)=*(0,41),(0,36);:_ZN5Base14getxEv;2A.;;",128,0,1,0

and keep the stabs for the cdtors in other contexts, most obviously  
the FUN stab where the function is defined.  e.g.

__ZN5Base1C1Ei:
         .stabd  46,0,0
         .stabd  68,0,3
LFB4:
         stmw r30,-8(r1)
[...]
         lmw r30,-8(r1)
         blr
LFE4:
         .stabs  "_ZN5Base1C1Ei:F(0,36)",36,0,3,__ZN5Base1C1Ei
         .stabs  "this:p(0,45)=k(0,43)",160,0,3,72
         .stabs  "i:p(0,9)",160,0,3,76
Lscope0:
         .stabs  "",36,0,0,Lscope0-__ZN5Base1C1Ei
         .stabd  78,0,0


Our GDB folks are still analyzing compiler output with included  
patch. Initial response is - it looks good.  I'd like to get your  
feedback on this. Is it a good idea in general for other debugging  
formats also ?

If peopler thinks this is a good idea then I can prepare patch for  
mainline.  Do we need a switch to control this ? I do not know. If  
you can think of better name for this switch, feel free to suggest.

-
Devang

[ I am intentionally including this patch to make it easier to read.  
This patch is against apple-local branch so it may not apply cleanly  
to FSF mainline. As I said, if this looks good then I'll prepare  
actual patch. ]

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.604.2.12
diff -Idpatel.pbxuser -c -3 -p -r1.604.2.12 c-common.c
*** c-common.c  15 Jun 2005 16:18:32 -0000      1.604.2.12
--- c-common.c  11 Jul 2005 21:34:24 -0000
*************** int flag_access_control = 1;
*** 454,459 ****
--- 454,463 ----

   int flag_check_new;

+ /* APPLE LOCAL begin 4167759 */
+ /* Nonzero if we want to omit debug info for certain constructors and
+    destructors.  */
+ int flag_compact_debug_info;
   /* Nonzero if we want the new ISO rules for pushing a new scope  
for `for'
      initialization variables.
      0: Old rules, set by -fno-for-scope.
Index: c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.276.6.9
diff -Idpatel.pbxuser -c -3 -p -r1.276.6.9 c-common.h
*** c-common.h  23 Jun 2005 01:30:09 -0000      1.276.6.9
--- c-common.h  11 Jul 2005 21:34:24 -0000
*************** extern int flag_access_control;
*** 579,584 ****
--- 579,589 ----

   extern int flag_check_new;

+ /* APPLE LOCAL begin 4167759 */
+ /* Nonzero if we want to omit debug info for certain constructors and
+    destructors.  */
+ extern int flag_compact_debug_info;
+ /* APPLE LOCAL end 4167759 */
   /* Nonzero if we want the new ISO rules for pushing a new scope  
for `for'
      initialization variables.
      0: Old rules, set by -fno-for-scope.
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.135.6.8
diff -Idpatel.pbxuser -c -3 -p -r1.135.6.8 c-opts.c
*** c-opts.c    1 Jul 2005 00:01:07 -0000       1.135.6.8
--- c-opts.c    11 Jul 2005 21:34:24 -0000
*************** c_common_handle_option (size_t scode, co
*** 688,693 ****
--- 688,698 ----
         flag_check_new = value;
         break;

+       /* APPLE LOCAL begin 4167759 */
+     case OPT_fcompact_debug_info:
+       flag_compact_debug_info = value;
+       break;
+       /* APPLE LOCAL end 4167759 */
       case OPT_fconserve_space:
         flag_conserve_space = value;
         break;
Index: c.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c.opt,v
retrieving revision 1.34.6.8
diff -Idpatel.pbxuser -c -3 -p -r1.34.6.8 c.opt
*** c.opt       1 Jul 2005 00:01:08 -0000       1.34.6.8
--- c.opt       11 Jul 2005 21:34:24 -0000
*************** fcheck-new
*** 572,577 ****
--- 572,583 ----
   C++ ObjC++
   Check the return value of new

+ ; APPLE LOCAL begin 4167759
+ fcompact-debug-info
+ C ObjC C++ ObjC++
+ Avoid verbose debug info related to constructors and destructors
+ ; APPLE LOCAL end 4167759
+
   ; APPLE LOCAL begin structor decloning
   fclone-structors
   C++ ObjC++
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.705.2.4
diff -Idpatel.pbxuser -c -3 -p -r1.705.2.4 class.c
*** cp/class.c  10 Jun 2005 18:46:07 -0000      1.705.2.4
--- cp/class.c  11 Jul 2005 21:34:25 -0000
*************** build_clone (tree fn, tree name)
*** 3768,3773 ****
--- 3768,3785 ----
         DECL_VINDEX (clone) = NULL_TREE;
       }

+   /* APPLE LOCAL begin 4167759 */
+   if (flag_compact_debug_info)
+     {
+       if (name == base_ctor_identifier
+         || name == complete_ctor_identifier
+         || name == complete_dtor_identifier
+         || name == base_dtor_identifier
+         || name == deleting_dtor_identifier)
+       DECL_IGNORED_P (clone) = 1;
+     }
+   /* APPLE LOCAL end 4167759 */
+
     /* If there was an in-charge parameter, drop it from the function
        type.  */
     if (DECL_HAS_IN_CHARGE_PARM_P (clone))
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.460.4.7
diff -Idpatel.pbxuser -c -3 -p -r1.460.4.7 semantics.c
*** cp/semantics.c      10 Jun 2005 18:46:22 -0000      1.460.4.7
--- cp/semantics.c      11 Jul 2005 21:34:26 -0000
*************** expand_body (tree fn)
*** 3015,3020 ****
--- 3015,3026 ----
        generating trees for a function.  */
     gcc_assert (function_depth == 0);

+   /* APPLE LOCAL begin 4167759 */
+   if (DECL_NAME (fn) == complete_ctor_identifier
+       || DECL_NAME (fn) == complete_dtor_identifier)
+     DECL_IGNORED_P (fn) = 0;
+   /* APPLE LOCAL end 4167759 */
+
     tree_rest_of_compilation (fn);

     current_function_decl = saved_function;


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

end of thread, other threads:[~2005-07-13 22:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-12  0:37 Reducing debug info for C++ ctors/dtors Devang Patel
2005-07-12  0:56 ` Daniel Jacobowitz
2005-07-12  1:12   ` Jason Molenda
2005-07-12  1:18     ` Daniel Jacobowitz
2005-07-12  3:46       ` Jason Molenda
2005-07-13 18:42       ` Devang Patel
2005-07-13 18:45         ` Eric Christopher
2005-07-13 19:36           ` Mike Stump
2005-07-13 19:39             ` Eric Christopher
2005-07-13 21:05               ` Mike Stump
2005-07-13 22:11                 ` Eric Christopher

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).