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 auxv fhpd command Date: Thu, 06 Dec 2007 12:41:00 -0000 [thread overview] Message-ID: <20071206124103.10542.qmail@sourceware.org> (raw) The branch, master has been updated via 92c63ef33c7b802db6fee1c0f46c091b5a8ba0f4 (commit) from abf779095e5f0032dd63a47ff641faed580989fa (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 92c63ef33c7b802db6fee1c0f46c091b5a8ba0f4 Author: Phil Muldoon <pmuldoon@redhat.com> Date: Thu Dec 6 12:40:26 2007 +0000 Add auxv fhpd command 2007-12-06 Phil Muldoon <pmuldoon@redhat.com> * TopLevelCommand.java(TopLevelCommand): add auxv command. * TestAuxvCommand.java: New. * AuxvCommand.java: New. ----------------------------------------------------------------------- Summary of changes: .../hpd/{LoadCommand.java => AuxvCommand.java} | 129 +++++++++++--------- frysk-core/frysk/hpd/ChangeLog | 6 + ...CompletionFactory.java => TestAuxvCommand.java} | 57 +++++----- frysk-core/frysk/hpd/TopLevelCommand.java | 1 + 4 files changed, 105 insertions(+), 88 deletions(-) copy frysk-core/frysk/hpd/{LoadCommand.java => AuxvCommand.java} (53%) copy frysk-core/frysk/hpd/{TestCompletionFactory.java => TestAuxvCommand.java} (70%) First 500 lines of diff: diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/AuxvCommand.java similarity index 53% copy from frysk-core/frysk/hpd/LoadCommand.java copy to frysk-core/frysk/hpd/AuxvCommand.java index 312c084..79f52fd 100644 --- a/frysk-core/frysk/hpd/LoadCommand.java +++ b/frysk-core/frysk/hpd/AuxvCommand.java @@ -39,70 +39,81 @@ package frysk.hpd; -import java.io.File; +import inua.elf.AT; import java.util.Iterator; -import frysk.debuginfo.DebugInfo; -import frysk.debuginfo.DebugInfoFrame; -import frysk.debuginfo.DebugInfoStackFactory; -import frysk.proc.Host; -import frysk.proc.dead.LinuxExeHost; -import frysk.proc.Manager; -import frysk.proc.Proc; -import frysk.proc.Task; import java.util.List; +import frysk.proc.Auxv; +import frysk.proc.Proc; -/** - * LoadCommand handles the "load path-to-executable" command on the fhpd - * commandline. - * - */ - -public class LoadCommand extends ParameterizedCommand { - - LoadCommand() { - super("load", "load path-to-executable", "load an executable file"); - } - - public void interpret(CLI cli, Input cmd, Object options) { - if (cmd.size() > 2) { - throw new InvalidCommandException("Too many parameters"); - } - - File executableFile = new File(cmd.parameter(0)); - - if (!executableFile.exists() || !executableFile.canRead() - || !executableFile.isFile()) { - throw new InvalidCommandException - ("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); - - int procID = cli.idManager.reserveProcID(); - cli.idManager.manageProc(exeProc, procID); - - Iterator foo = cli.targetset.getTasks(); - while (foo.hasNext()) { - Task task = (Task) foo.next(); - if (task.getTid() == exeProc.getMainTask().getTid()) { - DebugInfoFrame frame = DebugInfoStackFactory - .createDebugInfoStackTrace(task); - cli.setTaskFrame(task, frame); - cli.setTaskDebugInfo(task, new DebugInfo( - frame)); - } - } - synchronized (cli) { - cli.getLoadedProcs().put(exeProc, new Integer(procID)); +public class AuxvCommand extends ParameterizedCommand { + + boolean verbose = false; + + public AuxvCommand() { + super("Print process auxiliary", "auxv [-verbose]", + "Print out the process auxiliary data for this " + + "process."); + + add(new CommandOption("verbose", "Print out known auxv descriptions ") { + void parse(String argument, Object options) { + verbose = true; } + }); - cli.addMessage("Loaded executable file: " + cmd.parameter(0), - Message.TYPE_NORMAL); + } + + void interpret(CLI cli, Input cmd, Object options) { + PTSet ptset = cli.getCommandPTSet(cmd); + Iterator taskDataIterator = ptset.getTaskData(); + if (taskDataIterator.hasNext() == false) + cli.addMessage("Cannot find main task. Cannot print out auxv", Message.TYPE_ERROR); + Proc mainProc = ((TaskData) taskDataIterator.next()).getTask().getProc(); + Auxv[] liveAux = mainProc.getAuxv(); + + class BuildAuxv extends AuxvStringBuilder { + + public StringBuffer auxvData = new StringBuffer(); + public void buildLine(String type, String desc, String value) { + if (verbose) + auxvData.append(type+" (" + desc+") : " + value+"\n"); + else + auxvData.append(type+" : " + value+"\n"); + } } - - int completer(CLI cli, Input input, int cursor, List completions) { - return CompletionFactory.completeFileName(cli, input, cursor, - completions); + + BuildAuxv buildAuxv = new BuildAuxv(); + buildAuxv.construct(liveAux); + + cli.outWriter.println(buildAuxv.auxvData.toString()); + } + + int completer(CLI cli, Input input, int cursor, List completions) { + return -1; + } + + abstract class AuxvStringBuilder + { + protected AuxvStringBuilder() { } + + public final void construct (Auxv[] rawAuxv) { + String value; + for (int i=0; i < rawAuxv.length; i++) { + switch (rawAuxv[i].type) { + case 33: + case 16: + case 3: + case 9: + case 15: + value = "0x"+Long.toHexString(rawAuxv[i].val); + break; + default: + value = ""+rawAuxv[i].val; + } + buildLine(AT.toString(rawAuxv[i].type), AT.toPrintString(rawAuxv[i].type), value); + } + } + + abstract public void buildLine(String type, String desc, String value); + } } diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 2f4412a..7e612de 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,9 @@ +2007-12-06 Phil Muldoon <pmuldoon@redhat.com> + + * TopLevelCommand.java(TopLevelCommand): add auxv command. + * TestAuxvCommand.java: New. + * AuxvCommand.java: New. + 2007-12-04 Andrew Cagney <cagney@redhat.com> Merge frysk.sys.Sig into frysk.sys.Signal. diff --git a/frysk-core/frysk/hpd/TestCompletionFactory.java b/frysk-core/frysk/hpd/TestAuxvCommand.java similarity index 70% copy from frysk-core/frysk/hpd/TestCompletionFactory.java copy to frysk-core/frysk/hpd/TestAuxvCommand.java index 3f595bd..35fad72 100644 --- a/frysk-core/frysk/hpd/TestCompletionFactory.java +++ b/frysk-core/frysk/hpd/TestAuxvCommand.java @@ -41,33 +41,32 @@ package frysk.hpd; import frysk.Config; -public class TestCompletionFactory extends TestLib { - - public void setUp() { - super.setUp(); - e = new HpdTestbed(); - } - - /** - * At least two expansions of "funit-stack-" are - * "funit-stack-inlined" and "funit-stack-outlined"; there might - * also be .o files, but ignore that. - */ - private void checkFunitStackCompletion() { - e.send(Config.getPkgLibFile("funit-stack-").getAbsolutePath()); - e.send("\t"); - e.expect("funit-stack-inlined\\r\\n"); - e.expect("funit-stack-outlined\\r\\n"); - e.expectPrompt(); - } - - public void testCompleteFirstFileNameArg() { - e.send("run "); - checkFunitStackCompletion(); - } - - public void testCompleteSecondFileNameArg() { - e.send("run a "); - checkFunitStackCompletion(); - } +public class TestAuxvCommand extends TestLib { + + public void testAuxVCoreCommand() { + e = new HpdTestbed(); + e.send("core " + Config.getPkgDataFile("test-core-x86").getPath() + + " -noexe\n"); + e.expect(5, "Attached to core file.*"); + e.send("auxv\n"); + e.expect("AT_SYSINFO : 6464512"); + e.expect("AT_SYSINFO_EHDR : 0x62a000"); + e.expect("AT_HWCAP : 0xafe9f1bf"); + e.expect("AT_PAGESZ : 4096"); + e.expect("AT_CLKTCK : 100"); + e.expect("AT_PHDR : 0x8048034"); + e.expect("AT_PHENT : 32"); + e.expect("AT_PHNUM : 8"); + e.expect("AT_BASE : 0"); + e.expect("AT_FLAGS : 0"); + e.expect("AT_ENTRY : 0x80483e0"); + e.expect("AT_UID : 500"); + e.expect("AT_EUID : 500"); + e.expect("AT_GID : 500"); + e.expect("AT_EGID : 500"); + e.expect("AT_0x17 : 0"); + e.expect("AT_PLATFORM : 0xbfcfee4b"); + e.expect("AT_NULL : 0"); + e.close(); + } } diff --git a/frysk-core/frysk/hpd/TopLevelCommand.java b/frysk-core/frysk/hpd/TopLevelCommand.java index 4289903..875836a 100644 --- a/frysk-core/frysk/hpd/TopLevelCommand.java +++ b/frysk-core/frysk/hpd/TopLevelCommand.java @@ -80,6 +80,7 @@ public class TopLevelCommand extends MultiLevelCommand { add(new AliasCommands.Alias(), "alias"); add(new AliasCommands.Unalias(), "unalias"); add(new AttachCommand(), "attach"); + add(new AuxvCommand(), "auxv"); add(new BreakpointCommand(), "b|reak"); add(new CoreCommand(), "core"); add(new DbgVariableCommands.Set(), "set"); hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2007-12-06 12:41 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=20071206124103.10542.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).