System.Data.SQLite
Check-in [29690b4981]
Not logged in

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

Overview
Comment:Further fixes to the internal debugging interfaces, primarily focused on thread-safety.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 29690b498181236c8fa7a7bbb29ea0bf26fe5c9d
User & Date: mistachkin 2018-01-25 23:52:40
Context
2018-01-25
23:59
Remove trailing whitespace. check-in: 2435b29a4f user: mistachkin tags: trunk
23:52
Further fixes to the internal debugging interfaces, primarily focused on thread-safety. check-in: 29690b4981 user: mistachkin tags: trunk
21:43
Fixes and enhancements to the internal debugging interfaces. check-in: 9221073c65 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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

   140    140         /////////////////////////////////////////////////////////////////////////
   141    141   
   142    142         /// <summary>
   143    143         /// Queries the read counts for the runtime configuration settings.
   144    144         /// These numbers are used for debugging and testing purposes only.
   145    145         /// </summary>
   146    146         /// <param name="viaFile">
   147         -      /// Non-zero if the specified setting is being read from the XML
          147  +      /// Non-zero if the specified settings were read from the XML
   148    148         /// configuration file.
   149    149         /// </param>
   150    150         /// <returns>
   151    151         /// A copy of the statistics for the specified runtime configuration
   152    152         /// settings -OR- null if they are not available.
   153    153         /// </returns>
   154    154         public static object GetSettingReadCounts(
................................................................................
   169    169                     if (settingReadCounts == null)
   170    170                         return null;
   171    171   
   172    172                     return new Dictionary<string, int>(settingReadCounts);
   173    173                 }
   174    174             }
   175    175         }
          176  +
          177  +      /////////////////////////////////////////////////////////////////////////
          178  +
          179  +      /// <summary>
          180  +      /// Clears the read counts for the runtime configuration settings.
          181  +      /// These numbers are used for debugging and testing purposes only.
          182  +      /// </summary>
          183  +      /// <param name="viaFile">
          184  +      /// Non-zero if the specified settings were read from the XML
          185  +      /// configuration file.
          186  +      /// </param>
          187  +      public static void ClearSettingReadCounts(
          188  +          bool viaFile
          189  +          )
          190  +      {
          191  +          lock (staticSyncRoot)
          192  +          {
          193  +              if (viaFile)
          194  +              {
          195  +                  if (settingFileReadCounts != null)
          196  +                      settingFileReadCounts.Clear();
          197  +              }
          198  +              else
          199  +              {
          200  +                  if (settingReadCounts != null)
          201  +                      settingReadCounts.Clear();
          202  +              }
          203  +          }
          204  +      }
   176    205   
   177    206         /////////////////////////////////////////////////////////////////////////
   178    207   
   179    208         /// <summary>
   180    209         /// Increments the read count for the specified runtime configuration
   181    210         /// setting.  These numbers are used for debugging and testing purposes
   182    211         /// only.
................................................................................
   220    249                             settingReadCounts[name] = count + 1;
   221    250                         else
   222    251                             settingReadCounts.Add(name, 1);
   223    252                     }
   224    253                 }
   225    254             }
   226    255         }
          256  +
          257  +      /////////////////////////////////////////////////////////////////////////
          258  +
          259  +      /// <summary>
          260  +      /// Queries the counters.  These numbers are used for debugging and
          261  +      /// testing purposes only.
          262  +      /// </summary>
          263  +      /// <returns>
          264  +      /// A copy of the counters -OR- null if they are not available.
          265  +      /// </returns>
          266  +      public static object GetOtherCounts()
          267  +      {
          268  +          lock (staticSyncRoot)
          269  +          {
          270  +              if (otherCounts == null)
          271  +                  return null;
          272  +
          273  +              return new Dictionary<string, int>(otherCounts);
          274  +          }
          275  +      }
          276  +
          277  +      /////////////////////////////////////////////////////////////////////////
          278  +
          279  +      /// <summary>
          280  +      /// Clears the counters.  These numbers are used for debugging and
          281  +      /// testing purposes only.
          282  +      /// </summary>
          283  +      public static void ClearOtherCounts()
          284  +      {
          285  +          lock (staticSyncRoot)
          286  +          {
          287  +              if (otherCounts != null)
          288  +                  otherCounts.Clear();
          289  +          }
          290  +      }
   227    291   
   228    292         /////////////////////////////////////////////////////////////////////////
   229    293   
   230    294         /// <summary>
   231    295         /// Increments the specified counter.
   232    296         /// </summary>
   233    297         /// <param name="name">
................................................................................
  1147   1211         /////////////////////////////////////////////////////////////////////////
  1148   1212         /// <summary>
  1149   1213         /// Attempts to initialize this class by pre-loading the native SQLite
  1150   1214         /// library for the processor architecture of the current process.
  1151   1215         /// </summary>
  1152   1216         internal static void Initialize()
  1153   1217         {
         1218  +          #region Debug Build Only
         1219  +#if DEBUG
         1220  +          //
         1221  +          // NOTE: Create the lists of statistics that will contain
         1222  +          //       various counts used in debugging, including the
         1223  +          //       number of times each setting value has been read.
         1224  +          //
         1225  +          DebugData.Initialize();
         1226  +#endif
         1227  +          #endregion
         1228  +
  1154   1229             //
  1155   1230             // NOTE: Check if a debugger needs to be attached before doing any
  1156   1231             //       real work.
  1157   1232             //
  1158   1233             HelperMethods.MaybeBreakIntoDebugger();
  1159   1234   
  1160   1235   #if SQLITE_STANDARD || USE_INTEROP_DLL || PLATFORM_COMPACTFRAMEWORK
................................................................................
  1164   1239             //       anything), skip all of our special code and simply return.
  1165   1240             //
  1166   1241             if (GetSettingValue("No_PreLoadSQLite", null) != null)
  1167   1242                 return;
  1168   1243   #endif
  1169   1244   #endif
  1170   1245   
  1171         -          #region Debug Build Only
  1172         -#if DEBUG
  1173         -          //
  1174         -          // NOTE: Create the lists of statistics that will contain
  1175         -          //       various counts used in debugging, including the
  1176         -          //       number of times each setting value has been read.
  1177         -          //
  1178         -          DebugData.Initialize();
  1179         -#endif
  1180         -          #endregion
  1181         -
  1182   1246             lock (staticSyncRoot)
  1183   1247             {
  1184   1248                 //
  1185   1249                 // TODO: Make sure this list is updated if the supported
  1186   1250                 //       processor architecture names and/or platform names
  1187   1251                 //       changes.
  1188   1252                 //

Changes to lib/System.Data.SQLite/common.eagle.

  3579   3579           }
  3580   3580         }
  3581   3581       }
  3582   3582   
  3583   3583       proc getSettingReadCount { name {viaFile false} } {
  3584   3584         if {[haveConstraint buildConfiguration.Debug] && [catch {
  3585   3585           object invoke -flags +NonPublic -alias \
  3586         -            System.Data.SQLite.DebugData [expr {$viaFile ? \
  3587         -            "settingFileReadCounts" : "settingReadCounts"}]
         3586  +            System.Data.SQLite.DebugData GetSettingReadCounts $viaFile
  3588   3587         } settingReadCounts] == 0} then {
  3589   3588           if {[string length $name] > 0} then {
  3590   3589             if {[$settingReadCounts TryGetValue $name value]} then {
  3591   3590               tputs $::test_channel [appendArgs \
  3592   3591                   "---- setting \"" $name "\" was read " $value " times" \
  3593   3592                   [expr {$viaFile ? " from the configuration file" : ""}] \n]
  3594   3593   
................................................................................
  3623   3622   
  3624   3623         return -1
  3625   3624       }
  3626   3625   
  3627   3626       proc getOtherCount { name } {
  3628   3627         if {[haveConstraint buildConfiguration.Debug] && [catch {
  3629   3628           object invoke -flags +NonPublic -alias \
  3630         -            System.Data.SQLite.DebugData otherCounts
         3629  +            System.Data.SQLite.DebugData GetOtherCounts
  3631   3630         } otherCounts] == 0} then {
  3632   3631           if {[string length $name] > 0} then {
  3633   3632             if {[$otherCounts TryGetValue $name value]} then {
  3634   3633               tputs $::test_channel [appendArgs \
  3635   3634                   "---- other counter \"" $name "\" has value " $value \n]
  3636   3635   
  3637   3636               return $value
................................................................................
  3706   3705         # NOTE: If available, report on (and possibly reset) the runtime
  3707   3706         #       configuration statistics.
  3708   3707         #
  3709   3708         if {[haveSQLiteObjectCommand] && \
  3710   3709             [haveConstraint buildConfiguration.Debug]} then {
  3711   3710           if {[catch {
  3712   3711             object invoke -flags +NonPublic -alias \
  3713         -              System.Data.SQLite.DebugData settingReadCounts
         3712  +              System.Data.SQLite.DebugData GetSettingReadCounts false
  3714   3713           } settingReadCounts] == 0} then {
  3715   3714             set nameCount [$settingReadCounts Count]
  3716   3715             set valueCount 0
  3717   3716   
  3718   3717             object foreach -alias pair $settingReadCounts {
  3719   3718               incr valueCount [$pair Value]
  3720   3719   
................................................................................
  3722   3721                 tputs $channel [appendArgs \
  3723   3722                     "---- setting \"" [$pair Key] "\" was read " \
  3724   3723                     [$pair Value] " times\n"]
  3725   3724               }
  3726   3725             }
  3727   3726   
  3728   3727             if {$reset} then {
  3729         -            if {[catch {$settingReadCounts Clear} error] == 0} then {
         3728  +            if {[catch {
         3729  +              object invoke -flags +NonPublic -alias \
         3730  +                  System.Data.SQLite.DebugData ClearSettingReadCounts false
         3731  +            } error] == 0} then {
  3730   3732                 if {!$quiet} then {
  3731   3733                   tputs $channel [appendArgs \
  3732   3734                       "---- reset setting statistics for the previous " \
  3733   3735                       $nameCount " names and " $valueCount " values read\n"]
  3734   3736                 }
  3735   3737               } else {
  3736   3738                 if {!$quiet} then {
................................................................................
  3741   3743                 }
  3742   3744               }
  3743   3745             }
  3744   3746           }
  3745   3747   
  3746   3748           if {[catch {
  3747   3749             object invoke -flags +NonPublic -alias \
  3748         -              System.Data.SQLite.DebugData settingFileReadCounts
         3750  +              System.Data.SQLite.DebugData GetSettingReadCounts true
  3749   3751           } settingFileReadCounts] == 0} then {
  3750   3752             set nameCount [$settingFileReadCounts Count]
  3751   3753             set valueCount 0
  3752   3754   
  3753   3755             object foreach -alias pair $settingFileReadCounts {
  3754   3756               incr valueCount [$pair Value]
  3755   3757   
................................................................................
  3757   3759                 tputs $channel [appendArgs \
  3758   3760                     "---- setting \"" [$pair Key] "\" was read " \
  3759   3761                     [$pair Value] " times from the configuration file\n"]
  3760   3762               }
  3761   3763             }
  3762   3764   
  3763   3765             if {$reset} then {
  3764         -            if {[catch {$settingFileReadCounts Clear} error] == 0} then {
         3766  +            if {[catch {
         3767  +              object invoke -flags +NonPublic -alias \
         3768  +                  System.Data.SQLite.DebugData ClearSettingReadCounts true
         3769  +            } error] == 0} then {
  3765   3770                 if {!$quiet} then {
  3766   3771                   tputs $channel [appendArgs \
  3767   3772                       "---- reset setting statistics for the previous " \
  3768   3773                       $nameCount " names and " $valueCount " values read " \
  3769   3774                       "from the configuration file\n"]
  3770   3775                 }
  3771   3776               } else {
................................................................................
  3778   3783                 }
  3779   3784               }
  3780   3785             }
  3781   3786           }
  3782   3787   
  3783   3788           if {[catch {
  3784   3789             object invoke -flags +NonPublic -alias \
  3785         -              System.Data.SQLite.DebugData otherCounts
         3790  +              System.Data.SQLite.DebugData GetOtherCounts
  3786   3791           } otherCounts] == 0} then {
  3787   3792             set nameCount [$otherCounts Count]
  3788   3793             set valueCount 0
  3789   3794   
  3790   3795             object foreach -alias pair $otherCounts {
  3791   3796               incr valueCount [$pair Value]
  3792   3797   
................................................................................
  3794   3799                 tputs $channel [appendArgs \
  3795   3800                     "---- other counter \"" [$pair Key] "\" has value " \
  3796   3801                     [$pair Value] \n]
  3797   3802               }
  3798   3803             }
  3799   3804   
  3800   3805             if {$reset} then {
  3801         -            if {[catch {$otherCounts Clear} error] == 0} then {
         3806  +            if {[catch {
         3807  +              object invoke -flags +NonPublic -alias \
         3808  +                  System.Data.SQLite.DebugData ClearOtherCounts
         3809  +            } error] == 0} then {
  3802   3810                 if {!$quiet} then {
  3803   3811                   tputs $channel [appendArgs \
  3804   3812                       "---- reset other counters for the previous " \
  3805   3813                       $nameCount " names and " $valueCount " values\n"]
  3806   3814                 }
  3807   3815               } else {
  3808   3816                 if {!$quiet} then {
................................................................................
  4711   4719                 set sourceId null
  4712   4720               }
  4713   4721               tputs $::test_channel [appendArgs $sourceId \n]
  4714   4722             } else {
  4715   4723               tputs $::test_channel unknown\n
  4716   4724             }
  4717   4725           }
         4726  +
         4727  +        #
         4728  +        # NOTE: Reset cached "break into debugger" setting so that it can be
         4729  +        #       used during the test file, if needed.
         4730  +        #
         4731  +        if {![info exists ::no(resetBreakIntoDebugger)] && \
         4732  +            [haveSQLiteObjectCommand]} then {
         4733  +          if {[catch {
         4734  +            object invoke -flags +NonPublic \
         4735  +                System.Data.SQLite.HelperMethods ResetBreakIntoDebugger
         4736  +          } result] == 0} then {
         4737  +            tputs $::test_channel [appendArgs \
         4738  +                "---- call ResetBreakIntoDebugger()... ok\n"]
         4739  +          } else {
         4740  +            tputs $::test_channel [appendArgs \
         4741  +                "---- call ResetBreakIntoDebugger()... error: " \
         4742  +                \n\t $result \n]
         4743  +          }
         4744  +        }
  4718   4745   
  4719   4746           #
  4720   4747           # NOTE: Check the available builds (and "releases") of SQLite and
  4721   4748           #       System.Data.SQLite.
  4722   4749           #
  4723   4750           checkForSQLiteBuilds $::test_channel
  4724   4751           checkForSQLiteReleases $::test_channel