* 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