aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/eventsql.c112
-rw-r--r--mps/code/eventsql.h51
2 files changed, 110 insertions, 53 deletions
diff --git a/mps/code/eventsql.c b/mps/code/eventsql.c
index 8e0b0761998..d4401192942 100644
--- a/mps/code/eventsql.c
+++ b/mps/code/eventsql.c
@@ -1,5 +1,72 @@
1#include "config.h" 1/* eventsql.c: event log to SQLite importer
2 * Copyright (c) 2012 Ravenbrook Limited. See end of file for license.
3 *
4 * This is a command-line tool that imports events from a binary
5 * format telemetry output file from the MPS into a SQLite database
6 * file.
7 *
8 * The default MPS library will write a telemetry stream to a file called
9 * "mpsio.log" when the environment variable MPS_TELEMETRY_CONTROL is set
10 * to an integer whose bits select event kinds. For example:
11 *
12 * MPS_TELEMETRY_CONTROL=7 amcss
13 *
14 * will run the amcss test program and emit a file with event kinds 0, 1, 2.
15 * The file can then be imported into a SQLite database with this command:
16 *
17 * eventsql
18 *
19 * Note that the eventsql program can only read streams that come from an
20 * MPS compiled on the same platform.
21 *
22 * Each event type gets its own table in the database. These tables
23 * are created from the definitions in eventdef.h if they don't
24 * already exist. Each event becomes a single row in the appropriate
25 * table, which has a column for each event parameter, a time column
26 * for the event time field, and a log_serial column to identify the
27 * log file.
28 *
29 * The program also creates three other tables: two 'glue' tables
30 * containing event metadata - event_kind (one row per kind) and
31 * event_type (one row per type), again derived from eventdef.h - and
32 * the event_log table which has one row per log file imported (the
33 * log_serial column in the event tables is a primary key to this
34 * event_log table).
35 *
36 * No tables are created if they already exist, unless the -r
37 * (rebuild) switch is given.
38 *
39 * Options:
40 *
41 * -v (verbose): Increase verbosity. eventsql logs to stderr. By
42 * default, it doesn't log much; it can be made more and more
43 * loquacious by adding more -v switches. Given one or more -v
44 * switches, it also writes 'ticks' (periods) to stdout, to show
45 * progress (one dot is 100k events).
46 *
47 * -t (test): Run unit tests on parts of eventsql. There aren't many
48 * of these.
49 *
50 * -f (force): Import the events to SQL even if the SQL database
51 * already includes a record of importing this event log file (matched by
52 * size, modtime, and filesystem ID.
53 *
54 * -r (rebuild): Drop the glue tables from SQL, which will force them
55 * to be recreated. Important if you change event types or kinds in
56 * eventdef.h.
57 *
58 * -l <logfile>: Import events from the named logfile. If not
59 * specified, eventsql will use the MPS_TELEMETRY_FILENAME environment
60 * variable, and default to mpsio.log.
61 *
62 * -d <database>: Import events to the named database file. If not
63 * specified, eventsql will use the MPS_EVENT_DATABASE environment
64 * variable, and default to mpsevent.db.
65 *
66 * $Id$
67 */
2 68
69#include "config.h"
3#include "eventdef.h" 70#include "eventdef.h"
4#include "eventpro.h" 71#include "eventpro.h"
5 72
@@ -18,7 +85,7 @@
18/* we output rows of dots. One dot per SMALL_TICK events, 85/* we output rows of dots. One dot per SMALL_TICK events,
19 * BIG_TICK dots per row. */ 86 * BIG_TICK dots per row. */
20 87
21#define SMALL_TICK 1000 88#define SMALL_TICK 100000
22#define BIG_TICK 50 89#define BIG_TICK 50
23 90
24/* Utility code for logging to stderr with multiple log levels, 91/* Utility code for logging to stderr with multiple log levels,
@@ -728,3 +795,44 @@ int main(int argc, char *argv[])
728 closeDatabase(db); 795 closeDatabase(db);
729 return 0; 796 return 0;
730} 797}
798
799/* COPYRIGHT AND LICENSE
800 *
801 * Copyright (C) 2012 Ravenbrook Limited <http://www.ravenbrook.com/>.
802 * All rights reserved. This is an open source license. Contact
803 * Ravenbrook for commercial licensing options.
804 *
805 * Redistribution and use in source and binary forms, with or without
806 * modification, are permitted provided that the following conditions are
807 * met:
808 *
809 * 1. Redistributions of source code must retain the above copyright
810 * notice, this list of conditions and the following disclaimer.
811 *
812 * 2. Redistributions in binary form must reproduce the above copyright
813 * notice, this list of conditions and the following disclaimer in the
814 * documentation and/or other materials provided with the distribution.
815 *
816 * 3. Redistributions in any form must be accompanied by information on how
817 * to obtain complete source code for this software and any accompanying
818 * software that uses this software. The source code must either be
819 * included in the distribution or be available for no more than the cost
820 * of distribution plus a nominal fee, and must be freely redistributable
821 * under reasonable conditions. For an executable file, complete source
822 * code means the source code for all modules it contains. It does not
823 * include source code for modules or files that typically accompany the
824 * major components of the operating system on which the executable file
825 * runs.
826 *
827 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
828 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
829 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
830 * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
831 * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
832 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
833 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
834 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
835 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
836 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
837 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
838 */
diff --git a/mps/code/eventsql.h b/mps/code/eventsql.h
deleted file mode 100644
index a5d718fbffc..00000000000
--- a/mps/code/eventsql.h
+++ /dev/null
@@ -1,51 +0,0 @@
1/* <code/eventsql.h> -- Event Database Definitions
2 *
3 * $Id$
4 * Copyright (C) 2012 Ravenbrook Limited. See end of file for license.
5 */
6
7#ifndef eventsql_h
8#define eventsql_h
9
10#endif /* eventsql_h */
11
12/* C. COPYRIGHT AND LICENSE
13 *
14 * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
15 * All rights reserved. This is an open source license. Contact
16 * Ravenbrook for commercial licensing options.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met:
21 *
22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 *
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 *
29 * 3. Redistributions in any form must be accompanied by information on how
30 * to obtain complete source code for this software and any accompanying
31 * software that uses this software. The source code must either be
32 * included in the distribution or be available for no more than the cost
33 * of distribution plus a nominal fee, and must be freely redistributable
34 * under reasonable conditions. For an executable file, complete source
35 * code means the source code for all modules it contains. It does not
36 * include source code for modules or files that typically accompany the
37 * major components of the operating system on which the executable file
38 * runs.
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
41 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
42 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
43 * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
44 * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
45 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
48 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
50 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 */