How to do partial matches in GDB using python scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nupurchoudhary
    New Member
    • Jun 2016
    • 4

    How to do partial matches in GDB using python scripts

    Hi,
    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.
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    Code:
    set x = methodname(foo::FooManager)
    print $x
    is not Python. Are you parsing this code using a Python program. If so, show how you read the file.

    Comment

    • nupurchoudhary
      New Member
      • Jun 2016
      • 4

      #3
      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.

      Comment

      • dwblas
        Recognized Expert Contributor
        • May 2008
        • 626

        #4
        The Python Wiki has a write up on GDB at https://wiki.python.org/moin/DebuggingWithGdb Other than that, "It gives me error saying x is not defined in the current context" is not enough info to do anything with.

        Comment

        Working...