you can use
class-dump -C NSUndo /System/Library/Frameworks/Foundation.framework/Foundation
to learn about the internal structure of classes related to cancellation. You will find that NSUndoManager has two instance variables named _undoStack and _redoStack. It's pretty obvious how it is structured, so you can write a small stack printing method. I found this very convenient for debugging undo issues.