mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 21:41:47 +08:00
Specialize std::hash for gdb_exception
This adds a std::hash specialization for gdb_exception. This lets us store these objects in a hash table, which is used later in this series to de-duplicate the exception output from multiple threads.
This commit is contained in:
@ -24,6 +24,7 @@
|
|||||||
#include <new>
|
#include <new>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
/* Reasons for calling throw_exceptions(). NOTE: all reason values
|
/* Reasons for calling throw_exceptions(). NOTE: all reason values
|
||||||
must be different from zero. enum value 0 is reserved for internal
|
must be different from zero. enum value 0 is reserved for internal
|
||||||
@ -187,6 +188,24 @@ struct gdb_exception
|
|||||||
std::shared_ptr<std::string> message;
|
std::shared_ptr<std::string> message;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Specialization of std::hash for gdb_exception. */
|
||||||
|
template<>
|
||||||
|
struct hash<gdb_exception>
|
||||||
|
{
|
||||||
|
size_t operator() (const gdb_exception &exc) const
|
||||||
|
{
|
||||||
|
size_t result = exc.reason + exc.error;
|
||||||
|
if (exc.message != nullptr)
|
||||||
|
result += std::hash<std::string> {} (*exc.message);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* Functions to drive the sjlj-based exceptions state machine. Though
|
/* Functions to drive the sjlj-based exceptions state machine. Though
|
||||||
declared here by necessity, these functions should be considered
|
declared here by necessity, these functions should be considered
|
||||||
internal to the exceptions subsystem and not used other than via
|
internal to the exceptions subsystem and not used other than via
|
||||||
|
Reference in New Issue
Block a user