7

Is there a way to execute function in process core context in GDB?

The incentive is to run a function that will go through a large tree to find a specific node. I can walk the tree manually but I would like to build a function that will help me analyze the core.

Hence either a function or "GDB script" to run over the data tree.

1

2 Answers 2

5

Is there a way to execute function in process core context in GDB?

No: you need a "live" inferior process for that.

I can walk the tree manually but I would like to build a function that will help me analyze the core.

You can do that using Python scripting built into recent GDB versions.

Sign up to request clarification or add additional context in comments.

Comments

2

gdb can call C functions. If you type p myfunction(...parameters...), gdb will evaluate the expression and print the returned value. Of course, the program you're debugging must be stopped.

5 Comments

I understand that on a running program this will work (and thanks for the input). My problem is that the program has already crashed and I need to call a function from the core context no a running program.
Uhm... no, too late :( . The only hope is a gdb script, sorry
Of course, if you can catch the exception in gdb, the process is still alive and you can call your function.
No exception in my world C :)
Oh, sorry! I'd say "segmentation fault" :D

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.