Index: src/test_osinst.c ================================================================== --- src/test_osinst.c +++ src/test_osinst.c @@ -213,17 +213,21 @@ ** The following routine only works on pentium-class processors. ** It uses the RDTSC opcode to read the cycle count value out of the ** processor and returns that value. This can be used for high-res ** profiling. */ +#if defined(i386) || defined(__i386__) || defined(_M_IX86) __inline__ unsigned long long int hwtime(void){ unsigned long long int x; __asm__("rdtsc\n\t" "mov %%edx, %%ecx\n\t" :"=A" (x)); return x; } +#else + static unsigned long long int hwtime(void){ return 0; } +#endif #define OS_TIME_IO(eEvent, A, B, Call) { \ inst_file *p = (inst_file *)pFile; \ InstVfs *pInstVfs = p->pInstVfs; \ int rc; \ @@ -516,10 +520,11 @@ p->pClient = pClient; } void sqlite3_instvfs_destroy(sqlite3_vfs *pVfs){ sqlite3_vfs_unregister(pVfs); + sqlite3_instvfs_configure(pVfs, 0, 0, 0); sqlite3_free(pVfs); } void sqlite3_instvfs_reset(sqlite3_vfs *pVfs){ InstVfs *p = (InstVfs *)pVfs; @@ -644,22 +649,29 @@ switch( (enum IV_enum)iSub ){ case IV_CREATE: { char *zParent = 0; sqlite3_vfs *p; - if( objc!=4 && objc!=3 ){ - Tcl_WrongNumArgs(interp, 2, objv, "NAME ?PARENT-VFS?"); + int isDefault = 0; + if( objc>2 && 0==strcmp("-default", Tcl_GetString(objv[2])) ){ + isDefault = 1; + } + if( (objc-isDefault)!=4 && (objc-isDefault)!=3 ){ + Tcl_WrongNumArgs(interp, 2, objv, "?-default? NAME ?PARENT-VFS?"); return TCL_ERROR; } - if( objc==4 ){ - zParent = Tcl_GetString(objv[3]); + if( objc==(4+isDefault) ){ + zParent = Tcl_GetString(objv[3+isDefault]); } - p = sqlite3_instvfs_create(Tcl_GetString(objv[2]), zParent); + p = sqlite3_instvfs_create(Tcl_GetString(objv[2+isDefault]), zParent); if( !p ){ Tcl_AppendResult(interp, "error creating vfs ", 0); return TCL_ERROR; } + if( isDefault ){ + sqlite3_vfs_register(p, 1); + } Tcl_SetObjResult(interp, objv[2]); break; } case IV_CONFIGURE: { Index: test/tester.tcl ================================================================== --- test/tester.tcl +++ test/tester.tcl @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements some common TCL routines used for regression # testing the SQLite library # -# $Id: tester.tcl,v 1.113 2008/03/29 11:00:55 drh Exp $ +# $Id: tester.tcl,v 1.114 2008/04/10 17:27:39 danielk1977 Exp $ # # What for user input before continuing. This gives an opportunity # to connect profiling tools to the process. # @@ -59,11 +59,10 @@ for {set i 0} {$i<[llength $argv]} {incr i} { if {[lindex $argv $i] eq "--malloctrace"} { set argv [lreplace $argv $i $i] sqlite3_memdebug_backtrace 10 sqlite3_memdebug_log start - set argv [lreplace $argv $i $i] set tester_do_malloctrace 1 } } for {set i 0} {$i<[llength $argv]} {incr i} { if {[regexp {^--backtrace=(\d+)$} [lindex $argv $i] all value]} { @@ -70,10 +69,32 @@ sqlite3_memdebug_backtrace $value set argv [lreplace $argv $i $i] } } + +proc ostrace_call {zCall nClick zFile i32 i64} { + set s "INSERT INTO ostrace VALUES( '$zCall', $nClick, '$zFile', $i32, $i64);" + puts $::ostrace_fd $s +} + +for {set i 0} {$i<[llength $argv]} {incr i} { + if {[lindex $argv $i] eq "--ossummary" || [lindex $argv $i] eq "--ostrace"} { + sqlite3_instvfs create -default ostrace + set tester_do_ostrace 1 + set ostrace_fd [open ostrace.sql w] + puts $ostrace_fd "BEGIN;" + if {[lindex $argv $i] eq "--ostrace"} { + set s "CREATE TABLE ostrace" + append s "(method TEXT, clicks INT, file TEXT, i32 INT, i64 INT);" + puts $ostrace_fd $s + sqlite3_instvfs configure ostrace ostrace_call + } + set argv [lreplace $argv $i $i] + } +} + # # Check the command-line arguments to set the maximum number of # errors tolerated before halting. # if {![info exists maxErr]} { @@ -246,10 +267,24 @@ puts "******************************************************************" } if {$sqlite_open_file_count} { puts "$sqlite_open_file_count files were left open" incr nErr + } + if {[info exists ::tester_do_ostrace]} { + puts "Writing ostrace.sql..." + set fd $::ostrace_fd + + puts -nonewline $fd "CREATE TABLE ossummary" + puts $fd "(method TEXT, clicks INTEGER, count INTEGER);" + foreach row [sqlite3_instvfs report ostrace] { + foreach {method count clicks} $row break + puts $fd "INSERT INTO ossummary VALUES('$method', $clicks, $count);" + } + puts $fd "COMMIT;" + close $fd + sqlite3_instvfs destroy ostrace } if {[sqlite3_memory_used]>0} { puts "Unfreed memory: [sqlite3_memory_used] bytes" incr nErr ifcapable memdebug||mem5||(mem3&&debug) {