0

I would like to assign the "info sharedlibrary" value to a variable in user define function.

Such as,

define customFunction

    set $i = info sharedlibrary

end

But it seems impossible in gdb And also i cannot use python script too...

Is there any way to do this??

Thank you

ps. I trying to do this because i want to print only selected library's instructions.

1 Answer 1

1

You don't mention why you can't use a Python function. That's by far the simplest way to program gdb.

However, if you really must do it, and really must avoid Python, there is a way. It's gross! But it does work. It's like this:

  • Use the various set logging commands to redirect output to a temporary file.
  • Invoke the command you want.
  • Use set logging again to disable logging.
  • Use the shell command to run sed or perl or what-have-you on this temporary file to turn it into a sequence of gdb commands, say commands to set a variable, or commands to print exactly the output you want.
  • source the resulting file
Sign up to request clarification or add additional context in comments.

1 Comment

Wow, Thanks a lot. It's really helpful to me. And the reason that I cannot use Python is because i trying to use gdb in my Android devices.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.