Skip to content

Commit

Permalink
[vm] Include version information in DW_AT_producer.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rmacnak-google authored and Commit Queue committed Oct 2, 2024
1 parent 4fe2944 commit 783cd7f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 4 additions & 2 deletions runtime/vm/dwarf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "vm/elf.h"
#include "vm/image_snapshot.h"
#include "vm/object_store.h"
#include "vm/version.h"

namespace dart {

Expand Down Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions runtime/vm/image_snapshot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<void()> body) {
ASSERT(prefix != nullptr);
Expand Down

0 comments on commit 783cd7f

Please sign in to comment.