public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* LocationExpression
@ 2007-08-08  4:04 Stan Cox
  2007-08-08 10:15 ` LocationExpression Mark Wielaard
  0 siblings, 1 reply; 4+ messages in thread
From: Stan Cox @ 2007-08-08  4:04 UTC (permalink / raw)
  To: Frysk List

I added a location expression evaluator I wrote a while back to replace
the current location heuristics. It is implemented as a pushdown stack
machine similar to what the dwarf doc describes. It is not complete, as
some operators are missing and unsigned is not handled completely.
 frysk-core/frysk/debuginfo/LocationExpression.java



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

* Re: LocationExpression
  2007-08-08  4:04 LocationExpression Stan Cox
@ 2007-08-08 10:15 ` Mark Wielaard
  2007-08-08 11:04   ` LocationExpression Petr Machata
  2007-08-08 12:24   ` LocationExpression Stan Cox
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Wielaard @ 2007-08-08 10:15 UTC (permalink / raw)
  To: Stan Cox; +Cc: Frysk List

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

Hi Stan,

On Wed, 2007-08-08 at 00:03 -0400, Stan Cox wrote: 
>  frysk-core/frysk/debuginfo/LocationExpression.java

This doesn't compile on FC6. I didn't know that you could actually throw
a 'null', and so didn't the compiler :) But you are right according to
the spec that this is allowed and the semantics is precisely as if you
actually created a new NullPointerException at that place and then threw
it. So the fix is obvious:

2007-08-08  Mark Wielaard  <mwielaard@redhat.com>

        * LocationExpression.java (getRegisterNumber): Throw 
        NullPointerException.

diff -u -r1.1 LocationExpression.java
--- frysk-core/frysk/debuginfo/LocationExpression.java  8 Aug 2007 03:42:45 -0000       1.1
+++ frysk-core/frysk/debuginfo/LocationExpression.java  8 Aug 2007 09:54:27 -0000
@@ -263,6 +263,6 @@
        }
        else
            throw new ValueUavailableException();
-       throw null;
+       throw new NullPointerException();
     }
 }

Which is what I committed.

Cheers,

Mark

BTW. Are you sure you want to model this case with a
NullPointerException? Personally I would add a reason to the
ValueUavailableException and use that to differentiate between the
various ways that the LocationExpression couldn't be constructed, then
you could present that cause to the user (which might help us with bug
reports).

Idea for a patch attached (but not committed).

BTW2. I would have expected ValueUnavailableException (with an 'n').

[-- Attachment #2: ValueUavailableException.patch --]
[-- Type: text/x-patch, Size: 2039 bytes --]

Index: frysk-core/frysk/debuginfo/LocationExpression.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/debuginfo/LocationExpression.java,v
retrieving revision 1.1
diff -u -u -r1.1 LocationExpression.java
--- frysk-core/frysk/debuginfo/LocationExpression.java	8 Aug 2007 03:42:45 -0000	1.1
+++ frysk-core/frysk/debuginfo/LocationExpression.java	8 Aug 2007 09:50:47 -0000
@@ -69,7 +69,7 @@
 	int nops = ops.size();
 
 	if (nops == 0)
-	    throw new ValueUavailableException();
+	    throw new ValueUavailableException("nops == 0");
 
 	for(int i = 0; i < nops; i++) {
 	    int operator = ((DwarfDie.DwarfOp) ops.get(i)).operator;
@@ -241,7 +241,8 @@
 		// ??? Support remaining operators
 
 	    default:
-		throw new ValueUavailableException();
+		throw new ValueUavailableException("Unknown operator: "
+						   + operator);
 	    }
 	}
 	return ((Long)stack.removeFirst()).longValue();
@@ -260,9 +261,12 @@
 		|| operator <=  DwOpEncodings.DW_OP_reg31_)
 		return DwarfRegisterMapFactory.getRegisterMap(isa)
 		.getRegister(operator - DwOpEncodings.DW_OP_reg0_);
+	    else
+		throw new ValueUavailableException("Operator not a register: "
+						   + operator);
 	}
 	else
-	    throw new ValueUavailableException();
-	throw null;
+	    throw new ValueUavailableException("ops.size() not 1 ("
+					       + ops.size() + ")");
     }
 }
Index: frysk-core/frysk/debuginfo/ValueUavailableException.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/debuginfo/ValueUavailableException.java,v
retrieving revision 1.1
diff -u -u -r1.1 ValueUavailableException.java
--- frysk-core/frysk/debuginfo/ValueUavailableException.java	26 Jul 2007 14:04:53 -0000	1.1
+++ frysk-core/frysk/debuginfo/ValueUavailableException.java	8 Aug 2007 09:50:47 -0000
@@ -46,4 +46,8 @@
      */
     private static final long serialVersionUID = 1L;
 
+    public ValueUavailableException(String reason)
+    {
+      super(reason);
+    }
 }

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

* Re: LocationExpression
  2007-08-08 10:15 ` LocationExpression Mark Wielaard
@ 2007-08-08 11:04   ` Petr Machata
  2007-08-08 12:24   ` LocationExpression Stan Cox
  1 sibling, 0 replies; 4+ messages in thread
From: Petr Machata @ 2007-08-08 11:04 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: Stan Cox, Frysk List

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

Mark Wielaard wrote:
> This doesn't compile on FC6. I didn't know that you could actually throw
> a 'null', and so didn't the compiler :) But you are right according to
> the spec that this is allowed and the semantics is precisely as if you
> actually created a new NullPointerException at that place and then threw
> it.

Interesting, I was thinking that maybe this is a typo that was supposed
to read "return null" instead of "throw null"...

PM


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: LocationExpression
  2007-08-08 10:15 ` LocationExpression Mark Wielaard
  2007-08-08 11:04   ` LocationExpression Petr Machata
@ 2007-08-08 12:24   ` Stan Cox
  1 sibling, 0 replies; 4+ messages in thread
From: Stan Cox @ 2007-08-08 12:24 UTC (permalink / raw)
  To: Frysk List

On Wed, 2007-08-08 at 12:15 +0200, Mark Wielaard wrote:
> This doesn't compile on FC6.

Thanks for catching it.  Yea it was a typo for return null, meant to
silence a warning with gcj 4.1.2 20070502.  Didn't mean to throw it of
course, but it compiled with that compiler.

By the way, the current use of LocationExpression is in
DebugInfoEvaluator.java#get.  First it tries the get* methods in
AccessMemory; this is for cases where a symbol is accessed by address or
register+offset.  If that fails then it tries the get* methods in
AccessRegisters; this is for cases where a symbol is in a register.
These are the only cases currently supported by LocationExpression.


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

end of thread, other threads:[~2007-08-08 12:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-08  4:04 LocationExpression Stan Cox
2007-08-08 10:15 ` LocationExpression Mark Wielaard
2007-08-08 11:04   ` LocationExpression Petr Machata
2007-08-08 12:24   ` LocationExpression Stan Cox

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