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


Hi Frank,
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. This brings 2 scenarios :


i . An error is encountered in a search path but the listed member is found in another search path :
No error message displayed in this case.


ii . An error is encountered in reading dwarf info for a search path AND the listed member is not found in any search path :
The respective error msg is listed at the end when a semantic error is thrown for Translation failure.


This seems to work okay for now, but I'm looking forward to suggestions for improving it :-)

Frank Ch. Eigler wrote:
Prerna Saxena <prerna@linux.vnet.ibm.com> writes:

[...]
The code that prints to clog needs to go back to throwing exceptions,
or if absolutely necessary, to session.print_{warning,error}.

I had deliberately changed code in function translate_components() to
print to clog instead of throwing exceptions.

Right.


[...] I thought it would not be a good idea to make the code throw
an exception if a there are issues determining the dwarf information
for one search path traversing one of the nested structs ; there is
a reasonably good chance this member may be discovered in another
search path and the translation may succeed later on. [...]

The problem with this line of thought is that the user will see messages that he won't know what to do with. There should be no message on clog at all if the search succeeds down another branch.

One can use exceptions in this context just fine.  When you recurse,
you can catch the exceptions, only to throw a new (or a saved old) one
should the final search results come up empty.


- FChE
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
@@ -1846,9 +1846,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;
@@ -2256,7 +2280,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 : " + error_msg + "\n ALTERNATIVES [ " + alternatives.str() + " ] \n");
+	}
 
     /* Translate the assignment part, either
        x = $foo->bar->baz[NN]
@@ -2326,7 +2355,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 : " + error_msg + "\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]