Package: yasdu
Yet another stack/session dumper utilityA "simple" library to help analyze issues post-mortem without a debugger attached.UsageDumping the process stateYou can useyasdu.dump()to dump the process state.
Be careful:Dumps like this can contain sensitive data, like passwords, authentication tokens etc.SHARE THEM WITH EXTREME CAUTION.yasdu.dumpwill not overwrite files and will createfilename.numberfiles.importyasduyasdu.dump('dump.json','Comment here')# *** Created stack dump in 'dump.json' ***# => 'dump.json'# 'dump.json' is actual filename the dump was saved inyasdu.dump('dump.json','Comment here')# *** Created stack dump in 'dump.json.1' ***# => 'dump.json.1'# Since 'dump.json' already exists, the library picked 'dump.json.1'Hooking exceptions.Theyasdu.hook()function will hooksys.excepthookand if there's an uncaught
exception killing the program it will dump the process state intoyasdu_autodump_[ISODATETIME].jsonSeehook and crash exampleLoading dumpsCLI toolFor the CLI IPython is recommended but not needed.usage: yasdu [-h] -l FILE [-S] [-y]

optional arguments:
  -l FILE, --load FILE  Loads given file and starts a Python interpreter

  -S, --no-sources      Disables reading the sources from disk and showing them, useful if they have changed.
  -y                    Assume yes to all questions
  -h, --help            show this help message and exitExample:$pythonexamples/hook_and_crash.py
***Createdstackdumpin'yasdu_autodump.json'***
Traceback(mostrecentcalllast):File"examples/hook_and_crash.py",line13,in<module>happily_convert_some_values()File"examples/hook_and_crash.py",line8,inhappily_convert_some_valuesv2=int('deadbeef')# oh noesValueError:invalidliteralforint()withbase10:'deadbeef'Let's inspect the automatic dump.$yasdu-lyasdu_autodump.jsonLoadingdumpfilescanallowthemtoexecutecode.Doyoustillwanttoproceed?[y/N]yUnpickled9objects...Doneloadingdata.# exception traceback generated by the program ↓Thisisanautomaticdumpithasbeentriggeredbyanexception:Traceback(mostrecentcalllast):File"examples/hook_and_crash.py",line13,in<module>happily_convert_some_values()File"examples/hook_and_crash.py",line8,inhappily_convert_some_valuesv2=int('deadbeef')# oh noesValueError:invalidliteralforint()withbase10:'deadbeef'# stack data saved in the dump and sources loaded from diskAvailableframes0.examples/hook_and_crash.py:13happily_convert_some_values()<--# we're here1.examples/hook_and_crash.py:8v2=int('deadbeef')# oh noesLoadedFrameobjectisavailablethroughthe`_lframe`globalvariableUsingIPythonforshell...# [snip][hook_and_crash.py:13(0)]In[1]:sources()importyasdusome_global_variable='testing123'defhappily_convert_some_values():v1=int('deadbeef',16)v2=int('deadbeef')# oh noesif__name__=='__main__':yasdu.hook()->happily_convert_some_values()[hook_and_crash.py:13(0)]In[2]:down()Availableframes0.examples/hook_and_crash.py:13happily_convert_some_values()1.examples/hook_and_crash.py:8v2=int('deadbeef')# oh noes <--[hook_and_crash.py:13(0)]In[3]:sources()importyasdusome_global_variable='testing123'defhappily_convert_some_values():v1=int('deadbeef',16)->v2=int('deadbeef')# oh noesif__name__=='__main__':yasdu.hook()happily_convert_some_values()# variables are loaded from the dump[hook_and_crash.py:13(0)]In[4]:v1Out[4]:3735928559[hook_and_crash.py:13(0)]In[5]:some_global_variableOut[5]:'testing123'