@@ -268,7 +268,7 @@ def visit_function_obj(v, ids_seen_set):
268268
269269class PGLogger (bdb .Bdb ):
270270
271- def __init__ (self , cumulative_mode , heap_primitives , finalizer_func , disable_security_checks = False ):
271+ def __init__ (self , cumulative_mode , heap_primitives , show_only_outputs , finalizer_func , disable_security_checks = False ):
272272 bdb .Bdb .__init__ (self )
273273 self .mainpyfile = ''
274274 self ._wait_for_mainpyfile = 0
@@ -283,6 +283,10 @@ def __init__(self, cumulative_mode, heap_primitives, finalizer_func, disable_sec
283283 # if True, then render certain primitive objects as heap objects
284284 self .render_heap_primitives = heap_primitives
285285
286+ # if True, then don't render any data structures in the trace,
287+ # and show only outputs
288+ self .show_only_outputs = show_only_outputs
289+
286290 # a function that takes the output trace as a parameter and
287291 # processes it
288292 self .finalizer_func = finalizer_func
@@ -820,14 +824,24 @@ def create_encoded_stack_entry(cur_frame):
820824 e ['unique_hash' ] = hash_str
821825
822826
823- trace_entry = dict (line = lineno ,
824- event = event_type ,
825- func_name = tos [0 ].f_code .co_name ,
826- globals = encoded_globals ,
827- ordered_globals = ordered_globals ,
828- stack_to_render = stack_to_render ,
829- heap = self .encoder .get_heap (),
830- stdout = get_user_stdout (tos [0 ]))
827+ if self .show_only_outputs :
828+ trace_entry = dict (line = lineno ,
829+ event = event_type ,
830+ func_name = tos [0 ].f_code .co_name ,
831+ globals = {},
832+ ordered_globals = [],
833+ stack_to_render = [],
834+ heap = {},
835+ stdout = get_user_stdout (tos [0 ]))
836+ else :
837+ trace_entry = dict (line = lineno ,
838+ event = event_type ,
839+ func_name = tos [0 ].f_code .co_name ,
840+ globals = encoded_globals ,
841+ ordered_globals = ordered_globals ,
842+ stack_to_render = stack_to_render ,
843+ heap = self .encoder .get_heap (),
844+ stdout = get_user_stdout (tos [0 ]))
831845
832846 # TODO: refactor into a non-global
833847 global __html__ , __css__ , __js__
@@ -1042,7 +1056,7 @@ def finalize(self):
10421056def exec_script_str (script_str , raw_input_lst_json , options_json , finalizer_func ):
10431057 options = json .loads (options_json )
10441058
1045- logger = PGLogger (options ['cumulative_mode' ], options ['heap_primitives' ], finalizer_func )
1059+ logger = PGLogger (options ['cumulative_mode' ], options ['heap_primitives' ], options [ 'show_only_outputs' ], finalizer_func )
10461060
10471061 # TODO: refactor these NOT to be globals
10481062 global input_string_queue
@@ -1066,7 +1080,7 @@ def exec_script_str(script_str, raw_input_lst_json, options_json, finalizer_func
10661080# WARNING: ONLY RUN THIS LOCALLY and never over the web, since
10671081# security checks are disabled
10681082def exec_script_str_local (script_str , raw_input_lst_json , cumulative_mode , heap_primitives , finalizer_func ):
1069- logger = PGLogger (cumulative_mode , heap_primitives , finalizer_func , disable_security_checks = True )
1083+ logger = PGLogger (cumulative_mode , heap_primitives , False , finalizer_func , disable_security_checks = True )
10701084
10711085 # TODO: refactor these NOT to be globals
10721086 global input_string_queue
0 commit comments