diff --git a/gdb-port/parser.py b/gdb-port/parser.py index f69edddc68f38114461457a928cc09fdf9021c57..ffcaec886c3973755c11ad50c76c72446acc3362 100644 --- a/gdb-port/parser.py +++ b/gdb-port/parser.py @@ -144,7 +144,7 @@ class ParserStack: if len(self.bytes_at_enter) > 1: prev = self.bytes_at_enter[-2] thusfar = self.bytes_at_enter[-1] - prev - print("Bytes allocated since last h_do_parse:", thusfar, ", parser:", str(parser)) # DEBUG + #print("Bytes allocated since last h_do_parse:", thusfar, ", parser:", str(parser)) # DEBUG #import code; code.interact(local=locals()) # DEBUG #breakpoint() # DEBUG #if thusfar < 0: @@ -174,7 +174,7 @@ class ParserStack: allocs = self.commit_at_pop() #print("adding mem use: parser:", str(parser_obj), "arena:", hex(int(self.arena)), "bytes:", allocated_bytes) # DEBUG - print("adding mem use (alternate): parser:", str(parser_obj), "arena:", hex(int(self.arena)), "bytes:", allocs) # DEBUG + #print("adding mem use (alternate): parser:", str(parser_obj), "arena:", hex(int(self.arena)), "bytes:", allocs) # DEBUG #parser_obj.add_mem_use(int(self.arena), allocs) # TODO: allocations can be attributed to individual h_do_parse(parser) calls, thus the same per-parser per-arena stats tracking can be done @@ -340,10 +340,10 @@ class ParserStack: ev_list = self.stack_events[ev_start:] # NOTE: Assumes that ParserStack.pop() pops p_stack after this function runs current_parser = self.p_stack[-1] - print("commit_at_pop: self.committed:", self.committed) # DEBUG - print("commit_at_pop: ev_list:", ev_list) # DEBUG - print("commit_at_pop: current_parser:", current_parser) # DEBUG - print("commit_at_pop: current_event:", (current_event[0], current_event[1], hex(current_event[2].address))) # DEBUG + #print("commit_at_pop: self.committed:", self.committed) # DEBUG + #print("commit_at_pop: ev_list:", ev_list) # DEBUG + #print("commit_at_pop: current_parser:", current_parser) # DEBUG + #print("commit_at_pop: current_event:", (current_event[0], current_event[1], hex(current_event[2].address))) # DEBUG # We assume that there is either a string of "push" events before current event, or ev_list only contains the current event # This is because if there were a "pop" event, it'd have triggered a commit already, moving self.committed up to its index @@ -351,7 +351,7 @@ class ParserStack: assert ev_list[-1] == current_event # DEBUG # The memory allocated in the "frame" enclosed by current_event and the push event just prior current_frame_alloc = current_event[1] - previous_event[1] - print("commit_at_pop: current_frame_alloc", current_frame_alloc) # DEBUG + #print("commit_at_pop: current_frame_alloc", current_frame_alloc) # DEBUG pop_allocs = {} # TODO: clean up @@ -370,12 +370,12 @@ class ParserStack: for index, event in enumerate(ev_list[:-1]): alloc = next(differences) assert event != current_event - print("commit_at_pop: alloc:", alloc) # DEBUG - print("commit_at_pop: adding to parser", event[2].name, hex(event[2].address)) + #print("commit_at_pop: alloc:", alloc) # DEBUG + #print("commit_at_pop: adding to parser", event[2].name, hex(event[2].address)) event[2].add_mem_use(int(self.arena), alloc) pop_allocs[event[2].address] = pop_allocs.get(event[2].address, 0) + alloc - print("commit_at_pop: pop_allocs:", pop_allocs) # DEBUG + #print("commit_at_pop: pop_allocs:", pop_allocs) # DEBUG self.committed = len(self.stack_events)-1 return pop_allocs @@ -386,10 +386,10 @@ class ParserStack: ev_list = self.stack_events[ev_start:] # NOTE: assumes that ParserStack.push() has already pushed the parser in question on the stack current_parser = self.p_stack[-1] - print("commit_at_push: self.committed:", self.committed) # DEBUG - print("commit_at_push: ev_list:", ev_list) # DEBUG - print("commit_at_push: current_parser:", current_parser) # DEBUG - print("commit_at_push: current_event:", current_event) # DEBUG + #print("commit_at_push: self.committed:", self.committed) # DEBUG + #print("commit_at_push: ev_list:", ev_list) # DEBUG + #print("commit_at_push: current_parser:", current_parser) # DEBUG + #print("commit_at_push: current_event:", current_event) # DEBUG # Degenerate cases: there is a single push event on ev_list. In that case, we do nothing but increment self.committed # A pop followed by a push will also be effectively a no-op, with the difference in bytes allocated being zero (but potentially not always: does longjmp() mess with this?) @@ -401,11 +401,11 @@ class ParserStack: alloc = next(differences) event[2].add_mem_use(int(self.arena), alloc) push_allocs[event[2].address] = push_allocs.get(event[2].address, 0) + alloc - print("commit_at_push: push_allocs:", push_allocs) # DEBUG + #print("commit_at_push: push_allocs:", push_allocs) # DEBUG # Most recent event is a push event, and we have no information on its allocations yet. So we only increment self.committed up to the index of the previous event self.committed = len(self.stack_events)-2 - print("commit_at_push: self.committed after update:", self.committed) # DEBUG + #print("commit_at_push: self.committed after update:", self.committed) # DEBUG # TODO: do we want to increment mem use in commit_at_*, or do we want to return the dict and have it taken care of by push()/pop()? return push_allocs diff --git a/gdb-port/top-level-parse.py b/gdb-port/top-level-parse.py index b3f1f6d6b81718e3ebf673a99749e2f84219fec7..060a7c8d0920272633bd37923d2cb1752f2360f2 100644 --- a/gdb-port/top-level-parse.py +++ b/gdb-port/top-level-parse.py @@ -125,7 +125,7 @@ class TopLevelParse: # Caveat: parser_stack is assumed not to be None if we could get a parser_obj #if parser_obj.name == "ws": # print("breakpoint is adding", alloc_size, "bytes to ws") # DEBUG - print("breakpoint is adding", alloc_size, "bytes to", parser_obj.name, hex(parser_obj.address)) # DEBUG + #print("breakpoint is adding", alloc_size, "bytes to", parser_obj.name, hex(parser_obj.address)) # DEBUG parser_obj.add_mem_use(int(parser_stack.arena), alloc_size) elif parser_stack is not None: #print("Allocation of " + str(alloc_size) + " bytes without a parser on the stack. (Happens before first call perform_lowlevel_parse to or after return from that call)")