From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5727 invoked by alias); 8 Aug 2007 10:15:19 -0000 Received: (qmail 5709 invoked by uid 22791); 8 Aug 2007 10:15:18 -0000 X-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,FORGED_RCVD_HELO X-Spam-Check-By: sourceware.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (83.160.170.119) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 08 Aug 2007 10:15:11 +0000 Received: from dijkstra.wildebeest.org ([192.168.1.29]) by gnu.wildebeest.org with esmtp (Exim 4.43) id 1IIibw-0005qF-Ox; Wed, 08 Aug 2007 12:17:54 +0200 Subject: Re: LocationExpression From: Mark Wielaard To: Stan Cox Cc: Frysk List In-Reply-To: <1186545834.6921.14.camel@multics.rdu.redhat.com> References: <1186545834.6921.14.camel@multics.rdu.redhat.com> Content-Type: multipart/mixed; boundary="=-Q2//TMsuoq7Qv7htOAya" Date: Wed, 08 Aug 2007 10:15:00 -0000 Message-Id: <1186568104.29962.5.camel@dijkstra.wildebeest.org> Mime-Version: 1.0 X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) X-Spam-Score: -4.4 (----) X-Virus-Checked: Checked by ClamAV on sourceware.org X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2007-q3/txt/msg00275.txt.bz2 --=-Q2//TMsuoq7Qv7htOAya Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1449 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 * 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'). --=-Q2//TMsuoq7Qv7htOAya Content-Disposition: attachment; filename=ValueUavailableException.patch Content-Type: text/x-patch; name=ValueUavailableException.patch; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 2039 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); + } } --=-Q2//TMsuoq7Qv7htOAya--