This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap 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]

Re: [RFC updated PATCH 2/2] Bug Translator 3016 : Error accessing members of anonymous structs / unions


Thanks Frank,
I've implemented it on the lines you suggested...
Dwarf errors are also flagged as semantic errors, except that they additionally set a flag to indicate their nature.
The catch{} block for semantic errors is also a part of the while loop. It re-throws all semantic errors which are NOT due to failure in fetching dwarf info, while saves the last dwarf-based error.
In case no match is found in the master (parent) call of translate_components() , the saved dwarf error is thrown again.



Frank Ch. Eigler wrote:
Hi -

As per your suggestion , I've removed the clog messages and instead replaced them with a global (static) string to contain error messages in case of errors encountered in reading/decoding dwarf information.

(Actually, there remain one or two hard-coded clog references in the
patch, unless I'm misreading.)
Thanks for pointing that out, I removed the clog message...it wasn't required.. :-)
The use of the static error_msg string is unnecessary.  I advised
having an explicit try {} catch () within the search iterations, so
that each layer can just throw an exception if something is wrong.
The parent can catch exceptions and try another branch.  If the search
is unsuccessful, it can throw a new (or saved/reused) exception of its
own.  This should also simplify the logic.

- FChE
Pls let me know your comments..

Regards,

--
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India


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

Index: systemtap/tapsets.cxx
===================================================================
--- systemtap.orig/tapsets.cxx
+++ systemtap/tapsets.cxx
@@ -1845,9 +1845,33 @@ struct dwflpp
     // Output each sibling's name to 'o'.
     while (dwarf_tag (die) == DW_TAG_member)
       {
-	const char *member = (dwarf_diename_integrate (die) ?: "<anonymous>");
+	const char *member = dwarf_diename_integrate (die) ;
+	
+	if ( member != NULL )
+
+		o << " " << member;
+
+	else
+	    { 
+		Dwarf_Die temp_die = *die; 
+		Dwarf_Attribute temp_attr ;
+		
+		 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 ;
+                        }
+
+                   if ( ! dwarf_formref_die (&temp_attr,&temp_die))
+                        {
+                          clog<<"\n Error in decoding type attribute for "
+			      <<(dwarf_diename(&temp_die)?:"<anonymous>");
+                          return ;
+                        }
+		   print_members(&temp_die,o);
 
-	o << " " << member;
+	    }
 
 	if (dwarf_siblingof (die, &die_mem) != 0)
 	  break;
@@ -2283,7 +2307,12 @@ struct dwflpp
     die = translate_components (&pool, &tail, pc, components,
 				&vardie, &die_mem, &attr_mem);
     if(!die)
-	throw semantic_error("Translation failure");
+	{ 
+	  die = dwarf_formref_die (&attr_mem, &vardie);
+          stringstream alternatives;
+          print_members(die,alternatives); 
+	  throw semantic_error("Translation failure :  \n ALTERNATIVES [ " + alternatives.str() + " ] \n");
+	}
 
     /* Translate the assignment part, either
        x = $foo->bar->baz[NN]
@@ -2352,7 +2381,13 @@ struct dwflpp
     die = translate_components (&pool, &tail, pc, components,
 				vardie, &die_mem, &attr_mem);
     if(!die)
-	throw semantic_error("Translation Failure");
+	{ 
+	  die = dwarf_formref_die (&attr_mem, vardie);
+          stringstream alternatives;
+          print_members(die,alternatives); 
+	  throw semantic_error("Translation failure : \n ALTERNATIVES [ " + alternatives.str() + " ] \n");
+	}
+
 
     /* Translate the assignment part, either
        x = $return->bar->baz[NN]

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