Skip to content

[lldb/Reproducer] Correctly instrument enum values #637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lldb/include/lldb/Utility/ReproducerInstrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ template <typename... Ts> inline std::string stringify_args(const Ts &... ts) {
namespace lldb_private {
namespace repro {

template <class T>
struct is_trivially_serializable
: std::integral_constant<bool, std::is_fundamental<T>::value ||
std::is_enum<T>::value> {};

/// Mapping between serialized indices and their corresponding objects.
///
/// This class is used during replay to map indices back to in-memory objects.
Expand Down Expand Up @@ -279,7 +284,7 @@ class Deserializer {
/// Store the returned value in the index-to-object mapping.
template <typename T> void HandleReplayResult(const T &t) {
unsigned result = Deserialize<unsigned>();
if (std::is_fundamental<T>::value)
if (is_trivially_serializable<T>::value)
return;
// We need to make a copy as the original object might go out of scope.
m_index_to_object.AddObjectForIndex(result, new T(t));
Expand All @@ -288,7 +293,7 @@ class Deserializer {
/// Store the returned value in the index-to-object mapping.
template <typename T> void HandleReplayResult(T *t) {
unsigned result = Deserialize<unsigned>();
if (std::is_fundamental<T>::value)
if (is_trivially_serializable<T>::value)
return;
m_index_to_object.AddObjectForIndex(result, t);
}
Expand Down Expand Up @@ -565,7 +570,7 @@ class Serializer {
/// fundamental types (in which case we serialize its value) and references
/// to objects (in which case we serialize their index).
template <typename T> void Serialize(T &t) {
if (std::is_fundamental<T>::value) {
if (is_trivially_serializable<T>::value) {
m_stream.write(reinterpret_cast<const char *>(&t), sizeof(T));
} else {
unsigned idx = m_tracker.GetIndexForObject(&t);
Expand Down