This is the mail archive of the mailing list for the frysk 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: StackFrame.toString()

On Tue, Sep 05, 2006 at 04:34:26PM -0600, Tom Tromey wrote:
> I thought it would be handy if StackFrame had a toString method that
> did something sensible.  Patch appended.
> BTW it would be nice if the boundary cases for StackFrame accessor
> methods were documented -- this toString is written assuming:
> * getMethodName could return null or the empty string if it can't get
>   the function's name (and btw the name "getMethodName" is kind of a
>   misnomer IMO)
getMethodName is only return methodName, which is set by
unw_get_proc_name() in StackFrame::initialize().

In Gget_proc_name.c:get_proc_name(), we could know methodName is set
to empty string if function's name could not be got.
So your assumption to getMethodName is right.
> * getSourceFile will return null if the source file name can't be
>   found
Your assumption is right too. :-)
> * getLineNumber will return 0 if the line number is not known
getLineNumber is a java binding of dwfl_lineinfo, and LineNumber is
valid if the return value of dwfl_lineinfo is not empty.  Some codes
could be modified to meet your document,

        int lineNum;
        if (::dwfl_lineinfo(DWFL_LINE_POINTER, NULL, &lineNum, NULL,NULL,NULL))
          return (jint) lineNum;
	  return 0;

> I'm happy to document these accessors if someone would confirm that
> this is the intended interpretation.
This patch is fine to me.
> +  public String toString ()
> +  {
> +    StringBuffer builder = new StringBuffer("at 0x");
> +    builder.append(Long.toHexString(getAddress()));
> +    String mn = getMethodName();
> +    if (mn != null && ! "".equals(mn))
Just one question for my curiosity,
Is there any difference between ""equals(mn) and mn.equals("")?

Yao Qi

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