public static async System.Threading.Tasks.Task RundotNetScript(string[] args, IStaticSite ctx) { var logger = new ScriptLogger(ScriptConsole.Default.Out, true); var dependencyResolver = new RuntimeDependencyResolver(type => ((level, message) => { if (level == LogLevel.Debug) { logger.Verbose(message); } if (level == LogLevel.Info) { logger.Log(message); } })); var code = Microsoft.CodeAnalysis.Text.SourceText.From(File.ReadAllText("FlipLeaf.csx")); var scriptContext = new ScriptContext(code, Environment.CurrentDirectory ?? Directory.GetCurrentDirectory(), args, scriptMode: Dotnet.Script.DependencyModel.Context.ScriptMode.REPL); var compiler = new ScriptCompiler(logger, dependencyResolver); var runner = new ScriptRunner(compiler, logger, ScriptConsole.Default); await runner.Execute <int>(scriptContext); }
/// <summary> /// Code handled by Thread. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ScriptThread_DoWork(object sender, DoWorkEventArgs e) { // Stores "Thread" to var var worker = (BackgroundWorker)sender; // Invokes Thread safe Actions onto UI. In this case disable play button , enable stop button. Invoke((MethodInvoker) delegate { tsbplay.Enabled = false; }); Invoke((MethodInvoker) delegate { tsbstop.Enabled = true; }); //Enables logger methods from SDK ScriptLogger.Initialize(); //Initializes Loggin Event, wich performs an action whenever ScriptLogger gets new Logfiles. ScriptLogger.OnLogging += ScriptLogger_OnLogging; //Sample loop to repeat code inside, until thread gets stopped or application closed. while (!worker.CancellationPending) { //Sends Text to Logger, wich shares it onto UI through event. ScriptLogger.WriteLine("Hello Thread!"); // Let the thread sleep when not requiring actions. Thread.Sleep works better then "Waits" via Api-Call. Thread.Sleep(500); } // Invokes Thread safe Actions onto UI. In this case disable stop button, enable play button. Invoke((MethodInvoker) delegate { tsbplay.Enabled = true; }); Invoke((MethodInvoker) delegate { tsbstop.Enabled = false; }); }
private InteractiveTestContext GetRunner(string[] commands) { var reader = new StringReader(string.Join(Environment.NewLine, commands)); var writer = new StringWriter(); var error = new StringWriter(); var console = new ScriptConsole(writer, reader, error); var logger = new ScriptLogger(console.Error, true); var runtimeDependencyResolver = new RuntimeDependencyResolver(type => ((level, message) => { if (level == LogLevel.Debug) { logger.Verbose(message); } if (level == LogLevel.Info) { logger.Log(message); } })); var compiler = new ScriptCompiler(logger, runtimeDependencyResolver); var runner = new InteractiveRunner(compiler, logger, console); return(new InteractiveTestContext(console, runner)); }
/// <summary> /// SDK initializer which should be called one time only on first script call. /// </summary> public static void Initialize() { ContextOptions.Initialize(); Scanner.Initialize(); TileReader.Initialize(); ScriptLogger.Initialize(); }
private static void Run(bool debugMode, ScriptContext context) { var logger = new ScriptLogger(Console.Error, debugMode); var compiler = new ScriptCompiler(logger); var runner = new ScriptRunner(compiler, logger); runner.Execute <object>(context).GetAwaiter().GetResult(); }
private static Task Run(bool debugMode, ScriptContext context) { var logger = new ScriptLogger(Console.Error, debugMode); var compiler = new ScriptCompiler(logger, new ScriptProjectProvider(new ScriptParser(logger), logger)); var runner = new ScriptRunner(compiler, logger); return(runner.Execute <object>(context)); }
public void Reset(CSLE.ICLS_Logger logger) { if (logger == null) { logger = new ScriptLogger(); } scriptEnv = new CSLE.CLS_Environment(logger); RegTypes(); projectLoaded = false; }
private SOSRunner(NativeDebugger debugger, TestConfiguration config, TestRunner.OutputHelper outputHelper, Dictionary <string, string> variables, ScriptLogger scriptLogger, ProcessRunner processRunner, bool isDump) { Debugger = debugger; _config = config; _outputHelper = outputHelper; _variables = variables; _scriptLogger = scriptLogger; _processRunner = processRunner; _isDump = isDump; }
public void Reset(CSLE.ICLS_Logger logger) { if(logger ==null) { logger =new ScriptLogger(); } scriptEnv = new CSLE.CLS_Environment(logger); RegTypes(); projectLoaded = false; }
private LogFactory GetLogFactory() { var logger = new ScriptLogger(ScriptConsole.Default.Error, true); return(type => ((level, message) => { if (level == LogLevel.Debug) { logger.Verbose(message); } if (level == LogLevel.Info) { logger.Log(message); } })); }
public Startup() { var code = File.ReadAllText(ScriptFullPath); var sourceText = SourceText.From(code, Encoding.UTF8); var context = new ScriptContext(sourceText, Path.GetDirectoryName(ScriptFullPath), "Release", new List <string>(), ScriptFullPath); var logger = new ScriptLogger(Console.Out, false); var compiler = new AspNetScriptCompiler(logger); var runner = new ScriptRunner(compiler, logger); var result = runner.Execute <object, ScriptingHost>(context, _scriptHost).GetAwaiter().GetResult(); var compilationContext = compiler.Context as ScriptCompilationContext <object>; _scriptAssembly = compilationContext.GetScriptAssembly(); }
/// <summary> /// Wait for a container to be accessible /// </summary> /// <param name="container">Container to wait for</param> /// <param name="maximumDelay">Maximum delay</param> /// <returns>true if container is accessible</returns> public static bool WaitForContainer(Container container, TimeSpan maximumDelay) { DateTime timeout = DateTime.Now.Add(maximumDelay); while (DateTime.Now < timeout) { if (container.Valid) { return(true); } Thread.Sleep(250); } ScriptLogger.WriteLine("[ERROR] Failed to open container '" + container.Serial.Value + "'"); return(false); }
private static ScriptCompiler GetScriptCompiler(bool debugMode) { var logger = new ScriptLogger(ScriptConsole.Default.Error, debugMode); var runtimeDependencyResolver = new RuntimeDependencyResolver(type => ((level, message) => { if (level == LogLevel.Debug) { logger.Verbose(message); } if (level == LogLevel.Info) { logger.Log(message); } })); var compiler = new ScriptCompiler(logger, runtimeDependencyResolver); return(compiler); }
private ScriptCompiler GetScriptCompiler() { var logger = new ScriptLogger(ScriptConsole.Default.Error, LogVerbosityDebug); var runtimeDependencyResolver = new RuntimeDependencyResolver(type => ((level, message) => { switch (level) { case LogLevel.Debug: logger.Verbose(message); break; case LogLevel.Info: logger.Log(message); break; } })); var compiler = new ScriptCompiler(logger, runtimeDependencyResolver); return(compiler); }
public static void Run() { ScriptLogger.Initialize(); ScriptLogger.LogToStealth = true; if (ValidateConfig()) { try { var data = xmlconfig.Parse(); Stealth.Client.UseObject(data.ContainerID); while (Stealth.Client.GetLastContainer() != data.ContainerID) { Stealth.Client.Wait(data.WaitDelay); } if (Stealth.Client.FindTypeEx(0xFFFF, 0xFFFF, data.ContainerID, true) > 0) { var r = Stealth.Client.GetFindList(); var l = new List<string>(); foreach (var e in r) { Stealth.Client.ClickOnObject(e); var t = string.Empty; while (t.Trim() == "") t = Stealth.Client.GetTooltip(e, data.ToolTipDelay); l.Add(e + ";" + t.Replace("|", ";")); } File.WriteAllLines(data.FileName, l); } } catch (Exception) { ScriptLogger.WriteLine("Error on Export Handling!"); } } else { ScriptLogger.WriteLine(string.Format("Unable to find {0}", cfgname)); } }
public AspNetScriptCompiler(ScriptLogger logger) : base(logger) { }
/// <summary> /// Initializes a new instance of the <see cref="ScriptProjectProvider"/> class. /// </summary> /// <param name="scriptParser">The <see cref="IScriptParser"/> that is responsible for parsing NuGet references from script files.</param> public ScriptProjectProvider(ScriptParser scriptParser, ScriptLogger logger) { _logger = logger; this.scriptParser = scriptParser; }
/// <summary> /// Initializes a new instance of the <see cref="CommandRunner"/> class. /// </summary> /// <param name="logger">The <see cref="ScriptLogger"/> used for logging.</param> public CommandRunner(ScriptLogger logger) { _logger = logger; }
private static int Wain(string[] args) { var app = new CommandLineApplication(throwOnUnexpectedArg: false) { ExtendedHelpText = "Starting without a path to a CSX file or a command, starts the REPL (interactive) mode." }; var file = app.Argument("script", "Path to CSX script"); var interactive = app.Option("-i | --interactive", "Execute a script and drop into the interactive mode afterwards.", CommandOptionType.NoValue); var configuration = app.Option("-c | --configuration <configuration>", "Configuration to use for running the script [Release/Debug] Default is \"Debug\"", CommandOptionType.SingleValue); var packageSources = app.Option("-s | --sources <SOURCE>", "Specifies a NuGet package source to use when resolving NuGet packages.", CommandOptionType.MultipleValue); var debugMode = app.Option(DebugFlagShort + " | " + DebugFlagLong, "Enables debug output.", CommandOptionType.NoValue); var argsBeforeDoubleHyphen = args.TakeWhile(a => a != "--").ToArray(); var argsAfterDoubleHypen = args.SkipWhile(a => a != "--").Skip(1).ToArray(); app.HelpOption("-? | -h | --help"); app.VersionOption("-v | --version", GetVersion); var infoOption = app.Option("--info", "Displays environmental information", CommandOptionType.NoValue); app.Command("eval", c => { c.Description = "Execute CSX code."; var code = c.Argument("code", "Code to execute."); var cwd = c.Option("-cwd |--workingdirectory <currentworkingdirectory>", "Working directory for the code compiler. Defaults to current directory.", CommandOptionType.SingleValue); c.OnExecute(async() => { int exitCode = 0; if (!string.IsNullOrWhiteSpace(code.Value)) { var optimizationLevel = OptimizationLevel.Debug; if (configuration.HasValue() && configuration.Value().ToLower() == "release") { optimizationLevel = OptimizationLevel.Release; } exitCode = await RunCode(code.Value, debugMode.HasValue(), optimizationLevel, app.RemainingArguments.Concat(argsAfterDoubleHypen), cwd.Value(), packageSources.Values?.ToArray()); } return(exitCode); }); }); app.Command("init", c => { c.Description = "Creates a sample script along with the launch.json file needed to launch and debug the script."; var fileName = c.Argument("filename", "(Optional) The name of the sample script file to be created during initialization. Defaults to 'main.csx'"); var cwd = c.Option("-cwd |--workingdirectory <currentworkingdirectory>", "Working directory for initialization. Defaults to current directory.", CommandOptionType.SingleValue); c.OnExecute(() => { var scaffolder = new Scaffolder(new ScriptLogger(ScriptConsole.Default.Error, debugMode.HasValue())); scaffolder.InitializerFolder(fileName.Value, cwd.Value() ?? Directory.GetCurrentDirectory()); return(0); }); }); app.Command("new", c => { c.Description = "Creates a new script file"; var fileNameArgument = c.Argument("filename", "The script file name"); var cwd = c.Option("-cwd |--workingdirectory <currentworkingdirectory>", "Working directory the new script file to be created. Defaults to current directory.", CommandOptionType.SingleValue); c.OnExecute(() => { var scaffolder = new Scaffolder(new ScriptLogger(ScriptConsole.Default.Error, debugMode.HasValue())); if (fileNameArgument.Value == null) { c.ShowHelp(); return(0); } scaffolder.CreateNewScriptFile(fileNameArgument.Value, cwd.Value() ?? Directory.GetCurrentDirectory()); return(0); }); }); app.Command("publish", c => { c.Description = "Creates a self contained executable or DLL from a script"; var fileNameArgument = c.Argument("filename", "The script file name"); var publishDirectoryOption = c.Option("-o |--output", "Directory where the published executable should be placed. Defaults to a 'publish' folder in the current directory.", CommandOptionType.SingleValue); var dllName = c.Option("-n |--name", "The name for the generated DLL (executable not supported at this time). Defaults to the name of the script.", CommandOptionType.SingleValue); var dllOption = c.Option("--dll", "Publish to a .dll instead of an executable.", CommandOptionType.NoValue); var commandConfig = c.Option("-c | --configuration <configuration>", "Configuration to use for publishing the script [Release/Debug]. Default is \"Debug\"", CommandOptionType.SingleValue); var publishDebugMode = c.Option(DebugFlagShort + " | " + DebugFlagLong, "Enables debug output.", CommandOptionType.NoValue); var runtime = c.Option("-r |--runtime", "The runtime used when publishing the self contained executable. Defaults to your current runtime.", CommandOptionType.SingleValue); c.OnExecute(() => { if (fileNameArgument.Value == null) { c.ShowHelp(); return(0); } var optimizationLevel = OptimizationLevel.Debug; if (commandConfig.HasValue() && commandConfig.Value().ToLower() == "release") { optimizationLevel = OptimizationLevel.Release; } var runtimeIdentifier = runtime.Value() ?? ScriptEnvironment.Default.RuntimeIdentifier; var absoluteFilePath = Path.IsPathRooted(fileNameArgument.Value) ? fileNameArgument.Value : Path.Combine(Directory.GetCurrentDirectory(), fileNameArgument.Value); // if a publish directory has been specified, then it is used directly, otherwise: // -- for EXE {current dir}/publish/{runtime ID} // -- for DLL {current dir}/publish var publishDirectory = publishDirectoryOption.Value() ?? (dllOption.HasValue() ? Path.Combine(Path.GetDirectoryName(absoluteFilePath), "publish") : Path.Combine(Path.GetDirectoryName(absoluteFilePath), "publish", runtimeIdentifier)); var absolutePublishDirectory = Path.IsPathRooted(publishDirectory) ? publishDirectory : Path.Combine(Directory.GetCurrentDirectory(), publishDirectory); var logFactory = GetLogFactory(); var compiler = GetScriptCompiler(publishDebugMode.HasValue()); var scriptEmmiter = new ScriptEmitter(ScriptConsole.Default, compiler); var publisher = new ScriptPublisher(logFactory, scriptEmmiter); var code = SourceText.From(File.ReadAllText(absoluteFilePath)); var context = new ScriptContext(code, absolutePublishDirectory, Enumerable.Empty <string>(), absoluteFilePath, optimizationLevel); if (dllOption.HasValue()) { publisher.CreateAssembly <int, CommandLineScriptGlobals>(context, logFactory, dllName.Value()); } else { publisher.CreateExecutable <int, CommandLineScriptGlobals>(context, logFactory, runtimeIdentifier); } return(0); LogFactory GetLogFactory() { var logger = new ScriptLogger(ScriptConsole.Default.Error, publishDebugMode.HasValue()); return(type => ((level, message) => { if (level == LogLevel.Debug) { logger.Verbose(message); } if (level == LogLevel.Info) { logger.Log(message); } })); } }); }); app.Command("exec", c => { c.Description = "Run a script from a DLL."; var dllPath = c.Argument("dll", "Path to DLL based script"); var commandDebugMode = c.Option(DebugFlagShort + " | " + DebugFlagLong, "Enables debug output.", CommandOptionType.NoValue); c.OnExecute(async() => { int exitCode = 0; if (!string.IsNullOrWhiteSpace(dllPath.Value)) { if (!File.Exists(dllPath.Value)) { throw new Exception($"Couldn't find file '{dllPath.Value}'"); } var absoluteFilePath = Path.IsPathRooted(dllPath.Value) ? dllPath.Value : Path.Combine(Directory.GetCurrentDirectory(), dllPath.Value); var compiler = GetScriptCompiler(commandDebugMode.HasValue()); var runner = new ScriptRunner(compiler, compiler.Logger, ScriptConsole.Default); var result = await runner.Execute <int>(absoluteFilePath); return(result); } return(exitCode); }); }); app.OnExecute(async() => { int exitCode = 0; if (infoOption.HasValue()) { Console.Write(GetEnvironmentInfo()); return(0); } if (!string.IsNullOrWhiteSpace(file.Value)) { var optimizationLevel = OptimizationLevel.Debug; if (configuration.HasValue() && configuration.Value().ToLower() == "release") { optimizationLevel = OptimizationLevel.Release; } exitCode = await RunScript(file.Value, debugMode.HasValue(), optimizationLevel, app.RemainingArguments.Concat(argsAfterDoubleHypen), interactive.HasValue(), packageSources.Values?.ToArray()); } else { await RunInteractive(debugMode.HasValue(), packageSources.Values?.ToArray()); } return(exitCode); }); return(app.Execute(argsBeforeDoubleHyphen)); }
/// <summary> /// Initializes a new insstance of the <see cref="ScriptParser"/> class. /// </summary> public ScriptParser(ScriptLogger logger) { _logger = logger; }
public LegacyDependencyResolver(ScriptLogger logger) { _logger = logger; }
public void TestInitialize() { provider = new FileSystemBlockProvider(); //provider = new BlockExplorerProvider(); logger = new ScriptLogger(); }
public DependencyResolver(CommandRunner commandRunner, ScriptLogger logger) { _commandRunner = commandRunner; _logger = logger; }
/// <summary> /// Start a debuggee under a native debugger returning a sos runner instance. /// </summary> /// <param name="config">test configuration</param> /// <param name="output">output instance</param> /// <param name="testName">name of test</param> /// <param name="debuggeeName">debuggee name</param> /// <param name="debuggeeArguments">optional args to pass to debuggee</param> /// <param name="options">dump options</param> /// <returns>sos runner instance</returns> public static async Task <SOSRunner> StartDebugger(TestConfiguration config, ITestOutputHelper output, string testName, string debuggeeName, string debuggeeArguments = null, Options options = Options.None) { TestRunner.OutputHelper outputHelper = null; SOSRunner sosRunner = null; // Figure out which native debugger to use NativeDebugger debugger = GetNativeDebuggerToUse(config, options); try { // Setup the logging from the options in the config file outputHelper = TestRunner.ConfigureLogging(config, output, testName); // Restore and build the debuggee. DebuggeeConfiguration debuggeeConfig = await DebuggeeCompiler.Execute(config, debuggeeName, outputHelper); outputHelper.WriteLine("SOSRunner processing {0}", testName); outputHelper.WriteLine("{"); var variables = GenerateVariables(config, debuggeeConfig, options); var scriptLogger = new ScriptLogger(debugger, outputHelper.IndentedOutput); if (options == Options.LoadDump || options == Options.LoadDumpWithDotNetDump) { if (!variables.TryGetValue("%DUMP_NAME%", out string dumpName) || !File.Exists(dumpName)) { throw new FileNotFoundException($"Dump file does not exist: {dumpName ?? ""}"); } } // Get the full debuggee launch command line (includes the host if required) var debuggeeCommandLine = new StringBuilder(); if (!string.IsNullOrWhiteSpace(config.HostExe)) { debuggeeCommandLine.Append(config.HostExe); debuggeeCommandLine.Append(" "); if (!string.IsNullOrWhiteSpace(config.HostArgs)) { debuggeeCommandLine.Append(config.HostArgs); debuggeeCommandLine.Append(" "); } } debuggeeCommandLine.Append(debuggeeConfig.BinaryExePath); if (!string.IsNullOrWhiteSpace(debuggeeArguments)) { debuggeeCommandLine.Append(" "); debuggeeCommandLine.Append(debuggeeArguments); } // Get the native debugger path string debuggerPath = GetNativeDebuggerPath(debugger, config); if (string.IsNullOrWhiteSpace(debuggerPath) || !File.Exists(debuggerPath)) { throw new FileNotFoundException($"Native debugger path not set or does not exist: {debuggerPath}"); } // Get the debugger arguments and commands to run initially List <string> initialCommands = new List <string>(); var arguments = new StringBuilder(); switch (debugger) { case NativeDebugger.Cdb: string helperExtension = config.CDBHelperExtension(); if (string.IsNullOrWhiteSpace(helperExtension) || !File.Exists(helperExtension)) { throw new ArgumentException($"CDB helper script path not set or does not exist: {helperExtension}"); } arguments.AppendFormat(@"-c "".load {0}""", helperExtension); if (options == Options.LoadDump) { arguments.Append(" -z %DUMP_NAME%"); } else { arguments.AppendFormat(" -Gsins {0}", debuggeeCommandLine); // disable stopping on integer divide-by-zero and integer overflow exceptions initialCommands.Add("sxd dz"); initialCommands.Add("sxd iov"); } initialCommands.Add(".sympath %DEBUG_ROOT%"); initialCommands.Add(".extpath " + Path.GetDirectoryName(config.SOSPath())); // Add the path to runtime so cdb/sos can find mscordbi. string runtimeSymbolsPath = config.RuntimeSymbolsPath; if (runtimeSymbolsPath != null) { initialCommands.Add(".sympath+ " + runtimeSymbolsPath); } // Turn off warnings that can happen in the middle of a command's output initialCommands.Add(".outmask- 4"); break; case NativeDebugger.Lldb: // Get the lldb python script file path necessary to capture the output of commands // by printing a prompt after all the command output is printed. string lldbHelperScript = config.LLDBHelperScript(); if (string.IsNullOrWhiteSpace(lldbHelperScript) || !File.Exists(lldbHelperScript)) { throw new ArgumentException("LLDB helper script path not set or does not exist: " + lldbHelperScript); } arguments.AppendFormat(@"--no-lldbinit -o ""settings set interpreter.prompt-on-quit false"" -o ""command script import {0}"" -o ""version""", lldbHelperScript); // Load the dump or launch the debuggee process if (options == Options.LoadDump) { initialCommands.Add($@"target create --core ""%DUMP_NAME%"" ""{config.HostExe}"""); } else { var sb = new StringBuilder("settings set -- target.run-args"); if (!string.IsNullOrWhiteSpace(config.HostArgs)) { string[] args = ReplaceVariables(variables, config.HostArgs).Trim().Split(' '); foreach (string arg in args) { sb.AppendFormat(@" ""{0}""", arg); } } sb.AppendFormat(@" ""{0}""", debuggeeConfig.BinaryExePath); if (!string.IsNullOrWhiteSpace(debuggeeArguments)) { string[] args = ReplaceVariables(variables, debuggeeArguments).Trim().Split(' '); foreach (string arg in args) { sb.AppendFormat(@" ""{0}""", arg); } } initialCommands.Add($@"target create ""{config.HostExe}"""); initialCommands.Add(sb.ToString()); initialCommands.Add("process launch -s"); // .NET Core 1.1 or less don't catch stack overflow and abort so need to catch SIGSEGV if (config.StackOverflowSIGSEGV) { initialCommands.Add("process handle -s true -n true -p true SIGSEGV"); } else { initialCommands.Add("process handle -s false -n false -p true SIGSEGV"); } initialCommands.Add("process handle -s false -n false -p true SIGFPE"); initialCommands.Add("process handle -s true -n true -p true SIGABRT"); } break; case NativeDebugger.Gdb: if (options == Options.LoadDump || options == Options.LoadDumpWithDotNetDump) { throw new ArgumentException("GDB not meant for loading core dumps"); } arguments.AppendFormat("--args {0}", debuggeeCommandLine); // .NET Core 1.1 or less don't catch stack overflow and abort so need to catch SIGSEGV if (config.StackOverflowSIGSEGV) { initialCommands.Add("handle SIGSEGV stop print"); } else { initialCommands.Add("handle SIGSEGV nostop noprint"); } initialCommands.Add("handle SIGFPE nostop noprint"); initialCommands.Add("handle SIGABRT stop print"); initialCommands.Add("set startup-with-shell off"); initialCommands.Add("set use-coredump-filter on"); initialCommands.Add("run"); break; case NativeDebugger.DotNetDump: if (options != Options.LoadDumpWithDotNetDump) { throw new ArgumentException($"{options} not supported for dotnet-dump testing"); } if (string.IsNullOrWhiteSpace(config.HostExe)) { throw new ArgumentException("No HostExe in configuration"); } arguments.Append(debuggerPath); arguments.Append(@" analyze %DUMP_NAME%"); debuggerPath = config.HostExe; break; } // Create the native debugger process running ProcessRunner processRunner = new ProcessRunner(debuggerPath, ReplaceVariables(variables, arguments.ToString())). WithLog(scriptLogger). WithTimeout(TimeSpan.FromMinutes(10)); // Create the sos runner instance sosRunner = new SOSRunner(debugger, config, outputHelper, variables, scriptLogger, processRunner, options == Options.LoadDump || options == Options.LoadDumpWithDotNetDump); // Start the native debugger processRunner.Start(); // Set the coredump_filter flags on the gdb process so the coredump it // takes of the target process contains everything the tests need. if (debugger == NativeDebugger.Gdb) { initialCommands.Insert(0, string.Format("shell echo 0x3F > /proc/{0}/coredump_filter", processRunner.ProcessId)); } // Execute the initial debugger commands await sosRunner.RunCommands(initialCommands); return(sosRunner); } catch (Exception ex) { // Log the exception outputHelper?.WriteLine(ex.ToString()); // The runner needs to kill the process and dispose of the file logger sosRunner?.Dispose(); // The file logging output helper needs to be disposed to close the file outputHelper?.Dispose(); throw; } }
/// <summary> /// Deletes old Context Attachment and generate a new attachment, then parsing the context and store it to the corrosponding object. /// </summary> /// <returns></returns> public bool Parse() { if (ContextOptions.AssignedObject == null) { return(false); } Entries.Clear(); if (Owner == null) { return(false); } var LastUser = ContextOptions.AssignedObject; if (!LastUser.Value.Equals(0) && !LastUser.Equals(Owner.Serial)) { return(false); } Stealth.Client.ClearContextMenu(); Entries = new List <ContextMenuEntry>(); if (Owner == null) { return(false); } Stealth.Client.RequestContextMenu(Owner.Serial.Value); if (ContextOptions.ParserDelay > 0) { Stealth.Client.Wait(ContextOptions.ParserDelay); } var list = Stealth.Client.GetContextMenu(); if (!list.Contains("\r\n")) { const string Code = "ContextMenu Parsing Error!\nFollowing choices could solve the issue:\n* Increase Parser Delay\n* visit https://bitbucket.org/Stealthadmin/stealth-beta-client/issue/11/70411-update"; ScriptLogger.WriteLine(Code); return(false); } list = list.Replace("\r\n", ContextOptions.ParserSymbol.ToString()); var s = list.Split(ContextOptions.ParserSymbol); Entries.Clear(); foreach (var e in s) { Entries.Add(new ContextMenuEntry(e, this)); } ContextOptions.AssignedObject = Owner.Serial; return(true); }