Print() public method

public Print ( object obj ) : void
obj object
return void
コード例 #1
0
        public override void PrintFrame(ScriptingContext context, StackFrame frame)
        {
            context.Print(frame);
            bool native = false;

            if (!PrintSource(context.Interpreter, frame))
            {
                native = true;
            }
            if (native)
            {
                AssemblerLine insn = frame.Thread.DisassembleInstruction(
                    frame.Method, frame.TargetAddress);

                if (insn != null)
                {
                    context.Interpreter.PrintInstruction(insn);
                }
                else
                {
                    throw new ScriptingException(
                              "Cannot disassemble instruction at address {0}.",
                              frame.TargetAddress);
                }
            }
        }
コード例 #2
0
ファイル: EmonicCommand.cs プロジェクト: visual000/misc
        protected override object DoExecute(ScriptingContext context)
        {
            Backtrace backtrace = null;

            if ((mode == Backtrace.Mode.Default) && (max_frames == -1))
                backtrace = CurrentThread.CurrentBacktrace;

            if (backtrace == null)
                backtrace = CurrentThread.GetBacktrace (mode, max_frames);

            for (int i = 0; i < backtrace.Count; i++) {
                string prefix = i == backtrace.CurrentFrameIndex ? "(*)" : "   ";
                context.Print ("{0} {1}", prefix, backtrace [i]);

                EmonicInterpreter.backtraceData bt = new EmonicInterpreter.backtraceData();
                bt.frameNumber = backtrace[i].Level;
                bt.currentFrame = i == backtrace.CurrentFrameIndex;
                if (backtrace[i].Method != null) {
                    bt.method = backtrace[i].Method.Name;
                    if (bt.method == null)
                        bt.method = "";
                } else {
                    if (backtrace[i].Name == null)
                        bt.method = "";
                    else {
                        bt.method = backtrace[i].Name.ToString();
                        if (bt.method == null)
                            bt.method = "";
                    }
                }
                if (backtrace[i].SourceAddress != null && backtrace[i].SourceAddress.SourceFile != null)
                    bt.file = backtrace[i].SourceAddress.SourceFile.FileName;
                else
                    bt.file = "";
                if (backtrace[i].SourceAddress != null)
                    bt.lineNumber = backtrace[i].SourceAddress.Row;
                else
                    bt.lineNumber = -1;
                if (i+1 < backtrace.Count)
                    bt.moreData = true;
                else
                    bt.moreData = false;
                EmonicInterpreter.backtraceList.Add(bt);
            }

            return backtrace;
        }
コード例 #3
0
ファイル: Style.cs プロジェクト: baulig/debugger
        public override void PrintFrame(ScriptingContext context, StackFrame frame)
        {
            context.Print (frame);
            bool native = false;
            if (!PrintSource (context.Interpreter, frame))
                native = true;
            if (native) {
                AssemblerLine insn = frame.Thread.DisassembleInstruction (
                    frame.Method, frame.TargetAddress);

                if (insn != null)
                    context.Interpreter.PrintInstruction (insn);
                else
                    throw new ScriptingException (
                        "Cannot disassemble instruction at address {0}.",
                        frame.TargetAddress);
            }
        }
コード例 #4
0
ファイル: Command.cs プロジェクト: baulig/debugger
        protected override bool DoResolve(ScriptingContext context)
        {
            if ((Args == null) || (Args.Count < 1)) {
                context.Print ("Need an argument:{0}", GetCommandList());
                return false;
            }

            Type subcommand_type = (Type)subcommand_type_hash[(string) Args[0]];

            if (subcommand_type == null)
                throw new ScriptingException ("Syntax error");

            subcommand = (DebuggerCommand) Activator.CreateInstance (subcommand_type);

            ArrayList new_args = new ArrayList ();
            for (int i = 1; i < Args.Count; i++)
                new_args.Add (Args [i]);

            DebuggerEngine engine = context.Interpreter.DebuggerEngine;
            subcommand = (DebuggerCommand) engine.ParseArguments (subcommand, new_args);
            if (subcommand == null)
                return false;

            return subcommand.Resolve (context);
        }
コード例 #5
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override bool DoResolve(ScriptingContext context)
            {
                if ((Args == null) || (Args.Count != 1)) {
                    context.Print ("Need exactly one argument: the name of " +
                               "the thread group to delete");
                    return false;
                }

                return true;
            }
コード例 #6
0
ファイル: Command.cs プロジェクト: baulig/debugger
 protected override object DoExecute(ScriptingContext context)
 {
     int index = context.Interpreter.InsertExceptionCatchPoint (
         CurrentThread, tgroup, type, unhandled);
     context.Print ("Inserted catch point {0} for {1}", index, type.Name);
     return index;
 }
コード例 #7
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override bool DoResolve(ScriptingContext context)
            {
                if ((Args == null) || (Args.Count < 1)) {
                    Method method = CurrentThread.CurrentFrame.Method;
                    if (method != null) {
                        modules = new Module [1];
                        modules [0] = CurrentThread.CurrentFrame.Method.Module;
                        return true;
                    }

                    context.Print ("Invalid arguments: Need one or more module " +
                               "ids to operate on");
                    return false;
                }

                int[] ids = new int [Args.Count];
                for (int i = 0; i < Args.Count; i++) {
                    try {
                        ids [i] = (int) UInt32.Parse ((string) Args [i]);
                    } catch {
                        context.Print ("Invalid argument {0}: expected " +
                                   "module id", i);
                        return false;
                    }
                }

                modules = context.Interpreter.GetModules (ids);
                return modules != null;
            }
コード例 #8
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override object DoExecute(ScriptingContext context)
            {
                int current_id = -1;
                if (context.Interpreter.HasCurrentThread)
                    current_id = context.Interpreter.CurrentThread.ID;

                bool printed_something = false;
                foreach (Process process in context.Interpreter.Processes) {
                    context.Print ("Process {0}:",
                               context.Interpreter.PrintProcess (process));
                    foreach (Thread proc in process.GetThreads ()) {
                        string prefix = proc.ID == current_id ? "(*)" : "   ";
                        context.Print ("{0} {1} ({2}:{3:x}) {4} {5}", prefix, proc,
                                   proc.PID, proc.TID, proc.State, proc.ThreadFlags);
                        printed_something = true;
                    }
                }

                if (!printed_something)
                    context.Print ("No target.");

                return null;
            }
コード例 #9
0
ファイル: Command.cs プロジェクト: baulig/debugger
        protected override object DoExecute(ScriptingContext context)
        {
            Thread thread = context.Interpreter.CurrentThread;

            context.Print ("{0} ({1}:{2:x}) {3} {4}", thread,
                       thread.PID, thread.TID, thread.State,
                       thread.ThreadFlags);
            return thread;
        }
コード例 #10
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override object DoExecute(ScriptingContext context)
            {
                Process[] processes = context.Interpreter.Processes;
                if ((processes.Length > 0) && !context.Interpreter.HasCurrentProcess)
                    context.Interpreter.CurrentProcess = processes [0];
                foreach (Process process in processes) {
                    string prefix = process == context.Interpreter.CurrentProcess ?
                        "(*)" : "   ";

                    context.Print ("{0} Process {1}", prefix,
                               context.Interpreter.PrintProcess (process));
                }
                return null;
            }
コード例 #11
0
ファイル: Command.cs プロジェクト: baulig/debugger
        protected override bool DoResolve(ScriptingContext context)
        {
            if (context.HasTarget && context.Interpreter.IsInteractive) {
                if (context.Interpreter.Query ("The program is running.  Exit anyway?")) {
                    return true;
                }
                else {
                    context.Print ("Not confirmed.");
                    return false;
                }
            }

            return true;
        }
コード例 #12
0
ファイル: Command.cs プロジェクト: baulig/debugger
        protected override object DoExecute(ScriptingContext context)
        {
            StackFrame frame;
            if (frameIndex != -1) {
                Backtrace backtrace = CurrentThread.GetBacktrace ();
                try {
                    backtrace.CurrentFrameIndex = frameIndex;
                } catch {
                    throw new ScriptingException ("Invalid frame.");
                }
                frame = backtrace.CurrentFrame;
            } else
                frame = CurrentFrame;

            if (context.Interpreter.IsScript)
                context.Print (frame);
            else
                context.Interpreter.Style.PrintFrame (context, frame);

            return frame;
        }
コード例 #13
0
ファイル: Command.cs プロジェクト: baulig/debugger
 protected override object DoExecute(ScriptingContext context)
 {
     string pwd = context.Interpreter.Options.WorkingDirectory;
     context.Print ("Working directory: {0}.", pwd);
     return pwd;
 }
コード例 #14
0
ファイル: Command.cs プロジェクト: baulig/debugger
        protected override string Execute(ScriptingContext context,
						   Expression expression, DisplayFormat format)
        {
            TargetType type = expression.EvaluateType (context);
            string text = context.FormatType (type);
            context.Print (text);
            return text;
        }
コード例 #15
0
ファイル: Command.cs プロジェクト: baulig/debugger
        protected override string Execute(ScriptingContext context,
						   Expression expression, DisplayFormat format)
        {
            if (NestedBreakStates)
                context.ScriptingFlags |= ScriptingFlags.NestedBreakStates;

            if (expression is TypeExpression)
                throw new ScriptingException (
                    "`{0}' is a type, not a variable.", expression.Name);
            object retval = expression.Evaluate (context);
            string text = context.FormatObject (retval, format);
            context.Print (text);
            return text;
        }
コード例 #16
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override bool DoResolve(ScriptingContext context)
            {
                if ((Args == null) || (Args.Count < 1)) {
                    context.Print ("Invalid arguments: Need one or more source " +
                               "file ids to operate on");
                    return false;
                }

                int[] ids = new int [Args.Count];
                for (int i = 0; i < Args.Count; i++) {
                    try {
                        ids [i] = (int) UInt32.Parse ((string) Args [i]);
                    } catch {
                        context.Print ("Invalid argument {0}: expected " +
                                   "source file id", i);
                        return false;
                    }
                }

                sources = context.Interpreter.GetSources (ids);
                return sources != null;
            }
コード例 #17
0
ファイル: Command.cs プロジェクト: baulig/debugger
        protected override object DoExecute(ScriptingContext context)
        {
            Event handle;

            if (!address.IsNull) {
                handle = context.Interpreter.Session.InsertBreakpoint (
                    context.CurrentThread, tgroup, address);
                context.Print ("Breakpoint {0} at {1}", handle.Index, address);
            } else if (location != null) {
                handle = context.Interpreter.Session.InsertBreakpoint (
                    tgroup, location);
                context.Print ("Breakpoint {0} at {1}", handle.Index, location.Name);
            } else {
                handle = context.Interpreter.Session.InsertBreakpoint (
                    tgroup, type, Argument);
                context.Print ("Breakpoint {0} at {1}", handle.Index, Argument);
            }

            if (gui) {
                context.ActivatePendingBreakpoints ();
                return handle.Index;
            }

            if (!context.Interpreter.HasTarget)
                return handle.Index;

            try {
                if (handle.NeedsActivation)
                    handle.Activate (context.Interpreter.CurrentThread);
            } catch {
                if (!lazy)
                    throw;
            }

            return handle.Index;
        }
コード例 #18
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override object DoExecute(ScriptingContext context)
            {
                Module[] modules = CurrentProcess.Modules;

                context.Print ("{0,4}  {1,-8} {2,5} {3,5} {4,5} {5}",
                           "Id", "Group", "load?", "step?", "sym?", "Name");

                for (int i = 0; i < modules.Length; i++) {
                    Module module = modules [i];

                    if (!all && module.HideFromUser)
                        continue;

                    context.Print ("{0,4}  {1,-8} {2,5} {3,5} {4,5} {5}",
                               module.ID, module.ModuleGroup.Name,
                               module.LoadSymbols ? "y " : "n ",
                               module.StepInto ? "y " : "n ",
                               module.SymbolsLoaded ? "y " : "n ",
                               module.Name);
                }

                return null;
            }
コード例 #19
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override bool DoResolve(ScriptingContext context)
            {
                if (Argument == "") {
                    context.Print ("Invalid argument: Need the name of the style");
                    return false;
                }

                style = context.Interpreter.GetStyle (Argument);
                return true;
            }
コード例 #20
0
ファイル: Command.cs プロジェクト: baulig/debugger
 protected override object DoExecute(ScriptingContext context)
 {
     string regs = CurrentThread.PrintRegisters (CurrentFrame);
     context.Print (regs);
     return regs;
 }
コード例 #21
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override object DoExecute(ScriptingContext context)
            {
                DebuggerOptions options = context.Interpreter.Session.Options;

                string[] args = options.InferiorArgs;
                if (args == null)
                    args = new string [0];
                context.Print ("Target application:      {0}\n" +
                           "Command line arguments:  {1}\n" +
                           "Working directory:       {2}\n",
                           options.File, String.Join (" ", args),
                           options.WorkingDirectory);
                return args;
            }
コード例 #22
0
ファイル: Command.cs プロジェクト: baulig/debugger
 protected override object DoExecute(ScriptingContext context)
 {
     context.Print ("Current style interface: {0}",
                context.Interpreter.Style.Name);
     return null;
 }
コード例 #23
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override object DoExecute(ScriptingContext context)
            {
                context.Print ("Stack level {0}, stack pointer at {1}, " +
                           "frame pointer at {2}.", CurrentFrame.Level,
                           CurrentFrame.StackPointer,
                           CurrentFrame.FrameAddress);
                if (CurrentFrame.SourceAddress != null) {
                    SourceAddress source = CurrentFrame.SourceAddress;
                    TargetAddress address = CurrentFrame.TargetAddress;

                    context.Print ("Source: {0}", source);
                    context.Print ("{0} - {1}", address - source.LineOffset,
                               address + source.LineRange);
                }
                return null;
            }
コード例 #24
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override bool DoResolve(ScriptingContext context)
            {
                if ((Args == null) || (Args.Count < 2)) {
                    context.Print ("Invalid arguments: Need the name of the " +
                               "thread group to operate on and one ore more " +
                               "threads");
                    return false;
                }

                name = (string) Args [0];
                int[] ids = new int [Args.Count - 1];
                for (int i = 0; i < Args.Count - 1; i++) {
                    try {
                        ids [i] = (int) UInt32.Parse ((string) Args [i+1]);
                    } catch {
                        context.Print ("Invalid argument {0}: expected " +
                                   "thread id", i+1);
                        return false;
                    }
                }

                threads = context.Interpreter.GetThreads (ids);
                return threads != null;
            }
コード例 #25
0
ファイル: Command.cs プロジェクト: baulig/debugger
 protected override object DoExecute(ScriptingContext context)
 {
     // if lang == auto, we should print out what it currently is, ala gdb's
     // The current source language is "auto; currently c".
     context.Print ("The current source language is \"{0}\".",
                CurrentFrame.Language.Name);
     return null;
 }
コード例 #26
0
ファイル: Command.cs プロジェクト: baulig/debugger
        protected override object DoExecute(ScriptingContext context)
        {
            if (!Repeating) {
                PointerExpression pexp = expression as PointerExpression;
                if (pexp == null)
                    throw new ScriptingException (
                        "Expression `{0}' is not a pointer.",
                        expression.Name);

                address = pexp.EvaluateAddress (context);
            }

            int index = context.Interpreter.InsertHardwareWatchPoint (CurrentThread, address);
            context.Print ("Hardware watchpoint {0} at {1}", index, address);
            return index;
        }
コード例 #27
0
ファイル: Command.cs プロジェクト: baulig/debugger
        protected override object DoExecute(ScriptingContext context)
        {
            string name = (string) Args [0];

            ModuleBase module = null;
            if (name.StartsWith ("@")) {
                name = name.Substring (1);
                module = context.Interpreter.Session.Config.GetModuleGroup (name);
                if (module == null)
                    throw new ScriptingException ("No such module group `{0}'", name);
            } else {
                int index;
                try {
                    index = (int) UInt32.Parse (name);
                } catch {
                    context.Print ("Module number expected.");
                    return false;
                }

                foreach (Module mod in CurrentProcess.Modules) {
                    if (mod.ID == index) {
                        module = mod;
                        break;
                    }
                }
            }

            if (module == null)
                throw new ScriptingException ("No such module `{0}'", name);

            for (int i = 1; i < Args.Count; i++) {
                string command = (string) Args [i];

                switch (command) {
                case "step":
                    module.StepInto = true;
                    break;
                case "nostep":
                    module.StepInto = false;
                    break;
                case "hide":
                    module.HideFromUser = true;
                    break;
                case "nohide":
                    module.HideFromUser = false;
                    break;
                case "load":
                    module.LoadSymbols = true;
                    break;
                case "noload":
                    module.LoadSymbols = false;
                    break;
                default:
                    throw new ScriptingException ("Invalid module command `{0}'", command);
                }
            }

            context.Print ("{0}: {1} {2} {3}",
                       module.Name,
                       module.HideFromUser ? "hide" : "nohide",
                       module.StepInto ? "step" : "nostep",
                       module.LoadSymbols ? "load " : "noload");

            return null;
        }
コード例 #28
0
ファイル: Command.cs プロジェクト: baulig/debugger
        protected override object DoExecute(ScriptingContext context)
        {
            try {
                string new_dir;

                if (Argument == "..") {
                    new_dir = new DirectoryInfo (Environment.CurrentDirectory).Parent.FullName;
                }
                else if (Argument == ".") {
                    new_dir = new DirectoryInfo (Environment.CurrentDirectory).FullName;
                }
                else {
                    new_dir = new DirectoryInfo (Argument).FullName;
                }

                Environment.CurrentDirectory = new_dir;
                context.Interpreter.Options.WorkingDirectory = new_dir;

                context.Print ("Working directory {0}.", new_dir);
                return new_dir;
            } catch {
                throw new ScriptingException ("{0}: No such file or directory.", Argument);
            }
        }
コード例 #29
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override bool DoResolve(ScriptingContext context)
            {
                if ((Args == null) || (Args.Count != 1)) {
                    context.Print ("Invalid arguments: expression expected");
                    return false;
                }

                expression = ParseExpression (context);
                if (expression == null)
                    return false;

                expression = expression.Resolve (context);
                return expression != null;
            }
コード例 #30
0
ファイル: Command.cs プロジェクト: baulig/debugger
            protected override object DoExecute(ScriptingContext context)
            {
                StructAccessExpression sae = expression as StructAccessExpression;
                if ((sae != null) && (sae.InstanceObject != null)) {
                    string loc = sae.InstanceObject.PrintLocation ();
                    if (loc != null)
                        context.Print ("{0} is a field of type {1} contained in a " +
                                   "structure of type {2} stored at {3}",
                                   expression.Name, sae.Member.Type.Name, sae.Type.Name,
                                   loc);
                    else
                        context.Print ("{0} is a field of type {1} contained in a " +
                                   "structure of type {2}.", expression.Name,
                                   sae.Member.Type.Name, sae.Type.Name);
                    return null;
                }

                TargetVariable var = expression.EvaluateVariable (context);

                string location = var.PrintLocation (CurrentFrame);
                if (location != null)
                    context.Print ("{0} is a variable of type {1} stored at {2}",
                               var.Name, var.Type.Name, location);
                else
                    context.Print ("{0} is a variable of type {1}",
                               var.Name, var.Type.Name);

                return null;
            }
コード例 #31
0
ファイル: Command.cs プロジェクト: baulig/debugger
        protected override bool DoResolve(ScriptingContext context)
        {
            if ((Args == null) || (Args.Count < 1)) {
                context.Print ("Argument expected.");
                return false;
            }

            return true;
        }