Postmortem debugging with GDB

I've run into many cases where my sketch hits some sort of unexpected condition where it would be useful for me to do a "postmortem" debug of the program to find out its state. Here's what I had in mind:

1) Program encounters some unexpected condition. It dumps the register state and entire contents of SRAM over the serial terminal. 2) Some PC-side tool is used to assemble the memory dump into a core file (readable by gdb). 3) the core file and the compiled binary (with debug symbols) are loaded into GDB, allowing the developer to determine the state of the sketch at the time of the exceptional condition. This includes the call stack, variable values, etc.

Has anyone ever tried to do something like this? Would you have any guidance on how to dump the state of the AVR and package it into a core file? I am not familiar with the core file format that gdb uses. Is it literally just a dump of the SRAM, opr is there some other metadata that goes with it?