Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb evaluate function in process core

Tags:

c

gdb

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.

like image 416
Hagai Avatar asked Jan 17 '12 09:01

Hagai


2 Answers

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.

like image 86
Employed Russian Avatar answered Oct 17 '22 16:10

Employed Russian


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.

like image 43
Giuseppe Guerrini Avatar answered Oct 17 '22 16:10

Giuseppe Guerrini