Skip to content

Commit 783cd7f

Browse files
rmacnak-googleCommit Queue
authored and
Commit Queue
committed
[vm] Include version information in DW_AT_producer.
This follows gcc and clang's behavior. TEST=readelf Change-Id: Ic009d9439d1e233afda035d0dfd2592c590c0ce2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387821 Reviewed-by: Tess Strickland <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 4fe2944 commit 783cd7f

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

runtime/vm/dwarf.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "vm/elf.h"
1010
#include "vm/image_snapshot.h"
1111
#include "vm/object_store.h"
12+
#include "vm/version.h"
1213

1314
namespace dart {
1415

@@ -277,8 +278,9 @@ void Dwarf::WriteDebugInfo(DwarfWriteStream* stream) {
277278
zone_, IsolateGroup::Current()->object_store()->root_library());
278279
const String& root_uri = String::Handle(zone_, root_library.url());
279280
stream->string(root_uri.ToCString()); // DW_AT_name
280-
stream->string("Dart VM"); // DW_AT_producer
281-
stream->string(""); // DW_AT_comp_dir
281+
const char* producer = zone_->PrintToString("Dart %s\n", Version::String());
282+
stream->string(producer); // DW_AT_producer
283+
stream->string(""); // DW_AT_comp_dir
282284

283285
// DW_AT_low_pc
284286
// The lowest instruction address in this object file that is part of our

runtime/vm/image_snapshot.cc

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,22 @@ class DwarfAssemblyStream : public DwarfWriteStream {
10291029
void u8(uint64_t value) {
10301030
stream_->Printf("%s %" Pu64 "\n", kSizeDirectives[kInt64SizeLog2], value);
10311031
}
1032-
void string(const char* cstr) { // NOLINT
1033-
stream_->Printf(".string \"%s\"\n", cstr); // NOLINT
1032+
void string(const char* cstr) { // NOLINT
1033+
stream_->WriteString(".string \""); // NOLINT
1034+
while (char c = *cstr++) {
1035+
if (c == '"') {
1036+
stream_->WriteString("\\\"");
1037+
} else if (c == '\\') {
1038+
stream_->WriteString("\\\\");
1039+
} else if (c == '\n') {
1040+
stream_->WriteString("\\n");
1041+
} else if (c == '\r') {
1042+
stream_->WriteString("\\r");
1043+
} else {
1044+
stream_->WriteByte(c);
1045+
}
1046+
}
1047+
stream_->WriteString("\"\n");
10341048
}
10351049
void WritePrefixedLength(const char* prefix, std::function<void()> body) {
10361050
ASSERT(prefix != nullptr);

0 commit comments

Comments
 (0)