public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* frysk vs libunwind symbol lookup
@ 2007-11-19 11:45 Mark Wielaard
  2007-11-23 13:51 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2007-11-19 11:45 UTC (permalink / raw)
  To: frysk

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

Hi,

This looks like a small patch, but it actually is a pretty significant
change in how we are using libunwind. Since we weren't trusting the IP
address given by libunwind unw_get_reg() because that did a lookup of
the current address through the current frame even though that could
have missing or bogus dwarf info, we were using a full proc and symbol
name lookup for each frame through libunwind. With this patch, and a
small change to libunwind to always use the cached (and correct) ip
value of the cursor, we don't need to do any symbol lookup through
libunwind anymore (which will get rid of a lot of our workarounds, since
the libunwind symbol lookup was basically just a guess).

This also fixes a couple of issues with the load command that Rick was
seeing, like bug #5267. You can now do all the normal fhpd commands
(although the results are kind of boring of course). One last issue is
bug #5286 (and the duplicate? #5345) with print, but those seem to
happen also with other exe or core targets.

frysk-core/frysk/stack/ChangeLog
2007-11-19  Mark Wielaard  <mwielaard@redhat.com>

    * LibunwindFrame.java (getAddress): Don't do a proc name lookup,
    use new Cursor.getIP().

frysk-imports/libunwind/ChangeLog
2007-11-19  Mark Wielaard  <mwielaard@redhat.com>

    * src/mi/Gget_reg.c (unw_get_reg): Use cached value from cursor
    when looking for UNW_REG_IP.

frysk-sys/lib/unwind/ChangeLog
2007-11-19  Mark Wielaard  <mwielaard@redhat.com>

    * Cursor.java (getIP): New method.
    (unwind): Check current ip.
    * Unwind.java (getIP): New method.
    * cni/UnwindH.hxx (getIP): Likewise.
    (getContext): Check for null elfImage.

All tests PASS before and after this patch on x86 and x86_64 (Fedora 8).

I will clean up the libunwind interfaces up next to purge the stuff we
aren't using anymore and out custom patches to some of the symbol lookup
stuff in libunwind itself.

Cheers,

Mark

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

diff --git a/frysk-core/frysk/stack/LibunwindFrame.java b/frysk-core/frysk/stack/LibunwindFrame.java
index 080df12..64e9c28 100644
--- a/frysk-core/frysk/stack/LibunwindFrame.java
+++ b/frysk-core/frysk/stack/LibunwindFrame.java
@@ -44,7 +44,6 @@ import frysk.isa.Register;
 import java.util.logging.Logger;
 import lib.unwind.Cursor;
 import lib.unwind.ProcInfo;
-import lib.unwind.ProcName;
 import frysk.isa.ISA;
 import frysk.proc.Task;
 import frysk.symtab.Symbol;
@@ -92,13 +91,7 @@ class LibunwindFrame extends Frame
      * Returns the current program counter of this Frame.
      */
     public long getAddress() {
-	ProcInfo myInfo = cursor.getProcInfo();
-	ProcName myName = cursor.getProcName(0);
-    
-	if (myInfo.getError() != 0 || myName.getError() != 0)
-	    return 0;
-    
-	return myInfo.getStartIP() + myName.getOffset();
+      return cursor.getIP();
     }
   
     /**
diff --git a/frysk-imports/libunwind/src/mi/Gget_reg.c b/frysk-imports/libunwind/src/mi/Gget_reg.c
index 23b72be..5179a88 100644
--- a/frysk-imports/libunwind/src/mi/Gget_reg.c
+++ b/frysk-imports/libunwind/src/mi/Gget_reg.c
@@ -30,5 +30,12 @@ unw_get_reg (unw_cursor_t *cursor, int regnum, unw_word_t *valp)
 {
   struct cursor *c = (struct cursor *) cursor;
 
+  // No need to go look up the IP value since it is cached in the cursor.
+  if (regnum == UNW_REG_IP)
+    {
+      *valp = c->dwarf.ip;
+      return 0;
+    }
+
   return tdep_access_reg (c, regnum, valp, 0);
 }
diff --git a/frysk-sys/lib/unwind/Cursor.java b/frysk-sys/lib/unwind/Cursor.java
index 190e315..6433ace 100644
--- a/frysk-sys/lib/unwind/Cursor.java
+++ b/frysk-sys/lib/unwind/Cursor.java
@@ -81,6 +81,10 @@ public class Cursor
 			     bytes, start);
     }
 
+    public long getIP() {
+	return unwinder.getIP(cursor);
+    }
+  
     public long getSP() {
 	return unwinder.getSP(cursor);
     }
@@ -110,8 +114,8 @@ public class Cursor
     public Cursor unwind() {
 	logger.log(Level.FINE, "{0}, unwind\n", this);
 
-	//XXX: Don't unwind if no more frames.
-	if (step == 0)
+	//XXX: Don't unwind if no more, or unknown frames.
+	if (step == 0 || getIP() == 0)
 	    return null;
     
 	Cursor newCursor = new Cursor(addressSpace,
diff --git a/frysk-sys/lib/unwind/Unwind.java b/frysk-sys/lib/unwind/Unwind.java
index 23181ec..8e9d3d3 100644
--- a/frysk-sys/lib/unwind/Unwind.java
+++ b/frysk-sys/lib/unwind/Unwind.java
@@ -70,6 +70,7 @@ public abstract class Unwind
     abstract void setRegister(RawDataManaged cursor, int regNum,
 			      long offset, int length, byte[] word, int start);
   
+    public abstract long getIP(RawDataManaged cursor);
     public abstract long getSP(RawDataManaged cursor);
   
   abstract RawDataManaged copyCursor(RawDataManaged cursor);  
diff --git a/frysk-sys/lib/unwind/cni/UnwindH.hxx b/frysk-sys/lib/unwind/cni/UnwindH.hxx
index c13576c..f48494e 100644
--- a/frysk-sys/lib/unwind/cni/UnwindH.hxx
+++ b/frysk-sys/lib/unwind/cni/UnwindH.hxx
@@ -402,6 +402,17 @@ lib::unwind::TARGET::getSP(gnu::gcj::RawDataManaged* cursor)
     return sp;
 }
 
+jlong
+lib::unwind::TARGET::getIP(gnu::gcj::RawDataManaged* cursor)
+{
+  unw_word_t ip;
+  int status = unw_get_reg((::unw_cursor_t *) cursor, UNW_REG_IP, &ip);
+  if (status < 0)
+    return 0; // bottom of stack.
+  else
+    return ip;
+}
+
 
 jint
 lib::unwind::TARGET::getContext(gnu::gcj::RawDataManaged* context)
@@ -445,6 +456,9 @@ lib::unwind::TARGET::createProcInfoFromElfImage(lib::unwind::AddressSpace* addre
 						jboolean needUnwindInfo,
 						lib::unwind::ElfImage* elfImage)
 {
+  if (elfImage == NULL)
+    return new lib::unwind::ProcInfo(UNW_ENOINFO);
+
   unw_proc_info_t *procInfo
     = (::unw_proc_info_t *) JvAllocBytes(sizeof (::unw_proc_info_t));
 

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

* Re: frysk vs libunwind symbol lookup
  2007-11-19 11:45 frysk vs libunwind symbol lookup Mark Wielaard
@ 2007-11-23 13:51 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2007-11-23 13:51 UTC (permalink / raw)
  To: frysk

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

On Mon, 2007-11-19 at 12:45 +0100, Mark Wielaard wrote:
> I will clean up the libunwind interfaces up next to purge the stuff we
> aren't using anymore and out custom patches to some of the symbol lookup
> stuff in libunwind itself.

Here is the bulk. Now we really aren't doing any ProcName symbol lookups
through libunwind anymore. Hurray! This also gets rid of some of our
local libunwind patches that aren't needed anymore.

frysk-imports/libunwind/ChangeLog
2007-11-23  Mark Wielaard  <mwielaard@redhat.com>

    Revert:
    2006-09-16  Alexandre Oliva  <aoliva@redhat.com>

    * src/x86/Gget_proc_info.c (unw_get_proc_info): Use
    unw_get_proc_name to build a proper proc_info_t.
    * src/x86_64/Gget_proc_info.c (unw_get_proc_info): Likewise.
    * src/hppa/Gget_proc_info.c (unw_get_proc_info): Likewise.

    2006-09-27  Alexandre Oliva  <aoliva@redhat.com>

    * src/elfxx.c (lookup_symbol): Cope with NULL buf and zero buf_len.
    * src/mi/Gget_proc_name.c (intern_string, get_proc_name): Likewise.
    * src/hppa/Gget_proc_info.c (unw_get_proc_info): Use it.
    * src/x86/Gget_proc_info.c (unw_get_proc_info): Likewise.
    * src/x86_64/Gget_proc_info.c (unw_get_proc_info): Likewise.
    * doc/unw_get_proc_name.tex: Document NULL buf and zero buf_len.
    * doc/unw_create_addr_space.tex (get_proc_name): Likewise.
    * doc/unw_get_proc_name.man: Rebuilt.
    * doc/unw_create_addr_space.man: Likewise.

frysk-core/frysk/stack/ChangeLog
2007-11-23  Mark Wielaard  <mwielaard@redhat.com>

    * LibunwindAddressSpace.java (getModuleFromAddress): Removed.
    (getProcName): Removed.

frysk-sys/lib/unwind/ChangeLog
2007-11-23  Mark Wielaard  <mwielaard@redhat.com>

    * AddressSpace.java (getProcName): Removed.
    * Cursor.java (getProcName): Removed.
    * ProcName.java: Removed.
    * TestUnwind.java (getProcName): Removed.
    * Unwind.java (getProcName): Removed.
    * cnu/UnwindH.hxx (min): Removed.
    (get_proc_name): Return UNW_ENOMEM.
    (getProcName): Removed.

I extensively tested this on both x86 and x86_64 (Fedora 8) and no
regressions at all (I suspect there might actually be some unresolved
bugs that got fixed by this, but haven't checked yet). But since this is
actually a big change (as in a huge code path is now never taken) please
let me know if you see anything bad.

Cheers,

Mark

[-- Attachment #2: no-more-procname.patch --]
[-- Type: text/x-patch, Size: 19298 bytes --]

diff --git a/frysk-core/frysk/stack/LibunwindAddressSpace.java b/frysk-core/frysk/stack/LibunwindAddressSpace.java
index 80eb3cf..4b5f8d5 100644
--- a/frysk-core/frysk/stack/LibunwindAddressSpace.java
+++ b/frysk-core/frysk/stack/LibunwindAddressSpace.java
@@ -45,25 +45,18 @@ import lib.unwind.UnwindX8664;
 import lib.unwind.UnwindX86;
 import lib.unwind.UnwindPPC32;
 import lib.unwind.UnwindPPC64;
-import frysk.dwfl.DwflCache;
 import frysk.dwfl.DwflFactory;
-import frysk.event.Event;
 import frysk.isa.ISA;
-import frysk.proc.Manager;
 import frysk.proc.MemoryMap;
 import frysk.proc.Task;
 import java.util.Arrays;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import lib.dwfl.Dwfl;
-import lib.dwfl.DwflModule;
-import lib.dwfl.SymbolBuilder;
 import lib.unwind.AddressSpace;
 import lib.unwind.ByteOrder;
 import lib.unwind.Cursor;
 import lib.unwind.ElfImage;
 import lib.unwind.ProcInfo;
-import lib.unwind.ProcName;
 import frysk.isa.RegisterMap;
 
 class LibunwindAddressSpace extends AddressSpace {
@@ -168,60 +161,6 @@ class LibunwindAddressSpace extends AddressSpace {
 	return - lib.unwind.Error.UNW_ENOINFO_;
     }
 
-    private DwflModule getModuleFromAddress (long addr) {
-	logger.log(Level.FINE, "Looking for addr: 0x{0}\n",
-		   Long.toHexString(addr));
-	Dwfl dwfl = null;
-	dwfl = DwflCache.getDwfl(task);
-	logger.log(Level.FINEST, "got dwfl: {0}\n", dwfl);
-	if (dwfl == null) {
-	    logger.log(Level.FINE, "Dwfl was null\n");
-	    return null;
-	}
-	return dwfl.getModule(addr);
-    }
-
-    public ProcName getProcName (long addr, int maxNameSize) {
-	logger.log(Level.FINE,
-		   "entering getProcName addr: {0}, maxNameSize: {1}\n",
-		   new Object[] {
-		       Long.toHexString(addr),
-		       new Integer(maxNameSize)
-		   });
-	// Need to tell ptrace thread to perform the getProcName operation.
-	class ExecuteGetProcName 
-	    implements Event, SymbolBuilder
-	{
-	    ProcName procName;
-	    long addr;
-      
-	    ExecuteGetProcName (long addr) {
-		this.addr = addr;
-	    }
-      
-	    public void symbol (String name, long value, long size, int type,
-				int bind, int visibility) {
-		procName = new ProcName(addr-value, name);
-	    }
-      
-	    public void execute () {
-		DwflModule dwflModule = getModuleFromAddress(addr);
-		logger.log(Level.FINEST, "got dwflModule: {0}\n", dwflModule);
-		if (dwflModule != null) {
-		    dwflModule.getSymbol(addr, this);
-		    logger.log(Level.FINE, "ProcName is: {0}\n", procName);
-		}
-		if (procName == null)
-		    procName = new ProcName(- lib.unwind.Error.UNW_EUNSPEC_);
-	    }
-	}
-	ExecuteGetProcName executer = new ExecuteGetProcName(addr);
-	Manager.eventLoop.execute(executer);
-	logger.log(Level.FINE, "exiting getProcName, returning: {0}\n",
-		   executer.procName);
-	return executer.procName;
-    }
-
     public void putUnwindInfo (final ProcInfo procInfo) {
 	// No longer need to hold procInfo.
 	this.procInfo = null;
diff --git a/frysk-imports/libunwind/doc/unw_create_addr_space.man b/frysk-imports/libunwind/doc/unw_create_addr_space.man
index 4ff2b6e..4aca13e 100644
--- a/frysk-imports/libunwind/doc/unw_create_addr_space.man
+++ b/frysk-imports/libunwind/doc/unw_create_addr_space.man
@@ -413,19 +413,6 @@ pointed to by offp
 (assuming the procedure is at least 0x80 
 bytes long). 
 .PP
-If bufp
-is NULL
-, buf_len
-is still verified to fit
-and offp
-is set.  Passing buf_len
-as zero to indicate no
-limits on the buffer length is only safe if buf
-is NULL
-,
-otherwise the callback is entitled and likely to scribble anywhere in
-the entire address space.
-.PP
 On successful completion, the get_proc_name()
 call\-back must 
 return zero. Otherwise, the negative value of one of the 
diff --git a/frysk-imports/libunwind/doc/unw_create_addr_space.tex b/frysk-imports/libunwind/doc/unw_create_addr_space.tex
index f259d4c..8de0691 100644
--- a/frysk-imports/libunwind/doc/unw_create_addr_space.tex
+++ b/frysk-imports/libunwind/doc/unw_create_addr_space.tex
@@ -229,12 +229,6 @@ at address 0x40003000, then invoking \Func{get\_proc\_name}() with
 pointed to by \Var{offp} (assuming the procedure is at least 0x80
 bytes long).
 
-If \Var{bufp} is \Const{NULL}, \Var{buf\_len} is still verified to fit
-and \Var{offp} is set.  Passing \Var{buf\_len} as zero to indicate no
-limits on the buffer length is only safe if \Var{buf} is \Const{NULL},
-otherwise the callback is entitled and likely to scribble anywhere in
-the entire address space.
-
 On successful completion, the \Func{get\_proc\_name}() call-back must
 return zero.  Otherwise, the negative value of one of the
 \Type{unw\_error\_t} error-codes may be returned.
diff --git a/frysk-imports/libunwind/doc/unw_get_proc_name.man b/frysk-imports/libunwind/doc/unw_get_proc_name.man
index b84c5c4..bbf350f 100644
--- a/frysk-imports/libunwind/doc/unw_get_proc_name.man
+++ b/frysk-imports/libunwind/doc/unw_get_proc_name.man
@@ -54,19 +54,6 @@ return a value of 0x80 in the word pointed to by offp
 (assuming 
 the procedure is at least 0x80 bytes long). 
 .PP
-If bufp
-is NULL
-, buf_len
-is still verified to fit
-and offp
-is set.  Passing buf_len
-as zero to indicate no
-limits on the buffer length is only safe if buf
-is NULL
-,
-otherwise the callback is entitled and likely to scribble anywhere in
-the entire address space.
-.PP
 Note that on some platforms there is no reliable way to distinguish 
 between procedure names and ordinary labels. Furthermore, if symbol 
 information has been stripped from a program, procedure names may be 
diff --git a/frysk-imports/libunwind/doc/unw_get_proc_name.tex b/frysk-imports/libunwind/doc/unw_get_proc_name.tex
index bd2b8bc..4a9b585 100644
--- a/frysk-imports/libunwind/doc/unw_get_proc_name.tex
+++ b/frysk-imports/libunwind/doc/unw_get_proc_name.tex
@@ -29,12 +29,6 @@ stack frame with an instruction-pointer value of 0x40003080 would
 return a value of 0x80 in the word pointed to by \Var{offp} (assuming
 the procedure is at least 0x80 bytes long).
 
-If \Var{bufp} is \Const{NULL}, \Var{buf\_len} is still verified to fit
-and \Var{offp} is set.  Passing \Var{buf\_len} as zero to indicate no
-limits on the buffer length is only safe if \Var{buf} is \Const{NULL},
-otherwise the callback is entitled and likely to scribble anywhere in
-the entire address space.
-
 Note that on some platforms there is no reliable way to distinguish
 between procedure names and ordinary labels.  Furthermore, if symbol
 information has been stripped from a program, procedure names may be
diff --git a/frysk-imports/libunwind/src/elfxx.c b/frysk-imports/libunwind/src/elfxx.c
index c70d06b..ae1ef34 100644
--- a/frysk-imports/libunwind/src/elfxx.c
+++ b/frysk-imports/libunwind/src/elfxx.c
@@ -158,14 +158,14 @@ elf_w (lookup_symbol) (unw_addr_space_t as,
 		  Debug (16, "0x%016lx info=0x%02x %s\n",
 			 (long) val, sym->st_info, strtab + sym->st_name);
 
-		  min_dist = (Elf_W (Addr)) (ip - val);
-		  if (buf)
+		  if ((Elf_W (Addr)) (ip - val) < min_dist)
 		    {
+		      min_dist = (Elf_W (Addr)) (ip - val);
 		      strncpy (buf, strtab + sym->st_name, buf_len);
-		      buf[buf_len] = '\0';
+		      buf[buf_len - 1] = '\0';
+		      if (strlen (strtab + sym->st_name) >= buf_len)
+			ret = -UNW_ENOMEM;
 		    }
-		  if (strlen (strtab + sym->st_name) > buf_len)
-		    ret = -UNW_ENOMEM;
 		}
 	    }
 	  break;
diff --git a/frysk-imports/libunwind/src/hppa/Gget_proc_info.c b/frysk-imports/libunwind/src/hppa/Gget_proc_info.c
index 5c5a3fd..8d2c1fd 100644
--- a/frysk-imports/libunwind/src/hppa/Gget_proc_info.c
+++ b/frysk-imports/libunwind/src/hppa/Gget_proc_info.c
@@ -36,13 +36,8 @@ unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi)
 	 are missing DWARF unwind info.  We don't want to fail in that
 	 case, because those frames are uninteresting and just mark
 	 the end of the frame-chain anyhow.  */
-      unw_word_t offset;
-
-      if (unw_get_proc_name (cursor, NULL, 0, &offset) < 0)
-	offset = 0;
-
       memset (pi, 0, sizeof (*pi));
-      pi->start_ip = c->dwarf.ip - offset;
+      pi->start_ip = c->dwarf.ip;
       pi->end_ip = c->dwarf.ip + 4;
       return 0;
     }
diff --git a/frysk-imports/libunwind/src/mi/Gget_proc_name.c b/frysk-imports/libunwind/src/mi/Gget_proc_name.c
index bac98ff..7251c59 100644
--- a/frysk-imports/libunwind/src/mi/Gget_proc_name.c
+++ b/frysk-imports/libunwind/src/mi/Gget_proc_name.c
@@ -33,25 +33,16 @@ intern_string (unw_addr_space_t as, unw_accessors_t *a,
   size_t i;
   int ret;
 
-  buf_len--;
-
-  for (i = 0; i <= buf_len; ++i)
+  for (i = 0; i < buf_len; ++i)
     {
-      int8_t c, *p = buf ? (int8_t *)buf + i : &c;
-
-      if ((ret = fetch8 (as, a, &addr, p, arg)) < 0)
+      if ((ret = fetch8 (as, a, &addr, (int8_t *) buf + i, arg)) < 0)
 	return ret;
 
-      if (*p == '\0')
+      if (buf[i] == '\0')
 	return 0;		/* copied full string; return success */
     }
-  if (buf)
-    {
-      buf[buf_len] = '\0';	/* ensure string is NUL terminated */
-      return -UNW_ENOMEM;
-    }
-  else
-    return 0;
+  buf[buf_len - 1] = '\0';	/* ensure string is NUL terminated */
+  return -UNW_ENOMEM;
 }
 
 static inline int
@@ -62,8 +53,7 @@ get_proc_name (unw_addr_space_t as, unw_word_t ip,
   unw_proc_info_t pi;
   int ret;
 
-  if (buf)
-    buf[0] = '\0';	/* always return a valid string, even if it's empty */
+  buf[0] = '\0';	/* always return a valid string, even if it's empty */
 
   ret = unwi_find_dynamic_proc_info (as, ip, &pi, 1, arg);
   if (ret == 0)
diff --git a/frysk-imports/libunwind/src/x86/Gget_proc_info.c b/frysk-imports/libunwind/src/x86/Gget_proc_info.c
index ac4f98a..a533483 100644
--- a/frysk-imports/libunwind/src/x86/Gget_proc_info.c
+++ b/frysk-imports/libunwind/src/x86/Gget_proc_info.c
@@ -35,13 +35,8 @@ unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi)
       /* On x86, it's relatively common to be missing DWARF unwind
 	 info.  We don't want to fail in that case, because the
 	 frame-chain still would let us do a backtrace at least.  */
-      unw_word_t offset;
-
-      if (unw_get_proc_name (cursor, NULL, 0, &offset) < 0)
-	offset = 0;
-
       memset (pi, 0, sizeof (*pi));
-      pi->start_ip = c->dwarf.ip - offset;
+      pi->start_ip = c->dwarf.ip;
       pi->end_ip = c->dwarf.ip + 1;
       return 0;
     }
diff --git a/frysk-imports/libunwind/src/x86_64/Gget_proc_info.c b/frysk-imports/libunwind/src/x86_64/Gget_proc_info.c
index 6d5c3d5..213666e 100644
--- a/frysk-imports/libunwind/src/x86_64/Gget_proc_info.c
+++ b/frysk-imports/libunwind/src/x86_64/Gget_proc_info.c
@@ -38,13 +38,8 @@ unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi)
 	 are missing DWARF unwind info.  We don't want to fail in that
 	 case, because those frames are uninteresting and just mark
 	 the end of the frame-chain anyhow.  */
-      unw_word_t offset;
-
-      if (unw_get_proc_name (cursor, NULL, 0, &offset) < 0)
-	offset = 0;
-
       memset (pi, 0, sizeof (*pi));
-      pi->start_ip = c->dwarf.ip - offset;
+      pi->start_ip = c->dwarf.ip;
       pi->end_ip = c->dwarf.ip + 1;
       return 0;
     }
diff --git a/frysk-sys/lib/unwind/AddressSpace.java b/frysk-sys/lib/unwind/AddressSpace.java
index 28db0ee..c1df18b 100644
--- a/frysk-sys/lib/unwind/AddressSpace.java
+++ b/frysk-sys/lib/unwind/AddressSpace.java
@@ -104,6 +104,4 @@ public abstract class AddressSpace
     public abstract int accessFPReg (int regnum, byte[] fpvalp, boolean write);
 
     public abstract int resume (Cursor cursor);
-
-    public abstract ProcName getProcName (long addr, int maxSize);
 }
diff --git a/frysk-sys/lib/unwind/Cursor.java b/frysk-sys/lib/unwind/Cursor.java
index 6433ace..8628bd9 100644
--- a/frysk-sys/lib/unwind/Cursor.java
+++ b/frysk-sys/lib/unwind/Cursor.java
@@ -93,20 +93,6 @@ public class Cursor
 	return unwinder.step(cursor);
     }
   
-    public ProcName getProcName(int maxNameSize) {
-	return unwinder.getProcName(cursor, maxNameSize);
-    }
-  
-    public ProcName getProcName() {
-	int initialSize = 256;
-	ProcName myName;
-	do {
-	    myName = unwinder.getProcName(cursor, initialSize);
-	    initialSize *= 2;
-	} while (myName.getError() == - lib.unwind.Error.UNW_ENOMEM_);
-	return myName;
-    }
-  
     public ProcInfo getProcInfo () {
 	return unwinder.getProcInfo(cursor);
     }
diff --git a/frysk-sys/lib/unwind/ProcName.java b/frysk-sys/lib/unwind/ProcName.java
deleted file mode 100644
index 9141899..0000000
--- a/frysk-sys/lib/unwind/ProcName.java
+++ /dev/null
@@ -1,88 +0,0 @@
-// This file is part of the program FRYSK.
-//
-// Copyright 2007, Red Hat Inc.
-//
-// FRYSK is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by
-// the Free Software Foundation; version 2 of the License.
-//
-// FRYSK is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with FRYSK; if not, write to the Free Software Foundation,
-// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-// 
-// In addition, as a special exception, Red Hat, Inc. gives You the
-// additional right to link the code of FRYSK with code not covered
-// under the GNU General Public License ("Non-GPL Code") and to
-// distribute linked combinations including the two, subject to the
-// limitations in this paragraph. Non-GPL Code permitted under this
-// exception must only link to the code of FRYSK through those well
-// defined interfaces identified in the file named EXCEPTION found in
-// the source code files (the "Approved Interfaces"). The files of
-// Non-GPL Code may instantiate templates or use macros or inline
-// functions from the Approved Interfaces without causing the
-// resulting work to be covered by the GNU General Public
-// License. Only Red Hat, Inc. may make changes or additions to the
-// list of Approved Interfaces. You must obey the GNU General Public
-// License in all respects for all of the FRYSK code and other code
-// used in conjunction with FRYSK except the Non-GPL Code covered by
-// this exception. If you modify this file, you may extend this
-// exception to your version of the file, but you are not obligated to
-// do so. If you do not wish to provide this exception without
-// modification, you must delete this exception statement from your
-// version and license this file solely under the GPL without
-// exception.
-
-package lib.unwind;
-
-public class ProcName
-{
-  int error = 0;
-  final long offset;
-  final String name;
-  
-  public long getOffset()
-  {
-    return offset;
-  }
-  
-  public String getName()
-  {
-    return name;
-  }
-  
-  public int getError()
-  {
-    return error;
-  }
-  
-  private ProcName(int error, long offset, String name)
-  {
-    this.error = error;
-    this.offset = offset;
-    this.name = name;
-  }
-  
-  public ProcName(long address, String name)
-  {
-	  this(0, address, name);
-  }
-  
-  public ProcName(int error)
-  {
-	  this(error, 0, null);
-  }
-  
-  public String toString()
-  {
-    if (error != 0)
-    return "ProcName error: " + error;
-    
-    return "ProcName name: " + name + " offset: " + Long.toHexString(offset);
-  }
-  
-}
diff --git a/frysk-sys/lib/unwind/TestUnwind.java b/frysk-sys/lib/unwind/TestUnwind.java
index 6d57e78..255b36a 100644
--- a/frysk-sys/lib/unwind/TestUnwind.java
+++ b/frysk-sys/lib/unwind/TestUnwind.java
@@ -73,9 +73,6 @@ public class TestUnwind
 	public int getDynInfoListAddr (byte[] dilap) {
 	    return 0;
 	}
-	public ProcName getProcName (long addr, int maxNameSize) {
-	    return null;
-	}
 	public void putUnwindInfo (ProcInfo procInfo) {
 	}
 	public int resume (Cursor cursor) {
diff --git a/frysk-sys/lib/unwind/Unwind.java b/frysk-sys/lib/unwind/Unwind.java
index 8e9d3d3..2ab70ef 100644
--- a/frysk-sys/lib/unwind/Unwind.java
+++ b/frysk-sys/lib/unwind/Unwind.java
@@ -61,8 +61,6 @@ public abstract class Unwind
   
   abstract int step (RawDataManaged cursor);
   
-  abstract ProcName getProcName(RawDataManaged cursor, int maxNameSize);
-  
   abstract ProcInfo getProcInfo (RawDataManaged cursor);
   
     abstract void getRegister(RawDataManaged cursor, int regNum,
diff --git a/frysk-sys/lib/unwind/cni/UnwindH.hxx b/frysk-sys/lib/unwind/cni/UnwindH.hxx
index f48494e..77a24cf 100644
--- a/frysk-sys/lib/unwind/cni/UnwindH.hxx
+++ b/frysk-sys/lib/unwind/cni/UnwindH.hxx
@@ -67,7 +67,6 @@
 #include "lib/unwind/ByteOrder.h"
 #include "lib/unwind/CachingPolicy.h"
 #include "lib/unwind/ProcInfo.h"
-#include "lib/unwind/ProcName.h"
 #include "lib/unwind/ElfImage.h"
 
 #include "frysk/sys/cni/Errno.hxx"
@@ -188,12 +187,6 @@ resume(::unw_addr_space_t as, ::unw_cursor_t *cp, void *arg)
   return (int) addressSpace(arg)->resume ((lib::unwind::Cursor *) cp);
 }
 
-static size_t
-min (size_t a, size_t b)
-{
-  return a < b ? a : b;
-}
-
 /*
  * Returns the name of the procedure that the provided address is in as well as
  * the offset from the start of the procedure.
@@ -203,26 +196,7 @@ get_proc_name(::unw_addr_space_t as,
 	      ::unw_word_t addr, char *bufp,
 	      size_t buf_len, ::unw_word_t *offp, void *arg)
 {
-  lib::unwind::ProcName *procName
-    = addressSpace(arg)->getProcName ((jlong) addr, (jint) buf_len);
-  if (procName->error < 0 && procName->error != -UNW_ENOMEM)
-    return procName->error;
-  *offp = (unw_word_t) procName->offset;
-  //In case get_proc_name is used only to find addr;
-  if (bufp == NULL || buf_len == 0) 
-    return 0;
-  if (procName->name == NULL)
-      return 0;
-  //The maximum number of characters that can be copied are buf_len -1.
-  //with bufp[buf_len - 1] = '\0'.
-  //Otherwise copy name.length characters, and bufp[name.length] = '\0'
-  size_t upper_limit = min(buf_len - 1 , JvGetStringUTFLength(procName->name));
-  //JvGetStringUTFRegion(jstring STR, jsize START, jsize LEN, char* BUF);
-  JvGetStringUTFRegion(procName->name, 0, upper_limit, bufp);
-  bufp[upper_limit] = '\0';
-  if (upper_limit < buf_len)
-    return 0;
-  else
+    // This should never be called, always return an error.
     return -UNW_ENOMEM;
 }
 
@@ -290,31 +264,6 @@ lib::unwind::TARGET::step(gnu::gcj::RawDataManaged* cursor)
   return unw_step((unw_cursor_t *) cursor);
 }
 
-lib::unwind::ProcName*
-lib::unwind::TARGET::getProcName(gnu::gcj::RawDataManaged* cursor, jint maxNameSize)
-{
-  logFine (this, logger, "getProcName cursor: %p, maxNameSize: %d", cursor, (int) maxNameSize);
-
-  char bufp[maxNameSize];
-  bufp[0] = '\0';
-  unw_word_t offset;
-  int err = unw_get_proc_name((unw_cursor_t *) cursor, bufp, maxNameSize, &offset);
-
-  logFinest(this, logger, "getProcName bufp: %s, offset: %lx, error: %d", bufp,(long) offset, err);
-
-  if (err < 0)
-    return new lib::unwind::ProcName((jint) err);
-
-  jstring jName;
-  
-  if (bufp[0] == '\0')
-    jName = NULL;
-  else
-    jName = JvNewStringUTF(bufp);
-  
-  return new lib::unwind::ProcName((jlong) offset, jName);
-}
-
 static void
 verifyBounds(jlong offset, jint length, jbyteArray bytes, jint start, int size)
 {

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

end of thread, other threads:[~2007-11-23 13:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-19 11:45 frysk vs libunwind symbol lookup Mark Wielaard
2007-11-23 13:51 ` Mark Wielaard

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