Skip to content

Commit

Permalink
engine: save_addr_props: Properly skip areas without properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
pfalcon committed Jan 27, 2018
1 parent 27791dc commit 93b1e21
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scratchabit/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,13 @@ def save_addr_props(self, prefix):
if addr > area_end:
stream.close()
area_i += 1
while addr > areas[area_i][END]:
area_i += 1
try:
while addr < areas[area_i][START]:
area_i += 1
while addr > areas[area_i][END]:
area_i += 1
except IndexError:
return
assert addr >= areas[area_i][START], "%x vs %x" % (addr, areas[area_i][START])
stream = open(prefix + ".%08x" % areas[area_i][START], "w")
#stream.write("addr=%x area_end=%x\n" % (addr, area_end))
Expand Down

3 comments on commit 93b1e21

@thesourcerer8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking whether we should add warnings and write them at least to the logfile, so that we can analyze them in case we are starting to loose data we shouldn't loose.

@pfalcon
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's the reason why exceptions are logged and even showed to user in many other places ;-). In that particular case, it's safe - an issue would have been logged before. And save routines are optimized for speed (expected to be frequent operation), so doing extra stuff is not desirable. Anyway, I definitely keep that thing in mind - need to open a dedicated ticket to track it consistently actually.

@pfalcon
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P.S. Btw, "except IndexError" is not an error here, it's normal termination condition. That's exactly that "optimization for speed" - as Python check array bounds itself anyway, just relying on that to see when array is exhausted, instead of additional explicit check - that's not how I'd write a normal Python code, but again, that whole func is coded to cut overheads.

Please sign in to comment.