From: Mark Wielaard <mark@klomp.org>
To: Stan Cox <scox@redhat.com>
Cc: Frysk List <frysk@sourceware.org>
Subject: Re: LocationExpression
Date: Wed, 08 Aug 2007 10:15:00 -0000 [thread overview]
Message-ID: <1186568104.29962.5.camel@dijkstra.wildebeest.org> (raw)
In-Reply-To: <1186545834.6921.14.camel@multics.rdu.redhat.com>
[-- 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);
+ }
}
next prev parent reply other threads:[~2007-08-08 10:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-08 4:04 LocationExpression Stan Cox
2007-08-08 10:15 ` Mark Wielaard [this message]
2007-08-08 11:04 ` LocationExpression Petr Machata
2007-08-08 12:24 ` LocationExpression Stan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1186568104.29962.5.camel@dijkstra.wildebeest.org \
--to=mark@klomp.org \
--cc=frysk@sourceware.org \
--cc=scox@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).