public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/2] Bug Translator 3016 : Error accessing members of  anonymous structs / unions
@ 2008-08-29  9:14 Prerna Saxena
  2008-08-29 15:44 ` Frank Ch. Eigler
  2008-08-29 22:04 ` [RFC PATCH 1/2] " Masami Hiramatsu
  0 siblings, 2 replies; 16+ messages in thread
From: Prerna Saxena @ 2008-08-29  9:14 UTC (permalink / raw)
  To: systemtap

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

Hi all,
This patch modifies tapsets.cxx to enable members of anonymous structs/ 
unions to be recognised by the systemtap translator.
Pls let me know your comments..

Regards,
Prerna Saxena

[-- Attachment #2: anon-union-1.patch --]
[-- Type: text/plain, Size: 3040 bytes --]

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>

Index: systemtap/tapsets.cxx
===================================================================
--- systemtap.orig/tapsets.cxx
+++ systemtap/tapsets.cxx
@@ -1866,6 +1866,8 @@ struct dwflpp
   {
     Dwarf_Die *die = vardie;
     Dwarf_Die struct_die;
+    Dwarf_Attribute temp_attr;
+
     unsigned i = 0;
     while (i < components.size())
       {
@@ -1924,9 +1926,9 @@ struct dwflpp
 	    switch (dwarf_child (die, die_mem))
 	      {
 	      case 1:		/* No children.  */
-		throw semantic_error ("empty struct "
-				      + string (dwarf_diename_integrate (die) ?: "<anonymous>"));
-		break;
+		clog<<"\n Empty Struct "
+		    <<(dwarf_diename_integrate(die)?:"<anonymous>");
+		return NULL;
 	      case -1:		/* Error.  */
 	      default:		/* Shouldn't happen */
 		throw semantic_error (string (typetag == DW_TAG_union_type ? "union" : "struct")
@@ -1941,14 +1943,36 @@ struct dwflpp
 	    while (dwarf_tag (die) != DW_TAG_member
 		   || ({ const char *member = dwarf_diename_integrate (die);
 		       member == NULL || string(member) != components[i].second; }))
+	    {
+	      if ( dwarf_diename (die) == NULL )  // handling Anonymous structs/unions
+		{ 
+		   Dwarf_Die temp_die = *die;
+		   
+		   if (!dwarf_attr_integrate (&temp_die, DW_AT_type, &temp_attr))
+                      	{ 
+			  clog<<"\n Error in obtaining type attribute for "
+			      <<(dwarf_diename(&temp_die)?:"<anonymous>");
+                	  return NULL;
+                	}
+
+	           if ( !dwarf_formref_die (&temp_attr,&temp_die) )
+        	        { 
+			  clog<<"\n Error in decoding type attribute for "
+			      <<(dwarf_diename(&temp_die)?:"<anonymous>");
+                	  return NULL;
+                	}
+
+                   Dwarf_Die *result_die = translate_components(pool, tail, pc, components, &temp_die, &temp_die, &temp_attr );
+
+		   if (result_die != NULL)
+			{ 
+			  *attr_mem = temp_attr;
+			  return result_die;
+			}
+		}
 	      if (dwarf_siblingof (die, die_mem) != 0)
-	      {
-		  stringstream alternatives;
-		  print_members (&struct_die, alternatives);
-		  throw semantic_error ("field '" + components[i].second
-					+ "' not found (alternatives:"
-					+ alternatives.str () + ")");
-	      }
+		return NULL;
+	    }
 
 	    if (dwarf_attr_integrate (die, DW_AT_data_member_location,
 				      attr_mem) == NULL)
@@ -2230,6 +2254,8 @@ struct dwflpp
     Dwarf_Die die_mem, *die = NULL;
     die = translate_components (&pool, &tail, pc, components,
 				&vardie, &die_mem, &attr_mem);
+    if(!die)
+	throw semantic_error("Translation failure");
 
     /* Translate the assignment part, either
        x = $foo->bar->baz[NN]
@@ -2297,6 +2323,8 @@ struct dwflpp
     Dwarf_Die die_mem, *die = NULL;
     die = translate_components (&pool, &tail, pc, components,
 				vardie, &die_mem, &attr_mem);
+    if(!die)
+	throw semantic_error("Translation Failure");
 
     /* Translate the assignment part, either
        x = $return->bar->baz[NN]

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

end of thread, other threads:[~2008-09-17 14:45 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-29  9:14 [RFC PATCH 1/2] Bug Translator 3016 : Error accessing members of anonymous structs / unions Prerna Saxena
2008-08-29 15:44 ` Frank Ch. Eigler
2008-09-04  5:55   ` Prerna Saxena
2008-09-04 14:57     ` Frank Ch. Eigler
2008-09-08  8:55       ` [RFC updated PATCH 2/2] " Prerna Saxena
2008-09-08 20:08         ` Frank Ch. Eigler
2008-09-15  6:34           ` Prerna Saxena
2008-08-29 22:04 ` [RFC PATCH 1/2] " Masami Hiramatsu
2008-09-03 15:39   ` Masami Hiramatsu
2008-09-04 19:15     ` Masami Hiramatsu
2008-09-08  9:00       ` [RFC updated " Prerna Saxena
2008-09-08 15:43         ` Masami Hiramatsu
2008-09-15  6:17           ` Prerna Saxena
2008-09-16  6:28             ` Masami Hiramatsu
2008-09-17 11:24               ` [RFC updated PATCHES] " Prerna Saxena
2008-09-17 14:45                 ` Masami Hiramatsu

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