This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug mi/10586] Anonymous unions/structs not handled correctly under MI


------- Additional Comments From nickrob at snap dot net dot nz  2009-10-10 03:33 -------
Subject:  Anonymous unions/structs not handled correctly under MI

 > Thanks for looking at this. I have applied the patch to the latest cvs snapshot
 > of GDB (7.0.50.20091009) and still get "Duplicate variable object name" using
 > the posted testcase. Here's the debugger session.

I think the C++ case can be handled the same way like below.

-- 
Nick                                           http://users.snap.net.nz/~nickrob


2009-10-10  Nick Roberts  <nickrob@snap.net.nz>

	* varobj.c (c_describe_child, cplus_describe_child): Use the index
        for the name for anonymous structs/unions.


*** varobj.c	20 Sep 2009 11:44:22 +1200	1.149
--- varobj.c	10 Oct 2009 16:25:01 +1300	
*************** c_describe_child (struct varobj *parent,
*** 2816,2823 ****
      case TYPE_CODE_STRUCT:
      case TYPE_CODE_UNION:
        if (cname)
! 	*cname = xstrdup (TYPE_FIELD_NAME (type, index));
! 
        if (cvalue && value)
  	{
  	  /* For C, varobj index is the same as type index.  */
--- 2816,2830 ----
      case TYPE_CODE_STRUCT:
      case TYPE_CODE_UNION:
        if (cname)
! 	{
! 	  *cname = xstrdup (TYPE_FIELD_NAME (type, index));
! 	  /* Anonymous case.  */
! 	  if (strlen (*cname) == 0)
! 	    {
! 	      *cname = (char*) malloc (24);
! 	      sprintf (*cname, "%d", index);
! 	    }
! 	}
        if (cvalue && value)
  	{
  	  /* For C, varobj index is the same as type index.  */
*************** cplus_describe_child (struct varobj *par
*** 3215,3223 ****
  	    }
  	  --type_index;
  
! 	  if (cname)
  	    *cname = xstrdup (TYPE_FIELD_NAME (type, type_index));
! 
  	  if (cvalue && value)
  	    *cvalue = value_struct_element_index (value, type_index);
  
--- 3222,3236 ----
  	    }
  	  --type_index;
  
! 	  if (cname) {
  	    *cname = xstrdup (TYPE_FIELD_NAME (type, type_index));
! 	    /* Anonymous case.  */
! 	    if (strlen (*cname) == 0)
! 	      {
! 		*cname = (char*) malloc (24);
! 		sprintf (*cname, "%d", type_index);
! 	      }
! 	  }
  	  if (cvalue && value)
  	    *cvalue = value_struct_element_index (value, type_index);
  


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=10586

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]