From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12264 invoked by alias); 5 Jun 2008 23:15:07 -0000 Received: (qmail 12234 invoked by uid 367); 5 Jun 2008 23:15:06 -0000 Date: Thu, 05 Jun 2008 23:15:00 -0000 Message-ID: <20080605231506.12219.qmail@sourceware.org> From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Move getSourceLine from Dwfl to DwflModule. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 6c5c57e7c1e887ccedbab85f9da5074e691d44a1 X-Git-Newrev: b10ad03749019cfbac9a2f531f47bcebac7511b2 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q2/txt/msg00342.txt.bz2 The branch, master has been updated via b10ad03749019cfbac9a2f531f47bcebac7511b2 (commit) from 6c5c57e7c1e887ccedbab85f9da5074e691d44a1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit b10ad03749019cfbac9a2f531f47bcebac7511b2 Author: Andrew Cagney Date: Thu Jun 5 19:14:09 2008 -0400 Move getSourceLine from Dwfl to DwflModule. frysk-sys/lib/dwfl/ChangeLog 2008-06-05 Andrew Cagney * DwflLine.java: Pass pointer to native methods. (DwflLine(long,DwflModule)): Replace DwflLine(long,Dwfl). (getPointer()): Delete. * cni/DwflLine.cxx: Update. * jni/DwflLine.cxx: Update. * DwflModule.java (getSourceLine()): New. (dwfl_module_getsrc): New. * jni/DwflModule.cxx: Update. * cni/DwflModule.cxx: Update. * Dwfl.java (getSourceLine()): Call DwflModule.getSourceLine. (dwfl_getsrc): Delete. * cni/Dwfl.cxx: Update. * jni/Dwfl.cxx: Update. ----------------------------------------------------------------------- Summary of changes: frysk-sys/lib/dwfl/ChangeLog | 14 ++++ frysk-sys/lib/dwfl/Dwfl.java | 17 +---- frysk-sys/lib/dwfl/DwflLine.java | 109 +++++++++++++------------------- frysk-sys/lib/dwfl/DwflModule.java | 19 ++++++ frysk-sys/lib/dwfl/cni/Dwfl.cxx | 5 -- frysk-sys/lib/dwfl/cni/DwflLine.cxx | 47 +++++++------- frysk-sys/lib/dwfl/cni/DwflModule.cxx | 7 ++- frysk-sys/lib/dwfl/jni/Dwfl.cxx | 5 -- frysk-sys/lib/dwfl/jni/DwflLine.cxx | 12 ++-- frysk-sys/lib/dwfl/jni/DwflModule.cxx | 8 ++- 10 files changed, 124 insertions(+), 119 deletions(-) First 500 lines of diff: diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog index e6ff387..1160aa0 100644 --- a/frysk-sys/lib/dwfl/ChangeLog +++ b/frysk-sys/lib/dwfl/ChangeLog @@ -1,5 +1,19 @@ 2008-06-05 Andrew Cagney + * DwflLine.java: Pass pointer to native methods. + (DwflLine(long,DwflModule)): Replace DwflLine(long,Dwfl). + (getPointer()): Delete. + * cni/DwflLine.cxx: Update. + * jni/DwflLine.cxx: Update. + * DwflModule.java (getSourceLine()): New. + (dwfl_module_getsrc): New. + * jni/DwflModule.cxx: Update. + * cni/DwflModule.cxx: Update. + * Dwfl.java (getSourceLine()): Call DwflModule.getSourceLine. + (dwfl_getsrc): Delete. + * cni/Dwfl.cxx: Update. + * jni/Dwfl.cxx: Update. + * DwflDie.java: Replace DwflDieBias.java; extends DwarfDie. * DwarfDieFactory.java (makeDwflDie(long,DwflModule)): New. * DwarfDie.java: Simplify. diff --git a/frysk-sys/lib/dwfl/Dwfl.java b/frysk-sys/lib/dwfl/Dwfl.java index ecb1fd2..9e9ef82 100644 --- a/frysk-sys/lib/dwfl/Dwfl.java +++ b/frysk-sys/lib/dwfl/Dwfl.java @@ -81,16 +81,11 @@ public class Dwfl { private static native void callbacksEnd(long callbacks); public DwflLine getSourceLine (long addr) { - long val = 0; - try { - val = dwfl_getsrc(addr); - } catch (NullPointerException npe) { - System.out.println(npe.getMessage()); - val = 0; - } - if (val == 0) + DwflModule module = getModule(addr); + if (module == null) { return null; - return new DwflLine(val, this); + } + return module.getSourceLine(addr); } public DwflDie getCompilationUnit (long addr) { @@ -304,8 +299,4 @@ public class Dwfl { } return null; } - - // protected native long[] dwfl_get_modules(); - // protected native long[] dwfl_getdwarf(); - protected native long dwfl_getsrc (long addr); } diff --git a/frysk-sys/lib/dwfl/DwflLine.java b/frysk-sys/lib/dwfl/DwflLine.java index 637d33d..061e475 100644 --- a/frysk-sys/lib/dwfl/DwflLine.java +++ b/frysk-sys/lib/dwfl/DwflLine.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2005, 2007 Red Hat Inc. +// Copyright 2005, 2007, 2008 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 @@ -37,70 +37,49 @@ // version and license this file solely under the GPL without // exception. - package lib.dwfl; -public class DwflLine -{ - - private long pointer; - - private Dwfl parent; - - DwflLine (long pointer, Dwfl parent) - { - this.pointer = pointer; - this.parent = parent; - } - - public String toString() - { - return "DwflLine[0x" + Long.toHexString(getAddress()) - + " " + getSourceFile() + ":" + getLineNum() + ":" + getColumn() + "]"; - } - - public String getSourceFile () - { - return dwfl_lineinfo_source(); - } - - public long getAddress () - { - return dwfl_lineinfo_addr(); - } - - public int getLineNum () - { - return dwfl_lineinfo_linenum(); - } - - public int getColumn () - { - return dwfl_lineinfo_col(); - } - - public String getCompilationDir () - { - return dwfl_linecomp_dir(); - } - - protected long getPointer () - { - return pointer; - } - - protected Dwfl getParent () - { - return this.parent; - } - - protected native String dwfl_lineinfo_source (); - - protected native long dwfl_lineinfo_addr (); - - protected native int dwfl_lineinfo_linenum (); - - protected native int dwfl_lineinfo_col (); - - protected native String dwfl_linecomp_dir (); +public class DwflLine { + + private long pointer; + private DwflModule parent; + + DwflLine(long pointer, DwflModule parent) { + this.pointer = pointer; + this.parent = parent; + } + + DwflModule getParent() { + return parent; + } + + public String toString() { + return "DwflLine[0x" + Long.toHexString(getAddress()) + + " " + getSourceFile() + ":" + getLineNum() + ":" + getColumn() + "]"; + } + + public String getSourceFile() { + return dwfl_lineinfo_source(pointer); + } + private static native String dwfl_lineinfo_source(long pointer); + + public long getAddress() { + return dwfl_lineinfo_addr(pointer); + } + private static native long dwfl_lineinfo_addr(long pointer); + + public int getLineNum() { + return dwfl_lineinfo_linenum(pointer); + } + private static native int dwfl_lineinfo_linenum(long pointer); + + public int getColumn() { + return dwfl_lineinfo_col(pointer); + } + private native int dwfl_lineinfo_col(long pointer); + + public String getCompilationDir() { + return dwfl_line_comp_dir(pointer); + } + private native String dwfl_line_comp_dir(long pointer); } diff --git a/frysk-sys/lib/dwfl/DwflModule.java b/frysk-sys/lib/dwfl/DwflModule.java index 39cb01a..b262ec4 100644 --- a/frysk-sys/lib/dwfl/DwflModule.java +++ b/frysk-sys/lib/dwfl/DwflModule.java @@ -174,4 +174,23 @@ public class DwflModule { } private long bias = -1; private static native long dwflModuleGetBias(long pointer); + + + /** + * Return line information for the specified address. + */ + public DwflLine getSourceLine(long addr) { + try { + long dwflLinePointer = dwfl_module_getsrc(pointer, addr); + if (dwflLinePointer == 0) { + return null; + } else { + return new DwflLine(dwflLinePointer, this); + } + } catch (NullPointerException npe) { + System.out.println(npe.getMessage()); + return null; + } + } + private static native long dwfl_module_getsrc(long pointer, long addr); } diff --git a/frysk-sys/lib/dwfl/cni/Dwfl.cxx b/frysk-sys/lib/dwfl/cni/Dwfl.cxx index bba5dd0..066c5cc 100644 --- a/frysk-sys/lib/dwfl/cni/Dwfl.cxx +++ b/frysk-sys/lib/dwfl/cni/Dwfl.cxx @@ -202,8 +202,3 @@ struct ModuleAdderData DwflModuleArray *moduleArray; int index; }; - -jlong -lib::dwfl::Dwfl::dwfl_getsrc(jlong addr){ - return (jlong) ::dwfl_getsrc(DWFL_POINTER, (::Dwarf_Addr) addr); -} diff --git a/frysk-sys/lib/dwfl/cni/DwflLine.cxx b/frysk-sys/lib/dwfl/cni/DwflLine.cxx index 93df8ae..8c506e0 100644 --- a/frysk-sys/lib/dwfl/cni/DwflLine.cxx +++ b/frysk-sys/lib/dwfl/cni/DwflLine.cxx @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2005, Red Hat Inc. +// Copyright 2005, 2008, 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 @@ -36,47 +36,48 @@ // modification, you must delete this exception statement from your // version and license this file solely under the GPL without // exception. + #include #include #include #include "lib/dwfl/DwflLine.h" -#define DWFL_LINE_POINTER (::Dwfl_Line *) this->pointer +#define DWFL_LINE_POINTER ((::Dwfl_Line *) pointer) jstring -lib::dwfl::DwflLine::dwfl_lineinfo_source(){ - const char* str = ::dwfl_lineinfo(DWFL_LINE_POINTER, NULL, NULL, NULL, NULL, NULL); - return JvNewStringUTF(str); +lib::dwfl::DwflLine::dwfl_lineinfo_source(jlong pointer) { + const char* str = ::dwfl_lineinfo(DWFL_LINE_POINTER, NULL, NULL, NULL, NULL, NULL); + return JvNewStringUTF(str); } jlong -lib::dwfl::DwflLine::dwfl_lineinfo_addr(){ - Dwarf_Addr addr; - ::dwfl_lineinfo(DWFL_LINE_POINTER, &addr, NULL, NULL, NULL, NULL); - return (jlong) addr; +lib::dwfl::DwflLine::dwfl_lineinfo_addr(jlong pointer) { + Dwarf_Addr addr; + ::dwfl_lineinfo(DWFL_LINE_POINTER, &addr, NULL, NULL, NULL, NULL); + return (jlong) addr; } jint -lib::dwfl::DwflLine::dwfl_lineinfo_linenum(){ - int lineNum; - ::dwfl_lineinfo(DWFL_LINE_POINTER, NULL, &lineNum, NULL, NULL, NULL); - return (jint) lineNum; +lib::dwfl::DwflLine::dwfl_lineinfo_linenum(jlong pointer) { + int lineNum; + ::dwfl_lineinfo(DWFL_LINE_POINTER, NULL, &lineNum, NULL, NULL, NULL); + return (jint) lineNum; } jint -lib::dwfl::DwflLine::dwfl_lineinfo_col(){ - int col; - ::dwfl_lineinfo(DWFL_LINE_POINTER, NULL, NULL, &col, NULL, NULL); - return (jint) col; +lib::dwfl::DwflLine::dwfl_lineinfo_col(jlong pointer) { + int col; + ::dwfl_lineinfo(DWFL_LINE_POINTER, NULL, NULL, &col, NULL, NULL); + return (jint) col; } jstring -lib::dwfl::DwflLine::dwfl_linecomp_dir(){ - const char *dir = ::dwfl_line_comp_dir(DWFL_LINE_POINTER); - if(dir == NULL){ - return JvNewStringUTF(""); - } - return JvNewStringUTF(dir); +lib::dwfl::DwflLine::dwfl_line_comp_dir(jlong pointer) { + const char *dir = ::dwfl_line_comp_dir(DWFL_LINE_POINTER); + if(dir == NULL){ + return JvNewStringUTF(""); + } + return JvNewStringUTF(dir); } diff --git a/frysk-sys/lib/dwfl/cni/DwflModule.cxx b/frysk-sys/lib/dwfl/cni/DwflModule.cxx index 5cd51c4..ad85344 100644 --- a/frysk-sys/lib/dwfl/cni/DwflModule.cxx +++ b/frysk-sys/lib/dwfl/cni/DwflModule.cxx @@ -101,7 +101,7 @@ lib::dwfl::DwflModule::getLines(jstring filename, jint lineno, jint column) for (size_t i = 0; i < nsrcs; i++) { lib::dwfl::DwflLine *line = new lib::dwfl::DwflLine((jlong)srcsp[i], - getParent()); + this); elements(array)[i] = line; } std::free(srcsp); @@ -498,3 +498,8 @@ lib::dwfl::DwflModule::dwflModuleGetBias(jlong pointer) { else return -1; } + +jlong +lib::dwfl::DwflModule::dwfl_module_getsrc(jlong pointer, jlong addr) { + return (jlong) ::dwfl_module_getsrc(DWFL_MODULE_POINTER, (Dwarf_Addr)addr); +} diff --git a/frysk-sys/lib/dwfl/jni/Dwfl.cxx b/frysk-sys/lib/dwfl/jni/Dwfl.cxx index 50d7357..c984daa 100644 --- a/frysk-sys/lib/dwfl/jni/Dwfl.cxx +++ b/frysk-sys/lib/dwfl/jni/Dwfl.cxx @@ -185,8 +185,3 @@ lib::dwfl::Dwfl::reportModule(jnixx::env env, jlong pointer, (::Dwarf_Addr) low, (::Dwarf_Addr) high); } - -jlong -lib::dwfl::Dwfl::dwfl_getsrc(jnixx::env env, jlong addr){ - return (jlong) ::dwfl_getsrc(DWFL_POINTER_FIXME, (::Dwarf_Addr) addr); -} diff --git a/frysk-sys/lib/dwfl/jni/DwflLine.cxx b/frysk-sys/lib/dwfl/jni/DwflLine.cxx index 8a8fb5a..32d67ad 100644 --- a/frysk-sys/lib/dwfl/jni/DwflLine.cxx +++ b/frysk-sys/lib/dwfl/jni/DwflLine.cxx @@ -44,23 +44,23 @@ using namespace java::lang; -#define DWFL_LINE_POINTER ((::Dwfl_Line *) GetPointer(env)) +#define DWFL_LINE_POINTER ((::Dwfl_Line *) pointer) String -lib::dwfl::DwflLine::dwfl_lineinfo_source(jnixx::env env) { +lib::dwfl::DwflLine::dwfl_lineinfo_source(jnixx::env env, jlong pointer) { const char* str = ::dwfl_lineinfo(DWFL_LINE_POINTER, NULL, NULL, NULL, NULL, NULL); return String::NewStringUTF(env, str); } jlong -lib::dwfl::DwflLine::dwfl_lineinfo_addr(jnixx::env env) { +lib::dwfl::DwflLine::dwfl_lineinfo_addr(jnixx::env env, jlong pointer) { Dwarf_Addr addr; ::dwfl_lineinfo(DWFL_LINE_POINTER, &addr, NULL, NULL, NULL, NULL); return (jlong) addr; } jint -lib::dwfl::DwflLine::dwfl_lineinfo_linenum(jnixx::env env) { +lib::dwfl::DwflLine::dwfl_lineinfo_linenum(jnixx::env env, jlong pointer) { int lineNum; ::dwfl_lineinfo(DWFL_LINE_POINTER, NULL, &lineNum, NULL, NULL, NULL); return (jint) lineNum; @@ -68,14 +68,14 @@ lib::dwfl::DwflLine::dwfl_lineinfo_linenum(jnixx::env env) { jint -lib::dwfl::DwflLine::dwfl_lineinfo_col(jnixx::env env) { +lib::dwfl::DwflLine::dwfl_lineinfo_col(jnixx::env env, jlong pointer) { int col; ::dwfl_lineinfo(DWFL_LINE_POINTER, NULL, NULL, &col, NULL, NULL); return (jint) col; } String -lib::dwfl::DwflLine::dwfl_linecomp_dir(jnixx::env env) { +lib::dwfl::DwflLine::dwfl_line_comp_dir(jnixx::env env, jlong pointer) { const char *dir = ::dwfl_line_comp_dir(DWFL_LINE_POINTER); if(dir == NULL){ return String::NewStringUTF(env, ""); diff --git a/frysk-sys/lib/dwfl/jni/DwflModule.cxx b/frysk-sys/lib/dwfl/jni/DwflModule.cxx index 3582efe..09092ce 100644 --- a/frysk-sys/lib/dwfl/jni/DwflModule.cxx +++ b/frysk-sys/lib/dwfl/jni/DwflModule.cxx @@ -80,7 +80,7 @@ lib::dwfl::DwflModule::getLines(jnixx::env env, String jfilename, DwflLineArray array = DwflLineArray::NewObjectArray(env, nsrcs); for (size_t i = 0; i < nsrcs; i++) { lib::dwfl::DwflLine line = lib::dwfl::DwflLine::New(env, (jlong)srcsp[i], - getParent(env)); + *this); array.SetObjectArrayElement(env, i, line); line.DeleteLocalRef(env); } @@ -421,3 +421,9 @@ lib::dwfl::DwflModule::dwflModuleGetBias(jnixx::env env, jlong pointer) { else return -1; } + +jlong +lib::dwfl::DwflModule::dwfl_module_getsrc(jnixx::env env, jlong pointer, + jlong addr) { + return (jlong) ::dwfl_module_getsrc(DWFL_MODULE_POINTER, (Dwarf_Addr)addr); +} hooks/post-receive -- frysk system monitor/debugger