diff mbox

[Pointer,Bounds,Checker,29/x] Debug info

Message ID 20140611085004.GC17894@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich June 11, 2014, 8:50 a.m. UTC
Hi,

This patch skips all bounds during debug info generation.

Bootstrapped and tested on linux-x86_64.

Thanks,
Ilya
--
gcc/

2014-06-11  Ilya Enkovich  <ilya.enkovich@intel.com>

	* dbxout.c (dbxout_type): Ignore POINTER_BOUNDS_TYPE.
	* dwarf2out.c (gen_subprogram_die): Ignore bound args.
	(gen_type_die_with_usage): Skip pointer bounds.
	(dwarf2out_global_decl): Likewise.
	(is_base_type): Support POINTER_BOUNDS_TYPE.
	(gen_formal_types_die): Skip pointer bounds.
	(gen_decl_die): Likewise.
	* var-tracking.c (vt_add_function_parameters): Skip
	bounds parameters.

Comments

Jeff Law June 17, 2014, 8:56 p.m. UTC | #1
On 06/11/14 02:50, Ilya Enkovich wrote:
> Hi,
>
> This patch skips all bounds during debug info generation.
>
> Bootstrapped and tested on linux-x86_64.
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2014-06-11  Ilya Enkovich  <ilya.enkovich@intel.com>
>
> 	* dbxout.c (dbxout_type): Ignore POINTER_BOUNDS_TYPE.
> 	* dwarf2out.c (gen_subprogram_die): Ignore bound args.
> 	(gen_type_die_with_usage): Skip pointer bounds.
> 	(dwarf2out_global_decl): Likewise.
> 	(is_base_type): Support POINTER_BOUNDS_TYPE.
> 	(gen_formal_types_die): Skip pointer bounds.
> 	(gen_decl_die): Likewise.
> 	* var-tracking.c (vt_add_function_parameters): Skip
> 	bounds parameters.
OK.  Note that sdbout might need updating as well.   It's used even less 
than dbxout, but if you can see how to skip bounds in there to, it'd be 
appreciated.

It looks like mingw/cygwin still use sdbout (?!?), so if you need 
something tested, you can ping Kai Tietz.

jeff
Ilya Enkovich Oct. 15, 2014, 3:54 p.m. UTC | #2
2014-06-18 0:56 GMT+04:00 Jeff Law <law@redhat.com>:
> On 06/11/14 02:50, Ilya Enkovich wrote:
>>
>> Hi,
>>
>> This patch skips all bounds during debug info generation.
>>
>> Bootstrapped and tested on linux-x86_64.
>>
>> Thanks,
>> Ilya
>> --
>> gcc/
>>
>> 2014-06-11  Ilya Enkovich  <ilya.enkovich@intel.com>
>>
>>         * dbxout.c (dbxout_type): Ignore POINTER_BOUNDS_TYPE.
>>         * dwarf2out.c (gen_subprogram_die): Ignore bound args.
>>         (gen_type_die_with_usage): Skip pointer bounds.
>>         (dwarf2out_global_decl): Likewise.
>>         (is_base_type): Support POINTER_BOUNDS_TYPE.
>>         (gen_formal_types_die): Skip pointer bounds.
>>         (gen_decl_die): Likewise.
>>         * var-tracking.c (vt_add_function_parameters): Skip
>>         bounds parameters.
>
> OK.  Note that sdbout might need updating as well.   It's used even less
> than dbxout, but if you can see how to skip bounds in there to, it'd be
> appreciated.
>
> It looks like mingw/cygwin still use sdbout (?!?), so if you need something
> tested, you can ping Kai Tietz.
>
> jeff
>

I looked into sdbout.c code and didn't find any places requiring
fixes.  It seems it just ignores cases when it doesn't know what to
output.

To make some runtime tests I put SDB_DEBUGGING_INFO definition into
config/i386/x86-64.h and got linux compiler with sdb support.  Then I
used this compiler with -gcoff option on C benchmarks from SPEC2000.
There are 4 benchmarks on which compiler fails with ICEs.  All of them
with the same error:

cc1: internal compiler error: in needed_p, at cgraphunit.c:237
0x7c1a8c symtab_node::needed_p()
        ../../gcc-pl/gcc/cgraphunit.c:236
0x7c3933 analyze_functions
        ../../gcc-pl/gcc/cgraphunit.c:936

All other benchmarks compile OK and when I add '-fcheck-pointer-bounds
-mmpx' no new failures appear.

I couldn't fully build compiler under cygwin (it breaks somewhere on
library build) but I used obtained cc1.exe compiler on a source file
which caused ICE on linux and got the same failure.  So, I believe I
should expect the same results under cygwin.  Would it be enough to
say checker should be OK with sdbout?

BTW seems ICE appears when the same name is used for structure field
and a static var.  I get fail with the following testcase:

typedef struct {
  int *next;
} list;

int *next;

int main(int argc, char **argv)
{
  return 0;
}

Test stops to fail if I rename either field of static var.  It looks
like sdbout outputs type info and mark name 'next' as referenced.
Later it causes assert failure in symtab_node::needed_p when it checks
symbol's assembler name is not referenced.  Will submit a bug for it
but doubt someone is waiting for it to be fixed :)

Thanks,
Ilya
Jeff Law Oct. 15, 2014, 4:12 p.m. UTC | #3
On 10/15/14 09:54, Ilya Enkovich wrote:
>
> I looked into sdbout.c code and didn't find any places requiring
> fixes.  It seems it just ignores cases when it doesn't know what to
> output.
Perfect.  I really don't want to invest developer time into 
significantly improving sdbout or dbxout.  If sdbout is ignoring 
anything it doesn't understand, then that's good enough for me.

>
> To make some runtime tests I put SDB_DEBUGGING_INFO definition into
> config/i386/x86-64.h and got linux compiler with sdb support.  Then I
> used this compiler with -gcoff option on C benchmarks from SPEC2000.
> There are 4 benchmarks on which compiler fails with ICEs.  All of them
> with the same error:
>
> cc1: internal compiler error: in needed_p, at cgraphunit.c:237
> 0x7c1a8c symtab_node::needed_p()
>          ../../gcc-pl/gcc/cgraphunit.c:236
> 0x7c3933 analyze_functions
>          ../../gcc-pl/gcc/cgraphunit.c:936
>
> All other benchmarks compile OK and when I add '-fcheck-pointer-bounds
> -mmpx' no new failures appear.
>
> I couldn't fully build compiler under cygwin (it breaks somewhere on
> library build) but I used obtained cc1.exe compiler on a source file
> which caused ICE on linux and got the same failure.  So, I believe I
> should expect the same results under cygwin.  Would it be enough to
> say checker should be OK with sdbout?
Yea, I think that's sufficient.  Thanks for going the extra mile on this.


>
> BTW seems ICE appears when the same name is used for structure field
> and a static var.  I get fail with the following testcase:
>
> typedef struct {
>    int *next;
> } list;
>
> int *next;
>
> int main(int argc, char **argv)
> {
>    return 0;
> }
>
> Test stops to fail if I rename either field of static var.  It looks
> like sdbout outputs type info and mark name 'next' as referenced.
> Later it causes assert failure in symtab_node::needed_p when it checks
> symbol's assembler name is not referenced.  Will submit a bug for it
> but doubt someone is waiting for it to be fixed :)
Yes, please submit a bug.  I doubt it'll be considered high priority, 
but it might make a good project for someone to poke at in a free 
afternoon :-)

jeff
diff mbox

Patch

diff --git a/gcc/dbxout.c b/gcc/dbxout.c
index 7a13289..ee626eb 100644
--- a/gcc/dbxout.c
+++ b/gcc/dbxout.c
@@ -2367,6 +2367,10 @@  dbxout_type (tree type, int full)
       dbxout_type (TREE_TYPE (type), 0);
       break;
 
+    case POINTER_BOUNDS_TYPE:
+      /* No debug info for pointer bounds type supported yet.  */
+      break;
+
     default:
       gcc_unreachable ();
     }
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 67b37eb..f9c96d7 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -10255,6 +10255,7 @@  is_base_type (tree type)
     case FIXED_POINT_TYPE:
     case COMPLEX_TYPE:
     case BOOLEAN_TYPE:
+    case POINTER_BOUNDS_TYPE:
       return 1;
 
     case ARRAY_TYPE:
@@ -17555,18 +17556,21 @@  gen_formal_types_die (tree function_or_method_type, dw_die_ref context_die)
 	break;
 
       /* Output a (nameless) DIE to represent the formal parameter itself.  */
-      parm_die = gen_formal_parameter_die (formal_type, NULL,
-					   true /* Emit name attribute.  */,
-					   context_die);
-      if (TREE_CODE (function_or_method_type) == METHOD_TYPE
-	  && link == first_parm_type)
+      if (!POINTER_BOUNDS_TYPE_P (formal_type))
 	{
-	  add_AT_flag (parm_die, DW_AT_artificial, 1);
-	  if (dwarf_version >= 3 || !dwarf_strict)
-	    add_AT_die_ref (context_die, DW_AT_object_pointer, parm_die);
+	  parm_die = gen_formal_parameter_die (formal_type, NULL,
+					       true /* Emit name attribute.  */,
+					       context_die);
+	  if (TREE_CODE (function_or_method_type) == METHOD_TYPE
+	      && link == first_parm_type)
+	    {
+	      add_AT_flag (parm_die, DW_AT_artificial, 1);
+	      if (dwarf_version >= 3 || !dwarf_strict)
+		add_AT_die_ref (context_die, DW_AT_object_pointer, parm_die);
+	    }
+	  else if (arg && DECL_ARTIFICIAL (arg))
+	    add_AT_flag (parm_die, DW_AT_artificial, 1);
 	}
-      else if (arg && DECL_ARTIFICIAL (arg))
-	add_AT_flag (parm_die, DW_AT_artificial, 1);
 
       link = TREE_CHAIN (link);
       if (arg)
@@ -18336,7 +18340,7 @@  gen_subprogram_die (tree decl, dw_die_ref context_die)
 	    gen_formal_parameter_pack_die (generic_decl_parm,
 					   parm, subr_die,
 					   &parm);
-	  else if (parm)
+	  else if (parm && !POINTER_BOUNDS_P (parm))
 	    {
 	      dw_die_ref parm_die = gen_decl_die (parm, NULL, subr_die);
 
@@ -18348,6 +18352,8 @@  gen_subprogram_die (tree decl, dw_die_ref context_die)
 
 	      parm = DECL_CHAIN (parm);
 	    }
+	  else if (parm)
+	    parm = DECL_CHAIN (parm);
 
 	  if (generic_decl_parm)
 	    generic_decl_parm = DECL_CHAIN (generic_decl_parm);
@@ -19846,6 +19852,7 @@  gen_type_die_with_usage (tree type, dw_die_ref context_die,
     case FIXED_POINT_TYPE:
     case COMPLEX_TYPE:
     case BOOLEAN_TYPE:
+    case POINTER_BOUNDS_TYPE:
       /* No DIEs needed for fundamental types.  */
       break;
 
@@ -20310,6 +20317,12 @@  gen_decl_die (tree decl, tree origin, dw_die_ref context_die)
   if (DECL_P (decl_or_origin) && DECL_IGNORED_P (decl_or_origin))
     return NULL;
 
+  /* Ignore pointer bounds decls.  */
+  if (DECL_P (decl_or_origin)
+      && TREE_TYPE (decl_or_origin)
+      && POINTER_BOUNDS_P (decl_or_origin))
+    return NULL;
+
   switch (TREE_CODE (decl_or_origin))
     {
     case ERROR_MARK:
@@ -20517,7 +20530,8 @@  dwarf2out_global_decl (tree decl)
      declarations, file-scope (extern) function declarations (which
      had no corresponding body) and file-scope tagged type declarations
      and definitions which have not yet been forced out.  */
-  if (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))
+  if ((TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))
+      && !POINTER_BOUNDS_P (decl))
     dwarf2out_decl (decl);
 }
 
diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 65d8285..493b312 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -9796,7 +9796,8 @@  vt_add_function_parameters (void)
 
   for (parm = DECL_ARGUMENTS (current_function_decl);
        parm; parm = DECL_CHAIN (parm))
-    vt_add_function_parameter (parm);
+    if (!POINTER_BOUNDS_P (parm))
+      vt_add_function_parameter (parm);
 
   if (DECL_HAS_VALUE_EXPR_P (DECL_RESULT (current_function_decl)))
     {