diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-19 13:55:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-19 13:55:49 +0400 |
commit | 4bc46b18d1e3d3e72a27e7f721cd0800b8ff3a4f (patch) | |
tree | 99156a12b66281f4dfe251f30c2083f90182210d /source/blender/python/generic | |
parent | 4408a4aeffaa48a4346d03d758dce2fb5043b8d3 (diff) |
handy function for getting a python stacktrace while debugging in gdb
Diffstat (limited to 'source/blender/python/generic')
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index a9b9a5d6cf6..657844ebfff 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -152,6 +152,21 @@ void PyC_LineSpit(void) fprintf(stderr, "%s:%d\n", filename, lineno); } +void PyC_StackSpit(void) +{ + /* Note, allow calling from outside python (RNA) */ + if (!PYC_INTERPRETER_ACTIVE) { + fprintf(stderr, "python line lookup failed, interpreter inactive\n"); + return; + } + else { + /* lame but handy */ + PyGILState_STATE gilstate = PyGILState_Ensure(); + PyRun_SimpleString("__import__('traceback').print_stack()"); + PyGILState_Release(gilstate); + } +} + void PyC_FileAndNum(const char **filename, int *lineno) { PyFrameObject *frame; |