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