From db10f1a9bee624352ecfc6747d2566991752c92f Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 22 May 2017 18:40:22 -0500 Subject: [PATCH] Output JS source mapping file (instead of .txtmap). --- check.py | 18 +- src/parsing.h | 19 ++ src/tools/wasm-dis.cpp | 3 + src/wasm-binary.h | 11 +- src/wasm/wasm-binary.cpp | 205 +++++++++++++--- test/debugInfo.fromasm.clamp.map | 1 + test/debugInfo.fromasm.clamp.no-opts.map | 1 + test/debugInfo.fromasm.clamp.no-opts.txtmap | 14 -- test/debugInfo.fromasm.clamp.txtmap | 12 - test/debugInfo.fromasm.imprecise.map | 1 + test/debugInfo.fromasm.imprecise.no-opts.map | 1 + ...debugInfo.fromasm.imprecise.no-opts.txtmap | 14 -- test/debugInfo.fromasm.imprecise.txtmap | 12 - test/debugInfo.fromasm.map | 1 + test/debugInfo.fromasm.no-opts.map | 1 + test/debugInfo.fromasm.no-opts.txtmap | 14 -- test/debugInfo.fromasm.txtmap | 12 - test/fib-dbg.wasm | Bin 0 -> 913 bytes test/fib-dbg.wasm.fromBinary | 228 ++++++++++++++++++ test/fib-dbg.wasm.map | 1 + 20 files changed, 447 insertions(+), 122 deletions(-) create mode 100644 test/debugInfo.fromasm.clamp.map create mode 100644 test/debugInfo.fromasm.clamp.no-opts.map delete mode 100644 test/debugInfo.fromasm.clamp.no-opts.txtmap delete mode 100644 test/debugInfo.fromasm.clamp.txtmap create mode 100644 test/debugInfo.fromasm.imprecise.map create mode 100644 test/debugInfo.fromasm.imprecise.no-opts.map delete mode 100644 test/debugInfo.fromasm.imprecise.no-opts.txtmap delete mode 100644 test/debugInfo.fromasm.imprecise.txtmap create mode 100644 test/debugInfo.fromasm.map create mode 100644 test/debugInfo.fromasm.no-opts.map delete mode 100644 test/debugInfo.fromasm.no-opts.txtmap delete mode 100644 test/debugInfo.fromasm.txtmap create mode 100644 test/fib-dbg.wasm create mode 100644 test/fib-dbg.wasm.fromBinary create mode 100644 test/fib-dbg.wasm.map diff --git a/check.py b/check.py index 1081066a039..384ccfc30d0 100755 --- a/check.py +++ b/check.py @@ -177,19 +177,19 @@ def do_asm2wasm_test(): # verify debug info if 'debugInfo' in asm: - txtmap = 'a.wasm.txtmap' - cmd += ['--binarymap-file', txtmap, - '--binarymap-url', txtmap + '.map', + jsmap = 'a.wasm.map' + cmd += ['--binarymap-file', jsmap, + '--binarymap-url', 'http://example.org/' + jsmap, '-o', 'a.wasm'] run_command(cmd) - if not os.path.isfile(txtmap): - fail_with_error('Debug info map not created: %s' % txtmap) - with open(wasm + '.txtmap', 'rb') as expected: - with open(txtmap, 'rb') as actual: + if not os.path.isfile(jsmap): + fail_with_error('Debug info map not created: %s' % jsmap) + with open(wasm + '.map', 'rb') as expected: + with open(jsmap, 'rb') as actual: fail_if_not_identical(actual.read(), expected.read()) with open('a.wasm', 'rb') as binary: url_section_name = bytearray([16]) + bytearray('sourceMappingURL') - payload = txtmap + '.map' + payload = 'http://example.org/' + jsmap assert len(payload) < 256, 'name too long' url_section_contents = bytearray([len(payload)]) + bytearray(payload) print url_section_name @@ -252,6 +252,8 @@ def do_asm2wasm_test(): print '..', t t = os.path.join(options.binaryen_test, t) cmd = WASM_DIS + [t] + if os.path.isfile(t + '.map'): cmd += ['-bm', t + '.map'] + actual = run_command(cmd) with open(t + '.fromBinary') as f: diff --git a/src/parsing.h b/src/parsing.h index d4df3c1c25b..be3c112f3f0 100644 --- a/src/parsing.h +++ b/src/parsing.h @@ -193,6 +193,25 @@ struct ParseException { } }; +struct MapParseException { + std::string text; + + MapParseException() : text("unknown parse error") {} + MapParseException(std::string text) : text(text) {} + + void dump(std::ostream& o) { + Colors::magenta(o); + o << "["; + Colors::red(o); + o << "map parse exception: "; + Colors::green(o); + o << text; + Colors::magenta(o); + o << "]"; + Colors::normal(o); + } +}; + // Helper for parsers that may not have unique label names. This transforms // the names into unique ones, as required by Binaryen IR. struct UniqueNameMapper { diff --git a/src/tools/wasm-dis.cpp b/src/tools/wasm-dis.cpp index c33b4d333e0..2e5aa4ea2ec 100644 --- a/src/tools/wasm-dis.cpp +++ b/src/tools/wasm-dis.cpp @@ -64,6 +64,9 @@ int main(int argc, const char *argv[]) { } catch (ParseException& p) { p.dump(std::cerr); Fatal() << "error in parsing wasm binary"; + } catch (MapParseException& p) { + p.dump(std::cerr); + Fatal() << "error in parsing wasm source mapping"; } if (options.debug) std::cerr << "Printing..." << std::endl; diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 693ceaf469e..037d81899b1 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -593,6 +593,10 @@ class WasmBinaryWriter : public Visitor { void writeSourceMapUrl(); void writeSymbolMap(); + void writeBinaryMapProlog(); + void writeBinaryMapEpilog(); + void writeDebugLocation(size_t offset, const Function::DebugLocation& loc); + // helpers void writeInlineString(const char* name); void writeInlineBuffer(const char* data, size_t size); @@ -616,6 +620,7 @@ class WasmBinaryWriter : public Visitor { void recurse(Expression*& curr); std::vector breakStack; Function::DebugLocation lastDebugLocation; + size_t lastBytecodeOffset; void visit(Expression* curr) { if (binaryMap && currFunction) { @@ -623,9 +628,7 @@ class WasmBinaryWriter : public Visitor { auto& debugLocations = currFunction->debugLocations; auto iter = debugLocations.find(curr); if (iter != debugLocations.end() && iter->second != lastDebugLocation) { - lastDebugLocation = iter->second; - auto fileName = wasm->debugInfoFileNames[iter->second.fileIndex]; - *binaryMap << o.size() << ":" << fileName << ":" << iter->second.lineNumber << ":" << iter->second.columnNumber << '\n'; + writeDebugLocation(o.size(), iter->second); } } Visitor::visit(curr); @@ -767,11 +770,11 @@ class WasmBinaryBuilder { // Debug information reading helpers void setDebugLocations(std::istream* binaryMap_) { binaryMap = binaryMap_; - readNextDebugLocation(); } Function::DebugLocation debugLocation; std::unordered_map debugInfoFileIndices; void readNextDebugLocation(); + void readBinaryMapHeader(); // AST reading int depth = 0; // only for debugging diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index f3697048f8d..65e8413afed 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -33,6 +33,9 @@ void WasmBinaryWriter::prepare() { void WasmBinaryWriter::write() { writeHeader(); + if (binaryMap) { + writeBinaryMapProlog(); + } writeTypes(); writeImports(); @@ -49,6 +52,9 @@ void WasmBinaryWriter::write() { if (binaryMap) writeSourceMapUrl(); if (symbolMap.size() > 0) writeSymbolMap(); + if (binaryMap) { + writeBinaryMapEpilog(); + } finishUp(); } @@ -238,7 +244,6 @@ void WasmBinaryWriter::writeFunctions() { size_t start = o.size(); Function* function = wasm->functions[i].get(); currFunction = function; - lastDebugLocation = {0, 0, 0}; mappedLocals.clear(); numLocalsByType.clear(); if (debug) std::cerr << "writing" << function->name << std::endl; @@ -445,6 +450,50 @@ void WasmBinaryWriter::writeSymbolMap() { file.close(); } +void WasmBinaryWriter::writeBinaryMapProlog() { + lastDebugLocation = {0, /* lineNumber = */ 1, 0}; + lastBytecodeOffset = 0; + *binaryMap << "{\"version\":3,\"sources\":["; + for (size_t i = 0; i < wasm->debugInfoFileNames.size(); i++) { + if (i > 0) *binaryMap << ","; + // TODO respect JSON string encoding, e.g. quotes and control chars. + *binaryMap << "\"" << wasm->debugInfoFileNames[i] << "\""; + } + *binaryMap << "],\"names\":[],\"mappings\":\""; +} + +void WasmBinaryWriter::writeBinaryMapEpilog() { + *binaryMap << "\"}"; +} + +static void writeBase64VLQ(std::ostream& out, int32_t n) { + uint32_t value = n >= 0 ? n << 1 : ((-n) << 1) | 1; + while (1) { + uint32_t digit = value & 0x1F; + value >>= 5; + if (!value) { + // last VLQ digit -- base64 codes 'A'..'Z', 'a'..'f' + out << char(digit < 26 ? 'A' + digit : 'a' + digit - 26); + break; + } + // more VLG digit will follow -- add continuation bit (0x20), + // base64 codes 'g'..'z', '0'..'9', '+', '/' + out << char(digit < 20 ? 'g' + digit : digit < 30 ? '0' + digit - 20 : digit == 30 ? '+' : '/'); + } +} + +void WasmBinaryWriter::writeDebugLocation(size_t offset, const Function::DebugLocation& loc) { + if (lastBytecodeOffset > 0) { + *binaryMap << ","; + } + writeBase64VLQ(*binaryMap, int32_t(offset - lastBytecodeOffset)); + writeBase64VLQ(*binaryMap, int32_t(loc.fileIndex - lastDebugLocation.fileIndex)); + writeBase64VLQ(*binaryMap, int32_t(loc.lineNumber - lastDebugLocation.lineNumber)); + writeBase64VLQ(*binaryMap, int32_t(loc.columnNumber - lastDebugLocation.columnNumber)); + lastDebugLocation = loc; + lastBytecodeOffset = offset; +} + void WasmBinaryWriter::writeInlineString(const char* name) { int32_t size = strlen(name); o << U32LEB(size); @@ -949,6 +998,7 @@ static Name RETURN_BREAK("binaryen|break-to-return"); void WasmBinaryBuilder::read() { readHeader(); + readBinaryMapHeader(); // read sections until the end while (more()) { @@ -1402,43 +1452,134 @@ void WasmBinaryBuilder::readExports() { } } -void WasmBinaryBuilder::readNextDebugLocation() { - if (binaryMap) { - std::string line; - while (std::getline(*binaryMap, line)) { - auto pos = line.begin(); - while (pos < line.end() && pos[0] != ':') pos++; - if (pos == line.end()) continue; - uint32_t position = atoi(std::string(line.begin(), pos).c_str()); - auto filenameStart = ++pos; - while (pos < line.end() && pos[0] != ':') pos++; - if (pos == line.end()) continue; - std::string file(filenameStart, pos); - auto iter = debugInfoFileIndices.find(file); - if (iter == debugInfoFileIndices.end()) { - Index index = wasm.debugInfoFileNames.size(); - wasm.debugInfoFileNames.push_back(file); - debugInfoFileIndices[file] = index; +static int32_t readBase64VLQ(std::istream& in) { + uint32_t value = 0; + uint32_t shift = 0; + while (1) { + char ch = in.get(); + if (ch == EOF) + throw MapParseException("unexpected EOF in the middle of VLQ"); + if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch < 'g')) { + // last number digit + uint32_t digit = ch < 'a' ? ch - 'A' : ch - 'a' + 26; + value |= digit << shift; + break; + } + if (!(ch >= 'g' && ch <= 'z') && !(ch >= '0' && ch <= '9') && + ch != '+' && ch != '/') { + throw MapParseException("invalid VLQ digit"); + } + uint32_t digit = ch > '9' ? ch - 'g' : (ch >= '0' ? ch - '0' + 20 : (ch == '+' ? 30 : 31)); + value |= digit << shift; + shift += 5; + } + return value & 1 ? -int32_t(value >> 1) : int32_t(value >> 1); +} + +void WasmBinaryBuilder::readBinaryMapHeader() { + if (!binaryMap) { + return; + } + auto maybeReadChar = [&](char expected) { + if (binaryMap->peek() != expected) + return false; + binaryMap->get(); + return true; + }; + auto mustReadChar = [&](char expected) { + if (binaryMap->get() != expected) + throw MapParseException("Unexpected char"); + }; + auto findField = [&](const char* name, size_t len) { + bool matching = false; + size_t pos; + while (1) { + int ch = binaryMap->get(); + if (ch == EOF) return false; + if (ch == '\"') { + matching = true; + pos = 0; + } else if (matching && name[pos] == ch) { + ++pos; + if (pos == len) { + if (maybeReadChar('\"')) break; // found field + } + } else { + matching = false; } - uint32_t fileIndex = debugInfoFileIndices[file]; - auto lineNumberStart = ++pos; - while (pos < line.end() && pos[0] != ':') pos++; - if (pos == line.end()) { - // old format - uint32_t lineNumber = atoi(std::string(lineNumberStart, line.end()).c_str()); - nextDebugLocation = {position, {fileIndex, lineNumber, 0}}; - return; + } + mustReadChar(':'); + return true; + }; + auto readString = [&](std::string& str) { + std::vector vec; + mustReadChar('\"'); + if (!maybeReadChar('\"')) { + while (1) { + int ch = binaryMap->get(); + if (ch == EOF) + throw MapParseException("unexpected EOF in the middle of string"); + if (ch == '\"') break; + vec.push_back(ch); } - uint32_t lineNumber = atoi(std::string(lineNumberStart, pos).c_str()); - auto columnNumberStart = ++pos; - uint32_t columnNumber = atoi(std::string(columnNumberStart, line.end()).c_str()); - - nextDebugLocation = {position, {fileIndex, lineNumber, columnNumber}}; - return; } + str = std::string(vec.begin(), vec.end()); + }; + + if (!findField("sources", strlen("sources"))) + throw MapParseException("cannot find the sources field in map"); + mustReadChar('['); + if (!maybeReadChar(']')) { + do { + std::string file; + readString(file); + Index index = wasm.debugInfoFileNames.size(); + wasm.debugInfoFileNames.push_back(file); + debugInfoFileIndices[file] = index; + } while (maybeReadChar(',')); + mustReadChar(']'); + } + + if (!findField("mappings", strlen("mappings"))) + throw MapParseException("cannot find the mappings field in map"); + mustReadChar('\"'); + if (maybeReadChar('\"')) { // empty mappings + nextDebugLocation.first = 0; + return; + } + // read first debug location + uint32_t position = readBase64VLQ(*binaryMap); + uint32_t fileIndex = readBase64VLQ(*binaryMap); + uint32_t lineNumber = readBase64VLQ(*binaryMap) + 1; // adjust zero-based line number + uint32_t columnNumber = readBase64VLQ(*binaryMap); + nextDebugLocation = {position, {fileIndex, lineNumber, columnNumber}}; +} + +void WasmBinaryBuilder::readNextDebugLocation() { + if (!binaryMap) { + return; + } + char ch; + *binaryMap >> ch; + if (ch == '\"') { // end of records nextDebugLocation.first = 0; + return; } + if (ch != ',') + throw MapParseException("Unexpected delimiter"); + + int32_t positionDelta = readBase64VLQ(*binaryMap); + uint32_t position = nextDebugLocation.first + positionDelta; + int32_t fileIndexDelta = readBase64VLQ(*binaryMap); + uint32_t fileIndex = nextDebugLocation.second.fileIndex + fileIndexDelta; + int32_t lineNumberDelta = readBase64VLQ(*binaryMap); + uint32_t lineNumber = nextDebugLocation.second.lineNumber + lineNumberDelta; + int32_t columnNumberDelta = readBase64VLQ(*binaryMap); + uint32_t columnNumber = nextDebugLocation.second.columnNumber + columnNumberDelta; + + nextDebugLocation = {position, {fileIndex, lineNumber, columnNumber}}; } + Expression* WasmBinaryBuilder::readExpression() { assert(depth == 0); processExpressions(); diff --git a/test/debugInfo.fromasm.clamp.map b/test/debugInfo.fromasm.clamp.map new file mode 100644 index 00000000000..5680294cda5 --- /dev/null +++ b/test/debugInfo.fromasm.clamp.map @@ -0,0 +1 @@ +{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c"],"names":[],"mappings":"yLC8ylTA,cC7vlTA,OAkDA,mCCnGA,OACA,OACA,qBCAA,wBAKA,MAJA,OADA,0BAKA,iGCsi1DA"} \ No newline at end of file diff --git a/test/debugInfo.fromasm.clamp.no-opts.map b/test/debugInfo.fromasm.clamp.no-opts.map new file mode 100644 index 00000000000..82a92c68b2e --- /dev/null +++ b/test/debugInfo.fromasm.clamp.no-opts.map @@ -0,0 +1 @@ +{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c"],"names":[],"mappings":"uMAIA,IACA,ICyylTA,sBC7vlTA,OAkDA,uCCnGA,OACA,OACA,gCCAA,4BAKA,QAJA,OADA,8CAKA,kJCsi1DA"} \ No newline at end of file diff --git a/test/debugInfo.fromasm.clamp.no-opts.txtmap b/test/debugInfo.fromasm.clamp.no-opts.txtmap deleted file mode 100644 index f7b8c313154..00000000000 --- a/test/debugInfo.fromasm.clamp.no-opts.txtmap +++ /dev/null @@ -1,14 +0,0 @@ -199:tests/hello_world.c:5:0 -203:tests/hello_world.c:6:0 -207:tests/other_file.cpp:314159:0 -229:return.cpp:50:0 -236:return.cpp:100:0 -275:even-opted.cpp:1:0 -282:even-opted.cpp:2:0 -289:even-opted.cpp:3:0 -321:fib.c:3:0 -349:fib.c:8:0 -357:fib.c:4:0 -364:fib.c:3:0 -410:fib.c:8:0 -556:/tmp/emscripten_test_binaryen2_28hnAe/src.c:59950:0 diff --git a/test/debugInfo.fromasm.clamp.txtmap b/test/debugInfo.fromasm.clamp.txtmap deleted file mode 100644 index 5ab814a0d4a..00000000000 --- a/test/debugInfo.fromasm.clamp.txtmap +++ /dev/null @@ -1,12 +0,0 @@ -185:tests/other_file.cpp:314159:0 -199:return.cpp:50:0 -206:return.cpp:100:0 -241:even-opted.cpp:1:0 -248:even-opted.cpp:2:0 -255:even-opted.cpp:3:0 -276:fib.c:3:0 -300:fib.c:8:0 -306:fib.c:4:0 -313:fib.c:3:0 -339:fib.c:8:0 -436:/tmp/emscripten_test_binaryen2_28hnAe/src.c:59950:0 diff --git a/test/debugInfo.fromasm.imprecise.map b/test/debugInfo.fromasm.imprecise.map new file mode 100644 index 00000000000..60f44708269 --- /dev/null +++ b/test/debugInfo.fromasm.imprecise.map @@ -0,0 +1 @@ +{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c"],"names":[],"mappings":"wLC8ylTA,cC7vlTA,OAkDA,eCnGA,OACA,OACA,oBCAA,wBAKA,MAJA,OADA,0BAKA,iGCsi1DA"} \ No newline at end of file diff --git a/test/debugInfo.fromasm.imprecise.no-opts.map b/test/debugInfo.fromasm.imprecise.no-opts.map new file mode 100644 index 00000000000..2fcda4e2331 --- /dev/null +++ b/test/debugInfo.fromasm.imprecise.no-opts.map @@ -0,0 +1 @@ +{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c"],"names":[],"mappings":"sMAIA,IACA,ICyylTA,sBC7vlTA,OAkDA,kBCnGA,OACA,OACA,+BCAA,4BAKA,QAJA,OADA,8CAKA,kJCsi1DA"} \ No newline at end of file diff --git a/test/debugInfo.fromasm.imprecise.no-opts.txtmap b/test/debugInfo.fromasm.imprecise.no-opts.txtmap deleted file mode 100644 index 25ae6055e50..00000000000 --- a/test/debugInfo.fromasm.imprecise.no-opts.txtmap +++ /dev/null @@ -1,14 +0,0 @@ -198:tests/hello_world.c:5:0 -202:tests/hello_world.c:6:0 -206:tests/other_file.cpp:314159:0 -228:return.cpp:50:0 -235:return.cpp:100:0 -253:even-opted.cpp:1:0 -260:even-opted.cpp:2:0 -267:even-opted.cpp:3:0 -298:fib.c:3:0 -326:fib.c:8:0 -334:fib.c:4:0 -341:fib.c:3:0 -387:fib.c:8:0 -533:/tmp/emscripten_test_binaryen2_28hnAe/src.c:59950:0 diff --git a/test/debugInfo.fromasm.imprecise.txtmap b/test/debugInfo.fromasm.imprecise.txtmap deleted file mode 100644 index 89e0f75c13a..00000000000 --- a/test/debugInfo.fromasm.imprecise.txtmap +++ /dev/null @@ -1,12 +0,0 @@ -184:tests/other_file.cpp:314159:0 -198:return.cpp:50:0 -205:return.cpp:100:0 -220:even-opted.cpp:1:0 -227:even-opted.cpp:2:0 -234:even-opted.cpp:3:0 -254:fib.c:3:0 -278:fib.c:8:0 -284:fib.c:4:0 -291:fib.c:3:0 -317:fib.c:8:0 -414:/tmp/emscripten_test_binaryen2_28hnAe/src.c:59950:0 diff --git a/test/debugInfo.fromasm.map b/test/debugInfo.fromasm.map new file mode 100644 index 00000000000..5680294cda5 --- /dev/null +++ b/test/debugInfo.fromasm.map @@ -0,0 +1 @@ +{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c"],"names":[],"mappings":"yLC8ylTA,cC7vlTA,OAkDA,mCCnGA,OACA,OACA,qBCAA,wBAKA,MAJA,OADA,0BAKA,iGCsi1DA"} \ No newline at end of file diff --git a/test/debugInfo.fromasm.no-opts.map b/test/debugInfo.fromasm.no-opts.map new file mode 100644 index 00000000000..82a92c68b2e --- /dev/null +++ b/test/debugInfo.fromasm.no-opts.map @@ -0,0 +1 @@ +{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c"],"names":[],"mappings":"uMAIA,IACA,ICyylTA,sBC7vlTA,OAkDA,uCCnGA,OACA,OACA,gCCAA,4BAKA,QAJA,OADA,8CAKA,kJCsi1DA"} \ No newline at end of file diff --git a/test/debugInfo.fromasm.no-opts.txtmap b/test/debugInfo.fromasm.no-opts.txtmap deleted file mode 100644 index f7b8c313154..00000000000 --- a/test/debugInfo.fromasm.no-opts.txtmap +++ /dev/null @@ -1,14 +0,0 @@ -199:tests/hello_world.c:5:0 -203:tests/hello_world.c:6:0 -207:tests/other_file.cpp:314159:0 -229:return.cpp:50:0 -236:return.cpp:100:0 -275:even-opted.cpp:1:0 -282:even-opted.cpp:2:0 -289:even-opted.cpp:3:0 -321:fib.c:3:0 -349:fib.c:8:0 -357:fib.c:4:0 -364:fib.c:3:0 -410:fib.c:8:0 -556:/tmp/emscripten_test_binaryen2_28hnAe/src.c:59950:0 diff --git a/test/debugInfo.fromasm.txtmap b/test/debugInfo.fromasm.txtmap deleted file mode 100644 index 5ab814a0d4a..00000000000 --- a/test/debugInfo.fromasm.txtmap +++ /dev/null @@ -1,12 +0,0 @@ -185:tests/other_file.cpp:314159:0 -199:return.cpp:50:0 -206:return.cpp:100:0 -241:even-opted.cpp:1:0 -248:even-opted.cpp:2:0 -255:even-opted.cpp:3:0 -276:fib.c:3:0 -300:fib.c:8:0 -306:fib.c:4:0 -313:fib.c:3:0 -339:fib.c:8:0 -436:/tmp/emscripten_test_binaryen2_28hnAe/src.c:59950:0 diff --git a/test/fib-dbg.wasm b/test/fib-dbg.wasm new file mode 100644 index 0000000000000000000000000000000000000000..8e56773f2c28bd12f16ef059a499611f4811a824 GIT binary patch literal 913 zcmZuwJ#Q015S`ikv^P1Uq@moyt`nCil{c{>1+Zh;MuN&dTkF`tzB_#9M3F3=DL^z( zP|))q_$5?SP|)!!n7!B`37mBA-g`6qF*7;{k{JR3eqOCsVD(v+K_4^B`amy|0ASzV zP;A>!;e}U!*_4fwqwZ;|*Xp*7479tQs##o*7K5p3rSr9E$-~ojcP-pbR~|j3Rcl?y zb*~{`tPOTH*szgi_SrNV1XH6KG>zp(xhLUh5>C=9vh=z3OwFSC6~h%P3BKzG2H zD$=re9X|{bwK+FW*ck71%?>hy>No9=y2^(cmVpzX2ByK#U}~^5*aT9i+<_&Q9Zulh z59E1EtW%Hk=YIU3&~3x{ncvV&RN5WS)g_pGz6e`Ul6F*@fW4~{UC<;MchX?^suKr8 z1xA5P62XN6+{$^I@}ju{X7)yt0a(S{mD6c71SnA5D}dq;UBB~13&f1o%ASv9Pr!M_ zD|@nZF5}k~Phbf+@VEJrvRC5oaweeS@ees=H7x{IN}PYXPTP@iY-)Rl>|M@(YnvLJ zpTPx4c;ef_Hfs`ml;~UZbuA*MFiYI1(Uz9LbKelIq)$N<1RVR0aA;G*H@DCdmd}V< zqTsuN`N+4Bb6N~Hm!*=B!!LcZ83r?j-!*mMRx9vtl`}@@QU^=ET9z3pAtNS#Qy-WHL_hv!-2c3r8`v3p{ literal 0 HcmV?d00001 diff --git a/test/fib-dbg.wasm.fromBinary b/test/fib-dbg.wasm.fromBinary new file mode 100644 index 00000000000..3f940fa8ad6 --- /dev/null +++ b/test/fib-dbg.wasm.fromBinary @@ -0,0 +1,228 @@ +(module + (type $0 (func (param i32 i32))) + (type $1 (func (param i32) (result i32))) + (type $2 (func (result i32))) + (type $3 (func (param i32))) + (type $4 (func)) + (import "env" "DYNAMICTOP_PTR" (global $import$0 i32)) + (import "env" "tempDoublePtr" (global $import$1 i32)) + (import "env" "ABORT" (global $import$2 i32)) + (import "env" "STACKTOP" (global $import$3 i32)) + (import "env" "STACK_MAX" (global $import$4 i32)) + (import "env" "gb" (global $import$5 i32)) + (import "env" "fb" (global $import$6 i32)) + (import "global" "NaN" (global $import$7 f64)) + (import "global" "Infinity" (global $import$8 f64)) + (import "env" "memory" (memory $0 256 256)) + (import "env" "table" (table 0 0 anyfunc)) + (import "env" "memoryBase" (global $import$11 i32)) + (import "env" "tableBase" (global $import$12 i32)) + (global $global$0 (mut i32) (get_global $import$0)) + (global $global$1 (mut i32) (get_global $import$1)) + (global $global$2 (mut i32) (get_global $import$2)) + (global $global$3 (mut i32) (get_global $import$3)) + (global $global$4 (mut i32) (get_global $import$4)) + (global $global$5 (mut i32) (get_global $import$5)) + (global $global$6 (mut i32) (get_global $import$6)) + (global $global$7 (mut i32) (i32.const 0)) + (global $global$8 (mut i32) (i32.const 0)) + (global $global$9 (mut i32) (i32.const 0)) + (global $global$10 (mut i32) (i32.const 0)) + (global $global$11 (mut f64) (get_global $import$7)) + (global $global$12 (mut f64) (get_global $import$8)) + (global $global$13 (mut i32) (i32.const 0)) + (global $global$14 (mut i32) (i32.const 0)) + (global $global$15 (mut i32) (i32.const 0)) + (global $global$16 (mut i32) (i32.const 0)) + (global $global$17 (mut f64) (f64.const 0)) + (global $global$18 (mut i32) (i32.const 0)) + (global $global$19 (mut i32) (i32.const 0)) + (global $global$20 (mut i32) (i32.const 0)) + (global $global$21 (mut f64) (f64.const 0)) + (global $global$22 (mut i32) (i32.const 0)) + (global $global$23 (mut f64) (f64.const 0)) + (export "setThrew" (func $setThrew)) + (export "runPostSets" (func $runPostSets)) + (export "establishStackSpace" (func $establishStackSpace)) + (export "stackSave" (func $stackSave)) + (export "stackRestore" (func $stackRestore)) + (export "_fib" (func $_fib)) + (export "stackAlloc" (func $stackAlloc)) + (func $stackAlloc (type $1) (param $var$0 i32) (result i32) + (local $var$1 i32) + (block $label$0 + (set_local $var$1 + (get_global $global$3) + ) + (set_global $global$3 + (i32.add + (get_global $global$3) + (get_local $var$0) + ) + ) + (set_global $global$3 + (i32.and + (i32.add + (get_global $global$3) + (i32.const 15) + ) + (i32.const -16) + ) + ) + (return + (get_local $var$1) + ) + (unreachable) + ) + (unreachable) + ) + (func $stackSave (type $2) (result i32) + (return + (get_global $global$3) + ) + ) + (func $stackRestore (type $3) (param $var$0 i32) + (set_global $global$3 + (get_local $var$0) + ) + ) + (func $establishStackSpace (type $0) (param $var$0 i32) (param $var$1 i32) + (block $label$0 + (set_global $global$3 + (get_local $var$0) + ) + (set_global $global$4 + (get_local $var$1) + ) + ) + ) + (func $setThrew (type $0) (param $var$0 i32) (param $var$1 i32) + (if + (i32.eq + (get_global $global$7) + (i32.const 0) + ) + (block $label$0 + (set_global $global$7 + (get_local $var$0) + ) + (set_global $global$8 + (get_local $var$1) + ) + ) + ) + ) + (func $_fib (type $1) (param $var$0 i32) (result i32) + (local $var$1 i32) + (local $var$2 i32) + (local $var$3 i32) + (local $var$4 i32) + (local $var$5 i32) + (local $var$6 i32) + (local $var$7 i32) + (local $var$8 i32) + (local $var$9 i32) + (local $var$10 i32) + (local $var$11 i32) + ;;@ fib.c:8:0 + (block $label$0 + (set_local $var$11 + (get_global $global$3) + ) + ;;@ fib.c:3:0 + (set_local $var$6 + (i32.gt_s + (get_local $var$0) + (i32.const 0) + ) + ) + ;;@ fib.c:8:0 + (if + ;;@ fib.c:3:0 + (get_local $var$6) + (block $label$1 + (set_local $var$1 + (i32.const 0) + ) + (set_local $var$5 + (i32.const 1) + ) + (set_local $var$8 + (i32.const 0) + ) + ) + (block $label$2 + (set_local $var$4 + (i32.const 1) + ) + ;;@ fib.c:8:0 + (return + (get_local $var$4) + ) + ) + ) + ;;@ fib.c:3:0 + (loop $label$3 + (block $label$4 + ;;@ fib.c:4:0 + (set_local $var$3 + (i32.add + (get_local $var$5) + (get_local $var$1) + ) + ) + ;;@ fib.c:3:0 + (set_local $var$9 + (i32.add + (get_local $var$8) + (i32.const 1) + ) + ) + (set_local $var$7 + (i32.eq + (get_local $var$9) + (get_local $var$0) + ) + ) + (if + (get_local $var$7) + (block $label$5 + (set_local $var$4 + (get_local $var$3) + ) + (br $label$4) + ) + (block $label$6 + (set_local $var$2 + (get_local $var$5) + ) + (set_local $var$5 + (get_local $var$3) + ) + (set_local $var$8 + (get_local $var$9) + ) + (set_local $var$1 + (get_local $var$2) + ) + ) + ) + (br $label$3) + ) + ) + ;;@ fib.c:8:0 + (return + (get_local $var$4) + ) + (unreachable) + (unreachable) + ) + (unreachable) + ) + (func $runPostSets (type $4) + (local $var$0 i32) + (nop) + ) + ;; custom section "sourceMappingURL", size 35 +) + diff --git a/test/fib-dbg.wasm.map b/test/fib-dbg.wasm.map new file mode 100644 index 00000000000..831f55fbd27 --- /dev/null +++ b/test/fib-dbg.wasm.map @@ -0,0 +1 @@ +{"version":3,"sources":["fib.c"],"names":[],"mappings":"moBAEA,4BAKA,QAJA,OADA,OAAA,uCAKA"}