sprhawk / python-on-a-chip

Automatically exported from code.google.com/p/python-on-a-chip
Other
0 stars 0 forks source link

Add debug info to exception reports #103

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Bryan Jones asks for more useful error messages that report filename, line 
number and, in the case of NameErrors, the name that caused the error.

Original issue reported on code.google.com by dwhall...@gmail.com on 26 Jul 2010 at 5:28

GoogleCodeExporter commented 9 years ago
Here's info on the line number table found in code objects:
http://svn.python.org/view/python/trunk/Objects/lnotab_notes.txt?view=markup

Original comment by dwhall...@gmail.com on 26 Jul 2010 at 7:21

GoogleCodeExporter commented 9 years ago
r526
Size before:
    main.elf  :
    section             size      addr
    .text              46988         0
    .rodata             4236     46988
    .rodata.str1.1        69     51224
    .rodata.str1.4       136     51296
    .data               2232   2097152
    .bss               12812   2099384

Original comment by dwhall...@gmail.com on 26 Jul 2010 at 9:18

GoogleCodeExporter commented 9 years ago
Created HAVE_DEBUG_INFO definition in pmfeatures.h and pmImgCreator.py to 
select this feature.  Created 3 new fields in the CO struct: firstlineno, 
lnotab, filename.  Cleaned pmImgCreator.py and dismantle.py a little.  Had to 
update some unit tests since the CodeImage format changed.  The big changes are 
in plat_reportError(): added filename and exception name lookup tables; use the 
new line number table (lnotab) to calculate the line number for the traceback; 
printing filename for each frame on the traceback.

Original comment by dwhall...@gmail.com on 2 Aug 2010 at 3:02

GoogleCodeExporter commented 9 years ago
r538 is the new before (I just mainlined Issue #109)

Size before:
    main.elf  :
    section             size      addr
    .text              47188         0
    .rodata             4400     47188
    .rodata.str1.1        69     51588
    .rodata.str1.4       136     51660
    .data               2236   2097152
    .bss               12812   2099388

Original comment by dwhall...@gmail.com on 3 Aug 2010 at 3:46

GoogleCodeExporter commented 9 years ago
After fixing #109, this works like a charm:

ipm> def foo():
 def bar(n):
  return n * 2 / 0
 bar(6)

ipm> foo()
 Traceback (most recent call first):
  File "<ipm>", line 3, in bar
  File "<ipm>", line 4, in foo
  File "<ipm>", line 1, in <ipm>
  File "../lib/ipm.py", line 91, in ipm
  File "main.py", line 19, in main
  <module>.
ZeroDivisionError detected by interp.c:349

Original comment by dwhall...@gmail.com on 3 Aug 2010 at 7:18

GoogleCodeExporter commented 9 years ago
Added UNIT tests to ut_codeobj.c to test the co_filename and co_lnotab are 
non-null and that co_firstlineno is not 0xAAAA.  The heap is fill with 0xAA to 
detect errors when __DEBUG__ is true.

Also added new code images for the different cases of HAVE_CLOSURE and 
HAVE_DEBUG_INFO.

Original comment by dwhall...@gmail.com on 3 Aug 2010 at 7:20

GoogleCodeExporter commented 9 years ago
r549
Mainlined directly

Original comment by dwhall...@gmail.com on 4 Aug 2010 at 1:56

GoogleCodeExporter commented 9 years ago
r550
- Removed extraneous print from plat_reportError()
Post mainline checkin.

Original comment by dwhall...@gmail.com on 4 Aug 2010 at 3:48

GoogleCodeExporter commented 9 years ago
r551:
- Included and tested these improvement on the PIC. All tests pass.
- Updated Makefile (long out of date) to build for the PIC
- Updated docs and included some missing files, fixed most Doxygen complaints.

Original comment by bjones460@gmail.com on 4 Aug 2010 at 3:49

GoogleCodeExporter commented 9 years ago
r553
- Removed extraneous print from plat_reportError() in pic24/plat.c
Post mainline checkin.

Original comment by dwhall...@gmail.com on 4 Aug 2010 at 4:11