Skip to content

Conversation

@fosterbrereton
Copy link
Contributor

@fosterbrereton fosterbrereton commented May 30, 2024

Brandon caught a case where newer versions of ORC were passing over ODRVs it was previously reporting. This fix resolves it.

This change also includes a fix for #84, which required some juggling of a name from a named typedef to an unnamed struct that immediately follows it.

// seed. It also serves as the combiner the other routine variant uses to generate its new
// seed.
return (seed ^ x) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
return seed ^ (x + 0x9e3779b9 + (seed << 6) + (seed >> 2));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch


std::string to_json(const std::vector<odrv_report>&);

std::string version_json();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put this routine inside orc.cpp to encapsulate the usage of nlohmann::json to just that file.

// attributes by name to make sure the hashing is consistent regardless of attribute order.
constexpr const std::size_t max_names_k{32};
std::array<dw::at, max_names_k> names{dw::at::none};
// It is fixed to keep allocations from happening.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the start of some cleanup so I could better understand what fatal_attribute_hash was doing.

result = empool("const " + recurse(attributes).allocate_string());
} else if (die._tag == dw::tag::pointer_type) {
result = empool(recurse(attributes).allocate_string() + "*");
} else if (die._tag == dw::tag::typedef_) {
Copy link
Contributor Author

@fosterbrereton fosterbrereton May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the major fix- an improvement to the way anonymous typedefs are handled. I think this resolves #84, but I'd like to add a test before declaring victory here. Regardless, this is the fix that addressed what Brandon found.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: This is not the fix for 84.

s << " version: " << ORC_VERSION_STR() << tag_url << '\n';
s << " sha: " << ORC_SHA_STR() << '\n';
});
if (settings::instance()._output_file_mode == settings::output_file_mode::json) {
Copy link
Contributor Author

@fosterbrereton fosterbrereton May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the output file mode is set to json and ORC finds no files to process, it will emit a small JSON blob consisting of the ORC version and hash. This is useful for test harness wrappers that may use ORC, to know what version of the tool they are dealing with. (We now have one inside of Adobe that relies on this.)

@fosterbrereton fosterbrereton changed the title Improvement to handle anonymous typedefs Jun 1, 2024
@fosterbrereton fosterbrereton changed the title Improvement to handle unnamed typedefs Jun 1, 2024
Copy link
Contributor

@leethomason leethomason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - one small nit / question, but looks fine.

// seed. It also serves as the combiner the other routine variant uses to generate its new
// seed.
return (seed ^ x) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
return seed ^ (x + 0x9e3779b9 + (seed << 6) + (seed >> 2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

src/dwarf.cpp Outdated
constexpr const std::size_t max_names_k{32};
std::array<dw::at, max_names_k> names{dw::at::none};
// It is fixed to keep allocations from happening.
constexpr const std::size_t max_names_k{32};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit pick but fascinating: is there meaning to a const constexpr? And did you mean static constexpr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constexpr const is redundant, yeah. I have removed the const.

And great question about static constexpr. I looked into this a bit, and it would make sense to add the static qualification if the constexpr expression needs a runtime instance (e.g., to take its address when passing it to a function.) The static in that case ensures only one such instance is created (and in a threadsafe way). Given that max_names_k is not used like that, just constexpr should suffice (though I don't think there's any harm in adding the static).

@fosterbrereton fosterbrereton merged commit 772a75b into main Jun 17, 2024
@fosterbrereton fosterbrereton deleted the fosterbrereton/issue-84 branch June 17, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants