By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,407 Members | 2,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,407 IT Pros & Developers. It's quick & easy.

How to do partial matches in GDB using python scripts

P: 4
I have .cc code with singleton instances. Now I want to write a python script which runs on .cc code and does string match. The string to be matched is given outside the .py code by calling the function with the string. The script should then print the address of the string for me. I want to how do we do this in GDB. Also how to call functions of the .py script from outside the code. because I do something like below and it gives me error.
set x = methodname(foo::FooManager)
print $x

It gives me error saying x is not defined in the current context.

I have a function named methodname in my .py script.
Jun 17 '16 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 621
Expand|Select|Wrap|Line Numbers
  1. set x = methodname(foo::FooManager)
  2. print $x 
is not Python. Are you parsing this code using a Python program. If so, show how you read the file.
Jun 17 '16 #2

P: 4
I am doing it in GDB from outside the python code. I have a python script which does the string match on .cc code. I am calling the function in .py from outside the code using the syntax above. I do all this in GDB. I am not sure if the syntax is right, as it doesn't work.
Jun 17 '16 #3

Expert 100+
P: 621
The Python Wiki has a write up on GDB at Other than that, "It gives me error saying x is not defined in the current context" is not enough info to do anything with.
Jun 17 '16 #4

Post your reply

Sign in to post your reply or Sign up for a free account.