System.Data.SQLite
Check-in [a614401f38]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add TRACE_DETECTION compile-time define and modify several Trace.WriteLine calls in the native library pre-loading code to use it.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a614401f38a57e6d6fbca4bb47dd25419ab1e3bc
User & Date: mistachkin 2014-02-11 02:30:19
Context
2014-02-11
03:23
Fix variable leak in a test case. check-in: c3560a724b user: mistachkin tags: trunk
02:30
Add TRACE_DETECTION compile-time define and modify several Trace.WriteLine calls in the native library pre-loading code to use it. check-in: a614401f38 user: mistachkin tags: trunk
2014-02-10
22:17
Fix test project configuration file typos that cause EF6 tests to fail. check-in: b5c1a65c98 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SQLite.NET.Settings.targets.

437
438
439
440
441
442
443







444
445
446
447
448
449
450
  <PropertyGroup>
    <!--
        NOTE: Enable tracing of events related to connection handling?  By
              default, this is disabled.
    -->
    <TraceConnection Condition="'$(TraceConnection)' == ''">false</TraceConnection>








    <!--
        NOTE: Enable tracing of events related to CriticalHandle handling?  By
              default, this is disabled.
    -->
    <TraceHandle Condition="'$(TraceHandle)' == ''">false</TraceHandle>

    <!--







>
>
>
>
>
>
>







437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
  <PropertyGroup>
    <!--
        NOTE: Enable tracing of events related to connection handling?  By
              default, this is disabled.
    -->
    <TraceConnection Condition="'$(TraceConnection)' == ''">false</TraceConnection>

    <!--
        NOTE: Enable tracing of events related to automatic detection of the
              native library directory within the native library pre-loading
              code?  By default, this is disabled.
    -->
    <TraceDetection Condition="'$(TraceDetection)' == ''">false</TraceDetection>

    <!--
        NOTE: Enable tracing of events related to CriticalHandle handling?  By
              default, this is disabled.
    -->
    <TraceHandle Condition="'$(TraceHandle)' == ''">false</TraceHandle>

    <!--

Changes to Setup/set_user_mistachkin_Debug.bat.

11
12
13
14
15
16
17

18
19
20

REM
REM NOTE: Enables the extra debug code helpful in troubleshooting issues.
REM
SET MSBUILD_ARGS=/p:CheckState=true
SET MSBUILD_ARGS=%MSBUILD_ARGS% /p:CountHandle=true
SET MSBUILD_ARGS=%MSBUILD_ARGS% /p:TraceConnection=true

SET MSBUILD_ARGS=%MSBUILD_ARGS% /p:TraceHandle=true
SET MSBUILD_ARGS=%MSBUILD_ARGS% /p:TraceStatement=true
SET MSBUILD_ARGS=%MSBUILD_ARGS% /p:TrackMemoryBytes=true







>



11
12
13
14
15
16
17
18
19
20
21

REM
REM NOTE: Enables the extra debug code helpful in troubleshooting issues.
REM
SET MSBUILD_ARGS=/p:CheckState=true
SET MSBUILD_ARGS=%MSBUILD_ARGS% /p:CountHandle=true
SET MSBUILD_ARGS=%MSBUILD_ARGS% /p:TraceConnection=true
SET MSBUILD_ARGS=%MSBUILD_ARGS% /p:TraceDetection=true
SET MSBUILD_ARGS=%MSBUILD_ARGS% /p:TraceHandle=true
SET MSBUILD_ARGS=%MSBUILD_ARGS% /p:TraceStatement=true
SET MSBUILD_ARGS=%MSBUILD_ARGS% /p:TrackMemoryBytes=true

Changes to System.Data.SQLite/SQLiteDefineConstants.cs.

99
100
101
102
103
104
105




106
107
108
109
110
111
112
#if TRACE
            "TRACE",
#endif

#if TRACE_CONNECTION
            "TRACE_CONNECTION",
#endif





#if TRACE_HANDLE
            "TRACE_HANDLE",
#endif

#if TRACE_PRELOAD
            "TRACE_PRELOAD",







>
>
>
>







99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#if TRACE
            "TRACE",
#endif

#if TRACE_CONNECTION
            "TRACE_CONNECTION",
#endif

#if TRACE_DETECTION
            "TRACE_DETECTION",
#endif

#if TRACE_HANDLE
            "TRACE_HANDLE",
#endif

#if TRACE_PRELOAD
            "TRACE_PRELOAD",

Changes to System.Data.SQLite/System.Data.SQLite.Properties.targets.

208
209
210
211
212
213
214




215
216
217
218
219
220
221
      NOTE: Enable various Trace.WriteLine statements included in the code,
            based on several criteria (see the "SQLite.NET.Settings.targets"
            file for more information)?
  -->
  <PropertyGroup Condition="'$(TraceConnection)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_CONNECTION</DefineConstants>
  </PropertyGroup>





  <PropertyGroup Condition="'$(TraceHandle)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_HANDLE</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TracePreLoad)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_PRELOAD</DefineConstants>







>
>
>
>







208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
      NOTE: Enable various Trace.WriteLine statements included in the code,
            based on several criteria (see the "SQLite.NET.Settings.targets"
            file for more information)?
  -->
  <PropertyGroup Condition="'$(TraceConnection)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_CONNECTION</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TraceDetection)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_DETECTION</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TraceHandle)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_HANDLE</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TracePreLoad)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_PRELOAD</DefineConstants>

Changes to System.Data.SQLite/UnsafeNativeMethods.cs.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
...
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
...
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
...
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Globalization;

#if !NET_COMPACT_20 && (TRACE_PRELOAD || TRACE_HANDLE)
  using System.Diagnostics;
#endif

#if PRELOAD_NATIVE_LIBRARY
  using System.Collections.Generic;
  using System.IO;
  using System.Reflection;
................................................................................
                  localFileName); /* throw */

              string xmlConfigFileName = Path.Combine(
                  directory, XmlConfigFileName);

              if (File.Exists(xmlConfigFileName))
              {
#if !NET_COMPACT_20 && TRACE_SHARED
                  try
                  {
                      Trace.WriteLine(String.Format(
                          CultureInfo.CurrentCulture,
                          "Native library pre-loader found XML configuration file " +
                          "via code base for currently executing assembly: \"{0}\"",
                          xmlConfigFileName)); /* throw */
................................................................................
                  return true;
              }

              List<string> matches = null;

              if (CheckForArchitecturesAndPlatforms(directory, ref matches) > 0)
              {
#if !NET_COMPACT_20 && TRACE_SHARED
                  try
                  {
                      Trace.WriteLine(String.Format(
                          CultureInfo.CurrentCulture,
                          "Native library pre-loader found native sub-directories " +
                          "via code base for currently executing assembly: \"{0}\"",
                          ListToString(matches))); /* throw */
................................................................................
          //       wrong value in some circumstances.  Please refer to ticket
          //       [9ac9862611] for further information.
          //
          if ((IntPtr.Size == sizeof(int)) &&
              String.Equals(processorArchitecture, "AMD64",
                  StringComparison.OrdinalIgnoreCase))
          {
#if !NET_COMPACT_20 && TRACE_PRELOAD
              //
              // NOTE: When tracing is enabled, save the originally detected
              //       processor architecture before changing it.
              //
              string savedProcessorArchitecture = processorArchitecture;
#endif

................................................................................
              // NOTE: We know that operating systems that return "AMD64" as
              //       the processor architecture are actually a superset of
              //       the "x86" processor architecture; therefore, return
              //       "x86" when the pointer size is 32-bits.
              //
              processorArchitecture = "x86";

#if !NET_COMPACT_20 && TRACE_PRELOAD
              try
              {
                  //
                  // NOTE: Show that we hit a fairly unusual situation (i.e.
                  //       the "wrong" processor architecture was detected).
                  //
                  Trace.WriteLine(String.Format(







|







 







|







 







|







 







|







 







|







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
...
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
...
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
...
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Globalization;

#if !NET_COMPACT_20 && (TRACE_DETECTION || TRACE_SHARED || TRACE_PRELOAD || TRACE_HANDLE)
  using System.Diagnostics;
#endif

#if PRELOAD_NATIVE_LIBRARY
  using System.Collections.Generic;
  using System.IO;
  using System.Reflection;
................................................................................
                  localFileName); /* throw */

              string xmlConfigFileName = Path.Combine(
                  directory, XmlConfigFileName);

              if (File.Exists(xmlConfigFileName))
              {
#if !NET_COMPACT_20 && TRACE_DETECTION
                  try
                  {
                      Trace.WriteLine(String.Format(
                          CultureInfo.CurrentCulture,
                          "Native library pre-loader found XML configuration file " +
                          "via code base for currently executing assembly: \"{0}\"",
                          xmlConfigFileName)); /* throw */
................................................................................
                  return true;
              }

              List<string> matches = null;

              if (CheckForArchitecturesAndPlatforms(directory, ref matches) > 0)
              {
#if !NET_COMPACT_20 && TRACE_DETECTION
                  try
                  {
                      Trace.WriteLine(String.Format(
                          CultureInfo.CurrentCulture,
                          "Native library pre-loader found native sub-directories " +
                          "via code base for currently executing assembly: \"{0}\"",
                          ListToString(matches))); /* throw */
................................................................................
          //       wrong value in some circumstances.  Please refer to ticket
          //       [9ac9862611] for further information.
          //
          if ((IntPtr.Size == sizeof(int)) &&
              String.Equals(processorArchitecture, "AMD64",
                  StringComparison.OrdinalIgnoreCase))
          {
#if !NET_COMPACT_20 && TRACE_DETECTION
              //
              // NOTE: When tracing is enabled, save the originally detected
              //       processor architecture before changing it.
              //
              string savedProcessorArchitecture = processorArchitecture;
#endif

................................................................................
              // NOTE: We know that operating systems that return "AMD64" as
              //       the processor architecture are actually a superset of
              //       the "x86" processor architecture; therefore, return
              //       "x86" when the pointer size is 32-bits.
              //
              processorArchitecture = "x86";

#if !NET_COMPACT_20 && TRACE_DETECTION
              try
              {
                  //
                  // NOTE: Show that we hit a fairly unusual situation (i.e.
                  //       the "wrong" processor architecture was detected).
                  //
                  Trace.WriteLine(String.Format(

Changes to Tests/common.eagle.

2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
        #
        foreach defineConstant [list \
            CHECK_STATE COUNT_HANDLE DEBUG INTEROP_CODEC INTEROP_DEBUG \
            INTEROP_EXTENSION_FUNCTIONS INTEROP_LEGACY_CLOSE INTEROP_LOG \
            INTEROP_TEST_EXTENSION INTEROP_VIRTUAL_TABLE NET_20 NET_35 \
            NET_40 NET_45 NET_451 NET_COMPACT_20 PLATFORM_COMPACTFRAMEWORK \
            PRELOAD_NATIVE_LIBRARY RETARGETABLE SQLITE_STANDARD \
            THROW_ON_DISPOSED TRACE TRACE_CONNECTION TRACE_HANDLE \
            TRACE_PRELOAD TRACE_SHARED TRACE_STATEMENT TRACE_WARNING \
            TRACK_MEMORY_BYTES USE_ENTITY_FRAMEWORK_6 USE_INTEROP_DLL \
            USE_PREPARE_V2 WINDOWS] {
          #
          # NOTE: Check if the compile-time option is listed in the list of
          #       "define constants" kept track of by the managed assembly.
          #
          checkForSQLiteDefineConstant $::test_channel $defineConstant
        }








|
|
|
|







2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
        #
        foreach defineConstant [list \
            CHECK_STATE COUNT_HANDLE DEBUG INTEROP_CODEC INTEROP_DEBUG \
            INTEROP_EXTENSION_FUNCTIONS INTEROP_LEGACY_CLOSE INTEROP_LOG \
            INTEROP_TEST_EXTENSION INTEROP_VIRTUAL_TABLE NET_20 NET_35 \
            NET_40 NET_45 NET_451 NET_COMPACT_20 PLATFORM_COMPACTFRAMEWORK \
            PRELOAD_NATIVE_LIBRARY RETARGETABLE SQLITE_STANDARD \
            THROW_ON_DISPOSED TRACE TRACE_CONNECTION TRACE_DETECTION \
            TRACE_HANDLE TRACE_PRELOAD TRACE_SHARED TRACE_STATEMENT \
            TRACE_WARNING TRACK_MEMORY_BYTES USE_ENTITY_FRAMEWORK_6 \
            USE_INTEROP_DLL USE_PREPARE_V2 WINDOWS] {
          #
          # NOTE: Check if the compile-time option is listed in the list of
          #       "define constants" kept track of by the managed assembly.
          #
          checkForSQLiteDefineConstant $::test_channel $defineConstant
        }