viraptor
viraptor

Reputation: 34145

Where does gdb get function names from?

I'm looking at a live python process using GDB and see the following frames:

...
#5  call_function (oparg=<optimized out>, pp_stack=0x7fffb1b2ffa0) at Python/ceval.c:4084
#6  PyEval_EvalFrameEx (f=f@entry=0x1a03850, throwflag=throwflag@entry=0) at Python/ceval.c:2679
...

I'm confused about where does the call_function come from though. It doesn't seem to be a symbol in either the python executable or the binary:

~  ᐅ objdump -x /usr/lib/libpython3.3m.so.1.0 | grep call_function
000000000005f0e0 l     F .text  0000000000000094              call_function_tail

If it's not a known symbol, how does GDB know about it... and what is it exactly (apart of course that it's a normal function)?

Upvotes: 2

Views: 315

Answers (1)

rodrigo
rodrigo

Reputation: 98368

It is in the source of the Python interpreter, your gdb says where, but you can check it here, although in a different line: 3971.

The defintinition of the function is:

static PyObject * call_function(PyObject ***pp_stack, int oparg);

Since it is a static function it has internal linkage, so it will not be visible outside its compilation unit, let alone outsice its dynamic library (.so file).

The debugger knows about it because somehow it has access to the debugging information of the running code.

Upvotes: 1

Related Questions