[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to get current function?
From: |
Skip Montanaro |
Subject: |
Re: how to get current function? |
Date: |
10 Jun 2001 00:01:43 -0700 |
Following up to my own post...
I wrote:
> From within gdb I'd like to print a representation of the Python stack.
I now have something that seems to work (albeit slowly). I'm wondering if
there is a better way to achieve the same effect (either more foolproof or
faster). Here's what I've come up with so far:
define ppystack
set $__fr = 0
select-frame $__fr
while $pc < Py_Main || $pc > Py_GetArgcArgv
if $pc > eval_code2 && $pc < set_exc_info
set $__fn = PyString_AsString(co->co_filename)
set $__n = PyString_AsString(co->co_name)
printf "%s (%d): %s\n", $__fn, f->f_lineno, $__n
end
set $__fr = $__fr + 1
select-frame $__fr
end
select-frame 0
end
The condition on the while loop is an attempt to see if I've popped up far
enough on the stack to have seen all the eval_code2 stack frames. The condition
on the first if statement is a test to see if the current stack frame is
within eval_code2. Both rely on the fact that there are other functions
immediately following the functions of interest. I'm not sure how reliable
those tests are.
Any insights/improvements appreciated,
Skip