diff --git a/runtime/vm/dwarf.cc b/runtime/vm/dwarf.cc index 76dd781879a3..0aa736fcd18c 100644 --- a/runtime/vm/dwarf.cc +++ b/runtime/vm/dwarf.cc @@ -9,6 +9,7 @@ #include "vm/elf.h" #include "vm/image_snapshot.h" #include "vm/object_store.h" +#include "vm/version.h" namespace dart { @@ -277,8 +278,9 @@ void Dwarf::WriteDebugInfo(DwarfWriteStream* stream) { zone_, IsolateGroup::Current()->object_store()->root_library()); const String& root_uri = String::Handle(zone_, root_library.url()); stream->string(root_uri.ToCString()); // DW_AT_name - stream->string("Dart VM"); // DW_AT_producer - stream->string(""); // DW_AT_comp_dir + const char* producer = zone_->PrintToString("Dart %s\n", Version::String()); + stream->string(producer); // DW_AT_producer + stream->string(""); // DW_AT_comp_dir // DW_AT_low_pc // The lowest instruction address in this object file that is part of our diff --git a/runtime/vm/image_snapshot.cc b/runtime/vm/image_snapshot.cc index 050f1401aafb..72101c3f8770 100644 --- a/runtime/vm/image_snapshot.cc +++ b/runtime/vm/image_snapshot.cc @@ -1029,8 +1029,22 @@ class DwarfAssemblyStream : public DwarfWriteStream { void u8(uint64_t value) { stream_->Printf("%s %" Pu64 "\n", kSizeDirectives[kInt64SizeLog2], value); } - void string(const char* cstr) { // NOLINT - stream_->Printf(".string \"%s\"\n", cstr); // NOLINT + void string(const char* cstr) { // NOLINT + stream_->WriteString(".string \""); // NOLINT + while (char c = *cstr++) { + if (c == '"') { + stream_->WriteString("\\\""); + } else if (c == '\\') { + stream_->WriteString("\\\\"); + } else if (c == '\n') { + stream_->WriteString("\\n"); + } else if (c == '\r') { + stream_->WriteString("\\r"); + } else { + stream_->WriteByte(c); + } + } + stream_->WriteString("\"\n"); } void WritePrefixedLength(const char* prefix, std::function body) { ASSERT(prefix != nullptr);