More useful match reports. Made some functions static.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 17 Feb 2011 22:01:05 +0000 (17:01 -0500)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 17 Feb 2011 22:01:05 +0000 (17:01 -0500)
src/tracecut-advice.c

index a0863e717e59d598abf5608b27ee9dbbadcc3c9c..2802b3c9e11bcc28c0351599db01a0d4ee92c2c3 100644 (file)
@@ -94,18 +94,39 @@ get_tracecut (int tc_index)
 }
 
 void
-advance_state_machine (struct tuple *tuple, int num_rules, int symbol_index)
+tc_report_match (struct tracecut *tc, struct tuple *tuple, int symbol_index)
+{
+  fprintf (stderr, "(Tracecut) Match triggered by symbol: %s.", tc->symbol_names[symbol_index]);
+
+  if (tc->num_params > 0)
+    {
+      int i;
+
+      fprintf (stderr, "  Param values follow:\n");
+      for (i = 0; i < tc->num_params; i++)
+       fprintf (stderr, "  Param %d: 0x%p\n", i,
+                (void *)tuple->param_vals[i].value);
+    }
+  else
+    {
+      /* No params to print. */
+      fprintf (stderr, "\n");
+    }
+}
+
+static void
+advance_state_machine (struct tracecut *tc, struct tuple *tuple, int symbol_index)
 {
   int i;
-  for (i = 0; i < num_rules; i++)
+  for (i = 0; i < tc->num_rules; i++)
     {
       step (tuple->states[i], symbol_index);
       if (ismatch (tuple->states[i]))
-       fprintf (stderr, "Match!\n");
+       tc_report_match (tc, tuple, symbol_index);
     }
 }
 
-int
+static int
 event_matches_tuple (struct event *event, struct tuple *tuple)
 {
   int i;
@@ -131,19 +152,18 @@ event_matches_tuple (struct event *event, struct tuple *tuple)
   return 1;
 }
 
-int
+static int
 update_matching_tuples (struct event *event)
 {
   struct tracecut *tc = event->tracecut;
   struct tuple *tuple;
   int tuples_updated = 0;
-  int num_rules = event->tracecut->num_rules;
 
   for (tuple = tc->tuple_list; tuple != NULL; tuple = tuple->next)
     {
       if (event_matches_tuple (event, tuple))
        {
-         advance_state_machine (tuple, num_rules, event->symbol_index);
+         advance_state_machine (event->tracecut, tuple, event->symbol_index);
          tuples_updated++;
          fprintf (stderr, "Advancing existing tuple.\n");
        }
@@ -152,7 +172,8 @@ update_matching_tuples (struct event *event)
   return tuples_updated;
 }
 
-struct tuple *add_tuple_for_event (struct event *event)
+static struct tuple *
+add_tuple_for_event (struct event *event)
 {
   int i;
   struct tracecut *tc = event->tracecut;
@@ -210,7 +231,7 @@ struct tuple *add_tuple_for_event (struct event *event)
 
 /* An event is "complete" iff only if all its params are specified
    (i.e., none are vacant). */
-int
+static int
 is_event_complete (struct event *event)
 {
   int i;
@@ -223,11 +244,10 @@ is_event_complete (struct event *event)
   return 1;
 }
 
-void
+static void
 do_transition (struct event *event)
 {
   int tuples_updated;
-  int num_rules = event->tracecut->num_rules;
 
   tuples_updated = update_matching_tuples (event);
 
@@ -237,7 +257,7 @@ do_transition (struct event *event)
 
       tuple = add_tuple_for_event (event);
       if (tuple != NULL)
-       advance_state_machine (tuple, num_rules, event->symbol_index);
+       advance_state_machine (event->tracecut, tuple, event->symbol_index);
       fprintf (stderr, "Creating new tuple.\n");
     }
 }