debuginfo experiment
diff --git a/src/tools/asm2wasm.cpp b/src/tools/asm2wasm.cpp
index 0679ad3..9f0d0e4 100644
--- a/src/tools/asm2wasm.cpp
+++ b/src/tools/asm2wasm.cpp
@@ -128,7 +128,7 @@
 
   Asm2WasmPreProcessor pre;
   // wasm binaries can contain a names section, but not full debug info
-  pre.debugInfo = debugInfo && !emitBinary;
+  pre.debugInfo = debugInfo;
   auto input(
       read_file<std::vector<char>>(options.extra["infile"], Flags::Text, options.debug ? Flags::Debug : Flags::Release));
   char *start = pre.process(input.data());
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 2f2df7c..ec45f24 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -529,6 +529,7 @@
 class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> {
   Module* wasm;
   BufferWithRandomAccess& o;
+  Function* currFunction = nullptr;
   bool debug;
   bool debugInfo = true;
   std::string symbolMap;
@@ -602,6 +603,19 @@
   void recurse(Expression*& curr);
   std::vector<Name> breakStack;
 
+  void visit(Expression* curr) {
+    if (debugInfo && currFunction) {
+      // show an annotation, if there is one
+      auto& debugLocations = currFunction->debugLocations;
+      auto iter = debugLocations.find(curr);
+      if (iter != debugLocations.end()) {
+        auto fileName = wasm->debugInfoFileNames[iter->second.fileIndex];
+        std::cout << std::hex <<o.size() << ":" << fileName << ":" << std::dec <<iter->second.lineNumber << '\n';
+      }
+    }
+    Visitor<WasmBinaryWriter>::visit(curr);
+  }
+
   void visitBlock(Block *curr);
   // emits a node, but if it is a block with no name, emit a list of its contents
   void recursePossibleBlockContents(Expression* curr);
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 521edab..9a3c026 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -236,6 +236,7 @@
     size_t sizePos = writeU32LEBPlaceholder();
     size_t start = o.size();
     Function* function = wasm->functions[i].get();
+    currFunction = function;
     mappedLocals.clear();
     numLocalsByType.clear();
     if (debug) std::cerr << "writing" << function->name << std::endl;
@@ -258,6 +259,7 @@
     if (debug) std::cerr << "body size: " << size << ", writing at " << sizePos << ", next starts at " << o.size() << std::endl;
     o.writeAt(sizePos, U32LEB(size));
   }
+  currFunction = nullptr;
   finishSection(start);
 }