Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option to handle errors by breaking into a debugger (same behavior as in ipython --pdb) #38

Open
timotheecour opened this issue Jul 26, 2018 · 1 comment
Projects

Comments

@timotheecour
Copy link
Contributor

timotheecour commented Jul 26, 2018

this feature is invaluable for debugging:

 ipython3 --pdb -i tests/python/t01_inim_issue_debug_on_error.py
Python 3.6.5 (default, Jun 20 2018, 01:40:23)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
~/git_clone/nim/timn/tests/python/t01_inim_issue_debug_on_error.py in <module>()
      4   print(b[3])
      5
----> 6 fun()

~/git_clone/nim/timn/tests/python/t01_inim_issue_debug_on_error.py in fun()
      2   a = 10
      3   b = [1, 2, 3]
----> 4   print(b[3])
      5
      6 fun()

IndexError: list index out of range
> /Users/timothee/git_clone/nim/timn/tests/python/t01_inim_issue_debug_on_error.py(4)fun()
      2   a = 10
      3   b = [1, 2, 3]
----> 4   print(b[3])
      5
      6 fun()

ipdb> h

Documented commands (type help <topic>):
========================================
EOF    cl         disable  interact  next    psource  rv         unt
a      clear      display  j         p       q        s          until
alias  commands   down     jump      pdef    quit     source     up
args   condition  enable   l         pdoc    r        step       w
b      cont       exit     list      pfile   restart  tbreak     whatis
break  continue   h        ll        pinfo   return   u          where
bt     d          help     longlist  pinfo2  retval   unalias
c      debug      ignore   n         pp      run      undisplay

Miscellaneous help topics:
==========================
exec  pdb

ipdb> whatis a
<class 'int'>
ipdb> pp a
10
ipdb> pp b
[1, 2, 3]

tests/python/t01_inim_issue_debug_on_error.py

def fun():
  a = 10
  b = [1, 2, 3]
  print(b[3])

fun()

implementation

this could actually be pretty simple:
we could use this when compiling programs:
nim --debugger:native|endb

NOTE: this option should be enabled / disabled during inim session

NOTE: more generally, options for nim compilation (cf the --nim= I added) should be customizable during inim session. Just need a good way to handle these "meta" commands

@0atman
Copy link
Collaborator

0atman commented Apr 7, 2020

We now have compile-time options available after #51, Is this now possible?

@0atman 0atman added this to Needs triage in Bug Triage Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Bug Triage
  
Needs triage
Development

No branches or pull requests

2 participants