public BreakpointLocationCodeAddress(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires<ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_CODE_ADDRESS);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                    _context = Marshal.PtrToStringBSTR(location.unionmember1);
                if (location.unionmember2 != IntPtr.Zero)
                    _moduleUrl = Marshal.PtrToStringBSTR(location.unionmember2);
                if (location.unionmember3 != IntPtr.Zero)
                    _function = Marshal.PtrToStringBSTR(location.unionmember3);
                if (location.unionmember4 != IntPtr.Zero)
                    _address = Marshal.PtrToStringBSTR(location.unionmember4);
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                        Marshal.FreeBSTR(location.unionmember1);
                    if (location.unionmember2 != IntPtr.Zero)
                        Marshal.FreeBSTR(location.unionmember2);
                    if (location.unionmember3 != IntPtr.Zero)
                        Marshal.FreeBSTR(location.unionmember3);
                    if (location.unionmember4 != IntPtr.Zero)
                        Marshal.FreeBSTR(location.unionmember4);
                }
            }
        }
        public BreakpointLocationCodeFileLine(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires <ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                {
                    _context = Marshal.PtrToStringBSTR(location.unionmember1);
                }
                if (location.unionmember2 != IntPtr.Zero)
                {
                    _documentPosition = Marshal.GetObjectForIUnknown(location.unionmember2) as IDebugDocumentPosition2;
                }
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                    {
                        Marshal.FreeBSTR(location.unionmember1);
                    }
                    if (location.unionmember2 != IntPtr.Zero)
                    {
                        Marshal.Release(location.unionmember2);
                    }
                }
            }
        }
        public BreakpointLocationCodeString(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires <ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_CODE_STRING);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                {
                    _context = Marshal.PtrToStringBSTR(location.unionmember1);
                }
                if (location.unionmember2 != IntPtr.Zero)
                {
                    _codeExpression = Marshal.PtrToStringBSTR(location.unionmember2);
                }
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                    {
                        Marshal.FreeBSTR(location.unionmember1);
                    }
                    if (location.unionmember2 != IntPtr.Zero)
                    {
                        Marshal.FreeBSTR(location.unionmember2);
                    }
                }
            }
        }
        public BreakpointLocationCodeAddress(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires <ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_CODE_ADDRESS);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                {
                    _context = Marshal.PtrToStringBSTR(location.unionmember1);
                }
                if (location.unionmember2 != IntPtr.Zero)
                {
                    _moduleUrl = Marshal.PtrToStringBSTR(location.unionmember2);
                }
                if (location.unionmember3 != IntPtr.Zero)
                {
                    _function = Marshal.PtrToStringBSTR(location.unionmember3);
                }
                if (location.unionmember4 != IntPtr.Zero)
                {
                    _address = Marshal.PtrToStringBSTR(location.unionmember4);
                }
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                    {
                        Marshal.FreeBSTR(location.unionmember1);
                    }
                    if (location.unionmember2 != IntPtr.Zero)
                    {
                        Marshal.FreeBSTR(location.unionmember2);
                    }
                    if (location.unionmember3 != IntPtr.Zero)
                    {
                        Marshal.FreeBSTR(location.unionmember3);
                    }
                    if (location.unionmember4 != IntPtr.Zero)
                    {
                        Marshal.FreeBSTR(location.unionmember4);
                    }
                }
            }
        }
        public BreakpointLocationCodeContext(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires<ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_CODE_CONTEXT);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                    _codeContext = Marshal.GetObjectForIUnknown(location.unionmember2) as IDebugCodeContext2;
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                        Marshal.Release(location.unionmember1);
                }
            }
        }
        public BreakpointLocationResolution(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires<ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_RESOLUTION);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                    _resolution = Marshal.GetObjectForIUnknown(location.unionmember1) as IDebugBreakpointResolution2;
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                        Marshal.Release(location.unionmember1);
                }
            }
        }
        public BreakpointLocationDataString(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires <ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_DATA_STRING);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                {
                    _thread = Marshal.GetObjectForIUnknown(location.unionmember1) as IDebugThread2;
                }
                if (location.unionmember2 != IntPtr.Zero)
                {
                    _context = Marshal.PtrToStringBSTR(location.unionmember2);
                }
                if (location.unionmember3 != IntPtr.Zero)
                {
                    _dataExpression = Marshal.PtrToStringBSTR(location.unionmember3);
                }

                _elementCount = (uint)location.unionmember4;
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                    {
                        Marshal.Release(location.unionmember1);
                    }
                    if (location.unionmember2 != IntPtr.Zero)
                    {
                        Marshal.FreeBSTR(location.unionmember2);
                    }
                    if (location.unionmember3 != IntPtr.Zero)
                    {
                        Marshal.FreeBSTR(location.unionmember3);
                    }
                }
            }
        }
        public BreakpointLocationCodeString(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires<ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_CODE_STRING);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                    _context = Marshal.PtrToStringBSTR(location.unionmember1);
                if (location.unionmember2 != IntPtr.Zero)
                    _codeExpression = Marshal.PtrToStringBSTR(location.unionmember2);
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                        Marshal.FreeBSTR(location.unionmember1);
                    if (location.unionmember2 != IntPtr.Zero)
                        Marshal.FreeBSTR(location.unionmember2);
                }
            }
        }
        public BreakpointLocationCodeFileLine(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires<ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                    _context = Marshal.PtrToStringBSTR(location.unionmember1);
                if (location.unionmember2 != IntPtr.Zero)
                    _documentPosition = Marshal.GetObjectForIUnknown(location.unionmember2) as IDebugDocumentPosition2;
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                        Marshal.FreeBSTR(location.unionmember1);
                    if (location.unionmember2 != IntPtr.Zero)
                        Marshal.Release(location.unionmember2);
                }
            }
        }
        public BreakpointLocationCodeContext(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires <ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_CODE_CONTEXT);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                {
                    _codeContext = Marshal.GetObjectForIUnknown(location.unionmember2) as IDebugCodeContext2;
                }
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                    {
                        Marshal.Release(location.unionmember1);
                    }
                }
            }
        }
        public BreakpointLocationResolution(BP_LOCATION location, bool releaseComObjects)
        {
            Contract.Requires <ArgumentException>((enum_BP_LOCATION_TYPE)location.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_RESOLUTION);

            try
            {
                if (location.unionmember1 != IntPtr.Zero)
                {
                    _resolution = Marshal.GetObjectForIUnknown(location.unionmember1) as IDebugBreakpointResolution2;
                }
            }
            finally
            {
                if (releaseComObjects)
                {
                    if (location.unionmember1 != IntPtr.Zero)
                    {
                        Marshal.Release(location.unionmember1);
                    }
                }
            }
        }
        public static BreakpointLocation FromNativeForm(BP_LOCATION location, bool releaseComObjects)
        {
            switch ((enum_BP_LOCATION_TYPE)location.bpLocationType)
            {
            case enum_BP_LOCATION_TYPE.BPLT_CODE_ADDRESS:
                return(new BreakpointLocationCodeAddress(location, releaseComObjects));

            case enum_BP_LOCATION_TYPE.BPLT_CODE_CONTEXT:
                return(new BreakpointLocationCodeContext(location, releaseComObjects));

            case enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE:
                return(new BreakpointLocationCodeFileLine(location, releaseComObjects));

            case enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET:
                return(new BreakpointLocationCodeFunctionOffset(location, releaseComObjects));

            case enum_BP_LOCATION_TYPE.BPLT_CODE_STRING:
                return(new BreakpointLocationCodeString(location, releaseComObjects));

            case enum_BP_LOCATION_TYPE.BPLT_DATA_STRING:
                return(new BreakpointLocationDataString(location, releaseComObjects));

            case enum_BP_LOCATION_TYPE.BPLT_RESOLUTION:
                return(new BreakpointLocationResolution(location, releaseComObjects));

            case enum_BP_LOCATION_TYPE.BPLT_NONE:
            case enum_BP_LOCATION_TYPE.BPLT_STRING:
            case enum_BP_LOCATION_TYPE.BPLT_TYPE_MASK:
            case enum_BP_LOCATION_TYPE.BPLT_CONTEXT:
            case enum_BP_LOCATION_TYPE.BPLT_ADDRESS:
            case enum_BP_LOCATION_TYPE.BPLT_FILE_LINE:
            case enum_BP_LOCATION_TYPE.BPLT_FUNC_OFFSET:
            case enum_BP_LOCATION_TYPE.BPLT_LOCATION_TYPE_MASK:
            default:
                throw new ArgumentException();
            }
        }
Ejemplo n.º 13
0
        public static BreakpointLocation FromNativeForm(BP_LOCATION location, bool releaseComObjects)
        {
            switch ((enum_BP_LOCATION_TYPE)location.bpLocationType)
            {
            case enum_BP_LOCATION_TYPE.BPLT_CODE_ADDRESS:
                return new BreakpointLocationCodeAddress(location, releaseComObjects);

            case enum_BP_LOCATION_TYPE.BPLT_CODE_CONTEXT:
                return new BreakpointLocationCodeContext(location, releaseComObjects);

            case enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE:
                return new BreakpointLocationCodeFileLine(location, releaseComObjects);

            case enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET:
                return new BreakpointLocationCodeFunctionOffset(location, releaseComObjects);

            case enum_BP_LOCATION_TYPE.BPLT_CODE_STRING:
                return new BreakpointLocationCodeString(location, releaseComObjects);

            case enum_BP_LOCATION_TYPE.BPLT_DATA_STRING:
                return new BreakpointLocationDataString(location, releaseComObjects);

            case enum_BP_LOCATION_TYPE.BPLT_RESOLUTION:
                return new BreakpointLocationResolution(location, releaseComObjects);

            case enum_BP_LOCATION_TYPE.BPLT_NONE:
            case enum_BP_LOCATION_TYPE.BPLT_STRING:
            case enum_BP_LOCATION_TYPE.BPLT_TYPE_MASK:
            case enum_BP_LOCATION_TYPE.BPLT_CONTEXT:
            case enum_BP_LOCATION_TYPE.BPLT_ADDRESS:
            case enum_BP_LOCATION_TYPE.BPLT_FILE_LINE:
            case enum_BP_LOCATION_TYPE.BPLT_FUNC_OFFSET:
            case enum_BP_LOCATION_TYPE.BPLT_LOCATION_TYPE_MASK:
            default:
                throw new ArgumentException();
            }
        }