From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3051 invoked by alias); 5 Jul 2007 12:39:32 -0000 Received: (qmail 3013 invoked by uid 22791); 5 Jul 2007 12:39:30 -0000 X-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,FORGED_RCVD_HELO 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; Thu, 05 Jul 2007 12:39:26 +0000 Received: from dijkstra.wildebeest.org ([192.168.1.29]) by gnu.wildebeest.org with esmtp (Exim 4.43) id 1I6Qed-0006Rc-1R; Thu, 05 Jul 2007 14:41:52 +0200 Subject: Re: Breakpoint stepping From: Mark Wielaard To: Phil Muldoon Cc: frysk@sourceware.org In-Reply-To: <468C7757.3050105@redhat.com> References: <1183573205.3598.157.camel@dijkstra.wildebeest.org> <468C7757.3050105@redhat.com> Content-Type: multipart/mixed; boundary="=-aqo7mgRxgiZtRKq0lTMU" Date: Thu, 05 Jul 2007 12:39:00 -0000 Message-Id: <1183639162.32586.24.camel@dijkstra.wildebeest.org> Mime-Version: 1.0 X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) X-Spam-Score: -4.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-q3/txt/msg00024.txt.bz2 --=-aqo7mgRxgiZtRKq0lTMU Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 2815 Hi Phil, On Wed, 2007-07-04 at 23:45 -0500, Phil Muldoon wrote: > I'm still reading the rest of your email (the state machine changes I'm > still trying to understand). Please ask, I might not explain them right, or maybe they are really not that clear/well done in the first place. > Is the above entry point code similar too getting the Entry Point from > the process auxiliary? Cool! That is so much easier than what I was doing. Thanks, I didn't even know the auxiliary vector of a proc contained the entry point. Tested on x86 and x86_64 (and also added to powerpc now, even though I cannot test it and powerpc would need some other fixes to fully support ssol) and it works like a charm. Much nicer than mucking through the Elf image by hand. 2007-07-05 Mark Wielaard IsaIA32.java (getOutOfLineAddresses): Use Auxv entry point. IsaPowerPC.java (getOutOfLineAddresses): Likewise. IsaX8664.java (getOutOfLineAddresses): Likewise. I have to post more code to the list I see. You triggered on actual code instead of all the explanation of what it is all supposed to do. It is probably time to introduce a frysk-patches list to discuss actual patches a bit more (clicking through on the commit list URLs and trying to figure out what/why a change was made is pretty hard). > I agree on the main() entry-point being a good first step to as a usable > space, though I wonder how that would look in a corefile. Isn't that what ElfPrAuxv represents? But it might be wrong to have this in the Isa in the first place. It is probably a property of the Proc, not of the Isa. When I cleanup the outOfLineAddresses storage that you pointed out in the previous review I'll try to move this at the same time. > Though I > suspect if you are dumping core while stepping a process one is in > deeper trouble than one suspects ;) I admit to not have thought of this scenario. That is indeed troublesome since some breakpoints might actually still be embedded in the Proc code memory while the kernel writes out the core file. Have to think about that. What scenarios are there for a process to dump core? And is there any way for us to intercept and quickly remove any changes we done to the code segments before that? > One of the other ideas was creating > a custom solib and using it's address space to store the stuff needed. > All this sounds hacky though. I vaguely recall a discussion to how > uprobes does something similar by mapping in a page from somewhere? Do > you remember any of that stuff? uprobes has the kernel to help. So they just allocate a whole new VM area. We would have to somehow trigger a dummy shared library load inside the inferior (and hope it doesn't interfere with anything the process is doing at the time). Cheers, Mark --=-aqo7mgRxgiZtRKq0lTMU Content-Disposition: inline; filename=auxv.patch Content-Type: text/x-patch; name=auxv.patch; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 4960 Index: frysk-core/frysk/proc/IsaIA32.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/IsaIA32.java,v retrieving revision 1.25 diff -u -r1.25 IsaIA32.java --- frysk-core/frysk/proc/IsaIA32.java 3 Jul 2007 18:16:04 -0000 1.25 +++ frysk-core/frysk/proc/IsaIA32.java 5 Jul 2007 12:26:03 -0000 @@ -42,6 +42,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import inua.eio.ByteOrder; import lib.unwind.RegisterX86; @@ -51,15 +52,8 @@ import frysk.proc.live.RegisterSetByteBuffer; import frysk.proc.live.AddressSpaceByteBuffer; -import lib.elf.Elf; -import lib.elf.ElfCommand; -import lib.elf.ElfException; import lib.elf.ElfEMachine; -import lib.dw.Dwarf; -import lib.dw.DwarfCommand; -import lib.dw.DwarfDie; - public class IsaIA32 implements Isa { /** @@ -293,7 +287,7 @@ */ public long getBreakpointAddress(Task task) { - long pcValue = 0; + long pcValue; pcValue = this.pc(task); pcValue = pcValue - 1; @@ -308,21 +302,15 @@ */ public List getOutOfLineAddresses(Proc proc) { - String func = "main"; - try - { - Elf elf = new Elf(proc.getExe(), ElfCommand.ELF_C_READ); - Dwarf dwarf = new Dwarf(elf, DwarfCommand.READ, null); - DwarfDie die = DwarfDie.getDecl(dwarf, func); - return die.getEntryBreakpoints(); - } - catch (ElfException ee) + LinkedList addrs = new LinkedList(); + Auxv[] auxv = proc.getAuxv (); + // Find the Auxv ENTRY data + for (int i = 0; i < auxv.length; i++) { - IllegalStateException ise; - ise = new IllegalStateException("Unable to get at " + func); - ise.initCause(ee); - throw ise; + if (auxv[i].type == inua.elf.AT.ENTRY) + addrs.add(Long.valueOf(auxv[i].val)); } + return addrs; } /** Index: frysk-core/frysk/proc/IsaPowerPC.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/IsaPowerPC.java,v retrieving revision 1.9 diff -u -r1.9 IsaPowerPC.java --- frysk-core/frysk/proc/IsaPowerPC.java 2 Jul 2007 14:40:17 -0000 1.9 +++ frysk-core/frysk/proc/IsaPowerPC.java 5 Jul 2007 12:26:03 -0000 @@ -1,6 +1,7 @@ // This file is part of the program FRYSK. // // Copyright 2006 IBM Corp. +// 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 @@ -41,6 +42,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import inua.eio.ByteBuffer; import frysk.proc.live.AddressSpaceByteBuffer; @@ -102,7 +104,15 @@ public List getOutOfLineAddresses(Proc proc) { - throw new IllegalStateException("getOutOfLineAddresses not implemented"); + LinkedList addrs = new LinkedList(); + Auxv[] auxv = proc.getAuxv (); + // Find the Auxv ENTRY data + for (int i = 0; i < auxv.length; i++) + { + if (auxv[i].type == inua.elf.AT.ENTRY) + addrs.add(Long.valueOf(auxv[i].val)); + } + return addrs; } /** Index: frysk-core/frysk/proc/IsaX8664.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/proc/IsaX8664.java,v retrieving revision 1.17 diff -u -r1.17 IsaX8664.java --- frysk-core/frysk/proc/IsaX8664.java 3 Jul 2007 18:16:04 -0000 1.17 +++ frysk-core/frysk/proc/IsaX8664.java 5 Jul 2007 12:26:03 -0000 @@ -42,6 +42,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import inua.eio.ByteOrder; import inua.eio.ByteBuffer; @@ -50,16 +51,9 @@ import frysk.proc.live.RegisterSetByteBuffer; import frysk.proc.live.AddressSpaceByteBuffer; -import lib.elf.Elf; -import lib.elf.ElfCommand; -import lib.elf.ElfException; import lib.elf.ElfEMachine; import lib.unwind.RegisterAMD64; -import lib.dw.Dwarf; -import lib.dw.DwarfCommand; -import lib.dw.DwarfDie; - public class IsaX8664 implements Isa { @@ -305,21 +299,15 @@ */ public List getOutOfLineAddresses(Proc proc) { - String func = "main"; - try - { - Elf elf = new Elf(proc.getExe(), ElfCommand.ELF_C_READ); - Dwarf dwarf = new Dwarf(elf, DwarfCommand.READ, null); - DwarfDie die = DwarfDie.getDecl(dwarf, func); - return die.getEntryBreakpoints(); - } - catch (ElfException ee) + LinkedList addrs = new LinkedList(); + Auxv[] auxv = proc.getAuxv (); + // Find the Auxv ENTRY data + for (int i = 0; i < auxv.length; i++) { - IllegalStateException ise; - ise = new IllegalStateException("Unable to get at " + func); - ise.initCause(ee); - throw ise; + if (auxv[i].type == inua.elf.AT.ENTRY) + addrs.add(Long.valueOf(auxv[i].val)); } + return addrs; } /** --=-aqo7mgRxgiZtRKq0lTMU--