Example #1
0
        // this is inefficient so we try and grab everything in one gulp
        internal static async Task <DisasmInstruction[]> Disassemble(DebuggedProcess process, ulong startAddr, ulong endAddr)
        {
            string  cmd     = "-data-disassemble -s " + EngineUtils.AsAddr(startAddr, process.Is64BitArch) + " -e " + EngineUtils.AsAddr(endAddr, process.Is64BitArch) + " -- 2";
            Results results = await process.CmdAsync(cmd, ResultClass.None);

            if (results.ResultClass != ResultClass.done)
            {
                return(null);
            }

            return(DecodeDisassemblyInstructions(results.Find <ValueListValue>("asm_insns").AsArray <TupleValue>()));
        }
Example #2
0
        // this is inefficient so we try and grab everything in one gulp
        internal async Task <IEnumerable <DisasmInstruction> > Disassemble(DebuggedProcess process, string file, uint line, uint dwInstructions)
        {
            if (file.IndexOf(' ') >= 0) // only needs escaping if filename contains a space
            {
                file = process.EscapeSymbolPath(file);
            }
            string  cmd     = "-data-disassemble -f " + file + " -l " + line.ToString(CultureInfo.InvariantCulture) + " -n " + dwInstructions.ToString(CultureInfo.InvariantCulture) + " -- 1";
            Results results = await process.CmdAsync(cmd, ResultClass.None);

            if (results.ResultClass != ResultClass.done)
            {
                return(null);
            }

            return(DecodeSourceAnnotatedDisassemblyInstructions(process, results.Find <ResultListValue>("asm_insns").FindAll <TupleValue>("src_and_asm_line")));
        }
Example #3
0
        private async Task <SourceLineMap> LinesForFile(string file)
        {
            string  cmd     = "-symbol-list-lines " + _process.EscapePath(file);
            Results results = await _process.CmdAsync(cmd, ResultClass.None);

            if (results.ResultClass != ResultClass.done)
            {
                return(null);
            }

            ValueListValue lines    = results.Find <ValueListValue>("lines");
            SourceLineMap  linesMap = new SourceLineMap(lines.Content.Length);

            for (int i = 0; i < lines.Content.Length; ++i)
            {
                ulong addr = lines.Content[i].FindAddr("pc");
                uint  line = lines.Content[i].FindUint("line");
                linesMap.Add(addr, line);
            }
            return(linesMap);
        }
Example #4
0
        private async Task <SourceLineMap> LinesForFile(string file)
        {
            string  cmd     = "-symbol-list-lines " + _process.EscapeSymbolPath(file);
            Results results = await _process.CmdAsync(cmd, ResultClass.None);

            if (results.ResultClass != ResultClass.done)
            {
                return(null);
            }

            ValueListValue lines    = results.Find <ValueListValue>("lines");
            SourceLineMap  linesMap = new SourceLineMap(lines.Content.Length);

            for (int i = 0; i < lines.Content.Length; ++i)
            {
                ulong addr = lines.Content[i].FindAddr("pc");
                uint  line = lines.Content[i].FindUint("line");

                if (linesMap.ContainsKey(addr))
                {
                    // It is actually fairly common for an address to map to more than one line. For instance,
                    // in debug builds destructors can have an entry to line 0 as well as one to the correct line.
                    // Release builds with inlining will hit this very often.
                    // Unforunately, without more context, it is impossible to know which line is the "right" line.
                    // For the inline case, any line will be acceptable. For the destructor case, we should prefer
                    // a non-zero line.
                    if (linesMap[addr].Line == 0)
                    {
                        linesMap.Replace(addr, line);
                    }
                }
                else
                {
                    linesMap.Add(addr, line);
                }
            }
            return(linesMap);
        }
Example #5
0
        // this is inefficient so we try and grab everything in one gulp
        internal async Task<IEnumerable<DisasmInstruction>> Disassemble(DebuggedProcess process, string file, uint line, uint dwInstructions)
        {
            if (file.IndexOf(' ') >= 0) // only needs escaping if filename contains a space
            {
                file = process.EscapePath(file);
            }
            string cmd = "-data-disassemble -f " + file + " -l " + line.ToString() + " -n " + dwInstructions.ToString() + " -- 1";
            Results results = await process.CmdAsync(cmd, ResultClass.None);
            if (results.ResultClass != ResultClass.done)
            {
                return null;
            }

            return DecodeSourceAnnotatedDisassemblyInstructions(results.Find<ResultListValue>("asm_insns").FindAll<TupleValue>("src_and_asm_line"));
        }
Example #6
0
        // this is inefficient so we try and grab everything in one gulp
        internal static async Task<DisasmInstruction[]> Disassemble(DebuggedProcess process, ulong startAddr, ulong endAddr)
        {
            string cmd = "-data-disassemble -s " + EngineUtils.AsAddr(startAddr, process.Is64BitArch) + " -e " + EngineUtils.AsAddr(endAddr, process.Is64BitArch) + " -- 0";
            Results results = await process.CmdAsync(cmd, ResultClass.None);
            if (results.ResultClass != ResultClass.done)
            {
                return null;
            }

            return DecodeDisassemblyInstructions(results.Find<ValueListValue>("asm_insns").AsArray<TupleValue>());
        }
Example #7
0
        private static async Task <string> ExecuteMiCommand(DebuggedProcess lastProcess, string command)
        {
            Results results = await lastProcess.CmdAsync(command, ResultClass.None);

            return(results.ToString());
        }
 private static async Task<string> ExecuteMiCommand(DebuggedProcess lastProcess, string command, bool ignoreFailures)
 {
     Results results = await lastProcess.CmdAsync(command, ignoreFailures ? ResultClass.None : ResultClass.done);
     return results.ToString();
 }
 private static async Task<string> ExecuteMiCommand(DebuggedProcess lastProcess, string command)
 {
     Results results = await lastProcess.CmdAsync(command, ResultClass.None);
     return results.ToString();
 }
Example #10
0
        private static async Task <string> ExecuteMiCommand(DebuggedProcess lastProcess, string command, bool ignoreFailures)
        {
            Results results = await lastProcess.CmdAsync(command, ignoreFailures?ResultClass.None : ResultClass.done);

            return(results.ToString());
        }