diff --git a/Makefile.in b/Makefile.in
index d659b4e..d712b44 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -19,6 +19,7 @@
.PHONY: all
PROGRAMS=\
+ thin_debug \
thin_check \
thin_dump \
thin_restore
@@ -85,6 +86,7 @@ test-programs: $(TEST_PROGRAMS)
%.o: %.cc
$(CXX) -c $(INCLUDES) $(CXXFLAGS) -o $@ $<
+THIN_DEBUG_SOURCE=$(SOURCE)
THIN_DUMP_SOURCE=$(SOURCE)
THIN_RESTORE_SOURCE=$(SOURCE)
THIN_CHECK_SOURCE=\
@@ -101,10 +103,14 @@ THIN_CHECK_SOURCE=\
space_map_transactional.cc \
transaction_manager.cc
+THIN_DEBUG_OBJECTS=$(subst .cc,.o,$(THIN_DEBUG_SOURCE))
THIN_DUMP_OBJECTS=$(subst .cc,.o,$(THIN_DUMP_SOURCE))
THIN_RESTORE_OBJECTS=$(subst .cc,.o,$(THIN_RESTORE_SOURCE))
THIN_CHECK_OBJECTS=$(subst .cc,.o,$(THIN_CHECK_SOURCE))
+thin_debug: $(THIN_DEBUG_OBJECTS) thin_debug.o
+ $(CXX) $(CXXFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
+
thin_dump: $(THIN_DUMP_OBJECTS) thin_dump.o
$(CXX) $(CXXFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
diff --git a/thin_debug.cc b/thin_debug.cc
new file mode 100644
index 0000000..94e431c
--- /dev/null
+++ b/thin_debug.cc
@@ -0,0 +1,279 @@
+// Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+//
+// This file is part of the thin-provisioning-tools source.
+//
+// thin-provisioning-tools is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3 of
+// the License, or (at your option) any later version.
+//
+// thin-provisioning-tools is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with thin-provisioning-tools. If not, see
+// .
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include