[SCM] master: frysk-core/frysk/hpd/ChangeLog
cagney@sourceware.org
cagney@sourceware.org
Mon Feb 25 17:17:00 GMT 2008
The branch, master has been updated
via cc4b69ddad67f0d3efcb1574f32f37d0ad3e92e6 (commit)
from 8ae8b5bbf07d2a0dde2b5db8bcf01199e3ea2ced (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit cc4b69ddad67f0d3efcb1574f32f37d0ad3e92e6
Author: Andrew Cagney <cagney@redhat.com>
Date: Mon Feb 25 12:15:29 2008 -0500
frysk-core/frysk/hpd/ChangeLog
2008-02-25 Andrew Cagney <cagney@redhat.com>
* LoadCommand.java: Use LinuxExeFactory.
frysk-core/frysk/proc/dead/ChangeLog
2008-02-25 Andrew Cagney <cagney@redhat.com>
* LinuxExeFactory.java: New. Merge in LinuxExeHost, LinuxExeProc,
and LinuxExeTask.
* LinuxExeHost.java: Simplify.
* LinuxExeProc.java: Simplify.
* LinuxExeTask.java: Simplify.
* ExeByteBuffer.java (ExeByteBuffer(MemoryMap[])): Replace
ExeByteBuffer(ArrayList).
* TestLinuxExe.java: Update.
frysk-core/frysk/util/ChangeLog
2008-02-25 Andrew Cagney <cagney@redhat.com>
* ProcStopUtil.java: Use LinuxExeFactory.
-----------------------------------------------------------------------
Summary of changes:
frysk-core/frysk/hpd/ChangeLog | 4 +
frysk-core/frysk/hpd/LoadCommand.java | 11 +--
frysk-core/frysk/proc/dead/ChangeLog | 11 +++
frysk-core/frysk/proc/dead/ExeByteBuffer.java | 53 +++++-------
.../{LinuxExeTask.java => LinuxExeFactory.java} | 85 ++++++++----------
frysk-core/frysk/proc/dead/LinuxExeHost.java | 92 ++------------------
frysk-core/frysk/proc/dead/LinuxExeProc.java | 67 ++++-----------
frysk-core/frysk/proc/dead/LinuxExeTask.java | 35 ++------
frysk-core/frysk/proc/dead/TestLinuxExe.java | 75 ++--------------
frysk-core/frysk/util/ChangeLog | 4 +
frysk-core/frysk/util/ProcStopUtil.java | 7 +-
11 files changed, 128 insertions(+), 316 deletions(-)
copy frysk-core/frysk/proc/dead/{LinuxExeTask.java => LinuxExeFactory.java} (61%)
First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 7862c42..fc9b4d7 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-25 Andrew Cagney <cagney@redhat.com>
+
+ * LoadCommand.java: Use LinuxExeFactory.
+
2008-02-21 Nurdin Premji <npremji@redhat.com>
* StepCommand.java (StepCommand): Added -instruction parameter.
diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java
index bbd9893..4bc03ae 100644
--- a/frysk-core/frysk/hpd/LoadCommand.java
+++ b/frysk-core/frysk/hpd/LoadCommand.java
@@ -40,16 +40,12 @@
package frysk.hpd;
import java.io.File;
-//import java.util.HashMap;
import java.util.Iterator;
-//import java.util.Map;
-//import java.util.Set;
+import frysk.proc.dead.LinuxExeFactory;
import frysk.debuginfo.DebugInfo;
import frysk.debuginfo.DebugInfoFrame;
import frysk.debuginfo.DebugInfoStackFactory;
import frysk.dwfl.DwflCache;
-import frysk.proc.Host;
-import frysk.proc.dead.LinuxExeHost;
import frysk.proc.Manager;
import frysk.proc.Proc;
import frysk.proc.Task;
@@ -112,8 +108,9 @@ public class LoadCommand extends ParameterizedCommand {
("File does not exist or is not readable or is not a file.");
}
- Host exeHost = new LinuxExeHost(Manager.eventLoop, executableFile);
- Proc exeProc = frysk.util.Util.getProcFromExeFile(exeHost);
+ Proc exeProc = LinuxExeFactory.createProc(Manager.eventLoop,
+ executableFile,
+ cmd.stringArrayValue());
int procID;
if (cli.taskID < 0)
diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog
index a79fb3b..f09f868 100644
--- a/frysk-core/frysk/proc/dead/ChangeLog
+++ b/frysk-core/frysk/proc/dead/ChangeLog
@@ -1,3 +1,14 @@
+2008-02-25 Andrew Cagney <cagney@redhat.com>
+
+ * LinuxExeFactory.java: New. Merge in LinuxExeHost, LinuxExeProc,
+ and LinuxExeTask.
+ * LinuxExeHost.java: Simplify.
+ * LinuxExeProc.java: Simplify.
+ * LinuxExeTask.java: Simplify.
+ * ExeByteBuffer.java (ExeByteBuffer(MemoryMap[])): Replace
+ ExeByteBuffer(ArrayList).
+ * TestLinuxExe.java: Update.
+
2008-02-20 Andrew Cagney <cagney@redhat.com>
* LinuxExeProc.java (sendRefresh()): Delete.
diff --git a/frysk-core/frysk/proc/dead/ExeByteBuffer.java b/frysk-core/frysk/proc/dead/ExeByteBuffer.java
index cde7b8d..59f6d09 100644
--- a/frysk-core/frysk/proc/dead/ExeByteBuffer.java
+++ b/frysk-core/frysk/proc/dead/ExeByteBuffer.java
@@ -1,6 +1,6 @@
// This file is part of the program FRYSK.
//
-// Copyright 2007, Red Hat Inc.
+// Copyright 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
@@ -40,52 +40,41 @@
package frysk.proc.dead;
import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-
import frysk.sys.StatelessFile;
import frysk.proc.MemoryMap;
-
import inua.eio.ByteBuffer;
public class ExeByteBuffer extends ByteBuffer {
- ArrayList metaData = new ArrayList();
+ private final MemoryMap[] memoryMaps;
+ private final StatelessFile[] statelessFiles;
+ private final byte[] buffer = new byte[1];
- protected ExeByteBuffer(long lowWater, long highWater) {
- super(lowWater, highWater);
- }
-
- public ExeByteBuffer(ArrayList metaData)
- {
+ public ExeByteBuffer(MemoryMap[] memoryMaps) {
super(0,-1);
-
- this.metaData = metaData;
+ this.memoryMaps = memoryMaps;
+ this.statelessFiles = new StatelessFile[memoryMaps.length];
}
protected int peek(long caret) {
-
- Iterator i = metaData.iterator();
- MemoryMap line = null;
long offset = -1;
- byte[] buffer = new byte[1];
-
- while (i.hasNext())
- {
- line = ((MemoryMap)i.next());
- if ((caret >= line.addressLow) && (caret<= line.addressHigh))
- {
- offset = line.offset + (caret - line.addressLow);
- break;
- }
+ int i;
+ MemoryMap line = null;
+ for (i = 0; i < memoryMaps.length; i++) {
+ line = memoryMaps[i];
+ if ((caret >= line.addressLow) && (caret<= line.addressHigh)) {
+ offset = line.offset + (caret - line.addressLow);
+ break;
+ }
}
-
- if (offset == -1)
+ if (i >= memoryMaps.length)
throw new RuntimeException("Cannot find memory in exe file");
-
- StatelessFile temp = new StatelessFile(new File(line.name));
+ StatelessFile temp = statelessFiles[i];
+ if (temp == null) {
+ temp = new StatelessFile(new File(line.name));
+ statelessFiles[i] = temp;
+ }
temp.pread(offset, buffer,0,1);
-
return buffer[0];
}
diff --git a/frysk-core/frysk/proc/dead/LinuxExeTask.java b/frysk-core/frysk/proc/dead/LinuxExeFactory.java
similarity index 61%
copy from frysk-core/frysk/proc/dead/LinuxExeTask.java
copy to frysk-core/frysk/proc/dead/LinuxExeFactory.java
index 4d90354..28d0082 100644
--- a/frysk-core/frysk/proc/dead/LinuxExeTask.java
+++ b/frysk-core/frysk/proc/dead/LinuxExeFactory.java
@@ -39,59 +39,50 @@
package frysk.proc.dead;
-import inua.eio.ArrayByteBuffer;
-import inua.eio.ByteBuffer;
-import frysk.isa.banks.RegisterBanks;
-import frysk.isa.ISA;
+import java.io.File;
+import java.util.List;
+import java.util.LinkedList;
import lib.dwfl.Elf;
import lib.dwfl.ElfCommand;
import lib.dwfl.ElfEHeader;
-import lib.dwfl.ElfException;
-import java.io.File;
-
-public class LinuxExeTask extends DeadTask {
- private final long pc;
- private final LinuxExeProc proc;
+import frysk.proc.MemoryMap;
+import frysk.event.EventLoop;
- LinuxExeTask(LinuxExeProc proc, ISA isa) {
- super(proc, 0, isa, constructRegisterBanks(isa));
- this.proc = proc;
- // Compute a Fake PC. XXX should be done in Proc instead of
- // creating Elf object in the Task itself.
- Elf e = null;
- long pc;
+public class LinuxExeFactory {
+ public static LinuxExeProc createProc(EventLoop eventLoop,
+ final File exeFile,
+ String[] args) {
+ Elf exeElf = null;
try {
- e = new Elf(new File(getProc().getExe()), ElfCommand.ELF_C_READ);
- ElfEHeader h = e.getEHeader();
- pc = h.entry;
- } catch (ElfException ee) {
- // Nice try, just give up.
- pc = 0;
+ exeElf = new Elf(exeFile, ElfCommand.ELF_C_READ);
+ ElfEHeader eHeader = exeElf.getEHeader();
+ class BuildExeMaps extends SOLibMapBuilder {
+ private final List metaData = new LinkedList();
+ public void buildMap(long addrLow, long addrHigh, boolean permRead,
+ boolean permWrite, boolean permExecute,
+ long offset, String name, long align) {
+ metaData.add(new MemoryMap(addrLow, addrHigh, permRead,
+ permWrite, permExecute, false,
+ offset, -1, -1, -1, -1, -1,
+ exeFile.getAbsolutePath()));
+ }
+ MemoryMap[] getMemoryMaps() {
+ MemoryMap[] memoryMaps = new MemoryMap[metaData.size()];
+ metaData.toArray(memoryMaps);
+ return memoryMaps;
+ }
+ }
+ BuildExeMaps SOMaps = new BuildExeMaps();
+ // Add in case for executables maps.
+ SOMaps.construct(exeFile, 0);
+
+ LinuxExeHost host
+ = new LinuxExeHost(exeFile, eHeader, SOMaps.getMemoryMaps(),
+ args);
+ return host.getProc();
} finally {
- if (e != null)
- e.close();
+ if (exeElf != null)
+ exeElf.close();
}
- this.pc = pc;
- }
-
- public long getPC() {
- return pc;
- }
-
- public ByteBuffer getMemory() {
- return proc.getMemory();
}
-
- private static RegisterBanks constructRegisterBanks(ISA isa) {
- ByteBuffer[] bankBuffers = new ByteBuffer[4];
- // Create an empty page
- byte[] emptyBuffer = new byte[4096];
- for (int i = 0; i < emptyBuffer.length; i++)
- emptyBuffer[i] = 0;
- bankBuffers[0] = new ArrayByteBuffer(emptyBuffer);
- bankBuffers[1] = new ArrayByteBuffer(emptyBuffer);
- bankBuffers[2] = new ArrayByteBuffer(emptyBuffer);
- bankBuffers[3] = new ArrayByteBuffer(emptyBuffer);
- return CorefileRegisterBanksFactory.create(isa, bankBuffers);
- }
}
diff --git a/frysk-core/frysk/proc/dead/LinuxExeHost.java b/frysk-core/frysk/proc/dead/LinuxExeHost.java
index 7dd7431..a9932e0 100644
--- a/frysk-core/frysk/proc/dead/LinuxExeHost.java
+++ b/frysk-core/frysk/proc/dead/LinuxExeHost.java
@@ -40,100 +40,24 @@
package frysk.proc.dead;
import java.io.File;
-import java.util.Iterator;
-import java.util.List;
-import java.util.LinkedList;
-
-import lib.dwfl.Elf;
-import lib.dwfl.ElfCommand;
-import lib.dwfl.ElfData;
import lib.dwfl.ElfEHeader;
-import lib.dwfl.ElfPHeader;
-
-import frysk.event.EventLoop;
-import frysk.proc.Proc;
-import frysk.proc.ProcId;
+import frysk.proc.MemoryMap;
public class LinuxExeHost extends DeadHost {
-
- protected File exeFile = null;
- EventLoop eventLoop = null;
- Elf exeFileElf = null;
+ private final File exeFile;
+ private final LinuxExeProc proc;
- public LinuxExeHost(EventLoop eventLoop, File exeFile) {
+ LinuxExeHost(File exeFile, ElfEHeader eHeader, MemoryMap[] memoryMaps,
+ String[] args) {
this.exeFile = exeFile;
- this.eventLoop = eventLoop;
- this.exeFileElf = new Elf(exeFile, ElfCommand.ELF_C_READ);
- // Iterate (build) the /proc tree, passing each found PID to
- // procChanges where it can update the /proc tree.
- // Changes individual process.
- new DeconstructExeFile(this.exeFileElf);
- for (Iterator i = procPool.values().iterator(); i.hasNext();) {
- LinuxExeProc proc = (LinuxExeProc) i.next();
- proc.sendRefresh();
- }
- }
-
- private class DeconstructExeFile
- {
- List addedProcs = new LinkedList();
- Elf exeFileElf;
- ElfData noteData = null;
-
- DeconstructExeFile(Elf exeFileElf)
- {
- this.exeFileElf = exeFileElf;
- ElfEHeader eHeader = this.exeFileElf.getEHeader();
-
- // Get number of program header entries.
- long phSize = eHeader.phnum;
- for (int i=0; i<phSize; i++)
- {
- // Test if pheader is of types notes..
- ElfPHeader pHeader = exeFileElf.getPHeader(i);
- if (pHeader.type == ElfPHeader.PTYPE_NOTE)
- {
- // if so, copy, break and leave.
- noteData = exeFileElf.getRawData(pHeader.offset,pHeader.filesz);
- break;
- }
- }
-
- if (noteData != null)
- update(noteData);
- }
-
- Proc update (ElfData proc_pid)
- {
- final ProcId procId = new ProcId(0);
- // Currently there can only be one process per core file.
- // What happens when we have two core files denoting the same
- // process/pid? Leave the test here for now.
-
- Proc proc = (Proc) procPool.get(procId);
- if (proc == null)
- {
- // executable file processes have no parents as thy are captured
- // in isolation, and reconstructed.
- proc = new LinuxExeProc(proc_pid,LinuxExeHost.this);
- }
-
- addedProcs.add(proc);
-
- return proc;
- }
+ proc = new LinuxExeProc(this, exeFile, eHeader, memoryMaps, args);
}
public String getName() {
return exeFile.getName();
}
- /**
- * finalize closes the file descriptor for the executable.
- */
- protected void finalize()
- {
- this.exeFileElf.close();
+ LinuxExeProc getProc() {
+ return proc;
}
-
}
diff --git a/frysk-core/frysk/proc/dead/LinuxExeProc.java b/frysk-core/frysk/proc/dead/LinuxExeProc.java
index 4732d0e..9616965 100644
--- a/frysk-core/frysk/proc/dead/LinuxExeProc.java
+++ b/frysk-core/frysk/proc/dead/LinuxExeProc.java
@@ -39,50 +39,45 @@
package frysk.proc.dead;
-import inua.eio.ByteBuffer;
-
-import java.util.ArrayList;
-import lib.dwfl.ElfData;
-
-import frysk.isa.ISA;
-import frysk.isa.ElfMap;
+import lib.dwfl.ElfEHeader;
import frysk.proc.Auxv;
import frysk.proc.MemoryMap;
+import java.io.File;
public class LinuxExeProc extends DeadProc {
- private ElfData elfData = null;
- ArrayList metaData = new ArrayList();
- LinuxExeHost host = null;
+ private final MemoryMap[] memoryMaps;
+ private final String[] argv;
+ private final File exeFile;
- public LinuxExeProc(ElfData data, LinuxExeHost host) {
+ public LinuxExeProc(LinuxExeHost host, File exeFile, ElfEHeader eHeader,
+ MemoryMap[] memoryMaps, String[] argv) {
super(host, null, 0);
- this.host = host;
- this.elfData = data;
- sendRefresh();
- ISA isa = ElfMap.getISA(elfData.getParent().getEHeader());
- new LinuxExeTask(this, isa);
- buildMetaData();
+ this.exeFile = exeFile;
+ this.memoryMaps = memoryMaps;
+ this.argv = argv;
+ new LinuxExeTask(this, eHeader, memoryMaps);
}
public Auxv[] getAuxv() {
- return null;
+ return auxv;
}
+ private final Auxv[] auxv = new Auxv[0];
public int getUID() {
return 0;
}
public String[] getCmdLine() {
- return null;
+ return argv;
}
public String getCommand() {
- return this.host.exeFile.getName();
+ return exeFile.getName();
}
public String getExe() {
- return host.exeFile.getAbsolutePath();
+ return exeFile.getAbsolutePath();
}
public int getGID() {
@@ -90,34 +85,6 @@ public class LinuxExeProc extends DeadProc {
}
public MemoryMap[] getMaps() {
- return (MemoryMap[]) metaData.toArray(new MemoryMap[metaData.size()]);
- }
-
- ByteBuffer getMemory() {
- if (memory == null)
- memory = new ExeByteBuffer(metaData);
- return memory;
+ return memoryMaps;
}
- private ByteBuffer memory;
-
- private void buildMetaData()
- {
- class BuildExeMaps extends SOLibMapBuilder
-
- {
- public void buildMap(long addrLow, long addrHigh, boolean permRead,
- boolean permWrite, boolean permExecute, long offset,
- String name, long align)
- {
- metaData.add(new MemoryMap(addrLow, addrHigh, permRead,
- permWrite, permExecute, false, offset, -1, -1, -1, -1, -1,
- host.exeFile.getAbsolutePath()));
- }
- }
-
- BuildExeMaps SOMaps = new BuildExeMaps();
- // Add in case for executables maps.
- SOMaps.construct(this.host.exeFile, 0);
- }
-
}
diff --git a/frysk-core/frysk/proc/dead/LinuxExeTask.java b/frysk-core/frysk/proc/dead/LinuxExeTask.java
index 4d90354..a762769 100644
--- a/frysk-core/frysk/proc/dead/LinuxExeTask.java
+++ b/frysk-core/frysk/proc/dead/LinuxExeTask.java
@@ -43,35 +43,20 @@ import inua.eio.ArrayByteBuffer;
import inua.eio.ByteBuffer;
import frysk.isa.banks.RegisterBanks;
import frysk.isa.ISA;
-import lib.dwfl.Elf;
-import lib.dwfl.ElfCommand;
import lib.dwfl.ElfEHeader;
-import lib.dwfl.ElfException;
-import java.io.File;
+import frysk.isa.ElfMap;
+import frysk.proc.MemoryMap;
public class LinuxExeTask extends DeadTask {
private final long pc;
- private final LinuxExeProc proc;
+ private final ByteBuffer memory;
- LinuxExeTask(LinuxExeProc proc, ISA isa) {
- super(proc, 0, isa, constructRegisterBanks(isa));
- this.proc = proc;
- // Compute a Fake PC. XXX should be done in Proc instead of
hooks/post-receive
--
frysk system monitor/debugger
More information about the Frysk-cvs
mailing list