public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Throw/catch UserExceptions, not RuntimeExceptions in unwinder.
@ 2008-06-20 19:23 cagney
  0 siblings, 0 replies; only message in thread
From: cagney @ 2008-06-20 19:23 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  75e76209d2bde38c31b45978fcda6aa863547aeb (commit)
      from  50ae71ea90cbbb3d8822fa7929a08322247cd24c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 75e76209d2bde38c31b45978fcda6aa863547aeb
Author: Andrew Cagney <cagney@redhat.com>
Date:   Fri Jun 20 15:21:02 2008 -0400

    Throw/catch UserExceptions, not RuntimeExceptions in unwinder.
    
    This first gets the stack code catching just user (i.e., not bad frysk
    code) exceptions; and secondly, for jni, gets it catching them
    correctly.
    
    frysk-core/frysk/proc/dead/ChangeLog
    2008-06-20  Andrew Cagney  <cagney@redhat.com>
    
    	* CorefileByteBuffer.java: Throw UserException, not
    	RuntimeException.
    
    frysk-sys/lib/unwind/ChangeLog
    2008-06-20  Andrew Cagney  <cagney@redhat.com>
    
    	* jni/UnwindH.hxx (access_mem): Catch Throwable and then use
    	instanceof to identify a UserException.
    	* cni/UnwindH.hxx (access_mem): Ditto.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/proc/dead/ChangeLog               |    5 ++
 frysk-core/frysk/proc/dead/CorefileByteBuffer.java |   46 ++++++++++---------
 frysk-sys/lib/unwind/ChangeLog                     |    6 +++
 frysk-sys/lib/unwind/cni/UnwindH.hxx               |   15 ++++--
 frysk-sys/lib/unwind/jni/UnwindH.hxx               |   14 ++++--
 5 files changed, 54 insertions(+), 32 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog
index 83851a5..d2b8beb 100644
--- a/frysk-core/frysk/proc/dead/ChangeLog
+++ b/frysk-core/frysk/proc/dead/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-20  Andrew Cagney  <cagney@redhat.com>
+
+	* CorefileByteBuffer.java: Throw UserException, not
+	RuntimeException.
+
 2008-06-11  Andrew Cagney  <cagney@redhat.com>
 
 	* TestLinuxCore.java: Update to match stack trace output.
diff --git a/frysk-core/frysk/proc/dead/CorefileByteBuffer.java b/frysk-core/frysk/proc/dead/CorefileByteBuffer.java
index 0abed3b..86274e6 100644
--- a/frysk-core/frysk/proc/dead/CorefileByteBuffer.java
+++ b/frysk-core/frysk/proc/dead/CorefileByteBuffer.java
@@ -39,6 +39,7 @@
 
 package frysk.proc.dead;
 
+import frysk.UserException;
 import frysk.sys.StatelessFile;
 import java.io.File;
 import java.util.ArrayList;
@@ -92,10 +93,9 @@ public class CorefileByteBuffer extends ByteBuffer {
     closeCoreFileElf(elf);
   }
 
-  protected void poke(long arg0, int arg1) 
-  {
-    throw new RuntimeException("Cannot poke into a corefile!");
-  }
+    protected void poke(long arg0, int arg1) {
+	throw new UserException("Cannot poke into a corefile!");
+    }
   
   protected int peek(long address) 
   {
@@ -120,20 +120,22 @@ public class CorefileByteBuffer extends ByteBuffer {
 		    long offset = metaLine.solibOffset  + (address - metaLine.vaddr);
 		    temp.pread(offset, buffer,0,1);
 		} else {
-		    throw new RuntimeException("CorefileByteBuffer: Cannot peek() at address 0x"+
-					       Long.toHexString(address)+". Offset exists in file: " +
-					       metaLine.name+" but that file cannot be accessed.");
+		    throw new UserException
+			("CorefileByteBuffer: Cannot peek() at address 0x"
+			 + Long.toHexString(address)+". Offset exists in file: "
+			 + metaLine.name+" but that file cannot be accessed.");
 		}
 	    }
 	}
 	
-    else
-      throw new RuntimeException("CorefileByteBuffer: Cannot peek() " +
-      				 "at address 0x" +
-				 Long.toHexString(address)+"." +
-				 " Address location is unknown " +
-				 " (not in corefile, executable or "+
-				 " mapped solibs).");
+    else {
+	throw new UserException("CorefileByteBuffer: Cannot peek() " +
+				"at address 0x" +
+				Long.toHexString(address)+"." +
+				" Address location is unknown " +
+				" (not in corefile, executable or "+
+				" mapped solibs).");
+    }
 
     return buffer[0];
   }
@@ -236,14 +238,14 @@ public class CorefileByteBuffer extends ByteBuffer {
     //XXX: the boolean gate indicates offset not found.
     
     if (!foundOffset)
-      throw new RuntimeException("Cannot find file offset for given address 0x"
-                                 + Long.toHexString(address));
+	throw new UserException("Cannot find file offset for given address 0x"
+				+ Long.toHexString(address));
 
     
     if (!presentInFile)
-      throw new RuntimeException("Cannot read file offset for given address 0x"
-                                 + Long.toHexString(address) + 
-				 ". It is elided from the core file");
+	throw new UserException("Cannot read file offset for given address 0x"
+				+ Long.toHexString(address) + 
+				". It is elided from the core file");
     return offset;
   }
 
@@ -295,9 +297,9 @@ public class CorefileByteBuffer extends ByteBuffer {
 						   "",0x1000));
               }
           }
-      }
-    else
-      throw new RuntimeException("Cannot IO access " + this.coreFile.getPath());
+      } else {
+	throw new UserException("Cannot IO access " + this.coreFile.getPath());
+    }
 
     return (MapAddressHeader[]) localList.toArray(new MapAddressHeader[localList.size()]);
   }
diff --git a/frysk-sys/lib/unwind/ChangeLog b/frysk-sys/lib/unwind/ChangeLog
index 39bcd79..5e72c59 100644
--- a/frysk-sys/lib/unwind/ChangeLog
+++ b/frysk-sys/lib/unwind/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-20  Andrew Cagney  <cagney@redhat.com>
+
+	* jni/UnwindH.hxx (access_mem): Catch Throwable and then use
+	instanceof to identify a UserException.
+	* cni/UnwindH.hxx (access_mem): Ditto.
+
 2008-05-26  Andrew Cagney  <cagney@redhat.com>
 
 	* jni/ElfImage.cxx: Delete.
diff --git a/frysk-sys/lib/unwind/cni/UnwindH.hxx b/frysk-sys/lib/unwind/cni/UnwindH.hxx
index 925b8af..1469bcd 100644
--- a/frysk-sys/lib/unwind/cni/UnwindH.hxx
+++ b/frysk-sys/lib/unwind/cni/UnwindH.hxx
@@ -62,6 +62,7 @@
 #include <java/lang/ArrayIndexOutOfBoundsException.h>
 
 #include "inua/eio/ByteBuffer.h"
+#include "frysk/UserException.h"
 #include "frysk/rsl/Log.h"
 #include "frysk/rsl/cni/Log.hxx"
 #include "lib/dwfl/Dwfl.h"
@@ -149,11 +150,15 @@ access_mem(::unw_addr_space_t as, ::unw_word_t addr,
 					   tmp, (jboolean) write);
     memcpy(valp, elements(tmp), JvGetArrayLength(tmp));
     return ret;
-  } catch (RuntimeException *t) {
-    // We have to catch all RuntimeExceptions here since there
-    // is no indicator for just "invalid memory location".
-    // Core files might have "holes" in their memory.
-    return -UNW_EINVAL;
+  } catch (Throwable *t) {
+    if (frysk::UserException::class$.isInstance(t)) {
+      // We have to catch all RuntimeExceptions here since there
+      // is no indicator for just "invalid memory location".
+      // Core files might have "holes" in their memory.
+      return -UNW_EINVAL;
+    } else {
+      throw t;
+    }
   }
 }
 
diff --git a/frysk-sys/lib/unwind/jni/UnwindH.hxx b/frysk-sys/lib/unwind/jni/UnwindH.hxx
index 3f42723..76e57b7 100644
--- a/frysk-sys/lib/unwind/jni/UnwindH.hxx
+++ b/frysk-sys/lib/unwind/jni/UnwindH.hxx
@@ -147,11 +147,15 @@ access_mem(::unw_addr_space_t as, ::unw_word_t addr,
     tmp.release();
     jtmp.DeleteLocalRef(env);
     return ret;
-  } catch (RuntimeException *t) {
-    // We have to catch all RuntimeExceptions here since there
-    // is no indicator for just "invalid memory location".
-    // Core files might have "holes" in their memory.
-    return -UNW_EINVAL;
+  } catch (Throwable t) {
+    if (t.IsInstanceOf(env, frysk::UserException::_class_(env))) {
+      // We have to catch all RuntimeExceptions here since there is no
+      // indicator for just "invalid memory location".  Core files
+      // might have "holes" in their memory.
+      return -UNW_EINVAL;
+    } else {
+      throw t;
+    }
   }
 }
 


hooks/post-receive
--
frysk system monitor/debugger


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-20 19:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-20 19:23 [SCM] master: Throw/catch UserExceptions, not RuntimeExceptions in unwinder cagney

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