Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
trace.cpp File Reference
#include <portability.h>
#include <stdlib.h>
#include "trace.h"
#include "mem.h"
#include "production.h"
#include "kernel.h"
#include "lexer.h"
#include "symtab.h"
#include "agent.h"
#include "print.h"
#include "init_soar.h"
#include "gdatastructs.h"
#include "tempmem.h"
#include "wmem.h"
#include "xml.h"
#include "soar_TraceNames.h"
#include <ctype.h>

Go to the source code of this file.

Data Structures

union  trace_format_struct::trace_format_data_union
struct  trace_format_struct
struct  tracing_parameters
struct  tracing_rule_struct

Macros

#define GROWABLE_STRING_TRACE_FORMAT_LIST_TO_STRING_BUFFER_SIZE   50

Typedefs

typedef struct trace_format_struct trace_format
typedef struct tracing_rule_struct tracing_rule

Enumerations

enum  trace_format_type

Functions

void add_trace_for_attribute_path (agent *thisAgent, Symbol *object, list *path, growable_string *result, Bool print_attributes, Bool recursive)
void add_trace_for_wme (agent *thisAgent, growable_string *result, wme *w, Bool print_attribute, Bool recursive)
Bool add_trace_format (agent *thisAgent, Bool stack_trace, int type_restriction, Symbol *name_restriction, const char *format_string)
void add_values_of_attribute_path (agent *thisAgent, Symbol *object, list *path, growable_string *result, Bool recursive, int *count)
void deallocate_trace_format_list (agent *thisAgent, trace_format *tf)
trace_formatfind_appropriate_trace_format (agent *thisAgent, Bool stack_trace, int type, Symbol *name)
uint32_t hash_name_restriction (Symbol *name, short num_bits)
void init_tracing (agent *thisAgent)
trace_formatlookup_trace_format (agent *thisAgent, Bool stack_trace, int type_restriction, Symbol *name_restriction)
growable_string object_to_trace_string (agent *thisAgent, Symbol *object)
listparse_attribute_path_in_brackets (agent *thisAgent)
trace_formatparse_format_string (agent *thisAgent, const char *string)
trace_formatparse_item_from_format_string (agent *thisAgent)
trace_formatparse_pattern_in_brackets (agent *thisAgent, Bool read_opening_bracket)
void print_all_trace_formats (agent *thisAgent, Bool stack_trace, FILE *f)
void print_all_trace_formats_tcl (agent *thisAgent, Bool stack_trace, FILE *f)
void print_object_trace (agent *thisAgent, Symbol *object)
void print_object_trace_using_provided_format_string (agent *thisAgent, Symbol *object, Symbol *current_goal, char *format_string)
void print_stack_trace (agent *thisAgent, Symbol *object, Symbol *state, int slot_type, Bool allow_cycle_counts)
void print_stack_trace_xml (agent *thisAgent, Symbol *object, Symbol *state, int slot_type, Bool)
Bool print_trace_callback_fn (agent *thisAgent, void *item, void *)
Bool print_trace_callback_fn_tcl (agent *thisAgent, void *item, void *)
void print_trace_format_list (agent *thisAgent, trace_format *tf)
void print_tracing_rule (agent *thisAgent, int type_restriction, Symbol *name_restriction, trace_format *format)
void print_tracing_rule_tcl (agent *thisAgent, int type_restriction, Symbol *name_restriction, trace_format *format)
Bool remove_trace_format (agent *thisAgent, Bool stack_trace, int type_restriction, Symbol *name_restriction)
growable_string selection_to_trace_string (agent *thisAgent, Symbol *object, Symbol *current_state, int selection_type, Bool allow_cycle_counts)
void set_print_trace_formats (agent *thisAgent)
void set_tagged_trace_formats (agent *thisAgent)
growable_string trace_format_list_to_string (agent *thisAgent, trace_format *tf, Symbol *object)
uint32_t tracing_rule_hash_function (void *item, short num_bits)

Variables

const char * format
const char * format_string_error_message
Bool found_undefined
struct tracing_parameters tparams
char tracing_object_letters [3] = {'*','s','o'}

Macro Definition Documentation

#define GROWABLE_STRING_TRACE_FORMAT_LIST_TO_STRING_BUFFER_SIZE   50

Typedef Documentation

Enumeration Type Documentation

Enumerator:
STRING_TFT 
PERCENT_TFT 
L_BRACKET_TFT 
R_BRACKET_TFT 
VALUES_TFT 
VALUES_RECURSIVELY_TFT 
ATTS_AND_VALUES_TFT 
ATTS_AND_VALUES_RECURSIVELY_TFT 
CURRENT_STATE_TFT 
CURRENT_OPERATOR_TFT 
DECISION_CYCLE_COUNT_TFT 
ELABORATION_CYCLE_COUNT_TFT 
IDENTIFIER_TFT 
IF_ALL_DEFINED_TFT 
LEFT_JUSTIFY_TFT 
RIGHT_JUSTIFY_TFT 
SUBGOAL_DEPTH_TFT 
REPEAT_SUBGOAL_DEPTH_TFT 
NEWLINE_TFT 

Definition at line 49 of file trace.cpp.

{
STRING_TFT, /* print a string */
PERCENT_TFT, /* print a percent sign */
L_BRACKET_TFT, /* print a left bracket */
R_BRACKET_TFT, /* print a right bracket */
VALUES_TFT, /* print values of attr path or '*' */
VALUES_RECURSIVELY_TFT, /* ditto only print recursively */
ATTS_AND_VALUES_TFT, /* ditto only print attr's too */
ATTS_AND_VALUES_RECURSIVELY_TFT, /* combination of the two above */
CURRENT_STATE_TFT, /* print current state */
CURRENT_OPERATOR_TFT, /* print current operator */
DECISION_CYCLE_COUNT_TFT, /* print # of dc's */
ELABORATION_CYCLE_COUNT_TFT, /* print # of ec's */
IDENTIFIER_TFT, /* print identifier of object */
IF_ALL_DEFINED_TFT, /* print subformat if it's defined */
LEFT_JUSTIFY_TFT, /* left justify the subformat */
RIGHT_JUSTIFY_TFT, /* right justify the subformat */
SUBGOAL_DEPTH_TFT, /* print # of subgoal depth */
REPEAT_SUBGOAL_DEPTH_TFT, /* repeat subformat s.d. times */
NEWLINE_TFT }; /* print a newline */

Function Documentation

void add_trace_for_attribute_path ( agent thisAgent,
Symbol object,
list path,
growable_string result,
Bool  print_attributes,
Bool  recursive 
)

Definition at line 1028 of file trace.cpp.

References add_to_growable_string(), add_trace_for_wme(), add_values_of_attribute_path(), cons_struct::first, found_undefined, free_growable_string(), symbol_union::id, IDENTIFIER_SYMBOL_TYPE, identifier_struct::impasse_wmes, identifier_struct::input_wmes, length_of_growable_string(), make_blank_growable_string(), wme_struct::next, slot_struct::next, NIL, cons_struct::rest, identifier_struct::slots, symbol_to_string(), text_of_growable_string(), TRUE, and slot_struct::wmes.

Referenced by trace_format_list_to_string().

{
cons *c;
char *ch;
int count;
slot *s;
wme *w;
values = make_blank_growable_string(thisAgent);
if (! path) {
if (object->common.symbol_type!=IDENTIFIER_SYMBOL_TYPE) return;
for (s=object->id.slots; s!=NIL; s=s->next)
for (w=s->wmes; w!=NIL; w=w->next)
add_trace_for_wme (thisAgent, &values, w, print_attributes, recursive);
for (w=object->id.impasse_wmes; w!=NIL; w=w->next)
add_trace_for_wme (thisAgent, &values, w, print_attributes, recursive);
for (w=object->id.input_wmes; w!=NIL; w=w->next)
add_trace_for_wme (thisAgent, &values, w, print_attributes, recursive);
add_to_growable_string (thisAgent, result, text_of_growable_string(values)+1);
free_growable_string (thisAgent, values);
return;
}
count = 0;
add_values_of_attribute_path (thisAgent, object, path, &values, recursive, &count);
if (! count) {
free_growable_string (thisAgent, values);
return;
}
if (print_attributes) {
add_to_growable_string (thisAgent, result, "^");
for (c=path; c!=NIL; c=c->rest) {
ch = symbol_to_string (thisAgent, static_cast<symbol_union *>(c->first), TRUE, NULL, 0);
add_to_growable_string (thisAgent, result, ch);
if (c->rest) add_to_growable_string (thisAgent, result, ".");
}
add_to_growable_string (thisAgent, result, " ");
}
add_to_growable_string (thisAgent, result, text_of_growable_string(values)+1);
free_growable_string (thisAgent, values);
}
void add_trace_for_wme ( agent thisAgent,
growable_string result,
wme w,
Bool  print_attribute,
Bool  recursive 
)

Definition at line 993 of file trace.cpp.

References add_to_growable_string(), wme_struct::attr, free_growable_string(), object_to_trace_string(), symbol_to_string(), text_of_growable_string(), TRUE, and wme_struct::value.

Referenced by add_trace_for_attribute_path().

{
char *ch;
add_to_growable_string (thisAgent, result, " ");
if (print_attribute) {
add_to_growable_string (thisAgent, result, "^");
ch = symbol_to_string (thisAgent, w->attr, TRUE, NULL, 0);
add_to_growable_string (thisAgent, result, ch);
add_to_growable_string (thisAgent, result, " ");
}
if (recursive) {
gs = object_to_trace_string (thisAgent, w->value);
free_growable_string (thisAgent, gs);
} else {
ch = symbol_to_string (thisAgent, w->value, TRUE, NULL, 0);
add_to_growable_string (thisAgent, result, ch);
}
}
Bool add_trace_format ( agent thisAgent,
Bool  stack_trace,
int  type_restriction,
Symbol name_restriction,
const char *  format_string 
)

Definition at line 727 of file trace.cpp.

References add_to_hash_table(), allocate_memory(), FALSE, tracing_rule_struct::format, MISCELLANEOUS_MEM_USAGE, tracing_rule_struct::name_restriction, agent_struct::object_tf_for_anything, agent_struct::object_tr_ht, parse_format_string(), remove_trace_format(), agent_struct::stack_tf_for_anything, agent_struct::stack_tr_ht, symbol_add_ref(), TRUE, and tracing_rule_struct::type_restriction.

Referenced by init_soar_agent(), set_print_trace_formats(), and set_tagged_trace_formats().

{
trace_format *new_tf;
/* --- parse the format string into a trace_format --- */
new_tf = parse_format_string (thisAgent, format_string);
if (!new_tf) return FALSE;
/* --- first remove any existing trace format with same conditions --- */
remove_trace_format (thisAgent, stack_trace, type_restriction, name_restriction);
/* --- now add the new one --- */
if (name_restriction) {
symbol_add_ref (name_restriction);
if (stack_trace)
ht = thisAgent->stack_tr_ht[type_restriction];
else
ht = thisAgent->object_tr_ht[type_restriction];
tr = static_cast<tracing_rule_struct *>(allocate_memory (thisAgent, sizeof(tracing_rule),
tr->type_restriction = type_restriction;
tr->name_restriction = name_restriction;
tr->format = new_tf;
add_to_hash_table (thisAgent, ht, tr);
return TRUE;
}
/* --- no name restriction --- */
if (stack_trace)
thisAgent->stack_tf_for_anything[type_restriction] = new_tf;
else
thisAgent->object_tf_for_anything[type_restriction] = new_tf;
return TRUE;
}
void add_values_of_attribute_path ( agent thisAgent,
Symbol object,
list path,
growable_string result,
Bool  recursive,
int count 
)

Definition at line 939 of file trace.cpp.

References add_to_growable_string(), wme_struct::attr, find_slot(), cons_struct::first, free_growable_string(), symbol_union::id, IDENTIFIER_SYMBOL_TYPE, identifier_struct::impasse_wmes, identifier_struct::input_wmes, wme_struct::next, NIL, object_to_trace_string(), cons_struct::rest, symbol_to_string(), text_of_growable_string(), TRUE, wme_struct::value, and slot_struct::wmes.

Referenced by add_trace_for_attribute_path().

{
slot *s;
wme *w;
char *ch;
if (!path) { /* path is NIL, so we've reached the end of the path */
add_to_growable_string (thisAgent, result, " ");
if (recursive) {
gs = object_to_trace_string (thisAgent, object);
free_growable_string (thisAgent, gs);
} else {
ch = symbol_to_string (thisAgent, object, TRUE, NULL, 0);
add_to_growable_string (thisAgent, result, ch);
}
(*count)++;
return;
}
/* --- not at end of path yet --- */
/* --- can't follow any more path segments off of a non-identifier --- */
if (object->common.symbol_type != IDENTIFIER_SYMBOL_TYPE) return;
/* --- call this routine recursively on any wme matching the first segment
of the attribute path --- */
for (w=object->id.impasse_wmes; w!=NIL; w=w->next)
if (w->attr == path->first)
add_values_of_attribute_path (thisAgent, w->value, path->rest, result, recursive,
count);
for (w=object->id.input_wmes; w!=NIL; w=w->next)
if (w->attr == path->first)
add_values_of_attribute_path (thisAgent, w->value, path->rest, result, recursive,
count);
s = find_slot (object, static_cast<symbol_union *>(path->first));
if (s) {
for (w=s->wmes; w!=NIL; w=w->next)
add_values_of_attribute_path (thisAgent, w->value, path->rest, result, recursive,
count);
}
}
void deallocate_trace_format_list ( agent thisAgent,
trace_format tf 
)
trace_format* find_appropriate_trace_format ( agent thisAgent,
Bool  stack_trace,
int  type,
Symbol name 
)

Definition at line 1257 of file trace.cpp.

References FOR_ANYTHING_TF, lookup_trace_format(), and NIL.

Referenced by object_to_trace_string(), and selection_to_trace_string().

{
/* --- first try to find the exact one --- */
tf = lookup_trace_format (thisAgent, stack_trace, type, name);
if (tf) return tf;
/* --- failing that, try ignoring the type but retaining the name --- */
if (type!=FOR_ANYTHING_TF) {
tf = lookup_trace_format (thisAgent, stack_trace, FOR_ANYTHING_TF, name);
if (tf) return tf;
}
/* --- failing that, try ignoring the name but retaining the type --- */
if (name) {
tf = lookup_trace_format (thisAgent, stack_trace, type, NIL);
if (tf) return tf;
}
/* --- last resort: find a format that applies to anything at all --- */
return lookup_trace_format (thisAgent, stack_trace, FOR_ANYTHING_TF, NIL);
}
uint32_t hash_name_restriction ( Symbol name,
short  num_bits 
)
inline

Definition at line 638 of file trace.cpp.

References masks_for_n_low_order_bits.

Referenced by lookup_trace_format(), remove_trace_format(), and tracing_rule_hash_function().

{
return name->common.hash_id & masks_for_n_low_order_bits[num_bits];
}
void init_tracing ( agent thisAgent)
trace_format* lookup_trace_format ( agent thisAgent,
Bool  stack_trace,
int  type_restriction,
Symbol name_restriction 
)

Definition at line 665 of file trace.cpp.

References hash_table_struct::buckets, tracing_rule_struct::format, hash_name_restriction(), hash_table_struct::log2size, tracing_rule_struct::name_restriction, tracing_rule_struct::next_in_hash_bucket, NIL, agent_struct::object_tf_for_anything, agent_struct::object_tr_ht, agent_struct::stack_tf_for_anything, agent_struct::stack_tr_ht, tracing_rule_struct::type_restriction, and uint32_t().

Referenced by find_appropriate_trace_format().

{
uint32_t hash_value;
if (name_restriction) {
if (stack_trace)
ht = thisAgent->stack_tr_ht[type_restriction];
else
ht = thisAgent->object_tr_ht[type_restriction];
hash_value = hash_name_restriction (name_restriction, ht->log2size);
tr = reinterpret_cast<tracing_rule *>(*(ht->buckets + hash_value));
for ( ; tr!=NIL; tr = tr->next_in_hash_bucket)
if (tr->name_restriction==name_restriction) return tr->format;
return NIL;
}
/* --- no name restriction --- */
if (stack_trace)
return thisAgent->stack_tf_for_anything[type_restriction];
else
return thisAgent->object_tf_for_anything[type_restriction];
}
growable_string object_to_trace_string ( agent thisAgent,
Symbol object 
)

Definition at line 1283 of file trace.cpp.

References add_to_growable_string(), tracing_parameters::allow_cycle_counts, tracing_parameters::current_o, tracing_parameters::current_s, FALSE, find_appropriate_trace_format(), find_name_of_object(), FOR_ANYTHING_TF, FOR_OPERATORS_TF, FOR_STATES_TF, symbol_union::id, IDENTIFIER_SYMBOL_TYPE, identifier_struct::isa_goal, identifier_struct::isa_operator, make_blank_growable_string(), NIL, symbol_to_string(), identifier_struct::tc_num, agent_struct::tf_printing_tc, tparams, trace_format_list_to_string(), and TRUE.

Referenced by add_trace_for_wme(), add_values_of_attribute_path(), print_object_trace(), and trace_format_list_to_string().

{
int type_of_object;
Symbol *name;
struct tracing_parameters saved_tparams;
/* --- If it's not an identifier, just print it as an atom. Also, if it's
already being printed, print it as an atom to avoid getting into an
infinite loop. --- */
if ((object->common.symbol_type!=IDENTIFIER_SYMBOL_TYPE) ||
(object->id.tc_num == thisAgent->tf_printing_tc)) {
gs = make_blank_growable_string (thisAgent);
add_to_growable_string (thisAgent, &gs, symbol_to_string (thisAgent, object, TRUE, NIL, 0));
return gs;
}
/* --- mark it as being printed --- */
object->id.tc_num = thisAgent->tf_printing_tc;
/* --- determine the type and name of the object --- */
if (object->id.isa_goal) type_of_object=FOR_STATES_TF;
else if (object->id.isa_operator) type_of_object=FOR_OPERATORS_TF;
else type_of_object=FOR_ANYTHING_TF;
name = find_name_of_object (thisAgent, object);
/* --- find the trace format to use --- */
tf = find_appropriate_trace_format (thisAgent, FALSE, type_of_object, name);
/* --- now call trace_format_list_to_string() --- */
if (tf) {
saved_tparams = tparams;
gs = trace_format_list_to_string (thisAgent, tf, object);
tparams = saved_tparams;
} else {
/* --- no applicable trace format, so just print the object itself --- */
gs = make_blank_growable_string (thisAgent);
add_to_growable_string (thisAgent, &gs, symbol_to_string (thisAgent, object, TRUE, NIL, 0));
}
object->id.tc_num = 0; /* unmark it now that we're done */
return gs;
}
list* parse_attribute_path_in_brackets ( agent thisAgent)

Definition at line 180 of file trace.cpp.

References deallocate_symbol_list_removing_references(), destructively_reverse_list(), format, format_string_error_message, make_sym_constant(), MAX_LEXEME_LENGTH, NIL, push(), and TRUE.

Referenced by parse_item_from_format_string().

{
list *path;
char name[MAX_LEXEME_LENGTH+20], *ch;
Symbol *sym;
/* --- look for opening bracket --- */
if (*format != '[') {
format_string_error_message = "Expected '[' followed by attribute (path)";
return NIL;
}
format++;
/* --- check for '*' (null path) --- */
if (*format=='*') {
path = NIL;
format++;
} else {
/* --- normal case: read the attribute path --- */
path = NIL;
while (TRUE) {
ch = name;
while ((*format!=0)&&(*format!=']')&&(*format!='.')) *ch++ = *format++;
if (*format==0) {
format_string_error_message = "'[' without closing ']'";
return NIL;
}
if (ch==name) {
format_string_error_message = "null attribute found in attribute path";
return NIL;
}
*ch = 0;
sym = make_sym_constant (thisAgent, name);
push (thisAgent, sym, path);
if (*format==']') break;
format++; /* skip past '.' */
}
}
/* --- look for closing bracket --- */
if (*format != ']') {
format_string_error_message = "'[' without closing ']'";
return NIL;
}
format++;
return path;
}
trace_format* parse_format_string ( agent thisAgent,
const char *  string 
)

Definition at line 152 of file trace.cpp.

References deallocate_trace_format_list(), format, format_string_error_message, trace_format_struct::next, NIL, parse_item_from_format_string(), and print().

Referenced by add_trace_format(), and print_object_trace_using_provided_format_string().

{
trace_format *first, *prev, *New;
format = string;
prev = NIL;
first = NIL; /* unnecessary, but gcc -Wall warns without it */
while (*format!=0) {
New = parse_item_from_format_string (thisAgent);
if (!New) {
if (prev) prev->next = NIL; else first = NIL;
deallocate_trace_format_list (thisAgent, first);
print (thisAgent, "Error: bad trace format string: %s\n", string);
print (thisAgent, " %s\n", format_string_error_message);
print (thisAgent, " Error found at: %s\n", format);
}
return NIL;
}
if (prev) prev->next = New; else first = New;
prev = New;
}
if (prev) prev->next = NIL; else first = NIL;
return first;
}
trace_format * parse_item_from_format_string ( agent thisAgent)

Definition at line 270 of file trace.cpp.

References allocate_memory(), trace_format_struct::trace_format_data_union::attribute_path, ATTS_AND_VALUES_RECURSIVELY_TFT, ATTS_AND_VALUES_TFT, CURRENT_OPERATOR_TFT, CURRENT_STATE_TFT, trace_format_struct::data, DECISION_CYCLE_COUNT_TFT, ELABORATION_CYCLE_COUNT_TFT, FALSE, format, format_string_error_message, IDENTIFIER_TFT, IF_ALL_DEFINED_TFT, L_BRACKET_TFT, LEFT_JUSTIFY_TFT, make_memory_block_for_string(), MAX_LEXEME_LENGTH, MISCELLANEOUS_MEM_USAGE, NEWLINE_TFT, NIL, trace_format_struct::num, parse_attribute_path_in_brackets(), parse_pattern_in_brackets(), PERCENT_TFT, R_BRACKET_TFT, REPEAT_SUBGOAL_DEPTH_TFT, RIGHT_JUSTIFY_TFT, trace_format_struct::trace_format_data_union::string, STRING_TFT, trace_format_struct::trace_format_data_union::subformat, SUBGOAL_DEPTH_TFT, TRUE, trace_format_struct::type, VALUES_RECURSIVELY_TFT, and VALUES_TFT.

Referenced by parse_format_string(), and parse_pattern_in_brackets().

{
trace_format *tf, *pattern;
char *ch;
list *attribute_path;
int n;
if (*format == 0) return NIL;
if (*format == ']') return NIL;
if (*format == '[') {
format_string_error_message = "unexpected '[' character";
return NIL;
}
if (*format != '%') {
char buf[MAX_LEXEME_LENGTH+20];
ch = buf;
while ((*format != 0) && (*format != '%') &&
(*format != '[') && (*format != ']'))
*ch++ = *format++;
*ch = 0;
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
tf->data.string = make_memory_block_for_string (thisAgent, buf);
return tf;
}
/* --- otherwise *format is '%', so parse the escape sequence --- */
if (!strncmp(format, "%v", 2)) {
format += 2;
attribute_path = parse_attribute_path_in_brackets (thisAgent);
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
tf->data.attribute_path = attribute_path;
return tf;
}
if (!strncmp(format, "%o", 2)) {
format += 2;
attribute_path = parse_attribute_path_in_brackets (thisAgent);
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
tf->data.attribute_path = attribute_path;
return tf;
}
if (!strncmp(format, "%av", 3)) {
format += 3;
attribute_path = parse_attribute_path_in_brackets (thisAgent);
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
tf->data.attribute_path = attribute_path;
return tf;
}
if (!strncmp(format, "%ao", 3)) {
format += 3;
attribute_path = parse_attribute_path_in_brackets (thisAgent);
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
tf->data.attribute_path = attribute_path;
return tf;
}
if (!strncmp(format, "%cs", 3)) {
format += 3;
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
return tf;
}
if (!strncmp(format, "%co", 3)) {
format += 3;
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
return tf;
}
if (!strncmp(format, "%dc", 3)) {
format += 3;
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
return tf;
}
if (!strncmp(format, "%ec", 3)) {
format += 3;
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
return tf;
}
if (!strncmp(format, "%%", 2)) {
format += 2;
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
return tf;
}
if (!strncmp(format, "%[", 2)) {
format += 2;
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
return tf;
}
if (!strncmp(format, "%]", 2)) {
format += 2;
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
return tf;
}
if (!strncmp(format, "%sd", 3)) {
format += 3;
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
return tf;
}
if (!strncmp(format, "%id", 3)) {
format += 3;
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
return tf;
}
if (! strncmp (format, "%ifdef", 6)) {
format += 6;
pattern = parse_pattern_in_brackets (thisAgent, TRUE);
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
tf->data.subformat = pattern;
return tf;
}
if (! strncmp (format, "%left", 5)) {
format += 5;
if (*format != '[') {
format_string_error_message = "Expected '[' after %left";
return NIL;
}
format++;
if (! isdigit(*format)) {
format_string_error_message = "Expected number with %left";
return NIL;
}
n = 0;
while (isdigit(*format)) n = 10*n + (*format++ - '0');
if (*format != ',') {
format_string_error_message = "Expected ',' after number in %left";
return NIL;
}
format++;
pattern = parse_pattern_in_brackets (thisAgent, FALSE);
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
tf->num = n;
tf->data.subformat = pattern;
return tf;
}
if (! strncmp (format, "%right", 6)) {
format += 6;
if (*format != '[') {
format_string_error_message = "Expected '[' after %right";
return NIL;
}
format++;
if (! isdigit(*format)) {
format_string_error_message = "Expected number with %right";
return NIL;
}
n = 0;
while (isdigit(*format)) n = 10*n + (*format++ - '0');
if (*format != ',') {
format_string_error_message = "Expected ',' after number in %right";
return NIL;
}
format++;
pattern = parse_pattern_in_brackets (thisAgent, FALSE);
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
tf->num = n;
tf->data.subformat = pattern;
return tf;
}
if (! strncmp (format, "%rsd", 4)) {
format += 4;
pattern = parse_pattern_in_brackets (thisAgent, TRUE);
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
tf->data.subformat = pattern;
return tf;
}
if (!strncmp(format, "%nl", 3)) {
format += 3;
tf = static_cast<trace_format_struct *>(allocate_memory (thisAgent, sizeof(trace_format),
return tf;
}
/* --- if we haven't recognized it yet, we don't understand it --- */
format_string_error_message = "Unrecognized escape sequence";
return NIL;
}
trace_format* parse_pattern_in_brackets ( agent thisAgent,
Bool  read_opening_bracket 
)

Definition at line 232 of file trace.cpp.

References deallocate_trace_format_list(), format, format_string_error_message, trace_format_struct::next, NIL, and parse_item_from_format_string().

Referenced by parse_item_from_format_string().

{
trace_format *first, *prev, *New;
/* --- look for opening bracket --- */
if (read_opening_bracket) {
if (*format != '[') {
format_string_error_message = "Expected '[' followed by attribute path";
return NIL;
}
format++;
}
/* --- read pattern --- */
prev = NIL;
first = NIL; /* unnecessary, but gcc -Wall warns without it */
while ((*format!=0) && (*format!=']')) {
New = parse_item_from_format_string (thisAgent);
if (!New) {
if (prev) prev->next = NIL; else first = NIL;
deallocate_trace_format_list (thisAgent, first);
return NIL;
}
if (prev) prev->next = New; else first = New;
prev = New;
}
if (prev) prev->next = NIL; else first = NIL;
/* --- look for closing bracket --- */
if (*format != ']') {
format_string_error_message = "'[' without closing ']'";
deallocate_trace_format_list (thisAgent, first);
return NIL;
}
format++;
return first;
}
void print_all_trace_formats ( agent thisAgent,
Bool  stack_trace,
FILE *  f 
)

Definition at line 823 of file trace.cpp.

References do_for_all_items_in_hash_table(), NIL, agent_struct::object_tf_for_anything, agent_struct::object_tr_ht, print_trace_callback_fn(), print_tracing_rule(), agent_struct::printing_stack_traces, agent_struct::stack_tf_for_anything, and agent_struct::stack_tr_ht.

{
int i;
thisAgent->printing_stack_traces = stack_trace;
if (stack_trace) {
for (i=0; i<3; i++) {
if (thisAgent->stack_tf_for_anything[i])
print_tracing_rule (thisAgent, i, NIL, thisAgent->stack_tf_for_anything[i]);
do_for_all_items_in_hash_table (thisAgent, thisAgent->stack_tr_ht[i],print_trace_callback_fn,reinterpret_cast<void*>(f));
}
} else {
for (i=0; i<3; i++) {
if (thisAgent->object_tf_for_anything[i])
print_tracing_rule (thisAgent, i, NIL, thisAgent->object_tf_for_anything[i]);
do_for_all_items_in_hash_table (thisAgent, thisAgent->object_tr_ht[i],print_trace_callback_fn,reinterpret_cast<void*>(f));
}
}
}
void print_all_trace_formats_tcl ( agent thisAgent,
Bool  stack_trace,
FILE *  f 
)

Definition at line 843 of file trace.cpp.

References do_for_all_items_in_hash_table(), NIL, agent_struct::object_tf_for_anything, agent_struct::object_tr_ht, print_trace_callback_fn_tcl(), print_tracing_rule_tcl(), agent_struct::printing_stack_traces, agent_struct::stack_tf_for_anything, and agent_struct::stack_tr_ht.

{
int i;
thisAgent->printing_stack_traces = stack_trace;
if (stack_trace) {
for (i=0; i<3; i++) {
if (thisAgent->stack_tf_for_anything[i])
print_tracing_rule_tcl (thisAgent, i, NIL, thisAgent->stack_tf_for_anything[i]);
do_for_all_items_in_hash_table (thisAgent, thisAgent->stack_tr_ht[i],print_trace_callback_fn_tcl,reinterpret_cast<void*>(f));
}
} else {
for (i=0; i<3; i++) {
if (thisAgent->object_tf_for_anything[i])
print_tracing_rule_tcl (thisAgent, i, NIL, thisAgent->object_tf_for_anything[i]);
do_for_all_items_in_hash_table (thisAgent, thisAgent->object_tr_ht[i],print_trace_callback_fn_tcl,reinterpret_cast<void*>(f));
}
}
}
void print_object_trace ( agent thisAgent,
Symbol object 
)
void print_object_trace_using_provided_format_string ( agent thisAgent,
Symbol object,
Symbol current_goal,
char *  format_string 
)
void print_stack_trace ( agent thisAgent,
Symbol object,
Symbol state,
int  slot_type,
Bool  allow_cycle_counts 
)
void print_stack_trace_xml ( agent thisAgent,
Symbol object,
Symbol state,
int  slot_type,
Bool   
)

Definition at line 1386 of file trace.cpp.

References wme_struct::attr, agent_struct::attribute_symbol, tracing_parameters::current_o, agent_struct::d_cycle_count, find_name_of_object(), FOR_OPERATORS_TF, FOR_STATES_TF, symbol_union::id, agent_struct::impasse_symbol, identifier_struct::impasse_wmes, identifier_struct::level, sym_constant_struct::name, wme_struct::next, NIL, identifier_struct::operator_slot, symbol_union::sc, wme_struct::value, slot_struct::wmes, xml_att_val(), xml_begin_tag(), and xml_end_tag().

Referenced by print_stack_trace().

{
switch(slot_type) {
//create XML trace for state object
xml_begin_tag( thisAgent, kTagState );
xml_att_val( thisAgent, kState_StackLevel, state->id.level - 1 );
xml_att_val( thisAgent, kState_DecisionCycleCt, thisAgent->d_cycle_count );
xml_att_val( thisAgent, kState_ID, object );
// find impasse object and add it to XML
wme* w;
for (w=object->id.impasse_wmes; w!=NIL; w=w->next) {
if(w->attr == thisAgent->attribute_symbol) {
xml_att_val( thisAgent, kState_ImpasseObject, w->value->sc.name );
break;
}
}
// find impasse type and add it to XML
for (w=object->id.impasse_wmes; w!=NIL; w=w->next) {
if(w->attr == thisAgent->impasse_symbol) {
xml_att_val( thisAgent, kState_ImpasseType, w->value->sc.name );
break;
}
}
xml_end_tag( thisAgent, kTagState );
break;
//create XML trace for operator object
xml_begin_tag( thisAgent, kTagOperator );
xml_att_val( thisAgent, kState_StackLevel, object->id.level - 1 );
xml_att_val( thisAgent, kOperator_DecisionCycleCt, thisAgent->d_cycle_count );
if (state->id.operator_slot->wmes)
{
current_o = state->id.operator_slot->wmes->value;
}
if(current_o) {
xml_att_val( thisAgent, kOperator_ID, current_o );
Symbol* name = find_name_of_object(thisAgent, current_o);
if(name)
{
xml_att_val( thisAgent, kOperator_Name, name );
}
}
xml_end_tag( thisAgent, kTagOperator );
break;
default:
// technically it looks like we should try to print a name here, but I think that is an artifact (at least it doesn't make sense for the XML)
break;
}
/* These are the trace formats which I've directly implemented above
add_trace_format (thisAgent, TRUE, FOR_STATES_TF, NIL,
"<state stack_level=\"%sd\" decision_cycle_count=\"%dc\" current_state_id=\"%cs>");
add_trace_format (thisAgent, TRUE, FOR_OPERATORS_TF, NIL,
"<operator stack_level=\"%sd\" decision_cycle_count=\"%dc\" current_operator_id=\"%co>");
add_trace_format (thisAgent, FALSE, FOR_ANYTHING_TF, NIL,
"%id\" %ifdef[name=\"%v[name]\"]");
add_trace_format (thisAgent, FALSE, FOR_STATES_TF, NIL,
"%id\" %ifdef[impasse_object=\"%v[attribute]\" impasse_type=\"%v[impasse]\"]");
*/
}
Bool print_trace_callback_fn ( agent thisAgent,
void *  item,
void *   
)
Bool print_trace_callback_fn_tcl ( agent thisAgent,
void *  item,
void *   
)
void print_trace_format_list ( agent thisAgent,
trace_format tf 
)

Definition at line 514 of file trace.cpp.

References abort_with_fatal_error(), trace_format_struct::trace_format_data_union::attribute_path, ATTS_AND_VALUES_RECURSIVELY_TFT, ATTS_AND_VALUES_TFT, BUFFER_MSG_SIZE, CURRENT_OPERATOR_TFT, CURRENT_STATE_TFT, trace_format_struct::data, DECISION_CYCLE_COUNT_TFT, ELABORATION_CYCLE_COUNT_TFT, cons_struct::first, IDENTIFIER_TFT, IF_ALL_DEFINED_TFT, L_BRACKET_TFT, LEFT_JUSTIFY_TFT, agent_struct::name, NEWLINE_TFT, trace_format_struct::next, NIL, trace_format_struct::num, PERCENT_TFT, print(), print_string(), R_BRACKET_TFT, REPEAT_SUBGOAL_DEPTH_TFT, cons_struct::rest, RIGHT_JUSTIFY_TFT, trace_format_struct::trace_format_data_union::string, STRING_TFT, string_to_escaped_string(), trace_format_struct::trace_format_data_union::subformat, SUBGOAL_DEPTH_TFT, trace_format_struct::type, VALUES_RECURSIVELY_TFT, and VALUES_TFT.

Referenced by print_tracing_rule(), and print_tracing_rule_tcl().

{
cons *c;
for ( ; tf!=NIL; tf=tf->next) {
switch (tf->type) {
case STRING_TFT:
{ char *s;
size_t i, len;
s = string_to_escaped_string (thisAgent, tf->data.string, '"', NULL);
len = strlen (s);
for (i=1; i<len-1; i++) print (thisAgent, "%c", *(s+i));
}
break;
case PERCENT_TFT: print_string (thisAgent, "%%"); break;
case L_BRACKET_TFT: print_string (thisAgent, "%["); break;
case R_BRACKET_TFT: print_string (thisAgent, "%]"); break;
case VALUES_TFT:
if (tf->type==VALUES_TFT) print_string (thisAgent, "%v[");
else if (tf->type==VALUES_RECURSIVELY_TFT) print_string (thisAgent, "%o[");
else if (tf->type==ATTS_AND_VALUES_TFT) print_string (thisAgent, "%av[");
else print_string (thisAgent, "%ao[");
if (tf->data.attribute_path) {
for (c=tf->data.attribute_path; c!=NIL; c=c->rest) {
print_string (thisAgent, static_cast<Symbol *>(c->first)->sc.name);
if (c->rest) print_string (thisAgent, ".");
}
} else {
print_string (thisAgent, "*");
}
print_string (thisAgent, "]");
break;
case CURRENT_STATE_TFT: print_string (thisAgent, "%cs"); break;
case CURRENT_OPERATOR_TFT: print_string (thisAgent, "%co"); break;
case DECISION_CYCLE_COUNT_TFT: print_string (thisAgent, "%dc"); break;
case ELABORATION_CYCLE_COUNT_TFT: print_string (thisAgent, "%ec"); break;
case IDENTIFIER_TFT: print_string (thisAgent, "%id"); break;
print_string (thisAgent, "%ifdef[");
print_string (thisAgent, "]");
break;
if (tf->type==LEFT_JUSTIFY_TFT) print_string (thisAgent, "%left[");
else print_string (thisAgent, "%right[");
print (thisAgent, "%d,", tf->num);
print_string (thisAgent, "]");
break;
case SUBGOAL_DEPTH_TFT: print_string (thisAgent, "%sd"); break;
print_string (thisAgent, "%rsd[");
print_string (thisAgent, "]");
break;
case NEWLINE_TFT: print_string (thisAgent, "%nl"); break;
default:
{ char msg[BUFFER_MSG_SIZE];
strncpy (msg, "Internal error: bad trace format type\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
}
}
}
void print_tracing_rule ( agent thisAgent,
int  type_restriction,
Symbol name_restriction,
trace_format format 
)

Definition at line 769 of file trace.cpp.

References print(), print_string(), print_trace_format_list(), print_with_symbols(), agent_struct::printing_stack_traces, and tracing_object_letters.

Referenced by print_all_trace_formats(), and print_trace_callback_fn().

{
if (thisAgent->printing_stack_traces)
//#ifdef USE_TCL
print_string (thisAgent, "stack-trace-format");
else
print_string (thisAgent, "object-trace-format");
//#else
// print_string (thisAgent, "(stack-trace-format");
// else
// print_string (thisAgent, "(object-trace-format");
//#endif /* USE_TCL */
print (thisAgent, " :add %c ", tracing_object_letters[type_restriction]);
if (name_restriction) print_with_symbols (thisAgent, "%y ", name_restriction);
print_string (thisAgent, "\"");
print_trace_format_list (thisAgent, format);
//#ifdef USE_TCL
print (thisAgent, "\"\n");
//#else
// print (thisAgent, "\")\n");
//#endif /* USE_TCL */
}
void print_tracing_rule_tcl ( agent thisAgent,
int  type_restriction,
Symbol name_restriction,
trace_format format 
)

Definition at line 793 of file trace.cpp.

References print(), print_string(), print_trace_format_list(), print_with_symbols(), and tracing_object_letters.

Referenced by print_all_trace_formats_tcl(), and print_trace_callback_fn_tcl().

{
print (thisAgent, "%c ", tracing_object_letters[type_restriction]);
if (name_restriction) print_with_symbols (thisAgent, "%y ", name_restriction);
print_string (thisAgent, "{");
print_trace_format_list (thisAgent, format);
print (thisAgent, "}\n");
}
Bool remove_trace_format ( agent thisAgent,
Bool  stack_trace,
int  type_restriction,
Symbol name_restriction 
)

Definition at line 691 of file trace.cpp.

References hash_table_struct::buckets, deallocate_trace_format_list(), FALSE, format, tracing_rule_struct::format, free_memory(), hash_name_restriction(), hash_table_struct::log2size, MISCELLANEOUS_MEM_USAGE, tracing_rule_struct::name_restriction, tracing_rule_struct::next_in_hash_bucket, NIL, agent_struct::object_tf_for_anything, agent_struct::object_tr_ht, remove_from_hash_table(), agent_struct::stack_tf_for_anything, agent_struct::stack_tr_ht, symbol_remove_ref(), TRUE, tracing_rule_struct::type_restriction, and uint32_t().

Referenced by add_trace_format(), and destroy_soar_agent().

{
uint32_t hash_value;
if (name_restriction) {
if (stack_trace)
ht = thisAgent->stack_tr_ht[type_restriction];
else
ht = thisAgent->object_tr_ht[type_restriction];
hash_value = hash_name_restriction (name_restriction, ht->log2size);
tr = reinterpret_cast<tracing_rule *>(*(ht->buckets + hash_value));
for ( ; tr!=NIL; tr = tr->next_in_hash_bucket)
if (tr->name_restriction==name_restriction) break;
if (! tr) return FALSE;
remove_from_hash_table (thisAgent, ht, tr);
symbol_remove_ref (thisAgent, name_restriction);
return TRUE;
}
/* --- no name restriction --- */
if (stack_trace)
format = &(thisAgent->stack_tf_for_anything[type_restriction]);
else
format = &(thisAgent->object_tf_for_anything[type_restriction]);
if (! *format) return FALSE;
deallocate_trace_format_list (thisAgent, *format);
*format = NIL;
return TRUE;
}
growable_string selection_to_trace_string ( agent thisAgent,
Symbol object,
Symbol current_state,
int  selection_type,
Bool  allow_cycle_counts 
)

Definition at line 1330 of file trace.cpp.

References tracing_parameters::allow_cycle_counts, tracing_parameters::current_o, tracing_parameters::current_s, find_appropriate_trace_format(), symbol_union::id, make_blank_growable_string(), NIL, identifier_struct::operator_slot, tparams, trace_format_list_to_string(), TRUE, wme_struct::value, and slot_struct::wmes.

Referenced by print_stack_trace().

{
Symbol *name;
struct tracing_parameters saved_tparams;
/* --- find the problem space name --- */
name = NIL;
/* --- find the trace format to use --- */
tf = find_appropriate_trace_format (thisAgent, TRUE, selection_type, name);
/* --- if there's no applicable trace format, print nothing --- */
if (!tf) return make_blank_growable_string (thisAgent);
/* --- save/restore tparams, and call trace_format_list_to_string() --- */
saved_tparams = tparams;
if (current_state) {
tparams.current_s = current_state;
if (current_state->id.operator_slot->wmes) {
}
}
gs = trace_format_list_to_string (thisAgent, tf, object);
tparams = saved_tparams;
return gs;
}
void set_print_trace_formats ( agent thisAgent)
inline

Definition at line 864 of file trace.cpp.

References add_trace_format(), FALSE, FOR_ANYTHING_TF, FOR_OPERATORS_TF, FOR_STATES_TF, NIL, and TRUE.

{
/* --- add default object trace formats --- */
"%id %ifdef[(%v[name])]");
"%id %ifdef[(%v[attribute] %v[impasse])]");
/*********** enable when determine tagged output format
{ Symbol *evaluate_object_sym;
evaluate_object_sym = make_sym_constant (thisAgent, "evaluate-object");
add_trace_format (thisAgent, FALSE, FOR_OPERATORS_TF, evaluate_object_sym,
"%id (evaluate-object %o[object])");
symbol_remove_ref (thisAgent, evaluate_object_sym);
}
*************/
/* --- add default stack trace formats --- */
"%right[6,%dc]: %rsd[ ]==>S: %cs");
"%right[6,%dc]: %rsd[ ] O: %co");
}
void set_tagged_trace_formats ( agent thisAgent)
inline

Definition at line 884 of file trace.cpp.

References add_trace_format(), FALSE, FOR_ANYTHING_TF, FOR_OPERATORS_TF, FOR_STATES_TF, NIL, and TRUE.

{
// KJC 03/05: trying this for tagged output
/* --- add tagged object trace formats --- */
"%id\" %ifdef[name=\"%v[name]\"]");
"%id\" %ifdef[impasse_object=\"%v[attribute]\" impasse_type=\"%v[impasse]\"]");
/*********** enable when determine tagged output format
{ Symbol *evaluate_object_sym;
evaluate_object_sym = make_sym_constant (thisAgent, "evaluate-object");
add_trace_format (thisAgent, FALSE, FOR_OPERATORS_TF, evaluate_object_sym,
"%id (evaluate-object %o[object])");
symbol_remove_ref (thisAgent, evaluate_object_sym);
}
*************/
/* --- add tagged stack trace formats --- */
"<state stack_level=\"%sd\" decision_cycle_count=\"%dc\" current_state_id=\"%cs>");
"<operator stack_level=\"%sd\" decision_cycle_count=\"%dc\" current_operator_id=\"%co>");
}
growable_string trace_format_list_to_string ( agent thisAgent,
trace_format tf,
Symbol object 
)

Definition at line 1086 of file trace.cpp.

References abort_with_fatal_error(), add_to_growable_string(), add_trace_for_attribute_path(), tracing_parameters::allow_cycle_counts, trace_format_struct::trace_format_data_union::attribute_path, ATTS_AND_VALUES_RECURSIVELY_TFT, ATTS_AND_VALUES_TFT, BUFFER_MSG_SIZE, tracing_parameters::current_o, CURRENT_OPERATOR_TFT, tracing_parameters::current_s, CURRENT_STATE_TFT, agent_struct::d_cycle_count, trace_format_struct::data, DECISION_CYCLE_COUNT_TFT, agent_struct::e_cycle_count, ELABORATION_CYCLE_COUNT_TFT, FALSE, found_undefined, free_growable_string(), GROWABLE_STRING_TRACE_FORMAT_LIST_TO_STRING_BUFFER_SIZE, symbol_union::id, IDENTIFIER_TFT, IF_ALL_DEFINED_TFT, L_BRACKET_TFT, LEFT_JUSTIFY_TFT, length_of_growable_string(), identifier_struct::level, make_blank_growable_string(), NEWLINE_TFT, trace_format_struct::next, NIL, trace_format_struct::num, object_to_trace_string(), PERCENT_TFT, R_BRACKET_TFT, REPEAT_SUBGOAL_DEPTH_TFT, RIGHT_JUSTIFY_TFT, trace_format_struct::trace_format_data_union::string, STRING_TFT, trace_format_struct::trace_format_data_union::subformat, SUBGOAL_DEPTH_TFT, symbol_to_string(), text_of_growable_string(), tparams, TRUE, trace_format_struct::type, VALUES_RECURSIVELY_TFT, and VALUES_TFT.

Referenced by object_to_trace_string(), print_object_trace_using_provided_format_string(), and selection_to_trace_string().

{
#define GROWABLE_STRING_TRACE_FORMAT_LIST_TO_STRING_BUFFER_SIZE 50
growable_string result, temp_gs;
int i;
result = make_blank_growable_string(thisAgent);
for ( ; tf!=NIL; tf=tf->next) {
switch (tf->type) {
case STRING_TFT:
add_to_growable_string (thisAgent, &result, tf->data.string);
break;
add_to_growable_string (thisAgent, &result, "%");
break;
add_to_growable_string (thisAgent, &result, "[");
break;
add_to_growable_string (thisAgent, &result, "]");
break;
case VALUES_TFT:
add_trace_for_attribute_path (thisAgent, object, tf->data.attribute_path, &result,
break;
add_trace_for_attribute_path (thisAgent, object, tf->data.attribute_path, &result,
break;
add_trace_for_attribute_path (thisAgent, object, tf->data.attribute_path, &result,
break;
add_trace_for_attribute_path (thisAgent, object, tf->data.attribute_path, &result,
break;
if (! tparams.current_s) {
} else {
temp_gs = object_to_trace_string (thisAgent, tparams.current_s);
// KJC added to play with tagged output...
//add_to_growable_string (thisAgent, &result, "id=");
add_to_growable_string (thisAgent, &result, text_of_growable_string(temp_gs));
free_growable_string (thisAgent, temp_gs);
}
break;
if (! tparams.current_o) {
} else {
temp_gs = object_to_trace_string (thisAgent, tparams.current_o);
add_to_growable_string (thisAgent, &result, text_of_growable_string(temp_gs));
free_growable_string (thisAgent, temp_gs);
}
break;
SNPRINTF (buf,GROWABLE_STRING_TRACE_FORMAT_LIST_TO_STRING_BUFFER_SIZE, "%lu", static_cast<long unsigned int>(thisAgent->d_cycle_count));
buf[GROWABLE_STRING_TRACE_FORMAT_LIST_TO_STRING_BUFFER_SIZE - 1] = 0; /* ensure null termination */
add_to_growable_string (thisAgent, &result, buf);
} else {
}
break;
SNPRINTF (buf,GROWABLE_STRING_TRACE_FORMAT_LIST_TO_STRING_BUFFER_SIZE, "%lu", static_cast<long unsigned int>(thisAgent->e_cycle_count));
buf[GROWABLE_STRING_TRACE_FORMAT_LIST_TO_STRING_BUFFER_SIZE - 1] = 0; /* ensure null termination */
add_to_growable_string (thisAgent, &result, buf);
} else {
}
break;
ch = symbol_to_string (thisAgent, object, TRUE, NULL, 0);
add_to_growable_string (thisAgent, &result, ch);
break;
{ Bool saved_found_undefined;
saved_found_undefined = found_undefined;
temp_gs = trace_format_list_to_string (thisAgent, tf->data.subformat, object);
add_to_growable_string (thisAgent, &result, text_of_growable_string(temp_gs));
free_growable_string (thisAgent, temp_gs);
found_undefined = saved_found_undefined;
}
break;
temp_gs = trace_format_list_to_string (thisAgent, tf->data.subformat, object);
add_to_growable_string (thisAgent, &result, text_of_growable_string(temp_gs));
for (i=tf->num - length_of_growable_string(temp_gs); i>0; i--)
add_to_growable_string (thisAgent, &result, " ");
free_growable_string (thisAgent, temp_gs);
break;
temp_gs = trace_format_list_to_string (thisAgent, tf->data.subformat, object);
for (i=tf->num - length_of_growable_string(temp_gs); i>0; i--)
add_to_growable_string (thisAgent, &result, " ");
add_to_growable_string (thisAgent, &result, text_of_growable_string(temp_gs));
free_growable_string (thisAgent, temp_gs);
break;
SNPRINTF (buf,GROWABLE_STRING_TRACE_FORMAT_LIST_TO_STRING_BUFFER_SIZE, "%u", tparams.current_s->id.level - 1);
buf[GROWABLE_STRING_TRACE_FORMAT_LIST_TO_STRING_BUFFER_SIZE - 1] = 0; /* ensure null termination */
add_to_growable_string (thisAgent, &result, buf);
} else {
}
break;
temp_gs = trace_format_list_to_string (thisAgent, tf->data.subformat, object);
for (i = tparams.current_s->id.level - 1; i>0; i--)
add_to_growable_string (thisAgent, &result, text_of_growable_string(temp_gs));
free_growable_string (thisAgent, temp_gs);
} else {
}
break;
add_to_growable_string (thisAgent, &result, "\n");
break;
default:
{ char msg[BUFFER_MSG_SIZE];
strncpy (msg,"Internal error: bad trace format type\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
}
}
return result;
}
uint32_t tracing_rule_hash_function ( void *  item,
short  num_bits 
)

Definition at line 644 of file trace.cpp.

References hash_name_restriction(), and tracing_rule_struct::name_restriction.

Referenced by init_tracing().

{
tr = static_cast<tracing_rule_struct *>(item);
return hash_name_restriction (tr->name_restriction, num_bits);
}

Variable Documentation

const char* format
const char* format_string_error_message
Bool found_undefined

Definition at line 921 of file trace.cpp.

Referenced by add_trace_for_attribute_path(), and trace_format_list_to_string().

struct tracing_parameters tparams
char tracing_object_letters[3] = {'*','s','o'}

Definition at line 767 of file trace.cpp.

Referenced by print_tracing_rule(), and print_tracing_rule_tcl().