Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add some pointer/offset alignment checking to the managed virtual table subsystem. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
0621d7037c76f5f4fb6a656a285b8c2b |
User & Date: | mistachkin 2018-01-12 19:37:16.726 |
References
2018-01-15
| ||
18:18 | Correct and enhance the alignment diagnostics added by check-in [0621d7037c]. check-in: 7ca42fb6c0 user: mistachkin tags: trunk | |
Context
2018-01-15
| ||
17:20 | Fix compilation of the design-time components project using the latest Visual Studio 2017 update. check-in: ad7af0b258 user: mistachkin tags: trunk | |
2018-01-12
| ||
19:37 | Add some pointer/offset alignment checking to the managed virtual table subsystem. check-in: 0621d7037c user: mistachkin tags: trunk | |
2018-01-11
| ||
20:44 | Update SQLite core library to the latest trunk code. check-in: 356e9a22b6 user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLiteModule.cs.
︙ | ︙ | |||
4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 | /// The <see cref="Int32" /> value at the specified memory location. /// </returns> public static int ReadInt32( IntPtr pointer, int offset ) { #if !PLATFORM_COMPACTFRAMEWORK return Marshal.ReadInt32(pointer, offset); #else return Marshal.ReadInt32(IntPtrForOffset(pointer, offset)); #endif } | > > > > | 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 | /// The <see cref="Int32" /> value at the specified memory location. /// </returns> public static int ReadInt32( IntPtr pointer, int offset ) { #if DEBUG CheckAlignment("ReadInt32", pointer, offset); #endif #if !PLATFORM_COMPACTFRAMEWORK return Marshal.ReadInt32(pointer, offset); #else return Marshal.ReadInt32(IntPtrForOffset(pointer, offset)); #endif } |
︙ | ︙ | |||
4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 | /// The <see cref="Int64" /> value at the specified memory location. /// </returns> public static long ReadInt64( IntPtr pointer, int offset ) { #if !PLATFORM_COMPACTFRAMEWORK return Marshal.ReadInt64(pointer, offset); #else return Marshal.ReadInt64(IntPtrForOffset(pointer, offset)); #endif } | > > > > | 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 | /// The <see cref="Int64" /> value at the specified memory location. /// </returns> public static long ReadInt64( IntPtr pointer, int offset ) { #if DEBUG CheckAlignment("ReadInt64", pointer, offset); #endif #if !PLATFORM_COMPACTFRAMEWORK return Marshal.ReadInt64(pointer, offset); #else return Marshal.ReadInt64(IntPtrForOffset(pointer, offset)); #endif } |
︙ | ︙ | |||
4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 | /// The <see cref="Double" /> value at the specified memory location. /// </returns> public static double ReadDouble( IntPtr pointer, int offset ) { #if !PLATFORM_COMPACTFRAMEWORK return BitConverter.Int64BitsToDouble(Marshal.ReadInt64( pointer, offset)); #else return BitConverter.ToDouble(BitConverter.GetBytes( Marshal.ReadInt64(IntPtrForOffset(pointer, offset))), 0); #endif | > > > > | 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 | /// The <see cref="Double" /> value at the specified memory location. /// </returns> public static double ReadDouble( IntPtr pointer, int offset ) { #if DEBUG CheckAlignment("ReadDouble", pointer, offset); #endif #if !PLATFORM_COMPACTFRAMEWORK return BitConverter.Int64BitsToDouble(Marshal.ReadInt64( pointer, offset)); #else return BitConverter.ToDouble(BitConverter.GetBytes( Marshal.ReadInt64(IntPtrForOffset(pointer, offset))), 0); #endif |
︙ | ︙ | |||
4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 | /// The <see cref="IntPtr" /> value at the specified memory location. /// </returns> public static IntPtr ReadIntPtr( IntPtr pointer, int offset ) { #if !PLATFORM_COMPACTFRAMEWORK return Marshal.ReadIntPtr(pointer, offset); #else return Marshal.ReadIntPtr(IntPtrForOffset(pointer, offset)); #endif } #endregion | > > > > | 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 | /// The <see cref="IntPtr" /> value at the specified memory location. /// </returns> public static IntPtr ReadIntPtr( IntPtr pointer, int offset ) { #if DEBUG CheckAlignment("ReadIntPtr", pointer, offset); #endif #if !PLATFORM_COMPACTFRAMEWORK return Marshal.ReadIntPtr(pointer, offset); #else return Marshal.ReadIntPtr(IntPtrForOffset(pointer, offset)); #endif } #endregion |
︙ | ︙ | |||
4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 | /// </param> public static void WriteInt32( IntPtr pointer, int offset, int value ) { #if !PLATFORM_COMPACTFRAMEWORK Marshal.WriteInt32(pointer, offset, value); #else Marshal.WriteInt32(IntPtrForOffset(pointer, offset), value); #endif } | > > > > | 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 | /// </param> public static void WriteInt32( IntPtr pointer, int offset, int value ) { #if DEBUG CheckAlignment("WriteInt32", pointer, offset); #endif #if !PLATFORM_COMPACTFRAMEWORK Marshal.WriteInt32(pointer, offset, value); #else Marshal.WriteInt32(IntPtrForOffset(pointer, offset), value); #endif } |
︙ | ︙ | |||
4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 | /// </param> public static void WriteInt64( IntPtr pointer, int offset, long value ) { #if !PLATFORM_COMPACTFRAMEWORK Marshal.WriteInt64(pointer, offset, value); #else Marshal.WriteInt64(IntPtrForOffset(pointer, offset), value); #endif } | > > > > | 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 | /// </param> public static void WriteInt64( IntPtr pointer, int offset, long value ) { #if DEBUG CheckAlignment("WriteInt64", pointer, offset); #endif #if !PLATFORM_COMPACTFRAMEWORK Marshal.WriteInt64(pointer, offset, value); #else Marshal.WriteInt64(IntPtrForOffset(pointer, offset), value); #endif } |
︙ | ︙ | |||
4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 | /// </param> public static void WriteDouble( IntPtr pointer, int offset, double value ) { #if !PLATFORM_COMPACTFRAMEWORK Marshal.WriteInt64(pointer, offset, BitConverter.DoubleToInt64Bits(value)); #else Marshal.WriteInt64(IntPtrForOffset(pointer, offset), BitConverter.ToInt64(BitConverter.GetBytes(value), 0)); #endif | > > > > | 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 | /// </param> public static void WriteDouble( IntPtr pointer, int offset, double value ) { #if DEBUG CheckAlignment("WriteDouble", pointer, offset); #endif #if !PLATFORM_COMPACTFRAMEWORK Marshal.WriteInt64(pointer, offset, BitConverter.DoubleToInt64Bits(value)); #else Marshal.WriteInt64(IntPtrForOffset(pointer, offset), BitConverter.ToInt64(BitConverter.GetBytes(value), 0)); #endif |
︙ | ︙ | |||
4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 | /// </param> public static void WriteIntPtr( IntPtr pointer, int offset, IntPtr value ) { #if !PLATFORM_COMPACTFRAMEWORK Marshal.WriteIntPtr(pointer, offset, value); #else Marshal.WriteIntPtr(IntPtrForOffset(pointer, offset), value); #endif } #endregion | > > > > > | 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 | /// </param> public static void WriteIntPtr( IntPtr pointer, int offset, IntPtr value ) { #if DEBUG CheckAlignment("WriteIntPtr(pointer)", pointer, offset); CheckAlignment("WriteIntPtr(value)", value, 0); #endif #if !PLATFORM_COMPACTFRAMEWORK Marshal.WriteIntPtr(pointer, offset, value); #else Marshal.WriteIntPtr(IntPtrForOffset(pointer, offset), value); #endif } #endregion |
︙ | ︙ | |||
4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 | return RuntimeHelpers.GetHashCode(value); #endif if (value == null) return 0; return value.GetHashCode(); } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteModule Base Class /// <summary> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 | return RuntimeHelpers.GetHashCode(value); #endif if (value == null) return 0; return value.GetHashCode(); } #endregion /////////////////////////////////////////////////////////////////////// #region Private Methods #if DEBUG private static void CheckAlignment( string type, IntPtr pointer, int offset ) { if ((pointer.ToInt64() % IntPtr.Size) != 0) { SQLiteLog.LogMessage(SQLiteErrorCode.Warning, HelperMethods.StringFormat( CultureInfo.CurrentCulture, "{0}: pointer {1} is not aligned to {2}: {3}", type, pointer, IntPtr.Size, Environment.StackTrace)); } if ((offset % IntPtr.Size) != 0) { SQLiteLog.LogMessage(SQLiteErrorCode.Warning, HelperMethods.StringFormat( CultureInfo.CurrentCulture, "{0}: offset {1} is not aligned to {2}: {3}", type, offset, IntPtr.Size, Environment.StackTrace)); } } #endif #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteModule Base Class /// <summary> |
︙ | ︙ |