Extract all the global variables , data structures and sub-structures from a core dump

I am trying to extract all the global symbols (with name and corresponding values) of a C code from core file (core.pid file, generated when the code crashes).

This is one way to do, but it extracts symbols while code is executing: For example, we have list_globals.py script, and any C code which is crashing. suppose c_code.c.

import gdb
block = gdb.block_for_pc(long(gdb.parse_and_eval('$pc'))).global_block
for symbol in block:
gdb.write('SYMBOL: %20s,\tTYPE: %20s,\tValue: %20s\n' % (symbol.print_name, symbol.type, symbol.value()))
This script is tested in this way:

gcc -g c_code.c

./a.out

gdb a.out core.pid

(gdb) start

(gdb) source list_globals.py

This will print all the global symbols with name,type and values. But here, (gdb) start is must because symbols are extracted by executing the c_code again. i want to extract the same information from core file without executing the C code again. How to do this..? Thanks

Replies

You are reading an archived discussion.

Related Posts

Stanford engineers have succeeded in combining multiple layers of flexible materials to create a new type of pressure sensor. The final sensor is thinner than your currency note and the...
Just curious to know how may CEans are still using Windows XP and what's the main reason they haven't migrated to higher version of the operating system or switched entirely...
Samsung has admitted that the Samsung Galaxy S4 has Wi-Fi connection issue. Several users are reporting that Galaxy S4 cannot establish connection with D-Link routers. Staying connected to wireless connection...
What we proudly call the 'King of Small Cars', the company that has been selling the most number of passenger cars in India for decades is now foraying into something...
In India there are many companies represent them self as Direct Selling Companies, like Amway,RMP, Dolphin etc. They shows big money ,good future, luxury in this business. but some of...