diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/wasm-emscripten-finalize.cpp | 7 | ||||
-rw-r--r-- | src/tools/wasm-metadce.cpp | 1 | ||||
-rw-r--r-- | src/tools/wasm-opt.cpp | 15 |
3 files changed, 22 insertions, 1 deletions
diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp index b45b61b8f..a32a265cd 100644 --- a/src/tools/wasm-emscripten-finalize.cpp +++ b/src/tools/wasm-emscripten-finalize.cpp @@ -49,6 +49,7 @@ int main(int argc, const char* argv[]) { std::string dataSegmentFile; bool emitBinary = true; bool debugInfo = false; + bool DWARF = false; bool isSideModule = false; bool legalizeJavaScriptFFI = true; bool checkStackOverflow = false; @@ -71,6 +72,11 @@ int main(int argc, const char* argv[]) { "Emit names section in wasm binary (or full debuginfo in wast)", Options::Arguments::Zero, [&debugInfo](Options*, const std::string&) { debugInfo = true; }) + .add("--dwarf", + "", + "Update DWARF debug info", + Options::Arguments::Zero, + [&DWARF](Options*, const std::string&) { DWARF = true; }) .add("--emit-text", "-S", "Emit text instead of binary for the output file", @@ -164,6 +170,7 @@ int main(int argc, const char* argv[]) { Module wasm; ModuleReader reader; + reader.setDWARF(DWARF); try { reader.read(infile, wasm, inputSourceMapFilename); } catch (ParseException& p) { diff --git a/src/tools/wasm-metadce.cpp b/src/tools/wasm-metadce.cpp index 7d91b3e6f..3b889b984 100644 --- a/src/tools/wasm-metadce.cpp +++ b/src/tools/wasm-metadce.cpp @@ -498,6 +498,7 @@ int main(int argc, const char* argv[]) { std::cerr << "reading...\n"; } ModuleReader reader; + reader.setDWARF(debugInfo); try { reader.read(options.extra["infile"], wasm); } catch (ParseException& p) { diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index 7b04f5449..2fd78a3da 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -43,7 +43,7 @@ using namespace wasm; // runs a command and returns its output TODO: portability, return code checking -std::string runCommand(std::string command) { +static std::string runCommand(std::string command) { #ifdef __linux__ std::string output; const int MAX_BUFFER = 1024; @@ -59,6 +59,15 @@ std::string runCommand(std::string command) { #endif } +static bool willRemoveDebugInfo(const std::vector<std::string>& passes) { + for (auto& pass : passes) { + if (pass == "strip" || pass == "strip-debug" || pass == "strip-dwarf") { + return true; + } + } + return false; +} + // // main // @@ -210,6 +219,10 @@ int main(int argc, const char* argv[]) { if (!translateToFuzz) { ModuleReader reader; + // Enable DWARF parsing if we were asked for debug info, and were not + // asked to remove it. + reader.setDWARF(options.passOptions.debugInfo && + !willRemoveDebugInfo(options.passes)); try { reader.read(options.extra["infile"], wasm, inputSourceMapFilename); } catch (ParseException& p) { |