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: [PATCH] Add function name and file to semantic error messages for not found local variables.


Hi PrzemysÅaw,

On Tue, 2008-11-11 at 01:57 +0100, PrzemysÅaw PaweÅczyk wrote:
> Couple of days later, writing strace-like script
> (http://research.pawelczyk.it/systemtap/strace.stp) on clean systemtap
> I spotted, that more meaningful error message in mentioned case would
> be useful as well. I put some info on channel, but probably it was
> overlooked. Now I'm trying more formal way.
> 
> If I forgot about something, please let me know. It's my first message here.
> 
> diff --git a/tapsets.cxx b/tapsets.cxx
> index 5acf50c..fd81927 100644
> --- a/tapsets.cxx
> +++ b/tapsets.cxx
> @@ -1690,6 +1690,8 @@ struct dwflpp
>  	print_locals (scopes, alternatives);
>  	throw semantic_error ("unable to find local '" + local + "'"
>  			      + " near pc " + lex_cast_hex<string>(pc)
> +			      + " for " + dwarf_diename (scope_die)
> +			      + "(" + dwarf_diename (cu) + ")"
>  			      + (alternatives.str() == "" ? "" : (" (alternatives:" +
> alternatives.str () + ")")));
>        }

Thanks. I like patches that improve our error messages.

In this case we cannot always just print the diename of the scope we are
looking at since that might be NULL (see just above in the function). In
that case we are just looking for the scope by address. And while we are
improving the error message, lets also add the same for the other error
case just above it. So I think we want something like the attached. Does
that work for you?

Cheers,

Mark
diff --git a/tapsets.cxx b/tapsets.cxx
index 8d371a8..f3b6d3f 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -1677,6 +1677,9 @@ struct dwflpp
       {
 	throw semantic_error ("unable to find any scopes containing "
 			      + lex_cast_hex<string>(pc)
+			      + ((scope_die == NULL) ? ""
+				 : (string (" in ") + dwarf_diename (scope_die)
+			      	    + "(" + dwarf_diename (cu) + ")"))
 			      + " while searching for local '" + local + "'");
       }
 
@@ -1690,6 +1693,9 @@ struct dwflpp
 	print_locals (scopes, alternatives);
 	throw semantic_error ("unable to find local '" + local + "'"
 			      + " near pc " + lex_cast_hex<string>(pc)
+			      + ((scope_die == NULL) ? ""
+				 : (string (" in ") + dwarf_diename (scope_die)
+			      	    + "(" + dwarf_diename (cu) + ")"))
 			      + (alternatives.str() == "" ? "" : (" (alternatives:" + alternatives.str () + ")")));
       }
 

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