summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-io.cpp
diff options
context:
space:
mode:
authorYury Delendik <ydelendik@mozilla.com>2017-06-01 14:53:42 -0500
committerAlon Zakai <alonzakai@gmail.com>2017-06-01 12:53:42 -0700
commit0dc07eaa7db35cf65edbbccebe5c89b995613745 (patch)
tree0718148a976b882c826c09189a3e779be311c69e /src/wasm/wasm-io.cpp
parentfcbe14a64d082117d7aab9bbf479e941964cd0de (diff)
downloadbinaryen-0dc07eaa7db35cf65edbbccebe5c89b995613745.tar.gz
binaryen-0dc07eaa7db35cf65edbbccebe5c89b995613745.tar.bz2
binaryen-0dc07eaa7db35cf65edbbccebe5c89b995613745.zip
Exporting/importing debug location information from .wast/.asm.js/.s formats (#1017)
* Extends wasm-as, wasm-dis and s2wasm to consume debug locations. * Exports source map from asm2wasm
Diffstat (limited to 'src/wasm/wasm-io.cpp')
-rw-r--r--src/wasm/wasm-io.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/wasm/wasm-io.cpp b/src/wasm/wasm-io.cpp
index c3192efbf..ebc9af8de 100644
--- a/src/wasm/wasm-io.cpp
+++ b/src/wasm/wasm-io.cpp
@@ -72,11 +72,21 @@ void ModuleWriter::writeBinary(Module& wasm, std::string filename) {
if (debug) std::cerr << "writing binary to " << filename << "\n";
BufferWithRandomAccess buffer(debug);
WasmBinaryWriter writer(&wasm, buffer, debug);
- writer.setDebugInfo(debugInfo);
+ // if debug info is used, then we want to emit the names section
+ writer.setNamesSection(debugInfo);
+ std::unique_ptr<std::ofstream> sourceMapStream;
+ if (sourceMapFilename.size()) {
+ sourceMapStream = make_unique<std::ofstream>();
+ sourceMapStream->open(sourceMapFilename);
+ writer.setSourceMap(sourceMapStream.get(), sourceMapUrl);
+ }
if (symbolMap.size() > 0) writer.setSymbolMap(symbolMap);
writer.write();
Output output(filename, Flags::Binary, debug ? Flags::Debug : Flags::Release);
buffer.writeTo(output);
+ if (sourceMapStream) {
+ sourceMapStream->close();
+ }
}
void ModuleWriter::write(Module& wasm, std::string filename) {
@@ -88,4 +98,3 @@ void ModuleWriter::write(Module& wasm, std::string filename) {
}
}
-