From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1603 invoked by alias); 23 Nov 2007 11:35:37 -0000 Received: (qmail 1592 invoked by uid 22791); 23 Nov 2007 11:35:37 -0000 X-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,FORGED_RCVD_HELO,WLS_URI_OPT_0 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; Fri, 23 Nov 2007 11:35:33 +0000 Received: from dijkstra.wildebeest.org ([192.168.1.29]) by gnu.wildebeest.org with esmtp (Exim 4.63) (envelope-from ) id 1IvWok-00060q-3W; Fri, 23 Nov 2007 12:35:30 +0100 Subject: Quick pc hack for exe loading From: Mark Wielaard To: frysk@sourceware.org Cc: rmosely@redhat.com Content-Type: multipart/mixed; boundary="=-IrEgnAOr43kz5jfBisGh" Date: Fri, 23 Nov 2007 11:35:00 -0000 Message-Id: <1195817730.2981.21.camel@dijkstra.wildebeest.org> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 (2.12.1-3.fc8) X-Spam-Score: -1.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-q4/txt/msg00169.txt.bz2 --=-IrEgnAOr43kz5jfBisGh Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1070 Hi Rick, I wanted to test some libunwind lookup changes I made locally and the exe target is nice for that since it is so simple. The attached patch sets up the PC value and makes it possible to see where the exe would start: (fhpd) load /bin/bash Loaded executable file: /bin/bash (fhpd) where [0.0] DebugInfoStackFactory.printStackTrace() numberOfFrames 0 #0 0x0000000000419150 in _start () from /bin/bash It still cannot actually do the other way around though: (fhpd) print _start [0.0] Error: Object _start was not found Haven't looked into why that was since I was only interested in the stack thing. 2007-11-23 Mark Wielaard * LinuxExeTask.java (bankBuffers): New final field. (LinuxExeTask): Setup bankBuffers and explicitly set pc. (sendrecRegisterBanks): Use cached bankBuffers. It is a bit of a hack (as the comment explains), but it seems to work great and all tests still pass with this applied. Feel free to rip it out and completely replace with a real, less hacky, solution though. Cheers, Mark --=-IrEgnAOr43kz5jfBisGh Content-Disposition: inline; filename=exe-pc.patch Content-Type: text/x-patch; name=exe-pc.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 1541 diff --git a/frysk-core/frysk/proc/dead/LinuxExeTask.java b/frysk-core/frysk/proc/dead/LinuxExeTask.java index 3eb584c..1302be5 100644 --- a/frysk-core/frysk/proc/dead/LinuxExeTask.java +++ b/frysk-core/frysk/proc/dead/LinuxExeTask.java @@ -47,17 +47,44 @@ import frysk.proc.TaskId; import frysk.proc.TaskState; import frysk.isa.ISA; +import lib.dwfl.*; public class LinuxExeTask extends DeadTask { LinuxExeProc proc = null; TaskId id = null; + + // Holds all the register values, setup once in the constructor. + private final ByteBuffer[] bankBuffers; protected LinuxExeTask(LinuxExeProc proc, TaskId id, TaskState state) { super(proc, id, state); this.proc = proc; this.id = id; + this.bankBuffers = sendrecRegisterBuffersFIXME(); + + // Fake PC. XXX should be done in Proc instead of creating Elf + // object in the Task itself. + long pc; + Elf e = null; + try + { + e = new Elf(getProc().getExe(), ElfCommand.ELF_C_READ); + ElfEHeader h = e.getEHeader(); + pc = h.entry; + } + catch (ElfException ee) + { + // Nice try, just give up. + pc = 0; + } + finally + { + if (e != null) + e.close(); + } + getIsa().setPC(this, pc); } protected ISA sendrecISA() { @@ -93,6 +120,6 @@ public class LinuxExeTask extends DeadTask protected RegisterBanks sendrecRegisterBanks() { return CorefileRegisterBanksFactory.create - (getISA(), sendrecRegisterBuffersFIXME()); + (getISA(), bankBuffers); } } --=-IrEgnAOr43kz5jfBisGh--