Reputation: 4045
Is it possible to store the data in gdb in some data structure like a dictionary (some sort of key value pairs).
I have a core and I want to get some important statistics from this core. I am able to scan through the data structure which I want to dump. However I want to extract some more meaningful information while walking the data structure.
Example: Just a trivial example, While walking the data structure, I want to know how many times the element occurs in the data structure of my interest.
Is there a way we can create a dictionary in gdb which holds this as the key and the occurrences as the value?
Upvotes: 1
Views: 60
Reputation: 22549
It could maybe be done using the gdb CLI. However, it's likely to be an enormous pain -- especially because you want to debug core files, and for any non-trivial data structure, gdb wants to allocate memory in the inferior, which can't be done in this case.
So, save yourself a lot of pain and write a Python script using gdb's Python scripting API. By taking this route you have access to all of Python's data structures. And, it is simple to use gdb's API to walk data structures in your core file, or other things like that.
Upvotes: 1