gdb-best-friend/examples/python/caller_is/caller_is.py
Sergio Durigan Junior dd97dffcfb Adding slides in en_US
This commit adds the slides in en_US, and also the examples.
2014-10-16 18:47:50 -04:00

20 lines
739 B
Python

import gdb
class CallerIs (gdb.Function):
"""Return True if the calling function's name is equal to a string.
This function takes one or two arguments.
The first argument is the name of a function; if the calling function's
name is equal to this argument, this function returns True.
The optional second argument tells this function how many stack frames
to traverse to find the calling function. The default is 1."""
def __init__ (self):
super (CallerIs, self).__init__ ("caller_is")
def invoke (self, name, nframes = 1):
frame = gdb.selected_frame ()
while nframes > 0:
frame = frame.older ()
nframes = nframes - 1
return frame.name () == name.string ()
CallerIs()