コード例 #1
0
ファイル: Breakpoints.cs プロジェクト: skyformat99/MIEngine
        internal static async Task <BindResult> Bind(string documentName, uint line, uint column, DebuggedProcess process, string condition, AD7PendingBreakpoint pbreak)
        {
            process.VerifyNotDebuggingCoreDump();

            string basename = System.IO.Path.GetFileName(documentName);     // get basename from Windows path

            return(EvalBindResult(await process.MICommandFactory.BreakInsert(process.EscapePath(basename), line, condition, ResultClass.None), pbreak));
        }
コード例 #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.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")));
        }
コード例 #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);
        }
コード例 #4
0
ファイル: Breakpoints.cs プロジェクト: mmitche/MIEngine
        internal static async Task <BindResult> Bind(string documentName, uint line, uint column, DebuggedProcess process, string condition, AD7PendingBreakpoint pbreak)
        {
            process.VerifyNotDebuggingCoreDump();

            string basename = System.IO.Path.GetFileName(documentName);     // get basename from Windows path

            basename = process.EscapePath(basename);
            BindResult bindResults = EvalBindResult(await process.MICommandFactory.BreakInsert(basename, line, condition, ResultClass.None), pbreak);

            // On GDB, the returned line information is from the pending breakpoint instead of the bound breakpoint.
            // Check the address mapping to make sure the line info is correct.
            if (process.MICommandFactory.Mode == MIMode.Gdb &&
                bindResults.BoundBreakpoints != null)
            {
                foreach (var boundBreakpoint in bindResults.BoundBreakpoints)
                {
                    boundBreakpoint.Line = await process.LineForStartAddress(basename, boundBreakpoint.Addr);
                }
            }

            return(bindResults);
        }
コード例 #5
0
ファイル: SourceLine.cs プロジェクト: yizhang82/MIEngine
        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");

                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);
        }
コード例 #6
0
ファイル: Breakpoints.cs プロジェクト: orestst/MIEngine
 internal static async Task<BindResult> Bind(string documentName, uint line, uint column, DebuggedProcess process, string condition, AD7PendingBreakpoint pbreak)
 {
     string basename = System.IO.Path.GetFileName(documentName);     // get basename from Windows path
     return EvalBindResult(await process.MICommandFactory.BreakInsert(process.EscapePath(basename), line, condition, ResultClass.None), pbreak);
 }
コード例 #7
0
ファイル: Breakpoints.cs プロジェクト: yeaicc/MIEngine
        internal static async Task<BindResult> Bind(string documentName, uint line, uint column, DebuggedProcess process, string condition, AD7PendingBreakpoint pbreak)
        {
            process.VerifyNotDebuggingCoreDump();

            string basename = System.IO.Path.GetFileName(documentName);     // get basename from Windows path
            basename = process.EscapePath(basename);
            BindResult bindResults = EvalBindResult(await process.MICommandFactory.BreakInsert(basename, line, condition, ResultClass.None), pbreak);

            // On GDB, the returned line information is from the pending breakpoint instead of the bound breakpoint.
            // Check the address mapping to make sure the line info is correct.
            if (process.MICommandFactory.Mode == MIMode.Gdb &&
                bindResults.BoundBreakpoints != null)
            {
                foreach (var boundBreakpoint in bindResults.BoundBreakpoints)
                {
                    boundBreakpoint.Line = await process.LineForStartAddress(basename, boundBreakpoint.Addr);
                }
            }

            return bindResults;
        }
コード例 #8
0
ファイル: Disassembly.cs プロジェクト: lsgxeva/MIEngine
        // 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"));
        }
コード例 #9
0
        internal static async Task <BindResult> Bind(string documentName, uint line, uint column, DebuggedProcess process, string condition, AD7PendingBreakpoint pbreak)
        {
            string  basename   = System.IO.Path.GetFileName(documentName);  // get basename from Windows path
            Results bindResult = await process.MICommandFactory.BreakInsert(process.EscapePath(basename), line, condition, ResultClass.None);

            string errormsg = "Unknown error";

            if (bindResult.ResultClass == ResultClass.error)
            {
                if (bindResult.Contains("msg"))
                {
                    errormsg = bindResult.FindString("msg");
                }
                if (String.IsNullOrWhiteSpace(errormsg))
                {
                    errormsg = "Unknown error";
                }
                return(new BindResult(errormsg));
            }
            else if (bindResult.ResultClass != ResultClass.done)
            {
                return(new BindResult(errormsg));
            }
            TupleValue     bkpt = null;
            ValueListValue list = null;

            if (bindResult.Contains("bkpt"))
            {
                ResultValue b = bindResult.Find("bkpt");
                if (b is TupleValue)
                {
                    bkpt = b as TupleValue;
                }
                else if (b is ValueListValue)
                {
                    // "<MULTIPLE>" sometimes includes a list of bound breakpoints
                    list = b as ValueListValue;
                    bkpt = list.Content[0] as TupleValue;
                }
            }
            else
            {
                // If the source file is not found, "done" is the result without a binding
                // (the error is sent via an "&" string and hence lost)
                return(new BindResult(errormsg));
            }
            Debug.Assert(bkpt.FindString("type") == "breakpoint");

            string number = bkpt.FindString("number");
            string addr   = bkpt.TryFindString("addr");

            PendingBreakpoint bp = new PendingBreakpoint(pbreak, number, StringToBreakpointState(addr));

            if (list == null)   // single breakpoint
            {
                BoundBreakpoint bbp = bp.GetBoundBreakpoint(bkpt);

                if (bbp == null)
                {
                    return(new BindResult(bp, MICoreResources.Status_BreakpointPending));
                }
                return(new BindResult(bp, bbp));
            }
            else   // <MULTIPLE> with list of addresses
            {
                BindResult res = new BindResult(bp);
                for (int i = 1; i < list.Content.Length; ++i)
                {
                    BoundBreakpoint bbp = bp.GetBoundBreakpoint(list.Content[i] as TupleValue);
                    res.BoundBreakpoints.Add(bbp);
                }
                return(res);
            }
        }
コード例 #10
0
ファイル: Breakpoints.cs プロジェクト: lsgxeva/MIEngine
        internal static async Task<BindResult> Bind(string documentName, uint line, uint column, DebuggedProcess process, string condition, AD7PendingBreakpoint pbreak)
        {
            string basename = System.IO.Path.GetFileName(documentName);     // get basename from Windows path
            Results bindResult = await process.MICommandFactory.BreakInsert(process.EscapePath(basename), line, condition, ResultClass.None);
            string errormsg = "Unknown error";
            if (bindResult.ResultClass == ResultClass.error)
            {
                if (bindResult.Contains("msg"))
                {
                    errormsg = bindResult.FindString("msg");
                }
                if (String.IsNullOrWhiteSpace(errormsg))
                {
                    errormsg = "Unknown error";
                }
                return new BindResult(errormsg);
            }
            else if (bindResult.ResultClass != ResultClass.done)
            {
                return new BindResult(errormsg);
            }
            TupleValue bkpt = null;
            ValueListValue list = null;
            if (bindResult.Contains("bkpt"))
            {
                ResultValue b = bindResult.Find("bkpt");
                if (b is TupleValue)
                {
                    bkpt = b as TupleValue;
                }
                else if (b is ValueListValue)
                {
                    // "<MULTIPLE>" sometimes includes a list of bound breakpoints
                    list = b as ValueListValue;
                    bkpt = list.Content[0] as TupleValue;
                }
            }
            else
            {
                // If the source file is not found, "done" is the result without a binding
                // (the error is sent via an "&" string and hence lost)
                return new BindResult(errormsg);
            }
            Debug.Assert(bkpt.FindString("type") == "breakpoint");

            string number = bkpt.FindString("number");
            string addr = bkpt.TryFindString("addr");

            PendingBreakpoint bp = new PendingBreakpoint(pbreak, number, StringToBreakpointState(addr));
            if (list == null)   // single breakpoint
            {
                BoundBreakpoint bbp = bp.GetBoundBreakpoint(bkpt);

                if (bbp == null)
                {
                    return new BindResult(bp, MICoreResources.Status_BreakpointPending);
                }
                return new BindResult(bp, bbp);
            }
            else   // <MULTIPLE> with list of addresses
            {
                BindResult res = new BindResult(bp);
                for (int i = 1; i < list.Content.Length; ++i)
                {
                    BoundBreakpoint bbp = bp.GetBoundBreakpoint(list.Content[i] as TupleValue);
                    res.BoundBreakpoints.Add(bbp);
                }
                return res;
            }
        }