public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: pmuldoon@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Add frysk.rsl loggin. Date: Tue, 12 Feb 2008 20:03:00 -0000 [thread overview] Message-ID: <20080212200324.2256.qmail@sourceware.org> (raw) The branch, master has been updated via 26e3bdf51680d9aea0dac71a9813543f3e1e1f49 (commit) from 34a1f7390e8fbdac0f50d42b6ac21829be6ef993 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 26e3bdf51680d9aea0dac71a9813543f3e1e1f49 Author: Phil Muldoon <pmuldoon@redhat.com> Date: Tue Feb 12 20:03:13 2008 +0000 Add frysk.rsl loggin. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/proc/dead/CorefileByteBuffer.java | 29 ++++- frysk-core/frysk/proc/dead/LinuxCoreHost.java | 5 +- frysk-core/frysk/proc/dead/LinuxCoreProc.java | 120 ++++++++++++++++---- frysk-core/frysk/proc/dead/LinuxCoreTask.java | 4 + 4 files changed, 129 insertions(+), 29 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/proc/dead/CorefileByteBuffer.java b/frysk-core/frysk/proc/dead/CorefileByteBuffer.java index 3ef2164..ca2fa92 100644 --- a/frysk-core/frysk/proc/dead/CorefileByteBuffer.java +++ b/frysk-core/frysk/proc/dead/CorefileByteBuffer.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 @@ -53,6 +53,7 @@ import lib.dwfl.ElfPHeader; import inua.eio.ByteBuffer; import inua.eio.ByteOrder; +import frysk.rsl.Log; public class CorefileByteBuffer extends ByteBuffer @@ -65,6 +66,8 @@ public class CorefileByteBuffer File exeFile = null; StatelessFile coreFileRaw = null; boolean fileOpen = false; + + private static final Log finest = Log.finest(CorefileByteBuffer.class); private CorefileByteBuffer(File file, long lowerExtreem, long upperExtreem, @@ -104,6 +107,8 @@ public class CorefileByteBuffer protected int peek(long address) { + + finest.log(this,"peek() address 0x" + Long.toHexString(address)); byte[] buffer = new byte[1]; MapAddressHeader metaLine = findMetaData(address); @@ -120,6 +125,10 @@ public class CorefileByteBuffer StatelessFile temp = new StatelessFile(new File(metaLine.name)); long offset = metaLine.solibOffset + (address - metaLine.vaddr); temp.pread(offset, buffer,0,1); + finest.log(this,"peek'ed() 0x"+Integer.toHexString(buffer[0] & 0xff) + + " from address 0x"+Long.toHexString(address) + + " offset 0x"+Long.toHexString(offset) + + " from file: " +metaLine.name); } } @@ -180,18 +189,28 @@ public class CorefileByteBuffer data = offsetList[i]; if ((address >= data.vaddr) && - (address <= (data.vaddr_end))) + (address <= (data.vaddr_end))) { + finest.log(this, "findMetaData() memory location 0x" + + Long.toHexString(address)+ " found at " + + "0x"+Long.toHexString(data.vaddr)+"-"+ + "0x"+Long.toHexString(data.vaddr_end)+ + " Name: "+data.name); + return data; + } } + finest.log(this, "findMetaData() cannot find metadata for addr 0x"+Long.toHexString(address)); return null; } private boolean checkCorefileAddress(MapAddressHeader data) { + boolean isCoreFile = false; if (data.fileSize > 0) - return true; - else - return false; + isCoreFile = true; + + finest.log(this,"checkCorefileAddress()= " + isCoreFile); + return isCoreFile; } diff --git a/frysk-core/frysk/proc/dead/LinuxCoreHost.java b/frysk-core/frysk/proc/dead/LinuxCoreHost.java index 926175a..3af1cc7 100644 --- a/frysk-core/frysk/proc/dead/LinuxCoreHost.java +++ b/frysk-core/frysk/proc/dead/LinuxCoreHost.java @@ -110,8 +110,9 @@ public class LinuxCoreHost extends DeadHost { if (exeSetToNull == false) if (exeFile.canRead() && exeFile.exists()) { try { - this.exeFile = exeFile.getCanonicalFile(); - } catch (IOException e) { + //this.exeFile = exeFile.getCanonicalFile(); + this.exeFile = exeFile; + } catch (Exception e) { status.hasExe = false; status.hasExeProblem = true; } diff --git a/frysk-core/frysk/proc/dead/LinuxCoreProc.java b/frysk-core/frysk/proc/dead/LinuxCoreProc.java index bfd753c..09f0b44 100644 --- a/frysk-core/frysk/proc/dead/LinuxCoreProc.java +++ b/frysk-core/frysk/proc/dead/LinuxCoreProc.java @@ -61,6 +61,7 @@ import frysk.proc.Auxv; import frysk.proc.MemoryMap; import frysk.isa.ISA; import frysk.isa.ElfMap; +import frysk.rsl.Log; public class LinuxCoreProc extends DeadProc { @@ -73,10 +74,13 @@ public class LinuxCoreProc extends DeadProc { // Segment and solib metadata private MapAddressHeader metaData[]; private boolean metaDataBuilt = false; + + private static final Log fine = Log.fine(LinuxCoreProc.class); public LinuxCoreProc(ElfData data, LinuxCoreHost host, ProcId procId ) { super(host, null, procId); + fine.log(this, "LinuxCoreProc(ElfData, LinuxCoreHost, ProcId)"); this.elfData = data; this.elfProc = ElfPrpsinfo.decode(elfData); this.corefileBackEnd = host.coreFile; @@ -93,28 +97,36 @@ public class LinuxCoreProc extends DeadProc { } public String getCommand() { + fine.log(this,"getCommand()", elfProc.getPrFname()); return elfProc.getPrFname(); } public String getExe() { - if (this.exefileBackEnd != null) + if (this.exefileBackEnd != null) { + fine.log(this,"getExe()", this.exefileBackEnd.getPath()); return this.exefileBackEnd.getPath(); + } // Only place to find full path + exe is // in the args list. Remove ./ if present. String[] args = getCmdLine(); if (args.length > 0) { if (args[0].startsWith("./")) args[0]=args[0].substring(2); + fine.log(this, "getExe()", args[0]); return args[0]; - } else + } else { + fine.log(this, "getExe()", elfProc.getPrFname()); return elfProc.getPrFname(); + } } public int getUID() { + fine.log(this,"getUID()", elfProc.getPrUid()); return (int) elfProc.getPrUid(); } public int getGID() { + fine.log(this,"getGID()", elfProc.getPrGid()); return (int) elfProc.getPrGid(); } @@ -124,6 +136,7 @@ public class LinuxCoreProc extends DeadProc { String rawArgs = elfProc.getPrPsargs(); String args[] = rawArgs.split(" "); + fine.log(this,"getCmdLine()", args); return args; } @@ -144,6 +157,7 @@ public class LinuxCoreProc extends DeadProc { throw new RuntimeException(e); } + fine.log(this,"getMemory() caller: ", fine.caller()); return memory; } @@ -216,28 +230,51 @@ public class LinuxCoreProc extends DeadProc { private MemoryMap[] memoryMaps; public MemoryMap[] getMaps () { + fine.log(this,"getMaps()"); if (memoryMaps == null) { + fine.log(this,"getMaps() - Maps need to be built"); ArrayList maps = new ArrayList (); // Build meta data if not already built. if (!metaDataBuilt) constructMetaData (); + // Refactor metadata into format expected by clients of // sendrecMaps. - for (int i=0; i<metaData.length; i++) + for (int i=0; i<metaData.length; i++) { + fine.log(this,"getMaps() maps ", + + "0x"+Long.toHexString(metaData[i].vaddr)+ + "-0x" + Long.toHexString(metaData[i].vaddr_end)+ + " read: " + metaData[i].permRead + + " write: " + metaData[i].permWrite + + " execute: " + metaData[i].permExecute + + " false" + + " 0x" + Long.toHexString(metaData[i].solibOffset) + + " -1,-1,-1,-1,-1, " + + " " + metaData[i].name+"\n"); + maps.add(new MemoryMap(metaData[i].vaddr, metaData[i].vaddr_end, metaData[i].permRead, metaData[i].permWrite, metaData[i].permExecute,false, metaData[i].solibOffset,-1,-1,-1,-1,-1, metaData[i].name)); - + } memoryMaps = (MemoryMap[]) maps.toArray(new MemoryMap[maps.size()]); - } + } else { fine.log("getMaps() - maps already built, returning cache");} + + + fine.log(this,"getMaps() - Completed metadata."); + return memoryMaps; } private Auxv[] auxv; public Auxv[] getAuxv() { + + fine.log(this,"getAuxv()",fine.caller()); + if (auxv == null) { + fine.log(this,"Auxv is null, building"); final ElfPrAuxv prAuxv = ElfPrAuxv.decode(elfData); class BuildAuxv extends AuxvBuilder { Auxv[] vec; @@ -254,7 +291,7 @@ public class LinuxCoreProc extends DeadProc { BuildAuxv auxv = new BuildAuxv (); auxv.construct (prAuxv.getAuxvBuffer()); this.auxv = auxv.vec; - } + } else {fine.log(this,"Returning cached Auxv");} return auxv; } @@ -273,12 +310,18 @@ public class LinuxCoreProc extends DeadProc { */ private void constructMetaData () { + fine.log(this,"constructMetaData()"); + // We'll bake basic meta data for all corefiles metaData = constructBasicMapMetadata (); + if (exefileBackEnd != null) { + fine.log(this,"constructMetaData() - exe backend is not " + + "null, bake enhanced data"); // If an executable is available that is paired with // the corefile, much richer metadata can be constructed. metaData = constructEnhancedMapMetadata (metaData); + fine.log(this,"constructMetaData() - Enhanced metadata complete."); } } @@ -293,6 +336,7 @@ public class LinuxCoreProc extends DeadProc { */ private MapAddressHeader[] constructBasicMapMetadata () { + fine.log(this,"constructBasicMapMetaData()"); String name = ""; ArrayList tempMetaData = new ArrayList (); // Read in contents of the corefile @@ -345,14 +389,15 @@ public class LinuxCoreProc extends DeadProc { * */ private MapAddressHeader[] constructEnhancedMapMetadata(MapAddressHeader[] basicMetaData) { - + + fine.log(this,"constructEnhancedMapMetadata()"); // Clone data. Don't use data that the caller passed. MapAddressHeader[] tempMaps = new MapAddressHeader[basicMetaData.length]; System.arraycopy(basicMetaData,0,tempMaps,0,basicMetaData.length); // Find Dynamic Segment DynamicSegmentTuple dynamicTuple = getDynamicSegmentAddress(); - + // From that segment address, find linkmap table. long linkmapAddress = getLinkmapAddress(dynamicTuple); @@ -367,20 +412,24 @@ public class LinuxCoreProc extends DeadProc { // Edge case: Get interp address so when we traverse the linkmap // it can be paired with its name long interpAddr = getExeInterpreterAddress (); - + // Build the linkmap table from the linkmap tabl address class BuildLinkMap extends LinkmapBuilder { public ArrayList list = new ArrayList(); public void buildMap (long l_addr, long l_ld, long saddr, String name) { - + fine.log(this, "New linkmap item: l_addr = 0x"+Long.toHexString(l_addr) + + " l_ld = 0x"+Long.toHexString(l_ld) + + " s_addr = 0x"+Long.toHexString(l_addr) + + " name = " + name); list.add(new Linkmap(l_addr, l_ld, saddr, name)); } } // Create a temporary, noncache resetting view into the corefile - // memory. We can pass metadata as basic metadata has already been constructed. + // memory. We can pass metadata as basic metadata has already + // been constructed. CorefileByteBuffer tempMemory = null; try { tempMemory = new CorefileByteBuffer(this.corefileBackEnd, metaData); @@ -388,13 +437,16 @@ public class LinuxCoreProc extends DeadProc { throw new RuntimeException(e); } + fine.log(this, "Building linkmap"); BuildLinkMap linkMap = new BuildLinkMap(); linkMap.construct(linkmapAddress,tempMemory); Iterator linkMapIterator = linkMap.list.iterator(); while (linkMapIterator.hasNext()) { Linkmap tempMap = (Linkmap) linkMapIterator.next(); - if (tempMap.s_addr == interpAddr) + if (tempMap.s_addr == interpAddr) { + fine.log("Found interpretator at linkmap address 0x"+Long.toHexString(tempMap.s_addr)); tempMap.name = interpName; + } } // From the list of solibs in the linkamp, build @@ -427,9 +479,8 @@ public class LinuxCoreProc extends DeadProc { // Add in case for executables maps. - SOMaps.construct(this.exefileBackEnd,0,this.getMainTask().getISA().wordSize()); + SOMaps.construct(this.exefileBackEnd,0,this.getMainTask().getISA().wordSize()); - // Reconcile maps Iterator i = SOMaps.list.iterator(); while (i.hasNext()) { @@ -463,10 +514,14 @@ public class LinuxCoreProc extends DeadProc { * executable has been provided */ private boolean isExeProvided () { + boolean provided = false; + if (this.exefileBackEnd != null) if ((this.exefileBackEnd.isFile()) && (this.exefileBackEnd.canRead())) - return true; - return false; + provided = true; + fine.log(this, "isExeProvided()" + provided); + + return provided; } /** @@ -475,6 +530,7 @@ public class LinuxCoreProc extends DeadProc { */ private DynamicSegmentTuple getDynamicSegmentAddress() { + fine.log(this,"getDynamicSegmentAddress()"); // If we do not have an executable, we cannot find // the dynamic segment in the corefile. if (!isExeProvided ()) @@ -489,6 +545,9 @@ public class LinuxCoreProc extends DeadProc { exeDynamicTuple.addr = exeDynamicTuple.addr + coreEntryPoint - exeEntryPoint; + fine.log(this,"getDynamicSegmentAddress() tuple: 0x" + + Long.toHexString(exeDynamicTuple.addr) + + " Size " + exeDynamicTuple.size); return exeDynamicTuple; } @@ -499,12 +558,12 @@ public class LinuxCoreProc extends DeadProc { **/ private DynamicSegmentTuple getExeDynamicSegmentAddress () { + fine.log(this,"getExeDynamicSegmentAddress()"); DynamicSegmentTuple exeDynamicAddr = null; Elf exeElf = openElf(this.exefileBackEnd); if (exeElf != null) { ElfEHeader eHeader = exeElf.getEHeader(); - - + // Find dynamic segment by iterating through program segment // headers for(int headerCount=0; headerCount<eHeader.phnum; headerCount++) { @@ -519,7 +578,11 @@ public class LinuxCoreProc extends DeadProc { } exeElf.close(); - } + } + + fine.log(this,"getDynamicExeSegmentAddress() tuple: 0x" + + Long.toHexString(exeDynamicAddr.addr) + + " Size " + exeDynamicAddr.size); return exeDynamicAddr; } @@ -530,10 +593,15 @@ public class LinuxCoreProc extends DeadProc { * at the address specified by the DT_DEBUG field. */ private long getLinkmapAddress(DynamicSegmentTuple tuple) { + + fine.log(this,"getLinkmapAddress()"); final int DT_DEBUG = 21; - if (tuple == null) + if (tuple == null) { + fine.log(this,"Dynamic segment is null, linkmap set to 0"); return 0; + } + long dynSegmentEndAddress = tuple.addr + tuple.size; long dtDebugAddress = 0; long actualAddress = 0; @@ -583,6 +651,7 @@ public class LinuxCoreProc extends DeadProc { actualAddress = internalMem.getUWord(); } + fine.log(this,"Linkmap address is: 0x"+Long.toHexString(actualAddress)); return actualAddress; } @@ -609,6 +678,8 @@ public class LinuxCoreProc extends DeadProc { * interpeters address */ private long getExeInterpreterAddress () { + + fine.log(this,"getExeInterpreterAddress()"); Elf exeElf = openElf(this.exefileBackEnd); long interpreterAddress = 0; if (exeElf != null) { @@ -626,6 +697,7 @@ public class LinuxCoreProc extends DeadProc { exeElf.close(); } + fine.log(this,"Interpreter Addr: 0x"+Long.toHexString(interpreterAddress)); return interpreterAddress; } @@ -634,6 +706,7 @@ public class LinuxCoreProc extends DeadProc { * interpeters name */ private String getExeInterpreterName () { + fine.log(this,"getExeInterpreterName()"); Elf exeElf = openElf(this.exefileBackEnd); String interpName = ""; if (exeElf != null) { @@ -654,7 +727,7 @@ public class LinuxCoreProc extends DeadProc { exeElf.close(); } - + fine.log(this,"Interpreter name:", interpName); return interpName; } @@ -663,6 +736,7 @@ public class LinuxCoreProc extends DeadProc { * entry point */ private long getCorefileEntryPoint () { + fine.log(this,"getCorefileEntryPoint()"); // Need auxv data Auxv[] auxv = getAuxv (); long entryPoint = 0; @@ -677,6 +751,7 @@ public class LinuxCoreProc extends DeadProc { break; } + fine.log(this,"Corefile Entrypoint: 0x"+Long.toHexString(entryPoint)); return entryPoint; } @@ -685,6 +760,7 @@ public class LinuxCoreProc extends DeadProc { * VDSO address */ private long getCorefileVDSOAddress () { + fine.log(this,"getCorefileVDSOAddress()"); Auxv[] auxv = getAuxv(); long vdsoEntryPoint = 0; @@ -697,7 +773,7 @@ public class LinuxCoreProc extends DeadProc { vdsoEntryPoint = auxv[i].val; break; } - + fine.log(this,"Corefile VDSO Address 0x"+Long.toHexString(vdsoEntryPoint)); return vdsoEntryPoint; } hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-02-12 20:03 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20080212200324.2256.qmail@sourceware.org \ --to=pmuldoon@sourceware.org \ --cc=frysk-cvs@sourceware.org \ --cc=frysk@sourceware.org \ /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: linkBe 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).