Store 128-bit values as a struct with high and low fields, so that consumers
of airbag don't have to know the platform endianness. git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@118 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
600e56bc39
commit
1d78cad82e
2 changed files with 26 additions and 12 deletions
|
@ -56,7 +56,8 @@ typedef unsigned __int64 u_int64_t;
|
||||||
#endif /* !_WIN32 */
|
#endif /* !_WIN32 */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u_int64_t half[2];
|
u_int64_t high;
|
||||||
|
u_int64_t low;
|
||||||
} u_int128_t;
|
} u_int128_t;
|
||||||
|
|
||||||
typedef u_int64_t airbag_time_t;
|
typedef u_int64_t airbag_time_t;
|
||||||
|
|
|
@ -115,18 +115,23 @@ static inline void Swap(u_int64_t* value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Nontrivial, not often used, not inline. This will put *value into
|
// Given a pointer to a 128-bit int in the minidump data, set the "low"
|
||||||
// native endianness even on machines where there is no native 128-bit type.
|
// and "high" fields appropriately.
|
||||||
// half[0] will be the most significant half on big-endian CPUs and half[1]
|
static void Normalize128(u_int128_t* value, bool is_big_endian) {
|
||||||
// will be the most significant half on little-endian CPUs.
|
// The struct format is [high, low], so if the format is big-endian,
|
||||||
static void Swap(u_int128_t* value) {
|
// the most significant bytes will already be in the high field.
|
||||||
Swap(&value->half[0]);
|
if (!is_big_endian) {
|
||||||
Swap(&value->half[1]);
|
u_int64_t temp = value->low;
|
||||||
|
value->low = value->high;
|
||||||
|
value->high = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Swap the two sections with one another.
|
// This just swaps each int64 half of the 128-bit value.
|
||||||
u_int64_t temp = value->half[0];
|
// The value should also be normalized by calling Normalize128().
|
||||||
value->half[0] = value->half[1];
|
static void Swap(u_int128_t* value) {
|
||||||
value->half[1] = temp;
|
Swap(&value->low);
|
||||||
|
Swap(&value->high);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -378,6 +383,14 @@ bool MinidumpContext::Read(u_int32_t expected_size) {
|
||||||
if (!CheckAgainstSystemInfo(cpu_type))
|
if (!CheckAgainstSystemInfo(cpu_type))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Normalize the 128-bit types in the dump.
|
||||||
|
// Since this is PowerPC, by definition, the values are big-endian.
|
||||||
|
for (unsigned int vr_index = 0;
|
||||||
|
vr_index < MD_VECTORSAVEAREA_PPC_VR_COUNT;
|
||||||
|
++vr_index) {
|
||||||
|
Normalize128(&context_ppc->vector_save.save_vr[vr_index], true);
|
||||||
|
}
|
||||||
|
|
||||||
if (minidump_->swap()) {
|
if (minidump_->swap()) {
|
||||||
// context_ppc->context_flags was already swapped.
|
// context_ppc->context_flags was already swapped.
|
||||||
Swap(&context_ppc->srr0);
|
Swap(&context_ppc->srr0);
|
||||||
|
|
Loading…
Reference in a new issue