I have a crash dump. This crash dump contains a doubly-linked list with 15000 nodes whose head pointer is null, but still has a valid tail. In order to figure out whether the head pointer was wiped out by a logic error or heap corruption, I need to walk backwards from the tail, up to the first valid node.
If I can reach the first开发者_JS百科 valid node, i.e. the node that should follow the head, and it's not pointing to null, I can reasonably assume heap corruption. If this node is pointing to null, the problem is most likely a logic error.
Is there any way that I can use Visual Studio's debugger to print the contents of this linked list?
I thought that I might be able to use the immediate/command window to do this, but as far as I can tell, it only allows evaluation of single statements. I would need some sort of looping or recursion to step through the list.
Side note, this is not an std::list
.
There is this article showing how to write custom visualizers for Visual Studio: http://www.virtualdub.org/blog/pivot/entry.php?id=120, including lists. There is a comment asking about visualizers for doubly-linked lists, and apparently this should work:
typedef struct _Stream (
struct _Stream *p_next,
struct _Stream *p_prev,
/* the rest of the structure */
) _Stream;
This should be the visualizer:
_Stream{
children(
raw: [$e,!],
#list(
head: $e.p_next,
next: p_next,
skip: $e
))
}
精彩评论