Skip to content

Commit 78234d9

Browse files
committed
implemented simple breakpoints as '#break' end of line comments
1 parent 1e40239 commit 78234d9

5 files changed

Lines changed: 2689 additions & 1 deletion

File tree

v3/GChartWrapper/README

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Downloaded from https://code.google.com/p/google-chartwrapper/
22

33
and tweaked to remove dependency on utf-8 encoding, which seems to trip
4-
up parts of OPT
4+
up parts of OPT, and to remove unnecessary imports (for security and
5+
efficiency reasons)
56

67
See here for demos: http://justquick.github.io/google-chartwrapper-demos/
8+
9+
See here for the official API, which is now deprecated:
10+
https://developers.google.com/chart/image/
11+

v3/pg_logger.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
#DEBUG = False
5555
DEBUG = True
5656

57+
BREAKPOINT_STR = '#break'
58+
5759

5860
# simple sandboxing scheme:
5961
#
@@ -329,6 +331,13 @@ def __init__(self, cumulative_mode, heap_primitives, finalizer_func, disable_sec
329331

330332
self.executed_script = None # Python script to be executed!
331333

334+
# if there is at least one line that ends with BREAKPOINT_STR,
335+
# then activate "breakpoint mode", where execution should stop
336+
# ONLY at breakpoint lines.
337+
self.breakpoints = []
338+
339+
self.prev_lineno = -1 # keep track of previous line just executed
340+
332341

333342
def get_frame_id(self, cur_frame):
334343
return self.frame_ordered_ids[cur_frame]
@@ -470,6 +479,15 @@ def interaction(self, frame, traceback, event_type):
470479
top_frame = tos[0]
471480
lineno = tos[1]
472481

482+
# stop at both the breakpoint line and the next executed line,
483+
# so that if you set only ONE breakpoint, OPT shows the state
484+
# before and after that line gets executed.
485+
if self.breakpoints:
486+
if not ((lineno in self.breakpoints) or (self.prev_lineno in self.breakpoints)):
487+
return
488+
489+
self.prev_lineno = lineno
490+
473491

474492
# debug ...
475493
'''
@@ -854,6 +872,12 @@ def create_encoded_stack_entry(cur_frame):
854872
def _runscript(self, script_str):
855873
self.executed_script = script_str
856874

875+
for (i, line) in enumerate(self.executed_script.splitlines()):
876+
line_no = i + 1
877+
if line.endswith(BREAKPOINT_STR):
878+
self.breakpoints.append(line_no)
879+
880+
857881
# When bdb sets tracing, a number of call and line events happens
858882
# BEFORE debugger even reaches user's code (and the exact sequence of
859883
# events depends on python version). So we take special measures to

0 commit comments

Comments
 (0)