public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Phil Muldoon <pmuldoon@redhat.com>
Cc: frysk@sourceware.org
Subject: Re: Breakpoint stepping
Date: Thu, 05 Jul 2007 12:39:00 -0000	[thread overview]
Message-ID: <1183639162.32586.24.camel@dijkstra.wildebeest.org> (raw)
In-Reply-To: <468C7757.3050105@redhat.com>

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

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  <mwielaard@redhat.com>

        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

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

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;
   }
 
   /**

  reply	other threads:[~2007-07-05 12:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-04 18:20 Mark Wielaard
2007-07-05  4:45 ` Phil Muldoon
2007-07-05 12:39   ` Mark Wielaard [this message]
2007-07-10  9:59     ` Leaving visible breakpoints in memory/core (Was: Breakpoint stepping) Mark Wielaard
2007-07-10 13:52       ` Andrew Cagney
2007-07-10 18:06       ` Phil Muldoon
2007-07-11  9:47         ` Mark Wielaard
2007-07-12  2:49           ` Roland McGrath
2007-07-12 14:24             ` Phil Muldoon
2007-07-12 20:24               ` Roland McGrath
2007-07-16 15:57                 ` Mark Wielaard
2007-07-17 15:43                   ` Phil Muldoon
2007-07-17 17:06                     ` Mark Wielaard
2007-07-16 15:53               ` Mark Wielaard
2007-07-17 15:47                 ` Phil Muldoon
2007-07-17 17:08                   ` Mark Wielaard
2007-07-05 18:37 ` Breakpoint stepping Andrew Cagney
2007-07-23 12:19   ` Mark Wielaard
2007-07-10 10:39 ` Instruction parser (Was: Breakpoint stepping) Mark Wielaard
2007-07-10 10:50 ` Instruction breakpoint-stepping testsuite " Mark Wielaard
2007-07-16  9:19   ` [patch] " Mark Wielaard
2007-07-10 10:57 ` SSOL Area " Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1183639162.32586.24.camel@dijkstra.wildebeest.org \
    --to=mark@klomp.org \
    --cc=frysk@sourceware.org \
    --cc=pmuldoon@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).